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,250 @@
1
+ // Copyright 2006-2010 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
+
29
+ #ifndef V8_MIPS_REGEXP_MACRO_ASSEMBLER_MIPS_H_
30
+ #define V8_MIPS_REGEXP_MACRO_ASSEMBLER_MIPS_H_
31
+
32
+ namespace v8 {
33
+ namespace internal {
34
+
35
+ #ifdef V8_INTERPRETED_REGEXP
36
+ class RegExpMacroAssemblerMIPS: public RegExpMacroAssembler {
37
+ public:
38
+ RegExpMacroAssemblerMIPS();
39
+ virtual ~RegExpMacroAssemblerMIPS();
40
+ };
41
+ #else // V8_INTERPRETED_REGEXP
42
+ class RegExpMacroAssemblerMIPS: public NativeRegExpMacroAssembler {
43
+ public:
44
+ RegExpMacroAssemblerMIPS(Mode mode, int registers_to_save);
45
+ virtual ~RegExpMacroAssemblerMIPS();
46
+ virtual int stack_limit_slack();
47
+ virtual void AdvanceCurrentPosition(int by);
48
+ virtual void AdvanceRegister(int reg, int by);
49
+ virtual void Backtrack();
50
+ virtual void Bind(Label* label);
51
+ virtual void CheckAtStart(Label* on_at_start);
52
+ virtual void CheckCharacter(uint32_t c, Label* on_equal);
53
+ virtual void CheckCharacterAfterAnd(uint32_t c,
54
+ uint32_t mask,
55
+ Label* on_equal);
56
+ virtual void CheckCharacterGT(uc16 limit, Label* on_greater);
57
+ virtual void CheckCharacterLT(uc16 limit, Label* on_less);
58
+ virtual void CheckCharacters(Vector<const uc16> str,
59
+ int cp_offset,
60
+ Label* on_failure,
61
+ bool check_end_of_string);
62
+ // A "greedy loop" is a loop that is both greedy and with a simple
63
+ // body. It has a particularly simple implementation.
64
+ virtual void CheckGreedyLoop(Label* on_tos_equals_current_position);
65
+ virtual void CheckNotAtStart(Label* on_not_at_start);
66
+ virtual void CheckNotBackReference(int start_reg, Label* on_no_match);
67
+ virtual void CheckNotBackReferenceIgnoreCase(int start_reg,
68
+ Label* on_no_match);
69
+ virtual void CheckNotRegistersEqual(int reg1, int reg2, Label* on_not_equal);
70
+ virtual void CheckNotCharacter(uint32_t c, Label* on_not_equal);
71
+ virtual void CheckNotCharacterAfterAnd(uint32_t c,
72
+ uint32_t mask,
73
+ Label* on_not_equal);
74
+ virtual void CheckNotCharacterAfterMinusAnd(uc16 c,
75
+ uc16 minus,
76
+ uc16 mask,
77
+ Label* on_not_equal);
78
+ // Checks whether the given offset from the current position is before
79
+ // the end of the string.
80
+ virtual void CheckPosition(int cp_offset, Label* on_outside_input);
81
+ virtual bool CheckSpecialCharacterClass(uc16 type,
82
+ Label* on_no_match);
83
+ virtual void Fail();
84
+ virtual Handle<Object> GetCode(Handle<String> source);
85
+ virtual void GoTo(Label* label);
86
+ virtual void IfRegisterGE(int reg, int comparand, Label* if_ge);
87
+ virtual void IfRegisterLT(int reg, int comparand, Label* if_lt);
88
+ virtual void IfRegisterEqPos(int reg, Label* if_eq);
89
+ virtual IrregexpImplementation Implementation();
90
+ virtual void LoadCurrentCharacter(int cp_offset,
91
+ Label* on_end_of_input,
92
+ bool check_bounds = true,
93
+ int characters = 1);
94
+ virtual void PopCurrentPosition();
95
+ virtual void PopRegister(int register_index);
96
+ virtual void PushBacktrack(Label* label);
97
+ virtual void PushCurrentPosition();
98
+ virtual void PushRegister(int register_index,
99
+ StackCheckFlag check_stack_limit);
100
+ virtual void ReadCurrentPositionFromRegister(int reg);
101
+ virtual void ReadStackPointerFromRegister(int reg);
102
+ virtual void SetCurrentPositionFromEnd(int by);
103
+ virtual void SetRegister(int register_index, int to);
104
+ virtual void Succeed();
105
+ virtual void WriteCurrentPositionToRegister(int reg, int cp_offset);
106
+ virtual void ClearRegisters(int reg_from, int reg_to);
107
+ virtual void WriteStackPointerToRegister(int reg);
108
+
109
+ // Called from RegExp if the stack-guard is triggered.
110
+ // If the code object is relocated, the return address is fixed before
111
+ // returning.
112
+ static int CheckStackGuardState(Address* return_address,
113
+ Code* re_code,
114
+ Address re_frame);
115
+ private:
116
+ // Offsets from frame_pointer() of function parameters and stored registers.
117
+ static const int kFramePointer = 0;
118
+
119
+ // Above the frame pointer - Stored registers and stack passed parameters.
120
+ // Registers s0 to s7, fp, and ra.
121
+ static const int kStoredRegisters = kFramePointer;
122
+ // Return address (stored from link register, read into pc on return).
123
+ static const int kReturnAddress = kStoredRegisters + 9 * kPointerSize;
124
+ // Stack frame header.
125
+ static const int kStackFrameHeader = kReturnAddress + kPointerSize;
126
+ // Stack parameters placed by caller.
127
+ static const int kRegisterOutput = kStackFrameHeader + 16;
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
+ // Load a number of characters at the given offset from the
149
+ // current position, into the current-character register.
150
+ void LoadCurrentCharacterUnchecked(int cp_offset, int character_count);
151
+
152
+ // Check whether preemption has been requested.
153
+ void CheckPreemption();
154
+
155
+ // Check whether we are exceeding the stack limit on the backtrack stack.
156
+ void CheckStackLimit();
157
+
158
+
159
+ // Generate a call to CheckStackGuardState.
160
+ void CallCheckStackGuardState(Register scratch);
161
+
162
+ // The ebp-relative location of a regexp register.
163
+ MemOperand register_location(int register_index);
164
+
165
+ // Register holding the current input position as negative offset from
166
+ // the end of the string.
167
+ inline Register current_input_offset() { return t2; }
168
+
169
+ // The register containing the current character after LoadCurrentCharacter.
170
+ inline Register current_character() { return t3; }
171
+
172
+ // Register holding address of the end of the input string.
173
+ inline Register end_of_input_address() { return t6; }
174
+
175
+ // Register holding the frame address. Local variables, parameters and
176
+ // regexp registers are addressed relative to this.
177
+ inline Register frame_pointer() { return fp; }
178
+
179
+ // The register containing the backtrack stack top. Provides a meaningful
180
+ // name to the register.
181
+ inline Register backtrack_stackpointer() { return t4; }
182
+
183
+ // Register holding pointer to the current code object.
184
+ inline Register code_pointer() { return t1; }
185
+
186
+ // Byte size of chars in the string to match (decided by the Mode argument)
187
+ inline int char_size() { return static_cast<int>(mode_); }
188
+
189
+ // Equivalent to a conditional branch to the label, unless the label
190
+ // is NULL, in which case it is a conditional Backtrack.
191
+ void BranchOrBacktrack(Label* to,
192
+ Condition condition,
193
+ Register rs,
194
+ const Operand& rt);
195
+
196
+ // Call and return internally in the generated code in a way that
197
+ // is GC-safe (i.e., doesn't leave absolute code addresses on the stack)
198
+ inline void SafeCall(Label* to,
199
+ Condition cond,
200
+ Register rs,
201
+ const Operand& rt);
202
+ inline void SafeReturn();
203
+ inline void SafeCallTarget(Label* name);
204
+
205
+ // Pushes the value of a register on the backtrack stack. Decrements the
206
+ // stack pointer by a word size and stores the register's value there.
207
+ inline void Push(Register source);
208
+
209
+ // Pops a value from the backtrack stack. Reads the word at the stack pointer
210
+ // and increments it by a word size.
211
+ inline void Pop(Register target);
212
+
213
+ // Calls a C function and cleans up the frame alignment done by
214
+ // by FrameAlign. The called function *is* allowed to trigger a garbage
215
+ // collection, but may not take more than four arguments (no arguments
216
+ // passed on the stack), and the first argument will be a pointer to the
217
+ // return address.
218
+ inline void CallCFunctionUsingStub(ExternalReference function,
219
+ int num_arguments);
220
+
221
+
222
+ MacroAssembler* masm_;
223
+
224
+ // Which mode to generate code for (ASCII or UC16).
225
+ Mode mode_;
226
+
227
+ // One greater than maximal register index actually used.
228
+ int num_registers_;
229
+
230
+ // Number of registers to output at the end (the saved registers
231
+ // are always 0..num_saved_registers_-1)
232
+ int num_saved_registers_;
233
+
234
+ // Labels used internally.
235
+ Label entry_label_;
236
+ Label start_label_;
237
+ Label success_label_;
238
+ Label backtrack_label_;
239
+ Label exit_label_;
240
+ Label check_preempt_label_;
241
+ Label stack_overflow_label_;
242
+ };
243
+
244
+ #endif // V8_INTERPRETED_REGEXP
245
+
246
+
247
+ }} // namespace v8::internal
248
+
249
+ #endif // V8_MIPS_REGEXP_MACRO_ASSEMBLER_MIPS_H_
250
+
@@ -0,0 +1,134 @@
1
+ // Copyright 2010 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_IA32_REGISTER_ALLOCATOR_MIPS_INL_H_
29
+ #define V8_IA32_REGISTER_ALLOCATOR_MIPS_INL_H_
30
+
31
+ #include "v8.h"
32
+ #include "mips/assembler-mips.h"
33
+
34
+ namespace v8 {
35
+ namespace internal {
36
+
37
+ // -------------------------------------------------------------------------
38
+ // RegisterAllocator implementation.
39
+
40
+ bool RegisterAllocator::IsReserved(Register reg) {
41
+ // The code for this test relies on the order of register codes.
42
+ return reg.is(cp) || reg.is(s8_fp) || reg.is(sp);
43
+ }
44
+
45
+
46
+ int RegisterAllocator::ToNumber(Register reg) {
47
+ ASSERT(reg.is_valid() && !IsReserved(reg));
48
+ const int kNumbers[] = {
49
+ 0, // zero_reg
50
+ 1, // at
51
+ 2, // v0
52
+ 3, // v1
53
+ 4, // a0
54
+ 5, // a1
55
+ 6, // a2
56
+ 7, // a3
57
+ 8, // t0
58
+ 9, // t1
59
+ 10, // t2
60
+ 11, // t3
61
+ 12, // t4
62
+ 13, // t5
63
+ 14, // t
64
+ 15, // t7
65
+ 16, // t8
66
+ 17, // t9
67
+ 18, // s0
68
+ 19, // s1
69
+ 20, // s2
70
+ 21, // s3
71
+ 22, // s4
72
+ 23, // s5
73
+ 24, // s6
74
+ 25, // s7
75
+ 26, // k0
76
+ 27, // k1
77
+ 28, // gp
78
+ 29, // sp
79
+ 30, // s8_fp
80
+ 31, // ra
81
+ };
82
+ return kNumbers[reg.code()];
83
+ }
84
+
85
+
86
+ Register RegisterAllocator::ToRegister(int num) {
87
+ ASSERT(num >= 0 && num < kNumRegisters);
88
+ const Register kRegisters[] = {
89
+ zero_reg,
90
+ at,
91
+ v0,
92
+ v1,
93
+ a0,
94
+ a1,
95
+ a2,
96
+ a3,
97
+ t0,
98
+ t1,
99
+ t2,
100
+ t3,
101
+ t4,
102
+ t5,
103
+ t6,
104
+ t7,
105
+ s0,
106
+ s1,
107
+ s2,
108
+ s3,
109
+ s4,
110
+ s5,
111
+ s6,
112
+ s7,
113
+ t8,
114
+ t9,
115
+ k0,
116
+ k1,
117
+ gp,
118
+ sp,
119
+ s8_fp,
120
+ ra
121
+ };
122
+ return kRegisters[num];
123
+ }
124
+
125
+
126
+ void RegisterAllocator::Initialize() {
127
+ Reset();
128
+ }
129
+
130
+
131
+ } } // namespace v8::internal
132
+
133
+ #endif // V8_IA32_REGISTER_ALLOCATOR_MIPS_INL_H_
134
+
@@ -0,0 +1,47 @@
1
+ // Copyright 2010 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_MIPS_REGISTER_ALLOCATOR_MIPS_H_
29
+ #define V8_MIPS_REGISTER_ALLOCATOR_MIPS_H_
30
+
31
+ #include "mips/constants-mips.h"
32
+
33
+ namespace v8 {
34
+ namespace internal {
35
+
36
+ class RegisterAllocatorConstants : public AllStatic {
37
+ public:
38
+ // No registers are currently managed by the register allocator on MIPS.
39
+ static const int kNumRegisters = 0;
40
+ static const int kInvalidRegister = -1;
41
+ };
42
+
43
+
44
+ } } // namespace v8::internal
45
+
46
+ #endif // V8_MIPS_REGISTER_ALLOCATOR_MIPS_H_
47
+
@@ -0,0 +1,2438 @@
1
+ // Copyright 2010 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 <limits.h>
31
+ #include <cstdarg>
32
+ #include "v8.h"
33
+
34
+ #if defined(V8_TARGET_ARCH_MIPS)
35
+
36
+ #include "disasm.h"
37
+ #include "assembler.h"
38
+ #include "globals.h" // Need the BitCast
39
+ #include "mips/constants-mips.h"
40
+ #include "mips/simulator-mips.h"
41
+
42
+
43
+ // Only build the simulator if not compiling for real MIPS hardware.
44
+ #if defined(USE_SIMULATOR)
45
+
46
+ namespace v8 {
47
+ namespace internal {
48
+
49
+ // Utils functions
50
+ bool HaveSameSign(int32_t a, int32_t b) {
51
+ return ((a ^ b) >= 0);
52
+ }
53
+
54
+
55
+ uint32_t get_fcsr_condition_bit(uint32_t cc) {
56
+ if (cc == 0) {
57
+ return 23;
58
+ } else {
59
+ return 24 + cc;
60
+ }
61
+ }
62
+
63
+
64
+ // This macro provides a platform independent use of sscanf. The reason for
65
+ // SScanF not being implemented in a platform independent was through
66
+ // ::v8::internal::OS in the same way as SNPrintF is that the Windows C Run-Time
67
+ // Library does not provide vsscanf.
68
+ #define SScanF sscanf // NOLINT
69
+
70
+ // The MipsDebugger class is used by the simulator while debugging simulated
71
+ // code.
72
+ class MipsDebugger {
73
+ public:
74
+ explicit MipsDebugger(Simulator* sim);
75
+ ~MipsDebugger();
76
+
77
+ void Stop(Instruction* instr);
78
+ void Debug();
79
+ // Print all registers with a nice formatting.
80
+ void PrintAllRegs();
81
+ void PrintAllRegsIncludingFPU();
82
+
83
+ private:
84
+ // We set the breakpoint code to 0xfffff to easily recognize it.
85
+ static const Instr kBreakpointInstr = SPECIAL | BREAK | 0xfffff << 6;
86
+ static const Instr kNopInstr = 0x0;
87
+
88
+ Simulator* sim_;
89
+
90
+ int32_t GetRegisterValue(int regnum);
91
+ int32_t GetFPURegisterValueInt(int regnum);
92
+ int64_t GetFPURegisterValueLong(int regnum);
93
+ float GetFPURegisterValueFloat(int regnum);
94
+ double GetFPURegisterValueDouble(int regnum);
95
+ bool GetValue(const char* desc, int32_t* value);
96
+
97
+ // Set or delete a breakpoint. Returns true if successful.
98
+ bool SetBreakpoint(Instruction* breakpc);
99
+ bool DeleteBreakpoint(Instruction* breakpc);
100
+
101
+ // Undo and redo all breakpoints. This is needed to bracket disassembly and
102
+ // execution to skip past breakpoints when run from the debugger.
103
+ void UndoBreakpoints();
104
+ void RedoBreakpoints();
105
+ };
106
+
107
+ MipsDebugger::MipsDebugger(Simulator* sim) {
108
+ sim_ = sim;
109
+ }
110
+
111
+
112
+ MipsDebugger::~MipsDebugger() {
113
+ }
114
+
115
+
116
+ #ifdef GENERATED_CODE_COVERAGE
117
+ static FILE* coverage_log = NULL;
118
+
119
+
120
+ static void InitializeCoverage() {
121
+ char* file_name = getenv("V8_GENERATED_CODE_COVERAGE_LOG");
122
+ if (file_name != NULL) {
123
+ coverage_log = fopen(file_name, "aw+");
124
+ }
125
+ }
126
+
127
+
128
+ void MipsDebugger::Stop(Instruction* instr) {
129
+ UNIMPLEMENTED_MIPS();
130
+ char* str = reinterpret_cast<char*>(instr->InstructionBits());
131
+ if (strlen(str) > 0) {
132
+ if (coverage_log != NULL) {
133
+ fprintf(coverage_log, "%s\n", str);
134
+ fflush(coverage_log);
135
+ }
136
+ instr->SetInstructionBits(0x0); // Overwrite with nop.
137
+ }
138
+ sim_->set_pc(sim_->get_pc() + Instruction::kInstrSize);
139
+ }
140
+
141
+
142
+ #else // ndef GENERATED_CODE_COVERAGE
143
+
144
+ #define UNSUPPORTED() printf("Unsupported instruction.\n");
145
+
146
+ static void InitializeCoverage() {}
147
+
148
+
149
+ void MipsDebugger::Stop(Instruction* instr) {
150
+ const char* str = reinterpret_cast<char*>(instr->InstructionBits());
151
+ PrintF("Simulator hit %s\n", str);
152
+ sim_->set_pc(sim_->get_pc() + Instruction::kInstrSize);
153
+ Debug();
154
+ }
155
+ #endif // GENERATED_CODE_COVERAGE
156
+
157
+
158
+ int32_t MipsDebugger::GetRegisterValue(int regnum) {
159
+ if (regnum == kNumSimuRegisters) {
160
+ return sim_->get_pc();
161
+ } else {
162
+ return sim_->get_register(regnum);
163
+ }
164
+ }
165
+
166
+
167
+ int32_t MipsDebugger::GetFPURegisterValueInt(int regnum) {
168
+ if (regnum == kNumFPURegisters) {
169
+ return sim_->get_pc();
170
+ } else {
171
+ return sim_->get_fpu_register(regnum);
172
+ }
173
+ }
174
+
175
+
176
+ int64_t MipsDebugger::GetFPURegisterValueLong(int regnum) {
177
+ if (regnum == kNumFPURegisters) {
178
+ return sim_->get_pc();
179
+ } else {
180
+ return sim_->get_fpu_register_long(regnum);
181
+ }
182
+ }
183
+
184
+
185
+ float MipsDebugger::GetFPURegisterValueFloat(int regnum) {
186
+ if (regnum == kNumFPURegisters) {
187
+ return sim_->get_pc();
188
+ } else {
189
+ return sim_->get_fpu_register_float(regnum);
190
+ }
191
+ }
192
+
193
+
194
+ double MipsDebugger::GetFPURegisterValueDouble(int regnum) {
195
+ if (regnum == kNumFPURegisters) {
196
+ return sim_->get_pc();
197
+ } else {
198
+ return sim_->get_fpu_register_double(regnum);
199
+ }
200
+ }
201
+
202
+
203
+ bool MipsDebugger::GetValue(const char* desc, int32_t* value) {
204
+ int regnum = Registers::Number(desc);
205
+ int fpuregnum = FPURegisters::Number(desc);
206
+
207
+ if (regnum != kInvalidRegister) {
208
+ *value = GetRegisterValue(regnum);
209
+ return true;
210
+ } else if (fpuregnum != kInvalidFPURegister) {
211
+ *value = GetFPURegisterValueInt(fpuregnum);
212
+ return true;
213
+ } else if (strncmp(desc, "0x", 2) == 0) {
214
+ return SScanF(desc, "%x", reinterpret_cast<uint32_t*>(value)) == 1;
215
+ } else {
216
+ return SScanF(desc, "%i", value) == 1;
217
+ }
218
+ return false;
219
+ }
220
+
221
+
222
+ bool MipsDebugger::SetBreakpoint(Instruction* breakpc) {
223
+ // Check if a breakpoint can be set. If not return without any side-effects.
224
+ if (sim_->break_pc_ != NULL) {
225
+ return false;
226
+ }
227
+
228
+ // Set the breakpoint.
229
+ sim_->break_pc_ = breakpc;
230
+ sim_->break_instr_ = breakpc->InstructionBits();
231
+ // Not setting the breakpoint instruction in the code itself. It will be set
232
+ // when the debugger shell continues.
233
+ return true;
234
+ }
235
+
236
+
237
+ bool MipsDebugger::DeleteBreakpoint(Instruction* breakpc) {
238
+ if (sim_->break_pc_ != NULL) {
239
+ sim_->break_pc_->SetInstructionBits(sim_->break_instr_);
240
+ }
241
+
242
+ sim_->break_pc_ = NULL;
243
+ sim_->break_instr_ = 0;
244
+ return true;
245
+ }
246
+
247
+
248
+ void MipsDebugger::UndoBreakpoints() {
249
+ if (sim_->break_pc_ != NULL) {
250
+ sim_->break_pc_->SetInstructionBits(sim_->break_instr_);
251
+ }
252
+ }
253
+
254
+
255
+ void MipsDebugger::RedoBreakpoints() {
256
+ if (sim_->break_pc_ != NULL) {
257
+ sim_->break_pc_->SetInstructionBits(kBreakpointInstr);
258
+ }
259
+ }
260
+
261
+
262
+ void MipsDebugger::PrintAllRegs() {
263
+ #define REG_INFO(n) Registers::Name(n), GetRegisterValue(n), GetRegisterValue(n)
264
+
265
+ PrintF("\n");
266
+ // at, v0, a0
267
+ PrintF("%3s: 0x%08x %10d\t%3s: 0x%08x %10d\t%3s: 0x%08x %10d\n",
268
+ REG_INFO(1), REG_INFO(2), REG_INFO(4));
269
+ // v1, a1
270
+ PrintF("%26s\t%3s: 0x%08x %10d\t%3s: 0x%08x %10d\n",
271
+ "", REG_INFO(3), REG_INFO(5));
272
+ // a2
273
+ PrintF("%26s\t%26s\t%3s: 0x%08x %10d\n", "", "", REG_INFO(6));
274
+ // a3
275
+ PrintF("%26s\t%26s\t%3s: 0x%08x %10d\n", "", "", REG_INFO(7));
276
+ PrintF("\n");
277
+ // t0-t7, s0-s7
278
+ for (int i = 0; i < 8; i++) {
279
+ PrintF("%3s: 0x%08x %10d\t%3s: 0x%08x %10d\n",
280
+ REG_INFO(8+i), REG_INFO(16+i));
281
+ }
282
+ PrintF("\n");
283
+ // t8, k0, LO
284
+ PrintF("%3s: 0x%08x %10d\t%3s: 0x%08x %10d\t%3s: 0x%08x %10d\n",
285
+ REG_INFO(24), REG_INFO(26), REG_INFO(32));
286
+ // t9, k1, HI
287
+ PrintF("%3s: 0x%08x %10d\t%3s: 0x%08x %10d\t%3s: 0x%08x %10d\n",
288
+ REG_INFO(25), REG_INFO(27), REG_INFO(33));
289
+ // sp, fp, gp
290
+ PrintF("%3s: 0x%08x %10d\t%3s: 0x%08x %10d\t%3s: 0x%08x %10d\n",
291
+ REG_INFO(29), REG_INFO(30), REG_INFO(28));
292
+ // pc
293
+ PrintF("%3s: 0x%08x %10d\t%3s: 0x%08x %10d\n",
294
+ REG_INFO(31), REG_INFO(34));
295
+
296
+ #undef REG_INFO
297
+ #undef FPU_REG_INFO
298
+ }
299
+
300
+
301
+ void MipsDebugger::PrintAllRegsIncludingFPU() {
302
+ #define FPU_REG_INFO(n) FPURegisters::Name(n), FPURegisters::Name(n+1), \
303
+ GetFPURegisterValueInt(n+1), \
304
+ GetFPURegisterValueInt(n), \
305
+ GetFPURegisterValueDouble(n)
306
+
307
+ PrintAllRegs();
308
+
309
+ PrintF("\n\n");
310
+ // f0, f1, f2, ... f31
311
+ PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(0) );
312
+ PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(2) );
313
+ PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(4) );
314
+ PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(6) );
315
+ PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(8) );
316
+ PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(10));
317
+ PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(12));
318
+ PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(14));
319
+ PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(16));
320
+ PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(18));
321
+ PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(20));
322
+ PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(22));
323
+ PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(24));
324
+ PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(26));
325
+ PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(28));
326
+ PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(30));
327
+
328
+ #undef REG_INFO
329
+ #undef FPU_REG_INFO
330
+ }
331
+
332
+
333
+ void MipsDebugger::Debug() {
334
+ intptr_t last_pc = -1;
335
+ bool done = false;
336
+
337
+ #define COMMAND_SIZE 63
338
+ #define ARG_SIZE 255
339
+
340
+ #define STR(a) #a
341
+ #define XSTR(a) STR(a)
342
+
343
+ char cmd[COMMAND_SIZE + 1];
344
+ char arg1[ARG_SIZE + 1];
345
+ char arg2[ARG_SIZE + 1];
346
+ char* argv[3] = { cmd, arg1, arg2 };
347
+
348
+ // make sure to have a proper terminating character if reaching the limit
349
+ cmd[COMMAND_SIZE] = 0;
350
+ arg1[ARG_SIZE] = 0;
351
+ arg2[ARG_SIZE] = 0;
352
+
353
+ // Undo all set breakpoints while running in the debugger shell. This will
354
+ // make them invisible to all commands.
355
+ UndoBreakpoints();
356
+
357
+ while (!done && (sim_->get_pc() != Simulator::end_sim_pc)) {
358
+ if (last_pc != sim_->get_pc()) {
359
+ disasm::NameConverter converter;
360
+ disasm::Disassembler dasm(converter);
361
+ // use a reasonably large buffer
362
+ v8::internal::EmbeddedVector<char, 256> buffer;
363
+ dasm.InstructionDecode(buffer,
364
+ reinterpret_cast<byte_*>(sim_->get_pc()));
365
+ PrintF(" 0x%08x %s\n", sim_->get_pc(), buffer.start());
366
+ last_pc = sim_->get_pc();
367
+ }
368
+ char* line = ReadLine("sim> ");
369
+ if (line == NULL) {
370
+ break;
371
+ } else {
372
+ // Use sscanf to parse the individual parts of the command line. At the
373
+ // moment no command expects more than two parameters.
374
+ int argc = SScanF(line,
375
+ "%" XSTR(COMMAND_SIZE) "s "
376
+ "%" XSTR(ARG_SIZE) "s "
377
+ "%" XSTR(ARG_SIZE) "s",
378
+ cmd, arg1, arg2);
379
+ if ((strcmp(cmd, "si") == 0) || (strcmp(cmd, "stepi") == 0)) {
380
+ Instruction* instr = reinterpret_cast<Instruction*>(sim_->get_pc());
381
+ if (!(instr->IsTrap()) ||
382
+ instr->InstructionBits() == rtCallRedirInstr) {
383
+ sim_->InstructionDecode(
384
+ reinterpret_cast<Instruction*>(sim_->get_pc()));
385
+ } else {
386
+ // Allow si to jump over generated breakpoints.
387
+ PrintF("/!\\ Jumping over generated breakpoint.\n");
388
+ sim_->set_pc(sim_->get_pc() + Instruction::kInstrSize);
389
+ }
390
+ } else if ((strcmp(cmd, "c") == 0) || (strcmp(cmd, "cont") == 0)) {
391
+ // Execute the one instruction we broke at with breakpoints disabled.
392
+ sim_->InstructionDecode(reinterpret_cast<Instruction*>(sim_->get_pc()));
393
+ // Leave the debugger shell.
394
+ done = true;
395
+ } else if ((strcmp(cmd, "p") == 0) || (strcmp(cmd, "print") == 0)) {
396
+ if (argc == 2) {
397
+ int32_t value;
398
+ float fvalue;
399
+ if (strcmp(arg1, "all") == 0) {
400
+ PrintAllRegs();
401
+ } else if (strcmp(arg1, "allf") == 0) {
402
+ PrintAllRegsIncludingFPU();
403
+ } else {
404
+ int regnum = Registers::Number(arg1);
405
+ int fpuregnum = FPURegisters::Number(arg1);
406
+
407
+ if (regnum != kInvalidRegister) {
408
+ value = GetRegisterValue(regnum);
409
+ PrintF("%s: 0x%08x %d \n", arg1, value, value);
410
+ } else if (fpuregnum != kInvalidFPURegister) {
411
+ if (fpuregnum % 2 == 1) {
412
+ value = GetFPURegisterValueInt(fpuregnum);
413
+ fvalue = GetFPURegisterValueFloat(fpuregnum);
414
+ PrintF("%s: 0x%08x %11.4e\n", arg1, value, fvalue);
415
+ } else {
416
+ double dfvalue;
417
+ int32_t lvalue1 = GetFPURegisterValueInt(fpuregnum);
418
+ int32_t lvalue2 = GetFPURegisterValueInt(fpuregnum + 1);
419
+ dfvalue = GetFPURegisterValueDouble(fpuregnum);
420
+ PrintF("%3s,%3s: 0x%08x%08x %16.4e\n",
421
+ FPURegisters::Name(fpuregnum+1),
422
+ FPURegisters::Name(fpuregnum),
423
+ lvalue1,
424
+ lvalue2,
425
+ dfvalue);
426
+ }
427
+ } else {
428
+ PrintF("%s unrecognized\n", arg1);
429
+ }
430
+ }
431
+ } else {
432
+ if (argc == 3) {
433
+ if (strcmp(arg2, "single") == 0) {
434
+ int32_t value;
435
+ float fvalue;
436
+ int fpuregnum = FPURegisters::Number(arg1);
437
+
438
+ if (fpuregnum != kInvalidFPURegister) {
439
+ value = GetFPURegisterValueInt(fpuregnum);
440
+ fvalue = GetFPURegisterValueFloat(fpuregnum);
441
+ PrintF("%s: 0x%08x %11.4e\n", arg1, value, fvalue);
442
+ } else {
443
+ PrintF("%s unrecognized\n", arg1);
444
+ }
445
+ } else {
446
+ PrintF("print <fpu register> single\n");
447
+ }
448
+ } else {
449
+ PrintF("print <register> or print <fpu register> single\n");
450
+ }
451
+ }
452
+ } else if ((strcmp(cmd, "po") == 0)
453
+ || (strcmp(cmd, "printobject") == 0)) {
454
+ if (argc == 2) {
455
+ int32_t value;
456
+ if (GetValue(arg1, &value)) {
457
+ Object* obj = reinterpret_cast<Object*>(value);
458
+ PrintF("%s: \n", arg1);
459
+ #ifdef DEBUG
460
+ obj->PrintLn();
461
+ #else
462
+ obj->ShortPrint();
463
+ PrintF("\n");
464
+ #endif
465
+ } else {
466
+ PrintF("%s unrecognized\n", arg1);
467
+ }
468
+ } else {
469
+ PrintF("printobject <value>\n");
470
+ }
471
+ } else if (strcmp(cmd, "stack") == 0 || strcmp(cmd, "mem") == 0) {
472
+ int32_t* cur = NULL;
473
+ int32_t* end = NULL;
474
+ int next_arg = 1;
475
+
476
+ if (strcmp(cmd, "stack") == 0) {
477
+ cur = reinterpret_cast<int32_t*>(sim_->get_register(Simulator::sp));
478
+ } else { // "mem"
479
+ int32_t value;
480
+ if (!GetValue(arg1, &value)) {
481
+ PrintF("%s unrecognized\n", arg1);
482
+ continue;
483
+ }
484
+ cur = reinterpret_cast<int32_t*>(value);
485
+ next_arg++;
486
+ }
487
+
488
+ int32_t words;
489
+ if (argc == next_arg) {
490
+ words = 10;
491
+ } else if (argc == next_arg + 1) {
492
+ if (!GetValue(argv[next_arg], &words)) {
493
+ words = 10;
494
+ }
495
+ }
496
+ end = cur + words;
497
+
498
+ while (cur < end) {
499
+ PrintF(" 0x%08x: 0x%08x %10d\n",
500
+ reinterpret_cast<intptr_t>(cur), *cur, *cur);
501
+ cur++;
502
+ }
503
+
504
+ } else if ((strcmp(cmd, "disasm") == 0) || (strcmp(cmd, "dpc") == 0)) {
505
+ disasm::NameConverter converter;
506
+ disasm::Disassembler dasm(converter);
507
+ // use a reasonably large buffer
508
+ v8::internal::EmbeddedVector<char, 256> buffer;
509
+
510
+ byte_* cur = NULL;
511
+ byte_* end = NULL;
512
+
513
+ if (argc == 1) {
514
+ cur = reinterpret_cast<byte_*>(sim_->get_pc());
515
+ end = cur + (10 * Instruction::kInstrSize);
516
+ } else if (argc == 2) {
517
+ int32_t value;
518
+ if (GetValue(arg1, &value)) {
519
+ cur = reinterpret_cast<byte_*>(value);
520
+ // no length parameter passed, assume 10 instructions
521
+ end = cur + (10 * Instruction::kInstrSize);
522
+ }
523
+ } else {
524
+ int32_t value1;
525
+ int32_t value2;
526
+ if (GetValue(arg1, &value1) && GetValue(arg2, &value2)) {
527
+ cur = reinterpret_cast<byte_*>(value1);
528
+ end = cur + (value2 * Instruction::kInstrSize);
529
+ }
530
+ }
531
+
532
+ while (cur < end) {
533
+ dasm.InstructionDecode(buffer, cur);
534
+ PrintF(" 0x%08x %s\n",
535
+ reinterpret_cast<intptr_t>(cur), buffer.start());
536
+ cur += Instruction::kInstrSize;
537
+ }
538
+ } else if (strcmp(cmd, "gdb") == 0) {
539
+ PrintF("relinquishing control to gdb\n");
540
+ v8::internal::OS::DebugBreak();
541
+ PrintF("regaining control from gdb\n");
542
+ } else if (strcmp(cmd, "break") == 0) {
543
+ if (argc == 2) {
544
+ int32_t value;
545
+ if (GetValue(arg1, &value)) {
546
+ if (!SetBreakpoint(reinterpret_cast<Instruction*>(value))) {
547
+ PrintF("setting breakpoint failed\n");
548
+ }
549
+ } else {
550
+ PrintF("%s unrecognized\n", arg1);
551
+ }
552
+ } else {
553
+ PrintF("break <address>\n");
554
+ }
555
+ } else if (strcmp(cmd, "del") == 0) {
556
+ if (!DeleteBreakpoint(NULL)) {
557
+ PrintF("deleting breakpoint failed\n");
558
+ }
559
+ } else if (strcmp(cmd, "flags") == 0) {
560
+ PrintF("No flags on MIPS !\n");
561
+ } else if (strcmp(cmd, "unstop") == 0) {
562
+ PrintF("Unstop command not implemented on MIPS.");
563
+ } else if ((strcmp(cmd, "stat") == 0) || (strcmp(cmd, "st") == 0)) {
564
+ // Print registers and disassemble
565
+ PrintAllRegs();
566
+ PrintF("\n");
567
+
568
+ disasm::NameConverter converter;
569
+ disasm::Disassembler dasm(converter);
570
+ // use a reasonably large buffer
571
+ v8::internal::EmbeddedVector<char, 256> buffer;
572
+
573
+ byte_* cur = NULL;
574
+ byte_* end = NULL;
575
+
576
+ if (argc == 1) {
577
+ cur = reinterpret_cast<byte_*>(sim_->get_pc());
578
+ end = cur + (10 * Instruction::kInstrSize);
579
+ } else if (argc == 2) {
580
+ int32_t value;
581
+ if (GetValue(arg1, &value)) {
582
+ cur = reinterpret_cast<byte_*>(value);
583
+ // no length parameter passed, assume 10 instructions
584
+ end = cur + (10 * Instruction::kInstrSize);
585
+ }
586
+ } else {
587
+ int32_t value1;
588
+ int32_t value2;
589
+ if (GetValue(arg1, &value1) && GetValue(arg2, &value2)) {
590
+ cur = reinterpret_cast<byte_*>(value1);
591
+ end = cur + (value2 * Instruction::kInstrSize);
592
+ }
593
+ }
594
+
595
+ while (cur < end) {
596
+ dasm.InstructionDecode(buffer, cur);
597
+ PrintF(" 0x%08x %s\n",
598
+ reinterpret_cast<intptr_t>(cur), buffer.start());
599
+ cur += Instruction::kInstrSize;
600
+ }
601
+ } else if ((strcmp(cmd, "h") == 0) || (strcmp(cmd, "help") == 0)) {
602
+ PrintF("cont\n");
603
+ PrintF(" continue execution (alias 'c')\n");
604
+ PrintF("stepi\n");
605
+ PrintF(" step one instruction (alias 'si')\n");
606
+ PrintF("print <register>\n");
607
+ PrintF(" print register content (alias 'p')\n");
608
+ PrintF(" use register name 'all' to print all registers\n");
609
+ PrintF("printobject <register>\n");
610
+ PrintF(" print an object from a register (alias 'po')\n");
611
+ PrintF("stack [<words>]\n");
612
+ PrintF(" dump stack content, default dump 10 words)\n");
613
+ PrintF("mem <address> [<words>]\n");
614
+ PrintF(" dump memory content, default dump 10 words)\n");
615
+ PrintF("flags\n");
616
+ PrintF(" print flags\n");
617
+ PrintF("disasm [<instructions>]\n");
618
+ PrintF("disasm [[<address>] <instructions>]\n");
619
+ PrintF(" disassemble code, default is 10 instructions from pc\n");
620
+ PrintF("gdb\n");
621
+ PrintF(" enter gdb\n");
622
+ PrintF("break <address>\n");
623
+ PrintF(" set a break point on the address\n");
624
+ PrintF("del\n");
625
+ PrintF(" delete the breakpoint\n");
626
+ PrintF("unstop\n");
627
+ PrintF(" ignore the stop instruction at the current location");
628
+ PrintF(" from now on\n");
629
+ } else {
630
+ PrintF("Unknown command: %s\n", cmd);
631
+ }
632
+ }
633
+ DeleteArray(line);
634
+ }
635
+
636
+ // Add all the breakpoints back to stop execution and enter the debugger
637
+ // shell when hit.
638
+ RedoBreakpoints();
639
+
640
+ #undef COMMAND_SIZE
641
+ #undef ARG_SIZE
642
+
643
+ #undef STR
644
+ #undef XSTR
645
+ }
646
+
647
+
648
+ static bool ICacheMatch(void* one, void* two) {
649
+ ASSERT((reinterpret_cast<intptr_t>(one) & CachePage::kPageMask) == 0);
650
+ ASSERT((reinterpret_cast<intptr_t>(two) & CachePage::kPageMask) == 0);
651
+ return one == two;
652
+ }
653
+
654
+
655
+ static uint32_t ICacheHash(void* key) {
656
+ return static_cast<uint32_t>(reinterpret_cast<uintptr_t>(key)) >> 2;
657
+ }
658
+
659
+
660
+ static bool AllOnOnePage(uintptr_t start, int size) {
661
+ intptr_t start_page = (start & ~CachePage::kPageMask);
662
+ intptr_t end_page = ((start + size) & ~CachePage::kPageMask);
663
+ return start_page == end_page;
664
+ }
665
+
666
+
667
+ void Simulator::FlushICache(v8::internal::HashMap* i_cache,
668
+ void* start_addr,
669
+ size_t size) {
670
+ intptr_t start = reinterpret_cast<intptr_t>(start_addr);
671
+ int intra_line = (start & CachePage::kLineMask);
672
+ start -= intra_line;
673
+ size += intra_line;
674
+ size = ((size - 1) | CachePage::kLineMask) + 1;
675
+ int offset = (start & CachePage::kPageMask);
676
+ while (!AllOnOnePage(start, size - 1)) {
677
+ int bytes_to_flush = CachePage::kPageSize - offset;
678
+ FlushOnePage(i_cache, start, bytes_to_flush);
679
+ start += bytes_to_flush;
680
+ size -= bytes_to_flush;
681
+ ASSERT_EQ(0, start & CachePage::kPageMask);
682
+ offset = 0;
683
+ }
684
+ if (size != 0) {
685
+ FlushOnePage(i_cache, start, size);
686
+ }
687
+ }
688
+
689
+
690
+ CachePage* Simulator::GetCachePage(v8::internal::HashMap* i_cache, void* page) {
691
+ v8::internal::HashMap::Entry* entry = i_cache->Lookup(page,
692
+ ICacheHash(page),
693
+ true);
694
+ if (entry->value == NULL) {
695
+ CachePage* new_page = new CachePage();
696
+ entry->value = new_page;
697
+ }
698
+ return reinterpret_cast<CachePage*>(entry->value);
699
+ }
700
+
701
+
702
+ // Flush from start up to and not including start + size.
703
+ void Simulator::FlushOnePage(v8::internal::HashMap* i_cache,
704
+ intptr_t start,
705
+ int size) {
706
+ ASSERT(size <= CachePage::kPageSize);
707
+ ASSERT(AllOnOnePage(start, size - 1));
708
+ ASSERT((start & CachePage::kLineMask) == 0);
709
+ ASSERT((size & CachePage::kLineMask) == 0);
710
+ void* page = reinterpret_cast<void*>(start & (~CachePage::kPageMask));
711
+ int offset = (start & CachePage::kPageMask);
712
+ CachePage* cache_page = GetCachePage(i_cache, page);
713
+ char* valid_bytemap = cache_page->ValidityByte(offset);
714
+ memset(valid_bytemap, CachePage::LINE_INVALID, size >> CachePage::kLineShift);
715
+ }
716
+
717
+
718
+ void Simulator::CheckICache(v8::internal::HashMap* i_cache,
719
+ Instruction* instr) {
720
+ intptr_t address = reinterpret_cast<intptr_t>(instr);
721
+ void* page = reinterpret_cast<void*>(address & (~CachePage::kPageMask));
722
+ void* line = reinterpret_cast<void*>(address & (~CachePage::kLineMask));
723
+ int offset = (address & CachePage::kPageMask);
724
+ CachePage* cache_page = GetCachePage(i_cache, page);
725
+ char* cache_valid_byte = cache_page->ValidityByte(offset);
726
+ bool cache_hit = (*cache_valid_byte == CachePage::LINE_VALID);
727
+ char* cached_line = cache_page->CachedData(offset & ~CachePage::kLineMask);
728
+ if (cache_hit) {
729
+ // Check that the data in memory matches the contents of the I-cache.
730
+ CHECK(memcmp(reinterpret_cast<void*>(instr),
731
+ cache_page->CachedData(offset),
732
+ Instruction::kInstrSize) == 0);
733
+ } else {
734
+ // Cache miss. Load memory into the cache.
735
+ memcpy(cached_line, line, CachePage::kLineLength);
736
+ *cache_valid_byte = CachePage::LINE_VALID;
737
+ }
738
+ }
739
+
740
+
741
+ void Simulator::Initialize() {
742
+ if (Isolate::Current()->simulator_initialized()) return;
743
+ Isolate::Current()->set_simulator_initialized(true);
744
+ ::v8::internal::ExternalReference::set_redirector(&RedirectExternalReference);
745
+ }
746
+
747
+
748
+ Simulator::Simulator() : isolate_(Isolate::Current()) {
749
+ i_cache_ = isolate_->simulator_i_cache();
750
+ if (i_cache_ == NULL) {
751
+ i_cache_ = new v8::internal::HashMap(&ICacheMatch);
752
+ isolate_->set_simulator_i_cache(i_cache_);
753
+ }
754
+ Initialize();
755
+ // Setup simulator support first. Some of this information is needed to
756
+ // setup the architecture state.
757
+ stack_size_ = 1 * 1024*1024; // allocate 1MB for stack
758
+ stack_ = reinterpret_cast<char*>(malloc(stack_size_));
759
+ pc_modified_ = false;
760
+ icount_ = 0;
761
+ break_count_ = 0;
762
+ break_pc_ = NULL;
763
+ break_instr_ = 0;
764
+
765
+ // Setup architecture state.
766
+ // All registers are initialized to zero to start with.
767
+ for (int i = 0; i < kNumSimuRegisters; i++) {
768
+ registers_[i] = 0;
769
+ }
770
+ for (int i = 0; i < kNumFPURegisters; i++) {
771
+ FPUregisters_[i] = 0;
772
+ }
773
+ FCSR_ = 0;
774
+
775
+ // The sp is initialized to point to the bottom (high address) of the
776
+ // allocated stack area. To be safe in potential stack underflows we leave
777
+ // some buffer below.
778
+ registers_[sp] = reinterpret_cast<int32_t>(stack_) + stack_size_ - 64;
779
+ // The ra and pc are initialized to a known bad value that will cause an
780
+ // access violation if the simulator ever tries to execute it.
781
+ registers_[pc] = bad_ra;
782
+ registers_[ra] = bad_ra;
783
+ InitializeCoverage();
784
+ for (int i = 0; i < kNumExceptions; i++) {
785
+ exceptions[i] = 0;
786
+ }
787
+ }
788
+
789
+
790
+ // When the generated code calls an external reference we need to catch that in
791
+ // the simulator. The external reference will be a function compiled for the
792
+ // host architecture. We need to call that function instead of trying to
793
+ // execute it with the simulator. We do that by redirecting the external
794
+ // reference to a swi (software-interrupt) instruction that is handled by
795
+ // the simulator. We write the original destination of the jump just at a known
796
+ // offset from the swi instruction so the simulator knows what to call.
797
+ class Redirection {
798
+ public:
799
+ Redirection(void* external_function, ExternalReference::Type type)
800
+ : external_function_(external_function),
801
+ swi_instruction_(rtCallRedirInstr),
802
+ type_(type),
803
+ next_(NULL) {
804
+ Isolate* isolate = Isolate::Current();
805
+ next_ = isolate->simulator_redirection();
806
+ Simulator::current(isolate)->
807
+ FlushICache(isolate->simulator_i_cache(),
808
+ reinterpret_cast<void*>(&swi_instruction_),
809
+ Instruction::kInstrSize);
810
+ isolate->set_simulator_redirection(this);
811
+ }
812
+
813
+ void* address_of_swi_instruction() {
814
+ return reinterpret_cast<void*>(&swi_instruction_);
815
+ }
816
+
817
+ void* external_function() { return external_function_; }
818
+ ExternalReference::Type type() { return type_; }
819
+
820
+ static Redirection* Get(void* external_function,
821
+ ExternalReference::Type type) {
822
+ Isolate* isolate = Isolate::Current();
823
+ Redirection* current = isolate->simulator_redirection();
824
+ for (; current != NULL; current = current->next_) {
825
+ if (current->external_function_ == external_function) return current;
826
+ }
827
+ return new Redirection(external_function, type);
828
+ }
829
+
830
+ static Redirection* FromSwiInstruction(Instruction* swi_instruction) {
831
+ char* addr_of_swi = reinterpret_cast<char*>(swi_instruction);
832
+ char* addr_of_redirection =
833
+ addr_of_swi - OFFSET_OF(Redirection, swi_instruction_);
834
+ return reinterpret_cast<Redirection*>(addr_of_redirection);
835
+ }
836
+
837
+ private:
838
+ void* external_function_;
839
+ uint32_t swi_instruction_;
840
+ ExternalReference::Type type_;
841
+ Redirection* next_;
842
+ };
843
+
844
+
845
+ void* Simulator::RedirectExternalReference(void* external_function,
846
+ ExternalReference::Type type) {
847
+ Redirection* redirection = Redirection::Get(external_function, type);
848
+ return redirection->address_of_swi_instruction();
849
+ }
850
+
851
+
852
+ // Get the active Simulator for the current thread.
853
+ Simulator* Simulator::current(Isolate* isolate) {
854
+ v8::internal::Isolate::PerIsolateThreadData* isolate_data =
855
+ Isolate::CurrentPerIsolateThreadData();
856
+ if (isolate_data == NULL) {
857
+ Isolate::EnterDefaultIsolate();
858
+ isolate_data = Isolate::CurrentPerIsolateThreadData();
859
+ }
860
+ ASSERT(isolate_data != NULL);
861
+
862
+ Simulator* sim = isolate_data->simulator();
863
+ if (sim == NULL) {
864
+ // TODO(146): delete the simulator object when a thread/isolate goes away.
865
+ sim = new Simulator();
866
+ isolate_data->set_simulator(sim);
867
+ }
868
+ return sim;
869
+ }
870
+
871
+
872
+ // Sets the register in the architecture state. It will also deal with updating
873
+ // Simulator internal state for special registers such as PC.
874
+ void Simulator::set_register(int reg, int32_t value) {
875
+ ASSERT((reg >= 0) && (reg < kNumSimuRegisters));
876
+ if (reg == pc) {
877
+ pc_modified_ = true;
878
+ }
879
+
880
+ // zero register always hold 0.
881
+ registers_[reg] = (reg == 0) ? 0 : value;
882
+ }
883
+
884
+
885
+ void Simulator::set_fpu_register(int fpureg, int32_t value) {
886
+ ASSERT((fpureg >= 0) && (fpureg < kNumFPURegisters));
887
+ FPUregisters_[fpureg] = value;
888
+ }
889
+
890
+
891
+ void Simulator::set_fpu_register_float(int fpureg, float value) {
892
+ ASSERT((fpureg >= 0) && (fpureg < kNumFPURegisters));
893
+ *BitCast<float*>(&FPUregisters_[fpureg]) = value;
894
+ }
895
+
896
+
897
+ void Simulator::set_fpu_register_double(int fpureg, double value) {
898
+ ASSERT((fpureg >= 0) && (fpureg < kNumFPURegisters) && ((fpureg % 2) == 0));
899
+ *BitCast<double*>(&FPUregisters_[fpureg]) = value;
900
+ }
901
+
902
+
903
+ // Get the register from the architecture state. This function does handle
904
+ // the special case of accessing the PC register.
905
+ int32_t Simulator::get_register(int reg) const {
906
+ ASSERT((reg >= 0) && (reg < kNumSimuRegisters));
907
+ if (reg == 0)
908
+ return 0;
909
+ else
910
+ return registers_[reg] + ((reg == pc) ? Instruction::kPCReadOffset : 0);
911
+ }
912
+
913
+
914
+ int32_t Simulator::get_fpu_register(int fpureg) const {
915
+ ASSERT((fpureg >= 0) && (fpureg < kNumFPURegisters));
916
+ return FPUregisters_[fpureg];
917
+ }
918
+
919
+
920
+ int64_t Simulator::get_fpu_register_long(int fpureg) const {
921
+ ASSERT((fpureg >= 0) && (fpureg < kNumFPURegisters) && ((fpureg % 2) == 0));
922
+ return *BitCast<int64_t*>(
923
+ const_cast<int32_t*>(&FPUregisters_[fpureg]));
924
+ }
925
+
926
+
927
+ float Simulator::get_fpu_register_float(int fpureg) const {
928
+ ASSERT((fpureg >= 0) && (fpureg < kNumFPURegisters));
929
+ return *BitCast<float*>(
930
+ const_cast<int32_t*>(&FPUregisters_[fpureg]));
931
+ }
932
+
933
+
934
+ double Simulator::get_fpu_register_double(int fpureg) const {
935
+ ASSERT((fpureg >= 0) && (fpureg < kNumFPURegisters) && ((fpureg % 2) == 0));
936
+ return *BitCast<double*>(const_cast<int32_t*>(&FPUregisters_[fpureg]));
937
+ }
938
+
939
+
940
+ // Helper functions for setting and testing the FCSR register's bits.
941
+ void Simulator::set_fcsr_bit(uint32_t cc, bool value) {
942
+ if (value) {
943
+ FCSR_ |= (1 << cc);
944
+ } else {
945
+ FCSR_ &= ~(1 << cc);
946
+ }
947
+ }
948
+
949
+
950
+ bool Simulator::test_fcsr_bit(uint32_t cc) {
951
+ return FCSR_ & (1 << cc);
952
+ }
953
+
954
+
955
+ // Sets the rounding error codes in FCSR based on the result of the rounding.
956
+ // Returns true if the operation was invalid.
957
+ bool Simulator::set_fcsr_round_error(double original, double rounded) {
958
+ if (!isfinite(original) ||
959
+ rounded > LONG_MAX ||
960
+ rounded < LONG_MIN) {
961
+ set_fcsr_bit(6, true); // Invalid operation.
962
+ return true;
963
+ } else if (original != static_cast<double>(rounded)) {
964
+ set_fcsr_bit(2, true); // Inexact.
965
+ }
966
+ return false;
967
+ }
968
+
969
+
970
+ // Raw access to the PC register.
971
+ void Simulator::set_pc(int32_t value) {
972
+ pc_modified_ = true;
973
+ registers_[pc] = value;
974
+ }
975
+
976
+
977
+ bool Simulator::has_bad_pc() const {
978
+ return ((registers_[pc] == bad_ra) || (registers_[pc] == end_sim_pc));
979
+ }
980
+
981
+
982
+ // Raw access to the PC register without the special adjustment when reading.
983
+ int32_t Simulator::get_pc() const {
984
+ return registers_[pc];
985
+ }
986
+
987
+
988
+ // The MIPS cannot do unaligned reads and writes. On some MIPS platforms an
989
+ // interrupt is caused. On others it does a funky rotation thing. For now we
990
+ // simply disallow unaligned reads, but at some point we may want to move to
991
+ // emulating the rotate behaviour. Note that simulator runs have the runtime
992
+ // system running directly on the host system and only generated code is
993
+ // executed in the simulator. Since the host is typically IA32 we will not
994
+ // get the correct MIPS-like behaviour on unaligned accesses.
995
+
996
+ int Simulator::ReadW(int32_t addr, Instruction* instr) {
997
+ if (addr >=0 && addr < 0x400) {
998
+ // this has to be a NULL-dereference
999
+ MipsDebugger dbg(this);
1000
+ dbg.Debug();
1001
+ }
1002
+ if ((addr & kPointerAlignmentMask) == 0) {
1003
+ intptr_t* ptr = reinterpret_cast<intptr_t*>(addr);
1004
+ return *ptr;
1005
+ }
1006
+ PrintF("Unaligned read at 0x%08x, pc=%p\n", addr,
1007
+ reinterpret_cast<void*>(instr));
1008
+ MipsDebugger dbg(this);
1009
+ dbg.Debug();
1010
+ return 0;
1011
+ }
1012
+
1013
+
1014
+ void Simulator::WriteW(int32_t addr, int value, Instruction* instr) {
1015
+ if (addr >= 0 && addr < 0x400) {
1016
+ // this has to be a NULL-dereference
1017
+ MipsDebugger dbg(this);
1018
+ dbg.Debug();
1019
+ }
1020
+ if ((addr & kPointerAlignmentMask) == 0) {
1021
+ intptr_t* ptr = reinterpret_cast<intptr_t*>(addr);
1022
+ *ptr = value;
1023
+ return;
1024
+ }
1025
+ PrintF("Unaligned write at 0x%08x, pc=%p\n", addr,
1026
+ reinterpret_cast<void*>(instr));
1027
+ MipsDebugger dbg(this);
1028
+ dbg.Debug();
1029
+ }
1030
+
1031
+
1032
+ double Simulator::ReadD(int32_t addr, Instruction* instr) {
1033
+ if ((addr & kDoubleAlignmentMask) == 0) {
1034
+ double* ptr = reinterpret_cast<double*>(addr);
1035
+ return *ptr;
1036
+ }
1037
+ PrintF("Unaligned (double) read at 0x%08x, pc=%p\n", addr,
1038
+ reinterpret_cast<void*>(instr));
1039
+ OS::Abort();
1040
+ return 0;
1041
+ }
1042
+
1043
+
1044
+ void Simulator::WriteD(int32_t addr, double value, Instruction* instr) {
1045
+ if ((addr & kDoubleAlignmentMask) == 0) {
1046
+ double* ptr = reinterpret_cast<double*>(addr);
1047
+ *ptr = value;
1048
+ return;
1049
+ }
1050
+ PrintF("Unaligned (double) write at 0x%08x, pc=%p\n", addr,
1051
+ reinterpret_cast<void*>(instr));
1052
+ OS::Abort();
1053
+ }
1054
+
1055
+
1056
+ uint16_t Simulator::ReadHU(int32_t addr, Instruction* instr) {
1057
+ if ((addr & 1) == 0) {
1058
+ uint16_t* ptr = reinterpret_cast<uint16_t*>(addr);
1059
+ return *ptr;
1060
+ }
1061
+ PrintF("Unaligned unsigned halfword read at 0x%08x, pc=%p\n", addr,
1062
+ reinterpret_cast<void*>(instr));
1063
+ OS::Abort();
1064
+ return 0;
1065
+ }
1066
+
1067
+
1068
+ int16_t Simulator::ReadH(int32_t addr, Instruction* instr) {
1069
+ if ((addr & 1) == 0) {
1070
+ int16_t* ptr = reinterpret_cast<int16_t*>(addr);
1071
+ return *ptr;
1072
+ }
1073
+ PrintF("Unaligned signed halfword read at 0x%08x, pc=%p\n", addr,
1074
+ reinterpret_cast<void*>(instr));
1075
+ OS::Abort();
1076
+ return 0;
1077
+ }
1078
+
1079
+
1080
+ void Simulator::WriteH(int32_t addr, uint16_t value, Instruction* instr) {
1081
+ if ((addr & 1) == 0) {
1082
+ uint16_t* ptr = reinterpret_cast<uint16_t*>(addr);
1083
+ *ptr = value;
1084
+ return;
1085
+ }
1086
+ PrintF("Unaligned unsigned halfword write at 0x%08x, pc=%p\n", addr,
1087
+ reinterpret_cast<void*>(instr));
1088
+ OS::Abort();
1089
+ }
1090
+
1091
+
1092
+ void Simulator::WriteH(int32_t addr, int16_t value, Instruction* instr) {
1093
+ if ((addr & 1) == 0) {
1094
+ int16_t* ptr = reinterpret_cast<int16_t*>(addr);
1095
+ *ptr = value;
1096
+ return;
1097
+ }
1098
+ PrintF("Unaligned halfword write at 0x%08x, pc=%p\n", addr,
1099
+ reinterpret_cast<void*>(instr));
1100
+ OS::Abort();
1101
+ }
1102
+
1103
+
1104
+ uint32_t Simulator::ReadBU(int32_t addr) {
1105
+ uint8_t* ptr = reinterpret_cast<uint8_t*>(addr);
1106
+ return *ptr & 0xff;
1107
+ }
1108
+
1109
+
1110
+ int32_t Simulator::ReadB(int32_t addr) {
1111
+ int8_t* ptr = reinterpret_cast<int8_t*>(addr);
1112
+ return *ptr;
1113
+ }
1114
+
1115
+
1116
+ void Simulator::WriteB(int32_t addr, uint8_t value) {
1117
+ uint8_t* ptr = reinterpret_cast<uint8_t*>(addr);
1118
+ *ptr = value;
1119
+ }
1120
+
1121
+
1122
+ void Simulator::WriteB(int32_t addr, int8_t value) {
1123
+ int8_t* ptr = reinterpret_cast<int8_t*>(addr);
1124
+ *ptr = value;
1125
+ }
1126
+
1127
+
1128
+ // Returns the limit of the stack area to enable checking for stack overflows.
1129
+ uintptr_t Simulator::StackLimit() const {
1130
+ // Leave a safety margin of 256 bytes to prevent overrunning the stack when
1131
+ // pushing values.
1132
+ return reinterpret_cast<uintptr_t>(stack_) + 256;
1133
+ }
1134
+
1135
+
1136
+ // Unsupported instructions use Format to print an error and stop execution.
1137
+ void Simulator::Format(Instruction* instr, const char* format) {
1138
+ PrintF("Simulator found unsupported instruction:\n 0x%08x: %s\n",
1139
+ reinterpret_cast<intptr_t>(instr), format);
1140
+ UNIMPLEMENTED_MIPS();
1141
+ }
1142
+
1143
+
1144
+ // Calls into the V8 runtime are based on this very simple interface.
1145
+ // Note: To be able to return two values from some calls the code in runtime.cc
1146
+ // uses the ObjectPair which is essentially two 32-bit values stuffed into a
1147
+ // 64-bit value. With the code below we assume that all runtime calls return
1148
+ // 64 bits of result. If they don't, the v1 result register contains a bogus
1149
+ // value, which is fine because it is caller-saved.
1150
+ typedef int64_t (*SimulatorRuntimeCall)(int32_t arg0,
1151
+ int32_t arg1,
1152
+ int32_t arg2,
1153
+ int32_t arg3,
1154
+ int32_t arg4,
1155
+ int32_t arg5);
1156
+ typedef double (*SimulatorRuntimeFPCall)(int32_t arg0,
1157
+ int32_t arg1,
1158
+ int32_t arg2,
1159
+ int32_t arg3);
1160
+
1161
+ // Software interrupt instructions are used by the simulator to call into the
1162
+ // C-based V8 runtime. They are also used for debugging with simulator.
1163
+ void Simulator::SoftwareInterrupt(Instruction* instr) {
1164
+ // There are several instructions that could get us here,
1165
+ // the break_ instruction, or several variants of traps. All
1166
+ // Are "SPECIAL" class opcode, and are distinuished by function.
1167
+ int32_t func = instr->FunctionFieldRaw();
1168
+ int32_t code = (func == BREAK) ? instr->Bits(25, 6) : -1;
1169
+
1170
+ // We first check if we met a call_rt_redirected.
1171
+ if (instr->InstructionBits() == rtCallRedirInstr) {
1172
+ // Check if stack is aligned. Error if not aligned is reported below to
1173
+ // include information on the function called.
1174
+ bool stack_aligned =
1175
+ (get_register(sp)
1176
+ & (::v8::internal::FLAG_sim_stack_alignment - 1)) == 0;
1177
+ Redirection* redirection = Redirection::FromSwiInstruction(instr);
1178
+ int32_t arg0 = get_register(a0);
1179
+ int32_t arg1 = get_register(a1);
1180
+ int32_t arg2 = get_register(a2);
1181
+ int32_t arg3 = get_register(a3);
1182
+ int32_t arg4 = 0;
1183
+ int32_t arg5 = 0;
1184
+
1185
+ // Need to check if sp is valid before assigning arg4, arg5.
1186
+ // This is a fix for cctest test-api/CatchStackOverflow which causes
1187
+ // the stack to overflow. For some reason arm doesn't need this
1188
+ // stack check here.
1189
+ int32_t* stack_pointer = reinterpret_cast<int32_t*>(get_register(sp));
1190
+ int32_t* stack = reinterpret_cast<int32_t*>(stack_);
1191
+ if (stack_pointer >= stack && stack_pointer < stack + stack_size_) {
1192
+ arg4 = stack_pointer[0];
1193
+ arg5 = stack_pointer[1];
1194
+ }
1195
+ // This is dodgy but it works because the C entry stubs are never moved.
1196
+ // See comment in codegen-arm.cc and bug 1242173.
1197
+ int32_t saved_ra = get_register(ra);
1198
+
1199
+ intptr_t external =
1200
+ reinterpret_cast<int32_t>(redirection->external_function());
1201
+
1202
+ // Based on CpuFeatures::IsSupported(FPU), Mips will use either hardware
1203
+ // FPU, or gcc soft-float routines. Hardware FPU is simulated in this
1204
+ // simulator. Soft-float has additional abstraction of ExternalReference,
1205
+ // to support serialization. Finally, when simulated on x86 host, the
1206
+ // x86 softfloat routines are used, and this Redirection infrastructure
1207
+ // lets simulated-mips make calls into x86 C code.
1208
+ // When doing that, the 'double' return type must be handled differently
1209
+ // than the usual int64_t return. The data is returned in different
1210
+ // registers and cannot be cast from one type to the other. However, the
1211
+ // calling arguments are passed the same way in both cases.
1212
+ if (redirection->type() == ExternalReference::FP_RETURN_CALL) {
1213
+ SimulatorRuntimeFPCall target =
1214
+ reinterpret_cast<SimulatorRuntimeFPCall>(external);
1215
+ if (::v8::internal::FLAG_trace_sim || !stack_aligned) {
1216
+ PrintF("Call to host function at %p with args %08x:%08x %08x:%08x",
1217
+ FUNCTION_ADDR(target), arg0, arg1, arg2, arg3);
1218
+ if (!stack_aligned) {
1219
+ PrintF(" with unaligned stack %08x\n", get_register(sp));
1220
+ }
1221
+ PrintF("\n");
1222
+ }
1223
+ double result = target(arg0, arg1, arg2, arg3);
1224
+ // fp result -> registers v0 and v1.
1225
+ int32_t gpreg_pair[2];
1226
+ memcpy(&gpreg_pair[0], &result, 2 * sizeof(int32_t));
1227
+ set_register(v0, gpreg_pair[0]);
1228
+ set_register(v1, gpreg_pair[1]);
1229
+ } else if (redirection->type() == ExternalReference::DIRECT_API_CALL) {
1230
+ PrintF("Mips does not yet support ExternalReference::DIRECT_API_CALL\n");
1231
+ ASSERT(redirection->type() != ExternalReference::DIRECT_API_CALL);
1232
+ } else if (redirection->type() == ExternalReference::DIRECT_GETTER_CALL) {
1233
+ PrintF("Mips does not support ExternalReference::DIRECT_GETTER_CALL\n");
1234
+ ASSERT(redirection->type() != ExternalReference::DIRECT_GETTER_CALL);
1235
+ } else {
1236
+ // Builtin call.
1237
+ ASSERT(redirection->type() == ExternalReference::BUILTIN_CALL);
1238
+ SimulatorRuntimeCall target =
1239
+ reinterpret_cast<SimulatorRuntimeCall>(external);
1240
+ if (::v8::internal::FLAG_trace_sim || !stack_aligned) {
1241
+ PrintF(
1242
+ "Call to host function at %p: %08x, %08x, %08x, %08x, %08x, %08x",
1243
+ FUNCTION_ADDR(target),
1244
+ arg0,
1245
+ arg1,
1246
+ arg2,
1247
+ arg3,
1248
+ arg4,
1249
+ arg5);
1250
+ if (!stack_aligned) {
1251
+ PrintF(" with unaligned stack %08x\n", get_register(sp));
1252
+ }
1253
+ PrintF("\n");
1254
+ }
1255
+
1256
+ int64_t result = target(arg0, arg1, arg2, arg3, arg4, arg5);
1257
+ set_register(v0, static_cast<int32_t>(result));
1258
+ set_register(v1, static_cast<int32_t>(result >> 32));
1259
+ }
1260
+ if (::v8::internal::FLAG_trace_sim) {
1261
+ PrintF("Returned %08x : %08x\n", get_register(v1), get_register(v0));
1262
+ }
1263
+ set_register(ra, saved_ra);
1264
+ set_pc(get_register(ra));
1265
+
1266
+ } else if (func == BREAK && code >= 0 && code < 16) {
1267
+ // First 16 break_ codes interpreted as debug markers.
1268
+ MipsDebugger dbg(this);
1269
+ ++break_count_;
1270
+ PrintF("\n---- break %d marker: %3d (instr count: %8d) ----------"
1271
+ "----------------------------------",
1272
+ code, break_count_, icount_);
1273
+ dbg.PrintAllRegs(); // Print registers and continue running.
1274
+ } else {
1275
+ // All remaining break_ codes, and all traps are handled here.
1276
+ MipsDebugger dbg(this);
1277
+ dbg.Debug();
1278
+ }
1279
+ }
1280
+
1281
+
1282
+ void Simulator::SignalExceptions() {
1283
+ for (int i = 1; i < kNumExceptions; i++) {
1284
+ if (exceptions[i] != 0) {
1285
+ V8_Fatal(__FILE__, __LINE__, "Error: Exception %i raised.", i);
1286
+ }
1287
+ }
1288
+ }
1289
+
1290
+
1291
+ // Handle execution based on instruction types.
1292
+
1293
+ void Simulator::ConfigureTypeRegister(Instruction* instr,
1294
+ int32_t& alu_out,
1295
+ int64_t& i64hilo,
1296
+ uint64_t& u64hilo,
1297
+ int32_t& next_pc,
1298
+ bool& do_interrupt) {
1299
+ // Every local variable declared here needs to be const.
1300
+ // This is to make sure that changed values are sent back to
1301
+ // DecodeTypeRegister correctly.
1302
+
1303
+ // Instruction fields.
1304
+ const Opcode op = instr->OpcodeFieldRaw();
1305
+ const int32_t rs_reg = instr->RsValue();
1306
+ const int32_t rs = get_register(rs_reg);
1307
+ const uint32_t rs_u = static_cast<uint32_t>(rs);
1308
+ const int32_t rt_reg = instr->RtValue();
1309
+ const int32_t rt = get_register(rt_reg);
1310
+ const uint32_t rt_u = static_cast<uint32_t>(rt);
1311
+ const int32_t rd_reg = instr->RdValue();
1312
+ const uint32_t sa = instr->SaValue();
1313
+
1314
+ const int32_t fs_reg = instr->FsValue();
1315
+
1316
+
1317
+ // ---------- Configuration
1318
+ switch (op) {
1319
+ case COP1: // Coprocessor instructions
1320
+ switch (instr->RsFieldRaw()) {
1321
+ case BC1: // Handled in DecodeTypeImmed, should never come here.
1322
+ UNREACHABLE();
1323
+ break;
1324
+ case CFC1:
1325
+ // At the moment only FCSR is supported.
1326
+ ASSERT(fs_reg == kFCSRRegister);
1327
+ alu_out = FCSR_;
1328
+ break;
1329
+ case MFC1:
1330
+ alu_out = get_fpu_register(fs_reg);
1331
+ break;
1332
+ case MFHC1:
1333
+ UNIMPLEMENTED_MIPS();
1334
+ break;
1335
+ case CTC1:
1336
+ case MTC1:
1337
+ case MTHC1:
1338
+ // Do the store in the execution step.
1339
+ break;
1340
+ case S:
1341
+ case D:
1342
+ case W:
1343
+ case L:
1344
+ case PS:
1345
+ // Do everything in the execution step.
1346
+ break;
1347
+ default:
1348
+ UNIMPLEMENTED_MIPS();
1349
+ };
1350
+ break;
1351
+ case SPECIAL:
1352
+ switch (instr->FunctionFieldRaw()) {
1353
+ case JR:
1354
+ case JALR:
1355
+ next_pc = get_register(instr->RsValue());
1356
+ break;
1357
+ case SLL:
1358
+ alu_out = rt << sa;
1359
+ break;
1360
+ case SRL:
1361
+ if (rs_reg == 0) {
1362
+ // Regular logical right shift of a word by a fixed number of
1363
+ // bits instruction. RS field is always equal to 0.
1364
+ alu_out = rt_u >> sa;
1365
+ } else {
1366
+ // Logical right-rotate of a word by a fixed number of bits. This
1367
+ // is special case of SRL instruction, added in MIPS32 Release 2.
1368
+ // RS field is equal to 00001
1369
+ alu_out = (rt_u >> sa) | (rt_u << (32 - sa));
1370
+ }
1371
+ break;
1372
+ case SRA:
1373
+ alu_out = rt >> sa;
1374
+ break;
1375
+ case SLLV:
1376
+ alu_out = rt << rs;
1377
+ break;
1378
+ case SRLV:
1379
+ if (sa == 0) {
1380
+ // Regular logical right-shift of a word by a variable number of
1381
+ // bits instruction. SA field is always equal to 0.
1382
+ alu_out = rt_u >> rs;
1383
+ } else {
1384
+ // Logical right-rotate of a word by a variable number of bits.
1385
+ // This is special case od SRLV instruction, added in MIPS32
1386
+ // Release 2. SA field is equal to 00001
1387
+ alu_out = (rt_u >> rs_u) | (rt_u << (32 - rs_u));
1388
+ }
1389
+ break;
1390
+ case SRAV:
1391
+ alu_out = rt >> rs;
1392
+ break;
1393
+ case MFHI:
1394
+ alu_out = get_register(HI);
1395
+ break;
1396
+ case MFLO:
1397
+ alu_out = get_register(LO);
1398
+ break;
1399
+ case MULT:
1400
+ i64hilo = static_cast<int64_t>(rs) * static_cast<int64_t>(rt);
1401
+ break;
1402
+ case MULTU:
1403
+ u64hilo = static_cast<uint64_t>(rs_u) * static_cast<uint64_t>(rt_u);
1404
+ break;
1405
+ case DIV:
1406
+ case DIVU:
1407
+ exceptions[kDivideByZero] = rt == 0;
1408
+ break;
1409
+ case ADD:
1410
+ if (HaveSameSign(rs, rt)) {
1411
+ if (rs > 0) {
1412
+ exceptions[kIntegerOverflow] = rs > (Registers::kMaxValue - rt);
1413
+ } else if (rs < 0) {
1414
+ exceptions[kIntegerUnderflow] = rs < (Registers::kMinValue - rt);
1415
+ }
1416
+ }
1417
+ alu_out = rs + rt;
1418
+ break;
1419
+ case ADDU:
1420
+ alu_out = rs + rt;
1421
+ break;
1422
+ case SUB:
1423
+ if (!HaveSameSign(rs, rt)) {
1424
+ if (rs > 0) {
1425
+ exceptions[kIntegerOverflow] = rs > (Registers::kMaxValue + rt);
1426
+ } else if (rs < 0) {
1427
+ exceptions[kIntegerUnderflow] = rs < (Registers::kMinValue + rt);
1428
+ }
1429
+ }
1430
+ alu_out = rs - rt;
1431
+ break;
1432
+ case SUBU:
1433
+ alu_out = rs - rt;
1434
+ break;
1435
+ case AND:
1436
+ alu_out = rs & rt;
1437
+ break;
1438
+ case OR:
1439
+ alu_out = rs | rt;
1440
+ break;
1441
+ case XOR:
1442
+ alu_out = rs ^ rt;
1443
+ break;
1444
+ case NOR:
1445
+ alu_out = ~(rs | rt);
1446
+ break;
1447
+ case SLT:
1448
+ alu_out = rs < rt ? 1 : 0;
1449
+ break;
1450
+ case SLTU:
1451
+ alu_out = rs_u < rt_u ? 1 : 0;
1452
+ break;
1453
+ // Break and trap instructions
1454
+ case BREAK:
1455
+
1456
+ do_interrupt = true;
1457
+ break;
1458
+ case TGE:
1459
+ do_interrupt = rs >= rt;
1460
+ break;
1461
+ case TGEU:
1462
+ do_interrupt = rs_u >= rt_u;
1463
+ break;
1464
+ case TLT:
1465
+ do_interrupt = rs < rt;
1466
+ break;
1467
+ case TLTU:
1468
+ do_interrupt = rs_u < rt_u;
1469
+ break;
1470
+ case TEQ:
1471
+ do_interrupt = rs == rt;
1472
+ break;
1473
+ case TNE:
1474
+ do_interrupt = rs != rt;
1475
+ break;
1476
+ case MOVN:
1477
+ case MOVZ:
1478
+ case MOVCI:
1479
+ // No action taken on decode.
1480
+ break;
1481
+ default:
1482
+ UNREACHABLE();
1483
+ };
1484
+ break;
1485
+ case SPECIAL2:
1486
+ switch (instr->FunctionFieldRaw()) {
1487
+ case MUL:
1488
+ alu_out = rs_u * rt_u; // Only the lower 32 bits are kept.
1489
+ break;
1490
+ case CLZ:
1491
+ alu_out = __builtin_clz(rs_u);
1492
+ break;
1493
+ default:
1494
+ UNREACHABLE();
1495
+ };
1496
+ break;
1497
+ case SPECIAL3:
1498
+ switch (instr->FunctionFieldRaw()) {
1499
+ case INS: { // Mips32r2 instruction.
1500
+ // Interpret Rd field as 5-bit msb of insert.
1501
+ uint16_t msb = rd_reg;
1502
+ // Interpret sa field as 5-bit lsb of insert.
1503
+ uint16_t lsb = sa;
1504
+ uint16_t size = msb - lsb + 1;
1505
+ uint32_t mask = (1 << size) - 1;
1506
+ alu_out = (rt_u & ~(mask << lsb)) | ((rs_u & mask) << lsb);
1507
+ break;
1508
+ }
1509
+ case EXT: { // Mips32r2 instruction.
1510
+ // Interpret Rd field as 5-bit msb of extract.
1511
+ uint16_t msb = rd_reg;
1512
+ // Interpret sa field as 5-bit lsb of extract.
1513
+ uint16_t lsb = sa;
1514
+ uint16_t size = msb + 1;
1515
+ uint32_t mask = (1 << size) - 1;
1516
+ alu_out = (rs_u & (mask << lsb)) >> lsb;
1517
+ break;
1518
+ }
1519
+ default:
1520
+ UNREACHABLE();
1521
+ };
1522
+ break;
1523
+ default:
1524
+ UNREACHABLE();
1525
+ };
1526
+ }
1527
+
1528
+
1529
+ void Simulator::DecodeTypeRegister(Instruction* instr) {
1530
+ // Instruction fields.
1531
+ const Opcode op = instr->OpcodeFieldRaw();
1532
+ const int32_t rs_reg = instr->RsValue();
1533
+ const int32_t rs = get_register(rs_reg);
1534
+ const uint32_t rs_u = static_cast<uint32_t>(rs);
1535
+ const int32_t rt_reg = instr->RtValue();
1536
+ const int32_t rt = get_register(rt_reg);
1537
+ const uint32_t rt_u = static_cast<uint32_t>(rt);
1538
+ const int32_t rd_reg = instr->RdValue();
1539
+
1540
+ const int32_t fs_reg = instr->FsValue();
1541
+ const int32_t ft_reg = instr->FtValue();
1542
+ const int32_t fd_reg = instr->FdValue();
1543
+ int64_t i64hilo = 0;
1544
+ uint64_t u64hilo = 0;
1545
+
1546
+ // ALU output
1547
+ // It should not be used as is. Instructions using it should always
1548
+ // initialize it first.
1549
+ int32_t alu_out = 0x12345678;
1550
+
1551
+ // For break and trap instructions.
1552
+ bool do_interrupt = false;
1553
+
1554
+ // For jr and jalr
1555
+ // Get current pc.
1556
+ int32_t current_pc = get_pc();
1557
+ // Next pc
1558
+ int32_t next_pc = 0;
1559
+
1560
+ // Setup the variables if needed before executing the instruction.
1561
+ ConfigureTypeRegister(instr,
1562
+ alu_out,
1563
+ i64hilo,
1564
+ u64hilo,
1565
+ next_pc,
1566
+ do_interrupt);
1567
+
1568
+ // ---------- Raise exceptions triggered.
1569
+ SignalExceptions();
1570
+
1571
+ // ---------- Execution
1572
+ switch (op) {
1573
+ case COP1:
1574
+ switch (instr->RsFieldRaw()) {
1575
+ case BC1: // branch on coprocessor condition
1576
+ UNREACHABLE();
1577
+ break;
1578
+ case CFC1:
1579
+ set_register(rt_reg, alu_out);
1580
+ case MFC1:
1581
+ set_register(rt_reg, alu_out);
1582
+ break;
1583
+ case MFHC1:
1584
+ UNIMPLEMENTED_MIPS();
1585
+ break;
1586
+ case CTC1:
1587
+ // At the moment only FCSR is supported.
1588
+ ASSERT(fs_reg == kFCSRRegister);
1589
+ FCSR_ = registers_[rt_reg];
1590
+ break;
1591
+ case MTC1:
1592
+ FPUregisters_[fs_reg] = registers_[rt_reg];
1593
+ break;
1594
+ case MTHC1:
1595
+ UNIMPLEMENTED_MIPS();
1596
+ break;
1597
+ case S:
1598
+ float f;
1599
+ switch (instr->FunctionFieldRaw()) {
1600
+ case CVT_D_S:
1601
+ f = get_fpu_register_float(fs_reg);
1602
+ set_fpu_register_double(fd_reg, static_cast<double>(f));
1603
+ break;
1604
+ case CVT_W_S:
1605
+ case CVT_L_S:
1606
+ case TRUNC_W_S:
1607
+ case TRUNC_L_S:
1608
+ case ROUND_W_S:
1609
+ case ROUND_L_S:
1610
+ case FLOOR_W_S:
1611
+ case FLOOR_L_S:
1612
+ case CEIL_W_S:
1613
+ case CEIL_L_S:
1614
+ case CVT_PS_S:
1615
+ UNIMPLEMENTED_MIPS();
1616
+ break;
1617
+ default:
1618
+ UNREACHABLE();
1619
+ }
1620
+ break;
1621
+ case D:
1622
+ double ft, fs;
1623
+ uint32_t cc, fcsr_cc;
1624
+ int64_t i64;
1625
+ fs = get_fpu_register_double(fs_reg);
1626
+ ft = get_fpu_register_double(ft_reg);
1627
+ cc = instr->FCccValue();
1628
+ fcsr_cc = get_fcsr_condition_bit(cc);
1629
+ switch (instr->FunctionFieldRaw()) {
1630
+ case ADD_D:
1631
+ set_fpu_register_double(fd_reg, fs + ft);
1632
+ break;
1633
+ case SUB_D:
1634
+ set_fpu_register_double(fd_reg, fs - ft);
1635
+ break;
1636
+ case MUL_D:
1637
+ set_fpu_register_double(fd_reg, fs * ft);
1638
+ break;
1639
+ case DIV_D:
1640
+ set_fpu_register_double(fd_reg, fs / ft);
1641
+ break;
1642
+ case ABS_D:
1643
+ set_fpu_register_double(fd_reg, fs < 0 ? -fs : fs);
1644
+ break;
1645
+ case MOV_D:
1646
+ set_fpu_register_double(fd_reg, fs);
1647
+ break;
1648
+ case NEG_D:
1649
+ set_fpu_register_double(fd_reg, -fs);
1650
+ break;
1651
+ case SQRT_D:
1652
+ set_fpu_register_double(fd_reg, sqrt(fs));
1653
+ break;
1654
+ case C_UN_D:
1655
+ set_fcsr_bit(fcsr_cc, isnan(fs) || isnan(ft));
1656
+ break;
1657
+ case C_EQ_D:
1658
+ set_fcsr_bit(fcsr_cc, (fs == ft));
1659
+ break;
1660
+ case C_UEQ_D:
1661
+ set_fcsr_bit(fcsr_cc, (fs == ft) || (isnan(fs) || isnan(ft)));
1662
+ break;
1663
+ case C_OLT_D:
1664
+ set_fcsr_bit(fcsr_cc, (fs < ft));
1665
+ break;
1666
+ case C_ULT_D:
1667
+ set_fcsr_bit(fcsr_cc, (fs < ft) || (isnan(fs) || isnan(ft)));
1668
+ break;
1669
+ case C_OLE_D:
1670
+ set_fcsr_bit(fcsr_cc, (fs <= ft));
1671
+ break;
1672
+ case C_ULE_D:
1673
+ set_fcsr_bit(fcsr_cc, (fs <= ft) || (isnan(fs) || isnan(ft)));
1674
+ break;
1675
+ case CVT_W_D: // Convert double to word.
1676
+ // Rounding modes are not yet supported.
1677
+ ASSERT((FCSR_ & 3) == 0);
1678
+ // In rounding mode 0 it should behave like ROUND.
1679
+ case ROUND_W_D: // Round double to word.
1680
+ {
1681
+ double rounded = fs > 0 ? floor(fs + 0.5) : ceil(fs - 0.5);
1682
+ int32_t result = static_cast<int32_t>(rounded);
1683
+ set_fpu_register(fd_reg, result);
1684
+ if (set_fcsr_round_error(fs, rounded)) {
1685
+ set_fpu_register(fd_reg, kFPUInvalidResult);
1686
+ }
1687
+ }
1688
+ break;
1689
+ case TRUNC_W_D: // Truncate double to word (round towards 0).
1690
+ {
1691
+ int32_t result = static_cast<int32_t>(fs);
1692
+ set_fpu_register(fd_reg, result);
1693
+ if (set_fcsr_round_error(fs, static_cast<double>(result))) {
1694
+ set_fpu_register(fd_reg, kFPUInvalidResult);
1695
+ }
1696
+ }
1697
+ break;
1698
+ case FLOOR_W_D: // Round double to word towards negative infinity.
1699
+ {
1700
+ double rounded = floor(fs);
1701
+ int32_t result = static_cast<int32_t>(rounded);
1702
+ set_fpu_register(fd_reg, result);
1703
+ if (set_fcsr_round_error(fs, rounded)) {
1704
+ set_fpu_register(fd_reg, kFPUInvalidResult);
1705
+ }
1706
+ }
1707
+ break;
1708
+ case CEIL_W_D: // Round double to word towards positive infinity.
1709
+ {
1710
+ double rounded = ceil(fs);
1711
+ int32_t result = static_cast<int32_t>(rounded);
1712
+ set_fpu_register(fd_reg, result);
1713
+ if (set_fcsr_round_error(fs, rounded)) {
1714
+ set_fpu_register(fd_reg, kFPUInvalidResult);
1715
+ }
1716
+ }
1717
+ break;
1718
+ case CVT_S_D: // Convert double to float (single).
1719
+ set_fpu_register_float(fd_reg, static_cast<float>(fs));
1720
+ break;
1721
+ case CVT_L_D: // Mips32r2: Truncate double to 64-bit long-word.
1722
+ i64 = static_cast<int64_t>(fs);
1723
+ set_fpu_register(fd_reg, i64 & 0xffffffff);
1724
+ set_fpu_register(fd_reg + 1, i64 >> 32);
1725
+ break;
1726
+ case TRUNC_L_D: // Mips32r2 instruction.
1727
+ i64 = static_cast<int64_t>(fs);
1728
+ set_fpu_register(fd_reg, i64 & 0xffffffff);
1729
+ set_fpu_register(fd_reg + 1, i64 >> 32);
1730
+ break;
1731
+ case ROUND_L_D: { // Mips32r2 instruction.
1732
+ double rounded = fs > 0 ? floor(fs + 0.5) : ceil(fs - 0.5);
1733
+ i64 = static_cast<int64_t>(rounded);
1734
+ set_fpu_register(fd_reg, i64 & 0xffffffff);
1735
+ set_fpu_register(fd_reg + 1, i64 >> 32);
1736
+ break;
1737
+ }
1738
+ case FLOOR_L_D: // Mips32r2 instruction.
1739
+ i64 = static_cast<int64_t>(floor(fs));
1740
+ set_fpu_register(fd_reg, i64 & 0xffffffff);
1741
+ set_fpu_register(fd_reg + 1, i64 >> 32);
1742
+ break;
1743
+ case CEIL_L_D: // Mips32r2 instruction.
1744
+ i64 = static_cast<int64_t>(ceil(fs));
1745
+ set_fpu_register(fd_reg, i64 & 0xffffffff);
1746
+ set_fpu_register(fd_reg + 1, i64 >> 32);
1747
+ break;
1748
+ case C_F_D:
1749
+ UNIMPLEMENTED_MIPS();
1750
+ break;
1751
+ default:
1752
+ UNREACHABLE();
1753
+ }
1754
+ break;
1755
+ case W:
1756
+ switch (instr->FunctionFieldRaw()) {
1757
+ case CVT_S_W: // Convert word to float (single).
1758
+ alu_out = get_fpu_register(fs_reg);
1759
+ set_fpu_register_float(fd_reg, static_cast<float>(alu_out));
1760
+ break;
1761
+ case CVT_D_W: // Convert word to double.
1762
+ alu_out = get_fpu_register(fs_reg);
1763
+ set_fpu_register_double(fd_reg, static_cast<double>(alu_out));
1764
+ break;
1765
+ default:
1766
+ UNREACHABLE();
1767
+ };
1768
+ break;
1769
+ case L:
1770
+ switch (instr->FunctionFieldRaw()) {
1771
+ case CVT_D_L: // Mips32r2 instruction.
1772
+ // Watch the signs here, we want 2 32-bit vals
1773
+ // to make a sign-64.
1774
+ i64 = (uint32_t) get_fpu_register(fs_reg);
1775
+ i64 |= ((int64_t) get_fpu_register(fs_reg + 1) << 32);
1776
+ set_fpu_register_double(fd_reg, static_cast<double>(i64));
1777
+ break;
1778
+ case CVT_S_L:
1779
+ UNIMPLEMENTED_MIPS();
1780
+ break;
1781
+ default:
1782
+ UNREACHABLE();
1783
+ }
1784
+ break;
1785
+ case PS:
1786
+ break;
1787
+ default:
1788
+ UNREACHABLE();
1789
+ };
1790
+ break;
1791
+ case SPECIAL:
1792
+ switch (instr->FunctionFieldRaw()) {
1793
+ case JR: {
1794
+ Instruction* branch_delay_instr = reinterpret_cast<Instruction*>(
1795
+ current_pc+Instruction::kInstrSize);
1796
+ BranchDelayInstructionDecode(branch_delay_instr);
1797
+ set_pc(next_pc);
1798
+ pc_modified_ = true;
1799
+ break;
1800
+ }
1801
+ case JALR: {
1802
+ Instruction* branch_delay_instr = reinterpret_cast<Instruction*>(
1803
+ current_pc+Instruction::kInstrSize);
1804
+ BranchDelayInstructionDecode(branch_delay_instr);
1805
+ set_register(31, current_pc + 2* Instruction::kInstrSize);
1806
+ set_pc(next_pc);
1807
+ pc_modified_ = true;
1808
+ break;
1809
+ }
1810
+ // Instructions using HI and LO registers.
1811
+ case MULT:
1812
+ set_register(LO, static_cast<int32_t>(i64hilo & 0xffffffff));
1813
+ set_register(HI, static_cast<int32_t>(i64hilo >> 32));
1814
+ break;
1815
+ case MULTU:
1816
+ set_register(LO, static_cast<int32_t>(u64hilo & 0xffffffff));
1817
+ set_register(HI, static_cast<int32_t>(u64hilo >> 32));
1818
+ break;
1819
+ case DIV:
1820
+ // Divide by zero was checked in the configuration step.
1821
+ set_register(LO, rs / rt);
1822
+ set_register(HI, rs % rt);
1823
+ break;
1824
+ case DIVU:
1825
+ set_register(LO, rs_u / rt_u);
1826
+ set_register(HI, rs_u % rt_u);
1827
+ break;
1828
+ // Break and trap instructions.
1829
+ case BREAK:
1830
+ case TGE:
1831
+ case TGEU:
1832
+ case TLT:
1833
+ case TLTU:
1834
+ case TEQ:
1835
+ case TNE:
1836
+ if (do_interrupt) {
1837
+ SoftwareInterrupt(instr);
1838
+ }
1839
+ break;
1840
+ // Conditional moves.
1841
+ case MOVN:
1842
+ if (rt) set_register(rd_reg, rs);
1843
+ break;
1844
+ case MOVCI: {
1845
+ uint32_t cc = instr->FCccValue();
1846
+ uint32_t fcsr_cc = get_fcsr_condition_bit(cc);
1847
+ if (instr->Bit(16)) { // Read Tf bit
1848
+ if (test_fcsr_bit(fcsr_cc)) set_register(rd_reg, rs);
1849
+ } else {
1850
+ if (!test_fcsr_bit(fcsr_cc)) set_register(rd_reg, rs);
1851
+ }
1852
+ break;
1853
+ }
1854
+ case MOVZ:
1855
+ if (!rt) set_register(rd_reg, rs);
1856
+ break;
1857
+ default: // For other special opcodes we do the default operation.
1858
+ set_register(rd_reg, alu_out);
1859
+ };
1860
+ break;
1861
+ case SPECIAL2:
1862
+ switch (instr->FunctionFieldRaw()) {
1863
+ case MUL:
1864
+ set_register(rd_reg, alu_out);
1865
+ // HI and LO are UNPREDICTABLE after the operation.
1866
+ set_register(LO, Unpredictable);
1867
+ set_register(HI, Unpredictable);
1868
+ break;
1869
+ default: // For other special2 opcodes we do the default operation.
1870
+ set_register(rd_reg, alu_out);
1871
+ }
1872
+ break;
1873
+ case SPECIAL3:
1874
+ switch (instr->FunctionFieldRaw()) {
1875
+ case INS:
1876
+ // Ins instr leaves result in Rt, rather than Rd.
1877
+ set_register(rt_reg, alu_out);
1878
+ break;
1879
+ case EXT:
1880
+ // Ext instr leaves result in Rt, rather than Rd.
1881
+ set_register(rt_reg, alu_out);
1882
+ break;
1883
+ default:
1884
+ UNREACHABLE();
1885
+ };
1886
+ break;
1887
+ // Unimplemented opcodes raised an error in the configuration step before,
1888
+ // so we can use the default here to set the destination register in common
1889
+ // cases.
1890
+ default:
1891
+ set_register(rd_reg, alu_out);
1892
+ };
1893
+ }
1894
+
1895
+
1896
+ // Type 2: instructions using a 16 bytes immediate. (eg: addi, beq)
1897
+ void Simulator::DecodeTypeImmediate(Instruction* instr) {
1898
+ // Instruction fields.
1899
+ Opcode op = instr->OpcodeFieldRaw();
1900
+ int32_t rs = get_register(instr->RsValue());
1901
+ uint32_t rs_u = static_cast<uint32_t>(rs);
1902
+ int32_t rt_reg = instr->RtValue(); // destination register
1903
+ int32_t rt = get_register(rt_reg);
1904
+ int16_t imm16 = instr->Imm16Value();
1905
+
1906
+ int32_t ft_reg = instr->FtValue(); // destination register
1907
+
1908
+ // Zero extended immediate.
1909
+ uint32_t oe_imm16 = 0xffff & imm16;
1910
+ // Sign extended immediate.
1911
+ int32_t se_imm16 = imm16;
1912
+
1913
+ // Get current pc.
1914
+ int32_t current_pc = get_pc();
1915
+ // Next pc.
1916
+ int32_t next_pc = bad_ra;
1917
+
1918
+ // Used for conditional branch instructions.
1919
+ bool do_branch = false;
1920
+ bool execute_branch_delay_instruction = false;
1921
+
1922
+ // Used for arithmetic instructions.
1923
+ int32_t alu_out = 0;
1924
+ // Floating point.
1925
+ double fp_out = 0.0;
1926
+ uint32_t cc, cc_value, fcsr_cc;
1927
+
1928
+ // Used for memory instructions.
1929
+ int32_t addr = 0x0;
1930
+ // Value to be written in memory
1931
+ uint32_t mem_value = 0x0;
1932
+
1933
+ // ---------- Configuration (and execution for REGIMM)
1934
+ switch (op) {
1935
+ // ------------- COP1. Coprocessor instructions.
1936
+ case COP1:
1937
+ switch (instr->RsFieldRaw()) {
1938
+ case BC1: // Branch on coprocessor condition.
1939
+ cc = instr->FBccValue();
1940
+ fcsr_cc = get_fcsr_condition_bit(cc);
1941
+ cc_value = test_fcsr_bit(fcsr_cc);
1942
+ do_branch = (instr->FBtrueValue()) ? cc_value : !cc_value;
1943
+ execute_branch_delay_instruction = true;
1944
+ // Set next_pc
1945
+ if (do_branch) {
1946
+ next_pc = current_pc + (imm16 << 2) + Instruction::kInstrSize;
1947
+ } else {
1948
+ next_pc = current_pc + kBranchReturnOffset;
1949
+ }
1950
+ break;
1951
+ default:
1952
+ UNREACHABLE();
1953
+ };
1954
+ break;
1955
+ // ------------- REGIMM class
1956
+ case REGIMM:
1957
+ switch (instr->RtFieldRaw()) {
1958
+ case BLTZ:
1959
+ do_branch = (rs < 0);
1960
+ break;
1961
+ case BLTZAL:
1962
+ do_branch = rs < 0;
1963
+ break;
1964
+ case BGEZ:
1965
+ do_branch = rs >= 0;
1966
+ break;
1967
+ case BGEZAL:
1968
+ do_branch = rs >= 0;
1969
+ break;
1970
+ default:
1971
+ UNREACHABLE();
1972
+ };
1973
+ switch (instr->RtFieldRaw()) {
1974
+ case BLTZ:
1975
+ case BLTZAL:
1976
+ case BGEZ:
1977
+ case BGEZAL:
1978
+ // Branch instructions common part.
1979
+ execute_branch_delay_instruction = true;
1980
+ // Set next_pc
1981
+ if (do_branch) {
1982
+ next_pc = current_pc + (imm16 << 2) + Instruction::kInstrSize;
1983
+ if (instr->IsLinkingInstruction()) {
1984
+ set_register(31, current_pc + kBranchReturnOffset);
1985
+ }
1986
+ } else {
1987
+ next_pc = current_pc + kBranchReturnOffset;
1988
+ }
1989
+ default:
1990
+ break;
1991
+ };
1992
+ break; // case REGIMM
1993
+ // ------------- Branch instructions
1994
+ // When comparing to zero, the encoding of rt field is always 0, so we don't
1995
+ // need to replace rt with zero.
1996
+ case BEQ:
1997
+ do_branch = (rs == rt);
1998
+ break;
1999
+ case BNE:
2000
+ do_branch = rs != rt;
2001
+ break;
2002
+ case BLEZ:
2003
+ do_branch = rs <= 0;
2004
+ break;
2005
+ case BGTZ:
2006
+ do_branch = rs > 0;
2007
+ break;
2008
+ // ------------- Arithmetic instructions
2009
+ case ADDI:
2010
+ if (HaveSameSign(rs, se_imm16)) {
2011
+ if (rs > 0) {
2012
+ exceptions[kIntegerOverflow] = rs > (Registers::kMaxValue - se_imm16);
2013
+ } else if (rs < 0) {
2014
+ exceptions[kIntegerUnderflow] =
2015
+ rs < (Registers::kMinValue - se_imm16);
2016
+ }
2017
+ }
2018
+ alu_out = rs + se_imm16;
2019
+ break;
2020
+ case ADDIU:
2021
+ alu_out = rs + se_imm16;
2022
+ break;
2023
+ case SLTI:
2024
+ alu_out = (rs < se_imm16) ? 1 : 0;
2025
+ break;
2026
+ case SLTIU:
2027
+ alu_out = (rs_u < static_cast<uint32_t>(se_imm16)) ? 1 : 0;
2028
+ break;
2029
+ case ANDI:
2030
+ alu_out = rs & oe_imm16;
2031
+ break;
2032
+ case ORI:
2033
+ alu_out = rs | oe_imm16;
2034
+ break;
2035
+ case XORI:
2036
+ alu_out = rs ^ oe_imm16;
2037
+ break;
2038
+ case LUI:
2039
+ alu_out = (oe_imm16 << 16);
2040
+ break;
2041
+ // ------------- Memory instructions
2042
+ case LB:
2043
+ addr = rs + se_imm16;
2044
+ alu_out = ReadB(addr);
2045
+ break;
2046
+ case LH:
2047
+ addr = rs + se_imm16;
2048
+ alu_out = ReadH(addr, instr);
2049
+ break;
2050
+ case LWL: {
2051
+ // al_offset is an offset of the effective address within an aligned word
2052
+ uint8_t al_offset = (rs + se_imm16) & kPointerAlignmentMask;
2053
+ uint8_t byte_shift = kPointerAlignmentMask - al_offset;
2054
+ uint32_t mask = (1 << byte_shift * 8) - 1;
2055
+ addr = rs + se_imm16 - al_offset;
2056
+ alu_out = ReadW(addr, instr);
2057
+ alu_out <<= byte_shift * 8;
2058
+ alu_out |= rt & mask;
2059
+ break;
2060
+ }
2061
+ case LW:
2062
+ addr = rs + se_imm16;
2063
+ alu_out = ReadW(addr, instr);
2064
+ break;
2065
+ case LBU:
2066
+ addr = rs + se_imm16;
2067
+ alu_out = ReadBU(addr);
2068
+ break;
2069
+ case LHU:
2070
+ addr = rs + se_imm16;
2071
+ alu_out = ReadHU(addr, instr);
2072
+ break;
2073
+ case LWR: {
2074
+ // al_offset is an offset of the effective address within an aligned word
2075
+ uint8_t al_offset = (rs + se_imm16) & kPointerAlignmentMask;
2076
+ uint8_t byte_shift = kPointerAlignmentMask - al_offset;
2077
+ uint32_t mask = al_offset ? (~0 << (byte_shift + 1) * 8) : 0;
2078
+ addr = rs + se_imm16 - al_offset;
2079
+ alu_out = ReadW(addr, instr);
2080
+ alu_out = static_cast<uint32_t> (alu_out) >> al_offset * 8;
2081
+ alu_out |= rt & mask;
2082
+ break;
2083
+ }
2084
+ case SB:
2085
+ addr = rs + se_imm16;
2086
+ break;
2087
+ case SH:
2088
+ addr = rs + se_imm16;
2089
+ break;
2090
+ case SWL: {
2091
+ uint8_t al_offset = (rs + se_imm16) & kPointerAlignmentMask;
2092
+ uint8_t byte_shift = kPointerAlignmentMask - al_offset;
2093
+ uint32_t mask = byte_shift ? (~0 << (al_offset + 1) * 8) : 0;
2094
+ addr = rs + se_imm16 - al_offset;
2095
+ mem_value = ReadW(addr, instr) & mask;
2096
+ mem_value |= static_cast<uint32_t>(rt) >> byte_shift * 8;
2097
+ break;
2098
+ }
2099
+ case SW:
2100
+ addr = rs + se_imm16;
2101
+ break;
2102
+ case SWR: {
2103
+ uint8_t al_offset = (rs + se_imm16) & kPointerAlignmentMask;
2104
+ uint32_t mask = (1 << al_offset * 8) - 1;
2105
+ addr = rs + se_imm16 - al_offset;
2106
+ mem_value = ReadW(addr, instr);
2107
+ mem_value = (rt << al_offset * 8) | (mem_value & mask);
2108
+ break;
2109
+ }
2110
+ case LWC1:
2111
+ addr = rs + se_imm16;
2112
+ alu_out = ReadW(addr, instr);
2113
+ break;
2114
+ case LDC1:
2115
+ addr = rs + se_imm16;
2116
+ fp_out = ReadD(addr, instr);
2117
+ break;
2118
+ case SWC1:
2119
+ case SDC1:
2120
+ addr = rs + se_imm16;
2121
+ break;
2122
+ default:
2123
+ UNREACHABLE();
2124
+ };
2125
+
2126
+ // ---------- Raise exceptions triggered.
2127
+ SignalExceptions();
2128
+
2129
+ // ---------- Execution
2130
+ switch (op) {
2131
+ // ------------- Branch instructions
2132
+ case BEQ:
2133
+ case BNE:
2134
+ case BLEZ:
2135
+ case BGTZ:
2136
+ // Branch instructions common part.
2137
+ execute_branch_delay_instruction = true;
2138
+ // Set next_pc
2139
+ if (do_branch) {
2140
+ next_pc = current_pc + (imm16 << 2) + Instruction::kInstrSize;
2141
+ if (instr->IsLinkingInstruction()) {
2142
+ set_register(31, current_pc + 2* Instruction::kInstrSize);
2143
+ }
2144
+ } else {
2145
+ next_pc = current_pc + 2 * Instruction::kInstrSize;
2146
+ }
2147
+ break;
2148
+ // ------------- Arithmetic instructions
2149
+ case ADDI:
2150
+ case ADDIU:
2151
+ case SLTI:
2152
+ case SLTIU:
2153
+ case ANDI:
2154
+ case ORI:
2155
+ case XORI:
2156
+ case LUI:
2157
+ set_register(rt_reg, alu_out);
2158
+ break;
2159
+ // ------------- Memory instructions
2160
+ case LB:
2161
+ case LH:
2162
+ case LWL:
2163
+ case LW:
2164
+ case LBU:
2165
+ case LHU:
2166
+ case LWR:
2167
+ set_register(rt_reg, alu_out);
2168
+ break;
2169
+ case SB:
2170
+ WriteB(addr, static_cast<int8_t>(rt));
2171
+ break;
2172
+ case SH:
2173
+ WriteH(addr, static_cast<uint16_t>(rt), instr);
2174
+ break;
2175
+ case SWL:
2176
+ WriteW(addr, mem_value, instr);
2177
+ break;
2178
+ case SW:
2179
+ WriteW(addr, rt, instr);
2180
+ break;
2181
+ case SWR:
2182
+ WriteW(addr, mem_value, instr);
2183
+ break;
2184
+ case LWC1:
2185
+ set_fpu_register(ft_reg, alu_out);
2186
+ break;
2187
+ case LDC1:
2188
+ set_fpu_register_double(ft_reg, fp_out);
2189
+ break;
2190
+ case SWC1:
2191
+ addr = rs + se_imm16;
2192
+ WriteW(addr, get_fpu_register(ft_reg), instr);
2193
+ break;
2194
+ case SDC1:
2195
+ addr = rs + se_imm16;
2196
+ WriteD(addr, get_fpu_register_double(ft_reg), instr);
2197
+ break;
2198
+ default:
2199
+ break;
2200
+ };
2201
+
2202
+
2203
+ if (execute_branch_delay_instruction) {
2204
+ // Execute branch delay slot
2205
+ // We don't check for end_sim_pc. First it should not be met as the current
2206
+ // pc is valid. Secondly a jump should always execute its branch delay slot.
2207
+ Instruction* branch_delay_instr =
2208
+ reinterpret_cast<Instruction*>(current_pc+Instruction::kInstrSize);
2209
+ BranchDelayInstructionDecode(branch_delay_instr);
2210
+ }
2211
+
2212
+ // If needed update pc after the branch delay execution.
2213
+ if (next_pc != bad_ra) {
2214
+ set_pc(next_pc);
2215
+ }
2216
+ }
2217
+
2218
+
2219
+ // Type 3: instructions using a 26 bytes immediate. (eg: j, jal)
2220
+ void Simulator::DecodeTypeJump(Instruction* instr) {
2221
+ // Get current pc.
2222
+ int32_t current_pc = get_pc();
2223
+ // Get unchanged bits of pc.
2224
+ int32_t pc_high_bits = current_pc & 0xf0000000;
2225
+ // Next pc
2226
+ int32_t next_pc = pc_high_bits | (instr->Imm26Value() << 2);
2227
+
2228
+ // Execute branch delay slot
2229
+ // We don't check for end_sim_pc. First it should not be met as the current pc
2230
+ // is valid. Secondly a jump should always execute its branch delay slot.
2231
+ Instruction* branch_delay_instr =
2232
+ reinterpret_cast<Instruction*>(current_pc+Instruction::kInstrSize);
2233
+ BranchDelayInstructionDecode(branch_delay_instr);
2234
+
2235
+ // Update pc and ra if necessary.
2236
+ // Do this after the branch delay execution.
2237
+ if (instr->IsLinkingInstruction()) {
2238
+ set_register(31, current_pc + 2* Instruction::kInstrSize);
2239
+ }
2240
+ set_pc(next_pc);
2241
+ pc_modified_ = true;
2242
+ }
2243
+
2244
+
2245
+ // Executes the current instruction.
2246
+ void Simulator::InstructionDecode(Instruction* instr) {
2247
+ if (v8::internal::FLAG_check_icache) {
2248
+ CheckICache(isolate_->simulator_i_cache(), instr);
2249
+ }
2250
+ pc_modified_ = false;
2251
+ if (::v8::internal::FLAG_trace_sim) {
2252
+ disasm::NameConverter converter;
2253
+ disasm::Disassembler dasm(converter);
2254
+ // use a reasonably large buffer
2255
+ v8::internal::EmbeddedVector<char, 256> buffer;
2256
+ dasm.InstructionDecode(buffer, reinterpret_cast<byte_*>(instr));
2257
+ PrintF(" 0x%08x %s\n", reinterpret_cast<intptr_t>(instr),
2258
+ buffer.start());
2259
+ }
2260
+
2261
+ switch (instr->InstructionType()) {
2262
+ case Instruction::kRegisterType:
2263
+ DecodeTypeRegister(instr);
2264
+ break;
2265
+ case Instruction::kImmediateType:
2266
+ DecodeTypeImmediate(instr);
2267
+ break;
2268
+ case Instruction::kJumpType:
2269
+ DecodeTypeJump(instr);
2270
+ break;
2271
+ default:
2272
+ UNSUPPORTED();
2273
+ }
2274
+ if (!pc_modified_) {
2275
+ set_register(pc, reinterpret_cast<int32_t>(instr) +
2276
+ Instruction::kInstrSize);
2277
+ }
2278
+ }
2279
+
2280
+
2281
+
2282
+ void Simulator::Execute() {
2283
+ // Get the PC to simulate. Cannot use the accessor here as we need the
2284
+ // raw PC value and not the one used as input to arithmetic instructions.
2285
+ int program_counter = get_pc();
2286
+ if (::v8::internal::FLAG_stop_sim_at == 0) {
2287
+ // Fast version of the dispatch loop without checking whether the simulator
2288
+ // should be stopping at a particular executed instruction.
2289
+ while (program_counter != end_sim_pc) {
2290
+ Instruction* instr = reinterpret_cast<Instruction*>(program_counter);
2291
+ icount_++;
2292
+ InstructionDecode(instr);
2293
+ program_counter = get_pc();
2294
+ }
2295
+ } else {
2296
+ // FLAG_stop_sim_at is at the non-default value. Stop in the debugger when
2297
+ // we reach the particular instuction count.
2298
+ while (program_counter != end_sim_pc) {
2299
+ Instruction* instr = reinterpret_cast<Instruction*>(program_counter);
2300
+ icount_++;
2301
+ if (icount_ == ::v8::internal::FLAG_stop_sim_at) {
2302
+ MipsDebugger dbg(this);
2303
+ dbg.Debug();
2304
+ } else {
2305
+ InstructionDecode(instr);
2306
+ }
2307
+ program_counter = get_pc();
2308
+ }
2309
+ }
2310
+ }
2311
+
2312
+
2313
+ int32_t Simulator::Call(byte_* entry, int argument_count, ...) {
2314
+ va_list parameters;
2315
+ va_start(parameters, argument_count);
2316
+ // Setup arguments
2317
+
2318
+ // First four arguments passed in registers.
2319
+ ASSERT(argument_count >= 4);
2320
+ set_register(a0, va_arg(parameters, int32_t));
2321
+ set_register(a1, va_arg(parameters, int32_t));
2322
+ set_register(a2, va_arg(parameters, int32_t));
2323
+ set_register(a3, va_arg(parameters, int32_t));
2324
+
2325
+ // Remaining arguments passed on stack.
2326
+ int original_stack = get_register(sp);
2327
+ // Compute position of stack on entry to generated code.
2328
+ int entry_stack = (original_stack - (argument_count - 4) * sizeof(int32_t)
2329
+ - kCArgsSlotsSize);
2330
+ if (OS::ActivationFrameAlignment() != 0) {
2331
+ entry_stack &= -OS::ActivationFrameAlignment();
2332
+ }
2333
+ // Store remaining arguments on stack, from low to high memory.
2334
+ intptr_t* stack_argument = reinterpret_cast<intptr_t*>(entry_stack);
2335
+ for (int i = 4; i < argument_count; i++) {
2336
+ stack_argument[i - 4 + kArgsSlotsNum] = va_arg(parameters, int32_t);
2337
+ }
2338
+ va_end(parameters);
2339
+ set_register(sp, entry_stack);
2340
+
2341
+ // Prepare to execute the code at entry
2342
+ set_register(pc, reinterpret_cast<int32_t>(entry));
2343
+ // Put down marker for end of simulation. The simulator will stop simulation
2344
+ // when the PC reaches this value. By saving the "end simulation" value into
2345
+ // the LR the simulation stops when returning to this call point.
2346
+ set_register(ra, end_sim_pc);
2347
+
2348
+ // Remember the values of callee-saved registers.
2349
+ // The code below assumes that r9 is not used as sb (static base) in
2350
+ // simulator code and therefore is regarded as a callee-saved register.
2351
+ int32_t s0_val = get_register(s0);
2352
+ int32_t s1_val = get_register(s1);
2353
+ int32_t s2_val = get_register(s2);
2354
+ int32_t s3_val = get_register(s3);
2355
+ int32_t s4_val = get_register(s4);
2356
+ int32_t s5_val = get_register(s5);
2357
+ int32_t s6_val = get_register(s6);
2358
+ int32_t s7_val = get_register(s7);
2359
+ int32_t gp_val = get_register(gp);
2360
+ int32_t sp_val = get_register(sp);
2361
+ int32_t fp_val = get_register(fp);
2362
+
2363
+ // Setup the callee-saved registers with a known value. To be able to check
2364
+ // that they are preserved properly across JS execution.
2365
+ int32_t callee_saved_value = icount_;
2366
+ set_register(s0, callee_saved_value);
2367
+ set_register(s1, callee_saved_value);
2368
+ set_register(s2, callee_saved_value);
2369
+ set_register(s3, callee_saved_value);
2370
+ set_register(s4, callee_saved_value);
2371
+ set_register(s5, callee_saved_value);
2372
+ set_register(s6, callee_saved_value);
2373
+ set_register(s7, callee_saved_value);
2374
+ set_register(gp, callee_saved_value);
2375
+ set_register(fp, callee_saved_value);
2376
+
2377
+ // Start the simulation
2378
+ Execute();
2379
+
2380
+ // Check that the callee-saved registers have been preserved.
2381
+ CHECK_EQ(callee_saved_value, get_register(s0));
2382
+ CHECK_EQ(callee_saved_value, get_register(s1));
2383
+ CHECK_EQ(callee_saved_value, get_register(s2));
2384
+ CHECK_EQ(callee_saved_value, get_register(s3));
2385
+ CHECK_EQ(callee_saved_value, get_register(s4));
2386
+ CHECK_EQ(callee_saved_value, get_register(s5));
2387
+ CHECK_EQ(callee_saved_value, get_register(s6));
2388
+ CHECK_EQ(callee_saved_value, get_register(s7));
2389
+ CHECK_EQ(callee_saved_value, get_register(gp));
2390
+ CHECK_EQ(callee_saved_value, get_register(fp));
2391
+
2392
+ // Restore callee-saved registers with the original value.
2393
+ set_register(s0, s0_val);
2394
+ set_register(s1, s1_val);
2395
+ set_register(s2, s2_val);
2396
+ set_register(s3, s3_val);
2397
+ set_register(s4, s4_val);
2398
+ set_register(s5, s5_val);
2399
+ set_register(s6, s6_val);
2400
+ set_register(s7, s7_val);
2401
+ set_register(gp, gp_val);
2402
+ set_register(sp, sp_val);
2403
+ set_register(fp, fp_val);
2404
+
2405
+ // Pop stack passed arguments.
2406
+ CHECK_EQ(entry_stack, get_register(sp));
2407
+ set_register(sp, original_stack);
2408
+
2409
+ int32_t result = get_register(v0);
2410
+ return result;
2411
+ }
2412
+
2413
+
2414
+ uintptr_t Simulator::PushAddress(uintptr_t address) {
2415
+ int new_sp = get_register(sp) - sizeof(uintptr_t);
2416
+ uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(new_sp);
2417
+ *stack_slot = address;
2418
+ set_register(sp, new_sp);
2419
+ return new_sp;
2420
+ }
2421
+
2422
+
2423
+ uintptr_t Simulator::PopAddress() {
2424
+ int current_sp = get_register(sp);
2425
+ uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp);
2426
+ uintptr_t address = *stack_slot;
2427
+ set_register(sp, current_sp + sizeof(uintptr_t));
2428
+ return address;
2429
+ }
2430
+
2431
+
2432
+ #undef UNSUPPORTED
2433
+
2434
+ } } // namespace v8::internal
2435
+
2436
+ #endif // USE_SIMULATOR
2437
+
2438
+ #endif // V8_TARGET_ARCH_MIPS