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