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
File without changes
@@ -0,0 +1,130 @@
1
+ // Copyright 2010 the V8 project authors. All rights reserved.
2
+ // Redistribution and use in source and binary forms, with or without
3
+ // modification, are permitted provided that the following conditions are
4
+ // met:
5
+ //
6
+ // * Redistributions of source code must retain the above copyright
7
+ // notice, this list of conditions and the following disclaimer.
8
+ // * Redistributions in binary form must reproduce the above
9
+ // copyright notice, this list of conditions and the following
10
+ // disclaimer in the documentation and/or other materials provided
11
+ // with the distribution.
12
+ // * Neither the name of Google Inc. nor the names of its
13
+ // contributors may be used to endorse or promote products derived
14
+ // from this software without specific prior written permission.
15
+ //
16
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+
28
+ #ifndef V8_X64_FRAMES_X64_H_
29
+ #define V8_X64_FRAMES_X64_H_
30
+
31
+ namespace v8 {
32
+ namespace internal {
33
+
34
+ static const int kNumRegs = 16;
35
+ static const RegList kJSCallerSaved =
36
+ 1 << 0 | // rax
37
+ 1 << 1 | // rcx
38
+ 1 << 2 | // rdx
39
+ 1 << 3 | // rbx - used as a caller-saved register in JavaScript code
40
+ 1 << 7; // rdi - callee function
41
+
42
+ static const int kNumJSCallerSaved = 5;
43
+
44
+ typedef Object* JSCallerSavedBuffer[kNumJSCallerSaved];
45
+
46
+ // Number of registers for which space is reserved in safepoints.
47
+ static const int kNumSafepointRegisters = 16;
48
+
49
+ // ----------------------------------------------------
50
+
51
+ class StackHandlerConstants : public AllStatic {
52
+ public:
53
+ static const int kNextOffset = 0 * kPointerSize;
54
+ static const int kFPOffset = 1 * kPointerSize;
55
+ static const int kStateOffset = 2 * kPointerSize;
56
+ static const int kPCOffset = 3 * kPointerSize;
57
+
58
+ static const int kSize = 4 * kPointerSize;
59
+ };
60
+
61
+
62
+ class EntryFrameConstants : public AllStatic {
63
+ public:
64
+ #ifdef _WIN64
65
+ static const int kCallerFPOffset = -10 * kPointerSize;
66
+ #else
67
+ static const int kCallerFPOffset = -8 * kPointerSize;
68
+ #endif
69
+ static const int kArgvOffset = 6 * kPointerSize;
70
+ };
71
+
72
+
73
+ class ExitFrameConstants : public AllStatic {
74
+ public:
75
+ static const int kCodeOffset = -2 * kPointerSize;
76
+ static const int kSPOffset = -1 * kPointerSize;
77
+
78
+ static const int kCallerFPOffset = +0 * kPointerSize;
79
+ static const int kCallerPCOffset = +1 * kPointerSize;
80
+
81
+ // FP-relative displacement of the caller's SP. It points just
82
+ // below the saved PC.
83
+ static const int kCallerSPDisplacement = +2 * kPointerSize;
84
+ };
85
+
86
+
87
+ class StandardFrameConstants : public AllStatic {
88
+ public:
89
+ static const int kExpressionsOffset = -3 * kPointerSize;
90
+ static const int kMarkerOffset = -2 * kPointerSize;
91
+ static const int kContextOffset = -1 * kPointerSize;
92
+ static const int kCallerFPOffset = 0 * kPointerSize;
93
+ static const int kCallerPCOffset = +1 * kPointerSize;
94
+ static const int kCallerSPOffset = +2 * kPointerSize;
95
+ };
96
+
97
+
98
+ class JavaScriptFrameConstants : public AllStatic {
99
+ public:
100
+ // FP-relative.
101
+ static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset;
102
+ static const int kLastParameterOffset = +2 * kPointerSize;
103
+ static const int kFunctionOffset = StandardFrameConstants::kMarkerOffset;
104
+
105
+ // Caller SP-relative.
106
+ static const int kParam0Offset = -2 * kPointerSize;
107
+ static const int kReceiverOffset = -1 * kPointerSize;
108
+ };
109
+
110
+
111
+ class ArgumentsAdaptorFrameConstants : public AllStatic {
112
+ public:
113
+ static const int kLengthOffset = StandardFrameConstants::kExpressionsOffset;
114
+ };
115
+
116
+
117
+ class InternalFrameConstants : public AllStatic {
118
+ public:
119
+ static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
120
+ };
121
+
122
+
123
+ inline Object* JavaScriptFrame::function_slot_object() const {
124
+ const int offset = JavaScriptFrameConstants::kFunctionOffset;
125
+ return Memory::Object_at(fp() + offset);
126
+ }
127
+
128
+ } } // namespace v8::internal
129
+
130
+ #endif // V8_X64_FRAMES_X64_H_
@@ -0,0 +1,4339 @@
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 "code-stubs.h"
33
+ #include "codegen-inl.h"
34
+ #include "compiler.h"
35
+ #include "debug.h"
36
+ #include "full-codegen.h"
37
+ #include "parser.h"
38
+ #include "scopes.h"
39
+ #include "stub-cache.h"
40
+
41
+ namespace v8 {
42
+ namespace internal {
43
+
44
+ #define __ ACCESS_MASM(masm_)
45
+
46
+
47
+ class JumpPatchSite BASE_EMBEDDED {
48
+ public:
49
+ explicit JumpPatchSite(MacroAssembler* masm)
50
+ : masm_(masm) {
51
+ #ifdef DEBUG
52
+ info_emitted_ = false;
53
+ #endif
54
+ }
55
+
56
+ ~JumpPatchSite() {
57
+ ASSERT(patch_site_.is_bound() == info_emitted_);
58
+ }
59
+
60
+ void EmitJumpIfNotSmi(Register reg, NearLabel* target) {
61
+ __ testb(reg, Immediate(kSmiTagMask));
62
+ EmitJump(not_carry, target); // Always taken before patched.
63
+ }
64
+
65
+ void EmitJumpIfSmi(Register reg, NearLabel* target) {
66
+ __ testb(reg, Immediate(kSmiTagMask));
67
+ EmitJump(carry, target); // Never taken before patched.
68
+ }
69
+
70
+ void EmitPatchInfo() {
71
+ int delta_to_patch_site = masm_->SizeOfCodeGeneratedSince(&patch_site_);
72
+ ASSERT(is_int8(delta_to_patch_site));
73
+ __ testl(rax, Immediate(delta_to_patch_site));
74
+ #ifdef DEBUG
75
+ info_emitted_ = true;
76
+ #endif
77
+ }
78
+
79
+ bool is_bound() const { return patch_site_.is_bound(); }
80
+
81
+ private:
82
+ // jc will be patched with jz, jnc will become jnz.
83
+ void EmitJump(Condition cc, NearLabel* target) {
84
+ ASSERT(!patch_site_.is_bound() && !info_emitted_);
85
+ ASSERT(cc == carry || cc == not_carry);
86
+ __ bind(&patch_site_);
87
+ __ j(cc, target);
88
+ }
89
+
90
+ MacroAssembler* masm_;
91
+ Label patch_site_;
92
+ #ifdef DEBUG
93
+ bool info_emitted_;
94
+ #endif
95
+ };
96
+
97
+
98
+ // Generate code for a JS function. On entry to the function the receiver
99
+ // and arguments have been pushed on the stack left to right, with the
100
+ // return address on top of them. The actual argument count matches the
101
+ // formal parameter count expected by the function.
102
+ //
103
+ // The live registers are:
104
+ // o rdi: the JS function object being called (ie, ourselves)
105
+ // o rsi: our context
106
+ // o rbp: our caller's frame pointer
107
+ // o rsp: stack pointer (pointing to return address)
108
+ //
109
+ // The function builds a JS frame. Please see JavaScriptFrameConstants in
110
+ // frames-x64.h for its layout.
111
+ void FullCodeGenerator::Generate(CompilationInfo* info) {
112
+ ASSERT(info_ == NULL);
113
+ info_ = info;
114
+ SetFunctionPosition(function());
115
+ Comment cmnt(masm_, "[ function compiled by full code generator");
116
+
117
+ #ifdef DEBUG
118
+ if (strlen(FLAG_stop_at) > 0 &&
119
+ info->function()->name()->IsEqualTo(CStrVector(FLAG_stop_at))) {
120
+ __ int3();
121
+ }
122
+ #endif
123
+ __ push(rbp); // Caller's frame pointer.
124
+ __ movq(rbp, rsp);
125
+ __ push(rsi); // Callee's context.
126
+ __ push(rdi); // Callee's JS Function.
127
+
128
+ { Comment cmnt(masm_, "[ Allocate locals");
129
+ int locals_count = scope()->num_stack_slots();
130
+ if (locals_count == 1) {
131
+ __ PushRoot(Heap::kUndefinedValueRootIndex);
132
+ } else if (locals_count > 1) {
133
+ __ LoadRoot(rdx, Heap::kUndefinedValueRootIndex);
134
+ for (int i = 0; i < locals_count; i++) {
135
+ __ push(rdx);
136
+ }
137
+ }
138
+ }
139
+
140
+ bool function_in_register = true;
141
+
142
+ // Possibly allocate a local context.
143
+ int heap_slots = scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS;
144
+ if (heap_slots > 0) {
145
+ Comment cmnt(masm_, "[ Allocate local context");
146
+ // Argument to NewContext is the function, which is still in rdi.
147
+ __ push(rdi);
148
+ if (heap_slots <= FastNewContextStub::kMaximumSlots) {
149
+ FastNewContextStub stub(heap_slots);
150
+ __ CallStub(&stub);
151
+ } else {
152
+ __ CallRuntime(Runtime::kNewContext, 1);
153
+ }
154
+ function_in_register = false;
155
+ // Context is returned in both rax and rsi. It replaces the context
156
+ // passed to us. It's saved in the stack and kept live in rsi.
157
+ __ movq(Operand(rbp, StandardFrameConstants::kContextOffset), rsi);
158
+
159
+ // Copy any necessary parameters into the context.
160
+ int num_parameters = scope()->num_parameters();
161
+ for (int i = 0; i < num_parameters; i++) {
162
+ Slot* slot = scope()->parameter(i)->AsSlot();
163
+ if (slot != NULL && slot->type() == Slot::CONTEXT) {
164
+ int parameter_offset = StandardFrameConstants::kCallerSPOffset +
165
+ (num_parameters - 1 - i) * kPointerSize;
166
+ // Load parameter from stack.
167
+ __ movq(rax, Operand(rbp, parameter_offset));
168
+ // Store it in the context.
169
+ int context_offset = Context::SlotOffset(slot->index());
170
+ __ movq(Operand(rsi, context_offset), rax);
171
+ // Update the write barrier. This clobbers all involved
172
+ // registers, so we have use a third register to avoid
173
+ // clobbering rsi.
174
+ __ movq(rcx, rsi);
175
+ __ RecordWrite(rcx, context_offset, rax, rbx);
176
+ }
177
+ }
178
+ }
179
+
180
+ // Possibly allocate an arguments object.
181
+ Variable* arguments = scope()->arguments();
182
+ if (arguments != NULL) {
183
+ // Arguments object must be allocated after the context object, in
184
+ // case the "arguments" or ".arguments" variables are in the context.
185
+ Comment cmnt(masm_, "[ Allocate arguments object");
186
+ if (function_in_register) {
187
+ __ push(rdi);
188
+ } else {
189
+ __ push(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
190
+ }
191
+ // The receiver is just before the parameters on the caller's stack.
192
+ int offset = scope()->num_parameters() * kPointerSize;
193
+ __ lea(rdx,
194
+ Operand(rbp, StandardFrameConstants::kCallerSPOffset + offset));
195
+ __ push(rdx);
196
+ __ Push(Smi::FromInt(scope()->num_parameters()));
197
+ // Arguments to ArgumentsAccessStub:
198
+ // function, receiver address, parameter count.
199
+ // The stub will rewrite receiver and parameter count if the previous
200
+ // stack frame was an arguments adapter frame.
201
+ ArgumentsAccessStub stub(
202
+ is_strict_mode() ? ArgumentsAccessStub::NEW_STRICT
203
+ : ArgumentsAccessStub::NEW_NON_STRICT);
204
+ __ CallStub(&stub);
205
+
206
+ Variable* arguments_shadow = scope()->arguments_shadow();
207
+ if (arguments_shadow != NULL) {
208
+ // Store new arguments object in both "arguments" and ".arguments" slots.
209
+ __ movq(rcx, rax);
210
+ Move(arguments_shadow->AsSlot(), rcx, rbx, rdx);
211
+ }
212
+ Move(arguments->AsSlot(), rax, rbx, rdx);
213
+ }
214
+
215
+ if (FLAG_trace) {
216
+ __ CallRuntime(Runtime::kTraceEnter, 0);
217
+ }
218
+
219
+ // Visit the declarations and body unless there is an illegal
220
+ // redeclaration.
221
+ if (scope()->HasIllegalRedeclaration()) {
222
+ Comment cmnt(masm_, "[ Declarations");
223
+ scope()->VisitIllegalRedeclaration(this);
224
+ } else {
225
+ { Comment cmnt(masm_, "[ Declarations");
226
+ // For named function expressions, declare the function name as a
227
+ // constant.
228
+ if (scope()->is_function_scope() && scope()->function() != NULL) {
229
+ EmitDeclaration(scope()->function(), Variable::CONST, NULL);
230
+ }
231
+ VisitDeclarations(scope()->declarations());
232
+ }
233
+
234
+ { Comment cmnt(masm_, "[ Stack check");
235
+ PrepareForBailout(info->function(), NO_REGISTERS);
236
+ NearLabel ok;
237
+ __ CompareRoot(rsp, Heap::kStackLimitRootIndex);
238
+ __ j(above_equal, &ok);
239
+ StackCheckStub stub;
240
+ __ CallStub(&stub);
241
+ __ bind(&ok);
242
+ }
243
+
244
+ { Comment cmnt(masm_, "[ Body");
245
+ ASSERT(loop_depth() == 0);
246
+ VisitStatements(function()->body());
247
+ ASSERT(loop_depth() == 0);
248
+ }
249
+ }
250
+
251
+ // Always emit a 'return undefined' in case control fell off the end of
252
+ // the body.
253
+ { Comment cmnt(masm_, "[ return <undefined>;");
254
+ __ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
255
+ EmitReturnSequence();
256
+ }
257
+ }
258
+
259
+
260
+ void FullCodeGenerator::ClearAccumulator() {
261
+ __ Set(rax, 0);
262
+ }
263
+
264
+
265
+ void FullCodeGenerator::EmitStackCheck(IterationStatement* stmt) {
266
+ Comment cmnt(masm_, "[ Stack check");
267
+ NearLabel ok;
268
+ __ CompareRoot(rsp, Heap::kStackLimitRootIndex);
269
+ __ j(above_equal, &ok);
270
+ StackCheckStub stub;
271
+ __ CallStub(&stub);
272
+ // Record a mapping of this PC offset to the OSR id. This is used to find
273
+ // the AST id from the unoptimized code in order to use it as a key into
274
+ // the deoptimization input data found in the optimized code.
275
+ RecordStackCheck(stmt->OsrEntryId());
276
+
277
+ // Loop stack checks can be patched to perform on-stack replacement. In
278
+ // order to decide whether or not to perform OSR we embed the loop depth
279
+ // in a test instruction after the call so we can extract it from the OSR
280
+ // builtin.
281
+ ASSERT(loop_depth() > 0);
282
+ __ testl(rax, Immediate(Min(loop_depth(), Code::kMaxLoopNestingMarker)));
283
+
284
+ __ bind(&ok);
285
+ PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS);
286
+ // Record a mapping of the OSR id to this PC. This is used if the OSR
287
+ // entry becomes the target of a bailout. We don't expect it to be, but
288
+ // we want it to work if it is.
289
+ PrepareForBailoutForId(stmt->OsrEntryId(), NO_REGISTERS);
290
+ }
291
+
292
+
293
+ void FullCodeGenerator::EmitReturnSequence() {
294
+ Comment cmnt(masm_, "[ Return sequence");
295
+ if (return_label_.is_bound()) {
296
+ __ jmp(&return_label_);
297
+ } else {
298
+ __ bind(&return_label_);
299
+ if (FLAG_trace) {
300
+ __ push(rax);
301
+ __ CallRuntime(Runtime::kTraceExit, 1);
302
+ }
303
+ #ifdef DEBUG
304
+ // Add a label for checking the size of the code used for returning.
305
+ Label check_exit_codesize;
306
+ masm_->bind(&check_exit_codesize);
307
+ #endif
308
+ CodeGenerator::RecordPositions(masm_, function()->end_position() - 1);
309
+ __ RecordJSReturn();
310
+ // Do not use the leave instruction here because it is too short to
311
+ // patch with the code required by the debugger.
312
+ __ movq(rsp, rbp);
313
+ __ pop(rbp);
314
+
315
+ int arguments_bytes = (scope()->num_parameters() + 1) * kPointerSize;
316
+ __ Ret(arguments_bytes, rcx);
317
+
318
+ #ifdef ENABLE_DEBUGGER_SUPPORT
319
+ // Add padding that will be overwritten by a debugger breakpoint. We
320
+ // have just generated at least 7 bytes: "movq rsp, rbp; pop rbp; ret k"
321
+ // (3 + 1 + 3).
322
+ const int kPadding = Assembler::kJSReturnSequenceLength - 7;
323
+ for (int i = 0; i < kPadding; ++i) {
324
+ masm_->int3();
325
+ }
326
+ // Check that the size of the code used for returning is large enough
327
+ // for the debugger's requirements.
328
+ ASSERT(Assembler::kJSReturnSequenceLength <=
329
+ masm_->SizeOfCodeGeneratedSince(&check_exit_codesize));
330
+ #endif
331
+ }
332
+ }
333
+
334
+
335
+ void FullCodeGenerator::EffectContext::Plug(Slot* slot) const {
336
+ }
337
+
338
+
339
+ void FullCodeGenerator::AccumulatorValueContext::Plug(Slot* slot) const {
340
+ MemOperand slot_operand = codegen()->EmitSlotSearch(slot, result_register());
341
+ __ movq(result_register(), slot_operand);
342
+ }
343
+
344
+
345
+ void FullCodeGenerator::StackValueContext::Plug(Slot* slot) const {
346
+ MemOperand slot_operand = codegen()->EmitSlotSearch(slot, result_register());
347
+ __ push(slot_operand);
348
+ }
349
+
350
+
351
+ void FullCodeGenerator::TestContext::Plug(Slot* slot) const {
352
+ codegen()->Move(result_register(), slot);
353
+ codegen()->PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL);
354
+ codegen()->DoTest(true_label_, false_label_, fall_through_);
355
+ }
356
+
357
+
358
+ void FullCodeGenerator::EffectContext::Plug(Heap::RootListIndex index) const {
359
+ }
360
+
361
+
362
+ void FullCodeGenerator::AccumulatorValueContext::Plug(
363
+ Heap::RootListIndex index) const {
364
+ __ LoadRoot(result_register(), index);
365
+ }
366
+
367
+
368
+ void FullCodeGenerator::StackValueContext::Plug(
369
+ Heap::RootListIndex index) const {
370
+ __ PushRoot(index);
371
+ }
372
+
373
+
374
+ void FullCodeGenerator::TestContext::Plug(Heap::RootListIndex index) const {
375
+ codegen()->PrepareForBailoutBeforeSplit(TOS_REG,
376
+ true,
377
+ true_label_,
378
+ false_label_);
379
+ if (index == Heap::kUndefinedValueRootIndex ||
380
+ index == Heap::kNullValueRootIndex ||
381
+ index == Heap::kFalseValueRootIndex) {
382
+ if (false_label_ != fall_through_) __ jmp(false_label_);
383
+ } else if (index == Heap::kTrueValueRootIndex) {
384
+ if (true_label_ != fall_through_) __ jmp(true_label_);
385
+ } else {
386
+ __ LoadRoot(result_register(), index);
387
+ codegen()->DoTest(true_label_, false_label_, fall_through_);
388
+ }
389
+ }
390
+
391
+
392
+ void FullCodeGenerator::EffectContext::Plug(Handle<Object> lit) const {
393
+ }
394
+
395
+
396
+ void FullCodeGenerator::AccumulatorValueContext::Plug(
397
+ Handle<Object> lit) const {
398
+ __ Move(result_register(), lit);
399
+ }
400
+
401
+
402
+ void FullCodeGenerator::StackValueContext::Plug(Handle<Object> lit) const {
403
+ __ Push(lit);
404
+ }
405
+
406
+
407
+ void FullCodeGenerator::TestContext::Plug(Handle<Object> lit) const {
408
+ codegen()->PrepareForBailoutBeforeSplit(TOS_REG,
409
+ true,
410
+ true_label_,
411
+ false_label_);
412
+ ASSERT(!lit->IsUndetectableObject()); // There are no undetectable literals.
413
+ if (lit->IsUndefined() || lit->IsNull() || lit->IsFalse()) {
414
+ if (false_label_ != fall_through_) __ jmp(false_label_);
415
+ } else if (lit->IsTrue() || lit->IsJSObject()) {
416
+ if (true_label_ != fall_through_) __ jmp(true_label_);
417
+ } else if (lit->IsString()) {
418
+ if (String::cast(*lit)->length() == 0) {
419
+ if (false_label_ != fall_through_) __ jmp(false_label_);
420
+ } else {
421
+ if (true_label_ != fall_through_) __ jmp(true_label_);
422
+ }
423
+ } else if (lit->IsSmi()) {
424
+ if (Smi::cast(*lit)->value() == 0) {
425
+ if (false_label_ != fall_through_) __ jmp(false_label_);
426
+ } else {
427
+ if (true_label_ != fall_through_) __ jmp(true_label_);
428
+ }
429
+ } else {
430
+ // For simplicity we always test the accumulator register.
431
+ __ Move(result_register(), lit);
432
+ codegen()->DoTest(true_label_, false_label_, fall_through_);
433
+ }
434
+ }
435
+
436
+
437
+ void FullCodeGenerator::EffectContext::DropAndPlug(int count,
438
+ Register reg) const {
439
+ ASSERT(count > 0);
440
+ __ Drop(count);
441
+ }
442
+
443
+
444
+ void FullCodeGenerator::AccumulatorValueContext::DropAndPlug(
445
+ int count,
446
+ Register reg) const {
447
+ ASSERT(count > 0);
448
+ __ Drop(count);
449
+ __ Move(result_register(), reg);
450
+ }
451
+
452
+
453
+ void FullCodeGenerator::StackValueContext::DropAndPlug(int count,
454
+ Register reg) const {
455
+ ASSERT(count > 0);
456
+ if (count > 1) __ Drop(count - 1);
457
+ __ movq(Operand(rsp, 0), reg);
458
+ }
459
+
460
+
461
+ void FullCodeGenerator::TestContext::DropAndPlug(int count,
462
+ Register reg) const {
463
+ ASSERT(count > 0);
464
+ // For simplicity we always test the accumulator register.
465
+ __ Drop(count);
466
+ __ Move(result_register(), reg);
467
+ codegen()->PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL);
468
+ codegen()->DoTest(true_label_, false_label_, fall_through_);
469
+ }
470
+
471
+
472
+ void FullCodeGenerator::EffectContext::Plug(Label* materialize_true,
473
+ Label* materialize_false) const {
474
+ ASSERT(materialize_true == materialize_false);
475
+ __ bind(materialize_true);
476
+ }
477
+
478
+
479
+ void FullCodeGenerator::AccumulatorValueContext::Plug(
480
+ Label* materialize_true,
481
+ Label* materialize_false) const {
482
+ NearLabel done;
483
+ __ bind(materialize_true);
484
+ __ Move(result_register(), isolate()->factory()->true_value());
485
+ __ jmp(&done);
486
+ __ bind(materialize_false);
487
+ __ Move(result_register(), isolate()->factory()->false_value());
488
+ __ bind(&done);
489
+ }
490
+
491
+
492
+ void FullCodeGenerator::StackValueContext::Plug(
493
+ Label* materialize_true,
494
+ Label* materialize_false) const {
495
+ NearLabel done;
496
+ __ bind(materialize_true);
497
+ __ Push(isolate()->factory()->true_value());
498
+ __ jmp(&done);
499
+ __ bind(materialize_false);
500
+ __ Push(isolate()->factory()->false_value());
501
+ __ bind(&done);
502
+ }
503
+
504
+
505
+ void FullCodeGenerator::TestContext::Plug(Label* materialize_true,
506
+ Label* materialize_false) const {
507
+ ASSERT(materialize_true == true_label_);
508
+ ASSERT(materialize_false == false_label_);
509
+ }
510
+
511
+
512
+ void FullCodeGenerator::EffectContext::Plug(bool flag) const {
513
+ }
514
+
515
+
516
+ void FullCodeGenerator::AccumulatorValueContext::Plug(bool flag) const {
517
+ Heap::RootListIndex value_root_index =
518
+ flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex;
519
+ __ LoadRoot(result_register(), value_root_index);
520
+ }
521
+
522
+
523
+ void FullCodeGenerator::StackValueContext::Plug(bool flag) const {
524
+ Heap::RootListIndex value_root_index =
525
+ flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex;
526
+ __ PushRoot(value_root_index);
527
+ }
528
+
529
+
530
+ void FullCodeGenerator::TestContext::Plug(bool flag) const {
531
+ codegen()->PrepareForBailoutBeforeSplit(TOS_REG,
532
+ true,
533
+ true_label_,
534
+ false_label_);
535
+ if (flag) {
536
+ if (true_label_ != fall_through_) __ jmp(true_label_);
537
+ } else {
538
+ if (false_label_ != fall_through_) __ jmp(false_label_);
539
+ }
540
+ }
541
+
542
+
543
+ void FullCodeGenerator::DoTest(Label* if_true,
544
+ Label* if_false,
545
+ Label* fall_through) {
546
+ // Emit the inlined tests assumed by the stub.
547
+ __ CompareRoot(result_register(), Heap::kUndefinedValueRootIndex);
548
+ __ j(equal, if_false);
549
+ __ CompareRoot(result_register(), Heap::kTrueValueRootIndex);
550
+ __ j(equal, if_true);
551
+ __ CompareRoot(result_register(), Heap::kFalseValueRootIndex);
552
+ __ j(equal, if_false);
553
+ STATIC_ASSERT(kSmiTag == 0);
554
+ __ Cmp(result_register(), Smi::FromInt(0));
555
+ __ j(equal, if_false);
556
+ Condition is_smi = masm_->CheckSmi(result_register());
557
+ __ j(is_smi, if_true);
558
+
559
+ // Call the ToBoolean stub for all other cases.
560
+ ToBooleanStub stub;
561
+ __ push(result_register());
562
+ __ CallStub(&stub);
563
+ __ testq(rax, rax);
564
+
565
+ // The stub returns nonzero for true.
566
+ Split(not_zero, if_true, if_false, fall_through);
567
+ }
568
+
569
+
570
+ void FullCodeGenerator::Split(Condition cc,
571
+ Label* if_true,
572
+ Label* if_false,
573
+ Label* fall_through) {
574
+ if (if_false == fall_through) {
575
+ __ j(cc, if_true);
576
+ } else if (if_true == fall_through) {
577
+ __ j(NegateCondition(cc), if_false);
578
+ } else {
579
+ __ j(cc, if_true);
580
+ __ jmp(if_false);
581
+ }
582
+ }
583
+
584
+
585
+ MemOperand FullCodeGenerator::EmitSlotSearch(Slot* slot, Register scratch) {
586
+ switch (slot->type()) {
587
+ case Slot::PARAMETER:
588
+ case Slot::LOCAL:
589
+ return Operand(rbp, SlotOffset(slot));
590
+ case Slot::CONTEXT: {
591
+ int context_chain_length =
592
+ scope()->ContextChainLength(slot->var()->scope());
593
+ __ LoadContext(scratch, context_chain_length);
594
+ return ContextOperand(scratch, slot->index());
595
+ }
596
+ case Slot::LOOKUP:
597
+ UNREACHABLE();
598
+ }
599
+ UNREACHABLE();
600
+ return Operand(rax, 0);
601
+ }
602
+
603
+
604
+ void FullCodeGenerator::Move(Register destination, Slot* source) {
605
+ MemOperand location = EmitSlotSearch(source, destination);
606
+ __ movq(destination, location);
607
+ }
608
+
609
+
610
+ void FullCodeGenerator::Move(Slot* dst,
611
+ Register src,
612
+ Register scratch1,
613
+ Register scratch2) {
614
+ ASSERT(dst->type() != Slot::LOOKUP); // Not yet implemented.
615
+ ASSERT(!scratch1.is(src) && !scratch2.is(src));
616
+ MemOperand location = EmitSlotSearch(dst, scratch1);
617
+ __ movq(location, src);
618
+ // Emit the write barrier code if the location is in the heap.
619
+ if (dst->type() == Slot::CONTEXT) {
620
+ int offset = FixedArray::kHeaderSize + dst->index() * kPointerSize;
621
+ __ RecordWrite(scratch1, offset, src, scratch2);
622
+ }
623
+ }
624
+
625
+
626
+ void FullCodeGenerator::PrepareForBailoutBeforeSplit(State state,
627
+ bool should_normalize,
628
+ Label* if_true,
629
+ Label* if_false) {
630
+ // Only prepare for bailouts before splits if we're in a test
631
+ // context. Otherwise, we let the Visit function deal with the
632
+ // preparation to avoid preparing with the same AST id twice.
633
+ if (!context()->IsTest() || !info_->IsOptimizable()) return;
634
+
635
+ NearLabel skip;
636
+ if (should_normalize) __ jmp(&skip);
637
+
638
+ ForwardBailoutStack* current = forward_bailout_stack_;
639
+ while (current != NULL) {
640
+ PrepareForBailout(current->expr(), state);
641
+ current = current->parent();
642
+ }
643
+
644
+ if (should_normalize) {
645
+ __ CompareRoot(rax, Heap::kTrueValueRootIndex);
646
+ Split(equal, if_true, if_false, NULL);
647
+ __ bind(&skip);
648
+ }
649
+ }
650
+
651
+
652
+ void FullCodeGenerator::EmitDeclaration(Variable* variable,
653
+ Variable::Mode mode,
654
+ FunctionLiteral* function) {
655
+ Comment cmnt(masm_, "[ Declaration");
656
+ ASSERT(variable != NULL); // Must have been resolved.
657
+ Slot* slot = variable->AsSlot();
658
+ Property* prop = variable->AsProperty();
659
+
660
+ if (slot != NULL) {
661
+ switch (slot->type()) {
662
+ case Slot::PARAMETER:
663
+ case Slot::LOCAL:
664
+ if (mode == Variable::CONST) {
665
+ __ LoadRoot(kScratchRegister, Heap::kTheHoleValueRootIndex);
666
+ __ movq(Operand(rbp, SlotOffset(slot)), kScratchRegister);
667
+ } else if (function != NULL) {
668
+ VisitForAccumulatorValue(function);
669
+ __ movq(Operand(rbp, SlotOffset(slot)), result_register());
670
+ }
671
+ break;
672
+
673
+ case Slot::CONTEXT:
674
+ // We bypass the general EmitSlotSearch because we know more about
675
+ // this specific context.
676
+
677
+ // The variable in the decl always resides in the current context.
678
+ ASSERT_EQ(0, scope()->ContextChainLength(variable->scope()));
679
+ if (FLAG_debug_code) {
680
+ // Check if we have the correct context pointer.
681
+ __ movq(rbx, ContextOperand(rsi, Context::FCONTEXT_INDEX));
682
+ __ cmpq(rbx, rsi);
683
+ __ Check(equal, "Unexpected declaration in current context.");
684
+ }
685
+ if (mode == Variable::CONST) {
686
+ __ LoadRoot(kScratchRegister, Heap::kTheHoleValueRootIndex);
687
+ __ movq(ContextOperand(rsi, slot->index()), kScratchRegister);
688
+ // No write barrier since the hole value is in old space.
689
+ } else if (function != NULL) {
690
+ VisitForAccumulatorValue(function);
691
+ __ movq(ContextOperand(rsi, slot->index()), result_register());
692
+ int offset = Context::SlotOffset(slot->index());
693
+ __ movq(rbx, rsi);
694
+ __ RecordWrite(rbx, offset, result_register(), rcx);
695
+ }
696
+ break;
697
+
698
+ case Slot::LOOKUP: {
699
+ __ push(rsi);
700
+ __ Push(variable->name());
701
+ // Declaration nodes are always introduced in one of two modes.
702
+ ASSERT(mode == Variable::VAR || mode == Variable::CONST);
703
+ PropertyAttributes attr = (mode == Variable::VAR) ? NONE : READ_ONLY;
704
+ __ Push(Smi::FromInt(attr));
705
+ // Push initial value, if any.
706
+ // Note: For variables we must not push an initial value (such as
707
+ // 'undefined') because we may have a (legal) redeclaration and we
708
+ // must not destroy the current value.
709
+ if (mode == Variable::CONST) {
710
+ __ PushRoot(Heap::kTheHoleValueRootIndex);
711
+ } else if (function != NULL) {
712
+ VisitForStackValue(function);
713
+ } else {
714
+ __ Push(Smi::FromInt(0)); // no initial value!
715
+ }
716
+ __ CallRuntime(Runtime::kDeclareContextSlot, 4);
717
+ break;
718
+ }
719
+ }
720
+
721
+ } else if (prop != NULL) {
722
+ if (function != NULL || mode == Variable::CONST) {
723
+ // We are declaring a function or constant that rewrites to a
724
+ // property. Use (keyed) IC to set the initial value. We
725
+ // cannot visit the rewrite because it's shared and we risk
726
+ // recording duplicate AST IDs for bailouts from optimized code.
727
+ ASSERT(prop->obj()->AsVariableProxy() != NULL);
728
+ { AccumulatorValueContext for_object(this);
729
+ EmitVariableLoad(prop->obj()->AsVariableProxy()->var());
730
+ }
731
+ if (function != NULL) {
732
+ __ push(rax);
733
+ VisitForAccumulatorValue(function);
734
+ __ pop(rdx);
735
+ } else {
736
+ __ movq(rdx, rax);
737
+ __ LoadRoot(rax, Heap::kTheHoleValueRootIndex);
738
+ }
739
+ ASSERT(prop->key()->AsLiteral() != NULL &&
740
+ prop->key()->AsLiteral()->handle()->IsSmi());
741
+ __ Move(rcx, prop->key()->AsLiteral()->handle());
742
+
743
+ Handle<Code> ic = is_strict_mode()
744
+ ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict()
745
+ : isolate()->builtins()->KeyedStoreIC_Initialize();
746
+ EmitCallIC(ic, RelocInfo::CODE_TARGET);
747
+ }
748
+ }
749
+ }
750
+
751
+
752
+ void FullCodeGenerator::VisitDeclaration(Declaration* decl) {
753
+ EmitDeclaration(decl->proxy()->var(), decl->mode(), decl->fun());
754
+ }
755
+
756
+
757
+ void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) {
758
+ // Call the runtime to declare the globals.
759
+ __ push(rsi); // The context is the first argument.
760
+ __ Push(pairs);
761
+ __ Push(Smi::FromInt(is_eval() ? 1 : 0));
762
+ __ Push(Smi::FromInt(strict_mode_flag()));
763
+ __ CallRuntime(Runtime::kDeclareGlobals, 4);
764
+ // Return value is ignored.
765
+ }
766
+
767
+
768
+ void FullCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) {
769
+ Comment cmnt(masm_, "[ SwitchStatement");
770
+ Breakable nested_statement(this, stmt);
771
+ SetStatementPosition(stmt);
772
+
773
+ // Keep the switch value on the stack until a case matches.
774
+ VisitForStackValue(stmt->tag());
775
+ PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS);
776
+
777
+ ZoneList<CaseClause*>* clauses = stmt->cases();
778
+ CaseClause* default_clause = NULL; // Can occur anywhere in the list.
779
+
780
+ Label next_test; // Recycled for each test.
781
+ // Compile all the tests with branches to their bodies.
782
+ for (int i = 0; i < clauses->length(); i++) {
783
+ CaseClause* clause = clauses->at(i);
784
+ clause->body_target()->entry_label()->Unuse();
785
+
786
+ // The default is not a test, but remember it as final fall through.
787
+ if (clause->is_default()) {
788
+ default_clause = clause;
789
+ continue;
790
+ }
791
+
792
+ Comment cmnt(masm_, "[ Case comparison");
793
+ __ bind(&next_test);
794
+ next_test.Unuse();
795
+
796
+ // Compile the label expression.
797
+ VisitForAccumulatorValue(clause->label());
798
+
799
+ // Perform the comparison as if via '==='.
800
+ __ movq(rdx, Operand(rsp, 0)); // Switch value.
801
+ bool inline_smi_code = ShouldInlineSmiCase(Token::EQ_STRICT);
802
+ JumpPatchSite patch_site(masm_);
803
+ if (inline_smi_code) {
804
+ NearLabel slow_case;
805
+ __ movq(rcx, rdx);
806
+ __ or_(rcx, rax);
807
+ patch_site.EmitJumpIfNotSmi(rcx, &slow_case);
808
+
809
+ __ cmpq(rdx, rax);
810
+ __ j(not_equal, &next_test);
811
+ __ Drop(1); // Switch value is no longer needed.
812
+ __ jmp(clause->body_target()->entry_label());
813
+ __ bind(&slow_case);
814
+ }
815
+
816
+ // Record position before stub call for type feedback.
817
+ SetSourcePosition(clause->position());
818
+ Handle<Code> ic = CompareIC::GetUninitialized(Token::EQ_STRICT);
819
+ EmitCallIC(ic, &patch_site);
820
+
821
+ __ testq(rax, rax);
822
+ __ j(not_equal, &next_test);
823
+ __ Drop(1); // Switch value is no longer needed.
824
+ __ jmp(clause->body_target()->entry_label());
825
+ }
826
+
827
+ // Discard the test value and jump to the default if present, otherwise to
828
+ // the end of the statement.
829
+ __ bind(&next_test);
830
+ __ Drop(1); // Switch value is no longer needed.
831
+ if (default_clause == NULL) {
832
+ __ jmp(nested_statement.break_target());
833
+ } else {
834
+ __ jmp(default_clause->body_target()->entry_label());
835
+ }
836
+
837
+ // Compile all the case bodies.
838
+ for (int i = 0; i < clauses->length(); i++) {
839
+ Comment cmnt(masm_, "[ Case body");
840
+ CaseClause* clause = clauses->at(i);
841
+ __ bind(clause->body_target()->entry_label());
842
+ PrepareForBailoutForId(clause->EntryId(), NO_REGISTERS);
843
+ VisitStatements(clause->statements());
844
+ }
845
+
846
+ __ bind(nested_statement.break_target());
847
+ PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS);
848
+ }
849
+
850
+
851
+ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
852
+ Comment cmnt(masm_, "[ ForInStatement");
853
+ SetStatementPosition(stmt);
854
+
855
+ Label loop, exit;
856
+ ForIn loop_statement(this, stmt);
857
+ increment_loop_depth();
858
+
859
+ // Get the object to enumerate over. Both SpiderMonkey and JSC
860
+ // ignore null and undefined in contrast to the specification; see
861
+ // ECMA-262 section 12.6.4.
862
+ VisitForAccumulatorValue(stmt->enumerable());
863
+ __ CompareRoot(rax, Heap::kUndefinedValueRootIndex);
864
+ __ j(equal, &exit);
865
+ Register null_value = rdi;
866
+ __ LoadRoot(null_value, Heap::kNullValueRootIndex);
867
+ __ cmpq(rax, null_value);
868
+ __ j(equal, &exit);
869
+
870
+ // Convert the object to a JS object.
871
+ Label convert, done_convert;
872
+ __ JumpIfSmi(rax, &convert);
873
+ __ CmpObjectType(rax, FIRST_JS_OBJECT_TYPE, rcx);
874
+ __ j(above_equal, &done_convert);
875
+ __ bind(&convert);
876
+ __ push(rax);
877
+ __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION);
878
+ __ bind(&done_convert);
879
+ __ push(rax);
880
+
881
+ // Check cache validity in generated code. This is a fast case for
882
+ // the JSObject::IsSimpleEnum cache validity checks. If we cannot
883
+ // guarantee cache validity, call the runtime system to check cache
884
+ // validity or get the property names in a fixed array.
885
+ Label next, call_runtime;
886
+ Register empty_fixed_array_value = r8;
887
+ __ LoadRoot(empty_fixed_array_value, Heap::kEmptyFixedArrayRootIndex);
888
+ Register empty_descriptor_array_value = r9;
889
+ __ LoadRoot(empty_descriptor_array_value,
890
+ Heap::kEmptyDescriptorArrayRootIndex);
891
+ __ movq(rcx, rax);
892
+ __ bind(&next);
893
+
894
+ // Check that there are no elements. Register rcx contains the
895
+ // current JS object we've reached through the prototype chain.
896
+ __ cmpq(empty_fixed_array_value,
897
+ FieldOperand(rcx, JSObject::kElementsOffset));
898
+ __ j(not_equal, &call_runtime);
899
+
900
+ // Check that instance descriptors are not empty so that we can
901
+ // check for an enum cache. Leave the map in rbx for the subsequent
902
+ // prototype load.
903
+ __ movq(rbx, FieldOperand(rcx, HeapObject::kMapOffset));
904
+ __ movq(rdx, FieldOperand(rbx, Map::kInstanceDescriptorsOffset));
905
+ __ cmpq(rdx, empty_descriptor_array_value);
906
+ __ j(equal, &call_runtime);
907
+
908
+ // Check that there is an enum cache in the non-empty instance
909
+ // descriptors (rdx). This is the case if the next enumeration
910
+ // index field does not contain a smi.
911
+ __ movq(rdx, FieldOperand(rdx, DescriptorArray::kEnumerationIndexOffset));
912
+ __ JumpIfSmi(rdx, &call_runtime);
913
+
914
+ // For all objects but the receiver, check that the cache is empty.
915
+ NearLabel check_prototype;
916
+ __ cmpq(rcx, rax);
917
+ __ j(equal, &check_prototype);
918
+ __ movq(rdx, FieldOperand(rdx, DescriptorArray::kEnumCacheBridgeCacheOffset));
919
+ __ cmpq(rdx, empty_fixed_array_value);
920
+ __ j(not_equal, &call_runtime);
921
+
922
+ // Load the prototype from the map and loop if non-null.
923
+ __ bind(&check_prototype);
924
+ __ movq(rcx, FieldOperand(rbx, Map::kPrototypeOffset));
925
+ __ cmpq(rcx, null_value);
926
+ __ j(not_equal, &next);
927
+
928
+ // The enum cache is valid. Load the map of the object being
929
+ // iterated over and use the cache for the iteration.
930
+ NearLabel use_cache;
931
+ __ movq(rax, FieldOperand(rax, HeapObject::kMapOffset));
932
+ __ jmp(&use_cache);
933
+
934
+ // Get the set of properties to enumerate.
935
+ __ bind(&call_runtime);
936
+ __ push(rax); // Duplicate the enumerable object on the stack.
937
+ __ CallRuntime(Runtime::kGetPropertyNamesFast, 1);
938
+
939
+ // If we got a map from the runtime call, we can do a fast
940
+ // modification check. Otherwise, we got a fixed array, and we have
941
+ // to do a slow check.
942
+ NearLabel fixed_array;
943
+ __ CompareRoot(FieldOperand(rax, HeapObject::kMapOffset),
944
+ Heap::kMetaMapRootIndex);
945
+ __ j(not_equal, &fixed_array);
946
+
947
+ // We got a map in register rax. Get the enumeration cache from it.
948
+ __ bind(&use_cache);
949
+ __ movq(rcx, FieldOperand(rax, Map::kInstanceDescriptorsOffset));
950
+ __ movq(rcx, FieldOperand(rcx, DescriptorArray::kEnumerationIndexOffset));
951
+ __ movq(rdx, FieldOperand(rcx, DescriptorArray::kEnumCacheBridgeCacheOffset));
952
+
953
+ // Setup the four remaining stack slots.
954
+ __ push(rax); // Map.
955
+ __ push(rdx); // Enumeration cache.
956
+ __ movq(rax, FieldOperand(rdx, FixedArray::kLengthOffset));
957
+ __ push(rax); // Enumeration cache length (as smi).
958
+ __ Push(Smi::FromInt(0)); // Initial index.
959
+ __ jmp(&loop);
960
+
961
+ // We got a fixed array in register rax. Iterate through that.
962
+ __ bind(&fixed_array);
963
+ __ Push(Smi::FromInt(0)); // Map (0) - force slow check.
964
+ __ push(rax);
965
+ __ movq(rax, FieldOperand(rax, FixedArray::kLengthOffset));
966
+ __ push(rax); // Fixed array length (as smi).
967
+ __ Push(Smi::FromInt(0)); // Initial index.
968
+
969
+ // Generate code for doing the condition check.
970
+ __ bind(&loop);
971
+ __ movq(rax, Operand(rsp, 0 * kPointerSize)); // Get the current index.
972
+ __ cmpq(rax, Operand(rsp, 1 * kPointerSize)); // Compare to the array length.
973
+ __ j(above_equal, loop_statement.break_target());
974
+
975
+ // Get the current entry of the array into register rbx.
976
+ __ movq(rbx, Operand(rsp, 2 * kPointerSize));
977
+ SmiIndex index = masm()->SmiToIndex(rax, rax, kPointerSizeLog2);
978
+ __ movq(rbx, FieldOperand(rbx,
979
+ index.reg,
980
+ index.scale,
981
+ FixedArray::kHeaderSize));
982
+
983
+ // Get the expected map from the stack or a zero map in the
984
+ // permanent slow case into register rdx.
985
+ __ movq(rdx, Operand(rsp, 3 * kPointerSize));
986
+
987
+ // Check if the expected map still matches that of the enumerable.
988
+ // If not, we have to filter the key.
989
+ NearLabel update_each;
990
+ __ movq(rcx, Operand(rsp, 4 * kPointerSize));
991
+ __ cmpq(rdx, FieldOperand(rcx, HeapObject::kMapOffset));
992
+ __ j(equal, &update_each);
993
+
994
+ // Convert the entry to a string or null if it isn't a property
995
+ // anymore. If the property has been removed while iterating, we
996
+ // just skip it.
997
+ __ push(rcx); // Enumerable.
998
+ __ push(rbx); // Current entry.
999
+ __ InvokeBuiltin(Builtins::FILTER_KEY, CALL_FUNCTION);
1000
+ __ Cmp(rax, Smi::FromInt(0));
1001
+ __ j(equal, loop_statement.continue_target());
1002
+ __ movq(rbx, rax);
1003
+
1004
+ // Update the 'each' property or variable from the possibly filtered
1005
+ // entry in register rbx.
1006
+ __ bind(&update_each);
1007
+ __ movq(result_register(), rbx);
1008
+ // Perform the assignment as if via '='.
1009
+ { EffectContext context(this);
1010
+ EmitAssignment(stmt->each(), stmt->AssignmentId());
1011
+ }
1012
+
1013
+ // Generate code for the body of the loop.
1014
+ Visit(stmt->body());
1015
+
1016
+ // Generate code for going to the next element by incrementing the
1017
+ // index (smi) stored on top of the stack.
1018
+ __ bind(loop_statement.continue_target());
1019
+ __ SmiAddConstant(Operand(rsp, 0 * kPointerSize), Smi::FromInt(1));
1020
+
1021
+ EmitStackCheck(stmt);
1022
+ __ jmp(&loop);
1023
+
1024
+ // Remove the pointers stored on the stack.
1025
+ __ bind(loop_statement.break_target());
1026
+ __ addq(rsp, Immediate(5 * kPointerSize));
1027
+
1028
+ // Exit and decrement the loop depth.
1029
+ __ bind(&exit);
1030
+ decrement_loop_depth();
1031
+ }
1032
+
1033
+
1034
+ void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info,
1035
+ bool pretenure) {
1036
+ // Use the fast case closure allocation code that allocates in new
1037
+ // space for nested functions that don't need literals cloning. If
1038
+ // we're running with the --always-opt or the --prepare-always-opt
1039
+ // flag, we need to use the runtime function so that the new function
1040
+ // we are creating here gets a chance to have its code optimized and
1041
+ // doesn't just get a copy of the existing unoptimized code.
1042
+ if (!FLAG_always_opt &&
1043
+ !FLAG_prepare_always_opt &&
1044
+ !pretenure &&
1045
+ scope()->is_function_scope() &&
1046
+ info->num_literals() == 0) {
1047
+ FastNewClosureStub stub(info->strict_mode() ? kStrictMode : kNonStrictMode);
1048
+ __ Push(info);
1049
+ __ CallStub(&stub);
1050
+ } else {
1051
+ __ push(rsi);
1052
+ __ Push(info);
1053
+ __ Push(pretenure
1054
+ ? isolate()->factory()->true_value()
1055
+ : isolate()->factory()->false_value());
1056
+ __ CallRuntime(Runtime::kNewClosure, 3);
1057
+ }
1058
+ context()->Plug(rax);
1059
+ }
1060
+
1061
+
1062
+ void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) {
1063
+ Comment cmnt(masm_, "[ VariableProxy");
1064
+ EmitVariableLoad(expr->var());
1065
+ }
1066
+
1067
+
1068
+ void FullCodeGenerator::EmitLoadGlobalSlotCheckExtensions(
1069
+ Slot* slot,
1070
+ TypeofState typeof_state,
1071
+ Label* slow) {
1072
+ Register context = rsi;
1073
+ Register temp = rdx;
1074
+
1075
+ Scope* s = scope();
1076
+ while (s != NULL) {
1077
+ if (s->num_heap_slots() > 0) {
1078
+ if (s->calls_eval()) {
1079
+ // Check that extension is NULL.
1080
+ __ cmpq(ContextOperand(context, Context::EXTENSION_INDEX),
1081
+ Immediate(0));
1082
+ __ j(not_equal, slow);
1083
+ }
1084
+ // Load next context in chain.
1085
+ __ movq(temp, ContextOperand(context, Context::CLOSURE_INDEX));
1086
+ __ movq(temp, FieldOperand(temp, JSFunction::kContextOffset));
1087
+ // Walk the rest of the chain without clobbering rsi.
1088
+ context = temp;
1089
+ }
1090
+ // If no outer scope calls eval, we do not need to check more
1091
+ // context extensions. If we have reached an eval scope, we check
1092
+ // all extensions from this point.
1093
+ if (!s->outer_scope_calls_eval() || s->is_eval_scope()) break;
1094
+ s = s->outer_scope();
1095
+ }
1096
+
1097
+ if (s != NULL && s->is_eval_scope()) {
1098
+ // Loop up the context chain. There is no frame effect so it is
1099
+ // safe to use raw labels here.
1100
+ NearLabel next, fast;
1101
+ if (!context.is(temp)) {
1102
+ __ movq(temp, context);
1103
+ }
1104
+ // Load map for comparison into register, outside loop.
1105
+ __ LoadRoot(kScratchRegister, Heap::kGlobalContextMapRootIndex);
1106
+ __ bind(&next);
1107
+ // Terminate at global context.
1108
+ __ cmpq(kScratchRegister, FieldOperand(temp, HeapObject::kMapOffset));
1109
+ __ j(equal, &fast);
1110
+ // Check that extension is NULL.
1111
+ __ cmpq(ContextOperand(temp, Context::EXTENSION_INDEX), Immediate(0));
1112
+ __ j(not_equal, slow);
1113
+ // Load next context in chain.
1114
+ __ movq(temp, ContextOperand(temp, Context::CLOSURE_INDEX));
1115
+ __ movq(temp, FieldOperand(temp, JSFunction::kContextOffset));
1116
+ __ jmp(&next);
1117
+ __ bind(&fast);
1118
+ }
1119
+
1120
+ // All extension objects were empty and it is safe to use a global
1121
+ // load IC call.
1122
+ __ movq(rax, GlobalObjectOperand());
1123
+ __ Move(rcx, slot->var()->name());
1124
+ Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
1125
+ RelocInfo::Mode mode = (typeof_state == INSIDE_TYPEOF)
1126
+ ? RelocInfo::CODE_TARGET
1127
+ : RelocInfo::CODE_TARGET_CONTEXT;
1128
+ EmitCallIC(ic, mode);
1129
+ }
1130
+
1131
+
1132
+ MemOperand FullCodeGenerator::ContextSlotOperandCheckExtensions(
1133
+ Slot* slot,
1134
+ Label* slow) {
1135
+ ASSERT(slot->type() == Slot::CONTEXT);
1136
+ Register context = rsi;
1137
+ Register temp = rbx;
1138
+
1139
+ for (Scope* s = scope(); s != slot->var()->scope(); s = s->outer_scope()) {
1140
+ if (s->num_heap_slots() > 0) {
1141
+ if (s->calls_eval()) {
1142
+ // Check that extension is NULL.
1143
+ __ cmpq(ContextOperand(context, Context::EXTENSION_INDEX),
1144
+ Immediate(0));
1145
+ __ j(not_equal, slow);
1146
+ }
1147
+ __ movq(temp, ContextOperand(context, Context::CLOSURE_INDEX));
1148
+ __ movq(temp, FieldOperand(temp, JSFunction::kContextOffset));
1149
+ // Walk the rest of the chain without clobbering rsi.
1150
+ context = temp;
1151
+ }
1152
+ }
1153
+ // Check that last extension is NULL.
1154
+ __ cmpq(ContextOperand(context, Context::EXTENSION_INDEX), Immediate(0));
1155
+ __ j(not_equal, slow);
1156
+
1157
+ // This function is used only for loads, not stores, so it's safe to
1158
+ // return an rsi-based operand (the write barrier cannot be allowed to
1159
+ // destroy the rsi register).
1160
+ return ContextOperand(context, slot->index());
1161
+ }
1162
+
1163
+
1164
+ void FullCodeGenerator::EmitDynamicLoadFromSlotFastCase(
1165
+ Slot* slot,
1166
+ TypeofState typeof_state,
1167
+ Label* slow,
1168
+ Label* done) {
1169
+ // Generate fast-case code for variables that might be shadowed by
1170
+ // eval-introduced variables. Eval is used a lot without
1171
+ // introducing variables. In those cases, we do not want to
1172
+ // perform a runtime call for all variables in the scope
1173
+ // containing the eval.
1174
+ if (slot->var()->mode() == Variable::DYNAMIC_GLOBAL) {
1175
+ EmitLoadGlobalSlotCheckExtensions(slot, typeof_state, slow);
1176
+ __ jmp(done);
1177
+ } else if (slot->var()->mode() == Variable::DYNAMIC_LOCAL) {
1178
+ Slot* potential_slot = slot->var()->local_if_not_shadowed()->AsSlot();
1179
+ Expression* rewrite = slot->var()->local_if_not_shadowed()->rewrite();
1180
+ if (potential_slot != NULL) {
1181
+ // Generate fast case for locals that rewrite to slots.
1182
+ __ movq(rax,
1183
+ ContextSlotOperandCheckExtensions(potential_slot, slow));
1184
+ if (potential_slot->var()->mode() == Variable::CONST) {
1185
+ __ CompareRoot(rax, Heap::kTheHoleValueRootIndex);
1186
+ __ j(not_equal, done);
1187
+ __ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
1188
+ }
1189
+ __ jmp(done);
1190
+ } else if (rewrite != NULL) {
1191
+ // Generate fast case for calls of an argument function.
1192
+ Property* property = rewrite->AsProperty();
1193
+ if (property != NULL) {
1194
+ VariableProxy* obj_proxy = property->obj()->AsVariableProxy();
1195
+ Literal* key_literal = property->key()->AsLiteral();
1196
+ if (obj_proxy != NULL &&
1197
+ key_literal != NULL &&
1198
+ obj_proxy->IsArguments() &&
1199
+ key_literal->handle()->IsSmi()) {
1200
+ // Load arguments object if there are no eval-introduced
1201
+ // variables. Then load the argument from the arguments
1202
+ // object using keyed load.
1203
+ __ movq(rdx,
1204
+ ContextSlotOperandCheckExtensions(obj_proxy->var()->AsSlot(),
1205
+ slow));
1206
+ __ Move(rax, key_literal->handle());
1207
+ Handle<Code> ic =
1208
+ isolate()->builtins()->KeyedLoadIC_Initialize();
1209
+ EmitCallIC(ic, RelocInfo::CODE_TARGET);
1210
+ __ jmp(done);
1211
+ }
1212
+ }
1213
+ }
1214
+ }
1215
+ }
1216
+
1217
+
1218
+ void FullCodeGenerator::EmitVariableLoad(Variable* var) {
1219
+ // Four cases: non-this global variables, lookup slots, all other
1220
+ // types of slots, and parameters that rewrite to explicit property
1221
+ // accesses on the arguments object.
1222
+ Slot* slot = var->AsSlot();
1223
+ Property* property = var->AsProperty();
1224
+
1225
+ if (var->is_global() && !var->is_this()) {
1226
+ Comment cmnt(masm_, "Global variable");
1227
+ // Use inline caching. Variable name is passed in rcx and the global
1228
+ // object on the stack.
1229
+ __ Move(rcx, var->name());
1230
+ __ movq(rax, GlobalObjectOperand());
1231
+ Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
1232
+ EmitCallIC(ic, RelocInfo::CODE_TARGET_CONTEXT);
1233
+ context()->Plug(rax);
1234
+
1235
+ } else if (slot != NULL && slot->type() == Slot::LOOKUP) {
1236
+ Label done, slow;
1237
+
1238
+ // Generate code for loading from variables potentially shadowed
1239
+ // by eval-introduced variables.
1240
+ EmitDynamicLoadFromSlotFastCase(slot, NOT_INSIDE_TYPEOF, &slow, &done);
1241
+
1242
+ __ bind(&slow);
1243
+ Comment cmnt(masm_, "Lookup slot");
1244
+ __ push(rsi); // Context.
1245
+ __ Push(var->name());
1246
+ __ CallRuntime(Runtime::kLoadContextSlot, 2);
1247
+ __ bind(&done);
1248
+
1249
+ context()->Plug(rax);
1250
+
1251
+ } else if (slot != NULL) {
1252
+ Comment cmnt(masm_, (slot->type() == Slot::CONTEXT)
1253
+ ? "Context slot"
1254
+ : "Stack slot");
1255
+ if (var->mode() == Variable::CONST) {
1256
+ // Constants may be the hole value if they have not been initialized.
1257
+ // Unhole them.
1258
+ NearLabel done;
1259
+ MemOperand slot_operand = EmitSlotSearch(slot, rax);
1260
+ __ movq(rax, slot_operand);
1261
+ __ CompareRoot(rax, Heap::kTheHoleValueRootIndex);
1262
+ __ j(not_equal, &done);
1263
+ __ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
1264
+ __ bind(&done);
1265
+ context()->Plug(rax);
1266
+ } else {
1267
+ context()->Plug(slot);
1268
+ }
1269
+
1270
+ } else {
1271
+ Comment cmnt(masm_, "Rewritten parameter");
1272
+ ASSERT_NOT_NULL(property);
1273
+ // Rewritten parameter accesses are of the form "slot[literal]".
1274
+
1275
+ // Assert that the object is in a slot.
1276
+ Variable* object_var = property->obj()->AsVariableProxy()->AsVariable();
1277
+ ASSERT_NOT_NULL(object_var);
1278
+ Slot* object_slot = object_var->AsSlot();
1279
+ ASSERT_NOT_NULL(object_slot);
1280
+
1281
+ // Load the object.
1282
+ MemOperand object_loc = EmitSlotSearch(object_slot, rax);
1283
+ __ movq(rdx, object_loc);
1284
+
1285
+ // Assert that the key is a smi.
1286
+ Literal* key_literal = property->key()->AsLiteral();
1287
+ ASSERT_NOT_NULL(key_literal);
1288
+ ASSERT(key_literal->handle()->IsSmi());
1289
+
1290
+ // Load the key.
1291
+ __ Move(rax, key_literal->handle());
1292
+
1293
+ // Do a keyed property load.
1294
+ Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize();
1295
+ EmitCallIC(ic, RelocInfo::CODE_TARGET);
1296
+ context()->Plug(rax);
1297
+ }
1298
+ }
1299
+
1300
+
1301
+ void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
1302
+ Comment cmnt(masm_, "[ RegExpLiteral");
1303
+ Label materialized;
1304
+ // Registers will be used as follows:
1305
+ // rdi = JS function.
1306
+ // rcx = literals array.
1307
+ // rbx = regexp literal.
1308
+ // rax = regexp literal clone.
1309
+ __ movq(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
1310
+ __ movq(rcx, FieldOperand(rdi, JSFunction::kLiteralsOffset));
1311
+ int literal_offset =
1312
+ FixedArray::kHeaderSize + expr->literal_index() * kPointerSize;
1313
+ __ movq(rbx, FieldOperand(rcx, literal_offset));
1314
+ __ CompareRoot(rbx, Heap::kUndefinedValueRootIndex);
1315
+ __ j(not_equal, &materialized);
1316
+
1317
+ // Create regexp literal using runtime function
1318
+ // Result will be in rax.
1319
+ __ push(rcx);
1320
+ __ Push(Smi::FromInt(expr->literal_index()));
1321
+ __ Push(expr->pattern());
1322
+ __ Push(expr->flags());
1323
+ __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4);
1324
+ __ movq(rbx, rax);
1325
+
1326
+ __ bind(&materialized);
1327
+ int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
1328
+ Label allocated, runtime_allocate;
1329
+ __ AllocateInNewSpace(size, rax, rcx, rdx, &runtime_allocate, TAG_OBJECT);
1330
+ __ jmp(&allocated);
1331
+
1332
+ __ bind(&runtime_allocate);
1333
+ __ push(rbx);
1334
+ __ Push(Smi::FromInt(size));
1335
+ __ CallRuntime(Runtime::kAllocateInNewSpace, 1);
1336
+ __ pop(rbx);
1337
+
1338
+ __ bind(&allocated);
1339
+ // Copy the content into the newly allocated memory.
1340
+ // (Unroll copy loop once for better throughput).
1341
+ for (int i = 0; i < size - kPointerSize; i += 2 * kPointerSize) {
1342
+ __ movq(rdx, FieldOperand(rbx, i));
1343
+ __ movq(rcx, FieldOperand(rbx, i + kPointerSize));
1344
+ __ movq(FieldOperand(rax, i), rdx);
1345
+ __ movq(FieldOperand(rax, i + kPointerSize), rcx);
1346
+ }
1347
+ if ((size % (2 * kPointerSize)) != 0) {
1348
+ __ movq(rdx, FieldOperand(rbx, size - kPointerSize));
1349
+ __ movq(FieldOperand(rax, size - kPointerSize), rdx);
1350
+ }
1351
+ context()->Plug(rax);
1352
+ }
1353
+
1354
+
1355
+ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
1356
+ Comment cmnt(masm_, "[ ObjectLiteral");
1357
+ __ movq(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
1358
+ __ push(FieldOperand(rdi, JSFunction::kLiteralsOffset));
1359
+ __ Push(Smi::FromInt(expr->literal_index()));
1360
+ __ Push(expr->constant_properties());
1361
+ int flags = expr->fast_elements()
1362
+ ? ObjectLiteral::kFastElements
1363
+ : ObjectLiteral::kNoFlags;
1364
+ flags |= expr->has_function()
1365
+ ? ObjectLiteral::kHasFunction
1366
+ : ObjectLiteral::kNoFlags;
1367
+ __ Push(Smi::FromInt(flags));
1368
+ if (expr->depth() > 1) {
1369
+ __ CallRuntime(Runtime::kCreateObjectLiteral, 4);
1370
+ } else {
1371
+ __ CallRuntime(Runtime::kCreateObjectLiteralShallow, 4);
1372
+ }
1373
+
1374
+ // If result_saved is true the result is on top of the stack. If
1375
+ // result_saved is false the result is in rax.
1376
+ bool result_saved = false;
1377
+
1378
+ // Mark all computed expressions that are bound to a key that
1379
+ // is shadowed by a later occurrence of the same key. For the
1380
+ // marked expressions, no store code is emitted.
1381
+ expr->CalculateEmitStore();
1382
+
1383
+ for (int i = 0; i < expr->properties()->length(); i++) {
1384
+ ObjectLiteral::Property* property = expr->properties()->at(i);
1385
+ if (property->IsCompileTimeValue()) continue;
1386
+
1387
+ Literal* key = property->key();
1388
+ Expression* value = property->value();
1389
+ if (!result_saved) {
1390
+ __ push(rax); // Save result on the stack
1391
+ result_saved = true;
1392
+ }
1393
+ switch (property->kind()) {
1394
+ case ObjectLiteral::Property::CONSTANT:
1395
+ UNREACHABLE();
1396
+ case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1397
+ ASSERT(!CompileTimeValue::IsCompileTimeValue(value));
1398
+ // Fall through.
1399
+ case ObjectLiteral::Property::COMPUTED:
1400
+ if (key->handle()->IsSymbol()) {
1401
+ VisitForAccumulatorValue(value);
1402
+ __ Move(rcx, key->handle());
1403
+ __ movq(rdx, Operand(rsp, 0));
1404
+ if (property->emit_store()) {
1405
+ Handle<Code> ic = isolate()->builtins()->StoreIC_Initialize();
1406
+ EmitCallIC(ic, RelocInfo::CODE_TARGET);
1407
+ PrepareForBailoutForId(key->id(), NO_REGISTERS);
1408
+ }
1409
+ break;
1410
+ }
1411
+ // Fall through.
1412
+ case ObjectLiteral::Property::PROTOTYPE:
1413
+ __ push(Operand(rsp, 0)); // Duplicate receiver.
1414
+ VisitForStackValue(key);
1415
+ VisitForStackValue(value);
1416
+ if (property->emit_store()) {
1417
+ __ Push(Smi::FromInt(NONE)); // PropertyAttributes
1418
+ __ CallRuntime(Runtime::kSetProperty, 4);
1419
+ } else {
1420
+ __ Drop(3);
1421
+ }
1422
+ break;
1423
+ case ObjectLiteral::Property::SETTER:
1424
+ case ObjectLiteral::Property::GETTER:
1425
+ __ push(Operand(rsp, 0)); // Duplicate receiver.
1426
+ VisitForStackValue(key);
1427
+ __ Push(property->kind() == ObjectLiteral::Property::SETTER ?
1428
+ Smi::FromInt(1) :
1429
+ Smi::FromInt(0));
1430
+ VisitForStackValue(value);
1431
+ __ CallRuntime(Runtime::kDefineAccessor, 4);
1432
+ break;
1433
+ }
1434
+ }
1435
+
1436
+ if (expr->has_function()) {
1437
+ ASSERT(result_saved);
1438
+ __ push(Operand(rsp, 0));
1439
+ __ CallRuntime(Runtime::kToFastProperties, 1);
1440
+ }
1441
+
1442
+ if (result_saved) {
1443
+ context()->PlugTOS();
1444
+ } else {
1445
+ context()->Plug(rax);
1446
+ }
1447
+ }
1448
+
1449
+
1450
+ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
1451
+ Comment cmnt(masm_, "[ ArrayLiteral");
1452
+
1453
+ ZoneList<Expression*>* subexprs = expr->values();
1454
+ int length = subexprs->length();
1455
+
1456
+ __ movq(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
1457
+ __ push(FieldOperand(rbx, JSFunction::kLiteralsOffset));
1458
+ __ Push(Smi::FromInt(expr->literal_index()));
1459
+ __ Push(expr->constant_elements());
1460
+ if (expr->constant_elements()->map() ==
1461
+ isolate()->heap()->fixed_cow_array_map()) {
1462
+ FastCloneShallowArrayStub stub(
1463
+ FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, length);
1464
+ __ CallStub(&stub);
1465
+ __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1);
1466
+ } else if (expr->depth() > 1) {
1467
+ __ CallRuntime(Runtime::kCreateArrayLiteral, 3);
1468
+ } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) {
1469
+ __ CallRuntime(Runtime::kCreateArrayLiteralShallow, 3);
1470
+ } else {
1471
+ FastCloneShallowArrayStub stub(
1472
+ FastCloneShallowArrayStub::CLONE_ELEMENTS, length);
1473
+ __ CallStub(&stub);
1474
+ }
1475
+
1476
+ bool result_saved = false; // Is the result saved to the stack?
1477
+
1478
+ // Emit code to evaluate all the non-constant subexpressions and to store
1479
+ // them into the newly cloned array.
1480
+ for (int i = 0; i < length; i++) {
1481
+ Expression* subexpr = subexprs->at(i);
1482
+ // If the subexpression is a literal or a simple materialized literal it
1483
+ // is already set in the cloned array.
1484
+ if (subexpr->AsLiteral() != NULL ||
1485
+ CompileTimeValue::IsCompileTimeValue(subexpr)) {
1486
+ continue;
1487
+ }
1488
+
1489
+ if (!result_saved) {
1490
+ __ push(rax);
1491
+ result_saved = true;
1492
+ }
1493
+ VisitForAccumulatorValue(subexpr);
1494
+
1495
+ // Store the subexpression value in the array's elements.
1496
+ __ movq(rbx, Operand(rsp, 0)); // Copy of array literal.
1497
+ __ movq(rbx, FieldOperand(rbx, JSObject::kElementsOffset));
1498
+ int offset = FixedArray::kHeaderSize + (i * kPointerSize);
1499
+ __ movq(FieldOperand(rbx, offset), result_register());
1500
+
1501
+ // Update the write barrier for the array store.
1502
+ __ RecordWrite(rbx, offset, result_register(), rcx);
1503
+
1504
+ PrepareForBailoutForId(expr->GetIdForElement(i), NO_REGISTERS);
1505
+ }
1506
+
1507
+ if (result_saved) {
1508
+ context()->PlugTOS();
1509
+ } else {
1510
+ context()->Plug(rax);
1511
+ }
1512
+ }
1513
+
1514
+
1515
+ void FullCodeGenerator::VisitAssignment(Assignment* expr) {
1516
+ Comment cmnt(masm_, "[ Assignment");
1517
+ // Invalid left-hand sides are rewritten to have a 'throw ReferenceError'
1518
+ // on the left-hand side.
1519
+ if (!expr->target()->IsValidLeftHandSide()) {
1520
+ VisitForEffect(expr->target());
1521
+ return;
1522
+ }
1523
+
1524
+ // Left-hand side can only be a property, a global or a (parameter or local)
1525
+ // slot. Variables with rewrite to .arguments are treated as KEYED_PROPERTY.
1526
+ enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY };
1527
+ LhsKind assign_type = VARIABLE;
1528
+ Property* property = expr->target()->AsProperty();
1529
+ if (property != NULL) {
1530
+ assign_type = (property->key()->IsPropertyName())
1531
+ ? NAMED_PROPERTY
1532
+ : KEYED_PROPERTY;
1533
+ }
1534
+
1535
+ // Evaluate LHS expression.
1536
+ switch (assign_type) {
1537
+ case VARIABLE:
1538
+ // Nothing to do here.
1539
+ break;
1540
+ case NAMED_PROPERTY:
1541
+ if (expr->is_compound()) {
1542
+ // We need the receiver both on the stack and in the accumulator.
1543
+ VisitForAccumulatorValue(property->obj());
1544
+ __ push(result_register());
1545
+ } else {
1546
+ VisitForStackValue(property->obj());
1547
+ }
1548
+ break;
1549
+ case KEYED_PROPERTY: {
1550
+ if (expr->is_compound()) {
1551
+ if (property->is_arguments_access()) {
1552
+ VariableProxy* obj_proxy = property->obj()->AsVariableProxy();
1553
+ MemOperand slot_operand =
1554
+ EmitSlotSearch(obj_proxy->var()->AsSlot(), rcx);
1555
+ __ push(slot_operand);
1556
+ __ Move(rax, property->key()->AsLiteral()->handle());
1557
+ } else {
1558
+ VisitForStackValue(property->obj());
1559
+ VisitForAccumulatorValue(property->key());
1560
+ }
1561
+ __ movq(rdx, Operand(rsp, 0));
1562
+ __ push(rax);
1563
+ } else {
1564
+ if (property->is_arguments_access()) {
1565
+ VariableProxy* obj_proxy = property->obj()->AsVariableProxy();
1566
+ MemOperand slot_operand =
1567
+ EmitSlotSearch(obj_proxy->var()->AsSlot(), rcx);
1568
+ __ push(slot_operand);
1569
+ __ Push(property->key()->AsLiteral()->handle());
1570
+ } else {
1571
+ VisitForStackValue(property->obj());
1572
+ VisitForStackValue(property->key());
1573
+ }
1574
+ }
1575
+ break;
1576
+ }
1577
+ }
1578
+
1579
+ // For compound assignments we need another deoptimization point after the
1580
+ // variable/property load.
1581
+ if (expr->is_compound()) {
1582
+ { AccumulatorValueContext context(this);
1583
+ switch (assign_type) {
1584
+ case VARIABLE:
1585
+ EmitVariableLoad(expr->target()->AsVariableProxy()->var());
1586
+ PrepareForBailout(expr->target(), TOS_REG);
1587
+ break;
1588
+ case NAMED_PROPERTY:
1589
+ EmitNamedPropertyLoad(property);
1590
+ PrepareForBailoutForId(expr->CompoundLoadId(), TOS_REG);
1591
+ break;
1592
+ case KEYED_PROPERTY:
1593
+ EmitKeyedPropertyLoad(property);
1594
+ PrepareForBailoutForId(expr->CompoundLoadId(), TOS_REG);
1595
+ break;
1596
+ }
1597
+ }
1598
+
1599
+ Token::Value op = expr->binary_op();
1600
+ __ push(rax); // Left operand goes on the stack.
1601
+ VisitForAccumulatorValue(expr->value());
1602
+
1603
+ OverwriteMode mode = expr->value()->ResultOverwriteAllowed()
1604
+ ? OVERWRITE_RIGHT
1605
+ : NO_OVERWRITE;
1606
+ SetSourcePosition(expr->position() + 1);
1607
+ AccumulatorValueContext context(this);
1608
+ if (ShouldInlineSmiCase(op)) {
1609
+ EmitInlineSmiBinaryOp(expr,
1610
+ op,
1611
+ mode,
1612
+ expr->target(),
1613
+ expr->value());
1614
+ } else {
1615
+ EmitBinaryOp(op, mode);
1616
+ }
1617
+ // Deoptimization point in case the binary operation may have side effects.
1618
+ PrepareForBailout(expr->binary_operation(), TOS_REG);
1619
+ } else {
1620
+ VisitForAccumulatorValue(expr->value());
1621
+ }
1622
+
1623
+ // Record source position before possible IC call.
1624
+ SetSourcePosition(expr->position());
1625
+
1626
+ // Store the value.
1627
+ switch (assign_type) {
1628
+ case VARIABLE:
1629
+ EmitVariableAssignment(expr->target()->AsVariableProxy()->var(),
1630
+ expr->op());
1631
+ PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
1632
+ context()->Plug(rax);
1633
+ break;
1634
+ case NAMED_PROPERTY:
1635
+ EmitNamedPropertyAssignment(expr);
1636
+ break;
1637
+ case KEYED_PROPERTY:
1638
+ EmitKeyedPropertyAssignment(expr);
1639
+ break;
1640
+ }
1641
+ }
1642
+
1643
+
1644
+ void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) {
1645
+ SetSourcePosition(prop->position());
1646
+ Literal* key = prop->key()->AsLiteral();
1647
+ __ Move(rcx, key->handle());
1648
+ Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
1649
+ EmitCallIC(ic, RelocInfo::CODE_TARGET);
1650
+ }
1651
+
1652
+
1653
+ void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) {
1654
+ SetSourcePosition(prop->position());
1655
+ Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize();
1656
+ EmitCallIC(ic, RelocInfo::CODE_TARGET);
1657
+ }
1658
+
1659
+
1660
+ void FullCodeGenerator::EmitInlineSmiBinaryOp(Expression* expr,
1661
+ Token::Value op,
1662
+ OverwriteMode mode,
1663
+ Expression* left,
1664
+ Expression* right) {
1665
+ // Do combined smi check of the operands. Left operand is on the
1666
+ // stack (popped into rdx). Right operand is in rax but moved into
1667
+ // rcx to make the shifts easier.
1668
+ NearLabel done, stub_call, smi_case;
1669
+ __ pop(rdx);
1670
+ __ movq(rcx, rax);
1671
+ __ or_(rax, rdx);
1672
+ JumpPatchSite patch_site(masm_);
1673
+ patch_site.EmitJumpIfSmi(rax, &smi_case);
1674
+
1675
+ __ bind(&stub_call);
1676
+ __ movq(rax, rcx);
1677
+ TypeRecordingBinaryOpStub stub(op, mode);
1678
+ EmitCallIC(stub.GetCode(), &patch_site);
1679
+ __ jmp(&done);
1680
+
1681
+ __ bind(&smi_case);
1682
+ switch (op) {
1683
+ case Token::SAR:
1684
+ __ SmiShiftArithmeticRight(rax, rdx, rcx);
1685
+ break;
1686
+ case Token::SHL:
1687
+ __ SmiShiftLeft(rax, rdx, rcx);
1688
+ break;
1689
+ case Token::SHR:
1690
+ __ SmiShiftLogicalRight(rax, rdx, rcx, &stub_call);
1691
+ break;
1692
+ case Token::ADD:
1693
+ __ SmiAdd(rax, rdx, rcx, &stub_call);
1694
+ break;
1695
+ case Token::SUB:
1696
+ __ SmiSub(rax, rdx, rcx, &stub_call);
1697
+ break;
1698
+ case Token::MUL:
1699
+ __ SmiMul(rax, rdx, rcx, &stub_call);
1700
+ break;
1701
+ case Token::BIT_OR:
1702
+ __ SmiOr(rax, rdx, rcx);
1703
+ break;
1704
+ case Token::BIT_AND:
1705
+ __ SmiAnd(rax, rdx, rcx);
1706
+ break;
1707
+ case Token::BIT_XOR:
1708
+ __ SmiXor(rax, rdx, rcx);
1709
+ break;
1710
+ default:
1711
+ UNREACHABLE();
1712
+ break;
1713
+ }
1714
+
1715
+ __ bind(&done);
1716
+ context()->Plug(rax);
1717
+ }
1718
+
1719
+
1720
+ void FullCodeGenerator::EmitBinaryOp(Token::Value op,
1721
+ OverwriteMode mode) {
1722
+ __ pop(rdx);
1723
+ TypeRecordingBinaryOpStub stub(op, mode);
1724
+ EmitCallIC(stub.GetCode(), NULL); // NULL signals no inlined smi code.
1725
+ context()->Plug(rax);
1726
+ }
1727
+
1728
+
1729
+ void FullCodeGenerator::EmitAssignment(Expression* expr, int bailout_ast_id) {
1730
+ // Invalid left-hand sides are rewritten to have a 'throw
1731
+ // ReferenceError' on the left-hand side.
1732
+ if (!expr->IsValidLeftHandSide()) {
1733
+ VisitForEffect(expr);
1734
+ return;
1735
+ }
1736
+
1737
+ // Left-hand side can only be a property, a global or a (parameter or local)
1738
+ // slot. Variables with rewrite to .arguments are treated as KEYED_PROPERTY.
1739
+ enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY };
1740
+ LhsKind assign_type = VARIABLE;
1741
+ Property* prop = expr->AsProperty();
1742
+ if (prop != NULL) {
1743
+ assign_type = (prop->key()->IsPropertyName())
1744
+ ? NAMED_PROPERTY
1745
+ : KEYED_PROPERTY;
1746
+ }
1747
+
1748
+ switch (assign_type) {
1749
+ case VARIABLE: {
1750
+ Variable* var = expr->AsVariableProxy()->var();
1751
+ EffectContext context(this);
1752
+ EmitVariableAssignment(var, Token::ASSIGN);
1753
+ break;
1754
+ }
1755
+ case NAMED_PROPERTY: {
1756
+ __ push(rax); // Preserve value.
1757
+ VisitForAccumulatorValue(prop->obj());
1758
+ __ movq(rdx, rax);
1759
+ __ pop(rax); // Restore value.
1760
+ __ Move(rcx, prop->key()->AsLiteral()->handle());
1761
+ Handle<Code> ic = is_strict_mode()
1762
+ ? isolate()->builtins()->StoreIC_Initialize_Strict()
1763
+ : isolate()->builtins()->StoreIC_Initialize();
1764
+ EmitCallIC(ic, RelocInfo::CODE_TARGET);
1765
+ break;
1766
+ }
1767
+ case KEYED_PROPERTY: {
1768
+ __ push(rax); // Preserve value.
1769
+ if (prop->is_synthetic()) {
1770
+ ASSERT(prop->obj()->AsVariableProxy() != NULL);
1771
+ ASSERT(prop->key()->AsLiteral() != NULL);
1772
+ { AccumulatorValueContext for_object(this);
1773
+ EmitVariableLoad(prop->obj()->AsVariableProxy()->var());
1774
+ }
1775
+ __ movq(rdx, rax);
1776
+ __ Move(rcx, prop->key()->AsLiteral()->handle());
1777
+ } else {
1778
+ VisitForStackValue(prop->obj());
1779
+ VisitForAccumulatorValue(prop->key());
1780
+ __ movq(rcx, rax);
1781
+ __ pop(rdx);
1782
+ }
1783
+ __ pop(rax); // Restore value.
1784
+ Handle<Code> ic = is_strict_mode()
1785
+ ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict()
1786
+ : isolate()->builtins()->KeyedStoreIC_Initialize();
1787
+ EmitCallIC(ic, RelocInfo::CODE_TARGET);
1788
+ break;
1789
+ }
1790
+ }
1791
+ PrepareForBailoutForId(bailout_ast_id, TOS_REG);
1792
+ context()->Plug(rax);
1793
+ }
1794
+
1795
+
1796
+ void FullCodeGenerator::EmitVariableAssignment(Variable* var,
1797
+ Token::Value op) {
1798
+ // Left-hand sides that rewrite to explicit property accesses do not reach
1799
+ // here.
1800
+ ASSERT(var != NULL);
1801
+ ASSERT(var->is_global() || var->AsSlot() != NULL);
1802
+
1803
+ if (var->is_global()) {
1804
+ ASSERT(!var->is_this());
1805
+ // Assignment to a global variable. Use inline caching for the
1806
+ // assignment. Right-hand-side value is passed in rax, variable name in
1807
+ // rcx, and the global object on the stack.
1808
+ __ Move(rcx, var->name());
1809
+ __ movq(rdx, GlobalObjectOperand());
1810
+ Handle<Code> ic = is_strict_mode()
1811
+ ? isolate()->builtins()->StoreIC_Initialize_Strict()
1812
+ : isolate()->builtins()->StoreIC_Initialize();
1813
+ EmitCallIC(ic, RelocInfo::CODE_TARGET_CONTEXT);
1814
+
1815
+ } else if (op == Token::INIT_CONST) {
1816
+ // Like var declarations, const declarations are hoisted to function
1817
+ // scope. However, unlike var initializers, const initializers are able
1818
+ // to drill a hole to that function context, even from inside a 'with'
1819
+ // context. We thus bypass the normal static scope lookup.
1820
+ Slot* slot = var->AsSlot();
1821
+ Label skip;
1822
+ switch (slot->type()) {
1823
+ case Slot::PARAMETER:
1824
+ // No const parameters.
1825
+ UNREACHABLE();
1826
+ break;
1827
+ case Slot::LOCAL:
1828
+ __ movq(rdx, Operand(rbp, SlotOffset(slot)));
1829
+ __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex);
1830
+ __ j(not_equal, &skip);
1831
+ __ movq(Operand(rbp, SlotOffset(slot)), rax);
1832
+ break;
1833
+ case Slot::CONTEXT: {
1834
+ __ movq(rcx, ContextOperand(rsi, Context::FCONTEXT_INDEX));
1835
+ __ movq(rdx, ContextOperand(rcx, slot->index()));
1836
+ __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex);
1837
+ __ j(not_equal, &skip);
1838
+ __ movq(ContextOperand(rcx, slot->index()), rax);
1839
+ int offset = Context::SlotOffset(slot->index());
1840
+ __ movq(rdx, rax); // Preserve the stored value in eax.
1841
+ __ RecordWrite(rcx, offset, rdx, rbx);
1842
+ break;
1843
+ }
1844
+ case Slot::LOOKUP:
1845
+ __ push(rax);
1846
+ __ push(rsi);
1847
+ __ Push(var->name());
1848
+ __ CallRuntime(Runtime::kInitializeConstContextSlot, 3);
1849
+ break;
1850
+ }
1851
+ __ bind(&skip);
1852
+
1853
+ } else if (var->mode() != Variable::CONST) {
1854
+ // Perform the assignment for non-const variables. Const assignments
1855
+ // are simply skipped.
1856
+ Slot* slot = var->AsSlot();
1857
+ switch (slot->type()) {
1858
+ case Slot::PARAMETER:
1859
+ case Slot::LOCAL:
1860
+ // Perform the assignment.
1861
+ __ movq(Operand(rbp, SlotOffset(slot)), rax);
1862
+ break;
1863
+
1864
+ case Slot::CONTEXT: {
1865
+ MemOperand target = EmitSlotSearch(slot, rcx);
1866
+ // Perform the assignment and issue the write barrier.
1867
+ __ movq(target, rax);
1868
+ // The value of the assignment is in rax. RecordWrite clobbers its
1869
+ // register arguments.
1870
+ __ movq(rdx, rax);
1871
+ int offset = Context::SlotOffset(slot->index());
1872
+ __ RecordWrite(rcx, offset, rdx, rbx);
1873
+ break;
1874
+ }
1875
+
1876
+ case Slot::LOOKUP:
1877
+ // Call the runtime for the assignment.
1878
+ __ push(rax); // Value.
1879
+ __ push(rsi); // Context.
1880
+ __ Push(var->name());
1881
+ __ Push(Smi::FromInt(strict_mode_flag()));
1882
+ __ CallRuntime(Runtime::kStoreContextSlot, 4);
1883
+ break;
1884
+ }
1885
+ }
1886
+ }
1887
+
1888
+
1889
+ void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) {
1890
+ // Assignment to a property, using a named store IC.
1891
+ Property* prop = expr->target()->AsProperty();
1892
+ ASSERT(prop != NULL);
1893
+ ASSERT(prop->key()->AsLiteral() != NULL);
1894
+
1895
+ // If the assignment starts a block of assignments to the same object,
1896
+ // change to slow case to avoid the quadratic behavior of repeatedly
1897
+ // adding fast properties.
1898
+ if (expr->starts_initialization_block()) {
1899
+ __ push(result_register());
1900
+ __ push(Operand(rsp, kPointerSize)); // Receiver is now under value.
1901
+ __ CallRuntime(Runtime::kToSlowProperties, 1);
1902
+ __ pop(result_register());
1903
+ }
1904
+
1905
+ // Record source code position before IC call.
1906
+ SetSourcePosition(expr->position());
1907
+ __ Move(rcx, prop->key()->AsLiteral()->handle());
1908
+ if (expr->ends_initialization_block()) {
1909
+ __ movq(rdx, Operand(rsp, 0));
1910
+ } else {
1911
+ __ pop(rdx);
1912
+ }
1913
+ Handle<Code> ic = is_strict_mode()
1914
+ ? isolate()->builtins()->StoreIC_Initialize_Strict()
1915
+ : isolate()->builtins()->StoreIC_Initialize();
1916
+ EmitCallIC(ic, RelocInfo::CODE_TARGET);
1917
+
1918
+ // If the assignment ends an initialization block, revert to fast case.
1919
+ if (expr->ends_initialization_block()) {
1920
+ __ push(rax); // Result of assignment, saved even if not needed.
1921
+ __ push(Operand(rsp, kPointerSize)); // Receiver is under value.
1922
+ __ CallRuntime(Runtime::kToFastProperties, 1);
1923
+ __ pop(rax);
1924
+ __ Drop(1);
1925
+ }
1926
+ PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
1927
+ context()->Plug(rax);
1928
+ }
1929
+
1930
+
1931
+ void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) {
1932
+ // Assignment to a property, using a keyed store IC.
1933
+
1934
+ // If the assignment starts a block of assignments to the same object,
1935
+ // change to slow case to avoid the quadratic behavior of repeatedly
1936
+ // adding fast properties.
1937
+ if (expr->starts_initialization_block()) {
1938
+ __ push(result_register());
1939
+ // Receiver is now under the key and value.
1940
+ __ push(Operand(rsp, 2 * kPointerSize));
1941
+ __ CallRuntime(Runtime::kToSlowProperties, 1);
1942
+ __ pop(result_register());
1943
+ }
1944
+
1945
+ __ pop(rcx);
1946
+ if (expr->ends_initialization_block()) {
1947
+ __ movq(rdx, Operand(rsp, 0)); // Leave receiver on the stack for later.
1948
+ } else {
1949
+ __ pop(rdx);
1950
+ }
1951
+ // Record source code position before IC call.
1952
+ SetSourcePosition(expr->position());
1953
+ Handle<Code> ic = is_strict_mode()
1954
+ ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict()
1955
+ : isolate()->builtins()->KeyedStoreIC_Initialize();
1956
+ EmitCallIC(ic, RelocInfo::CODE_TARGET);
1957
+
1958
+ // If the assignment ends an initialization block, revert to fast case.
1959
+ if (expr->ends_initialization_block()) {
1960
+ __ pop(rdx);
1961
+ __ push(rax); // Result of assignment, saved even if not needed.
1962
+ __ push(rdx);
1963
+ __ CallRuntime(Runtime::kToFastProperties, 1);
1964
+ __ pop(rax);
1965
+ }
1966
+
1967
+ PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
1968
+ context()->Plug(rax);
1969
+ }
1970
+
1971
+
1972
+ void FullCodeGenerator::VisitProperty(Property* expr) {
1973
+ Comment cmnt(masm_, "[ Property");
1974
+ Expression* key = expr->key();
1975
+
1976
+ if (key->IsPropertyName()) {
1977
+ VisitForAccumulatorValue(expr->obj());
1978
+ EmitNamedPropertyLoad(expr);
1979
+ context()->Plug(rax);
1980
+ } else {
1981
+ VisitForStackValue(expr->obj());
1982
+ VisitForAccumulatorValue(expr->key());
1983
+ __ pop(rdx);
1984
+ EmitKeyedPropertyLoad(expr);
1985
+ context()->Plug(rax);
1986
+ }
1987
+ }
1988
+
1989
+
1990
+ void FullCodeGenerator::EmitCallWithIC(Call* expr,
1991
+ Handle<Object> name,
1992
+ RelocInfo::Mode mode) {
1993
+ // Code common for calls using the IC.
1994
+ ZoneList<Expression*>* args = expr->arguments();
1995
+ int arg_count = args->length();
1996
+ { PreservePositionScope scope(masm()->positions_recorder());
1997
+ for (int i = 0; i < arg_count; i++) {
1998
+ VisitForStackValue(args->at(i));
1999
+ }
2000
+ __ Move(rcx, name);
2001
+ }
2002
+ // Record source position for debugger.
2003
+ SetSourcePosition(expr->position());
2004
+ // Call the IC initialization code.
2005
+ InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP;
2006
+ Handle<Code> ic =
2007
+ ISOLATE->stub_cache()->ComputeCallInitialize(arg_count, in_loop);
2008
+ EmitCallIC(ic, mode);
2009
+ RecordJSReturnSite(expr);
2010
+ // Restore context register.
2011
+ __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
2012
+ context()->Plug(rax);
2013
+ }
2014
+
2015
+
2016
+ void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr,
2017
+ Expression* key,
2018
+ RelocInfo::Mode mode) {
2019
+ // Load the key.
2020
+ VisitForAccumulatorValue(key);
2021
+
2022
+ // Swap the name of the function and the receiver on the stack to follow
2023
+ // the calling convention for call ICs.
2024
+ __ pop(rcx);
2025
+ __ push(rax);
2026
+ __ push(rcx);
2027
+
2028
+ // Load the arguments.
2029
+ ZoneList<Expression*>* args = expr->arguments();
2030
+ int arg_count = args->length();
2031
+ { PreservePositionScope scope(masm()->positions_recorder());
2032
+ for (int i = 0; i < arg_count; i++) {
2033
+ VisitForStackValue(args->at(i));
2034
+ }
2035
+ }
2036
+ // Record source position for debugger.
2037
+ SetSourcePosition(expr->position());
2038
+ // Call the IC initialization code.
2039
+ InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP;
2040
+ Handle<Code> ic =
2041
+ ISOLATE->stub_cache()->ComputeKeyedCallInitialize(arg_count, in_loop);
2042
+ __ movq(rcx, Operand(rsp, (arg_count + 1) * kPointerSize)); // Key.
2043
+ EmitCallIC(ic, mode);
2044
+ RecordJSReturnSite(expr);
2045
+ // Restore context register.
2046
+ __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
2047
+ context()->DropAndPlug(1, rax); // Drop the key still on the stack.
2048
+ }
2049
+
2050
+
2051
+ void FullCodeGenerator::EmitCallWithStub(Call* expr) {
2052
+ // Code common for calls using the call stub.
2053
+ ZoneList<Expression*>* args = expr->arguments();
2054
+ int arg_count = args->length();
2055
+ { PreservePositionScope scope(masm()->positions_recorder());
2056
+ for (int i = 0; i < arg_count; i++) {
2057
+ VisitForStackValue(args->at(i));
2058
+ }
2059
+ }
2060
+ // Record source position for debugger.
2061
+ SetSourcePosition(expr->position());
2062
+ InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP;
2063
+ CallFunctionStub stub(arg_count, in_loop, RECEIVER_MIGHT_BE_VALUE);
2064
+ __ CallStub(&stub);
2065
+ RecordJSReturnSite(expr);
2066
+ // Restore context register.
2067
+ __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
2068
+ // Discard the function left on TOS.
2069
+ context()->DropAndPlug(1, rax);
2070
+ }
2071
+
2072
+
2073
+ void FullCodeGenerator::EmitResolvePossiblyDirectEval(ResolveEvalFlag flag,
2074
+ int arg_count) {
2075
+ // Push copy of the first argument or undefined if it doesn't exist.
2076
+ if (arg_count > 0) {
2077
+ __ push(Operand(rsp, arg_count * kPointerSize));
2078
+ } else {
2079
+ __ PushRoot(Heap::kUndefinedValueRootIndex);
2080
+ }
2081
+
2082
+ // Push the receiver of the enclosing function and do runtime call.
2083
+ __ push(Operand(rbp, (2 + scope()->num_parameters()) * kPointerSize));
2084
+
2085
+ // Push the strict mode flag.
2086
+ __ Push(Smi::FromInt(strict_mode_flag()));
2087
+
2088
+ __ CallRuntime(flag == SKIP_CONTEXT_LOOKUP
2089
+ ? Runtime::kResolvePossiblyDirectEvalNoLookup
2090
+ : Runtime::kResolvePossiblyDirectEval, 4);
2091
+ }
2092
+
2093
+
2094
+ void FullCodeGenerator::VisitCall(Call* expr) {
2095
+ #ifdef DEBUG
2096
+ // We want to verify that RecordJSReturnSite gets called on all paths
2097
+ // through this function. Avoid early returns.
2098
+ expr->return_is_recorded_ = false;
2099
+ #endif
2100
+
2101
+ Comment cmnt(masm_, "[ Call");
2102
+ Expression* fun = expr->expression();
2103
+ Variable* var = fun->AsVariableProxy()->AsVariable();
2104
+
2105
+ if (var != NULL && var->is_possibly_eval()) {
2106
+ // In a call to eval, we first call %ResolvePossiblyDirectEval to
2107
+ // resolve the function we need to call and the receiver of the
2108
+ // call. Then we call the resolved function using the given
2109
+ // arguments.
2110
+ ZoneList<Expression*>* args = expr->arguments();
2111
+ int arg_count = args->length();
2112
+ { PreservePositionScope pos_scope(masm()->positions_recorder());
2113
+ VisitForStackValue(fun);
2114
+ __ PushRoot(Heap::kUndefinedValueRootIndex); // Reserved receiver slot.
2115
+
2116
+ // Push the arguments.
2117
+ for (int i = 0; i < arg_count; i++) {
2118
+ VisitForStackValue(args->at(i));
2119
+ }
2120
+
2121
+ // If we know that eval can only be shadowed by eval-introduced
2122
+ // variables we attempt to load the global eval function directly
2123
+ // in generated code. If we succeed, there is no need to perform a
2124
+ // context lookup in the runtime system.
2125
+ Label done;
2126
+ if (var->AsSlot() != NULL && var->mode() == Variable::DYNAMIC_GLOBAL) {
2127
+ Label slow;
2128
+ EmitLoadGlobalSlotCheckExtensions(var->AsSlot(),
2129
+ NOT_INSIDE_TYPEOF,
2130
+ &slow);
2131
+ // Push the function and resolve eval.
2132
+ __ push(rax);
2133
+ EmitResolvePossiblyDirectEval(SKIP_CONTEXT_LOOKUP, arg_count);
2134
+ __ jmp(&done);
2135
+ __ bind(&slow);
2136
+ }
2137
+
2138
+ // Push copy of the function (found below the arguments) and
2139
+ // resolve eval.
2140
+ __ push(Operand(rsp, (arg_count + 1) * kPointerSize));
2141
+ EmitResolvePossiblyDirectEval(PERFORM_CONTEXT_LOOKUP, arg_count);
2142
+ if (done.is_linked()) {
2143
+ __ bind(&done);
2144
+ }
2145
+
2146
+ // The runtime call returns a pair of values in rax (function) and
2147
+ // rdx (receiver). Touch up the stack with the right values.
2148
+ __ movq(Operand(rsp, (arg_count + 0) * kPointerSize), rdx);
2149
+ __ movq(Operand(rsp, (arg_count + 1) * kPointerSize), rax);
2150
+ }
2151
+ // Record source position for debugger.
2152
+ SetSourcePosition(expr->position());
2153
+ InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP;
2154
+ CallFunctionStub stub(arg_count, in_loop, RECEIVER_MIGHT_BE_VALUE);
2155
+ __ CallStub(&stub);
2156
+ RecordJSReturnSite(expr);
2157
+ // Restore context register.
2158
+ __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
2159
+ context()->DropAndPlug(1, rax);
2160
+ } else if (var != NULL && !var->is_this() && var->is_global()) {
2161
+ // Call to a global variable.
2162
+ // Push global object as receiver for the call IC lookup.
2163
+ __ push(GlobalObjectOperand());
2164
+ EmitCallWithIC(expr, var->name(), RelocInfo::CODE_TARGET_CONTEXT);
2165
+ } else if (var != NULL && var->AsSlot() != NULL &&
2166
+ var->AsSlot()->type() == Slot::LOOKUP) {
2167
+ // Call to a lookup slot (dynamically introduced variable).
2168
+ Label slow, done;
2169
+
2170
+ { PreservePositionScope scope(masm()->positions_recorder());
2171
+ // Generate code for loading from variables potentially shadowed
2172
+ // by eval-introduced variables.
2173
+ EmitDynamicLoadFromSlotFastCase(var->AsSlot(),
2174
+ NOT_INSIDE_TYPEOF,
2175
+ &slow,
2176
+ &done);
2177
+
2178
+ __ bind(&slow);
2179
+ }
2180
+ // Call the runtime to find the function to call (returned in rax)
2181
+ // and the object holding it (returned in rdx).
2182
+ __ push(context_register());
2183
+ __ Push(var->name());
2184
+ __ CallRuntime(Runtime::kLoadContextSlot, 2);
2185
+ __ push(rax); // Function.
2186
+ __ push(rdx); // Receiver.
2187
+
2188
+ // If fast case code has been generated, emit code to push the
2189
+ // function and receiver and have the slow path jump around this
2190
+ // code.
2191
+ if (done.is_linked()) {
2192
+ NearLabel call;
2193
+ __ jmp(&call);
2194
+ __ bind(&done);
2195
+ // Push function.
2196
+ __ push(rax);
2197
+ // Push global receiver.
2198
+ __ movq(rbx, GlobalObjectOperand());
2199
+ __ push(FieldOperand(rbx, GlobalObject::kGlobalReceiverOffset));
2200
+ __ bind(&call);
2201
+ }
2202
+
2203
+ EmitCallWithStub(expr);
2204
+ } else if (fun->AsProperty() != NULL) {
2205
+ // Call to an object property.
2206
+ Property* prop = fun->AsProperty();
2207
+ Literal* key = prop->key()->AsLiteral();
2208
+ if (key != NULL && key->handle()->IsSymbol()) {
2209
+ // Call to a named property, use call IC.
2210
+ { PreservePositionScope scope(masm()->positions_recorder());
2211
+ VisitForStackValue(prop->obj());
2212
+ }
2213
+ EmitCallWithIC(expr, key->handle(), RelocInfo::CODE_TARGET);
2214
+ } else {
2215
+ // Call to a keyed property.
2216
+ // For a synthetic property use keyed load IC followed by function call,
2217
+ // for a regular property use keyed EmitCallIC.
2218
+ if (prop->is_synthetic()) {
2219
+ // Do not visit the object and key subexpressions (they are shared
2220
+ // by all occurrences of the same rewritten parameter).
2221
+ ASSERT(prop->obj()->AsVariableProxy() != NULL);
2222
+ ASSERT(prop->obj()->AsVariableProxy()->var()->AsSlot() != NULL);
2223
+ Slot* slot = prop->obj()->AsVariableProxy()->var()->AsSlot();
2224
+ MemOperand operand = EmitSlotSearch(slot, rdx);
2225
+ __ movq(rdx, operand);
2226
+
2227
+ ASSERT(prop->key()->AsLiteral() != NULL);
2228
+ ASSERT(prop->key()->AsLiteral()->handle()->IsSmi());
2229
+ __ Move(rax, prop->key()->AsLiteral()->handle());
2230
+
2231
+ // Record source code position for IC call.
2232
+ SetSourcePosition(prop->position());
2233
+
2234
+ Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize();
2235
+ EmitCallIC(ic, RelocInfo::CODE_TARGET);
2236
+ // Push result (function).
2237
+ __ push(rax);
2238
+ // Push Global receiver.
2239
+ __ movq(rcx, GlobalObjectOperand());
2240
+ __ push(FieldOperand(rcx, GlobalObject::kGlobalReceiverOffset));
2241
+ EmitCallWithStub(expr);
2242
+ } else {
2243
+ { PreservePositionScope scope(masm()->positions_recorder());
2244
+ VisitForStackValue(prop->obj());
2245
+ }
2246
+ EmitKeyedCallWithIC(expr, prop->key(), RelocInfo::CODE_TARGET);
2247
+ }
2248
+ }
2249
+ } else {
2250
+ { PreservePositionScope scope(masm()->positions_recorder());
2251
+ VisitForStackValue(fun);
2252
+ }
2253
+ // Load global receiver object.
2254
+ __ movq(rbx, GlobalObjectOperand());
2255
+ __ push(FieldOperand(rbx, GlobalObject::kGlobalReceiverOffset));
2256
+ // Emit function call.
2257
+ EmitCallWithStub(expr);
2258
+ }
2259
+
2260
+ #ifdef DEBUG
2261
+ // RecordJSReturnSite should have been called.
2262
+ ASSERT(expr->return_is_recorded_);
2263
+ #endif
2264
+ }
2265
+
2266
+
2267
+ void FullCodeGenerator::VisitCallNew(CallNew* expr) {
2268
+ Comment cmnt(masm_, "[ CallNew");
2269
+ // According to ECMA-262, section 11.2.2, page 44, the function
2270
+ // expression in new calls must be evaluated before the
2271
+ // arguments.
2272
+
2273
+ // Push constructor on the stack. If it's not a function it's used as
2274
+ // receiver for CALL_NON_FUNCTION, otherwise the value on the stack is
2275
+ // ignored.
2276
+ VisitForStackValue(expr->expression());
2277
+
2278
+ // Push the arguments ("left-to-right") on the stack.
2279
+ ZoneList<Expression*>* args = expr->arguments();
2280
+ int arg_count = args->length();
2281
+ for (int i = 0; i < arg_count; i++) {
2282
+ VisitForStackValue(args->at(i));
2283
+ }
2284
+
2285
+ // Call the construct call builtin that handles allocation and
2286
+ // constructor invocation.
2287
+ SetSourcePosition(expr->position());
2288
+
2289
+ // Load function and argument count into rdi and rax.
2290
+ __ Set(rax, arg_count);
2291
+ __ movq(rdi, Operand(rsp, arg_count * kPointerSize));
2292
+
2293
+ Handle<Code> construct_builtin =
2294
+ isolate()->builtins()->JSConstructCall();
2295
+ __ Call(construct_builtin, RelocInfo::CONSTRUCT_CALL);
2296
+ context()->Plug(rax);
2297
+ }
2298
+
2299
+
2300
+ void FullCodeGenerator::EmitIsSmi(ZoneList<Expression*>* args) {
2301
+ ASSERT(args->length() == 1);
2302
+
2303
+ VisitForAccumulatorValue(args->at(0));
2304
+
2305
+ Label materialize_true, materialize_false;
2306
+ Label* if_true = NULL;
2307
+ Label* if_false = NULL;
2308
+ Label* fall_through = NULL;
2309
+ context()->PrepareTest(&materialize_true, &materialize_false,
2310
+ &if_true, &if_false, &fall_through);
2311
+
2312
+ PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
2313
+ __ JumpIfSmi(rax, if_true);
2314
+ __ jmp(if_false);
2315
+
2316
+ context()->Plug(if_true, if_false);
2317
+ }
2318
+
2319
+
2320
+ void FullCodeGenerator::EmitIsNonNegativeSmi(ZoneList<Expression*>* args) {
2321
+ ASSERT(args->length() == 1);
2322
+
2323
+ VisitForAccumulatorValue(args->at(0));
2324
+
2325
+ Label materialize_true, materialize_false;
2326
+ Label* if_true = NULL;
2327
+ Label* if_false = NULL;
2328
+ Label* fall_through = NULL;
2329
+ context()->PrepareTest(&materialize_true, &materialize_false,
2330
+ &if_true, &if_false, &fall_through);
2331
+
2332
+ PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
2333
+ Condition non_negative_smi = masm()->CheckNonNegativeSmi(rax);
2334
+ Split(non_negative_smi, if_true, if_false, fall_through);
2335
+
2336
+ context()->Plug(if_true, if_false);
2337
+ }
2338
+
2339
+
2340
+ void FullCodeGenerator::EmitIsObject(ZoneList<Expression*>* args) {
2341
+ ASSERT(args->length() == 1);
2342
+
2343
+ VisitForAccumulatorValue(args->at(0));
2344
+
2345
+ Label materialize_true, materialize_false;
2346
+ Label* if_true = NULL;
2347
+ Label* if_false = NULL;
2348
+ Label* fall_through = NULL;
2349
+ context()->PrepareTest(&materialize_true, &materialize_false,
2350
+ &if_true, &if_false, &fall_through);
2351
+
2352
+ __ JumpIfSmi(rax, if_false);
2353
+ __ CompareRoot(rax, Heap::kNullValueRootIndex);
2354
+ __ j(equal, if_true);
2355
+ __ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset));
2356
+ // Undetectable objects behave like undefined when tested with typeof.
2357
+ __ testb(FieldOperand(rbx, Map::kBitFieldOffset),
2358
+ Immediate(1 << Map::kIsUndetectable));
2359
+ __ j(not_zero, if_false);
2360
+ __ movzxbq(rbx, FieldOperand(rbx, Map::kInstanceTypeOffset));
2361
+ __ cmpq(rbx, Immediate(FIRST_JS_OBJECT_TYPE));
2362
+ __ j(below, if_false);
2363
+ __ cmpq(rbx, Immediate(LAST_JS_OBJECT_TYPE));
2364
+ PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
2365
+ Split(below_equal, if_true, if_false, fall_through);
2366
+
2367
+ context()->Plug(if_true, if_false);
2368
+ }
2369
+
2370
+
2371
+ void FullCodeGenerator::EmitIsSpecObject(ZoneList<Expression*>* args) {
2372
+ ASSERT(args->length() == 1);
2373
+
2374
+ VisitForAccumulatorValue(args->at(0));
2375
+
2376
+ Label materialize_true, materialize_false;
2377
+ Label* if_true = NULL;
2378
+ Label* if_false = NULL;
2379
+ Label* fall_through = NULL;
2380
+ context()->PrepareTest(&materialize_true, &materialize_false,
2381
+ &if_true, &if_false, &fall_through);
2382
+
2383
+ __ JumpIfSmi(rax, if_false);
2384
+ __ CmpObjectType(rax, FIRST_JS_OBJECT_TYPE, rbx);
2385
+ PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
2386
+ Split(above_equal, if_true, if_false, fall_through);
2387
+
2388
+ context()->Plug(if_true, if_false);
2389
+ }
2390
+
2391
+
2392
+ void FullCodeGenerator::EmitIsUndetectableObject(ZoneList<Expression*>* args) {
2393
+ ASSERT(args->length() == 1);
2394
+
2395
+ VisitForAccumulatorValue(args->at(0));
2396
+
2397
+ Label materialize_true, materialize_false;
2398
+ Label* if_true = NULL;
2399
+ Label* if_false = NULL;
2400
+ Label* fall_through = NULL;
2401
+ context()->PrepareTest(&materialize_true, &materialize_false,
2402
+ &if_true, &if_false, &fall_through);
2403
+
2404
+ __ JumpIfSmi(rax, if_false);
2405
+ __ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset));
2406
+ __ testb(FieldOperand(rbx, Map::kBitFieldOffset),
2407
+ Immediate(1 << Map::kIsUndetectable));
2408
+ PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
2409
+ Split(not_zero, if_true, if_false, fall_through);
2410
+
2411
+ context()->Plug(if_true, if_false);
2412
+ }
2413
+
2414
+
2415
+ void FullCodeGenerator::EmitIsStringWrapperSafeForDefaultValueOf(
2416
+ ZoneList<Expression*>* args) {
2417
+ ASSERT(args->length() == 1);
2418
+
2419
+ VisitForAccumulatorValue(args->at(0));
2420
+
2421
+ Label materialize_true, materialize_false;
2422
+ Label* if_true = NULL;
2423
+ Label* if_false = NULL;
2424
+ Label* fall_through = NULL;
2425
+ context()->PrepareTest(&materialize_true, &materialize_false,
2426
+ &if_true, &if_false, &fall_through);
2427
+
2428
+ if (FLAG_debug_code) __ AbortIfSmi(rax);
2429
+
2430
+ // Check whether this map has already been checked to be safe for default
2431
+ // valueOf.
2432
+ __ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset));
2433
+ __ testb(FieldOperand(rbx, Map::kBitField2Offset),
2434
+ Immediate(1 << Map::kStringWrapperSafeForDefaultValueOf));
2435
+ __ j(not_zero, if_true);
2436
+
2437
+ // Check for fast case object. Generate false result for slow case object.
2438
+ __ movq(rcx, FieldOperand(rax, JSObject::kPropertiesOffset));
2439
+ __ movq(rcx, FieldOperand(rcx, HeapObject::kMapOffset));
2440
+ __ CompareRoot(rcx, Heap::kHashTableMapRootIndex);
2441
+ __ j(equal, if_false);
2442
+
2443
+ // Look for valueOf symbol in the descriptor array, and indicate false if
2444
+ // found. The type is not checked, so if it is a transition it is a false
2445
+ // negative.
2446
+ __ movq(rbx, FieldOperand(rbx, Map::kInstanceDescriptorsOffset));
2447
+ __ movq(rcx, FieldOperand(rbx, FixedArray::kLengthOffset));
2448
+ // rbx: descriptor array
2449
+ // rcx: length of descriptor array
2450
+ // Calculate the end of the descriptor array.
2451
+ SmiIndex index = masm_->SmiToIndex(rdx, rcx, kPointerSizeLog2);
2452
+ __ lea(rcx,
2453
+ Operand(
2454
+ rbx, index.reg, index.scale, FixedArray::kHeaderSize));
2455
+ // Calculate location of the first key name.
2456
+ __ addq(rbx,
2457
+ Immediate(FixedArray::kHeaderSize +
2458
+ DescriptorArray::kFirstIndex * kPointerSize));
2459
+ // Loop through all the keys in the descriptor array. If one of these is the
2460
+ // symbol valueOf the result is false.
2461
+ Label entry, loop;
2462
+ __ jmp(&entry);
2463
+ __ bind(&loop);
2464
+ __ movq(rdx, FieldOperand(rbx, 0));
2465
+ __ Cmp(rdx, FACTORY->value_of_symbol());
2466
+ __ j(equal, if_false);
2467
+ __ addq(rbx, Immediate(kPointerSize));
2468
+ __ bind(&entry);
2469
+ __ cmpq(rbx, rcx);
2470
+ __ j(not_equal, &loop);
2471
+
2472
+ // Reload map as register rbx was used as temporary above.
2473
+ __ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset));
2474
+
2475
+ // If a valueOf property is not found on the object check that it's
2476
+ // prototype is the un-modified String prototype. If not result is false.
2477
+ __ movq(rcx, FieldOperand(rbx, Map::kPrototypeOffset));
2478
+ __ testq(rcx, Immediate(kSmiTagMask));
2479
+ __ j(zero, if_false);
2480
+ __ movq(rcx, FieldOperand(rcx, HeapObject::kMapOffset));
2481
+ __ movq(rdx, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX)));
2482
+ __ movq(rdx, FieldOperand(rdx, GlobalObject::kGlobalContextOffset));
2483
+ __ cmpq(rcx,
2484
+ ContextOperand(rdx, Context::STRING_FUNCTION_PROTOTYPE_MAP_INDEX));
2485
+ __ j(not_equal, if_false);
2486
+ // Set the bit in the map to indicate that it has been checked safe for
2487
+ // default valueOf and set true result.
2488
+ __ or_(FieldOperand(rbx, Map::kBitField2Offset),
2489
+ Immediate(1 << Map::kStringWrapperSafeForDefaultValueOf));
2490
+ __ jmp(if_true);
2491
+
2492
+ PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
2493
+ context()->Plug(if_true, if_false);
2494
+ }
2495
+
2496
+
2497
+ void FullCodeGenerator::EmitIsFunction(ZoneList<Expression*>* args) {
2498
+ ASSERT(args->length() == 1);
2499
+
2500
+ VisitForAccumulatorValue(args->at(0));
2501
+
2502
+ Label materialize_true, materialize_false;
2503
+ Label* if_true = NULL;
2504
+ Label* if_false = NULL;
2505
+ Label* fall_through = NULL;
2506
+ context()->PrepareTest(&materialize_true, &materialize_false,
2507
+ &if_true, &if_false, &fall_through);
2508
+
2509
+ __ JumpIfSmi(rax, if_false);
2510
+ __ CmpObjectType(rax, JS_FUNCTION_TYPE, rbx);
2511
+ PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
2512
+ Split(equal, if_true, if_false, fall_through);
2513
+
2514
+ context()->Plug(if_true, if_false);
2515
+ }
2516
+
2517
+
2518
+ void FullCodeGenerator::EmitIsArray(ZoneList<Expression*>* args) {
2519
+ ASSERT(args->length() == 1);
2520
+
2521
+ VisitForAccumulatorValue(args->at(0));
2522
+
2523
+ Label materialize_true, materialize_false;
2524
+ Label* if_true = NULL;
2525
+ Label* if_false = NULL;
2526
+ Label* fall_through = NULL;
2527
+ context()->PrepareTest(&materialize_true, &materialize_false,
2528
+ &if_true, &if_false, &fall_through);
2529
+
2530
+ __ JumpIfSmi(rax, if_false);
2531
+ __ CmpObjectType(rax, JS_ARRAY_TYPE, rbx);
2532
+ PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
2533
+ Split(equal, if_true, if_false, fall_through);
2534
+
2535
+ context()->Plug(if_true, if_false);
2536
+ }
2537
+
2538
+
2539
+ void FullCodeGenerator::EmitIsRegExp(ZoneList<Expression*>* args) {
2540
+ ASSERT(args->length() == 1);
2541
+
2542
+ VisitForAccumulatorValue(args->at(0));
2543
+
2544
+ Label materialize_true, materialize_false;
2545
+ Label* if_true = NULL;
2546
+ Label* if_false = NULL;
2547
+ Label* fall_through = NULL;
2548
+ context()->PrepareTest(&materialize_true, &materialize_false,
2549
+ &if_true, &if_false, &fall_through);
2550
+
2551
+ __ JumpIfSmi(rax, if_false);
2552
+ __ CmpObjectType(rax, JS_REGEXP_TYPE, rbx);
2553
+ PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
2554
+ Split(equal, if_true, if_false, fall_through);
2555
+
2556
+ context()->Plug(if_true, if_false);
2557
+ }
2558
+
2559
+
2560
+
2561
+ void FullCodeGenerator::EmitIsConstructCall(ZoneList<Expression*>* args) {
2562
+ ASSERT(args->length() == 0);
2563
+
2564
+ Label materialize_true, materialize_false;
2565
+ Label* if_true = NULL;
2566
+ Label* if_false = NULL;
2567
+ Label* fall_through = NULL;
2568
+ context()->PrepareTest(&materialize_true, &materialize_false,
2569
+ &if_true, &if_false, &fall_through);
2570
+
2571
+ // Get the frame pointer for the calling frame.
2572
+ __ movq(rax, Operand(rbp, StandardFrameConstants::kCallerFPOffset));
2573
+
2574
+ // Skip the arguments adaptor frame if it exists.
2575
+ Label check_frame_marker;
2576
+ __ Cmp(Operand(rax, StandardFrameConstants::kContextOffset),
2577
+ Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
2578
+ __ j(not_equal, &check_frame_marker);
2579
+ __ movq(rax, Operand(rax, StandardFrameConstants::kCallerFPOffset));
2580
+
2581
+ // Check the marker in the calling frame.
2582
+ __ bind(&check_frame_marker);
2583
+ __ Cmp(Operand(rax, StandardFrameConstants::kMarkerOffset),
2584
+ Smi::FromInt(StackFrame::CONSTRUCT));
2585
+ PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
2586
+ Split(equal, if_true, if_false, fall_through);
2587
+
2588
+ context()->Plug(if_true, if_false);
2589
+ }
2590
+
2591
+
2592
+ void FullCodeGenerator::EmitObjectEquals(ZoneList<Expression*>* args) {
2593
+ ASSERT(args->length() == 2);
2594
+
2595
+ // Load the two objects into registers and perform the comparison.
2596
+ VisitForStackValue(args->at(0));
2597
+ VisitForAccumulatorValue(args->at(1));
2598
+
2599
+ Label materialize_true, materialize_false;
2600
+ Label* if_true = NULL;
2601
+ Label* if_false = NULL;
2602
+ Label* fall_through = NULL;
2603
+ context()->PrepareTest(&materialize_true, &materialize_false,
2604
+ &if_true, &if_false, &fall_through);
2605
+
2606
+ __ pop(rbx);
2607
+ __ cmpq(rax, rbx);
2608
+ PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
2609
+ Split(equal, if_true, if_false, fall_through);
2610
+
2611
+ context()->Plug(if_true, if_false);
2612
+ }
2613
+
2614
+
2615
+ void FullCodeGenerator::EmitArguments(ZoneList<Expression*>* args) {
2616
+ ASSERT(args->length() == 1);
2617
+
2618
+ // ArgumentsAccessStub expects the key in rdx and the formal
2619
+ // parameter count in rax.
2620
+ VisitForAccumulatorValue(args->at(0));
2621
+ __ movq(rdx, rax);
2622
+ __ Move(rax, Smi::FromInt(scope()->num_parameters()));
2623
+ ArgumentsAccessStub stub(ArgumentsAccessStub::READ_ELEMENT);
2624
+ __ CallStub(&stub);
2625
+ context()->Plug(rax);
2626
+ }
2627
+
2628
+
2629
+ void FullCodeGenerator::EmitArgumentsLength(ZoneList<Expression*>* args) {
2630
+ ASSERT(args->length() == 0);
2631
+
2632
+ NearLabel exit;
2633
+ // Get the number of formal parameters.
2634
+ __ Move(rax, Smi::FromInt(scope()->num_parameters()));
2635
+
2636
+ // Check if the calling frame is an arguments adaptor frame.
2637
+ __ movq(rbx, Operand(rbp, StandardFrameConstants::kCallerFPOffset));
2638
+ __ Cmp(Operand(rbx, StandardFrameConstants::kContextOffset),
2639
+ Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
2640
+ __ j(not_equal, &exit);
2641
+
2642
+ // Arguments adaptor case: Read the arguments length from the
2643
+ // adaptor frame.
2644
+ __ movq(rax, Operand(rbx, ArgumentsAdaptorFrameConstants::kLengthOffset));
2645
+
2646
+ __ bind(&exit);
2647
+ if (FLAG_debug_code) __ AbortIfNotSmi(rax);
2648
+ context()->Plug(rax);
2649
+ }
2650
+
2651
+
2652
+ void FullCodeGenerator::EmitClassOf(ZoneList<Expression*>* args) {
2653
+ ASSERT(args->length() == 1);
2654
+ Label done, null, function, non_function_constructor;
2655
+
2656
+ VisitForAccumulatorValue(args->at(0));
2657
+
2658
+ // If the object is a smi, we return null.
2659
+ __ JumpIfSmi(rax, &null);
2660
+
2661
+ // Check that the object is a JS object but take special care of JS
2662
+ // functions to make sure they have 'Function' as their class.
2663
+ __ CmpObjectType(rax, FIRST_JS_OBJECT_TYPE, rax); // Map is now in rax.
2664
+ __ j(below, &null);
2665
+
2666
+ // As long as JS_FUNCTION_TYPE is the last instance type and it is
2667
+ // right after LAST_JS_OBJECT_TYPE, we can avoid checking for
2668
+ // LAST_JS_OBJECT_TYPE.
2669
+ ASSERT(LAST_TYPE == JS_FUNCTION_TYPE);
2670
+ ASSERT(JS_FUNCTION_TYPE == LAST_JS_OBJECT_TYPE + 1);
2671
+ __ CmpInstanceType(rax, JS_FUNCTION_TYPE);
2672
+ __ j(equal, &function);
2673
+
2674
+ // Check if the constructor in the map is a function.
2675
+ __ movq(rax, FieldOperand(rax, Map::kConstructorOffset));
2676
+ __ CmpObjectType(rax, JS_FUNCTION_TYPE, rbx);
2677
+ __ j(not_equal, &non_function_constructor);
2678
+
2679
+ // rax now contains the constructor function. Grab the
2680
+ // instance class name from there.
2681
+ __ movq(rax, FieldOperand(rax, JSFunction::kSharedFunctionInfoOffset));
2682
+ __ movq(rax, FieldOperand(rax, SharedFunctionInfo::kInstanceClassNameOffset));
2683
+ __ jmp(&done);
2684
+
2685
+ // Functions have class 'Function'.
2686
+ __ bind(&function);
2687
+ __ Move(rax, isolate()->factory()->function_class_symbol());
2688
+ __ jmp(&done);
2689
+
2690
+ // Objects with a non-function constructor have class 'Object'.
2691
+ __ bind(&non_function_constructor);
2692
+ __ Move(rax, isolate()->factory()->Object_symbol());
2693
+ __ jmp(&done);
2694
+
2695
+ // Non-JS objects have class null.
2696
+ __ bind(&null);
2697
+ __ LoadRoot(rax, Heap::kNullValueRootIndex);
2698
+
2699
+ // All done.
2700
+ __ bind(&done);
2701
+
2702
+ context()->Plug(rax);
2703
+ }
2704
+
2705
+
2706
+ void FullCodeGenerator::EmitLog(ZoneList<Expression*>* args) {
2707
+ // Conditionally generate a log call.
2708
+ // Args:
2709
+ // 0 (literal string): The type of logging (corresponds to the flags).
2710
+ // This is used to determine whether or not to generate the log call.
2711
+ // 1 (string): Format string. Access the string at argument index 2
2712
+ // with '%2s' (see Logger::LogRuntime for all the formats).
2713
+ // 2 (array): Arguments to the format string.
2714
+ ASSERT_EQ(args->length(), 3);
2715
+ #ifdef ENABLE_LOGGING_AND_PROFILING
2716
+ if (CodeGenerator::ShouldGenerateLog(args->at(0))) {
2717
+ VisitForStackValue(args->at(1));
2718
+ VisitForStackValue(args->at(2));
2719
+ __ CallRuntime(Runtime::kLog, 2);
2720
+ }
2721
+ #endif
2722
+ // Finally, we're expected to leave a value on the top of the stack.
2723
+ __ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
2724
+ context()->Plug(rax);
2725
+ }
2726
+
2727
+
2728
+ void FullCodeGenerator::EmitRandomHeapNumber(ZoneList<Expression*>* args) {
2729
+ ASSERT(args->length() == 0);
2730
+
2731
+ Label slow_allocate_heapnumber;
2732
+ Label heapnumber_allocated;
2733
+
2734
+ __ AllocateHeapNumber(rbx, rcx, &slow_allocate_heapnumber);
2735
+ __ jmp(&heapnumber_allocated);
2736
+
2737
+ __ bind(&slow_allocate_heapnumber);
2738
+ // Allocate a heap number.
2739
+ __ CallRuntime(Runtime::kNumberAlloc, 0);
2740
+ __ movq(rbx, rax);
2741
+
2742
+ __ bind(&heapnumber_allocated);
2743
+
2744
+ // Return a random uint32 number in rax.
2745
+ // The fresh HeapNumber is in rbx, which is callee-save on both x64 ABIs.
2746
+ __ PrepareCallCFunction(1);
2747
+ #ifdef _WIN64
2748
+ __ LoadAddress(rcx, ExternalReference::isolate_address());
2749
+ #else
2750
+ __ LoadAddress(rdi, ExternalReference::isolate_address());
2751
+ #endif
2752
+ __ CallCFunction(ExternalReference::random_uint32_function(isolate()), 1);
2753
+
2754
+ // Convert 32 random bits in rax to 0.(32 random bits) in a double
2755
+ // by computing:
2756
+ // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)).
2757
+ __ movl(rcx, Immediate(0x49800000)); // 1.0 x 2^20 as single.
2758
+ __ movd(xmm1, rcx);
2759
+ __ movd(xmm0, rax);
2760
+ __ cvtss2sd(xmm1, xmm1);
2761
+ __ xorpd(xmm0, xmm1);
2762
+ __ subsd(xmm0, xmm1);
2763
+ __ movsd(FieldOperand(rbx, HeapNumber::kValueOffset), xmm0);
2764
+
2765
+ __ movq(rax, rbx);
2766
+ context()->Plug(rax);
2767
+ }
2768
+
2769
+
2770
+ void FullCodeGenerator::EmitSubString(ZoneList<Expression*>* args) {
2771
+ // Load the arguments on the stack and call the stub.
2772
+ SubStringStub stub;
2773
+ ASSERT(args->length() == 3);
2774
+ VisitForStackValue(args->at(0));
2775
+ VisitForStackValue(args->at(1));
2776
+ VisitForStackValue(args->at(2));
2777
+ __ CallStub(&stub);
2778
+ context()->Plug(rax);
2779
+ }
2780
+
2781
+
2782
+ void FullCodeGenerator::EmitRegExpExec(ZoneList<Expression*>* args) {
2783
+ // Load the arguments on the stack and call the stub.
2784
+ RegExpExecStub stub;
2785
+ ASSERT(args->length() == 4);
2786
+ VisitForStackValue(args->at(0));
2787
+ VisitForStackValue(args->at(1));
2788
+ VisitForStackValue(args->at(2));
2789
+ VisitForStackValue(args->at(3));
2790
+ __ CallStub(&stub);
2791
+ context()->Plug(rax);
2792
+ }
2793
+
2794
+
2795
+ void FullCodeGenerator::EmitValueOf(ZoneList<Expression*>* args) {
2796
+ ASSERT(args->length() == 1);
2797
+
2798
+ VisitForAccumulatorValue(args->at(0)); // Load the object.
2799
+
2800
+ Label done;
2801
+ // If the object is a smi return the object.
2802
+ __ JumpIfSmi(rax, &done);
2803
+ // If the object is not a value type, return the object.
2804
+ __ CmpObjectType(rax, JS_VALUE_TYPE, rbx);
2805
+ __ j(not_equal, &done);
2806
+ __ movq(rax, FieldOperand(rax, JSValue::kValueOffset));
2807
+
2808
+ __ bind(&done);
2809
+ context()->Plug(rax);
2810
+ }
2811
+
2812
+
2813
+ void FullCodeGenerator::EmitMathPow(ZoneList<Expression*>* args) {
2814
+ // Load the arguments on the stack and call the runtime function.
2815
+ ASSERT(args->length() == 2);
2816
+ VisitForStackValue(args->at(0));
2817
+ VisitForStackValue(args->at(1));
2818
+ MathPowStub stub;
2819
+ __ CallStub(&stub);
2820
+ context()->Plug(rax);
2821
+ }
2822
+
2823
+
2824
+ void FullCodeGenerator::EmitSetValueOf(ZoneList<Expression*>* args) {
2825
+ ASSERT(args->length() == 2);
2826
+
2827
+ VisitForStackValue(args->at(0)); // Load the object.
2828
+ VisitForAccumulatorValue(args->at(1)); // Load the value.
2829
+ __ pop(rbx); // rax = value. rbx = object.
2830
+
2831
+ Label done;
2832
+ // If the object is a smi, return the value.
2833
+ __ JumpIfSmi(rbx, &done);
2834
+
2835
+ // If the object is not a value type, return the value.
2836
+ __ CmpObjectType(rbx, JS_VALUE_TYPE, rcx);
2837
+ __ j(not_equal, &done);
2838
+
2839
+ // Store the value.
2840
+ __ movq(FieldOperand(rbx, JSValue::kValueOffset), rax);
2841
+ // Update the write barrier. Save the value as it will be
2842
+ // overwritten by the write barrier code and is needed afterward.
2843
+ __ movq(rdx, rax);
2844
+ __ RecordWrite(rbx, JSValue::kValueOffset, rdx, rcx);
2845
+
2846
+ __ bind(&done);
2847
+ context()->Plug(rax);
2848
+ }
2849
+
2850
+
2851
+ void FullCodeGenerator::EmitNumberToString(ZoneList<Expression*>* args) {
2852
+ ASSERT_EQ(args->length(), 1);
2853
+
2854
+ // Load the argument on the stack and call the stub.
2855
+ VisitForStackValue(args->at(0));
2856
+
2857
+ NumberToStringStub stub;
2858
+ __ CallStub(&stub);
2859
+ context()->Plug(rax);
2860
+ }
2861
+
2862
+
2863
+ void FullCodeGenerator::EmitStringCharFromCode(ZoneList<Expression*>* args) {
2864
+ ASSERT(args->length() == 1);
2865
+
2866
+ VisitForAccumulatorValue(args->at(0));
2867
+
2868
+ Label done;
2869
+ StringCharFromCodeGenerator generator(rax, rbx);
2870
+ generator.GenerateFast(masm_);
2871
+ __ jmp(&done);
2872
+
2873
+ NopRuntimeCallHelper call_helper;
2874
+ generator.GenerateSlow(masm_, call_helper);
2875
+
2876
+ __ bind(&done);
2877
+ context()->Plug(rbx);
2878
+ }
2879
+
2880
+
2881
+ void FullCodeGenerator::EmitStringCharCodeAt(ZoneList<Expression*>* args) {
2882
+ ASSERT(args->length() == 2);
2883
+
2884
+ VisitForStackValue(args->at(0));
2885
+ VisitForAccumulatorValue(args->at(1));
2886
+
2887
+ Register object = rbx;
2888
+ Register index = rax;
2889
+ Register scratch = rcx;
2890
+ Register result = rdx;
2891
+
2892
+ __ pop(object);
2893
+
2894
+ Label need_conversion;
2895
+ Label index_out_of_range;
2896
+ Label done;
2897
+ StringCharCodeAtGenerator generator(object,
2898
+ index,
2899
+ scratch,
2900
+ result,
2901
+ &need_conversion,
2902
+ &need_conversion,
2903
+ &index_out_of_range,
2904
+ STRING_INDEX_IS_NUMBER);
2905
+ generator.GenerateFast(masm_);
2906
+ __ jmp(&done);
2907
+
2908
+ __ bind(&index_out_of_range);
2909
+ // When the index is out of range, the spec requires us to return
2910
+ // NaN.
2911
+ __ LoadRoot(result, Heap::kNanValueRootIndex);
2912
+ __ jmp(&done);
2913
+
2914
+ __ bind(&need_conversion);
2915
+ // Move the undefined value into the result register, which will
2916
+ // trigger conversion.
2917
+ __ LoadRoot(result, Heap::kUndefinedValueRootIndex);
2918
+ __ jmp(&done);
2919
+
2920
+ NopRuntimeCallHelper call_helper;
2921
+ generator.GenerateSlow(masm_, call_helper);
2922
+
2923
+ __ bind(&done);
2924
+ context()->Plug(result);
2925
+ }
2926
+
2927
+
2928
+ void FullCodeGenerator::EmitStringCharAt(ZoneList<Expression*>* args) {
2929
+ ASSERT(args->length() == 2);
2930
+
2931
+ VisitForStackValue(args->at(0));
2932
+ VisitForAccumulatorValue(args->at(1));
2933
+
2934
+ Register object = rbx;
2935
+ Register index = rax;
2936
+ Register scratch1 = rcx;
2937
+ Register scratch2 = rdx;
2938
+ Register result = rax;
2939
+
2940
+ __ pop(object);
2941
+
2942
+ Label need_conversion;
2943
+ Label index_out_of_range;
2944
+ Label done;
2945
+ StringCharAtGenerator generator(object,
2946
+ index,
2947
+ scratch1,
2948
+ scratch2,
2949
+ result,
2950
+ &need_conversion,
2951
+ &need_conversion,
2952
+ &index_out_of_range,
2953
+ STRING_INDEX_IS_NUMBER);
2954
+ generator.GenerateFast(masm_);
2955
+ __ jmp(&done);
2956
+
2957
+ __ bind(&index_out_of_range);
2958
+ // When the index is out of range, the spec requires us to return
2959
+ // the empty string.
2960
+ __ LoadRoot(result, Heap::kEmptyStringRootIndex);
2961
+ __ jmp(&done);
2962
+
2963
+ __ bind(&need_conversion);
2964
+ // Move smi zero into the result register, which will trigger
2965
+ // conversion.
2966
+ __ Move(result, Smi::FromInt(0));
2967
+ __ jmp(&done);
2968
+
2969
+ NopRuntimeCallHelper call_helper;
2970
+ generator.GenerateSlow(masm_, call_helper);
2971
+
2972
+ __ bind(&done);
2973
+ context()->Plug(result);
2974
+ }
2975
+
2976
+
2977
+ void FullCodeGenerator::EmitStringAdd(ZoneList<Expression*>* args) {
2978
+ ASSERT_EQ(2, args->length());
2979
+
2980
+ VisitForStackValue(args->at(0));
2981
+ VisitForStackValue(args->at(1));
2982
+
2983
+ StringAddStub stub(NO_STRING_ADD_FLAGS);
2984
+ __ CallStub(&stub);
2985
+ context()->Plug(rax);
2986
+ }
2987
+
2988
+
2989
+ void FullCodeGenerator::EmitStringCompare(ZoneList<Expression*>* args) {
2990
+ ASSERT_EQ(2, args->length());
2991
+
2992
+ VisitForStackValue(args->at(0));
2993
+ VisitForStackValue(args->at(1));
2994
+
2995
+ StringCompareStub stub;
2996
+ __ CallStub(&stub);
2997
+ context()->Plug(rax);
2998
+ }
2999
+
3000
+
3001
+ void FullCodeGenerator::EmitMathSin(ZoneList<Expression*>* args) {
3002
+ // Load the argument on the stack and call the stub.
3003
+ TranscendentalCacheStub stub(TranscendentalCache::SIN,
3004
+ TranscendentalCacheStub::TAGGED);
3005
+ ASSERT(args->length() == 1);
3006
+ VisitForStackValue(args->at(0));
3007
+ __ CallStub(&stub);
3008
+ context()->Plug(rax);
3009
+ }
3010
+
3011
+
3012
+ void FullCodeGenerator::EmitMathCos(ZoneList<Expression*>* args) {
3013
+ // Load the argument on the stack and call the stub.
3014
+ TranscendentalCacheStub stub(TranscendentalCache::COS,
3015
+ TranscendentalCacheStub::TAGGED);
3016
+ ASSERT(args->length() == 1);
3017
+ VisitForStackValue(args->at(0));
3018
+ __ CallStub(&stub);
3019
+ context()->Plug(rax);
3020
+ }
3021
+
3022
+
3023
+ void FullCodeGenerator::EmitMathLog(ZoneList<Expression*>* args) {
3024
+ // Load the argument on the stack and call the stub.
3025
+ TranscendentalCacheStub stub(TranscendentalCache::LOG,
3026
+ TranscendentalCacheStub::TAGGED);
3027
+ ASSERT(args->length() == 1);
3028
+ VisitForStackValue(args->at(0));
3029
+ __ CallStub(&stub);
3030
+ context()->Plug(rax);
3031
+ }
3032
+
3033
+
3034
+ void FullCodeGenerator::EmitMathSqrt(ZoneList<Expression*>* args) {
3035
+ // Load the argument on the stack and call the runtime function.
3036
+ ASSERT(args->length() == 1);
3037
+ VisitForStackValue(args->at(0));
3038
+ __ CallRuntime(Runtime::kMath_sqrt, 1);
3039
+ context()->Plug(rax);
3040
+ }
3041
+
3042
+
3043
+ void FullCodeGenerator::EmitCallFunction(ZoneList<Expression*>* args) {
3044
+ ASSERT(args->length() >= 2);
3045
+
3046
+ int arg_count = args->length() - 2; // For receiver and function.
3047
+ VisitForStackValue(args->at(0)); // Receiver.
3048
+ for (int i = 0; i < arg_count; i++) {
3049
+ VisitForStackValue(args->at(i + 1));
3050
+ }
3051
+ VisitForAccumulatorValue(args->at(arg_count + 1)); // Function.
3052
+
3053
+ // InvokeFunction requires function in rdi. Move it in there.
3054
+ if (!result_register().is(rdi)) __ movq(rdi, result_register());
3055
+ ParameterCount count(arg_count);
3056
+ __ InvokeFunction(rdi, count, CALL_FUNCTION);
3057
+ __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
3058
+ context()->Plug(rax);
3059
+ }
3060
+
3061
+
3062
+ void FullCodeGenerator::EmitRegExpConstructResult(ZoneList<Expression*>* args) {
3063
+ RegExpConstructResultStub stub;
3064
+ ASSERT(args->length() == 3);
3065
+ VisitForStackValue(args->at(0));
3066
+ VisitForStackValue(args->at(1));
3067
+ VisitForStackValue(args->at(2));
3068
+ __ CallStub(&stub);
3069
+ context()->Plug(rax);
3070
+ }
3071
+
3072
+
3073
+ void FullCodeGenerator::EmitSwapElements(ZoneList<Expression*>* args) {
3074
+ ASSERT(args->length() == 3);
3075
+ VisitForStackValue(args->at(0));
3076
+ VisitForStackValue(args->at(1));
3077
+ VisitForStackValue(args->at(2));
3078
+ Label done;
3079
+ Label slow_case;
3080
+ Register object = rax;
3081
+ Register index_1 = rbx;
3082
+ Register index_2 = rcx;
3083
+ Register elements = rdi;
3084
+ Register temp = rdx;
3085
+ __ movq(object, Operand(rsp, 2 * kPointerSize));
3086
+ // Fetch the map and check if array is in fast case.
3087
+ // Check that object doesn't require security checks and
3088
+ // has no indexed interceptor.
3089
+ __ CmpObjectType(object, JS_ARRAY_TYPE, temp);
3090
+ __ j(not_equal, &slow_case);
3091
+ __ testb(FieldOperand(temp, Map::kBitFieldOffset),
3092
+ Immediate(KeyedLoadIC::kSlowCaseBitFieldMask));
3093
+ __ j(not_zero, &slow_case);
3094
+
3095
+ // Check the object's elements are in fast case and writable.
3096
+ __ movq(elements, FieldOperand(object, JSObject::kElementsOffset));
3097
+ __ CompareRoot(FieldOperand(elements, HeapObject::kMapOffset),
3098
+ Heap::kFixedArrayMapRootIndex);
3099
+ __ j(not_equal, &slow_case);
3100
+
3101
+ // Check that both indices are smis.
3102
+ __ movq(index_1, Operand(rsp, 1 * kPointerSize));
3103
+ __ movq(index_2, Operand(rsp, 0 * kPointerSize));
3104
+ __ JumpIfNotBothSmi(index_1, index_2, &slow_case);
3105
+
3106
+ // Check that both indices are valid.
3107
+ // The JSArray length field is a smi since the array is in fast case mode.
3108
+ __ movq(temp, FieldOperand(object, JSArray::kLengthOffset));
3109
+ __ SmiCompare(temp, index_1);
3110
+ __ j(below_equal, &slow_case);
3111
+ __ SmiCompare(temp, index_2);
3112
+ __ j(below_equal, &slow_case);
3113
+
3114
+ __ SmiToInteger32(index_1, index_1);
3115
+ __ SmiToInteger32(index_2, index_2);
3116
+ // Bring addresses into index1 and index2.
3117
+ __ lea(index_1, FieldOperand(elements, index_1, times_pointer_size,
3118
+ FixedArray::kHeaderSize));
3119
+ __ lea(index_2, FieldOperand(elements, index_2, times_pointer_size,
3120
+ FixedArray::kHeaderSize));
3121
+
3122
+ // Swap elements. Use object and temp as scratch registers.
3123
+ __ movq(object, Operand(index_1, 0));
3124
+ __ movq(temp, Operand(index_2, 0));
3125
+ __ movq(Operand(index_2, 0), object);
3126
+ __ movq(Operand(index_1, 0), temp);
3127
+
3128
+ Label new_space;
3129
+ __ InNewSpace(elements, temp, equal, &new_space);
3130
+
3131
+ __ movq(object, elements);
3132
+ __ RecordWriteHelper(object, index_1, temp);
3133
+ __ RecordWriteHelper(elements, index_2, temp);
3134
+
3135
+ __ bind(&new_space);
3136
+ // We are done. Drop elements from the stack, and return undefined.
3137
+ __ addq(rsp, Immediate(3 * kPointerSize));
3138
+ __ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
3139
+ __ jmp(&done);
3140
+
3141
+ __ bind(&slow_case);
3142
+ __ CallRuntime(Runtime::kSwapElements, 3);
3143
+
3144
+ __ bind(&done);
3145
+ context()->Plug(rax);
3146
+ }
3147
+
3148
+
3149
+ void FullCodeGenerator::EmitGetFromCache(ZoneList<Expression*>* args) {
3150
+ ASSERT_EQ(2, args->length());
3151
+
3152
+ ASSERT_NE(NULL, args->at(0)->AsLiteral());
3153
+ int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value();
3154
+
3155
+ Handle<FixedArray> jsfunction_result_caches(
3156
+ isolate()->global_context()->jsfunction_result_caches());
3157
+ if (jsfunction_result_caches->length() <= cache_id) {
3158
+ __ Abort("Attempt to use undefined cache.");
3159
+ __ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
3160
+ context()->Plug(rax);
3161
+ return;
3162
+ }
3163
+
3164
+ VisitForAccumulatorValue(args->at(1));
3165
+
3166
+ Register key = rax;
3167
+ Register cache = rbx;
3168
+ Register tmp = rcx;
3169
+ __ movq(cache, ContextOperand(rsi, Context::GLOBAL_INDEX));
3170
+ __ movq(cache,
3171
+ FieldOperand(cache, GlobalObject::kGlobalContextOffset));
3172
+ __ movq(cache,
3173
+ ContextOperand(cache, Context::JSFUNCTION_RESULT_CACHES_INDEX));
3174
+ __ movq(cache,
3175
+ FieldOperand(cache, FixedArray::OffsetOfElementAt(cache_id)));
3176
+
3177
+ NearLabel done, not_found;
3178
+ // tmp now holds finger offset as a smi.
3179
+ ASSERT(kSmiTag == 0 && kSmiTagSize == 1);
3180
+ __ movq(tmp, FieldOperand(cache, JSFunctionResultCache::kFingerOffset));
3181
+ SmiIndex index =
3182
+ __ SmiToIndex(kScratchRegister, tmp, kPointerSizeLog2);
3183
+ __ cmpq(key, FieldOperand(cache,
3184
+ index.reg,
3185
+ index.scale,
3186
+ FixedArray::kHeaderSize));
3187
+ __ j(not_equal, &not_found);
3188
+ __ movq(rax, FieldOperand(cache,
3189
+ index.reg,
3190
+ index.scale,
3191
+ FixedArray::kHeaderSize + kPointerSize));
3192
+ __ jmp(&done);
3193
+
3194
+ __ bind(&not_found);
3195
+ // Call runtime to perform the lookup.
3196
+ __ push(cache);
3197
+ __ push(key);
3198
+ __ CallRuntime(Runtime::kGetFromCache, 2);
3199
+
3200
+ __ bind(&done);
3201
+ context()->Plug(rax);
3202
+ }
3203
+
3204
+
3205
+ void FullCodeGenerator::EmitIsRegExpEquivalent(ZoneList<Expression*>* args) {
3206
+ ASSERT_EQ(2, args->length());
3207
+
3208
+ Register right = rax;
3209
+ Register left = rbx;
3210
+ Register tmp = rcx;
3211
+
3212
+ VisitForStackValue(args->at(0));
3213
+ VisitForAccumulatorValue(args->at(1));
3214
+ __ pop(left);
3215
+
3216
+ NearLabel done, fail, ok;
3217
+ __ cmpq(left, right);
3218
+ __ j(equal, &ok);
3219
+ // Fail if either is a non-HeapObject.
3220
+ Condition either_smi = masm()->CheckEitherSmi(left, right, tmp);
3221
+ __ j(either_smi, &fail);
3222
+ __ j(zero, &fail);
3223
+ __ movq(tmp, FieldOperand(left, HeapObject::kMapOffset));
3224
+ __ cmpb(FieldOperand(tmp, Map::kInstanceTypeOffset),
3225
+ Immediate(JS_REGEXP_TYPE));
3226
+ __ j(not_equal, &fail);
3227
+ __ cmpq(tmp, FieldOperand(right, HeapObject::kMapOffset));
3228
+ __ j(not_equal, &fail);
3229
+ __ movq(tmp, FieldOperand(left, JSRegExp::kDataOffset));
3230
+ __ cmpq(tmp, FieldOperand(right, JSRegExp::kDataOffset));
3231
+ __ j(equal, &ok);
3232
+ __ bind(&fail);
3233
+ __ Move(rax, isolate()->factory()->false_value());
3234
+ __ jmp(&done);
3235
+ __ bind(&ok);
3236
+ __ Move(rax, isolate()->factory()->true_value());
3237
+ __ bind(&done);
3238
+
3239
+ context()->Plug(rax);
3240
+ }
3241
+
3242
+
3243
+ void FullCodeGenerator::EmitHasCachedArrayIndex(ZoneList<Expression*>* args) {
3244
+ ASSERT(args->length() == 1);
3245
+
3246
+ VisitForAccumulatorValue(args->at(0));
3247
+
3248
+ Label materialize_true, materialize_false;
3249
+ Label* if_true = NULL;
3250
+ Label* if_false = NULL;
3251
+ Label* fall_through = NULL;
3252
+ context()->PrepareTest(&materialize_true, &materialize_false,
3253
+ &if_true, &if_false, &fall_through);
3254
+
3255
+ __ testl(FieldOperand(rax, String::kHashFieldOffset),
3256
+ Immediate(String::kContainsCachedArrayIndexMask));
3257
+ PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
3258
+ __ j(zero, if_true);
3259
+ __ jmp(if_false);
3260
+
3261
+ context()->Plug(if_true, if_false);
3262
+ }
3263
+
3264
+
3265
+ void FullCodeGenerator::EmitGetCachedArrayIndex(ZoneList<Expression*>* args) {
3266
+ ASSERT(args->length() == 1);
3267
+ VisitForAccumulatorValue(args->at(0));
3268
+
3269
+ if (FLAG_debug_code) {
3270
+ __ AbortIfNotString(rax);
3271
+ }
3272
+
3273
+ __ movl(rax, FieldOperand(rax, String::kHashFieldOffset));
3274
+ ASSERT(String::kHashShift >= kSmiTagSize);
3275
+ __ IndexFromHash(rax, rax);
3276
+
3277
+ context()->Plug(rax);
3278
+ }
3279
+
3280
+
3281
+ void FullCodeGenerator::EmitFastAsciiArrayJoin(ZoneList<Expression*>* args) {
3282
+ Label bailout, return_result, done, one_char_separator, long_separator,
3283
+ non_trivial_array, not_size_one_array, loop,
3284
+ loop_1, loop_1_condition, loop_2, loop_2_entry, loop_3, loop_3_entry;
3285
+ ASSERT(args->length() == 2);
3286
+ // We will leave the separator on the stack until the end of the function.
3287
+ VisitForStackValue(args->at(1));
3288
+ // Load this to rax (= array)
3289
+ VisitForAccumulatorValue(args->at(0));
3290
+ // All aliases of the same register have disjoint lifetimes.
3291
+ Register array = rax;
3292
+ Register elements = no_reg; // Will be rax.
3293
+
3294
+ Register index = rdx;
3295
+
3296
+ Register string_length = rcx;
3297
+
3298
+ Register string = rsi;
3299
+
3300
+ Register scratch = rbx;
3301
+
3302
+ Register array_length = rdi;
3303
+ Register result_pos = no_reg; // Will be rdi.
3304
+
3305
+ Operand separator_operand = Operand(rsp, 2 * kPointerSize);
3306
+ Operand result_operand = Operand(rsp, 1 * kPointerSize);
3307
+ Operand array_length_operand = Operand(rsp, 0 * kPointerSize);
3308
+ // Separator operand is already pushed. Make room for the two
3309
+ // other stack fields, and clear the direction flag in anticipation
3310
+ // of calling CopyBytes.
3311
+ __ subq(rsp, Immediate(2 * kPointerSize));
3312
+ __ cld();
3313
+ // Check that the array is a JSArray
3314
+ __ JumpIfSmi(array, &bailout);
3315
+ __ CmpObjectType(array, JS_ARRAY_TYPE, scratch);
3316
+ __ j(not_equal, &bailout);
3317
+
3318
+ // Check that the array has fast elements.
3319
+ __ testb(FieldOperand(scratch, Map::kBitField2Offset),
3320
+ Immediate(1 << Map::kHasFastElements));
3321
+ __ j(zero, &bailout);
3322
+
3323
+ // Array has fast elements, so its length must be a smi.
3324
+ // If the array has length zero, return the empty string.
3325
+ __ movq(array_length, FieldOperand(array, JSArray::kLengthOffset));
3326
+ __ SmiCompare(array_length, Smi::FromInt(0));
3327
+ __ j(not_zero, &non_trivial_array);
3328
+ __ LoadRoot(rax, Heap::kEmptyStringRootIndex);
3329
+ __ jmp(&return_result);
3330
+
3331
+ // Save the array length on the stack.
3332
+ __ bind(&non_trivial_array);
3333
+ __ SmiToInteger32(array_length, array_length);
3334
+ __ movl(array_length_operand, array_length);
3335
+
3336
+ // Save the FixedArray containing array's elements.
3337
+ // End of array's live range.
3338
+ elements = array;
3339
+ __ movq(elements, FieldOperand(array, JSArray::kElementsOffset));
3340
+ array = no_reg;
3341
+
3342
+
3343
+ // Check that all array elements are sequential ASCII strings, and
3344
+ // accumulate the sum of their lengths, as a smi-encoded value.
3345
+ __ Set(index, 0);
3346
+ __ Set(string_length, 0);
3347
+ // Loop condition: while (index < array_length).
3348
+ // Live loop registers: index(int32), array_length(int32), string(String*),
3349
+ // scratch, string_length(int32), elements(FixedArray*).
3350
+ if (FLAG_debug_code) {
3351
+ __ cmpq(index, array_length);
3352
+ __ Assert(below, "No empty arrays here in EmitFastAsciiArrayJoin");
3353
+ }
3354
+ __ bind(&loop);
3355
+ __ movq(string, FieldOperand(elements,
3356
+ index,
3357
+ times_pointer_size,
3358
+ FixedArray::kHeaderSize));
3359
+ __ JumpIfSmi(string, &bailout);
3360
+ __ movq(scratch, FieldOperand(string, HeapObject::kMapOffset));
3361
+ __ movzxbl(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset));
3362
+ __ andb(scratch, Immediate(
3363
+ kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask));
3364
+ __ cmpb(scratch, Immediate(kStringTag | kAsciiStringTag | kSeqStringTag));
3365
+ __ j(not_equal, &bailout);
3366
+ __ AddSmiField(string_length,
3367
+ FieldOperand(string, SeqAsciiString::kLengthOffset));
3368
+ __ j(overflow, &bailout);
3369
+ __ incl(index);
3370
+ __ cmpl(index, array_length);
3371
+ __ j(less, &loop);
3372
+
3373
+ // Live registers:
3374
+ // string_length: Sum of string lengths.
3375
+ // elements: FixedArray of strings.
3376
+ // index: Array length.
3377
+ // array_length: Array length.
3378
+
3379
+ // If array_length is 1, return elements[0], a string.
3380
+ __ cmpl(array_length, Immediate(1));
3381
+ __ j(not_equal, &not_size_one_array);
3382
+ __ movq(rax, FieldOperand(elements, FixedArray::kHeaderSize));
3383
+ __ jmp(&return_result);
3384
+
3385
+ __ bind(&not_size_one_array);
3386
+
3387
+ // End of array_length live range.
3388
+ result_pos = array_length;
3389
+ array_length = no_reg;
3390
+
3391
+ // Live registers:
3392
+ // string_length: Sum of string lengths.
3393
+ // elements: FixedArray of strings.
3394
+ // index: Array length.
3395
+
3396
+ // Check that the separator is a sequential ASCII string.
3397
+ __ movq(string, separator_operand);
3398
+ __ JumpIfSmi(string, &bailout);
3399
+ __ movq(scratch, FieldOperand(string, HeapObject::kMapOffset));
3400
+ __ movzxbl(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset));
3401
+ __ andb(scratch, Immediate(
3402
+ kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask));
3403
+ __ cmpb(scratch, Immediate(kStringTag | kAsciiStringTag | kSeqStringTag));
3404
+ __ j(not_equal, &bailout);
3405
+
3406
+ // Live registers:
3407
+ // string_length: Sum of string lengths.
3408
+ // elements: FixedArray of strings.
3409
+ // index: Array length.
3410
+ // string: Separator string.
3411
+
3412
+ // Add (separator length times (array_length - 1)) to string_length.
3413
+ __ SmiToInteger32(scratch,
3414
+ FieldOperand(string, SeqAsciiString::kLengthOffset));
3415
+ __ decl(index);
3416
+ __ imull(scratch, index);
3417
+ __ j(overflow, &bailout);
3418
+ __ addl(string_length, scratch);
3419
+ __ j(overflow, &bailout);
3420
+
3421
+ // Live registers and stack values:
3422
+ // string_length: Total length of result string.
3423
+ // elements: FixedArray of strings.
3424
+ __ AllocateAsciiString(result_pos, string_length, scratch,
3425
+ index, string, &bailout);
3426
+ __ movq(result_operand, result_pos);
3427
+ __ lea(result_pos, FieldOperand(result_pos, SeqAsciiString::kHeaderSize));
3428
+
3429
+ __ movq(string, separator_operand);
3430
+ __ SmiCompare(FieldOperand(string, SeqAsciiString::kLengthOffset),
3431
+ Smi::FromInt(1));
3432
+ __ j(equal, &one_char_separator);
3433
+ __ j(greater, &long_separator);
3434
+
3435
+
3436
+ // Empty separator case:
3437
+ __ Set(index, 0);
3438
+ __ movl(scratch, array_length_operand);
3439
+ __ jmp(&loop_1_condition);
3440
+ // Loop condition: while (index < array_length).
3441
+ __ bind(&loop_1);
3442
+ // Each iteration of the loop concatenates one string to the result.
3443
+ // Live values in registers:
3444
+ // index: which element of the elements array we are adding to the result.
3445
+ // result_pos: the position to which we are currently copying characters.
3446
+ // elements: the FixedArray of strings we are joining.
3447
+ // scratch: array length.
3448
+
3449
+ // Get string = array[index].
3450
+ __ movq(string, FieldOperand(elements, index,
3451
+ times_pointer_size,
3452
+ FixedArray::kHeaderSize));
3453
+ __ SmiToInteger32(string_length,
3454
+ FieldOperand(string, String::kLengthOffset));
3455
+ __ lea(string,
3456
+ FieldOperand(string, SeqAsciiString::kHeaderSize));
3457
+ __ CopyBytes(result_pos, string, string_length);
3458
+ __ incl(index);
3459
+ __ bind(&loop_1_condition);
3460
+ __ cmpl(index, scratch);
3461
+ __ j(less, &loop_1); // Loop while (index < array_length).
3462
+ __ jmp(&done);
3463
+
3464
+ // Generic bailout code used from several places.
3465
+ __ bind(&bailout);
3466
+ __ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
3467
+ __ jmp(&return_result);
3468
+
3469
+
3470
+ // One-character separator case
3471
+ __ bind(&one_char_separator);
3472
+ // Get the separator ascii character value.
3473
+ // Register "string" holds the separator.
3474
+ __ movzxbl(scratch, FieldOperand(string, SeqAsciiString::kHeaderSize));
3475
+ __ Set(index, 0);
3476
+ // Jump into the loop after the code that copies the separator, so the first
3477
+ // element is not preceded by a separator
3478
+ __ jmp(&loop_2_entry);
3479
+ // Loop condition: while (index < length).
3480
+ __ bind(&loop_2);
3481
+ // Each iteration of the loop concatenates one string to the result.
3482
+ // Live values in registers:
3483
+ // elements: The FixedArray of strings we are joining.
3484
+ // index: which element of the elements array we are adding to the result.
3485
+ // result_pos: the position to which we are currently copying characters.
3486
+ // scratch: Separator character.
3487
+
3488
+ // Copy the separator character to the result.
3489
+ __ movb(Operand(result_pos, 0), scratch);
3490
+ __ incq(result_pos);
3491
+
3492
+ __ bind(&loop_2_entry);
3493
+ // Get string = array[index].
3494
+ __ movq(string, FieldOperand(elements, index,
3495
+ times_pointer_size,
3496
+ FixedArray::kHeaderSize));
3497
+ __ SmiToInteger32(string_length,
3498
+ FieldOperand(string, String::kLengthOffset));
3499
+ __ lea(string,
3500
+ FieldOperand(string, SeqAsciiString::kHeaderSize));
3501
+ __ CopyBytes(result_pos, string, string_length);
3502
+ __ incl(index);
3503
+ __ cmpl(index, array_length_operand);
3504
+ __ j(less, &loop_2); // End while (index < length).
3505
+ __ jmp(&done);
3506
+
3507
+
3508
+ // Long separator case (separator is more than one character).
3509
+ __ bind(&long_separator);
3510
+
3511
+ // Make elements point to end of elements array, and index
3512
+ // count from -array_length to zero, so we don't need to maintain
3513
+ // a loop limit.
3514
+ __ movl(index, array_length_operand);
3515
+ __ lea(elements, FieldOperand(elements, index, times_pointer_size,
3516
+ FixedArray::kHeaderSize));
3517
+ __ neg(index);
3518
+
3519
+ // Replace separator string with pointer to its first character, and
3520
+ // make scratch be its length.
3521
+ __ movq(string, separator_operand);
3522
+ __ SmiToInteger32(scratch,
3523
+ FieldOperand(string, String::kLengthOffset));
3524
+ __ lea(string,
3525
+ FieldOperand(string, SeqAsciiString::kHeaderSize));
3526
+ __ movq(separator_operand, string);
3527
+
3528
+ // Jump into the loop after the code that copies the separator, so the first
3529
+ // element is not preceded by a separator
3530
+ __ jmp(&loop_3_entry);
3531
+ // Loop condition: while (index < length).
3532
+ __ bind(&loop_3);
3533
+ // Each iteration of the loop concatenates one string to the result.
3534
+ // Live values in registers:
3535
+ // index: which element of the elements array we are adding to the result.
3536
+ // result_pos: the position to which we are currently copying characters.
3537
+ // scratch: Separator length.
3538
+ // separator_operand (rsp[0x10]): Address of first char of separator.
3539
+
3540
+ // Copy the separator to the result.
3541
+ __ movq(string, separator_operand);
3542
+ __ movl(string_length, scratch);
3543
+ __ CopyBytes(result_pos, string, string_length, 2);
3544
+
3545
+ __ bind(&loop_3_entry);
3546
+ // Get string = array[index].
3547
+ __ movq(string, Operand(elements, index, times_pointer_size, 0));
3548
+ __ SmiToInteger32(string_length,
3549
+ FieldOperand(string, String::kLengthOffset));
3550
+ __ lea(string,
3551
+ FieldOperand(string, SeqAsciiString::kHeaderSize));
3552
+ __ CopyBytes(result_pos, string, string_length);
3553
+ __ incq(index);
3554
+ __ j(not_equal, &loop_3); // Loop while (index < 0).
3555
+
3556
+ __ bind(&done);
3557
+ __ movq(rax, result_operand);
3558
+
3559
+ __ bind(&return_result);
3560
+ // Drop temp values from the stack, and restore context register.
3561
+ __ addq(rsp, Immediate(3 * kPointerSize));
3562
+ __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
3563
+ context()->Plug(rax);
3564
+ }
3565
+
3566
+
3567
+ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
3568
+ Handle<String> name = expr->name();
3569
+ if (name->length() > 0 && name->Get(0) == '_') {
3570
+ Comment cmnt(masm_, "[ InlineRuntimeCall");
3571
+ EmitInlineRuntimeCall(expr);
3572
+ return;
3573
+ }
3574
+
3575
+ Comment cmnt(masm_, "[ CallRuntime");
3576
+ ZoneList<Expression*>* args = expr->arguments();
3577
+
3578
+ if (expr->is_jsruntime()) {
3579
+ // Prepare for calling JS runtime function.
3580
+ __ movq(rax, GlobalObjectOperand());
3581
+ __ push(FieldOperand(rax, GlobalObject::kBuiltinsOffset));
3582
+ }
3583
+
3584
+ // Push the arguments ("left-to-right").
3585
+ int arg_count = args->length();
3586
+ for (int i = 0; i < arg_count; i++) {
3587
+ VisitForStackValue(args->at(i));
3588
+ }
3589
+
3590
+ if (expr->is_jsruntime()) {
3591
+ // Call the JS runtime function using a call IC.
3592
+ __ Move(rcx, expr->name());
3593
+ InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP;
3594
+ Handle<Code> ic =
3595
+ ISOLATE->stub_cache()->ComputeCallInitialize(arg_count, in_loop);
3596
+ EmitCallIC(ic, RelocInfo::CODE_TARGET);
3597
+ // Restore context register.
3598
+ __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
3599
+ } else {
3600
+ __ CallRuntime(expr->function(), arg_count);
3601
+ }
3602
+ context()->Plug(rax);
3603
+ }
3604
+
3605
+
3606
+ void FullCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) {
3607
+ switch (expr->op()) {
3608
+ case Token::DELETE: {
3609
+ Comment cmnt(masm_, "[ UnaryOperation (DELETE)");
3610
+ Property* prop = expr->expression()->AsProperty();
3611
+ Variable* var = expr->expression()->AsVariableProxy()->AsVariable();
3612
+
3613
+ if (prop != NULL) {
3614
+ if (prop->is_synthetic()) {
3615
+ // Result of deleting parameters is false, even when they rewrite
3616
+ // to accesses on the arguments object.
3617
+ context()->Plug(false);
3618
+ } else {
3619
+ VisitForStackValue(prop->obj());
3620
+ VisitForStackValue(prop->key());
3621
+ __ Push(Smi::FromInt(strict_mode_flag()));
3622
+ __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
3623
+ context()->Plug(rax);
3624
+ }
3625
+ } else if (var != NULL) {
3626
+ // Delete of an unqualified identifier is disallowed in strict mode
3627
+ // but "delete this" is.
3628
+ ASSERT(strict_mode_flag() == kNonStrictMode || var->is_this());
3629
+ if (var->is_global()) {
3630
+ __ push(GlobalObjectOperand());
3631
+ __ Push(var->name());
3632
+ __ Push(Smi::FromInt(kNonStrictMode));
3633
+ __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
3634
+ context()->Plug(rax);
3635
+ } else if (var->AsSlot() != NULL &&
3636
+ var->AsSlot()->type() != Slot::LOOKUP) {
3637
+ // Result of deleting non-global, non-dynamic variables is false.
3638
+ // The subexpression does not have side effects.
3639
+ context()->Plug(false);
3640
+ } else {
3641
+ // Non-global variable. Call the runtime to try to delete from the
3642
+ // context where the variable was introduced.
3643
+ __ push(context_register());
3644
+ __ Push(var->name());
3645
+ __ CallRuntime(Runtime::kDeleteContextSlot, 2);
3646
+ context()->Plug(rax);
3647
+ }
3648
+ } else {
3649
+ // Result of deleting non-property, non-variable reference is true.
3650
+ // The subexpression may have side effects.
3651
+ VisitForEffect(expr->expression());
3652
+ context()->Plug(true);
3653
+ }
3654
+ break;
3655
+ }
3656
+
3657
+ case Token::VOID: {
3658
+ Comment cmnt(masm_, "[ UnaryOperation (VOID)");
3659
+ VisitForEffect(expr->expression());
3660
+ context()->Plug(Heap::kUndefinedValueRootIndex);
3661
+ break;
3662
+ }
3663
+
3664
+ case Token::NOT: {
3665
+ Comment cmnt(masm_, "[ UnaryOperation (NOT)");
3666
+ if (context()->IsEffect()) {
3667
+ // Unary NOT has no side effects so it's only necessary to visit the
3668
+ // subexpression. Match the optimizing compiler by not branching.
3669
+ VisitForEffect(expr->expression());
3670
+ } else {
3671
+ Label materialize_true, materialize_false;
3672
+ Label* if_true = NULL;
3673
+ Label* if_false = NULL;
3674
+ Label* fall_through = NULL;
3675
+ // Notice that the labels are swapped.
3676
+ context()->PrepareTest(&materialize_true, &materialize_false,
3677
+ &if_false, &if_true, &fall_through);
3678
+ if (context()->IsTest()) ForwardBailoutToChild(expr);
3679
+ VisitForControl(expr->expression(), if_true, if_false, fall_through);
3680
+ context()->Plug(if_false, if_true); // Labels swapped.
3681
+ }
3682
+ break;
3683
+ }
3684
+
3685
+ case Token::TYPEOF: {
3686
+ Comment cmnt(masm_, "[ UnaryOperation (TYPEOF)");
3687
+ { StackValueContext context(this);
3688
+ VisitForTypeofValue(expr->expression());
3689
+ }
3690
+ __ CallRuntime(Runtime::kTypeof, 1);
3691
+ context()->Plug(rax);
3692
+ break;
3693
+ }
3694
+
3695
+ case Token::ADD: {
3696
+ Comment cmt(masm_, "[ UnaryOperation (ADD)");
3697
+ VisitForAccumulatorValue(expr->expression());
3698
+ Label no_conversion;
3699
+ Condition is_smi = masm_->CheckSmi(result_register());
3700
+ __ j(is_smi, &no_conversion);
3701
+ ToNumberStub convert_stub;
3702
+ __ CallStub(&convert_stub);
3703
+ __ bind(&no_conversion);
3704
+ context()->Plug(result_register());
3705
+ break;
3706
+ }
3707
+
3708
+ case Token::SUB: {
3709
+ Comment cmt(masm_, "[ UnaryOperation (SUB)");
3710
+ bool can_overwrite = expr->expression()->ResultOverwriteAllowed();
3711
+ UnaryOverwriteMode overwrite =
3712
+ can_overwrite ? UNARY_OVERWRITE : UNARY_NO_OVERWRITE;
3713
+ GenericUnaryOpStub stub(Token::SUB, overwrite, NO_UNARY_FLAGS);
3714
+ // GenericUnaryOpStub expects the argument to be in the
3715
+ // accumulator register rax.
3716
+ VisitForAccumulatorValue(expr->expression());
3717
+ __ CallStub(&stub);
3718
+ context()->Plug(rax);
3719
+ break;
3720
+ }
3721
+
3722
+ case Token::BIT_NOT: {
3723
+ Comment cmt(masm_, "[ UnaryOperation (BIT_NOT)");
3724
+ // The generic unary operation stub expects the argument to be
3725
+ // in the accumulator register rax.
3726
+ VisitForAccumulatorValue(expr->expression());
3727
+ Label done;
3728
+ bool inline_smi_case = ShouldInlineSmiCase(expr->op());
3729
+ if (inline_smi_case) {
3730
+ Label call_stub;
3731
+ __ JumpIfNotSmi(rax, &call_stub);
3732
+ __ SmiNot(rax, rax);
3733
+ __ jmp(&done);
3734
+ __ bind(&call_stub);
3735
+ }
3736
+ bool overwrite = expr->expression()->ResultOverwriteAllowed();
3737
+ UnaryOverwriteMode mode =
3738
+ overwrite ? UNARY_OVERWRITE : UNARY_NO_OVERWRITE;
3739
+ UnaryOpFlags flags = inline_smi_case
3740
+ ? NO_UNARY_SMI_CODE_IN_STUB
3741
+ : NO_UNARY_FLAGS;
3742
+ GenericUnaryOpStub stub(Token::BIT_NOT, mode, flags);
3743
+ __ CallStub(&stub);
3744
+ __ bind(&done);
3745
+ context()->Plug(rax);
3746
+ break;
3747
+ }
3748
+
3749
+ default:
3750
+ UNREACHABLE();
3751
+ }
3752
+ }
3753
+
3754
+
3755
+ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
3756
+ Comment cmnt(masm_, "[ CountOperation");
3757
+ SetSourcePosition(expr->position());
3758
+
3759
+ // Invalid left-hand-sides are rewritten to have a 'throw
3760
+ // ReferenceError' as the left-hand side.
3761
+ if (!expr->expression()->IsValidLeftHandSide()) {
3762
+ VisitForEffect(expr->expression());
3763
+ return;
3764
+ }
3765
+
3766
+ // Expression can only be a property, a global or a (parameter or local)
3767
+ // slot. Variables with rewrite to .arguments are treated as KEYED_PROPERTY.
3768
+ enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY };
3769
+ LhsKind assign_type = VARIABLE;
3770
+ Property* prop = expr->expression()->AsProperty();
3771
+ // In case of a property we use the uninitialized expression context
3772
+ // of the key to detect a named property.
3773
+ if (prop != NULL) {
3774
+ assign_type =
3775
+ (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY;
3776
+ }
3777
+
3778
+ // Evaluate expression and get value.
3779
+ if (assign_type == VARIABLE) {
3780
+ ASSERT(expr->expression()->AsVariableProxy()->var() != NULL);
3781
+ AccumulatorValueContext context(this);
3782
+ EmitVariableLoad(expr->expression()->AsVariableProxy()->var());
3783
+ } else {
3784
+ // Reserve space for result of postfix operation.
3785
+ if (expr->is_postfix() && !context()->IsEffect()) {
3786
+ __ Push(Smi::FromInt(0));
3787
+ }
3788
+ if (assign_type == NAMED_PROPERTY) {
3789
+ VisitForAccumulatorValue(prop->obj());
3790
+ __ push(rax); // Copy of receiver, needed for later store.
3791
+ EmitNamedPropertyLoad(prop);
3792
+ } else {
3793
+ if (prop->is_arguments_access()) {
3794
+ VariableProxy* obj_proxy = prop->obj()->AsVariableProxy();
3795
+ MemOperand slot_operand =
3796
+ EmitSlotSearch(obj_proxy->var()->AsSlot(), rcx);
3797
+ __ push(slot_operand);
3798
+ __ Move(rax, prop->key()->AsLiteral()->handle());
3799
+ } else {
3800
+ VisitForStackValue(prop->obj());
3801
+ VisitForAccumulatorValue(prop->key());
3802
+ }
3803
+ __ movq(rdx, Operand(rsp, 0)); // Leave receiver on stack
3804
+ __ push(rax); // Copy of key, needed for later store.
3805
+ EmitKeyedPropertyLoad(prop);
3806
+ }
3807
+ }
3808
+
3809
+ // We need a second deoptimization point after loading the value
3810
+ // in case evaluating the property load my have a side effect.
3811
+ if (assign_type == VARIABLE) {
3812
+ PrepareForBailout(expr->expression(), TOS_REG);
3813
+ } else {
3814
+ PrepareForBailout(expr->increment(), TOS_REG);
3815
+ }
3816
+
3817
+ // Call ToNumber only if operand is not a smi.
3818
+ NearLabel no_conversion;
3819
+ Condition is_smi;
3820
+ is_smi = masm_->CheckSmi(rax);
3821
+ __ j(is_smi, &no_conversion);
3822
+ ToNumberStub convert_stub;
3823
+ __ CallStub(&convert_stub);
3824
+ __ bind(&no_conversion);
3825
+
3826
+ // Save result for postfix expressions.
3827
+ if (expr->is_postfix()) {
3828
+ if (!context()->IsEffect()) {
3829
+ // Save the result on the stack. If we have a named or keyed property
3830
+ // we store the result under the receiver that is currently on top
3831
+ // of the stack.
3832
+ switch (assign_type) {
3833
+ case VARIABLE:
3834
+ __ push(rax);
3835
+ break;
3836
+ case NAMED_PROPERTY:
3837
+ __ movq(Operand(rsp, kPointerSize), rax);
3838
+ break;
3839
+ case KEYED_PROPERTY:
3840
+ __ movq(Operand(rsp, 2 * kPointerSize), rax);
3841
+ break;
3842
+ }
3843
+ }
3844
+ }
3845
+
3846
+ // Inline smi case if we are in a loop.
3847
+ NearLabel stub_call, done;
3848
+ JumpPatchSite patch_site(masm_);
3849
+
3850
+ if (ShouldInlineSmiCase(expr->op())) {
3851
+ if (expr->op() == Token::INC) {
3852
+ __ SmiAddConstant(rax, rax, Smi::FromInt(1));
3853
+ } else {
3854
+ __ SmiSubConstant(rax, rax, Smi::FromInt(1));
3855
+ }
3856
+ __ j(overflow, &stub_call);
3857
+ // We could eliminate this smi check if we split the code at
3858
+ // the first smi check before calling ToNumber.
3859
+ patch_site.EmitJumpIfSmi(rax, &done);
3860
+
3861
+ __ bind(&stub_call);
3862
+ // Call stub. Undo operation first.
3863
+ if (expr->op() == Token::INC) {
3864
+ __ SmiSubConstant(rax, rax, Smi::FromInt(1));
3865
+ } else {
3866
+ __ SmiAddConstant(rax, rax, Smi::FromInt(1));
3867
+ }
3868
+ }
3869
+
3870
+ // Record position before stub call.
3871
+ SetSourcePosition(expr->position());
3872
+
3873
+ // Call stub for +1/-1.
3874
+ TypeRecordingBinaryOpStub stub(expr->binary_op(), NO_OVERWRITE);
3875
+ if (expr->op() == Token::INC) {
3876
+ __ Move(rdx, Smi::FromInt(1));
3877
+ } else {
3878
+ __ movq(rdx, rax);
3879
+ __ Move(rax, Smi::FromInt(1));
3880
+ }
3881
+ EmitCallIC(stub.GetCode(), &patch_site);
3882
+ __ bind(&done);
3883
+
3884
+ // Store the value returned in rax.
3885
+ switch (assign_type) {
3886
+ case VARIABLE:
3887
+ if (expr->is_postfix()) {
3888
+ // Perform the assignment as if via '='.
3889
+ { EffectContext context(this);
3890
+ EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(),
3891
+ Token::ASSIGN);
3892
+ PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
3893
+ context.Plug(rax);
3894
+ }
3895
+ // For all contexts except kEffect: We have the result on
3896
+ // top of the stack.
3897
+ if (!context()->IsEffect()) {
3898
+ context()->PlugTOS();
3899
+ }
3900
+ } else {
3901
+ // Perform the assignment as if via '='.
3902
+ EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(),
3903
+ Token::ASSIGN);
3904
+ PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
3905
+ context()->Plug(rax);
3906
+ }
3907
+ break;
3908
+ case NAMED_PROPERTY: {
3909
+ __ Move(rcx, prop->key()->AsLiteral()->handle());
3910
+ __ pop(rdx);
3911
+ Handle<Code> ic = is_strict_mode()
3912
+ ? isolate()->builtins()->StoreIC_Initialize_Strict()
3913
+ : isolate()->builtins()->StoreIC_Initialize();
3914
+ EmitCallIC(ic, RelocInfo::CODE_TARGET);
3915
+ PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
3916
+ if (expr->is_postfix()) {
3917
+ if (!context()->IsEffect()) {
3918
+ context()->PlugTOS();
3919
+ }
3920
+ } else {
3921
+ context()->Plug(rax);
3922
+ }
3923
+ break;
3924
+ }
3925
+ case KEYED_PROPERTY: {
3926
+ __ pop(rcx);
3927
+ __ pop(rdx);
3928
+ Handle<Code> ic = is_strict_mode()
3929
+ ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict()
3930
+ : isolate()->builtins()->KeyedStoreIC_Initialize();
3931
+ EmitCallIC(ic, RelocInfo::CODE_TARGET);
3932
+ PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
3933
+ if (expr->is_postfix()) {
3934
+ if (!context()->IsEffect()) {
3935
+ context()->PlugTOS();
3936
+ }
3937
+ } else {
3938
+ context()->Plug(rax);
3939
+ }
3940
+ break;
3941
+ }
3942
+ }
3943
+ }
3944
+
3945
+
3946
+ void FullCodeGenerator::VisitForTypeofValue(Expression* expr) {
3947
+ VariableProxy* proxy = expr->AsVariableProxy();
3948
+ ASSERT(!context()->IsEffect());
3949
+ ASSERT(!context()->IsTest());
3950
+
3951
+ if (proxy != NULL && !proxy->var()->is_this() && proxy->var()->is_global()) {
3952
+ Comment cmnt(masm_, "Global variable");
3953
+ __ Move(rcx, proxy->name());
3954
+ __ movq(rax, GlobalObjectOperand());
3955
+ Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
3956
+ // Use a regular load, not a contextual load, to avoid a reference
3957
+ // error.
3958
+ EmitCallIC(ic, RelocInfo::CODE_TARGET);
3959
+ PrepareForBailout(expr, TOS_REG);
3960
+ context()->Plug(rax);
3961
+ } else if (proxy != NULL &&
3962
+ proxy->var()->AsSlot() != NULL &&
3963
+ proxy->var()->AsSlot()->type() == Slot::LOOKUP) {
3964
+ Label done, slow;
3965
+
3966
+ // Generate code for loading from variables potentially shadowed
3967
+ // by eval-introduced variables.
3968
+ Slot* slot = proxy->var()->AsSlot();
3969
+ EmitDynamicLoadFromSlotFastCase(slot, INSIDE_TYPEOF, &slow, &done);
3970
+
3971
+ __ bind(&slow);
3972
+ __ push(rsi);
3973
+ __ Push(proxy->name());
3974
+ __ CallRuntime(Runtime::kLoadContextSlotNoReferenceError, 2);
3975
+ PrepareForBailout(expr, TOS_REG);
3976
+ __ bind(&done);
3977
+
3978
+ context()->Plug(rax);
3979
+ } else {
3980
+ // This expression cannot throw a reference error at the top level.
3981
+ context()->HandleExpression(expr);
3982
+ }
3983
+ }
3984
+
3985
+
3986
+ bool FullCodeGenerator::TryLiteralCompare(Token::Value op,
3987
+ Expression* left,
3988
+ Expression* right,
3989
+ Label* if_true,
3990
+ Label* if_false,
3991
+ Label* fall_through) {
3992
+ if (op != Token::EQ && op != Token::EQ_STRICT) return false;
3993
+
3994
+ // Check for the pattern: typeof <expression> == <string literal>.
3995
+ Literal* right_literal = right->AsLiteral();
3996
+ if (right_literal == NULL) return false;
3997
+ Handle<Object> right_literal_value = right_literal->handle();
3998
+ if (!right_literal_value->IsString()) return false;
3999
+ UnaryOperation* left_unary = left->AsUnaryOperation();
4000
+ if (left_unary == NULL || left_unary->op() != Token::TYPEOF) return false;
4001
+ Handle<String> check = Handle<String>::cast(right_literal_value);
4002
+
4003
+ { AccumulatorValueContext context(this);
4004
+ VisitForTypeofValue(left_unary->expression());
4005
+ }
4006
+ PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
4007
+
4008
+ if (check->Equals(isolate()->heap()->number_symbol())) {
4009
+ __ JumpIfSmi(rax, if_true);
4010
+ __ movq(rax, FieldOperand(rax, HeapObject::kMapOffset));
4011
+ __ CompareRoot(rax, Heap::kHeapNumberMapRootIndex);
4012
+ Split(equal, if_true, if_false, fall_through);
4013
+ } else if (check->Equals(isolate()->heap()->string_symbol())) {
4014
+ __ JumpIfSmi(rax, if_false);
4015
+ // Check for undetectable objects => false.
4016
+ __ CmpObjectType(rax, FIRST_NONSTRING_TYPE, rdx);
4017
+ __ j(above_equal, if_false);
4018
+ __ testb(FieldOperand(rdx, Map::kBitFieldOffset),
4019
+ Immediate(1 << Map::kIsUndetectable));
4020
+ Split(zero, if_true, if_false, fall_through);
4021
+ } else if (check->Equals(isolate()->heap()->boolean_symbol())) {
4022
+ __ CompareRoot(rax, Heap::kTrueValueRootIndex);
4023
+ __ j(equal, if_true);
4024
+ __ CompareRoot(rax, Heap::kFalseValueRootIndex);
4025
+ Split(equal, if_true, if_false, fall_through);
4026
+ } else if (check->Equals(isolate()->heap()->undefined_symbol())) {
4027
+ __ CompareRoot(rax, Heap::kUndefinedValueRootIndex);
4028
+ __ j(equal, if_true);
4029
+ __ JumpIfSmi(rax, if_false);
4030
+ // Check for undetectable objects => true.
4031
+ __ movq(rdx, FieldOperand(rax, HeapObject::kMapOffset));
4032
+ __ testb(FieldOperand(rdx, Map::kBitFieldOffset),
4033
+ Immediate(1 << Map::kIsUndetectable));
4034
+ Split(not_zero, if_true, if_false, fall_through);
4035
+ } else if (check->Equals(isolate()->heap()->function_symbol())) {
4036
+ __ JumpIfSmi(rax, if_false);
4037
+ __ CmpObjectType(rax, FIRST_FUNCTION_CLASS_TYPE, rdx);
4038
+ Split(above_equal, if_true, if_false, fall_through);
4039
+ } else if (check->Equals(isolate()->heap()->object_symbol())) {
4040
+ __ JumpIfSmi(rax, if_false);
4041
+ __ CompareRoot(rax, Heap::kNullValueRootIndex);
4042
+ __ j(equal, if_true);
4043
+ __ CmpObjectType(rax, FIRST_JS_OBJECT_TYPE, rdx);
4044
+ __ j(below, if_false);
4045
+ __ CmpInstanceType(rdx, FIRST_FUNCTION_CLASS_TYPE);
4046
+ __ j(above_equal, if_false);
4047
+ // Check for undetectable objects => false.
4048
+ __ testb(FieldOperand(rdx, Map::kBitFieldOffset),
4049
+ Immediate(1 << Map::kIsUndetectable));
4050
+ Split(zero, if_true, if_false, fall_through);
4051
+ } else {
4052
+ if (if_false != fall_through) __ jmp(if_false);
4053
+ }
4054
+
4055
+ return true;
4056
+ }
4057
+
4058
+
4059
+ void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) {
4060
+ Comment cmnt(masm_, "[ CompareOperation");
4061
+ SetSourcePosition(expr->position());
4062
+
4063
+ // Always perform the comparison for its control flow. Pack the result
4064
+ // into the expression's context after the comparison is performed.
4065
+ Label materialize_true, materialize_false;
4066
+ Label* if_true = NULL;
4067
+ Label* if_false = NULL;
4068
+ Label* fall_through = NULL;
4069
+ context()->PrepareTest(&materialize_true, &materialize_false,
4070
+ &if_true, &if_false, &fall_through);
4071
+
4072
+ // First we try a fast inlined version of the compare when one of
4073
+ // the operands is a literal.
4074
+ Token::Value op = expr->op();
4075
+ Expression* left = expr->left();
4076
+ Expression* right = expr->right();
4077
+ if (TryLiteralCompare(op, left, right, if_true, if_false, fall_through)) {
4078
+ context()->Plug(if_true, if_false);
4079
+ return;
4080
+ }
4081
+
4082
+ VisitForStackValue(expr->left());
4083
+ switch (op) {
4084
+ case Token::IN:
4085
+ VisitForStackValue(expr->right());
4086
+ __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION);
4087
+ PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL);
4088
+ __ CompareRoot(rax, Heap::kTrueValueRootIndex);
4089
+ Split(equal, if_true, if_false, fall_through);
4090
+ break;
4091
+
4092
+ case Token::INSTANCEOF: {
4093
+ VisitForStackValue(expr->right());
4094
+ InstanceofStub stub(InstanceofStub::kNoFlags);
4095
+ __ CallStub(&stub);
4096
+ PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
4097
+ __ testq(rax, rax);
4098
+ // The stub returns 0 for true.
4099
+ Split(zero, if_true, if_false, fall_through);
4100
+ break;
4101
+ }
4102
+
4103
+ default: {
4104
+ VisitForAccumulatorValue(expr->right());
4105
+ Condition cc = no_condition;
4106
+ bool strict = false;
4107
+ switch (op) {
4108
+ case Token::EQ_STRICT:
4109
+ strict = true;
4110
+ // Fall through.
4111
+ case Token::EQ:
4112
+ cc = equal;
4113
+ __ pop(rdx);
4114
+ break;
4115
+ case Token::LT:
4116
+ cc = less;
4117
+ __ pop(rdx);
4118
+ break;
4119
+ case Token::GT:
4120
+ // Reverse left and right sizes to obtain ECMA-262 conversion order.
4121
+ cc = less;
4122
+ __ movq(rdx, result_register());
4123
+ __ pop(rax);
4124
+ break;
4125
+ case Token::LTE:
4126
+ // Reverse left and right sizes to obtain ECMA-262 conversion order.
4127
+ cc = greater_equal;
4128
+ __ movq(rdx, result_register());
4129
+ __ pop(rax);
4130
+ break;
4131
+ case Token::GTE:
4132
+ cc = greater_equal;
4133
+ __ pop(rdx);
4134
+ break;
4135
+ case Token::IN:
4136
+ case Token::INSTANCEOF:
4137
+ default:
4138
+ UNREACHABLE();
4139
+ }
4140
+
4141
+ bool inline_smi_code = ShouldInlineSmiCase(op);
4142
+ JumpPatchSite patch_site(masm_);
4143
+ if (inline_smi_code) {
4144
+ NearLabel slow_case;
4145
+ __ movq(rcx, rdx);
4146
+ __ or_(rcx, rax);
4147
+ patch_site.EmitJumpIfNotSmi(rcx, &slow_case);
4148
+ __ cmpq(rdx, rax);
4149
+ Split(cc, if_true, if_false, NULL);
4150
+ __ bind(&slow_case);
4151
+ }
4152
+
4153
+ // Record position and call the compare IC.
4154
+ SetSourcePosition(expr->position());
4155
+ Handle<Code> ic = CompareIC::GetUninitialized(op);
4156
+ EmitCallIC(ic, &patch_site);
4157
+
4158
+ PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
4159
+ __ testq(rax, rax);
4160
+ Split(cc, if_true, if_false, fall_through);
4161
+ }
4162
+ }
4163
+
4164
+ // Convert the result of the comparison into one expected for this
4165
+ // expression's context.
4166
+ context()->Plug(if_true, if_false);
4167
+ }
4168
+
4169
+
4170
+ void FullCodeGenerator::VisitCompareToNull(CompareToNull* expr) {
4171
+ Comment cmnt(masm_, "[ CompareToNull");
4172
+ Label materialize_true, materialize_false;
4173
+ Label* if_true = NULL;
4174
+ Label* if_false = NULL;
4175
+ Label* fall_through = NULL;
4176
+ context()->PrepareTest(&materialize_true, &materialize_false,
4177
+ &if_true, &if_false, &fall_through);
4178
+
4179
+ VisitForAccumulatorValue(expr->expression());
4180
+ PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
4181
+ __ CompareRoot(rax, Heap::kNullValueRootIndex);
4182
+ if (expr->is_strict()) {
4183
+ Split(equal, if_true, if_false, fall_through);
4184
+ } else {
4185
+ __ j(equal, if_true);
4186
+ __ CompareRoot(rax, Heap::kUndefinedValueRootIndex);
4187
+ __ j(equal, if_true);
4188
+ Condition is_smi = masm_->CheckSmi(rax);
4189
+ __ j(is_smi, if_false);
4190
+ // It can be an undetectable object.
4191
+ __ movq(rdx, FieldOperand(rax, HeapObject::kMapOffset));
4192
+ __ testb(FieldOperand(rdx, Map::kBitFieldOffset),
4193
+ Immediate(1 << Map::kIsUndetectable));
4194
+ Split(not_zero, if_true, if_false, fall_through);
4195
+ }
4196
+ context()->Plug(if_true, if_false);
4197
+ }
4198
+
4199
+
4200
+ void FullCodeGenerator::VisitThisFunction(ThisFunction* expr) {
4201
+ __ movq(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
4202
+ context()->Plug(rax);
4203
+ }
4204
+
4205
+
4206
+ Register FullCodeGenerator::result_register() {
4207
+ return rax;
4208
+ }
4209
+
4210
+
4211
+ Register FullCodeGenerator::context_register() {
4212
+ return rsi;
4213
+ }
4214
+
4215
+
4216
+ void FullCodeGenerator::EmitCallIC(Handle<Code> ic, RelocInfo::Mode mode) {
4217
+ ASSERT(mode == RelocInfo::CODE_TARGET ||
4218
+ mode == RelocInfo::CODE_TARGET_CONTEXT);
4219
+ Counters* counters = isolate()->counters();
4220
+ switch (ic->kind()) {
4221
+ case Code::LOAD_IC:
4222
+ __ IncrementCounter(counters->named_load_full(), 1);
4223
+ break;
4224
+ case Code::KEYED_LOAD_IC:
4225
+ __ IncrementCounter(counters->keyed_load_full(), 1);
4226
+ break;
4227
+ case Code::STORE_IC:
4228
+ __ IncrementCounter(counters->named_store_full(), 1);
4229
+ break;
4230
+ case Code::KEYED_STORE_IC:
4231
+ __ IncrementCounter(counters->keyed_store_full(), 1);
4232
+ default:
4233
+ break;
4234
+ }
4235
+
4236
+ __ call(ic, mode);
4237
+
4238
+ // Crankshaft doesn't need patching of inlined loads and stores.
4239
+ // When compiling the snapshot we need to produce code that works
4240
+ // with and without Crankshaft.
4241
+ if (V8::UseCrankshaft() && !Serializer::enabled()) {
4242
+ return;
4243
+ }
4244
+
4245
+ // If we're calling a (keyed) load or store stub, we have to mark
4246
+ // the call as containing no inlined code so we will not attempt to
4247
+ // patch it.
4248
+ switch (ic->kind()) {
4249
+ case Code::LOAD_IC:
4250
+ case Code::KEYED_LOAD_IC:
4251
+ case Code::STORE_IC:
4252
+ case Code::KEYED_STORE_IC:
4253
+ __ nop(); // Signals no inlined code.
4254
+ break;
4255
+ default:
4256
+ // Do nothing.
4257
+ break;
4258
+ }
4259
+ }
4260
+
4261
+
4262
+ void FullCodeGenerator::EmitCallIC(Handle<Code> ic, JumpPatchSite* patch_site) {
4263
+ Counters* counters = isolate()->counters();
4264
+ switch (ic->kind()) {
4265
+ case Code::LOAD_IC:
4266
+ __ IncrementCounter(counters->named_load_full(), 1);
4267
+ break;
4268
+ case Code::KEYED_LOAD_IC:
4269
+ __ IncrementCounter(counters->keyed_load_full(), 1);
4270
+ break;
4271
+ case Code::STORE_IC:
4272
+ __ IncrementCounter(counters->named_store_full(), 1);
4273
+ break;
4274
+ case Code::KEYED_STORE_IC:
4275
+ __ IncrementCounter(counters->keyed_store_full(), 1);
4276
+ default:
4277
+ break;
4278
+ }
4279
+
4280
+ __ call(ic, RelocInfo::CODE_TARGET);
4281
+ if (patch_site != NULL && patch_site->is_bound()) {
4282
+ patch_site->EmitPatchInfo();
4283
+ } else {
4284
+ __ nop(); // Signals no inlined code.
4285
+ }
4286
+ }
4287
+
4288
+
4289
+ void FullCodeGenerator::StoreToFrameField(int frame_offset, Register value) {
4290
+ ASSERT(IsAligned(frame_offset, kPointerSize));
4291
+ __ movq(Operand(rbp, frame_offset), value);
4292
+ }
4293
+
4294
+
4295
+ void FullCodeGenerator::LoadContextField(Register dst, int context_index) {
4296
+ __ movq(dst, ContextOperand(rsi, context_index));
4297
+ }
4298
+
4299
+
4300
+ // ----------------------------------------------------------------------------
4301
+ // Non-local control flow support.
4302
+
4303
+
4304
+ void FullCodeGenerator::EnterFinallyBlock() {
4305
+ ASSERT(!result_register().is(rdx));
4306
+ ASSERT(!result_register().is(rcx));
4307
+ // Cook return address on top of stack (smi encoded Code* delta)
4308
+ __ movq(rdx, Operand(rsp, 0));
4309
+ __ Move(rcx, masm_->CodeObject());
4310
+ __ subq(rdx, rcx);
4311
+ __ Integer32ToSmi(rdx, rdx);
4312
+ __ movq(Operand(rsp, 0), rdx);
4313
+ // Store result register while executing finally block.
4314
+ __ push(result_register());
4315
+ }
4316
+
4317
+
4318
+ void FullCodeGenerator::ExitFinallyBlock() {
4319
+ ASSERT(!result_register().is(rdx));
4320
+ ASSERT(!result_register().is(rcx));
4321
+ // Restore result register from stack.
4322
+ __ pop(result_register());
4323
+ // Uncook return address.
4324
+ __ movq(rdx, Operand(rsp, 0));
4325
+ __ SmiToInteger32(rdx, rdx);
4326
+ __ Move(rcx, masm_->CodeObject());
4327
+ __ addq(rdx, rcx);
4328
+ __ movq(Operand(rsp, 0), rdx);
4329
+ // And return.
4330
+ __ ret(0);
4331
+ }
4332
+
4333
+
4334
+ #undef __
4335
+
4336
+
4337
+ } } // namespace v8::internal
4338
+
4339
+ #endif // V8_TARGET_ARCH_X64