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