libv8-sgonyea 3.3.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (500) hide show
  1. data/.gitignore +8 -0
  2. data/.gitmodules +3 -0
  3. data/Gemfile +4 -0
  4. data/README.md +76 -0
  5. data/Rakefile +113 -0
  6. data/ext/libv8/extconf.rb +28 -0
  7. data/lib/libv8.rb +15 -0
  8. data/lib/libv8/Makefile +30 -0
  9. data/lib/libv8/detect_cpu.rb +27 -0
  10. data/lib/libv8/fpic-on-linux-amd64.patch +13 -0
  11. data/lib/libv8/v8/.gitignore +35 -0
  12. data/lib/libv8/v8/AUTHORS +44 -0
  13. data/lib/libv8/v8/ChangeLog +2839 -0
  14. data/lib/libv8/v8/LICENSE +52 -0
  15. data/lib/libv8/v8/LICENSE.strongtalk +29 -0
  16. data/lib/libv8/v8/LICENSE.v8 +26 -0
  17. data/lib/libv8/v8/LICENSE.valgrind +45 -0
  18. data/lib/libv8/v8/SConstruct +1478 -0
  19. data/lib/libv8/v8/build/README.txt +49 -0
  20. data/lib/libv8/v8/build/all.gyp +18 -0
  21. data/lib/libv8/v8/build/armu.gypi +32 -0
  22. data/lib/libv8/v8/build/common.gypi +144 -0
  23. data/lib/libv8/v8/build/gyp_v8 +145 -0
  24. data/lib/libv8/v8/include/v8-debug.h +395 -0
  25. data/lib/libv8/v8/include/v8-preparser.h +117 -0
  26. data/lib/libv8/v8/include/v8-profiler.h +505 -0
  27. data/lib/libv8/v8/include/v8-testing.h +104 -0
  28. data/lib/libv8/v8/include/v8.h +4124 -0
  29. data/lib/libv8/v8/include/v8stdint.h +53 -0
  30. data/lib/libv8/v8/preparser/SConscript +38 -0
  31. data/lib/libv8/v8/preparser/preparser-process.cc +379 -0
  32. data/lib/libv8/v8/src/SConscript +368 -0
  33. data/lib/libv8/v8/src/accessors.cc +767 -0
  34. data/lib/libv8/v8/src/accessors.h +123 -0
  35. data/lib/libv8/v8/src/allocation-inl.h +49 -0
  36. data/lib/libv8/v8/src/allocation.cc +122 -0
  37. data/lib/libv8/v8/src/allocation.h +143 -0
  38. data/lib/libv8/v8/src/api.cc +5845 -0
  39. data/lib/libv8/v8/src/api.h +574 -0
  40. data/lib/libv8/v8/src/apinatives.js +110 -0
  41. data/lib/libv8/v8/src/apiutils.h +73 -0
  42. data/lib/libv8/v8/src/arguments.h +118 -0
  43. data/lib/libv8/v8/src/arm/assembler-arm-inl.h +353 -0
  44. data/lib/libv8/v8/src/arm/assembler-arm.cc +2661 -0
  45. data/lib/libv8/v8/src/arm/assembler-arm.h +1375 -0
  46. data/lib/libv8/v8/src/arm/builtins-arm.cc +1658 -0
  47. data/lib/libv8/v8/src/arm/code-stubs-arm.cc +6398 -0
  48. data/lib/libv8/v8/src/arm/code-stubs-arm.h +673 -0
  49. data/lib/libv8/v8/src/arm/codegen-arm.cc +52 -0
  50. data/lib/libv8/v8/src/arm/codegen-arm.h +91 -0
  51. data/lib/libv8/v8/src/arm/constants-arm.cc +152 -0
  52. data/lib/libv8/v8/src/arm/constants-arm.h +775 -0
  53. data/lib/libv8/v8/src/arm/cpu-arm.cc +120 -0
  54. data/lib/libv8/v8/src/arm/debug-arm.cc +317 -0
  55. data/lib/libv8/v8/src/arm/deoptimizer-arm.cc +754 -0
  56. data/lib/libv8/v8/src/arm/disasm-arm.cc +1506 -0
  57. data/lib/libv8/v8/src/arm/frames-arm.cc +45 -0
  58. data/lib/libv8/v8/src/arm/frames-arm.h +168 -0
  59. data/lib/libv8/v8/src/arm/full-codegen-arm.cc +4375 -0
  60. data/lib/libv8/v8/src/arm/ic-arm.cc +1562 -0
  61. data/lib/libv8/v8/src/arm/lithium-arm.cc +2206 -0
  62. data/lib/libv8/v8/src/arm/lithium-arm.h +2348 -0
  63. data/lib/libv8/v8/src/arm/lithium-codegen-arm.cc +4526 -0
  64. data/lib/libv8/v8/src/arm/lithium-codegen-arm.h +403 -0
  65. data/lib/libv8/v8/src/arm/lithium-gap-resolver-arm.cc +305 -0
  66. data/lib/libv8/v8/src/arm/lithium-gap-resolver-arm.h +84 -0
  67. data/lib/libv8/v8/src/arm/macro-assembler-arm.cc +3163 -0
  68. data/lib/libv8/v8/src/arm/macro-assembler-arm.h +1126 -0
  69. data/lib/libv8/v8/src/arm/regexp-macro-assembler-arm.cc +1287 -0
  70. data/lib/libv8/v8/src/arm/regexp-macro-assembler-arm.h +253 -0
  71. data/lib/libv8/v8/src/arm/simulator-arm.cc +3424 -0
  72. data/lib/libv8/v8/src/arm/simulator-arm.h +431 -0
  73. data/lib/libv8/v8/src/arm/stub-cache-arm.cc +4243 -0
  74. data/lib/libv8/v8/src/array.js +1366 -0
  75. data/lib/libv8/v8/src/assembler.cc +1207 -0
  76. data/lib/libv8/v8/src/assembler.h +858 -0
  77. data/lib/libv8/v8/src/ast-inl.h +112 -0
  78. data/lib/libv8/v8/src/ast.cc +1146 -0
  79. data/lib/libv8/v8/src/ast.h +2188 -0
  80. data/lib/libv8/v8/src/atomicops.h +167 -0
  81. data/lib/libv8/v8/src/atomicops_internals_arm_gcc.h +145 -0
  82. data/lib/libv8/v8/src/atomicops_internals_mips_gcc.h +169 -0
  83. data/lib/libv8/v8/src/atomicops_internals_x86_gcc.cc +133 -0
  84. data/lib/libv8/v8/src/atomicops_internals_x86_gcc.h +287 -0
  85. data/lib/libv8/v8/src/atomicops_internals_x86_macosx.h +301 -0
  86. data/lib/libv8/v8/src/atomicops_internals_x86_msvc.h +203 -0
  87. data/lib/libv8/v8/src/bignum-dtoa.cc +655 -0
  88. data/lib/libv8/v8/src/bignum-dtoa.h +81 -0
  89. data/lib/libv8/v8/src/bignum.cc +768 -0
  90. data/lib/libv8/v8/src/bignum.h +140 -0
  91. data/lib/libv8/v8/src/bootstrapper.cc +2184 -0
  92. data/lib/libv8/v8/src/bootstrapper.h +188 -0
  93. data/lib/libv8/v8/src/builtins.cc +1707 -0
  94. data/lib/libv8/v8/src/builtins.h +371 -0
  95. data/lib/libv8/v8/src/bytecodes-irregexp.h +105 -0
  96. data/lib/libv8/v8/src/cached-powers.cc +177 -0
  97. data/lib/libv8/v8/src/cached-powers.h +65 -0
  98. data/lib/libv8/v8/src/char-predicates-inl.h +94 -0
  99. data/lib/libv8/v8/src/char-predicates.h +67 -0
  100. data/lib/libv8/v8/src/checks.cc +110 -0
  101. data/lib/libv8/v8/src/checks.h +296 -0
  102. data/lib/libv8/v8/src/circular-queue-inl.h +53 -0
  103. data/lib/libv8/v8/src/circular-queue.cc +122 -0
  104. data/lib/libv8/v8/src/circular-queue.h +103 -0
  105. data/lib/libv8/v8/src/code-stubs.cc +267 -0
  106. data/lib/libv8/v8/src/code-stubs.h +1011 -0
  107. data/lib/libv8/v8/src/code.h +70 -0
  108. data/lib/libv8/v8/src/codegen.cc +231 -0
  109. data/lib/libv8/v8/src/codegen.h +84 -0
  110. data/lib/libv8/v8/src/compilation-cache.cc +540 -0
  111. data/lib/libv8/v8/src/compilation-cache.h +287 -0
  112. data/lib/libv8/v8/src/compiler.cc +786 -0
  113. data/lib/libv8/v8/src/compiler.h +312 -0
  114. data/lib/libv8/v8/src/contexts.cc +347 -0
  115. data/lib/libv8/v8/src/contexts.h +391 -0
  116. data/lib/libv8/v8/src/conversions-inl.h +106 -0
  117. data/lib/libv8/v8/src/conversions.cc +1131 -0
  118. data/lib/libv8/v8/src/conversions.h +135 -0
  119. data/lib/libv8/v8/src/counters.cc +93 -0
  120. data/lib/libv8/v8/src/counters.h +254 -0
  121. data/lib/libv8/v8/src/cpu-profiler-inl.h +101 -0
  122. data/lib/libv8/v8/src/cpu-profiler.cc +609 -0
  123. data/lib/libv8/v8/src/cpu-profiler.h +302 -0
  124. data/lib/libv8/v8/src/cpu.h +69 -0
  125. data/lib/libv8/v8/src/d8-debug.cc +367 -0
  126. data/lib/libv8/v8/src/d8-debug.h +158 -0
  127. data/lib/libv8/v8/src/d8-posix.cc +695 -0
  128. data/lib/libv8/v8/src/d8-readline.cc +130 -0
  129. data/lib/libv8/v8/src/d8-windows.cc +42 -0
  130. data/lib/libv8/v8/src/d8.cc +803 -0
  131. data/lib/libv8/v8/src/d8.gyp +91 -0
  132. data/lib/libv8/v8/src/d8.h +235 -0
  133. data/lib/libv8/v8/src/d8.js +2798 -0
  134. data/lib/libv8/v8/src/data-flow.cc +66 -0
  135. data/lib/libv8/v8/src/data-flow.h +205 -0
  136. data/lib/libv8/v8/src/date.js +1103 -0
  137. data/lib/libv8/v8/src/dateparser-inl.h +127 -0
  138. data/lib/libv8/v8/src/dateparser.cc +178 -0
  139. data/lib/libv8/v8/src/dateparser.h +266 -0
  140. data/lib/libv8/v8/src/debug-agent.cc +447 -0
  141. data/lib/libv8/v8/src/debug-agent.h +129 -0
  142. data/lib/libv8/v8/src/debug-debugger.js +2569 -0
  143. data/lib/libv8/v8/src/debug.cc +3165 -0
  144. data/lib/libv8/v8/src/debug.h +1057 -0
  145. data/lib/libv8/v8/src/deoptimizer.cc +1256 -0
  146. data/lib/libv8/v8/src/deoptimizer.h +602 -0
  147. data/lib/libv8/v8/src/disasm.h +80 -0
  148. data/lib/libv8/v8/src/disassembler.cc +343 -0
  149. data/lib/libv8/v8/src/disassembler.h +58 -0
  150. data/lib/libv8/v8/src/diy-fp.cc +58 -0
  151. data/lib/libv8/v8/src/diy-fp.h +117 -0
  152. data/lib/libv8/v8/src/double.h +238 -0
  153. data/lib/libv8/v8/src/dtoa.cc +103 -0
  154. data/lib/libv8/v8/src/dtoa.h +85 -0
  155. data/lib/libv8/v8/src/execution.cc +849 -0
  156. data/lib/libv8/v8/src/execution.h +297 -0
  157. data/lib/libv8/v8/src/extensions/experimental/break-iterator.cc +250 -0
  158. data/lib/libv8/v8/src/extensions/experimental/break-iterator.h +89 -0
  159. data/lib/libv8/v8/src/extensions/experimental/collator.cc +218 -0
  160. data/lib/libv8/v8/src/extensions/experimental/collator.h +69 -0
  161. data/lib/libv8/v8/src/extensions/experimental/experimental.gyp +94 -0
  162. data/lib/libv8/v8/src/extensions/experimental/i18n-extension.cc +78 -0
  163. data/lib/libv8/v8/src/extensions/experimental/i18n-extension.h +54 -0
  164. data/lib/libv8/v8/src/extensions/experimental/i18n-locale.cc +112 -0
  165. data/lib/libv8/v8/src/extensions/experimental/i18n-locale.h +60 -0
  166. data/lib/libv8/v8/src/extensions/experimental/i18n-utils.cc +43 -0
  167. data/lib/libv8/v8/src/extensions/experimental/i18n-utils.h +49 -0
  168. data/lib/libv8/v8/src/extensions/experimental/i18n.js +180 -0
  169. data/lib/libv8/v8/src/extensions/experimental/language-matcher.cc +251 -0
  170. data/lib/libv8/v8/src/extensions/experimental/language-matcher.h +95 -0
  171. data/lib/libv8/v8/src/extensions/externalize-string-extension.cc +141 -0
  172. data/lib/libv8/v8/src/extensions/externalize-string-extension.h +50 -0
  173. data/lib/libv8/v8/src/extensions/gc-extension.cc +58 -0
  174. data/lib/libv8/v8/src/extensions/gc-extension.h +49 -0
  175. data/lib/libv8/v8/src/factory.cc +1222 -0
  176. data/lib/libv8/v8/src/factory.h +442 -0
  177. data/lib/libv8/v8/src/fast-dtoa.cc +736 -0
  178. data/lib/libv8/v8/src/fast-dtoa.h +83 -0
  179. data/lib/libv8/v8/src/fixed-dtoa.cc +405 -0
  180. data/lib/libv8/v8/src/fixed-dtoa.h +55 -0
  181. data/lib/libv8/v8/src/flag-definitions.h +560 -0
  182. data/lib/libv8/v8/src/flags.cc +551 -0
  183. data/lib/libv8/v8/src/flags.h +79 -0
  184. data/lib/libv8/v8/src/frames-inl.h +247 -0
  185. data/lib/libv8/v8/src/frames.cc +1243 -0
  186. data/lib/libv8/v8/src/frames.h +870 -0
  187. data/lib/libv8/v8/src/full-codegen.cc +1374 -0
  188. data/lib/libv8/v8/src/full-codegen.h +771 -0
  189. data/lib/libv8/v8/src/func-name-inferrer.cc +92 -0
  190. data/lib/libv8/v8/src/func-name-inferrer.h +111 -0
  191. data/lib/libv8/v8/src/gdb-jit.cc +1555 -0
  192. data/lib/libv8/v8/src/gdb-jit.h +143 -0
  193. data/lib/libv8/v8/src/global-handles.cc +665 -0
  194. data/lib/libv8/v8/src/global-handles.h +284 -0
  195. data/lib/libv8/v8/src/globals.h +325 -0
  196. data/lib/libv8/v8/src/handles-inl.h +177 -0
  197. data/lib/libv8/v8/src/handles.cc +987 -0
  198. data/lib/libv8/v8/src/handles.h +382 -0
  199. data/lib/libv8/v8/src/hashmap.cc +230 -0
  200. data/lib/libv8/v8/src/hashmap.h +123 -0
  201. data/lib/libv8/v8/src/heap-inl.h +704 -0
  202. data/lib/libv8/v8/src/heap-profiler.cc +1173 -0
  203. data/lib/libv8/v8/src/heap-profiler.h +397 -0
  204. data/lib/libv8/v8/src/heap.cc +5930 -0
  205. data/lib/libv8/v8/src/heap.h +2268 -0
  206. data/lib/libv8/v8/src/hydrogen-instructions.cc +1769 -0
  207. data/lib/libv8/v8/src/hydrogen-instructions.h +3971 -0
  208. data/lib/libv8/v8/src/hydrogen.cc +6239 -0
  209. data/lib/libv8/v8/src/hydrogen.h +1202 -0
  210. data/lib/libv8/v8/src/ia32/assembler-ia32-inl.h +446 -0
  211. data/lib/libv8/v8/src/ia32/assembler-ia32.cc +2487 -0
  212. data/lib/libv8/v8/src/ia32/assembler-ia32.h +1144 -0
  213. data/lib/libv8/v8/src/ia32/builtins-ia32.cc +1621 -0
  214. data/lib/libv8/v8/src/ia32/code-stubs-ia32.cc +6198 -0
  215. data/lib/libv8/v8/src/ia32/code-stubs-ia32.h +517 -0
  216. data/lib/libv8/v8/src/ia32/codegen-ia32.cc +265 -0
  217. data/lib/libv8/v8/src/ia32/codegen-ia32.h +79 -0
  218. data/lib/libv8/v8/src/ia32/cpu-ia32.cc +88 -0
  219. data/lib/libv8/v8/src/ia32/debug-ia32.cc +312 -0
  220. data/lib/libv8/v8/src/ia32/deoptimizer-ia32.cc +774 -0
  221. data/lib/libv8/v8/src/ia32/disasm-ia32.cc +1628 -0
  222. data/lib/libv8/v8/src/ia32/frames-ia32.cc +45 -0
  223. data/lib/libv8/v8/src/ia32/frames-ia32.h +142 -0
  224. data/lib/libv8/v8/src/ia32/full-codegen-ia32.cc +4338 -0
  225. data/lib/libv8/v8/src/ia32/ic-ia32.cc +1597 -0
  226. data/lib/libv8/v8/src/ia32/lithium-codegen-ia32.cc +4461 -0
  227. data/lib/libv8/v8/src/ia32/lithium-codegen-ia32.h +375 -0
  228. data/lib/libv8/v8/src/ia32/lithium-gap-resolver-ia32.cc +475 -0
  229. data/lib/libv8/v8/src/ia32/lithium-gap-resolver-ia32.h +110 -0
  230. data/lib/libv8/v8/src/ia32/lithium-ia32.cc +2261 -0
  231. data/lib/libv8/v8/src/ia32/lithium-ia32.h +2396 -0
  232. data/lib/libv8/v8/src/ia32/macro-assembler-ia32.cc +2136 -0
  233. data/lib/libv8/v8/src/ia32/macro-assembler-ia32.h +775 -0
  234. data/lib/libv8/v8/src/ia32/regexp-macro-assembler-ia32.cc +1263 -0
  235. data/lib/libv8/v8/src/ia32/regexp-macro-assembler-ia32.h +216 -0
  236. data/lib/libv8/v8/src/ia32/simulator-ia32.cc +30 -0
  237. data/lib/libv8/v8/src/ia32/simulator-ia32.h +74 -0
  238. data/lib/libv8/v8/src/ia32/stub-cache-ia32.cc +3847 -0
  239. data/lib/libv8/v8/src/ic-inl.h +130 -0
  240. data/lib/libv8/v8/src/ic.cc +2577 -0
  241. data/lib/libv8/v8/src/ic.h +736 -0
  242. data/lib/libv8/v8/src/inspector.cc +63 -0
  243. data/lib/libv8/v8/src/inspector.h +62 -0
  244. data/lib/libv8/v8/src/interpreter-irregexp.cc +659 -0
  245. data/lib/libv8/v8/src/interpreter-irregexp.h +49 -0
  246. data/lib/libv8/v8/src/isolate-inl.h +50 -0
  247. data/lib/libv8/v8/src/isolate.cc +1869 -0
  248. data/lib/libv8/v8/src/isolate.h +1382 -0
  249. data/lib/libv8/v8/src/json-parser.cc +504 -0
  250. data/lib/libv8/v8/src/json-parser.h +161 -0
  251. data/lib/libv8/v8/src/json.js +342 -0
  252. data/lib/libv8/v8/src/jsregexp.cc +5385 -0
  253. data/lib/libv8/v8/src/jsregexp.h +1492 -0
  254. data/lib/libv8/v8/src/list-inl.h +212 -0
  255. data/lib/libv8/v8/src/list.h +174 -0
  256. data/lib/libv8/v8/src/lithium-allocator-inl.h +142 -0
  257. data/lib/libv8/v8/src/lithium-allocator.cc +2123 -0
  258. data/lib/libv8/v8/src/lithium-allocator.h +630 -0
  259. data/lib/libv8/v8/src/lithium.cc +190 -0
  260. data/lib/libv8/v8/src/lithium.h +597 -0
  261. data/lib/libv8/v8/src/liveedit-debugger.js +1082 -0
  262. data/lib/libv8/v8/src/liveedit.cc +1691 -0
  263. data/lib/libv8/v8/src/liveedit.h +180 -0
  264. data/lib/libv8/v8/src/liveobjectlist-inl.h +126 -0
  265. data/lib/libv8/v8/src/liveobjectlist.cc +2589 -0
  266. data/lib/libv8/v8/src/liveobjectlist.h +322 -0
  267. data/lib/libv8/v8/src/log-inl.h +59 -0
  268. data/lib/libv8/v8/src/log-utils.cc +428 -0
  269. data/lib/libv8/v8/src/log-utils.h +231 -0
  270. data/lib/libv8/v8/src/log.cc +1993 -0
  271. data/lib/libv8/v8/src/log.h +476 -0
  272. data/lib/libv8/v8/src/macro-assembler.h +120 -0
  273. data/lib/libv8/v8/src/macros.py +178 -0
  274. data/lib/libv8/v8/src/mark-compact.cc +3143 -0
  275. data/lib/libv8/v8/src/mark-compact.h +506 -0
  276. data/lib/libv8/v8/src/math.js +264 -0
  277. data/lib/libv8/v8/src/messages.cc +179 -0
  278. data/lib/libv8/v8/src/messages.h +113 -0
  279. data/lib/libv8/v8/src/messages.js +1096 -0
  280. data/lib/libv8/v8/src/mips/assembler-mips-inl.h +312 -0
  281. data/lib/libv8/v8/src/mips/assembler-mips.cc +1960 -0
  282. data/lib/libv8/v8/src/mips/assembler-mips.h +1138 -0
  283. data/lib/libv8/v8/src/mips/builtins-mips.cc +1628 -0
  284. data/lib/libv8/v8/src/mips/code-stubs-mips.cc +6656 -0
  285. data/lib/libv8/v8/src/mips/code-stubs-mips.h +682 -0
  286. data/lib/libv8/v8/src/mips/codegen-mips.cc +52 -0
  287. data/lib/libv8/v8/src/mips/codegen-mips.h +98 -0
  288. data/lib/libv8/v8/src/mips/constants-mips.cc +352 -0
  289. data/lib/libv8/v8/src/mips/constants-mips.h +739 -0
  290. data/lib/libv8/v8/src/mips/cpu-mips.cc +96 -0
  291. data/lib/libv8/v8/src/mips/debug-mips.cc +308 -0
  292. data/lib/libv8/v8/src/mips/deoptimizer-mips.cc +91 -0
  293. data/lib/libv8/v8/src/mips/disasm-mips.cc +1050 -0
  294. data/lib/libv8/v8/src/mips/frames-mips.cc +47 -0
  295. data/lib/libv8/v8/src/mips/frames-mips.h +219 -0
  296. data/lib/libv8/v8/src/mips/full-codegen-mips.cc +4388 -0
  297. data/lib/libv8/v8/src/mips/ic-mips.cc +1580 -0
  298. data/lib/libv8/v8/src/mips/lithium-codegen-mips.h +65 -0
  299. data/lib/libv8/v8/src/mips/lithium-mips.h +307 -0
  300. data/lib/libv8/v8/src/mips/macro-assembler-mips.cc +4056 -0
  301. data/lib/libv8/v8/src/mips/macro-assembler-mips.h +1214 -0
  302. data/lib/libv8/v8/src/mips/regexp-macro-assembler-mips.cc +1251 -0
  303. data/lib/libv8/v8/src/mips/regexp-macro-assembler-mips.h +252 -0
  304. data/lib/libv8/v8/src/mips/simulator-mips.cc +2621 -0
  305. data/lib/libv8/v8/src/mips/simulator-mips.h +401 -0
  306. data/lib/libv8/v8/src/mips/stub-cache-mips.cc +4285 -0
  307. data/lib/libv8/v8/src/mirror-debugger.js +2382 -0
  308. data/lib/libv8/v8/src/mksnapshot.cc +328 -0
  309. data/lib/libv8/v8/src/natives.h +64 -0
  310. data/lib/libv8/v8/src/objects-debug.cc +738 -0
  311. data/lib/libv8/v8/src/objects-inl.h +4323 -0
  312. data/lib/libv8/v8/src/objects-printer.cc +829 -0
  313. data/lib/libv8/v8/src/objects-visiting.cc +148 -0
  314. data/lib/libv8/v8/src/objects-visiting.h +424 -0
  315. data/lib/libv8/v8/src/objects.cc +10585 -0
  316. data/lib/libv8/v8/src/objects.h +6838 -0
  317. data/lib/libv8/v8/src/parser.cc +4997 -0
  318. data/lib/libv8/v8/src/parser.h +765 -0
  319. data/lib/libv8/v8/src/platform-cygwin.cc +779 -0
  320. data/lib/libv8/v8/src/platform-freebsd.cc +826 -0
  321. data/lib/libv8/v8/src/platform-linux.cc +1149 -0
  322. data/lib/libv8/v8/src/platform-macos.cc +830 -0
  323. data/lib/libv8/v8/src/platform-nullos.cc +479 -0
  324. data/lib/libv8/v8/src/platform-openbsd.cc +640 -0
  325. data/lib/libv8/v8/src/platform-posix.cc +424 -0
  326. data/lib/libv8/v8/src/platform-solaris.cc +762 -0
  327. data/lib/libv8/v8/src/platform-tls-mac.h +62 -0
  328. data/lib/libv8/v8/src/platform-tls-win32.h +62 -0
  329. data/lib/libv8/v8/src/platform-tls.h +50 -0
  330. data/lib/libv8/v8/src/platform-win32.cc +2021 -0
  331. data/lib/libv8/v8/src/platform.h +667 -0
  332. data/lib/libv8/v8/src/preparse-data-format.h +62 -0
  333. data/lib/libv8/v8/src/preparse-data.cc +183 -0
  334. data/lib/libv8/v8/src/preparse-data.h +225 -0
  335. data/lib/libv8/v8/src/preparser-api.cc +220 -0
  336. data/lib/libv8/v8/src/preparser.cc +1450 -0
  337. data/lib/libv8/v8/src/preparser.h +493 -0
  338. data/lib/libv8/v8/src/prettyprinter.cc +1493 -0
  339. data/lib/libv8/v8/src/prettyprinter.h +223 -0
  340. data/lib/libv8/v8/src/profile-generator-inl.h +128 -0
  341. data/lib/libv8/v8/src/profile-generator.cc +3098 -0
  342. data/lib/libv8/v8/src/profile-generator.h +1126 -0
  343. data/lib/libv8/v8/src/property.cc +105 -0
  344. data/lib/libv8/v8/src/property.h +365 -0
  345. data/lib/libv8/v8/src/proxy.js +83 -0
  346. data/lib/libv8/v8/src/regexp-macro-assembler-irregexp-inl.h +78 -0
  347. data/lib/libv8/v8/src/regexp-macro-assembler-irregexp.cc +471 -0
  348. data/lib/libv8/v8/src/regexp-macro-assembler-irregexp.h +142 -0
  349. data/lib/libv8/v8/src/regexp-macro-assembler-tracer.cc +373 -0
  350. data/lib/libv8/v8/src/regexp-macro-assembler-tracer.h +104 -0
  351. data/lib/libv8/v8/src/regexp-macro-assembler.cc +267 -0
  352. data/lib/libv8/v8/src/regexp-macro-assembler.h +243 -0
  353. data/lib/libv8/v8/src/regexp-stack.cc +111 -0
  354. data/lib/libv8/v8/src/regexp-stack.h +147 -0
  355. data/lib/libv8/v8/src/regexp.js +483 -0
  356. data/lib/libv8/v8/src/rewriter.cc +360 -0
  357. data/lib/libv8/v8/src/rewriter.h +50 -0
  358. data/lib/libv8/v8/src/runtime-profiler.cc +489 -0
  359. data/lib/libv8/v8/src/runtime-profiler.h +201 -0
  360. data/lib/libv8/v8/src/runtime.cc +12227 -0
  361. data/lib/libv8/v8/src/runtime.h +652 -0
  362. data/lib/libv8/v8/src/runtime.js +649 -0
  363. data/lib/libv8/v8/src/safepoint-table.cc +256 -0
  364. data/lib/libv8/v8/src/safepoint-table.h +270 -0
  365. data/lib/libv8/v8/src/scanner-base.cc +952 -0
  366. data/lib/libv8/v8/src/scanner-base.h +670 -0
  367. data/lib/libv8/v8/src/scanner.cc +345 -0
  368. data/lib/libv8/v8/src/scanner.h +146 -0
  369. data/lib/libv8/v8/src/scopeinfo.cc +646 -0
  370. data/lib/libv8/v8/src/scopeinfo.h +254 -0
  371. data/lib/libv8/v8/src/scopes.cc +1150 -0
  372. data/lib/libv8/v8/src/scopes.h +507 -0
  373. data/lib/libv8/v8/src/serialize.cc +1574 -0
  374. data/lib/libv8/v8/src/serialize.h +589 -0
  375. data/lib/libv8/v8/src/shell.h +55 -0
  376. data/lib/libv8/v8/src/simulator.h +43 -0
  377. data/lib/libv8/v8/src/small-pointer-list.h +163 -0
  378. data/lib/libv8/v8/src/smart-pointer.h +109 -0
  379. data/lib/libv8/v8/src/snapshot-common.cc +83 -0
  380. data/lib/libv8/v8/src/snapshot-empty.cc +54 -0
  381. data/lib/libv8/v8/src/snapshot.h +91 -0
  382. data/lib/libv8/v8/src/spaces-inl.h +529 -0
  383. data/lib/libv8/v8/src/spaces.cc +3145 -0
  384. data/lib/libv8/v8/src/spaces.h +2369 -0
  385. data/lib/libv8/v8/src/splay-tree-inl.h +310 -0
  386. data/lib/libv8/v8/src/splay-tree.h +205 -0
  387. data/lib/libv8/v8/src/string-search.cc +41 -0
  388. data/lib/libv8/v8/src/string-search.h +568 -0
  389. data/lib/libv8/v8/src/string-stream.cc +592 -0
  390. data/lib/libv8/v8/src/string-stream.h +191 -0
  391. data/lib/libv8/v8/src/string.js +994 -0
  392. data/lib/libv8/v8/src/strtod.cc +440 -0
  393. data/lib/libv8/v8/src/strtod.h +40 -0
  394. data/lib/libv8/v8/src/stub-cache.cc +1965 -0
  395. data/lib/libv8/v8/src/stub-cache.h +924 -0
  396. data/lib/libv8/v8/src/third_party/valgrind/valgrind.h +3925 -0
  397. data/lib/libv8/v8/src/token.cc +63 -0
  398. data/lib/libv8/v8/src/token.h +288 -0
  399. data/lib/libv8/v8/src/type-info.cc +507 -0
  400. data/lib/libv8/v8/src/type-info.h +272 -0
  401. data/lib/libv8/v8/src/unbound-queue-inl.h +95 -0
  402. data/lib/libv8/v8/src/unbound-queue.h +69 -0
  403. data/lib/libv8/v8/src/unicode-inl.h +238 -0
  404. data/lib/libv8/v8/src/unicode.cc +1624 -0
  405. data/lib/libv8/v8/src/unicode.h +280 -0
  406. data/lib/libv8/v8/src/uri.js +408 -0
  407. data/lib/libv8/v8/src/utils-inl.h +48 -0
  408. data/lib/libv8/v8/src/utils.cc +371 -0
  409. data/lib/libv8/v8/src/utils.h +800 -0
  410. data/lib/libv8/v8/src/v8-counters.cc +62 -0
  411. data/lib/libv8/v8/src/v8-counters.h +314 -0
  412. data/lib/libv8/v8/src/v8.cc +213 -0
  413. data/lib/libv8/v8/src/v8.h +131 -0
  414. data/lib/libv8/v8/src/v8checks.h +64 -0
  415. data/lib/libv8/v8/src/v8dll-main.cc +44 -0
  416. data/lib/libv8/v8/src/v8globals.h +512 -0
  417. data/lib/libv8/v8/src/v8memory.h +82 -0
  418. data/lib/libv8/v8/src/v8natives.js +1310 -0
  419. data/lib/libv8/v8/src/v8preparserdll-main.cc +39 -0
  420. data/lib/libv8/v8/src/v8threads.cc +464 -0
  421. data/lib/libv8/v8/src/v8threads.h +165 -0
  422. data/lib/libv8/v8/src/v8utils.h +319 -0
  423. data/lib/libv8/v8/src/variables.cc +114 -0
  424. data/lib/libv8/v8/src/variables.h +167 -0
  425. data/lib/libv8/v8/src/version.cc +116 -0
  426. data/lib/libv8/v8/src/version.h +68 -0
  427. data/lib/libv8/v8/src/vm-state-inl.h +138 -0
  428. data/lib/libv8/v8/src/vm-state.h +71 -0
  429. data/lib/libv8/v8/src/win32-headers.h +96 -0
  430. data/lib/libv8/v8/src/x64/assembler-x64-inl.h +462 -0
  431. data/lib/libv8/v8/src/x64/assembler-x64.cc +3027 -0
  432. data/lib/libv8/v8/src/x64/assembler-x64.h +1633 -0
  433. data/lib/libv8/v8/src/x64/builtins-x64.cc +1520 -0
  434. data/lib/libv8/v8/src/x64/code-stubs-x64.cc +5132 -0
  435. data/lib/libv8/v8/src/x64/code-stubs-x64.h +514 -0
  436. data/lib/libv8/v8/src/x64/codegen-x64.cc +146 -0
  437. data/lib/libv8/v8/src/x64/codegen-x64.h +76 -0
  438. data/lib/libv8/v8/src/x64/cpu-x64.cc +88 -0
  439. data/lib/libv8/v8/src/x64/debug-x64.cc +319 -0
  440. data/lib/libv8/v8/src/x64/deoptimizer-x64.cc +815 -0
  441. data/lib/libv8/v8/src/x64/disasm-x64.cc +1832 -0
  442. data/lib/libv8/v8/src/x64/frames-x64.cc +45 -0
  443. data/lib/libv8/v8/src/x64/frames-x64.h +130 -0
  444. data/lib/libv8/v8/src/x64/full-codegen-x64.cc +4318 -0
  445. data/lib/libv8/v8/src/x64/ic-x64.cc +1608 -0
  446. data/lib/libv8/v8/src/x64/lithium-codegen-x64.cc +4267 -0
  447. data/lib/libv8/v8/src/x64/lithium-codegen-x64.h +367 -0
  448. data/lib/libv8/v8/src/x64/lithium-gap-resolver-x64.cc +320 -0
  449. data/lib/libv8/v8/src/x64/lithium-gap-resolver-x64.h +74 -0
  450. data/lib/libv8/v8/src/x64/lithium-x64.cc +2202 -0
  451. data/lib/libv8/v8/src/x64/lithium-x64.h +2333 -0
  452. data/lib/libv8/v8/src/x64/macro-assembler-x64.cc +3745 -0
  453. data/lib/libv8/v8/src/x64/macro-assembler-x64.h +1290 -0
  454. data/lib/libv8/v8/src/x64/regexp-macro-assembler-x64.cc +1398 -0
  455. data/lib/libv8/v8/src/x64/regexp-macro-assembler-x64.h +282 -0
  456. data/lib/libv8/v8/src/x64/simulator-x64.cc +27 -0
  457. data/lib/libv8/v8/src/x64/simulator-x64.h +72 -0
  458. data/lib/libv8/v8/src/x64/stub-cache-x64.cc +3610 -0
  459. data/lib/libv8/v8/src/zone-inl.h +140 -0
  460. data/lib/libv8/v8/src/zone.cc +196 -0
  461. data/lib/libv8/v8/src/zone.h +240 -0
  462. data/lib/libv8/v8/tools/codemap.js +265 -0
  463. data/lib/libv8/v8/tools/consarray.js +93 -0
  464. data/lib/libv8/v8/tools/csvparser.js +78 -0
  465. data/lib/libv8/v8/tools/disasm.py +92 -0
  466. data/lib/libv8/v8/tools/freebsd-tick-processor +10 -0
  467. data/lib/libv8/v8/tools/gc-nvp-trace-processor.py +342 -0
  468. data/lib/libv8/v8/tools/gcmole/README +62 -0
  469. data/lib/libv8/v8/tools/gcmole/gccause.lua +60 -0
  470. data/lib/libv8/v8/tools/gcmole/gcmole.cc +1261 -0
  471. data/lib/libv8/v8/tools/gcmole/gcmole.lua +378 -0
  472. data/lib/libv8/v8/tools/generate-ten-powers.scm +286 -0
  473. data/lib/libv8/v8/tools/grokdump.py +841 -0
  474. data/lib/libv8/v8/tools/gyp/v8.gyp +995 -0
  475. data/lib/libv8/v8/tools/js2c.py +364 -0
  476. data/lib/libv8/v8/tools/jsmin.py +280 -0
  477. data/lib/libv8/v8/tools/linux-tick-processor +35 -0
  478. data/lib/libv8/v8/tools/ll_prof.py +942 -0
  479. data/lib/libv8/v8/tools/logreader.js +185 -0
  480. data/lib/libv8/v8/tools/mac-nm +18 -0
  481. data/lib/libv8/v8/tools/mac-tick-processor +6 -0
  482. data/lib/libv8/v8/tools/oom_dump/README +31 -0
  483. data/lib/libv8/v8/tools/oom_dump/SConstruct +42 -0
  484. data/lib/libv8/v8/tools/oom_dump/oom_dump.cc +288 -0
  485. data/lib/libv8/v8/tools/presubmit.py +305 -0
  486. data/lib/libv8/v8/tools/process-heap-prof.py +120 -0
  487. data/lib/libv8/v8/tools/profile.js +751 -0
  488. data/lib/libv8/v8/tools/profile_view.js +219 -0
  489. data/lib/libv8/v8/tools/run-valgrind.py +77 -0
  490. data/lib/libv8/v8/tools/splaytree.js +316 -0
  491. data/lib/libv8/v8/tools/stats-viewer.py +468 -0
  492. data/lib/libv8/v8/tools/test.py +1510 -0
  493. data/lib/libv8/v8/tools/tickprocessor-driver.js +59 -0
  494. data/lib/libv8/v8/tools/tickprocessor.js +877 -0
  495. data/lib/libv8/v8/tools/utils.py +96 -0
  496. data/lib/libv8/v8/tools/visual_studio/README.txt +12 -0
  497. data/lib/libv8/v8/tools/windows-tick-processor.bat +30 -0
  498. data/lib/libv8/version.rb +5 -0
  499. data/libv8.gemspec +36 -0
  500. metadata +578 -0
@@ -0,0 +1,1628 @@
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
+
29
+
30
+ #include "v8.h"
31
+
32
+ #if defined(V8_TARGET_ARCH_MIPS)
33
+
34
+ #include "codegen.h"
35
+ #include "debug.h"
36
+ #include "deoptimizer.h"
37
+ #include "full-codegen.h"
38
+ #include "runtime.h"
39
+
40
+ namespace v8 {
41
+ namespace internal {
42
+
43
+
44
+ #define __ ACCESS_MASM(masm)
45
+
46
+
47
+ void Builtins::Generate_Adaptor(MacroAssembler* masm,
48
+ CFunctionId id,
49
+ BuiltinExtraArguments extra_args) {
50
+ // ----------- S t a t e -------------
51
+ // -- a0 : number of arguments excluding receiver
52
+ // -- a1 : called function (only guaranteed when
53
+ // -- extra_args requires it)
54
+ // -- cp : context
55
+ // -- sp[0] : last argument
56
+ // -- ...
57
+ // -- sp[4 * (argc - 1)] : first argument
58
+ // -- sp[4 * agrc] : receiver
59
+ // -----------------------------------
60
+
61
+ // Insert extra arguments.
62
+ int num_extra_args = 0;
63
+ if (extra_args == NEEDS_CALLED_FUNCTION) {
64
+ num_extra_args = 1;
65
+ __ push(a1);
66
+ } else {
67
+ ASSERT(extra_args == NO_EXTRA_ARGUMENTS);
68
+ }
69
+
70
+ // JumpToExternalReference expects a0 to contain the number of arguments
71
+ // including the receiver and the extra arguments.
72
+ __ Addu(a0, a0, Operand(num_extra_args + 1));
73
+ __ JumpToExternalReference(ExternalReference(id, masm->isolate()));
74
+ }
75
+
76
+
77
+ // Load the built-in Array function from the current context.
78
+ static void GenerateLoadArrayFunction(MacroAssembler* masm, Register result) {
79
+ // Load the global context.
80
+
81
+ __ lw(result, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX)));
82
+ __ lw(result,
83
+ FieldMemOperand(result, GlobalObject::kGlobalContextOffset));
84
+ // Load the Array function from the global context.
85
+ __ lw(result,
86
+ MemOperand(result,
87
+ Context::SlotOffset(Context::ARRAY_FUNCTION_INDEX)));
88
+ }
89
+
90
+
91
+ // This constant has the same value as JSArray::kPreallocatedArrayElements and
92
+ // if JSArray::kPreallocatedArrayElements is changed handling of loop unfolding
93
+ // below should be reconsidered.
94
+ static const int kLoopUnfoldLimit = 4;
95
+
96
+
97
+ // Allocate an empty JSArray. The allocated array is put into the result
98
+ // register. An elements backing store is allocated with size initial_capacity
99
+ // and filled with the hole values.
100
+ static void AllocateEmptyJSArray(MacroAssembler* masm,
101
+ Register array_function,
102
+ Register result,
103
+ Register scratch1,
104
+ Register scratch2,
105
+ Register scratch3,
106
+ int initial_capacity,
107
+ Label* gc_required) {
108
+ ASSERT(initial_capacity > 0);
109
+ // Load the initial map from the array function.
110
+ __ lw(scratch1, FieldMemOperand(array_function,
111
+ JSFunction::kPrototypeOrInitialMapOffset));
112
+
113
+ // Allocate the JSArray object together with space for a fixed array with the
114
+ // requested elements.
115
+ int size = JSArray::kSize + FixedArray::SizeFor(initial_capacity);
116
+ __ AllocateInNewSpace(size,
117
+ result,
118
+ scratch2,
119
+ scratch3,
120
+ gc_required,
121
+ TAG_OBJECT);
122
+ // Allocated the JSArray. Now initialize the fields except for the elements
123
+ // array.
124
+ // result: JSObject
125
+ // scratch1: initial map
126
+ // scratch2: start of next object
127
+ __ sw(scratch1, FieldMemOperand(result, JSObject::kMapOffset));
128
+ __ LoadRoot(scratch1, Heap::kEmptyFixedArrayRootIndex);
129
+ __ sw(scratch1, FieldMemOperand(result, JSArray::kPropertiesOffset));
130
+ // Field JSArray::kElementsOffset is initialized later.
131
+ __ mov(scratch3, zero_reg);
132
+ __ sw(scratch3, FieldMemOperand(result, JSArray::kLengthOffset));
133
+
134
+ // Calculate the location of the elements array and set elements array member
135
+ // of the JSArray.
136
+ // result: JSObject
137
+ // scratch2: start of next object
138
+ __ Addu(scratch1, result, Operand(JSArray::kSize));
139
+ __ sw(scratch1, FieldMemOperand(result, JSArray::kElementsOffset));
140
+
141
+ // Clear the heap tag on the elements array.
142
+ __ And(scratch1, scratch1, Operand(~kHeapObjectTagMask));
143
+
144
+ // Initialize the FixedArray and fill it with holes. FixedArray length is
145
+ // stored as a smi.
146
+ // result: JSObject
147
+ // scratch1: elements array (untagged)
148
+ // scratch2: start of next object
149
+ __ LoadRoot(scratch3, Heap::kFixedArrayMapRootIndex);
150
+ ASSERT_EQ(0 * kPointerSize, FixedArray::kMapOffset);
151
+ __ sw(scratch3, MemOperand(scratch1));
152
+ __ Addu(scratch1, scratch1, kPointerSize);
153
+ __ li(scratch3, Operand(Smi::FromInt(initial_capacity)));
154
+ ASSERT_EQ(1 * kPointerSize, FixedArray::kLengthOffset);
155
+ __ sw(scratch3, MemOperand(scratch1));
156
+ __ Addu(scratch1, scratch1, kPointerSize);
157
+
158
+ // Fill the FixedArray with the hole value.
159
+ ASSERT_EQ(2 * kPointerSize, FixedArray::kHeaderSize);
160
+ ASSERT(initial_capacity <= kLoopUnfoldLimit);
161
+ __ LoadRoot(scratch3, Heap::kTheHoleValueRootIndex);
162
+ for (int i = 0; i < initial_capacity; i++) {
163
+ __ sw(scratch3, MemOperand(scratch1));
164
+ __ Addu(scratch1, scratch1, kPointerSize);
165
+ }
166
+ }
167
+
168
+
169
+ // Allocate a JSArray with the number of elements stored in a register. The
170
+ // register array_function holds the built-in Array function and the register
171
+ // array_size holds the size of the array as a smi. The allocated array is put
172
+ // into the result register and beginning and end of the FixedArray elements
173
+ // storage is put into registers elements_array_storage and elements_array_end
174
+ // (see below for when that is not the case). If the parameter fill_with_holes
175
+ // is true the allocated elements backing store is filled with the hole values
176
+ // otherwise it is left uninitialized. When the backing store is filled the
177
+ // register elements_array_storage is scratched.
178
+ static void AllocateJSArray(MacroAssembler* masm,
179
+ Register array_function, // Array function.
180
+ Register array_size, // As a smi.
181
+ Register result,
182
+ Register elements_array_storage,
183
+ Register elements_array_end,
184
+ Register scratch1,
185
+ Register scratch2,
186
+ bool fill_with_hole,
187
+ Label* gc_required) {
188
+ Label not_empty, allocated;
189
+
190
+ // Load the initial map from the array function.
191
+ __ lw(elements_array_storage,
192
+ FieldMemOperand(array_function,
193
+ JSFunction::kPrototypeOrInitialMapOffset));
194
+
195
+ // Check whether an empty sized array is requested.
196
+ __ Branch(&not_empty, ne, array_size, Operand(zero_reg));
197
+
198
+ // If an empty array is requested allocate a small elements array anyway. This
199
+ // keeps the code below free of special casing for the empty array.
200
+ int size = JSArray::kSize +
201
+ FixedArray::SizeFor(JSArray::kPreallocatedArrayElements);
202
+ __ AllocateInNewSpace(size,
203
+ result,
204
+ elements_array_end,
205
+ scratch1,
206
+ gc_required,
207
+ TAG_OBJECT);
208
+ __ Branch(&allocated);
209
+
210
+ // Allocate the JSArray object together with space for a FixedArray with the
211
+ // requested number of elements.
212
+ __ bind(&not_empty);
213
+ ASSERT(kSmiTagSize == 1 && kSmiTag == 0);
214
+ __ li(elements_array_end,
215
+ (JSArray::kSize + FixedArray::kHeaderSize) / kPointerSize);
216
+ __ sra(scratch1, array_size, kSmiTagSize);
217
+ __ Addu(elements_array_end, elements_array_end, scratch1);
218
+ __ AllocateInNewSpace(
219
+ elements_array_end,
220
+ result,
221
+ scratch1,
222
+ scratch2,
223
+ gc_required,
224
+ static_cast<AllocationFlags>(TAG_OBJECT | SIZE_IN_WORDS));
225
+
226
+ // Allocated the JSArray. Now initialize the fields except for the elements
227
+ // array.
228
+ // result: JSObject
229
+ // elements_array_storage: initial map
230
+ // array_size: size of array (smi)
231
+ __ bind(&allocated);
232
+ __ sw(elements_array_storage, FieldMemOperand(result, JSObject::kMapOffset));
233
+ __ LoadRoot(elements_array_storage, Heap::kEmptyFixedArrayRootIndex);
234
+ __ sw(elements_array_storage,
235
+ FieldMemOperand(result, JSArray::kPropertiesOffset));
236
+ // Field JSArray::kElementsOffset is initialized later.
237
+ __ sw(array_size, FieldMemOperand(result, JSArray::kLengthOffset));
238
+
239
+ // Calculate the location of the elements array and set elements array member
240
+ // of the JSArray.
241
+ // result: JSObject
242
+ // array_size: size of array (smi)
243
+ __ Addu(elements_array_storage, result, Operand(JSArray::kSize));
244
+ __ sw(elements_array_storage,
245
+ FieldMemOperand(result, JSArray::kElementsOffset));
246
+
247
+ // Clear the heap tag on the elements array.
248
+ __ And(elements_array_storage,
249
+ elements_array_storage,
250
+ Operand(~kHeapObjectTagMask));
251
+ // Initialize the fixed array and fill it with holes. FixedArray length is
252
+ // stored as a smi.
253
+ // result: JSObject
254
+ // elements_array_storage: elements array (untagged)
255
+ // array_size: size of array (smi)
256
+ __ LoadRoot(scratch1, Heap::kFixedArrayMapRootIndex);
257
+ ASSERT_EQ(0 * kPointerSize, FixedArray::kMapOffset);
258
+ __ sw(scratch1, MemOperand(elements_array_storage));
259
+ __ Addu(elements_array_storage, elements_array_storage, kPointerSize);
260
+
261
+ // Length of the FixedArray is the number of pre-allocated elements if
262
+ // the actual JSArray has length 0 and the size of the JSArray for non-empty
263
+ // JSArrays. The length of a FixedArray is stored as a smi.
264
+ ASSERT(kSmiTag == 0);
265
+ __ li(at, Operand(Smi::FromInt(JSArray::kPreallocatedArrayElements)));
266
+ __ movz(array_size, at, array_size);
267
+
268
+ ASSERT_EQ(1 * kPointerSize, FixedArray::kLengthOffset);
269
+ __ sw(array_size, MemOperand(elements_array_storage));
270
+ __ Addu(elements_array_storage, elements_array_storage, kPointerSize);
271
+
272
+ // Calculate elements array and elements array end.
273
+ // result: JSObject
274
+ // elements_array_storage: elements array element storage
275
+ // array_size: smi-tagged size of elements array
276
+ ASSERT(kSmiTag == 0 && kSmiTagSize < kPointerSizeLog2);
277
+ __ sll(elements_array_end, array_size, kPointerSizeLog2 - kSmiTagSize);
278
+ __ Addu(elements_array_end, elements_array_storage, elements_array_end);
279
+
280
+ // Fill the allocated FixedArray with the hole value if requested.
281
+ // result: JSObject
282
+ // elements_array_storage: elements array element storage
283
+ // elements_array_end: start of next object
284
+ if (fill_with_hole) {
285
+ Label loop, entry;
286
+ __ LoadRoot(scratch1, Heap::kTheHoleValueRootIndex);
287
+ __ Branch(&entry);
288
+ __ bind(&loop);
289
+ __ sw(scratch1, MemOperand(elements_array_storage));
290
+ __ Addu(elements_array_storage, elements_array_storage, kPointerSize);
291
+
292
+ __ bind(&entry);
293
+ __ Branch(&loop, lt, elements_array_storage, Operand(elements_array_end));
294
+ }
295
+ }
296
+
297
+
298
+ // Create a new array for the built-in Array function. This function allocates
299
+ // the JSArray object and the FixedArray elements array and initializes these.
300
+ // If the Array cannot be constructed in native code the runtime is called. This
301
+ // function assumes the following state:
302
+ // a0: argc
303
+ // a1: constructor (built-in Array function)
304
+ // ra: return address
305
+ // sp[0]: last argument
306
+ // This function is used for both construct and normal calls of Array. The only
307
+ // difference between handling a construct call and a normal call is that for a
308
+ // construct call the constructor function in a1 needs to be preserved for
309
+ // entering the generic code. In both cases argc in a0 needs to be preserved.
310
+ // Both registers are preserved by this code so no need to differentiate between
311
+ // construct call and normal call.
312
+ static void ArrayNativeCode(MacroAssembler* masm,
313
+ Label* call_generic_code) {
314
+ Counters* counters = masm->isolate()->counters();
315
+ Label argc_one_or_more, argc_two_or_more;
316
+
317
+ // Check for array construction with zero arguments or one.
318
+ __ Branch(&argc_one_or_more, ne, a0, Operand(zero_reg));
319
+ // Handle construction of an empty array.
320
+ AllocateEmptyJSArray(masm,
321
+ a1,
322
+ a2,
323
+ a3,
324
+ t0,
325
+ t1,
326
+ JSArray::kPreallocatedArrayElements,
327
+ call_generic_code);
328
+ __ IncrementCounter(counters->array_function_native(), 1, a3, t0);
329
+ // Setup return value, remove receiver from stack and return.
330
+ __ mov(v0, a2);
331
+ __ Addu(sp, sp, Operand(kPointerSize));
332
+ __ Ret();
333
+
334
+ // Check for one argument. Bail out if argument is not smi or if it is
335
+ // negative.
336
+ __ bind(&argc_one_or_more);
337
+ __ Branch(&argc_two_or_more, ne, a0, Operand(1));
338
+
339
+ ASSERT(kSmiTag == 0);
340
+ __ lw(a2, MemOperand(sp)); // Get the argument from the stack.
341
+ __ And(a3, a2, Operand(kIntptrSignBit | kSmiTagMask));
342
+ __ Branch(call_generic_code, eq, a3, Operand(zero_reg));
343
+
344
+ // Handle construction of an empty array of a certain size. Bail out if size
345
+ // is too large to actually allocate an elements array.
346
+ ASSERT(kSmiTag == 0);
347
+ __ Branch(call_generic_code, ge, a2,
348
+ Operand(JSObject::kInitialMaxFastElementArray << kSmiTagSize));
349
+
350
+ // a0: argc
351
+ // a1: constructor
352
+ // a2: array_size (smi)
353
+ // sp[0]: argument
354
+ AllocateJSArray(masm,
355
+ a1,
356
+ a2,
357
+ a3,
358
+ t0,
359
+ t1,
360
+ t2,
361
+ t3,
362
+ true,
363
+ call_generic_code);
364
+ __ IncrementCounter(counters->array_function_native(), 1, a2, t0);
365
+
366
+ // Setup return value, remove receiver and argument from stack and return.
367
+ __ mov(v0, a3);
368
+ __ Addu(sp, sp, Operand(2 * kPointerSize));
369
+ __ Ret();
370
+
371
+ // Handle construction of an array from a list of arguments.
372
+ __ bind(&argc_two_or_more);
373
+ __ sll(a2, a0, kSmiTagSize); // Convert argc to a smi.
374
+
375
+ // a0: argc
376
+ // a1: constructor
377
+ // a2: array_size (smi)
378
+ // sp[0]: last argument
379
+ AllocateJSArray(masm,
380
+ a1,
381
+ a2,
382
+ a3,
383
+ t0,
384
+ t1,
385
+ t2,
386
+ t3,
387
+ false,
388
+ call_generic_code);
389
+ __ IncrementCounter(counters->array_function_native(), 1, a2, t2);
390
+
391
+ // Fill arguments as array elements. Copy from the top of the stack (last
392
+ // element) to the array backing store filling it backwards. Note:
393
+ // elements_array_end points after the backing store.
394
+ // a0: argc
395
+ // a3: JSArray
396
+ // t0: elements_array storage start (untagged)
397
+ // t1: elements_array_end (untagged)
398
+ // sp[0]: last argument
399
+
400
+ Label loop, entry;
401
+ __ Branch(&entry);
402
+ __ bind(&loop);
403
+ __ pop(a2);
404
+ __ Addu(t1, t1, -kPointerSize);
405
+ __ sw(a2, MemOperand(t1));
406
+ __ bind(&entry);
407
+ __ Branch(&loop, lt, t0, Operand(t1));
408
+
409
+ // Remove caller arguments and receiver from the stack, setup return value and
410
+ // return.
411
+ // a0: argc
412
+ // a3: JSArray
413
+ // sp[0]: receiver
414
+ __ Addu(sp, sp, Operand(kPointerSize));
415
+ __ mov(v0, a3);
416
+ __ Ret();
417
+ }
418
+
419
+
420
+ void Builtins::Generate_ArrayCode(MacroAssembler* masm) {
421
+ // ----------- S t a t e -------------
422
+ // -- a0 : number of arguments
423
+ // -- ra : return address
424
+ // -- sp[...]: constructor arguments
425
+ // -----------------------------------
426
+ Label generic_array_code;
427
+
428
+ // Get the Array function.
429
+ GenerateLoadArrayFunction(masm, a1);
430
+
431
+ if (FLAG_debug_code) {
432
+ // Initial map for the builtin Array functions should be maps.
433
+ __ lw(a2, FieldMemOperand(a1, JSFunction::kPrototypeOrInitialMapOffset));
434
+ __ And(t0, a2, Operand(kSmiTagMask));
435
+ __ Assert(ne, "Unexpected initial map for Array function (1)",
436
+ t0, Operand(zero_reg));
437
+ __ GetObjectType(a2, a3, t0);
438
+ __ Assert(eq, "Unexpected initial map for Array function (2)",
439
+ t0, Operand(MAP_TYPE));
440
+ }
441
+
442
+ // Run the native code for the Array function called as a normal function.
443
+ ArrayNativeCode(masm, &generic_array_code);
444
+
445
+ // Jump to the generic array code if the specialized code cannot handle
446
+ // the construction.
447
+ __ bind(&generic_array_code);
448
+
449
+ Handle<Code> array_code =
450
+ masm->isolate()->builtins()->ArrayCodeGeneric();
451
+ __ Jump(array_code, RelocInfo::CODE_TARGET);
452
+ }
453
+
454
+
455
+ void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) {
456
+ // ----------- S t a t e -------------
457
+ // -- a0 : number of arguments
458
+ // -- a1 : constructor function
459
+ // -- ra : return address
460
+ // -- sp[...]: constructor arguments
461
+ // -----------------------------------
462
+ Label generic_constructor;
463
+
464
+ if (FLAG_debug_code) {
465
+ // The array construct code is only set for the builtin and internal
466
+ // Array functions which always have a map.
467
+ // Initial map for the builtin Array function should be a map.
468
+ __ lw(a2, FieldMemOperand(a1, JSFunction::kPrototypeOrInitialMapOffset));
469
+ __ And(t0, a2, Operand(kSmiTagMask));
470
+ __ Assert(ne, "Unexpected initial map for Array function (3)",
471
+ t0, Operand(zero_reg));
472
+ __ GetObjectType(a2, a3, t0);
473
+ __ Assert(eq, "Unexpected initial map for Array function (4)",
474
+ t0, Operand(MAP_TYPE));
475
+ }
476
+
477
+ // Run the native code for the Array function called as a constructor.
478
+ ArrayNativeCode(masm, &generic_constructor);
479
+
480
+ // Jump to the generic construct code in case the specialized code cannot
481
+ // handle the construction.
482
+ __ bind(&generic_constructor);
483
+
484
+ Handle<Code> generic_construct_stub =
485
+ masm->isolate()->builtins()->JSConstructStubGeneric();
486
+ __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET);
487
+ }
488
+
489
+
490
+ void Builtins::Generate_StringConstructCode(MacroAssembler* masm) {
491
+ // ----------- S t a t e -------------
492
+ // -- a0 : number of arguments
493
+ // -- a1 : constructor function
494
+ // -- ra : return address
495
+ // -- sp[(argc - n - 1) * 4] : arg[n] (zero based)
496
+ // -- sp[argc * 4] : receiver
497
+ // -----------------------------------
498
+ Counters* counters = masm->isolate()->counters();
499
+ __ IncrementCounter(counters->string_ctor_calls(), 1, a2, a3);
500
+
501
+ Register function = a1;
502
+ if (FLAG_debug_code) {
503
+ __ LoadGlobalFunction(Context::STRING_FUNCTION_INDEX, a2);
504
+ __ Assert(eq, "Unexpected String function", function, Operand(a2));
505
+ }
506
+
507
+ // Load the first arguments in a0 and get rid of the rest.
508
+ Label no_arguments;
509
+ __ Branch(&no_arguments, eq, a0, Operand(zero_reg));
510
+ // First args = sp[(argc - 1) * 4].
511
+ __ Subu(a0, a0, Operand(1));
512
+ __ sll(a0, a0, kPointerSizeLog2);
513
+ __ Addu(sp, a0, sp);
514
+ __ lw(a0, MemOperand(sp));
515
+ // sp now point to args[0], drop args[0] + receiver.
516
+ __ Drop(2);
517
+
518
+ Register argument = a2;
519
+ Label not_cached, argument_is_string;
520
+ NumberToStringStub::GenerateLookupNumberStringCache(
521
+ masm,
522
+ a0, // Input.
523
+ argument, // Result.
524
+ a3, // Scratch.
525
+ t0, // Scratch.
526
+ t1, // Scratch.
527
+ false, // Is it a Smi?
528
+ &not_cached);
529
+ __ IncrementCounter(counters->string_ctor_cached_number(), 1, a3, t0);
530
+ __ bind(&argument_is_string);
531
+
532
+ // ----------- S t a t e -------------
533
+ // -- a2 : argument converted to string
534
+ // -- a1 : constructor function
535
+ // -- ra : return address
536
+ // -----------------------------------
537
+
538
+ Label gc_required;
539
+ __ AllocateInNewSpace(JSValue::kSize,
540
+ v0, // Result.
541
+ a3, // Scratch.
542
+ t0, // Scratch.
543
+ &gc_required,
544
+ TAG_OBJECT);
545
+
546
+ // Initialising the String Object.
547
+ Register map = a3;
548
+ __ LoadGlobalFunctionInitialMap(function, map, t0);
549
+ if (FLAG_debug_code) {
550
+ __ lbu(t0, FieldMemOperand(map, Map::kInstanceSizeOffset));
551
+ __ Assert(eq, "Unexpected string wrapper instance size",
552
+ t0, Operand(JSValue::kSize >> kPointerSizeLog2));
553
+ __ lbu(t0, FieldMemOperand(map, Map::kUnusedPropertyFieldsOffset));
554
+ __ Assert(eq, "Unexpected unused properties of string wrapper",
555
+ t0, Operand(zero_reg));
556
+ }
557
+ __ sw(map, FieldMemOperand(v0, HeapObject::kMapOffset));
558
+
559
+ __ LoadRoot(a3, Heap::kEmptyFixedArrayRootIndex);
560
+ __ sw(a3, FieldMemOperand(v0, JSObject::kPropertiesOffset));
561
+ __ sw(a3, FieldMemOperand(v0, JSObject::kElementsOffset));
562
+
563
+ __ sw(argument, FieldMemOperand(v0, JSValue::kValueOffset));
564
+
565
+ // Ensure the object is fully initialized.
566
+ STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize);
567
+
568
+ __ Ret();
569
+
570
+ // The argument was not found in the number to string cache. Check
571
+ // if it's a string already before calling the conversion builtin.
572
+ Label convert_argument;
573
+ __ bind(&not_cached);
574
+ __ JumpIfSmi(a0, &convert_argument);
575
+
576
+ // Is it a String?
577
+ __ lw(a2, FieldMemOperand(a0, HeapObject::kMapOffset));
578
+ __ lbu(a3, FieldMemOperand(a2, Map::kInstanceTypeOffset));
579
+ ASSERT(kNotStringTag != 0);
580
+ __ And(t0, a3, Operand(kIsNotStringMask));
581
+ __ Branch(&convert_argument, ne, t0, Operand(zero_reg));
582
+ __ mov(argument, a0);
583
+ __ IncrementCounter(counters->string_ctor_conversions(), 1, a3, t0);
584
+ __ Branch(&argument_is_string);
585
+
586
+ // Invoke the conversion builtin and put the result into a2.
587
+ __ bind(&convert_argument);
588
+ __ push(function); // Preserve the function.
589
+ __ IncrementCounter(counters->string_ctor_conversions(), 1, a3, t0);
590
+ __ EnterInternalFrame();
591
+ __ push(v0);
592
+ __ InvokeBuiltin(Builtins::TO_STRING, CALL_FUNCTION);
593
+ __ LeaveInternalFrame();
594
+ __ pop(function);
595
+ __ mov(argument, v0);
596
+ __ Branch(&argument_is_string);
597
+
598
+ // Load the empty string into a2, remove the receiver from the
599
+ // stack, and jump back to the case where the argument is a string.
600
+ __ bind(&no_arguments);
601
+ __ LoadRoot(argument, Heap::kEmptyStringRootIndex);
602
+ __ Drop(1);
603
+ __ Branch(&argument_is_string);
604
+
605
+ // At this point the argument is already a string. Call runtime to
606
+ // create a string wrapper.
607
+ __ bind(&gc_required);
608
+ __ IncrementCounter(counters->string_ctor_gc_required(), 1, a3, t0);
609
+ __ EnterInternalFrame();
610
+ __ push(argument);
611
+ __ CallRuntime(Runtime::kNewStringWrapper, 1);
612
+ __ LeaveInternalFrame();
613
+ __ Ret();
614
+ }
615
+
616
+
617
+ void Builtins::Generate_JSConstructCall(MacroAssembler* masm) {
618
+ // ----------- S t a t e -------------
619
+ // -- a0 : number of arguments
620
+ // -- a1 : constructor function
621
+ // -- ra : return address
622
+ // -- sp[...]: constructor arguments
623
+ // -----------------------------------
624
+
625
+ Label non_function_call;
626
+ // Check that the function is not a smi.
627
+ __ And(t0, a1, Operand(kSmiTagMask));
628
+ __ Branch(&non_function_call, eq, t0, Operand(zero_reg));
629
+ // Check that the function is a JSFunction.
630
+ __ GetObjectType(a1, a2, a2);
631
+ __ Branch(&non_function_call, ne, a2, Operand(JS_FUNCTION_TYPE));
632
+
633
+ // Jump to the function-specific construct stub.
634
+ __ lw(a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset));
635
+ __ lw(a2, FieldMemOperand(a2, SharedFunctionInfo::kConstructStubOffset));
636
+ __ Addu(t9, a2, Operand(Code::kHeaderSize - kHeapObjectTag));
637
+ __ Jump(Operand(t9));
638
+
639
+ // a0: number of arguments
640
+ // a1: called object
641
+ __ bind(&non_function_call);
642
+ // CALL_NON_FUNCTION expects the non-function constructor as receiver
643
+ // (instead of the original receiver from the call site). The receiver is
644
+ // stack element argc.
645
+ // Set expected number of arguments to zero (not changing a0).
646
+ __ mov(a2, zero_reg);
647
+ __ GetBuiltinEntry(a3, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR);
648
+ __ SetCallKind(t1, CALL_AS_METHOD);
649
+ __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(),
650
+ RelocInfo::CODE_TARGET);
651
+ }
652
+
653
+
654
+ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
655
+ bool is_api_function,
656
+ bool count_constructions) {
657
+ // Should never count constructions for api objects.
658
+ ASSERT(!is_api_function || !count_constructions);
659
+
660
+ Isolate* isolate = masm->isolate();
661
+
662
+ // ----------- S t a t e -------------
663
+ // -- a0 : number of arguments
664
+ // -- a1 : constructor function
665
+ // -- ra : return address
666
+ // -- sp[...]: constructor arguments
667
+ // -----------------------------------
668
+
669
+ // Enter a construct frame.
670
+ __ EnterConstructFrame();
671
+
672
+ // Preserve the two incoming parameters on the stack.
673
+ __ sll(a0, a0, kSmiTagSize); // Tag arguments count.
674
+ __ MultiPushReversed(a0.bit() | a1.bit());
675
+
676
+ // Use t7 to hold undefined, which is used in several places below.
677
+ __ LoadRoot(t7, Heap::kUndefinedValueRootIndex);
678
+
679
+ Label rt_call, allocated;
680
+ // Try to allocate the object without transitioning into C code. If any of the
681
+ // preconditions is not met, the code bails out to the runtime call.
682
+ if (FLAG_inline_new) {
683
+ Label undo_allocation;
684
+ #ifdef ENABLE_DEBUGGER_SUPPORT
685
+ ExternalReference debug_step_in_fp =
686
+ ExternalReference::debug_step_in_fp_address(isolate);
687
+ __ li(a2, Operand(debug_step_in_fp));
688
+ __ lw(a2, MemOperand(a2));
689
+ __ Branch(&rt_call, ne, a2, Operand(zero_reg));
690
+ #endif
691
+
692
+ // Load the initial map and verify that it is in fact a map.
693
+ // a1: constructor function
694
+ __ lw(a2, FieldMemOperand(a1, JSFunction::kPrototypeOrInitialMapOffset));
695
+ __ And(t0, a2, Operand(kSmiTagMask));
696
+ __ Branch(&rt_call, eq, t0, Operand(zero_reg));
697
+ __ GetObjectType(a2, a3, t4);
698
+ __ Branch(&rt_call, ne, t4, Operand(MAP_TYPE));
699
+
700
+ // Check that the constructor is not constructing a JSFunction (see comments
701
+ // in Runtime_NewObject in runtime.cc). In which case the initial map's
702
+ // instance type would be JS_FUNCTION_TYPE.
703
+ // a1: constructor function
704
+ // a2: initial map
705
+ __ lbu(a3, FieldMemOperand(a2, Map::kInstanceTypeOffset));
706
+ __ Branch(&rt_call, eq, a3, Operand(JS_FUNCTION_TYPE));
707
+
708
+ if (count_constructions) {
709
+ Label allocate;
710
+ // Decrease generous allocation count.
711
+ __ lw(a3, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset));
712
+ MemOperand constructor_count =
713
+ FieldMemOperand(a3, SharedFunctionInfo::kConstructionCountOffset);
714
+ __ lbu(t0, constructor_count);
715
+ __ Subu(t0, t0, Operand(1));
716
+ __ sb(t0, constructor_count);
717
+ __ Branch(&allocate, ne, t0, Operand(zero_reg));
718
+
719
+ __ Push(a1, a2);
720
+
721
+ __ push(a1); // Constructor.
722
+ // The call will replace the stub, so the countdown is only done once.
723
+ __ CallRuntime(Runtime::kFinalizeInstanceSize, 1);
724
+
725
+ __ pop(a2);
726
+ __ pop(a1);
727
+
728
+ __ bind(&allocate);
729
+ }
730
+
731
+ // Now allocate the JSObject on the heap.
732
+ // a1: constructor function
733
+ // a2: initial map
734
+ __ lbu(a3, FieldMemOperand(a2, Map::kInstanceSizeOffset));
735
+ __ AllocateInNewSpace(a3, t4, t5, t6, &rt_call, SIZE_IN_WORDS);
736
+
737
+ // Allocated the JSObject, now initialize the fields. Map is set to initial
738
+ // map and properties and elements are set to empty fixed array.
739
+ // a1: constructor function
740
+ // a2: initial map
741
+ // a3: object size
742
+ // t4: JSObject (not tagged)
743
+ __ LoadRoot(t6, Heap::kEmptyFixedArrayRootIndex);
744
+ __ mov(t5, t4);
745
+ __ sw(a2, MemOperand(t5, JSObject::kMapOffset));
746
+ __ sw(t6, MemOperand(t5, JSObject::kPropertiesOffset));
747
+ __ sw(t6, MemOperand(t5, JSObject::kElementsOffset));
748
+ __ Addu(t5, t5, Operand(3*kPointerSize));
749
+ ASSERT_EQ(0 * kPointerSize, JSObject::kMapOffset);
750
+ ASSERT_EQ(1 * kPointerSize, JSObject::kPropertiesOffset);
751
+ ASSERT_EQ(2 * kPointerSize, JSObject::kElementsOffset);
752
+
753
+ // Fill all the in-object properties with appropriate filler.
754
+ // a1: constructor function
755
+ // a2: initial map
756
+ // a3: object size (in words)
757
+ // t4: JSObject (not tagged)
758
+ // t5: First in-object property of JSObject (not tagged)
759
+ __ sll(t0, a3, kPointerSizeLog2);
760
+ __ addu(t6, t4, t0); // End of object.
761
+ ASSERT_EQ(3 * kPointerSize, JSObject::kHeaderSize);
762
+ { Label loop, entry;
763
+ if (count_constructions) {
764
+ // To allow for truncation.
765
+ __ LoadRoot(t7, Heap::kOnePointerFillerMapRootIndex);
766
+ } else {
767
+ __ LoadRoot(t7, Heap::kUndefinedValueRootIndex);
768
+ }
769
+ __ jmp(&entry);
770
+ __ bind(&loop);
771
+ __ sw(t7, MemOperand(t5, 0));
772
+ __ addiu(t5, t5, kPointerSize);
773
+ __ bind(&entry);
774
+ __ Branch(&loop, Uless, t5, Operand(t6));
775
+ }
776
+
777
+ // Add the object tag to make the JSObject real, so that we can continue and
778
+ // jump into the continuation code at any time from now on. Any failures
779
+ // need to undo the allocation, so that the heap is in a consistent state
780
+ // and verifiable.
781
+ __ Addu(t4, t4, Operand(kHeapObjectTag));
782
+
783
+ // Check if a non-empty properties array is needed. Continue with allocated
784
+ // object if not fall through to runtime call if it is.
785
+ // a1: constructor function
786
+ // t4: JSObject
787
+ // t5: start of next object (not tagged)
788
+ __ lbu(a3, FieldMemOperand(a2, Map::kUnusedPropertyFieldsOffset));
789
+ // The field instance sizes contains both pre-allocated property fields and
790
+ // in-object properties.
791
+ __ lw(a0, FieldMemOperand(a2, Map::kInstanceSizesOffset));
792
+ __ And(t6,
793
+ a0,
794
+ Operand(0x000000FF << Map::kPreAllocatedPropertyFieldsByte * 8));
795
+ __ srl(t0, t6, Map::kPreAllocatedPropertyFieldsByte * 8);
796
+ __ Addu(a3, a3, Operand(t0));
797
+ __ And(t6, a0, Operand(0x000000FF << Map::kInObjectPropertiesByte * 8));
798
+ __ srl(t0, t6, Map::kInObjectPropertiesByte * 8);
799
+ __ subu(a3, a3, t0);
800
+
801
+ // Done if no extra properties are to be allocated.
802
+ __ Branch(&allocated, eq, a3, Operand(zero_reg));
803
+ __ Assert(greater_equal, "Property allocation count failed.",
804
+ a3, Operand(zero_reg));
805
+
806
+ // Scale the number of elements by pointer size and add the header for
807
+ // FixedArrays to the start of the next object calculation from above.
808
+ // a1: constructor
809
+ // a3: number of elements in properties array
810
+ // t4: JSObject
811
+ // t5: start of next object
812
+ __ Addu(a0, a3, Operand(FixedArray::kHeaderSize / kPointerSize));
813
+ __ AllocateInNewSpace(
814
+ a0,
815
+ t5,
816
+ t6,
817
+ a2,
818
+ &undo_allocation,
819
+ static_cast<AllocationFlags>(RESULT_CONTAINS_TOP | SIZE_IN_WORDS));
820
+
821
+ // Initialize the FixedArray.
822
+ // a1: constructor
823
+ // a3: number of elements in properties array (un-tagged)
824
+ // t4: JSObject
825
+ // t5: start of next object
826
+ __ LoadRoot(t6, Heap::kFixedArrayMapRootIndex);
827
+ __ mov(a2, t5);
828
+ __ sw(t6, MemOperand(a2, JSObject::kMapOffset));
829
+ __ sll(a0, a3, kSmiTagSize);
830
+ __ sw(a0, MemOperand(a2, FixedArray::kLengthOffset));
831
+ __ Addu(a2, a2, Operand(2 * kPointerSize));
832
+
833
+ ASSERT_EQ(0 * kPointerSize, JSObject::kMapOffset);
834
+ ASSERT_EQ(1 * kPointerSize, FixedArray::kLengthOffset);
835
+
836
+ // Initialize the fields to undefined.
837
+ // a1: constructor
838
+ // a2: First element of FixedArray (not tagged)
839
+ // a3: number of elements in properties array
840
+ // t4: JSObject
841
+ // t5: FixedArray (not tagged)
842
+ __ sll(t3, a3, kPointerSizeLog2);
843
+ __ addu(t6, a2, t3); // End of object.
844
+ ASSERT_EQ(2 * kPointerSize, FixedArray::kHeaderSize);
845
+ { Label loop, entry;
846
+ if (count_constructions) {
847
+ __ LoadRoot(t7, Heap::kUndefinedValueRootIndex);
848
+ } else if (FLAG_debug_code) {
849
+ __ LoadRoot(t8, Heap::kUndefinedValueRootIndex);
850
+ __ Assert(eq, "Undefined value not loaded.", t7, Operand(t8));
851
+ }
852
+ __ jmp(&entry);
853
+ __ bind(&loop);
854
+ __ sw(t7, MemOperand(a2));
855
+ __ addiu(a2, a2, kPointerSize);
856
+ __ bind(&entry);
857
+ __ Branch(&loop, less, a2, Operand(t6));
858
+ }
859
+
860
+ // Store the initialized FixedArray into the properties field of
861
+ // the JSObject.
862
+ // a1: constructor function
863
+ // t4: JSObject
864
+ // t5: FixedArray (not tagged)
865
+ __ Addu(t5, t5, Operand(kHeapObjectTag)); // Add the heap tag.
866
+ __ sw(t5, FieldMemOperand(t4, JSObject::kPropertiesOffset));
867
+
868
+ // Continue with JSObject being successfully allocated.
869
+ // a1: constructor function
870
+ // a4: JSObject
871
+ __ jmp(&allocated);
872
+
873
+ // Undo the setting of the new top so that the heap is verifiable. For
874
+ // example, the map's unused properties potentially do not match the
875
+ // allocated objects unused properties.
876
+ // t4: JSObject (previous new top)
877
+ __ bind(&undo_allocation);
878
+ __ UndoAllocationInNewSpace(t4, t5);
879
+ }
880
+
881
+ __ bind(&rt_call);
882
+ // Allocate the new receiver object using the runtime call.
883
+ // a1: constructor function
884
+ __ push(a1); // Argument for Runtime_NewObject.
885
+ __ CallRuntime(Runtime::kNewObject, 1);
886
+ __ mov(t4, v0);
887
+
888
+ // Receiver for constructor call allocated.
889
+ // t4: JSObject
890
+ __ bind(&allocated);
891
+ __ push(t4);
892
+
893
+ // Push the function and the allocated receiver from the stack.
894
+ // sp[0]: receiver (newly allocated object)
895
+ // sp[1]: constructor function
896
+ // sp[2]: number of arguments (smi-tagged)
897
+ __ lw(a1, MemOperand(sp, kPointerSize));
898
+ __ MultiPushReversed(a1.bit() | t4.bit());
899
+
900
+ // Reload the number of arguments from the stack.
901
+ // a1: constructor function
902
+ // sp[0]: receiver
903
+ // sp[1]: constructor function
904
+ // sp[2]: receiver
905
+ // sp[3]: constructor function
906
+ // sp[4]: number of arguments (smi-tagged)
907
+ __ lw(a3, MemOperand(sp, 4 * kPointerSize));
908
+
909
+ // Setup pointer to last argument.
910
+ __ Addu(a2, fp, Operand(StandardFrameConstants::kCallerSPOffset));
911
+
912
+ // Setup number of arguments for function call below.
913
+ __ srl(a0, a3, kSmiTagSize);
914
+
915
+ // Copy arguments and receiver to the expression stack.
916
+ // a0: number of arguments
917
+ // a1: constructor function
918
+ // a2: address of last argument (caller sp)
919
+ // a3: number of arguments (smi-tagged)
920
+ // sp[0]: receiver
921
+ // sp[1]: constructor function
922
+ // sp[2]: receiver
923
+ // sp[3]: constructor function
924
+ // sp[4]: number of arguments (smi-tagged)
925
+ Label loop, entry;
926
+ __ jmp(&entry);
927
+ __ bind(&loop);
928
+ __ sll(t0, a3, kPointerSizeLog2 - kSmiTagSize);
929
+ __ Addu(t0, a2, Operand(t0));
930
+ __ lw(t1, MemOperand(t0));
931
+ __ push(t1);
932
+ __ bind(&entry);
933
+ __ Addu(a3, a3, Operand(-2));
934
+ __ Branch(&loop, greater_equal, a3, Operand(zero_reg));
935
+
936
+ // Call the function.
937
+ // a0: number of arguments
938
+ // a1: constructor function
939
+ if (is_api_function) {
940
+ __ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset));
941
+ Handle<Code> code =
942
+ masm->isolate()->builtins()->HandleApiCallConstruct();
943
+ ParameterCount expected(0);
944
+ __ InvokeCode(code, expected, expected,
945
+ RelocInfo::CODE_TARGET, CALL_FUNCTION);
946
+ } else {
947
+ ParameterCount actual(a0);
948
+ __ InvokeFunction(a1, actual, CALL_FUNCTION);
949
+ }
950
+
951
+ // Pop the function from the stack.
952
+ // v0: result
953
+ // sp[0]: constructor function
954
+ // sp[2]: receiver
955
+ // sp[3]: constructor function
956
+ // sp[4]: number of arguments (smi-tagged)
957
+ __ Pop();
958
+
959
+ // Restore context from the frame.
960
+ __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
961
+
962
+ // If the result is an object (in the ECMA sense), we should get rid
963
+ // of the receiver and use the result; see ECMA-262 section 13.2.2-7
964
+ // on page 74.
965
+ Label use_receiver, exit;
966
+
967
+ // If the result is a smi, it is *not* an object in the ECMA sense.
968
+ // v0: result
969
+ // sp[0]: receiver (newly allocated object)
970
+ // sp[1]: constructor function
971
+ // sp[2]: number of arguments (smi-tagged)
972
+ __ And(t0, v0, Operand(kSmiTagMask));
973
+ __ Branch(&use_receiver, eq, t0, Operand(zero_reg));
974
+
975
+ // If the type of the result (stored in its map) is less than
976
+ // FIRST_JS_OBJECT_TYPE, it is not an object in the ECMA sense.
977
+ __ GetObjectType(v0, a3, a3);
978
+ __ Branch(&exit, greater_equal, a3, Operand(FIRST_JS_OBJECT_TYPE));
979
+
980
+ // Throw away the result of the constructor invocation and use the
981
+ // on-stack receiver as the result.
982
+ __ bind(&use_receiver);
983
+ __ lw(v0, MemOperand(sp));
984
+
985
+ // Remove receiver from the stack, remove caller arguments, and
986
+ // return.
987
+ __ bind(&exit);
988
+ // v0: result
989
+ // sp[0]: receiver (newly allocated object)
990
+ // sp[1]: constructor function
991
+ // sp[2]: number of arguments (smi-tagged)
992
+ __ lw(a1, MemOperand(sp, 2 * kPointerSize));
993
+ __ LeaveConstructFrame();
994
+ __ sll(t0, a1, kPointerSizeLog2 - 1);
995
+ __ Addu(sp, sp, t0);
996
+ __ Addu(sp, sp, kPointerSize);
997
+ __ IncrementCounter(isolate->counters()->constructed_objects(), 1, a1, a2);
998
+ __ Ret();
999
+ }
1000
+
1001
+
1002
+ void Builtins::Generate_JSConstructStubCountdown(MacroAssembler* masm) {
1003
+ Generate_JSConstructStubHelper(masm, false, true);
1004
+ }
1005
+
1006
+
1007
+ void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) {
1008
+ Generate_JSConstructStubHelper(masm, false, false);
1009
+ }
1010
+
1011
+
1012
+ void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) {
1013
+ Generate_JSConstructStubHelper(masm, true, false);
1014
+ }
1015
+
1016
+
1017
+ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
1018
+ bool is_construct) {
1019
+ // Called from JSEntryStub::GenerateBody
1020
+
1021
+ // ----------- S t a t e -------------
1022
+ // -- a0: code entry
1023
+ // -- a1: function
1024
+ // -- a2: reveiver_pointer
1025
+ // -- a3: argc
1026
+ // -- s0: argv
1027
+ // -----------------------------------
1028
+
1029
+ // Clear the context before we push it when entering the JS frame.
1030
+ __ mov(cp, zero_reg);
1031
+
1032
+ // Enter an internal frame.
1033
+ __ EnterInternalFrame();
1034
+
1035
+ // Set up the context from the function argument.
1036
+ __ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset));
1037
+
1038
+ // Set up the roots register.
1039
+ ExternalReference roots_address =
1040
+ ExternalReference::roots_address(masm->isolate());
1041
+ __ li(s6, Operand(roots_address));
1042
+
1043
+ // Push the function and the receiver onto the stack.
1044
+ __ Push(a1, a2);
1045
+
1046
+ // Copy arguments to the stack in a loop.
1047
+ // a3: argc
1048
+ // s0: argv, ie points to first arg
1049
+ Label loop, entry;
1050
+ __ sll(t0, a3, kPointerSizeLog2);
1051
+ __ addu(t2, s0, t0);
1052
+ __ b(&entry);
1053
+ __ nop(); // Branch delay slot nop.
1054
+ // t2 points past last arg.
1055
+ __ bind(&loop);
1056
+ __ lw(t0, MemOperand(s0)); // Read next parameter.
1057
+ __ addiu(s0, s0, kPointerSize);
1058
+ __ lw(t0, MemOperand(t0)); // Dereference handle.
1059
+ __ push(t0); // Push parameter.
1060
+ __ bind(&entry);
1061
+ __ Branch(&loop, ne, s0, Operand(t2));
1062
+
1063
+ // Initialize all JavaScript callee-saved registers, since they will be seen
1064
+ // by the garbage collector as part of handlers.
1065
+ __ LoadRoot(t0, Heap::kUndefinedValueRootIndex);
1066
+ __ mov(s1, t0);
1067
+ __ mov(s2, t0);
1068
+ __ mov(s3, t0);
1069
+ __ mov(s4, t0);
1070
+ __ mov(s5, t0);
1071
+ // s6 holds the root address. Do not clobber.
1072
+ // s7 is cp. Do not init.
1073
+
1074
+ // Invoke the code and pass argc as a0.
1075
+ __ mov(a0, a3);
1076
+ if (is_construct) {
1077
+ __ Call(masm->isolate()->builtins()->JSConstructCall(),
1078
+ RelocInfo::CODE_TARGET);
1079
+ } else {
1080
+ ParameterCount actual(a0);
1081
+ __ InvokeFunction(a1, actual, CALL_FUNCTION);
1082
+ }
1083
+
1084
+ __ LeaveInternalFrame();
1085
+
1086
+ __ Jump(ra);
1087
+ }
1088
+
1089
+
1090
+ void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) {
1091
+ Generate_JSEntryTrampolineHelper(masm, false);
1092
+ }
1093
+
1094
+
1095
+ void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) {
1096
+ Generate_JSEntryTrampolineHelper(masm, true);
1097
+ }
1098
+
1099
+
1100
+ void Builtins::Generate_LazyCompile(MacroAssembler* masm) {
1101
+ // Enter an internal frame.
1102
+ __ EnterInternalFrame();
1103
+
1104
+ // Preserve the function.
1105
+ __ push(a1);
1106
+ // Push call kind information.
1107
+ __ push(t1);
1108
+
1109
+ // Push the function on the stack as the argument to the runtime function.
1110
+ __ push(a1);
1111
+ // Call the runtime function.
1112
+ __ CallRuntime(Runtime::kLazyCompile, 1);
1113
+ // Calculate the entry point.
1114
+ __ addiu(t9, v0, Code::kHeaderSize - kHeapObjectTag);
1115
+
1116
+ // Restore call kind information.
1117
+ __ pop(t1);
1118
+ // Restore saved function.
1119
+ __ pop(a1);
1120
+
1121
+ // Tear down temporary frame.
1122
+ __ LeaveInternalFrame();
1123
+
1124
+ // Do a tail-call of the compiled function.
1125
+ __ Jump(t9);
1126
+ }
1127
+
1128
+
1129
+ void Builtins::Generate_LazyRecompile(MacroAssembler* masm) {
1130
+ // Enter an internal frame.
1131
+ __ EnterInternalFrame();
1132
+
1133
+ // Preserve the function.
1134
+ __ push(a1);
1135
+ // Push call kind information.
1136
+ __ push(t1);
1137
+
1138
+ // Push the function on the stack as the argument to the runtime function.
1139
+ __ push(a1);
1140
+ __ CallRuntime(Runtime::kLazyRecompile, 1);
1141
+ // Calculate the entry point.
1142
+ __ Addu(t9, v0, Operand(Code::kHeaderSize - kHeapObjectTag));
1143
+
1144
+ // Restore call kind information.
1145
+ __ pop(t1);
1146
+ // Restore saved function.
1147
+ __ pop(a1);
1148
+
1149
+ // Tear down temporary frame.
1150
+ __ LeaveInternalFrame();
1151
+
1152
+ // Do a tail-call of the compiled function.
1153
+ __ Jump(t9);
1154
+ }
1155
+
1156
+
1157
+ // These functions are called from C++ but cannot be used in live code.
1158
+ void Builtins::Generate_NotifyDeoptimized(MacroAssembler* masm) {
1159
+ __ Abort("Call to unimplemented function in builtins-mips.cc");
1160
+ }
1161
+
1162
+
1163
+ void Builtins::Generate_NotifyLazyDeoptimized(MacroAssembler* masm) {
1164
+ __ Abort("Call to unimplemented function in builtins-mips.cc");
1165
+ }
1166
+
1167
+
1168
+ void Builtins::Generate_NotifyOSR(MacroAssembler* masm) {
1169
+ __ Abort("Call to unimplemented function in builtins-mips.cc");
1170
+ }
1171
+
1172
+
1173
+ void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) {
1174
+ __ Abort("Call to unimplemented function in builtins-mips.cc");
1175
+ }
1176
+
1177
+
1178
+ void Builtins::Generate_FunctionCall(MacroAssembler* masm) {
1179
+ // 1. Make sure we have at least one argument.
1180
+ // a0: actual number of arguments
1181
+ { Label done;
1182
+ __ Branch(&done, ne, a0, Operand(zero_reg));
1183
+ __ LoadRoot(t2, Heap::kUndefinedValueRootIndex);
1184
+ __ push(t2);
1185
+ __ Addu(a0, a0, Operand(1));
1186
+ __ bind(&done);
1187
+ }
1188
+
1189
+ // 2. Get the function to call (passed as receiver) from the stack, check
1190
+ // if it is a function.
1191
+ // a0: actual number of arguments
1192
+ Label non_function;
1193
+ __ sll(at, a0, kPointerSizeLog2);
1194
+ __ addu(at, sp, at);
1195
+ __ lw(a1, MemOperand(at));
1196
+ __ And(at, a1, Operand(kSmiTagMask));
1197
+ __ Branch(&non_function, eq, at, Operand(zero_reg));
1198
+ __ GetObjectType(a1, a2, a2);
1199
+ __ Branch(&non_function, ne, a2, Operand(JS_FUNCTION_TYPE));
1200
+
1201
+ // 3a. Patch the first argument if necessary when calling a function.
1202
+ // a0: actual number of arguments
1203
+ // a1: function
1204
+ Label shift_arguments;
1205
+ { Label convert_to_object, use_global_receiver, patch_receiver;
1206
+ // Change context eagerly in case we need the global receiver.
1207
+ __ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset));
1208
+
1209
+ // Do not transform the receiver for strict mode functions.
1210
+ __ lw(a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset));
1211
+ __ lw(a3, FieldMemOperand(a2, SharedFunctionInfo::kCompilerHintsOffset));
1212
+ __ And(t0, a3, Operand(1 << (SharedFunctionInfo::kStrictModeFunction +
1213
+ kSmiTagSize)));
1214
+ __ Branch(&shift_arguments, ne, t0, Operand(zero_reg));
1215
+
1216
+ // Do not transform the receiver for native (Compilerhints already in a3).
1217
+ __ And(t0, a3, Operand(1 << (SharedFunctionInfo::kES5Native +
1218
+ kSmiTagSize)));
1219
+ __ Branch(&shift_arguments, ne, t0, Operand(zero_reg));
1220
+
1221
+ // Compute the receiver in non-strict mode.
1222
+ // Load first argument in a2. a2 = -kPointerSize(sp + n_args << 2).
1223
+ __ sll(at, a0, kPointerSizeLog2);
1224
+ __ addu(a2, sp, at);
1225
+ __ lw(a2, MemOperand(a2, -kPointerSize));
1226
+ // a0: actual number of arguments
1227
+ // a1: function
1228
+ // a2: first argument
1229
+ __ JumpIfSmi(a2, &convert_to_object, t2);
1230
+
1231
+ __ LoadRoot(a3, Heap::kUndefinedValueRootIndex);
1232
+ __ Branch(&use_global_receiver, eq, a2, Operand(a3));
1233
+ __ LoadRoot(a3, Heap::kNullValueRootIndex);
1234
+ __ Branch(&use_global_receiver, eq, a2, Operand(a3));
1235
+
1236
+ STATIC_ASSERT(LAST_JS_OBJECT_TYPE + 1 == LAST_TYPE);
1237
+ STATIC_ASSERT(LAST_TYPE == JS_FUNCTION_TYPE);
1238
+ __ GetObjectType(a2, a3, a3);
1239
+ __ Branch(&shift_arguments, ge, a3, Operand(FIRST_JS_OBJECT_TYPE));
1240
+
1241
+ __ bind(&convert_to_object);
1242
+ __ EnterInternalFrame(); // In order to preserve argument count.
1243
+ __ sll(a0, a0, kSmiTagSize); // Smi tagged.
1244
+ __ push(a0);
1245
+
1246
+ __ push(a2);
1247
+ __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION);
1248
+ __ mov(a2, v0);
1249
+
1250
+ __ pop(a0);
1251
+ __ sra(a0, a0, kSmiTagSize); // Un-tag.
1252
+ __ LeaveInternalFrame();
1253
+ // Restore the function to a1.
1254
+ __ sll(at, a0, kPointerSizeLog2);
1255
+ __ addu(at, sp, at);
1256
+ __ lw(a1, MemOperand(at));
1257
+ __ Branch(&patch_receiver);
1258
+
1259
+ // Use the global receiver object from the called function as the
1260
+ // receiver.
1261
+ __ bind(&use_global_receiver);
1262
+ const int kGlobalIndex =
1263
+ Context::kHeaderSize + Context::GLOBAL_INDEX * kPointerSize;
1264
+ __ lw(a2, FieldMemOperand(cp, kGlobalIndex));
1265
+ __ lw(a2, FieldMemOperand(a2, GlobalObject::kGlobalContextOffset));
1266
+ __ lw(a2, FieldMemOperand(a2, kGlobalIndex));
1267
+ __ lw(a2, FieldMemOperand(a2, GlobalObject::kGlobalReceiverOffset));
1268
+
1269
+ __ bind(&patch_receiver);
1270
+ __ sll(at, a0, kPointerSizeLog2);
1271
+ __ addu(a3, sp, at);
1272
+ __ sw(a2, MemOperand(a3, -kPointerSize));
1273
+
1274
+ __ Branch(&shift_arguments);
1275
+ }
1276
+
1277
+ // 3b. Patch the first argument when calling a non-function. The
1278
+ // CALL_NON_FUNCTION builtin expects the non-function callee as
1279
+ // receiver, so overwrite the first argument which will ultimately
1280
+ // become the receiver.
1281
+ // a0: actual number of arguments
1282
+ // a1: function
1283
+ __ bind(&non_function);
1284
+ // Restore the function in case it has been modified.
1285
+ __ sll(at, a0, kPointerSizeLog2);
1286
+ __ addu(a2, sp, at);
1287
+ __ sw(a1, MemOperand(a2, -kPointerSize));
1288
+ // Clear a1 to indicate a non-function being called.
1289
+ __ mov(a1, zero_reg);
1290
+
1291
+ // 4. Shift arguments and return address one slot down on the stack
1292
+ // (overwriting the original receiver). Adjust argument count to make
1293
+ // the original first argument the new receiver.
1294
+ // a0: actual number of arguments
1295
+ // a1: function
1296
+ __ bind(&shift_arguments);
1297
+ { Label loop;
1298
+ // Calculate the copy start address (destination). Copy end address is sp.
1299
+ __ sll(at, a0, kPointerSizeLog2);
1300
+ __ addu(a2, sp, at);
1301
+
1302
+ __ bind(&loop);
1303
+ __ lw(at, MemOperand(a2, -kPointerSize));
1304
+ __ sw(at, MemOperand(a2));
1305
+ __ Subu(a2, a2, Operand(kPointerSize));
1306
+ __ Branch(&loop, ne, a2, Operand(sp));
1307
+ // Adjust the actual number of arguments and remove the top element
1308
+ // (which is a copy of the last argument).
1309
+ __ Subu(a0, a0, Operand(1));
1310
+ __ Pop();
1311
+ }
1312
+
1313
+ // 5a. Call non-function via tail call to CALL_NON_FUNCTION builtin.
1314
+ // a0: actual number of arguments
1315
+ // a1: function
1316
+ { Label function;
1317
+ __ Branch(&function, ne, a1, Operand(zero_reg));
1318
+ __ mov(a2, zero_reg); // expected arguments is 0 for CALL_NON_FUNCTION
1319
+ __ GetBuiltinEntry(a3, Builtins::CALL_NON_FUNCTION);
1320
+ __ SetCallKind(t1, CALL_AS_METHOD);
1321
+ __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(),
1322
+ RelocInfo::CODE_TARGET);
1323
+ __ bind(&function);
1324
+ }
1325
+
1326
+ // 5b. Get the code to call from the function and check that the number of
1327
+ // expected arguments matches what we're providing. If so, jump
1328
+ // (tail-call) to the code in register edx without checking arguments.
1329
+ // a0: actual number of arguments
1330
+ // a1: function
1331
+ __ lw(a3, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset));
1332
+ __ lw(a2,
1333
+ FieldMemOperand(a3, SharedFunctionInfo::kFormalParameterCountOffset));
1334
+ __ sra(a2, a2, kSmiTagSize);
1335
+ __ lw(a3, FieldMemOperand(a1, JSFunction::kCodeEntryOffset));
1336
+ __ SetCallKind(t1, CALL_AS_METHOD);
1337
+ // Check formal and actual parameter counts.
1338
+ __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(),
1339
+ RelocInfo::CODE_TARGET, ne, a2, Operand(a0));
1340
+
1341
+ ParameterCount expected(0);
1342
+ __ InvokeCode(a3, expected, expected, JUMP_FUNCTION);
1343
+ }
1344
+
1345
+
1346
+ void Builtins::Generate_FunctionApply(MacroAssembler* masm) {
1347
+ const int kIndexOffset = -5 * kPointerSize;
1348
+ const int kLimitOffset = -4 * kPointerSize;
1349
+ const int kArgsOffset = 2 * kPointerSize;
1350
+ const int kRecvOffset = 3 * kPointerSize;
1351
+ const int kFunctionOffset = 4 * kPointerSize;
1352
+
1353
+ __ EnterInternalFrame();
1354
+
1355
+ __ lw(a0, MemOperand(fp, kFunctionOffset)); // Get the function.
1356
+ __ push(a0);
1357
+ __ lw(a0, MemOperand(fp, kArgsOffset)); // Get the args array.
1358
+ __ push(a0);
1359
+ // Returns (in v0) number of arguments to copy to stack as Smi.
1360
+ __ InvokeBuiltin(Builtins::APPLY_PREPARE, CALL_FUNCTION);
1361
+
1362
+ // Check the stack for overflow. We are not trying need to catch
1363
+ // interruptions (e.g. debug break and preemption) here, so the "real stack
1364
+ // limit" is checked.
1365
+ Label okay;
1366
+ __ LoadRoot(a2, Heap::kRealStackLimitRootIndex);
1367
+ // Make a2 the space we have left. The stack might already be overflowed
1368
+ // here which will cause a2 to become negative.
1369
+ __ subu(a2, sp, a2);
1370
+ // Check if the arguments will overflow the stack.
1371
+ __ sll(t0, v0, kPointerSizeLog2 - kSmiTagSize);
1372
+ __ Branch(&okay, gt, a2, Operand(t0)); // Signed comparison.
1373
+
1374
+ // Out of stack space.
1375
+ __ lw(a1, MemOperand(fp, kFunctionOffset));
1376
+ __ push(a1);
1377
+ __ push(v0);
1378
+ __ InvokeBuiltin(Builtins::APPLY_OVERFLOW, CALL_FUNCTION);
1379
+ // End of stack check.
1380
+
1381
+ // Push current limit and index.
1382
+ __ bind(&okay);
1383
+ __ push(v0); // Limit.
1384
+ __ mov(a1, zero_reg); // Initial index.
1385
+ __ push(a1);
1386
+
1387
+ // Change context eagerly to get the right global object if necessary.
1388
+ __ lw(a0, MemOperand(fp, kFunctionOffset));
1389
+ __ lw(cp, FieldMemOperand(a0, JSFunction::kContextOffset));
1390
+ // Load the shared function info while the function is still in a0.
1391
+ __ lw(a1, FieldMemOperand(a0, JSFunction::kSharedFunctionInfoOffset));
1392
+
1393
+ // Compute the receiver.
1394
+ Label call_to_object, use_global_receiver, push_receiver;
1395
+ __ lw(a0, MemOperand(fp, kRecvOffset));
1396
+
1397
+ // Do not transform the receiver for strict mode functions.
1398
+ __ lw(a2, FieldMemOperand(a1, SharedFunctionInfo::kCompilerHintsOffset));
1399
+ __ And(t0, a2, Operand(1 << (SharedFunctionInfo::kStrictModeFunction +
1400
+ kSmiTagSize)));
1401
+ __ Branch(&push_receiver, ne, t0, Operand(zero_reg));
1402
+
1403
+ // Do not transform the receiver for native (Compilerhints already in a2).
1404
+ __ And(t0, a2, Operand(1 << (SharedFunctionInfo::kES5Native +
1405
+ kSmiTagSize)));
1406
+ __ Branch(&push_receiver, ne, t0, Operand(zero_reg));
1407
+
1408
+ // Compute the receiver in non-strict mode.
1409
+ __ And(t0, a0, Operand(kSmiTagMask));
1410
+ __ Branch(&call_to_object, eq, t0, Operand(zero_reg));
1411
+ __ LoadRoot(a1, Heap::kNullValueRootIndex);
1412
+ __ Branch(&use_global_receiver, eq, a0, Operand(a1));
1413
+ __ LoadRoot(a2, Heap::kUndefinedValueRootIndex);
1414
+ __ Branch(&use_global_receiver, eq, a0, Operand(a2));
1415
+
1416
+ // Check if the receiver is already a JavaScript object.
1417
+ // a0: receiver
1418
+ STATIC_ASSERT(LAST_JS_OBJECT_TYPE + 1 == LAST_TYPE);
1419
+ STATIC_ASSERT(LAST_TYPE == JS_FUNCTION_TYPE);
1420
+ __ GetObjectType(a0, a1, a1);
1421
+ __ Branch(&push_receiver, ge, a1, Operand(FIRST_JS_OBJECT_TYPE));
1422
+
1423
+ // Convert the receiver to a regular object.
1424
+ // a0: receiver
1425
+ __ bind(&call_to_object);
1426
+ __ push(a0);
1427
+ __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION);
1428
+ __ mov(a0, v0); // Put object in a0 to match other paths to push_receiver.
1429
+ __ Branch(&push_receiver);
1430
+
1431
+ // Use the current global receiver object as the receiver.
1432
+ __ bind(&use_global_receiver);
1433
+ const int kGlobalOffset =
1434
+ Context::kHeaderSize + Context::GLOBAL_INDEX * kPointerSize;
1435
+ __ lw(a0, FieldMemOperand(cp, kGlobalOffset));
1436
+ __ lw(a0, FieldMemOperand(a0, GlobalObject::kGlobalContextOffset));
1437
+ __ lw(a0, FieldMemOperand(a0, kGlobalOffset));
1438
+ __ lw(a0, FieldMemOperand(a0, GlobalObject::kGlobalReceiverOffset));
1439
+
1440
+ // Push the receiver.
1441
+ // a0: receiver
1442
+ __ bind(&push_receiver);
1443
+ __ push(a0);
1444
+
1445
+ // Copy all arguments from the array to the stack.
1446
+ Label entry, loop;
1447
+ __ lw(a0, MemOperand(fp, kIndexOffset));
1448
+ __ Branch(&entry);
1449
+
1450
+ // Load the current argument from the arguments array and push it to the
1451
+ // stack.
1452
+ // a0: current argument index
1453
+ __ bind(&loop);
1454
+ __ lw(a1, MemOperand(fp, kArgsOffset));
1455
+ __ push(a1);
1456
+ __ push(a0);
1457
+
1458
+ // Call the runtime to access the property in the arguments array.
1459
+ __ CallRuntime(Runtime::kGetProperty, 2);
1460
+ __ push(v0);
1461
+
1462
+ // Use inline caching to access the arguments.
1463
+ __ lw(a0, MemOperand(fp, kIndexOffset));
1464
+ __ Addu(a0, a0, Operand(1 << kSmiTagSize));
1465
+ __ sw(a0, MemOperand(fp, kIndexOffset));
1466
+
1467
+ // Test if the copy loop has finished copying all the elements from the
1468
+ // arguments object.
1469
+ __ bind(&entry);
1470
+ __ lw(a1, MemOperand(fp, kLimitOffset));
1471
+ __ Branch(&loop, ne, a0, Operand(a1));
1472
+ // Invoke the function.
1473
+ ParameterCount actual(a0);
1474
+ __ sra(a0, a0, kSmiTagSize);
1475
+ __ lw(a1, MemOperand(fp, kFunctionOffset));
1476
+ __ InvokeFunction(a1, actual, CALL_FUNCTION);
1477
+
1478
+ // Tear down the internal frame and remove function, receiver and args.
1479
+ __ LeaveInternalFrame();
1480
+ __ Addu(sp, sp, Operand(3 * kPointerSize));
1481
+ __ Ret();
1482
+ }
1483
+
1484
+
1485
+ static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) {
1486
+ __ sll(a0, a0, kSmiTagSize);
1487
+ __ li(t0, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
1488
+ __ MultiPush(a0.bit() | a1.bit() | t0.bit() | fp.bit() | ra.bit());
1489
+ __ Addu(fp, sp, Operand(3 * kPointerSize));
1490
+ }
1491
+
1492
+
1493
+ static void LeaveArgumentsAdaptorFrame(MacroAssembler* masm) {
1494
+ // ----------- S t a t e -------------
1495
+ // -- v0 : result being passed through
1496
+ // -----------------------------------
1497
+ // Get the number of arguments passed (as a smi), tear down the frame and
1498
+ // then tear down the parameters.
1499
+ __ lw(a1, MemOperand(fp, -3 * kPointerSize));
1500
+ __ mov(sp, fp);
1501
+ __ MultiPop(fp.bit() | ra.bit());
1502
+ __ sll(t0, a1, kPointerSizeLog2 - kSmiTagSize);
1503
+ __ Addu(sp, sp, t0);
1504
+ // Adjust for the receiver.
1505
+ __ Addu(sp, sp, Operand(kPointerSize));
1506
+ }
1507
+
1508
+
1509
+ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
1510
+ // State setup as expected by MacroAssembler::InvokePrologue.
1511
+ // ----------- S t a t e -------------
1512
+ // -- a0: actual arguments count
1513
+ // -- a1: function (passed through to callee)
1514
+ // -- a2: expected arguments count
1515
+ // -- a3: callee code entry
1516
+ // -- t1: call kind information
1517
+ // -----------------------------------
1518
+
1519
+ Label invoke, dont_adapt_arguments;
1520
+
1521
+ Label enough, too_few;
1522
+ __ Branch(&dont_adapt_arguments, eq,
1523
+ a2, Operand(SharedFunctionInfo::kDontAdaptArgumentsSentinel));
1524
+ // We use Uless as the number of argument should always be greater than 0.
1525
+ __ Branch(&too_few, Uless, a0, Operand(a2));
1526
+
1527
+ { // Enough parameters: actual >= expected.
1528
+ // a0: actual number of arguments as a smi
1529
+ // a1: function
1530
+ // a2: expected number of arguments
1531
+ // a3: code entry to call
1532
+ __ bind(&enough);
1533
+ EnterArgumentsAdaptorFrame(masm);
1534
+
1535
+ // Calculate copy start address into a0 and copy end address into a2.
1536
+ __ sll(a0, a0, kPointerSizeLog2 - kSmiTagSize);
1537
+ __ Addu(a0, fp, a0);
1538
+ // Adjust for return address and receiver.
1539
+ __ Addu(a0, a0, Operand(2 * kPointerSize));
1540
+ // Compute copy end address.
1541
+ __ sll(a2, a2, kPointerSizeLog2);
1542
+ __ subu(a2, a0, a2);
1543
+
1544
+ // Copy the arguments (including the receiver) to the new stack frame.
1545
+ // a0: copy start address
1546
+ // a1: function
1547
+ // a2: copy end address
1548
+ // a3: code entry to call
1549
+
1550
+ Label copy;
1551
+ __ bind(&copy);
1552
+ __ lw(t0, MemOperand(a0));
1553
+ __ push(t0);
1554
+ __ Branch(USE_DELAY_SLOT, &copy, ne, a0, Operand(a2));
1555
+ __ addiu(a0, a0, -kPointerSize); // In delay slot.
1556
+
1557
+ __ jmp(&invoke);
1558
+ }
1559
+
1560
+ { // Too few parameters: Actual < expected.
1561
+ __ bind(&too_few);
1562
+ EnterArgumentsAdaptorFrame(masm);
1563
+
1564
+ // TODO(MIPS): Optimize these loops.
1565
+
1566
+ // Calculate copy start address into a0 and copy end address is fp.
1567
+ // a0: actual number of arguments as a smi
1568
+ // a1: function
1569
+ // a2: expected number of arguments
1570
+ // a3: code entry to call
1571
+ __ sll(a0, a0, kPointerSizeLog2 - kSmiTagSize);
1572
+ __ Addu(a0, fp, a0);
1573
+ // Adjust for return address and receiver.
1574
+ __ Addu(a0, a0, Operand(2 * kPointerSize));
1575
+ // Compute copy end address. Also adjust for return address.
1576
+ __ Addu(t1, fp, kPointerSize);
1577
+
1578
+ // Copy the arguments (including the receiver) to the new stack frame.
1579
+ // a0: copy start address
1580
+ // a1: function
1581
+ // a2: expected number of arguments
1582
+ // a3: code entry to call
1583
+ // t1: copy end address
1584
+ Label copy;
1585
+ __ bind(&copy);
1586
+ __ lw(t0, MemOperand(a0)); // Adjusted above for return addr and receiver.
1587
+ __ push(t0);
1588
+ __ Subu(a0, a0, kPointerSize);
1589
+ __ Branch(&copy, ne, a0, Operand(t1));
1590
+
1591
+ // Fill the remaining expected arguments with undefined.
1592
+ // a1: function
1593
+ // a2: expected number of arguments
1594
+ // a3: code entry to call
1595
+ __ LoadRoot(t0, Heap::kUndefinedValueRootIndex);
1596
+ __ sll(t2, a2, kPointerSizeLog2);
1597
+ __ Subu(a2, fp, Operand(t2));
1598
+ __ Addu(a2, a2, Operand(-4 * kPointerSize)); // Adjust for frame.
1599
+
1600
+ Label fill;
1601
+ __ bind(&fill);
1602
+ __ push(t0);
1603
+ __ Branch(&fill, ne, sp, Operand(a2));
1604
+ }
1605
+
1606
+ // Call the entry point.
1607
+ __ bind(&invoke);
1608
+
1609
+ __ Call(a3);
1610
+
1611
+ // Exit frame and return.
1612
+ LeaveArgumentsAdaptorFrame(masm);
1613
+ __ Ret();
1614
+
1615
+
1616
+ // -------------------------------------------
1617
+ // Don't adapt arguments.
1618
+ // -------------------------------------------
1619
+ __ bind(&dont_adapt_arguments);
1620
+ __ Jump(a3);
1621
+ }
1622
+
1623
+
1624
+ #undef __
1625
+
1626
+ } } // namespace v8::internal
1627
+
1628
+ #endif // V8_TARGET_ARCH_MIPS