therubyracer 0.8.1.pre2 → 0.8.1

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