therubyracer 0.9.0beta2 → 0.9.0beta3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of therubyracer might be problematic. Click here for more details.

Files changed (920) hide show
  1. data/.gitmodules +3 -0
  2. data/ext/v8/upstream/Makefile +1 -2
  3. data/ext/v8/upstream/v8/.gitignore +33 -0
  4. data/ext/v8/upstream/v8/AUTHORS +42 -0
  5. data/ext/v8/upstream/v8/ChangeLog +2663 -0
  6. data/ext/v8/upstream/{3.1.8 → v8}/LICENSE +0 -0
  7. data/ext/v8/upstream/{3.1.8 → v8}/LICENSE.strongtalk +0 -0
  8. data/ext/v8/upstream/{3.1.8 → v8}/LICENSE.v8 +0 -0
  9. data/ext/v8/upstream/{3.1.8 → v8}/LICENSE.valgrind +0 -0
  10. data/ext/v8/upstream/v8/SConstruct +1473 -0
  11. data/ext/v8/upstream/{3.1.8 → v8}/build/README.txt +0 -0
  12. data/ext/v8/upstream/{3.1.8 → v8}/build/all.gyp +0 -0
  13. data/ext/v8/upstream/{3.1.8 → v8}/build/armu.gypi +0 -0
  14. data/ext/v8/upstream/{3.1.8 → v8}/build/common.gypi +0 -0
  15. data/ext/v8/upstream/{3.1.8 → v8}/build/gyp_v8 +0 -0
  16. data/ext/v8/upstream/v8/include/v8-debug.h +394 -0
  17. data/ext/v8/upstream/v8/include/v8-preparser.h +116 -0
  18. data/ext/v8/upstream/v8/include/v8-profiler.h +505 -0
  19. data/ext/v8/upstream/v8/include/v8-testing.h +104 -0
  20. data/ext/v8/upstream/v8/include/v8.h +4000 -0
  21. data/ext/v8/upstream/{3.1.8 → v8}/include/v8stdint.h +0 -0
  22. data/ext/v8/upstream/v8/preparser/SConscript +38 -0
  23. data/ext/v8/upstream/v8/preparser/preparser-process.cc +169 -0
  24. data/ext/v8/upstream/v8/src/SConscript +380 -0
  25. data/ext/v8/upstream/v8/src/accessors.cc +766 -0
  26. data/ext/v8/upstream/{3.1.8 → v8}/src/accessors.h +0 -0
  27. data/ext/v8/upstream/v8/src/allocation-inl.h +49 -0
  28. data/ext/v8/upstream/v8/src/allocation.cc +122 -0
  29. data/ext/v8/upstream/v8/src/allocation.h +143 -0
  30. data/ext/v8/upstream/v8/src/api.cc +5678 -0
  31. data/ext/v8/upstream/v8/src/api.h +572 -0
  32. data/ext/v8/upstream/{3.1.8 → v8}/src/apinatives.js +0 -0
  33. data/ext/v8/upstream/v8/src/apiutils.h +73 -0
  34. data/ext/v8/upstream/v8/src/arguments.h +116 -0
  35. data/ext/v8/upstream/v8/src/arm/assembler-arm-inl.h +353 -0
  36. data/ext/v8/upstream/v8/src/arm/assembler-arm.cc +2877 -0
  37. data/ext/v8/upstream/v8/src/arm/assembler-arm.h +1382 -0
  38. data/ext/v8/upstream/v8/src/arm/builtins-arm.cc +1634 -0
  39. data/ext/v8/upstream/v8/src/arm/code-stubs-arm.cc +6917 -0
  40. data/ext/v8/upstream/v8/src/arm/code-stubs-arm.h +623 -0
  41. data/ext/v8/upstream/{3.1.8 → v8}/src/arm/codegen-arm-inl.h +0 -0
  42. data/ext/v8/upstream/v8/src/arm/codegen-arm.cc +7437 -0
  43. data/ext/v8/upstream/v8/src/arm/codegen-arm.h +595 -0
  44. data/ext/v8/upstream/{3.1.8 → v8}/src/arm/constants-arm.cc +0 -0
  45. data/ext/v8/upstream/v8/src/arm/constants-arm.h +778 -0
  46. data/ext/v8/upstream/v8/src/arm/cpu-arm.cc +149 -0
  47. data/ext/v8/upstream/v8/src/arm/debug-arm.cc +317 -0
  48. data/ext/v8/upstream/v8/src/arm/deoptimizer-arm.cc +737 -0
  49. data/ext/v8/upstream/v8/src/arm/disasm-arm.cc +1503 -0
  50. data/ext/v8/upstream/{3.1.8 → v8}/src/arm/frames-arm.cc +0 -0
  51. data/ext/v8/upstream/v8/src/arm/frames-arm.h +168 -0
  52. data/ext/v8/upstream/v8/src/arm/full-codegen-arm.cc +4374 -0
  53. data/ext/v8/upstream/v8/src/arm/ic-arm.cc +1793 -0
  54. data/ext/v8/upstream/{3.1.8 → v8}/src/arm/jump-target-arm.cc +0 -0
  55. data/ext/v8/upstream/v8/src/arm/lithium-arm.cc +2120 -0
  56. data/ext/v8/upstream/v8/src/arm/lithium-arm.h +2179 -0
  57. data/ext/v8/upstream/v8/src/arm/lithium-codegen-arm.cc +4132 -0
  58. data/ext/v8/upstream/v8/src/arm/lithium-codegen-arm.h +329 -0
  59. data/ext/v8/upstream/v8/src/arm/lithium-gap-resolver-arm.cc +305 -0
  60. data/ext/v8/upstream/{3.1.8 → v8}/src/arm/lithium-gap-resolver-arm.h +0 -0
  61. data/ext/v8/upstream/v8/src/arm/macro-assembler-arm.cc +2939 -0
  62. data/ext/v8/upstream/v8/src/arm/macro-assembler-arm.h +1071 -0
  63. data/ext/v8/upstream/v8/src/arm/regexp-macro-assembler-arm.cc +1287 -0
  64. data/ext/v8/upstream/v8/src/arm/regexp-macro-assembler-arm.h +253 -0
  65. data/ext/v8/upstream/{3.1.8 → v8}/src/arm/register-allocator-arm-inl.h +0 -0
  66. data/ext/v8/upstream/{3.1.8 → v8}/src/arm/register-allocator-arm.cc +0 -0
  67. data/ext/v8/upstream/{3.1.8 → v8}/src/arm/register-allocator-arm.h +0 -0
  68. data/ext/v8/upstream/v8/src/arm/simulator-arm.cc +3288 -0
  69. data/ext/v8/upstream/v8/src/arm/simulator-arm.h +413 -0
  70. data/ext/v8/upstream/v8/src/arm/stub-cache-arm.cc +4034 -0
  71. data/ext/v8/upstream/{3.1.8 → v8}/src/arm/virtual-frame-arm-inl.h +0 -0
  72. data/ext/v8/upstream/v8/src/arm/virtual-frame-arm.cc +843 -0
  73. data/ext/v8/upstream/v8/src/arm/virtual-frame-arm.h +523 -0
  74. data/ext/v8/upstream/v8/src/array.js +1249 -0
  75. data/ext/v8/upstream/v8/src/assembler.cc +1067 -0
  76. data/ext/v8/upstream/v8/src/assembler.h +823 -0
  77. data/ext/v8/upstream/v8/src/ast-inl.h +112 -0
  78. data/ext/v8/upstream/v8/src/ast.cc +1078 -0
  79. data/ext/v8/upstream/v8/src/ast.h +2234 -0
  80. data/ext/v8/upstream/v8/src/atomicops.h +167 -0
  81. data/ext/v8/upstream/{3.1.8 → v8}/src/atomicops_internals_arm_gcc.h +0 -0
  82. data/ext/v8/upstream/v8/src/atomicops_internals_mips_gcc.h +169 -0
  83. data/ext/v8/upstream/{3.1.8 → v8}/src/atomicops_internals_x86_gcc.cc +0 -0
  84. data/ext/v8/upstream/{3.1.8 → v8}/src/atomicops_internals_x86_gcc.h +0 -0
  85. data/ext/v8/upstream/{3.1.8 → v8}/src/atomicops_internals_x86_macosx.h +0 -0
  86. data/ext/v8/upstream/{3.1.8 → v8}/src/atomicops_internals_x86_msvc.h +0 -0
  87. data/ext/v8/upstream/{3.1.8 → v8}/src/bignum-dtoa.cc +0 -0
  88. data/ext/v8/upstream/{3.1.8 → v8}/src/bignum-dtoa.h +0 -0
  89. data/ext/v8/upstream/{3.1.8 → v8}/src/bignum.cc +0 -0
  90. data/ext/v8/upstream/{3.1.8 → v8}/src/bignum.h +0 -0
  91. data/ext/v8/upstream/v8/src/bootstrapper.cc +2138 -0
  92. data/ext/v8/upstream/v8/src/bootstrapper.h +185 -0
  93. data/ext/v8/upstream/v8/src/builtins.cc +1708 -0
  94. data/ext/v8/upstream/v8/src/builtins.h +368 -0
  95. data/ext/v8/upstream/{3.1.8 → v8}/src/bytecodes-irregexp.h +0 -0
  96. data/ext/v8/upstream/{3.1.8 → v8}/src/cached-powers.cc +0 -0
  97. data/ext/v8/upstream/{3.1.8 → v8}/src/cached-powers.h +0 -0
  98. data/ext/v8/upstream/{3.1.8 → v8}/src/char-predicates-inl.h +0 -0
  99. data/ext/v8/upstream/{3.1.8 → v8}/src/char-predicates.h +0 -0
  100. data/ext/v8/upstream/v8/src/checks.cc +110 -0
  101. data/ext/v8/upstream/v8/src/checks.h +296 -0
  102. data/ext/v8/upstream/{3.1.8 → v8}/src/circular-queue-inl.h +0 -0
  103. data/ext/v8/upstream/{3.1.8 → v8}/src/circular-queue.cc +0 -0
  104. data/ext/v8/upstream/{3.1.8 → v8}/src/circular-queue.h +0 -0
  105. data/ext/v8/upstream/v8/src/code-stubs.cc +240 -0
  106. data/ext/v8/upstream/v8/src/code-stubs.h +971 -0
  107. data/ext/v8/upstream/{3.1.8 → v8}/src/code.h +0 -0
  108. data/ext/v8/upstream/v8/src/codegen-inl.h +68 -0
  109. data/ext/v8/upstream/v8/src/codegen.cc +505 -0
  110. data/ext/v8/upstream/v8/src/codegen.h +245 -0
  111. data/ext/v8/upstream/v8/src/compilation-cache.cc +540 -0
  112. data/ext/v8/upstream/v8/src/compilation-cache.h +287 -0
  113. data/ext/v8/upstream/v8/src/compiler.cc +792 -0
  114. data/ext/v8/upstream/v8/src/compiler.h +307 -0
  115. data/ext/v8/upstream/v8/src/contexts.cc +327 -0
  116. data/ext/v8/upstream/v8/src/contexts.h +382 -0
  117. data/ext/v8/upstream/{3.1.8 → v8}/src/conversions-inl.h +0 -0
  118. data/ext/v8/upstream/v8/src/conversions.cc +1125 -0
  119. data/ext/v8/upstream/{3.1.8 → v8}/src/conversions.h +0 -0
  120. data/ext/v8/upstream/v8/src/counters.cc +93 -0
  121. data/ext/v8/upstream/v8/src/counters.h +254 -0
  122. data/ext/v8/upstream/v8/src/cpu-profiler-inl.h +101 -0
  123. data/ext/v8/upstream/v8/src/cpu-profiler.cc +606 -0
  124. data/ext/v8/upstream/v8/src/cpu-profiler.h +305 -0
  125. data/ext/v8/upstream/v8/src/cpu.h +67 -0
  126. data/ext/v8/upstream/v8/src/d8-debug.cc +367 -0
  127. data/ext/v8/upstream/v8/src/d8-debug.h +158 -0
  128. data/ext/v8/upstream/v8/src/d8-posix.cc +695 -0
  129. data/ext/v8/upstream/{3.1.8 → v8}/src/d8-readline.cc +0 -0
  130. data/ext/v8/upstream/{3.1.8 → v8}/src/d8-windows.cc +0 -0
  131. data/ext/v8/upstream/v8/src/d8.cc +796 -0
  132. data/ext/v8/upstream/v8/src/d8.gyp +88 -0
  133. data/ext/v8/upstream/{3.1.8 → v8}/src/d8.h +0 -0
  134. data/ext/v8/upstream/{3.1.8 → v8}/src/d8.js +0 -0
  135. data/ext/v8/upstream/{3.1.8 → v8}/src/data-flow.cc +0 -0
  136. data/ext/v8/upstream/v8/src/data-flow.h +379 -0
  137. data/ext/v8/upstream/{3.1.8 → v8}/src/date.js +0 -0
  138. data/ext/v8/upstream/{3.1.8 → v8}/src/dateparser-inl.h +0 -0
  139. data/ext/v8/upstream/{3.1.8 → v8}/src/dateparser.cc +0 -0
  140. data/ext/v8/upstream/v8/src/dateparser.h +265 -0
  141. data/ext/v8/upstream/v8/src/debug-agent.cc +447 -0
  142. data/ext/v8/upstream/v8/src/debug-agent.h +129 -0
  143. data/ext/v8/upstream/{3.1.8 → v8}/src/debug-debugger.js +0 -0
  144. data/ext/v8/upstream/v8/src/debug.cc +3188 -0
  145. data/ext/v8/upstream/v8/src/debug.h +1055 -0
  146. data/ext/v8/upstream/v8/src/deoptimizer.cc +1296 -0
  147. data/ext/v8/upstream/v8/src/deoptimizer.h +629 -0
  148. data/ext/v8/upstream/v8/src/disasm.h +80 -0
  149. data/ext/v8/upstream/v8/src/disassembler.cc +339 -0
  150. data/ext/v8/upstream/{3.1.8 → v8}/src/disassembler.h +0 -0
  151. data/ext/v8/upstream/{3.1.8 → v8}/src/diy-fp.cc +0 -0
  152. data/ext/v8/upstream/{3.1.8 → v8}/src/diy-fp.h +0 -0
  153. data/ext/v8/upstream/{3.1.8 → v8}/src/double.h +0 -0
  154. data/ext/v8/upstream/{3.1.8 → v8}/src/dtoa.cc +0 -0
  155. data/ext/v8/upstream/{3.1.8 → v8}/src/dtoa.h +0 -0
  156. data/ext/v8/upstream/v8/src/execution.cc +791 -0
  157. data/ext/v8/upstream/v8/src/execution.h +291 -0
  158. data/ext/v8/upstream/v8/src/extensions/experimental/break-iterator.cc +250 -0
  159. data/ext/v8/upstream/v8/src/extensions/experimental/break-iterator.h +89 -0
  160. data/ext/v8/upstream/v8/src/extensions/experimental/experimental.gyp +55 -0
  161. data/ext/v8/upstream/v8/src/extensions/experimental/i18n-extension.cc +284 -0
  162. data/ext/v8/upstream/{3.1.8 → v8}/src/extensions/experimental/i18n-extension.h +0 -0
  163. data/ext/v8/upstream/v8/src/extensions/externalize-string-extension.cc +141 -0
  164. data/ext/v8/upstream/{3.1.8 → v8}/src/extensions/externalize-string-extension.h +0 -0
  165. data/ext/v8/upstream/v8/src/extensions/gc-extension.cc +58 -0
  166. data/ext/v8/upstream/{3.1.8 → v8}/src/extensions/gc-extension.h +0 -0
  167. data/ext/v8/upstream/v8/src/factory.cc +1194 -0
  168. data/ext/v8/upstream/v8/src/factory.h +436 -0
  169. data/ext/v8/upstream/{3.1.8 → v8}/src/fast-dtoa.cc +0 -0
  170. data/ext/v8/upstream/{3.1.8 → v8}/src/fast-dtoa.h +0 -0
  171. data/ext/v8/upstream/{3.1.8 → v8}/src/fixed-dtoa.cc +0 -0
  172. data/ext/v8/upstream/{3.1.8 → v8}/src/fixed-dtoa.h +0 -0
  173. data/ext/v8/upstream/v8/src/flag-definitions.h +556 -0
  174. data/ext/v8/upstream/{3.1.8 → v8}/src/flags.cc +0 -0
  175. data/ext/v8/upstream/{3.1.8 → v8}/src/flags.h +0 -0
  176. data/ext/v8/upstream/v8/src/frame-element.cc +37 -0
  177. data/ext/v8/upstream/v8/src/frame-element.h +269 -0
  178. data/ext/v8/upstream/v8/src/frames-inl.h +236 -0
  179. data/ext/v8/upstream/v8/src/frames.cc +1273 -0
  180. data/ext/v8/upstream/v8/src/frames.h +854 -0
  181. data/ext/v8/upstream/v8/src/full-codegen.cc +1385 -0
  182. data/ext/v8/upstream/v8/src/full-codegen.h +753 -0
  183. data/ext/v8/upstream/v8/src/func-name-inferrer.cc +91 -0
  184. data/ext/v8/upstream/v8/src/func-name-inferrer.h +111 -0
  185. data/ext/v8/upstream/v8/src/gdb-jit.cc +1548 -0
  186. data/ext/v8/upstream/{3.1.8 → v8}/src/gdb-jit.h +0 -0
  187. data/ext/v8/upstream/v8/src/global-handles.cc +596 -0
  188. data/ext/v8/upstream/v8/src/global-handles.h +239 -0
  189. data/ext/v8/upstream/v8/src/globals.h +325 -0
  190. data/ext/v8/upstream/v8/src/handles-inl.h +177 -0
  191. data/ext/v8/upstream/v8/src/handles.cc +965 -0
  192. data/ext/v8/upstream/v8/src/handles.h +372 -0
  193. data/ext/v8/upstream/{3.1.8 → v8}/src/hashmap.cc +0 -0
  194. data/ext/v8/upstream/v8/src/hashmap.h +121 -0
  195. data/ext/v8/upstream/v8/src/heap-inl.h +703 -0
  196. data/ext/v8/upstream/v8/src/heap-profiler.cc +1173 -0
  197. data/ext/v8/upstream/v8/src/heap-profiler.h +396 -0
  198. data/ext/v8/upstream/v8/src/heap.cc +5856 -0
  199. data/ext/v8/upstream/v8/src/heap.h +2264 -0
  200. data/ext/v8/upstream/v8/src/hydrogen-instructions.cc +1639 -0
  201. data/ext/v8/upstream/v8/src/hydrogen-instructions.h +3657 -0
  202. data/ext/v8/upstream/v8/src/hydrogen.cc +6011 -0
  203. data/ext/v8/upstream/v8/src/hydrogen.h +1137 -0
  204. data/ext/v8/upstream/v8/src/ia32/assembler-ia32-inl.h +430 -0
  205. data/ext/v8/upstream/v8/src/ia32/assembler-ia32.cc +2846 -0
  206. data/ext/v8/upstream/v8/src/ia32/assembler-ia32.h +1159 -0
  207. data/ext/v8/upstream/v8/src/ia32/builtins-ia32.cc +1596 -0
  208. data/ext/v8/upstream/v8/src/ia32/code-stubs-ia32.cc +6549 -0
  209. data/ext/v8/upstream/v8/src/ia32/code-stubs-ia32.h +495 -0
  210. data/ext/v8/upstream/{3.1.8 → v8}/src/ia32/codegen-ia32-inl.h +0 -0
  211. data/ext/v8/upstream/v8/src/ia32/codegen-ia32.cc +10385 -0
  212. data/ext/v8/upstream/v8/src/ia32/codegen-ia32.h +801 -0
  213. data/ext/v8/upstream/v8/src/ia32/cpu-ia32.cc +88 -0
  214. data/ext/v8/upstream/v8/src/ia32/debug-ia32.cc +312 -0
  215. data/ext/v8/upstream/v8/src/ia32/deoptimizer-ia32.cc +774 -0
  216. data/ext/v8/upstream/v8/src/ia32/disasm-ia32.cc +1620 -0
  217. data/ext/v8/upstream/{3.1.8 → v8}/src/ia32/frames-ia32.cc +0 -0
  218. data/ext/v8/upstream/v8/src/ia32/frames-ia32.h +140 -0
  219. data/ext/v8/upstream/v8/src/ia32/full-codegen-ia32.cc +4357 -0
  220. data/ext/v8/upstream/v8/src/ia32/ic-ia32.cc +1779 -0
  221. data/ext/v8/upstream/{3.1.8 → v8}/src/ia32/jump-target-ia32.cc +0 -0
  222. data/ext/v8/upstream/v8/src/ia32/lithium-codegen-ia32.cc +4158 -0
  223. data/ext/v8/upstream/v8/src/ia32/lithium-codegen-ia32.h +318 -0
  224. data/ext/v8/upstream/v8/src/ia32/lithium-gap-resolver-ia32.cc +466 -0
  225. data/ext/v8/upstream/{3.1.8 → v8}/src/ia32/lithium-gap-resolver-ia32.h +0 -0
  226. data/ext/v8/upstream/v8/src/ia32/lithium-ia32.cc +2181 -0
  227. data/ext/v8/upstream/v8/src/ia32/lithium-ia32.h +2235 -0
  228. data/ext/v8/upstream/v8/src/ia32/macro-assembler-ia32.cc +2056 -0
  229. data/ext/v8/upstream/v8/src/ia32/macro-assembler-ia32.h +807 -0
  230. data/ext/v8/upstream/v8/src/ia32/regexp-macro-assembler-ia32.cc +1264 -0
  231. data/ext/v8/upstream/v8/src/ia32/regexp-macro-assembler-ia32.h +216 -0
  232. data/ext/v8/upstream/{3.1.8 → v8}/src/ia32/register-allocator-ia32-inl.h +0 -0
  233. data/ext/v8/upstream/v8/src/ia32/register-allocator-ia32.cc +157 -0
  234. data/ext/v8/upstream/{3.1.8 → v8}/src/ia32/register-allocator-ia32.h +0 -0
  235. data/ext/v8/upstream/{3.1.8 → v8}/src/ia32/simulator-ia32.cc +0 -0
  236. data/ext/v8/upstream/v8/src/ia32/simulator-ia32.h +72 -0
  237. data/ext/v8/upstream/v8/src/ia32/stub-cache-ia32.cc +3711 -0
  238. data/ext/v8/upstream/v8/src/ia32/virtual-frame-ia32.cc +1366 -0
  239. data/ext/v8/upstream/v8/src/ia32/virtual-frame-ia32.h +650 -0
  240. data/ext/v8/upstream/v8/src/ic-inl.h +130 -0
  241. data/ext/v8/upstream/v8/src/ic.cc +2389 -0
  242. data/ext/v8/upstream/v8/src/ic.h +675 -0
  243. data/ext/v8/upstream/{3.1.8 → v8}/src/inspector.cc +0 -0
  244. data/ext/v8/upstream/{3.1.8 → v8}/src/inspector.h +0 -0
  245. data/ext/v8/upstream/v8/src/interpreter-irregexp.cc +659 -0
  246. data/ext/v8/upstream/v8/src/interpreter-irregexp.h +49 -0
  247. data/ext/v8/upstream/v8/src/isolate.cc +883 -0
  248. data/ext/v8/upstream/v8/src/isolate.h +1306 -0
  249. data/ext/v8/upstream/v8/src/json.js +342 -0
  250. data/ext/v8/upstream/v8/src/jsregexp.cc +5371 -0
  251. data/ext/v8/upstream/v8/src/jsregexp.h +1483 -0
  252. data/ext/v8/upstream/{3.1.8 → v8}/src/jump-target-heavy-inl.h +0 -0
  253. data/ext/v8/upstream/v8/src/jump-target-heavy.cc +427 -0
  254. data/ext/v8/upstream/v8/src/jump-target-heavy.h +238 -0
  255. data/ext/v8/upstream/v8/src/jump-target-inl.h +48 -0
  256. data/ext/v8/upstream/{3.1.8 → v8}/src/jump-target-light-inl.h +0 -0
  257. data/ext/v8/upstream/v8/src/jump-target-light.cc +111 -0
  258. data/ext/v8/upstream/{3.1.8 → v8}/src/jump-target-light.h +0 -0
  259. data/ext/v8/upstream/{3.1.8 → v8}/src/jump-target.cc +0 -0
  260. data/ext/v8/upstream/{3.1.8 → v8}/src/jump-target.h +0 -0
  261. data/ext/v8/upstream/{3.1.8 → v8}/src/list-inl.h +0 -0
  262. data/ext/v8/upstream/{3.1.8 → v8}/src/list.h +0 -0
  263. data/ext/v8/upstream/v8/src/lithium-allocator-inl.h +142 -0
  264. data/ext/v8/upstream/v8/src/lithium-allocator.cc +2105 -0
  265. data/ext/v8/upstream/v8/src/lithium-allocator.h +630 -0
  266. data/ext/v8/upstream/v8/src/lithium.cc +169 -0
  267. data/ext/v8/upstream/{3.1.8 → v8}/src/lithium.h +0 -0
  268. data/ext/v8/upstream/{3.1.8 → v8}/src/liveedit-debugger.js +0 -0
  269. data/ext/v8/upstream/v8/src/liveedit.cc +1693 -0
  270. data/ext/v8/upstream/v8/src/liveedit.h +179 -0
  271. data/ext/v8/upstream/{3.1.8 → v8}/src/liveobjectlist-inl.h +0 -0
  272. data/ext/v8/upstream/v8/src/liveobjectlist.cc +2589 -0
  273. data/ext/v8/upstream/v8/src/liveobjectlist.h +322 -0
  274. data/ext/v8/upstream/{3.1.8 → v8}/src/log-inl.h +0 -0
  275. data/ext/v8/upstream/v8/src/log-utils.cc +423 -0
  276. data/ext/v8/upstream/v8/src/log-utils.h +229 -0
  277. data/ext/v8/upstream/v8/src/log.cc +1666 -0
  278. data/ext/v8/upstream/v8/src/log.h +446 -0
  279. data/ext/v8/upstream/{3.1.8 → v8}/src/macro-assembler.h +0 -0
  280. data/ext/v8/upstream/{3.1.8 → v8}/src/macros.py +0 -0
  281. data/ext/v8/upstream/v8/src/mark-compact.cc +3092 -0
  282. data/ext/v8/upstream/v8/src/mark-compact.h +506 -0
  283. data/ext/v8/upstream/{3.1.8 → v8}/src/math.js +0 -0
  284. data/ext/v8/upstream/v8/src/messages.cc +166 -0
  285. data/ext/v8/upstream/{3.1.8 → v8}/src/messages.h +0 -0
  286. data/ext/v8/upstream/v8/src/messages.js +1090 -0
  287. data/ext/v8/upstream/v8/src/mips/assembler-mips-inl.h +335 -0
  288. data/ext/v8/upstream/v8/src/mips/assembler-mips.cc +2093 -0
  289. data/ext/v8/upstream/v8/src/mips/assembler-mips.h +1066 -0
  290. data/ext/v8/upstream/v8/src/mips/builtins-mips.cc +148 -0
  291. data/ext/v8/upstream/v8/src/mips/code-stubs-mips.cc +752 -0
  292. data/ext/v8/upstream/v8/src/mips/code-stubs-mips.h +511 -0
  293. data/ext/v8/upstream/v8/src/mips/codegen-mips-inl.h +64 -0
  294. data/ext/v8/upstream/v8/src/mips/codegen-mips.cc +1213 -0
  295. data/ext/v8/upstream/v8/src/mips/codegen-mips.h +633 -0
  296. data/ext/v8/upstream/v8/src/mips/constants-mips.cc +352 -0
  297. data/ext/v8/upstream/v8/src/mips/constants-mips.h +723 -0
  298. data/ext/v8/upstream/v8/src/mips/cpu-mips.cc +90 -0
  299. data/ext/v8/upstream/v8/src/mips/debug-mips.cc +155 -0
  300. data/ext/v8/upstream/v8/src/mips/deoptimizer-mips.cc +91 -0
  301. data/ext/v8/upstream/v8/src/mips/disasm-mips.cc +1023 -0
  302. data/ext/v8/upstream/v8/src/mips/frames-mips.cc +48 -0
  303. data/ext/v8/upstream/v8/src/mips/frames-mips.h +179 -0
  304. data/ext/v8/upstream/v8/src/mips/full-codegen-mips.cc +727 -0
  305. data/ext/v8/upstream/v8/src/mips/ic-mips.cc +244 -0
  306. data/ext/v8/upstream/v8/src/mips/jump-target-mips.cc +80 -0
  307. data/ext/v8/upstream/v8/src/mips/lithium-codegen-mips.h +65 -0
  308. data/ext/v8/upstream/v8/src/mips/lithium-mips.h +304 -0
  309. data/ext/v8/upstream/v8/src/mips/macro-assembler-mips.cc +3327 -0
  310. data/ext/v8/upstream/v8/src/mips/macro-assembler-mips.h +1058 -0
  311. data/ext/v8/upstream/v8/src/mips/regexp-macro-assembler-mips.cc +478 -0
  312. data/ext/v8/upstream/v8/src/mips/regexp-macro-assembler-mips.h +250 -0
  313. data/ext/v8/upstream/v8/src/mips/register-allocator-mips-inl.h +134 -0
  314. data/ext/v8/upstream/{3.1.8 → v8}/src/mips/register-allocator-mips.cc +0 -0
  315. data/ext/v8/upstream/v8/src/mips/register-allocator-mips.h +47 -0
  316. data/ext/v8/upstream/v8/src/mips/simulator-mips.cc +2438 -0
  317. data/ext/v8/upstream/v8/src/mips/simulator-mips.h +394 -0
  318. data/ext/v8/upstream/v8/src/mips/stub-cache-mips.cc +601 -0
  319. data/ext/v8/upstream/v8/src/mips/virtual-frame-mips-inl.h +58 -0
  320. data/ext/v8/upstream/v8/src/mips/virtual-frame-mips.cc +307 -0
  321. data/ext/v8/upstream/v8/src/mips/virtual-frame-mips.h +530 -0
  322. data/ext/v8/upstream/v8/src/mirror-debugger.js +2381 -0
  323. data/ext/v8/upstream/v8/src/mksnapshot.cc +256 -0
  324. data/ext/v8/upstream/{3.1.8 → v8}/src/natives.h +0 -0
  325. data/ext/v8/upstream/v8/src/objects-debug.cc +722 -0
  326. data/ext/v8/upstream/v8/src/objects-inl.h +4166 -0
  327. data/ext/v8/upstream/v8/src/objects-printer.cc +801 -0
  328. data/ext/v8/upstream/v8/src/objects-visiting.cc +142 -0
  329. data/ext/v8/upstream/v8/src/objects-visiting.h +422 -0
  330. data/ext/v8/upstream/v8/src/objects.cc +10296 -0
  331. data/ext/v8/upstream/v8/src/objects.h +6662 -0
  332. data/ext/v8/upstream/v8/src/parser.cc +5168 -0
  333. data/ext/v8/upstream/v8/src/parser.h +823 -0
  334. data/ext/v8/upstream/v8/src/platform-cygwin.cc +811 -0
  335. data/ext/v8/upstream/v8/src/platform-freebsd.cc +854 -0
  336. data/ext/v8/upstream/v8/src/platform-linux.cc +1120 -0
  337. data/ext/v8/upstream/v8/src/platform-macos.cc +865 -0
  338. data/ext/v8/upstream/v8/src/platform-nullos.cc +504 -0
  339. data/ext/v8/upstream/v8/src/platform-openbsd.cc +672 -0
  340. data/ext/v8/upstream/v8/src/platform-posix.cc +424 -0
  341. data/ext/v8/upstream/v8/src/platform-solaris.cc +796 -0
  342. data/ext/v8/upstream/v8/src/platform-tls-mac.h +62 -0
  343. data/ext/v8/upstream/v8/src/platform-tls-win32.h +62 -0
  344. data/ext/v8/upstream/v8/src/platform-tls.h +50 -0
  345. data/ext/v8/upstream/v8/src/platform-win32.cc +2072 -0
  346. data/ext/v8/upstream/v8/src/platform.h +693 -0
  347. data/ext/v8/upstream/v8/src/preparse-data.cc +185 -0
  348. data/ext/v8/upstream/{3.1.8 → v8}/src/preparse-data.h +0 -0
  349. data/ext/v8/upstream/v8/src/preparser-api.cc +219 -0
  350. data/ext/v8/upstream/v8/src/preparser.cc +1205 -0
  351. data/ext/v8/upstream/{3.1.8 → v8}/src/preparser.h +0 -0
  352. data/ext/v8/upstream/v8/src/prettyprinter.cc +1530 -0
  353. data/ext/v8/upstream/v8/src/prettyprinter.h +223 -0
  354. data/ext/v8/upstream/{3.1.8 → v8}/src/profile-generator-inl.h +0 -0
  355. data/ext/v8/upstream/v8/src/profile-generator.cc +3095 -0
  356. data/ext/v8/upstream/v8/src/profile-generator.h +1125 -0
  357. data/ext/v8/upstream/v8/src/property.cc +102 -0
  358. data/ext/v8/upstream/v8/src/property.h +348 -0
  359. data/ext/v8/upstream/{3.1.8 → v8}/src/regexp-macro-assembler-irregexp-inl.h +0 -0
  360. data/ext/v8/upstream/v8/src/regexp-macro-assembler-irregexp.cc +470 -0
  361. data/ext/v8/upstream/{3.1.8 → v8}/src/regexp-macro-assembler-irregexp.h +0 -0
  362. data/ext/v8/upstream/{3.1.8 → v8}/src/regexp-macro-assembler-tracer.cc +0 -0
  363. data/ext/v8/upstream/{3.1.8 → v8}/src/regexp-macro-assembler-tracer.h +0 -0
  364. data/ext/v8/upstream/v8/src/regexp-macro-assembler.cc +266 -0
  365. data/ext/v8/upstream/v8/src/regexp-macro-assembler.h +236 -0
  366. data/ext/v8/upstream/v8/src/regexp-stack.cc +111 -0
  367. data/ext/v8/upstream/v8/src/regexp-stack.h +147 -0
  368. data/ext/v8/upstream/v8/src/regexp.js +483 -0
  369. data/ext/v8/upstream/v8/src/register-allocator-inl.h +141 -0
  370. data/ext/v8/upstream/v8/src/register-allocator.cc +98 -0
  371. data/ext/v8/upstream/v8/src/register-allocator.h +310 -0
  372. data/ext/v8/upstream/v8/src/rewriter.cc +1024 -0
  373. data/ext/v8/upstream/{3.1.8 → v8}/src/rewriter.h +0 -0
  374. data/ext/v8/upstream/v8/src/runtime-profiler.cc +478 -0
  375. data/ext/v8/upstream/v8/src/runtime-profiler.h +192 -0
  376. data/ext/v8/upstream/v8/src/runtime.cc +11949 -0
  377. data/ext/v8/upstream/v8/src/runtime.h +643 -0
  378. data/ext/v8/upstream/{3.1.8 → v8}/src/runtime.js +0 -0
  379. data/ext/v8/upstream/v8/src/safepoint-table.cc +256 -0
  380. data/ext/v8/upstream/v8/src/safepoint-table.h +269 -0
  381. data/ext/v8/upstream/v8/src/scanner-base.cc +964 -0
  382. data/ext/v8/upstream/v8/src/scanner-base.h +664 -0
  383. data/ext/v8/upstream/v8/src/scanner.cc +584 -0
  384. data/ext/v8/upstream/v8/src/scanner.h +196 -0
  385. data/ext/v8/upstream/v8/src/scopeinfo.cc +631 -0
  386. data/ext/v8/upstream/v8/src/scopeinfo.h +249 -0
  387. data/ext/v8/upstream/v8/src/scopes.cc +1093 -0
  388. data/ext/v8/upstream/v8/src/scopes.h +508 -0
  389. data/ext/v8/upstream/v8/src/serialize.cc +1574 -0
  390. data/ext/v8/upstream/v8/src/serialize.h +589 -0
  391. data/ext/v8/upstream/{3.1.8 → v8}/src/shell.h +0 -0
  392. data/ext/v8/upstream/{3.1.8 → v8}/src/simulator.h +0 -0
  393. data/ext/v8/upstream/v8/src/small-pointer-list.h +163 -0
  394. data/ext/v8/upstream/{3.1.8 → v8}/src/smart-pointer.h +0 -0
  395. data/ext/v8/upstream/v8/src/snapshot-common.cc +82 -0
  396. data/ext/v8/upstream/{3.1.8 → v8}/src/snapshot-empty.cc +0 -0
  397. data/ext/v8/upstream/v8/src/snapshot.h +73 -0
  398. data/ext/v8/upstream/v8/src/spaces-inl.h +529 -0
  399. data/ext/v8/upstream/v8/src/spaces.cc +3147 -0
  400. data/ext/v8/upstream/v8/src/spaces.h +2368 -0
  401. data/ext/v8/upstream/{3.1.8 → v8}/src/splay-tree-inl.h +0 -0
  402. data/ext/v8/upstream/{3.1.8 → v8}/src/splay-tree.h +0 -0
  403. data/ext/v8/upstream/v8/src/string-search.cc +41 -0
  404. data/ext/v8/upstream/v8/src/string-search.h +568 -0
  405. data/ext/v8/upstream/v8/src/string-stream.cc +592 -0
  406. data/ext/v8/upstream/{3.1.8 → v8}/src/string-stream.h +0 -0
  407. data/ext/v8/upstream/v8/src/string.js +915 -0
  408. data/ext/v8/upstream/{3.1.8 → v8}/src/strtod.cc +0 -0
  409. data/ext/v8/upstream/{3.1.8 → v8}/src/strtod.h +0 -0
  410. data/ext/v8/upstream/v8/src/stub-cache.cc +1940 -0
  411. data/ext/v8/upstream/v8/src/stub-cache.h +866 -0
  412. data/ext/v8/upstream/{3.1.8 → v8}/src/third_party/valgrind/valgrind.h +0 -0
  413. data/ext/v8/upstream/v8/src/token.cc +63 -0
  414. data/ext/v8/upstream/v8/src/token.h +288 -0
  415. data/ext/v8/upstream/v8/src/top.cc +983 -0
  416. data/ext/v8/upstream/v8/src/type-info.cc +472 -0
  417. data/ext/v8/upstream/v8/src/type-info.h +290 -0
  418. data/ext/v8/upstream/{3.1.8 → v8}/src/unbound-queue-inl.h +0 -0
  419. data/ext/v8/upstream/{3.1.8 → v8}/src/unbound-queue.h +0 -0
  420. data/ext/v8/upstream/{3.1.8 → v8}/src/unicode-inl.h +0 -0
  421. data/ext/v8/upstream/v8/src/unicode.cc +1624 -0
  422. data/ext/v8/upstream/v8/src/unicode.h +280 -0
  423. data/ext/v8/upstream/{3.1.8 → v8}/src/uri.js +0 -0
  424. data/ext/v8/upstream/{3.1.8 → v8}/src/utils.cc +0 -0
  425. data/ext/v8/upstream/v8/src/utils.h +796 -0
  426. data/ext/v8/upstream/v8/src/v8-counters.cc +62 -0
  427. data/ext/v8/upstream/v8/src/v8-counters.h +311 -0
  428. data/ext/v8/upstream/v8/src/v8.cc +215 -0
  429. data/ext/v8/upstream/v8/src/v8.h +130 -0
  430. data/ext/v8/upstream/{3.1.8 → v8}/src/v8checks.h +0 -0
  431. data/ext/v8/upstream/{3.1.8 → v8}/src/v8dll-main.cc +0 -0
  432. data/ext/v8/upstream/v8/src/v8globals.h +486 -0
  433. data/ext/v8/upstream/{3.1.8/src/memory.h → v8/src/v8memory.h} +0 -0
  434. data/ext/v8/upstream/v8/src/v8natives.js +1293 -0
  435. data/ext/v8/upstream/{3.1.8 → v8}/src/v8preparserdll-main.cc +0 -0
  436. data/ext/v8/upstream/v8/src/v8threads.cc +453 -0
  437. data/ext/v8/upstream/v8/src/v8threads.h +164 -0
  438. data/ext/v8/upstream/v8/src/v8utils.h +317 -0
  439. data/ext/v8/upstream/{3.1.8 → v8}/src/variables.cc +0 -0
  440. data/ext/v8/upstream/v8/src/variables.h +212 -0
  441. data/ext/v8/upstream/v8/src/version.cc +116 -0
  442. data/ext/v8/upstream/v8/src/version.h +68 -0
  443. data/ext/v8/upstream/{3.1.8 → v8}/src/virtual-frame-heavy-inl.h +0 -0
  444. data/ext/v8/upstream/{3.1.8 → v8}/src/virtual-frame-heavy.cc +0 -0
  445. data/ext/v8/upstream/{3.1.8 → v8}/src/virtual-frame-inl.h +0 -0
  446. data/ext/v8/upstream/v8/src/virtual-frame-light-inl.h +171 -0
  447. data/ext/v8/upstream/{3.1.8 → v8}/src/virtual-frame-light.cc +0 -0
  448. data/ext/v8/upstream/{3.1.8 → v8}/src/virtual-frame.cc +0 -0
  449. data/ext/v8/upstream/{3.1.8 → v8}/src/virtual-frame.h +0 -0
  450. data/ext/v8/upstream/v8/src/vm-state-inl.h +138 -0
  451. data/ext/v8/upstream/v8/src/vm-state.h +70 -0
  452. data/ext/v8/upstream/v8/src/win32-headers.h +96 -0
  453. data/ext/v8/upstream/v8/src/x64/assembler-x64-inl.h +456 -0
  454. data/ext/v8/upstream/v8/src/x64/assembler-x64.cc +2954 -0
  455. data/ext/v8/upstream/v8/src/x64/assembler-x64.h +1630 -0
  456. data/ext/v8/upstream/v8/src/x64/builtins-x64.cc +1493 -0
  457. data/ext/v8/upstream/v8/src/x64/code-stubs-x64.cc +5132 -0
  458. data/ext/v8/upstream/v8/src/x64/code-stubs-x64.h +477 -0
  459. data/ext/v8/upstream/{3.1.8 → v8}/src/x64/codegen-x64-inl.h +0 -0
  460. data/ext/v8/upstream/v8/src/x64/codegen-x64.cc +8843 -0
  461. data/ext/v8/upstream/v8/src/x64/codegen-x64.h +753 -0
  462. data/ext/v8/upstream/v8/src/x64/cpu-x64.cc +88 -0
  463. data/ext/v8/upstream/v8/src/x64/debug-x64.cc +318 -0
  464. data/ext/v8/upstream/v8/src/x64/deoptimizer-x64.cc +815 -0
  465. data/ext/v8/upstream/v8/src/x64/disasm-x64.cc +1752 -0
  466. data/ext/v8/upstream/{3.1.8 → v8}/src/x64/frames-x64.cc +0 -0
  467. data/ext/v8/upstream/v8/src/x64/frames-x64.h +130 -0
  468. data/ext/v8/upstream/v8/src/x64/full-codegen-x64.cc +4339 -0
  469. data/ext/v8/upstream/v8/src/x64/ic-x64.cc +1752 -0
  470. data/ext/v8/upstream/{3.1.8 → v8}/src/x64/jump-target-x64.cc +0 -0
  471. data/ext/v8/upstream/v8/src/x64/lithium-codegen-x64.cc +3970 -0
  472. data/ext/v8/upstream/v8/src/x64/lithium-codegen-x64.h +318 -0
  473. data/ext/v8/upstream/{3.1.8 → v8}/src/x64/lithium-gap-resolver-x64.cc +0 -0
  474. data/ext/v8/upstream/{3.1.8 → v8}/src/x64/lithium-gap-resolver-x64.h +0 -0
  475. data/ext/v8/upstream/v8/src/x64/lithium-x64.cc +2115 -0
  476. data/ext/v8/upstream/v8/src/x64/lithium-x64.h +2161 -0
  477. data/ext/v8/upstream/v8/src/x64/macro-assembler-x64.cc +2911 -0
  478. data/ext/v8/upstream/v8/src/x64/macro-assembler-x64.h +1984 -0
  479. data/ext/v8/upstream/v8/src/x64/regexp-macro-assembler-x64.cc +1398 -0
  480. data/ext/v8/upstream/v8/src/x64/regexp-macro-assembler-x64.h +282 -0
  481. data/ext/v8/upstream/v8/src/x64/register-allocator-x64-inl.h +87 -0
  482. data/ext/v8/upstream/v8/src/x64/register-allocator-x64.cc +95 -0
  483. data/ext/v8/upstream/{3.1.8 → v8}/src/x64/register-allocator-x64.h +0 -0
  484. data/ext/v8/upstream/{3.1.8 → v8}/src/x64/simulator-x64.cc +0 -0
  485. data/ext/v8/upstream/v8/src/x64/simulator-x64.h +71 -0
  486. data/ext/v8/upstream/v8/src/x64/stub-cache-x64.cc +3460 -0
  487. data/ext/v8/upstream/v8/src/x64/virtual-frame-x64.cc +1296 -0
  488. data/ext/v8/upstream/v8/src/x64/virtual-frame-x64.h +597 -0
  489. data/ext/v8/upstream/v8/src/zone-inl.h +129 -0
  490. data/ext/v8/upstream/v8/src/zone.cc +196 -0
  491. data/ext/v8/upstream/v8/src/zone.h +236 -0
  492. data/ext/v8/upstream/{3.1.8 → v8}/tools/codemap.js +0 -0
  493. data/ext/v8/upstream/{3.1.8 → v8}/tools/consarray.js +0 -0
  494. data/ext/v8/upstream/{3.1.8 → v8}/tools/csvparser.js +0 -0
  495. data/ext/v8/upstream/{3.1.8 → v8}/tools/disasm.py +0 -0
  496. data/ext/v8/upstream/v8/tools/freebsd-tick-processor +10 -0
  497. data/ext/v8/upstream/{3.1.8 → v8}/tools/gc-nvp-trace-processor.py +0 -0
  498. data/ext/v8/upstream/{3.1.8 → v8}/tools/generate-ten-powers.scm +0 -0
  499. data/ext/v8/upstream/{3.1.8 → v8}/tools/grokdump.py +0 -0
  500. data/ext/v8/upstream/v8/tools/gyp/v8.gyp +844 -0
  501. data/ext/v8/upstream/{3.1.8 → v8}/tools/js2c.py +0 -0
  502. data/ext/v8/upstream/{3.1.8 → v8}/tools/jsmin.py +0 -0
  503. data/ext/v8/upstream/v8/tools/linux-tick-processor +35 -0
  504. data/ext/v8/upstream/{3.1.8 → v8}/tools/ll_prof.py +0 -0
  505. data/ext/v8/upstream/{3.1.8 → v8}/tools/logreader.js +0 -0
  506. data/ext/v8/upstream/{3.1.8 → v8}/tools/mac-nm +0 -0
  507. data/ext/v8/upstream/{3.1.8 → v8}/tools/mac-tick-processor +0 -0
  508. data/ext/v8/upstream/{3.1.8 → v8}/tools/oom_dump/README +0 -0
  509. data/ext/v8/upstream/{3.1.8 → v8}/tools/oom_dump/SConstruct +0 -0
  510. data/ext/v8/upstream/{3.1.8 → v8}/tools/oom_dump/oom_dump.cc +0 -0
  511. data/ext/v8/upstream/{3.1.8 → v8}/tools/presubmit.py +0 -0
  512. data/ext/v8/upstream/{3.1.8 → v8}/tools/process-heap-prof.py +0 -0
  513. data/ext/v8/upstream/{3.1.8 → v8}/tools/profile.js +0 -0
  514. data/ext/v8/upstream/{3.1.8 → v8}/tools/profile_view.js +0 -0
  515. data/ext/v8/upstream/{3.1.8 → v8}/tools/run-valgrind.py +0 -0
  516. data/ext/v8/upstream/{3.1.8 → v8}/tools/splaytree.js +0 -0
  517. data/ext/v8/upstream/{3.1.8 → v8}/tools/stats-viewer.py +0 -0
  518. data/ext/v8/upstream/v8/tools/test.py +1490 -0
  519. data/ext/v8/upstream/{3.1.8 → v8}/tools/tickprocessor-driver.js +0 -0
  520. data/ext/v8/upstream/v8/tools/tickprocessor.js +877 -0
  521. data/ext/v8/upstream/{3.1.8 → v8}/tools/utils.py +0 -0
  522. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/README.txt +0 -0
  523. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/arm.vsprops +0 -0
  524. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/common.vsprops +0 -0
  525. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/d8.vcproj +0 -0
  526. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/d8_arm.vcproj +0 -0
  527. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/d8_x64.vcproj +0 -0
  528. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/d8js2c.cmd +0 -0
  529. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/debug.vsprops +0 -0
  530. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/ia32.vsprops +0 -0
  531. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/js2c.cmd +0 -0
  532. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/release.vsprops +0 -0
  533. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8.sln +0 -0
  534. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8.vcproj +0 -0
  535. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_arm.sln +0 -0
  536. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_arm.vcproj +0 -0
  537. data/ext/v8/upstream/v8/tools/visual_studio/v8_base.vcproj +1308 -0
  538. data/ext/v8/upstream/v8/tools/visual_studio/v8_base_arm.vcproj +1238 -0
  539. data/ext/v8/upstream/v8/tools/visual_studio/v8_base_x64.vcproj +1300 -0
  540. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_cctest.vcproj +0 -0
  541. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_cctest_arm.vcproj +0 -0
  542. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_cctest_x64.vcproj +0 -0
  543. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_mksnapshot.vcproj +0 -0
  544. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_mksnapshot_x64.vcproj +0 -0
  545. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_process_sample.vcproj +0 -0
  546. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_process_sample_arm.vcproj +0 -0
  547. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_process_sample_x64.vcproj +0 -0
  548. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_shell_sample.vcproj +0 -0
  549. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_shell_sample_arm.vcproj +0 -0
  550. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_shell_sample_x64.vcproj +0 -0
  551. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_snapshot.vcproj +0 -0
  552. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_snapshot_cc.vcproj +0 -0
  553. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_snapshot_cc_x64.vcproj +0 -0
  554. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_snapshot_x64.vcproj +0 -0
  555. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_x64.sln +0 -0
  556. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_x64.vcproj +0 -0
  557. data/ext/v8/upstream/v8/tools/visual_studio/x64.vsprops +18 -0
  558. data/ext/v8/upstream/{3.1.8 → v8}/tools/windows-tick-processor.bat +0 -0
  559. data/ext/v8/v8_callbacks.cpp +52 -92
  560. data/ext/v8/v8_date.cpp +2 -3
  561. data/ext/v8/v8_object.cpp +4 -0
  562. data/ext/v8/v8_template.cpp +2 -2
  563. data/ext/v8/v8_try_catch.cpp +8 -38
  564. data/lib/v8/version.rb +1 -1
  565. data/spec/ext/ext_spec_helper.rb +2 -20
  566. data/spec/ext/object_spec.rb +0 -12
  567. data/spec/ext/try_catch_spec.rb +29 -1
  568. data/spec/spec_helper.rb +1 -0
  569. data/spec/v8/portal/proxies_spec.rb +1 -84
  570. data/specmem/handle_memspec.rb +41 -0
  571. data/specmem/object_memspec.rb +16 -0
  572. data/specmem/proxies_memspec.rb +86 -0
  573. data/specmem/spec_helper.rb +24 -0
  574. data/therubyracer.gemspec +7 -2
  575. metadata +564 -541
  576. data/ext/v8/upstream/3.1.8/.gitignore +0 -31
  577. data/ext/v8/upstream/3.1.8/AUTHORS +0 -40
  578. data/ext/v8/upstream/3.1.8/ChangeLog +0 -2566
  579. data/ext/v8/upstream/3.1.8/SConstruct +0 -1192
  580. data/ext/v8/upstream/3.1.8/include/v8-debug.h +0 -384
  581. data/ext/v8/upstream/3.1.8/include/v8-preparser.h +0 -116
  582. data/ext/v8/upstream/3.1.8/include/v8-profiler.h +0 -426
  583. data/ext/v8/upstream/3.1.8/include/v8-testing.h +0 -99
  584. data/ext/v8/upstream/3.1.8/include/v8.h +0 -3846
  585. data/ext/v8/upstream/3.1.8/preparser/preparser-process.cc +0 -206
  586. data/ext/v8/upstream/3.1.8/src/SConscript +0 -356
  587. data/ext/v8/upstream/3.1.8/src/accessors.cc +0 -907
  588. data/ext/v8/upstream/3.1.8/src/allocation.cc +0 -204
  589. data/ext/v8/upstream/3.1.8/src/allocation.h +0 -176
  590. data/ext/v8/upstream/3.1.8/src/api.cc +0 -5191
  591. data/ext/v8/upstream/3.1.8/src/api.h +0 -508
  592. data/ext/v8/upstream/3.1.8/src/apiutils.h +0 -80
  593. data/ext/v8/upstream/3.1.8/src/arguments.h +0 -105
  594. data/ext/v8/upstream/3.1.8/src/arm/assembler-arm-inl.h +0 -352
  595. data/ext/v8/upstream/3.1.8/src/arm/assembler-arm.cc +0 -2756
  596. data/ext/v8/upstream/3.1.8/src/arm/assembler-arm.h +0 -1294
  597. data/ext/v8/upstream/3.1.8/src/arm/builtins-arm.cc +0 -1628
  598. data/ext/v8/upstream/3.1.8/src/arm/code-stubs-arm.cc +0 -6783
  599. data/ext/v8/upstream/3.1.8/src/arm/code-stubs-arm.h +0 -657
  600. data/ext/v8/upstream/3.1.8/src/arm/codegen-arm.cc +0 -7403
  601. data/ext/v8/upstream/3.1.8/src/arm/codegen-arm.h +0 -595
  602. data/ext/v8/upstream/3.1.8/src/arm/constants-arm.h +0 -769
  603. data/ext/v8/upstream/3.1.8/src/arm/cpu-arm.cc +0 -147
  604. data/ext/v8/upstream/3.1.8/src/arm/debug-arm.cc +0 -315
  605. data/ext/v8/upstream/3.1.8/src/arm/deoptimizer-arm.cc +0 -700
  606. data/ext/v8/upstream/3.1.8/src/arm/disasm-arm.cc +0 -1439
  607. data/ext/v8/upstream/3.1.8/src/arm/frames-arm.h +0 -168
  608. data/ext/v8/upstream/3.1.8/src/arm/full-codegen-arm.cc +0 -4230
  609. data/ext/v8/upstream/3.1.8/src/arm/ic-arm.cc +0 -1799
  610. data/ext/v8/upstream/3.1.8/src/arm/lithium-arm.cc +0 -2041
  611. data/ext/v8/upstream/3.1.8/src/arm/lithium-arm.h +0 -2046
  612. data/ext/v8/upstream/3.1.8/src/arm/lithium-codegen-arm.cc +0 -3822
  613. data/ext/v8/upstream/3.1.8/src/arm/lithium-codegen-arm.h +0 -312
  614. data/ext/v8/upstream/3.1.8/src/arm/lithium-gap-resolver-arm.cc +0 -303
  615. data/ext/v8/upstream/3.1.8/src/arm/macro-assembler-arm.cc +0 -2701
  616. data/ext/v8/upstream/3.1.8/src/arm/macro-assembler-arm.h +0 -1015
  617. data/ext/v8/upstream/3.1.8/src/arm/regexp-macro-assembler-arm.cc +0 -1280
  618. data/ext/v8/upstream/3.1.8/src/arm/regexp-macro-assembler-arm.h +0 -252
  619. data/ext/v8/upstream/3.1.8/src/arm/simulator-arm.cc +0 -3165
  620. data/ext/v8/upstream/3.1.8/src/arm/simulator-arm.h +0 -402
  621. data/ext/v8/upstream/3.1.8/src/arm/stub-cache-arm.cc +0 -4077
  622. data/ext/v8/upstream/3.1.8/src/arm/virtual-frame-arm.cc +0 -843
  623. data/ext/v8/upstream/3.1.8/src/arm/virtual-frame-arm.h +0 -520
  624. data/ext/v8/upstream/3.1.8/src/array.js +0 -1231
  625. data/ext/v8/upstream/3.1.8/src/assembler.cc +0 -973
  626. data/ext/v8/upstream/3.1.8/src/assembler.h +0 -787
  627. data/ext/v8/upstream/3.1.8/src/ast-inl.h +0 -107
  628. data/ext/v8/upstream/3.1.8/src/ast.cc +0 -1067
  629. data/ext/v8/upstream/3.1.8/src/ast.h +0 -2177
  630. data/ext/v8/upstream/3.1.8/src/atomicops.h +0 -165
  631. data/ext/v8/upstream/3.1.8/src/bootstrapper.cc +0 -1888
  632. data/ext/v8/upstream/3.1.8/src/bootstrapper.h +0 -118
  633. data/ext/v8/upstream/3.1.8/src/builtins.cc +0 -1586
  634. data/ext/v8/upstream/3.1.8/src/builtins.h +0 -339
  635. data/ext/v8/upstream/3.1.8/src/checks.cc +0 -110
  636. data/ext/v8/upstream/3.1.8/src/checks.h +0 -292
  637. data/ext/v8/upstream/3.1.8/src/code-stubs.cc +0 -230
  638. data/ext/v8/upstream/3.1.8/src/code-stubs.h +0 -950
  639. data/ext/v8/upstream/3.1.8/src/codegen-inl.h +0 -64
  640. data/ext/v8/upstream/3.1.8/src/codegen.cc +0 -495
  641. data/ext/v8/upstream/3.1.8/src/codegen.h +0 -245
  642. data/ext/v8/upstream/3.1.8/src/compilation-cache.cc +0 -654
  643. data/ext/v8/upstream/3.1.8/src/compilation-cache.h +0 -112
  644. data/ext/v8/upstream/3.1.8/src/compiler.cc +0 -806
  645. data/ext/v8/upstream/3.1.8/src/compiler.h +0 -290
  646. data/ext/v8/upstream/3.1.8/src/contexts.cc +0 -320
  647. data/ext/v8/upstream/3.1.8/src/contexts.h +0 -376
  648. data/ext/v8/upstream/3.1.8/src/conversions.cc +0 -1069
  649. data/ext/v8/upstream/3.1.8/src/counters.cc +0 -78
  650. data/ext/v8/upstream/3.1.8/src/counters.h +0 -242
  651. data/ext/v8/upstream/3.1.8/src/cpu-profiler-inl.h +0 -100
  652. data/ext/v8/upstream/3.1.8/src/cpu-profiler.cc +0 -554
  653. data/ext/v8/upstream/3.1.8/src/cpu-profiler.h +0 -291
  654. data/ext/v8/upstream/3.1.8/src/cpu.h +0 -65
  655. data/ext/v8/upstream/3.1.8/src/d8-debug.cc +0 -367
  656. data/ext/v8/upstream/3.1.8/src/d8-debug.h +0 -157
  657. data/ext/v8/upstream/3.1.8/src/d8-posix.cc +0 -693
  658. data/ext/v8/upstream/3.1.8/src/d8.cc +0 -792
  659. data/ext/v8/upstream/3.1.8/src/d8.gyp +0 -85
  660. data/ext/v8/upstream/3.1.8/src/data-flow.h +0 -379
  661. data/ext/v8/upstream/3.1.8/src/dateparser.h +0 -263
  662. data/ext/v8/upstream/3.1.8/src/debug-agent.cc +0 -446
  663. data/ext/v8/upstream/3.1.8/src/debug-agent.h +0 -131
  664. data/ext/v8/upstream/3.1.8/src/debug.cc +0 -3085
  665. data/ext/v8/upstream/3.1.8/src/debug.h +0 -1025
  666. data/ext/v8/upstream/3.1.8/src/deoptimizer.cc +0 -1185
  667. data/ext/v8/upstream/3.1.8/src/deoptimizer.h +0 -529
  668. data/ext/v8/upstream/3.1.8/src/disasm.h +0 -77
  669. data/ext/v8/upstream/3.1.8/src/disassembler.cc +0 -338
  670. data/ext/v8/upstream/3.1.8/src/execution.cc +0 -735
  671. data/ext/v8/upstream/3.1.8/src/execution.h +0 -322
  672. data/ext/v8/upstream/3.1.8/src/extensions/experimental/experimental.gyp +0 -53
  673. data/ext/v8/upstream/3.1.8/src/extensions/experimental/i18n-extension.cc +0 -264
  674. data/ext/v8/upstream/3.1.8/src/extensions/externalize-string-extension.cc +0 -141
  675. data/ext/v8/upstream/3.1.8/src/extensions/gc-extension.cc +0 -58
  676. data/ext/v8/upstream/3.1.8/src/factory.cc +0 -1087
  677. data/ext/v8/upstream/3.1.8/src/factory.h +0 -432
  678. data/ext/v8/upstream/3.1.8/src/flag-definitions.h +0 -552
  679. data/ext/v8/upstream/3.1.8/src/frame-element.cc +0 -42
  680. data/ext/v8/upstream/3.1.8/src/frame-element.h +0 -277
  681. data/ext/v8/upstream/3.1.8/src/frames-inl.h +0 -210
  682. data/ext/v8/upstream/3.1.8/src/frames.cc +0 -1232
  683. data/ext/v8/upstream/3.1.8/src/frames.h +0 -826
  684. data/ext/v8/upstream/3.1.8/src/full-codegen.cc +0 -1382
  685. data/ext/v8/upstream/3.1.8/src/full-codegen.h +0 -751
  686. data/ext/v8/upstream/3.1.8/src/func-name-inferrer.cc +0 -90
  687. data/ext/v8/upstream/3.1.8/src/func-name-inferrer.h +0 -111
  688. data/ext/v8/upstream/3.1.8/src/gdb-jit.cc +0 -1547
  689. data/ext/v8/upstream/3.1.8/src/global-handles.cc +0 -534
  690. data/ext/v8/upstream/3.1.8/src/global-handles.h +0 -181
  691. data/ext/v8/upstream/3.1.8/src/globals.h +0 -325
  692. data/ext/v8/upstream/3.1.8/src/handles-inl.h +0 -80
  693. data/ext/v8/upstream/3.1.8/src/handles.cc +0 -910
  694. data/ext/v8/upstream/3.1.8/src/handles.h +0 -424
  695. data/ext/v8/upstream/3.1.8/src/hashmap.h +0 -121
  696. data/ext/v8/upstream/3.1.8/src/heap-inl.h +0 -587
  697. data/ext/v8/upstream/3.1.8/src/heap-profiler.cc +0 -1128
  698. data/ext/v8/upstream/3.1.8/src/heap-profiler.h +0 -381
  699. data/ext/v8/upstream/3.1.8/src/heap.cc +0 -5610
  700. data/ext/v8/upstream/3.1.8/src/heap.h +0 -2218
  701. data/ext/v8/upstream/3.1.8/src/hydrogen-instructions.cc +0 -1490
  702. data/ext/v8/upstream/3.1.8/src/hydrogen-instructions.h +0 -3493
  703. data/ext/v8/upstream/3.1.8/src/hydrogen.cc +0 -6056
  704. data/ext/v8/upstream/3.1.8/src/hydrogen.h +0 -1091
  705. data/ext/v8/upstream/3.1.8/src/ia32/assembler-ia32-inl.h +0 -429
  706. data/ext/v8/upstream/3.1.8/src/ia32/assembler-ia32.cc +0 -2800
  707. data/ext/v8/upstream/3.1.8/src/ia32/assembler-ia32.h +0 -1093
  708. data/ext/v8/upstream/3.1.8/src/ia32/builtins-ia32.cc +0 -1590
  709. data/ext/v8/upstream/3.1.8/src/ia32/code-stubs-ia32.cc +0 -6624
  710. data/ext/v8/upstream/3.1.8/src/ia32/code-stubs-ia32.h +0 -536
  711. data/ext/v8/upstream/3.1.8/src/ia32/codegen-ia32.cc +0 -10354
  712. data/ext/v8/upstream/3.1.8/src/ia32/codegen-ia32.h +0 -798
  713. data/ext/v8/upstream/3.1.8/src/ia32/cpu-ia32.cc +0 -87
  714. data/ext/v8/upstream/3.1.8/src/ia32/debug-ia32.cc +0 -309
  715. data/ext/v8/upstream/3.1.8/src/ia32/deoptimizer-ia32.cc +0 -664
  716. data/ext/v8/upstream/3.1.8/src/ia32/disasm-ia32.cc +0 -1597
  717. data/ext/v8/upstream/3.1.8/src/ia32/frames-ia32.h +0 -140
  718. data/ext/v8/upstream/3.1.8/src/ia32/full-codegen-ia32.cc +0 -4278
  719. data/ext/v8/upstream/3.1.8/src/ia32/ic-ia32.cc +0 -1786
  720. data/ext/v8/upstream/3.1.8/src/ia32/lithium-codegen-ia32.cc +0 -3880
  721. data/ext/v8/upstream/3.1.8/src/ia32/lithium-codegen-ia32.h +0 -309
  722. data/ext/v8/upstream/3.1.8/src/ia32/lithium-gap-resolver-ia32.cc +0 -460
  723. data/ext/v8/upstream/3.1.8/src/ia32/lithium-ia32.cc +0 -2095
  724. data/ext/v8/upstream/3.1.8/src/ia32/lithium-ia32.h +0 -2127
  725. data/ext/v8/upstream/3.1.8/src/ia32/macro-assembler-ia32.cc +0 -2031
  726. data/ext/v8/upstream/3.1.8/src/ia32/macro-assembler-ia32.h +0 -798
  727. data/ext/v8/upstream/3.1.8/src/ia32/regexp-macro-assembler-ia32.cc +0 -1253
  728. data/ext/v8/upstream/3.1.8/src/ia32/regexp-macro-assembler-ia32.h +0 -215
  729. data/ext/v8/upstream/3.1.8/src/ia32/register-allocator-ia32.cc +0 -157
  730. data/ext/v8/upstream/3.1.8/src/ia32/simulator-ia32.h +0 -72
  731. data/ext/v8/upstream/3.1.8/src/ia32/stub-cache-ia32.cc +0 -3732
  732. data/ext/v8/upstream/3.1.8/src/ia32/virtual-frame-ia32.cc +0 -1360
  733. data/ext/v8/upstream/3.1.8/src/ia32/virtual-frame-ia32.h +0 -646
  734. data/ext/v8/upstream/3.1.8/src/ic-inl.h +0 -129
  735. data/ext/v8/upstream/3.1.8/src/ic.cc +0 -2333
  736. data/ext/v8/upstream/3.1.8/src/ic.h +0 -639
  737. data/ext/v8/upstream/3.1.8/src/interpreter-irregexp.cc +0 -655
  738. data/ext/v8/upstream/3.1.8/src/interpreter-irregexp.h +0 -48
  739. data/ext/v8/upstream/3.1.8/src/json.js +0 -342
  740. data/ext/v8/upstream/3.1.8/src/jsregexp.cc +0 -5340
  741. data/ext/v8/upstream/3.1.8/src/jsregexp.h +0 -1484
  742. data/ext/v8/upstream/3.1.8/src/jump-target-heavy.cc +0 -430
  743. data/ext/v8/upstream/3.1.8/src/jump-target-heavy.h +0 -244
  744. data/ext/v8/upstream/3.1.8/src/jump-target-inl.h +0 -48
  745. data/ext/v8/upstream/3.1.8/src/jump-target-light.cc +0 -111
  746. data/ext/v8/upstream/3.1.8/src/lithium-allocator-inl.h +0 -140
  747. data/ext/v8/upstream/3.1.8/src/lithium-allocator.cc +0 -2093
  748. data/ext/v8/upstream/3.1.8/src/lithium-allocator.h +0 -644
  749. data/ext/v8/upstream/3.1.8/src/lithium.cc +0 -168
  750. data/ext/v8/upstream/3.1.8/src/liveedit.cc +0 -1650
  751. data/ext/v8/upstream/3.1.8/src/liveedit.h +0 -174
  752. data/ext/v8/upstream/3.1.8/src/liveobjectlist.cc +0 -2527
  753. data/ext/v8/upstream/3.1.8/src/liveobjectlist.h +0 -322
  754. data/ext/v8/upstream/3.1.8/src/log-utils.cc +0 -336
  755. data/ext/v8/upstream/3.1.8/src/log-utils.h +0 -232
  756. data/ext/v8/upstream/3.1.8/src/log.cc +0 -1608
  757. data/ext/v8/upstream/3.1.8/src/log.h +0 -379
  758. data/ext/v8/upstream/3.1.8/src/mark-compact.cc +0 -2957
  759. data/ext/v8/upstream/3.1.8/src/mark-compact.h +0 -433
  760. data/ext/v8/upstream/3.1.8/src/messages.cc +0 -164
  761. data/ext/v8/upstream/3.1.8/src/messages.js +0 -1071
  762. data/ext/v8/upstream/3.1.8/src/mips/assembler-mips-inl.h +0 -215
  763. data/ext/v8/upstream/3.1.8/src/mips/assembler-mips.cc +0 -1219
  764. data/ext/v8/upstream/3.1.8/src/mips/assembler-mips.h +0 -667
  765. data/ext/v8/upstream/3.1.8/src/mips/builtins-mips.cc +0 -205
  766. data/ext/v8/upstream/3.1.8/src/mips/codegen-mips-inl.h +0 -70
  767. data/ext/v8/upstream/3.1.8/src/mips/codegen-mips.cc +0 -1437
  768. data/ext/v8/upstream/3.1.8/src/mips/codegen-mips.h +0 -431
  769. data/ext/v8/upstream/3.1.8/src/mips/constants-mips.cc +0 -328
  770. data/ext/v8/upstream/3.1.8/src/mips/constants-mips.h +0 -525
  771. data/ext/v8/upstream/3.1.8/src/mips/cpu-mips.cc +0 -73
  772. data/ext/v8/upstream/3.1.8/src/mips/debug-mips.cc +0 -127
  773. data/ext/v8/upstream/3.1.8/src/mips/disasm-mips.cc +0 -787
  774. data/ext/v8/upstream/3.1.8/src/mips/fast-codegen-mips.cc +0 -77
  775. data/ext/v8/upstream/3.1.8/src/mips/frames-mips.cc +0 -96
  776. data/ext/v8/upstream/3.1.8/src/mips/frames-mips.h +0 -164
  777. data/ext/v8/upstream/3.1.8/src/mips/full-codegen-mips.cc +0 -277
  778. data/ext/v8/upstream/3.1.8/src/mips/ic-mips.cc +0 -208
  779. data/ext/v8/upstream/3.1.8/src/mips/jump-target-mips.cc +0 -175
  780. data/ext/v8/upstream/3.1.8/src/mips/macro-assembler-mips.cc +0 -1326
  781. data/ext/v8/upstream/3.1.8/src/mips/macro-assembler-mips.h +0 -461
  782. data/ext/v8/upstream/3.1.8/src/mips/register-allocator-mips-inl.h +0 -137
  783. data/ext/v8/upstream/3.1.8/src/mips/register-allocator-mips.h +0 -46
  784. data/ext/v8/upstream/3.1.8/src/mips/simulator-mips.cc +0 -1650
  785. data/ext/v8/upstream/3.1.8/src/mips/simulator-mips.h +0 -311
  786. data/ext/v8/upstream/3.1.8/src/mips/stub-cache-mips.cc +0 -418
  787. data/ext/v8/upstream/3.1.8/src/mips/virtual-frame-mips.cc +0 -319
  788. data/ext/v8/upstream/3.1.8/src/mips/virtual-frame-mips.h +0 -548
  789. data/ext/v8/upstream/3.1.8/src/mirror-debugger.js +0 -2380
  790. data/ext/v8/upstream/3.1.8/src/mksnapshot.cc +0 -256
  791. data/ext/v8/upstream/3.1.8/src/objects-debug.cc +0 -722
  792. data/ext/v8/upstream/3.1.8/src/objects-inl.h +0 -3946
  793. data/ext/v8/upstream/3.1.8/src/objects-printer.cc +0 -801
  794. data/ext/v8/upstream/3.1.8/src/objects-visiting.cc +0 -142
  795. data/ext/v8/upstream/3.1.8/src/objects-visiting.h +0 -401
  796. data/ext/v8/upstream/3.1.8/src/objects.cc +0 -10044
  797. data/ext/v8/upstream/3.1.8/src/objects.h +0 -6571
  798. data/ext/v8/upstream/3.1.8/src/parser.cc +0 -5165
  799. data/ext/v8/upstream/3.1.8/src/parser.h +0 -802
  800. data/ext/v8/upstream/3.1.8/src/platform-cygwin.cc +0 -745
  801. data/ext/v8/upstream/3.1.8/src/platform-freebsd.cc +0 -702
  802. data/ext/v8/upstream/3.1.8/src/platform-linux.cc +0 -981
  803. data/ext/v8/upstream/3.1.8/src/platform-macos.cc +0 -732
  804. data/ext/v8/upstream/3.1.8/src/platform-nullos.cc +0 -498
  805. data/ext/v8/upstream/3.1.8/src/platform-openbsd.cc +0 -657
  806. data/ext/v8/upstream/3.1.8/src/platform-posix.cc +0 -399
  807. data/ext/v8/upstream/3.1.8/src/platform-solaris.cc +0 -714
  808. data/ext/v8/upstream/3.1.8/src/platform-win32.cc +0 -1974
  809. data/ext/v8/upstream/3.1.8/src/platform.h +0 -636
  810. data/ext/v8/upstream/3.1.8/src/preparse-data.cc +0 -183
  811. data/ext/v8/upstream/3.1.8/src/preparser-api.cc +0 -213
  812. data/ext/v8/upstream/3.1.8/src/preparser.cc +0 -1205
  813. data/ext/v8/upstream/3.1.8/src/prettyprinter.cc +0 -1539
  814. data/ext/v8/upstream/3.1.8/src/prettyprinter.h +0 -223
  815. data/ext/v8/upstream/3.1.8/src/profile-generator.cc +0 -2899
  816. data/ext/v8/upstream/3.1.8/src/profile-generator.h +0 -1151
  817. data/ext/v8/upstream/3.1.8/src/property.cc +0 -96
  818. data/ext/v8/upstream/3.1.8/src/property.h +0 -337
  819. data/ext/v8/upstream/3.1.8/src/regexp-macro-assembler-irregexp.cc +0 -470
  820. data/ext/v8/upstream/3.1.8/src/regexp-macro-assembler.cc +0 -257
  821. data/ext/v8/upstream/3.1.8/src/regexp-macro-assembler.h +0 -231
  822. data/ext/v8/upstream/3.1.8/src/regexp-stack.cc +0 -103
  823. data/ext/v8/upstream/3.1.8/src/regexp-stack.h +0 -123
  824. data/ext/v8/upstream/3.1.8/src/regexp.js +0 -483
  825. data/ext/v8/upstream/3.1.8/src/register-allocator-inl.h +0 -141
  826. data/ext/v8/upstream/3.1.8/src/register-allocator.cc +0 -104
  827. data/ext/v8/upstream/3.1.8/src/register-allocator.h +0 -320
  828. data/ext/v8/upstream/3.1.8/src/rewriter.cc +0 -1023
  829. data/ext/v8/upstream/3.1.8/src/runtime-profiler.cc +0 -443
  830. data/ext/v8/upstream/3.1.8/src/runtime-profiler.h +0 -77
  831. data/ext/v8/upstream/3.1.8/src/runtime.cc +0 -11592
  832. data/ext/v8/upstream/3.1.8/src/runtime.h +0 -582
  833. data/ext/v8/upstream/3.1.8/src/safepoint-table.cc +0 -253
  834. data/ext/v8/upstream/3.1.8/src/safepoint-table.h +0 -263
  835. data/ext/v8/upstream/3.1.8/src/scanner-base.cc +0 -971
  836. data/ext/v8/upstream/3.1.8/src/scanner-base.h +0 -653
  837. data/ext/v8/upstream/3.1.8/src/scanner.cc +0 -586
  838. data/ext/v8/upstream/3.1.8/src/scanner.h +0 -194
  839. data/ext/v8/upstream/3.1.8/src/scopeinfo.cc +0 -636
  840. data/ext/v8/upstream/3.1.8/src/scopeinfo.h +0 -238
  841. data/ext/v8/upstream/3.1.8/src/scopes.cc +0 -1063
  842. data/ext/v8/upstream/3.1.8/src/scopes.h +0 -494
  843. data/ext/v8/upstream/3.1.8/src/serialize.cc +0 -1535
  844. data/ext/v8/upstream/3.1.8/src/serialize.h +0 -584
  845. data/ext/v8/upstream/3.1.8/src/snapshot-common.cc +0 -82
  846. data/ext/v8/upstream/3.1.8/src/snapshot.h +0 -71
  847. data/ext/v8/upstream/3.1.8/src/spaces-inl.h +0 -524
  848. data/ext/v8/upstream/3.1.8/src/spaces.cc +0 -3254
  849. data/ext/v8/upstream/3.1.8/src/spaces.h +0 -2362
  850. data/ext/v8/upstream/3.1.8/src/string-search.cc +0 -40
  851. data/ext/v8/upstream/3.1.8/src/string-search.h +0 -567
  852. data/ext/v8/upstream/3.1.8/src/string-stream.cc +0 -584
  853. data/ext/v8/upstream/3.1.8/src/string.js +0 -915
  854. data/ext/v8/upstream/3.1.8/src/stub-cache.cc +0 -1878
  855. data/ext/v8/upstream/3.1.8/src/stub-cache.h +0 -849
  856. data/ext/v8/upstream/3.1.8/src/token.cc +0 -63
  857. data/ext/v8/upstream/3.1.8/src/token.h +0 -288
  858. data/ext/v8/upstream/3.1.8/src/top.cc +0 -1152
  859. data/ext/v8/upstream/3.1.8/src/top.h +0 -608
  860. data/ext/v8/upstream/3.1.8/src/type-info.cc +0 -406
  861. data/ext/v8/upstream/3.1.8/src/type-info.h +0 -283
  862. data/ext/v8/upstream/3.1.8/src/unicode.cc +0 -1624
  863. data/ext/v8/upstream/3.1.8/src/unicode.h +0 -280
  864. data/ext/v8/upstream/3.1.8/src/utils.h +0 -793
  865. data/ext/v8/upstream/3.1.8/src/v8-counters.cc +0 -55
  866. data/ext/v8/upstream/3.1.8/src/v8-counters.h +0 -290
  867. data/ext/v8/upstream/3.1.8/src/v8.cc +0 -270
  868. data/ext/v8/upstream/3.1.8/src/v8.h +0 -127
  869. data/ext/v8/upstream/3.1.8/src/v8globals.h +0 -480
  870. data/ext/v8/upstream/3.1.8/src/v8natives.js +0 -1252
  871. data/ext/v8/upstream/3.1.8/src/v8threads.cc +0 -440
  872. data/ext/v8/upstream/3.1.8/src/v8threads.h +0 -157
  873. data/ext/v8/upstream/3.1.8/src/v8utils.h +0 -354
  874. data/ext/v8/upstream/3.1.8/src/variables.h +0 -212
  875. data/ext/v8/upstream/3.1.8/src/version.cc +0 -95
  876. data/ext/v8/upstream/3.1.8/src/version.h +0 -64
  877. data/ext/v8/upstream/3.1.8/src/virtual-frame-light-inl.h +0 -170
  878. data/ext/v8/upstream/3.1.8/src/vm-state-inl.h +0 -134
  879. data/ext/v8/upstream/3.1.8/src/vm-state.h +0 -68
  880. data/ext/v8/upstream/3.1.8/src/win32-headers.h +0 -95
  881. data/ext/v8/upstream/3.1.8/src/x64/assembler-x64-inl.h +0 -455
  882. data/ext/v8/upstream/3.1.8/src/x64/assembler-x64.cc +0 -3162
  883. data/ext/v8/upstream/3.1.8/src/x64/assembler-x64.h +0 -1584
  884. data/ext/v8/upstream/3.1.8/src/x64/builtins-x64.cc +0 -1492
  885. data/ext/v8/upstream/3.1.8/src/x64/code-stubs-x64.cc +0 -5150
  886. data/ext/v8/upstream/3.1.8/src/x64/code-stubs-x64.h +0 -519
  887. data/ext/v8/upstream/3.1.8/src/x64/codegen-x64.cc +0 -8835
  888. data/ext/v8/upstream/3.1.8/src/x64/codegen-x64.h +0 -750
  889. data/ext/v8/upstream/3.1.8/src/x64/cpu-x64.cc +0 -86
  890. data/ext/v8/upstream/3.1.8/src/x64/debug-x64.cc +0 -316
  891. data/ext/v8/upstream/3.1.8/src/x64/deoptimizer-x64.cc +0 -781
  892. data/ext/v8/upstream/3.1.8/src/x64/disasm-x64.cc +0 -1737
  893. data/ext/v8/upstream/3.1.8/src/x64/frames-x64.h +0 -130
  894. data/ext/v8/upstream/3.1.8/src/x64/full-codegen-x64.cc +0 -3984
  895. data/ext/v8/upstream/3.1.8/src/x64/ic-x64.cc +0 -1761
  896. data/ext/v8/upstream/3.1.8/src/x64/lithium-codegen-x64.cc +0 -3639
  897. data/ext/v8/upstream/3.1.8/src/x64/lithium-codegen-x64.h +0 -305
  898. data/ext/v8/upstream/3.1.8/src/x64/lithium-x64.cc +0 -2044
  899. data/ext/v8/upstream/3.1.8/src/x64/lithium-x64.h +0 -2052
  900. data/ext/v8/upstream/3.1.8/src/x64/macro-assembler-x64.cc +0 -2660
  901. data/ext/v8/upstream/3.1.8/src/x64/macro-assembler-x64.h +0 -1852
  902. data/ext/v8/upstream/3.1.8/src/x64/regexp-macro-assembler-x64.cc +0 -1382
  903. data/ext/v8/upstream/3.1.8/src/x64/regexp-macro-assembler-x64.h +0 -278
  904. data/ext/v8/upstream/3.1.8/src/x64/register-allocator-x64-inl.h +0 -87
  905. data/ext/v8/upstream/3.1.8/src/x64/register-allocator-x64.cc +0 -91
  906. data/ext/v8/upstream/3.1.8/src/x64/simulator-x64.h +0 -71
  907. data/ext/v8/upstream/3.1.8/src/x64/stub-cache-x64.cc +0 -3509
  908. data/ext/v8/upstream/3.1.8/src/x64/virtual-frame-x64.cc +0 -1292
  909. data/ext/v8/upstream/3.1.8/src/x64/virtual-frame-x64.h +0 -593
  910. data/ext/v8/upstream/3.1.8/src/zone-inl.h +0 -83
  911. data/ext/v8/upstream/3.1.8/src/zone.cc +0 -195
  912. data/ext/v8/upstream/3.1.8/src/zone.h +0 -233
  913. data/ext/v8/upstream/3.1.8/tools/gyp/v8.gyp +0 -869
  914. data/ext/v8/upstream/3.1.8/tools/linux-tick-processor +0 -33
  915. data/ext/v8/upstream/3.1.8/tools/tickprocessor.js +0 -863
  916. data/ext/v8/upstream/3.1.8/tools/visual_studio/v8_base.vcproj +0 -1296
  917. data/ext/v8/upstream/3.1.8/tools/visual_studio/v8_base_arm.vcproj +0 -1234
  918. data/ext/v8/upstream/3.1.8/tools/visual_studio/v8_base_x64.vcproj +0 -1296
  919. data/ext/v8/upstream/3.1.8/tools/visual_studio/x64.vsprops +0 -17
  920. data/spec/ext/mem_spec.rb +0 -42
@@ -0,0 +1,253 @@
1
+ // Copyright 2006-2008 the V8 project authors. All rights reserved.
2
+ // Redistribution and use in source and binary forms, with or without
3
+ // modification, are permitted provided that the following conditions are
4
+ // met:
5
+ //
6
+ // * Redistributions of source code must retain the above copyright
7
+ // notice, this list of conditions and the following disclaimer.
8
+ // * Redistributions in binary form must reproduce the above
9
+ // copyright notice, this list of conditions and the following
10
+ // disclaimer in the documentation and/or other materials provided
11
+ // with the distribution.
12
+ // * Neither the name of Google Inc. nor the names of its
13
+ // contributors may be used to endorse or promote products derived
14
+ // from this software without specific prior written permission.
15
+ //
16
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+
28
+ #ifndef V8_ARM_REGEXP_MACRO_ASSEMBLER_ARM_H_
29
+ #define V8_ARM_REGEXP_MACRO_ASSEMBLER_ARM_H_
30
+
31
+ namespace v8 {
32
+ namespace internal {
33
+
34
+
35
+ #ifdef V8_INTERPRETED_REGEXP
36
+ class RegExpMacroAssemblerARM: public RegExpMacroAssembler {
37
+ public:
38
+ RegExpMacroAssemblerARM();
39
+ virtual ~RegExpMacroAssemblerARM();
40
+ };
41
+
42
+ #else // V8_INTERPRETED_REGEXP
43
+ class RegExpMacroAssemblerARM: public NativeRegExpMacroAssembler {
44
+ public:
45
+ RegExpMacroAssemblerARM(Mode mode, int registers_to_save);
46
+ virtual ~RegExpMacroAssemblerARM();
47
+ virtual int stack_limit_slack();
48
+ virtual void AdvanceCurrentPosition(int by);
49
+ virtual void AdvanceRegister(int reg, int by);
50
+ virtual void Backtrack();
51
+ virtual void Bind(Label* label);
52
+ virtual void CheckAtStart(Label* on_at_start);
53
+ virtual void CheckCharacter(unsigned c, Label* on_equal);
54
+ virtual void CheckCharacterAfterAnd(unsigned c,
55
+ unsigned mask,
56
+ Label* on_equal);
57
+ virtual void CheckCharacterGT(uc16 limit, Label* on_greater);
58
+ virtual void CheckCharacterLT(uc16 limit, Label* on_less);
59
+ virtual void CheckCharacters(Vector<const uc16> str,
60
+ int cp_offset,
61
+ Label* on_failure,
62
+ bool check_end_of_string);
63
+ // A "greedy loop" is a loop that is both greedy and with a simple
64
+ // body. It has a particularly simple implementation.
65
+ virtual void CheckGreedyLoop(Label* on_tos_equals_current_position);
66
+ virtual void CheckNotAtStart(Label* on_not_at_start);
67
+ virtual void CheckNotBackReference(int start_reg, Label* on_no_match);
68
+ virtual void CheckNotBackReferenceIgnoreCase(int start_reg,
69
+ Label* on_no_match);
70
+ virtual void CheckNotRegistersEqual(int reg1, int reg2, Label* on_not_equal);
71
+ virtual void CheckNotCharacter(unsigned c, Label* on_not_equal);
72
+ virtual void CheckNotCharacterAfterAnd(unsigned c,
73
+ unsigned mask,
74
+ Label* on_not_equal);
75
+ virtual void CheckNotCharacterAfterMinusAnd(uc16 c,
76
+ uc16 minus,
77
+ uc16 mask,
78
+ Label* on_not_equal);
79
+ // Checks whether the given offset from the current position is before
80
+ // the end of the string.
81
+ virtual void CheckPosition(int cp_offset, Label* on_outside_input);
82
+ virtual bool CheckSpecialCharacterClass(uc16 type,
83
+ Label* on_no_match);
84
+ virtual void Fail();
85
+ virtual Handle<Object> GetCode(Handle<String> source);
86
+ virtual void GoTo(Label* label);
87
+ virtual void IfRegisterGE(int reg, int comparand, Label* if_ge);
88
+ virtual void IfRegisterLT(int reg, int comparand, Label* if_lt);
89
+ virtual void IfRegisterEqPos(int reg, Label* if_eq);
90
+ virtual IrregexpImplementation Implementation();
91
+ virtual void LoadCurrentCharacter(int cp_offset,
92
+ Label* on_end_of_input,
93
+ bool check_bounds = true,
94
+ int characters = 1);
95
+ virtual void PopCurrentPosition();
96
+ virtual void PopRegister(int register_index);
97
+ virtual void PushBacktrack(Label* label);
98
+ virtual void PushCurrentPosition();
99
+ virtual void PushRegister(int register_index,
100
+ StackCheckFlag check_stack_limit);
101
+ virtual void ReadCurrentPositionFromRegister(int reg);
102
+ virtual void ReadStackPointerFromRegister(int reg);
103
+ virtual void SetCurrentPositionFromEnd(int by);
104
+ virtual void SetRegister(int register_index, int to);
105
+ virtual void Succeed();
106
+ virtual void WriteCurrentPositionToRegister(int reg, int cp_offset);
107
+ virtual void ClearRegisters(int reg_from, int reg_to);
108
+ virtual void WriteStackPointerToRegister(int reg);
109
+
110
+ // Called from RegExp if the stack-guard is triggered.
111
+ // If the code object is relocated, the return address is fixed before
112
+ // returning.
113
+ static int CheckStackGuardState(Address* return_address,
114
+ Code* re_code,
115
+ Address re_frame);
116
+ private:
117
+ // Offsets from frame_pointer() of function parameters and stored registers.
118
+ static const int kFramePointer = 0;
119
+
120
+ // Above the frame pointer - Stored registers and stack passed parameters.
121
+ // Register 4..11.
122
+ static const int kStoredRegisters = kFramePointer;
123
+ // Return address (stored from link register, read into pc on return).
124
+ static const int kReturnAddress = kStoredRegisters + 8 * kPointerSize;
125
+ static const int kSecondaryReturnAddress = kReturnAddress + kPointerSize;
126
+ // Stack parameters placed by caller.
127
+ static const int kRegisterOutput = kSecondaryReturnAddress + kPointerSize;
128
+ static const int kStackHighEnd = kRegisterOutput + kPointerSize;
129
+ static const int kDirectCall = kStackHighEnd + kPointerSize;
130
+ static const int kIsolate = kDirectCall + kPointerSize;
131
+
132
+ // Below the frame pointer.
133
+ // Register parameters stored by setup code.
134
+ static const int kInputEnd = kFramePointer - kPointerSize;
135
+ static const int kInputStart = kInputEnd - kPointerSize;
136
+ static const int kStartIndex = kInputStart - kPointerSize;
137
+ static const int kInputString = kStartIndex - kPointerSize;
138
+ // When adding local variables remember to push space for them in
139
+ // the frame in GetCode.
140
+ static const int kInputStartMinusOne = kInputString - kPointerSize;
141
+ static const int kAtStart = kInputStartMinusOne - kPointerSize;
142
+ // First register address. Following registers are below it on the stack.
143
+ static const int kRegisterZero = kAtStart - kPointerSize;
144
+
145
+ // Initial size of code buffer.
146
+ static const size_t kRegExpCodeSize = 1024;
147
+
148
+ static const int kBacktrackConstantPoolSize = 4;
149
+
150
+ // Load a number of characters at the given offset from the
151
+ // current position, into the current-character register.
152
+ void LoadCurrentCharacterUnchecked(int cp_offset, int character_count);
153
+
154
+ // Check whether preemption has been requested.
155
+ void CheckPreemption();
156
+
157
+ // Check whether we are exceeding the stack limit on the backtrack stack.
158
+ void CheckStackLimit();
159
+
160
+ void EmitBacktrackConstantPool();
161
+ int GetBacktrackConstantPoolEntry();
162
+
163
+
164
+ // Generate a call to CheckStackGuardState.
165
+ void CallCheckStackGuardState(Register scratch);
166
+
167
+ // The ebp-relative location of a regexp register.
168
+ MemOperand register_location(int register_index);
169
+
170
+ // Register holding the current input position as negative offset from
171
+ // the end of the string.
172
+ inline Register current_input_offset() { return r6; }
173
+
174
+ // The register containing the current character after LoadCurrentCharacter.
175
+ inline Register current_character() { return r7; }
176
+
177
+ // Register holding address of the end of the input string.
178
+ inline Register end_of_input_address() { return r10; }
179
+
180
+ // Register holding the frame address. Local variables, parameters and
181
+ // regexp registers are addressed relative to this.
182
+ inline Register frame_pointer() { return fp; }
183
+
184
+ // The register containing the backtrack stack top. Provides a meaningful
185
+ // name to the register.
186
+ inline Register backtrack_stackpointer() { return r8; }
187
+
188
+ // Register holding pointer to the current code object.
189
+ inline Register code_pointer() { return r5; }
190
+
191
+ // Byte size of chars in the string to match (decided by the Mode argument)
192
+ inline int char_size() { return static_cast<int>(mode_); }
193
+
194
+ // Equivalent to a conditional branch to the label, unless the label
195
+ // is NULL, in which case it is a conditional Backtrack.
196
+ void BranchOrBacktrack(Condition condition, Label* to);
197
+
198
+ // Call and return internally in the generated code in a way that
199
+ // is GC-safe (i.e., doesn't leave absolute code addresses on the stack)
200
+ inline void SafeCall(Label* to, Condition cond = al);
201
+ inline void SafeReturn();
202
+ inline void SafeCallTarget(Label* name);
203
+
204
+ // Pushes the value of a register on the backtrack stack. Decrements the
205
+ // stack pointer by a word size and stores the register's value there.
206
+ inline void Push(Register source);
207
+
208
+ // Pops a value from the backtrack stack. Reads the word at the stack pointer
209
+ // and increments it by a word size.
210
+ inline void Pop(Register target);
211
+
212
+ // Calls a C function and cleans up the frame alignment done by
213
+ // by FrameAlign. The called function *is* allowed to trigger a garbage
214
+ // collection, but may not take more than four arguments (no arguments
215
+ // passed on the stack), and the first argument will be a pointer to the
216
+ // return address.
217
+ inline void CallCFunctionUsingStub(ExternalReference function,
218
+ int num_arguments);
219
+
220
+
221
+ MacroAssembler* masm_;
222
+
223
+ // Which mode to generate code for (ASCII or UC16).
224
+ Mode mode_;
225
+
226
+ // One greater than maximal register index actually used.
227
+ int num_registers_;
228
+
229
+ // Number of registers to output at the end (the saved registers
230
+ // are always 0..num_saved_registers_-1)
231
+ int num_saved_registers_;
232
+
233
+ // Manage a small pre-allocated pool for writing label targets
234
+ // to for pushing backtrack addresses.
235
+ int backtrack_constant_pool_offset_;
236
+ int backtrack_constant_pool_capacity_;
237
+
238
+ // Labels used internally.
239
+ Label entry_label_;
240
+ Label start_label_;
241
+ Label success_label_;
242
+ Label backtrack_label_;
243
+ Label exit_label_;
244
+ Label check_preempt_label_;
245
+ Label stack_overflow_label_;
246
+ };
247
+
248
+ #endif // V8_INTERPRETED_REGEXP
249
+
250
+
251
+ }} // namespace v8::internal
252
+
253
+ #endif // V8_ARM_REGEXP_MACRO_ASSEMBLER_ARM_H_
@@ -0,0 +1,3288 @@
1
+ // Copyright 2011 the V8 project authors. All rights reserved.
2
+ // Redistribution and use in source and binary forms, with or without
3
+ // modification, are permitted provided that the following conditions are
4
+ // met:
5
+ //
6
+ // * Redistributions of source code must retain the above copyright
7
+ // notice, this list of conditions and the following disclaimer.
8
+ // * Redistributions in binary form must reproduce the above
9
+ // copyright notice, this list of conditions and the following
10
+ // disclaimer in the documentation and/or other materials provided
11
+ // with the distribution.
12
+ // * Neither the name of Google Inc. nor the names of its
13
+ // contributors may be used to endorse or promote products derived
14
+ // from this software without specific prior written permission.
15
+ //
16
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+
28
+ #include <stdlib.h>
29
+ #include <math.h>
30
+ #include <cstdarg>
31
+ #include "v8.h"
32
+
33
+ #if defined(V8_TARGET_ARCH_ARM)
34
+
35
+ #include "disasm.h"
36
+ #include "assembler.h"
37
+ #include "arm/constants-arm.h"
38
+ #include "arm/simulator-arm.h"
39
+
40
+ #if defined(USE_SIMULATOR)
41
+
42
+ // Only build the simulator if not compiling for real ARM hardware.
43
+ namespace v8 {
44
+ namespace internal {
45
+
46
+ // This macro provides a platform independent use of sscanf. The reason for
47
+ // SScanF not being implemented in a platform independent way through
48
+ // ::v8::internal::OS in the same way as SNPrintF is that the
49
+ // Windows C Run-Time Library does not provide vsscanf.
50
+ #define SScanF sscanf // NOLINT
51
+
52
+ // The ArmDebugger class is used by the simulator while debugging simulated ARM
53
+ // code.
54
+ class ArmDebugger {
55
+ public:
56
+ explicit ArmDebugger(Simulator* sim);
57
+ ~ArmDebugger();
58
+
59
+ void Stop(Instruction* instr);
60
+ void Debug();
61
+
62
+ private:
63
+ static const Instr kBreakpointInstr =
64
+ (al | (7*B25) | (1*B24) | kBreakpoint);
65
+ static const Instr kNopInstr = (al | (13*B21));
66
+
67
+ Simulator* sim_;
68
+
69
+ int32_t GetRegisterValue(int regnum);
70
+ double GetVFPDoubleRegisterValue(int regnum);
71
+ bool GetValue(const char* desc, int32_t* value);
72
+ bool GetVFPSingleValue(const char* desc, float* value);
73
+ bool GetVFPDoubleValue(const char* desc, double* value);
74
+
75
+ // Set or delete a breakpoint. Returns true if successful.
76
+ bool SetBreakpoint(Instruction* breakpc);
77
+ bool DeleteBreakpoint(Instruction* breakpc);
78
+
79
+ // Undo and redo all breakpoints. This is needed to bracket disassembly and
80
+ // execution to skip past breakpoints when run from the debugger.
81
+ void UndoBreakpoints();
82
+ void RedoBreakpoints();
83
+ };
84
+
85
+
86
+ ArmDebugger::ArmDebugger(Simulator* sim) {
87
+ sim_ = sim;
88
+ }
89
+
90
+
91
+ ArmDebugger::~ArmDebugger() {
92
+ }
93
+
94
+
95
+
96
+ #ifdef GENERATED_CODE_COVERAGE
97
+ static FILE* coverage_log = NULL;
98
+
99
+
100
+ static void InitializeCoverage() {
101
+ char* file_name = getenv("V8_GENERATED_CODE_COVERAGE_LOG");
102
+ if (file_name != NULL) {
103
+ coverage_log = fopen(file_name, "aw+");
104
+ }
105
+ }
106
+
107
+
108
+ void ArmDebugger::Stop(Instruction* instr) {
109
+ // Get the stop code.
110
+ uint32_t code = instr->SvcValue() & kStopCodeMask;
111
+ // Retrieve the encoded address, which comes just after this stop.
112
+ char** msg_address =
113
+ reinterpret_cast<char**>(sim_->get_pc() + Instruction::kInstrSize);
114
+ char* msg = *msg_address;
115
+ ASSERT(msg != NULL);
116
+
117
+ // Update this stop description.
118
+ if (isWatchedStop(code) && !watched_stops[code].desc) {
119
+ watched_stops[code].desc = msg;
120
+ }
121
+
122
+ if (strlen(msg) > 0) {
123
+ if (coverage_log != NULL) {
124
+ fprintf(coverage_log, "%s\n", msg);
125
+ fflush(coverage_log);
126
+ }
127
+ // Overwrite the instruction and address with nops.
128
+ instr->SetInstructionBits(kNopInstr);
129
+ reinterpret_cast<Instruction*>(msg_address)->SetInstructionBits(kNopInstr);
130
+ }
131
+ sim_->set_pc(sim_->get_pc() + 2 * Instruction::kInstrSize);
132
+ }
133
+
134
+ #else // ndef GENERATED_CODE_COVERAGE
135
+
136
+ static void InitializeCoverage() {
137
+ }
138
+
139
+
140
+ void ArmDebugger::Stop(Instruction* instr) {
141
+ // Get the stop code.
142
+ uint32_t code = instr->SvcValue() & kStopCodeMask;
143
+ // Retrieve the encoded address, which comes just after this stop.
144
+ char* msg = *reinterpret_cast<char**>(sim_->get_pc()
145
+ + Instruction::kInstrSize);
146
+ // Update this stop description.
147
+ if (sim_->isWatchedStop(code) && !sim_->watched_stops[code].desc) {
148
+ sim_->watched_stops[code].desc = msg;
149
+ }
150
+ // Print the stop message and code if it is not the default code.
151
+ if (code != kMaxStopCode) {
152
+ PrintF("Simulator hit stop %u: %s\n", code, msg);
153
+ } else {
154
+ PrintF("Simulator hit %s\n", msg);
155
+ }
156
+ sim_->set_pc(sim_->get_pc() + 2 * Instruction::kInstrSize);
157
+ Debug();
158
+ }
159
+ #endif
160
+
161
+
162
+ int32_t ArmDebugger::GetRegisterValue(int regnum) {
163
+ if (regnum == kPCRegister) {
164
+ return sim_->get_pc();
165
+ } else {
166
+ return sim_->get_register(regnum);
167
+ }
168
+ }
169
+
170
+
171
+ double ArmDebugger::GetVFPDoubleRegisterValue(int regnum) {
172
+ return sim_->get_double_from_d_register(regnum);
173
+ }
174
+
175
+
176
+ bool ArmDebugger::GetValue(const char* desc, int32_t* value) {
177
+ int regnum = Registers::Number(desc);
178
+ if (regnum != kNoRegister) {
179
+ *value = GetRegisterValue(regnum);
180
+ return true;
181
+ } else {
182
+ if (strncmp(desc, "0x", 2) == 0) {
183
+ return SScanF(desc + 2, "%x", reinterpret_cast<uint32_t*>(value)) == 1;
184
+ } else {
185
+ return SScanF(desc, "%u", reinterpret_cast<uint32_t*>(value)) == 1;
186
+ }
187
+ }
188
+ return false;
189
+ }
190
+
191
+
192
+ bool ArmDebugger::GetVFPSingleValue(const char* desc, float* value) {
193
+ bool is_double;
194
+ int regnum = VFPRegisters::Number(desc, &is_double);
195
+ if (regnum != kNoRegister && !is_double) {
196
+ *value = sim_->get_float_from_s_register(regnum);
197
+ return true;
198
+ }
199
+ return false;
200
+ }
201
+
202
+
203
+ bool ArmDebugger::GetVFPDoubleValue(const char* desc, double* value) {
204
+ bool is_double;
205
+ int regnum = VFPRegisters::Number(desc, &is_double);
206
+ if (regnum != kNoRegister && is_double) {
207
+ *value = sim_->get_double_from_d_register(regnum);
208
+ return true;
209
+ }
210
+ return false;
211
+ }
212
+
213
+
214
+ bool ArmDebugger::SetBreakpoint(Instruction* breakpc) {
215
+ // Check if a breakpoint can be set. If not return without any side-effects.
216
+ if (sim_->break_pc_ != NULL) {
217
+ return false;
218
+ }
219
+
220
+ // Set the breakpoint.
221
+ sim_->break_pc_ = breakpc;
222
+ sim_->break_instr_ = breakpc->InstructionBits();
223
+ // Not setting the breakpoint instruction in the code itself. It will be set
224
+ // when the debugger shell continues.
225
+ return true;
226
+ }
227
+
228
+
229
+ bool ArmDebugger::DeleteBreakpoint(Instruction* breakpc) {
230
+ if (sim_->break_pc_ != NULL) {
231
+ sim_->break_pc_->SetInstructionBits(sim_->break_instr_);
232
+ }
233
+
234
+ sim_->break_pc_ = NULL;
235
+ sim_->break_instr_ = 0;
236
+ return true;
237
+ }
238
+
239
+
240
+ void ArmDebugger::UndoBreakpoints() {
241
+ if (sim_->break_pc_ != NULL) {
242
+ sim_->break_pc_->SetInstructionBits(sim_->break_instr_);
243
+ }
244
+ }
245
+
246
+
247
+ void ArmDebugger::RedoBreakpoints() {
248
+ if (sim_->break_pc_ != NULL) {
249
+ sim_->break_pc_->SetInstructionBits(kBreakpointInstr);
250
+ }
251
+ }
252
+
253
+
254
+ void ArmDebugger::Debug() {
255
+ intptr_t last_pc = -1;
256
+ bool done = false;
257
+
258
+ #define COMMAND_SIZE 63
259
+ #define ARG_SIZE 255
260
+
261
+ #define STR(a) #a
262
+ #define XSTR(a) STR(a)
263
+
264
+ char cmd[COMMAND_SIZE + 1];
265
+ char arg1[ARG_SIZE + 1];
266
+ char arg2[ARG_SIZE + 1];
267
+ char* argv[3] = { cmd, arg1, arg2 };
268
+
269
+ // make sure to have a proper terminating character if reaching the limit
270
+ cmd[COMMAND_SIZE] = 0;
271
+ arg1[ARG_SIZE] = 0;
272
+ arg2[ARG_SIZE] = 0;
273
+
274
+ // Undo all set breakpoints while running in the debugger shell. This will
275
+ // make them invisible to all commands.
276
+ UndoBreakpoints();
277
+
278
+ while (!done) {
279
+ if (last_pc != sim_->get_pc()) {
280
+ disasm::NameConverter converter;
281
+ disasm::Disassembler dasm(converter);
282
+ // use a reasonably large buffer
283
+ v8::internal::EmbeddedVector<char, 256> buffer;
284
+ dasm.InstructionDecode(buffer,
285
+ reinterpret_cast<byte*>(sim_->get_pc()));
286
+ PrintF(" 0x%08x %s\n", sim_->get_pc(), buffer.start());
287
+ last_pc = sim_->get_pc();
288
+ }
289
+ char* line = ReadLine("sim> ");
290
+ if (line == NULL) {
291
+ break;
292
+ } else {
293
+ // Use sscanf to parse the individual parts of the command line. At the
294
+ // moment no command expects more than two parameters.
295
+ int argc = SScanF(line,
296
+ "%" XSTR(COMMAND_SIZE) "s "
297
+ "%" XSTR(ARG_SIZE) "s "
298
+ "%" XSTR(ARG_SIZE) "s",
299
+ cmd, arg1, arg2);
300
+ if ((strcmp(cmd, "si") == 0) || (strcmp(cmd, "stepi") == 0)) {
301
+ sim_->InstructionDecode(reinterpret_cast<Instruction*>(sim_->get_pc()));
302
+ } else if ((strcmp(cmd, "c") == 0) || (strcmp(cmd, "cont") == 0)) {
303
+ // Execute the one instruction we broke at with breakpoints disabled.
304
+ sim_->InstructionDecode(reinterpret_cast<Instruction*>(sim_->get_pc()));
305
+ // Leave the debugger shell.
306
+ done = true;
307
+ } else if ((strcmp(cmd, "p") == 0) || (strcmp(cmd, "print") == 0)) {
308
+ if (argc == 2) {
309
+ int32_t value;
310
+ float svalue;
311
+ double dvalue;
312
+ if (strcmp(arg1, "all") == 0) {
313
+ for (int i = 0; i < kNumRegisters; i++) {
314
+ value = GetRegisterValue(i);
315
+ PrintF("%3s: 0x%08x %10d\n", Registers::Name(i), value, value);
316
+ }
317
+ for (int i = 0; i < kNumVFPDoubleRegisters; i++) {
318
+ dvalue = GetVFPDoubleRegisterValue(i);
319
+ uint64_t as_words = BitCast<uint64_t>(dvalue);
320
+ PrintF("%3s: %f 0x%08x %08x\n",
321
+ VFPRegisters::Name(i, true),
322
+ dvalue,
323
+ static_cast<uint32_t>(as_words >> 32),
324
+ static_cast<uint32_t>(as_words & 0xffffffff));
325
+ }
326
+ } else {
327
+ if (GetValue(arg1, &value)) {
328
+ PrintF("%s: 0x%08x %d \n", arg1, value, value);
329
+ } else if (GetVFPSingleValue(arg1, &svalue)) {
330
+ uint32_t as_word = BitCast<uint32_t>(svalue);
331
+ PrintF("%s: %f 0x%08x\n", arg1, svalue, as_word);
332
+ } else if (GetVFPDoubleValue(arg1, &dvalue)) {
333
+ uint64_t as_words = BitCast<uint64_t>(dvalue);
334
+ PrintF("%s: %f 0x%08x %08x\n",
335
+ arg1,
336
+ dvalue,
337
+ static_cast<uint32_t>(as_words >> 32),
338
+ static_cast<uint32_t>(as_words & 0xffffffff));
339
+ } else {
340
+ PrintF("%s unrecognized\n", arg1);
341
+ }
342
+ }
343
+ } else {
344
+ PrintF("print <register>\n");
345
+ }
346
+ } else if ((strcmp(cmd, "po") == 0)
347
+ || (strcmp(cmd, "printobject") == 0)) {
348
+ if (argc == 2) {
349
+ int32_t value;
350
+ if (GetValue(arg1, &value)) {
351
+ Object* obj = reinterpret_cast<Object*>(value);
352
+ PrintF("%s: \n", arg1);
353
+ #ifdef DEBUG
354
+ obj->PrintLn();
355
+ #else
356
+ obj->ShortPrint();
357
+ PrintF("\n");
358
+ #endif
359
+ } else {
360
+ PrintF("%s unrecognized\n", arg1);
361
+ }
362
+ } else {
363
+ PrintF("printobject <value>\n");
364
+ }
365
+ } else if (strcmp(cmd, "stack") == 0 || strcmp(cmd, "mem") == 0) {
366
+ int32_t* cur = NULL;
367
+ int32_t* end = NULL;
368
+ int next_arg = 1;
369
+
370
+ if (strcmp(cmd, "stack") == 0) {
371
+ cur = reinterpret_cast<int32_t*>(sim_->get_register(Simulator::sp));
372
+ } else { // "mem"
373
+ int32_t value;
374
+ if (!GetValue(arg1, &value)) {
375
+ PrintF("%s unrecognized\n", arg1);
376
+ continue;
377
+ }
378
+ cur = reinterpret_cast<int32_t*>(value);
379
+ next_arg++;
380
+ }
381
+
382
+ int32_t words;
383
+ if (argc == next_arg) {
384
+ words = 10;
385
+ } else if (argc == next_arg + 1) {
386
+ if (!GetValue(argv[next_arg], &words)) {
387
+ words = 10;
388
+ }
389
+ }
390
+ end = cur + words;
391
+
392
+ while (cur < end) {
393
+ PrintF(" 0x%08x: 0x%08x %10d",
394
+ reinterpret_cast<intptr_t>(cur), *cur, *cur);
395
+ HeapObject* obj = reinterpret_cast<HeapObject*>(*cur);
396
+ int value = *cur;
397
+ Heap* current_heap = v8::internal::Isolate::Current()->heap();
398
+ if (current_heap->Contains(obj) || ((value & 1) == 0)) {
399
+ PrintF(" (");
400
+ if ((value & 1) == 0) {
401
+ PrintF("smi %d", value / 2);
402
+ } else {
403
+ obj->ShortPrint();
404
+ }
405
+ PrintF(")");
406
+ }
407
+ PrintF("\n");
408
+ cur++;
409
+ }
410
+ } else if (strcmp(cmd, "disasm") == 0 || strcmp(cmd, "di") == 0) {
411
+ disasm::NameConverter converter;
412
+ disasm::Disassembler dasm(converter);
413
+ // use a reasonably large buffer
414
+ v8::internal::EmbeddedVector<char, 256> buffer;
415
+
416
+ byte* prev = NULL;
417
+ byte* cur = NULL;
418
+ byte* end = NULL;
419
+
420
+ if (argc == 1) {
421
+ cur = reinterpret_cast<byte*>(sim_->get_pc());
422
+ end = cur + (10 * Instruction::kInstrSize);
423
+ } else if (argc == 2) {
424
+ int regnum = Registers::Number(arg1);
425
+ if (regnum != kNoRegister || strncmp(arg1, "0x", 2) == 0) {
426
+ // The argument is an address or a register name.
427
+ int32_t value;
428
+ if (GetValue(arg1, &value)) {
429
+ cur = reinterpret_cast<byte*>(value);
430
+ // Disassemble 10 instructions at <arg1>.
431
+ end = cur + (10 * Instruction::kInstrSize);
432
+ }
433
+ } else {
434
+ // The argument is the number of instructions.
435
+ int32_t value;
436
+ if (GetValue(arg1, &value)) {
437
+ cur = reinterpret_cast<byte*>(sim_->get_pc());
438
+ // Disassemble <arg1> instructions.
439
+ end = cur + (value * Instruction::kInstrSize);
440
+ }
441
+ }
442
+ } else {
443
+ int32_t value1;
444
+ int32_t value2;
445
+ if (GetValue(arg1, &value1) && GetValue(arg2, &value2)) {
446
+ cur = reinterpret_cast<byte*>(value1);
447
+ end = cur + (value2 * Instruction::kInstrSize);
448
+ }
449
+ }
450
+
451
+ while (cur < end) {
452
+ prev = cur;
453
+ cur += dasm.InstructionDecode(buffer, cur);
454
+ PrintF(" 0x%08x %s\n",
455
+ reinterpret_cast<intptr_t>(prev), buffer.start());
456
+ }
457
+ } else if (strcmp(cmd, "gdb") == 0) {
458
+ PrintF("relinquishing control to gdb\n");
459
+ v8::internal::OS::DebugBreak();
460
+ PrintF("regaining control from gdb\n");
461
+ } else if (strcmp(cmd, "break") == 0) {
462
+ if (argc == 2) {
463
+ int32_t value;
464
+ if (GetValue(arg1, &value)) {
465
+ if (!SetBreakpoint(reinterpret_cast<Instruction*>(value))) {
466
+ PrintF("setting breakpoint failed\n");
467
+ }
468
+ } else {
469
+ PrintF("%s unrecognized\n", arg1);
470
+ }
471
+ } else {
472
+ PrintF("break <address>\n");
473
+ }
474
+ } else if (strcmp(cmd, "del") == 0) {
475
+ if (!DeleteBreakpoint(NULL)) {
476
+ PrintF("deleting breakpoint failed\n");
477
+ }
478
+ } else if (strcmp(cmd, "flags") == 0) {
479
+ PrintF("N flag: %d; ", sim_->n_flag_);
480
+ PrintF("Z flag: %d; ", sim_->z_flag_);
481
+ PrintF("C flag: %d; ", sim_->c_flag_);
482
+ PrintF("V flag: %d\n", sim_->v_flag_);
483
+ PrintF("INVALID OP flag: %d; ", sim_->inv_op_vfp_flag_);
484
+ PrintF("DIV BY ZERO flag: %d; ", sim_->div_zero_vfp_flag_);
485
+ PrintF("OVERFLOW flag: %d; ", sim_->overflow_vfp_flag_);
486
+ PrintF("UNDERFLOW flag: %d; ", sim_->underflow_vfp_flag_);
487
+ PrintF("INEXACT flag: %d;\n", sim_->inexact_vfp_flag_);
488
+ } else if (strcmp(cmd, "stop") == 0) {
489
+ int32_t value;
490
+ intptr_t stop_pc = sim_->get_pc() - 2 * Instruction::kInstrSize;
491
+ Instruction* stop_instr = reinterpret_cast<Instruction*>(stop_pc);
492
+ Instruction* msg_address =
493
+ reinterpret_cast<Instruction*>(stop_pc + Instruction::kInstrSize);
494
+ if ((argc == 2) && (strcmp(arg1, "unstop") == 0)) {
495
+ // Remove the current stop.
496
+ if (sim_->isStopInstruction(stop_instr)) {
497
+ stop_instr->SetInstructionBits(kNopInstr);
498
+ msg_address->SetInstructionBits(kNopInstr);
499
+ } else {
500
+ PrintF("Not at debugger stop.\n");
501
+ }
502
+ } else if (argc == 3) {
503
+ // Print information about all/the specified breakpoint(s).
504
+ if (strcmp(arg1, "info") == 0) {
505
+ if (strcmp(arg2, "all") == 0) {
506
+ PrintF("Stop information:\n");
507
+ for (uint32_t i = 0; i < sim_->kNumOfWatchedStops; i++) {
508
+ sim_->PrintStopInfo(i);
509
+ }
510
+ } else if (GetValue(arg2, &value)) {
511
+ sim_->PrintStopInfo(value);
512
+ } else {
513
+ PrintF("Unrecognized argument.\n");
514
+ }
515
+ } else if (strcmp(arg1, "enable") == 0) {
516
+ // Enable all/the specified breakpoint(s).
517
+ if (strcmp(arg2, "all") == 0) {
518
+ for (uint32_t i = 0; i < sim_->kNumOfWatchedStops; i++) {
519
+ sim_->EnableStop(i);
520
+ }
521
+ } else if (GetValue(arg2, &value)) {
522
+ sim_->EnableStop(value);
523
+ } else {
524
+ PrintF("Unrecognized argument.\n");
525
+ }
526
+ } else if (strcmp(arg1, "disable") == 0) {
527
+ // Disable all/the specified breakpoint(s).
528
+ if (strcmp(arg2, "all") == 0) {
529
+ for (uint32_t i = 0; i < sim_->kNumOfWatchedStops; i++) {
530
+ sim_->DisableStop(i);
531
+ }
532
+ } else if (GetValue(arg2, &value)) {
533
+ sim_->DisableStop(value);
534
+ } else {
535
+ PrintF("Unrecognized argument.\n");
536
+ }
537
+ }
538
+ } else {
539
+ PrintF("Wrong usage. Use help command for more information.\n");
540
+ }
541
+ } else if ((strcmp(cmd, "t") == 0) || strcmp(cmd, "trace") == 0) {
542
+ ::v8::internal::FLAG_trace_sim = !::v8::internal::FLAG_trace_sim;
543
+ PrintF("Trace of executed instructions is %s\n",
544
+ ::v8::internal::FLAG_trace_sim ? "on" : "off");
545
+ } else if ((strcmp(cmd, "h") == 0) || (strcmp(cmd, "help") == 0)) {
546
+ PrintF("cont\n");
547
+ PrintF(" continue execution (alias 'c')\n");
548
+ PrintF("stepi\n");
549
+ PrintF(" step one instruction (alias 'si')\n");
550
+ PrintF("print <register>\n");
551
+ PrintF(" print register content (alias 'p')\n");
552
+ PrintF(" use register name 'all' to print all registers\n");
553
+ PrintF("printobject <register>\n");
554
+ PrintF(" print an object from a register (alias 'po')\n");
555
+ PrintF("flags\n");
556
+ PrintF(" print flags\n");
557
+ PrintF("stack [<words>]\n");
558
+ PrintF(" dump stack content, default dump 10 words)\n");
559
+ PrintF("mem <address> [<words>]\n");
560
+ PrintF(" dump memory content, default dump 10 words)\n");
561
+ PrintF("disasm [<instructions>]\n");
562
+ PrintF("disasm [<address/register>]\n");
563
+ PrintF("disasm [[<address/register>] <instructions>]\n");
564
+ PrintF(" disassemble code, default is 10 instructions\n");
565
+ PrintF(" from pc (alias 'di')\n");
566
+ PrintF("gdb\n");
567
+ PrintF(" enter gdb\n");
568
+ PrintF("break <address>\n");
569
+ PrintF(" set a break point on the address\n");
570
+ PrintF("del\n");
571
+ PrintF(" delete the breakpoint\n");
572
+ PrintF("trace (alias 't')\n");
573
+ PrintF(" toogle the tracing of all executed statements\n");
574
+ PrintF("stop feature:\n");
575
+ PrintF(" Description:\n");
576
+ PrintF(" Stops are debug instructions inserted by\n");
577
+ PrintF(" the Assembler::stop() function.\n");
578
+ PrintF(" When hitting a stop, the Simulator will\n");
579
+ PrintF(" stop and and give control to the ArmDebugger.\n");
580
+ PrintF(" The first %d stop codes are watched:\n",
581
+ Simulator::kNumOfWatchedStops);
582
+ PrintF(" - They can be enabled / disabled: the Simulator\n");
583
+ PrintF(" will / won't stop when hitting them.\n");
584
+ PrintF(" - The Simulator keeps track of how many times they \n");
585
+ PrintF(" are met. (See the info command.) Going over a\n");
586
+ PrintF(" disabled stop still increases its counter. \n");
587
+ PrintF(" Commands:\n");
588
+ PrintF(" stop info all/<code> : print infos about number <code>\n");
589
+ PrintF(" or all stop(s).\n");
590
+ PrintF(" stop enable/disable all/<code> : enables / disables\n");
591
+ PrintF(" all or number <code> stop(s)\n");
592
+ PrintF(" stop unstop\n");
593
+ PrintF(" ignore the stop instruction at the current location\n");
594
+ PrintF(" from now on\n");
595
+ } else {
596
+ PrintF("Unknown command: %s\n", cmd);
597
+ }
598
+ }
599
+ DeleteArray(line);
600
+ }
601
+
602
+ // Add all the breakpoints back to stop execution and enter the debugger
603
+ // shell when hit.
604
+ RedoBreakpoints();
605
+
606
+ #undef COMMAND_SIZE
607
+ #undef ARG_SIZE
608
+
609
+ #undef STR
610
+ #undef XSTR
611
+ }
612
+
613
+
614
+ static bool ICacheMatch(void* one, void* two) {
615
+ ASSERT((reinterpret_cast<intptr_t>(one) & CachePage::kPageMask) == 0);
616
+ ASSERT((reinterpret_cast<intptr_t>(two) & CachePage::kPageMask) == 0);
617
+ return one == two;
618
+ }
619
+
620
+
621
+ static uint32_t ICacheHash(void* key) {
622
+ return static_cast<uint32_t>(reinterpret_cast<uintptr_t>(key)) >> 2;
623
+ }
624
+
625
+
626
+ static bool AllOnOnePage(uintptr_t start, int size) {
627
+ intptr_t start_page = (start & ~CachePage::kPageMask);
628
+ intptr_t end_page = ((start + size) & ~CachePage::kPageMask);
629
+ return start_page == end_page;
630
+ }
631
+
632
+
633
+ void Simulator::FlushICache(v8::internal::HashMap* i_cache,
634
+ void* start_addr,
635
+ size_t size) {
636
+ intptr_t start = reinterpret_cast<intptr_t>(start_addr);
637
+ int intra_line = (start & CachePage::kLineMask);
638
+ start -= intra_line;
639
+ size += intra_line;
640
+ size = ((size - 1) | CachePage::kLineMask) + 1;
641
+ int offset = (start & CachePage::kPageMask);
642
+ while (!AllOnOnePage(start, size - 1)) {
643
+ int bytes_to_flush = CachePage::kPageSize - offset;
644
+ FlushOnePage(i_cache, start, bytes_to_flush);
645
+ start += bytes_to_flush;
646
+ size -= bytes_to_flush;
647
+ ASSERT_EQ(0, start & CachePage::kPageMask);
648
+ offset = 0;
649
+ }
650
+ if (size != 0) {
651
+ FlushOnePage(i_cache, start, size);
652
+ }
653
+ }
654
+
655
+
656
+ CachePage* Simulator::GetCachePage(v8::internal::HashMap* i_cache, void* page) {
657
+ v8::internal::HashMap::Entry* entry = i_cache->Lookup(page,
658
+ ICacheHash(page),
659
+ true);
660
+ if (entry->value == NULL) {
661
+ CachePage* new_page = new CachePage();
662
+ entry->value = new_page;
663
+ }
664
+ return reinterpret_cast<CachePage*>(entry->value);
665
+ }
666
+
667
+
668
+ // Flush from start up to and not including start + size.
669
+ void Simulator::FlushOnePage(v8::internal::HashMap* i_cache,
670
+ intptr_t start,
671
+ int size) {
672
+ ASSERT(size <= CachePage::kPageSize);
673
+ ASSERT(AllOnOnePage(start, size - 1));
674
+ ASSERT((start & CachePage::kLineMask) == 0);
675
+ ASSERT((size & CachePage::kLineMask) == 0);
676
+ void* page = reinterpret_cast<void*>(start & (~CachePage::kPageMask));
677
+ int offset = (start & CachePage::kPageMask);
678
+ CachePage* cache_page = GetCachePage(i_cache, page);
679
+ char* valid_bytemap = cache_page->ValidityByte(offset);
680
+ memset(valid_bytemap, CachePage::LINE_INVALID, size >> CachePage::kLineShift);
681
+ }
682
+
683
+
684
+ void Simulator::CheckICache(v8::internal::HashMap* i_cache,
685
+ Instruction* instr) {
686
+ intptr_t address = reinterpret_cast<intptr_t>(instr);
687
+ void* page = reinterpret_cast<void*>(address & (~CachePage::kPageMask));
688
+ void* line = reinterpret_cast<void*>(address & (~CachePage::kLineMask));
689
+ int offset = (address & CachePage::kPageMask);
690
+ CachePage* cache_page = GetCachePage(i_cache, page);
691
+ char* cache_valid_byte = cache_page->ValidityByte(offset);
692
+ bool cache_hit = (*cache_valid_byte == CachePage::LINE_VALID);
693
+ char* cached_line = cache_page->CachedData(offset & ~CachePage::kLineMask);
694
+ if (cache_hit) {
695
+ // Check that the data in memory matches the contents of the I-cache.
696
+ CHECK(memcmp(reinterpret_cast<void*>(instr),
697
+ cache_page->CachedData(offset),
698
+ Instruction::kInstrSize) == 0);
699
+ } else {
700
+ // Cache miss. Load memory into the cache.
701
+ memcpy(cached_line, line, CachePage::kLineLength);
702
+ *cache_valid_byte = CachePage::LINE_VALID;
703
+ }
704
+ }
705
+
706
+
707
+ void Simulator::Initialize() {
708
+ if (Isolate::Current()->simulator_initialized()) return;
709
+ Isolate::Current()->set_simulator_initialized(true);
710
+ ::v8::internal::ExternalReference::set_redirector(&RedirectExternalReference);
711
+ }
712
+
713
+
714
+ Simulator::Simulator() : isolate_(Isolate::Current()) {
715
+ i_cache_ = isolate_->simulator_i_cache();
716
+ if (i_cache_ == NULL) {
717
+ i_cache_ = new v8::internal::HashMap(&ICacheMatch);
718
+ isolate_->set_simulator_i_cache(i_cache_);
719
+ }
720
+ Initialize();
721
+ // Setup simulator support first. Some of this information is needed to
722
+ // setup the architecture state.
723
+ size_t stack_size = 1 * 1024*1024; // allocate 1MB for stack
724
+ stack_ = reinterpret_cast<char*>(malloc(stack_size));
725
+ pc_modified_ = false;
726
+ icount_ = 0;
727
+ break_pc_ = NULL;
728
+ break_instr_ = 0;
729
+
730
+ // Setup architecture state.
731
+ // All registers are initialized to zero to start with.
732
+ for (int i = 0; i < num_registers; i++) {
733
+ registers_[i] = 0;
734
+ }
735
+ n_flag_ = false;
736
+ z_flag_ = false;
737
+ c_flag_ = false;
738
+ v_flag_ = false;
739
+
740
+ // Initializing VFP registers.
741
+ // All registers are initialized to zero to start with
742
+ // even though s_registers_ & d_registers_ share the same
743
+ // physical registers in the target.
744
+ for (int i = 0; i < num_s_registers; i++) {
745
+ vfp_register[i] = 0;
746
+ }
747
+ n_flag_FPSCR_ = false;
748
+ z_flag_FPSCR_ = false;
749
+ c_flag_FPSCR_ = false;
750
+ v_flag_FPSCR_ = false;
751
+ FPSCR_rounding_mode_ = RZ;
752
+
753
+ inv_op_vfp_flag_ = false;
754
+ div_zero_vfp_flag_ = false;
755
+ overflow_vfp_flag_ = false;
756
+ underflow_vfp_flag_ = false;
757
+ inexact_vfp_flag_ = false;
758
+
759
+ // The sp is initialized to point to the bottom (high address) of the
760
+ // allocated stack area. To be safe in potential stack underflows we leave
761
+ // some buffer below.
762
+ registers_[sp] = reinterpret_cast<int32_t>(stack_) + stack_size - 64;
763
+ // The lr and pc are initialized to a known bad value that will cause an
764
+ // access violation if the simulator ever tries to execute it.
765
+ registers_[pc] = bad_lr;
766
+ registers_[lr] = bad_lr;
767
+ InitializeCoverage();
768
+ }
769
+
770
+
771
+ // When the generated code calls an external reference we need to catch that in
772
+ // the simulator. The external reference will be a function compiled for the
773
+ // host architecture. We need to call that function instead of trying to
774
+ // execute it with the simulator. We do that by redirecting the external
775
+ // reference to a svc (Supervisor Call) instruction that is handled by
776
+ // the simulator. We write the original destination of the jump just at a known
777
+ // offset from the svc instruction so the simulator knows what to call.
778
+ class Redirection {
779
+ public:
780
+ Redirection(void* external_function, ExternalReference::Type type)
781
+ : external_function_(external_function),
782
+ swi_instruction_(al | (0xf*B24) | kCallRtRedirected),
783
+ type_(type),
784
+ next_(NULL) {
785
+ Isolate* isolate = Isolate::Current();
786
+ next_ = isolate->simulator_redirection();
787
+ Simulator::current(isolate)->
788
+ FlushICache(isolate->simulator_i_cache(),
789
+ reinterpret_cast<void*>(&swi_instruction_),
790
+ Instruction::kInstrSize);
791
+ isolate->set_simulator_redirection(this);
792
+ }
793
+
794
+ void* address_of_swi_instruction() {
795
+ return reinterpret_cast<void*>(&swi_instruction_);
796
+ }
797
+
798
+ void* external_function() { return external_function_; }
799
+ ExternalReference::Type type() { return type_; }
800
+
801
+ static Redirection* Get(void* external_function,
802
+ ExternalReference::Type type) {
803
+ Isolate* isolate = Isolate::Current();
804
+ Redirection* current = isolate->simulator_redirection();
805
+ for (; current != NULL; current = current->next_) {
806
+ if (current->external_function_ == external_function) return current;
807
+ }
808
+ return new Redirection(external_function, type);
809
+ }
810
+
811
+ static Redirection* FromSwiInstruction(Instruction* swi_instruction) {
812
+ char* addr_of_swi = reinterpret_cast<char*>(swi_instruction);
813
+ char* addr_of_redirection =
814
+ addr_of_swi - OFFSET_OF(Redirection, swi_instruction_);
815
+ return reinterpret_cast<Redirection*>(addr_of_redirection);
816
+ }
817
+
818
+ private:
819
+ void* external_function_;
820
+ uint32_t swi_instruction_;
821
+ ExternalReference::Type type_;
822
+ Redirection* next_;
823
+ };
824
+
825
+
826
+ void* Simulator::RedirectExternalReference(void* external_function,
827
+ ExternalReference::Type type) {
828
+ Redirection* redirection = Redirection::Get(external_function, type);
829
+ return redirection->address_of_swi_instruction();
830
+ }
831
+
832
+
833
+ // Get the active Simulator for the current thread.
834
+ Simulator* Simulator::current(Isolate* isolate) {
835
+ v8::internal::Isolate::PerIsolateThreadData* isolate_data =
836
+ Isolate::CurrentPerIsolateThreadData();
837
+ if (isolate_data == NULL) {
838
+ Isolate::EnterDefaultIsolate();
839
+ isolate_data = Isolate::CurrentPerIsolateThreadData();
840
+ }
841
+ ASSERT(isolate_data != NULL);
842
+
843
+ Simulator* sim = isolate_data->simulator();
844
+ if (sim == NULL) {
845
+ // TODO(146): delete the simulator object when a thread/isolate goes away.
846
+ sim = new Simulator();
847
+ isolate_data->set_simulator(sim);
848
+ }
849
+ return sim;
850
+ }
851
+
852
+
853
+ // Sets the register in the architecture state. It will also deal with updating
854
+ // Simulator internal state for special registers such as PC.
855
+ void Simulator::set_register(int reg, int32_t value) {
856
+ ASSERT((reg >= 0) && (reg < num_registers));
857
+ if (reg == pc) {
858
+ pc_modified_ = true;
859
+ }
860
+ registers_[reg] = value;
861
+ }
862
+
863
+
864
+ // Get the register from the architecture state. This function does handle
865
+ // the special case of accessing the PC register.
866
+ int32_t Simulator::get_register(int reg) const {
867
+ ASSERT((reg >= 0) && (reg < num_registers));
868
+ // Stupid code added to avoid bug in GCC.
869
+ // See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949
870
+ if (reg >= num_registers) return 0;
871
+ // End stupid code.
872
+ return registers_[reg] + ((reg == pc) ? Instruction::kPCReadOffset : 0);
873
+ }
874
+
875
+
876
+ void Simulator::set_dw_register(int dreg, const int* dbl) {
877
+ ASSERT((dreg >= 0) && (dreg < num_d_registers));
878
+ registers_[dreg] = dbl[0];
879
+ registers_[dreg + 1] = dbl[1];
880
+ }
881
+
882
+
883
+ // Raw access to the PC register.
884
+ void Simulator::set_pc(int32_t value) {
885
+ pc_modified_ = true;
886
+ registers_[pc] = value;
887
+ }
888
+
889
+
890
+ bool Simulator::has_bad_pc() const {
891
+ return ((registers_[pc] == bad_lr) || (registers_[pc] == end_sim_pc));
892
+ }
893
+
894
+
895
+ // Raw access to the PC register without the special adjustment when reading.
896
+ int32_t Simulator::get_pc() const {
897
+ return registers_[pc];
898
+ }
899
+
900
+
901
+ // Getting from and setting into VFP registers.
902
+ void Simulator::set_s_register(int sreg, unsigned int value) {
903
+ ASSERT((sreg >= 0) && (sreg < num_s_registers));
904
+ vfp_register[sreg] = value;
905
+ }
906
+
907
+
908
+ unsigned int Simulator::get_s_register(int sreg) const {
909
+ ASSERT((sreg >= 0) && (sreg < num_s_registers));
910
+ return vfp_register[sreg];
911
+ }
912
+
913
+
914
+ void Simulator::set_s_register_from_float(int sreg, const float flt) {
915
+ ASSERT((sreg >= 0) && (sreg < num_s_registers));
916
+ // Read the bits from the single precision floating point value
917
+ // into the unsigned integer element of vfp_register[] given by index=sreg.
918
+ char buffer[sizeof(vfp_register[0])];
919
+ memcpy(buffer, &flt, sizeof(vfp_register[0]));
920
+ memcpy(&vfp_register[sreg], buffer, sizeof(vfp_register[0]));
921
+ }
922
+
923
+
924
+ void Simulator::set_s_register_from_sinteger(int sreg, const int sint) {
925
+ ASSERT((sreg >= 0) && (sreg < num_s_registers));
926
+ // Read the bits from the integer value into the unsigned integer element of
927
+ // vfp_register[] given by index=sreg.
928
+ char buffer[sizeof(vfp_register[0])];
929
+ memcpy(buffer, &sint, sizeof(vfp_register[0]));
930
+ memcpy(&vfp_register[sreg], buffer, sizeof(vfp_register[0]));
931
+ }
932
+
933
+
934
+ void Simulator::set_d_register_from_double(int dreg, const double& dbl) {
935
+ ASSERT((dreg >= 0) && (dreg < num_d_registers));
936
+ // Read the bits from the double precision floating point value into the two
937
+ // consecutive unsigned integer elements of vfp_register[] given by index
938
+ // 2*sreg and 2*sreg+1.
939
+ char buffer[2 * sizeof(vfp_register[0])];
940
+ memcpy(buffer, &dbl, 2 * sizeof(vfp_register[0]));
941
+ #ifndef BIG_ENDIAN_FLOATING_POINT
942
+ memcpy(&vfp_register[dreg * 2], buffer, 2 * sizeof(vfp_register[0]));
943
+ #else
944
+ memcpy(&vfp_register[dreg * 2], &buffer[4], sizeof(vfp_register[0]));
945
+ memcpy(&vfp_register[dreg * 2 + 1], &buffer[0], sizeof(vfp_register[0]));
946
+ #endif
947
+ }
948
+
949
+
950
+ float Simulator::get_float_from_s_register(int sreg) {
951
+ ASSERT((sreg >= 0) && (sreg < num_s_registers));
952
+
953
+ float sm_val = 0.0;
954
+ // Read the bits from the unsigned integer vfp_register[] array
955
+ // into the single precision floating point value and return it.
956
+ char buffer[sizeof(vfp_register[0])];
957
+ memcpy(buffer, &vfp_register[sreg], sizeof(vfp_register[0]));
958
+ memcpy(&sm_val, buffer, sizeof(vfp_register[0]));
959
+ return(sm_val);
960
+ }
961
+
962
+
963
+ int Simulator::get_sinteger_from_s_register(int sreg) {
964
+ ASSERT((sreg >= 0) && (sreg < num_s_registers));
965
+
966
+ int sm_val = 0;
967
+ // Read the bits from the unsigned integer vfp_register[] array
968
+ // into the single precision floating point value and return it.
969
+ char buffer[sizeof(vfp_register[0])];
970
+ memcpy(buffer, &vfp_register[sreg], sizeof(vfp_register[0]));
971
+ memcpy(&sm_val, buffer, sizeof(vfp_register[0]));
972
+ return(sm_val);
973
+ }
974
+
975
+
976
+ double Simulator::get_double_from_d_register(int dreg) {
977
+ ASSERT((dreg >= 0) && (dreg < num_d_registers));
978
+
979
+ double dm_val = 0.0;
980
+ // Read the bits from the unsigned integer vfp_register[] array
981
+ // into the double precision floating point value and return it.
982
+ char buffer[2 * sizeof(vfp_register[0])];
983
+ #ifdef BIG_ENDIAN_FLOATING_POINT
984
+ memcpy(&buffer[0], &vfp_register[2 * dreg + 1], sizeof(vfp_register[0]));
985
+ memcpy(&buffer[4], &vfp_register[2 * dreg], sizeof(vfp_register[0]));
986
+ #else
987
+ memcpy(buffer, &vfp_register[2 * dreg], 2 * sizeof(vfp_register[0]));
988
+ #endif
989
+ memcpy(&dm_val, buffer, 2 * sizeof(vfp_register[0]));
990
+ return(dm_val);
991
+ }
992
+
993
+
994
+ // For use in calls that take two double values, constructed from r0, r1, r2
995
+ // and r3.
996
+ void Simulator::GetFpArgs(double* x, double* y) {
997
+ // We use a char buffer to get around the strict-aliasing rules which
998
+ // otherwise allow the compiler to optimize away the copy.
999
+ char buffer[2 * sizeof(registers_[0])];
1000
+ // Registers 0 and 1 -> x.
1001
+ memcpy(buffer, registers_, sizeof(buffer));
1002
+ memcpy(x, buffer, sizeof(buffer));
1003
+ // Registers 2 and 3 -> y.
1004
+ memcpy(buffer, registers_ + 2, sizeof(buffer));
1005
+ memcpy(y, buffer, sizeof(buffer));
1006
+ }
1007
+
1008
+
1009
+ void Simulator::SetFpResult(const double& result) {
1010
+ char buffer[2 * sizeof(registers_[0])];
1011
+ memcpy(buffer, &result, sizeof(buffer));
1012
+ // result -> registers 0 and 1.
1013
+ memcpy(registers_, buffer, sizeof(buffer));
1014
+ }
1015
+
1016
+
1017
+ void Simulator::TrashCallerSaveRegisters() {
1018
+ // We don't trash the registers with the return value.
1019
+ registers_[2] = 0x50Bad4U;
1020
+ registers_[3] = 0x50Bad4U;
1021
+ registers_[12] = 0x50Bad4U;
1022
+ }
1023
+
1024
+ // Some Operating Systems allow unaligned access on ARMv7 targets. We
1025
+ // assume that unaligned accesses are not allowed unless the v8 build system
1026
+ // defines the CAN_USE_UNALIGNED_ACCESSES macro to be non-zero.
1027
+ // The following statements below describes the behavior of the ARM CPUs
1028
+ // that don't support unaligned access.
1029
+ // Some ARM platforms raise an interrupt on detecting unaligned access.
1030
+ // On others it does a funky rotation thing. For now we
1031
+ // simply disallow unaligned reads. Note that simulator runs have the runtime
1032
+ // system running directly on the host system and only generated code is
1033
+ // executed in the simulator. Since the host is typically IA32 we will not
1034
+ // get the correct ARM-like behaviour on unaligned accesses for those ARM
1035
+ // targets that don't support unaligned loads and stores.
1036
+
1037
+
1038
+ int Simulator::ReadW(int32_t addr, Instruction* instr) {
1039
+ #if V8_TARGET_CAN_READ_UNALIGNED
1040
+ intptr_t* ptr = reinterpret_cast<intptr_t*>(addr);
1041
+ return *ptr;
1042
+ #else
1043
+ if ((addr & 3) == 0) {
1044
+ intptr_t* ptr = reinterpret_cast<intptr_t*>(addr);
1045
+ return *ptr;
1046
+ }
1047
+ PrintF("Unaligned read at 0x%08x, pc=0x%08" V8PRIxPTR "\n",
1048
+ addr,
1049
+ reinterpret_cast<intptr_t>(instr));
1050
+ UNIMPLEMENTED();
1051
+ return 0;
1052
+ #endif
1053
+ }
1054
+
1055
+
1056
+ void Simulator::WriteW(int32_t addr, int value, Instruction* instr) {
1057
+ #if V8_TARGET_CAN_READ_UNALIGNED
1058
+ intptr_t* ptr = reinterpret_cast<intptr_t*>(addr);
1059
+ *ptr = value;
1060
+ return;
1061
+ #else
1062
+ if ((addr & 3) == 0) {
1063
+ intptr_t* ptr = reinterpret_cast<intptr_t*>(addr);
1064
+ *ptr = value;
1065
+ return;
1066
+ }
1067
+ PrintF("Unaligned write at 0x%08x, pc=0x%08" V8PRIxPTR "\n",
1068
+ addr,
1069
+ reinterpret_cast<intptr_t>(instr));
1070
+ UNIMPLEMENTED();
1071
+ #endif
1072
+ }
1073
+
1074
+
1075
+ uint16_t Simulator::ReadHU(int32_t addr, Instruction* instr) {
1076
+ #if V8_TARGET_CAN_READ_UNALIGNED
1077
+ uint16_t* ptr = reinterpret_cast<uint16_t*>(addr);
1078
+ return *ptr;
1079
+ #else
1080
+ if ((addr & 1) == 0) {
1081
+ uint16_t* ptr = reinterpret_cast<uint16_t*>(addr);
1082
+ return *ptr;
1083
+ }
1084
+ PrintF("Unaligned unsigned halfword read at 0x%08x, pc=0x%08" V8PRIxPTR "\n",
1085
+ addr,
1086
+ reinterpret_cast<intptr_t>(instr));
1087
+ UNIMPLEMENTED();
1088
+ return 0;
1089
+ #endif
1090
+ }
1091
+
1092
+
1093
+ int16_t Simulator::ReadH(int32_t addr, Instruction* instr) {
1094
+ #if V8_TARGET_CAN_READ_UNALIGNED
1095
+ int16_t* ptr = reinterpret_cast<int16_t*>(addr);
1096
+ return *ptr;
1097
+ #else
1098
+ if ((addr & 1) == 0) {
1099
+ int16_t* ptr = reinterpret_cast<int16_t*>(addr);
1100
+ return *ptr;
1101
+ }
1102
+ PrintF("Unaligned signed halfword read at 0x%08x\n", addr);
1103
+ UNIMPLEMENTED();
1104
+ return 0;
1105
+ #endif
1106
+ }
1107
+
1108
+
1109
+ void Simulator::WriteH(int32_t addr, uint16_t value, Instruction* instr) {
1110
+ #if V8_TARGET_CAN_READ_UNALIGNED
1111
+ uint16_t* ptr = reinterpret_cast<uint16_t*>(addr);
1112
+ *ptr = value;
1113
+ return;
1114
+ #else
1115
+ if ((addr & 1) == 0) {
1116
+ uint16_t* ptr = reinterpret_cast<uint16_t*>(addr);
1117
+ *ptr = value;
1118
+ return;
1119
+ }
1120
+ PrintF("Unaligned unsigned halfword write at 0x%08x, pc=0x%08" V8PRIxPTR "\n",
1121
+ addr,
1122
+ reinterpret_cast<intptr_t>(instr));
1123
+ UNIMPLEMENTED();
1124
+ #endif
1125
+ }
1126
+
1127
+
1128
+ void Simulator::WriteH(int32_t addr, int16_t value, Instruction* instr) {
1129
+ #if V8_TARGET_CAN_READ_UNALIGNED
1130
+ int16_t* ptr = reinterpret_cast<int16_t*>(addr);
1131
+ *ptr = value;
1132
+ return;
1133
+ #else
1134
+ if ((addr & 1) == 0) {
1135
+ int16_t* ptr = reinterpret_cast<int16_t*>(addr);
1136
+ *ptr = value;
1137
+ return;
1138
+ }
1139
+ PrintF("Unaligned halfword write at 0x%08x, pc=0x%08" V8PRIxPTR "\n",
1140
+ addr,
1141
+ reinterpret_cast<intptr_t>(instr));
1142
+ UNIMPLEMENTED();
1143
+ #endif
1144
+ }
1145
+
1146
+
1147
+ uint8_t Simulator::ReadBU(int32_t addr) {
1148
+ uint8_t* ptr = reinterpret_cast<uint8_t*>(addr);
1149
+ return *ptr;
1150
+ }
1151
+
1152
+
1153
+ int8_t Simulator::ReadB(int32_t addr) {
1154
+ int8_t* ptr = reinterpret_cast<int8_t*>(addr);
1155
+ return *ptr;
1156
+ }
1157
+
1158
+
1159
+ void Simulator::WriteB(int32_t addr, uint8_t value) {
1160
+ uint8_t* ptr = reinterpret_cast<uint8_t*>(addr);
1161
+ *ptr = value;
1162
+ }
1163
+
1164
+
1165
+ void Simulator::WriteB(int32_t addr, int8_t value) {
1166
+ int8_t* ptr = reinterpret_cast<int8_t*>(addr);
1167
+ *ptr = value;
1168
+ }
1169
+
1170
+
1171
+ int32_t* Simulator::ReadDW(int32_t addr) {
1172
+ #if V8_TARGET_CAN_READ_UNALIGNED
1173
+ int32_t* ptr = reinterpret_cast<int32_t*>(addr);
1174
+ return ptr;
1175
+ #else
1176
+ if ((addr & 3) == 0) {
1177
+ int32_t* ptr = reinterpret_cast<int32_t*>(addr);
1178
+ return ptr;
1179
+ }
1180
+ PrintF("Unaligned read at 0x%08x\n", addr);
1181
+ UNIMPLEMENTED();
1182
+ return 0;
1183
+ #endif
1184
+ }
1185
+
1186
+
1187
+ void Simulator::WriteDW(int32_t addr, int32_t value1, int32_t value2) {
1188
+ #if V8_TARGET_CAN_READ_UNALIGNED
1189
+ int32_t* ptr = reinterpret_cast<int32_t*>(addr);
1190
+ *ptr++ = value1;
1191
+ *ptr = value2;
1192
+ return;
1193
+ #else
1194
+ if ((addr & 3) == 0) {
1195
+ int32_t* ptr = reinterpret_cast<int32_t*>(addr);
1196
+ *ptr++ = value1;
1197
+ *ptr = value2;
1198
+ return;
1199
+ }
1200
+ PrintF("Unaligned write at 0x%08x\n", addr);
1201
+ UNIMPLEMENTED();
1202
+ #endif
1203
+ }
1204
+
1205
+
1206
+ // Returns the limit of the stack area to enable checking for stack overflows.
1207
+ uintptr_t Simulator::StackLimit() const {
1208
+ // Leave a safety margin of 256 bytes to prevent overrunning the stack when
1209
+ // pushing values.
1210
+ return reinterpret_cast<uintptr_t>(stack_) + 256;
1211
+ }
1212
+
1213
+
1214
+ // Unsupported instructions use Format to print an error and stop execution.
1215
+ void Simulator::Format(Instruction* instr, const char* format) {
1216
+ PrintF("Simulator found unsupported instruction:\n 0x%08x: %s\n",
1217
+ reinterpret_cast<intptr_t>(instr), format);
1218
+ UNIMPLEMENTED();
1219
+ }
1220
+
1221
+
1222
+ // Checks if the current instruction should be executed based on its
1223
+ // condition bits.
1224
+ bool Simulator::ConditionallyExecute(Instruction* instr) {
1225
+ switch (instr->ConditionField()) {
1226
+ case eq: return z_flag_;
1227
+ case ne: return !z_flag_;
1228
+ case cs: return c_flag_;
1229
+ case cc: return !c_flag_;
1230
+ case mi: return n_flag_;
1231
+ case pl: return !n_flag_;
1232
+ case vs: return v_flag_;
1233
+ case vc: return !v_flag_;
1234
+ case hi: return c_flag_ && !z_flag_;
1235
+ case ls: return !c_flag_ || z_flag_;
1236
+ case ge: return n_flag_ == v_flag_;
1237
+ case lt: return n_flag_ != v_flag_;
1238
+ case gt: return !z_flag_ && (n_flag_ == v_flag_);
1239
+ case le: return z_flag_ || (n_flag_ != v_flag_);
1240
+ case al: return true;
1241
+ default: UNREACHABLE();
1242
+ }
1243
+ return false;
1244
+ }
1245
+
1246
+
1247
+ // Calculate and set the Negative and Zero flags.
1248
+ void Simulator::SetNZFlags(int32_t val) {
1249
+ n_flag_ = (val < 0);
1250
+ z_flag_ = (val == 0);
1251
+ }
1252
+
1253
+
1254
+ // Set the Carry flag.
1255
+ void Simulator::SetCFlag(bool val) {
1256
+ c_flag_ = val;
1257
+ }
1258
+
1259
+
1260
+ // Set the oVerflow flag.
1261
+ void Simulator::SetVFlag(bool val) {
1262
+ v_flag_ = val;
1263
+ }
1264
+
1265
+
1266
+ // Calculate C flag value for additions.
1267
+ bool Simulator::CarryFrom(int32_t left, int32_t right) {
1268
+ uint32_t uleft = static_cast<uint32_t>(left);
1269
+ uint32_t uright = static_cast<uint32_t>(right);
1270
+ uint32_t urest = 0xffffffffU - uleft;
1271
+
1272
+ return (uright > urest);
1273
+ }
1274
+
1275
+
1276
+ // Calculate C flag value for subtractions.
1277
+ bool Simulator::BorrowFrom(int32_t left, int32_t right) {
1278
+ uint32_t uleft = static_cast<uint32_t>(left);
1279
+ uint32_t uright = static_cast<uint32_t>(right);
1280
+
1281
+ return (uright > uleft);
1282
+ }
1283
+
1284
+
1285
+ // Calculate V flag value for additions and subtractions.
1286
+ bool Simulator::OverflowFrom(int32_t alu_out,
1287
+ int32_t left, int32_t right, bool addition) {
1288
+ bool overflow;
1289
+ if (addition) {
1290
+ // operands have the same sign
1291
+ overflow = ((left >= 0 && right >= 0) || (left < 0 && right < 0))
1292
+ // and operands and result have different sign
1293
+ && ((left < 0 && alu_out >= 0) || (left >= 0 && alu_out < 0));
1294
+ } else {
1295
+ // operands have different signs
1296
+ overflow = ((left < 0 && right >= 0) || (left >= 0 && right < 0))
1297
+ // and first operand and result have different signs
1298
+ && ((left < 0 && alu_out >= 0) || (left >= 0 && alu_out < 0));
1299
+ }
1300
+ return overflow;
1301
+ }
1302
+
1303
+
1304
+ // Support for VFP comparisons.
1305
+ void Simulator::Compute_FPSCR_Flags(double val1, double val2) {
1306
+ if (isnan(val1) || isnan(val2)) {
1307
+ n_flag_FPSCR_ = false;
1308
+ z_flag_FPSCR_ = false;
1309
+ c_flag_FPSCR_ = true;
1310
+ v_flag_FPSCR_ = true;
1311
+ // All non-NaN cases.
1312
+ } else if (val1 == val2) {
1313
+ n_flag_FPSCR_ = false;
1314
+ z_flag_FPSCR_ = true;
1315
+ c_flag_FPSCR_ = true;
1316
+ v_flag_FPSCR_ = false;
1317
+ } else if (val1 < val2) {
1318
+ n_flag_FPSCR_ = true;
1319
+ z_flag_FPSCR_ = false;
1320
+ c_flag_FPSCR_ = false;
1321
+ v_flag_FPSCR_ = false;
1322
+ } else {
1323
+ // Case when (val1 > val2).
1324
+ n_flag_FPSCR_ = false;
1325
+ z_flag_FPSCR_ = false;
1326
+ c_flag_FPSCR_ = true;
1327
+ v_flag_FPSCR_ = false;
1328
+ }
1329
+ }
1330
+
1331
+
1332
+ void Simulator::Copy_FPSCR_to_APSR() {
1333
+ n_flag_ = n_flag_FPSCR_;
1334
+ z_flag_ = z_flag_FPSCR_;
1335
+ c_flag_ = c_flag_FPSCR_;
1336
+ v_flag_ = v_flag_FPSCR_;
1337
+ }
1338
+
1339
+
1340
+ // Addressing Mode 1 - Data-processing operands:
1341
+ // Get the value based on the shifter_operand with register.
1342
+ int32_t Simulator::GetShiftRm(Instruction* instr, bool* carry_out) {
1343
+ ShiftOp shift = instr->ShiftField();
1344
+ int shift_amount = instr->ShiftAmountValue();
1345
+ int32_t result = get_register(instr->RmValue());
1346
+ if (instr->Bit(4) == 0) {
1347
+ // by immediate
1348
+ if ((shift == ROR) && (shift_amount == 0)) {
1349
+ UNIMPLEMENTED();
1350
+ return result;
1351
+ } else if (((shift == LSR) || (shift == ASR)) && (shift_amount == 0)) {
1352
+ shift_amount = 32;
1353
+ }
1354
+ switch (shift) {
1355
+ case ASR: {
1356
+ if (shift_amount == 0) {
1357
+ if (result < 0) {
1358
+ result = 0xffffffff;
1359
+ *carry_out = true;
1360
+ } else {
1361
+ result = 0;
1362
+ *carry_out = false;
1363
+ }
1364
+ } else {
1365
+ result >>= (shift_amount - 1);
1366
+ *carry_out = (result & 1) == 1;
1367
+ result >>= 1;
1368
+ }
1369
+ break;
1370
+ }
1371
+
1372
+ case LSL: {
1373
+ if (shift_amount == 0) {
1374
+ *carry_out = c_flag_;
1375
+ } else {
1376
+ result <<= (shift_amount - 1);
1377
+ *carry_out = (result < 0);
1378
+ result <<= 1;
1379
+ }
1380
+ break;
1381
+ }
1382
+
1383
+ case LSR: {
1384
+ if (shift_amount == 0) {
1385
+ result = 0;
1386
+ *carry_out = c_flag_;
1387
+ } else {
1388
+ uint32_t uresult = static_cast<uint32_t>(result);
1389
+ uresult >>= (shift_amount - 1);
1390
+ *carry_out = (uresult & 1) == 1;
1391
+ uresult >>= 1;
1392
+ result = static_cast<int32_t>(uresult);
1393
+ }
1394
+ break;
1395
+ }
1396
+
1397
+ case ROR: {
1398
+ UNIMPLEMENTED();
1399
+ break;
1400
+ }
1401
+
1402
+ default: {
1403
+ UNREACHABLE();
1404
+ break;
1405
+ }
1406
+ }
1407
+ } else {
1408
+ // by register
1409
+ int rs = instr->RsValue();
1410
+ shift_amount = get_register(rs) &0xff;
1411
+ switch (shift) {
1412
+ case ASR: {
1413
+ if (shift_amount == 0) {
1414
+ *carry_out = c_flag_;
1415
+ } else if (shift_amount < 32) {
1416
+ result >>= (shift_amount - 1);
1417
+ *carry_out = (result & 1) == 1;
1418
+ result >>= 1;
1419
+ } else {
1420
+ ASSERT(shift_amount >= 32);
1421
+ if (result < 0) {
1422
+ *carry_out = true;
1423
+ result = 0xffffffff;
1424
+ } else {
1425
+ *carry_out = false;
1426
+ result = 0;
1427
+ }
1428
+ }
1429
+ break;
1430
+ }
1431
+
1432
+ case LSL: {
1433
+ if (shift_amount == 0) {
1434
+ *carry_out = c_flag_;
1435
+ } else if (shift_amount < 32) {
1436
+ result <<= (shift_amount - 1);
1437
+ *carry_out = (result < 0);
1438
+ result <<= 1;
1439
+ } else if (shift_amount == 32) {
1440
+ *carry_out = (result & 1) == 1;
1441
+ result = 0;
1442
+ } else {
1443
+ ASSERT(shift_amount > 32);
1444
+ *carry_out = false;
1445
+ result = 0;
1446
+ }
1447
+ break;
1448
+ }
1449
+
1450
+ case LSR: {
1451
+ if (shift_amount == 0) {
1452
+ *carry_out = c_flag_;
1453
+ } else if (shift_amount < 32) {
1454
+ uint32_t uresult = static_cast<uint32_t>(result);
1455
+ uresult >>= (shift_amount - 1);
1456
+ *carry_out = (uresult & 1) == 1;
1457
+ uresult >>= 1;
1458
+ result = static_cast<int32_t>(uresult);
1459
+ } else if (shift_amount == 32) {
1460
+ *carry_out = (result < 0);
1461
+ result = 0;
1462
+ } else {
1463
+ *carry_out = false;
1464
+ result = 0;
1465
+ }
1466
+ break;
1467
+ }
1468
+
1469
+ case ROR: {
1470
+ UNIMPLEMENTED();
1471
+ break;
1472
+ }
1473
+
1474
+ default: {
1475
+ UNREACHABLE();
1476
+ break;
1477
+ }
1478
+ }
1479
+ }
1480
+ return result;
1481
+ }
1482
+
1483
+
1484
+ // Addressing Mode 1 - Data-processing operands:
1485
+ // Get the value based on the shifter_operand with immediate.
1486
+ int32_t Simulator::GetImm(Instruction* instr, bool* carry_out) {
1487
+ int rotate = instr->RotateValue() * 2;
1488
+ int immed8 = instr->Immed8Value();
1489
+ int imm = (immed8 >> rotate) | (immed8 << (32 - rotate));
1490
+ *carry_out = (rotate == 0) ? c_flag_ : (imm < 0);
1491
+ return imm;
1492
+ }
1493
+
1494
+
1495
+ static int count_bits(int bit_vector) {
1496
+ int count = 0;
1497
+ while (bit_vector != 0) {
1498
+ if ((bit_vector & 1) != 0) {
1499
+ count++;
1500
+ }
1501
+ bit_vector >>= 1;
1502
+ }
1503
+ return count;
1504
+ }
1505
+
1506
+
1507
+ void Simulator::ProcessPUW(Instruction* instr,
1508
+ int num_regs,
1509
+ int reg_size,
1510
+ intptr_t* start_address,
1511
+ intptr_t* end_address) {
1512
+ int rn = instr->RnValue();
1513
+ int32_t rn_val = get_register(rn);
1514
+ switch (instr->PUField()) {
1515
+ case da_x: {
1516
+ UNIMPLEMENTED();
1517
+ break;
1518
+ }
1519
+ case ia_x: {
1520
+ *start_address = rn_val;
1521
+ *end_address = rn_val + (num_regs * reg_size) - reg_size;
1522
+ rn_val = rn_val + (num_regs * reg_size);
1523
+ break;
1524
+ }
1525
+ case db_x: {
1526
+ *start_address = rn_val - (num_regs * reg_size);
1527
+ *end_address = rn_val - reg_size;
1528
+ rn_val = *start_address;
1529
+ break;
1530
+ }
1531
+ case ib_x: {
1532
+ *start_address = rn_val + reg_size;
1533
+ *end_address = rn_val + (num_regs * reg_size);
1534
+ rn_val = *end_address;
1535
+ break;
1536
+ }
1537
+ default: {
1538
+ UNREACHABLE();
1539
+ break;
1540
+ }
1541
+ }
1542
+ if (instr->HasW()) {
1543
+ set_register(rn, rn_val);
1544
+ }
1545
+ }
1546
+
1547
+ // Addressing Mode 4 - Load and Store Multiple
1548
+ void Simulator::HandleRList(Instruction* instr, bool load) {
1549
+ int rlist = instr->RlistValue();
1550
+ int num_regs = count_bits(rlist);
1551
+
1552
+ intptr_t start_address = 0;
1553
+ intptr_t end_address = 0;
1554
+ ProcessPUW(instr, num_regs, kPointerSize, &start_address, &end_address);
1555
+
1556
+ intptr_t* address = reinterpret_cast<intptr_t*>(start_address);
1557
+ int reg = 0;
1558
+ while (rlist != 0) {
1559
+ if ((rlist & 1) != 0) {
1560
+ if (load) {
1561
+ set_register(reg, *address);
1562
+ } else {
1563
+ *address = get_register(reg);
1564
+ }
1565
+ address += 1;
1566
+ }
1567
+ reg++;
1568
+ rlist >>= 1;
1569
+ }
1570
+ ASSERT(end_address == ((intptr_t)address) - 4);
1571
+ }
1572
+
1573
+
1574
+ // Addressing Mode 6 - Load and Store Multiple Coprocessor registers.
1575
+ void Simulator::HandleVList(Instruction* instr) {
1576
+ VFPRegPrecision precision =
1577
+ (instr->SzValue() == 0) ? kSinglePrecision : kDoublePrecision;
1578
+ int operand_size = (precision == kSinglePrecision) ? 4 : 8;
1579
+
1580
+ bool load = (instr->VLValue() == 0x1);
1581
+
1582
+ int vd;
1583
+ int num_regs;
1584
+ vd = instr->VFPDRegValue(precision);
1585
+ if (precision == kSinglePrecision) {
1586
+ num_regs = instr->Immed8Value();
1587
+ } else {
1588
+ num_regs = instr->Immed8Value() / 2;
1589
+ }
1590
+
1591
+ intptr_t start_address = 0;
1592
+ intptr_t end_address = 0;
1593
+ ProcessPUW(instr, num_regs, operand_size, &start_address, &end_address);
1594
+
1595
+ intptr_t* address = reinterpret_cast<intptr_t*>(start_address);
1596
+ for (int reg = vd; reg < vd + num_regs; reg++) {
1597
+ if (precision == kSinglePrecision) {
1598
+ if (load) {
1599
+ set_s_register_from_sinteger(
1600
+ reg, ReadW(reinterpret_cast<int32_t>(address), instr));
1601
+ } else {
1602
+ WriteW(reinterpret_cast<int32_t>(address),
1603
+ get_sinteger_from_s_register(reg), instr);
1604
+ }
1605
+ address += 1;
1606
+ } else {
1607
+ if (load) {
1608
+ set_s_register_from_sinteger(
1609
+ 2 * reg, ReadW(reinterpret_cast<int32_t>(address), instr));
1610
+ set_s_register_from_sinteger(
1611
+ 2 * reg + 1, ReadW(reinterpret_cast<int32_t>(address + 1), instr));
1612
+ } else {
1613
+ WriteW(reinterpret_cast<int32_t>(address),
1614
+ get_sinteger_from_s_register(2 * reg), instr);
1615
+ WriteW(reinterpret_cast<int32_t>(address + 1),
1616
+ get_sinteger_from_s_register(2 * reg + 1), instr);
1617
+ }
1618
+ address += 2;
1619
+ }
1620
+ }
1621
+ ASSERT_EQ(((intptr_t)address) - operand_size, end_address);
1622
+ }
1623
+
1624
+
1625
+ // Calls into the V8 runtime are based on this very simple interface.
1626
+ // Note: To be able to return two values from some calls the code in runtime.cc
1627
+ // uses the ObjectPair which is essentially two 32-bit values stuffed into a
1628
+ // 64-bit value. With the code below we assume that all runtime calls return
1629
+ // 64 bits of result. If they don't, the r1 result register contains a bogus
1630
+ // value, which is fine because it is caller-saved.
1631
+ typedef int64_t (*SimulatorRuntimeCall)(int32_t arg0,
1632
+ int32_t arg1,
1633
+ int32_t arg2,
1634
+ int32_t arg3,
1635
+ int32_t arg4,
1636
+ int32_t arg5);
1637
+ typedef double (*SimulatorRuntimeFPCall)(int32_t arg0,
1638
+ int32_t arg1,
1639
+ int32_t arg2,
1640
+ int32_t arg3);
1641
+
1642
+ // This signature supports direct call in to API function native callback
1643
+ // (refer to InvocationCallback in v8.h).
1644
+ typedef v8::Handle<v8::Value> (*SimulatorRuntimeDirectApiCall)(int32_t arg0);
1645
+
1646
+ // This signature supports direct call to accessor getter callback.
1647
+ typedef v8::Handle<v8::Value> (*SimulatorRuntimeDirectGetterCall)(int32_t arg0,
1648
+ int32_t arg1);
1649
+
1650
+ // Software interrupt instructions are used by the simulator to call into the
1651
+ // C-based V8 runtime.
1652
+ void Simulator::SoftwareInterrupt(Instruction* instr) {
1653
+ int svc = instr->SvcValue();
1654
+ switch (svc) {
1655
+ case kCallRtRedirected: {
1656
+ // Check if stack is aligned. Error if not aligned is reported below to
1657
+ // include information on the function called.
1658
+ bool stack_aligned =
1659
+ (get_register(sp)
1660
+ & (::v8::internal::FLAG_sim_stack_alignment - 1)) == 0;
1661
+ Redirection* redirection = Redirection::FromSwiInstruction(instr);
1662
+ int32_t arg0 = get_register(r0);
1663
+ int32_t arg1 = get_register(r1);
1664
+ int32_t arg2 = get_register(r2);
1665
+ int32_t arg3 = get_register(r3);
1666
+ int32_t* stack_pointer = reinterpret_cast<int32_t*>(get_register(sp));
1667
+ int32_t arg4 = stack_pointer[0];
1668
+ int32_t arg5 = stack_pointer[1];
1669
+ // This is dodgy but it works because the C entry stubs are never moved.
1670
+ // See comment in codegen-arm.cc and bug 1242173.
1671
+ int32_t saved_lr = get_register(lr);
1672
+ intptr_t external =
1673
+ reinterpret_cast<intptr_t>(redirection->external_function());
1674
+ if (redirection->type() == ExternalReference::FP_RETURN_CALL) {
1675
+ SimulatorRuntimeFPCall target =
1676
+ reinterpret_cast<SimulatorRuntimeFPCall>(external);
1677
+ if (::v8::internal::FLAG_trace_sim || !stack_aligned) {
1678
+ double x, y;
1679
+ GetFpArgs(&x, &y);
1680
+ PrintF("Call to host function at %p with args %f, %f",
1681
+ FUNCTION_ADDR(target), x, y);
1682
+ if (!stack_aligned) {
1683
+ PrintF(" with unaligned stack %08x\n", get_register(sp));
1684
+ }
1685
+ PrintF("\n");
1686
+ }
1687
+ CHECK(stack_aligned);
1688
+ double result = target(arg0, arg1, arg2, arg3);
1689
+ SetFpResult(result);
1690
+ } else if (redirection->type() == ExternalReference::DIRECT_API_CALL) {
1691
+ SimulatorRuntimeDirectApiCall target =
1692
+ reinterpret_cast<SimulatorRuntimeDirectApiCall>(external);
1693
+ if (::v8::internal::FLAG_trace_sim || !stack_aligned) {
1694
+ PrintF("Call to host function at %p args %08x",
1695
+ FUNCTION_ADDR(target), arg0);
1696
+ if (!stack_aligned) {
1697
+ PrintF(" with unaligned stack %08x\n", get_register(sp));
1698
+ }
1699
+ PrintF("\n");
1700
+ }
1701
+ CHECK(stack_aligned);
1702
+ v8::Handle<v8::Value> result = target(arg0);
1703
+ if (::v8::internal::FLAG_trace_sim) {
1704
+ PrintF("Returned %p\n", reinterpret_cast<void *>(*result));
1705
+ }
1706
+ set_register(r0, (int32_t) *result);
1707
+ } else if (redirection->type() == ExternalReference::DIRECT_GETTER_CALL) {
1708
+ SimulatorRuntimeDirectGetterCall target =
1709
+ reinterpret_cast<SimulatorRuntimeDirectGetterCall>(external);
1710
+ if (::v8::internal::FLAG_trace_sim || !stack_aligned) {
1711
+ PrintF("Call to host function at %p args %08x %08x",
1712
+ FUNCTION_ADDR(target), arg0, arg1);
1713
+ if (!stack_aligned) {
1714
+ PrintF(" with unaligned stack %08x\n", get_register(sp));
1715
+ }
1716
+ PrintF("\n");
1717
+ }
1718
+ CHECK(stack_aligned);
1719
+ v8::Handle<v8::Value> result = target(arg0, arg1);
1720
+ if (::v8::internal::FLAG_trace_sim) {
1721
+ PrintF("Returned %p\n", reinterpret_cast<void *>(*result));
1722
+ }
1723
+ set_register(r0, (int32_t) *result);
1724
+ } else {
1725
+ // builtin call.
1726
+ ASSERT(redirection->type() == ExternalReference::BUILTIN_CALL);
1727
+ SimulatorRuntimeCall target =
1728
+ reinterpret_cast<SimulatorRuntimeCall>(external);
1729
+ if (::v8::internal::FLAG_trace_sim || !stack_aligned) {
1730
+ PrintF(
1731
+ "Call to host function at %p"
1732
+ "args %08x, %08x, %08x, %08x, %08x, %08x",
1733
+ FUNCTION_ADDR(target),
1734
+ arg0,
1735
+ arg1,
1736
+ arg2,
1737
+ arg3,
1738
+ arg4,
1739
+ arg5);
1740
+ if (!stack_aligned) {
1741
+ PrintF(" with unaligned stack %08x\n", get_register(sp));
1742
+ }
1743
+ PrintF("\n");
1744
+ }
1745
+ CHECK(stack_aligned);
1746
+ int64_t result = target(arg0, arg1, arg2, arg3, arg4, arg5);
1747
+ int32_t lo_res = static_cast<int32_t>(result);
1748
+ int32_t hi_res = static_cast<int32_t>(result >> 32);
1749
+ if (::v8::internal::FLAG_trace_sim) {
1750
+ PrintF("Returned %08x\n", lo_res);
1751
+ }
1752
+ set_register(r0, lo_res);
1753
+ set_register(r1, hi_res);
1754
+ }
1755
+ set_register(lr, saved_lr);
1756
+ set_pc(get_register(lr));
1757
+ break;
1758
+ }
1759
+ case kBreakpoint: {
1760
+ ArmDebugger dbg(this);
1761
+ dbg.Debug();
1762
+ break;
1763
+ }
1764
+ // stop uses all codes greater than 1 << 23.
1765
+ default: {
1766
+ if (svc >= (1 << 23)) {
1767
+ uint32_t code = svc & kStopCodeMask;
1768
+ if (isWatchedStop(code)) {
1769
+ IncreaseStopCounter(code);
1770
+ }
1771
+ // Stop if it is enabled, otherwise go on jumping over the stop
1772
+ // and the message address.
1773
+ if (isEnabledStop(code)) {
1774
+ ArmDebugger dbg(this);
1775
+ dbg.Stop(instr);
1776
+ } else {
1777
+ set_pc(get_pc() + 2 * Instruction::kInstrSize);
1778
+ }
1779
+ } else {
1780
+ // This is not a valid svc code.
1781
+ UNREACHABLE();
1782
+ break;
1783
+ }
1784
+ }
1785
+ }
1786
+ }
1787
+
1788
+
1789
+ // Stop helper functions.
1790
+ bool Simulator::isStopInstruction(Instruction* instr) {
1791
+ return (instr->Bits(27, 24) == 0xF) && (instr->SvcValue() >= kStopCode);
1792
+ }
1793
+
1794
+
1795
+ bool Simulator::isWatchedStop(uint32_t code) {
1796
+ ASSERT(code <= kMaxStopCode);
1797
+ return code < kNumOfWatchedStops;
1798
+ }
1799
+
1800
+
1801
+ bool Simulator::isEnabledStop(uint32_t code) {
1802
+ ASSERT(code <= kMaxStopCode);
1803
+ // Unwatched stops are always enabled.
1804
+ return !isWatchedStop(code) ||
1805
+ !(watched_stops[code].count & kStopDisabledBit);
1806
+ }
1807
+
1808
+
1809
+ void Simulator::EnableStop(uint32_t code) {
1810
+ ASSERT(isWatchedStop(code));
1811
+ if (!isEnabledStop(code)) {
1812
+ watched_stops[code].count &= ~kStopDisabledBit;
1813
+ }
1814
+ }
1815
+
1816
+
1817
+ void Simulator::DisableStop(uint32_t code) {
1818
+ ASSERT(isWatchedStop(code));
1819
+ if (isEnabledStop(code)) {
1820
+ watched_stops[code].count |= kStopDisabledBit;
1821
+ }
1822
+ }
1823
+
1824
+
1825
+ void Simulator::IncreaseStopCounter(uint32_t code) {
1826
+ ASSERT(code <= kMaxStopCode);
1827
+ ASSERT(isWatchedStop(code));
1828
+ if ((watched_stops[code].count & ~(1 << 31)) == 0x7fffffff) {
1829
+ PrintF("Stop counter for code %i has overflowed.\n"
1830
+ "Enabling this code and reseting the counter to 0.\n", code);
1831
+ watched_stops[code].count = 0;
1832
+ EnableStop(code);
1833
+ } else {
1834
+ watched_stops[code].count++;
1835
+ }
1836
+ }
1837
+
1838
+
1839
+ // Print a stop status.
1840
+ void Simulator::PrintStopInfo(uint32_t code) {
1841
+ ASSERT(code <= kMaxStopCode);
1842
+ if (!isWatchedStop(code)) {
1843
+ PrintF("Stop not watched.");
1844
+ } else {
1845
+ const char* state = isEnabledStop(code) ? "Enabled" : "Disabled";
1846
+ int32_t count = watched_stops[code].count & ~kStopDisabledBit;
1847
+ // Don't print the state of unused breakpoints.
1848
+ if (count != 0) {
1849
+ if (watched_stops[code].desc) {
1850
+ PrintF("stop %i - 0x%x: \t%s, \tcounter = %i, \t%s\n",
1851
+ code, code, state, count, watched_stops[code].desc);
1852
+ } else {
1853
+ PrintF("stop %i - 0x%x: \t%s, \tcounter = %i\n",
1854
+ code, code, state, count);
1855
+ }
1856
+ }
1857
+ }
1858
+ }
1859
+
1860
+
1861
+ // Handle execution based on instruction types.
1862
+
1863
+ // Instruction types 0 and 1 are both rolled into one function because they
1864
+ // only differ in the handling of the shifter_operand.
1865
+ void Simulator::DecodeType01(Instruction* instr) {
1866
+ int type = instr->TypeValue();
1867
+ if ((type == 0) && instr->IsSpecialType0()) {
1868
+ // multiply instruction or extra loads and stores
1869
+ if (instr->Bits(7, 4) == 9) {
1870
+ if (instr->Bit(24) == 0) {
1871
+ // Raw field decoding here. Multiply instructions have their Rd in
1872
+ // funny places.
1873
+ int rn = instr->RnValue();
1874
+ int rm = instr->RmValue();
1875
+ int rs = instr->RsValue();
1876
+ int32_t rs_val = get_register(rs);
1877
+ int32_t rm_val = get_register(rm);
1878
+ if (instr->Bit(23) == 0) {
1879
+ if (instr->Bit(21) == 0) {
1880
+ // The MUL instruction description (A 4.1.33) refers to Rd as being
1881
+ // the destination for the operation, but it confusingly uses the
1882
+ // Rn field to encode it.
1883
+ // Format(instr, "mul'cond's 'rn, 'rm, 'rs");
1884
+ int rd = rn; // Remap the rn field to the Rd register.
1885
+ int32_t alu_out = rm_val * rs_val;
1886
+ set_register(rd, alu_out);
1887
+ if (instr->HasS()) {
1888
+ SetNZFlags(alu_out);
1889
+ }
1890
+ } else {
1891
+ // The MLA instruction description (A 4.1.28) refers to the order
1892
+ // of registers as "Rd, Rm, Rs, Rn". But confusingly it uses the
1893
+ // Rn field to encode the Rd register and the Rd field to encode
1894
+ // the Rn register.
1895
+ Format(instr, "mla'cond's 'rn, 'rm, 'rs, 'rd");
1896
+ }
1897
+ } else {
1898
+ // The signed/long multiply instructions use the terms RdHi and RdLo
1899
+ // when referring to the target registers. They are mapped to the Rn
1900
+ // and Rd fields as follows:
1901
+ // RdLo == Rd
1902
+ // RdHi == Rn (This is confusingly stored in variable rd here
1903
+ // because the mul instruction from above uses the
1904
+ // Rn field to encode the Rd register. Good luck figuring
1905
+ // this out without reading the ARM instruction manual
1906
+ // at a very detailed level.)
1907
+ // Format(instr, "'um'al'cond's 'rd, 'rn, 'rs, 'rm");
1908
+ int rd_hi = rn; // Remap the rn field to the RdHi register.
1909
+ int rd_lo = instr->RdValue();
1910
+ int32_t hi_res = 0;
1911
+ int32_t lo_res = 0;
1912
+ if (instr->Bit(22) == 1) {
1913
+ int64_t left_op = static_cast<int32_t>(rm_val);
1914
+ int64_t right_op = static_cast<int32_t>(rs_val);
1915
+ uint64_t result = left_op * right_op;
1916
+ hi_res = static_cast<int32_t>(result >> 32);
1917
+ lo_res = static_cast<int32_t>(result & 0xffffffff);
1918
+ } else {
1919
+ // unsigned multiply
1920
+ uint64_t left_op = static_cast<uint32_t>(rm_val);
1921
+ uint64_t right_op = static_cast<uint32_t>(rs_val);
1922
+ uint64_t result = left_op * right_op;
1923
+ hi_res = static_cast<int32_t>(result >> 32);
1924
+ lo_res = static_cast<int32_t>(result & 0xffffffff);
1925
+ }
1926
+ set_register(rd_lo, lo_res);
1927
+ set_register(rd_hi, hi_res);
1928
+ if (instr->HasS()) {
1929
+ UNIMPLEMENTED();
1930
+ }
1931
+ }
1932
+ } else {
1933
+ UNIMPLEMENTED(); // Not used by V8.
1934
+ }
1935
+ } else {
1936
+ // extra load/store instructions
1937
+ int rd = instr->RdValue();
1938
+ int rn = instr->RnValue();
1939
+ int32_t rn_val = get_register(rn);
1940
+ int32_t addr = 0;
1941
+ if (instr->Bit(22) == 0) {
1942
+ int rm = instr->RmValue();
1943
+ int32_t rm_val = get_register(rm);
1944
+ switch (instr->PUField()) {
1945
+ case da_x: {
1946
+ // Format(instr, "'memop'cond'sign'h 'rd, ['rn], -'rm");
1947
+ ASSERT(!instr->HasW());
1948
+ addr = rn_val;
1949
+ rn_val -= rm_val;
1950
+ set_register(rn, rn_val);
1951
+ break;
1952
+ }
1953
+ case ia_x: {
1954
+ // Format(instr, "'memop'cond'sign'h 'rd, ['rn], +'rm");
1955
+ ASSERT(!instr->HasW());
1956
+ addr = rn_val;
1957
+ rn_val += rm_val;
1958
+ set_register(rn, rn_val);
1959
+ break;
1960
+ }
1961
+ case db_x: {
1962
+ // Format(instr, "'memop'cond'sign'h 'rd, ['rn, -'rm]'w");
1963
+ rn_val -= rm_val;
1964
+ addr = rn_val;
1965
+ if (instr->HasW()) {
1966
+ set_register(rn, rn_val);
1967
+ }
1968
+ break;
1969
+ }
1970
+ case ib_x: {
1971
+ // Format(instr, "'memop'cond'sign'h 'rd, ['rn, +'rm]'w");
1972
+ rn_val += rm_val;
1973
+ addr = rn_val;
1974
+ if (instr->HasW()) {
1975
+ set_register(rn, rn_val);
1976
+ }
1977
+ break;
1978
+ }
1979
+ default: {
1980
+ // The PU field is a 2-bit field.
1981
+ UNREACHABLE();
1982
+ break;
1983
+ }
1984
+ }
1985
+ } else {
1986
+ int32_t imm_val = (instr->ImmedHValue() << 4) | instr->ImmedLValue();
1987
+ switch (instr->PUField()) {
1988
+ case da_x: {
1989
+ // Format(instr, "'memop'cond'sign'h 'rd, ['rn], #-'off8");
1990
+ ASSERT(!instr->HasW());
1991
+ addr = rn_val;
1992
+ rn_val -= imm_val;
1993
+ set_register(rn, rn_val);
1994
+ break;
1995
+ }
1996
+ case ia_x: {
1997
+ // Format(instr, "'memop'cond'sign'h 'rd, ['rn], #+'off8");
1998
+ ASSERT(!instr->HasW());
1999
+ addr = rn_val;
2000
+ rn_val += imm_val;
2001
+ set_register(rn, rn_val);
2002
+ break;
2003
+ }
2004
+ case db_x: {
2005
+ // Format(instr, "'memop'cond'sign'h 'rd, ['rn, #-'off8]'w");
2006
+ rn_val -= imm_val;
2007
+ addr = rn_val;
2008
+ if (instr->HasW()) {
2009
+ set_register(rn, rn_val);
2010
+ }
2011
+ break;
2012
+ }
2013
+ case ib_x: {
2014
+ // Format(instr, "'memop'cond'sign'h 'rd, ['rn, #+'off8]'w");
2015
+ rn_val += imm_val;
2016
+ addr = rn_val;
2017
+ if (instr->HasW()) {
2018
+ set_register(rn, rn_val);
2019
+ }
2020
+ break;
2021
+ }
2022
+ default: {
2023
+ // The PU field is a 2-bit field.
2024
+ UNREACHABLE();
2025
+ break;
2026
+ }
2027
+ }
2028
+ }
2029
+ if (((instr->Bits(7, 4) & 0xd) == 0xd) && (instr->Bit(20) == 0)) {
2030
+ ASSERT((rd % 2) == 0);
2031
+ if (instr->HasH()) {
2032
+ // The strd instruction.
2033
+ int32_t value1 = get_register(rd);
2034
+ int32_t value2 = get_register(rd+1);
2035
+ WriteDW(addr, value1, value2);
2036
+ } else {
2037
+ // The ldrd instruction.
2038
+ int* rn_data = ReadDW(addr);
2039
+ set_dw_register(rd, rn_data);
2040
+ }
2041
+ } else if (instr->HasH()) {
2042
+ if (instr->HasSign()) {
2043
+ if (instr->HasL()) {
2044
+ int16_t val = ReadH(addr, instr);
2045
+ set_register(rd, val);
2046
+ } else {
2047
+ int16_t val = get_register(rd);
2048
+ WriteH(addr, val, instr);
2049
+ }
2050
+ } else {
2051
+ if (instr->HasL()) {
2052
+ uint16_t val = ReadHU(addr, instr);
2053
+ set_register(rd, val);
2054
+ } else {
2055
+ uint16_t val = get_register(rd);
2056
+ WriteH(addr, val, instr);
2057
+ }
2058
+ }
2059
+ } else {
2060
+ // signed byte loads
2061
+ ASSERT(instr->HasSign());
2062
+ ASSERT(instr->HasL());
2063
+ int8_t val = ReadB(addr);
2064
+ set_register(rd, val);
2065
+ }
2066
+ return;
2067
+ }
2068
+ } else if ((type == 0) && instr->IsMiscType0()) {
2069
+ if (instr->Bits(22, 21) == 1) {
2070
+ int rm = instr->RmValue();
2071
+ switch (instr->BitField(7, 4)) {
2072
+ case BX:
2073
+ set_pc(get_register(rm));
2074
+ break;
2075
+ case BLX: {
2076
+ uint32_t old_pc = get_pc();
2077
+ set_pc(get_register(rm));
2078
+ set_register(lr, old_pc + Instruction::kInstrSize);
2079
+ break;
2080
+ }
2081
+ case BKPT: {
2082
+ ArmDebugger dbg(this);
2083
+ PrintF("Simulator hit BKPT.\n");
2084
+ dbg.Debug();
2085
+ break;
2086
+ }
2087
+ default:
2088
+ UNIMPLEMENTED();
2089
+ }
2090
+ } else if (instr->Bits(22, 21) == 3) {
2091
+ int rm = instr->RmValue();
2092
+ int rd = instr->RdValue();
2093
+ switch (instr->BitField(7, 4)) {
2094
+ case CLZ: {
2095
+ uint32_t bits = get_register(rm);
2096
+ int leading_zeros = 0;
2097
+ if (bits == 0) {
2098
+ leading_zeros = 32;
2099
+ } else {
2100
+ while ((bits & 0x80000000u) == 0) {
2101
+ bits <<= 1;
2102
+ leading_zeros++;
2103
+ }
2104
+ }
2105
+ set_register(rd, leading_zeros);
2106
+ break;
2107
+ }
2108
+ default:
2109
+ UNIMPLEMENTED();
2110
+ }
2111
+ } else {
2112
+ PrintF("%08x\n", instr->InstructionBits());
2113
+ UNIMPLEMENTED();
2114
+ }
2115
+ } else {
2116
+ int rd = instr->RdValue();
2117
+ int rn = instr->RnValue();
2118
+ int32_t rn_val = get_register(rn);
2119
+ int32_t shifter_operand = 0;
2120
+ bool shifter_carry_out = 0;
2121
+ if (type == 0) {
2122
+ shifter_operand = GetShiftRm(instr, &shifter_carry_out);
2123
+ } else {
2124
+ ASSERT(instr->TypeValue() == 1);
2125
+ shifter_operand = GetImm(instr, &shifter_carry_out);
2126
+ }
2127
+ int32_t alu_out;
2128
+
2129
+ switch (instr->OpcodeField()) {
2130
+ case AND: {
2131
+ // Format(instr, "and'cond's 'rd, 'rn, 'shift_rm");
2132
+ // Format(instr, "and'cond's 'rd, 'rn, 'imm");
2133
+ alu_out = rn_val & shifter_operand;
2134
+ set_register(rd, alu_out);
2135
+ if (instr->HasS()) {
2136
+ SetNZFlags(alu_out);
2137
+ SetCFlag(shifter_carry_out);
2138
+ }
2139
+ break;
2140
+ }
2141
+
2142
+ case EOR: {
2143
+ // Format(instr, "eor'cond's 'rd, 'rn, 'shift_rm");
2144
+ // Format(instr, "eor'cond's 'rd, 'rn, 'imm");
2145
+ alu_out = rn_val ^ shifter_operand;
2146
+ set_register(rd, alu_out);
2147
+ if (instr->HasS()) {
2148
+ SetNZFlags(alu_out);
2149
+ SetCFlag(shifter_carry_out);
2150
+ }
2151
+ break;
2152
+ }
2153
+
2154
+ case SUB: {
2155
+ // Format(instr, "sub'cond's 'rd, 'rn, 'shift_rm");
2156
+ // Format(instr, "sub'cond's 'rd, 'rn, 'imm");
2157
+ alu_out = rn_val - shifter_operand;
2158
+ set_register(rd, alu_out);
2159
+ if (instr->HasS()) {
2160
+ SetNZFlags(alu_out);
2161
+ SetCFlag(!BorrowFrom(rn_val, shifter_operand));
2162
+ SetVFlag(OverflowFrom(alu_out, rn_val, shifter_operand, false));
2163
+ }
2164
+ break;
2165
+ }
2166
+
2167
+ case RSB: {
2168
+ // Format(instr, "rsb'cond's 'rd, 'rn, 'shift_rm");
2169
+ // Format(instr, "rsb'cond's 'rd, 'rn, 'imm");
2170
+ alu_out = shifter_operand - rn_val;
2171
+ set_register(rd, alu_out);
2172
+ if (instr->HasS()) {
2173
+ SetNZFlags(alu_out);
2174
+ SetCFlag(!BorrowFrom(shifter_operand, rn_val));
2175
+ SetVFlag(OverflowFrom(alu_out, shifter_operand, rn_val, false));
2176
+ }
2177
+ break;
2178
+ }
2179
+
2180
+ case ADD: {
2181
+ // Format(instr, "add'cond's 'rd, 'rn, 'shift_rm");
2182
+ // Format(instr, "add'cond's 'rd, 'rn, 'imm");
2183
+ alu_out = rn_val + shifter_operand;
2184
+ set_register(rd, alu_out);
2185
+ if (instr->HasS()) {
2186
+ SetNZFlags(alu_out);
2187
+ SetCFlag(CarryFrom(rn_val, shifter_operand));
2188
+ SetVFlag(OverflowFrom(alu_out, rn_val, shifter_operand, true));
2189
+ }
2190
+ break;
2191
+ }
2192
+
2193
+ case ADC: {
2194
+ Format(instr, "adc'cond's 'rd, 'rn, 'shift_rm");
2195
+ Format(instr, "adc'cond's 'rd, 'rn, 'imm");
2196
+ break;
2197
+ }
2198
+
2199
+ case SBC: {
2200
+ Format(instr, "sbc'cond's 'rd, 'rn, 'shift_rm");
2201
+ Format(instr, "sbc'cond's 'rd, 'rn, 'imm");
2202
+ break;
2203
+ }
2204
+
2205
+ case RSC: {
2206
+ Format(instr, "rsc'cond's 'rd, 'rn, 'shift_rm");
2207
+ Format(instr, "rsc'cond's 'rd, 'rn, 'imm");
2208
+ break;
2209
+ }
2210
+
2211
+ case TST: {
2212
+ if (instr->HasS()) {
2213
+ // Format(instr, "tst'cond 'rn, 'shift_rm");
2214
+ // Format(instr, "tst'cond 'rn, 'imm");
2215
+ alu_out = rn_val & shifter_operand;
2216
+ SetNZFlags(alu_out);
2217
+ SetCFlag(shifter_carry_out);
2218
+ } else {
2219
+ // Format(instr, "movw'cond 'rd, 'imm").
2220
+ alu_out = instr->ImmedMovwMovtValue();
2221
+ set_register(rd, alu_out);
2222
+ }
2223
+ break;
2224
+ }
2225
+
2226
+ case TEQ: {
2227
+ if (instr->HasS()) {
2228
+ // Format(instr, "teq'cond 'rn, 'shift_rm");
2229
+ // Format(instr, "teq'cond 'rn, 'imm");
2230
+ alu_out = rn_val ^ shifter_operand;
2231
+ SetNZFlags(alu_out);
2232
+ SetCFlag(shifter_carry_out);
2233
+ } else {
2234
+ // Other instructions matching this pattern are handled in the
2235
+ // miscellaneous instructions part above.
2236
+ UNREACHABLE();
2237
+ }
2238
+ break;
2239
+ }
2240
+
2241
+ case CMP: {
2242
+ if (instr->HasS()) {
2243
+ // Format(instr, "cmp'cond 'rn, 'shift_rm");
2244
+ // Format(instr, "cmp'cond 'rn, 'imm");
2245
+ alu_out = rn_val - shifter_operand;
2246
+ SetNZFlags(alu_out);
2247
+ SetCFlag(!BorrowFrom(rn_val, shifter_operand));
2248
+ SetVFlag(OverflowFrom(alu_out, rn_val, shifter_operand, false));
2249
+ } else {
2250
+ // Format(instr, "movt'cond 'rd, 'imm").
2251
+ alu_out = (get_register(rd) & 0xffff) |
2252
+ (instr->ImmedMovwMovtValue() << 16);
2253
+ set_register(rd, alu_out);
2254
+ }
2255
+ break;
2256
+ }
2257
+
2258
+ case CMN: {
2259
+ if (instr->HasS()) {
2260
+ // Format(instr, "cmn'cond 'rn, 'shift_rm");
2261
+ // Format(instr, "cmn'cond 'rn, 'imm");
2262
+ alu_out = rn_val + shifter_operand;
2263
+ SetNZFlags(alu_out);
2264
+ SetCFlag(!CarryFrom(rn_val, shifter_operand));
2265
+ SetVFlag(OverflowFrom(alu_out, rn_val, shifter_operand, true));
2266
+ } else {
2267
+ // Other instructions matching this pattern are handled in the
2268
+ // miscellaneous instructions part above.
2269
+ UNREACHABLE();
2270
+ }
2271
+ break;
2272
+ }
2273
+
2274
+ case ORR: {
2275
+ // Format(instr, "orr'cond's 'rd, 'rn, 'shift_rm");
2276
+ // Format(instr, "orr'cond's 'rd, 'rn, 'imm");
2277
+ alu_out = rn_val | shifter_operand;
2278
+ set_register(rd, alu_out);
2279
+ if (instr->HasS()) {
2280
+ SetNZFlags(alu_out);
2281
+ SetCFlag(shifter_carry_out);
2282
+ }
2283
+ break;
2284
+ }
2285
+
2286
+ case MOV: {
2287
+ // Format(instr, "mov'cond's 'rd, 'shift_rm");
2288
+ // Format(instr, "mov'cond's 'rd, 'imm");
2289
+ alu_out = shifter_operand;
2290
+ set_register(rd, alu_out);
2291
+ if (instr->HasS()) {
2292
+ SetNZFlags(alu_out);
2293
+ SetCFlag(shifter_carry_out);
2294
+ }
2295
+ break;
2296
+ }
2297
+
2298
+ case BIC: {
2299
+ // Format(instr, "bic'cond's 'rd, 'rn, 'shift_rm");
2300
+ // Format(instr, "bic'cond's 'rd, 'rn, 'imm");
2301
+ alu_out = rn_val & ~shifter_operand;
2302
+ set_register(rd, alu_out);
2303
+ if (instr->HasS()) {
2304
+ SetNZFlags(alu_out);
2305
+ SetCFlag(shifter_carry_out);
2306
+ }
2307
+ break;
2308
+ }
2309
+
2310
+ case MVN: {
2311
+ // Format(instr, "mvn'cond's 'rd, 'shift_rm");
2312
+ // Format(instr, "mvn'cond's 'rd, 'imm");
2313
+ alu_out = ~shifter_operand;
2314
+ set_register(rd, alu_out);
2315
+ if (instr->HasS()) {
2316
+ SetNZFlags(alu_out);
2317
+ SetCFlag(shifter_carry_out);
2318
+ }
2319
+ break;
2320
+ }
2321
+
2322
+ default: {
2323
+ UNREACHABLE();
2324
+ break;
2325
+ }
2326
+ }
2327
+ }
2328
+ }
2329
+
2330
+
2331
+ void Simulator::DecodeType2(Instruction* instr) {
2332
+ int rd = instr->RdValue();
2333
+ int rn = instr->RnValue();
2334
+ int32_t rn_val = get_register(rn);
2335
+ int32_t im_val = instr->Offset12Value();
2336
+ int32_t addr = 0;
2337
+ switch (instr->PUField()) {
2338
+ case da_x: {
2339
+ // Format(instr, "'memop'cond'b 'rd, ['rn], #-'off12");
2340
+ ASSERT(!instr->HasW());
2341
+ addr = rn_val;
2342
+ rn_val -= im_val;
2343
+ set_register(rn, rn_val);
2344
+ break;
2345
+ }
2346
+ case ia_x: {
2347
+ // Format(instr, "'memop'cond'b 'rd, ['rn], #+'off12");
2348
+ ASSERT(!instr->HasW());
2349
+ addr = rn_val;
2350
+ rn_val += im_val;
2351
+ set_register(rn, rn_val);
2352
+ break;
2353
+ }
2354
+ case db_x: {
2355
+ // Format(instr, "'memop'cond'b 'rd, ['rn, #-'off12]'w");
2356
+ rn_val -= im_val;
2357
+ addr = rn_val;
2358
+ if (instr->HasW()) {
2359
+ set_register(rn, rn_val);
2360
+ }
2361
+ break;
2362
+ }
2363
+ case ib_x: {
2364
+ // Format(instr, "'memop'cond'b 'rd, ['rn, #+'off12]'w");
2365
+ rn_val += im_val;
2366
+ addr = rn_val;
2367
+ if (instr->HasW()) {
2368
+ set_register(rn, rn_val);
2369
+ }
2370
+ break;
2371
+ }
2372
+ default: {
2373
+ UNREACHABLE();
2374
+ break;
2375
+ }
2376
+ }
2377
+ if (instr->HasB()) {
2378
+ if (instr->HasL()) {
2379
+ byte val = ReadBU(addr);
2380
+ set_register(rd, val);
2381
+ } else {
2382
+ byte val = get_register(rd);
2383
+ WriteB(addr, val);
2384
+ }
2385
+ } else {
2386
+ if (instr->HasL()) {
2387
+ set_register(rd, ReadW(addr, instr));
2388
+ } else {
2389
+ WriteW(addr, get_register(rd), instr);
2390
+ }
2391
+ }
2392
+ }
2393
+
2394
+
2395
+ void Simulator::DecodeType3(Instruction* instr) {
2396
+ int rd = instr->RdValue();
2397
+ int rn = instr->RnValue();
2398
+ int32_t rn_val = get_register(rn);
2399
+ bool shifter_carry_out = 0;
2400
+ int32_t shifter_operand = GetShiftRm(instr, &shifter_carry_out);
2401
+ int32_t addr = 0;
2402
+ switch (instr->PUField()) {
2403
+ case da_x: {
2404
+ ASSERT(!instr->HasW());
2405
+ Format(instr, "'memop'cond'b 'rd, ['rn], -'shift_rm");
2406
+ UNIMPLEMENTED();
2407
+ break;
2408
+ }
2409
+ case ia_x: {
2410
+ if (instr->HasW()) {
2411
+ ASSERT(instr->Bits(5, 4) == 0x1);
2412
+
2413
+ if (instr->Bit(22) == 0x1) { // USAT.
2414
+ int32_t sat_pos = instr->Bits(20, 16);
2415
+ int32_t sat_val = (1 << sat_pos) - 1;
2416
+ int32_t shift = instr->Bits(11, 7);
2417
+ int32_t shift_type = instr->Bit(6);
2418
+ int32_t rm_val = get_register(instr->RmValue());
2419
+ if (shift_type == 0) { // LSL
2420
+ rm_val <<= shift;
2421
+ } else { // ASR
2422
+ rm_val >>= shift;
2423
+ }
2424
+ // If saturation occurs, the Q flag should be set in the CPSR.
2425
+ // There is no Q flag yet, and no instruction (MRS) to read the
2426
+ // CPSR directly.
2427
+ if (rm_val > sat_val) {
2428
+ rm_val = sat_val;
2429
+ } else if (rm_val < 0) {
2430
+ rm_val = 0;
2431
+ }
2432
+ set_register(rd, rm_val);
2433
+ } else { // SSAT.
2434
+ UNIMPLEMENTED();
2435
+ }
2436
+ return;
2437
+ } else {
2438
+ Format(instr, "'memop'cond'b 'rd, ['rn], +'shift_rm");
2439
+ UNIMPLEMENTED();
2440
+ }
2441
+ break;
2442
+ }
2443
+ case db_x: {
2444
+ // Format(instr, "'memop'cond'b 'rd, ['rn, -'shift_rm]'w");
2445
+ addr = rn_val - shifter_operand;
2446
+ if (instr->HasW()) {
2447
+ set_register(rn, addr);
2448
+ }
2449
+ break;
2450
+ }
2451
+ case ib_x: {
2452
+ if (instr->HasW() && (instr->Bits(6, 4) == 0x5)) {
2453
+ uint32_t widthminus1 = static_cast<uint32_t>(instr->Bits(20, 16));
2454
+ uint32_t lsbit = static_cast<uint32_t>(instr->Bits(11, 7));
2455
+ uint32_t msbit = widthminus1 + lsbit;
2456
+ if (msbit <= 31) {
2457
+ if (instr->Bit(22)) {
2458
+ // ubfx - unsigned bitfield extract.
2459
+ uint32_t rm_val =
2460
+ static_cast<uint32_t>(get_register(instr->RmValue()));
2461
+ uint32_t extr_val = rm_val << (31 - msbit);
2462
+ extr_val = extr_val >> (31 - widthminus1);
2463
+ set_register(instr->RdValue(), extr_val);
2464
+ } else {
2465
+ // sbfx - signed bitfield extract.
2466
+ int32_t rm_val = get_register(instr->RmValue());
2467
+ int32_t extr_val = rm_val << (31 - msbit);
2468
+ extr_val = extr_val >> (31 - widthminus1);
2469
+ set_register(instr->RdValue(), extr_val);
2470
+ }
2471
+ } else {
2472
+ UNREACHABLE();
2473
+ }
2474
+ return;
2475
+ } else if (!instr->HasW() && (instr->Bits(6, 4) == 0x1)) {
2476
+ uint32_t lsbit = static_cast<uint32_t>(instr->Bits(11, 7));
2477
+ uint32_t msbit = static_cast<uint32_t>(instr->Bits(20, 16));
2478
+ if (msbit >= lsbit) {
2479
+ // bfc or bfi - bitfield clear/insert.
2480
+ uint32_t rd_val =
2481
+ static_cast<uint32_t>(get_register(instr->RdValue()));
2482
+ uint32_t bitcount = msbit - lsbit + 1;
2483
+ uint32_t mask = (1 << bitcount) - 1;
2484
+ rd_val &= ~(mask << lsbit);
2485
+ if (instr->RmValue() != 15) {
2486
+ // bfi - bitfield insert.
2487
+ uint32_t rm_val =
2488
+ static_cast<uint32_t>(get_register(instr->RmValue()));
2489
+ rm_val &= mask;
2490
+ rd_val |= rm_val << lsbit;
2491
+ }
2492
+ set_register(instr->RdValue(), rd_val);
2493
+ } else {
2494
+ UNREACHABLE();
2495
+ }
2496
+ return;
2497
+ } else {
2498
+ // Format(instr, "'memop'cond'b 'rd, ['rn, +'shift_rm]'w");
2499
+ addr = rn_val + shifter_operand;
2500
+ if (instr->HasW()) {
2501
+ set_register(rn, addr);
2502
+ }
2503
+ }
2504
+ break;
2505
+ }
2506
+ default: {
2507
+ UNREACHABLE();
2508
+ break;
2509
+ }
2510
+ }
2511
+ if (instr->HasB()) {
2512
+ if (instr->HasL()) {
2513
+ uint8_t byte = ReadB(addr);
2514
+ set_register(rd, byte);
2515
+ } else {
2516
+ uint8_t byte = get_register(rd);
2517
+ WriteB(addr, byte);
2518
+ }
2519
+ } else {
2520
+ if (instr->HasL()) {
2521
+ set_register(rd, ReadW(addr, instr));
2522
+ } else {
2523
+ WriteW(addr, get_register(rd), instr);
2524
+ }
2525
+ }
2526
+ }
2527
+
2528
+
2529
+ void Simulator::DecodeType4(Instruction* instr) {
2530
+ ASSERT(instr->Bit(22) == 0); // only allowed to be set in privileged mode
2531
+ if (instr->HasL()) {
2532
+ // Format(instr, "ldm'cond'pu 'rn'w, 'rlist");
2533
+ HandleRList(instr, true);
2534
+ } else {
2535
+ // Format(instr, "stm'cond'pu 'rn'w, 'rlist");
2536
+ HandleRList(instr, false);
2537
+ }
2538
+ }
2539
+
2540
+
2541
+ void Simulator::DecodeType5(Instruction* instr) {
2542
+ // Format(instr, "b'l'cond 'target");
2543
+ int off = (instr->SImmed24Value() << 2);
2544
+ intptr_t pc_address = get_pc();
2545
+ if (instr->HasLink()) {
2546
+ set_register(lr, pc_address + Instruction::kInstrSize);
2547
+ }
2548
+ int pc_reg = get_register(pc);
2549
+ set_pc(pc_reg + off);
2550
+ }
2551
+
2552
+
2553
+ void Simulator::DecodeType6(Instruction* instr) {
2554
+ DecodeType6CoprocessorIns(instr);
2555
+ }
2556
+
2557
+
2558
+ void Simulator::DecodeType7(Instruction* instr) {
2559
+ if (instr->Bit(24) == 1) {
2560
+ SoftwareInterrupt(instr);
2561
+ } else {
2562
+ DecodeTypeVFP(instr);
2563
+ }
2564
+ }
2565
+
2566
+
2567
+ // void Simulator::DecodeTypeVFP(Instruction* instr)
2568
+ // The Following ARMv7 VFPv instructions are currently supported.
2569
+ // vmov :Sn = Rt
2570
+ // vmov :Rt = Sn
2571
+ // vcvt: Dd = Sm
2572
+ // vcvt: Sd = Dm
2573
+ // Dd = vabs(Dm)
2574
+ // Dd = vneg(Dm)
2575
+ // Dd = vadd(Dn, Dm)
2576
+ // Dd = vsub(Dn, Dm)
2577
+ // Dd = vmul(Dn, Dm)
2578
+ // Dd = vdiv(Dn, Dm)
2579
+ // vcmp(Dd, Dm)
2580
+ // vmrs
2581
+ // Dd = vsqrt(Dm)
2582
+ void Simulator::DecodeTypeVFP(Instruction* instr) {
2583
+ ASSERT((instr->TypeValue() == 7) && (instr->Bit(24) == 0x0) );
2584
+ ASSERT(instr->Bits(11, 9) == 0x5);
2585
+
2586
+ // Obtain double precision register codes.
2587
+ int vm = instr->VFPMRegValue(kDoublePrecision);
2588
+ int vd = instr->VFPDRegValue(kDoublePrecision);
2589
+ int vn = instr->VFPNRegValue(kDoublePrecision);
2590
+
2591
+ if (instr->Bit(4) == 0) {
2592
+ if (instr->Opc1Value() == 0x7) {
2593
+ // Other data processing instructions
2594
+ if ((instr->Opc2Value() == 0x0) && (instr->Opc3Value() == 0x1)) {
2595
+ // vmov register to register.
2596
+ if (instr->SzValue() == 0x1) {
2597
+ int m = instr->VFPMRegValue(kDoublePrecision);
2598
+ int d = instr->VFPDRegValue(kDoublePrecision);
2599
+ set_d_register_from_double(d, get_double_from_d_register(m));
2600
+ } else {
2601
+ int m = instr->VFPMRegValue(kSinglePrecision);
2602
+ int d = instr->VFPDRegValue(kSinglePrecision);
2603
+ set_s_register_from_float(d, get_float_from_s_register(m));
2604
+ }
2605
+ } else if ((instr->Opc2Value() == 0x0) && (instr->Opc3Value() == 0x3)) {
2606
+ // vabs
2607
+ double dm_value = get_double_from_d_register(vm);
2608
+ double dd_value = fabs(dm_value);
2609
+ set_d_register_from_double(vd, dd_value);
2610
+ } else if ((instr->Opc2Value() == 0x1) && (instr->Opc3Value() == 0x1)) {
2611
+ // vneg
2612
+ double dm_value = get_double_from_d_register(vm);
2613
+ double dd_value = -dm_value;
2614
+ set_d_register_from_double(vd, dd_value);
2615
+ } else if ((instr->Opc2Value() == 0x7) && (instr->Opc3Value() == 0x3)) {
2616
+ DecodeVCVTBetweenDoubleAndSingle(instr);
2617
+ } else if ((instr->Opc2Value() == 0x8) && (instr->Opc3Value() & 0x1)) {
2618
+ DecodeVCVTBetweenFloatingPointAndInteger(instr);
2619
+ } else if (((instr->Opc2Value() >> 1) == 0x6) &&
2620
+ (instr->Opc3Value() & 0x1)) {
2621
+ DecodeVCVTBetweenFloatingPointAndInteger(instr);
2622
+ } else if (((instr->Opc2Value() == 0x4) || (instr->Opc2Value() == 0x5)) &&
2623
+ (instr->Opc3Value() & 0x1)) {
2624
+ DecodeVCMP(instr);
2625
+ } else if (((instr->Opc2Value() == 0x1)) && (instr->Opc3Value() == 0x3)) {
2626
+ // vsqrt
2627
+ double dm_value = get_double_from_d_register(vm);
2628
+ double dd_value = sqrt(dm_value);
2629
+ set_d_register_from_double(vd, dd_value);
2630
+ } else if (instr->Opc3Value() == 0x0) {
2631
+ // vmov immediate.
2632
+ if (instr->SzValue() == 0x1) {
2633
+ set_d_register_from_double(vd, instr->DoubleImmedVmov());
2634
+ } else {
2635
+ UNREACHABLE(); // Not used by v8.
2636
+ }
2637
+ } else {
2638
+ UNREACHABLE(); // Not used by V8.
2639
+ }
2640
+ } else if (instr->Opc1Value() == 0x3) {
2641
+ if (instr->SzValue() != 0x1) {
2642
+ UNREACHABLE(); // Not used by V8.
2643
+ }
2644
+
2645
+ if (instr->Opc3Value() & 0x1) {
2646
+ // vsub
2647
+ double dn_value = get_double_from_d_register(vn);
2648
+ double dm_value = get_double_from_d_register(vm);
2649
+ double dd_value = dn_value - dm_value;
2650
+ set_d_register_from_double(vd, dd_value);
2651
+ } else {
2652
+ // vadd
2653
+ double dn_value = get_double_from_d_register(vn);
2654
+ double dm_value = get_double_from_d_register(vm);
2655
+ double dd_value = dn_value + dm_value;
2656
+ set_d_register_from_double(vd, dd_value);
2657
+ }
2658
+ } else if ((instr->Opc1Value() == 0x2) && !(instr->Opc3Value() & 0x1)) {
2659
+ // vmul
2660
+ if (instr->SzValue() != 0x1) {
2661
+ UNREACHABLE(); // Not used by V8.
2662
+ }
2663
+
2664
+ double dn_value = get_double_from_d_register(vn);
2665
+ double dm_value = get_double_from_d_register(vm);
2666
+ double dd_value = dn_value * dm_value;
2667
+ set_d_register_from_double(vd, dd_value);
2668
+ } else if ((instr->Opc1Value() == 0x4) && !(instr->Opc3Value() & 0x1)) {
2669
+ // vdiv
2670
+ if (instr->SzValue() != 0x1) {
2671
+ UNREACHABLE(); // Not used by V8.
2672
+ }
2673
+
2674
+ double dn_value = get_double_from_d_register(vn);
2675
+ double dm_value = get_double_from_d_register(vm);
2676
+ double dd_value = dn_value / dm_value;
2677
+ div_zero_vfp_flag_ = (dm_value == 0);
2678
+ set_d_register_from_double(vd, dd_value);
2679
+ } else {
2680
+ UNIMPLEMENTED(); // Not used by V8.
2681
+ }
2682
+ } else {
2683
+ if ((instr->VCValue() == 0x0) &&
2684
+ (instr->VAValue() == 0x0)) {
2685
+ DecodeVMOVBetweenCoreAndSinglePrecisionRegisters(instr);
2686
+ } else if ((instr->VLValue() == 0x1) &&
2687
+ (instr->VCValue() == 0x0) &&
2688
+ (instr->VAValue() == 0x7) &&
2689
+ (instr->Bits(19, 16) == 0x1)) {
2690
+ // vmrs
2691
+ uint32_t rt = instr->RtValue();
2692
+ if (rt == 0xF) {
2693
+ Copy_FPSCR_to_APSR();
2694
+ } else {
2695
+ // Emulate FPSCR from the Simulator flags.
2696
+ uint32_t fpscr = (n_flag_FPSCR_ << 31) |
2697
+ (z_flag_FPSCR_ << 30) |
2698
+ (c_flag_FPSCR_ << 29) |
2699
+ (v_flag_FPSCR_ << 28) |
2700
+ (inexact_vfp_flag_ << 4) |
2701
+ (underflow_vfp_flag_ << 3) |
2702
+ (overflow_vfp_flag_ << 2) |
2703
+ (div_zero_vfp_flag_ << 1) |
2704
+ (inv_op_vfp_flag_ << 0) |
2705
+ (FPSCR_rounding_mode_);
2706
+ set_register(rt, fpscr);
2707
+ }
2708
+ } else if ((instr->VLValue() == 0x0) &&
2709
+ (instr->VCValue() == 0x0) &&
2710
+ (instr->VAValue() == 0x7) &&
2711
+ (instr->Bits(19, 16) == 0x1)) {
2712
+ // vmsr
2713
+ uint32_t rt = instr->RtValue();
2714
+ if (rt == pc) {
2715
+ UNREACHABLE();
2716
+ } else {
2717
+ uint32_t rt_value = get_register(rt);
2718
+ n_flag_FPSCR_ = (rt_value >> 31) & 1;
2719
+ z_flag_FPSCR_ = (rt_value >> 30) & 1;
2720
+ c_flag_FPSCR_ = (rt_value >> 29) & 1;
2721
+ v_flag_FPSCR_ = (rt_value >> 28) & 1;
2722
+ inexact_vfp_flag_ = (rt_value >> 4) & 1;
2723
+ underflow_vfp_flag_ = (rt_value >> 3) & 1;
2724
+ overflow_vfp_flag_ = (rt_value >> 2) & 1;
2725
+ div_zero_vfp_flag_ = (rt_value >> 1) & 1;
2726
+ inv_op_vfp_flag_ = (rt_value >> 0) & 1;
2727
+ FPSCR_rounding_mode_ =
2728
+ static_cast<VFPRoundingMode>((rt_value) & kVFPRoundingModeMask);
2729
+ }
2730
+ } else {
2731
+ UNIMPLEMENTED(); // Not used by V8.
2732
+ }
2733
+ }
2734
+ }
2735
+
2736
+
2737
+ void Simulator::DecodeVMOVBetweenCoreAndSinglePrecisionRegisters(
2738
+ Instruction* instr) {
2739
+ ASSERT((instr->Bit(4) == 1) && (instr->VCValue() == 0x0) &&
2740
+ (instr->VAValue() == 0x0));
2741
+
2742
+ int t = instr->RtValue();
2743
+ int n = instr->VFPNRegValue(kSinglePrecision);
2744
+ bool to_arm_register = (instr->VLValue() == 0x1);
2745
+
2746
+ if (to_arm_register) {
2747
+ int32_t int_value = get_sinteger_from_s_register(n);
2748
+ set_register(t, int_value);
2749
+ } else {
2750
+ int32_t rs_val = get_register(t);
2751
+ set_s_register_from_sinteger(n, rs_val);
2752
+ }
2753
+ }
2754
+
2755
+
2756
+ void Simulator::DecodeVCMP(Instruction* instr) {
2757
+ ASSERT((instr->Bit(4) == 0) && (instr->Opc1Value() == 0x7));
2758
+ ASSERT(((instr->Opc2Value() == 0x4) || (instr->Opc2Value() == 0x5)) &&
2759
+ (instr->Opc3Value() & 0x1));
2760
+ // Comparison.
2761
+
2762
+ VFPRegPrecision precision = kSinglePrecision;
2763
+ if (instr->SzValue() == 1) {
2764
+ precision = kDoublePrecision;
2765
+ }
2766
+
2767
+ int d = instr->VFPDRegValue(precision);
2768
+ int m = 0;
2769
+ if (instr->Opc2Value() == 0x4) {
2770
+ m = instr->VFPMRegValue(precision);
2771
+ }
2772
+
2773
+ if (precision == kDoublePrecision) {
2774
+ double dd_value = get_double_from_d_register(d);
2775
+ double dm_value = 0.0;
2776
+ if (instr->Opc2Value() == 0x4) {
2777
+ dm_value = get_double_from_d_register(m);
2778
+ }
2779
+
2780
+ // Raise exceptions for quiet NaNs if necessary.
2781
+ if (instr->Bit(7) == 1) {
2782
+ if (isnan(dd_value)) {
2783
+ inv_op_vfp_flag_ = true;
2784
+ }
2785
+ }
2786
+
2787
+ Compute_FPSCR_Flags(dd_value, dm_value);
2788
+ } else {
2789
+ UNIMPLEMENTED(); // Not used by V8.
2790
+ }
2791
+ }
2792
+
2793
+
2794
+ void Simulator::DecodeVCVTBetweenDoubleAndSingle(Instruction* instr) {
2795
+ ASSERT((instr->Bit(4) == 0) && (instr->Opc1Value() == 0x7));
2796
+ ASSERT((instr->Opc2Value() == 0x7) && (instr->Opc3Value() == 0x3));
2797
+
2798
+ VFPRegPrecision dst_precision = kDoublePrecision;
2799
+ VFPRegPrecision src_precision = kSinglePrecision;
2800
+ if (instr->SzValue() == 1) {
2801
+ dst_precision = kSinglePrecision;
2802
+ src_precision = kDoublePrecision;
2803
+ }
2804
+
2805
+ int dst = instr->VFPDRegValue(dst_precision);
2806
+ int src = instr->VFPMRegValue(src_precision);
2807
+
2808
+ if (dst_precision == kSinglePrecision) {
2809
+ double val = get_double_from_d_register(src);
2810
+ set_s_register_from_float(dst, static_cast<float>(val));
2811
+ } else {
2812
+ float val = get_float_from_s_register(src);
2813
+ set_d_register_from_double(dst, static_cast<double>(val));
2814
+ }
2815
+ }
2816
+
2817
+ bool get_inv_op_vfp_flag(VFPRoundingMode mode,
2818
+ double val,
2819
+ bool unsigned_) {
2820
+ ASSERT((mode == RN) || (mode == RM) || (mode == RZ));
2821
+ double max_uint = static_cast<double>(0xffffffffu);
2822
+ double max_int = static_cast<double>(kMaxInt);
2823
+ double min_int = static_cast<double>(kMinInt);
2824
+
2825
+ // Check for NaN.
2826
+ if (val != val) {
2827
+ return true;
2828
+ }
2829
+
2830
+ // Check for overflow. This code works because 32bit integers can be
2831
+ // exactly represented by ieee-754 64bit floating-point values.
2832
+ switch (mode) {
2833
+ case RN:
2834
+ return unsigned_ ? (val >= (max_uint + 0.5)) ||
2835
+ (val < -0.5)
2836
+ : (val >= (max_int + 0.5)) ||
2837
+ (val < (min_int - 0.5));
2838
+
2839
+ case RM:
2840
+ return unsigned_ ? (val >= (max_uint + 1.0)) ||
2841
+ (val < 0)
2842
+ : (val >= (max_int + 1.0)) ||
2843
+ (val < min_int);
2844
+
2845
+ case RZ:
2846
+ return unsigned_ ? (val >= (max_uint + 1.0)) ||
2847
+ (val <= -1)
2848
+ : (val >= (max_int + 1.0)) ||
2849
+ (val <= (min_int - 1.0));
2850
+ default:
2851
+ UNREACHABLE();
2852
+ return true;
2853
+ }
2854
+ }
2855
+
2856
+
2857
+ // We call this function only if we had a vfp invalid exception.
2858
+ // It returns the correct saturated value.
2859
+ int VFPConversionSaturate(double val, bool unsigned_res) {
2860
+ if (val != val) {
2861
+ return 0;
2862
+ } else {
2863
+ if (unsigned_res) {
2864
+ return (val < 0) ? 0 : 0xffffffffu;
2865
+ } else {
2866
+ return (val < 0) ? kMinInt : kMaxInt;
2867
+ }
2868
+ }
2869
+ }
2870
+
2871
+
2872
+ void Simulator::DecodeVCVTBetweenFloatingPointAndInteger(Instruction* instr) {
2873
+ ASSERT((instr->Bit(4) == 0) && (instr->Opc1Value() == 0x7) &&
2874
+ (instr->Bits(27, 23) == 0x1D));
2875
+ ASSERT(((instr->Opc2Value() == 0x8) && (instr->Opc3Value() & 0x1)) ||
2876
+ (((instr->Opc2Value() >> 1) == 0x6) && (instr->Opc3Value() & 0x1)));
2877
+
2878
+ // Conversion between floating-point and integer.
2879
+ bool to_integer = (instr->Bit(18) == 1);
2880
+
2881
+ VFPRegPrecision src_precision = (instr->SzValue() == 1) ? kDoublePrecision
2882
+ : kSinglePrecision;
2883
+
2884
+ if (to_integer) {
2885
+ // We are playing with code close to the C++ standard's limits below,
2886
+ // hence the very simple code and heavy checks.
2887
+ //
2888
+ // Note:
2889
+ // C++ defines default type casting from floating point to integer as
2890
+ // (close to) rounding toward zero ("fractional part discarded").
2891
+
2892
+ int dst = instr->VFPDRegValue(kSinglePrecision);
2893
+ int src = instr->VFPMRegValue(src_precision);
2894
+
2895
+ // Bit 7 in vcvt instructions indicates if we should use the FPSCR rounding
2896
+ // mode or the default Round to Zero mode.
2897
+ VFPRoundingMode mode = (instr->Bit(7) != 1) ? FPSCR_rounding_mode_
2898
+ : RZ;
2899
+ ASSERT((mode == RM) || (mode == RZ) || (mode == RN));
2900
+
2901
+ bool unsigned_integer = (instr->Bit(16) == 0);
2902
+ bool double_precision = (src_precision == kDoublePrecision);
2903
+
2904
+ double val = double_precision ? get_double_from_d_register(src)
2905
+ : get_float_from_s_register(src);
2906
+
2907
+ int temp = unsigned_integer ? static_cast<uint32_t>(val)
2908
+ : static_cast<int32_t>(val);
2909
+
2910
+ inv_op_vfp_flag_ = get_inv_op_vfp_flag(mode, val, unsigned_integer);
2911
+
2912
+ double abs_diff =
2913
+ unsigned_integer ? fabs(val - static_cast<uint32_t>(temp))
2914
+ : fabs(val - temp);
2915
+
2916
+ inexact_vfp_flag_ = (abs_diff != 0);
2917
+
2918
+ if (inv_op_vfp_flag_) {
2919
+ temp = VFPConversionSaturate(val, unsigned_integer);
2920
+ } else {
2921
+ switch (mode) {
2922
+ case RN: {
2923
+ int val_sign = (val > 0) ? 1 : -1;
2924
+ if (abs_diff > 0.5) {
2925
+ temp += val_sign;
2926
+ } else if (abs_diff == 0.5) {
2927
+ // Round to even if exactly halfway.
2928
+ temp = ((temp % 2) == 0) ? temp : temp + val_sign;
2929
+ }
2930
+ break;
2931
+ }
2932
+
2933
+ case RM:
2934
+ temp = temp > val ? temp - 1 : temp;
2935
+ break;
2936
+
2937
+ case RZ:
2938
+ // Nothing to do.
2939
+ break;
2940
+
2941
+ default:
2942
+ UNREACHABLE();
2943
+ }
2944
+ }
2945
+
2946
+ // Update the destination register.
2947
+ set_s_register_from_sinteger(dst, temp);
2948
+
2949
+ } else {
2950
+ bool unsigned_integer = (instr->Bit(7) == 0);
2951
+
2952
+ int dst = instr->VFPDRegValue(src_precision);
2953
+ int src = instr->VFPMRegValue(kSinglePrecision);
2954
+
2955
+ int val = get_sinteger_from_s_register(src);
2956
+
2957
+ if (src_precision == kDoublePrecision) {
2958
+ if (unsigned_integer) {
2959
+ set_d_register_from_double(dst,
2960
+ static_cast<double>((uint32_t)val));
2961
+ } else {
2962
+ set_d_register_from_double(dst, static_cast<double>(val));
2963
+ }
2964
+ } else {
2965
+ if (unsigned_integer) {
2966
+ set_s_register_from_float(dst,
2967
+ static_cast<float>((uint32_t)val));
2968
+ } else {
2969
+ set_s_register_from_float(dst, static_cast<float>(val));
2970
+ }
2971
+ }
2972
+ }
2973
+ }
2974
+
2975
+
2976
+ // void Simulator::DecodeType6CoprocessorIns(Instruction* instr)
2977
+ // Decode Type 6 coprocessor instructions.
2978
+ // Dm = vmov(Rt, Rt2)
2979
+ // <Rt, Rt2> = vmov(Dm)
2980
+ // Ddst = MEM(Rbase + 4*offset).
2981
+ // MEM(Rbase + 4*offset) = Dsrc.
2982
+ void Simulator::DecodeType6CoprocessorIns(Instruction* instr) {
2983
+ ASSERT((instr->TypeValue() == 6));
2984
+
2985
+ if (instr->CoprocessorValue() == 0xA) {
2986
+ switch (instr->OpcodeValue()) {
2987
+ case 0x8:
2988
+ case 0xA:
2989
+ case 0xC:
2990
+ case 0xE: { // Load and store single precision float to memory.
2991
+ int rn = instr->RnValue();
2992
+ int vd = instr->VFPDRegValue(kSinglePrecision);
2993
+ int offset = instr->Immed8Value();
2994
+ if (!instr->HasU()) {
2995
+ offset = -offset;
2996
+ }
2997
+
2998
+ int32_t address = get_register(rn) + 4 * offset;
2999
+ if (instr->HasL()) {
3000
+ // Load double from memory: vldr.
3001
+ set_s_register_from_sinteger(vd, ReadW(address, instr));
3002
+ } else {
3003
+ // Store double to memory: vstr.
3004
+ WriteW(address, get_sinteger_from_s_register(vd), instr);
3005
+ }
3006
+ break;
3007
+ }
3008
+ case 0x4:
3009
+ case 0x5:
3010
+ case 0x6:
3011
+ case 0x7:
3012
+ case 0x9:
3013
+ case 0xB:
3014
+ // Load/store multiple single from memory: vldm/vstm.
3015
+ HandleVList(instr);
3016
+ break;
3017
+ default:
3018
+ UNIMPLEMENTED(); // Not used by V8.
3019
+ }
3020
+ } else if (instr->CoprocessorValue() == 0xB) {
3021
+ switch (instr->OpcodeValue()) {
3022
+ case 0x2:
3023
+ // Load and store double to two GP registers
3024
+ if (instr->Bits(7, 4) != 0x1) {
3025
+ UNIMPLEMENTED(); // Not used by V8.
3026
+ } else {
3027
+ int rt = instr->RtValue();
3028
+ int rn = instr->RnValue();
3029
+ int vm = instr->VmValue();
3030
+ if (instr->HasL()) {
3031
+ int32_t rt_int_value = get_sinteger_from_s_register(2*vm);
3032
+ int32_t rn_int_value = get_sinteger_from_s_register(2*vm+1);
3033
+
3034
+ set_register(rt, rt_int_value);
3035
+ set_register(rn, rn_int_value);
3036
+ } else {
3037
+ int32_t rs_val = get_register(rt);
3038
+ int32_t rn_val = get_register(rn);
3039
+
3040
+ set_s_register_from_sinteger(2*vm, rs_val);
3041
+ set_s_register_from_sinteger((2*vm+1), rn_val);
3042
+ }
3043
+ }
3044
+ break;
3045
+ case 0x8:
3046
+ case 0xC: { // Load and store double to memory.
3047
+ int rn = instr->RnValue();
3048
+ int vd = instr->VdValue();
3049
+ int offset = instr->Immed8Value();
3050
+ if (!instr->HasU()) {
3051
+ offset = -offset;
3052
+ }
3053
+ int32_t address = get_register(rn) + 4 * offset;
3054
+ if (instr->HasL()) {
3055
+ // Load double from memory: vldr.
3056
+ set_s_register_from_sinteger(2*vd, ReadW(address, instr));
3057
+ set_s_register_from_sinteger(2*vd + 1, ReadW(address + 4, instr));
3058
+ } else {
3059
+ // Store double to memory: vstr.
3060
+ WriteW(address, get_sinteger_from_s_register(2*vd), instr);
3061
+ WriteW(address + 4, get_sinteger_from_s_register(2*vd + 1), instr);
3062
+ }
3063
+ break;
3064
+ }
3065
+ case 0x4:
3066
+ case 0x5:
3067
+ case 0x9:
3068
+ // Load/store multiple double from memory: vldm/vstm.
3069
+ HandleVList(instr);
3070
+ break;
3071
+ default:
3072
+ UNIMPLEMENTED(); // Not used by V8.
3073
+ }
3074
+ } else {
3075
+ UNIMPLEMENTED(); // Not used by V8.
3076
+ }
3077
+ }
3078
+
3079
+
3080
+ // Executes the current instruction.
3081
+ void Simulator::InstructionDecode(Instruction* instr) {
3082
+ if (v8::internal::FLAG_check_icache) {
3083
+ CheckICache(isolate_->simulator_i_cache(), instr);
3084
+ }
3085
+ pc_modified_ = false;
3086
+ if (::v8::internal::FLAG_trace_sim) {
3087
+ disasm::NameConverter converter;
3088
+ disasm::Disassembler dasm(converter);
3089
+ // use a reasonably large buffer
3090
+ v8::internal::EmbeddedVector<char, 256> buffer;
3091
+ dasm.InstructionDecode(buffer,
3092
+ reinterpret_cast<byte*>(instr));
3093
+ PrintF(" 0x%08x %s\n", reinterpret_cast<intptr_t>(instr), buffer.start());
3094
+ }
3095
+ if (instr->ConditionField() == kSpecialCondition) {
3096
+ UNIMPLEMENTED();
3097
+ } else if (ConditionallyExecute(instr)) {
3098
+ switch (instr->TypeValue()) {
3099
+ case 0:
3100
+ case 1: {
3101
+ DecodeType01(instr);
3102
+ break;
3103
+ }
3104
+ case 2: {
3105
+ DecodeType2(instr);
3106
+ break;
3107
+ }
3108
+ case 3: {
3109
+ DecodeType3(instr);
3110
+ break;
3111
+ }
3112
+ case 4: {
3113
+ DecodeType4(instr);
3114
+ break;
3115
+ }
3116
+ case 5: {
3117
+ DecodeType5(instr);
3118
+ break;
3119
+ }
3120
+ case 6: {
3121
+ DecodeType6(instr);
3122
+ break;
3123
+ }
3124
+ case 7: {
3125
+ DecodeType7(instr);
3126
+ break;
3127
+ }
3128
+ default: {
3129
+ UNIMPLEMENTED();
3130
+ break;
3131
+ }
3132
+ }
3133
+ // If the instruction is a non taken conditional stop, we need to skip the
3134
+ // inlined message address.
3135
+ } else if (instr->IsStop()) {
3136
+ set_pc(get_pc() + 2 * Instruction::kInstrSize);
3137
+ }
3138
+ if (!pc_modified_) {
3139
+ set_register(pc, reinterpret_cast<int32_t>(instr)
3140
+ + Instruction::kInstrSize);
3141
+ }
3142
+ }
3143
+
3144
+
3145
+ void Simulator::Execute() {
3146
+ // Get the PC to simulate. Cannot use the accessor here as we need the
3147
+ // raw PC value and not the one used as input to arithmetic instructions.
3148
+ int program_counter = get_pc();
3149
+
3150
+ if (::v8::internal::FLAG_stop_sim_at == 0) {
3151
+ // Fast version of the dispatch loop without checking whether the simulator
3152
+ // should be stopping at a particular executed instruction.
3153
+ while (program_counter != end_sim_pc) {
3154
+ Instruction* instr = reinterpret_cast<Instruction*>(program_counter);
3155
+ icount_++;
3156
+ InstructionDecode(instr);
3157
+ program_counter = get_pc();
3158
+ }
3159
+ } else {
3160
+ // FLAG_stop_sim_at is at the non-default value. Stop in the debugger when
3161
+ // we reach the particular instuction count.
3162
+ while (program_counter != end_sim_pc) {
3163
+ Instruction* instr = reinterpret_cast<Instruction*>(program_counter);
3164
+ icount_++;
3165
+ if (icount_ == ::v8::internal::FLAG_stop_sim_at) {
3166
+ ArmDebugger dbg(this);
3167
+ dbg.Debug();
3168
+ } else {
3169
+ InstructionDecode(instr);
3170
+ }
3171
+ program_counter = get_pc();
3172
+ }
3173
+ }
3174
+ }
3175
+
3176
+
3177
+ int32_t Simulator::Call(byte* entry, int argument_count, ...) {
3178
+ va_list parameters;
3179
+ va_start(parameters, argument_count);
3180
+ // Setup arguments
3181
+
3182
+ // First four arguments passed in registers.
3183
+ ASSERT(argument_count >= 4);
3184
+ set_register(r0, va_arg(parameters, int32_t));
3185
+ set_register(r1, va_arg(parameters, int32_t));
3186
+ set_register(r2, va_arg(parameters, int32_t));
3187
+ set_register(r3, va_arg(parameters, int32_t));
3188
+
3189
+ // Remaining arguments passed on stack.
3190
+ int original_stack = get_register(sp);
3191
+ // Compute position of stack on entry to generated code.
3192
+ int entry_stack = (original_stack - (argument_count - 4) * sizeof(int32_t));
3193
+ if (OS::ActivationFrameAlignment() != 0) {
3194
+ entry_stack &= -OS::ActivationFrameAlignment();
3195
+ }
3196
+ // Store remaining arguments on stack, from low to high memory.
3197
+ intptr_t* stack_argument = reinterpret_cast<intptr_t*>(entry_stack);
3198
+ for (int i = 4; i < argument_count; i++) {
3199
+ stack_argument[i - 4] = va_arg(parameters, int32_t);
3200
+ }
3201
+ va_end(parameters);
3202
+ set_register(sp, entry_stack);
3203
+
3204
+ // Prepare to execute the code at entry
3205
+ set_register(pc, reinterpret_cast<int32_t>(entry));
3206
+ // Put down marker for end of simulation. The simulator will stop simulation
3207
+ // when the PC reaches this value. By saving the "end simulation" value into
3208
+ // the LR the simulation stops when returning to this call point.
3209
+ set_register(lr, end_sim_pc);
3210
+
3211
+ // Remember the values of callee-saved registers.
3212
+ // The code below assumes that r9 is not used as sb (static base) in
3213
+ // simulator code and therefore is regarded as a callee-saved register.
3214
+ int32_t r4_val = get_register(r4);
3215
+ int32_t r5_val = get_register(r5);
3216
+ int32_t r6_val = get_register(r6);
3217
+ int32_t r7_val = get_register(r7);
3218
+ int32_t r8_val = get_register(r8);
3219
+ int32_t r9_val = get_register(r9);
3220
+ int32_t r10_val = get_register(r10);
3221
+ int32_t r11_val = get_register(r11);
3222
+
3223
+ // Setup the callee-saved registers with a known value. To be able to check
3224
+ // that they are preserved properly across JS execution.
3225
+ int32_t callee_saved_value = icount_;
3226
+ set_register(r4, callee_saved_value);
3227
+ set_register(r5, callee_saved_value);
3228
+ set_register(r6, callee_saved_value);
3229
+ set_register(r7, callee_saved_value);
3230
+ set_register(r8, callee_saved_value);
3231
+ set_register(r9, callee_saved_value);
3232
+ set_register(r10, callee_saved_value);
3233
+ set_register(r11, callee_saved_value);
3234
+
3235
+ // Start the simulation
3236
+ Execute();
3237
+
3238
+ // Check that the callee-saved registers have been preserved.
3239
+ CHECK_EQ(callee_saved_value, get_register(r4));
3240
+ CHECK_EQ(callee_saved_value, get_register(r5));
3241
+ CHECK_EQ(callee_saved_value, get_register(r6));
3242
+ CHECK_EQ(callee_saved_value, get_register(r7));
3243
+ CHECK_EQ(callee_saved_value, get_register(r8));
3244
+ CHECK_EQ(callee_saved_value, get_register(r9));
3245
+ CHECK_EQ(callee_saved_value, get_register(r10));
3246
+ CHECK_EQ(callee_saved_value, get_register(r11));
3247
+
3248
+ // Restore callee-saved registers with the original value.
3249
+ set_register(r4, r4_val);
3250
+ set_register(r5, r5_val);
3251
+ set_register(r6, r6_val);
3252
+ set_register(r7, r7_val);
3253
+ set_register(r8, r8_val);
3254
+ set_register(r9, r9_val);
3255
+ set_register(r10, r10_val);
3256
+ set_register(r11, r11_val);
3257
+
3258
+ // Pop stack passed arguments.
3259
+ CHECK_EQ(entry_stack, get_register(sp));
3260
+ set_register(sp, original_stack);
3261
+
3262
+ int32_t result = get_register(r0);
3263
+ return result;
3264
+ }
3265
+
3266
+
3267
+ uintptr_t Simulator::PushAddress(uintptr_t address) {
3268
+ int new_sp = get_register(sp) - sizeof(uintptr_t);
3269
+ uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(new_sp);
3270
+ *stack_slot = address;
3271
+ set_register(sp, new_sp);
3272
+ return new_sp;
3273
+ }
3274
+
3275
+
3276
+ uintptr_t Simulator::PopAddress() {
3277
+ int current_sp = get_register(sp);
3278
+ uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp);
3279
+ uintptr_t address = *stack_slot;
3280
+ set_register(sp, current_sp + sizeof(uintptr_t));
3281
+ return address;
3282
+ }
3283
+
3284
+ } } // namespace v8::internal
3285
+
3286
+ #endif // USE_SIMULATOR
3287
+
3288
+ #endif // V8_TARGET_ARCH_ARM