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,1580 @@
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 "code-stubs.h"
36
+ #include "ic-inl.h"
37
+ #include "runtime.h"
38
+ #include "stub-cache.h"
39
+
40
+ namespace v8 {
41
+ namespace internal {
42
+
43
+
44
+ // ----------------------------------------------------------------------------
45
+ // Static IC stub generators.
46
+ //
47
+
48
+ #define __ ACCESS_MASM(masm)
49
+
50
+
51
+ static void GenerateGlobalInstanceTypeCheck(MacroAssembler* masm,
52
+ Register type,
53
+ Label* global_object) {
54
+ // Register usage:
55
+ // type: holds the receiver instance type on entry.
56
+ __ Branch(global_object, eq, type, Operand(JS_GLOBAL_OBJECT_TYPE));
57
+ __ Branch(global_object, eq, type, Operand(JS_BUILTINS_OBJECT_TYPE));
58
+ __ Branch(global_object, eq, type, Operand(JS_GLOBAL_PROXY_TYPE));
59
+ }
60
+
61
+
62
+ // Generated code falls through if the receiver is a regular non-global
63
+ // JS object with slow properties and no interceptors.
64
+ static void GenerateStringDictionaryReceiverCheck(MacroAssembler* masm,
65
+ Register receiver,
66
+ Register elements,
67
+ Register scratch0,
68
+ Register scratch1,
69
+ Label* miss) {
70
+ // Register usage:
71
+ // receiver: holds the receiver on entry and is unchanged.
72
+ // elements: holds the property dictionary on fall through.
73
+ // Scratch registers:
74
+ // scratch0: used to holds the receiver map.
75
+ // scratch1: used to holds the receiver instance type, receiver bit mask
76
+ // and elements map.
77
+
78
+ // Check that the receiver isn't a smi.
79
+ __ JumpIfSmi(receiver, miss);
80
+
81
+ // Check that the receiver is a valid JS object.
82
+ __ GetObjectType(receiver, scratch0, scratch1);
83
+ __ Branch(miss, lt, scratch1, Operand(FIRST_JS_OBJECT_TYPE));
84
+
85
+ // If this assert fails, we have to check upper bound too.
86
+ ASSERT(LAST_TYPE == JS_FUNCTION_TYPE);
87
+
88
+ GenerateGlobalInstanceTypeCheck(masm, scratch1, miss);
89
+
90
+ // Check that the global object does not require access checks.
91
+ __ lbu(scratch1, FieldMemOperand(scratch0, Map::kBitFieldOffset));
92
+ __ And(scratch1, scratch1, Operand((1 << Map::kIsAccessCheckNeeded) |
93
+ (1 << Map::kHasNamedInterceptor)));
94
+ __ Branch(miss, ne, scratch1, Operand(zero_reg));
95
+
96
+ __ lw(elements, FieldMemOperand(receiver, JSObject::kPropertiesOffset));
97
+ __ lw(scratch1, FieldMemOperand(elements, HeapObject::kMapOffset));
98
+ __ LoadRoot(scratch0, Heap::kHashTableMapRootIndex);
99
+ __ Branch(miss, ne, scratch1, Operand(scratch0));
100
+ }
101
+
102
+
103
+ // Helper function used from LoadIC/CallIC GenerateNormal.
104
+ //
105
+ // elements: Property dictionary. It is not clobbered if a jump to the miss
106
+ // label is done.
107
+ // name: Property name. It is not clobbered if a jump to the miss label is
108
+ // done
109
+ // result: Register for the result. It is only updated if a jump to the miss
110
+ // label is not done. Can be the same as elements or name clobbering
111
+ // one of these in the case of not jumping to the miss label.
112
+ // The two scratch registers need to be different from elements, name and
113
+ // result.
114
+ // The generated code assumes that the receiver has slow properties,
115
+ // is not a global object and does not have interceptors.
116
+ // The address returned from GenerateStringDictionaryProbes() in scratch2
117
+ // is used.
118
+ static void GenerateDictionaryLoad(MacroAssembler* masm,
119
+ Label* miss,
120
+ Register elements,
121
+ Register name,
122
+ Register result,
123
+ Register scratch1,
124
+ Register scratch2) {
125
+ // Main use of the scratch registers.
126
+ // scratch1: Used as temporary and to hold the capacity of the property
127
+ // dictionary.
128
+ // scratch2: Used as temporary.
129
+ Label done;
130
+
131
+ // Probe the dictionary.
132
+ StringDictionaryLookupStub::GeneratePositiveLookup(masm,
133
+ miss,
134
+ &done,
135
+ elements,
136
+ name,
137
+ scratch1,
138
+ scratch2);
139
+
140
+ // If probing finds an entry check that the value is a normal
141
+ // property.
142
+ __ bind(&done); // scratch2 == elements + 4 * index.
143
+ const int kElementsStartOffset = StringDictionary::kHeaderSize +
144
+ StringDictionary::kElementsStartIndex * kPointerSize;
145
+ const int kDetailsOffset = kElementsStartOffset + 2 * kPointerSize;
146
+ __ lw(scratch1, FieldMemOperand(scratch2, kDetailsOffset));
147
+ __ And(at,
148
+ scratch1,
149
+ Operand(PropertyDetails::TypeField::mask() << kSmiTagSize));
150
+ __ Branch(miss, ne, at, Operand(zero_reg));
151
+
152
+ // Get the value at the masked, scaled index and return.
153
+ __ lw(result,
154
+ FieldMemOperand(scratch2, kElementsStartOffset + 1 * kPointerSize));
155
+ }
156
+
157
+
158
+ // Helper function used from StoreIC::GenerateNormal.
159
+ //
160
+ // elements: Property dictionary. It is not clobbered if a jump to the miss
161
+ // label is done.
162
+ // name: Property name. It is not clobbered if a jump to the miss label is
163
+ // done
164
+ // value: The value to store.
165
+ // The two scratch registers need to be different from elements, name and
166
+ // result.
167
+ // The generated code assumes that the receiver has slow properties,
168
+ // is not a global object and does not have interceptors.
169
+ // The address returned from GenerateStringDictionaryProbes() in scratch2
170
+ // is used.
171
+ static void GenerateDictionaryStore(MacroAssembler* masm,
172
+ Label* miss,
173
+ Register elements,
174
+ Register name,
175
+ Register value,
176
+ Register scratch1,
177
+ Register scratch2) {
178
+ // Main use of the scratch registers.
179
+ // scratch1: Used as temporary and to hold the capacity of the property
180
+ // dictionary.
181
+ // scratch2: Used as temporary.
182
+ Label done;
183
+
184
+ // Probe the dictionary.
185
+ StringDictionaryLookupStub::GeneratePositiveLookup(masm,
186
+ miss,
187
+ &done,
188
+ elements,
189
+ name,
190
+ scratch1,
191
+ scratch2);
192
+
193
+ // If probing finds an entry in the dictionary check that the value
194
+ // is a normal property that is not read only.
195
+ __ bind(&done); // scratch2 == elements + 4 * index.
196
+ const int kElementsStartOffset = StringDictionary::kHeaderSize +
197
+ StringDictionary::kElementsStartIndex * kPointerSize;
198
+ const int kDetailsOffset = kElementsStartOffset + 2 * kPointerSize;
199
+ const int kTypeAndReadOnlyMask
200
+ = (PropertyDetails::TypeField::mask() |
201
+ PropertyDetails::AttributesField::encode(READ_ONLY)) << kSmiTagSize;
202
+ __ lw(scratch1, FieldMemOperand(scratch2, kDetailsOffset));
203
+ __ And(at, scratch1, Operand(kTypeAndReadOnlyMask));
204
+ __ Branch(miss, ne, at, Operand(zero_reg));
205
+
206
+ // Store the value at the masked, scaled index and return.
207
+ const int kValueOffset = kElementsStartOffset + kPointerSize;
208
+ __ Addu(scratch2, scratch2, Operand(kValueOffset - kHeapObjectTag));
209
+ __ sw(value, MemOperand(scratch2));
210
+
211
+ // Update the write barrier. Make sure not to clobber the value.
212
+ __ mov(scratch1, value);
213
+ __ RecordWrite(elements, scratch2, scratch1);
214
+ }
215
+
216
+
217
+ static void GenerateNumberDictionaryLoad(MacroAssembler* masm,
218
+ Label* miss,
219
+ Register elements,
220
+ Register key,
221
+ Register result,
222
+ Register reg0,
223
+ Register reg1,
224
+ Register reg2) {
225
+ // Register use:
226
+ //
227
+ // elements - holds the slow-case elements of the receiver on entry.
228
+ // Unchanged unless 'result' is the same register.
229
+ //
230
+ // key - holds the smi key on entry.
231
+ // Unchanged unless 'result' is the same register.
232
+ //
233
+ //
234
+ // result - holds the result on exit if the load succeeded.
235
+ // Allowed to be the same as 'key' or 'result'.
236
+ // Unchanged on bailout so 'key' or 'result' can be used
237
+ // in further computation.
238
+ //
239
+ // Scratch registers:
240
+ //
241
+ // reg0 - holds the untagged key on entry and holds the hash once computed.
242
+ //
243
+ // reg1 - Used to hold the capacity mask of the dictionary.
244
+ //
245
+ // reg2 - Used for the index into the dictionary.
246
+ // at - Temporary (avoid MacroAssembler instructions also using 'at').
247
+ Label done;
248
+
249
+ // Compute the hash code from the untagged key. This must be kept in sync
250
+ // with ComputeIntegerHash in utils.h.
251
+ //
252
+ // hash = ~hash + (hash << 15);
253
+ __ nor(reg1, reg0, zero_reg);
254
+ __ sll(at, reg0, 15);
255
+ __ addu(reg0, reg1, at);
256
+
257
+ // hash = hash ^ (hash >> 12);
258
+ __ srl(at, reg0, 12);
259
+ __ xor_(reg0, reg0, at);
260
+
261
+ // hash = hash + (hash << 2);
262
+ __ sll(at, reg0, 2);
263
+ __ addu(reg0, reg0, at);
264
+
265
+ // hash = hash ^ (hash >> 4);
266
+ __ srl(at, reg0, 4);
267
+ __ xor_(reg0, reg0, at);
268
+
269
+ // hash = hash * 2057;
270
+ __ li(reg1, Operand(2057));
271
+ __ mul(reg0, reg0, reg1);
272
+
273
+ // hash = hash ^ (hash >> 16);
274
+ __ srl(at, reg0, 16);
275
+ __ xor_(reg0, reg0, at);
276
+
277
+ // Compute the capacity mask.
278
+ __ lw(reg1, FieldMemOperand(elements, NumberDictionary::kCapacityOffset));
279
+ __ sra(reg1, reg1, kSmiTagSize);
280
+ __ Subu(reg1, reg1, Operand(1));
281
+
282
+ // Generate an unrolled loop that performs a few probes before giving up.
283
+ static const int kProbes = 4;
284
+ for (int i = 0; i < kProbes; i++) {
285
+ // Use reg2 for index calculations and keep the hash intact in reg0.
286
+ __ mov(reg2, reg0);
287
+ // Compute the masked index: (hash + i + i * i) & mask.
288
+ if (i > 0) {
289
+ __ Addu(reg2, reg2, Operand(NumberDictionary::GetProbeOffset(i)));
290
+ }
291
+ __ and_(reg2, reg2, reg1);
292
+
293
+ // Scale the index by multiplying by the element size.
294
+ ASSERT(NumberDictionary::kEntrySize == 3);
295
+ __ sll(at, reg2, 1); // 2x.
296
+ __ addu(reg2, reg2, at); // reg2 = reg2 * 3.
297
+
298
+ // Check if the key is identical to the name.
299
+ __ sll(at, reg2, kPointerSizeLog2);
300
+ __ addu(reg2, elements, at);
301
+
302
+ __ lw(at, FieldMemOperand(reg2, NumberDictionary::kElementsStartOffset));
303
+ if (i != kProbes - 1) {
304
+ __ Branch(&done, eq, key, Operand(at));
305
+ } else {
306
+ __ Branch(miss, ne, key, Operand(at));
307
+ }
308
+ }
309
+
310
+ __ bind(&done);
311
+ // Check that the value is a normal property.
312
+ // reg2: elements + (index * kPointerSize).
313
+ const int kDetailsOffset =
314
+ NumberDictionary::kElementsStartOffset + 2 * kPointerSize;
315
+ __ lw(reg1, FieldMemOperand(reg2, kDetailsOffset));
316
+ __ And(at, reg1, Operand(Smi::FromInt(PropertyDetails::TypeField::mask())));
317
+ __ Branch(miss, ne, at, Operand(zero_reg));
318
+
319
+ // Get the value at the masked, scaled index and return.
320
+ const int kValueOffset =
321
+ NumberDictionary::kElementsStartOffset + kPointerSize;
322
+ __ lw(result, FieldMemOperand(reg2, kValueOffset));
323
+ }
324
+
325
+
326
+ void LoadIC::GenerateArrayLength(MacroAssembler* masm) {
327
+ // ----------- S t a t e -------------
328
+ // -- a2 : name
329
+ // -- ra : return address
330
+ // -- a0 : receiver
331
+ // -- sp[0] : receiver
332
+ // -----------------------------------
333
+ Label miss;
334
+
335
+ StubCompiler::GenerateLoadArrayLength(masm, a0, a3, &miss);
336
+ __ bind(&miss);
337
+ StubCompiler::GenerateLoadMiss(masm, Code::LOAD_IC);
338
+ }
339
+
340
+
341
+ void LoadIC::GenerateStringLength(MacroAssembler* masm, bool support_wrappers) {
342
+ // ----------- S t a t e -------------
343
+ // -- a2 : name
344
+ // -- lr : return address
345
+ // -- a0 : receiver
346
+ // -- sp[0] : receiver
347
+ // -----------------------------------
348
+ Label miss;
349
+
350
+ StubCompiler::GenerateLoadStringLength(masm, a0, a1, a3, &miss,
351
+ support_wrappers);
352
+ // Cache miss: Jump to runtime.
353
+ __ bind(&miss);
354
+ StubCompiler::GenerateLoadMiss(masm, Code::LOAD_IC);
355
+ }
356
+
357
+
358
+ void LoadIC::GenerateFunctionPrototype(MacroAssembler* masm) {
359
+ // ----------- S t a t e -------------
360
+ // -- a2 : name
361
+ // -- lr : return address
362
+ // -- a0 : receiver
363
+ // -- sp[0] : receiver
364
+ // -----------------------------------
365
+ Label miss;
366
+
367
+ StubCompiler::GenerateLoadFunctionPrototype(masm, a0, a1, a3, &miss);
368
+ __ bind(&miss);
369
+ StubCompiler::GenerateLoadMiss(masm, Code::LOAD_IC);
370
+ }
371
+
372
+
373
+ // Checks the receiver for special cases (value type, slow case bits).
374
+ // Falls through for regular JS object.
375
+ static void GenerateKeyedLoadReceiverCheck(MacroAssembler* masm,
376
+ Register receiver,
377
+ Register map,
378
+ Register scratch,
379
+ int interceptor_bit,
380
+ Label* slow) {
381
+ // Check that the object isn't a smi.
382
+ __ JumpIfSmi(receiver, slow);
383
+ // Get the map of the receiver.
384
+ __ lw(map, FieldMemOperand(receiver, HeapObject::kMapOffset));
385
+ // Check bit field.
386
+ __ lbu(scratch, FieldMemOperand(map, Map::kBitFieldOffset));
387
+ __ And(at, scratch, Operand(KeyedLoadIC::kSlowCaseBitFieldMask));
388
+ __ Branch(slow, ne, at, Operand(zero_reg));
389
+ // Check that the object is some kind of JS object EXCEPT JS Value type.
390
+ // In the case that the object is a value-wrapper object,
391
+ // we enter the runtime system to make sure that indexing into string
392
+ // objects work as intended.
393
+ ASSERT(JS_OBJECT_TYPE > JS_VALUE_TYPE);
394
+ __ lbu(scratch, FieldMemOperand(map, Map::kInstanceTypeOffset));
395
+ __ Branch(slow, lt, scratch, Operand(JS_OBJECT_TYPE));
396
+ }
397
+
398
+
399
+ // Loads an indexed element from a fast case array.
400
+ // If not_fast_array is NULL, doesn't perform the elements map check.
401
+ static void GenerateFastArrayLoad(MacroAssembler* masm,
402
+ Register receiver,
403
+ Register key,
404
+ Register elements,
405
+ Register scratch1,
406
+ Register scratch2,
407
+ Register result,
408
+ Label* not_fast_array,
409
+ Label* out_of_range) {
410
+ // Register use:
411
+ //
412
+ // receiver - holds the receiver on entry.
413
+ // Unchanged unless 'result' is the same register.
414
+ //
415
+ // key - holds the smi key on entry.
416
+ // Unchanged unless 'result' is the same register.
417
+ //
418
+ // elements - holds the elements of the receiver on exit.
419
+ //
420
+ // result - holds the result on exit if the load succeeded.
421
+ // Allowed to be the the same as 'receiver' or 'key'.
422
+ // Unchanged on bailout so 'receiver' and 'key' can be safely
423
+ // used by further computation.
424
+ //
425
+ // Scratch registers:
426
+ //
427
+ // scratch1 - used to hold elements map and elements length.
428
+ // Holds the elements map if not_fast_array branch is taken.
429
+ //
430
+ // scratch2 - used to hold the loaded value.
431
+
432
+ __ lw(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
433
+ if (not_fast_array != NULL) {
434
+ // Check that the object is in fast mode (not dictionary).
435
+ __ lw(scratch1, FieldMemOperand(elements, HeapObject::kMapOffset));
436
+ __ LoadRoot(at, Heap::kFixedArrayMapRootIndex);
437
+ __ Branch(not_fast_array, ne, scratch1, Operand(at));
438
+ } else {
439
+ __ AssertFastElements(elements);
440
+ }
441
+
442
+ // Check that the key (index) is within bounds.
443
+ __ lw(scratch1, FieldMemOperand(elements, FixedArray::kLengthOffset));
444
+ __ Branch(out_of_range, hs, key, Operand(scratch1));
445
+
446
+ // Fast case: Do the load.
447
+ __ Addu(scratch1, elements,
448
+ Operand(FixedArray::kHeaderSize - kHeapObjectTag));
449
+ // The key is a smi.
450
+ ASSERT(kSmiTag == 0 && kSmiTagSize < kPointerSizeLog2);
451
+ __ sll(at, key, kPointerSizeLog2 - kSmiTagSize);
452
+ __ addu(at, at, scratch1);
453
+ __ lw(scratch2, MemOperand(at));
454
+
455
+ __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
456
+ // In case the loaded value is the_hole we have to consult GetProperty
457
+ // to ensure the prototype chain is searched.
458
+ __ Branch(out_of_range, eq, scratch2, Operand(at));
459
+ __ mov(result, scratch2);
460
+ }
461
+
462
+
463
+ // Checks whether a key is an array index string or a symbol string.
464
+ // Falls through if a key is a symbol.
465
+ static void GenerateKeyStringCheck(MacroAssembler* masm,
466
+ Register key,
467
+ Register map,
468
+ Register hash,
469
+ Label* index_string,
470
+ Label* not_symbol) {
471
+ // The key is not a smi.
472
+ // Is it a string?
473
+ __ GetObjectType(key, map, hash);
474
+ __ Branch(not_symbol, ge, hash, Operand(FIRST_NONSTRING_TYPE));
475
+
476
+ // Is the string an array index, with cached numeric value?
477
+ __ lw(hash, FieldMemOperand(key, String::kHashFieldOffset));
478
+ __ And(at, hash, Operand(String::kContainsCachedArrayIndexMask));
479
+ __ Branch(index_string, eq, at, Operand(zero_reg));
480
+
481
+ // Is the string a symbol?
482
+ // map: key map
483
+ __ lbu(hash, FieldMemOperand(map, Map::kInstanceTypeOffset));
484
+ ASSERT(kSymbolTag != 0);
485
+ __ And(at, hash, Operand(kIsSymbolMask));
486
+ __ Branch(not_symbol, eq, at, Operand(zero_reg));
487
+ }
488
+
489
+
490
+ // Defined in ic.cc.
491
+ Object* CallIC_Miss(Arguments args);
492
+
493
+ // The generated code does not accept smi keys.
494
+ // The generated code falls through if both probes miss.
495
+ static void GenerateMonomorphicCacheProbe(MacroAssembler* masm,
496
+ int argc,
497
+ Code::Kind kind,
498
+ Code::ExtraICState extra_ic_state) {
499
+ // ----------- S t a t e -------------
500
+ // -- a1 : receiver
501
+ // -- a2 : name
502
+ // -----------------------------------
503
+ Label number, non_number, non_string, boolean, probe, miss;
504
+
505
+ // Probe the stub cache.
506
+ Code::Flags flags = Code::ComputeFlags(kind,
507
+ NOT_IN_LOOP,
508
+ MONOMORPHIC,
509
+ extra_ic_state,
510
+ NORMAL,
511
+ argc);
512
+ Isolate::Current()->stub_cache()->GenerateProbe(
513
+ masm, flags, a1, a2, a3, t0, t1);
514
+
515
+ // If the stub cache probing failed, the receiver might be a value.
516
+ // For value objects, we use the map of the prototype objects for
517
+ // the corresponding JSValue for the cache and that is what we need
518
+ // to probe.
519
+ //
520
+ // Check for number.
521
+ __ JumpIfSmi(a1, &number, t1);
522
+ __ GetObjectType(a1, a3, a3);
523
+ __ Branch(&non_number, ne, a3, Operand(HEAP_NUMBER_TYPE));
524
+ __ bind(&number);
525
+ StubCompiler::GenerateLoadGlobalFunctionPrototype(
526
+ masm, Context::NUMBER_FUNCTION_INDEX, a1);
527
+ __ Branch(&probe);
528
+
529
+ // Check for string.
530
+ __ bind(&non_number);
531
+ __ Branch(&non_string, Ugreater_equal, a3, Operand(FIRST_NONSTRING_TYPE));
532
+ StubCompiler::GenerateLoadGlobalFunctionPrototype(
533
+ masm, Context::STRING_FUNCTION_INDEX, a1);
534
+ __ Branch(&probe);
535
+
536
+ // Check for boolean.
537
+ __ bind(&non_string);
538
+ __ LoadRoot(t0, Heap::kTrueValueRootIndex);
539
+ __ Branch(&boolean, eq, a1, Operand(t0));
540
+ __ LoadRoot(t1, Heap::kFalseValueRootIndex);
541
+ __ Branch(&miss, ne, a1, Operand(t1));
542
+ __ bind(&boolean);
543
+ StubCompiler::GenerateLoadGlobalFunctionPrototype(
544
+ masm, Context::BOOLEAN_FUNCTION_INDEX, a1);
545
+
546
+ // Probe the stub cache for the value object.
547
+ __ bind(&probe);
548
+ Isolate::Current()->stub_cache()->GenerateProbe(
549
+ masm, flags, a1, a2, a3, t0, t1);
550
+
551
+ __ bind(&miss);
552
+ }
553
+
554
+
555
+ static void GenerateFunctionTailCall(MacroAssembler* masm,
556
+ int argc,
557
+ Label* miss,
558
+ Register scratch) {
559
+ // a1: function
560
+
561
+ // Check that the value isn't a smi.
562
+ __ JumpIfSmi(a1, miss);
563
+
564
+ // Check that the value is a JSFunction.
565
+ __ GetObjectType(a1, scratch, scratch);
566
+ __ Branch(miss, ne, scratch, Operand(JS_FUNCTION_TYPE));
567
+
568
+ // Invoke the function.
569
+ ParameterCount actual(argc);
570
+ __ InvokeFunction(a1, actual, JUMP_FUNCTION);
571
+ }
572
+
573
+
574
+ static void GenerateCallNormal(MacroAssembler* masm, int argc) {
575
+ // ----------- S t a t e -------------
576
+ // -- a2 : name
577
+ // -- ra : return address
578
+ // -----------------------------------
579
+ Label miss;
580
+
581
+ // Get the receiver of the function from the stack into a1.
582
+ __ lw(a1, MemOperand(sp, argc * kPointerSize));
583
+
584
+ GenerateStringDictionaryReceiverCheck(masm, a1, a0, a3, t0, &miss);
585
+
586
+ // a0: elements
587
+ // Search the dictionary - put result in register a1.
588
+ GenerateDictionaryLoad(masm, &miss, a0, a2, a1, a3, t0);
589
+
590
+ GenerateFunctionTailCall(masm, argc, &miss, t0);
591
+
592
+ // Cache miss: Jump to runtime.
593
+ __ bind(&miss);
594
+ }
595
+
596
+
597
+ static void GenerateCallMiss(MacroAssembler* masm,
598
+ int argc,
599
+ IC::UtilityId id,
600
+ Code::ExtraICState extra_ic_state) {
601
+ // ----------- S t a t e -------------
602
+ // -- a2 : name
603
+ // -- ra : return address
604
+ // -----------------------------------
605
+ Isolate* isolate = masm->isolate();
606
+
607
+ if (id == IC::kCallIC_Miss) {
608
+ __ IncrementCounter(isolate->counters()->call_miss(), 1, a3, t0);
609
+ } else {
610
+ __ IncrementCounter(isolate->counters()->keyed_call_miss(), 1, a3, t0);
611
+ }
612
+
613
+ // Get the receiver of the function from the stack.
614
+ __ lw(a3, MemOperand(sp, argc*kPointerSize));
615
+
616
+ __ EnterInternalFrame();
617
+
618
+ // Push the receiver and the name of the function.
619
+ __ Push(a3, a2);
620
+
621
+ // Call the entry.
622
+ __ li(a0, Operand(2));
623
+ __ li(a1, Operand(ExternalReference(IC_Utility(id), isolate)));
624
+
625
+ CEntryStub stub(1);
626
+ __ CallStub(&stub);
627
+
628
+ // Move result to a1 and leave the internal frame.
629
+ __ mov(a1, v0);
630
+ __ LeaveInternalFrame();
631
+
632
+ // Check if the receiver is a global object of some sort.
633
+ // This can happen only for regular CallIC but not KeyedCallIC.
634
+ if (id == IC::kCallIC_Miss) {
635
+ Label invoke, global;
636
+ __ lw(a2, MemOperand(sp, argc * kPointerSize));
637
+ __ andi(t0, a2, kSmiTagMask);
638
+ __ Branch(&invoke, eq, t0, Operand(zero_reg));
639
+ __ GetObjectType(a2, a3, a3);
640
+ __ Branch(&global, eq, a3, Operand(JS_GLOBAL_OBJECT_TYPE));
641
+ __ Branch(&invoke, ne, a3, Operand(JS_BUILTINS_OBJECT_TYPE));
642
+
643
+ // Patch the receiver on the stack.
644
+ __ bind(&global);
645
+ __ lw(a2, FieldMemOperand(a2, GlobalObject::kGlobalReceiverOffset));
646
+ __ sw(a2, MemOperand(sp, argc * kPointerSize));
647
+ __ bind(&invoke);
648
+ }
649
+ // Invoke the function.
650
+ CallKind call_kind = CallICBase::Contextual::decode(extra_ic_state)
651
+ ? CALL_AS_FUNCTION
652
+ : CALL_AS_METHOD;
653
+ ParameterCount actual(argc);
654
+ __ InvokeFunction(a1,
655
+ actual,
656
+ JUMP_FUNCTION,
657
+ NullCallWrapper(),
658
+ call_kind);
659
+ }
660
+
661
+
662
+ void CallIC::GenerateMiss(MacroAssembler* masm,
663
+ int argc,
664
+ Code::ExtraICState extra_ic_state) {
665
+ // ----------- S t a t e -------------
666
+ // -- a2 : name
667
+ // -- ra : return address
668
+ // -----------------------------------
669
+
670
+ GenerateCallMiss(masm, argc, IC::kCallIC_Miss, extra_ic_state);
671
+ }
672
+
673
+
674
+ void CallIC::GenerateMegamorphic(MacroAssembler* masm,
675
+ int argc,
676
+ Code::ExtraICState extra_ic_state) {
677
+ // ----------- S t a t e -------------
678
+ // -- a2 : name
679
+ // -- ra : return address
680
+ // -----------------------------------
681
+
682
+ // Get the receiver of the function from the stack into a1.
683
+ __ lw(a1, MemOperand(sp, argc * kPointerSize));
684
+ GenerateMonomorphicCacheProbe(masm, argc, Code::CALL_IC, extra_ic_state);
685
+ GenerateMiss(masm, argc, extra_ic_state);
686
+ }
687
+
688
+
689
+ void CallIC::GenerateNormal(MacroAssembler* masm, int argc) {
690
+ // ----------- S t a t e -------------
691
+ // -- a2 : name
692
+ // -- ra : return address
693
+ // -----------------------------------
694
+
695
+ GenerateCallNormal(masm, argc);
696
+ GenerateMiss(masm, argc, Code::kNoExtraICState);
697
+ }
698
+
699
+
700
+ void KeyedCallIC::GenerateMiss(MacroAssembler* masm, int argc) {
701
+ // ----------- S t a t e -------------
702
+ // -- a2 : name
703
+ // -- ra : return address
704
+ // -----------------------------------
705
+
706
+ GenerateCallMiss(masm, argc, IC::kKeyedCallIC_Miss, Code::kNoExtraICState);
707
+ }
708
+
709
+
710
+ void KeyedCallIC::GenerateMegamorphic(MacroAssembler* masm, int argc) {
711
+ // ----------- S t a t e -------------
712
+ // -- a2 : name
713
+ // -- ra : return address
714
+ // -----------------------------------
715
+
716
+ // Get the receiver of the function from the stack into a1.
717
+ __ lw(a1, MemOperand(sp, argc * kPointerSize));
718
+
719
+ Label do_call, slow_call, slow_load, slow_reload_receiver;
720
+ Label check_number_dictionary, check_string, lookup_monomorphic_cache;
721
+ Label index_smi, index_string;
722
+
723
+ // Check that the key is a smi.
724
+ __ JumpIfNotSmi(a2, &check_string);
725
+ __ bind(&index_smi);
726
+ // Now the key is known to be a smi. This place is also jumped to from below
727
+ // where a numeric string is converted to a smi.
728
+
729
+ GenerateKeyedLoadReceiverCheck(
730
+ masm, a1, a0, a3, Map::kHasIndexedInterceptor, &slow_call);
731
+
732
+ GenerateFastArrayLoad(
733
+ masm, a1, a2, t0, a3, a0, a1, &check_number_dictionary, &slow_load);
734
+ Counters* counters = masm->isolate()->counters();
735
+ __ IncrementCounter(counters->keyed_call_generic_smi_fast(), 1, a0, a3);
736
+
737
+ __ bind(&do_call);
738
+ // receiver in a1 is not used after this point.
739
+ // a2: key
740
+ // a1: function
741
+
742
+ GenerateFunctionTailCall(masm, argc, &slow_call, a0);
743
+
744
+ __ bind(&check_number_dictionary);
745
+ // a2: key
746
+ // a3: elements map
747
+ // t0: elements pointer
748
+ // Check whether the elements is a number dictionary.
749
+ __ LoadRoot(at, Heap::kHashTableMapRootIndex);
750
+ __ Branch(&slow_load, ne, a3, Operand(at));
751
+ __ sra(a0, a2, kSmiTagSize);
752
+ // a0: untagged index
753
+ GenerateNumberDictionaryLoad(masm, &slow_load, t0, a2, a1, a0, a3, t1);
754
+ __ IncrementCounter(counters->keyed_call_generic_smi_dict(), 1, a0, a3);
755
+ __ jmp(&do_call);
756
+
757
+ __ bind(&slow_load);
758
+ // This branch is taken when calling KeyedCallIC_Miss is neither required
759
+ // nor beneficial.
760
+ __ IncrementCounter(counters->keyed_call_generic_slow_load(), 1, a0, a3);
761
+ __ EnterInternalFrame();
762
+ __ push(a2); // Save the key.
763
+ __ Push(a1, a2); // Pass the receiver and the key.
764
+ __ CallRuntime(Runtime::kKeyedGetProperty, 2);
765
+ __ pop(a2); // Restore the key.
766
+ __ LeaveInternalFrame();
767
+ __ mov(a1, v0);
768
+ __ jmp(&do_call);
769
+
770
+ __ bind(&check_string);
771
+ GenerateKeyStringCheck(masm, a2, a0, a3, &index_string, &slow_call);
772
+
773
+ // The key is known to be a symbol.
774
+ // If the receiver is a regular JS object with slow properties then do
775
+ // a quick inline probe of the receiver's dictionary.
776
+ // Otherwise do the monomorphic cache probe.
777
+ GenerateKeyedLoadReceiverCheck(
778
+ masm, a1, a0, a3, Map::kHasNamedInterceptor, &lookup_monomorphic_cache);
779
+
780
+ __ lw(a0, FieldMemOperand(a1, JSObject::kPropertiesOffset));
781
+ __ lw(a3, FieldMemOperand(a0, HeapObject::kMapOffset));
782
+ __ LoadRoot(at, Heap::kHashTableMapRootIndex);
783
+ __ Branch(&lookup_monomorphic_cache, ne, a3, Operand(at));
784
+
785
+ GenerateDictionaryLoad(masm, &slow_load, a0, a2, a1, a3, t0);
786
+ __ IncrementCounter(counters->keyed_call_generic_lookup_dict(), 1, a0, a3);
787
+ __ jmp(&do_call);
788
+
789
+ __ bind(&lookup_monomorphic_cache);
790
+ __ IncrementCounter(counters->keyed_call_generic_lookup_cache(), 1, a0, a3);
791
+ GenerateMonomorphicCacheProbe(masm,
792
+ argc,
793
+ Code::KEYED_CALL_IC,
794
+ Code::kNoExtraICState);
795
+ // Fall through on miss.
796
+
797
+ __ bind(&slow_call);
798
+ // This branch is taken if:
799
+ // - the receiver requires boxing or access check,
800
+ // - the key is neither smi nor symbol,
801
+ // - the value loaded is not a function,
802
+ // - there is hope that the runtime will create a monomorphic call stub,
803
+ // that will get fetched next time.
804
+ __ IncrementCounter(counters->keyed_call_generic_slow(), 1, a0, a3);
805
+ GenerateMiss(masm, argc);
806
+
807
+ __ bind(&index_string);
808
+ __ IndexFromHash(a3, a2);
809
+ // Now jump to the place where smi keys are handled.
810
+ __ jmp(&index_smi);
811
+ }
812
+
813
+
814
+ void KeyedCallIC::GenerateNormal(MacroAssembler* masm, int argc) {
815
+ // ----------- S t a t e -------------
816
+ // -- a2 : name
817
+ // -- ra : return address
818
+ // -----------------------------------
819
+
820
+ // Check if the name is a string.
821
+ Label miss;
822
+ __ JumpIfSmi(a2, &miss);
823
+ __ IsObjectJSStringType(a2, a0, &miss);
824
+
825
+ GenerateCallNormal(masm, argc);
826
+ __ bind(&miss);
827
+ GenerateMiss(masm, argc);
828
+ }
829
+
830
+
831
+ // Defined in ic.cc.
832
+ Object* LoadIC_Miss(Arguments args);
833
+
834
+ void LoadIC::GenerateMegamorphic(MacroAssembler* masm) {
835
+ // ----------- S t a t e -------------
836
+ // -- a2 : name
837
+ // -- ra : return address
838
+ // -- a0 : receiver
839
+ // -- sp[0] : receiver
840
+ // -----------------------------------
841
+
842
+ // Probe the stub cache.
843
+ Code::Flags flags = Code::ComputeFlags(Code::LOAD_IC,
844
+ NOT_IN_LOOP,
845
+ MONOMORPHIC);
846
+ Isolate::Current()->stub_cache()->GenerateProbe(
847
+ masm, flags, a0, a2, a3, t0, t1);
848
+
849
+ // Cache miss: Jump to runtime.
850
+ GenerateMiss(masm);
851
+ }
852
+
853
+
854
+ void LoadIC::GenerateNormal(MacroAssembler* masm) {
855
+ // ----------- S t a t e -------------
856
+ // -- a2 : name
857
+ // -- lr : return address
858
+ // -- a0 : receiver
859
+ // -- sp[0] : receiver
860
+ // -----------------------------------
861
+ Label miss;
862
+
863
+ GenerateStringDictionaryReceiverCheck(masm, a0, a1, a3, t0, &miss);
864
+
865
+ // a1: elements
866
+ GenerateDictionaryLoad(masm, &miss, a1, a2, v0, a3, t0);
867
+ __ Ret();
868
+
869
+ // Cache miss: Jump to runtime.
870
+ __ bind(&miss);
871
+ GenerateMiss(masm);
872
+ }
873
+
874
+
875
+ void LoadIC::GenerateMiss(MacroAssembler* masm) {
876
+ // ----------- S t a t e -------------
877
+ // -- a2 : name
878
+ // -- ra : return address
879
+ // -- a0 : receiver
880
+ // -- sp[0] : receiver
881
+ // -----------------------------------
882
+ Isolate* isolate = masm->isolate();
883
+
884
+ __ IncrementCounter(isolate->counters()->keyed_load_miss(), 1, a3, t0);
885
+
886
+ __ mov(a3, a0);
887
+ __ Push(a3, a2);
888
+
889
+ // Perform tail call to the entry.
890
+ ExternalReference ref = ExternalReference(IC_Utility(kLoadIC_Miss), isolate);
891
+ __ TailCallExternalReference(ref, 2, 1);
892
+ }
893
+
894
+
895
+ void KeyedLoadIC::GenerateMiss(MacroAssembler* masm, bool force_generic) {
896
+ // ---------- S t a t e --------------
897
+ // -- ra : return address
898
+ // -- a0 : key
899
+ // -- a1 : receiver
900
+ // -----------------------------------
901
+ Isolate* isolate = masm->isolate();
902
+
903
+ __ IncrementCounter(isolate->counters()->keyed_load_miss(), 1, a3, t0);
904
+
905
+ __ Push(a1, a0);
906
+
907
+ // Perform tail call to the entry.
908
+ ExternalReference ref = force_generic
909
+ ? ExternalReference(IC_Utility(kKeyedLoadIC_MissForceGeneric), isolate)
910
+ : ExternalReference(IC_Utility(kKeyedLoadIC_Miss), isolate);
911
+
912
+ __ TailCallExternalReference(ref, 2, 1);
913
+ }
914
+
915
+
916
+ void KeyedLoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) {
917
+ // ---------- S t a t e --------------
918
+ // -- ra : return address
919
+ // -- a0 : key
920
+ // -- a1 : receiver
921
+ // -----------------------------------
922
+
923
+ __ Push(a1, a0);
924
+
925
+ __ TailCallRuntime(Runtime::kKeyedGetProperty, 2, 1);
926
+ }
927
+
928
+
929
+ void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) {
930
+ // ---------- S t a t e --------------
931
+ // -- ra : return address
932
+ // -- a0 : key
933
+ // -- a1 : receiver
934
+ // -----------------------------------
935
+ Label slow, check_string, index_smi, index_string, property_array_property;
936
+ Label probe_dictionary, check_number_dictionary;
937
+
938
+ Register key = a0;
939
+ Register receiver = a1;
940
+
941
+ Isolate* isolate = masm->isolate();
942
+
943
+ // Check that the key is a smi.
944
+ __ JumpIfNotSmi(key, &check_string);
945
+ __ bind(&index_smi);
946
+ // Now the key is known to be a smi. This place is also jumped to from below
947
+ // where a numeric string is converted to a smi.
948
+
949
+ GenerateKeyedLoadReceiverCheck(
950
+ masm, receiver, a2, a3, Map::kHasIndexedInterceptor, &slow);
951
+
952
+ // Check the "has fast elements" bit in the receiver's map which is
953
+ // now in a2.
954
+ __ lbu(a3, FieldMemOperand(a2, Map::kBitField2Offset));
955
+ __ And(at, a3, Operand(1 << Map::kHasFastElements));
956
+ __ Branch(&check_number_dictionary, eq, at, Operand(zero_reg));
957
+
958
+ GenerateFastArrayLoad(
959
+ masm, receiver, key, t0, a3, a2, v0, NULL, &slow);
960
+
961
+ __ IncrementCounter(isolate->counters()->keyed_load_generic_smi(), 1, a2, a3);
962
+ __ Ret();
963
+
964
+ __ bind(&check_number_dictionary);
965
+ __ lw(t0, FieldMemOperand(receiver, JSObject::kElementsOffset));
966
+ __ lw(a3, FieldMemOperand(t0, JSObject::kMapOffset));
967
+
968
+ // Check whether the elements is a number dictionary.
969
+ // a0: key
970
+ // a3: elements map
971
+ // t0: elements
972
+ __ LoadRoot(at, Heap::kHashTableMapRootIndex);
973
+ __ Branch(&slow, ne, a3, Operand(at));
974
+ __ sra(a2, a0, kSmiTagSize);
975
+ GenerateNumberDictionaryLoad(masm, &slow, t0, a0, v0, a2, a3, t1);
976
+ __ Ret();
977
+
978
+ // Slow case, key and receiver still in a0 and a1.
979
+ __ bind(&slow);
980
+ __ IncrementCounter(isolate->counters()->keyed_load_generic_slow(),
981
+ 1,
982
+ a2,
983
+ a3);
984
+ GenerateRuntimeGetProperty(masm);
985
+
986
+ __ bind(&check_string);
987
+ GenerateKeyStringCheck(masm, key, a2, a3, &index_string, &slow);
988
+
989
+ GenerateKeyedLoadReceiverCheck(
990
+ masm, receiver, a2, a3, Map::kHasIndexedInterceptor, &slow);
991
+
992
+
993
+ // If the receiver is a fast-case object, check the keyed lookup
994
+ // cache. Otherwise probe the dictionary.
995
+ __ lw(a3, FieldMemOperand(a1, JSObject::kPropertiesOffset));
996
+ __ lw(t0, FieldMemOperand(a3, HeapObject::kMapOffset));
997
+ __ LoadRoot(at, Heap::kHashTableMapRootIndex);
998
+ __ Branch(&probe_dictionary, eq, t0, Operand(at));
999
+
1000
+ // Load the map of the receiver, compute the keyed lookup cache hash
1001
+ // based on 32 bits of the map pointer and the string hash.
1002
+ __ lw(a2, FieldMemOperand(a1, HeapObject::kMapOffset));
1003
+ __ sra(a3, a2, KeyedLookupCache::kMapHashShift);
1004
+ __ lw(t0, FieldMemOperand(a0, String::kHashFieldOffset));
1005
+ __ sra(at, t0, String::kHashShift);
1006
+ __ xor_(a3, a3, at);
1007
+ __ And(a3, a3, Operand(KeyedLookupCache::kCapacityMask));
1008
+
1009
+ // Load the key (consisting of map and symbol) from the cache and
1010
+ // check for match.
1011
+ ExternalReference cache_keys =
1012
+ ExternalReference::keyed_lookup_cache_keys(isolate);
1013
+ __ li(t0, Operand(cache_keys));
1014
+ __ sll(at, a3, kPointerSizeLog2 + 1);
1015
+ __ addu(t0, t0, at);
1016
+ __ lw(t1, MemOperand(t0)); // Move t0 to symbol.
1017
+ __ Addu(t0, t0, Operand(kPointerSize));
1018
+ __ Branch(&slow, ne, a2, Operand(t1));
1019
+ __ lw(t1, MemOperand(t0));
1020
+ __ Branch(&slow, ne, a0, Operand(t1));
1021
+
1022
+ // Get field offset.
1023
+ // a0 : key
1024
+ // a1 : receiver
1025
+ // a2 : receiver's map
1026
+ // a3 : lookup cache index
1027
+ ExternalReference cache_field_offsets =
1028
+ ExternalReference::keyed_lookup_cache_field_offsets(isolate);
1029
+ __ li(t0, Operand(cache_field_offsets));
1030
+ __ sll(at, a3, kPointerSizeLog2);
1031
+ __ addu(at, t0, at);
1032
+ __ lw(t1, MemOperand(at));
1033
+ __ lbu(t2, FieldMemOperand(a2, Map::kInObjectPropertiesOffset));
1034
+ __ Subu(t1, t1, t2);
1035
+ __ Branch(&property_array_property, ge, t1, Operand(zero_reg));
1036
+
1037
+ // Load in-object property.
1038
+ __ lbu(t2, FieldMemOperand(a2, Map::kInstanceSizeOffset));
1039
+ __ addu(t2, t2, t1); // Index from start of object.
1040
+ __ Subu(a1, a1, Operand(kHeapObjectTag)); // Remove the heap tag.
1041
+ __ sll(at, t2, kPointerSizeLog2);
1042
+ __ addu(at, a1, at);
1043
+ __ lw(v0, MemOperand(at));
1044
+ __ IncrementCounter(isolate->counters()->keyed_load_generic_lookup_cache(),
1045
+ 1,
1046
+ a2,
1047
+ a3);
1048
+ __ Ret();
1049
+
1050
+ // Load property array property.
1051
+ __ bind(&property_array_property);
1052
+ __ lw(a1, FieldMemOperand(a1, JSObject::kPropertiesOffset));
1053
+ __ Addu(a1, a1, FixedArray::kHeaderSize - kHeapObjectTag);
1054
+ __ sll(t0, t1, kPointerSizeLog2);
1055
+ __ Addu(t0, t0, a1);
1056
+ __ lw(v0, MemOperand(t0));
1057
+ __ IncrementCounter(isolate->counters()->keyed_load_generic_lookup_cache(),
1058
+ 1,
1059
+ a2,
1060
+ a3);
1061
+ __ Ret();
1062
+
1063
+
1064
+ // Do a quick inline probe of the receiver's dictionary, if it
1065
+ // exists.
1066
+ __ bind(&probe_dictionary);
1067
+ // a1: receiver
1068
+ // a0: key
1069
+ // a3: elements
1070
+ __ lw(a2, FieldMemOperand(a1, HeapObject::kMapOffset));
1071
+ __ lbu(a2, FieldMemOperand(a2, Map::kInstanceTypeOffset));
1072
+ GenerateGlobalInstanceTypeCheck(masm, a2, &slow);
1073
+ // Load the property to v0.
1074
+ GenerateDictionaryLoad(masm, &slow, a3, a0, v0, a2, t0);
1075
+ __ IncrementCounter(isolate->counters()->keyed_load_generic_symbol(),
1076
+ 1,
1077
+ a2,
1078
+ a3);
1079
+ __ Ret();
1080
+
1081
+ __ bind(&index_string);
1082
+ __ IndexFromHash(a3, key);
1083
+ // Now jump to the place where smi keys are handled.
1084
+ __ Branch(&index_smi);
1085
+ }
1086
+
1087
+
1088
+ void KeyedLoadIC::GenerateString(MacroAssembler* masm) {
1089
+ // ---------- S t a t e --------------
1090
+ // -- ra : return address
1091
+ // -- a0 : key (index)
1092
+ // -- a1 : receiver
1093
+ // -----------------------------------
1094
+ Label miss;
1095
+
1096
+ Register receiver = a1;
1097
+ Register index = a0;
1098
+ Register scratch1 = a2;
1099
+ Register scratch2 = a3;
1100
+ Register result = v0;
1101
+
1102
+ StringCharAtGenerator char_at_generator(receiver,
1103
+ index,
1104
+ scratch1,
1105
+ scratch2,
1106
+ result,
1107
+ &miss, // When not a string.
1108
+ &miss, // When not a number.
1109
+ &miss, // When index out of range.
1110
+ STRING_INDEX_IS_ARRAY_INDEX);
1111
+ char_at_generator.GenerateFast(masm);
1112
+ __ Ret();
1113
+
1114
+ StubRuntimeCallHelper call_helper;
1115
+ char_at_generator.GenerateSlow(masm, call_helper);
1116
+
1117
+ __ bind(&miss);
1118
+ GenerateMiss(masm, false);
1119
+ }
1120
+
1121
+
1122
+ void KeyedStoreIC::GenerateRuntimeSetProperty(MacroAssembler* masm,
1123
+ StrictModeFlag strict_mode) {
1124
+ // ---------- S t a t e --------------
1125
+ // -- a0 : value
1126
+ // -- a1 : key
1127
+ // -- a2 : receiver
1128
+ // -- ra : return address
1129
+ // -----------------------------------
1130
+
1131
+ // Push receiver, key and value for runtime call.
1132
+ __ Push(a2, a1, a0);
1133
+ __ li(a1, Operand(Smi::FromInt(NONE))); // PropertyAttributes.
1134
+ __ li(a0, Operand(Smi::FromInt(strict_mode))); // Strict mode.
1135
+ __ Push(a1, a0);
1136
+
1137
+ __ TailCallRuntime(Runtime::kSetProperty, 5, 1);
1138
+ }
1139
+
1140
+
1141
+ void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm,
1142
+ StrictModeFlag strict_mode) {
1143
+ // ---------- S t a t e --------------
1144
+ // -- a0 : value
1145
+ // -- a1 : key
1146
+ // -- a2 : receiver
1147
+ // -- ra : return address
1148
+ // -----------------------------------
1149
+
1150
+ Label slow, fast, array, extra, exit;
1151
+
1152
+ // Register usage.
1153
+ Register value = a0;
1154
+ Register key = a1;
1155
+ Register receiver = a2;
1156
+ Register elements = a3; // Elements array of the receiver.
1157
+ // t0 is used as ip in the arm version.
1158
+ // t3-t4 are used as temporaries.
1159
+
1160
+ // Check that the key is a smi.
1161
+ __ JumpIfNotSmi(key, &slow);
1162
+ // Check that the object isn't a smi.
1163
+ __ JumpIfSmi(receiver, &slow);
1164
+
1165
+ // Get the map of the object.
1166
+ __ lw(t3, FieldMemOperand(receiver, HeapObject::kMapOffset));
1167
+ // Check that the receiver does not require access checks. We need
1168
+ // to do this because this generic stub does not perform map checks.
1169
+ __ lbu(t0, FieldMemOperand(t3, Map::kBitFieldOffset));
1170
+ __ And(t0, t0, Operand(1 << Map::kIsAccessCheckNeeded));
1171
+ __ Branch(&slow, ne, t0, Operand(zero_reg));
1172
+ // Check if the object is a JS array or not.
1173
+ __ lbu(t3, FieldMemOperand(t3, Map::kInstanceTypeOffset));
1174
+
1175
+ __ Branch(&array, eq, t3, Operand(JS_ARRAY_TYPE));
1176
+ // Check that the object is some kind of JS object.
1177
+ __ Branch(&slow, lt, t3, Operand(FIRST_JS_OBJECT_TYPE));
1178
+
1179
+ // Object case: Check key against length in the elements array.
1180
+ __ lw(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
1181
+ // Check that the object is in fast mode and writable.
1182
+ __ lw(t3, FieldMemOperand(elements, HeapObject::kMapOffset));
1183
+ __ LoadRoot(t0, Heap::kFixedArrayMapRootIndex);
1184
+ __ Branch(&slow, ne, t3, Operand(t0));
1185
+ // Check array bounds. Both the key and the length of FixedArray are smis.
1186
+ __ lw(t0, FieldMemOperand(elements, FixedArray::kLengthOffset));
1187
+ __ Branch(&fast, lo, key, Operand(t0));
1188
+ // Fall thru to slow if un-tagged index >= length.
1189
+
1190
+ // Slow case, handle jump to runtime.
1191
+ __ bind(&slow);
1192
+
1193
+ // Entry registers are intact.
1194
+ // a0: value.
1195
+ // a1: key.
1196
+ // a2: receiver.
1197
+
1198
+ GenerateRuntimeSetProperty(masm, strict_mode);
1199
+
1200
+ // Extra capacity case: Check if there is extra capacity to
1201
+ // perform the store and update the length. Used for adding one
1202
+ // element to the array by writing to array[array.length].
1203
+
1204
+ __ bind(&extra);
1205
+ // Only support writing to array[array.length].
1206
+ __ Branch(&slow, ne, key, Operand(t0));
1207
+ // Check for room in the elements backing store.
1208
+ // Both the key and the length of FixedArray are smis.
1209
+ __ lw(t0, FieldMemOperand(elements, FixedArray::kLengthOffset));
1210
+ __ Branch(&slow, hs, key, Operand(t0));
1211
+ // Calculate key + 1 as smi.
1212
+ ASSERT_EQ(0, kSmiTag);
1213
+ __ Addu(t3, key, Operand(Smi::FromInt(1)));
1214
+ __ sw(t3, FieldMemOperand(receiver, JSArray::kLengthOffset));
1215
+ __ Branch(&fast);
1216
+
1217
+
1218
+ // Array case: Get the length and the elements array from the JS
1219
+ // array. Check that the array is in fast mode (and writable); if it
1220
+ // is the length is always a smi.
1221
+
1222
+ __ bind(&array);
1223
+ __ lw(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
1224
+ __ lw(t3, FieldMemOperand(elements, HeapObject::kMapOffset));
1225
+ __ LoadRoot(t0, Heap::kFixedArrayMapRootIndex);
1226
+ __ Branch(&slow, ne, t3, Operand(t0));
1227
+
1228
+ // Check the key against the length in the array.
1229
+ __ lw(t0, FieldMemOperand(receiver, JSArray::kLengthOffset));
1230
+ __ Branch(&extra, hs, key, Operand(t0));
1231
+ // Fall through to fast case.
1232
+
1233
+ __ bind(&fast);
1234
+ // Fast case, store the value to the elements backing store.
1235
+ __ Addu(t4, elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
1236
+ __ sll(t1, key, kPointerSizeLog2 - kSmiTagSize);
1237
+ __ Addu(t4, t4, Operand(t1));
1238
+ __ sw(value, MemOperand(t4));
1239
+ // Skip write barrier if the written value is a smi.
1240
+ __ JumpIfSmi(value, &exit);
1241
+
1242
+ // Update write barrier for the elements array address.
1243
+ __ Subu(t3, t4, Operand(elements));
1244
+
1245
+ __ RecordWrite(elements, Operand(t3), t4, t5);
1246
+ __ bind(&exit);
1247
+
1248
+ __ mov(v0, a0); // Return the value written.
1249
+ __ Ret();
1250
+ }
1251
+
1252
+
1253
+ void KeyedLoadIC::GenerateIndexedInterceptor(MacroAssembler* masm) {
1254
+ // ---------- S t a t e --------------
1255
+ // -- ra : return address
1256
+ // -- a0 : key
1257
+ // -- a1 : receiver
1258
+ // -----------------------------------
1259
+ Label slow;
1260
+
1261
+ // Check that the receiver isn't a smi.
1262
+ __ JumpIfSmi(a1, &slow);
1263
+
1264
+ // Check that the key is an array index, that is Uint32.
1265
+ __ And(t0, a0, Operand(kSmiTagMask | kSmiSignMask));
1266
+ __ Branch(&slow, ne, t0, Operand(zero_reg));
1267
+
1268
+ // Get the map of the receiver.
1269
+ __ lw(a2, FieldMemOperand(a1, HeapObject::kMapOffset));
1270
+
1271
+ // Check that it has indexed interceptor and access checks
1272
+ // are not enabled for this object.
1273
+ __ lbu(a3, FieldMemOperand(a2, Map::kBitFieldOffset));
1274
+ __ And(a3, a3, Operand(kSlowCaseBitFieldMask));
1275
+ __ Branch(&slow, ne, a3, Operand(1 << Map::kHasIndexedInterceptor));
1276
+ // Everything is fine, call runtime.
1277
+ __ Push(a1, a0); // Receiver, key.
1278
+
1279
+ // Perform tail call to the entry.
1280
+ __ TailCallExternalReference(ExternalReference(
1281
+ IC_Utility(kKeyedLoadPropertyWithInterceptor), masm->isolate()), 2, 1);
1282
+
1283
+ __ bind(&slow);
1284
+ GenerateMiss(masm, false);
1285
+ }
1286
+
1287
+
1288
+ void KeyedStoreIC::GenerateMiss(MacroAssembler* masm, bool force_generic) {
1289
+ // ---------- S t a t e --------------
1290
+ // -- a0 : value
1291
+ // -- a1 : key
1292
+ // -- a2 : receiver
1293
+ // -- ra : return address
1294
+ // -----------------------------------
1295
+
1296
+ // Push receiver, key and value for runtime call.
1297
+ __ Push(a2, a1, a0);
1298
+
1299
+ ExternalReference ref = force_generic
1300
+ ? ExternalReference(IC_Utility(kKeyedStoreIC_MissForceGeneric),
1301
+ masm->isolate())
1302
+ : ExternalReference(IC_Utility(kKeyedStoreIC_Miss), masm->isolate());
1303
+ __ TailCallExternalReference(ref, 3, 1);
1304
+ }
1305
+
1306
+
1307
+ void KeyedStoreIC::GenerateSlow(MacroAssembler* masm) {
1308
+ // ---------- S t a t e --------------
1309
+ // -- a0 : value
1310
+ // -- a1 : key
1311
+ // -- a2 : receiver
1312
+ // -- ra : return address
1313
+ // -----------------------------------
1314
+
1315
+ // Push receiver, key and value for runtime call.
1316
+ // We can't use MultiPush as the order of the registers is important.
1317
+ __ Push(a2, a1, a0);
1318
+
1319
+ // The slow case calls into the runtime to complete the store without causing
1320
+ // an IC miss that would otherwise cause a transition to the generic stub.
1321
+ ExternalReference ref =
1322
+ ExternalReference(IC_Utility(kKeyedStoreIC_Slow), masm->isolate());
1323
+
1324
+ __ TailCallExternalReference(ref, 3, 1);
1325
+ }
1326
+
1327
+
1328
+ void StoreIC::GenerateMegamorphic(MacroAssembler* masm,
1329
+ StrictModeFlag strict_mode) {
1330
+ // ----------- S t a t e -------------
1331
+ // -- a0 : value
1332
+ // -- a1 : receiver
1333
+ // -- a2 : name
1334
+ // -- ra : return address
1335
+ // -----------------------------------
1336
+
1337
+ // Get the receiver from the stack and probe the stub cache.
1338
+ Code::Flags flags = Code::ComputeFlags(Code::STORE_IC,
1339
+ NOT_IN_LOOP,
1340
+ MONOMORPHIC,
1341
+ strict_mode);
1342
+ Isolate::Current()->stub_cache()->GenerateProbe(
1343
+ masm, flags, a1, a2, a3, t0, t1);
1344
+
1345
+ // Cache miss: Jump to runtime.
1346
+ GenerateMiss(masm);
1347
+ }
1348
+
1349
+
1350
+ void StoreIC::GenerateMiss(MacroAssembler* masm) {
1351
+ // ----------- S t a t e -------------
1352
+ // -- a0 : value
1353
+ // -- a1 : receiver
1354
+ // -- a2 : name
1355
+ // -- ra : return address
1356
+ // -----------------------------------
1357
+
1358
+ __ Push(a1, a2, a0);
1359
+ // Perform tail call to the entry.
1360
+ ExternalReference ref = ExternalReference(IC_Utility(kStoreIC_Miss),
1361
+ masm->isolate());
1362
+ __ TailCallExternalReference(ref, 3, 1);
1363
+ }
1364
+
1365
+
1366
+ void StoreIC::GenerateArrayLength(MacroAssembler* masm) {
1367
+ // ----------- S t a t e -------------
1368
+ // -- a0 : value
1369
+ // -- a1 : receiver
1370
+ // -- a2 : name
1371
+ // -- ra : return address
1372
+ // -----------------------------------
1373
+ //
1374
+ // This accepts as a receiver anything JSObject::SetElementsLength accepts
1375
+ // (currently anything except for external and pixel arrays which means
1376
+ // anything with elements of FixedArray type.), but currently is restricted
1377
+ // to JSArray.
1378
+ // Value must be a number, but only smis are accepted as the most common case.
1379
+
1380
+ Label miss;
1381
+
1382
+ Register receiver = a1;
1383
+ Register value = a0;
1384
+ Register scratch = a3;
1385
+
1386
+ // Check that the receiver isn't a smi.
1387
+ __ JumpIfSmi(receiver, &miss);
1388
+
1389
+ // Check that the object is a JS array.
1390
+ __ GetObjectType(receiver, scratch, scratch);
1391
+ __ Branch(&miss, ne, scratch, Operand(JS_ARRAY_TYPE));
1392
+
1393
+ // Check that elements are FixedArray.
1394
+ // We rely on StoreIC_ArrayLength below to deal with all types of
1395
+ // fast elements (including COW).
1396
+ __ lw(scratch, FieldMemOperand(receiver, JSArray::kElementsOffset));
1397
+ __ GetObjectType(scratch, scratch, scratch);
1398
+ __ Branch(&miss, ne, scratch, Operand(FIXED_ARRAY_TYPE));
1399
+
1400
+ // Check that value is a smi.
1401
+ __ JumpIfNotSmi(value, &miss);
1402
+
1403
+ // Prepare tail call to StoreIC_ArrayLength.
1404
+ __ Push(receiver, value);
1405
+
1406
+ ExternalReference ref = ExternalReference(IC_Utility(kStoreIC_ArrayLength),
1407
+ masm->isolate());
1408
+ __ TailCallExternalReference(ref, 2, 1);
1409
+
1410
+ __ bind(&miss);
1411
+
1412
+ GenerateMiss(masm);
1413
+ }
1414
+
1415
+
1416
+ void StoreIC::GenerateNormal(MacroAssembler* masm) {
1417
+ // ----------- S t a t e -------------
1418
+ // -- a0 : value
1419
+ // -- a1 : receiver
1420
+ // -- a2 : name
1421
+ // -- ra : return address
1422
+ // -----------------------------------
1423
+ Label miss;
1424
+
1425
+ GenerateStringDictionaryReceiverCheck(masm, a1, a3, t0, t1, &miss);
1426
+
1427
+ GenerateDictionaryStore(masm, &miss, a3, a2, a0, t0, t1);
1428
+ Counters* counters = masm->isolate()->counters();
1429
+ __ IncrementCounter(counters->store_normal_hit(), 1, t0, t1);
1430
+ __ Ret();
1431
+
1432
+ __ bind(&miss);
1433
+ __ IncrementCounter(counters->store_normal_miss(), 1, t0, t1);
1434
+ GenerateMiss(masm);
1435
+ }
1436
+
1437
+
1438
+ void StoreIC::GenerateGlobalProxy(MacroAssembler* masm,
1439
+ StrictModeFlag strict_mode) {
1440
+ // ----------- S t a t e -------------
1441
+ // -- a0 : value
1442
+ // -- a1 : receiver
1443
+ // -- a2 : name
1444
+ // -- ra : return address
1445
+ // -----------------------------------
1446
+
1447
+ __ Push(a1, a2, a0);
1448
+
1449
+ __ li(a1, Operand(Smi::FromInt(NONE))); // PropertyAttributes.
1450
+ __ li(a0, Operand(Smi::FromInt(strict_mode)));
1451
+ __ Push(a1, a0);
1452
+
1453
+ // Do tail-call to runtime routine.
1454
+ __ TailCallRuntime(Runtime::kSetProperty, 5, 1);
1455
+ }
1456
+
1457
+
1458
+ #undef __
1459
+
1460
+
1461
+ Condition CompareIC::ComputeCondition(Token::Value op) {
1462
+ switch (op) {
1463
+ case Token::EQ_STRICT:
1464
+ case Token::EQ:
1465
+ return eq;
1466
+ case Token::LT:
1467
+ return lt;
1468
+ case Token::GT:
1469
+ // Reverse left and right operands to obtain ECMA-262 conversion order.
1470
+ return lt;
1471
+ case Token::LTE:
1472
+ // Reverse left and right operands to obtain ECMA-262 conversion order.
1473
+ return ge;
1474
+ case Token::GTE:
1475
+ return ge;
1476
+ default:
1477
+ UNREACHABLE();
1478
+ return kNoCondition;
1479
+ }
1480
+ }
1481
+
1482
+
1483
+ void CompareIC::UpdateCaches(Handle<Object> x, Handle<Object> y) {
1484
+ HandleScope scope;
1485
+ Handle<Code> rewritten;
1486
+ State previous_state = GetState();
1487
+ State state = TargetState(previous_state, false, x, y);
1488
+ if (state == GENERIC) {
1489
+ CompareStub stub(GetCondition(), strict(), NO_COMPARE_FLAGS, a1, a0);
1490
+ rewritten = stub.GetCode();
1491
+ } else {
1492
+ ICCompareStub stub(op_, state);
1493
+ rewritten = stub.GetCode();
1494
+ }
1495
+ set_target(*rewritten);
1496
+
1497
+ #ifdef DEBUG
1498
+ if (FLAG_trace_ic) {
1499
+ PrintF("[CompareIC (%s->%s)#%s]\n",
1500
+ GetStateName(previous_state),
1501
+ GetStateName(state),
1502
+ Token::Name(op_));
1503
+ }
1504
+ #endif
1505
+
1506
+ // Activate inlined smi code.
1507
+ if (previous_state == UNINITIALIZED) {
1508
+ PatchInlinedSmiCode(address());
1509
+ }
1510
+ }
1511
+
1512
+
1513
+ void PatchInlinedSmiCode(Address address) {
1514
+ Address andi_instruction_address =
1515
+ address + Assembler::kCallTargetAddressOffset;
1516
+
1517
+ // If the instruction following the call is not a andi at, rx, #yyy, nothing
1518
+ // was inlined.
1519
+ Instr instr = Assembler::instr_at(andi_instruction_address);
1520
+ if (!Assembler::IsAndImmediate(instr)) {
1521
+ return;
1522
+ }
1523
+
1524
+ // The delta to the start of the map check instruction and the
1525
+ // condition code uses at the patched jump.
1526
+ int delta = Assembler::GetImmediate16(instr);
1527
+ delta += Assembler::GetRs(instr) * kImm16Mask;
1528
+ // If the delta is 0 the instruction is andi at, zero_reg, #0 which also
1529
+ // signals that nothing was inlined.
1530
+ if (delta == 0) {
1531
+ return;
1532
+ }
1533
+
1534
+ #ifdef DEBUG
1535
+ if (FLAG_trace_ic) {
1536
+ PrintF("[ patching ic at %p, andi=%p, delta=%d\n",
1537
+ address, andi_instruction_address, delta);
1538
+ }
1539
+ #endif
1540
+
1541
+ Address patch_address =
1542
+ andi_instruction_address - delta * Instruction::kInstrSize;
1543
+ Instr instr_at_patch = Assembler::instr_at(patch_address);
1544
+ Instr branch_instr =
1545
+ Assembler::instr_at(patch_address + Instruction::kInstrSize);
1546
+ ASSERT(Assembler::IsAndImmediate(instr_at_patch));
1547
+ ASSERT_EQ(0, Assembler::GetImmediate16(instr_at_patch));
1548
+ ASSERT(Assembler::IsBranch(branch_instr));
1549
+ if (Assembler::IsBeq(branch_instr)) {
1550
+ // This is patching a "jump if not smi" site to be active.
1551
+ // Changing:
1552
+ // andi at, rx, 0
1553
+ // Branch <target>, eq, at, Operand(zero_reg)
1554
+ // to:
1555
+ // andi at, rx, #kSmiTagMask
1556
+ // Branch <target>, ne, at, Operand(zero_reg)
1557
+ CodePatcher patcher(patch_address, 2);
1558
+ Register reg = Register::from_code(Assembler::GetRs(instr_at_patch));
1559
+ patcher.masm()->andi(at, reg, kSmiTagMask);
1560
+ patcher.ChangeBranchCondition(ne);
1561
+ } else {
1562
+ ASSERT(Assembler::IsBne(branch_instr));
1563
+ // This is patching a "jump if smi" site to be active.
1564
+ // Changing:
1565
+ // andi at, rx, 0
1566
+ // Branch <target>, ne, at, Operand(zero_reg)
1567
+ // to:
1568
+ // andi at, rx, #kSmiTagMask
1569
+ // Branch <target>, eq, at, Operand(zero_reg)
1570
+ CodePatcher patcher(patch_address, 2);
1571
+ Register reg = Register::from_code(Assembler::GetRs(instr_at_patch));
1572
+ patcher.masm()->andi(at, reg, kSmiTagMask);
1573
+ patcher.ChangeBranchCondition(eq);
1574
+ }
1575
+ }
1576
+
1577
+
1578
+ } } // namespace v8::internal
1579
+
1580
+ #endif // V8_TARGET_ARCH_MIPS