mustang 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -0
- data/Isolate +9 -0
- data/README.md +6 -12
- data/Rakefile +30 -4
- data/TODO.md +9 -0
- data/ext/v8/extconf.rb +56 -0
- data/ext/v8/v8.cpp +37 -0
- data/ext/v8/v8_array.cpp +161 -0
- data/ext/v8/v8_array.h +17 -0
- data/ext/v8/v8_base.cpp +147 -0
- data/ext/v8/v8_base.h +23 -0
- data/ext/v8/v8_cast.cpp +151 -0
- data/ext/v8/v8_cast.h +64 -0
- data/ext/v8/v8_context.cpp +174 -0
- data/ext/v8/v8_context.h +12 -0
- data/ext/v8/v8_date.cpp +61 -0
- data/ext/v8/v8_date.h +16 -0
- data/ext/v8/v8_errors.cpp +147 -0
- data/ext/v8/v8_errors.h +19 -0
- data/ext/v8/v8_external.cpp +66 -0
- data/ext/v8/v8_external.h +16 -0
- data/ext/v8/v8_function.cpp +182 -0
- data/ext/v8/v8_function.h +14 -0
- data/ext/v8/v8_integer.cpp +70 -0
- data/ext/v8/v8_integer.h +16 -0
- data/ext/v8/v8_macros.h +30 -0
- data/ext/v8/v8_main.cpp +53 -0
- data/ext/v8/v8_main.h +13 -0
- data/ext/v8/v8_number.cpp +62 -0
- data/ext/v8/v8_number.h +16 -0
- data/ext/v8/v8_object.cpp +172 -0
- data/ext/v8/v8_object.h +17 -0
- data/ext/v8/v8_ref.cpp +72 -0
- data/ext/v8/v8_ref.h +43 -0
- data/ext/v8/v8_regexp.cpp +148 -0
- data/ext/v8/v8_regexp.h +16 -0
- data/ext/v8/v8_string.cpp +78 -0
- data/ext/v8/v8_string.h +16 -0
- data/ext/v8/v8_value.cpp +370 -0
- data/ext/v8/v8_value.h +19 -0
- data/gemspec.yml +2 -1
- data/lib/core_ext/class.rb +14 -0
- data/lib/core_ext/object.rb +12 -0
- data/lib/core_ext/symbol.rb +23 -0
- data/lib/mustang.rb +44 -0
- data/lib/mustang/context.rb +69 -0
- data/lib/mustang/errors.rb +36 -0
- data/lib/support/delegated.rb +25 -0
- data/lib/v8/array.rb +21 -0
- data/lib/v8/context.rb +13 -0
- data/lib/v8/date.rb +20 -0
- data/lib/v8/error.rb +15 -0
- data/lib/v8/external.rb +16 -0
- data/lib/v8/function.rb +11 -0
- data/lib/v8/integer.rb +16 -0
- data/lib/v8/number.rb +16 -0
- data/lib/v8/object.rb +66 -0
- data/lib/v8/regexp.rb +23 -0
- data/lib/v8/string.rb +27 -0
- data/mustang.gemspec +3 -0
- data/spec/core_ext/class_spec.rb +19 -0
- data/spec/core_ext/object_spec.rb +19 -0
- data/spec/core_ext/symbol_spec.rb +27 -0
- data/spec/fixtures/test1.js +2 -0
- data/spec/fixtures/test2.js +2 -0
- data/spec/spec_helper.rb +20 -0
- data/spec/v8/array_spec.rb +88 -0
- data/spec/v8/cast_spec.rb +151 -0
- data/spec/v8/context_spec.rb +78 -0
- data/spec/v8/data_spec.rb +39 -0
- data/spec/v8/date_spec.rb +45 -0
- data/spec/v8/empty_spec.rb +27 -0
- data/spec/v8/errors_spec.rb +142 -0
- data/spec/v8/external_spec.rb +44 -0
- data/spec/v8/function_spec.rb +170 -0
- data/spec/v8/integer_spec.rb +41 -0
- data/spec/v8/main_spec.rb +18 -0
- data/spec/v8/null_spec.rb +27 -0
- data/spec/v8/number_spec.rb +40 -0
- data/spec/v8/object_spec.rb +79 -0
- data/spec/v8/primitive_spec.rb +9 -0
- data/spec/v8/regexp_spec.rb +65 -0
- data/spec/v8/string_spec.rb +48 -0
- data/spec/v8/undefined_spec.rb +27 -0
- data/spec/v8/value_spec.rb +215 -0
- data/vendor/v8/.gitignore +2 -0
- data/vendor/v8/AUTHORS +3 -1
- data/vendor/v8/ChangeLog +117 -0
- data/vendor/v8/SConstruct +334 -53
- data/vendor/v8/include/v8-debug.h +21 -11
- data/vendor/v8/include/v8-preparser.h +1 -1
- data/vendor/v8/include/v8-profiler.h +122 -43
- data/vendor/v8/include/v8-testing.h +5 -0
- data/vendor/v8/include/v8.h +171 -17
- data/vendor/v8/preparser/SConscript +38 -0
- data/vendor/v8/preparser/preparser-process.cc +77 -114
- data/vendor/v8/samples/shell.cc +232 -46
- data/vendor/v8/src/SConscript +29 -5
- data/vendor/v8/src/accessors.cc +70 -211
- data/vendor/v8/{test/cctest/test-mips.cc → src/allocation-inl.h} +15 -18
- data/vendor/v8/src/allocation.cc +0 -82
- data/vendor/v8/src/allocation.h +9 -42
- data/vendor/v8/src/api.cc +1645 -1156
- data/vendor/v8/src/api.h +76 -12
- data/vendor/v8/src/apiutils.h +0 -7
- data/vendor/v8/src/arguments.h +15 -4
- data/vendor/v8/src/arm/assembler-arm-inl.h +10 -9
- data/vendor/v8/src/arm/assembler-arm.cc +62 -23
- data/vendor/v8/src/arm/assembler-arm.h +76 -11
- data/vendor/v8/src/arm/builtins-arm.cc +39 -33
- data/vendor/v8/src/arm/code-stubs-arm.cc +1182 -402
- data/vendor/v8/src/arm/code-stubs-arm.h +20 -54
- data/vendor/v8/src/arm/codegen-arm.cc +159 -106
- data/vendor/v8/src/arm/codegen-arm.h +6 -6
- data/vendor/v8/src/arm/constants-arm.h +16 -1
- data/vendor/v8/src/arm/cpu-arm.cc +7 -5
- data/vendor/v8/src/arm/debug-arm.cc +6 -4
- data/vendor/v8/src/arm/deoptimizer-arm.cc +51 -14
- data/vendor/v8/src/arm/disasm-arm.cc +47 -15
- data/vendor/v8/src/arm/frames-arm.h +1 -1
- data/vendor/v8/src/arm/full-codegen-arm.cc +724 -408
- data/vendor/v8/src/arm/ic-arm.cc +90 -85
- data/vendor/v8/src/arm/lithium-arm.cc +140 -69
- data/vendor/v8/src/arm/lithium-arm.h +161 -46
- data/vendor/v8/src/arm/lithium-codegen-arm.cc +567 -297
- data/vendor/v8/src/arm/lithium-codegen-arm.h +21 -9
- data/vendor/v8/src/arm/lithium-gap-resolver-arm.cc +2 -0
- data/vendor/v8/src/arm/macro-assembler-arm.cc +457 -96
- data/vendor/v8/src/arm/macro-assembler-arm.h +115 -18
- data/vendor/v8/src/arm/regexp-macro-assembler-arm.cc +20 -13
- data/vendor/v8/src/arm/regexp-macro-assembler-arm.h +1 -0
- data/vendor/v8/src/arm/simulator-arm.cc +184 -101
- data/vendor/v8/src/arm/simulator-arm.h +26 -21
- data/vendor/v8/src/arm/stub-cache-arm.cc +450 -467
- data/vendor/v8/src/arm/virtual-frame-arm.cc +14 -12
- data/vendor/v8/src/arm/virtual-frame-arm.h +11 -8
- data/vendor/v8/src/array.js +35 -18
- data/vendor/v8/src/assembler.cc +186 -92
- data/vendor/v8/src/assembler.h +106 -69
- data/vendor/v8/src/ast-inl.h +5 -0
- data/vendor/v8/src/ast.cc +46 -35
- data/vendor/v8/src/ast.h +107 -50
- data/vendor/v8/src/atomicops.h +2 -0
- data/vendor/v8/src/atomicops_internals_mips_gcc.h +169 -0
- data/vendor/v8/src/bootstrapper.cc +649 -399
- data/vendor/v8/src/bootstrapper.h +94 -27
- data/vendor/v8/src/builtins.cc +359 -227
- data/vendor/v8/src/builtins.h +157 -123
- data/vendor/v8/src/checks.cc +2 -2
- data/vendor/v8/src/checks.h +4 -0
- data/vendor/v8/src/code-stubs.cc +27 -17
- data/vendor/v8/src/code-stubs.h +38 -17
- data/vendor/v8/src/codegen-inl.h +5 -1
- data/vendor/v8/src/codegen.cc +27 -17
- data/vendor/v8/src/codegen.h +9 -9
- data/vendor/v8/src/compilation-cache.cc +92 -206
- data/vendor/v8/src/compilation-cache.h +205 -30
- data/vendor/v8/src/compiler.cc +107 -120
- data/vendor/v8/src/compiler.h +17 -2
- data/vendor/v8/src/contexts.cc +22 -15
- data/vendor/v8/src/contexts.h +14 -8
- data/vendor/v8/src/conversions.cc +86 -30
- data/vendor/v8/src/counters.cc +19 -4
- data/vendor/v8/src/counters.h +28 -16
- data/vendor/v8/src/cpu-profiler-inl.h +4 -3
- data/vendor/v8/src/cpu-profiler.cc +123 -72
- data/vendor/v8/src/cpu-profiler.h +33 -19
- data/vendor/v8/src/cpu.h +2 -0
- data/vendor/v8/src/d8-debug.cc +3 -3
- data/vendor/v8/src/d8-debug.h +7 -6
- data/vendor/v8/src/d8-posix.cc +2 -0
- data/vendor/v8/src/d8.cc +22 -12
- data/vendor/v8/src/d8.gyp +3 -0
- data/vendor/v8/src/d8.js +618 -0
- data/vendor/v8/src/data-flow.h +3 -3
- data/vendor/v8/src/dateparser.h +4 -2
- data/vendor/v8/src/debug-agent.cc +10 -9
- data/vendor/v8/src/debug-agent.h +9 -11
- data/vendor/v8/src/debug-debugger.js +121 -0
- data/vendor/v8/src/debug.cc +331 -227
- data/vendor/v8/src/debug.h +248 -219
- data/vendor/v8/src/deoptimizer.cc +173 -62
- data/vendor/v8/src/deoptimizer.h +119 -19
- data/vendor/v8/src/disasm.h +3 -0
- data/vendor/v8/src/disassembler.cc +10 -9
- data/vendor/v8/src/execution.cc +185 -129
- data/vendor/v8/src/execution.h +47 -78
- data/vendor/v8/src/extensions/experimental/break-iterator.cc +250 -0
- data/vendor/v8/src/extensions/experimental/break-iterator.h +89 -0
- data/vendor/v8/src/extensions/experimental/experimental.gyp +2 -0
- data/vendor/v8/src/extensions/experimental/i18n-extension.cc +22 -2
- data/vendor/v8/src/extensions/externalize-string-extension.cc +2 -2
- data/vendor/v8/src/extensions/gc-extension.cc +1 -1
- data/vendor/v8/src/factory.cc +261 -154
- data/vendor/v8/src/factory.h +162 -158
- data/vendor/v8/src/flag-definitions.h +17 -11
- data/vendor/v8/src/frame-element.cc +0 -5
- data/vendor/v8/src/frame-element.h +9 -13
- data/vendor/v8/src/frames-inl.h +7 -0
- data/vendor/v8/src/frames.cc +56 -46
- data/vendor/v8/src/frames.h +36 -25
- data/vendor/v8/src/full-codegen.cc +15 -24
- data/vendor/v8/src/full-codegen.h +13 -41
- data/vendor/v8/src/func-name-inferrer.cc +7 -6
- data/vendor/v8/src/func-name-inferrer.h +1 -1
- data/vendor/v8/src/gdb-jit.cc +1 -0
- data/vendor/v8/src/global-handles.cc +118 -56
- data/vendor/v8/src/global-handles.h +98 -40
- data/vendor/v8/src/globals.h +2 -2
- data/vendor/v8/src/handles-inl.h +106 -9
- data/vendor/v8/src/handles.cc +220 -157
- data/vendor/v8/src/handles.h +38 -59
- data/vendor/v8/src/hashmap.h +3 -3
- data/vendor/v8/src/heap-inl.h +141 -25
- data/vendor/v8/src/heap-profiler.cc +117 -63
- data/vendor/v8/src/heap-profiler.h +38 -21
- data/vendor/v8/src/heap.cc +805 -564
- data/vendor/v8/src/heap.h +640 -594
- data/vendor/v8/src/hydrogen-instructions.cc +216 -73
- data/vendor/v8/src/hydrogen-instructions.h +259 -124
- data/vendor/v8/src/hydrogen.cc +996 -1171
- data/vendor/v8/src/hydrogen.h +163 -144
- data/vendor/v8/src/ia32/assembler-ia32-inl.h +12 -11
- data/vendor/v8/src/ia32/assembler-ia32.cc +85 -39
- data/vendor/v8/src/ia32/assembler-ia32.h +82 -16
- data/vendor/v8/src/ia32/builtins-ia32.cc +64 -58
- data/vendor/v8/src/ia32/code-stubs-ia32.cc +248 -324
- data/vendor/v8/src/ia32/code-stubs-ia32.h +3 -44
- data/vendor/v8/src/ia32/codegen-ia32.cc +217 -165
- data/vendor/v8/src/ia32/codegen-ia32.h +3 -0
- data/vendor/v8/src/ia32/cpu-ia32.cc +6 -5
- data/vendor/v8/src/ia32/debug-ia32.cc +8 -5
- data/vendor/v8/src/ia32/deoptimizer-ia32.cc +124 -14
- data/vendor/v8/src/ia32/disasm-ia32.cc +85 -62
- data/vendor/v8/src/ia32/frames-ia32.h +1 -1
- data/vendor/v8/src/ia32/full-codegen-ia32.cc +348 -435
- data/vendor/v8/src/ia32/ic-ia32.cc +91 -91
- data/vendor/v8/src/ia32/lithium-codegen-ia32.cc +500 -255
- data/vendor/v8/src/ia32/lithium-codegen-ia32.h +13 -4
- data/vendor/v8/src/ia32/lithium-gap-resolver-ia32.cc +6 -0
- data/vendor/v8/src/ia32/lithium-ia32.cc +122 -45
- data/vendor/v8/src/ia32/lithium-ia32.h +128 -41
- data/vendor/v8/src/ia32/macro-assembler-ia32.cc +109 -84
- data/vendor/v8/src/ia32/macro-assembler-ia32.h +18 -9
- data/vendor/v8/src/ia32/regexp-macro-assembler-ia32.cc +26 -15
- data/vendor/v8/src/ia32/regexp-macro-assembler-ia32.h +1 -0
- data/vendor/v8/src/ia32/register-allocator-ia32.cc +30 -30
- data/vendor/v8/src/ia32/simulator-ia32.h +4 -4
- data/vendor/v8/src/ia32/stub-cache-ia32.cc +383 -400
- data/vendor/v8/src/ia32/virtual-frame-ia32.cc +36 -13
- data/vendor/v8/src/ia32/virtual-frame-ia32.h +11 -5
- data/vendor/v8/src/ic-inl.h +12 -2
- data/vendor/v8/src/ic.cc +304 -221
- data/vendor/v8/src/ic.h +115 -58
- data/vendor/v8/src/interpreter-irregexp.cc +25 -21
- data/vendor/v8/src/interpreter-irregexp.h +2 -1
- data/vendor/v8/src/isolate.cc +883 -0
- data/vendor/v8/src/isolate.h +1304 -0
- data/vendor/v8/src/json.js +10 -10
- data/vendor/v8/src/jsregexp.cc +111 -80
- data/vendor/v8/src/jsregexp.h +6 -7
- data/vendor/v8/src/jump-target-heavy.cc +5 -8
- data/vendor/v8/src/jump-target-heavy.h +0 -6
- data/vendor/v8/src/jump-target-inl.h +1 -1
- data/vendor/v8/src/jump-target-light.cc +3 -3
- data/vendor/v8/src/lithium-allocator-inl.h +2 -0
- data/vendor/v8/src/lithium-allocator.cc +42 -30
- data/vendor/v8/src/lithium-allocator.h +8 -22
- data/vendor/v8/src/lithium.cc +1 -0
- data/vendor/v8/src/liveedit.cc +141 -99
- data/vendor/v8/src/liveedit.h +7 -2
- data/vendor/v8/src/liveobjectlist-inl.h +90 -0
- data/vendor/v8/src/liveobjectlist.cc +2537 -1
- data/vendor/v8/src/liveobjectlist.h +245 -35
- data/vendor/v8/src/log-utils.cc +122 -35
- data/vendor/v8/src/log-utils.h +33 -36
- data/vendor/v8/src/log.cc +299 -241
- data/vendor/v8/src/log.h +177 -110
- data/vendor/v8/src/mark-compact.cc +612 -470
- data/vendor/v8/src/mark-compact.h +153 -80
- data/vendor/v8/src/messages.cc +16 -14
- data/vendor/v8/src/messages.js +30 -7
- data/vendor/v8/src/mips/assembler-mips-inl.h +155 -35
- data/vendor/v8/src/mips/assembler-mips.cc +1093 -219
- data/vendor/v8/src/mips/assembler-mips.h +552 -153
- data/vendor/v8/src/mips/builtins-mips.cc +43 -100
- data/vendor/v8/src/mips/code-stubs-mips.cc +752 -0
- data/vendor/v8/src/mips/code-stubs-mips.h +511 -0
- data/vendor/v8/src/mips/codegen-mips-inl.h +8 -14
- data/vendor/v8/src/mips/codegen-mips.cc +672 -896
- data/vendor/v8/src/mips/codegen-mips.h +271 -69
- data/vendor/v8/src/mips/constants-mips.cc +44 -20
- data/vendor/v8/src/mips/constants-mips.h +238 -40
- data/vendor/v8/src/mips/cpu-mips.cc +20 -3
- data/vendor/v8/src/mips/debug-mips.cc +35 -7
- data/vendor/v8/src/mips/deoptimizer-mips.cc +91 -0
- data/vendor/v8/src/mips/disasm-mips.cc +329 -93
- data/vendor/v8/src/mips/frames-mips.cc +2 -50
- data/vendor/v8/src/mips/frames-mips.h +24 -9
- data/vendor/v8/src/mips/full-codegen-mips.cc +473 -23
- data/vendor/v8/src/mips/ic-mips.cc +81 -45
- data/vendor/v8/src/mips/jump-target-mips.cc +11 -106
- data/vendor/v8/src/mips/lithium-codegen-mips.h +65 -0
- data/vendor/v8/src/mips/lithium-mips.h +304 -0
- data/vendor/v8/src/mips/macro-assembler-mips.cc +2391 -390
- data/vendor/v8/src/mips/macro-assembler-mips.h +718 -121
- data/vendor/v8/src/mips/regexp-macro-assembler-mips.cc +478 -0
- data/vendor/v8/src/mips/regexp-macro-assembler-mips.h +250 -0
- data/vendor/v8/src/mips/register-allocator-mips-inl.h +0 -3
- data/vendor/v8/src/mips/register-allocator-mips.h +3 -2
- data/vendor/v8/src/mips/simulator-mips.cc +1009 -221
- data/vendor/v8/src/mips/simulator-mips.h +119 -36
- data/vendor/v8/src/mips/stub-cache-mips.cc +331 -148
- data/vendor/v8/src/mips/{fast-codegen-mips.cc → virtual-frame-mips-inl.h} +11 -30
- data/vendor/v8/src/mips/virtual-frame-mips.cc +137 -149
- data/vendor/v8/src/mips/virtual-frame-mips.h +294 -312
- data/vendor/v8/src/mirror-debugger.js +9 -8
- data/vendor/v8/src/mksnapshot.cc +2 -2
- data/vendor/v8/src/objects-debug.cc +16 -16
- data/vendor/v8/src/objects-inl.h +421 -195
- data/vendor/v8/src/objects-printer.cc +7 -7
- data/vendor/v8/src/objects-visiting.cc +1 -1
- data/vendor/v8/src/objects-visiting.h +33 -12
- data/vendor/v8/src/objects.cc +935 -658
- data/vendor/v8/src/objects.h +234 -139
- data/vendor/v8/src/parser.cc +484 -439
- data/vendor/v8/src/parser.h +35 -14
- data/vendor/v8/src/platform-cygwin.cc +173 -107
- data/vendor/v8/src/platform-freebsd.cc +224 -72
- data/vendor/v8/src/platform-linux.cc +234 -95
- data/vendor/v8/src/platform-macos.cc +215 -82
- data/vendor/v8/src/platform-nullos.cc +9 -3
- data/vendor/v8/src/platform-openbsd.cc +22 -7
- data/vendor/v8/src/platform-posix.cc +30 -5
- data/vendor/v8/src/platform-solaris.cc +120 -38
- data/vendor/v8/src/platform-tls-mac.h +62 -0
- data/vendor/v8/src/platform-tls-win32.h +62 -0
- data/vendor/v8/src/platform-tls.h +50 -0
- data/vendor/v8/src/platform-win32.cc +195 -97
- data/vendor/v8/src/platform.h +72 -15
- data/vendor/v8/src/preparse-data.cc +2 -0
- data/vendor/v8/src/preparser-api.cc +8 -2
- data/vendor/v8/src/preparser.cc +1 -1
- data/vendor/v8/src/prettyprinter.cc +43 -52
- data/vendor/v8/src/prettyprinter.h +1 -1
- data/vendor/v8/src/profile-generator-inl.h +0 -28
- data/vendor/v8/src/profile-generator.cc +942 -685
- data/vendor/v8/src/profile-generator.h +210 -176
- data/vendor/v8/src/property.cc +6 -0
- data/vendor/v8/src/property.h +14 -3
- data/vendor/v8/src/regexp-macro-assembler-irregexp.cc +1 -1
- data/vendor/v8/src/regexp-macro-assembler.cc +28 -19
- data/vendor/v8/src/regexp-macro-assembler.h +11 -6
- data/vendor/v8/src/regexp-stack.cc +18 -10
- data/vendor/v8/src/regexp-stack.h +45 -21
- data/vendor/v8/src/regexp.js +3 -3
- data/vendor/v8/src/register-allocator-inl.h +3 -3
- data/vendor/v8/src/register-allocator.cc +1 -7
- data/vendor/v8/src/register-allocator.h +5 -15
- data/vendor/v8/src/rewriter.cc +2 -1
- data/vendor/v8/src/runtime-profiler.cc +158 -128
- data/vendor/v8/src/runtime-profiler.h +131 -15
- data/vendor/v8/src/runtime.cc +2409 -1692
- data/vendor/v8/src/runtime.h +93 -17
- data/vendor/v8/src/safepoint-table.cc +3 -0
- data/vendor/v8/src/safepoint-table.h +9 -3
- data/vendor/v8/src/scanner-base.cc +21 -28
- data/vendor/v8/src/scanner-base.h +22 -11
- data/vendor/v8/src/scanner.cc +3 -5
- data/vendor/v8/src/scanner.h +4 -2
- data/vendor/v8/src/scopeinfo.cc +11 -16
- data/vendor/v8/src/scopeinfo.h +26 -15
- data/vendor/v8/src/scopes.cc +67 -37
- data/vendor/v8/src/scopes.h +26 -12
- data/vendor/v8/src/serialize.cc +193 -154
- data/vendor/v8/src/serialize.h +41 -36
- data/vendor/v8/src/small-pointer-list.h +163 -0
- data/vendor/v8/src/snapshot-common.cc +1 -1
- data/vendor/v8/src/snapshot.h +3 -1
- data/vendor/v8/src/spaces-inl.h +30 -25
- data/vendor/v8/src/spaces.cc +263 -370
- data/vendor/v8/src/spaces.h +178 -166
- data/vendor/v8/src/string-search.cc +4 -3
- data/vendor/v8/src/string-search.h +21 -20
- data/vendor/v8/src/string-stream.cc +32 -24
- data/vendor/v8/src/string.js +7 -7
- data/vendor/v8/src/stub-cache.cc +324 -248
- data/vendor/v8/src/stub-cache.h +181 -155
- data/vendor/v8/src/token.cc +3 -3
- data/vendor/v8/src/token.h +3 -3
- data/vendor/v8/src/top.cc +218 -390
- data/vendor/v8/src/type-info.cc +98 -32
- data/vendor/v8/src/type-info.h +10 -3
- data/vendor/v8/src/unicode.cc +1 -1
- data/vendor/v8/src/unicode.h +1 -1
- data/vendor/v8/src/utils.h +3 -0
- data/vendor/v8/src/v8-counters.cc +18 -11
- data/vendor/v8/src/v8-counters.h +34 -13
- data/vendor/v8/src/v8.cc +66 -121
- data/vendor/v8/src/v8.h +7 -4
- data/vendor/v8/src/v8globals.h +18 -12
- data/vendor/v8/src/{memory.h → v8memory.h} +0 -0
- data/vendor/v8/src/v8natives.js +59 -18
- data/vendor/v8/src/v8threads.cc +127 -114
- data/vendor/v8/src/v8threads.h +42 -35
- data/vendor/v8/src/v8utils.h +2 -39
- data/vendor/v8/src/variables.h +1 -1
- data/vendor/v8/src/version.cc +26 -5
- data/vendor/v8/src/version.h +4 -0
- data/vendor/v8/src/virtual-frame-heavy-inl.h +2 -4
- data/vendor/v8/src/virtual-frame-light-inl.h +5 -4
- data/vendor/v8/src/vm-state-inl.h +21 -17
- data/vendor/v8/src/vm-state.h +7 -5
- data/vendor/v8/src/win32-headers.h +1 -0
- data/vendor/v8/src/x64/assembler-x64-inl.h +12 -11
- data/vendor/v8/src/x64/assembler-x64.cc +80 -40
- data/vendor/v8/src/x64/assembler-x64.h +67 -17
- data/vendor/v8/src/x64/builtins-x64.cc +34 -33
- data/vendor/v8/src/x64/code-stubs-x64.cc +636 -377
- data/vendor/v8/src/x64/code-stubs-x64.h +14 -48
- data/vendor/v8/src/x64/codegen-x64-inl.h +1 -1
- data/vendor/v8/src/x64/codegen-x64.cc +158 -136
- data/vendor/v8/src/x64/codegen-x64.h +4 -1
- data/vendor/v8/src/x64/cpu-x64.cc +7 -5
- data/vendor/v8/src/x64/debug-x64.cc +8 -6
- data/vendor/v8/src/x64/deoptimizer-x64.cc +195 -20
- data/vendor/v8/src/x64/disasm-x64.cc +42 -23
- data/vendor/v8/src/x64/frames-x64.cc +1 -1
- data/vendor/v8/src/x64/frames-x64.h +2 -2
- data/vendor/v8/src/x64/full-codegen-x64.cc +780 -218
- data/vendor/v8/src/x64/ic-x64.cc +77 -79
- data/vendor/v8/src/x64/jump-target-x64.cc +1 -1
- data/vendor/v8/src/x64/lithium-codegen-x64.cc +698 -181
- data/vendor/v8/src/x64/lithium-codegen-x64.h +31 -6
- data/vendor/v8/src/x64/lithium-x64.cc +136 -54
- data/vendor/v8/src/x64/lithium-x64.h +142 -51
- data/vendor/v8/src/x64/macro-assembler-x64.cc +456 -187
- data/vendor/v8/src/x64/macro-assembler-x64.h +166 -34
- data/vendor/v8/src/x64/regexp-macro-assembler-x64.cc +44 -28
- data/vendor/v8/src/x64/regexp-macro-assembler-x64.h +8 -4
- data/vendor/v8/src/x64/register-allocator-x64-inl.h +3 -3
- data/vendor/v8/src/x64/register-allocator-x64.cc +12 -8
- data/vendor/v8/src/x64/simulator-x64.h +5 -5
- data/vendor/v8/src/x64/stub-cache-x64.cc +299 -344
- data/vendor/v8/src/x64/virtual-frame-x64.cc +37 -13
- data/vendor/v8/src/x64/virtual-frame-x64.h +13 -7
- data/vendor/v8/src/zone-inl.h +49 -3
- data/vendor/v8/src/zone.cc +42 -41
- data/vendor/v8/src/zone.h +37 -34
- data/vendor/v8/test/benchmarks/testcfg.py +100 -0
- data/vendor/v8/test/cctest/SConscript +5 -4
- data/vendor/v8/test/cctest/cctest.h +3 -2
- data/vendor/v8/test/cctest/cctest.status +6 -11
- data/vendor/v8/test/cctest/test-accessors.cc +3 -3
- data/vendor/v8/test/cctest/test-alloc.cc +39 -33
- data/vendor/v8/test/cctest/test-api.cc +1092 -205
- data/vendor/v8/test/cctest/test-assembler-arm.cc +39 -25
- data/vendor/v8/test/cctest/test-assembler-ia32.cc +36 -37
- data/vendor/v8/test/cctest/test-assembler-mips.cc +1098 -40
- data/vendor/v8/test/cctest/test-assembler-x64.cc +32 -25
- data/vendor/v8/test/cctest/test-ast.cc +1 -0
- data/vendor/v8/test/cctest/test-circular-queue.cc +8 -5
- data/vendor/v8/test/cctest/test-compiler.cc +24 -24
- data/vendor/v8/test/cctest/test-cpu-profiler.cc +140 -5
- data/vendor/v8/test/cctest/test-dataflow.cc +1 -0
- data/vendor/v8/test/cctest/test-debug.cc +136 -77
- data/vendor/v8/test/cctest/test-decls.cc +1 -1
- data/vendor/v8/test/cctest/test-deoptimization.cc +25 -24
- data/vendor/v8/test/cctest/test-disasm-arm.cc +9 -4
- data/vendor/v8/test/cctest/test-disasm-ia32.cc +10 -8
- data/vendor/v8/test/cctest/test-func-name-inference.cc +10 -4
- data/vendor/v8/test/cctest/test-heap-profiler.cc +226 -164
- data/vendor/v8/test/cctest/test-heap.cc +240 -217
- data/vendor/v8/test/cctest/test-liveedit.cc +1 -0
- data/vendor/v8/test/cctest/test-log-stack-tracer.cc +18 -20
- data/vendor/v8/test/cctest/test-log.cc +114 -108
- data/vendor/v8/test/cctest/test-macro-assembler-x64.cc +247 -177
- data/vendor/v8/test/cctest/test-mark-compact.cc +129 -90
- data/vendor/v8/test/cctest/test-parsing.cc +15 -14
- data/vendor/v8/test/cctest/test-platform-linux.cc +1 -0
- data/vendor/v8/test/cctest/test-platform-tls.cc +66 -0
- data/vendor/v8/test/cctest/test-platform-win32.cc +1 -0
- data/vendor/v8/test/cctest/test-profile-generator.cc +1 -1
- data/vendor/v8/test/cctest/test-regexp.cc +53 -41
- data/vendor/v8/test/cctest/test-reloc-info.cc +18 -11
- data/vendor/v8/test/cctest/test-serialize.cc +44 -43
- data/vendor/v8/test/cctest/test-sockets.cc +8 -3
- data/vendor/v8/test/cctest/test-spaces.cc +47 -29
- data/vendor/v8/test/cctest/test-strings.cc +20 -20
- data/vendor/v8/test/cctest/test-thread-termination.cc +8 -3
- data/vendor/v8/test/cctest/test-threads.cc +5 -3
- data/vendor/v8/test/cctest/test-utils.cc +5 -4
- data/vendor/v8/test/cctest/testcfg.py +7 -3
- data/vendor/v8/test/es5conform/es5conform.status +2 -77
- data/vendor/v8/test/es5conform/testcfg.py +1 -1
- data/vendor/v8/test/message/testcfg.py +1 -1
- data/vendor/v8/test/mjsunit/accessors-on-global-object.js +3 -3
- data/vendor/v8/test/mjsunit/array-concat.js +43 -1
- data/vendor/v8/test/mjsunit/array-join.js +25 -0
- data/vendor/v8/test/mjsunit/bitops-info.js +7 -1
- data/vendor/v8/test/mjsunit/compiler/array-length.js +2 -2
- data/vendor/v8/test/mjsunit/compiler/global-accessors.js +47 -0
- data/vendor/v8/test/mjsunit/compiler/pic.js +1 -1
- data/vendor/v8/test/mjsunit/compiler/regress-loadfield.js +65 -0
- data/vendor/v8/test/mjsunit/math-sqrt.js +5 -1
- data/vendor/v8/test/mjsunit/mjsunit.js +59 -8
- data/vendor/v8/test/mjsunit/mjsunit.status +0 -12
- data/vendor/v8/test/mjsunit/mul-exhaustive.js +129 -11
- data/vendor/v8/test/mjsunit/negate-zero.js +1 -1
- data/vendor/v8/test/mjsunit/object-freeze.js +5 -13
- data/vendor/v8/test/mjsunit/object-prevent-extensions.js +9 -50
- data/vendor/v8/test/mjsunit/object-seal.js +4 -13
- data/vendor/v8/test/mjsunit/override-eval-with-non-function.js +36 -0
- data/vendor/v8/test/mjsunit/regress/regress-1145.js +54 -0
- data/vendor/v8/test/mjsunit/regress/regress-1172-bis.js +37 -0
- data/vendor/v8/test/mjsunit/regress/regress-1181.js +54 -0
- data/vendor/v8/test/mjsunit/regress/regress-1207.js +35 -0
- data/vendor/v8/test/mjsunit/regress/regress-1209.js +34 -0
- data/vendor/v8/test/mjsunit/regress/regress-1210.js +48 -0
- data/vendor/v8/test/mjsunit/regress/regress-1213.js +43 -0
- data/vendor/v8/test/mjsunit/regress/regress-1218.js +29 -0
- data/vendor/v8/test/mjsunit/regress/regress-1229.js +79 -0
- data/vendor/v8/test/mjsunit/regress/regress-1233.js +47 -0
- data/vendor/v8/test/mjsunit/regress/regress-1236.js +34 -0
- data/vendor/v8/test/mjsunit/regress/regress-1237.js +36 -0
- data/vendor/v8/test/mjsunit/regress/regress-1240.js +39 -0
- data/vendor/v8/test/mjsunit/regress/regress-1257.js +58 -0
- data/vendor/v8/test/mjsunit/regress/regress-1278.js +69 -0
- data/vendor/v8/test/mjsunit/regress/regress-create-exception.js +1 -0
- data/vendor/v8/test/mjsunit/regress/regress-lazy-deopt-reloc.js +52 -0
- data/vendor/v8/test/mjsunit/sin-cos.js +15 -10
- data/vendor/v8/test/mjsunit/smi-negative-zero.js +2 -2
- data/vendor/v8/test/mjsunit/str-to-num.js +1 -1
- data/vendor/v8/test/mjsunit/strict-mode.js +435 -0
- data/vendor/v8/test/mjsunit/testcfg.py +23 -6
- data/vendor/v8/test/mozilla/mozilla.status +0 -2
- data/vendor/v8/test/mozilla/testcfg.py +1 -1
- data/vendor/v8/test/preparser/empty.js +28 -0
- data/vendor/v8/test/preparser/functions-only.js +38 -0
- data/vendor/v8/test/preparser/non-alphanum.js +34 -0
- data/vendor/v8/test/preparser/symbols-only.js +49 -0
- data/vendor/v8/test/preparser/testcfg.py +90 -0
- data/vendor/v8/test/sputnik/testcfg.py +1 -1
- data/vendor/v8/test/test262/README +16 -0
- data/vendor/v8/test/test262/harness-adapt.js +80 -0
- data/vendor/v8/test/test262/test262.status +1506 -0
- data/vendor/v8/test/test262/testcfg.py +123 -0
- data/vendor/v8/tools/freebsd-tick-processor +10 -0
- data/vendor/v8/tools/gyp/v8.gyp +8 -33
- data/vendor/v8/tools/linux-tick-processor +5 -3
- data/vendor/v8/tools/test.py +37 -14
- data/vendor/v8/tools/tickprocessor.js +22 -8
- data/vendor/v8/tools/visual_studio/v8_base.vcproj +13 -1
- data/vendor/v8/tools/visual_studio/v8_base_arm.vcproj +5 -1
- data/vendor/v8/tools/visual_studio/v8_base_x64.vcproj +5 -1
- data/vendor/v8/tools/visual_studio/x64.vsprops +1 -0
- metadata +1495 -1341
- data/ext/extconf.rb +0 -22
- data/ext/mustang.cpp +0 -58
- data/vendor/v8/src/top.h +0 -608
@@ -33,73 +33,140 @@ namespace v8 {
|
|
33
33
|
namespace internal {
|
34
34
|
|
35
35
|
|
36
|
-
|
36
|
+
// A SourceCodeCache uses a FixedArray to store pairs of
|
37
|
+
// (AsciiString*, JSFunction*), mapping names of native code files
|
38
|
+
// (runtime.js, etc.) to precompiled functions. Instead of mapping
|
39
|
+
// names to functions it might make sense to let the JS2C tool
|
40
|
+
// generate an index for each native JS file.
|
41
|
+
class SourceCodeCache BASE_EMBEDDED {
|
37
42
|
public:
|
38
|
-
|
39
|
-
~BootstrapperActive() { nesting_--; }
|
43
|
+
explicit SourceCodeCache(Script::Type type): type_(type), cache_(NULL) { }
|
40
44
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
+
void Initialize(bool create_heap_objects) {
|
46
|
+
cache_ = create_heap_objects ? HEAP->empty_fixed_array() : NULL;
|
47
|
+
}
|
48
|
+
|
49
|
+
void Iterate(ObjectVisitor* v) {
|
50
|
+
v->VisitPointer(BitCast<Object**, FixedArray**>(&cache_));
|
51
|
+
}
|
52
|
+
|
53
|
+
bool Lookup(Vector<const char> name, Handle<SharedFunctionInfo>* handle) {
|
54
|
+
for (int i = 0; i < cache_->length(); i+=2) {
|
55
|
+
SeqAsciiString* str = SeqAsciiString::cast(cache_->get(i));
|
56
|
+
if (str->IsEqualTo(name)) {
|
57
|
+
*handle = Handle<SharedFunctionInfo>(
|
58
|
+
SharedFunctionInfo::cast(cache_->get(i + 1)));
|
59
|
+
return true;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
return false;
|
63
|
+
}
|
64
|
+
|
65
|
+
void Add(Vector<const char> name, Handle<SharedFunctionInfo> shared) {
|
66
|
+
HandleScope scope;
|
67
|
+
int length = cache_->length();
|
68
|
+
Handle<FixedArray> new_array =
|
69
|
+
FACTORY->NewFixedArray(length + 2, TENURED);
|
70
|
+
cache_->CopyTo(0, *new_array, 0, cache_->length());
|
71
|
+
cache_ = *new_array;
|
72
|
+
Handle<String> str = FACTORY->NewStringFromAscii(name, TENURED);
|
73
|
+
cache_->set(length, *str);
|
74
|
+
cache_->set(length + 1, *shared);
|
75
|
+
Script::cast(shared->script())->set_type(Smi::FromInt(type_));
|
76
|
+
}
|
45
77
|
|
46
78
|
private:
|
47
|
-
|
48
|
-
|
49
|
-
|
79
|
+
Script::Type type_;
|
80
|
+
FixedArray* cache_;
|
81
|
+
DISALLOW_COPY_AND_ASSIGN(SourceCodeCache);
|
50
82
|
};
|
51
83
|
|
52
84
|
|
53
85
|
// The Boostrapper is the public interface for creating a JavaScript global
|
54
86
|
// context.
|
55
|
-
class Bootstrapper
|
87
|
+
class Bootstrapper {
|
56
88
|
public:
|
57
89
|
// Requires: Heap::Setup has been called.
|
58
|
-
|
59
|
-
|
90
|
+
void Initialize(bool create_heap_objects);
|
91
|
+
void TearDown();
|
60
92
|
|
61
93
|
// Creates a JavaScript Global Context with initial object graph.
|
62
94
|
// The returned value is a global handle casted to V8Environment*.
|
63
|
-
|
95
|
+
Handle<Context> CreateEnvironment(
|
64
96
|
Handle<Object> global_object,
|
65
97
|
v8::Handle<v8::ObjectTemplate> global_template,
|
66
98
|
v8::ExtensionConfiguration* extensions);
|
67
99
|
|
68
100
|
// Detach the environment from its outer global object.
|
69
|
-
|
101
|
+
void DetachGlobal(Handle<Context> env);
|
70
102
|
|
71
103
|
// Reattach an outer global object to an environment.
|
72
|
-
|
104
|
+
void ReattachGlobal(Handle<Context> env, Handle<Object> global_object);
|
73
105
|
|
74
106
|
// Traverses the pointers for memory management.
|
75
|
-
|
107
|
+
void Iterate(ObjectVisitor* v);
|
76
108
|
|
77
109
|
// Accessor for the native scripts source code.
|
78
|
-
|
110
|
+
Handle<String> NativesSourceLookup(int index);
|
79
111
|
|
80
112
|
// Tells whether bootstrapping is active.
|
81
|
-
|
113
|
+
bool IsActive() const { return nesting_ != 0; }
|
82
114
|
|
83
115
|
// Support for thread preemption.
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
116
|
+
RLYSTC int ArchiveSpacePerThread();
|
117
|
+
char* ArchiveState(char* to);
|
118
|
+
char* RestoreState(char* from);
|
119
|
+
void FreeThreadResources();
|
88
120
|
|
89
121
|
// This will allocate a char array that is deleted when V8 is shut down.
|
90
122
|
// It should only be used for strictly finite allocations.
|
91
|
-
|
123
|
+
char* AllocateAutoDeletedArray(int bytes);
|
92
124
|
|
93
125
|
// Used for new context creation.
|
94
|
-
|
95
|
-
|
126
|
+
bool InstallExtensions(Handle<Context> global_context,
|
127
|
+
v8::ExtensionConfiguration* extensions);
|
128
|
+
|
129
|
+
SourceCodeCache* extensions_cache() { return &extensions_cache_; }
|
130
|
+
|
131
|
+
private:
|
132
|
+
typedef int NestingCounterType;
|
133
|
+
NestingCounterType nesting_;
|
134
|
+
SourceCodeCache extensions_cache_;
|
135
|
+
// This is for delete, not delete[].
|
136
|
+
List<char*>* delete_these_non_arrays_on_tear_down_;
|
137
|
+
// This is for delete[]
|
138
|
+
List<char*>* delete_these_arrays_on_tear_down_;
|
139
|
+
|
140
|
+
friend class BootstrapperActive;
|
141
|
+
friend class Isolate;
|
142
|
+
friend class NativesExternalStringResource;
|
143
|
+
|
144
|
+
Bootstrapper();
|
145
|
+
|
146
|
+
DISALLOW_COPY_AND_ASSIGN(Bootstrapper);
|
147
|
+
};
|
148
|
+
|
149
|
+
|
150
|
+
class BootstrapperActive BASE_EMBEDDED {
|
151
|
+
public:
|
152
|
+
BootstrapperActive() {
|
153
|
+
++Isolate::Current()->bootstrapper()->nesting_;
|
154
|
+
}
|
155
|
+
|
156
|
+
~BootstrapperActive() {
|
157
|
+
--Isolate::Current()->bootstrapper()->nesting_;
|
158
|
+
}
|
159
|
+
|
160
|
+
private:
|
161
|
+
DISALLOW_COPY_AND_ASSIGN(BootstrapperActive);
|
96
162
|
};
|
97
163
|
|
98
164
|
|
99
165
|
class NativesExternalStringResource
|
100
166
|
: public v8::String::ExternalAsciiStringResource {
|
101
167
|
public:
|
102
|
-
explicit NativesExternalStringResource(
|
168
|
+
explicit NativesExternalStringResource(Bootstrapper* bootstrapper,
|
169
|
+
const char* source);
|
103
170
|
|
104
171
|
const char* data() const {
|
105
172
|
return data_;
|
data/vendor/v8/src/builtins.cc
CHANGED
@@ -107,7 +107,6 @@ BUILTIN_LIST_C(DEF_ARG_TYPE)
|
|
107
107
|
|
108
108
|
} // namespace
|
109
109
|
|
110
|
-
|
111
110
|
// ----------------------------------------------------------------------------
|
112
111
|
// Support macro for defining builtins in C++.
|
113
112
|
// ----------------------------------------------------------------------------
|
@@ -123,26 +122,27 @@ BUILTIN_LIST_C(DEF_ARG_TYPE)
|
|
123
122
|
|
124
123
|
#ifdef DEBUG
|
125
124
|
|
126
|
-
#define BUILTIN(name)
|
127
|
-
MUST_USE_RESULT static MaybeObject* Builtin_Impl_##name(
|
128
|
-
name##ArgumentsType args);
|
129
|
-
MUST_USE_RESULT static MaybeObject* Builtin_##name(
|
130
|
-
name##ArgumentsType args) {
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
125
|
+
#define BUILTIN(name) \
|
126
|
+
MUST_USE_RESULT static MaybeObject* Builtin_Impl_##name( \
|
127
|
+
name##ArgumentsType args, Isolate* isolate); \
|
128
|
+
MUST_USE_RESULT static MaybeObject* Builtin_##name( \
|
129
|
+
name##ArgumentsType args, Isolate* isolate) { \
|
130
|
+
ASSERT(isolate == Isolate::Current()); \
|
131
|
+
args.Verify(); \
|
132
|
+
return Builtin_Impl_##name(args, isolate); \
|
133
|
+
} \
|
134
|
+
MUST_USE_RESULT static MaybeObject* Builtin_Impl_##name( \
|
135
|
+
name##ArgumentsType args, Isolate* isolate)
|
136
136
|
|
137
137
|
#else // For release mode.
|
138
138
|
|
139
|
-
#define BUILTIN(name)
|
140
|
-
static MaybeObject* Builtin_##name(name##ArgumentsType args)
|
139
|
+
#define BUILTIN(name) \
|
140
|
+
static MaybeObject* Builtin_##name(name##ArgumentsType args, Isolate* isolate)
|
141
141
|
|
142
142
|
#endif
|
143
143
|
|
144
144
|
|
145
|
-
static inline bool CalledAsConstructor() {
|
145
|
+
static inline bool CalledAsConstructor(Isolate* isolate) {
|
146
146
|
#ifdef DEBUG
|
147
147
|
// Calculate the result using a full stack frame iterator and check
|
148
148
|
// that the state of the stack is as we assume it to be in the
|
@@ -153,7 +153,7 @@ static inline bool CalledAsConstructor() {
|
|
153
153
|
StackFrame* frame = it.frame();
|
154
154
|
bool reference_result = frame->is_construct();
|
155
155
|
#endif
|
156
|
-
Address fp =
|
156
|
+
Address fp = Isolate::c_entry_fp(isolate->thread_local_top());
|
157
157
|
// Because we know fp points to an exit frame we can use the relevant
|
158
158
|
// part of ExitFrame::ComputeCallerState directly.
|
159
159
|
const int kCallerOffset = ExitFrameConstants::kCallerFPOffset;
|
@@ -172,30 +172,30 @@ static inline bool CalledAsConstructor() {
|
|
172
172
|
|
173
173
|
// ----------------------------------------------------------------------------
|
174
174
|
|
175
|
-
|
176
175
|
BUILTIN(Illegal) {
|
177
176
|
UNREACHABLE();
|
178
|
-
return
|
177
|
+
return isolate->heap()->undefined_value(); // Make compiler happy.
|
179
178
|
}
|
180
179
|
|
181
180
|
|
182
181
|
BUILTIN(EmptyFunction) {
|
183
|
-
return
|
182
|
+
return isolate->heap()->undefined_value();
|
184
183
|
}
|
185
184
|
|
186
185
|
|
187
186
|
BUILTIN(ArrayCodeGeneric) {
|
188
|
-
|
187
|
+
Heap* heap = isolate->heap();
|
188
|
+
isolate->counters()->array_function_runtime()->Increment();
|
189
189
|
|
190
190
|
JSArray* array;
|
191
|
-
if (CalledAsConstructor()) {
|
191
|
+
if (CalledAsConstructor(isolate)) {
|
192
192
|
array = JSArray::cast(*args.receiver());
|
193
193
|
} else {
|
194
194
|
// Allocate the JS Array
|
195
195
|
JSFunction* constructor =
|
196
|
-
|
196
|
+
isolate->context()->global_context()->array_function();
|
197
197
|
Object* obj;
|
198
|
-
{ MaybeObject* maybe_obj =
|
198
|
+
{ MaybeObject* maybe_obj = heap->AllocateJSObject(constructor);
|
199
199
|
if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
200
200
|
}
|
201
201
|
array = JSArray::cast(obj);
|
@@ -212,7 +212,7 @@ BUILTIN(ArrayCodeGeneric) {
|
|
212
212
|
int len = Smi::cast(obj)->value();
|
213
213
|
if (len >= 0 && len < JSObject::kInitialMaxFastElementArray) {
|
214
214
|
Object* obj;
|
215
|
-
{ MaybeObject* maybe_obj =
|
215
|
+
{ MaybeObject* maybe_obj = heap->AllocateFixedArrayWithHoles(len);
|
216
216
|
if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
217
217
|
}
|
218
218
|
array->SetContent(FixedArray::cast(obj));
|
@@ -235,7 +235,7 @@ BUILTIN(ArrayCodeGeneric) {
|
|
235
235
|
int number_of_elements = args.length() - 1;
|
236
236
|
Smi* len = Smi::FromInt(number_of_elements);
|
237
237
|
Object* obj;
|
238
|
-
{ MaybeObject* maybe_obj =
|
238
|
+
{ MaybeObject* maybe_obj = heap->AllocateFixedArrayWithHoles(len->value());
|
239
239
|
if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
240
240
|
}
|
241
241
|
|
@@ -255,77 +255,81 @@ BUILTIN(ArrayCodeGeneric) {
|
|
255
255
|
}
|
256
256
|
|
257
257
|
|
258
|
-
MUST_USE_RESULT static MaybeObject* AllocateJSArray() {
|
258
|
+
MUST_USE_RESULT static MaybeObject* AllocateJSArray(Heap* heap) {
|
259
259
|
JSFunction* array_function =
|
260
|
-
|
260
|
+
heap->isolate()->context()->global_context()->array_function();
|
261
261
|
Object* result;
|
262
|
-
{ MaybeObject* maybe_result =
|
262
|
+
{ MaybeObject* maybe_result = heap->AllocateJSObject(array_function);
|
263
263
|
if (!maybe_result->ToObject(&result)) return maybe_result;
|
264
264
|
}
|
265
265
|
return result;
|
266
266
|
}
|
267
267
|
|
268
268
|
|
269
|
-
MUST_USE_RESULT static MaybeObject* AllocateEmptyJSArray() {
|
269
|
+
MUST_USE_RESULT static MaybeObject* AllocateEmptyJSArray(Heap* heap) {
|
270
270
|
Object* result;
|
271
|
-
{ MaybeObject* maybe_result = AllocateJSArray();
|
271
|
+
{ MaybeObject* maybe_result = AllocateJSArray(heap);
|
272
272
|
if (!maybe_result->ToObject(&result)) return maybe_result;
|
273
273
|
}
|
274
274
|
JSArray* result_array = JSArray::cast(result);
|
275
275
|
result_array->set_length(Smi::FromInt(0));
|
276
|
-
result_array->set_elements(
|
276
|
+
result_array->set_elements(heap->empty_fixed_array());
|
277
277
|
return result_array;
|
278
278
|
}
|
279
279
|
|
280
280
|
|
281
|
-
static void CopyElements(
|
281
|
+
static void CopyElements(Heap* heap,
|
282
|
+
AssertNoAllocation* no_gc,
|
282
283
|
FixedArray* dst,
|
283
284
|
int dst_index,
|
284
285
|
FixedArray* src,
|
285
286
|
int src_index,
|
286
287
|
int len) {
|
287
288
|
ASSERT(dst != src); // Use MoveElements instead.
|
288
|
-
ASSERT(dst->map() !=
|
289
|
+
ASSERT(dst->map() != HEAP->fixed_cow_array_map());
|
289
290
|
ASSERT(len > 0);
|
290
291
|
CopyWords(dst->data_start() + dst_index,
|
291
292
|
src->data_start() + src_index,
|
292
293
|
len);
|
293
294
|
WriteBarrierMode mode = dst->GetWriteBarrierMode(*no_gc);
|
294
295
|
if (mode == UPDATE_WRITE_BARRIER) {
|
295
|
-
|
296
|
+
heap->RecordWrites(dst->address(), dst->OffsetOfElementAt(dst_index), len);
|
296
297
|
}
|
297
298
|
}
|
298
299
|
|
299
300
|
|
300
|
-
static void MoveElements(
|
301
|
+
static void MoveElements(Heap* heap,
|
302
|
+
AssertNoAllocation* no_gc,
|
301
303
|
FixedArray* dst,
|
302
304
|
int dst_index,
|
303
305
|
FixedArray* src,
|
304
306
|
int src_index,
|
305
307
|
int len) {
|
306
|
-
ASSERT(dst->map() !=
|
308
|
+
ASSERT(dst->map() != HEAP->fixed_cow_array_map());
|
307
309
|
memmove(dst->data_start() + dst_index,
|
308
310
|
src->data_start() + src_index,
|
309
311
|
len * kPointerSize);
|
310
312
|
WriteBarrierMode mode = dst->GetWriteBarrierMode(*no_gc);
|
311
313
|
if (mode == UPDATE_WRITE_BARRIER) {
|
312
|
-
|
314
|
+
heap->RecordWrites(dst->address(), dst->OffsetOfElementAt(dst_index), len);
|
313
315
|
}
|
314
316
|
}
|
315
317
|
|
316
318
|
|
317
|
-
static void FillWithHoles(FixedArray* dst, int from, int to) {
|
318
|
-
ASSERT(dst->map() !=
|
319
|
-
MemsetPointer(dst->data_start() + from,
|
319
|
+
static void FillWithHoles(Heap* heap, FixedArray* dst, int from, int to) {
|
320
|
+
ASSERT(dst->map() != heap->fixed_cow_array_map());
|
321
|
+
MemsetPointer(dst->data_start() + from, heap->the_hole_value(), to - from);
|
320
322
|
}
|
321
323
|
|
322
324
|
|
323
|
-
static FixedArray* LeftTrimFixedArray(
|
324
|
-
|
325
|
+
static FixedArray* LeftTrimFixedArray(Heap* heap,
|
326
|
+
FixedArray* elms,
|
327
|
+
int to_trim) {
|
328
|
+
ASSERT(elms->map() != HEAP->fixed_cow_array_map());
|
325
329
|
// For now this trick is only applied to fixed arrays in new and paged space.
|
326
330
|
// In large object space the object's start must coincide with chunk
|
327
331
|
// and thus the trick is just not applicable.
|
328
|
-
ASSERT(!
|
332
|
+
ASSERT(!HEAP->lo_space()->Contains(elms));
|
329
333
|
|
330
334
|
STATIC_ASSERT(FixedArray::kMapOffset == 0);
|
331
335
|
STATIC_ASSERT(FixedArray::kLengthOffset == kPointerSize);
|
@@ -336,7 +340,7 @@ static FixedArray* LeftTrimFixedArray(FixedArray* elms, int to_trim) {
|
|
336
340
|
const int len = elms->length();
|
337
341
|
|
338
342
|
if (to_trim > FixedArray::kHeaderSize / kPointerSize &&
|
339
|
-
!
|
343
|
+
!heap->new_space()->Contains(elms)) {
|
340
344
|
// If we are doing a big trim in old space then we zap the space that was
|
341
345
|
// formerly part of the array so that the GC (aided by the card-based
|
342
346
|
// remembered set) won't find pointers to new-space there.
|
@@ -349,9 +353,9 @@ static FixedArray* LeftTrimFixedArray(FixedArray* elms, int to_trim) {
|
|
349
353
|
// Technically in new space this write might be omitted (except for
|
350
354
|
// debug mode which iterates through the heap), but to play safer
|
351
355
|
// we still do it.
|
352
|
-
|
356
|
+
heap->CreateFillerObjectAt(elms->address(), to_trim * kPointerSize);
|
353
357
|
|
354
|
-
former_start[to_trim] =
|
358
|
+
former_start[to_trim] = heap->fixed_array_map();
|
355
359
|
former_start[to_trim + 1] = Smi::FromInt(len - to_trim);
|
356
360
|
|
357
361
|
return FixedArray::cast(HeapObject::FromAddress(
|
@@ -359,20 +363,21 @@ static FixedArray* LeftTrimFixedArray(FixedArray* elms, int to_trim) {
|
|
359
363
|
}
|
360
364
|
|
361
365
|
|
362
|
-
static bool ArrayPrototypeHasNoElements(
|
366
|
+
static bool ArrayPrototypeHasNoElements(Heap* heap,
|
367
|
+
Context* global_context,
|
363
368
|
JSObject* array_proto) {
|
364
369
|
// This method depends on non writability of Object and Array prototype
|
365
370
|
// fields.
|
366
|
-
if (array_proto->elements() !=
|
371
|
+
if (array_proto->elements() != heap->empty_fixed_array()) return false;
|
367
372
|
// Hidden prototype
|
368
373
|
array_proto = JSObject::cast(array_proto->GetPrototype());
|
369
|
-
ASSERT(array_proto->elements() ==
|
374
|
+
ASSERT(array_proto->elements() == heap->empty_fixed_array());
|
370
375
|
// Object.prototype
|
371
376
|
Object* proto = array_proto->GetPrototype();
|
372
|
-
if (proto ==
|
377
|
+
if (proto == heap->null_value()) return false;
|
373
378
|
array_proto = JSObject::cast(proto);
|
374
379
|
if (array_proto != global_context->initial_object_prototype()) return false;
|
375
|
-
if (array_proto->elements() !=
|
380
|
+
if (array_proto->elements() != heap->empty_fixed_array()) return false;
|
376
381
|
ASSERT(array_proto->GetPrototype()->IsNull());
|
377
382
|
return true;
|
378
383
|
}
|
@@ -380,35 +385,38 @@ static bool ArrayPrototypeHasNoElements(Context* global_context,
|
|
380
385
|
|
381
386
|
MUST_USE_RESULT
|
382
387
|
static inline MaybeObject* EnsureJSArrayWithWritableFastElements(
|
383
|
-
Object* receiver) {
|
388
|
+
Heap* heap, Object* receiver) {
|
384
389
|
if (!receiver->IsJSArray()) return NULL;
|
385
390
|
JSArray* array = JSArray::cast(receiver);
|
386
391
|
HeapObject* elms = array->elements();
|
387
|
-
if (elms->map() ==
|
388
|
-
if (elms->map() ==
|
392
|
+
if (elms->map() == heap->fixed_array_map()) return elms;
|
393
|
+
if (elms->map() == heap->fixed_cow_array_map()) {
|
389
394
|
return array->EnsureWritableFastElements();
|
390
395
|
}
|
391
396
|
return NULL;
|
392
397
|
}
|
393
398
|
|
394
399
|
|
395
|
-
static inline bool IsJSArrayFastElementMovingAllowed(
|
396
|
-
|
400
|
+
static inline bool IsJSArrayFastElementMovingAllowed(Heap* heap,
|
401
|
+
JSArray* receiver) {
|
402
|
+
Context* global_context = heap->isolate()->context()->global_context();
|
397
403
|
JSObject* array_proto =
|
398
404
|
JSObject::cast(global_context->array_function()->prototype());
|
399
405
|
return receiver->GetPrototype() == array_proto &&
|
400
|
-
ArrayPrototypeHasNoElements(global_context, array_proto);
|
406
|
+
ArrayPrototypeHasNoElements(heap, global_context, array_proto);
|
401
407
|
}
|
402
408
|
|
403
409
|
|
404
410
|
MUST_USE_RESULT static MaybeObject* CallJsBuiltin(
|
411
|
+
Isolate* isolate,
|
405
412
|
const char* name,
|
406
413
|
BuiltinArguments<NO_EXTRA_ARGUMENTS> args) {
|
407
|
-
HandleScope handleScope;
|
414
|
+
HandleScope handleScope(isolate);
|
408
415
|
|
409
416
|
Handle<Object> js_builtin =
|
410
|
-
GetProperty(Handle<JSObject>(
|
411
|
-
|
417
|
+
GetProperty(Handle<JSObject>(
|
418
|
+
isolate->global_context()->builtins()),
|
419
|
+
name);
|
412
420
|
ASSERT(js_builtin->IsJSFunction());
|
413
421
|
Handle<JSFunction> function(Handle<JSFunction>::cast(js_builtin));
|
414
422
|
ScopedVector<Object**> argv(args.length() - 1);
|
@@ -428,11 +436,14 @@ MUST_USE_RESULT static MaybeObject* CallJsBuiltin(
|
|
428
436
|
|
429
437
|
|
430
438
|
BUILTIN(ArrayPush) {
|
439
|
+
Heap* heap = isolate->heap();
|
431
440
|
Object* receiver = *args.receiver();
|
432
441
|
Object* elms_obj;
|
433
442
|
{ MaybeObject* maybe_elms_obj =
|
434
|
-
EnsureJSArrayWithWritableFastElements(receiver);
|
435
|
-
if (maybe_elms_obj == NULL)
|
443
|
+
EnsureJSArrayWithWritableFastElements(heap, receiver);
|
444
|
+
if (maybe_elms_obj == NULL) {
|
445
|
+
return CallJsBuiltin(isolate, "ArrayPush", args);
|
446
|
+
}
|
436
447
|
if (!maybe_elms_obj->ToObject(&elms_obj)) return maybe_elms_obj;
|
437
448
|
}
|
438
449
|
FixedArray* elms = FixedArray::cast(elms_obj);
|
@@ -453,16 +464,16 @@ BUILTIN(ArrayPush) {
|
|
453
464
|
// New backing storage is needed.
|
454
465
|
int capacity = new_length + (new_length >> 1) + 16;
|
455
466
|
Object* obj;
|
456
|
-
{ MaybeObject* maybe_obj =
|
467
|
+
{ MaybeObject* maybe_obj = heap->AllocateUninitializedFixedArray(capacity);
|
457
468
|
if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
458
469
|
}
|
459
470
|
FixedArray* new_elms = FixedArray::cast(obj);
|
460
471
|
|
461
472
|
AssertNoAllocation no_gc;
|
462
473
|
if (len > 0) {
|
463
|
-
CopyElements(&no_gc, new_elms, 0, elms, 0, len);
|
474
|
+
CopyElements(heap, &no_gc, new_elms, 0, elms, 0, len);
|
464
475
|
}
|
465
|
-
FillWithHoles(new_elms, new_length, capacity);
|
476
|
+
FillWithHoles(heap, new_elms, new_length, capacity);
|
466
477
|
|
467
478
|
elms = new_elms;
|
468
479
|
array->set_elements(elms);
|
@@ -482,18 +493,19 @@ BUILTIN(ArrayPush) {
|
|
482
493
|
|
483
494
|
|
484
495
|
BUILTIN(ArrayPop) {
|
496
|
+
Heap* heap = isolate->heap();
|
485
497
|
Object* receiver = *args.receiver();
|
486
498
|
Object* elms_obj;
|
487
499
|
{ MaybeObject* maybe_elms_obj =
|
488
|
-
EnsureJSArrayWithWritableFastElements(receiver);
|
489
|
-
if (maybe_elms_obj == NULL) return CallJsBuiltin("ArrayPop", args);
|
500
|
+
EnsureJSArrayWithWritableFastElements(heap, receiver);
|
501
|
+
if (maybe_elms_obj == NULL) return CallJsBuiltin(isolate, "ArrayPop", args);
|
490
502
|
if (!maybe_elms_obj->ToObject(&elms_obj)) return maybe_elms_obj;
|
491
503
|
}
|
492
504
|
FixedArray* elms = FixedArray::cast(elms_obj);
|
493
505
|
JSArray* array = JSArray::cast(receiver);
|
494
506
|
|
495
507
|
int len = Smi::cast(array->length())->value();
|
496
|
-
if (len == 0) return
|
508
|
+
if (len == 0) return heap->undefined_value();
|
497
509
|
|
498
510
|
// Get top element
|
499
511
|
MaybeObject* top = elms->get(len - 1);
|
@@ -514,38 +526,40 @@ BUILTIN(ArrayPop) {
|
|
514
526
|
|
515
527
|
|
516
528
|
BUILTIN(ArrayShift) {
|
529
|
+
Heap* heap = isolate->heap();
|
517
530
|
Object* receiver = *args.receiver();
|
518
531
|
Object* elms_obj;
|
519
532
|
{ MaybeObject* maybe_elms_obj =
|
520
|
-
EnsureJSArrayWithWritableFastElements(receiver);
|
521
|
-
if (maybe_elms_obj == NULL)
|
533
|
+
EnsureJSArrayWithWritableFastElements(heap, receiver);
|
534
|
+
if (maybe_elms_obj == NULL)
|
535
|
+
return CallJsBuiltin(isolate, "ArrayShift", args);
|
522
536
|
if (!maybe_elms_obj->ToObject(&elms_obj)) return maybe_elms_obj;
|
523
537
|
}
|
524
|
-
if (!IsJSArrayFastElementMovingAllowed(JSArray::cast(receiver))) {
|
525
|
-
return CallJsBuiltin("ArrayShift", args);
|
538
|
+
if (!IsJSArrayFastElementMovingAllowed(heap, JSArray::cast(receiver))) {
|
539
|
+
return CallJsBuiltin(isolate, "ArrayShift", args);
|
526
540
|
}
|
527
541
|
FixedArray* elms = FixedArray::cast(elms_obj);
|
528
542
|
JSArray* array = JSArray::cast(receiver);
|
529
543
|
ASSERT(array->HasFastElements());
|
530
544
|
|
531
545
|
int len = Smi::cast(array->length())->value();
|
532
|
-
if (len == 0) return
|
546
|
+
if (len == 0) return heap->undefined_value();
|
533
547
|
|
534
548
|
// Get first element
|
535
549
|
Object* first = elms->get(0);
|
536
550
|
if (first->IsTheHole()) {
|
537
|
-
first =
|
551
|
+
first = heap->undefined_value();
|
538
552
|
}
|
539
553
|
|
540
|
-
if (!
|
554
|
+
if (!heap->lo_space()->Contains(elms)) {
|
541
555
|
// As elms still in the same space they used to be,
|
542
556
|
// there is no need to update region dirty mark.
|
543
|
-
array->set_elements(LeftTrimFixedArray(elms, 1), SKIP_WRITE_BARRIER);
|
557
|
+
array->set_elements(LeftTrimFixedArray(heap, elms, 1), SKIP_WRITE_BARRIER);
|
544
558
|
} else {
|
545
559
|
// Shift the elements.
|
546
560
|
AssertNoAllocation no_gc;
|
547
|
-
MoveElements(&no_gc, elms, 0, elms, 1, len - 1);
|
548
|
-
elms->set(len - 1,
|
561
|
+
MoveElements(heap, &no_gc, elms, 0, elms, 1, len - 1);
|
562
|
+
elms->set(len - 1, heap->the_hole_value());
|
549
563
|
}
|
550
564
|
|
551
565
|
// Set the length.
|
@@ -556,15 +570,17 @@ BUILTIN(ArrayShift) {
|
|
556
570
|
|
557
571
|
|
558
572
|
BUILTIN(ArrayUnshift) {
|
573
|
+
Heap* heap = isolate->heap();
|
559
574
|
Object* receiver = *args.receiver();
|
560
575
|
Object* elms_obj;
|
561
576
|
{ MaybeObject* maybe_elms_obj =
|
562
|
-
EnsureJSArrayWithWritableFastElements(receiver);
|
563
|
-
if (maybe_elms_obj == NULL)
|
577
|
+
EnsureJSArrayWithWritableFastElements(heap, receiver);
|
578
|
+
if (maybe_elms_obj == NULL)
|
579
|
+
return CallJsBuiltin(isolate, "ArrayUnshift", args);
|
564
580
|
if (!maybe_elms_obj->ToObject(&elms_obj)) return maybe_elms_obj;
|
565
581
|
}
|
566
|
-
if (!IsJSArrayFastElementMovingAllowed(JSArray::cast(receiver))) {
|
567
|
-
return CallJsBuiltin("ArrayUnshift", args);
|
582
|
+
if (!IsJSArrayFastElementMovingAllowed(heap, JSArray::cast(receiver))) {
|
583
|
+
return CallJsBuiltin(isolate, "ArrayUnshift", args);
|
568
584
|
}
|
569
585
|
FixedArray* elms = FixedArray::cast(elms_obj);
|
570
586
|
JSArray* array = JSArray::cast(receiver);
|
@@ -581,22 +597,22 @@ BUILTIN(ArrayUnshift) {
|
|
581
597
|
// New backing storage is needed.
|
582
598
|
int capacity = new_length + (new_length >> 1) + 16;
|
583
599
|
Object* obj;
|
584
|
-
{ MaybeObject* maybe_obj =
|
600
|
+
{ MaybeObject* maybe_obj = heap->AllocateUninitializedFixedArray(capacity);
|
585
601
|
if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
586
602
|
}
|
587
603
|
FixedArray* new_elms = FixedArray::cast(obj);
|
588
604
|
|
589
605
|
AssertNoAllocation no_gc;
|
590
606
|
if (len > 0) {
|
591
|
-
CopyElements(&no_gc, new_elms, to_add, elms, 0, len);
|
607
|
+
CopyElements(heap, &no_gc, new_elms, to_add, elms, 0, len);
|
592
608
|
}
|
593
|
-
FillWithHoles(new_elms, new_length, capacity);
|
609
|
+
FillWithHoles(heap, new_elms, new_length, capacity);
|
594
610
|
|
595
611
|
elms = new_elms;
|
596
612
|
array->set_elements(elms);
|
597
613
|
} else {
|
598
614
|
AssertNoAllocation no_gc;
|
599
|
-
MoveElements(&no_gc, elms, to_add, elms, 0, len);
|
615
|
+
MoveElements(heap, &no_gc, elms, to_add, elms, 0, len);
|
600
616
|
}
|
601
617
|
|
602
618
|
// Add the provided values.
|
@@ -613,14 +629,15 @@ BUILTIN(ArrayUnshift) {
|
|
613
629
|
|
614
630
|
|
615
631
|
BUILTIN(ArraySlice) {
|
632
|
+
Heap* heap = isolate->heap();
|
616
633
|
Object* receiver = *args.receiver();
|
617
634
|
FixedArray* elms;
|
618
635
|
int len = -1;
|
619
636
|
if (receiver->IsJSArray()) {
|
620
637
|
JSArray* array = JSArray::cast(receiver);
|
621
638
|
if (!array->HasFastElements() ||
|
622
|
-
!IsJSArrayFastElementMovingAllowed(array)) {
|
623
|
-
return CallJsBuiltin("ArraySlice", args);
|
639
|
+
!IsJSArrayFastElementMovingAllowed(heap, array)) {
|
640
|
+
return CallJsBuiltin(isolate, "ArraySlice", args);
|
624
641
|
}
|
625
642
|
|
626
643
|
elms = FixedArray::cast(array->elements());
|
@@ -629,28 +646,28 @@ BUILTIN(ArraySlice) {
|
|
629
646
|
// Array.slice(arguments, ...) is quite a common idiom (notably more
|
630
647
|
// than 50% of invocations in Web apps). Treat it in C++ as well.
|
631
648
|
Map* arguments_map =
|
632
|
-
|
649
|
+
isolate->context()->global_context()->arguments_boilerplate()->map();
|
633
650
|
|
634
651
|
bool is_arguments_object_with_fast_elements =
|
635
652
|
receiver->IsJSObject()
|
636
653
|
&& JSObject::cast(receiver)->map() == arguments_map
|
637
654
|
&& JSObject::cast(receiver)->HasFastElements();
|
638
655
|
if (!is_arguments_object_with_fast_elements) {
|
639
|
-
return CallJsBuiltin("ArraySlice", args);
|
656
|
+
return CallJsBuiltin(isolate, "ArraySlice", args);
|
640
657
|
}
|
641
658
|
elms = FixedArray::cast(JSObject::cast(receiver)->elements());
|
642
659
|
Object* len_obj = JSObject::cast(receiver)
|
643
|
-
->InObjectPropertyAt(Heap::
|
660
|
+
->InObjectPropertyAt(Heap::kArgumentsLengthIndex);
|
644
661
|
if (!len_obj->IsSmi()) {
|
645
|
-
return CallJsBuiltin("ArraySlice", args);
|
662
|
+
return CallJsBuiltin(isolate, "ArraySlice", args);
|
646
663
|
}
|
647
664
|
len = Smi::cast(len_obj)->value();
|
648
665
|
if (len > elms->length()) {
|
649
|
-
return CallJsBuiltin("ArraySlice", args);
|
666
|
+
return CallJsBuiltin(isolate, "ArraySlice", args);
|
650
667
|
}
|
651
668
|
for (int i = 0; i < len; i++) {
|
652
|
-
if (elms->get(i) ==
|
653
|
-
return CallJsBuiltin("ArraySlice", args);
|
669
|
+
if (elms->get(i) == heap->the_hole_value()) {
|
670
|
+
return CallJsBuiltin(isolate, "ArraySlice", args);
|
654
671
|
}
|
655
672
|
}
|
656
673
|
}
|
@@ -667,14 +684,14 @@ BUILTIN(ArraySlice) {
|
|
667
684
|
if (arg1->IsSmi()) {
|
668
685
|
relative_start = Smi::cast(arg1)->value();
|
669
686
|
} else if (!arg1->IsUndefined()) {
|
670
|
-
return CallJsBuiltin("ArraySlice", args);
|
687
|
+
return CallJsBuiltin(isolate, "ArraySlice", args);
|
671
688
|
}
|
672
689
|
if (n_arguments > 1) {
|
673
690
|
Object* arg2 = args[2];
|
674
691
|
if (arg2->IsSmi()) {
|
675
692
|
relative_end = Smi::cast(arg2)->value();
|
676
693
|
} else if (!arg2->IsUndefined()) {
|
677
|
-
return CallJsBuiltin("ArraySlice", args);
|
694
|
+
return CallJsBuiltin(isolate, "ArraySlice", args);
|
678
695
|
}
|
679
696
|
}
|
680
697
|
}
|
@@ -690,23 +707,23 @@ BUILTIN(ArraySlice) {
|
|
690
707
|
// Calculate the length of result array.
|
691
708
|
int result_len = final - k;
|
692
709
|
if (result_len <= 0) {
|
693
|
-
return AllocateEmptyJSArray();
|
710
|
+
return AllocateEmptyJSArray(heap);
|
694
711
|
}
|
695
712
|
|
696
713
|
Object* result;
|
697
|
-
{ MaybeObject* maybe_result = AllocateJSArray();
|
714
|
+
{ MaybeObject* maybe_result = AllocateJSArray(heap);
|
698
715
|
if (!maybe_result->ToObject(&result)) return maybe_result;
|
699
716
|
}
|
700
717
|
JSArray* result_array = JSArray::cast(result);
|
701
718
|
|
702
719
|
{ MaybeObject* maybe_result =
|
703
|
-
|
720
|
+
heap->AllocateUninitializedFixedArray(result_len);
|
704
721
|
if (!maybe_result->ToObject(&result)) return maybe_result;
|
705
722
|
}
|
706
723
|
FixedArray* result_elms = FixedArray::cast(result);
|
707
724
|
|
708
725
|
AssertNoAllocation no_gc;
|
709
|
-
CopyElements(&no_gc, result_elms, 0, elms, k, result_len);
|
726
|
+
CopyElements(heap, &no_gc, result_elms, 0, elms, k, result_len);
|
710
727
|
|
711
728
|
// Set elements.
|
712
729
|
result_array->set_elements(result_elms);
|
@@ -718,15 +735,17 @@ BUILTIN(ArraySlice) {
|
|
718
735
|
|
719
736
|
|
720
737
|
BUILTIN(ArraySplice) {
|
738
|
+
Heap* heap = isolate->heap();
|
721
739
|
Object* receiver = *args.receiver();
|
722
740
|
Object* elms_obj;
|
723
741
|
{ MaybeObject* maybe_elms_obj =
|
724
|
-
EnsureJSArrayWithWritableFastElements(receiver);
|
725
|
-
if (maybe_elms_obj == NULL)
|
742
|
+
EnsureJSArrayWithWritableFastElements(heap, receiver);
|
743
|
+
if (maybe_elms_obj == NULL)
|
744
|
+
return CallJsBuiltin(isolate, "ArraySplice", args);
|
726
745
|
if (!maybe_elms_obj->ToObject(&elms_obj)) return maybe_elms_obj;
|
727
746
|
}
|
728
|
-
if (!IsJSArrayFastElementMovingAllowed(JSArray::cast(receiver))) {
|
729
|
-
return CallJsBuiltin("ArraySplice", args);
|
747
|
+
if (!IsJSArrayFastElementMovingAllowed(heap, JSArray::cast(receiver))) {
|
748
|
+
return CallJsBuiltin(isolate, "ArraySplice", args);
|
730
749
|
}
|
731
750
|
FixedArray* elms = FixedArray::cast(elms_obj);
|
732
751
|
JSArray* array = JSArray::cast(receiver);
|
@@ -742,7 +761,7 @@ BUILTIN(ArraySplice) {
|
|
742
761
|
if (arg1->IsSmi()) {
|
743
762
|
relative_start = Smi::cast(arg1)->value();
|
744
763
|
} else if (!arg1->IsUndefined()) {
|
745
|
-
return CallJsBuiltin("ArraySplice", args);
|
764
|
+
return CallJsBuiltin(isolate, "ArraySplice", args);
|
746
765
|
}
|
747
766
|
}
|
748
767
|
int actual_start = (relative_start < 0) ? Max(len + relative_start, 0)
|
@@ -764,7 +783,7 @@ BUILTIN(ArraySplice) {
|
|
764
783
|
if (arg2->IsSmi()) {
|
765
784
|
value = Smi::cast(arg2)->value();
|
766
785
|
} else {
|
767
|
-
return CallJsBuiltin("ArraySplice", args);
|
786
|
+
return CallJsBuiltin(isolate, "ArraySplice", args);
|
768
787
|
}
|
769
788
|
}
|
770
789
|
actual_delete_count = Min(Max(value, 0), len - actual_start);
|
@@ -773,27 +792,28 @@ BUILTIN(ArraySplice) {
|
|
773
792
|
JSArray* result_array = NULL;
|
774
793
|
if (actual_delete_count == 0) {
|
775
794
|
Object* result;
|
776
|
-
{ MaybeObject* maybe_result = AllocateEmptyJSArray();
|
795
|
+
{ MaybeObject* maybe_result = AllocateEmptyJSArray(heap);
|
777
796
|
if (!maybe_result->ToObject(&result)) return maybe_result;
|
778
797
|
}
|
779
798
|
result_array = JSArray::cast(result);
|
780
799
|
} else {
|
781
800
|
// Allocate result array.
|
782
801
|
Object* result;
|
783
|
-
{ MaybeObject* maybe_result = AllocateJSArray();
|
802
|
+
{ MaybeObject* maybe_result = AllocateJSArray(heap);
|
784
803
|
if (!maybe_result->ToObject(&result)) return maybe_result;
|
785
804
|
}
|
786
805
|
result_array = JSArray::cast(result);
|
787
806
|
|
788
807
|
{ MaybeObject* maybe_result =
|
789
|
-
|
808
|
+
heap->AllocateUninitializedFixedArray(actual_delete_count);
|
790
809
|
if (!maybe_result->ToObject(&result)) return maybe_result;
|
791
810
|
}
|
792
811
|
FixedArray* result_elms = FixedArray::cast(result);
|
793
812
|
|
794
813
|
AssertNoAllocation no_gc;
|
795
814
|
// Fill newly created array.
|
796
|
-
CopyElements(
|
815
|
+
CopyElements(heap,
|
816
|
+
&no_gc,
|
797
817
|
result_elms, 0,
|
798
818
|
elms, actual_start,
|
799
819
|
actual_delete_count);
|
@@ -811,7 +831,7 @@ BUILTIN(ArraySplice) {
|
|
811
831
|
|
812
832
|
if (item_count < actual_delete_count) {
|
813
833
|
// Shrink the array.
|
814
|
-
const bool trim_array = !
|
834
|
+
const bool trim_array = !heap->lo_space()->Contains(elms) &&
|
815
835
|
((actual_start + item_count) <
|
816
836
|
(len - actual_delete_count - actual_start));
|
817
837
|
if (trim_array) {
|
@@ -822,15 +842,15 @@ BUILTIN(ArraySplice) {
|
|
822
842
|
memmove(start + delta, start, actual_start * kPointerSize);
|
823
843
|
}
|
824
844
|
|
825
|
-
elms = LeftTrimFixedArray(elms, delta);
|
845
|
+
elms = LeftTrimFixedArray(heap, elms, delta);
|
826
846
|
array->set_elements(elms, SKIP_WRITE_BARRIER);
|
827
847
|
} else {
|
828
848
|
AssertNoAllocation no_gc;
|
829
|
-
MoveElements(&no_gc,
|
849
|
+
MoveElements(heap, &no_gc,
|
830
850
|
elms, actual_start + item_count,
|
831
851
|
elms, actual_start + actual_delete_count,
|
832
852
|
(len - actual_delete_count - actual_start));
|
833
|
-
FillWithHoles(elms, new_length, len);
|
853
|
+
FillWithHoles(heap, elms, new_length, len);
|
834
854
|
}
|
835
855
|
} else if (item_count > actual_delete_count) {
|
836
856
|
// Currently fixed arrays cannot grow too big, so
|
@@ -843,7 +863,7 @@ BUILTIN(ArraySplice) {
|
|
843
863
|
int capacity = new_length + (new_length >> 1) + 16;
|
844
864
|
Object* obj;
|
845
865
|
{ MaybeObject* maybe_obj =
|
846
|
-
|
866
|
+
heap->AllocateUninitializedFixedArray(capacity);
|
847
867
|
if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
848
868
|
}
|
849
869
|
FixedArray* new_elms = FixedArray::cast(obj);
|
@@ -851,22 +871,22 @@ BUILTIN(ArraySplice) {
|
|
851
871
|
AssertNoAllocation no_gc;
|
852
872
|
// Copy the part before actual_start as is.
|
853
873
|
if (actual_start > 0) {
|
854
|
-
CopyElements(&no_gc, new_elms, 0, elms, 0, actual_start);
|
874
|
+
CopyElements(heap, &no_gc, new_elms, 0, elms, 0, actual_start);
|
855
875
|
}
|
856
876
|
const int to_copy = len - actual_delete_count - actual_start;
|
857
877
|
if (to_copy > 0) {
|
858
|
-
CopyElements(&no_gc,
|
878
|
+
CopyElements(heap, &no_gc,
|
859
879
|
new_elms, actual_start + item_count,
|
860
880
|
elms, actual_start + actual_delete_count,
|
861
881
|
to_copy);
|
862
882
|
}
|
863
|
-
FillWithHoles(new_elms, new_length, capacity);
|
883
|
+
FillWithHoles(heap, new_elms, new_length, capacity);
|
864
884
|
|
865
885
|
elms = new_elms;
|
866
886
|
array->set_elements(elms);
|
867
887
|
} else {
|
868
888
|
AssertNoAllocation no_gc;
|
869
|
-
MoveElements(&no_gc,
|
889
|
+
MoveElements(heap, &no_gc,
|
870
890
|
elms, actual_start + item_count,
|
871
891
|
elms, actual_start + actual_delete_count,
|
872
892
|
(len - actual_delete_count - actual_start));
|
@@ -887,11 +907,12 @@ BUILTIN(ArraySplice) {
|
|
887
907
|
|
888
908
|
|
889
909
|
BUILTIN(ArrayConcat) {
|
890
|
-
|
910
|
+
Heap* heap = isolate->heap();
|
911
|
+
Context* global_context = isolate->context()->global_context();
|
891
912
|
JSObject* array_proto =
|
892
913
|
JSObject::cast(global_context->array_function()->prototype());
|
893
|
-
if (!ArrayPrototypeHasNoElements(global_context, array_proto)) {
|
894
|
-
return CallJsBuiltin("ArrayConcat", args);
|
914
|
+
if (!ArrayPrototypeHasNoElements(heap, global_context, array_proto)) {
|
915
|
+
return CallJsBuiltin(isolate, "ArrayConcat", args);
|
895
916
|
}
|
896
917
|
|
897
918
|
// Iterate through all the arguments performing checks
|
@@ -902,7 +923,7 @@ BUILTIN(ArrayConcat) {
|
|
902
923
|
Object* arg = args[i];
|
903
924
|
if (!arg->IsJSArray() || !JSArray::cast(arg)->HasFastElements()
|
904
925
|
|| JSArray::cast(arg)->GetPrototype() != array_proto) {
|
905
|
-
return CallJsBuiltin("ArrayConcat", args);
|
926
|
+
return CallJsBuiltin(isolate, "ArrayConcat", args);
|
906
927
|
}
|
907
928
|
|
908
929
|
int len = Smi::cast(JSArray::cast(arg)->length())->value();
|
@@ -915,23 +936,23 @@ BUILTIN(ArrayConcat) {
|
|
915
936
|
ASSERT(result_len >= 0);
|
916
937
|
|
917
938
|
if (result_len > FixedArray::kMaxLength) {
|
918
|
-
return CallJsBuiltin("ArrayConcat", args);
|
939
|
+
return CallJsBuiltin(isolate, "ArrayConcat", args);
|
919
940
|
}
|
920
941
|
}
|
921
942
|
|
922
943
|
if (result_len == 0) {
|
923
|
-
return AllocateEmptyJSArray();
|
944
|
+
return AllocateEmptyJSArray(heap);
|
924
945
|
}
|
925
946
|
|
926
947
|
// Allocate result.
|
927
948
|
Object* result;
|
928
|
-
{ MaybeObject* maybe_result = AllocateJSArray();
|
949
|
+
{ MaybeObject* maybe_result = AllocateJSArray(heap);
|
929
950
|
if (!maybe_result->ToObject(&result)) return maybe_result;
|
930
951
|
}
|
931
952
|
JSArray* result_array = JSArray::cast(result);
|
932
953
|
|
933
954
|
{ MaybeObject* maybe_result =
|
934
|
-
|
955
|
+
heap->AllocateUninitializedFixedArray(result_len);
|
935
956
|
if (!maybe_result->ToObject(&result)) return maybe_result;
|
936
957
|
}
|
937
958
|
FixedArray* result_elms = FixedArray::cast(result);
|
@@ -944,7 +965,7 @@ BUILTIN(ArrayConcat) {
|
|
944
965
|
int len = Smi::cast(array->length())->value();
|
945
966
|
if (len > 0) {
|
946
967
|
FixedArray* elms = FixedArray::cast(array->elements());
|
947
|
-
CopyElements(&no_gc, result_elms, start_pos, elms, 0, len);
|
968
|
+
CopyElements(heap, &no_gc, result_elms, start_pos, elms, 0, len);
|
948
969
|
start_pos += len;
|
949
970
|
}
|
950
971
|
}
|
@@ -958,6 +979,38 @@ BUILTIN(ArrayConcat) {
|
|
958
979
|
}
|
959
980
|
|
960
981
|
|
982
|
+
// -----------------------------------------------------------------------------
|
983
|
+
// Strict mode poison pills
|
984
|
+
|
985
|
+
|
986
|
+
BUILTIN(StrictArgumentsCallee) {
|
987
|
+
HandleScope scope;
|
988
|
+
return isolate->Throw(*isolate->factory()->NewTypeError(
|
989
|
+
"strict_arguments_callee", HandleVector<Object>(NULL, 0)));
|
990
|
+
}
|
991
|
+
|
992
|
+
|
993
|
+
BUILTIN(StrictArgumentsCaller) {
|
994
|
+
HandleScope scope;
|
995
|
+
return isolate->Throw(*isolate->factory()->NewTypeError(
|
996
|
+
"strict_arguments_caller", HandleVector<Object>(NULL, 0)));
|
997
|
+
}
|
998
|
+
|
999
|
+
|
1000
|
+
BUILTIN(StrictFunctionCaller) {
|
1001
|
+
HandleScope scope;
|
1002
|
+
return isolate->Throw(*isolate->factory()->NewTypeError(
|
1003
|
+
"strict_function_caller", HandleVector<Object>(NULL, 0)));
|
1004
|
+
}
|
1005
|
+
|
1006
|
+
|
1007
|
+
BUILTIN(StrictFunctionArguments) {
|
1008
|
+
HandleScope scope;
|
1009
|
+
return isolate->Throw(*isolate->factory()->NewTypeError(
|
1010
|
+
"strict_function_arguments", HandleVector<Object>(NULL, 0)));
|
1011
|
+
}
|
1012
|
+
|
1013
|
+
|
961
1014
|
// -----------------------------------------------------------------------------
|
962
1015
|
//
|
963
1016
|
|
@@ -968,7 +1021,8 @@ BUILTIN(ArrayConcat) {
|
|
968
1021
|
// overwritten with undefined. Arguments that do fit the expected
|
969
1022
|
// type is overwritten with the object in the prototype chain that
|
970
1023
|
// actually has that type.
|
971
|
-
static inline Object* TypeCheck(
|
1024
|
+
static inline Object* TypeCheck(Heap* heap,
|
1025
|
+
int argc,
|
972
1026
|
Object** argv,
|
973
1027
|
FunctionTemplateInfo* info) {
|
974
1028
|
Object* recv = argv[0];
|
@@ -980,12 +1034,12 @@ static inline Object* TypeCheck(int argc,
|
|
980
1034
|
|
981
1035
|
Object* holder = recv;
|
982
1036
|
if (!recv_type->IsUndefined()) {
|
983
|
-
for (; holder !=
|
1037
|
+
for (; holder != heap->null_value(); holder = holder->GetPrototype()) {
|
984
1038
|
if (holder->IsInstanceOf(FunctionTemplateInfo::cast(recv_type))) {
|
985
1039
|
break;
|
986
1040
|
}
|
987
1041
|
}
|
988
|
-
if (holder ==
|
1042
|
+
if (holder == heap->null_value()) return holder;
|
989
1043
|
}
|
990
1044
|
Object* args_obj = sig->args();
|
991
1045
|
// If there is no argument signature we're done
|
@@ -998,13 +1052,13 @@ static inline Object* TypeCheck(int argc,
|
|
998
1052
|
if (argtype->IsUndefined()) continue;
|
999
1053
|
Object** arg = &argv[-1 - i];
|
1000
1054
|
Object* current = *arg;
|
1001
|
-
for (; current !=
|
1055
|
+
for (; current != heap->null_value(); current = current->GetPrototype()) {
|
1002
1056
|
if (current->IsInstanceOf(FunctionTemplateInfo::cast(argtype))) {
|
1003
1057
|
*arg = current;
|
1004
1058
|
break;
|
1005
1059
|
}
|
1006
1060
|
}
|
1007
|
-
if (current ==
|
1061
|
+
if (current == heap->null_value()) *arg = heap->undefined_value();
|
1008
1062
|
}
|
1009
1063
|
return holder;
|
1010
1064
|
}
|
@@ -1012,31 +1066,33 @@ static inline Object* TypeCheck(int argc,
|
|
1012
1066
|
|
1013
1067
|
template <bool is_construct>
|
1014
1068
|
MUST_USE_RESULT static MaybeObject* HandleApiCallHelper(
|
1015
|
-
BuiltinArguments<NEEDS_CALLED_FUNCTION> args) {
|
1016
|
-
ASSERT(is_construct == CalledAsConstructor());
|
1069
|
+
BuiltinArguments<NEEDS_CALLED_FUNCTION> args, Isolate* isolate) {
|
1070
|
+
ASSERT(is_construct == CalledAsConstructor(isolate));
|
1071
|
+
Heap* heap = isolate->heap();
|
1017
1072
|
|
1018
|
-
HandleScope scope;
|
1073
|
+
HandleScope scope(isolate);
|
1019
1074
|
Handle<JSFunction> function = args.called_function();
|
1020
1075
|
ASSERT(function->shared()->IsApiFunction());
|
1021
1076
|
|
1022
1077
|
FunctionTemplateInfo* fun_data = function->shared()->get_api_func_data();
|
1023
1078
|
if (is_construct) {
|
1024
|
-
Handle<FunctionTemplateInfo> desc(fun_data);
|
1079
|
+
Handle<FunctionTemplateInfo> desc(fun_data, isolate);
|
1025
1080
|
bool pending_exception = false;
|
1026
|
-
|
1027
|
-
|
1028
|
-
ASSERT(
|
1081
|
+
isolate->factory()->ConfigureInstance(
|
1082
|
+
desc, Handle<JSObject>::cast(args.receiver()), &pending_exception);
|
1083
|
+
ASSERT(isolate->has_pending_exception() == pending_exception);
|
1029
1084
|
if (pending_exception) return Failure::Exception();
|
1030
1085
|
fun_data = *desc;
|
1031
1086
|
}
|
1032
1087
|
|
1033
|
-
Object* raw_holder = TypeCheck(args.length(), &args[0], fun_data);
|
1088
|
+
Object* raw_holder = TypeCheck(heap, args.length(), &args[0], fun_data);
|
1034
1089
|
|
1035
1090
|
if (raw_holder->IsNull()) {
|
1036
1091
|
// This function cannot be called with the given receiver. Abort!
|
1037
1092
|
Handle<Object> obj =
|
1038
|
-
|
1039
|
-
|
1093
|
+
isolate->factory()->NewTypeError(
|
1094
|
+
"illegal_invocation", HandleVector(&function, 1));
|
1095
|
+
return isolate->Throw(*obj);
|
1040
1096
|
}
|
1041
1097
|
|
1042
1098
|
Object* raw_call_data = fun_data->call_code();
|
@@ -1048,10 +1104,10 @@ MUST_USE_RESULT static MaybeObject* HandleApiCallHelper(
|
|
1048
1104
|
Object* data_obj = call_data->data();
|
1049
1105
|
Object* result;
|
1050
1106
|
|
1051
|
-
LOG(ApiObjectAccess("call", JSObject::cast(*args.receiver())));
|
1107
|
+
LOG(isolate, ApiObjectAccess("call", JSObject::cast(*args.receiver())));
|
1052
1108
|
ASSERT(raw_holder->IsJSObject());
|
1053
1109
|
|
1054
|
-
CustomArguments custom;
|
1110
|
+
CustomArguments custom(isolate);
|
1055
1111
|
v8::ImplementationUtilities::PrepareArgumentsData(custom.end(),
|
1056
1112
|
data_obj, *function, raw_holder);
|
1057
1113
|
|
@@ -1064,17 +1120,18 @@ MUST_USE_RESULT static MaybeObject* HandleApiCallHelper(
|
|
1064
1120
|
v8::Handle<v8::Value> value;
|
1065
1121
|
{
|
1066
1122
|
// Leaving JavaScript.
|
1067
|
-
VMState state(EXTERNAL);
|
1068
|
-
ExternalCallbackScope call_scope(
|
1123
|
+
VMState state(isolate, EXTERNAL);
|
1124
|
+
ExternalCallbackScope call_scope(isolate,
|
1125
|
+
v8::ToCData<Address>(callback_obj));
|
1069
1126
|
value = callback(new_args);
|
1070
1127
|
}
|
1071
1128
|
if (value.IsEmpty()) {
|
1072
|
-
result =
|
1129
|
+
result = heap->undefined_value();
|
1073
1130
|
} else {
|
1074
1131
|
result = *reinterpret_cast<Object**>(*value);
|
1075
1132
|
}
|
1076
1133
|
|
1077
|
-
RETURN_IF_SCHEDULED_EXCEPTION();
|
1134
|
+
RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
1078
1135
|
if (!is_construct || result->IsJSObject()) return result;
|
1079
1136
|
}
|
1080
1137
|
|
@@ -1083,12 +1140,12 @@ MUST_USE_RESULT static MaybeObject* HandleApiCallHelper(
|
|
1083
1140
|
|
1084
1141
|
|
1085
1142
|
BUILTIN(HandleApiCall) {
|
1086
|
-
return HandleApiCallHelper<false>(args);
|
1143
|
+
return HandleApiCallHelper<false>(args, isolate);
|
1087
1144
|
}
|
1088
1145
|
|
1089
1146
|
|
1090
1147
|
BUILTIN(HandleApiCallConstruct) {
|
1091
|
-
return HandleApiCallHelper<true>(args);
|
1148
|
+
return HandleApiCallHelper<true>(args, isolate);
|
1092
1149
|
}
|
1093
1150
|
|
1094
1151
|
|
@@ -1110,7 +1167,8 @@ static void VerifyTypeCheck(Handle<JSObject> object,
|
|
1110
1167
|
|
1111
1168
|
|
1112
1169
|
BUILTIN(FastHandleApiCall) {
|
1113
|
-
ASSERT(!CalledAsConstructor());
|
1170
|
+
ASSERT(!CalledAsConstructor(isolate));
|
1171
|
+
Heap* heap = isolate->heap();
|
1114
1172
|
const bool is_construct = false;
|
1115
1173
|
|
1116
1174
|
// We expect four more arguments: callback, function, call data, and holder.
|
@@ -1129,25 +1187,26 @@ BUILTIN(FastHandleApiCall) {
|
|
1129
1187
|
VerifyTypeCheck(Utils::OpenHandle(*new_args.Holder()),
|
1130
1188
|
Utils::OpenHandle(*new_args.Callee()));
|
1131
1189
|
#endif
|
1132
|
-
HandleScope scope;
|
1190
|
+
HandleScope scope(isolate);
|
1133
1191
|
Object* result;
|
1134
1192
|
v8::Handle<v8::Value> value;
|
1135
1193
|
{
|
1136
1194
|
// Leaving JavaScript.
|
1137
|
-
VMState state(EXTERNAL);
|
1138
|
-
ExternalCallbackScope call_scope(
|
1195
|
+
VMState state(isolate, EXTERNAL);
|
1196
|
+
ExternalCallbackScope call_scope(isolate,
|
1197
|
+
v8::ToCData<Address>(callback_obj));
|
1139
1198
|
v8::InvocationCallback callback =
|
1140
1199
|
v8::ToCData<v8::InvocationCallback>(callback_obj);
|
1141
1200
|
|
1142
1201
|
value = callback(new_args);
|
1143
1202
|
}
|
1144
1203
|
if (value.IsEmpty()) {
|
1145
|
-
result =
|
1204
|
+
result = heap->undefined_value();
|
1146
1205
|
} else {
|
1147
1206
|
result = *reinterpret_cast<Object**>(*value);
|
1148
1207
|
}
|
1149
1208
|
|
1150
|
-
RETURN_IF_SCHEDULED_EXCEPTION();
|
1209
|
+
RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
1151
1210
|
return result;
|
1152
1211
|
}
|
1153
1212
|
|
@@ -1156,11 +1215,13 @@ BUILTIN(FastHandleApiCall) {
|
|
1156
1215
|
// API. The object can be called as either a constructor (using new) or just as
|
1157
1216
|
// a function (without new).
|
1158
1217
|
MUST_USE_RESULT static MaybeObject* HandleApiCallAsFunctionOrConstructor(
|
1218
|
+
Isolate* isolate,
|
1159
1219
|
bool is_construct_call,
|
1160
1220
|
BuiltinArguments<NO_EXTRA_ARGUMENTS> args) {
|
1161
1221
|
// Non-functions are never called as constructors. Even if this is an object
|
1162
1222
|
// called as a constructor the delegate call is not a construct call.
|
1163
|
-
ASSERT(!CalledAsConstructor());
|
1223
|
+
ASSERT(!CalledAsConstructor(isolate));
|
1224
|
+
Heap* heap = isolate->heap();
|
1164
1225
|
|
1165
1226
|
Handle<Object> receiver = args.at<Object>(0);
|
1166
1227
|
|
@@ -1183,11 +1244,10 @@ MUST_USE_RESULT static MaybeObject* HandleApiCallAsFunctionOrConstructor(
|
|
1183
1244
|
// Get the data for the call and perform the callback.
|
1184
1245
|
Object* result;
|
1185
1246
|
{
|
1186
|
-
HandleScope scope;
|
1187
|
-
|
1188
|
-
LOG(ApiObjectAccess("call non-function", obj));
|
1247
|
+
HandleScope scope(isolate);
|
1248
|
+
LOG(isolate, ApiObjectAccess("call non-function", obj));
|
1189
1249
|
|
1190
|
-
CustomArguments custom;
|
1250
|
+
CustomArguments custom(isolate);
|
1191
1251
|
v8::ImplementationUtilities::PrepareArgumentsData(custom.end(),
|
1192
1252
|
call_data->data(), constructor, obj);
|
1193
1253
|
v8::Arguments new_args = v8::ImplementationUtilities::NewArguments(
|
@@ -1198,18 +1258,19 @@ MUST_USE_RESULT static MaybeObject* HandleApiCallAsFunctionOrConstructor(
|
|
1198
1258
|
v8::Handle<v8::Value> value;
|
1199
1259
|
{
|
1200
1260
|
// Leaving JavaScript.
|
1201
|
-
VMState state(EXTERNAL);
|
1202
|
-
ExternalCallbackScope call_scope(
|
1261
|
+
VMState state(isolate, EXTERNAL);
|
1262
|
+
ExternalCallbackScope call_scope(isolate,
|
1263
|
+
v8::ToCData<Address>(callback_obj));
|
1203
1264
|
value = callback(new_args);
|
1204
1265
|
}
|
1205
1266
|
if (value.IsEmpty()) {
|
1206
|
-
result =
|
1267
|
+
result = heap->undefined_value();
|
1207
1268
|
} else {
|
1208
1269
|
result = *reinterpret_cast<Object**>(*value);
|
1209
1270
|
}
|
1210
1271
|
}
|
1211
1272
|
// Check for exceptions and return result.
|
1212
|
-
RETURN_IF_SCHEDULED_EXCEPTION();
|
1273
|
+
RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
1213
1274
|
return result;
|
1214
1275
|
}
|
1215
1276
|
|
@@ -1217,14 +1278,14 @@ MUST_USE_RESULT static MaybeObject* HandleApiCallAsFunctionOrConstructor(
|
|
1217
1278
|
// Handle calls to non-function objects created through the API. This delegate
|
1218
1279
|
// function is used when the call is a normal function call.
|
1219
1280
|
BUILTIN(HandleApiCallAsFunction) {
|
1220
|
-
return HandleApiCallAsFunctionOrConstructor(false, args);
|
1281
|
+
return HandleApiCallAsFunctionOrConstructor(isolate, false, args);
|
1221
1282
|
}
|
1222
1283
|
|
1223
1284
|
|
1224
1285
|
// Handle calls to non-function objects created through the API. This delegate
|
1225
1286
|
// function is used when the call is a construct call.
|
1226
1287
|
BUILTIN(HandleApiCallAsConstructor) {
|
1227
|
-
return HandleApiCallAsFunctionOrConstructor(true, args);
|
1288
|
+
return HandleApiCallAsFunctionOrConstructor(isolate, true, args);
|
1228
1289
|
}
|
1229
1290
|
|
1230
1291
|
|
@@ -1328,12 +1389,12 @@ static void Generate_StoreIC_Normal_Strict(MacroAssembler* masm) {
|
|
1328
1389
|
|
1329
1390
|
|
1330
1391
|
static void Generate_StoreIC_Megamorphic(MacroAssembler* masm) {
|
1331
|
-
StoreIC::GenerateMegamorphic(masm,
|
1392
|
+
StoreIC::GenerateMegamorphic(masm, kNonStrictMode);
|
1332
1393
|
}
|
1333
1394
|
|
1334
1395
|
|
1335
1396
|
static void Generate_StoreIC_Megamorphic_Strict(MacroAssembler* masm) {
|
1336
|
-
StoreIC::GenerateMegamorphic(masm,
|
1397
|
+
StoreIC::GenerateMegamorphic(masm, kStrictMode);
|
1337
1398
|
}
|
1338
1399
|
|
1339
1400
|
|
@@ -1348,17 +1409,22 @@ static void Generate_StoreIC_ArrayLength_Strict(MacroAssembler* masm) {
|
|
1348
1409
|
|
1349
1410
|
|
1350
1411
|
static void Generate_StoreIC_GlobalProxy(MacroAssembler* masm) {
|
1351
|
-
StoreIC::GenerateGlobalProxy(masm);
|
1412
|
+
StoreIC::GenerateGlobalProxy(masm, kNonStrictMode);
|
1352
1413
|
}
|
1353
1414
|
|
1354
1415
|
|
1355
1416
|
static void Generate_StoreIC_GlobalProxy_Strict(MacroAssembler* masm) {
|
1356
|
-
StoreIC::GenerateGlobalProxy(masm);
|
1417
|
+
StoreIC::GenerateGlobalProxy(masm, kStrictMode);
|
1357
1418
|
}
|
1358
1419
|
|
1359
1420
|
|
1360
1421
|
static void Generate_KeyedStoreIC_Generic(MacroAssembler* masm) {
|
1361
|
-
KeyedStoreIC::GenerateGeneric(masm);
|
1422
|
+
KeyedStoreIC::GenerateGeneric(masm, kNonStrictMode);
|
1423
|
+
}
|
1424
|
+
|
1425
|
+
|
1426
|
+
static void Generate_KeyedStoreIC_Generic_Strict(MacroAssembler* masm) {
|
1427
|
+
KeyedStoreIC::GenerateGeneric(masm, kStrictMode);
|
1362
1428
|
}
|
1363
1429
|
|
1364
1430
|
|
@@ -1372,6 +1438,11 @@ static void Generate_KeyedStoreIC_Initialize(MacroAssembler* masm) {
|
|
1372
1438
|
}
|
1373
1439
|
|
1374
1440
|
|
1441
|
+
static void Generate_KeyedStoreIC_Initialize_Strict(MacroAssembler* masm) {
|
1442
|
+
KeyedStoreIC::GenerateInitialize(masm);
|
1443
|
+
}
|
1444
|
+
|
1445
|
+
|
1375
1446
|
#ifdef ENABLE_DEBUGGER_SUPPORT
|
1376
1447
|
static void Generate_LoadIC_DebugBreak(MacroAssembler* masm) {
|
1377
1448
|
Debug::GenerateLoadICDebugBreak(masm);
|
@@ -1423,73 +1494,113 @@ static void Generate_FrameDropper_LiveEdit(MacroAssembler* masm) {
|
|
1423
1494
|
}
|
1424
1495
|
#endif
|
1425
1496
|
|
1426
|
-
|
1427
|
-
|
1497
|
+
|
1498
|
+
Builtins::Builtins() : initialized_(false) {
|
1499
|
+
memset(builtins_, 0, sizeof(builtins_[0]) * builtin_count);
|
1500
|
+
memset(names_, 0, sizeof(names_[0]) * builtin_count);
|
1501
|
+
}
|
1502
|
+
|
1503
|
+
|
1504
|
+
Builtins::~Builtins() {
|
1505
|
+
}
|
1506
|
+
|
1428
1507
|
|
1429
1508
|
#define DEF_ENUM_C(name, ignore) FUNCTION_ADDR(Builtin_##name),
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1509
|
+
Address const Builtins::c_functions_[cfunction_count] = {
|
1510
|
+
BUILTIN_LIST_C(DEF_ENUM_C)
|
1511
|
+
};
|
1433
1512
|
#undef DEF_ENUM_C
|
1434
1513
|
|
1435
1514
|
#define DEF_JS_NAME(name, ignore) #name,
|
1436
1515
|
#define DEF_JS_ARGC(ignore, argc) argc,
|
1437
|
-
const char* Builtins::javascript_names_[id_count] = {
|
1516
|
+
const char* const Builtins::javascript_names_[id_count] = {
|
1438
1517
|
BUILTINS_LIST_JS(DEF_JS_NAME)
|
1439
1518
|
};
|
1440
1519
|
|
1441
|
-
int Builtins::javascript_argc_[id_count] = {
|
1520
|
+
int const Builtins::javascript_argc_[id_count] = {
|
1442
1521
|
BUILTINS_LIST_JS(DEF_JS_ARGC)
|
1443
1522
|
};
|
1444
1523
|
#undef DEF_JS_NAME
|
1445
1524
|
#undef DEF_JS_ARGC
|
1446
1525
|
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1526
|
+
struct BuiltinDesc {
|
1527
|
+
byte* generator;
|
1528
|
+
byte* c_code;
|
1529
|
+
const char* s_name; // name is only used for generating log information.
|
1530
|
+
int name;
|
1531
|
+
Code::Flags flags;
|
1532
|
+
BuiltinExtraArguments extra_args;
|
1533
|
+
};
|
1450
1534
|
|
1451
|
-
|
1452
|
-
|
1535
|
+
class BuiltinFunctionTable {
|
1536
|
+
public:
|
1537
|
+
BuiltinFunctionTable() {
|
1538
|
+
Builtins::InitBuiltinFunctionTable();
|
1539
|
+
}
|
1453
1540
|
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1541
|
+
static const BuiltinDesc* functions() { return functions_; }
|
1542
|
+
|
1543
|
+
private:
|
1544
|
+
static BuiltinDesc functions_[Builtins::builtin_count + 1];
|
1545
|
+
|
1546
|
+
friend class Builtins;
|
1547
|
+
};
|
1548
|
+
|
1549
|
+
BuiltinDesc BuiltinFunctionTable::functions_[Builtins::builtin_count + 1];
|
1550
|
+
|
1551
|
+
static const BuiltinFunctionTable builtin_function_table_init;
|
1552
|
+
|
1553
|
+
// Define array of pointers to generators and C builtin functions.
|
1554
|
+
// We do this in a sort of roundabout way so that we can do the initialization
|
1555
|
+
// within the lexical scope of Builtins:: and within a context where
|
1556
|
+
// Code::Flags names a non-abstract type.
|
1557
|
+
void Builtins::InitBuiltinFunctionTable() {
|
1558
|
+
BuiltinDesc* functions = BuiltinFunctionTable::functions_;
|
1559
|
+
functions[builtin_count].generator = NULL;
|
1560
|
+
functions[builtin_count].c_code = NULL;
|
1561
|
+
functions[builtin_count].s_name = NULL;
|
1562
|
+
functions[builtin_count].name = builtin_count;
|
1563
|
+
functions[builtin_count].flags = static_cast<Code::Flags>(0);
|
1564
|
+
functions[builtin_count].extra_args = NO_EXTRA_ARGUMENTS;
|
1565
|
+
|
1566
|
+
#define DEF_FUNCTION_PTR_C(aname, aextra_args) \
|
1567
|
+
functions->generator = FUNCTION_ADDR(Generate_Adaptor); \
|
1568
|
+
functions->c_code = FUNCTION_ADDR(Builtin_##aname); \
|
1569
|
+
functions->s_name = #aname; \
|
1570
|
+
functions->name = c_##aname; \
|
1571
|
+
functions->flags = Code::ComputeFlags(Code::BUILTIN); \
|
1572
|
+
functions->extra_args = aextra_args; \
|
1573
|
+
++functions;
|
1574
|
+
|
1575
|
+
#define DEF_FUNCTION_PTR_A(aname, kind, state, extra) \
|
1576
|
+
functions->generator = FUNCTION_ADDR(Generate_##aname); \
|
1577
|
+
functions->c_code = NULL; \
|
1578
|
+
functions->s_name = #aname; \
|
1579
|
+
functions->name = k##aname; \
|
1580
|
+
functions->flags = Code::ComputeFlags(Code::kind, \
|
1581
|
+
NOT_IN_LOOP, \
|
1582
|
+
state, \
|
1583
|
+
extra); \
|
1584
|
+
functions->extra_args = NO_EXTRA_ARGUMENTS; \
|
1585
|
+
++functions;
|
1586
|
+
|
1587
|
+
BUILTIN_LIST_C(DEF_FUNCTION_PTR_C)
|
1588
|
+
BUILTIN_LIST_A(DEF_FUNCTION_PTR_A)
|
1589
|
+
BUILTIN_LIST_DEBUG_A(DEF_FUNCTION_PTR_A)
|
1490
1590
|
|
1491
1591
|
#undef DEF_FUNCTION_PTR_C
|
1492
1592
|
#undef DEF_FUNCTION_PTR_A
|
1593
|
+
}
|
1594
|
+
|
1595
|
+
void Builtins::Setup(bool create_heap_objects) {
|
1596
|
+
ASSERT(!initialized_);
|
1597
|
+
Isolate* isolate = Isolate::Current();
|
1598
|
+
Heap* heap = isolate->heap();
|
1599
|
+
|
1600
|
+
// Create a scope for the handles in the builtins.
|
1601
|
+
HandleScope scope(isolate);
|
1602
|
+
|
1603
|
+
const BuiltinDesc* functions = BuiltinFunctionTable::functions();
|
1493
1604
|
|
1494
1605
|
// For now we generate builtin adaptor code into a stack-allocated
|
1495
1606
|
// buffer, before copying it into individual code objects.
|
@@ -1499,7 +1610,7 @@ void Builtins::Setup(bool create_heap_objects) {
|
|
1499
1610
|
// separate code object for each one.
|
1500
1611
|
for (int i = 0; i < builtin_count; i++) {
|
1501
1612
|
if (create_heap_objects) {
|
1502
|
-
MacroAssembler masm(buffer, sizeof buffer);
|
1613
|
+
MacroAssembler masm(isolate, buffer, sizeof buffer);
|
1503
1614
|
// Generate the code/adaptor.
|
1504
1615
|
typedef void (*Generator)(MacroAssembler*, int, BuiltinExtraArguments);
|
1505
1616
|
Generator g = FUNCTION_CAST<Generator>(functions[i].generator);
|
@@ -1517,14 +1628,15 @@ void Builtins::Setup(bool create_heap_objects) {
|
|
1517
1628
|
// This simplifies things because we don't need to retry.
|
1518
1629
|
AlwaysAllocateScope __scope__;
|
1519
1630
|
{ MaybeObject* maybe_code =
|
1520
|
-
|
1631
|
+
heap->CreateCode(desc, flags, masm.CodeObject());
|
1521
1632
|
if (!maybe_code->ToObject(&code)) {
|
1522
1633
|
v8::internal::V8::FatalProcessOutOfMemory("CreateCode");
|
1523
1634
|
}
|
1524
1635
|
}
|
1525
1636
|
}
|
1526
1637
|
// Log the event and add the code to the builtins array.
|
1527
|
-
PROFILE(
|
1638
|
+
PROFILE(isolate,
|
1639
|
+
CodeCreateEvent(Logger::BUILTIN_TAG,
|
1528
1640
|
Code::cast(code),
|
1529
1641
|
functions[i].s_name));
|
1530
1642
|
GDBJIT(AddCode(GDBJITInterface::BUILTIN,
|
@@ -1546,12 +1658,12 @@ void Builtins::Setup(bool create_heap_objects) {
|
|
1546
1658
|
}
|
1547
1659
|
|
1548
1660
|
// Mark as initialized.
|
1549
|
-
|
1661
|
+
initialized_ = true;
|
1550
1662
|
}
|
1551
1663
|
|
1552
1664
|
|
1553
1665
|
void Builtins::TearDown() {
|
1554
|
-
|
1666
|
+
initialized_ = false;
|
1555
1667
|
}
|
1556
1668
|
|
1557
1669
|
|
@@ -1561,7 +1673,8 @@ void Builtins::IterateBuiltins(ObjectVisitor* v) {
|
|
1561
1673
|
|
1562
1674
|
|
1563
1675
|
const char* Builtins::Lookup(byte* pc) {
|
1564
|
-
|
1676
|
+
// may be called during initialization (disassembler!)
|
1677
|
+
if (initialized_) {
|
1565
1678
|
for (int i = 0; i < builtin_count; i++) {
|
1566
1679
|
Code* entry = Code::cast(builtins_[i]);
|
1567
1680
|
if (entry->contains(pc)) {
|
@@ -1573,4 +1686,23 @@ const char* Builtins::Lookup(byte* pc) {
|
|
1573
1686
|
}
|
1574
1687
|
|
1575
1688
|
|
1689
|
+
#define DEFINE_BUILTIN_ACCESSOR_C(name, ignore) \
|
1690
|
+
Handle<Code> Builtins::name() { \
|
1691
|
+
Code** code_address = \
|
1692
|
+
reinterpret_cast<Code**>(builtin_address(k##name)); \
|
1693
|
+
return Handle<Code>(code_address); \
|
1694
|
+
}
|
1695
|
+
#define DEFINE_BUILTIN_ACCESSOR_A(name, kind, state, extra) \
|
1696
|
+
Handle<Code> Builtins::name() { \
|
1697
|
+
Code** code_address = \
|
1698
|
+
reinterpret_cast<Code**>(builtin_address(k##name)); \
|
1699
|
+
return Handle<Code>(code_address); \
|
1700
|
+
}
|
1701
|
+
BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C)
|
1702
|
+
BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A)
|
1703
|
+
BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
|
1704
|
+
#undef DEFINE_BUILTIN_ACCESSOR_C
|
1705
|
+
#undef DEFINE_BUILTIN_ACCESSOR_A
|
1706
|
+
|
1707
|
+
|
1576
1708
|
} } // namespace v8::internal
|