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,49 @@
|
|
1
|
+
// Copyright 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
|
+
// A simple interpreter for the Irregexp byte code.
|
29
|
+
|
30
|
+
#ifndef V8_INTERPRETER_IRREGEXP_H_
|
31
|
+
#define V8_INTERPRETER_IRREGEXP_H_
|
32
|
+
|
33
|
+
namespace v8 {
|
34
|
+
namespace internal {
|
35
|
+
|
36
|
+
|
37
|
+
class IrregexpInterpreter {
|
38
|
+
public:
|
39
|
+
static bool Match(Isolate* isolate,
|
40
|
+
Handle<ByteArray> code,
|
41
|
+
Handle<String> subject,
|
42
|
+
int* captures,
|
43
|
+
int start_position);
|
44
|
+
};
|
45
|
+
|
46
|
+
|
47
|
+
} } // namespace v8::internal
|
48
|
+
|
49
|
+
#endif // V8_INTERPRETER_IRREGEXP_H_
|
@@ -0,0 +1,50 @@
|
|
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
|
+
#ifndef V8_ISOLATE_INL_H_
|
29
|
+
#define V8_ISOLATE_INL_H_
|
30
|
+
|
31
|
+
#include "isolate.h"
|
32
|
+
|
33
|
+
#include "debug.h"
|
34
|
+
|
35
|
+
namespace v8 {
|
36
|
+
namespace internal {
|
37
|
+
|
38
|
+
|
39
|
+
bool Isolate::DebuggerHasBreakPoints() {
|
40
|
+
#ifdef ENABLE_DEBUGGER_SUPPORT
|
41
|
+
return debug()->has_break_points();
|
42
|
+
#else
|
43
|
+
return false;
|
44
|
+
#endif
|
45
|
+
}
|
46
|
+
|
47
|
+
|
48
|
+
} } // namespace v8::internal
|
49
|
+
|
50
|
+
#endif // V8_ISOLATE_INL_H_
|
@@ -0,0 +1,1869 @@
|
|
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 <stdlib.h>
|
29
|
+
|
30
|
+
#include "v8.h"
|
31
|
+
|
32
|
+
#include "ast.h"
|
33
|
+
#include "bootstrapper.h"
|
34
|
+
#include "codegen.h"
|
35
|
+
#include "compilation-cache.h"
|
36
|
+
#include "debug.h"
|
37
|
+
#include "deoptimizer.h"
|
38
|
+
#include "heap-profiler.h"
|
39
|
+
#include "hydrogen.h"
|
40
|
+
#include "isolate.h"
|
41
|
+
#include "lithium-allocator.h"
|
42
|
+
#include "log.h"
|
43
|
+
#include "messages.h"
|
44
|
+
#include "regexp-stack.h"
|
45
|
+
#include "runtime-profiler.h"
|
46
|
+
#include "scanner.h"
|
47
|
+
#include "scopeinfo.h"
|
48
|
+
#include "serialize.h"
|
49
|
+
#include "simulator.h"
|
50
|
+
#include "spaces.h"
|
51
|
+
#include "stub-cache.h"
|
52
|
+
#include "version.h"
|
53
|
+
#include "vm-state-inl.h"
|
54
|
+
|
55
|
+
|
56
|
+
namespace v8 {
|
57
|
+
namespace internal {
|
58
|
+
|
59
|
+
Atomic32 ThreadId::highest_thread_id_ = 0;
|
60
|
+
|
61
|
+
int ThreadId::AllocateThreadId() {
|
62
|
+
int new_id = NoBarrier_AtomicIncrement(&highest_thread_id_, 1);
|
63
|
+
return new_id;
|
64
|
+
}
|
65
|
+
|
66
|
+
|
67
|
+
int ThreadId::GetCurrentThreadId() {
|
68
|
+
int thread_id = Thread::GetThreadLocalInt(Isolate::thread_id_key_);
|
69
|
+
if (thread_id == 0) {
|
70
|
+
thread_id = AllocateThreadId();
|
71
|
+
Thread::SetThreadLocalInt(Isolate::thread_id_key_, thread_id);
|
72
|
+
}
|
73
|
+
return thread_id;
|
74
|
+
}
|
75
|
+
|
76
|
+
|
77
|
+
ThreadLocalTop::ThreadLocalTop() {
|
78
|
+
InitializeInternal();
|
79
|
+
}
|
80
|
+
|
81
|
+
|
82
|
+
void ThreadLocalTop::InitializeInternal() {
|
83
|
+
c_entry_fp_ = 0;
|
84
|
+
handler_ = 0;
|
85
|
+
#ifdef USE_SIMULATOR
|
86
|
+
simulator_ = NULL;
|
87
|
+
#endif
|
88
|
+
#ifdef ENABLE_LOGGING_AND_PROFILING
|
89
|
+
js_entry_sp_ = NULL;
|
90
|
+
external_callback_ = NULL;
|
91
|
+
#endif
|
92
|
+
#ifdef ENABLE_VMSTATE_TRACKING
|
93
|
+
current_vm_state_ = EXTERNAL;
|
94
|
+
#endif
|
95
|
+
try_catch_handler_address_ = NULL;
|
96
|
+
context_ = NULL;
|
97
|
+
thread_id_ = ThreadId::Invalid();
|
98
|
+
external_caught_exception_ = false;
|
99
|
+
failed_access_check_callback_ = NULL;
|
100
|
+
save_context_ = NULL;
|
101
|
+
catcher_ = NULL;
|
102
|
+
}
|
103
|
+
|
104
|
+
|
105
|
+
void ThreadLocalTop::Initialize() {
|
106
|
+
InitializeInternal();
|
107
|
+
#ifdef USE_SIMULATOR
|
108
|
+
#ifdef V8_TARGET_ARCH_ARM
|
109
|
+
simulator_ = Simulator::current(isolate_);
|
110
|
+
#elif V8_TARGET_ARCH_MIPS
|
111
|
+
simulator_ = Simulator::current(isolate_);
|
112
|
+
#endif
|
113
|
+
#endif
|
114
|
+
thread_id_ = ThreadId::Current();
|
115
|
+
}
|
116
|
+
|
117
|
+
|
118
|
+
v8::TryCatch* ThreadLocalTop::TryCatchHandler() {
|
119
|
+
return TRY_CATCH_FROM_ADDRESS(try_catch_handler_address());
|
120
|
+
}
|
121
|
+
|
122
|
+
|
123
|
+
// Create a dummy thread that will wait forever on a semaphore. The only
|
124
|
+
// purpose for this thread is to have some stack area to save essential data
|
125
|
+
// into for use by a stacks only core dump (aka minidump).
|
126
|
+
class PreallocatedMemoryThread: public Thread {
|
127
|
+
public:
|
128
|
+
char* data() {
|
129
|
+
if (data_ready_semaphore_ != NULL) {
|
130
|
+
// Initial access is guarded until the data has been published.
|
131
|
+
data_ready_semaphore_->Wait();
|
132
|
+
delete data_ready_semaphore_;
|
133
|
+
data_ready_semaphore_ = NULL;
|
134
|
+
}
|
135
|
+
return data_;
|
136
|
+
}
|
137
|
+
|
138
|
+
unsigned length() {
|
139
|
+
if (data_ready_semaphore_ != NULL) {
|
140
|
+
// Initial access is guarded until the data has been published.
|
141
|
+
data_ready_semaphore_->Wait();
|
142
|
+
delete data_ready_semaphore_;
|
143
|
+
data_ready_semaphore_ = NULL;
|
144
|
+
}
|
145
|
+
return length_;
|
146
|
+
}
|
147
|
+
|
148
|
+
// Stop the PreallocatedMemoryThread and release its resources.
|
149
|
+
void StopThread() {
|
150
|
+
keep_running_ = false;
|
151
|
+
wait_for_ever_semaphore_->Signal();
|
152
|
+
|
153
|
+
// Wait for the thread to terminate.
|
154
|
+
Join();
|
155
|
+
|
156
|
+
if (data_ready_semaphore_ != NULL) {
|
157
|
+
delete data_ready_semaphore_;
|
158
|
+
data_ready_semaphore_ = NULL;
|
159
|
+
}
|
160
|
+
|
161
|
+
delete wait_for_ever_semaphore_;
|
162
|
+
wait_for_ever_semaphore_ = NULL;
|
163
|
+
}
|
164
|
+
|
165
|
+
protected:
|
166
|
+
// When the thread starts running it will allocate a fixed number of bytes
|
167
|
+
// on the stack and publish the location of this memory for others to use.
|
168
|
+
void Run() {
|
169
|
+
EmbeddedVector<char, 15 * 1024> local_buffer;
|
170
|
+
|
171
|
+
// Initialize the buffer with a known good value.
|
172
|
+
OS::StrNCpy(local_buffer, "Trace data was not generated.\n",
|
173
|
+
local_buffer.length());
|
174
|
+
|
175
|
+
// Publish the local buffer and signal its availability.
|
176
|
+
data_ = local_buffer.start();
|
177
|
+
length_ = local_buffer.length();
|
178
|
+
data_ready_semaphore_->Signal();
|
179
|
+
|
180
|
+
while (keep_running_) {
|
181
|
+
// This thread will wait here until the end of time.
|
182
|
+
wait_for_ever_semaphore_->Wait();
|
183
|
+
}
|
184
|
+
|
185
|
+
// Make sure we access the buffer after the wait to remove all possibility
|
186
|
+
// of it being optimized away.
|
187
|
+
OS::StrNCpy(local_buffer, "PreallocatedMemoryThread shutting down.\n",
|
188
|
+
local_buffer.length());
|
189
|
+
}
|
190
|
+
|
191
|
+
|
192
|
+
private:
|
193
|
+
explicit PreallocatedMemoryThread(Isolate* isolate)
|
194
|
+
: Thread(isolate, "v8:PreallocMem"),
|
195
|
+
keep_running_(true),
|
196
|
+
wait_for_ever_semaphore_(OS::CreateSemaphore(0)),
|
197
|
+
data_ready_semaphore_(OS::CreateSemaphore(0)),
|
198
|
+
data_(NULL),
|
199
|
+
length_(0) {
|
200
|
+
}
|
201
|
+
|
202
|
+
// Used to make sure that the thread keeps looping even for spurious wakeups.
|
203
|
+
bool keep_running_;
|
204
|
+
|
205
|
+
// This semaphore is used by the PreallocatedMemoryThread to wait for ever.
|
206
|
+
Semaphore* wait_for_ever_semaphore_;
|
207
|
+
// Semaphore to signal that the data has been initialized.
|
208
|
+
Semaphore* data_ready_semaphore_;
|
209
|
+
|
210
|
+
// Location and size of the preallocated memory block.
|
211
|
+
char* data_;
|
212
|
+
unsigned length_;
|
213
|
+
|
214
|
+
friend class Isolate;
|
215
|
+
|
216
|
+
DISALLOW_COPY_AND_ASSIGN(PreallocatedMemoryThread);
|
217
|
+
};
|
218
|
+
|
219
|
+
|
220
|
+
void Isolate::PreallocatedMemoryThreadStart() {
|
221
|
+
if (preallocated_memory_thread_ != NULL) return;
|
222
|
+
preallocated_memory_thread_ = new PreallocatedMemoryThread(this);
|
223
|
+
preallocated_memory_thread_->Start();
|
224
|
+
}
|
225
|
+
|
226
|
+
|
227
|
+
void Isolate::PreallocatedMemoryThreadStop() {
|
228
|
+
if (preallocated_memory_thread_ == NULL) return;
|
229
|
+
preallocated_memory_thread_->StopThread();
|
230
|
+
// Done with the thread entirely.
|
231
|
+
delete preallocated_memory_thread_;
|
232
|
+
preallocated_memory_thread_ = NULL;
|
233
|
+
}
|
234
|
+
|
235
|
+
|
236
|
+
void Isolate::PreallocatedStorageInit(size_t size) {
|
237
|
+
ASSERT(free_list_.next_ == &free_list_);
|
238
|
+
ASSERT(free_list_.previous_ == &free_list_);
|
239
|
+
PreallocatedStorage* free_chunk =
|
240
|
+
reinterpret_cast<PreallocatedStorage*>(new char[size]);
|
241
|
+
free_list_.next_ = free_list_.previous_ = free_chunk;
|
242
|
+
free_chunk->next_ = free_chunk->previous_ = &free_list_;
|
243
|
+
free_chunk->size_ = size - sizeof(PreallocatedStorage);
|
244
|
+
preallocated_storage_preallocated_ = true;
|
245
|
+
}
|
246
|
+
|
247
|
+
|
248
|
+
void* Isolate::PreallocatedStorageNew(size_t size) {
|
249
|
+
if (!preallocated_storage_preallocated_) {
|
250
|
+
return FreeStoreAllocationPolicy::New(size);
|
251
|
+
}
|
252
|
+
ASSERT(free_list_.next_ != &free_list_);
|
253
|
+
ASSERT(free_list_.previous_ != &free_list_);
|
254
|
+
|
255
|
+
size = (size + kPointerSize - 1) & ~(kPointerSize - 1);
|
256
|
+
// Search for exact fit.
|
257
|
+
for (PreallocatedStorage* storage = free_list_.next_;
|
258
|
+
storage != &free_list_;
|
259
|
+
storage = storage->next_) {
|
260
|
+
if (storage->size_ == size) {
|
261
|
+
storage->Unlink();
|
262
|
+
storage->LinkTo(&in_use_list_);
|
263
|
+
return reinterpret_cast<void*>(storage + 1);
|
264
|
+
}
|
265
|
+
}
|
266
|
+
// Search for first fit.
|
267
|
+
for (PreallocatedStorage* storage = free_list_.next_;
|
268
|
+
storage != &free_list_;
|
269
|
+
storage = storage->next_) {
|
270
|
+
if (storage->size_ >= size + sizeof(PreallocatedStorage)) {
|
271
|
+
storage->Unlink();
|
272
|
+
storage->LinkTo(&in_use_list_);
|
273
|
+
PreallocatedStorage* left_over =
|
274
|
+
reinterpret_cast<PreallocatedStorage*>(
|
275
|
+
reinterpret_cast<char*>(storage + 1) + size);
|
276
|
+
left_over->size_ = storage->size_ - size - sizeof(PreallocatedStorage);
|
277
|
+
ASSERT(size + left_over->size_ + sizeof(PreallocatedStorage) ==
|
278
|
+
storage->size_);
|
279
|
+
storage->size_ = size;
|
280
|
+
left_over->LinkTo(&free_list_);
|
281
|
+
return reinterpret_cast<void*>(storage + 1);
|
282
|
+
}
|
283
|
+
}
|
284
|
+
// Allocation failure.
|
285
|
+
ASSERT(false);
|
286
|
+
return NULL;
|
287
|
+
}
|
288
|
+
|
289
|
+
|
290
|
+
// We don't attempt to coalesce.
|
291
|
+
void Isolate::PreallocatedStorageDelete(void* p) {
|
292
|
+
if (p == NULL) {
|
293
|
+
return;
|
294
|
+
}
|
295
|
+
if (!preallocated_storage_preallocated_) {
|
296
|
+
FreeStoreAllocationPolicy::Delete(p);
|
297
|
+
return;
|
298
|
+
}
|
299
|
+
PreallocatedStorage* storage = reinterpret_cast<PreallocatedStorage*>(p) - 1;
|
300
|
+
ASSERT(storage->next_->previous_ == storage);
|
301
|
+
ASSERT(storage->previous_->next_ == storage);
|
302
|
+
storage->Unlink();
|
303
|
+
storage->LinkTo(&free_list_);
|
304
|
+
}
|
305
|
+
|
306
|
+
|
307
|
+
Isolate* Isolate::default_isolate_ = NULL;
|
308
|
+
Thread::LocalStorageKey Isolate::isolate_key_;
|
309
|
+
Thread::LocalStorageKey Isolate::thread_id_key_;
|
310
|
+
Thread::LocalStorageKey Isolate::per_isolate_thread_data_key_;
|
311
|
+
Mutex* Isolate::process_wide_mutex_ = OS::CreateMutex();
|
312
|
+
Isolate::ThreadDataTable* Isolate::thread_data_table_ = NULL;
|
313
|
+
|
314
|
+
|
315
|
+
class IsolateInitializer {
|
316
|
+
public:
|
317
|
+
IsolateInitializer() {
|
318
|
+
Isolate::EnsureDefaultIsolate();
|
319
|
+
}
|
320
|
+
};
|
321
|
+
|
322
|
+
static IsolateInitializer* EnsureDefaultIsolateAllocated() {
|
323
|
+
// TODO(isolates): Use the system threading API to do this once?
|
324
|
+
static IsolateInitializer static_initializer;
|
325
|
+
return &static_initializer;
|
326
|
+
}
|
327
|
+
|
328
|
+
// This variable only needed to trigger static intialization.
|
329
|
+
static IsolateInitializer* static_initializer = EnsureDefaultIsolateAllocated();
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
Isolate::PerIsolateThreadData* Isolate::AllocatePerIsolateThreadData(
|
336
|
+
ThreadId thread_id) {
|
337
|
+
ASSERT(!thread_id.Equals(ThreadId::Invalid()));
|
338
|
+
PerIsolateThreadData* per_thread = new PerIsolateThreadData(this, thread_id);
|
339
|
+
{
|
340
|
+
ScopedLock lock(process_wide_mutex_);
|
341
|
+
ASSERT(thread_data_table_->Lookup(this, thread_id) == NULL);
|
342
|
+
thread_data_table_->Insert(per_thread);
|
343
|
+
ASSERT(thread_data_table_->Lookup(this, thread_id) == per_thread);
|
344
|
+
}
|
345
|
+
return per_thread;
|
346
|
+
}
|
347
|
+
|
348
|
+
|
349
|
+
Isolate::PerIsolateThreadData*
|
350
|
+
Isolate::FindOrAllocatePerThreadDataForThisThread() {
|
351
|
+
ThreadId thread_id = ThreadId::Current();
|
352
|
+
PerIsolateThreadData* per_thread = NULL;
|
353
|
+
{
|
354
|
+
ScopedLock lock(process_wide_mutex_);
|
355
|
+
per_thread = thread_data_table_->Lookup(this, thread_id);
|
356
|
+
if (per_thread == NULL) {
|
357
|
+
per_thread = AllocatePerIsolateThreadData(thread_id);
|
358
|
+
}
|
359
|
+
}
|
360
|
+
return per_thread;
|
361
|
+
}
|
362
|
+
|
363
|
+
|
364
|
+
Isolate::PerIsolateThreadData* Isolate::FindPerThreadDataForThisThread() {
|
365
|
+
ThreadId thread_id = ThreadId::Current();
|
366
|
+
PerIsolateThreadData* per_thread = NULL;
|
367
|
+
{
|
368
|
+
ScopedLock lock(process_wide_mutex_);
|
369
|
+
per_thread = thread_data_table_->Lookup(this, thread_id);
|
370
|
+
}
|
371
|
+
return per_thread;
|
372
|
+
}
|
373
|
+
|
374
|
+
|
375
|
+
void Isolate::EnsureDefaultIsolate() {
|
376
|
+
ScopedLock lock(process_wide_mutex_);
|
377
|
+
if (default_isolate_ == NULL) {
|
378
|
+
isolate_key_ = Thread::CreateThreadLocalKey();
|
379
|
+
thread_id_key_ = Thread::CreateThreadLocalKey();
|
380
|
+
per_isolate_thread_data_key_ = Thread::CreateThreadLocalKey();
|
381
|
+
thread_data_table_ = new Isolate::ThreadDataTable();
|
382
|
+
default_isolate_ = new Isolate();
|
383
|
+
}
|
384
|
+
// Can't use SetIsolateThreadLocals(default_isolate_, NULL) here
|
385
|
+
// becase a non-null thread data may be already set.
|
386
|
+
if (Thread::GetThreadLocal(isolate_key_) == NULL) {
|
387
|
+
Thread::SetThreadLocal(isolate_key_, default_isolate_);
|
388
|
+
}
|
389
|
+
CHECK(default_isolate_->PreInit());
|
390
|
+
}
|
391
|
+
|
392
|
+
|
393
|
+
#ifdef ENABLE_DEBUGGER_SUPPORT
|
394
|
+
Debugger* Isolate::GetDefaultIsolateDebugger() {
|
395
|
+
EnsureDefaultIsolate();
|
396
|
+
return default_isolate_->debugger();
|
397
|
+
}
|
398
|
+
#endif
|
399
|
+
|
400
|
+
|
401
|
+
StackGuard* Isolate::GetDefaultIsolateStackGuard() {
|
402
|
+
EnsureDefaultIsolate();
|
403
|
+
return default_isolate_->stack_guard();
|
404
|
+
}
|
405
|
+
|
406
|
+
|
407
|
+
void Isolate::EnterDefaultIsolate() {
|
408
|
+
EnsureDefaultIsolate();
|
409
|
+
ASSERT(default_isolate_ != NULL);
|
410
|
+
|
411
|
+
PerIsolateThreadData* data = CurrentPerIsolateThreadData();
|
412
|
+
// If not yet in default isolate - enter it.
|
413
|
+
if (data == NULL || data->isolate() != default_isolate_) {
|
414
|
+
default_isolate_->Enter();
|
415
|
+
}
|
416
|
+
}
|
417
|
+
|
418
|
+
|
419
|
+
Isolate* Isolate::GetDefaultIsolateForLocking() {
|
420
|
+
EnsureDefaultIsolate();
|
421
|
+
return default_isolate_;
|
422
|
+
}
|
423
|
+
|
424
|
+
|
425
|
+
Address Isolate::get_address_from_id(Isolate::AddressId id) {
|
426
|
+
return isolate_addresses_[id];
|
427
|
+
}
|
428
|
+
|
429
|
+
|
430
|
+
char* Isolate::Iterate(ObjectVisitor* v, char* thread_storage) {
|
431
|
+
ThreadLocalTop* thread = reinterpret_cast<ThreadLocalTop*>(thread_storage);
|
432
|
+
Iterate(v, thread);
|
433
|
+
return thread_storage + sizeof(ThreadLocalTop);
|
434
|
+
}
|
435
|
+
|
436
|
+
|
437
|
+
void Isolate::IterateThread(ThreadVisitor* v) {
|
438
|
+
v->VisitThread(this, thread_local_top());
|
439
|
+
}
|
440
|
+
|
441
|
+
|
442
|
+
void Isolate::IterateThread(ThreadVisitor* v, char* t) {
|
443
|
+
ThreadLocalTop* thread = reinterpret_cast<ThreadLocalTop*>(t);
|
444
|
+
v->VisitThread(this, thread);
|
445
|
+
}
|
446
|
+
|
447
|
+
|
448
|
+
void Isolate::Iterate(ObjectVisitor* v, ThreadLocalTop* thread) {
|
449
|
+
// Visit the roots from the top for a given thread.
|
450
|
+
Object* pending;
|
451
|
+
// The pending exception can sometimes be a failure. We can't show
|
452
|
+
// that to the GC, which only understands objects.
|
453
|
+
if (thread->pending_exception_->ToObject(&pending)) {
|
454
|
+
v->VisitPointer(&pending);
|
455
|
+
thread->pending_exception_ = pending; // In case GC updated it.
|
456
|
+
}
|
457
|
+
v->VisitPointer(&(thread->pending_message_obj_));
|
458
|
+
v->VisitPointer(BitCast<Object**>(&(thread->pending_message_script_)));
|
459
|
+
v->VisitPointer(BitCast<Object**>(&(thread->context_)));
|
460
|
+
Object* scheduled;
|
461
|
+
if (thread->scheduled_exception_->ToObject(&scheduled)) {
|
462
|
+
v->VisitPointer(&scheduled);
|
463
|
+
thread->scheduled_exception_ = scheduled;
|
464
|
+
}
|
465
|
+
|
466
|
+
for (v8::TryCatch* block = thread->TryCatchHandler();
|
467
|
+
block != NULL;
|
468
|
+
block = TRY_CATCH_FROM_ADDRESS(block->next_)) {
|
469
|
+
v->VisitPointer(BitCast<Object**>(&(block->exception_)));
|
470
|
+
v->VisitPointer(BitCast<Object**>(&(block->message_)));
|
471
|
+
}
|
472
|
+
|
473
|
+
// Iterate over pointers on native execution stack.
|
474
|
+
for (StackFrameIterator it(this, thread); !it.done(); it.Advance()) {
|
475
|
+
it.frame()->Iterate(v);
|
476
|
+
}
|
477
|
+
}
|
478
|
+
|
479
|
+
|
480
|
+
void Isolate::Iterate(ObjectVisitor* v) {
|
481
|
+
ThreadLocalTop* current_t = thread_local_top();
|
482
|
+
Iterate(v, current_t);
|
483
|
+
}
|
484
|
+
|
485
|
+
|
486
|
+
void Isolate::RegisterTryCatchHandler(v8::TryCatch* that) {
|
487
|
+
// The ARM simulator has a separate JS stack. We therefore register
|
488
|
+
// the C++ try catch handler with the simulator and get back an
|
489
|
+
// address that can be used for comparisons with addresses into the
|
490
|
+
// JS stack. When running without the simulator, the address
|
491
|
+
// returned will be the address of the C++ try catch handler itself.
|
492
|
+
Address address = reinterpret_cast<Address>(
|
493
|
+
SimulatorStack::RegisterCTryCatch(reinterpret_cast<uintptr_t>(that)));
|
494
|
+
thread_local_top()->set_try_catch_handler_address(address);
|
495
|
+
}
|
496
|
+
|
497
|
+
|
498
|
+
void Isolate::UnregisterTryCatchHandler(v8::TryCatch* that) {
|
499
|
+
ASSERT(thread_local_top()->TryCatchHandler() == that);
|
500
|
+
thread_local_top()->set_try_catch_handler_address(
|
501
|
+
reinterpret_cast<Address>(that->next_));
|
502
|
+
thread_local_top()->catcher_ = NULL;
|
503
|
+
SimulatorStack::UnregisterCTryCatch();
|
504
|
+
}
|
505
|
+
|
506
|
+
|
507
|
+
Handle<String> Isolate::StackTraceString() {
|
508
|
+
if (stack_trace_nesting_level_ == 0) {
|
509
|
+
stack_trace_nesting_level_++;
|
510
|
+
HeapStringAllocator allocator;
|
511
|
+
StringStream::ClearMentionedObjectCache();
|
512
|
+
StringStream accumulator(&allocator);
|
513
|
+
incomplete_message_ = &accumulator;
|
514
|
+
PrintStack(&accumulator);
|
515
|
+
Handle<String> stack_trace = accumulator.ToString();
|
516
|
+
incomplete_message_ = NULL;
|
517
|
+
stack_trace_nesting_level_ = 0;
|
518
|
+
return stack_trace;
|
519
|
+
} else if (stack_trace_nesting_level_ == 1) {
|
520
|
+
stack_trace_nesting_level_++;
|
521
|
+
OS::PrintError(
|
522
|
+
"\n\nAttempt to print stack while printing stack (double fault)\n");
|
523
|
+
OS::PrintError(
|
524
|
+
"If you are lucky you may find a partial stack dump on stdout.\n\n");
|
525
|
+
incomplete_message_->OutputToStdOut();
|
526
|
+
return factory()->empty_symbol();
|
527
|
+
} else {
|
528
|
+
OS::Abort();
|
529
|
+
// Unreachable
|
530
|
+
return factory()->empty_symbol();
|
531
|
+
}
|
532
|
+
}
|
533
|
+
|
534
|
+
|
535
|
+
Handle<JSArray> Isolate::CaptureCurrentStackTrace(
|
536
|
+
int frame_limit, StackTrace::StackTraceOptions options) {
|
537
|
+
// Ensure no negative values.
|
538
|
+
int limit = Max(frame_limit, 0);
|
539
|
+
Handle<JSArray> stack_trace = factory()->NewJSArray(frame_limit);
|
540
|
+
|
541
|
+
Handle<String> column_key = factory()->LookupAsciiSymbol("column");
|
542
|
+
Handle<String> line_key = factory()->LookupAsciiSymbol("lineNumber");
|
543
|
+
Handle<String> script_key = factory()->LookupAsciiSymbol("scriptName");
|
544
|
+
Handle<String> name_or_source_url_key =
|
545
|
+
factory()->LookupAsciiSymbol("nameOrSourceURL");
|
546
|
+
Handle<String> script_name_or_source_url_key =
|
547
|
+
factory()->LookupAsciiSymbol("scriptNameOrSourceURL");
|
548
|
+
Handle<String> function_key = factory()->LookupAsciiSymbol("functionName");
|
549
|
+
Handle<String> eval_key = factory()->LookupAsciiSymbol("isEval");
|
550
|
+
Handle<String> constructor_key =
|
551
|
+
factory()->LookupAsciiSymbol("isConstructor");
|
552
|
+
|
553
|
+
StackTraceFrameIterator it(this);
|
554
|
+
int frames_seen = 0;
|
555
|
+
while (!it.done() && (frames_seen < limit)) {
|
556
|
+
JavaScriptFrame* frame = it.frame();
|
557
|
+
// Set initial size to the maximum inlining level + 1 for the outermost
|
558
|
+
// function.
|
559
|
+
List<FrameSummary> frames(Compiler::kMaxInliningLevels + 1);
|
560
|
+
frame->Summarize(&frames);
|
561
|
+
for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) {
|
562
|
+
// Create a JSObject to hold the information for the StackFrame.
|
563
|
+
Handle<JSObject> stackFrame = factory()->NewJSObject(object_function());
|
564
|
+
|
565
|
+
Handle<JSFunction> fun = frames[i].function();
|
566
|
+
Handle<Script> script(Script::cast(fun->shared()->script()));
|
567
|
+
|
568
|
+
if (options & StackTrace::kLineNumber) {
|
569
|
+
int script_line_offset = script->line_offset()->value();
|
570
|
+
int position = frames[i].code()->SourcePosition(frames[i].pc());
|
571
|
+
int line_number = GetScriptLineNumber(script, position);
|
572
|
+
// line_number is already shifted by the script_line_offset.
|
573
|
+
int relative_line_number = line_number - script_line_offset;
|
574
|
+
if (options & StackTrace::kColumnOffset && relative_line_number >= 0) {
|
575
|
+
Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends()));
|
576
|
+
int start = (relative_line_number == 0) ? 0 :
|
577
|
+
Smi::cast(line_ends->get(relative_line_number - 1))->value() + 1;
|
578
|
+
int column_offset = position - start;
|
579
|
+
if (relative_line_number == 0) {
|
580
|
+
// For the case where the code is on the same line as the script
|
581
|
+
// tag.
|
582
|
+
column_offset += script->column_offset()->value();
|
583
|
+
}
|
584
|
+
SetLocalPropertyNoThrow(stackFrame, column_key,
|
585
|
+
Handle<Smi>(Smi::FromInt(column_offset + 1)));
|
586
|
+
}
|
587
|
+
SetLocalPropertyNoThrow(stackFrame, line_key,
|
588
|
+
Handle<Smi>(Smi::FromInt(line_number + 1)));
|
589
|
+
}
|
590
|
+
|
591
|
+
if (options & StackTrace::kScriptName) {
|
592
|
+
Handle<Object> script_name(script->name(), this);
|
593
|
+
SetLocalPropertyNoThrow(stackFrame, script_key, script_name);
|
594
|
+
}
|
595
|
+
|
596
|
+
if (options & StackTrace::kScriptNameOrSourceURL) {
|
597
|
+
Handle<Object> script_name(script->name(), this);
|
598
|
+
Handle<JSValue> script_wrapper = GetScriptWrapper(script);
|
599
|
+
Handle<Object> property = GetProperty(script_wrapper,
|
600
|
+
name_or_source_url_key);
|
601
|
+
ASSERT(property->IsJSFunction());
|
602
|
+
Handle<JSFunction> method = Handle<JSFunction>::cast(property);
|
603
|
+
bool caught_exception;
|
604
|
+
Handle<Object> result = Execution::TryCall(method, script_wrapper, 0,
|
605
|
+
NULL, &caught_exception);
|
606
|
+
if (caught_exception) {
|
607
|
+
result = factory()->undefined_value();
|
608
|
+
}
|
609
|
+
SetLocalPropertyNoThrow(stackFrame, script_name_or_source_url_key,
|
610
|
+
result);
|
611
|
+
}
|
612
|
+
|
613
|
+
if (options & StackTrace::kFunctionName) {
|
614
|
+
Handle<Object> fun_name(fun->shared()->name(), this);
|
615
|
+
if (fun_name->ToBoolean()->IsFalse()) {
|
616
|
+
fun_name = Handle<Object>(fun->shared()->inferred_name(), this);
|
617
|
+
}
|
618
|
+
SetLocalPropertyNoThrow(stackFrame, function_key, fun_name);
|
619
|
+
}
|
620
|
+
|
621
|
+
if (options & StackTrace::kIsEval) {
|
622
|
+
int type = Smi::cast(script->compilation_type())->value();
|
623
|
+
Handle<Object> is_eval = (type == Script::COMPILATION_TYPE_EVAL) ?
|
624
|
+
factory()->true_value() : factory()->false_value();
|
625
|
+
SetLocalPropertyNoThrow(stackFrame, eval_key, is_eval);
|
626
|
+
}
|
627
|
+
|
628
|
+
if (options & StackTrace::kIsConstructor) {
|
629
|
+
Handle<Object> is_constructor = (frames[i].is_constructor()) ?
|
630
|
+
factory()->true_value() : factory()->false_value();
|
631
|
+
SetLocalPropertyNoThrow(stackFrame, constructor_key, is_constructor);
|
632
|
+
}
|
633
|
+
|
634
|
+
FixedArray::cast(stack_trace->elements())->set(frames_seen, *stackFrame);
|
635
|
+
frames_seen++;
|
636
|
+
}
|
637
|
+
it.Advance();
|
638
|
+
}
|
639
|
+
|
640
|
+
stack_trace->set_length(Smi::FromInt(frames_seen));
|
641
|
+
return stack_trace;
|
642
|
+
}
|
643
|
+
|
644
|
+
|
645
|
+
void Isolate::PrintStack() {
|
646
|
+
if (stack_trace_nesting_level_ == 0) {
|
647
|
+
stack_trace_nesting_level_++;
|
648
|
+
|
649
|
+
StringAllocator* allocator;
|
650
|
+
if (preallocated_message_space_ == NULL) {
|
651
|
+
allocator = new HeapStringAllocator();
|
652
|
+
} else {
|
653
|
+
allocator = preallocated_message_space_;
|
654
|
+
}
|
655
|
+
|
656
|
+
StringStream::ClearMentionedObjectCache();
|
657
|
+
StringStream accumulator(allocator);
|
658
|
+
incomplete_message_ = &accumulator;
|
659
|
+
PrintStack(&accumulator);
|
660
|
+
accumulator.OutputToStdOut();
|
661
|
+
accumulator.Log();
|
662
|
+
incomplete_message_ = NULL;
|
663
|
+
stack_trace_nesting_level_ = 0;
|
664
|
+
if (preallocated_message_space_ == NULL) {
|
665
|
+
// Remove the HeapStringAllocator created above.
|
666
|
+
delete allocator;
|
667
|
+
}
|
668
|
+
} else if (stack_trace_nesting_level_ == 1) {
|
669
|
+
stack_trace_nesting_level_++;
|
670
|
+
OS::PrintError(
|
671
|
+
"\n\nAttempt to print stack while printing stack (double fault)\n");
|
672
|
+
OS::PrintError(
|
673
|
+
"If you are lucky you may find a partial stack dump on stdout.\n\n");
|
674
|
+
incomplete_message_->OutputToStdOut();
|
675
|
+
}
|
676
|
+
}
|
677
|
+
|
678
|
+
|
679
|
+
static void PrintFrames(StringStream* accumulator,
|
680
|
+
StackFrame::PrintMode mode) {
|
681
|
+
StackFrameIterator it;
|
682
|
+
for (int i = 0; !it.done(); it.Advance()) {
|
683
|
+
it.frame()->Print(accumulator, mode, i++);
|
684
|
+
}
|
685
|
+
}
|
686
|
+
|
687
|
+
|
688
|
+
void Isolate::PrintStack(StringStream* accumulator) {
|
689
|
+
if (!IsInitialized()) {
|
690
|
+
accumulator->Add(
|
691
|
+
"\n==== Stack trace is not available ==========================\n\n");
|
692
|
+
accumulator->Add(
|
693
|
+
"\n==== Isolate for the thread is not initialized =============\n\n");
|
694
|
+
return;
|
695
|
+
}
|
696
|
+
// The MentionedObjectCache is not GC-proof at the moment.
|
697
|
+
AssertNoAllocation nogc;
|
698
|
+
ASSERT(StringStream::IsMentionedObjectCacheClear());
|
699
|
+
|
700
|
+
// Avoid printing anything if there are no frames.
|
701
|
+
if (c_entry_fp(thread_local_top()) == 0) return;
|
702
|
+
|
703
|
+
accumulator->Add(
|
704
|
+
"\n==== Stack trace ============================================\n\n");
|
705
|
+
PrintFrames(accumulator, StackFrame::OVERVIEW);
|
706
|
+
|
707
|
+
accumulator->Add(
|
708
|
+
"\n==== Details ================================================\n\n");
|
709
|
+
PrintFrames(accumulator, StackFrame::DETAILS);
|
710
|
+
|
711
|
+
accumulator->PrintMentionedObjectCache();
|
712
|
+
accumulator->Add("=====================\n\n");
|
713
|
+
}
|
714
|
+
|
715
|
+
|
716
|
+
void Isolate::SetFailedAccessCheckCallback(
|
717
|
+
v8::FailedAccessCheckCallback callback) {
|
718
|
+
thread_local_top()->failed_access_check_callback_ = callback;
|
719
|
+
}
|
720
|
+
|
721
|
+
|
722
|
+
void Isolate::ReportFailedAccessCheck(JSObject* receiver, v8::AccessType type) {
|
723
|
+
if (!thread_local_top()->failed_access_check_callback_) return;
|
724
|
+
|
725
|
+
ASSERT(receiver->IsAccessCheckNeeded());
|
726
|
+
ASSERT(context());
|
727
|
+
|
728
|
+
// Get the data object from access check info.
|
729
|
+
JSFunction* constructor = JSFunction::cast(receiver->map()->constructor());
|
730
|
+
if (!constructor->shared()->IsApiFunction()) return;
|
731
|
+
Object* data_obj =
|
732
|
+
constructor->shared()->get_api_func_data()->access_check_info();
|
733
|
+
if (data_obj == heap_.undefined_value()) return;
|
734
|
+
|
735
|
+
HandleScope scope;
|
736
|
+
Handle<JSObject> receiver_handle(receiver);
|
737
|
+
Handle<Object> data(AccessCheckInfo::cast(data_obj)->data());
|
738
|
+
thread_local_top()->failed_access_check_callback_(
|
739
|
+
v8::Utils::ToLocal(receiver_handle),
|
740
|
+
type,
|
741
|
+
v8::Utils::ToLocal(data));
|
742
|
+
}
|
743
|
+
|
744
|
+
|
745
|
+
enum MayAccessDecision {
|
746
|
+
YES, NO, UNKNOWN
|
747
|
+
};
|
748
|
+
|
749
|
+
|
750
|
+
static MayAccessDecision MayAccessPreCheck(Isolate* isolate,
|
751
|
+
JSObject* receiver,
|
752
|
+
v8::AccessType type) {
|
753
|
+
// During bootstrapping, callback functions are not enabled yet.
|
754
|
+
if (isolate->bootstrapper()->IsActive()) return YES;
|
755
|
+
|
756
|
+
if (receiver->IsJSGlobalProxy()) {
|
757
|
+
Object* receiver_context = JSGlobalProxy::cast(receiver)->context();
|
758
|
+
if (!receiver_context->IsContext()) return NO;
|
759
|
+
|
760
|
+
// Get the global context of current top context.
|
761
|
+
// avoid using Isolate::global_context() because it uses Handle.
|
762
|
+
Context* global_context = isolate->context()->global()->global_context();
|
763
|
+
if (receiver_context == global_context) return YES;
|
764
|
+
|
765
|
+
if (Context::cast(receiver_context)->security_token() ==
|
766
|
+
global_context->security_token())
|
767
|
+
return YES;
|
768
|
+
}
|
769
|
+
|
770
|
+
return UNKNOWN;
|
771
|
+
}
|
772
|
+
|
773
|
+
|
774
|
+
bool Isolate::MayNamedAccess(JSObject* receiver, Object* key,
|
775
|
+
v8::AccessType type) {
|
776
|
+
ASSERT(receiver->IsAccessCheckNeeded());
|
777
|
+
|
778
|
+
// The callers of this method are not expecting a GC.
|
779
|
+
AssertNoAllocation no_gc;
|
780
|
+
|
781
|
+
// Skip checks for hidden properties access. Note, we do not
|
782
|
+
// require existence of a context in this case.
|
783
|
+
if (key == heap_.hidden_symbol()) return true;
|
784
|
+
|
785
|
+
// Check for compatibility between the security tokens in the
|
786
|
+
// current lexical context and the accessed object.
|
787
|
+
ASSERT(context());
|
788
|
+
|
789
|
+
MayAccessDecision decision = MayAccessPreCheck(this, receiver, type);
|
790
|
+
if (decision != UNKNOWN) return decision == YES;
|
791
|
+
|
792
|
+
// Get named access check callback
|
793
|
+
JSFunction* constructor = JSFunction::cast(receiver->map()->constructor());
|
794
|
+
if (!constructor->shared()->IsApiFunction()) return false;
|
795
|
+
|
796
|
+
Object* data_obj =
|
797
|
+
constructor->shared()->get_api_func_data()->access_check_info();
|
798
|
+
if (data_obj == heap_.undefined_value()) return false;
|
799
|
+
|
800
|
+
Object* fun_obj = AccessCheckInfo::cast(data_obj)->named_callback();
|
801
|
+
v8::NamedSecurityCallback callback =
|
802
|
+
v8::ToCData<v8::NamedSecurityCallback>(fun_obj);
|
803
|
+
|
804
|
+
if (!callback) return false;
|
805
|
+
|
806
|
+
HandleScope scope(this);
|
807
|
+
Handle<JSObject> receiver_handle(receiver, this);
|
808
|
+
Handle<Object> key_handle(key, this);
|
809
|
+
Handle<Object> data(AccessCheckInfo::cast(data_obj)->data(), this);
|
810
|
+
LOG(this, ApiNamedSecurityCheck(key));
|
811
|
+
bool result = false;
|
812
|
+
{
|
813
|
+
// Leaving JavaScript.
|
814
|
+
VMState state(this, EXTERNAL);
|
815
|
+
result = callback(v8::Utils::ToLocal(receiver_handle),
|
816
|
+
v8::Utils::ToLocal(key_handle),
|
817
|
+
type,
|
818
|
+
v8::Utils::ToLocal(data));
|
819
|
+
}
|
820
|
+
return result;
|
821
|
+
}
|
822
|
+
|
823
|
+
|
824
|
+
bool Isolate::MayIndexedAccess(JSObject* receiver,
|
825
|
+
uint32_t index,
|
826
|
+
v8::AccessType type) {
|
827
|
+
ASSERT(receiver->IsAccessCheckNeeded());
|
828
|
+
// Check for compatibility between the security tokens in the
|
829
|
+
// current lexical context and the accessed object.
|
830
|
+
ASSERT(context());
|
831
|
+
|
832
|
+
MayAccessDecision decision = MayAccessPreCheck(this, receiver, type);
|
833
|
+
if (decision != UNKNOWN) return decision == YES;
|
834
|
+
|
835
|
+
// Get indexed access check callback
|
836
|
+
JSFunction* constructor = JSFunction::cast(receiver->map()->constructor());
|
837
|
+
if (!constructor->shared()->IsApiFunction()) return false;
|
838
|
+
|
839
|
+
Object* data_obj =
|
840
|
+
constructor->shared()->get_api_func_data()->access_check_info();
|
841
|
+
if (data_obj == heap_.undefined_value()) return false;
|
842
|
+
|
843
|
+
Object* fun_obj = AccessCheckInfo::cast(data_obj)->indexed_callback();
|
844
|
+
v8::IndexedSecurityCallback callback =
|
845
|
+
v8::ToCData<v8::IndexedSecurityCallback>(fun_obj);
|
846
|
+
|
847
|
+
if (!callback) return false;
|
848
|
+
|
849
|
+
HandleScope scope(this);
|
850
|
+
Handle<JSObject> receiver_handle(receiver, this);
|
851
|
+
Handle<Object> data(AccessCheckInfo::cast(data_obj)->data(), this);
|
852
|
+
LOG(this, ApiIndexedSecurityCheck(index));
|
853
|
+
bool result = false;
|
854
|
+
{
|
855
|
+
// Leaving JavaScript.
|
856
|
+
VMState state(this, EXTERNAL);
|
857
|
+
result = callback(v8::Utils::ToLocal(receiver_handle),
|
858
|
+
index,
|
859
|
+
type,
|
860
|
+
v8::Utils::ToLocal(data));
|
861
|
+
}
|
862
|
+
return result;
|
863
|
+
}
|
864
|
+
|
865
|
+
|
866
|
+
const char* const Isolate::kStackOverflowMessage =
|
867
|
+
"Uncaught RangeError: Maximum call stack size exceeded";
|
868
|
+
|
869
|
+
|
870
|
+
Failure* Isolate::StackOverflow() {
|
871
|
+
HandleScope scope;
|
872
|
+
Handle<String> key = factory()->stack_overflow_symbol();
|
873
|
+
Handle<JSObject> boilerplate =
|
874
|
+
Handle<JSObject>::cast(GetProperty(js_builtins_object(), key));
|
875
|
+
Handle<Object> exception = Copy(boilerplate);
|
876
|
+
// TODO(1240995): To avoid having to call JavaScript code to compute
|
877
|
+
// the message for stack overflow exceptions which is very likely to
|
878
|
+
// double fault with another stack overflow exception, we use a
|
879
|
+
// precomputed message.
|
880
|
+
DoThrow(*exception, NULL);
|
881
|
+
return Failure::Exception();
|
882
|
+
}
|
883
|
+
|
884
|
+
|
885
|
+
Failure* Isolate::TerminateExecution() {
|
886
|
+
DoThrow(heap_.termination_exception(), NULL);
|
887
|
+
return Failure::Exception();
|
888
|
+
}
|
889
|
+
|
890
|
+
|
891
|
+
Failure* Isolate::Throw(Object* exception, MessageLocation* location) {
|
892
|
+
DoThrow(exception, location);
|
893
|
+
return Failure::Exception();
|
894
|
+
}
|
895
|
+
|
896
|
+
|
897
|
+
Failure* Isolate::ReThrow(MaybeObject* exception, MessageLocation* location) {
|
898
|
+
bool can_be_caught_externally = false;
|
899
|
+
bool catchable_by_javascript = is_catchable_by_javascript(exception);
|
900
|
+
ShouldReportException(&can_be_caught_externally, catchable_by_javascript);
|
901
|
+
|
902
|
+
thread_local_top()->catcher_ = can_be_caught_externally ?
|
903
|
+
try_catch_handler() : NULL;
|
904
|
+
|
905
|
+
// Set the exception being re-thrown.
|
906
|
+
set_pending_exception(exception);
|
907
|
+
if (exception->IsFailure()) return exception->ToFailureUnchecked();
|
908
|
+
return Failure::Exception();
|
909
|
+
}
|
910
|
+
|
911
|
+
|
912
|
+
Failure* Isolate::ThrowIllegalOperation() {
|
913
|
+
return Throw(heap_.illegal_access_symbol());
|
914
|
+
}
|
915
|
+
|
916
|
+
|
917
|
+
void Isolate::ScheduleThrow(Object* exception) {
|
918
|
+
// When scheduling a throw we first throw the exception to get the
|
919
|
+
// error reporting if it is uncaught before rescheduling it.
|
920
|
+
Throw(exception);
|
921
|
+
thread_local_top()->scheduled_exception_ = pending_exception();
|
922
|
+
thread_local_top()->external_caught_exception_ = false;
|
923
|
+
clear_pending_exception();
|
924
|
+
}
|
925
|
+
|
926
|
+
|
927
|
+
Failure* Isolate::PromoteScheduledException() {
|
928
|
+
MaybeObject* thrown = scheduled_exception();
|
929
|
+
clear_scheduled_exception();
|
930
|
+
// Re-throw the exception to avoid getting repeated error reporting.
|
931
|
+
return ReThrow(thrown);
|
932
|
+
}
|
933
|
+
|
934
|
+
|
935
|
+
void Isolate::PrintCurrentStackTrace(FILE* out) {
|
936
|
+
StackTraceFrameIterator it(this);
|
937
|
+
while (!it.done()) {
|
938
|
+
HandleScope scope;
|
939
|
+
// Find code position if recorded in relocation info.
|
940
|
+
JavaScriptFrame* frame = it.frame();
|
941
|
+
int pos = frame->LookupCode()->SourcePosition(frame->pc());
|
942
|
+
Handle<Object> pos_obj(Smi::FromInt(pos));
|
943
|
+
// Fetch function and receiver.
|
944
|
+
Handle<JSFunction> fun(JSFunction::cast(frame->function()));
|
945
|
+
Handle<Object> recv(frame->receiver());
|
946
|
+
// Advance to the next JavaScript frame and determine if the
|
947
|
+
// current frame is the top-level frame.
|
948
|
+
it.Advance();
|
949
|
+
Handle<Object> is_top_level = it.done()
|
950
|
+
? factory()->true_value()
|
951
|
+
: factory()->false_value();
|
952
|
+
// Generate and print stack trace line.
|
953
|
+
Handle<String> line =
|
954
|
+
Execution::GetStackTraceLine(recv, fun, pos_obj, is_top_level);
|
955
|
+
if (line->length() > 0) {
|
956
|
+
line->PrintOn(out);
|
957
|
+
fprintf(out, "\n");
|
958
|
+
}
|
959
|
+
}
|
960
|
+
}
|
961
|
+
|
962
|
+
|
963
|
+
void Isolate::ComputeLocation(MessageLocation* target) {
|
964
|
+
*target = MessageLocation(Handle<Script>(heap_.empty_script()), -1, -1);
|
965
|
+
StackTraceFrameIterator it(this);
|
966
|
+
if (!it.done()) {
|
967
|
+
JavaScriptFrame* frame = it.frame();
|
968
|
+
JSFunction* fun = JSFunction::cast(frame->function());
|
969
|
+
Object* script = fun->shared()->script();
|
970
|
+
if (script->IsScript() &&
|
971
|
+
!(Script::cast(script)->source()->IsUndefined())) {
|
972
|
+
int pos = frame->LookupCode()->SourcePosition(frame->pc());
|
973
|
+
// Compute the location from the function and the reloc info.
|
974
|
+
Handle<Script> casted_script(Script::cast(script));
|
975
|
+
*target = MessageLocation(casted_script, pos, pos + 1);
|
976
|
+
}
|
977
|
+
}
|
978
|
+
}
|
979
|
+
|
980
|
+
|
981
|
+
bool Isolate::ShouldReportException(bool* can_be_caught_externally,
|
982
|
+
bool catchable_by_javascript) {
|
983
|
+
// Find the top-most try-catch handler.
|
984
|
+
StackHandler* handler =
|
985
|
+
StackHandler::FromAddress(Isolate::handler(thread_local_top()));
|
986
|
+
while (handler != NULL && !handler->is_try_catch()) {
|
987
|
+
handler = handler->next();
|
988
|
+
}
|
989
|
+
|
990
|
+
// Get the address of the external handler so we can compare the address to
|
991
|
+
// determine which one is closer to the top of the stack.
|
992
|
+
Address external_handler_address =
|
993
|
+
thread_local_top()->try_catch_handler_address();
|
994
|
+
|
995
|
+
// The exception has been externally caught if and only if there is
|
996
|
+
// an external handler which is on top of the top-most try-catch
|
997
|
+
// handler.
|
998
|
+
*can_be_caught_externally = external_handler_address != NULL &&
|
999
|
+
(handler == NULL || handler->address() > external_handler_address ||
|
1000
|
+
!catchable_by_javascript);
|
1001
|
+
|
1002
|
+
if (*can_be_caught_externally) {
|
1003
|
+
// Only report the exception if the external handler is verbose.
|
1004
|
+
return try_catch_handler()->is_verbose_;
|
1005
|
+
} else {
|
1006
|
+
// Report the exception if it isn't caught by JavaScript code.
|
1007
|
+
return handler == NULL;
|
1008
|
+
}
|
1009
|
+
}
|
1010
|
+
|
1011
|
+
|
1012
|
+
void Isolate::DoThrow(MaybeObject* exception, MessageLocation* location) {
|
1013
|
+
ASSERT(!has_pending_exception());
|
1014
|
+
|
1015
|
+
HandleScope scope;
|
1016
|
+
Object* exception_object = Smi::FromInt(0);
|
1017
|
+
bool is_object = exception->ToObject(&exception_object);
|
1018
|
+
Handle<Object> exception_handle(exception_object);
|
1019
|
+
|
1020
|
+
// Determine reporting and whether the exception is caught externally.
|
1021
|
+
bool catchable_by_javascript = is_catchable_by_javascript(exception);
|
1022
|
+
// Only real objects can be caught by JS.
|
1023
|
+
ASSERT(!catchable_by_javascript || is_object);
|
1024
|
+
bool can_be_caught_externally = false;
|
1025
|
+
bool should_report_exception =
|
1026
|
+
ShouldReportException(&can_be_caught_externally, catchable_by_javascript);
|
1027
|
+
bool report_exception = catchable_by_javascript && should_report_exception;
|
1028
|
+
|
1029
|
+
#ifdef ENABLE_DEBUGGER_SUPPORT
|
1030
|
+
// Notify debugger of exception.
|
1031
|
+
if (catchable_by_javascript) {
|
1032
|
+
debugger_->OnException(exception_handle, report_exception);
|
1033
|
+
}
|
1034
|
+
#endif
|
1035
|
+
|
1036
|
+
// Generate the message.
|
1037
|
+
Handle<Object> message_obj;
|
1038
|
+
MessageLocation potential_computed_location;
|
1039
|
+
bool try_catch_needs_message =
|
1040
|
+
can_be_caught_externally &&
|
1041
|
+
try_catch_handler()->capture_message_;
|
1042
|
+
if (report_exception || try_catch_needs_message) {
|
1043
|
+
if (location == NULL) {
|
1044
|
+
// If no location was specified we use a computed one instead
|
1045
|
+
ComputeLocation(&potential_computed_location);
|
1046
|
+
location = &potential_computed_location;
|
1047
|
+
}
|
1048
|
+
if (!bootstrapper()->IsActive()) {
|
1049
|
+
// It's not safe to try to make message objects or collect stack
|
1050
|
+
// traces while the bootstrapper is active since the infrastructure
|
1051
|
+
// may not have been properly initialized.
|
1052
|
+
Handle<String> stack_trace;
|
1053
|
+
if (FLAG_trace_exception) stack_trace = StackTraceString();
|
1054
|
+
Handle<JSArray> stack_trace_object;
|
1055
|
+
if (report_exception && capture_stack_trace_for_uncaught_exceptions_) {
|
1056
|
+
stack_trace_object = CaptureCurrentStackTrace(
|
1057
|
+
stack_trace_for_uncaught_exceptions_frame_limit_,
|
1058
|
+
stack_trace_for_uncaught_exceptions_options_);
|
1059
|
+
}
|
1060
|
+
ASSERT(is_object); // Can't use the handle unless there's a real object.
|
1061
|
+
message_obj = MessageHandler::MakeMessageObject("uncaught_exception",
|
1062
|
+
location, HandleVector<Object>(&exception_handle, 1), stack_trace,
|
1063
|
+
stack_trace_object);
|
1064
|
+
}
|
1065
|
+
}
|
1066
|
+
|
1067
|
+
// Save the message for reporting if the the exception remains uncaught.
|
1068
|
+
thread_local_top()->has_pending_message_ = report_exception;
|
1069
|
+
if (!message_obj.is_null()) {
|
1070
|
+
thread_local_top()->pending_message_obj_ = *message_obj;
|
1071
|
+
if (location != NULL) {
|
1072
|
+
thread_local_top()->pending_message_script_ = *location->script();
|
1073
|
+
thread_local_top()->pending_message_start_pos_ = location->start_pos();
|
1074
|
+
thread_local_top()->pending_message_end_pos_ = location->end_pos();
|
1075
|
+
}
|
1076
|
+
}
|
1077
|
+
|
1078
|
+
// Do not forget to clean catcher_ if currently thrown exception cannot
|
1079
|
+
// be caught. If necessary, ReThrow will update the catcher.
|
1080
|
+
thread_local_top()->catcher_ = can_be_caught_externally ?
|
1081
|
+
try_catch_handler() : NULL;
|
1082
|
+
|
1083
|
+
// NOTE: Notifying the debugger or generating the message
|
1084
|
+
// may have caused new exceptions. For now, we just ignore
|
1085
|
+
// that and set the pending exception to the original one.
|
1086
|
+
if (is_object) {
|
1087
|
+
set_pending_exception(*exception_handle);
|
1088
|
+
} else {
|
1089
|
+
// Failures are not on the heap so they neither need nor work with handles.
|
1090
|
+
ASSERT(exception_handle->IsFailure());
|
1091
|
+
set_pending_exception(exception);
|
1092
|
+
}
|
1093
|
+
}
|
1094
|
+
|
1095
|
+
|
1096
|
+
bool Isolate::IsExternallyCaught() {
|
1097
|
+
ASSERT(has_pending_exception());
|
1098
|
+
|
1099
|
+
if ((thread_local_top()->catcher_ == NULL) ||
|
1100
|
+
(try_catch_handler() != thread_local_top()->catcher_)) {
|
1101
|
+
// When throwing the exception, we found no v8::TryCatch
|
1102
|
+
// which should care about this exception.
|
1103
|
+
return false;
|
1104
|
+
}
|
1105
|
+
|
1106
|
+
if (!is_catchable_by_javascript(pending_exception())) {
|
1107
|
+
return true;
|
1108
|
+
}
|
1109
|
+
|
1110
|
+
// Get the address of the external handler so we can compare the address to
|
1111
|
+
// determine which one is closer to the top of the stack.
|
1112
|
+
Address external_handler_address =
|
1113
|
+
thread_local_top()->try_catch_handler_address();
|
1114
|
+
ASSERT(external_handler_address != NULL);
|
1115
|
+
|
1116
|
+
// The exception has been externally caught if and only if there is
|
1117
|
+
// an external handler which is on top of the top-most try-finally
|
1118
|
+
// handler.
|
1119
|
+
// There should be no try-catch blocks as they would prohibit us from
|
1120
|
+
// finding external catcher in the first place (see catcher_ check above).
|
1121
|
+
//
|
1122
|
+
// Note, that finally clause would rethrow an exception unless it's
|
1123
|
+
// aborted by jumps in control flow like return, break, etc. and we'll
|
1124
|
+
// have another chances to set proper v8::TryCatch.
|
1125
|
+
StackHandler* handler =
|
1126
|
+
StackHandler::FromAddress(Isolate::handler(thread_local_top()));
|
1127
|
+
while (handler != NULL && handler->address() < external_handler_address) {
|
1128
|
+
ASSERT(!handler->is_try_catch());
|
1129
|
+
if (handler->is_try_finally()) return false;
|
1130
|
+
|
1131
|
+
handler = handler->next();
|
1132
|
+
}
|
1133
|
+
|
1134
|
+
return true;
|
1135
|
+
}
|
1136
|
+
|
1137
|
+
|
1138
|
+
void Isolate::ReportPendingMessages() {
|
1139
|
+
ASSERT(has_pending_exception());
|
1140
|
+
PropagatePendingExceptionToExternalTryCatch();
|
1141
|
+
|
1142
|
+
// If the pending exception is OutOfMemoryException set out_of_memory in
|
1143
|
+
// the global context. Note: We have to mark the global context here
|
1144
|
+
// since the GenerateThrowOutOfMemory stub cannot make a RuntimeCall to
|
1145
|
+
// set it.
|
1146
|
+
HandleScope scope;
|
1147
|
+
if (thread_local_top_.pending_exception_ == Failure::OutOfMemoryException()) {
|
1148
|
+
context()->mark_out_of_memory();
|
1149
|
+
} else if (thread_local_top_.pending_exception_ ==
|
1150
|
+
heap()->termination_exception()) {
|
1151
|
+
// Do nothing: if needed, the exception has been already propagated to
|
1152
|
+
// v8::TryCatch.
|
1153
|
+
} else {
|
1154
|
+
if (thread_local_top_.has_pending_message_) {
|
1155
|
+
thread_local_top_.has_pending_message_ = false;
|
1156
|
+
if (!thread_local_top_.pending_message_obj_->IsTheHole()) {
|
1157
|
+
HandleScope scope;
|
1158
|
+
Handle<Object> message_obj(thread_local_top_.pending_message_obj_);
|
1159
|
+
if (thread_local_top_.pending_message_script_ != NULL) {
|
1160
|
+
Handle<Script> script(thread_local_top_.pending_message_script_);
|
1161
|
+
int start_pos = thread_local_top_.pending_message_start_pos_;
|
1162
|
+
int end_pos = thread_local_top_.pending_message_end_pos_;
|
1163
|
+
MessageLocation location(script, start_pos, end_pos);
|
1164
|
+
MessageHandler::ReportMessage(this, &location, message_obj);
|
1165
|
+
} else {
|
1166
|
+
MessageHandler::ReportMessage(this, NULL, message_obj);
|
1167
|
+
}
|
1168
|
+
}
|
1169
|
+
}
|
1170
|
+
}
|
1171
|
+
clear_pending_message();
|
1172
|
+
}
|
1173
|
+
|
1174
|
+
|
1175
|
+
void Isolate::TraceException(bool flag) {
|
1176
|
+
FLAG_trace_exception = flag; // TODO(isolates): This is an unfortunate use.
|
1177
|
+
}
|
1178
|
+
|
1179
|
+
|
1180
|
+
bool Isolate::OptionalRescheduleException(bool is_bottom_call) {
|
1181
|
+
ASSERT(has_pending_exception());
|
1182
|
+
PropagatePendingExceptionToExternalTryCatch();
|
1183
|
+
|
1184
|
+
// Allways reschedule out of memory exceptions.
|
1185
|
+
if (!is_out_of_memory()) {
|
1186
|
+
bool is_termination_exception =
|
1187
|
+
pending_exception() == heap_.termination_exception();
|
1188
|
+
|
1189
|
+
// Do not reschedule the exception if this is the bottom call.
|
1190
|
+
bool clear_exception = is_bottom_call;
|
1191
|
+
|
1192
|
+
if (is_termination_exception) {
|
1193
|
+
if (is_bottom_call) {
|
1194
|
+
thread_local_top()->external_caught_exception_ = false;
|
1195
|
+
clear_pending_exception();
|
1196
|
+
return false;
|
1197
|
+
}
|
1198
|
+
} else if (thread_local_top()->external_caught_exception_) {
|
1199
|
+
// If the exception is externally caught, clear it if there are no
|
1200
|
+
// JavaScript frames on the way to the C++ frame that has the
|
1201
|
+
// external handler.
|
1202
|
+
ASSERT(thread_local_top()->try_catch_handler_address() != NULL);
|
1203
|
+
Address external_handler_address =
|
1204
|
+
thread_local_top()->try_catch_handler_address();
|
1205
|
+
JavaScriptFrameIterator it;
|
1206
|
+
if (it.done() || (it.frame()->sp() > external_handler_address)) {
|
1207
|
+
clear_exception = true;
|
1208
|
+
}
|
1209
|
+
}
|
1210
|
+
|
1211
|
+
// Clear the exception if needed.
|
1212
|
+
if (clear_exception) {
|
1213
|
+
thread_local_top()->external_caught_exception_ = false;
|
1214
|
+
clear_pending_exception();
|
1215
|
+
return false;
|
1216
|
+
}
|
1217
|
+
}
|
1218
|
+
|
1219
|
+
// Reschedule the exception.
|
1220
|
+
thread_local_top()->scheduled_exception_ = pending_exception();
|
1221
|
+
clear_pending_exception();
|
1222
|
+
return true;
|
1223
|
+
}
|
1224
|
+
|
1225
|
+
|
1226
|
+
void Isolate::SetCaptureStackTraceForUncaughtExceptions(
|
1227
|
+
bool capture,
|
1228
|
+
int frame_limit,
|
1229
|
+
StackTrace::StackTraceOptions options) {
|
1230
|
+
capture_stack_trace_for_uncaught_exceptions_ = capture;
|
1231
|
+
stack_trace_for_uncaught_exceptions_frame_limit_ = frame_limit;
|
1232
|
+
stack_trace_for_uncaught_exceptions_options_ = options;
|
1233
|
+
}
|
1234
|
+
|
1235
|
+
|
1236
|
+
bool Isolate::is_out_of_memory() {
|
1237
|
+
if (has_pending_exception()) {
|
1238
|
+
MaybeObject* e = pending_exception();
|
1239
|
+
if (e->IsFailure() && Failure::cast(e)->IsOutOfMemoryException()) {
|
1240
|
+
return true;
|
1241
|
+
}
|
1242
|
+
}
|
1243
|
+
if (has_scheduled_exception()) {
|
1244
|
+
MaybeObject* e = scheduled_exception();
|
1245
|
+
if (e->IsFailure() && Failure::cast(e)->IsOutOfMemoryException()) {
|
1246
|
+
return true;
|
1247
|
+
}
|
1248
|
+
}
|
1249
|
+
return false;
|
1250
|
+
}
|
1251
|
+
|
1252
|
+
|
1253
|
+
Handle<Context> Isolate::global_context() {
|
1254
|
+
GlobalObject* global = thread_local_top()->context_->global();
|
1255
|
+
return Handle<Context>(global->global_context());
|
1256
|
+
}
|
1257
|
+
|
1258
|
+
|
1259
|
+
Handle<Context> Isolate::GetCallingGlobalContext() {
|
1260
|
+
JavaScriptFrameIterator it;
|
1261
|
+
#ifdef ENABLE_DEBUGGER_SUPPORT
|
1262
|
+
if (debug_->InDebugger()) {
|
1263
|
+
while (!it.done()) {
|
1264
|
+
JavaScriptFrame* frame = it.frame();
|
1265
|
+
Context* context = Context::cast(frame->context());
|
1266
|
+
if (context->global_context() == *debug_->debug_context()) {
|
1267
|
+
it.Advance();
|
1268
|
+
} else {
|
1269
|
+
break;
|
1270
|
+
}
|
1271
|
+
}
|
1272
|
+
}
|
1273
|
+
#endif // ENABLE_DEBUGGER_SUPPORT
|
1274
|
+
if (it.done()) return Handle<Context>::null();
|
1275
|
+
JavaScriptFrame* frame = it.frame();
|
1276
|
+
Context* context = Context::cast(frame->context());
|
1277
|
+
return Handle<Context>(context->global_context());
|
1278
|
+
}
|
1279
|
+
|
1280
|
+
|
1281
|
+
char* Isolate::ArchiveThread(char* to) {
|
1282
|
+
if (RuntimeProfiler::IsEnabled() && current_vm_state() == JS) {
|
1283
|
+
RuntimeProfiler::IsolateExitedJS(this);
|
1284
|
+
}
|
1285
|
+
memcpy(to, reinterpret_cast<char*>(thread_local_top()),
|
1286
|
+
sizeof(ThreadLocalTop));
|
1287
|
+
InitializeThreadLocal();
|
1288
|
+
return to + sizeof(ThreadLocalTop);
|
1289
|
+
}
|
1290
|
+
|
1291
|
+
|
1292
|
+
char* Isolate::RestoreThread(char* from) {
|
1293
|
+
memcpy(reinterpret_cast<char*>(thread_local_top()), from,
|
1294
|
+
sizeof(ThreadLocalTop));
|
1295
|
+
// This might be just paranoia, but it seems to be needed in case a
|
1296
|
+
// thread_local_top_ is restored on a separate OS thread.
|
1297
|
+
#ifdef USE_SIMULATOR
|
1298
|
+
#ifdef V8_TARGET_ARCH_ARM
|
1299
|
+
thread_local_top()->simulator_ = Simulator::current(this);
|
1300
|
+
#elif V8_TARGET_ARCH_MIPS
|
1301
|
+
thread_local_top()->simulator_ = Simulator::current(this);
|
1302
|
+
#endif
|
1303
|
+
#endif
|
1304
|
+
if (RuntimeProfiler::IsEnabled() && current_vm_state() == JS) {
|
1305
|
+
RuntimeProfiler::IsolateEnteredJS(this);
|
1306
|
+
}
|
1307
|
+
return from + sizeof(ThreadLocalTop);
|
1308
|
+
}
|
1309
|
+
|
1310
|
+
|
1311
|
+
Isolate::ThreadDataTable::ThreadDataTable()
|
1312
|
+
: list_(NULL) {
|
1313
|
+
}
|
1314
|
+
|
1315
|
+
|
1316
|
+
Isolate::PerIsolateThreadData*
|
1317
|
+
Isolate::ThreadDataTable::Lookup(Isolate* isolate,
|
1318
|
+
ThreadId thread_id) {
|
1319
|
+
for (PerIsolateThreadData* data = list_; data != NULL; data = data->next_) {
|
1320
|
+
if (data->Matches(isolate, thread_id)) return data;
|
1321
|
+
}
|
1322
|
+
return NULL;
|
1323
|
+
}
|
1324
|
+
|
1325
|
+
|
1326
|
+
void Isolate::ThreadDataTable::Insert(Isolate::PerIsolateThreadData* data) {
|
1327
|
+
if (list_ != NULL) list_->prev_ = data;
|
1328
|
+
data->next_ = list_;
|
1329
|
+
list_ = data;
|
1330
|
+
}
|
1331
|
+
|
1332
|
+
|
1333
|
+
void Isolate::ThreadDataTable::Remove(PerIsolateThreadData* data) {
|
1334
|
+
if (list_ == data) list_ = data->next_;
|
1335
|
+
if (data->next_ != NULL) data->next_->prev_ = data->prev_;
|
1336
|
+
if (data->prev_ != NULL) data->prev_->next_ = data->next_;
|
1337
|
+
}
|
1338
|
+
|
1339
|
+
|
1340
|
+
void Isolate::ThreadDataTable::Remove(Isolate* isolate,
|
1341
|
+
ThreadId thread_id) {
|
1342
|
+
PerIsolateThreadData* data = Lookup(isolate, thread_id);
|
1343
|
+
if (data != NULL) {
|
1344
|
+
Remove(data);
|
1345
|
+
}
|
1346
|
+
}
|
1347
|
+
|
1348
|
+
|
1349
|
+
#ifdef DEBUG
|
1350
|
+
#define TRACE_ISOLATE(tag) \
|
1351
|
+
do { \
|
1352
|
+
if (FLAG_trace_isolates) { \
|
1353
|
+
PrintF("Isolate %p " #tag "\n", reinterpret_cast<void*>(this)); \
|
1354
|
+
} \
|
1355
|
+
} while (false)
|
1356
|
+
#else
|
1357
|
+
#define TRACE_ISOLATE(tag)
|
1358
|
+
#endif
|
1359
|
+
|
1360
|
+
|
1361
|
+
Isolate::Isolate()
|
1362
|
+
: state_(UNINITIALIZED),
|
1363
|
+
entry_stack_(NULL),
|
1364
|
+
stack_trace_nesting_level_(0),
|
1365
|
+
incomplete_message_(NULL),
|
1366
|
+
preallocated_memory_thread_(NULL),
|
1367
|
+
preallocated_message_space_(NULL),
|
1368
|
+
bootstrapper_(NULL),
|
1369
|
+
runtime_profiler_(NULL),
|
1370
|
+
compilation_cache_(NULL),
|
1371
|
+
counters_(new Counters()),
|
1372
|
+
code_range_(NULL),
|
1373
|
+
break_access_(OS::CreateMutex()),
|
1374
|
+
logger_(new Logger()),
|
1375
|
+
stats_table_(new StatsTable()),
|
1376
|
+
stub_cache_(NULL),
|
1377
|
+
deoptimizer_data_(NULL),
|
1378
|
+
capture_stack_trace_for_uncaught_exceptions_(false),
|
1379
|
+
stack_trace_for_uncaught_exceptions_frame_limit_(0),
|
1380
|
+
stack_trace_for_uncaught_exceptions_options_(StackTrace::kOverview),
|
1381
|
+
transcendental_cache_(NULL),
|
1382
|
+
memory_allocator_(NULL),
|
1383
|
+
keyed_lookup_cache_(NULL),
|
1384
|
+
context_slot_cache_(NULL),
|
1385
|
+
descriptor_lookup_cache_(NULL),
|
1386
|
+
handle_scope_implementer_(NULL),
|
1387
|
+
unicode_cache_(NULL),
|
1388
|
+
in_use_list_(0),
|
1389
|
+
free_list_(0),
|
1390
|
+
preallocated_storage_preallocated_(false),
|
1391
|
+
pc_to_code_cache_(NULL),
|
1392
|
+
write_input_buffer_(NULL),
|
1393
|
+
global_handles_(NULL),
|
1394
|
+
context_switcher_(NULL),
|
1395
|
+
thread_manager_(NULL),
|
1396
|
+
ast_sentinels_(NULL),
|
1397
|
+
string_tracker_(NULL),
|
1398
|
+
regexp_stack_(NULL),
|
1399
|
+
frame_element_constant_list_(0),
|
1400
|
+
result_constant_list_(0),
|
1401
|
+
embedder_data_(NULL) {
|
1402
|
+
TRACE_ISOLATE(constructor);
|
1403
|
+
|
1404
|
+
memset(isolate_addresses_, 0,
|
1405
|
+
sizeof(isolate_addresses_[0]) * (k_isolate_address_count + 1));
|
1406
|
+
|
1407
|
+
heap_.isolate_ = this;
|
1408
|
+
zone_.isolate_ = this;
|
1409
|
+
stack_guard_.isolate_ = this;
|
1410
|
+
|
1411
|
+
// ThreadManager is initialized early to support locking an isolate
|
1412
|
+
// before it is entered.
|
1413
|
+
thread_manager_ = new ThreadManager();
|
1414
|
+
thread_manager_->isolate_ = this;
|
1415
|
+
|
1416
|
+
#if defined(V8_TARGET_ARCH_ARM) && !defined(__arm__) || \
|
1417
|
+
defined(V8_TARGET_ARCH_MIPS) && !defined(__mips__)
|
1418
|
+
simulator_initialized_ = false;
|
1419
|
+
simulator_i_cache_ = NULL;
|
1420
|
+
simulator_redirection_ = NULL;
|
1421
|
+
#endif
|
1422
|
+
|
1423
|
+
#ifdef DEBUG
|
1424
|
+
// heap_histograms_ initializes itself.
|
1425
|
+
memset(&js_spill_information_, 0, sizeof(js_spill_information_));
|
1426
|
+
memset(code_kind_statistics_, 0,
|
1427
|
+
sizeof(code_kind_statistics_[0]) * Code::NUMBER_OF_KINDS);
|
1428
|
+
#endif
|
1429
|
+
|
1430
|
+
#ifdef ENABLE_DEBUGGER_SUPPORT
|
1431
|
+
debug_ = NULL;
|
1432
|
+
debugger_ = NULL;
|
1433
|
+
#endif
|
1434
|
+
|
1435
|
+
#ifdef ENABLE_LOGGING_AND_PROFILING
|
1436
|
+
producer_heap_profile_ = NULL;
|
1437
|
+
#endif
|
1438
|
+
|
1439
|
+
handle_scope_data_.Initialize();
|
1440
|
+
|
1441
|
+
#define ISOLATE_INIT_EXECUTE(type, name, initial_value) \
|
1442
|
+
name##_ = (initial_value);
|
1443
|
+
ISOLATE_INIT_LIST(ISOLATE_INIT_EXECUTE)
|
1444
|
+
#undef ISOLATE_INIT_EXECUTE
|
1445
|
+
|
1446
|
+
#define ISOLATE_INIT_ARRAY_EXECUTE(type, name, length) \
|
1447
|
+
memset(name##_, 0, sizeof(type) * length);
|
1448
|
+
ISOLATE_INIT_ARRAY_LIST(ISOLATE_INIT_ARRAY_EXECUTE)
|
1449
|
+
#undef ISOLATE_INIT_ARRAY_EXECUTE
|
1450
|
+
}
|
1451
|
+
|
1452
|
+
void Isolate::TearDown() {
|
1453
|
+
TRACE_ISOLATE(tear_down);
|
1454
|
+
|
1455
|
+
// Temporarily set this isolate as current so that various parts of
|
1456
|
+
// the isolate can access it in their destructors without having a
|
1457
|
+
// direct pointer. We don't use Enter/Exit here to avoid
|
1458
|
+
// initializing the thread data.
|
1459
|
+
PerIsolateThreadData* saved_data = CurrentPerIsolateThreadData();
|
1460
|
+
Isolate* saved_isolate = UncheckedCurrent();
|
1461
|
+
SetIsolateThreadLocals(this, NULL);
|
1462
|
+
|
1463
|
+
Deinit();
|
1464
|
+
|
1465
|
+
if (!IsDefaultIsolate()) {
|
1466
|
+
delete this;
|
1467
|
+
}
|
1468
|
+
|
1469
|
+
// Restore the previous current isolate.
|
1470
|
+
SetIsolateThreadLocals(saved_isolate, saved_data);
|
1471
|
+
}
|
1472
|
+
|
1473
|
+
|
1474
|
+
void Isolate::Deinit() {
|
1475
|
+
if (state_ == INITIALIZED) {
|
1476
|
+
TRACE_ISOLATE(deinit);
|
1477
|
+
|
1478
|
+
if (FLAG_hydrogen_stats) HStatistics::Instance()->Print();
|
1479
|
+
|
1480
|
+
// We must stop the logger before we tear down other components.
|
1481
|
+
logger_->EnsureTickerStopped();
|
1482
|
+
|
1483
|
+
delete deoptimizer_data_;
|
1484
|
+
deoptimizer_data_ = NULL;
|
1485
|
+
if (FLAG_preemption) {
|
1486
|
+
v8::Locker locker;
|
1487
|
+
v8::Locker::StopPreemption();
|
1488
|
+
}
|
1489
|
+
builtins_.TearDown();
|
1490
|
+
bootstrapper_->TearDown();
|
1491
|
+
|
1492
|
+
// Remove the external reference to the preallocated stack memory.
|
1493
|
+
delete preallocated_message_space_;
|
1494
|
+
preallocated_message_space_ = NULL;
|
1495
|
+
PreallocatedMemoryThreadStop();
|
1496
|
+
|
1497
|
+
HeapProfiler::TearDown();
|
1498
|
+
CpuProfiler::TearDown();
|
1499
|
+
if (runtime_profiler_ != NULL) {
|
1500
|
+
runtime_profiler_->TearDown();
|
1501
|
+
delete runtime_profiler_;
|
1502
|
+
runtime_profiler_ = NULL;
|
1503
|
+
}
|
1504
|
+
heap_.TearDown();
|
1505
|
+
logger_->TearDown();
|
1506
|
+
|
1507
|
+
// The default isolate is re-initializable due to legacy API.
|
1508
|
+
state_ = PREINITIALIZED;
|
1509
|
+
}
|
1510
|
+
}
|
1511
|
+
|
1512
|
+
|
1513
|
+
void Isolate::SetIsolateThreadLocals(Isolate* isolate,
|
1514
|
+
PerIsolateThreadData* data) {
|
1515
|
+
Thread::SetThreadLocal(isolate_key_, isolate);
|
1516
|
+
Thread::SetThreadLocal(per_isolate_thread_data_key_, data);
|
1517
|
+
}
|
1518
|
+
|
1519
|
+
|
1520
|
+
Isolate::~Isolate() {
|
1521
|
+
TRACE_ISOLATE(destructor);
|
1522
|
+
|
1523
|
+
#ifdef ENABLE_LOGGING_AND_PROFILING
|
1524
|
+
delete producer_heap_profile_;
|
1525
|
+
producer_heap_profile_ = NULL;
|
1526
|
+
#endif
|
1527
|
+
|
1528
|
+
delete unicode_cache_;
|
1529
|
+
unicode_cache_ = NULL;
|
1530
|
+
|
1531
|
+
delete regexp_stack_;
|
1532
|
+
regexp_stack_ = NULL;
|
1533
|
+
|
1534
|
+
delete ast_sentinels_;
|
1535
|
+
ast_sentinels_ = NULL;
|
1536
|
+
|
1537
|
+
delete descriptor_lookup_cache_;
|
1538
|
+
descriptor_lookup_cache_ = NULL;
|
1539
|
+
delete context_slot_cache_;
|
1540
|
+
context_slot_cache_ = NULL;
|
1541
|
+
delete keyed_lookup_cache_;
|
1542
|
+
keyed_lookup_cache_ = NULL;
|
1543
|
+
|
1544
|
+
delete transcendental_cache_;
|
1545
|
+
transcendental_cache_ = NULL;
|
1546
|
+
delete stub_cache_;
|
1547
|
+
stub_cache_ = NULL;
|
1548
|
+
delete stats_table_;
|
1549
|
+
stats_table_ = NULL;
|
1550
|
+
|
1551
|
+
delete logger_;
|
1552
|
+
logger_ = NULL;
|
1553
|
+
|
1554
|
+
delete counters_;
|
1555
|
+
counters_ = NULL;
|
1556
|
+
|
1557
|
+
delete handle_scope_implementer_;
|
1558
|
+
handle_scope_implementer_ = NULL;
|
1559
|
+
delete break_access_;
|
1560
|
+
break_access_ = NULL;
|
1561
|
+
|
1562
|
+
delete compilation_cache_;
|
1563
|
+
compilation_cache_ = NULL;
|
1564
|
+
delete bootstrapper_;
|
1565
|
+
bootstrapper_ = NULL;
|
1566
|
+
delete pc_to_code_cache_;
|
1567
|
+
pc_to_code_cache_ = NULL;
|
1568
|
+
delete write_input_buffer_;
|
1569
|
+
write_input_buffer_ = NULL;
|
1570
|
+
|
1571
|
+
delete context_switcher_;
|
1572
|
+
context_switcher_ = NULL;
|
1573
|
+
delete thread_manager_;
|
1574
|
+
thread_manager_ = NULL;
|
1575
|
+
|
1576
|
+
delete string_tracker_;
|
1577
|
+
string_tracker_ = NULL;
|
1578
|
+
|
1579
|
+
delete memory_allocator_;
|
1580
|
+
memory_allocator_ = NULL;
|
1581
|
+
delete code_range_;
|
1582
|
+
code_range_ = NULL;
|
1583
|
+
delete global_handles_;
|
1584
|
+
global_handles_ = NULL;
|
1585
|
+
|
1586
|
+
#ifdef ENABLE_DEBUGGER_SUPPORT
|
1587
|
+
delete debugger_;
|
1588
|
+
debugger_ = NULL;
|
1589
|
+
delete debug_;
|
1590
|
+
debug_ = NULL;
|
1591
|
+
#endif
|
1592
|
+
}
|
1593
|
+
|
1594
|
+
|
1595
|
+
bool Isolate::PreInit() {
|
1596
|
+
if (state_ != UNINITIALIZED) return true;
|
1597
|
+
|
1598
|
+
TRACE_ISOLATE(preinit);
|
1599
|
+
|
1600
|
+
ASSERT(Isolate::Current() == this);
|
1601
|
+
#ifdef ENABLE_DEBUGGER_SUPPORT
|
1602
|
+
debug_ = new Debug(this);
|
1603
|
+
debugger_ = new Debugger();
|
1604
|
+
debugger_->isolate_ = this;
|
1605
|
+
#endif
|
1606
|
+
|
1607
|
+
memory_allocator_ = new MemoryAllocator();
|
1608
|
+
memory_allocator_->isolate_ = this;
|
1609
|
+
code_range_ = new CodeRange();
|
1610
|
+
code_range_->isolate_ = this;
|
1611
|
+
|
1612
|
+
// Safe after setting Heap::isolate_, initializing StackGuard and
|
1613
|
+
// ensuring that Isolate::Current() == this.
|
1614
|
+
heap_.SetStackLimits();
|
1615
|
+
|
1616
|
+
#ifdef DEBUG
|
1617
|
+
DisallowAllocationFailure disallow_allocation_failure;
|
1618
|
+
#endif
|
1619
|
+
|
1620
|
+
#define C(name) isolate_addresses_[Isolate::k_##name] = \
|
1621
|
+
reinterpret_cast<Address>(name());
|
1622
|
+
ISOLATE_ADDRESS_LIST(C)
|
1623
|
+
ISOLATE_ADDRESS_LIST_PROF(C)
|
1624
|
+
#undef C
|
1625
|
+
|
1626
|
+
string_tracker_ = new StringTracker();
|
1627
|
+
string_tracker_->isolate_ = this;
|
1628
|
+
compilation_cache_ = new CompilationCache(this);
|
1629
|
+
transcendental_cache_ = new TranscendentalCache();
|
1630
|
+
keyed_lookup_cache_ = new KeyedLookupCache();
|
1631
|
+
context_slot_cache_ = new ContextSlotCache();
|
1632
|
+
descriptor_lookup_cache_ = new DescriptorLookupCache();
|
1633
|
+
unicode_cache_ = new UnicodeCache();
|
1634
|
+
pc_to_code_cache_ = new PcToCodeCache(this);
|
1635
|
+
write_input_buffer_ = new StringInputBuffer();
|
1636
|
+
global_handles_ = new GlobalHandles(this);
|
1637
|
+
bootstrapper_ = new Bootstrapper();
|
1638
|
+
handle_scope_implementer_ = new HandleScopeImplementer(this);
|
1639
|
+
stub_cache_ = new StubCache(this);
|
1640
|
+
ast_sentinels_ = new AstSentinels();
|
1641
|
+
regexp_stack_ = new RegExpStack();
|
1642
|
+
regexp_stack_->isolate_ = this;
|
1643
|
+
|
1644
|
+
#ifdef ENABLE_LOGGING_AND_PROFILING
|
1645
|
+
producer_heap_profile_ = new ProducerHeapProfile();
|
1646
|
+
producer_heap_profile_->isolate_ = this;
|
1647
|
+
#endif
|
1648
|
+
|
1649
|
+
state_ = PREINITIALIZED;
|
1650
|
+
return true;
|
1651
|
+
}
|
1652
|
+
|
1653
|
+
|
1654
|
+
void Isolate::InitializeThreadLocal() {
|
1655
|
+
thread_local_top_.isolate_ = this;
|
1656
|
+
thread_local_top_.Initialize();
|
1657
|
+
clear_pending_exception();
|
1658
|
+
clear_pending_message();
|
1659
|
+
clear_scheduled_exception();
|
1660
|
+
}
|
1661
|
+
|
1662
|
+
|
1663
|
+
void Isolate::PropagatePendingExceptionToExternalTryCatch() {
|
1664
|
+
ASSERT(has_pending_exception());
|
1665
|
+
|
1666
|
+
bool external_caught = IsExternallyCaught();
|
1667
|
+
thread_local_top_.external_caught_exception_ = external_caught;
|
1668
|
+
|
1669
|
+
if (!external_caught) return;
|
1670
|
+
|
1671
|
+
if (thread_local_top_.pending_exception_ == Failure::OutOfMemoryException()) {
|
1672
|
+
// Do not propagate OOM exception: we should kill VM asap.
|
1673
|
+
} else if (thread_local_top_.pending_exception_ ==
|
1674
|
+
heap()->termination_exception()) {
|
1675
|
+
try_catch_handler()->can_continue_ = false;
|
1676
|
+
try_catch_handler()->exception_ = heap()->null_value();
|
1677
|
+
} else {
|
1678
|
+
// At this point all non-object (failure) exceptions have
|
1679
|
+
// been dealt with so this shouldn't fail.
|
1680
|
+
ASSERT(!pending_exception()->IsFailure());
|
1681
|
+
try_catch_handler()->can_continue_ = true;
|
1682
|
+
try_catch_handler()->exception_ = pending_exception();
|
1683
|
+
if (!thread_local_top_.pending_message_obj_->IsTheHole()) {
|
1684
|
+
try_catch_handler()->message_ = thread_local_top_.pending_message_obj_;
|
1685
|
+
}
|
1686
|
+
}
|
1687
|
+
}
|
1688
|
+
|
1689
|
+
|
1690
|
+
bool Isolate::Init(Deserializer* des) {
|
1691
|
+
ASSERT(state_ != INITIALIZED);
|
1692
|
+
|
1693
|
+
TRACE_ISOLATE(init);
|
1694
|
+
|
1695
|
+
bool create_heap_objects = des == NULL;
|
1696
|
+
|
1697
|
+
#ifdef DEBUG
|
1698
|
+
// The initialization process does not handle memory exhaustion.
|
1699
|
+
DisallowAllocationFailure disallow_allocation_failure;
|
1700
|
+
#endif
|
1701
|
+
|
1702
|
+
if (state_ == UNINITIALIZED && !PreInit()) return false;
|
1703
|
+
|
1704
|
+
// Enable logging before setting up the heap
|
1705
|
+
logger_->Setup();
|
1706
|
+
|
1707
|
+
CpuProfiler::Setup();
|
1708
|
+
HeapProfiler::Setup();
|
1709
|
+
|
1710
|
+
// Initialize other runtime facilities
|
1711
|
+
#if defined(USE_SIMULATOR)
|
1712
|
+
#if defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_MIPS)
|
1713
|
+
Simulator::Initialize(this);
|
1714
|
+
#endif
|
1715
|
+
#endif
|
1716
|
+
|
1717
|
+
{ // NOLINT
|
1718
|
+
// Ensure that the thread has a valid stack guard. The v8::Locker object
|
1719
|
+
// will ensure this too, but we don't have to use lockers if we are only
|
1720
|
+
// using one thread.
|
1721
|
+
ExecutionAccess lock(this);
|
1722
|
+
stack_guard_.InitThread(lock);
|
1723
|
+
}
|
1724
|
+
|
1725
|
+
// Setup the object heap
|
1726
|
+
ASSERT(!heap_.HasBeenSetup());
|
1727
|
+
if (!heap_.Setup(create_heap_objects)) {
|
1728
|
+
V8::SetFatalError();
|
1729
|
+
return false;
|
1730
|
+
}
|
1731
|
+
|
1732
|
+
bootstrapper_->Initialize(create_heap_objects);
|
1733
|
+
builtins_.Setup(create_heap_objects);
|
1734
|
+
|
1735
|
+
InitializeThreadLocal();
|
1736
|
+
|
1737
|
+
// Only preallocate on the first initialization.
|
1738
|
+
if (FLAG_preallocate_message_memory && preallocated_message_space_ == NULL) {
|
1739
|
+
// Start the thread which will set aside some memory.
|
1740
|
+
PreallocatedMemoryThreadStart();
|
1741
|
+
preallocated_message_space_ =
|
1742
|
+
new NoAllocationStringAllocator(
|
1743
|
+
preallocated_memory_thread_->data(),
|
1744
|
+
preallocated_memory_thread_->length());
|
1745
|
+
PreallocatedStorageInit(preallocated_memory_thread_->length() / 4);
|
1746
|
+
}
|
1747
|
+
|
1748
|
+
if (FLAG_preemption) {
|
1749
|
+
v8::Locker locker;
|
1750
|
+
v8::Locker::StartPreemption(100);
|
1751
|
+
}
|
1752
|
+
|
1753
|
+
#ifdef ENABLE_DEBUGGER_SUPPORT
|
1754
|
+
debug_->Setup(create_heap_objects);
|
1755
|
+
#endif
|
1756
|
+
stub_cache_->Initialize(create_heap_objects);
|
1757
|
+
|
1758
|
+
// If we are deserializing, read the state into the now-empty heap.
|
1759
|
+
if (des != NULL) {
|
1760
|
+
des->Deserialize();
|
1761
|
+
stub_cache_->Clear();
|
1762
|
+
}
|
1763
|
+
|
1764
|
+
// Deserializing may put strange things in the root array's copy of the
|
1765
|
+
// stack guard.
|
1766
|
+
heap_.SetStackLimits();
|
1767
|
+
|
1768
|
+
deoptimizer_data_ = new DeoptimizerData;
|
1769
|
+
runtime_profiler_ = new RuntimeProfiler(this);
|
1770
|
+
runtime_profiler_->Setup();
|
1771
|
+
|
1772
|
+
// If we are deserializing, log non-function code objects and compiled
|
1773
|
+
// functions found in the snapshot.
|
1774
|
+
if (des != NULL && (FLAG_log_code || FLAG_ll_prof)) {
|
1775
|
+
HandleScope scope;
|
1776
|
+
LOG(this, LogCodeObjects());
|
1777
|
+
LOG(this, LogCompiledFunctions());
|
1778
|
+
}
|
1779
|
+
|
1780
|
+
state_ = INITIALIZED;
|
1781
|
+
return true;
|
1782
|
+
}
|
1783
|
+
|
1784
|
+
|
1785
|
+
void Isolate::Enter() {
|
1786
|
+
Isolate* current_isolate = NULL;
|
1787
|
+
PerIsolateThreadData* current_data = CurrentPerIsolateThreadData();
|
1788
|
+
if (current_data != NULL) {
|
1789
|
+
current_isolate = current_data->isolate_;
|
1790
|
+
ASSERT(current_isolate != NULL);
|
1791
|
+
if (current_isolate == this) {
|
1792
|
+
ASSERT(Current() == this);
|
1793
|
+
ASSERT(entry_stack_ != NULL);
|
1794
|
+
ASSERT(entry_stack_->previous_thread_data == NULL ||
|
1795
|
+
entry_stack_->previous_thread_data->thread_id().Equals(
|
1796
|
+
ThreadId::Current()));
|
1797
|
+
// Same thread re-enters the isolate, no need to re-init anything.
|
1798
|
+
entry_stack_->entry_count++;
|
1799
|
+
return;
|
1800
|
+
}
|
1801
|
+
}
|
1802
|
+
|
1803
|
+
// Threads can have default isolate set into TLS as Current but not yet have
|
1804
|
+
// PerIsolateThreadData for it, as it requires more advanced phase of the
|
1805
|
+
// initialization. For example, a thread might be the one that system used for
|
1806
|
+
// static initializers - in this case the default isolate is set in TLS but
|
1807
|
+
// the thread did not yet Enter the isolate. If PerisolateThreadData is not
|
1808
|
+
// there, use the isolate set in TLS.
|
1809
|
+
if (current_isolate == NULL) {
|
1810
|
+
current_isolate = Isolate::UncheckedCurrent();
|
1811
|
+
}
|
1812
|
+
|
1813
|
+
PerIsolateThreadData* data = FindOrAllocatePerThreadDataForThisThread();
|
1814
|
+
ASSERT(data != NULL);
|
1815
|
+
ASSERT(data->isolate_ == this);
|
1816
|
+
|
1817
|
+
EntryStackItem* item = new EntryStackItem(current_data,
|
1818
|
+
current_isolate,
|
1819
|
+
entry_stack_);
|
1820
|
+
entry_stack_ = item;
|
1821
|
+
|
1822
|
+
SetIsolateThreadLocals(this, data);
|
1823
|
+
|
1824
|
+
CHECK(PreInit());
|
1825
|
+
|
1826
|
+
// In case it's the first time some thread enters the isolate.
|
1827
|
+
set_thread_id(data->thread_id());
|
1828
|
+
}
|
1829
|
+
|
1830
|
+
|
1831
|
+
void Isolate::Exit() {
|
1832
|
+
ASSERT(entry_stack_ != NULL);
|
1833
|
+
ASSERT(entry_stack_->previous_thread_data == NULL ||
|
1834
|
+
entry_stack_->previous_thread_data->thread_id().Equals(
|
1835
|
+
ThreadId::Current()));
|
1836
|
+
|
1837
|
+
if (--entry_stack_->entry_count > 0) return;
|
1838
|
+
|
1839
|
+
ASSERT(CurrentPerIsolateThreadData() != NULL);
|
1840
|
+
ASSERT(CurrentPerIsolateThreadData()->isolate_ == this);
|
1841
|
+
|
1842
|
+
// Pop the stack.
|
1843
|
+
EntryStackItem* item = entry_stack_;
|
1844
|
+
entry_stack_ = item->previous_item;
|
1845
|
+
|
1846
|
+
PerIsolateThreadData* previous_thread_data = item->previous_thread_data;
|
1847
|
+
Isolate* previous_isolate = item->previous_isolate;
|
1848
|
+
|
1849
|
+
delete item;
|
1850
|
+
|
1851
|
+
// Reinit the current thread for the isolate it was running before this one.
|
1852
|
+
SetIsolateThreadLocals(previous_isolate, previous_thread_data);
|
1853
|
+
}
|
1854
|
+
|
1855
|
+
|
1856
|
+
void Isolate::ResetEagerOptimizingData() {
|
1857
|
+
compilation_cache_->ResetEagerOptimizingData();
|
1858
|
+
}
|
1859
|
+
|
1860
|
+
|
1861
|
+
#ifdef DEBUG
|
1862
|
+
#define ISOLATE_FIELD_OFFSET(type, name, ignored) \
|
1863
|
+
const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_);
|
1864
|
+
ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET)
|
1865
|
+
ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET)
|
1866
|
+
#undef ISOLATE_FIELD_OFFSET
|
1867
|
+
#endif
|
1868
|
+
|
1869
|
+
} } // namespace v8::internal
|