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,3970 @@
1
+ // Copyright 2011 the V8 project authors. All rights reserved.
2
+ // Redistribution and use in source and binary forms, with or without
3
+ // modification, are permitted provided that the following conditions are
4
+ // met:
5
+ //
6
+ // * Redistributions of source code must retain the above copyright
7
+ // notice, this list of conditions and the following disclaimer.
8
+ // * Redistributions in binary form must reproduce the above
9
+ // copyright notice, this list of conditions and the following
10
+ // disclaimer in the documentation and/or other materials provided
11
+ // with the distribution.
12
+ // * Neither the name of Google Inc. nor the names of its
13
+ // contributors may be used to endorse or promote products derived
14
+ // from this software without specific prior written permission.
15
+ //
16
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+
28
+ #include "v8.h"
29
+
30
+ #if defined(V8_TARGET_ARCH_X64)
31
+
32
+ #include "x64/lithium-codegen-x64.h"
33
+ #include "code-stubs.h"
34
+ #include "stub-cache.h"
35
+
36
+ namespace v8 {
37
+ namespace internal {
38
+
39
+
40
+ // When invoking builtins, we need to record the safepoint in the middle of
41
+ // the invoke instruction sequence generated by the macro assembler.
42
+ class SafepointGenerator : public CallWrapper {
43
+ public:
44
+ SafepointGenerator(LCodeGen* codegen,
45
+ LPointerMap* pointers,
46
+ int deoptimization_index)
47
+ : codegen_(codegen),
48
+ pointers_(pointers),
49
+ deoptimization_index_(deoptimization_index) { }
50
+ virtual ~SafepointGenerator() { }
51
+
52
+ virtual void BeforeCall(int call_size) {
53
+ ASSERT(call_size >= 0);
54
+ // Ensure that we have enough space after the previous safepoint position
55
+ // for the jump generated there.
56
+ int call_end = codegen_->masm()->pc_offset() + call_size;
57
+ int prev_jump_end = codegen_->LastSafepointEnd() + kMinSafepointSize;
58
+ if (call_end < prev_jump_end) {
59
+ int padding_size = prev_jump_end - call_end;
60
+ STATIC_ASSERT(kMinSafepointSize <= 9); // One multibyte nop is enough.
61
+ codegen_->masm()->nop(padding_size);
62
+ }
63
+ }
64
+
65
+ virtual void AfterCall() {
66
+ codegen_->RecordSafepoint(pointers_, deoptimization_index_);
67
+ }
68
+
69
+ private:
70
+ static const int kMinSafepointSize =
71
+ MacroAssembler::kShortCallInstructionLength;
72
+ LCodeGen* codegen_;
73
+ LPointerMap* pointers_;
74
+ int deoptimization_index_;
75
+ };
76
+
77
+
78
+ #define __ masm()->
79
+
80
+ bool LCodeGen::GenerateCode() {
81
+ HPhase phase("Code generation", chunk());
82
+ ASSERT(is_unused());
83
+ status_ = GENERATING;
84
+ return GeneratePrologue() &&
85
+ GenerateBody() &&
86
+ GenerateDeferredCode() &&
87
+ GenerateJumpTable() &&
88
+ GenerateSafepointTable();
89
+ }
90
+
91
+
92
+ void LCodeGen::FinishCode(Handle<Code> code) {
93
+ ASSERT(is_done());
94
+ code->set_stack_slots(StackSlotCount());
95
+ code->set_safepoint_table_offset(safepoints_.GetCodeOffset());
96
+ PopulateDeoptimizationData(code);
97
+ Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(code);
98
+ }
99
+
100
+
101
+ void LCodeGen::Abort(const char* format, ...) {
102
+ if (FLAG_trace_bailout) {
103
+ SmartPointer<char> name(info()->shared_info()->DebugName()->ToCString());
104
+ PrintF("Aborting LCodeGen in @\"%s\": ", *name);
105
+ va_list arguments;
106
+ va_start(arguments, format);
107
+ OS::VPrint(format, arguments);
108
+ va_end(arguments);
109
+ PrintF("\n");
110
+ }
111
+ status_ = ABORTED;
112
+ }
113
+
114
+
115
+ void LCodeGen::Comment(const char* format, ...) {
116
+ if (!FLAG_code_comments) return;
117
+ char buffer[4 * KB];
118
+ StringBuilder builder(buffer, ARRAY_SIZE(buffer));
119
+ va_list arguments;
120
+ va_start(arguments, format);
121
+ builder.AddFormattedList(format, arguments);
122
+ va_end(arguments);
123
+
124
+ // Copy the string before recording it in the assembler to avoid
125
+ // issues when the stack allocated buffer goes out of scope.
126
+ int length = builder.position();
127
+ Vector<char> copy = Vector<char>::New(length + 1);
128
+ memcpy(copy.start(), builder.Finalize(), copy.length());
129
+ masm()->RecordComment(copy.start());
130
+ }
131
+
132
+
133
+ bool LCodeGen::GeneratePrologue() {
134
+ ASSERT(is_generating());
135
+
136
+ #ifdef DEBUG
137
+ if (strlen(FLAG_stop_at) > 0 &&
138
+ info_->function()->name()->IsEqualTo(CStrVector(FLAG_stop_at))) {
139
+ __ int3();
140
+ }
141
+ #endif
142
+
143
+ __ push(rbp); // Caller's frame pointer.
144
+ __ movq(rbp, rsp);
145
+ __ push(rsi); // Callee's context.
146
+ __ push(rdi); // Callee's JS function.
147
+
148
+ // Reserve space for the stack slots needed by the code.
149
+ int slots = StackSlotCount();
150
+ if (slots > 0) {
151
+ if (FLAG_debug_code) {
152
+ __ movl(rax, Immediate(slots));
153
+ __ movq(kScratchRegister, kSlotsZapValue, RelocInfo::NONE);
154
+ Label loop;
155
+ __ bind(&loop);
156
+ __ push(kScratchRegister);
157
+ __ decl(rax);
158
+ __ j(not_zero, &loop);
159
+ } else {
160
+ __ subq(rsp, Immediate(slots * kPointerSize));
161
+ #ifdef _MSC_VER
162
+ // On windows, you may not access the stack more than one page below
163
+ // the most recently mapped page. To make the allocated area randomly
164
+ // accessible, we write to each page in turn (the value is irrelevant).
165
+ const int kPageSize = 4 * KB;
166
+ for (int offset = slots * kPointerSize - kPageSize;
167
+ offset > 0;
168
+ offset -= kPageSize) {
169
+ __ movq(Operand(rsp, offset), rax);
170
+ }
171
+ #endif
172
+ }
173
+ }
174
+
175
+ // Possibly allocate a local context.
176
+ int heap_slots = scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS;
177
+ if (heap_slots > 0) {
178
+ Comment(";;; Allocate local context");
179
+ // Argument to NewContext is the function, which is still in rdi.
180
+ __ push(rdi);
181
+ if (heap_slots <= FastNewContextStub::kMaximumSlots) {
182
+ FastNewContextStub stub(heap_slots);
183
+ __ CallStub(&stub);
184
+ } else {
185
+ __ CallRuntime(Runtime::kNewContext, 1);
186
+ }
187
+ RecordSafepoint(Safepoint::kNoDeoptimizationIndex);
188
+ // Context is returned in both rax and rsi. It replaces the context
189
+ // passed to us. It's saved in the stack and kept live in rsi.
190
+ __ movq(Operand(rbp, StandardFrameConstants::kContextOffset), rsi);
191
+
192
+ // Copy any necessary parameters into the context.
193
+ int num_parameters = scope()->num_parameters();
194
+ for (int i = 0; i < num_parameters; i++) {
195
+ Slot* slot = scope()->parameter(i)->AsSlot();
196
+ if (slot != NULL && slot->type() == Slot::CONTEXT) {
197
+ int parameter_offset = StandardFrameConstants::kCallerSPOffset +
198
+ (num_parameters - 1 - i) * kPointerSize;
199
+ // Load parameter from stack.
200
+ __ movq(rax, Operand(rbp, parameter_offset));
201
+ // Store it in the context.
202
+ int context_offset = Context::SlotOffset(slot->index());
203
+ __ movq(Operand(rsi, context_offset), rax);
204
+ // Update the write barrier. This clobbers all involved
205
+ // registers, so we have use a third register to avoid
206
+ // clobbering rsi.
207
+ __ movq(rcx, rsi);
208
+ __ RecordWrite(rcx, context_offset, rax, rbx);
209
+ }
210
+ }
211
+ Comment(";;; End allocate local context");
212
+ }
213
+
214
+ // Trace the call.
215
+ if (FLAG_trace) {
216
+ __ CallRuntime(Runtime::kTraceEnter, 0);
217
+ }
218
+ return !is_aborted();
219
+ }
220
+
221
+
222
+ bool LCodeGen::GenerateBody() {
223
+ ASSERT(is_generating());
224
+ bool emit_instructions = true;
225
+ for (current_instruction_ = 0;
226
+ !is_aborted() && current_instruction_ < instructions_->length();
227
+ current_instruction_++) {
228
+ LInstruction* instr = instructions_->at(current_instruction_);
229
+ if (instr->IsLabel()) {
230
+ LLabel* label = LLabel::cast(instr);
231
+ emit_instructions = !label->HasReplacement();
232
+ }
233
+
234
+ if (emit_instructions) {
235
+ Comment(";;; @%d: %s.", current_instruction_, instr->Mnemonic());
236
+ instr->CompileToNative(this);
237
+ }
238
+ }
239
+ return !is_aborted();
240
+ }
241
+
242
+
243
+ LInstruction* LCodeGen::GetNextInstruction() {
244
+ if (current_instruction_ < instructions_->length() - 1) {
245
+ return instructions_->at(current_instruction_ + 1);
246
+ } else {
247
+ return NULL;
248
+ }
249
+ }
250
+
251
+
252
+ bool LCodeGen::GenerateJumpTable() {
253
+ for (int i = 0; i < jump_table_.length(); i++) {
254
+ __ bind(&jump_table_[i].label);
255
+ __ Jump(jump_table_[i].address, RelocInfo::RUNTIME_ENTRY);
256
+ }
257
+ return !is_aborted();
258
+ }
259
+
260
+
261
+ bool LCodeGen::GenerateDeferredCode() {
262
+ ASSERT(is_generating());
263
+ for (int i = 0; !is_aborted() && i < deferred_.length(); i++) {
264
+ LDeferredCode* code = deferred_[i];
265
+ __ bind(code->entry());
266
+ code->Generate();
267
+ __ jmp(code->exit());
268
+ }
269
+
270
+ // Deferred code is the last part of the instruction sequence. Mark
271
+ // the generated code as done unless we bailed out.
272
+ if (!is_aborted()) status_ = DONE;
273
+ return !is_aborted();
274
+ }
275
+
276
+
277
+ bool LCodeGen::GenerateSafepointTable() {
278
+ ASSERT(is_done());
279
+ // Ensure that there is space at the end of the code to write a number
280
+ // of jump instructions, as well as to afford writing a call near the end
281
+ // of the code.
282
+ // The jumps are used when there isn't room in the code stream to write
283
+ // a long call instruction. Instead it writes a shorter call to a
284
+ // jump instruction in the same code object.
285
+ // The calls are used when lazy deoptimizing a function and calls to a
286
+ // deoptimization function.
287
+ int short_deopts = safepoints_.CountShortDeoptimizationIntervals(
288
+ static_cast<unsigned>(MacroAssembler::kJumpInstructionLength));
289
+ int byte_count = (short_deopts) * MacroAssembler::kJumpInstructionLength;
290
+ while (byte_count-- > 0) {
291
+ __ int3();
292
+ }
293
+ safepoints_.Emit(masm(), StackSlotCount());
294
+ return !is_aborted();
295
+ }
296
+
297
+
298
+ Register LCodeGen::ToRegister(int index) const {
299
+ return Register::FromAllocationIndex(index);
300
+ }
301
+
302
+
303
+ XMMRegister LCodeGen::ToDoubleRegister(int index) const {
304
+ return XMMRegister::FromAllocationIndex(index);
305
+ }
306
+
307
+
308
+ Register LCodeGen::ToRegister(LOperand* op) const {
309
+ ASSERT(op->IsRegister());
310
+ return ToRegister(op->index());
311
+ }
312
+
313
+
314
+ XMMRegister LCodeGen::ToDoubleRegister(LOperand* op) const {
315
+ ASSERT(op->IsDoubleRegister());
316
+ return ToDoubleRegister(op->index());
317
+ }
318
+
319
+
320
+ bool LCodeGen::IsInteger32Constant(LConstantOperand* op) const {
321
+ return op->IsConstantOperand() &&
322
+ chunk_->LookupLiteralRepresentation(op).IsInteger32();
323
+ }
324
+
325
+
326
+ bool LCodeGen::IsTaggedConstant(LConstantOperand* op) const {
327
+ return op->IsConstantOperand() &&
328
+ chunk_->LookupLiteralRepresentation(op).IsTagged();
329
+ }
330
+
331
+
332
+ int LCodeGen::ToInteger32(LConstantOperand* op) const {
333
+ Handle<Object> value = chunk_->LookupLiteral(op);
334
+ ASSERT(chunk_->LookupLiteralRepresentation(op).IsInteger32());
335
+ ASSERT(static_cast<double>(static_cast<int32_t>(value->Number())) ==
336
+ value->Number());
337
+ return static_cast<int32_t>(value->Number());
338
+ }
339
+
340
+
341
+ Handle<Object> LCodeGen::ToHandle(LConstantOperand* op) const {
342
+ Handle<Object> literal = chunk_->LookupLiteral(op);
343
+ ASSERT(chunk_->LookupLiteralRepresentation(op).IsTagged());
344
+ return literal;
345
+ }
346
+
347
+
348
+ Operand LCodeGen::ToOperand(LOperand* op) const {
349
+ // Does not handle registers. In X64 assembler, plain registers are not
350
+ // representable as an Operand.
351
+ ASSERT(op->IsStackSlot() || op->IsDoubleStackSlot());
352
+ int index = op->index();
353
+ if (index >= 0) {
354
+ // Local or spill slot. Skip the frame pointer, function, and
355
+ // context in the fixed part of the frame.
356
+ return Operand(rbp, -(index + 3) * kPointerSize);
357
+ } else {
358
+ // Incoming parameter. Skip the return address.
359
+ return Operand(rbp, -(index - 1) * kPointerSize);
360
+ }
361
+ }
362
+
363
+
364
+ void LCodeGen::WriteTranslation(LEnvironment* environment,
365
+ Translation* translation) {
366
+ if (environment == NULL) return;
367
+
368
+ // The translation includes one command per value in the environment.
369
+ int translation_size = environment->values()->length();
370
+ // The output frame height does not include the parameters.
371
+ int height = translation_size - environment->parameter_count();
372
+
373
+ WriteTranslation(environment->outer(), translation);
374
+ int closure_id = DefineDeoptimizationLiteral(environment->closure());
375
+ translation->BeginFrame(environment->ast_id(), closure_id, height);
376
+ for (int i = 0; i < translation_size; ++i) {
377
+ LOperand* value = environment->values()->at(i);
378
+ // spilled_registers_ and spilled_double_registers_ are either
379
+ // both NULL or both set.
380
+ if (environment->spilled_registers() != NULL && value != NULL) {
381
+ if (value->IsRegister() &&
382
+ environment->spilled_registers()[value->index()] != NULL) {
383
+ translation->MarkDuplicate();
384
+ AddToTranslation(translation,
385
+ environment->spilled_registers()[value->index()],
386
+ environment->HasTaggedValueAt(i));
387
+ } else if (
388
+ value->IsDoubleRegister() &&
389
+ environment->spilled_double_registers()[value->index()] != NULL) {
390
+ translation->MarkDuplicate();
391
+ AddToTranslation(
392
+ translation,
393
+ environment->spilled_double_registers()[value->index()],
394
+ false);
395
+ }
396
+ }
397
+
398
+ AddToTranslation(translation, value, environment->HasTaggedValueAt(i));
399
+ }
400
+ }
401
+
402
+
403
+ void LCodeGen::AddToTranslation(Translation* translation,
404
+ LOperand* op,
405
+ bool is_tagged) {
406
+ if (op == NULL) {
407
+ // TODO(twuerthinger): Introduce marker operands to indicate that this value
408
+ // is not present and must be reconstructed from the deoptimizer. Currently
409
+ // this is only used for the arguments object.
410
+ translation->StoreArgumentsObject();
411
+ } else if (op->IsStackSlot()) {
412
+ if (is_tagged) {
413
+ translation->StoreStackSlot(op->index());
414
+ } else {
415
+ translation->StoreInt32StackSlot(op->index());
416
+ }
417
+ } else if (op->IsDoubleStackSlot()) {
418
+ translation->StoreDoubleStackSlot(op->index());
419
+ } else if (op->IsArgument()) {
420
+ ASSERT(is_tagged);
421
+ int src_index = StackSlotCount() + op->index();
422
+ translation->StoreStackSlot(src_index);
423
+ } else if (op->IsRegister()) {
424
+ Register reg = ToRegister(op);
425
+ if (is_tagged) {
426
+ translation->StoreRegister(reg);
427
+ } else {
428
+ translation->StoreInt32Register(reg);
429
+ }
430
+ } else if (op->IsDoubleRegister()) {
431
+ XMMRegister reg = ToDoubleRegister(op);
432
+ translation->StoreDoubleRegister(reg);
433
+ } else if (op->IsConstantOperand()) {
434
+ Handle<Object> literal = chunk()->LookupLiteral(LConstantOperand::cast(op));
435
+ int src_index = DefineDeoptimizationLiteral(literal);
436
+ translation->StoreLiteral(src_index);
437
+ } else {
438
+ UNREACHABLE();
439
+ }
440
+ }
441
+
442
+
443
+ void LCodeGen::CallCode(Handle<Code> code,
444
+ RelocInfo::Mode mode,
445
+ LInstruction* instr) {
446
+ ASSERT(instr != NULL);
447
+ LPointerMap* pointers = instr->pointer_map();
448
+ RecordPosition(pointers->position());
449
+ __ call(code, mode);
450
+ RegisterLazyDeoptimization(instr);
451
+
452
+ // Signal that we don't inline smi code before these stubs in the
453
+ // optimizing code generator.
454
+ if (code->kind() == Code::TYPE_RECORDING_BINARY_OP_IC ||
455
+ code->kind() == Code::COMPARE_IC) {
456
+ __ nop();
457
+ }
458
+ }
459
+
460
+
461
+ void LCodeGen::CallRuntime(const Runtime::Function* function,
462
+ int num_arguments,
463
+ LInstruction* instr) {
464
+ ASSERT(instr != NULL);
465
+ ASSERT(instr->HasPointerMap());
466
+ LPointerMap* pointers = instr->pointer_map();
467
+ RecordPosition(pointers->position());
468
+
469
+ __ CallRuntime(function, num_arguments);
470
+ RegisterLazyDeoptimization(instr);
471
+ }
472
+
473
+
474
+ void LCodeGen::RegisterLazyDeoptimization(LInstruction* instr) {
475
+ // Create the environment to bailout to. If the call has side effects
476
+ // execution has to continue after the call otherwise execution can continue
477
+ // from a previous bailout point repeating the call.
478
+ LEnvironment* deoptimization_environment;
479
+ if (instr->HasDeoptimizationEnvironment()) {
480
+ deoptimization_environment = instr->deoptimization_environment();
481
+ } else {
482
+ deoptimization_environment = instr->environment();
483
+ }
484
+
485
+ RegisterEnvironmentForDeoptimization(deoptimization_environment);
486
+ RecordSafepoint(instr->pointer_map(),
487
+ deoptimization_environment->deoptimization_index());
488
+ }
489
+
490
+
491
+ void LCodeGen::RegisterEnvironmentForDeoptimization(LEnvironment* environment) {
492
+ if (!environment->HasBeenRegistered()) {
493
+ // Physical stack frame layout:
494
+ // -x ............. -4 0 ..................................... y
495
+ // [incoming arguments] [spill slots] [pushed outgoing arguments]
496
+
497
+ // Layout of the environment:
498
+ // 0 ..................................................... size-1
499
+ // [parameters] [locals] [expression stack including arguments]
500
+
501
+ // Layout of the translation:
502
+ // 0 ........................................................ size - 1 + 4
503
+ // [expression stack including arguments] [locals] [4 words] [parameters]
504
+ // |>------------ translation_size ------------<|
505
+
506
+ int frame_count = 0;
507
+ for (LEnvironment* e = environment; e != NULL; e = e->outer()) {
508
+ ++frame_count;
509
+ }
510
+ Translation translation(&translations_, frame_count);
511
+ WriteTranslation(environment, &translation);
512
+ int deoptimization_index = deoptimizations_.length();
513
+ environment->Register(deoptimization_index, translation.index());
514
+ deoptimizations_.Add(environment);
515
+ }
516
+ }
517
+
518
+
519
+ void LCodeGen::DeoptimizeIf(Condition cc, LEnvironment* environment) {
520
+ RegisterEnvironmentForDeoptimization(environment);
521
+ ASSERT(environment->HasBeenRegistered());
522
+ int id = environment->deoptimization_index();
523
+ Address entry = Deoptimizer::GetDeoptimizationEntry(id, Deoptimizer::EAGER);
524
+ ASSERT(entry != NULL);
525
+ if (entry == NULL) {
526
+ Abort("bailout was not prepared");
527
+ return;
528
+ }
529
+
530
+ if (cc == no_condition) {
531
+ __ Jump(entry, RelocInfo::RUNTIME_ENTRY);
532
+ } else {
533
+ // We often have several deopts to the same entry, reuse the last
534
+ // jump entry if this is the case.
535
+ if (jump_table_.is_empty() ||
536
+ jump_table_.last().address != entry) {
537
+ jump_table_.Add(entry);
538
+ }
539
+ __ j(cc, &jump_table_.last().label);
540
+ }
541
+ }
542
+
543
+
544
+ void LCodeGen::PopulateDeoptimizationData(Handle<Code> code) {
545
+ int length = deoptimizations_.length();
546
+ if (length == 0) return;
547
+ ASSERT(FLAG_deopt);
548
+ Handle<DeoptimizationInputData> data =
549
+ factory()->NewDeoptimizationInputData(length, TENURED);
550
+
551
+ Handle<ByteArray> translations = translations_.CreateByteArray();
552
+ data->SetTranslationByteArray(*translations);
553
+ data->SetInlinedFunctionCount(Smi::FromInt(inlined_function_count_));
554
+
555
+ Handle<FixedArray> literals =
556
+ factory()->NewFixedArray(deoptimization_literals_.length(), TENURED);
557
+ for (int i = 0; i < deoptimization_literals_.length(); i++) {
558
+ literals->set(i, *deoptimization_literals_[i]);
559
+ }
560
+ data->SetLiteralArray(*literals);
561
+
562
+ data->SetOsrAstId(Smi::FromInt(info_->osr_ast_id()));
563
+ data->SetOsrPcOffset(Smi::FromInt(osr_pc_offset_));
564
+
565
+ // Populate the deoptimization entries.
566
+ for (int i = 0; i < length; i++) {
567
+ LEnvironment* env = deoptimizations_[i];
568
+ data->SetAstId(i, Smi::FromInt(env->ast_id()));
569
+ data->SetTranslationIndex(i, Smi::FromInt(env->translation_index()));
570
+ data->SetArgumentsStackHeight(i,
571
+ Smi::FromInt(env->arguments_stack_height()));
572
+ }
573
+ code->set_deoptimization_data(*data);
574
+ }
575
+
576
+
577
+ int LCodeGen::DefineDeoptimizationLiteral(Handle<Object> literal) {
578
+ int result = deoptimization_literals_.length();
579
+ for (int i = 0; i < deoptimization_literals_.length(); ++i) {
580
+ if (deoptimization_literals_[i].is_identical_to(literal)) return i;
581
+ }
582
+ deoptimization_literals_.Add(literal);
583
+ return result;
584
+ }
585
+
586
+
587
+ void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() {
588
+ ASSERT(deoptimization_literals_.length() == 0);
589
+
590
+ const ZoneList<Handle<JSFunction> >* inlined_closures =
591
+ chunk()->inlined_closures();
592
+
593
+ for (int i = 0, length = inlined_closures->length();
594
+ i < length;
595
+ i++) {
596
+ DefineDeoptimizationLiteral(inlined_closures->at(i));
597
+ }
598
+
599
+ inlined_function_count_ = deoptimization_literals_.length();
600
+ }
601
+
602
+
603
+ void LCodeGen::RecordSafepoint(
604
+ LPointerMap* pointers,
605
+ Safepoint::Kind kind,
606
+ int arguments,
607
+ int deoptimization_index) {
608
+ const ZoneList<LOperand*>* operands = pointers->operands();
609
+
610
+ Safepoint safepoint = safepoints_.DefineSafepoint(masm(),
611
+ kind, arguments, deoptimization_index);
612
+ for (int i = 0; i < operands->length(); i++) {
613
+ LOperand* pointer = operands->at(i);
614
+ if (pointer->IsStackSlot()) {
615
+ safepoint.DefinePointerSlot(pointer->index());
616
+ } else if (pointer->IsRegister() && (kind & Safepoint::kWithRegisters)) {
617
+ safepoint.DefinePointerRegister(ToRegister(pointer));
618
+ }
619
+ }
620
+ if (kind & Safepoint::kWithRegisters) {
621
+ // Register rsi always contains a pointer to the context.
622
+ safepoint.DefinePointerRegister(rsi);
623
+ }
624
+ }
625
+
626
+
627
+ void LCodeGen::RecordSafepoint(LPointerMap* pointers,
628
+ int deoptimization_index) {
629
+ RecordSafepoint(pointers, Safepoint::kSimple, 0, deoptimization_index);
630
+ }
631
+
632
+
633
+ void LCodeGen::RecordSafepoint(int deoptimization_index) {
634
+ LPointerMap empty_pointers(RelocInfo::kNoPosition);
635
+ RecordSafepoint(&empty_pointers, deoptimization_index);
636
+ }
637
+
638
+
639
+ void LCodeGen::RecordSafepointWithRegisters(LPointerMap* pointers,
640
+ int arguments,
641
+ int deoptimization_index) {
642
+ RecordSafepoint(pointers, Safepoint::kWithRegisters, arguments,
643
+ deoptimization_index);
644
+ }
645
+
646
+
647
+ void LCodeGen::RecordPosition(int position) {
648
+ if (!FLAG_debug_info || position == RelocInfo::kNoPosition) return;
649
+ masm()->positions_recorder()->RecordPosition(position);
650
+ }
651
+
652
+
653
+ void LCodeGen::DoLabel(LLabel* label) {
654
+ if (label->is_loop_header()) {
655
+ Comment(";;; B%d - LOOP entry", label->block_id());
656
+ } else {
657
+ Comment(";;; B%d", label->block_id());
658
+ }
659
+ __ bind(label->label());
660
+ current_block_ = label->block_id();
661
+ LCodeGen::DoGap(label);
662
+ }
663
+
664
+
665
+ void LCodeGen::DoParallelMove(LParallelMove* move) {
666
+ resolver_.Resolve(move);
667
+ }
668
+
669
+
670
+ void LCodeGen::DoGap(LGap* gap) {
671
+ for (int i = LGap::FIRST_INNER_POSITION;
672
+ i <= LGap::LAST_INNER_POSITION;
673
+ i++) {
674
+ LGap::InnerPosition inner_pos = static_cast<LGap::InnerPosition>(i);
675
+ LParallelMove* move = gap->GetParallelMove(inner_pos);
676
+ if (move != NULL) DoParallelMove(move);
677
+ }
678
+
679
+ LInstruction* next = GetNextInstruction();
680
+ if (next != NULL && next->IsLazyBailout()) {
681
+ int pc = masm()->pc_offset();
682
+ safepoints_.SetPcAfterGap(pc);
683
+ }
684
+ }
685
+
686
+
687
+ void LCodeGen::DoParameter(LParameter* instr) {
688
+ // Nothing to do.
689
+ }
690
+
691
+
692
+ void LCodeGen::DoCallStub(LCallStub* instr) {
693
+ ASSERT(ToRegister(instr->result()).is(rax));
694
+ switch (instr->hydrogen()->major_key()) {
695
+ case CodeStub::RegExpConstructResult: {
696
+ RegExpConstructResultStub stub;
697
+ CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
698
+ break;
699
+ }
700
+ case CodeStub::RegExpExec: {
701
+ RegExpExecStub stub;
702
+ CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
703
+ break;
704
+ }
705
+ case CodeStub::SubString: {
706
+ SubStringStub stub;
707
+ CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
708
+ break;
709
+ }
710
+ case CodeStub::NumberToString: {
711
+ NumberToStringStub stub;
712
+ CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
713
+ break;
714
+ }
715
+ case CodeStub::StringAdd: {
716
+ StringAddStub stub(NO_STRING_ADD_FLAGS);
717
+ CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
718
+ break;
719
+ }
720
+ case CodeStub::StringCompare: {
721
+ StringCompareStub stub;
722
+ CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
723
+ break;
724
+ }
725
+ case CodeStub::TranscendentalCache: {
726
+ TranscendentalCacheStub stub(instr->transcendental_type(),
727
+ TranscendentalCacheStub::TAGGED);
728
+ CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
729
+ break;
730
+ }
731
+ default:
732
+ UNREACHABLE();
733
+ }
734
+ }
735
+
736
+
737
+ void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) {
738
+ // Nothing to do.
739
+ }
740
+
741
+
742
+ void LCodeGen::DoModI(LModI* instr) {
743
+ if (instr->hydrogen()->HasPowerOf2Divisor()) {
744
+ Register dividend = ToRegister(instr->InputAt(0));
745
+
746
+ int32_t divisor =
747
+ HConstant::cast(instr->hydrogen()->right())->Integer32Value();
748
+
749
+ if (divisor < 0) divisor = -divisor;
750
+
751
+ NearLabel positive_dividend, done;
752
+ __ testl(dividend, dividend);
753
+ __ j(not_sign, &positive_dividend);
754
+ __ negl(dividend);
755
+ __ andl(dividend, Immediate(divisor - 1));
756
+ __ negl(dividend);
757
+ if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
758
+ __ j(not_zero, &done);
759
+ DeoptimizeIf(no_condition, instr->environment());
760
+ }
761
+ __ bind(&positive_dividend);
762
+ __ andl(dividend, Immediate(divisor - 1));
763
+ __ bind(&done);
764
+ } else {
765
+ LOperand* right = instr->InputAt(1);
766
+ Register right_reg = ToRegister(right);
767
+
768
+ ASSERT(ToRegister(instr->result()).is(rdx));
769
+ ASSERT(ToRegister(instr->InputAt(0)).is(rax));
770
+ ASSERT(!right_reg.is(rax));
771
+ ASSERT(!right_reg.is(rdx));
772
+
773
+ // Check for x % 0.
774
+ if (instr->hydrogen()->CheckFlag(HValue::kCanBeDivByZero)) {
775
+ __ testl(right_reg, right_reg);
776
+ DeoptimizeIf(zero, instr->environment());
777
+ }
778
+
779
+ // Sign extend eax to edx.
780
+ // (We are using only the low 32 bits of the values.)
781
+ __ cdq();
782
+
783
+ // Check for (0 % -x) that will produce negative zero.
784
+ if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
785
+ NearLabel positive_left;
786
+ NearLabel done;
787
+ __ testl(rax, rax);
788
+ __ j(not_sign, &positive_left);
789
+ __ idivl(right_reg);
790
+
791
+ // Test the remainder for 0, because then the result would be -0.
792
+ __ testl(rdx, rdx);
793
+ __ j(not_zero, &done);
794
+
795
+ DeoptimizeIf(no_condition, instr->environment());
796
+ __ bind(&positive_left);
797
+ __ idivl(right_reg);
798
+ __ bind(&done);
799
+ } else {
800
+ __ idivl(right_reg);
801
+ }
802
+ }
803
+ }
804
+
805
+
806
+ void LCodeGen::DoDivI(LDivI* instr) {
807
+ LOperand* right = instr->InputAt(1);
808
+ ASSERT(ToRegister(instr->result()).is(rax));
809
+ ASSERT(ToRegister(instr->InputAt(0)).is(rax));
810
+ ASSERT(!ToRegister(instr->InputAt(1)).is(rax));
811
+ ASSERT(!ToRegister(instr->InputAt(1)).is(rdx));
812
+
813
+ Register left_reg = rax;
814
+
815
+ // Check for x / 0.
816
+ Register right_reg = ToRegister(right);
817
+ if (instr->hydrogen()->CheckFlag(HValue::kCanBeDivByZero)) {
818
+ __ testl(right_reg, right_reg);
819
+ DeoptimizeIf(zero, instr->environment());
820
+ }
821
+
822
+ // Check for (0 / -x) that will produce negative zero.
823
+ if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
824
+ NearLabel left_not_zero;
825
+ __ testl(left_reg, left_reg);
826
+ __ j(not_zero, &left_not_zero);
827
+ __ testl(right_reg, right_reg);
828
+ DeoptimizeIf(sign, instr->environment());
829
+ __ bind(&left_not_zero);
830
+ }
831
+
832
+ // Check for (-kMinInt / -1).
833
+ if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) {
834
+ NearLabel left_not_min_int;
835
+ __ cmpl(left_reg, Immediate(kMinInt));
836
+ __ j(not_zero, &left_not_min_int);
837
+ __ cmpl(right_reg, Immediate(-1));
838
+ DeoptimizeIf(zero, instr->environment());
839
+ __ bind(&left_not_min_int);
840
+ }
841
+
842
+ // Sign extend to rdx.
843
+ __ cdq();
844
+ __ idivl(right_reg);
845
+
846
+ // Deoptimize if remainder is not 0.
847
+ __ testl(rdx, rdx);
848
+ DeoptimizeIf(not_zero, instr->environment());
849
+ }
850
+
851
+
852
+ void LCodeGen::DoMulI(LMulI* instr) {
853
+ Register left = ToRegister(instr->InputAt(0));
854
+ LOperand* right = instr->InputAt(1);
855
+
856
+ if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
857
+ __ movl(kScratchRegister, left);
858
+ }
859
+
860
+ bool can_overflow =
861
+ instr->hydrogen()->CheckFlag(HValue::kCanOverflow);
862
+ if (right->IsConstantOperand()) {
863
+ int right_value = ToInteger32(LConstantOperand::cast(right));
864
+ if (right_value == -1) {
865
+ __ negl(left);
866
+ } else if (right_value == 0) {
867
+ __ xorl(left, left);
868
+ } else if (right_value == 2) {
869
+ __ addl(left, left);
870
+ } else if (!can_overflow) {
871
+ // If the multiplication is known to not overflow, we
872
+ // can use operations that don't set the overflow flag
873
+ // correctly.
874
+ switch (right_value) {
875
+ case 1:
876
+ // Do nothing.
877
+ break;
878
+ case 3:
879
+ __ leal(left, Operand(left, left, times_2, 0));
880
+ break;
881
+ case 4:
882
+ __ shll(left, Immediate(2));
883
+ break;
884
+ case 5:
885
+ __ leal(left, Operand(left, left, times_4, 0));
886
+ break;
887
+ case 8:
888
+ __ shll(left, Immediate(3));
889
+ break;
890
+ case 9:
891
+ __ leal(left, Operand(left, left, times_8, 0));
892
+ break;
893
+ case 16:
894
+ __ shll(left, Immediate(4));
895
+ break;
896
+ default:
897
+ __ imull(left, left, Immediate(right_value));
898
+ break;
899
+ }
900
+ } else {
901
+ __ imull(left, left, Immediate(right_value));
902
+ }
903
+ } else if (right->IsStackSlot()) {
904
+ __ imull(left, ToOperand(right));
905
+ } else {
906
+ __ imull(left, ToRegister(right));
907
+ }
908
+
909
+ if (can_overflow) {
910
+ DeoptimizeIf(overflow, instr->environment());
911
+ }
912
+
913
+ if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
914
+ // Bail out if the result is supposed to be negative zero.
915
+ NearLabel done;
916
+ __ testl(left, left);
917
+ __ j(not_zero, &done);
918
+ if (right->IsConstantOperand()) {
919
+ if (ToInteger32(LConstantOperand::cast(right)) <= 0) {
920
+ DeoptimizeIf(no_condition, instr->environment());
921
+ }
922
+ } else if (right->IsStackSlot()) {
923
+ __ or_(kScratchRegister, ToOperand(right));
924
+ DeoptimizeIf(sign, instr->environment());
925
+ } else {
926
+ // Test the non-zero operand for negative sign.
927
+ __ or_(kScratchRegister, ToRegister(right));
928
+ DeoptimizeIf(sign, instr->environment());
929
+ }
930
+ __ bind(&done);
931
+ }
932
+ }
933
+
934
+
935
+ void LCodeGen::DoBitI(LBitI* instr) {
936
+ LOperand* left = instr->InputAt(0);
937
+ LOperand* right = instr->InputAt(1);
938
+ ASSERT(left->Equals(instr->result()));
939
+ ASSERT(left->IsRegister());
940
+
941
+ if (right->IsConstantOperand()) {
942
+ int right_operand = ToInteger32(LConstantOperand::cast(right));
943
+ switch (instr->op()) {
944
+ case Token::BIT_AND:
945
+ __ andl(ToRegister(left), Immediate(right_operand));
946
+ break;
947
+ case Token::BIT_OR:
948
+ __ orl(ToRegister(left), Immediate(right_operand));
949
+ break;
950
+ case Token::BIT_XOR:
951
+ __ xorl(ToRegister(left), Immediate(right_operand));
952
+ break;
953
+ default:
954
+ UNREACHABLE();
955
+ break;
956
+ }
957
+ } else if (right->IsStackSlot()) {
958
+ switch (instr->op()) {
959
+ case Token::BIT_AND:
960
+ __ andl(ToRegister(left), ToOperand(right));
961
+ break;
962
+ case Token::BIT_OR:
963
+ __ orl(ToRegister(left), ToOperand(right));
964
+ break;
965
+ case Token::BIT_XOR:
966
+ __ xorl(ToRegister(left), ToOperand(right));
967
+ break;
968
+ default:
969
+ UNREACHABLE();
970
+ break;
971
+ }
972
+ } else {
973
+ ASSERT(right->IsRegister());
974
+ switch (instr->op()) {
975
+ case Token::BIT_AND:
976
+ __ andl(ToRegister(left), ToRegister(right));
977
+ break;
978
+ case Token::BIT_OR:
979
+ __ orl(ToRegister(left), ToRegister(right));
980
+ break;
981
+ case Token::BIT_XOR:
982
+ __ xorl(ToRegister(left), ToRegister(right));
983
+ break;
984
+ default:
985
+ UNREACHABLE();
986
+ break;
987
+ }
988
+ }
989
+ }
990
+
991
+
992
+ void LCodeGen::DoShiftI(LShiftI* instr) {
993
+ LOperand* left = instr->InputAt(0);
994
+ LOperand* right = instr->InputAt(1);
995
+ ASSERT(left->Equals(instr->result()));
996
+ ASSERT(left->IsRegister());
997
+ if (right->IsRegister()) {
998
+ ASSERT(ToRegister(right).is(rcx));
999
+
1000
+ switch (instr->op()) {
1001
+ case Token::SAR:
1002
+ __ sarl_cl(ToRegister(left));
1003
+ break;
1004
+ case Token::SHR:
1005
+ __ shrl_cl(ToRegister(left));
1006
+ if (instr->can_deopt()) {
1007
+ __ testl(ToRegister(left), ToRegister(left));
1008
+ DeoptimizeIf(negative, instr->environment());
1009
+ }
1010
+ break;
1011
+ case Token::SHL:
1012
+ __ shll_cl(ToRegister(left));
1013
+ break;
1014
+ default:
1015
+ UNREACHABLE();
1016
+ break;
1017
+ }
1018
+ } else {
1019
+ int value = ToInteger32(LConstantOperand::cast(right));
1020
+ uint8_t shift_count = static_cast<uint8_t>(value & 0x1F);
1021
+ switch (instr->op()) {
1022
+ case Token::SAR:
1023
+ if (shift_count != 0) {
1024
+ __ sarl(ToRegister(left), Immediate(shift_count));
1025
+ }
1026
+ break;
1027
+ case Token::SHR:
1028
+ if (shift_count == 0 && instr->can_deopt()) {
1029
+ __ testl(ToRegister(left), ToRegister(left));
1030
+ DeoptimizeIf(negative, instr->environment());
1031
+ } else {
1032
+ __ shrl(ToRegister(left), Immediate(shift_count));
1033
+ }
1034
+ break;
1035
+ case Token::SHL:
1036
+ if (shift_count != 0) {
1037
+ __ shll(ToRegister(left), Immediate(shift_count));
1038
+ }
1039
+ break;
1040
+ default:
1041
+ UNREACHABLE();
1042
+ break;
1043
+ }
1044
+ }
1045
+ }
1046
+
1047
+
1048
+ void LCodeGen::DoSubI(LSubI* instr) {
1049
+ LOperand* left = instr->InputAt(0);
1050
+ LOperand* right = instr->InputAt(1);
1051
+ ASSERT(left->Equals(instr->result()));
1052
+
1053
+ if (right->IsConstantOperand()) {
1054
+ __ subl(ToRegister(left),
1055
+ Immediate(ToInteger32(LConstantOperand::cast(right))));
1056
+ } else if (right->IsRegister()) {
1057
+ __ subl(ToRegister(left), ToRegister(right));
1058
+ } else {
1059
+ __ subl(ToRegister(left), ToOperand(right));
1060
+ }
1061
+
1062
+ if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) {
1063
+ DeoptimizeIf(overflow, instr->environment());
1064
+ }
1065
+ }
1066
+
1067
+
1068
+ void LCodeGen::DoConstantI(LConstantI* instr) {
1069
+ ASSERT(instr->result()->IsRegister());
1070
+ __ movl(ToRegister(instr->result()), Immediate(instr->value()));
1071
+ }
1072
+
1073
+
1074
+ void LCodeGen::DoConstantD(LConstantD* instr) {
1075
+ ASSERT(instr->result()->IsDoubleRegister());
1076
+ XMMRegister res = ToDoubleRegister(instr->result());
1077
+ double v = instr->value();
1078
+ uint64_t int_val = BitCast<uint64_t, double>(v);
1079
+ // Use xor to produce +0.0 in a fast and compact way, but avoid to
1080
+ // do so if the constant is -0.0.
1081
+ if (int_val == 0) {
1082
+ __ xorpd(res, res);
1083
+ } else {
1084
+ Register tmp = ToRegister(instr->TempAt(0));
1085
+ __ Set(tmp, int_val);
1086
+ __ movq(res, tmp);
1087
+ }
1088
+ }
1089
+
1090
+
1091
+ void LCodeGen::DoConstantT(LConstantT* instr) {
1092
+ ASSERT(instr->result()->IsRegister());
1093
+ __ Move(ToRegister(instr->result()), instr->value());
1094
+ }
1095
+
1096
+
1097
+ void LCodeGen::DoJSArrayLength(LJSArrayLength* instr) {
1098
+ Register result = ToRegister(instr->result());
1099
+ Register array = ToRegister(instr->InputAt(0));
1100
+ __ movq(result, FieldOperand(array, JSArray::kLengthOffset));
1101
+ }
1102
+
1103
+
1104
+ void LCodeGen::DoFixedArrayLength(LFixedArrayLength* instr) {
1105
+ Register result = ToRegister(instr->result());
1106
+ Register array = ToRegister(instr->InputAt(0));
1107
+ __ movq(result, FieldOperand(array, FixedArray::kLengthOffset));
1108
+ }
1109
+
1110
+
1111
+ void LCodeGen::DoExternalArrayLength(LExternalArrayLength* instr) {
1112
+ Register result = ToRegister(instr->result());
1113
+ Register array = ToRegister(instr->InputAt(0));
1114
+ __ movl(result, FieldOperand(array, ExternalPixelArray::kLengthOffset));
1115
+ }
1116
+
1117
+
1118
+ void LCodeGen::DoValueOf(LValueOf* instr) {
1119
+ Register input = ToRegister(instr->InputAt(0));
1120
+ Register result = ToRegister(instr->result());
1121
+ ASSERT(input.is(result));
1122
+ NearLabel done;
1123
+ // If the object is a smi return the object.
1124
+ __ JumpIfSmi(input, &done);
1125
+
1126
+ // If the object is not a value type, return the object.
1127
+ __ CmpObjectType(input, JS_VALUE_TYPE, kScratchRegister);
1128
+ __ j(not_equal, &done);
1129
+ __ movq(result, FieldOperand(input, JSValue::kValueOffset));
1130
+
1131
+ __ bind(&done);
1132
+ }
1133
+
1134
+
1135
+ void LCodeGen::DoBitNotI(LBitNotI* instr) {
1136
+ LOperand* input = instr->InputAt(0);
1137
+ ASSERT(input->Equals(instr->result()));
1138
+ __ not_(ToRegister(input));
1139
+ }
1140
+
1141
+
1142
+ void LCodeGen::DoThrow(LThrow* instr) {
1143
+ __ push(ToRegister(instr->InputAt(0)));
1144
+ CallRuntime(Runtime::kThrow, 1, instr);
1145
+
1146
+ if (FLAG_debug_code) {
1147
+ Comment("Unreachable code.");
1148
+ __ int3();
1149
+ }
1150
+ }
1151
+
1152
+
1153
+ void LCodeGen::DoAddI(LAddI* instr) {
1154
+ LOperand* left = instr->InputAt(0);
1155
+ LOperand* right = instr->InputAt(1);
1156
+ ASSERT(left->Equals(instr->result()));
1157
+
1158
+ if (right->IsConstantOperand()) {
1159
+ __ addl(ToRegister(left),
1160
+ Immediate(ToInteger32(LConstantOperand::cast(right))));
1161
+ } else if (right->IsRegister()) {
1162
+ __ addl(ToRegister(left), ToRegister(right));
1163
+ } else {
1164
+ __ addl(ToRegister(left), ToOperand(right));
1165
+ }
1166
+
1167
+ if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) {
1168
+ DeoptimizeIf(overflow, instr->environment());
1169
+ }
1170
+ }
1171
+
1172
+
1173
+ void LCodeGen::DoArithmeticD(LArithmeticD* instr) {
1174
+ XMMRegister left = ToDoubleRegister(instr->InputAt(0));
1175
+ XMMRegister right = ToDoubleRegister(instr->InputAt(1));
1176
+ XMMRegister result = ToDoubleRegister(instr->result());
1177
+ // All operations except MOD are computed in-place.
1178
+ ASSERT(instr->op() == Token::MOD || left.is(result));
1179
+ switch (instr->op()) {
1180
+ case Token::ADD:
1181
+ __ addsd(left, right);
1182
+ break;
1183
+ case Token::SUB:
1184
+ __ subsd(left, right);
1185
+ break;
1186
+ case Token::MUL:
1187
+ __ mulsd(left, right);
1188
+ break;
1189
+ case Token::DIV:
1190
+ __ divsd(left, right);
1191
+ break;
1192
+ case Token::MOD:
1193
+ __ PrepareCallCFunction(2);
1194
+ __ movsd(xmm0, left);
1195
+ ASSERT(right.is(xmm1));
1196
+ __ CallCFunction(
1197
+ ExternalReference::double_fp_operation(Token::MOD, isolate()), 2);
1198
+ __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
1199
+ __ movsd(result, xmm0);
1200
+ break;
1201
+ default:
1202
+ UNREACHABLE();
1203
+ break;
1204
+ }
1205
+ }
1206
+
1207
+
1208
+ void LCodeGen::DoArithmeticT(LArithmeticT* instr) {
1209
+ ASSERT(ToRegister(instr->InputAt(0)).is(rdx));
1210
+ ASSERT(ToRegister(instr->InputAt(1)).is(rax));
1211
+ ASSERT(ToRegister(instr->result()).is(rax));
1212
+
1213
+ TypeRecordingBinaryOpStub stub(instr->op(), NO_OVERWRITE);
1214
+ CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
1215
+ }
1216
+
1217
+
1218
+ int LCodeGen::GetNextEmittedBlock(int block) {
1219
+ for (int i = block + 1; i < graph()->blocks()->length(); ++i) {
1220
+ LLabel* label = chunk_->GetLabel(i);
1221
+ if (!label->HasReplacement()) return i;
1222
+ }
1223
+ return -1;
1224
+ }
1225
+
1226
+
1227
+ void LCodeGen::EmitBranch(int left_block, int right_block, Condition cc) {
1228
+ int next_block = GetNextEmittedBlock(current_block_);
1229
+ right_block = chunk_->LookupDestination(right_block);
1230
+ left_block = chunk_->LookupDestination(left_block);
1231
+
1232
+ if (right_block == left_block) {
1233
+ EmitGoto(left_block);
1234
+ } else if (left_block == next_block) {
1235
+ __ j(NegateCondition(cc), chunk_->GetAssemblyLabel(right_block));
1236
+ } else if (right_block == next_block) {
1237
+ __ j(cc, chunk_->GetAssemblyLabel(left_block));
1238
+ } else {
1239
+ __ j(cc, chunk_->GetAssemblyLabel(left_block));
1240
+ if (cc != always) {
1241
+ __ jmp(chunk_->GetAssemblyLabel(right_block));
1242
+ }
1243
+ }
1244
+ }
1245
+
1246
+
1247
+ void LCodeGen::DoBranch(LBranch* instr) {
1248
+ int true_block = chunk_->LookupDestination(instr->true_block_id());
1249
+ int false_block = chunk_->LookupDestination(instr->false_block_id());
1250
+
1251
+ Representation r = instr->hydrogen()->representation();
1252
+ if (r.IsInteger32()) {
1253
+ Register reg = ToRegister(instr->InputAt(0));
1254
+ __ testl(reg, reg);
1255
+ EmitBranch(true_block, false_block, not_zero);
1256
+ } else if (r.IsDouble()) {
1257
+ XMMRegister reg = ToDoubleRegister(instr->InputAt(0));
1258
+ __ xorpd(xmm0, xmm0);
1259
+ __ ucomisd(reg, xmm0);
1260
+ EmitBranch(true_block, false_block, not_equal);
1261
+ } else {
1262
+ ASSERT(r.IsTagged());
1263
+ Register reg = ToRegister(instr->InputAt(0));
1264
+ HType type = instr->hydrogen()->type();
1265
+ if (type.IsBoolean()) {
1266
+ __ CompareRoot(reg, Heap::kTrueValueRootIndex);
1267
+ EmitBranch(true_block, false_block, equal);
1268
+ } else if (type.IsSmi()) {
1269
+ __ SmiCompare(reg, Smi::FromInt(0));
1270
+ EmitBranch(true_block, false_block, not_equal);
1271
+ } else {
1272
+ Label* true_label = chunk_->GetAssemblyLabel(true_block);
1273
+ Label* false_label = chunk_->GetAssemblyLabel(false_block);
1274
+
1275
+ __ CompareRoot(reg, Heap::kUndefinedValueRootIndex);
1276
+ __ j(equal, false_label);
1277
+ __ CompareRoot(reg, Heap::kTrueValueRootIndex);
1278
+ __ j(equal, true_label);
1279
+ __ CompareRoot(reg, Heap::kFalseValueRootIndex);
1280
+ __ j(equal, false_label);
1281
+ __ Cmp(reg, Smi::FromInt(0));
1282
+ __ j(equal, false_label);
1283
+ __ JumpIfSmi(reg, true_label);
1284
+
1285
+ // Test for double values. Plus/minus zero and NaN are false.
1286
+ NearLabel call_stub;
1287
+ __ CompareRoot(FieldOperand(reg, HeapObject::kMapOffset),
1288
+ Heap::kHeapNumberMapRootIndex);
1289
+ __ j(not_equal, &call_stub);
1290
+
1291
+ // HeapNumber => false iff +0, -0, or NaN. These three cases set the
1292
+ // zero flag when compared to zero using ucomisd.
1293
+ __ xorpd(xmm0, xmm0);
1294
+ __ ucomisd(xmm0, FieldOperand(reg, HeapNumber::kValueOffset));
1295
+ __ j(zero, false_label);
1296
+ __ jmp(true_label);
1297
+
1298
+ // The conversion stub doesn't cause garbage collections so it's
1299
+ // safe to not record a safepoint after the call.
1300
+ __ bind(&call_stub);
1301
+ ToBooleanStub stub;
1302
+ __ Pushad();
1303
+ __ push(reg);
1304
+ __ CallStub(&stub);
1305
+ __ testq(rax, rax);
1306
+ __ Popad();
1307
+ EmitBranch(true_block, false_block, not_zero);
1308
+ }
1309
+ }
1310
+ }
1311
+
1312
+
1313
+ void LCodeGen::EmitGoto(int block, LDeferredCode* deferred_stack_check) {
1314
+ block = chunk_->LookupDestination(block);
1315
+ int next_block = GetNextEmittedBlock(current_block_);
1316
+ if (block != next_block) {
1317
+ // Perform stack overflow check if this goto needs it before jumping.
1318
+ if (deferred_stack_check != NULL) {
1319
+ __ CompareRoot(rsp, Heap::kStackLimitRootIndex);
1320
+ __ j(above_equal, chunk_->GetAssemblyLabel(block));
1321
+ __ jmp(deferred_stack_check->entry());
1322
+ deferred_stack_check->SetExit(chunk_->GetAssemblyLabel(block));
1323
+ } else {
1324
+ __ jmp(chunk_->GetAssemblyLabel(block));
1325
+ }
1326
+ }
1327
+ }
1328
+
1329
+
1330
+ void LCodeGen::DoDeferredStackCheck(LGoto* instr) {
1331
+ __ Pushad();
1332
+ __ CallRuntimeSaveDoubles(Runtime::kStackGuard);
1333
+ RecordSafepointWithRegisters(
1334
+ instr->pointer_map(), 0, Safepoint::kNoDeoptimizationIndex);
1335
+ __ Popad();
1336
+ }
1337
+
1338
+
1339
+ void LCodeGen::DoGoto(LGoto* instr) {
1340
+ class DeferredStackCheck: public LDeferredCode {
1341
+ public:
1342
+ DeferredStackCheck(LCodeGen* codegen, LGoto* instr)
1343
+ : LDeferredCode(codegen), instr_(instr) { }
1344
+ virtual void Generate() { codegen()->DoDeferredStackCheck(instr_); }
1345
+ private:
1346
+ LGoto* instr_;
1347
+ };
1348
+
1349
+ DeferredStackCheck* deferred = NULL;
1350
+ if (instr->include_stack_check()) {
1351
+ deferred = new DeferredStackCheck(this, instr);
1352
+ }
1353
+ EmitGoto(instr->block_id(), deferred);
1354
+ }
1355
+
1356
+
1357
+ inline Condition LCodeGen::TokenToCondition(Token::Value op, bool is_unsigned) {
1358
+ Condition cond = no_condition;
1359
+ switch (op) {
1360
+ case Token::EQ:
1361
+ case Token::EQ_STRICT:
1362
+ cond = equal;
1363
+ break;
1364
+ case Token::LT:
1365
+ cond = is_unsigned ? below : less;
1366
+ break;
1367
+ case Token::GT:
1368
+ cond = is_unsigned ? above : greater;
1369
+ break;
1370
+ case Token::LTE:
1371
+ cond = is_unsigned ? below_equal : less_equal;
1372
+ break;
1373
+ case Token::GTE:
1374
+ cond = is_unsigned ? above_equal : greater_equal;
1375
+ break;
1376
+ case Token::IN:
1377
+ case Token::INSTANCEOF:
1378
+ default:
1379
+ UNREACHABLE();
1380
+ }
1381
+ return cond;
1382
+ }
1383
+
1384
+
1385
+ void LCodeGen::EmitCmpI(LOperand* left, LOperand* right) {
1386
+ if (right->IsConstantOperand()) {
1387
+ int32_t value = ToInteger32(LConstantOperand::cast(right));
1388
+ if (left->IsRegister()) {
1389
+ __ cmpl(ToRegister(left), Immediate(value));
1390
+ } else {
1391
+ __ cmpl(ToOperand(left), Immediate(value));
1392
+ }
1393
+ } else if (right->IsRegister()) {
1394
+ __ cmpl(ToRegister(left), ToRegister(right));
1395
+ } else {
1396
+ __ cmpl(ToRegister(left), ToOperand(right));
1397
+ }
1398
+ }
1399
+
1400
+
1401
+ void LCodeGen::DoCmpID(LCmpID* instr) {
1402
+ LOperand* left = instr->InputAt(0);
1403
+ LOperand* right = instr->InputAt(1);
1404
+ LOperand* result = instr->result();
1405
+
1406
+ NearLabel unordered;
1407
+ if (instr->is_double()) {
1408
+ // Don't base result on EFLAGS when a NaN is involved. Instead
1409
+ // jump to the unordered case, which produces a false value.
1410
+ __ ucomisd(ToDoubleRegister(left), ToDoubleRegister(right));
1411
+ __ j(parity_even, &unordered);
1412
+ } else {
1413
+ EmitCmpI(left, right);
1414
+ }
1415
+
1416
+ NearLabel done;
1417
+ Condition cc = TokenToCondition(instr->op(), instr->is_double());
1418
+ __ LoadRoot(ToRegister(result), Heap::kTrueValueRootIndex);
1419
+ __ j(cc, &done);
1420
+
1421
+ __ bind(&unordered);
1422
+ __ LoadRoot(ToRegister(result), Heap::kFalseValueRootIndex);
1423
+ __ bind(&done);
1424
+ }
1425
+
1426
+
1427
+ void LCodeGen::DoCmpIDAndBranch(LCmpIDAndBranch* instr) {
1428
+ LOperand* left = instr->InputAt(0);
1429
+ LOperand* right = instr->InputAt(1);
1430
+ int false_block = chunk_->LookupDestination(instr->false_block_id());
1431
+ int true_block = chunk_->LookupDestination(instr->true_block_id());
1432
+
1433
+ if (instr->is_double()) {
1434
+ // Don't base result on EFLAGS when a NaN is involved. Instead
1435
+ // jump to the false block.
1436
+ __ ucomisd(ToDoubleRegister(left), ToDoubleRegister(right));
1437
+ __ j(parity_even, chunk_->GetAssemblyLabel(false_block));
1438
+ } else {
1439
+ EmitCmpI(left, right);
1440
+ }
1441
+
1442
+ Condition cc = TokenToCondition(instr->op(), instr->is_double());
1443
+ EmitBranch(true_block, false_block, cc);
1444
+ }
1445
+
1446
+
1447
+ void LCodeGen::DoCmpJSObjectEq(LCmpJSObjectEq* instr) {
1448
+ Register left = ToRegister(instr->InputAt(0));
1449
+ Register right = ToRegister(instr->InputAt(1));
1450
+ Register result = ToRegister(instr->result());
1451
+
1452
+ NearLabel different, done;
1453
+ __ cmpq(left, right);
1454
+ __ j(not_equal, &different);
1455
+ __ LoadRoot(result, Heap::kTrueValueRootIndex);
1456
+ __ jmp(&done);
1457
+ __ bind(&different);
1458
+ __ LoadRoot(result, Heap::kFalseValueRootIndex);
1459
+ __ bind(&done);
1460
+ }
1461
+
1462
+
1463
+ void LCodeGen::DoCmpJSObjectEqAndBranch(LCmpJSObjectEqAndBranch* instr) {
1464
+ Register left = ToRegister(instr->InputAt(0));
1465
+ Register right = ToRegister(instr->InputAt(1));
1466
+ int false_block = chunk_->LookupDestination(instr->false_block_id());
1467
+ int true_block = chunk_->LookupDestination(instr->true_block_id());
1468
+
1469
+ __ cmpq(left, right);
1470
+ EmitBranch(true_block, false_block, equal);
1471
+ }
1472
+
1473
+
1474
+ void LCodeGen::DoIsNull(LIsNull* instr) {
1475
+ Register reg = ToRegister(instr->InputAt(0));
1476
+ Register result = ToRegister(instr->result());
1477
+
1478
+ // If the expression is known to be a smi, then it's
1479
+ // definitely not null. Materialize false.
1480
+ // Consider adding other type and representation tests too.
1481
+ if (instr->hydrogen()->value()->type().IsSmi()) {
1482
+ __ LoadRoot(result, Heap::kFalseValueRootIndex);
1483
+ return;
1484
+ }
1485
+
1486
+ __ CompareRoot(reg, Heap::kNullValueRootIndex);
1487
+ if (instr->is_strict()) {
1488
+ __ movl(result, Immediate(Heap::kTrueValueRootIndex));
1489
+ NearLabel load;
1490
+ __ j(equal, &load);
1491
+ __ movl(result, Immediate(Heap::kFalseValueRootIndex));
1492
+ __ bind(&load);
1493
+ __ LoadRootIndexed(result, result, 0);
1494
+ } else {
1495
+ NearLabel true_value, false_value, done;
1496
+ __ j(equal, &true_value);
1497
+ __ CompareRoot(reg, Heap::kUndefinedValueRootIndex);
1498
+ __ j(equal, &true_value);
1499
+ __ JumpIfSmi(reg, &false_value);
1500
+ // Check for undetectable objects by looking in the bit field in
1501
+ // the map. The object has already been smi checked.
1502
+ Register scratch = result;
1503
+ __ movq(scratch, FieldOperand(reg, HeapObject::kMapOffset));
1504
+ __ testb(FieldOperand(scratch, Map::kBitFieldOffset),
1505
+ Immediate(1 << Map::kIsUndetectable));
1506
+ __ j(not_zero, &true_value);
1507
+ __ bind(&false_value);
1508
+ __ LoadRoot(result, Heap::kFalseValueRootIndex);
1509
+ __ jmp(&done);
1510
+ __ bind(&true_value);
1511
+ __ LoadRoot(result, Heap::kTrueValueRootIndex);
1512
+ __ bind(&done);
1513
+ }
1514
+ }
1515
+
1516
+
1517
+ void LCodeGen::DoIsNullAndBranch(LIsNullAndBranch* instr) {
1518
+ Register reg = ToRegister(instr->InputAt(0));
1519
+
1520
+ int false_block = chunk_->LookupDestination(instr->false_block_id());
1521
+
1522
+ if (instr->hydrogen()->representation().IsSpecialization() ||
1523
+ instr->hydrogen()->type().IsSmi()) {
1524
+ // If the expression is known to untagged or smi, then it's definitely
1525
+ // not null, and it can't be a an undetectable object.
1526
+ // Jump directly to the false block.
1527
+ EmitGoto(false_block);
1528
+ return;
1529
+ }
1530
+
1531
+ int true_block = chunk_->LookupDestination(instr->true_block_id());
1532
+
1533
+ __ CompareRoot(reg, Heap::kNullValueRootIndex);
1534
+ if (instr->is_strict()) {
1535
+ EmitBranch(true_block, false_block, equal);
1536
+ } else {
1537
+ Label* true_label = chunk_->GetAssemblyLabel(true_block);
1538
+ Label* false_label = chunk_->GetAssemblyLabel(false_block);
1539
+ __ j(equal, true_label);
1540
+ __ CompareRoot(reg, Heap::kUndefinedValueRootIndex);
1541
+ __ j(equal, true_label);
1542
+ __ JumpIfSmi(reg, false_label);
1543
+ // Check for undetectable objects by looking in the bit field in
1544
+ // the map. The object has already been smi checked.
1545
+ Register scratch = ToRegister(instr->TempAt(0));
1546
+ __ movq(scratch, FieldOperand(reg, HeapObject::kMapOffset));
1547
+ __ testb(FieldOperand(scratch, Map::kBitFieldOffset),
1548
+ Immediate(1 << Map::kIsUndetectable));
1549
+ EmitBranch(true_block, false_block, not_zero);
1550
+ }
1551
+ }
1552
+
1553
+
1554
+ Condition LCodeGen::EmitIsObject(Register input,
1555
+ Label* is_not_object,
1556
+ Label* is_object) {
1557
+ ASSERT(!input.is(kScratchRegister));
1558
+
1559
+ __ JumpIfSmi(input, is_not_object);
1560
+
1561
+ __ CompareRoot(input, Heap::kNullValueRootIndex);
1562
+ __ j(equal, is_object);
1563
+
1564
+ __ movq(kScratchRegister, FieldOperand(input, HeapObject::kMapOffset));
1565
+ // Undetectable objects behave like undefined.
1566
+ __ testb(FieldOperand(kScratchRegister, Map::kBitFieldOffset),
1567
+ Immediate(1 << Map::kIsUndetectable));
1568
+ __ j(not_zero, is_not_object);
1569
+
1570
+ __ movzxbl(kScratchRegister,
1571
+ FieldOperand(kScratchRegister, Map::kInstanceTypeOffset));
1572
+ __ cmpb(kScratchRegister, Immediate(FIRST_JS_OBJECT_TYPE));
1573
+ __ j(below, is_not_object);
1574
+ __ cmpb(kScratchRegister, Immediate(LAST_JS_OBJECT_TYPE));
1575
+ return below_equal;
1576
+ }
1577
+
1578
+
1579
+ void LCodeGen::DoIsObject(LIsObject* instr) {
1580
+ Register reg = ToRegister(instr->InputAt(0));
1581
+ Register result = ToRegister(instr->result());
1582
+ Label is_false, is_true, done;
1583
+
1584
+ Condition true_cond = EmitIsObject(reg, &is_false, &is_true);
1585
+ __ j(true_cond, &is_true);
1586
+
1587
+ __ bind(&is_false);
1588
+ __ LoadRoot(result, Heap::kFalseValueRootIndex);
1589
+ __ jmp(&done);
1590
+
1591
+ __ bind(&is_true);
1592
+ __ LoadRoot(result, Heap::kTrueValueRootIndex);
1593
+
1594
+ __ bind(&done);
1595
+ }
1596
+
1597
+
1598
+ void LCodeGen::DoIsObjectAndBranch(LIsObjectAndBranch* instr) {
1599
+ Register reg = ToRegister(instr->InputAt(0));
1600
+
1601
+ int true_block = chunk_->LookupDestination(instr->true_block_id());
1602
+ int false_block = chunk_->LookupDestination(instr->false_block_id());
1603
+ Label* true_label = chunk_->GetAssemblyLabel(true_block);
1604
+ Label* false_label = chunk_->GetAssemblyLabel(false_block);
1605
+
1606
+ Condition true_cond = EmitIsObject(reg, false_label, true_label);
1607
+
1608
+ EmitBranch(true_block, false_block, true_cond);
1609
+ }
1610
+
1611
+
1612
+ void LCodeGen::DoIsSmi(LIsSmi* instr) {
1613
+ LOperand* input_operand = instr->InputAt(0);
1614
+ Register result = ToRegister(instr->result());
1615
+ if (input_operand->IsRegister()) {
1616
+ Register input = ToRegister(input_operand);
1617
+ __ CheckSmiToIndicator(result, input);
1618
+ } else {
1619
+ Operand input = ToOperand(instr->InputAt(0));
1620
+ __ CheckSmiToIndicator(result, input);
1621
+ }
1622
+ // result is zero if input is a smi, and one otherwise.
1623
+ ASSERT(Heap::kFalseValueRootIndex == Heap::kTrueValueRootIndex + 1);
1624
+ __ LoadRootIndexed(result, result, Heap::kTrueValueRootIndex);
1625
+ }
1626
+
1627
+
1628
+ void LCodeGen::DoIsSmiAndBranch(LIsSmiAndBranch* instr) {
1629
+ int true_block = chunk_->LookupDestination(instr->true_block_id());
1630
+ int false_block = chunk_->LookupDestination(instr->false_block_id());
1631
+
1632
+ Condition is_smi;
1633
+ if (instr->InputAt(0)->IsRegister()) {
1634
+ Register input = ToRegister(instr->InputAt(0));
1635
+ is_smi = masm()->CheckSmi(input);
1636
+ } else {
1637
+ Operand input = ToOperand(instr->InputAt(0));
1638
+ is_smi = masm()->CheckSmi(input);
1639
+ }
1640
+ EmitBranch(true_block, false_block, is_smi);
1641
+ }
1642
+
1643
+
1644
+ static InstanceType TestType(HHasInstanceType* instr) {
1645
+ InstanceType from = instr->from();
1646
+ InstanceType to = instr->to();
1647
+ if (from == FIRST_TYPE) return to;
1648
+ ASSERT(from == to || to == LAST_TYPE);
1649
+ return from;
1650
+ }
1651
+
1652
+
1653
+ static Condition BranchCondition(HHasInstanceType* instr) {
1654
+ InstanceType from = instr->from();
1655
+ InstanceType to = instr->to();
1656
+ if (from == to) return equal;
1657
+ if (to == LAST_TYPE) return above_equal;
1658
+ if (from == FIRST_TYPE) return below_equal;
1659
+ UNREACHABLE();
1660
+ return equal;
1661
+ }
1662
+
1663
+
1664
+ void LCodeGen::DoHasInstanceType(LHasInstanceType* instr) {
1665
+ Register input = ToRegister(instr->InputAt(0));
1666
+ Register result = ToRegister(instr->result());
1667
+
1668
+ ASSERT(instr->hydrogen()->value()->representation().IsTagged());
1669
+ __ testl(input, Immediate(kSmiTagMask));
1670
+ NearLabel done, is_false;
1671
+ __ j(zero, &is_false);
1672
+ __ CmpObjectType(input, TestType(instr->hydrogen()), result);
1673
+ __ j(NegateCondition(BranchCondition(instr->hydrogen())), &is_false);
1674
+ __ LoadRoot(result, Heap::kTrueValueRootIndex);
1675
+ __ jmp(&done);
1676
+ __ bind(&is_false);
1677
+ __ LoadRoot(result, Heap::kFalseValueRootIndex);
1678
+ __ bind(&done);
1679
+ }
1680
+
1681
+
1682
+ void LCodeGen::DoHasInstanceTypeAndBranch(LHasInstanceTypeAndBranch* instr) {
1683
+ Register input = ToRegister(instr->InputAt(0));
1684
+
1685
+ int true_block = chunk_->LookupDestination(instr->true_block_id());
1686
+ int false_block = chunk_->LookupDestination(instr->false_block_id());
1687
+
1688
+ Label* false_label = chunk_->GetAssemblyLabel(false_block);
1689
+
1690
+ __ JumpIfSmi(input, false_label);
1691
+
1692
+ __ CmpObjectType(input, TestType(instr->hydrogen()), kScratchRegister);
1693
+ EmitBranch(true_block, false_block, BranchCondition(instr->hydrogen()));
1694
+ }
1695
+
1696
+
1697
+ void LCodeGen::DoGetCachedArrayIndex(LGetCachedArrayIndex* instr) {
1698
+ Register input = ToRegister(instr->InputAt(0));
1699
+ Register result = ToRegister(instr->result());
1700
+
1701
+ if (FLAG_debug_code) {
1702
+ __ AbortIfNotString(input);
1703
+ }
1704
+
1705
+ __ movl(result, FieldOperand(input, String::kHashFieldOffset));
1706
+ ASSERT(String::kHashShift >= kSmiTagSize);
1707
+ __ IndexFromHash(result, result);
1708
+ }
1709
+
1710
+
1711
+ void LCodeGen::DoHasCachedArrayIndex(LHasCachedArrayIndex* instr) {
1712
+ Register input = ToRegister(instr->InputAt(0));
1713
+ Register result = ToRegister(instr->result());
1714
+
1715
+ ASSERT(instr->hydrogen()->value()->representation().IsTagged());
1716
+ __ LoadRoot(result, Heap::kTrueValueRootIndex);
1717
+ __ testl(FieldOperand(input, String::kHashFieldOffset),
1718
+ Immediate(String::kContainsCachedArrayIndexMask));
1719
+ NearLabel done;
1720
+ __ j(zero, &done);
1721
+ __ LoadRoot(result, Heap::kFalseValueRootIndex);
1722
+ __ bind(&done);
1723
+ }
1724
+
1725
+
1726
+ void LCodeGen::DoHasCachedArrayIndexAndBranch(
1727
+ LHasCachedArrayIndexAndBranch* instr) {
1728
+ Register input = ToRegister(instr->InputAt(0));
1729
+
1730
+ int true_block = chunk_->LookupDestination(instr->true_block_id());
1731
+ int false_block = chunk_->LookupDestination(instr->false_block_id());
1732
+
1733
+ __ testl(FieldOperand(input, String::kHashFieldOffset),
1734
+ Immediate(String::kContainsCachedArrayIndexMask));
1735
+ EmitBranch(true_block, false_block, equal);
1736
+ }
1737
+
1738
+
1739
+ // Branches to a label or falls through with the answer in the z flag.
1740
+ // Trashes the temp register and possibly input (if it and temp are aliased).
1741
+ void LCodeGen::EmitClassOfTest(Label* is_true,
1742
+ Label* is_false,
1743
+ Handle<String> class_name,
1744
+ Register input,
1745
+ Register temp) {
1746
+ __ JumpIfSmi(input, is_false);
1747
+ __ CmpObjectType(input, FIRST_JS_OBJECT_TYPE, temp);
1748
+ __ j(below, is_false);
1749
+
1750
+ // Map is now in temp.
1751
+ // Functions have class 'Function'.
1752
+ __ CmpInstanceType(temp, JS_FUNCTION_TYPE);
1753
+ if (class_name->IsEqualTo(CStrVector("Function"))) {
1754
+ __ j(equal, is_true);
1755
+ } else {
1756
+ __ j(equal, is_false);
1757
+ }
1758
+
1759
+ // Check if the constructor in the map is a function.
1760
+ __ movq(temp, FieldOperand(temp, Map::kConstructorOffset));
1761
+
1762
+ // As long as JS_FUNCTION_TYPE is the last instance type and it is
1763
+ // right after LAST_JS_OBJECT_TYPE, we can avoid checking for
1764
+ // LAST_JS_OBJECT_TYPE.
1765
+ ASSERT(LAST_TYPE == JS_FUNCTION_TYPE);
1766
+ ASSERT(JS_FUNCTION_TYPE == LAST_JS_OBJECT_TYPE + 1);
1767
+
1768
+ // Objects with a non-function constructor have class 'Object'.
1769
+ __ CmpObjectType(temp, JS_FUNCTION_TYPE, kScratchRegister);
1770
+ if (class_name->IsEqualTo(CStrVector("Object"))) {
1771
+ __ j(not_equal, is_true);
1772
+ } else {
1773
+ __ j(not_equal, is_false);
1774
+ }
1775
+
1776
+ // temp now contains the constructor function. Grab the
1777
+ // instance class name from there.
1778
+ __ movq(temp, FieldOperand(temp, JSFunction::kSharedFunctionInfoOffset));
1779
+ __ movq(temp, FieldOperand(temp,
1780
+ SharedFunctionInfo::kInstanceClassNameOffset));
1781
+ // The class name we are testing against is a symbol because it's a literal.
1782
+ // The name in the constructor is a symbol because of the way the context is
1783
+ // booted. This routine isn't expected to work for random API-created
1784
+ // classes and it doesn't have to because you can't access it with natives
1785
+ // syntax. Since both sides are symbols it is sufficient to use an identity
1786
+ // comparison.
1787
+ ASSERT(class_name->IsSymbol());
1788
+ __ Cmp(temp, class_name);
1789
+ // End with the answer in the z flag.
1790
+ }
1791
+
1792
+
1793
+ void LCodeGen::DoClassOfTest(LClassOfTest* instr) {
1794
+ Register input = ToRegister(instr->InputAt(0));
1795
+ Register result = ToRegister(instr->result());
1796
+ ASSERT(input.is(result));
1797
+ Register temp = ToRegister(instr->TempAt(0));
1798
+ Handle<String> class_name = instr->hydrogen()->class_name();
1799
+ NearLabel done;
1800
+ Label is_true, is_false;
1801
+
1802
+ EmitClassOfTest(&is_true, &is_false, class_name, input, temp);
1803
+
1804
+ __ j(not_equal, &is_false);
1805
+
1806
+ __ bind(&is_true);
1807
+ __ LoadRoot(result, Heap::kTrueValueRootIndex);
1808
+ __ jmp(&done);
1809
+
1810
+ __ bind(&is_false);
1811
+ __ LoadRoot(result, Heap::kFalseValueRootIndex);
1812
+ __ bind(&done);
1813
+ }
1814
+
1815
+
1816
+ void LCodeGen::DoClassOfTestAndBranch(LClassOfTestAndBranch* instr) {
1817
+ Register input = ToRegister(instr->InputAt(0));
1818
+ Register temp = ToRegister(instr->TempAt(0));
1819
+ Handle<String> class_name = instr->hydrogen()->class_name();
1820
+
1821
+ int true_block = chunk_->LookupDestination(instr->true_block_id());
1822
+ int false_block = chunk_->LookupDestination(instr->false_block_id());
1823
+
1824
+ Label* true_label = chunk_->GetAssemblyLabel(true_block);
1825
+ Label* false_label = chunk_->GetAssemblyLabel(false_block);
1826
+
1827
+ EmitClassOfTest(true_label, false_label, class_name, input, temp);
1828
+
1829
+ EmitBranch(true_block, false_block, equal);
1830
+ }
1831
+
1832
+
1833
+ void LCodeGen::DoCmpMapAndBranch(LCmpMapAndBranch* instr) {
1834
+ Register reg = ToRegister(instr->InputAt(0));
1835
+ int true_block = instr->true_block_id();
1836
+ int false_block = instr->false_block_id();
1837
+
1838
+ __ Cmp(FieldOperand(reg, HeapObject::kMapOffset), instr->map());
1839
+ EmitBranch(true_block, false_block, equal);
1840
+ }
1841
+
1842
+
1843
+ void LCodeGen::DoInstanceOf(LInstanceOf* instr) {
1844
+ InstanceofStub stub(InstanceofStub::kNoFlags);
1845
+ __ push(ToRegister(instr->InputAt(0)));
1846
+ __ push(ToRegister(instr->InputAt(1)));
1847
+ CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
1848
+ NearLabel true_value, done;
1849
+ __ testq(rax, rax);
1850
+ __ j(zero, &true_value);
1851
+ __ LoadRoot(ToRegister(instr->result()), Heap::kFalseValueRootIndex);
1852
+ __ jmp(&done);
1853
+ __ bind(&true_value);
1854
+ __ LoadRoot(ToRegister(instr->result()), Heap::kTrueValueRootIndex);
1855
+ __ bind(&done);
1856
+ }
1857
+
1858
+
1859
+ void LCodeGen::DoInstanceOfAndBranch(LInstanceOfAndBranch* instr) {
1860
+ int true_block = chunk_->LookupDestination(instr->true_block_id());
1861
+ int false_block = chunk_->LookupDestination(instr->false_block_id());
1862
+
1863
+ InstanceofStub stub(InstanceofStub::kNoFlags);
1864
+ __ push(ToRegister(instr->InputAt(0)));
1865
+ __ push(ToRegister(instr->InputAt(1)));
1866
+ CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
1867
+ __ testq(rax, rax);
1868
+ EmitBranch(true_block, false_block, zero);
1869
+ }
1870
+
1871
+
1872
+ void LCodeGen::DoInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) {
1873
+ class DeferredInstanceOfKnownGlobal: public LDeferredCode {
1874
+ public:
1875
+ DeferredInstanceOfKnownGlobal(LCodeGen* codegen,
1876
+ LInstanceOfKnownGlobal* instr)
1877
+ : LDeferredCode(codegen), instr_(instr) { }
1878
+ virtual void Generate() {
1879
+ codegen()->DoDeferredLInstanceOfKnownGlobal(instr_, &map_check_);
1880
+ }
1881
+
1882
+ Label* map_check() { return &map_check_; }
1883
+
1884
+ private:
1885
+ LInstanceOfKnownGlobal* instr_;
1886
+ Label map_check_;
1887
+ };
1888
+
1889
+
1890
+ DeferredInstanceOfKnownGlobal* deferred;
1891
+ deferred = new DeferredInstanceOfKnownGlobal(this, instr);
1892
+
1893
+ Label done, false_result;
1894
+ Register object = ToRegister(instr->InputAt(0));
1895
+
1896
+ // A Smi is not an instance of anything.
1897
+ __ JumpIfSmi(object, &false_result);
1898
+
1899
+ // This is the inlined call site instanceof cache. The two occurences of the
1900
+ // hole value will be patched to the last map/result pair generated by the
1901
+ // instanceof stub.
1902
+ NearLabel cache_miss;
1903
+ // Use a temp register to avoid memory operands with variable lengths.
1904
+ Register map = ToRegister(instr->TempAt(0));
1905
+ __ movq(map, FieldOperand(object, HeapObject::kMapOffset));
1906
+ __ bind(deferred->map_check()); // Label for calculating code patching.
1907
+ __ movq(kScratchRegister, factory()->the_hole_value(),
1908
+ RelocInfo::EMBEDDED_OBJECT);
1909
+ __ cmpq(map, kScratchRegister); // Patched to cached map.
1910
+ __ j(not_equal, &cache_miss);
1911
+ // Patched to load either true or false.
1912
+ __ LoadRoot(ToRegister(instr->result()), Heap::kTheHoleValueRootIndex);
1913
+ #ifdef DEBUG
1914
+ // Check that the code size between patch label and patch sites is invariant.
1915
+ Label end_of_patched_code;
1916
+ __ bind(&end_of_patched_code);
1917
+ ASSERT(true);
1918
+ #endif
1919
+ __ jmp(&done);
1920
+
1921
+ // The inlined call site cache did not match. Check for null and string
1922
+ // before calling the deferred code.
1923
+ __ bind(&cache_miss); // Null is not an instance of anything.
1924
+ __ CompareRoot(object, Heap::kNullValueRootIndex);
1925
+ __ j(equal, &false_result);
1926
+
1927
+ // String values are not instances of anything.
1928
+ __ JumpIfNotString(object, kScratchRegister, deferred->entry());
1929
+
1930
+ __ bind(&false_result);
1931
+ __ LoadRoot(ToRegister(instr->result()), Heap::kFalseValueRootIndex);
1932
+
1933
+ __ bind(deferred->exit());
1934
+ __ bind(&done);
1935
+ }
1936
+
1937
+
1938
+ void LCodeGen::DoDeferredLInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr,
1939
+ Label* map_check) {
1940
+ __ PushSafepointRegisters();
1941
+ InstanceofStub::Flags flags = static_cast<InstanceofStub::Flags>(
1942
+ InstanceofStub::kNoFlags | InstanceofStub::kCallSiteInlineCheck);
1943
+ InstanceofStub stub(flags);
1944
+
1945
+ __ push(ToRegister(instr->InputAt(0)));
1946
+ __ Push(instr->function());
1947
+ Register temp = ToRegister(instr->TempAt(0));
1948
+ ASSERT(temp.is(rdi));
1949
+ static const int kAdditionalDelta = 16;
1950
+ int delta =
1951
+ masm_->SizeOfCodeGeneratedSince(map_check) + kAdditionalDelta;
1952
+ __ movq(temp, Immediate(delta));
1953
+ __ push(temp);
1954
+ CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
1955
+ __ movq(kScratchRegister, rax);
1956
+ __ PopSafepointRegisters();
1957
+ __ testq(kScratchRegister, kScratchRegister);
1958
+ Label load_false;
1959
+ Label done;
1960
+ __ j(not_zero, &load_false);
1961
+ __ LoadRoot(rax, Heap::kTrueValueRootIndex);
1962
+ __ jmp(&done);
1963
+ __ bind(&load_false);
1964
+ __ LoadRoot(rax, Heap::kFalseValueRootIndex);
1965
+ __ bind(&done);
1966
+ }
1967
+
1968
+
1969
+ void LCodeGen::DoCmpT(LCmpT* instr) {
1970
+ Token::Value op = instr->op();
1971
+
1972
+ Handle<Code> ic = CompareIC::GetUninitialized(op);
1973
+ CallCode(ic, RelocInfo::CODE_TARGET, instr);
1974
+
1975
+ Condition condition = TokenToCondition(op, false);
1976
+ if (op == Token::GT || op == Token::LTE) {
1977
+ condition = ReverseCondition(condition);
1978
+ }
1979
+ NearLabel true_value, done;
1980
+ __ testq(rax, rax);
1981
+ __ j(condition, &true_value);
1982
+ __ LoadRoot(ToRegister(instr->result()), Heap::kFalseValueRootIndex);
1983
+ __ jmp(&done);
1984
+ __ bind(&true_value);
1985
+ __ LoadRoot(ToRegister(instr->result()), Heap::kTrueValueRootIndex);
1986
+ __ bind(&done);
1987
+ }
1988
+
1989
+
1990
+ void LCodeGen::DoCmpTAndBranch(LCmpTAndBranch* instr) {
1991
+ Token::Value op = instr->op();
1992
+ int true_block = chunk_->LookupDestination(instr->true_block_id());
1993
+ int false_block = chunk_->LookupDestination(instr->false_block_id());
1994
+
1995
+ Handle<Code> ic = CompareIC::GetUninitialized(op);
1996
+ CallCode(ic, RelocInfo::CODE_TARGET, instr);
1997
+
1998
+ // The compare stub expects compare condition and the input operands
1999
+ // reversed for GT and LTE.
2000
+ Condition condition = TokenToCondition(op, false);
2001
+ if (op == Token::GT || op == Token::LTE) {
2002
+ condition = ReverseCondition(condition);
2003
+ }
2004
+ __ testq(rax, rax);
2005
+ EmitBranch(true_block, false_block, condition);
2006
+ }
2007
+
2008
+
2009
+ void LCodeGen::DoReturn(LReturn* instr) {
2010
+ if (FLAG_trace) {
2011
+ // Preserve the return value on the stack and rely on the runtime
2012
+ // call to return the value in the same register.
2013
+ __ push(rax);
2014
+ __ CallRuntime(Runtime::kTraceExit, 1);
2015
+ }
2016
+ __ movq(rsp, rbp);
2017
+ __ pop(rbp);
2018
+ __ Ret((ParameterCount() + 1) * kPointerSize, rcx);
2019
+ }
2020
+
2021
+
2022
+ void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) {
2023
+ Register result = ToRegister(instr->result());
2024
+ if (result.is(rax)) {
2025
+ __ load_rax(instr->hydrogen()->cell().location(),
2026
+ RelocInfo::GLOBAL_PROPERTY_CELL);
2027
+ } else {
2028
+ __ movq(result, instr->hydrogen()->cell(), RelocInfo::GLOBAL_PROPERTY_CELL);
2029
+ __ movq(result, Operand(result, 0));
2030
+ }
2031
+ if (instr->hydrogen()->check_hole_value()) {
2032
+ __ CompareRoot(result, Heap::kTheHoleValueRootIndex);
2033
+ DeoptimizeIf(equal, instr->environment());
2034
+ }
2035
+ }
2036
+
2037
+
2038
+ void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) {
2039
+ ASSERT(ToRegister(instr->global_object()).is(rax));
2040
+ ASSERT(ToRegister(instr->result()).is(rax));
2041
+
2042
+ __ Move(rcx, instr->name());
2043
+ RelocInfo::Mode mode = instr->for_typeof() ? RelocInfo::CODE_TARGET :
2044
+ RelocInfo::CODE_TARGET_CONTEXT;
2045
+ Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
2046
+ CallCode(ic, mode, instr);
2047
+ }
2048
+
2049
+
2050
+ void LCodeGen::DoStoreGlobalCell(LStoreGlobalCell* instr) {
2051
+ Register value = ToRegister(instr->InputAt(0));
2052
+ Register temp = ToRegister(instr->TempAt(0));
2053
+ ASSERT(!value.is(temp));
2054
+ bool check_hole = instr->hydrogen()->check_hole_value();
2055
+ if (!check_hole && value.is(rax)) {
2056
+ __ store_rax(instr->hydrogen()->cell().location(),
2057
+ RelocInfo::GLOBAL_PROPERTY_CELL);
2058
+ return;
2059
+ }
2060
+ // If the cell we are storing to contains the hole it could have
2061
+ // been deleted from the property dictionary. In that case, we need
2062
+ // to update the property details in the property dictionary to mark
2063
+ // it as no longer deleted. We deoptimize in that case.
2064
+ __ movq(temp, instr->hydrogen()->cell(), RelocInfo::GLOBAL_PROPERTY_CELL);
2065
+ if (check_hole) {
2066
+ __ CompareRoot(Operand(temp, 0), Heap::kTheHoleValueRootIndex);
2067
+ DeoptimizeIf(equal, instr->environment());
2068
+ }
2069
+ __ movq(Operand(temp, 0), value);
2070
+ }
2071
+
2072
+
2073
+ void LCodeGen::DoStoreGlobalGeneric(LStoreGlobalGeneric* instr) {
2074
+ ASSERT(ToRegister(instr->global_object()).is(rdx));
2075
+ ASSERT(ToRegister(instr->value()).is(rax));
2076
+
2077
+ __ Move(rcx, instr->name());
2078
+ Handle<Code> ic = isolate()->builtins()->StoreIC_Initialize();
2079
+ CallCode(ic, RelocInfo::CODE_TARGET_CONTEXT, instr);
2080
+ }
2081
+
2082
+
2083
+ void LCodeGen::DoLoadContextSlot(LLoadContextSlot* instr) {
2084
+ Register context = ToRegister(instr->context());
2085
+ Register result = ToRegister(instr->result());
2086
+ __ movq(result, ContextOperand(context, instr->slot_index()));
2087
+ }
2088
+
2089
+
2090
+ void LCodeGen::DoStoreContextSlot(LStoreContextSlot* instr) {
2091
+ Register context = ToRegister(instr->context());
2092
+ Register value = ToRegister(instr->value());
2093
+ __ movq(ContextOperand(context, instr->slot_index()), value);
2094
+ if (instr->needs_write_barrier()) {
2095
+ int offset = Context::SlotOffset(instr->slot_index());
2096
+ Register scratch = ToRegister(instr->TempAt(0));
2097
+ __ RecordWrite(context, offset, value, scratch);
2098
+ }
2099
+ }
2100
+
2101
+
2102
+ void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) {
2103
+ Register object = ToRegister(instr->InputAt(0));
2104
+ Register result = ToRegister(instr->result());
2105
+ if (instr->hydrogen()->is_in_object()) {
2106
+ __ movq(result, FieldOperand(object, instr->hydrogen()->offset()));
2107
+ } else {
2108
+ __ movq(result, FieldOperand(object, JSObject::kPropertiesOffset));
2109
+ __ movq(result, FieldOperand(result, instr->hydrogen()->offset()));
2110
+ }
2111
+ }
2112
+
2113
+
2114
+ void LCodeGen::EmitLoadField(Register result,
2115
+ Register object,
2116
+ Handle<Map> type,
2117
+ Handle<String> name) {
2118
+ LookupResult lookup;
2119
+ type->LookupInDescriptors(NULL, *name, &lookup);
2120
+ ASSERT(lookup.IsProperty() && lookup.type() == FIELD);
2121
+ int index = lookup.GetLocalFieldIndexFromMap(*type);
2122
+ int offset = index * kPointerSize;
2123
+ if (index < 0) {
2124
+ // Negative property indices are in-object properties, indexed
2125
+ // from the end of the fixed part of the object.
2126
+ __ movq(result, FieldOperand(object, offset + type->instance_size()));
2127
+ } else {
2128
+ // Non-negative property indices are in the properties array.
2129
+ __ movq(result, FieldOperand(object, JSObject::kPropertiesOffset));
2130
+ __ movq(result, FieldOperand(result, offset + FixedArray::kHeaderSize));
2131
+ }
2132
+ }
2133
+
2134
+
2135
+ void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) {
2136
+ Register object = ToRegister(instr->object());
2137
+ Register result = ToRegister(instr->result());
2138
+
2139
+ int map_count = instr->hydrogen()->types()->length();
2140
+ Handle<String> name = instr->hydrogen()->name();
2141
+
2142
+ if (map_count == 0) {
2143
+ ASSERT(instr->hydrogen()->need_generic());
2144
+ __ Move(rcx, instr->hydrogen()->name());
2145
+ Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
2146
+ CallCode(ic, RelocInfo::CODE_TARGET, instr);
2147
+ } else {
2148
+ NearLabel done;
2149
+ for (int i = 0; i < map_count - 1; ++i) {
2150
+ Handle<Map> map = instr->hydrogen()->types()->at(i);
2151
+ NearLabel next;
2152
+ __ Cmp(FieldOperand(object, HeapObject::kMapOffset), map);
2153
+ __ j(not_equal, &next);
2154
+ EmitLoadField(result, object, map, name);
2155
+ __ jmp(&done);
2156
+ __ bind(&next);
2157
+ }
2158
+ Handle<Map> map = instr->hydrogen()->types()->last();
2159
+ __ Cmp(FieldOperand(object, HeapObject::kMapOffset), map);
2160
+ if (instr->hydrogen()->need_generic()) {
2161
+ NearLabel generic;
2162
+ __ j(not_equal, &generic);
2163
+ EmitLoadField(result, object, map, name);
2164
+ __ jmp(&done);
2165
+ __ bind(&generic);
2166
+ __ Move(rcx, instr->hydrogen()->name());
2167
+ Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
2168
+ CallCode(ic, RelocInfo::CODE_TARGET, instr);
2169
+ } else {
2170
+ DeoptimizeIf(not_equal, instr->environment());
2171
+ EmitLoadField(result, object, map, name);
2172
+ }
2173
+ __ bind(&done);
2174
+ }
2175
+ }
2176
+
2177
+
2178
+ void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) {
2179
+ ASSERT(ToRegister(instr->object()).is(rax));
2180
+ ASSERT(ToRegister(instr->result()).is(rax));
2181
+
2182
+ __ Move(rcx, instr->name());
2183
+ Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
2184
+ CallCode(ic, RelocInfo::CODE_TARGET, instr);
2185
+ }
2186
+
2187
+
2188
+ void LCodeGen::DoLoadFunctionPrototype(LLoadFunctionPrototype* instr) {
2189
+ Register function = ToRegister(instr->function());
2190
+ Register result = ToRegister(instr->result());
2191
+
2192
+ // Check that the function really is a function.
2193
+ __ CmpObjectType(function, JS_FUNCTION_TYPE, result);
2194
+ DeoptimizeIf(not_equal, instr->environment());
2195
+
2196
+ // Check whether the function has an instance prototype.
2197
+ NearLabel non_instance;
2198
+ __ testb(FieldOperand(result, Map::kBitFieldOffset),
2199
+ Immediate(1 << Map::kHasNonInstancePrototype));
2200
+ __ j(not_zero, &non_instance);
2201
+
2202
+ // Get the prototype or initial map from the function.
2203
+ __ movq(result,
2204
+ FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset));
2205
+
2206
+ // Check that the function has a prototype or an initial map.
2207
+ __ CompareRoot(result, Heap::kTheHoleValueRootIndex);
2208
+ DeoptimizeIf(equal, instr->environment());
2209
+
2210
+ // If the function does not have an initial map, we're done.
2211
+ NearLabel done;
2212
+ __ CmpObjectType(result, MAP_TYPE, kScratchRegister);
2213
+ __ j(not_equal, &done);
2214
+
2215
+ // Get the prototype from the initial map.
2216
+ __ movq(result, FieldOperand(result, Map::kPrototypeOffset));
2217
+ __ jmp(&done);
2218
+
2219
+ // Non-instance prototype: Fetch prototype from constructor field
2220
+ // in the function's map.
2221
+ __ bind(&non_instance);
2222
+ __ movq(result, FieldOperand(result, Map::kConstructorOffset));
2223
+
2224
+ // All done.
2225
+ __ bind(&done);
2226
+ }
2227
+
2228
+
2229
+ void LCodeGen::DoLoadElements(LLoadElements* instr) {
2230
+ Register result = ToRegister(instr->result());
2231
+ Register input = ToRegister(instr->InputAt(0));
2232
+ __ movq(result, FieldOperand(input, JSObject::kElementsOffset));
2233
+ if (FLAG_debug_code) {
2234
+ NearLabel done;
2235
+ __ CompareRoot(FieldOperand(result, HeapObject::kMapOffset),
2236
+ Heap::kFixedArrayMapRootIndex);
2237
+ __ j(equal, &done);
2238
+ __ CompareRoot(FieldOperand(result, HeapObject::kMapOffset),
2239
+ Heap::kFixedCOWArrayMapRootIndex);
2240
+ __ j(equal, &done);
2241
+ Register temp((result.is(rax)) ? rbx : rax);
2242
+ __ push(temp);
2243
+ __ movq(temp, FieldOperand(result, HeapObject::kMapOffset));
2244
+ __ movzxbq(temp, FieldOperand(temp, Map::kInstanceTypeOffset));
2245
+ __ subq(temp, Immediate(FIRST_EXTERNAL_ARRAY_TYPE));
2246
+ __ cmpq(temp, Immediate(kExternalArrayTypeCount));
2247
+ __ pop(temp);
2248
+ __ Check(below, "Check for fast elements failed.");
2249
+ __ bind(&done);
2250
+ }
2251
+ }
2252
+
2253
+
2254
+ void LCodeGen::DoLoadExternalArrayPointer(
2255
+ LLoadExternalArrayPointer* instr) {
2256
+ Register result = ToRegister(instr->result());
2257
+ Register input = ToRegister(instr->InputAt(0));
2258
+ __ movq(result, FieldOperand(input,
2259
+ ExternalPixelArray::kExternalPointerOffset));
2260
+ }
2261
+
2262
+
2263
+ void LCodeGen::DoAccessArgumentsAt(LAccessArgumentsAt* instr) {
2264
+ Register arguments = ToRegister(instr->arguments());
2265
+ Register length = ToRegister(instr->length());
2266
+ Register result = ToRegister(instr->result());
2267
+
2268
+ if (instr->index()->IsRegister()) {
2269
+ __ subl(length, ToRegister(instr->index()));
2270
+ } else {
2271
+ __ subl(length, ToOperand(instr->index()));
2272
+ }
2273
+ DeoptimizeIf(below_equal, instr->environment());
2274
+
2275
+ // There are two words between the frame pointer and the last argument.
2276
+ // Subtracting from length accounts for one of them add one more.
2277
+ __ movq(result, Operand(arguments, length, times_pointer_size, kPointerSize));
2278
+ }
2279
+
2280
+
2281
+ void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) {
2282
+ Register elements = ToRegister(instr->elements());
2283
+ Register key = ToRegister(instr->key());
2284
+ Register result = ToRegister(instr->result());
2285
+ ASSERT(result.is(elements));
2286
+
2287
+ // Load the result.
2288
+ __ movq(result, FieldOperand(elements,
2289
+ key,
2290
+ times_pointer_size,
2291
+ FixedArray::kHeaderSize));
2292
+
2293
+ // Check for the hole value.
2294
+ __ CompareRoot(result, Heap::kTheHoleValueRootIndex);
2295
+ DeoptimizeIf(equal, instr->environment());
2296
+ }
2297
+
2298
+
2299
+ void LCodeGen::DoLoadKeyedSpecializedArrayElement(
2300
+ LLoadKeyedSpecializedArrayElement* instr) {
2301
+ Register external_pointer = ToRegister(instr->external_pointer());
2302
+ Register key = ToRegister(instr->key());
2303
+ ExternalArrayType array_type = instr->array_type();
2304
+ if (array_type == kExternalFloatArray) {
2305
+ XMMRegister result(ToDoubleRegister(instr->result()));
2306
+ __ movss(result, Operand(external_pointer, key, times_4, 0));
2307
+ __ cvtss2sd(result, result);
2308
+ } else {
2309
+ Register result(ToRegister(instr->result()));
2310
+ switch (array_type) {
2311
+ case kExternalByteArray:
2312
+ __ movsxbq(result, Operand(external_pointer, key, times_1, 0));
2313
+ break;
2314
+ case kExternalUnsignedByteArray:
2315
+ case kExternalPixelArray:
2316
+ __ movzxbq(result, Operand(external_pointer, key, times_1, 0));
2317
+ break;
2318
+ case kExternalShortArray:
2319
+ __ movsxwq(result, Operand(external_pointer, key, times_2, 0));
2320
+ break;
2321
+ case kExternalUnsignedShortArray:
2322
+ __ movzxwq(result, Operand(external_pointer, key, times_2, 0));
2323
+ break;
2324
+ case kExternalIntArray:
2325
+ __ movsxlq(result, Operand(external_pointer, key, times_4, 0));
2326
+ break;
2327
+ case kExternalUnsignedIntArray:
2328
+ __ movl(result, Operand(external_pointer, key, times_4, 0));
2329
+ __ testl(result, result);
2330
+ // TODO(danno): we could be more clever here, perhaps having a special
2331
+ // version of the stub that detects if the overflow case actually
2332
+ // happens, and generate code that returns a double rather than int.
2333
+ DeoptimizeIf(negative, instr->environment());
2334
+ break;
2335
+ case kExternalFloatArray:
2336
+ UNREACHABLE();
2337
+ break;
2338
+ }
2339
+ }
2340
+ }
2341
+
2342
+
2343
+ void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) {
2344
+ ASSERT(ToRegister(instr->object()).is(rdx));
2345
+ ASSERT(ToRegister(instr->key()).is(rax));
2346
+
2347
+ Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize();
2348
+ CallCode(ic, RelocInfo::CODE_TARGET, instr);
2349
+ }
2350
+
2351
+
2352
+ void LCodeGen::DoArgumentsElements(LArgumentsElements* instr) {
2353
+ Register result = ToRegister(instr->result());
2354
+
2355
+ // Check for arguments adapter frame.
2356
+ NearLabel done, adapted;
2357
+ __ movq(result, Operand(rbp, StandardFrameConstants::kCallerFPOffset));
2358
+ __ Cmp(Operand(result, StandardFrameConstants::kContextOffset),
2359
+ Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
2360
+ __ j(equal, &adapted);
2361
+
2362
+ // No arguments adaptor frame.
2363
+ __ movq(result, rbp);
2364
+ __ jmp(&done);
2365
+
2366
+ // Arguments adaptor frame present.
2367
+ __ bind(&adapted);
2368
+ __ movq(result, Operand(rbp, StandardFrameConstants::kCallerFPOffset));
2369
+
2370
+ // Result is the frame pointer for the frame if not adapted and for the real
2371
+ // frame below the adaptor frame if adapted.
2372
+ __ bind(&done);
2373
+ }
2374
+
2375
+
2376
+ void LCodeGen::DoArgumentsLength(LArgumentsLength* instr) {
2377
+ Register result = ToRegister(instr->result());
2378
+
2379
+ NearLabel done;
2380
+
2381
+ // If no arguments adaptor frame the number of arguments is fixed.
2382
+ if (instr->InputAt(0)->IsRegister()) {
2383
+ __ cmpq(rbp, ToRegister(instr->InputAt(0)));
2384
+ } else {
2385
+ __ cmpq(rbp, ToOperand(instr->InputAt(0)));
2386
+ }
2387
+ __ movq(result, Immediate(scope()->num_parameters()));
2388
+ __ j(equal, &done);
2389
+
2390
+ // Arguments adaptor frame present. Get argument length from there.
2391
+ __ movq(result, Operand(rbp, StandardFrameConstants::kCallerFPOffset));
2392
+ __ movq(result, Operand(result,
2393
+ ArgumentsAdaptorFrameConstants::kLengthOffset));
2394
+ __ SmiToInteger32(result, result);
2395
+
2396
+ // Argument length is in result register.
2397
+ __ bind(&done);
2398
+ }
2399
+
2400
+
2401
+ void LCodeGen::DoApplyArguments(LApplyArguments* instr) {
2402
+ Register receiver = ToRegister(instr->receiver());
2403
+ Register function = ToRegister(instr->function());
2404
+ Register length = ToRegister(instr->length());
2405
+ Register elements = ToRegister(instr->elements());
2406
+ ASSERT(receiver.is(rax)); // Used for parameter count.
2407
+ ASSERT(function.is(rdi)); // Required by InvokeFunction.
2408
+ ASSERT(ToRegister(instr->result()).is(rax));
2409
+
2410
+ // If the receiver is null or undefined, we have to pass the global object
2411
+ // as a receiver.
2412
+ NearLabel global_object, receiver_ok;
2413
+ __ CompareRoot(receiver, Heap::kNullValueRootIndex);
2414
+ __ j(equal, &global_object);
2415
+ __ CompareRoot(receiver, Heap::kUndefinedValueRootIndex);
2416
+ __ j(equal, &global_object);
2417
+
2418
+ // The receiver should be a JS object.
2419
+ Condition is_smi = __ CheckSmi(receiver);
2420
+ DeoptimizeIf(is_smi, instr->environment());
2421
+ __ CmpObjectType(receiver, FIRST_JS_OBJECT_TYPE, kScratchRegister);
2422
+ DeoptimizeIf(below, instr->environment());
2423
+ __ jmp(&receiver_ok);
2424
+
2425
+ __ bind(&global_object);
2426
+ // TODO(kmillikin): We have a hydrogen value for the global object. See
2427
+ // if it's better to use it than to explicitly fetch it from the context
2428
+ // here.
2429
+ __ movq(receiver, Operand(rbp, StandardFrameConstants::kContextOffset));
2430
+ __ movq(receiver, ContextOperand(receiver, Context::GLOBAL_INDEX));
2431
+ __ bind(&receiver_ok);
2432
+
2433
+ // Copy the arguments to this function possibly from the
2434
+ // adaptor frame below it.
2435
+ const uint32_t kArgumentsLimit = 1 * KB;
2436
+ __ cmpq(length, Immediate(kArgumentsLimit));
2437
+ DeoptimizeIf(above, instr->environment());
2438
+
2439
+ __ push(receiver);
2440
+ __ movq(receiver, length);
2441
+
2442
+ // Loop through the arguments pushing them onto the execution
2443
+ // stack.
2444
+ NearLabel invoke, loop;
2445
+ // length is a small non-negative integer, due to the test above.
2446
+ __ testl(length, length);
2447
+ __ j(zero, &invoke);
2448
+ __ bind(&loop);
2449
+ __ push(Operand(elements, length, times_pointer_size, 1 * kPointerSize));
2450
+ __ decl(length);
2451
+ __ j(not_zero, &loop);
2452
+
2453
+ // Invoke the function.
2454
+ __ bind(&invoke);
2455
+ ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment());
2456
+ LPointerMap* pointers = instr->pointer_map();
2457
+ LEnvironment* env = instr->deoptimization_environment();
2458
+ RecordPosition(pointers->position());
2459
+ RegisterEnvironmentForDeoptimization(env);
2460
+ SafepointGenerator safepoint_generator(this,
2461
+ pointers,
2462
+ env->deoptimization_index());
2463
+ v8::internal::ParameterCount actual(rax);
2464
+ __ InvokeFunction(function, actual, CALL_FUNCTION, &safepoint_generator);
2465
+ }
2466
+
2467
+
2468
+ void LCodeGen::DoPushArgument(LPushArgument* instr) {
2469
+ LOperand* argument = instr->InputAt(0);
2470
+ if (argument->IsConstantOperand()) {
2471
+ EmitPushConstantOperand(argument);
2472
+ } else if (argument->IsRegister()) {
2473
+ __ push(ToRegister(argument));
2474
+ } else {
2475
+ ASSERT(!argument->IsDoubleRegister());
2476
+ __ push(ToOperand(argument));
2477
+ }
2478
+ }
2479
+
2480
+
2481
+ void LCodeGen::DoContext(LContext* instr) {
2482
+ Register result = ToRegister(instr->result());
2483
+ __ movq(result, Operand(rbp, StandardFrameConstants::kContextOffset));
2484
+ }
2485
+
2486
+
2487
+ void LCodeGen::DoOuterContext(LOuterContext* instr) {
2488
+ Register context = ToRegister(instr->context());
2489
+ Register result = ToRegister(instr->result());
2490
+ __ movq(result,
2491
+ Operand(context, Context::SlotOffset(Context::CLOSURE_INDEX)));
2492
+ __ movq(result, FieldOperand(result, JSFunction::kContextOffset));
2493
+ }
2494
+
2495
+
2496
+ void LCodeGen::DoGlobalObject(LGlobalObject* instr) {
2497
+ Register result = ToRegister(instr->result());
2498
+ __ movq(result, GlobalObjectOperand());
2499
+ }
2500
+
2501
+
2502
+ void LCodeGen::DoGlobalReceiver(LGlobalReceiver* instr) {
2503
+ Register global = ToRegister(instr->global());
2504
+ Register result = ToRegister(instr->result());
2505
+ __ movq(result, FieldOperand(global, GlobalObject::kGlobalReceiverOffset));
2506
+ }
2507
+
2508
+
2509
+ void LCodeGen::CallKnownFunction(Handle<JSFunction> function,
2510
+ int arity,
2511
+ LInstruction* instr) {
2512
+ // Change context if needed.
2513
+ bool change_context =
2514
+ (info()->closure()->context() != function->context()) ||
2515
+ scope()->contains_with() ||
2516
+ (scope()->num_heap_slots() > 0);
2517
+ if (change_context) {
2518
+ __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
2519
+ }
2520
+
2521
+ // Set rax to arguments count if adaption is not needed. Assumes that rax
2522
+ // is available to write to at this point.
2523
+ if (!function->NeedsArgumentsAdaption()) {
2524
+ __ Set(rax, arity);
2525
+ }
2526
+
2527
+ LPointerMap* pointers = instr->pointer_map();
2528
+ RecordPosition(pointers->position());
2529
+
2530
+ // Invoke function.
2531
+ if (*function == *info()->closure()) {
2532
+ __ CallSelf();
2533
+ } else {
2534
+ __ call(FieldOperand(rdi, JSFunction::kCodeEntryOffset));
2535
+ }
2536
+
2537
+ // Setup deoptimization.
2538
+ RegisterLazyDeoptimization(instr);
2539
+
2540
+ // Restore context.
2541
+ __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
2542
+ }
2543
+
2544
+
2545
+ void LCodeGen::DoCallConstantFunction(LCallConstantFunction* instr) {
2546
+ ASSERT(ToRegister(instr->result()).is(rax));
2547
+ __ Move(rdi, instr->function());
2548
+ CallKnownFunction(instr->function(), instr->arity(), instr);
2549
+ }
2550
+
2551
+
2552
+ void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr) {
2553
+ Register input_reg = ToRegister(instr->InputAt(0));
2554
+ __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset),
2555
+ Heap::kHeapNumberMapRootIndex);
2556
+ DeoptimizeIf(not_equal, instr->environment());
2557
+
2558
+ Label done;
2559
+ Register tmp = input_reg.is(rax) ? rcx : rax;
2560
+ Register tmp2 = tmp.is(rcx) ? rdx : input_reg.is(rcx) ? rdx : rcx;
2561
+
2562
+ // Preserve the value of all registers.
2563
+ __ PushSafepointRegisters();
2564
+
2565
+ Label negative;
2566
+ __ movl(tmp, FieldOperand(input_reg, HeapNumber::kExponentOffset));
2567
+ // Check the sign of the argument. If the argument is positive, just
2568
+ // return it. We do not need to patch the stack since |input| and
2569
+ // |result| are the same register and |input| will be restored
2570
+ // unchanged by popping safepoint registers.
2571
+ __ testl(tmp, Immediate(HeapNumber::kSignMask));
2572
+ __ j(not_zero, &negative);
2573
+ __ jmp(&done);
2574
+
2575
+ __ bind(&negative);
2576
+
2577
+ Label allocated, slow;
2578
+ __ AllocateHeapNumber(tmp, tmp2, &slow);
2579
+ __ jmp(&allocated);
2580
+
2581
+ // Slow case: Call the runtime system to do the number allocation.
2582
+ __ bind(&slow);
2583
+
2584
+ __ CallRuntimeSaveDoubles(Runtime::kAllocateHeapNumber);
2585
+ RecordSafepointWithRegisters(
2586
+ instr->pointer_map(), 0, Safepoint::kNoDeoptimizationIndex);
2587
+ // Set the pointer to the new heap number in tmp.
2588
+ if (!tmp.is(rax)) {
2589
+ __ movq(tmp, rax);
2590
+ }
2591
+
2592
+ // Restore input_reg after call to runtime.
2593
+ __ LoadFromSafepointRegisterSlot(input_reg, input_reg);
2594
+
2595
+ __ bind(&allocated);
2596
+ __ movq(tmp2, FieldOperand(input_reg, HeapNumber::kValueOffset));
2597
+ __ shl(tmp2, Immediate(1));
2598
+ __ shr(tmp2, Immediate(1));
2599
+ __ movq(FieldOperand(tmp, HeapNumber::kValueOffset), tmp2);
2600
+ __ StoreToSafepointRegisterSlot(input_reg, tmp);
2601
+
2602
+ __ bind(&done);
2603
+ __ PopSafepointRegisters();
2604
+ }
2605
+
2606
+
2607
+ void LCodeGen::EmitIntegerMathAbs(LUnaryMathOperation* instr) {
2608
+ Register input_reg = ToRegister(instr->InputAt(0));
2609
+ __ testl(input_reg, input_reg);
2610
+ Label is_positive;
2611
+ __ j(not_sign, &is_positive);
2612
+ __ negl(input_reg); // Sets flags.
2613
+ DeoptimizeIf(negative, instr->environment());
2614
+ __ bind(&is_positive);
2615
+ }
2616
+
2617
+
2618
+ void LCodeGen::DoMathAbs(LUnaryMathOperation* instr) {
2619
+ // Class for deferred case.
2620
+ class DeferredMathAbsTaggedHeapNumber: public LDeferredCode {
2621
+ public:
2622
+ DeferredMathAbsTaggedHeapNumber(LCodeGen* codegen,
2623
+ LUnaryMathOperation* instr)
2624
+ : LDeferredCode(codegen), instr_(instr) { }
2625
+ virtual void Generate() {
2626
+ codegen()->DoDeferredMathAbsTaggedHeapNumber(instr_);
2627
+ }
2628
+ private:
2629
+ LUnaryMathOperation* instr_;
2630
+ };
2631
+
2632
+ ASSERT(instr->InputAt(0)->Equals(instr->result()));
2633
+ Representation r = instr->hydrogen()->value()->representation();
2634
+
2635
+ if (r.IsDouble()) {
2636
+ XMMRegister scratch = xmm0;
2637
+ XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0));
2638
+ __ xorpd(scratch, scratch);
2639
+ __ subsd(scratch, input_reg);
2640
+ __ andpd(input_reg, scratch);
2641
+ } else if (r.IsInteger32()) {
2642
+ EmitIntegerMathAbs(instr);
2643
+ } else { // Tagged case.
2644
+ DeferredMathAbsTaggedHeapNumber* deferred =
2645
+ new DeferredMathAbsTaggedHeapNumber(this, instr);
2646
+ Register input_reg = ToRegister(instr->InputAt(0));
2647
+ // Smi check.
2648
+ __ JumpIfNotSmi(input_reg, deferred->entry());
2649
+ EmitIntegerMathAbs(instr);
2650
+ __ bind(deferred->exit());
2651
+ }
2652
+ }
2653
+
2654
+
2655
+ void LCodeGen::DoMathFloor(LUnaryMathOperation* instr) {
2656
+ XMMRegister xmm_scratch = xmm0;
2657
+ Register output_reg = ToRegister(instr->result());
2658
+ XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0));
2659
+ __ xorpd(xmm_scratch, xmm_scratch); // Zero the register.
2660
+ __ ucomisd(input_reg, xmm_scratch);
2661
+
2662
+ if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
2663
+ DeoptimizeIf(below_equal, instr->environment());
2664
+ } else {
2665
+ DeoptimizeIf(below, instr->environment());
2666
+ }
2667
+
2668
+ // Use truncating instruction (OK because input is positive).
2669
+ __ cvttsd2si(output_reg, input_reg);
2670
+
2671
+ // Overflow is signalled with minint.
2672
+ __ cmpl(output_reg, Immediate(0x80000000));
2673
+ DeoptimizeIf(equal, instr->environment());
2674
+ }
2675
+
2676
+
2677
+ void LCodeGen::DoMathRound(LUnaryMathOperation* instr) {
2678
+ const XMMRegister xmm_scratch = xmm0;
2679
+ Register output_reg = ToRegister(instr->result());
2680
+ XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0));
2681
+
2682
+ // xmm_scratch = 0.5
2683
+ __ movq(kScratchRegister, V8_INT64_C(0x3FE0000000000000), RelocInfo::NONE);
2684
+ __ movq(xmm_scratch, kScratchRegister);
2685
+
2686
+ // input = input + 0.5
2687
+ __ addsd(input_reg, xmm_scratch);
2688
+
2689
+ // We need to return -0 for the input range [-0.5, 0[, otherwise
2690
+ // compute Math.floor(value + 0.5).
2691
+ if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
2692
+ __ ucomisd(input_reg, xmm_scratch);
2693
+ DeoptimizeIf(below_equal, instr->environment());
2694
+ } else {
2695
+ // If we don't need to bailout on -0, we check only bailout
2696
+ // on negative inputs.
2697
+ __ xorpd(xmm_scratch, xmm_scratch); // Zero the register.
2698
+ __ ucomisd(input_reg, xmm_scratch);
2699
+ DeoptimizeIf(below, instr->environment());
2700
+ }
2701
+
2702
+ // Compute Math.floor(value + 0.5).
2703
+ // Use truncating instruction (OK because input is positive).
2704
+ __ cvttsd2si(output_reg, input_reg);
2705
+
2706
+ // Overflow is signalled with minint.
2707
+ __ cmpl(output_reg, Immediate(0x80000000));
2708
+ DeoptimizeIf(equal, instr->environment());
2709
+ }
2710
+
2711
+
2712
+ void LCodeGen::DoMathSqrt(LUnaryMathOperation* instr) {
2713
+ XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0));
2714
+ ASSERT(ToDoubleRegister(instr->result()).is(input_reg));
2715
+ __ sqrtsd(input_reg, input_reg);
2716
+ }
2717
+
2718
+
2719
+ void LCodeGen::DoMathPowHalf(LUnaryMathOperation* instr) {
2720
+ XMMRegister xmm_scratch = xmm0;
2721
+ XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0));
2722
+ ASSERT(ToDoubleRegister(instr->result()).is(input_reg));
2723
+ __ xorpd(xmm_scratch, xmm_scratch);
2724
+ __ addsd(input_reg, xmm_scratch); // Convert -0 to +0.
2725
+ __ sqrtsd(input_reg, input_reg);
2726
+ }
2727
+
2728
+
2729
+ void LCodeGen::DoPower(LPower* instr) {
2730
+ LOperand* left = instr->InputAt(0);
2731
+ XMMRegister left_reg = ToDoubleRegister(left);
2732
+ ASSERT(!left_reg.is(xmm1));
2733
+ LOperand* right = instr->InputAt(1);
2734
+ XMMRegister result_reg = ToDoubleRegister(instr->result());
2735
+ Representation exponent_type = instr->hydrogen()->right()->representation();
2736
+ if (exponent_type.IsDouble()) {
2737
+ __ PrepareCallCFunction(2);
2738
+ // Move arguments to correct registers
2739
+ __ movsd(xmm0, left_reg);
2740
+ ASSERT(ToDoubleRegister(right).is(xmm1));
2741
+ __ CallCFunction(
2742
+ ExternalReference::power_double_double_function(isolate()), 2);
2743
+ } else if (exponent_type.IsInteger32()) {
2744
+ __ PrepareCallCFunction(2);
2745
+ // Move arguments to correct registers: xmm0 and edi (not rdi).
2746
+ // On Windows, the registers are xmm0 and edx.
2747
+ __ movsd(xmm0, left_reg);
2748
+ #ifdef _WIN64
2749
+ ASSERT(ToRegister(right).is(rdx));
2750
+ #else
2751
+ ASSERT(ToRegister(right).is(rdi));
2752
+ #endif
2753
+ __ CallCFunction(
2754
+ ExternalReference::power_double_int_function(isolate()), 2);
2755
+ } else {
2756
+ ASSERT(exponent_type.IsTagged());
2757
+ Register right_reg = ToRegister(right);
2758
+
2759
+ Label non_smi, call;
2760
+ __ JumpIfNotSmi(right_reg, &non_smi);
2761
+ __ SmiToInteger32(right_reg, right_reg);
2762
+ __ cvtlsi2sd(xmm1, right_reg);
2763
+ __ jmp(&call);
2764
+
2765
+ __ bind(&non_smi);
2766
+ __ CmpObjectType(right_reg, HEAP_NUMBER_TYPE , kScratchRegister);
2767
+ DeoptimizeIf(not_equal, instr->environment());
2768
+ __ movsd(xmm1, FieldOperand(right_reg, HeapNumber::kValueOffset));
2769
+
2770
+ __ bind(&call);
2771
+ __ PrepareCallCFunction(2);
2772
+ // Move arguments to correct registers xmm0 and xmm1.
2773
+ __ movsd(xmm0, left_reg);
2774
+ // Right argument is already in xmm1.
2775
+ __ CallCFunction(
2776
+ ExternalReference::power_double_double_function(isolate()), 2);
2777
+ }
2778
+ // Return value is in xmm0.
2779
+ __ movsd(result_reg, xmm0);
2780
+ // Restore context register.
2781
+ __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
2782
+ }
2783
+
2784
+
2785
+ void LCodeGen::DoMathLog(LUnaryMathOperation* instr) {
2786
+ ASSERT(ToDoubleRegister(instr->result()).is(xmm1));
2787
+ TranscendentalCacheStub stub(TranscendentalCache::LOG,
2788
+ TranscendentalCacheStub::UNTAGGED);
2789
+ CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
2790
+ }
2791
+
2792
+
2793
+ void LCodeGen::DoMathCos(LUnaryMathOperation* instr) {
2794
+ ASSERT(ToDoubleRegister(instr->result()).is(xmm1));
2795
+ TranscendentalCacheStub stub(TranscendentalCache::COS,
2796
+ TranscendentalCacheStub::UNTAGGED);
2797
+ CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
2798
+ }
2799
+
2800
+
2801
+ void LCodeGen::DoMathSin(LUnaryMathOperation* instr) {
2802
+ ASSERT(ToDoubleRegister(instr->result()).is(xmm1));
2803
+ TranscendentalCacheStub stub(TranscendentalCache::SIN,
2804
+ TranscendentalCacheStub::UNTAGGED);
2805
+ CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
2806
+ }
2807
+
2808
+
2809
+ void LCodeGen::DoUnaryMathOperation(LUnaryMathOperation* instr) {
2810
+ switch (instr->op()) {
2811
+ case kMathAbs:
2812
+ DoMathAbs(instr);
2813
+ break;
2814
+ case kMathFloor:
2815
+ DoMathFloor(instr);
2816
+ break;
2817
+ case kMathRound:
2818
+ DoMathRound(instr);
2819
+ break;
2820
+ case kMathSqrt:
2821
+ DoMathSqrt(instr);
2822
+ break;
2823
+ case kMathPowHalf:
2824
+ DoMathPowHalf(instr);
2825
+ break;
2826
+ case kMathCos:
2827
+ DoMathCos(instr);
2828
+ break;
2829
+ case kMathSin:
2830
+ DoMathSin(instr);
2831
+ break;
2832
+ case kMathLog:
2833
+ DoMathLog(instr);
2834
+ break;
2835
+
2836
+ default:
2837
+ UNREACHABLE();
2838
+ }
2839
+ }
2840
+
2841
+
2842
+ void LCodeGen::DoCallKeyed(LCallKeyed* instr) {
2843
+ ASSERT(ToRegister(instr->key()).is(rcx));
2844
+ ASSERT(ToRegister(instr->result()).is(rax));
2845
+
2846
+ int arity = instr->arity();
2847
+ Handle<Code> ic = isolate()->stub_cache()->ComputeKeyedCallInitialize(
2848
+ arity, NOT_IN_LOOP);
2849
+ CallCode(ic, RelocInfo::CODE_TARGET, instr);
2850
+ __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
2851
+ }
2852
+
2853
+
2854
+ void LCodeGen::DoCallNamed(LCallNamed* instr) {
2855
+ ASSERT(ToRegister(instr->result()).is(rax));
2856
+
2857
+ int arity = instr->arity();
2858
+ Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(
2859
+ arity, NOT_IN_LOOP);
2860
+ __ Move(rcx, instr->name());
2861
+ CallCode(ic, RelocInfo::CODE_TARGET, instr);
2862
+ __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
2863
+ }
2864
+
2865
+
2866
+ void LCodeGen::DoCallFunction(LCallFunction* instr) {
2867
+ ASSERT(ToRegister(instr->result()).is(rax));
2868
+
2869
+ int arity = instr->arity();
2870
+ CallFunctionStub stub(arity, NOT_IN_LOOP, RECEIVER_MIGHT_BE_VALUE);
2871
+ CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
2872
+ __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
2873
+ __ Drop(1);
2874
+ }
2875
+
2876
+
2877
+ void LCodeGen::DoCallGlobal(LCallGlobal* instr) {
2878
+ ASSERT(ToRegister(instr->result()).is(rax));
2879
+ int arity = instr->arity();
2880
+ Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(
2881
+ arity, NOT_IN_LOOP);
2882
+ __ Move(rcx, instr->name());
2883
+ CallCode(ic, RelocInfo::CODE_TARGET_CONTEXT, instr);
2884
+ __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
2885
+ }
2886
+
2887
+
2888
+ void LCodeGen::DoCallKnownGlobal(LCallKnownGlobal* instr) {
2889
+ ASSERT(ToRegister(instr->result()).is(rax));
2890
+ __ Move(rdi, instr->target());
2891
+ CallKnownFunction(instr->target(), instr->arity(), instr);
2892
+ }
2893
+
2894
+
2895
+ void LCodeGen::DoCallNew(LCallNew* instr) {
2896
+ ASSERT(ToRegister(instr->InputAt(0)).is(rdi));
2897
+ ASSERT(ToRegister(instr->result()).is(rax));
2898
+
2899
+ Handle<Code> builtin = isolate()->builtins()->JSConstructCall();
2900
+ __ Set(rax, instr->arity());
2901
+ CallCode(builtin, RelocInfo::CONSTRUCT_CALL, instr);
2902
+ }
2903
+
2904
+
2905
+ void LCodeGen::DoCallRuntime(LCallRuntime* instr) {
2906
+ CallRuntime(instr->function(), instr->arity(), instr);
2907
+ }
2908
+
2909
+
2910
+ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) {
2911
+ Register object = ToRegister(instr->object());
2912
+ Register value = ToRegister(instr->value());
2913
+ int offset = instr->offset();
2914
+
2915
+ if (!instr->transition().is_null()) {
2916
+ __ Move(FieldOperand(object, HeapObject::kMapOffset), instr->transition());
2917
+ }
2918
+
2919
+ // Do the store.
2920
+ if (instr->is_in_object()) {
2921
+ __ movq(FieldOperand(object, offset), value);
2922
+ if (instr->needs_write_barrier()) {
2923
+ Register temp = ToRegister(instr->TempAt(0));
2924
+ // Update the write barrier for the object for in-object properties.
2925
+ __ RecordWrite(object, offset, value, temp);
2926
+ }
2927
+ } else {
2928
+ Register temp = ToRegister(instr->TempAt(0));
2929
+ __ movq(temp, FieldOperand(object, JSObject::kPropertiesOffset));
2930
+ __ movq(FieldOperand(temp, offset), value);
2931
+ if (instr->needs_write_barrier()) {
2932
+ // Update the write barrier for the properties array.
2933
+ // object is used as a scratch register.
2934
+ __ RecordWrite(temp, offset, value, object);
2935
+ }
2936
+ }
2937
+ }
2938
+
2939
+
2940
+ void LCodeGen::DoStoreNamedGeneric(LStoreNamedGeneric* instr) {
2941
+ ASSERT(ToRegister(instr->object()).is(rdx));
2942
+ ASSERT(ToRegister(instr->value()).is(rax));
2943
+
2944
+ __ Move(rcx, instr->hydrogen()->name());
2945
+ Handle<Code> ic = info_->is_strict()
2946
+ ? isolate()->builtins()->StoreIC_Initialize_Strict()
2947
+ : isolate()->builtins()->StoreIC_Initialize();
2948
+ CallCode(ic, RelocInfo::CODE_TARGET, instr);
2949
+ }
2950
+
2951
+
2952
+ void LCodeGen::DoStoreKeyedSpecializedArrayElement(
2953
+ LStoreKeyedSpecializedArrayElement* instr) {
2954
+ Register external_pointer = ToRegister(instr->external_pointer());
2955
+ Register key = ToRegister(instr->key());
2956
+ ExternalArrayType array_type = instr->array_type();
2957
+ if (array_type == kExternalFloatArray) {
2958
+ XMMRegister value(ToDoubleRegister(instr->value()));
2959
+ __ cvtsd2ss(value, value);
2960
+ __ movss(Operand(external_pointer, key, times_4, 0), value);
2961
+ } else {
2962
+ Register value(ToRegister(instr->value()));
2963
+ switch (array_type) {
2964
+ case kExternalPixelArray:
2965
+ { // Clamp the value to [0..255].
2966
+ NearLabel done;
2967
+ __ testl(value, Immediate(0xFFFFFF00));
2968
+ __ j(zero, &done);
2969
+ __ setcc(negative, value); // 1 if negative, 0 if positive.
2970
+ __ decb(value); // 0 if negative, 255 if positive.
2971
+ __ bind(&done);
2972
+ __ movb(Operand(external_pointer, key, times_1, 0), value);
2973
+ }
2974
+ break;
2975
+ case kExternalByteArray:
2976
+ case kExternalUnsignedByteArray:
2977
+ __ movb(Operand(external_pointer, key, times_1, 0), value);
2978
+ break;
2979
+ case kExternalShortArray:
2980
+ case kExternalUnsignedShortArray:
2981
+ __ movw(Operand(external_pointer, key, times_2, 0), value);
2982
+ break;
2983
+ case kExternalIntArray:
2984
+ case kExternalUnsignedIntArray:
2985
+ __ movl(Operand(external_pointer, key, times_4, 0), value);
2986
+ break;
2987
+ case kExternalFloatArray:
2988
+ UNREACHABLE();
2989
+ break;
2990
+ }
2991
+ }
2992
+ }
2993
+
2994
+
2995
+ void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) {
2996
+ if (instr->length()->IsRegister()) {
2997
+ __ cmpq(ToRegister(instr->index()), ToRegister(instr->length()));
2998
+ } else {
2999
+ __ cmpq(ToRegister(instr->index()), ToOperand(instr->length()));
3000
+ }
3001
+ DeoptimizeIf(above_equal, instr->environment());
3002
+ }
3003
+
3004
+
3005
+ void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) {
3006
+ Register value = ToRegister(instr->value());
3007
+ Register elements = ToRegister(instr->object());
3008
+ Register key = instr->key()->IsRegister() ? ToRegister(instr->key()) : no_reg;
3009
+
3010
+ // Do the store.
3011
+ if (instr->key()->IsConstantOperand()) {
3012
+ ASSERT(!instr->hydrogen()->NeedsWriteBarrier());
3013
+ LConstantOperand* const_operand = LConstantOperand::cast(instr->key());
3014
+ int offset =
3015
+ ToInteger32(const_operand) * kPointerSize + FixedArray::kHeaderSize;
3016
+ __ movq(FieldOperand(elements, offset), value);
3017
+ } else {
3018
+ __ movq(FieldOperand(elements,
3019
+ key,
3020
+ times_pointer_size,
3021
+ FixedArray::kHeaderSize),
3022
+ value);
3023
+ }
3024
+
3025
+ if (instr->hydrogen()->NeedsWriteBarrier()) {
3026
+ // Compute address of modified element and store it into key register.
3027
+ __ lea(key, FieldOperand(elements,
3028
+ key,
3029
+ times_pointer_size,
3030
+ FixedArray::kHeaderSize));
3031
+ __ RecordWrite(elements, key, value);
3032
+ }
3033
+ }
3034
+
3035
+
3036
+ void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) {
3037
+ ASSERT(ToRegister(instr->object()).is(rdx));
3038
+ ASSERT(ToRegister(instr->key()).is(rcx));
3039
+ ASSERT(ToRegister(instr->value()).is(rax));
3040
+
3041
+ Handle<Code> ic = info_->is_strict()
3042
+ ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict()
3043
+ : isolate()->builtins()->KeyedStoreIC_Initialize();
3044
+ CallCode(ic, RelocInfo::CODE_TARGET, instr);
3045
+ }
3046
+
3047
+
3048
+ void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) {
3049
+ class DeferredStringCharCodeAt: public LDeferredCode {
3050
+ public:
3051
+ DeferredStringCharCodeAt(LCodeGen* codegen, LStringCharCodeAt* instr)
3052
+ : LDeferredCode(codegen), instr_(instr) { }
3053
+ virtual void Generate() { codegen()->DoDeferredStringCharCodeAt(instr_); }
3054
+ private:
3055
+ LStringCharCodeAt* instr_;
3056
+ };
3057
+
3058
+ Register string = ToRegister(instr->string());
3059
+ Register index = no_reg;
3060
+ int const_index = -1;
3061
+ if (instr->index()->IsConstantOperand()) {
3062
+ const_index = ToInteger32(LConstantOperand::cast(instr->index()));
3063
+ STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue);
3064
+ if (!Smi::IsValid(const_index)) {
3065
+ // Guaranteed to be out of bounds because of the assert above.
3066
+ // So the bounds check that must dominate this instruction must
3067
+ // have deoptimized already.
3068
+ if (FLAG_debug_code) {
3069
+ __ Abort("StringCharCodeAt: out of bounds index.");
3070
+ }
3071
+ // No code needs to be generated.
3072
+ return;
3073
+ }
3074
+ } else {
3075
+ index = ToRegister(instr->index());
3076
+ }
3077
+ Register result = ToRegister(instr->result());
3078
+
3079
+ DeferredStringCharCodeAt* deferred =
3080
+ new DeferredStringCharCodeAt(this, instr);
3081
+
3082
+ NearLabel flat_string, ascii_string, done;
3083
+
3084
+ // Fetch the instance type of the receiver into result register.
3085
+ __ movq(result, FieldOperand(string, HeapObject::kMapOffset));
3086
+ __ movzxbl(result, FieldOperand(result, Map::kInstanceTypeOffset));
3087
+
3088
+ // We need special handling for non-sequential strings.
3089
+ STATIC_ASSERT(kSeqStringTag == 0);
3090
+ __ testb(result, Immediate(kStringRepresentationMask));
3091
+ __ j(zero, &flat_string);
3092
+
3093
+ // Handle cons strings and go to deferred code for the rest.
3094
+ __ testb(result, Immediate(kIsConsStringMask));
3095
+ __ j(zero, deferred->entry());
3096
+
3097
+ // ConsString.
3098
+ // Check whether the right hand side is the empty string (i.e. if
3099
+ // this is really a flat string in a cons string). If that is not
3100
+ // the case we would rather go to the runtime system now to flatten
3101
+ // the string.
3102
+ __ CompareRoot(FieldOperand(string, ConsString::kSecondOffset),
3103
+ Heap::kEmptyStringRootIndex);
3104
+ __ j(not_equal, deferred->entry());
3105
+ // Get the first of the two strings and load its instance type.
3106
+ __ movq(string, FieldOperand(string, ConsString::kFirstOffset));
3107
+ __ movq(result, FieldOperand(string, HeapObject::kMapOffset));
3108
+ __ movzxbl(result, FieldOperand(result, Map::kInstanceTypeOffset));
3109
+ // If the first cons component is also non-flat, then go to runtime.
3110
+ STATIC_ASSERT(kSeqStringTag == 0);
3111
+ __ testb(result, Immediate(kStringRepresentationMask));
3112
+ __ j(not_zero, deferred->entry());
3113
+
3114
+ // Check for ASCII or two-byte string.
3115
+ __ bind(&flat_string);
3116
+ STATIC_ASSERT(kAsciiStringTag != 0);
3117
+ __ testb(result, Immediate(kStringEncodingMask));
3118
+ __ j(not_zero, &ascii_string);
3119
+
3120
+ // Two-byte string.
3121
+ // Load the two-byte character code into the result register.
3122
+ STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1);
3123
+ if (instr->index()->IsConstantOperand()) {
3124
+ __ movzxwl(result,
3125
+ FieldOperand(string,
3126
+ SeqTwoByteString::kHeaderSize +
3127
+ (kUC16Size * const_index)));
3128
+ } else {
3129
+ __ movzxwl(result, FieldOperand(string,
3130
+ index,
3131
+ times_2,
3132
+ SeqTwoByteString::kHeaderSize));
3133
+ }
3134
+ __ jmp(&done);
3135
+
3136
+ // ASCII string.
3137
+ // Load the byte into the result register.
3138
+ __ bind(&ascii_string);
3139
+ if (instr->index()->IsConstantOperand()) {
3140
+ __ movzxbl(result, FieldOperand(string,
3141
+ SeqAsciiString::kHeaderSize + const_index));
3142
+ } else {
3143
+ __ movzxbl(result, FieldOperand(string,
3144
+ index,
3145
+ times_1,
3146
+ SeqAsciiString::kHeaderSize));
3147
+ }
3148
+ __ bind(&done);
3149
+ __ bind(deferred->exit());
3150
+ }
3151
+
3152
+
3153
+ void LCodeGen::DoDeferredStringCharCodeAt(LStringCharCodeAt* instr) {
3154
+ Register string = ToRegister(instr->string());
3155
+ Register result = ToRegister(instr->result());
3156
+
3157
+ // TODO(3095996): Get rid of this. For now, we need to make the
3158
+ // result register contain a valid pointer because it is already
3159
+ // contained in the register pointer map.
3160
+ __ Set(result, 0);
3161
+
3162
+ __ PushSafepointRegisters();
3163
+ __ push(string);
3164
+ // Push the index as a smi. This is safe because of the checks in
3165
+ // DoStringCharCodeAt above.
3166
+ STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue);
3167
+ if (instr->index()->IsConstantOperand()) {
3168
+ int const_index = ToInteger32(LConstantOperand::cast(instr->index()));
3169
+ __ Push(Smi::FromInt(const_index));
3170
+ } else {
3171
+ Register index = ToRegister(instr->index());
3172
+ __ Integer32ToSmi(index, index);
3173
+ __ push(index);
3174
+ }
3175
+ __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
3176
+ __ CallRuntimeSaveDoubles(Runtime::kStringCharCodeAt);
3177
+ RecordSafepointWithRegisters(
3178
+ instr->pointer_map(), 2, Safepoint::kNoDeoptimizationIndex);
3179
+ if (FLAG_debug_code) {
3180
+ __ AbortIfNotSmi(rax);
3181
+ }
3182
+ __ SmiToInteger32(rax, rax);
3183
+ __ StoreToSafepointRegisterSlot(result, rax);
3184
+ __ PopSafepointRegisters();
3185
+ }
3186
+
3187
+
3188
+ void LCodeGen::DoStringCharFromCode(LStringCharFromCode* instr) {
3189
+ class DeferredStringCharFromCode: public LDeferredCode {
3190
+ public:
3191
+ DeferredStringCharFromCode(LCodeGen* codegen, LStringCharFromCode* instr)
3192
+ : LDeferredCode(codegen), instr_(instr) { }
3193
+ virtual void Generate() { codegen()->DoDeferredStringCharFromCode(instr_); }
3194
+ private:
3195
+ LStringCharFromCode* instr_;
3196
+ };
3197
+
3198
+ DeferredStringCharFromCode* deferred =
3199
+ new DeferredStringCharFromCode(this, instr);
3200
+
3201
+ ASSERT(instr->hydrogen()->value()->representation().IsInteger32());
3202
+ Register char_code = ToRegister(instr->char_code());
3203
+ Register result = ToRegister(instr->result());
3204
+ ASSERT(!char_code.is(result));
3205
+
3206
+ __ cmpl(char_code, Immediate(String::kMaxAsciiCharCode));
3207
+ __ j(above, deferred->entry());
3208
+ __ LoadRoot(result, Heap::kSingleCharacterStringCacheRootIndex);
3209
+ __ movq(result, FieldOperand(result,
3210
+ char_code, times_pointer_size,
3211
+ FixedArray::kHeaderSize));
3212
+ __ CompareRoot(result, Heap::kUndefinedValueRootIndex);
3213
+ __ j(equal, deferred->entry());
3214
+ __ bind(deferred->exit());
3215
+ }
3216
+
3217
+
3218
+ void LCodeGen::DoDeferredStringCharFromCode(LStringCharFromCode* instr) {
3219
+ Register char_code = ToRegister(instr->char_code());
3220
+ Register result = ToRegister(instr->result());
3221
+
3222
+ // TODO(3095996): Get rid of this. For now, we need to make the
3223
+ // result register contain a valid pointer because it is already
3224
+ // contained in the register pointer map.
3225
+ __ Set(result, 0);
3226
+
3227
+ __ PushSafepointRegisters();
3228
+ __ Integer32ToSmi(char_code, char_code);
3229
+ __ push(char_code);
3230
+ __ CallRuntimeSaveDoubles(Runtime::kCharFromCode);
3231
+ RecordSafepointWithRegisters(
3232
+ instr->pointer_map(), 1, Safepoint::kNoDeoptimizationIndex);
3233
+ __ StoreToSafepointRegisterSlot(result, rax);
3234
+ __ PopSafepointRegisters();
3235
+ }
3236
+
3237
+
3238
+ void LCodeGen::DoStringLength(LStringLength* instr) {
3239
+ Register string = ToRegister(instr->string());
3240
+ Register result = ToRegister(instr->result());
3241
+ __ movq(result, FieldOperand(string, String::kLengthOffset));
3242
+ }
3243
+
3244
+
3245
+ void LCodeGen::DoInteger32ToDouble(LInteger32ToDouble* instr) {
3246
+ LOperand* input = instr->InputAt(0);
3247
+ ASSERT(input->IsRegister() || input->IsStackSlot());
3248
+ LOperand* output = instr->result();
3249
+ ASSERT(output->IsDoubleRegister());
3250
+ if (input->IsRegister()) {
3251
+ __ cvtlsi2sd(ToDoubleRegister(output), ToRegister(input));
3252
+ } else {
3253
+ __ cvtlsi2sd(ToDoubleRegister(output), ToOperand(input));
3254
+ }
3255
+ }
3256
+
3257
+
3258
+ void LCodeGen::DoNumberTagI(LNumberTagI* instr) {
3259
+ LOperand* input = instr->InputAt(0);
3260
+ ASSERT(input->IsRegister() && input->Equals(instr->result()));
3261
+ Register reg = ToRegister(input);
3262
+
3263
+ __ Integer32ToSmi(reg, reg);
3264
+ }
3265
+
3266
+
3267
+ void LCodeGen::DoNumberTagD(LNumberTagD* instr) {
3268
+ class DeferredNumberTagD: public LDeferredCode {
3269
+ public:
3270
+ DeferredNumberTagD(LCodeGen* codegen, LNumberTagD* instr)
3271
+ : LDeferredCode(codegen), instr_(instr) { }
3272
+ virtual void Generate() { codegen()->DoDeferredNumberTagD(instr_); }
3273
+ private:
3274
+ LNumberTagD* instr_;
3275
+ };
3276
+
3277
+ XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0));
3278
+ Register reg = ToRegister(instr->result());
3279
+ Register tmp = ToRegister(instr->TempAt(0));
3280
+
3281
+ DeferredNumberTagD* deferred = new DeferredNumberTagD(this, instr);
3282
+ if (FLAG_inline_new) {
3283
+ __ AllocateHeapNumber(reg, tmp, deferred->entry());
3284
+ } else {
3285
+ __ jmp(deferred->entry());
3286
+ }
3287
+ __ bind(deferred->exit());
3288
+ __ movsd(FieldOperand(reg, HeapNumber::kValueOffset), input_reg);
3289
+ }
3290
+
3291
+
3292
+ void LCodeGen::DoDeferredNumberTagD(LNumberTagD* instr) {
3293
+ // TODO(3095996): Get rid of this. For now, we need to make the
3294
+ // result register contain a valid pointer because it is already
3295
+ // contained in the register pointer map.
3296
+ Register reg = ToRegister(instr->result());
3297
+ __ Move(reg, Smi::FromInt(0));
3298
+
3299
+ __ PushSafepointRegisters();
3300
+ __ CallRuntimeSaveDoubles(Runtime::kAllocateHeapNumber);
3301
+ RecordSafepointWithRegisters(
3302
+ instr->pointer_map(), 0, Safepoint::kNoDeoptimizationIndex);
3303
+ // Ensure that value in rax survives popping registers.
3304
+ __ movq(kScratchRegister, rax);
3305
+ __ PopSafepointRegisters();
3306
+ __ movq(reg, kScratchRegister);
3307
+ }
3308
+
3309
+
3310
+ void LCodeGen::DoSmiTag(LSmiTag* instr) {
3311
+ ASSERT(instr->InputAt(0)->Equals(instr->result()));
3312
+ Register input = ToRegister(instr->InputAt(0));
3313
+ ASSERT(!instr->hydrogen_value()->CheckFlag(HValue::kCanOverflow));
3314
+ __ Integer32ToSmi(input, input);
3315
+ }
3316
+
3317
+
3318
+ void LCodeGen::DoSmiUntag(LSmiUntag* instr) {
3319
+ ASSERT(instr->InputAt(0)->Equals(instr->result()));
3320
+ Register input = ToRegister(instr->InputAt(0));
3321
+ if (instr->needs_check()) {
3322
+ Condition is_smi = __ CheckSmi(input);
3323
+ DeoptimizeIf(NegateCondition(is_smi), instr->environment());
3324
+ }
3325
+ __ SmiToInteger32(input, input);
3326
+ }
3327
+
3328
+
3329
+ void LCodeGen::EmitNumberUntagD(Register input_reg,
3330
+ XMMRegister result_reg,
3331
+ LEnvironment* env) {
3332
+ NearLabel load_smi, heap_number, done;
3333
+
3334
+ // Smi check.
3335
+ __ JumpIfSmi(input_reg, &load_smi);
3336
+
3337
+ // Heap number map check.
3338
+ __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset),
3339
+ Heap::kHeapNumberMapRootIndex);
3340
+ __ j(equal, &heap_number);
3341
+
3342
+ __ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex);
3343
+ DeoptimizeIf(not_equal, env);
3344
+
3345
+ // Convert undefined to NaN. Compute NaN as 0/0.
3346
+ __ xorpd(result_reg, result_reg);
3347
+ __ divsd(result_reg, result_reg);
3348
+ __ jmp(&done);
3349
+
3350
+ // Heap number to XMM conversion.
3351
+ __ bind(&heap_number);
3352
+ __ movsd(result_reg, FieldOperand(input_reg, HeapNumber::kValueOffset));
3353
+ __ jmp(&done);
3354
+
3355
+ // Smi to XMM conversion
3356
+ __ bind(&load_smi);
3357
+ __ SmiToInteger32(kScratchRegister, input_reg);
3358
+ __ cvtlsi2sd(result_reg, kScratchRegister);
3359
+ __ bind(&done);
3360
+ }
3361
+
3362
+
3363
+ class DeferredTaggedToI: public LDeferredCode {
3364
+ public:
3365
+ DeferredTaggedToI(LCodeGen* codegen, LTaggedToI* instr)
3366
+ : LDeferredCode(codegen), instr_(instr) { }
3367
+ virtual void Generate() { codegen()->DoDeferredTaggedToI(instr_); }
3368
+ private:
3369
+ LTaggedToI* instr_;
3370
+ };
3371
+
3372
+
3373
+ void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr) {
3374
+ NearLabel done, heap_number;
3375
+ Register input_reg = ToRegister(instr->InputAt(0));
3376
+
3377
+ // Heap number map check.
3378
+ __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset),
3379
+ Heap::kHeapNumberMapRootIndex);
3380
+
3381
+ if (instr->truncating()) {
3382
+ __ j(equal, &heap_number);
3383
+ // Check for undefined. Undefined is converted to zero for truncating
3384
+ // conversions.
3385
+ __ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex);
3386
+ DeoptimizeIf(not_equal, instr->environment());
3387
+ __ movl(input_reg, Immediate(0));
3388
+ __ jmp(&done);
3389
+
3390
+ __ bind(&heap_number);
3391
+
3392
+ __ movsd(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset));
3393
+ __ cvttsd2siq(input_reg, xmm0);
3394
+ __ Set(kScratchRegister, V8_UINT64_C(0x8000000000000000));
3395
+ __ cmpl(input_reg, kScratchRegister);
3396
+ DeoptimizeIf(equal, instr->environment());
3397
+ } else {
3398
+ // Deoptimize if we don't have a heap number.
3399
+ DeoptimizeIf(not_equal, instr->environment());
3400
+
3401
+ XMMRegister xmm_temp = ToDoubleRegister(instr->TempAt(0));
3402
+ __ movsd(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset));
3403
+ __ cvttsd2si(input_reg, xmm0);
3404
+ __ cvtlsi2sd(xmm_temp, input_reg);
3405
+ __ ucomisd(xmm0, xmm_temp);
3406
+ DeoptimizeIf(not_equal, instr->environment());
3407
+ DeoptimizeIf(parity_even, instr->environment()); // NaN.
3408
+ if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
3409
+ __ testl(input_reg, input_reg);
3410
+ __ j(not_zero, &done);
3411
+ __ movmskpd(input_reg, xmm0);
3412
+ __ andl(input_reg, Immediate(1));
3413
+ DeoptimizeIf(not_zero, instr->environment());
3414
+ }
3415
+ }
3416
+ __ bind(&done);
3417
+ }
3418
+
3419
+
3420
+ void LCodeGen::DoTaggedToI(LTaggedToI* instr) {
3421
+ LOperand* input = instr->InputAt(0);
3422
+ ASSERT(input->IsRegister());
3423
+ ASSERT(input->Equals(instr->result()));
3424
+
3425
+ Register input_reg = ToRegister(input);
3426
+ DeferredTaggedToI* deferred = new DeferredTaggedToI(this, instr);
3427
+ __ JumpIfNotSmi(input_reg, deferred->entry());
3428
+ __ SmiToInteger32(input_reg, input_reg);
3429
+ __ bind(deferred->exit());
3430
+ }
3431
+
3432
+
3433
+ void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) {
3434
+ LOperand* input = instr->InputAt(0);
3435
+ ASSERT(input->IsRegister());
3436
+ LOperand* result = instr->result();
3437
+ ASSERT(result->IsDoubleRegister());
3438
+
3439
+ Register input_reg = ToRegister(input);
3440
+ XMMRegister result_reg = ToDoubleRegister(result);
3441
+
3442
+ EmitNumberUntagD(input_reg, result_reg, instr->environment());
3443
+ }
3444
+
3445
+
3446
+ void LCodeGen::DoDoubleToI(LDoubleToI* instr) {
3447
+ LOperand* input = instr->InputAt(0);
3448
+ ASSERT(input->IsDoubleRegister());
3449
+ LOperand* result = instr->result();
3450
+ ASSERT(result->IsRegister());
3451
+
3452
+ XMMRegister input_reg = ToDoubleRegister(input);
3453
+ Register result_reg = ToRegister(result);
3454
+
3455
+ if (instr->truncating()) {
3456
+ // Performs a truncating conversion of a floating point number as used by
3457
+ // the JS bitwise operations.
3458
+ __ cvttsd2siq(result_reg, input_reg);
3459
+ __ movq(kScratchRegister, V8_INT64_C(0x8000000000000000), RelocInfo::NONE);
3460
+ __ cmpl(result_reg, kScratchRegister);
3461
+ DeoptimizeIf(equal, instr->environment());
3462
+ } else {
3463
+ __ cvttsd2si(result_reg, input_reg);
3464
+ __ cvtlsi2sd(xmm0, result_reg);
3465
+ __ ucomisd(xmm0, input_reg);
3466
+ DeoptimizeIf(not_equal, instr->environment());
3467
+ DeoptimizeIf(parity_even, instr->environment()); // NaN.
3468
+ if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
3469
+ NearLabel done;
3470
+ // The integer converted back is equal to the original. We
3471
+ // only have to test if we got -0 as an input.
3472
+ __ testl(result_reg, result_reg);
3473
+ __ j(not_zero, &done);
3474
+ __ movmskpd(result_reg, input_reg);
3475
+ // Bit 0 contains the sign of the double in input_reg.
3476
+ // If input was positive, we are ok and return 0, otherwise
3477
+ // deoptimize.
3478
+ __ andl(result_reg, Immediate(1));
3479
+ DeoptimizeIf(not_zero, instr->environment());
3480
+ __ bind(&done);
3481
+ }
3482
+ }
3483
+ }
3484
+
3485
+
3486
+ void LCodeGen::DoCheckSmi(LCheckSmi* instr) {
3487
+ LOperand* input = instr->InputAt(0);
3488
+ Condition cc = masm()->CheckSmi(ToRegister(input));
3489
+ DeoptimizeIf(NegateCondition(cc), instr->environment());
3490
+ }
3491
+
3492
+
3493
+ void LCodeGen::DoCheckNonSmi(LCheckNonSmi* instr) {
3494
+ LOperand* input = instr->InputAt(0);
3495
+ Condition cc = masm()->CheckSmi(ToRegister(input));
3496
+ DeoptimizeIf(cc, instr->environment());
3497
+ }
3498
+
3499
+
3500
+ void LCodeGen::DoCheckInstanceType(LCheckInstanceType* instr) {
3501
+ Register input = ToRegister(instr->InputAt(0));
3502
+ InstanceType first = instr->hydrogen()->first();
3503
+ InstanceType last = instr->hydrogen()->last();
3504
+
3505
+ __ movq(kScratchRegister, FieldOperand(input, HeapObject::kMapOffset));
3506
+
3507
+ // If there is only one type in the interval check for equality.
3508
+ if (first == last) {
3509
+ __ cmpb(FieldOperand(kScratchRegister, Map::kInstanceTypeOffset),
3510
+ Immediate(static_cast<int8_t>(first)));
3511
+ DeoptimizeIf(not_equal, instr->environment());
3512
+ } else if (first == FIRST_STRING_TYPE && last == LAST_STRING_TYPE) {
3513
+ // String has a dedicated bit in instance type.
3514
+ __ testb(FieldOperand(kScratchRegister, Map::kInstanceTypeOffset),
3515
+ Immediate(kIsNotStringMask));
3516
+ DeoptimizeIf(not_zero, instr->environment());
3517
+ } else {
3518
+ __ cmpb(FieldOperand(kScratchRegister, Map::kInstanceTypeOffset),
3519
+ Immediate(static_cast<int8_t>(first)));
3520
+ DeoptimizeIf(below, instr->environment());
3521
+ // Omit check for the last type.
3522
+ if (last != LAST_TYPE) {
3523
+ __ cmpb(FieldOperand(kScratchRegister, Map::kInstanceTypeOffset),
3524
+ Immediate(static_cast<int8_t>(last)));
3525
+ DeoptimizeIf(above, instr->environment());
3526
+ }
3527
+ }
3528
+ }
3529
+
3530
+
3531
+ void LCodeGen::DoCheckFunction(LCheckFunction* instr) {
3532
+ ASSERT(instr->InputAt(0)->IsRegister());
3533
+ Register reg = ToRegister(instr->InputAt(0));
3534
+ __ Cmp(reg, instr->hydrogen()->target());
3535
+ DeoptimizeIf(not_equal, instr->environment());
3536
+ }
3537
+
3538
+
3539
+ void LCodeGen::DoCheckMap(LCheckMap* instr) {
3540
+ LOperand* input = instr->InputAt(0);
3541
+ ASSERT(input->IsRegister());
3542
+ Register reg = ToRegister(input);
3543
+ __ Cmp(FieldOperand(reg, HeapObject::kMapOffset),
3544
+ instr->hydrogen()->map());
3545
+ DeoptimizeIf(not_equal, instr->environment());
3546
+ }
3547
+
3548
+
3549
+ void LCodeGen::LoadHeapObject(Register result, Handle<HeapObject> object) {
3550
+ if (heap()->InNewSpace(*object)) {
3551
+ Handle<JSGlobalPropertyCell> cell =
3552
+ factory()->NewJSGlobalPropertyCell(object);
3553
+ __ movq(result, cell, RelocInfo::GLOBAL_PROPERTY_CELL);
3554
+ __ movq(result, Operand(result, 0));
3555
+ } else {
3556
+ __ Move(result, object);
3557
+ }
3558
+ }
3559
+
3560
+
3561
+ void LCodeGen::DoCheckPrototypeMaps(LCheckPrototypeMaps* instr) {
3562
+ Register reg = ToRegister(instr->TempAt(0));
3563
+
3564
+ Handle<JSObject> holder = instr->holder();
3565
+ Handle<JSObject> current_prototype = instr->prototype();
3566
+
3567
+ // Load prototype object.
3568
+ LoadHeapObject(reg, current_prototype);
3569
+
3570
+ // Check prototype maps up to the holder.
3571
+ while (!current_prototype.is_identical_to(holder)) {
3572
+ __ Cmp(FieldOperand(reg, HeapObject::kMapOffset),
3573
+ Handle<Map>(current_prototype->map()));
3574
+ DeoptimizeIf(not_equal, instr->environment());
3575
+ current_prototype =
3576
+ Handle<JSObject>(JSObject::cast(current_prototype->GetPrototype()));
3577
+ // Load next prototype object.
3578
+ LoadHeapObject(reg, current_prototype);
3579
+ }
3580
+
3581
+ // Check the holder map.
3582
+ __ Cmp(FieldOperand(reg, HeapObject::kMapOffset),
3583
+ Handle<Map>(current_prototype->map()));
3584
+ DeoptimizeIf(not_equal, instr->environment());
3585
+ }
3586
+
3587
+
3588
+ void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) {
3589
+ // Setup the parameters to the stub/runtime call.
3590
+ __ movq(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
3591
+ __ push(FieldOperand(rax, JSFunction::kLiteralsOffset));
3592
+ __ Push(Smi::FromInt(instr->hydrogen()->literal_index()));
3593
+ __ Push(instr->hydrogen()->constant_elements());
3594
+
3595
+ // Pick the right runtime function or stub to call.
3596
+ int length = instr->hydrogen()->length();
3597
+ if (instr->hydrogen()->IsCopyOnWrite()) {
3598
+ ASSERT(instr->hydrogen()->depth() == 1);
3599
+ FastCloneShallowArrayStub::Mode mode =
3600
+ FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS;
3601
+ FastCloneShallowArrayStub stub(mode, length);
3602
+ CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
3603
+ } else if (instr->hydrogen()->depth() > 1) {
3604
+ CallRuntime(Runtime::kCreateArrayLiteral, 3, instr);
3605
+ } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) {
3606
+ CallRuntime(Runtime::kCreateArrayLiteralShallow, 3, instr);
3607
+ } else {
3608
+ FastCloneShallowArrayStub::Mode mode =
3609
+ FastCloneShallowArrayStub::CLONE_ELEMENTS;
3610
+ FastCloneShallowArrayStub stub(mode, length);
3611
+ CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
3612
+ }
3613
+ }
3614
+
3615
+
3616
+ void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) {
3617
+ // Setup the parameters to the stub/runtime call.
3618
+ __ movq(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
3619
+ __ push(FieldOperand(rax, JSFunction::kLiteralsOffset));
3620
+ __ Push(Smi::FromInt(instr->hydrogen()->literal_index()));
3621
+ __ Push(instr->hydrogen()->constant_properties());
3622
+ __ Push(Smi::FromInt(instr->hydrogen()->fast_elements() ? 1 : 0));
3623
+
3624
+ // Pick the right runtime function to call.
3625
+ if (instr->hydrogen()->depth() > 1) {
3626
+ CallRuntime(Runtime::kCreateObjectLiteral, 4, instr);
3627
+ } else {
3628
+ CallRuntime(Runtime::kCreateObjectLiteralShallow, 4, instr);
3629
+ }
3630
+ }
3631
+
3632
+
3633
+ void LCodeGen::DoToFastProperties(LToFastProperties* instr) {
3634
+ ASSERT(ToRegister(instr->InputAt(0)).is(rax));
3635
+ __ push(rax);
3636
+ CallRuntime(Runtime::kToFastProperties, 1, instr);
3637
+ }
3638
+
3639
+
3640
+ void LCodeGen::DoRegExpLiteral(LRegExpLiteral* instr) {
3641
+ NearLabel materialized;
3642
+ // Registers will be used as follows:
3643
+ // rdi = JS function.
3644
+ // rcx = literals array.
3645
+ // rbx = regexp literal.
3646
+ // rax = regexp literal clone.
3647
+ __ movq(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
3648
+ __ movq(rcx, FieldOperand(rdi, JSFunction::kLiteralsOffset));
3649
+ int literal_offset = FixedArray::kHeaderSize +
3650
+ instr->hydrogen()->literal_index() * kPointerSize;
3651
+ __ movq(rbx, FieldOperand(rcx, literal_offset));
3652
+ __ CompareRoot(rbx, Heap::kUndefinedValueRootIndex);
3653
+ __ j(not_equal, &materialized);
3654
+
3655
+ // Create regexp literal using runtime function
3656
+ // Result will be in rax.
3657
+ __ push(rcx);
3658
+ __ Push(Smi::FromInt(instr->hydrogen()->literal_index()));
3659
+ __ Push(instr->hydrogen()->pattern());
3660
+ __ Push(instr->hydrogen()->flags());
3661
+ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4, instr);
3662
+ __ movq(rbx, rax);
3663
+
3664
+ __ bind(&materialized);
3665
+ int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
3666
+ Label allocated, runtime_allocate;
3667
+ __ AllocateInNewSpace(size, rax, rcx, rdx, &runtime_allocate, TAG_OBJECT);
3668
+ __ jmp(&allocated);
3669
+
3670
+ __ bind(&runtime_allocate);
3671
+ __ push(rbx);
3672
+ __ Push(Smi::FromInt(size));
3673
+ CallRuntime(Runtime::kAllocateInNewSpace, 1, instr);
3674
+ __ pop(rbx);
3675
+
3676
+ __ bind(&allocated);
3677
+ // Copy the content into the newly allocated memory.
3678
+ // (Unroll copy loop once for better throughput).
3679
+ for (int i = 0; i < size - kPointerSize; i += 2 * kPointerSize) {
3680
+ __ movq(rdx, FieldOperand(rbx, i));
3681
+ __ movq(rcx, FieldOperand(rbx, i + kPointerSize));
3682
+ __ movq(FieldOperand(rax, i), rdx);
3683
+ __ movq(FieldOperand(rax, i + kPointerSize), rcx);
3684
+ }
3685
+ if ((size % (2 * kPointerSize)) != 0) {
3686
+ __ movq(rdx, FieldOperand(rbx, size - kPointerSize));
3687
+ __ movq(FieldOperand(rax, size - kPointerSize), rdx);
3688
+ }
3689
+ }
3690
+
3691
+
3692
+ void LCodeGen::DoFunctionLiteral(LFunctionLiteral* instr) {
3693
+ // Use the fast case closure allocation code that allocates in new
3694
+ // space for nested functions that don't need literals cloning.
3695
+ Handle<SharedFunctionInfo> shared_info = instr->shared_info();
3696
+ bool pretenure = instr->hydrogen()->pretenure();
3697
+ if (!pretenure && shared_info->num_literals() == 0) {
3698
+ FastNewClosureStub stub(
3699
+ shared_info->strict_mode() ? kStrictMode : kNonStrictMode);
3700
+ __ Push(shared_info);
3701
+ CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
3702
+ } else {
3703
+ __ push(rsi);
3704
+ __ Push(shared_info);
3705
+ __ PushRoot(pretenure ?
3706
+ Heap::kTrueValueRootIndex :
3707
+ Heap::kFalseValueRootIndex);
3708
+ CallRuntime(Runtime::kNewClosure, 3, instr);
3709
+ }
3710
+ }
3711
+
3712
+
3713
+ void LCodeGen::DoTypeof(LTypeof* instr) {
3714
+ LOperand* input = instr->InputAt(0);
3715
+ if (input->IsConstantOperand()) {
3716
+ __ Push(ToHandle(LConstantOperand::cast(input)));
3717
+ } else if (input->IsRegister()) {
3718
+ __ push(ToRegister(input));
3719
+ } else {
3720
+ ASSERT(input->IsStackSlot());
3721
+ __ push(ToOperand(input));
3722
+ }
3723
+ CallRuntime(Runtime::kTypeof, 1, instr);
3724
+ }
3725
+
3726
+
3727
+ void LCodeGen::DoTypeofIs(LTypeofIs* instr) {
3728
+ Register input = ToRegister(instr->InputAt(0));
3729
+ Register result = ToRegister(instr->result());
3730
+ Label true_label;
3731
+ Label false_label;
3732
+ NearLabel done;
3733
+
3734
+ Condition final_branch_condition = EmitTypeofIs(&true_label,
3735
+ &false_label,
3736
+ input,
3737
+ instr->type_literal());
3738
+ __ j(final_branch_condition, &true_label);
3739
+ __ bind(&false_label);
3740
+ __ LoadRoot(result, Heap::kFalseValueRootIndex);
3741
+ __ jmp(&done);
3742
+
3743
+ __ bind(&true_label);
3744
+ __ LoadRoot(result, Heap::kTrueValueRootIndex);
3745
+
3746
+ __ bind(&done);
3747
+ }
3748
+
3749
+
3750
+ void LCodeGen::EmitPushConstantOperand(LOperand* operand) {
3751
+ ASSERT(operand->IsConstantOperand());
3752
+ LConstantOperand* const_op = LConstantOperand::cast(operand);
3753
+ Handle<Object> literal = chunk_->LookupLiteral(const_op);
3754
+ Representation r = chunk_->LookupLiteralRepresentation(const_op);
3755
+ if (r.IsInteger32()) {
3756
+ ASSERT(literal->IsNumber());
3757
+ __ push(Immediate(static_cast<int32_t>(literal->Number())));
3758
+ } else if (r.IsDouble()) {
3759
+ Abort("unsupported double immediate");
3760
+ } else {
3761
+ ASSERT(r.IsTagged());
3762
+ __ Push(literal);
3763
+ }
3764
+ }
3765
+
3766
+
3767
+ void LCodeGen::DoTypeofIsAndBranch(LTypeofIsAndBranch* instr) {
3768
+ Register input = ToRegister(instr->InputAt(0));
3769
+ int true_block = chunk_->LookupDestination(instr->true_block_id());
3770
+ int false_block = chunk_->LookupDestination(instr->false_block_id());
3771
+ Label* true_label = chunk_->GetAssemblyLabel(true_block);
3772
+ Label* false_label = chunk_->GetAssemblyLabel(false_block);
3773
+
3774
+ Condition final_branch_condition = EmitTypeofIs(true_label,
3775
+ false_label,
3776
+ input,
3777
+ instr->type_literal());
3778
+
3779
+ EmitBranch(true_block, false_block, final_branch_condition);
3780
+ }
3781
+
3782
+
3783
+ Condition LCodeGen::EmitTypeofIs(Label* true_label,
3784
+ Label* false_label,
3785
+ Register input,
3786
+ Handle<String> type_name) {
3787
+ Condition final_branch_condition = no_condition;
3788
+ if (type_name->Equals(heap()->number_symbol())) {
3789
+ __ JumpIfSmi(input, true_label);
3790
+ __ CompareRoot(FieldOperand(input, HeapObject::kMapOffset),
3791
+ Heap::kHeapNumberMapRootIndex);
3792
+
3793
+ final_branch_condition = equal;
3794
+
3795
+ } else if (type_name->Equals(heap()->string_symbol())) {
3796
+ __ JumpIfSmi(input, false_label);
3797
+ __ CmpObjectType(input, FIRST_NONSTRING_TYPE, input);
3798
+ __ j(above_equal, false_label);
3799
+ __ testb(FieldOperand(input, Map::kBitFieldOffset),
3800
+ Immediate(1 << Map::kIsUndetectable));
3801
+ final_branch_condition = zero;
3802
+
3803
+ } else if (type_name->Equals(heap()->boolean_symbol())) {
3804
+ __ CompareRoot(input, Heap::kTrueValueRootIndex);
3805
+ __ j(equal, true_label);
3806
+ __ CompareRoot(input, Heap::kFalseValueRootIndex);
3807
+ final_branch_condition = equal;
3808
+
3809
+ } else if (type_name->Equals(heap()->undefined_symbol())) {
3810
+ __ CompareRoot(input, Heap::kUndefinedValueRootIndex);
3811
+ __ j(equal, true_label);
3812
+ __ JumpIfSmi(input, false_label);
3813
+ // Check for undetectable objects => true.
3814
+ __ movq(input, FieldOperand(input, HeapObject::kMapOffset));
3815
+ __ testb(FieldOperand(input, Map::kBitFieldOffset),
3816
+ Immediate(1 << Map::kIsUndetectable));
3817
+ final_branch_condition = not_zero;
3818
+
3819
+ } else if (type_name->Equals(heap()->function_symbol())) {
3820
+ __ JumpIfSmi(input, false_label);
3821
+ __ CmpObjectType(input, FIRST_FUNCTION_CLASS_TYPE, input);
3822
+ final_branch_condition = above_equal;
3823
+
3824
+ } else if (type_name->Equals(heap()->object_symbol())) {
3825
+ __ JumpIfSmi(input, false_label);
3826
+ __ CompareRoot(input, Heap::kNullValueRootIndex);
3827
+ __ j(equal, true_label);
3828
+ __ CmpObjectType(input, FIRST_JS_OBJECT_TYPE, input);
3829
+ __ j(below, false_label);
3830
+ __ CmpInstanceType(input, FIRST_FUNCTION_CLASS_TYPE);
3831
+ __ j(above_equal, false_label);
3832
+ // Check for undetectable objects => false.
3833
+ __ testb(FieldOperand(input, Map::kBitFieldOffset),
3834
+ Immediate(1 << Map::kIsUndetectable));
3835
+ final_branch_condition = zero;
3836
+
3837
+ } else {
3838
+ final_branch_condition = never;
3839
+ __ jmp(false_label);
3840
+ }
3841
+
3842
+ return final_branch_condition;
3843
+ }
3844
+
3845
+
3846
+ void LCodeGen::DoIsConstructCall(LIsConstructCall* instr) {
3847
+ Register result = ToRegister(instr->result());
3848
+ NearLabel true_label;
3849
+ NearLabel false_label;
3850
+ NearLabel done;
3851
+
3852
+ EmitIsConstructCall(result);
3853
+ __ j(equal, &true_label);
3854
+
3855
+ __ LoadRoot(result, Heap::kFalseValueRootIndex);
3856
+ __ jmp(&done);
3857
+
3858
+ __ bind(&true_label);
3859
+ __ LoadRoot(result, Heap::kTrueValueRootIndex);
3860
+
3861
+
3862
+ __ bind(&done);
3863
+ }
3864
+
3865
+
3866
+ void LCodeGen::DoIsConstructCallAndBranch(LIsConstructCallAndBranch* instr) {
3867
+ Register temp = ToRegister(instr->TempAt(0));
3868
+ int true_block = chunk_->LookupDestination(instr->true_block_id());
3869
+ int false_block = chunk_->LookupDestination(instr->false_block_id());
3870
+
3871
+ EmitIsConstructCall(temp);
3872
+ EmitBranch(true_block, false_block, equal);
3873
+ }
3874
+
3875
+
3876
+ void LCodeGen::EmitIsConstructCall(Register temp) {
3877
+ // Get the frame pointer for the calling frame.
3878
+ __ movq(temp, Operand(rbp, StandardFrameConstants::kCallerFPOffset));
3879
+
3880
+ // Skip the arguments adaptor frame if it exists.
3881
+ NearLabel check_frame_marker;
3882
+ __ Cmp(Operand(temp, StandardFrameConstants::kContextOffset),
3883
+ Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
3884
+ __ j(not_equal, &check_frame_marker);
3885
+ __ movq(temp, Operand(rax, StandardFrameConstants::kCallerFPOffset));
3886
+
3887
+ // Check the marker in the calling frame.
3888
+ __ bind(&check_frame_marker);
3889
+ __ Cmp(Operand(temp, StandardFrameConstants::kMarkerOffset),
3890
+ Smi::FromInt(StackFrame::CONSTRUCT));
3891
+ }
3892
+
3893
+
3894
+ void LCodeGen::DoLazyBailout(LLazyBailout* instr) {
3895
+ // No code for lazy bailout instruction. Used to capture environment after a
3896
+ // call for populating the safepoint data with deoptimization data.
3897
+ }
3898
+
3899
+
3900
+ void LCodeGen::DoDeoptimize(LDeoptimize* instr) {
3901
+ DeoptimizeIf(no_condition, instr->environment());
3902
+ }
3903
+
3904
+
3905
+ void LCodeGen::DoDeleteProperty(LDeleteProperty* instr) {
3906
+ LOperand* obj = instr->object();
3907
+ LOperand* key = instr->key();
3908
+ // Push object.
3909
+ if (obj->IsRegister()) {
3910
+ __ push(ToRegister(obj));
3911
+ } else {
3912
+ __ push(ToOperand(obj));
3913
+ }
3914
+ // Push key.
3915
+ if (key->IsConstantOperand()) {
3916
+ EmitPushConstantOperand(key);
3917
+ } else if (key->IsRegister()) {
3918
+ __ push(ToRegister(key));
3919
+ } else {
3920
+ __ push(ToOperand(key));
3921
+ }
3922
+ ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment());
3923
+ LPointerMap* pointers = instr->pointer_map();
3924
+ LEnvironment* env = instr->deoptimization_environment();
3925
+ RecordPosition(pointers->position());
3926
+ RegisterEnvironmentForDeoptimization(env);
3927
+ // Create safepoint generator that will also ensure enough space in the
3928
+ // reloc info for patching in deoptimization (since this is invoking a
3929
+ // builtin)
3930
+ SafepointGenerator safepoint_generator(this,
3931
+ pointers,
3932
+ env->deoptimization_index());
3933
+ __ Push(Smi::FromInt(strict_mode_flag()));
3934
+ __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION, &safepoint_generator);
3935
+ }
3936
+
3937
+
3938
+ void LCodeGen::DoStackCheck(LStackCheck* instr) {
3939
+ // Perform stack overflow check.
3940
+ NearLabel done;
3941
+ __ CompareRoot(rsp, Heap::kStackLimitRootIndex);
3942
+ __ j(above_equal, &done);
3943
+
3944
+ StackCheckStub stub;
3945
+ CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
3946
+ __ bind(&done);
3947
+ }
3948
+
3949
+
3950
+ void LCodeGen::DoOsrEntry(LOsrEntry* instr) {
3951
+ // This is a pseudo-instruction that ensures that the environment here is
3952
+ // properly registered for deoptimization and records the assembler's PC
3953
+ // offset.
3954
+ LEnvironment* environment = instr->environment();
3955
+ environment->SetSpilledRegisters(instr->SpilledRegisterArray(),
3956
+ instr->SpilledDoubleRegisterArray());
3957
+
3958
+ // If the environment were already registered, we would have no way of
3959
+ // backpatching it with the spill slot operands.
3960
+ ASSERT(!environment->HasBeenRegistered());
3961
+ RegisterEnvironmentForDeoptimization(environment);
3962
+ ASSERT(osr_pc_offset_ == -1);
3963
+ osr_pc_offset_ = masm()->pc_offset();
3964
+ }
3965
+
3966
+ #undef __
3967
+
3968
+ } } // namespace v8::internal
3969
+
3970
+ #endif // V8_TARGET_ARCH_X64