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
@@ -44,100 +44,57 @@
|
|
44
44
|
namespace v8 {
|
45
45
|
namespace internal {
|
46
46
|
|
47
|
-
// A SourceCodeCache uses a FixedArray to store pairs of
|
48
|
-
// (AsciiString*, JSFunction*), mapping names of native code files
|
49
|
-
// (runtime.js, etc.) to precompiled functions. Instead of mapping
|
50
|
-
// names to functions it might make sense to let the JS2C tool
|
51
|
-
// generate an index for each native JS file.
|
52
|
-
class SourceCodeCache BASE_EMBEDDED {
|
53
|
-
public:
|
54
|
-
explicit SourceCodeCache(Script::Type type): type_(type), cache_(NULL) { }
|
55
|
-
|
56
|
-
void Initialize(bool create_heap_objects) {
|
57
|
-
cache_ = create_heap_objects ? Heap::empty_fixed_array() : NULL;
|
58
|
-
}
|
59
|
-
|
60
|
-
void Iterate(ObjectVisitor* v) {
|
61
|
-
v->VisitPointer(BitCast<Object**>(&cache_));
|
62
|
-
}
|
63
|
-
|
64
|
-
|
65
|
-
bool Lookup(Vector<const char> name, Handle<SharedFunctionInfo>* handle) {
|
66
|
-
for (int i = 0; i < cache_->length(); i+=2) {
|
67
|
-
SeqAsciiString* str = SeqAsciiString::cast(cache_->get(i));
|
68
|
-
if (str->IsEqualTo(name)) {
|
69
|
-
*handle = Handle<SharedFunctionInfo>(
|
70
|
-
SharedFunctionInfo::cast(cache_->get(i + 1)));
|
71
|
-
return true;
|
72
|
-
}
|
73
|
-
}
|
74
|
-
return false;
|
75
|
-
}
|
76
|
-
|
77
|
-
|
78
|
-
void Add(Vector<const char> name, Handle<SharedFunctionInfo> shared) {
|
79
|
-
HandleScope scope;
|
80
|
-
int length = cache_->length();
|
81
|
-
Handle<FixedArray> new_array =
|
82
|
-
Factory::NewFixedArray(length + 2, TENURED);
|
83
|
-
cache_->CopyTo(0, *new_array, 0, cache_->length());
|
84
|
-
cache_ = *new_array;
|
85
|
-
Handle<String> str = Factory::NewStringFromAscii(name, TENURED);
|
86
|
-
cache_->set(length, *str);
|
87
|
-
cache_->set(length + 1, *shared);
|
88
|
-
Script::cast(shared->script())->set_type(Smi::FromInt(type_));
|
89
|
-
}
|
90
|
-
|
91
|
-
private:
|
92
|
-
Script::Type type_;
|
93
|
-
FixedArray* cache_;
|
94
|
-
DISALLOW_COPY_AND_ASSIGN(SourceCodeCache);
|
95
|
-
};
|
96
47
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
// This is for delete[]
|
101
|
-
static List<char*>* delete_these_arrays_on_tear_down = NULL;
|
102
|
-
|
103
|
-
|
104
|
-
NativesExternalStringResource::NativesExternalStringResource(const char* source)
|
48
|
+
NativesExternalStringResource::NativesExternalStringResource(
|
49
|
+
Bootstrapper* bootstrapper,
|
50
|
+
const char* source)
|
105
51
|
: data_(source), length_(StrLength(source)) {
|
106
|
-
if (
|
107
|
-
|
52
|
+
if (bootstrapper->delete_these_non_arrays_on_tear_down_ == NULL) {
|
53
|
+
bootstrapper->delete_these_non_arrays_on_tear_down_ = new List<char*>(2);
|
108
54
|
}
|
109
55
|
// The resources are small objects and we only make a fixed number of
|
110
56
|
// them, but let's clean them up on exit for neatness.
|
111
|
-
|
57
|
+
bootstrapper->delete_these_non_arrays_on_tear_down_->
|
112
58
|
Add(reinterpret_cast<char*>(this));
|
113
59
|
}
|
114
60
|
|
115
61
|
|
62
|
+
Bootstrapper::Bootstrapper()
|
63
|
+
: nesting_(0),
|
64
|
+
extensions_cache_(Script::TYPE_EXTENSION),
|
65
|
+
delete_these_non_arrays_on_tear_down_(NULL),
|
66
|
+
delete_these_arrays_on_tear_down_(NULL) {
|
67
|
+
}
|
68
|
+
|
69
|
+
|
116
70
|
Handle<String> Bootstrapper::NativesSourceLookup(int index) {
|
117
71
|
ASSERT(0 <= index && index < Natives::GetBuiltinsCount());
|
118
|
-
|
72
|
+
Isolate* isolate = Isolate::Current();
|
73
|
+
Factory* factory = isolate->factory();
|
74
|
+
Heap* heap = isolate->heap();
|
75
|
+
if (heap->natives_source_cache()->get(index)->IsUndefined()) {
|
119
76
|
if (!Snapshot::IsEnabled() || FLAG_new_snapshot) {
|
120
77
|
// We can use external strings for the natives.
|
121
78
|
NativesExternalStringResource* resource =
|
122
|
-
new NativesExternalStringResource(
|
79
|
+
new NativesExternalStringResource(this,
|
123
80
|
Natives::GetScriptSource(index).start());
|
124
81
|
Handle<String> source_code =
|
125
|
-
|
126
|
-
|
82
|
+
factory->NewExternalStringFromAscii(resource);
|
83
|
+
heap->natives_source_cache()->set(index, *source_code);
|
127
84
|
} else {
|
128
85
|
// Old snapshot code can't cope with external strings at all.
|
129
86
|
Handle<String> source_code =
|
130
|
-
|
131
|
-
|
87
|
+
factory->NewStringFromAscii(Natives::GetScriptSource(index));
|
88
|
+
heap->natives_source_cache()->set(index, *source_code);
|
132
89
|
}
|
133
90
|
}
|
134
|
-
Handle<Object> cached_source(
|
91
|
+
Handle<Object> cached_source(heap->natives_source_cache()->get(index));
|
135
92
|
return Handle<String>::cast(cached_source);
|
136
93
|
}
|
137
94
|
|
138
95
|
|
139
96
|
void Bootstrapper::Initialize(bool create_heap_objects) {
|
140
|
-
|
97
|
+
extensions_cache_.Initialize(create_heap_objects);
|
141
98
|
GCExtension::Register();
|
142
99
|
ExternalizeStringExtension::Register();
|
143
100
|
}
|
@@ -146,39 +103,39 @@ void Bootstrapper::Initialize(bool create_heap_objects) {
|
|
146
103
|
char* Bootstrapper::AllocateAutoDeletedArray(int bytes) {
|
147
104
|
char* memory = new char[bytes];
|
148
105
|
if (memory != NULL) {
|
149
|
-
if (
|
150
|
-
|
106
|
+
if (delete_these_arrays_on_tear_down_ == NULL) {
|
107
|
+
delete_these_arrays_on_tear_down_ = new List<char*>(2);
|
151
108
|
}
|
152
|
-
|
109
|
+
delete_these_arrays_on_tear_down_->Add(memory);
|
153
110
|
}
|
154
111
|
return memory;
|
155
112
|
}
|
156
113
|
|
157
114
|
|
158
115
|
void Bootstrapper::TearDown() {
|
159
|
-
if (
|
160
|
-
int len =
|
116
|
+
if (delete_these_non_arrays_on_tear_down_ != NULL) {
|
117
|
+
int len = delete_these_non_arrays_on_tear_down_->length();
|
161
118
|
ASSERT(len < 20); // Don't use this mechanism for unbounded allocations.
|
162
119
|
for (int i = 0; i < len; i++) {
|
163
|
-
delete
|
164
|
-
|
120
|
+
delete delete_these_non_arrays_on_tear_down_->at(i);
|
121
|
+
delete_these_non_arrays_on_tear_down_->at(i) = NULL;
|
165
122
|
}
|
166
|
-
delete
|
167
|
-
|
123
|
+
delete delete_these_non_arrays_on_tear_down_;
|
124
|
+
delete_these_non_arrays_on_tear_down_ = NULL;
|
168
125
|
}
|
169
126
|
|
170
|
-
if (
|
171
|
-
int len =
|
127
|
+
if (delete_these_arrays_on_tear_down_ != NULL) {
|
128
|
+
int len = delete_these_arrays_on_tear_down_->length();
|
172
129
|
ASSERT(len < 1000); // Don't use this mechanism for unbounded allocations.
|
173
130
|
for (int i = 0; i < len; i++) {
|
174
|
-
delete[]
|
175
|
-
|
131
|
+
delete[] delete_these_arrays_on_tear_down_->at(i);
|
132
|
+
delete_these_arrays_on_tear_down_->at(i) = NULL;
|
176
133
|
}
|
177
|
-
delete
|
178
|
-
|
134
|
+
delete delete_these_arrays_on_tear_down_;
|
135
|
+
delete_these_arrays_on_tear_down_ = NULL;
|
179
136
|
}
|
180
137
|
|
181
|
-
|
138
|
+
extensions_cache_.Initialize(false); // Yes, symmetrical
|
182
139
|
}
|
183
140
|
|
184
141
|
|
@@ -207,6 +164,10 @@ class Genesis BASE_EMBEDDED {
|
|
207
164
|
void CreateRoots();
|
208
165
|
// Creates the empty function. Used for creating a context from scratch.
|
209
166
|
Handle<JSFunction> CreateEmptyFunction();
|
167
|
+
// Creates the ThrowTypeError function. ECMA 5th Ed. 13.2.3
|
168
|
+
Handle<JSFunction> CreateThrowTypeErrorFunction(Builtins::Name builtin);
|
169
|
+
|
170
|
+
void CreateStrictModeFunctionMaps(Handle<JSFunction> empty);
|
210
171
|
// Creates the global objects using the global and the template passed in
|
211
172
|
// through the API. We call this regardless of whether we are building a
|
212
173
|
// context from scratch or using a deserialized one from the partial snapshot
|
@@ -260,10 +221,24 @@ class Genesis BASE_EMBEDDED {
|
|
260
221
|
ADD_READONLY_PROTOTYPE,
|
261
222
|
ADD_WRITEABLE_PROTOTYPE
|
262
223
|
};
|
224
|
+
|
225
|
+
Handle<Map> CreateFunctionMap(PrototypePropertyMode prototype_mode);
|
226
|
+
|
263
227
|
Handle<DescriptorArray> ComputeFunctionInstanceDescriptor(
|
264
228
|
PrototypePropertyMode prototypeMode);
|
265
229
|
void MakeFunctionInstancePrototypeWritable();
|
266
230
|
|
231
|
+
Handle<Map> CreateStrictModeFunctionMap(
|
232
|
+
PrototypePropertyMode prototype_mode,
|
233
|
+
Handle<JSFunction> empty_function,
|
234
|
+
Handle<FixedArray> arguments_callbacks,
|
235
|
+
Handle<FixedArray> caller_callbacks);
|
236
|
+
|
237
|
+
Handle<DescriptorArray> ComputeStrictFunctionInstanceDescriptor(
|
238
|
+
PrototypePropertyMode propertyMode,
|
239
|
+
Handle<FixedArray> arguments,
|
240
|
+
Handle<FixedArray> caller);
|
241
|
+
|
267
242
|
static bool CompileBuiltin(int index);
|
268
243
|
static bool CompileNative(Vector<const char> name, Handle<String> source);
|
269
244
|
static bool CompileScriptCached(Vector<const char> name,
|
@@ -274,14 +249,21 @@ class Genesis BASE_EMBEDDED {
|
|
274
249
|
bool use_runtime_context);
|
275
250
|
|
276
251
|
Handle<Context> result_;
|
277
|
-
|
252
|
+
|
253
|
+
// Function instance maps. Function literal maps are created initially with
|
254
|
+
// a read only prototype for the processing of JS builtins. Later the function
|
255
|
+
// instance maps are replaced in order to make prototype writable.
|
256
|
+
// These are the final, writable prototype, maps.
|
257
|
+
Handle<Map> function_instance_map_writable_prototype_;
|
258
|
+
Handle<Map> strict_mode_function_instance_map_writable_prototype_;
|
259
|
+
|
278
260
|
BootstrapperActive active_;
|
279
261
|
friend class Bootstrapper;
|
280
262
|
};
|
281
263
|
|
282
264
|
|
283
265
|
void Bootstrapper::Iterate(ObjectVisitor* v) {
|
284
|
-
|
266
|
+
extensions_cache_.Iterate(v);
|
285
267
|
v->Synchronize("Extensions");
|
286
268
|
}
|
287
269
|
|
@@ -306,16 +288,17 @@ Handle<Context> Bootstrapper::CreateEnvironment(
|
|
306
288
|
static void SetObjectPrototype(Handle<JSObject> object, Handle<Object> proto) {
|
307
289
|
// object.__proto__ = proto;
|
308
290
|
Handle<Map> old_to_map = Handle<Map>(object->map());
|
309
|
-
Handle<Map> new_to_map =
|
291
|
+
Handle<Map> new_to_map = FACTORY->CopyMapDropTransitions(old_to_map);
|
310
292
|
new_to_map->set_prototype(*proto);
|
311
293
|
object->set_map(*new_to_map);
|
312
294
|
}
|
313
295
|
|
314
296
|
|
315
297
|
void Bootstrapper::DetachGlobal(Handle<Context> env) {
|
316
|
-
|
298
|
+
Factory* factory = Isolate::Current()->factory();
|
299
|
+
JSGlobalProxy::cast(env->global_proxy())->set_context(*factory->null_value());
|
317
300
|
SetObjectPrototype(Handle<JSObject>(env->global_proxy()),
|
318
|
-
|
301
|
+
factory->null_value());
|
319
302
|
env->set_global_proxy(env->global());
|
320
303
|
env->global()->set_global_receiver(env->global());
|
321
304
|
}
|
@@ -339,11 +322,13 @@ static Handle<JSFunction> InstallFunction(Handle<JSObject> target,
|
|
339
322
|
Handle<JSObject> prototype,
|
340
323
|
Builtins::Name call,
|
341
324
|
bool is_ecma_native) {
|
342
|
-
|
343
|
-
|
325
|
+
Isolate* isolate = Isolate::Current();
|
326
|
+
Factory* factory = isolate->factory();
|
327
|
+
Handle<String> symbol = factory->LookupAsciiSymbol(name);
|
328
|
+
Handle<Code> call_code = Handle<Code>(isolate->builtins()->builtin(call));
|
344
329
|
Handle<JSFunction> function = prototype.is_null() ?
|
345
|
-
|
346
|
-
|
330
|
+
factory->NewFunctionWithoutPrototype(symbol, call_code) :
|
331
|
+
factory->NewFunctionWithPrototype(symbol,
|
347
332
|
type,
|
348
333
|
instance_size,
|
349
334
|
prototype,
|
@@ -359,174 +344,312 @@ static Handle<JSFunction> InstallFunction(Handle<JSObject> target,
|
|
359
344
|
|
360
345
|
Handle<DescriptorArray> Genesis::ComputeFunctionInstanceDescriptor(
|
361
346
|
PrototypePropertyMode prototypeMode) {
|
362
|
-
|
347
|
+
Factory* factory = Isolate::Current()->factory();
|
348
|
+
Handle<DescriptorArray> descriptors =
|
349
|
+
factory->NewDescriptorArray(prototypeMode == DONT_ADD_PROTOTYPE ? 4 : 5);
|
350
|
+
PropertyAttributes attributes =
|
351
|
+
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
|
363
352
|
|
353
|
+
{ // Add length.
|
354
|
+
Handle<Proxy> proxy = factory->NewProxy(&Accessors::FunctionLength);
|
355
|
+
CallbacksDescriptor d(*factory->length_symbol(), *proxy, attributes);
|
356
|
+
descriptors->Set(0, &d);
|
357
|
+
}
|
358
|
+
{ // Add name.
|
359
|
+
Handle<Proxy> proxy = factory->NewProxy(&Accessors::FunctionName);
|
360
|
+
CallbacksDescriptor d(*factory->name_symbol(), *proxy, attributes);
|
361
|
+
descriptors->Set(1, &d);
|
362
|
+
}
|
363
|
+
{ // Add arguments.
|
364
|
+
Handle<Proxy> proxy = factory->NewProxy(&Accessors::FunctionArguments);
|
365
|
+
CallbacksDescriptor d(*factory->arguments_symbol(), *proxy, attributes);
|
366
|
+
descriptors->Set(2, &d);
|
367
|
+
}
|
368
|
+
{ // Add caller.
|
369
|
+
Handle<Proxy> proxy = factory->NewProxy(&Accessors::FunctionCaller);
|
370
|
+
CallbacksDescriptor d(*factory->caller_symbol(), *proxy, attributes);
|
371
|
+
descriptors->Set(3, &d);
|
372
|
+
}
|
364
373
|
if (prototypeMode != DONT_ADD_PROTOTYPE) {
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
Factory::prototype_symbol(),
|
373
|
-
Factory::NewProxy(&Accessors::FunctionPrototype),
|
374
|
-
attributes);
|
374
|
+
// Add prototype.
|
375
|
+
if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) {
|
376
|
+
attributes = static_cast<PropertyAttributes>(attributes & ~READ_ONLY);
|
377
|
+
}
|
378
|
+
Handle<Proxy> proxy = factory->NewProxy(&Accessors::FunctionPrototype);
|
379
|
+
CallbacksDescriptor d(*factory->prototype_symbol(), *proxy, attributes);
|
380
|
+
descriptors->Set(4, &d);
|
375
381
|
}
|
382
|
+
descriptors->Sort();
|
383
|
+
return descriptors;
|
384
|
+
}
|
376
385
|
|
377
|
-
PropertyAttributes attributes =
|
378
|
-
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
|
379
|
-
// Add length.
|
380
|
-
result =
|
381
|
-
Factory::CopyAppendProxyDescriptor(
|
382
|
-
result,
|
383
|
-
Factory::length_symbol(),
|
384
|
-
Factory::NewProxy(&Accessors::FunctionLength),
|
385
|
-
attributes);
|
386
|
-
|
387
|
-
// Add name.
|
388
|
-
result =
|
389
|
-
Factory::CopyAppendProxyDescriptor(
|
390
|
-
result,
|
391
|
-
Factory::name_symbol(),
|
392
|
-
Factory::NewProxy(&Accessors::FunctionName),
|
393
|
-
attributes);
|
394
|
-
|
395
|
-
// Add arguments.
|
396
|
-
result =
|
397
|
-
Factory::CopyAppendProxyDescriptor(
|
398
|
-
result,
|
399
|
-
Factory::arguments_symbol(),
|
400
|
-
Factory::NewProxy(&Accessors::FunctionArguments),
|
401
|
-
attributes);
|
402
|
-
|
403
|
-
// Add caller.
|
404
|
-
result =
|
405
|
-
Factory::CopyAppendProxyDescriptor(
|
406
|
-
result,
|
407
|
-
Factory::caller_symbol(),
|
408
|
-
Factory::NewProxy(&Accessors::FunctionCaller),
|
409
|
-
attributes);
|
410
386
|
|
411
|
-
|
387
|
+
Handle<Map> Genesis::CreateFunctionMap(PrototypePropertyMode prototype_mode) {
|
388
|
+
Handle<Map> map = FACTORY->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize);
|
389
|
+
Handle<DescriptorArray> descriptors =
|
390
|
+
ComputeFunctionInstanceDescriptor(prototype_mode);
|
391
|
+
map->set_instance_descriptors(*descriptors);
|
392
|
+
map->set_function_with_prototype(prototype_mode != DONT_ADD_PROTOTYPE);
|
393
|
+
return map;
|
412
394
|
}
|
413
395
|
|
414
396
|
|
415
397
|
Handle<JSFunction> Genesis::CreateEmptyFunction() {
|
416
|
-
// Allocate the map for function instances.
|
417
|
-
|
418
|
-
|
398
|
+
// Allocate the map for function instances. Maps are allocated first and their
|
399
|
+
// prototypes patched later, once empty function is created.
|
400
|
+
|
419
401
|
// Please note that the prototype property for function instances must be
|
420
402
|
// writable.
|
421
|
-
Handle<
|
422
|
-
|
423
|
-
|
424
|
-
fm->set_function_with_prototype(true);
|
403
|
+
Handle<Map> function_instance_map =
|
404
|
+
CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE);
|
405
|
+
global_context()->set_function_instance_map(*function_instance_map);
|
425
406
|
|
426
407
|
// Functions with this map will not have a 'prototype' property, and
|
427
408
|
// can not be used as constructors.
|
428
409
|
Handle<Map> function_without_prototype_map =
|
429
|
-
|
410
|
+
CreateFunctionMap(DONT_ADD_PROTOTYPE);
|
430
411
|
global_context()->set_function_without_prototype_map(
|
431
412
|
*function_without_prototype_map);
|
432
|
-
Handle<DescriptorArray> function_without_prototype_map_descriptors =
|
433
|
-
ComputeFunctionInstanceDescriptor(DONT_ADD_PROTOTYPE);
|
434
|
-
function_without_prototype_map->set_instance_descriptors(
|
435
|
-
*function_without_prototype_map_descriptors);
|
436
|
-
function_without_prototype_map->set_function_with_prototype(false);
|
437
413
|
|
438
|
-
// Allocate the function map
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
414
|
+
// Allocate the function map. This map is temporary, used only for processing
|
415
|
+
// of builtins.
|
416
|
+
// Later the map is replaced with writable prototype map, allocated below.
|
417
|
+
Handle<Map> function_map = CreateFunctionMap(ADD_READONLY_PROTOTYPE);
|
418
|
+
global_context()->set_function_map(*function_map);
|
419
|
+
|
420
|
+
// The final map for functions. Writeable prototype.
|
421
|
+
// This map is installed in MakeFunctionInstancePrototypeWritable.
|
422
|
+
function_instance_map_writable_prototype_ =
|
423
|
+
CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE);
|
445
424
|
|
446
|
-
|
425
|
+
Isolate* isolate = Isolate::Current();
|
426
|
+
Factory* factory = isolate->factory();
|
427
|
+
Heap* heap = isolate->heap();
|
428
|
+
|
429
|
+
Handle<String> object_name = Handle<String>(heap->Object_symbol());
|
447
430
|
|
448
431
|
{ // --- O b j e c t ---
|
449
432
|
Handle<JSFunction> object_fun =
|
450
|
-
|
433
|
+
factory->NewFunction(object_name, factory->null_value());
|
451
434
|
Handle<Map> object_function_map =
|
452
|
-
|
435
|
+
factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
|
453
436
|
object_fun->set_initial_map(*object_function_map);
|
454
437
|
object_function_map->set_constructor(*object_fun);
|
455
438
|
|
456
439
|
global_context()->set_object_function(*object_fun);
|
457
440
|
|
458
441
|
// Allocate a new prototype for the object function.
|
459
|
-
Handle<JSObject> prototype =
|
460
|
-
|
442
|
+
Handle<JSObject> prototype = factory->NewJSObject(
|
443
|
+
isolate->object_function(),
|
444
|
+
TENURED);
|
461
445
|
|
462
446
|
global_context()->set_initial_object_prototype(*prototype);
|
463
447
|
SetPrototype(object_fun, prototype);
|
464
448
|
object_function_map->
|
465
|
-
set_instance_descriptors(
|
449
|
+
set_instance_descriptors(heap->empty_descriptor_array());
|
466
450
|
}
|
467
451
|
|
468
452
|
// Allocate the empty function as the prototype for function ECMAScript
|
469
453
|
// 262 15.3.4.
|
470
|
-
Handle<String> symbol =
|
454
|
+
Handle<String> symbol = factory->LookupAsciiSymbol("Empty");
|
471
455
|
Handle<JSFunction> empty_function =
|
472
|
-
|
456
|
+
factory->NewFunctionWithoutPrototype(symbol, kNonStrictMode);
|
473
457
|
|
474
458
|
// --- E m p t y ---
|
475
459
|
Handle<Code> code =
|
476
|
-
Handle<Code>(
|
460
|
+
Handle<Code>(isolate->builtins()->builtin(
|
461
|
+
Builtins::kEmptyFunction));
|
477
462
|
empty_function->set_code(*code);
|
478
463
|
empty_function->shared()->set_code(*code);
|
479
|
-
Handle<String> source =
|
480
|
-
Handle<Script> script =
|
464
|
+
Handle<String> source = factory->NewStringFromAscii(CStrVector("() {}"));
|
465
|
+
Handle<Script> script = factory->NewScript(source);
|
481
466
|
script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
|
482
467
|
empty_function->shared()->set_script(*script);
|
483
468
|
empty_function->shared()->set_start_position(0);
|
484
469
|
empty_function->shared()->set_end_position(source->length());
|
485
470
|
empty_function->shared()->DontAdaptArguments();
|
471
|
+
|
472
|
+
// Set prototypes for the function maps.
|
486
473
|
global_context()->function_map()->set_prototype(*empty_function);
|
487
474
|
global_context()->function_instance_map()->set_prototype(*empty_function);
|
488
475
|
global_context()->function_without_prototype_map()->
|
489
476
|
set_prototype(*empty_function);
|
477
|
+
function_instance_map_writable_prototype_->set_prototype(*empty_function);
|
490
478
|
|
491
479
|
// Allocate the function map first and then patch the prototype later
|
492
|
-
Handle<Map> empty_fm =
|
480
|
+
Handle<Map> empty_fm = factory->CopyMapDropDescriptors(
|
493
481
|
function_without_prototype_map);
|
494
482
|
empty_fm->set_instance_descriptors(
|
495
|
-
|
483
|
+
function_without_prototype_map->instance_descriptors());
|
496
484
|
empty_fm->set_prototype(global_context()->object_function()->prototype());
|
497
485
|
empty_function->set_map(*empty_fm);
|
498
486
|
return empty_function;
|
499
487
|
}
|
500
488
|
|
501
489
|
|
490
|
+
Handle<DescriptorArray> Genesis::ComputeStrictFunctionInstanceDescriptor(
|
491
|
+
PrototypePropertyMode prototypeMode,
|
492
|
+
Handle<FixedArray> arguments,
|
493
|
+
Handle<FixedArray> caller) {
|
494
|
+
Factory* factory = Isolate::Current()->factory();
|
495
|
+
Handle<DescriptorArray> descriptors =
|
496
|
+
factory->NewDescriptorArray(prototypeMode == DONT_ADD_PROTOTYPE ? 4 : 5);
|
497
|
+
PropertyAttributes attributes = static_cast<PropertyAttributes>(
|
498
|
+
DONT_ENUM | DONT_DELETE | READ_ONLY);
|
499
|
+
|
500
|
+
{ // length
|
501
|
+
Handle<Proxy> proxy = factory->NewProxy(&Accessors::FunctionLength);
|
502
|
+
CallbacksDescriptor d(*factory->length_symbol(), *proxy, attributes);
|
503
|
+
descriptors->Set(0, &d);
|
504
|
+
}
|
505
|
+
{ // name
|
506
|
+
Handle<Proxy> proxy = factory->NewProxy(&Accessors::FunctionName);
|
507
|
+
CallbacksDescriptor d(*factory->name_symbol(), *proxy, attributes);
|
508
|
+
descriptors->Set(1, &d);
|
509
|
+
}
|
510
|
+
{ // arguments
|
511
|
+
CallbacksDescriptor d(*factory->arguments_symbol(), *arguments, attributes);
|
512
|
+
descriptors->Set(2, &d);
|
513
|
+
}
|
514
|
+
{ // caller
|
515
|
+
CallbacksDescriptor d(*factory->caller_symbol(), *caller, attributes);
|
516
|
+
descriptors->Set(3, &d);
|
517
|
+
}
|
518
|
+
|
519
|
+
// prototype
|
520
|
+
if (prototypeMode != DONT_ADD_PROTOTYPE) {
|
521
|
+
if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) {
|
522
|
+
attributes = static_cast<PropertyAttributes>(attributes & ~READ_ONLY);
|
523
|
+
}
|
524
|
+
Handle<Proxy> proxy = factory->NewProxy(&Accessors::FunctionPrototype);
|
525
|
+
CallbacksDescriptor d(*factory->prototype_symbol(), *proxy, attributes);
|
526
|
+
descriptors->Set(4, &d);
|
527
|
+
}
|
528
|
+
|
529
|
+
descriptors->Sort();
|
530
|
+
return descriptors;
|
531
|
+
}
|
532
|
+
|
533
|
+
|
534
|
+
// ECMAScript 5th Edition, 13.2.3
|
535
|
+
Handle<JSFunction> Genesis::CreateThrowTypeErrorFunction(
|
536
|
+
Builtins::Name builtin) {
|
537
|
+
Isolate* isolate = Isolate::Current();
|
538
|
+
Factory* factory = isolate->factory();
|
539
|
+
|
540
|
+
Handle<String> name = factory->LookupAsciiSymbol("ThrowTypeError");
|
541
|
+
Handle<JSFunction> throw_type_error =
|
542
|
+
factory->NewFunctionWithoutPrototype(name, kStrictMode);
|
543
|
+
Handle<Code> code = Handle<Code>(
|
544
|
+
isolate->builtins()->builtin(builtin));
|
545
|
+
|
546
|
+
throw_type_error->set_map(global_context()->strict_mode_function_map());
|
547
|
+
throw_type_error->set_code(*code);
|
548
|
+
throw_type_error->shared()->set_code(*code);
|
549
|
+
throw_type_error->shared()->DontAdaptArguments();
|
550
|
+
|
551
|
+
PreventExtensions(throw_type_error);
|
552
|
+
|
553
|
+
return throw_type_error;
|
554
|
+
}
|
555
|
+
|
556
|
+
|
557
|
+
Handle<Map> Genesis::CreateStrictModeFunctionMap(
|
558
|
+
PrototypePropertyMode prototype_mode,
|
559
|
+
Handle<JSFunction> empty_function,
|
560
|
+
Handle<FixedArray> arguments_callbacks,
|
561
|
+
Handle<FixedArray> caller_callbacks) {
|
562
|
+
Handle<Map> map = FACTORY->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize);
|
563
|
+
Handle<DescriptorArray> descriptors =
|
564
|
+
ComputeStrictFunctionInstanceDescriptor(prototype_mode,
|
565
|
+
arguments_callbacks,
|
566
|
+
caller_callbacks);
|
567
|
+
map->set_instance_descriptors(*descriptors);
|
568
|
+
map->set_function_with_prototype(prototype_mode != DONT_ADD_PROTOTYPE);
|
569
|
+
map->set_prototype(*empty_function);
|
570
|
+
return map;
|
571
|
+
}
|
572
|
+
|
573
|
+
|
574
|
+
void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) {
|
575
|
+
// Create the callbacks arrays for ThrowTypeError functions.
|
576
|
+
// The get/set callacks are filled in after the maps are created below.
|
577
|
+
Factory* factory = Isolate::Current()->factory();
|
578
|
+
Handle<FixedArray> arguments = factory->NewFixedArray(2, TENURED);
|
579
|
+
Handle<FixedArray> caller = factory->NewFixedArray(2, TENURED);
|
580
|
+
|
581
|
+
// Allocate map for the strict mode function instances.
|
582
|
+
Handle<Map> strict_mode_function_instance_map =
|
583
|
+
CreateStrictModeFunctionMap(
|
584
|
+
ADD_WRITEABLE_PROTOTYPE, empty, arguments, caller);
|
585
|
+
global_context()->set_strict_mode_function_instance_map(
|
586
|
+
*strict_mode_function_instance_map);
|
587
|
+
|
588
|
+
// Allocate map for the prototype-less strict mode instances.
|
589
|
+
Handle<Map> strict_mode_function_without_prototype_map =
|
590
|
+
CreateStrictModeFunctionMap(
|
591
|
+
DONT_ADD_PROTOTYPE, empty, arguments, caller);
|
592
|
+
global_context()->set_strict_mode_function_without_prototype_map(
|
593
|
+
*strict_mode_function_without_prototype_map);
|
594
|
+
|
595
|
+
// Allocate map for the strict mode functions. This map is temporary, used
|
596
|
+
// only for processing of builtins.
|
597
|
+
// Later the map is replaced with writable prototype map, allocated below.
|
598
|
+
Handle<Map> strict_mode_function_map =
|
599
|
+
CreateStrictModeFunctionMap(
|
600
|
+
ADD_READONLY_PROTOTYPE, empty, arguments, caller);
|
601
|
+
global_context()->set_strict_mode_function_map(
|
602
|
+
*strict_mode_function_map);
|
603
|
+
|
604
|
+
// The final map for the strict mode functions. Writeable prototype.
|
605
|
+
// This map is installed in MakeFunctionInstancePrototypeWritable.
|
606
|
+
strict_mode_function_instance_map_writable_prototype_ =
|
607
|
+
CreateStrictModeFunctionMap(
|
608
|
+
ADD_WRITEABLE_PROTOTYPE, empty, arguments, caller);
|
609
|
+
|
610
|
+
// Create the ThrowTypeError function instances.
|
611
|
+
Handle<JSFunction> arguments_throw =
|
612
|
+
CreateThrowTypeErrorFunction(Builtins::kStrictFunctionArguments);
|
613
|
+
Handle<JSFunction> caller_throw =
|
614
|
+
CreateThrowTypeErrorFunction(Builtins::kStrictFunctionCaller);
|
615
|
+
|
616
|
+
// Complete the callback fixed arrays.
|
617
|
+
arguments->set(0, *arguments_throw);
|
618
|
+
arguments->set(1, *arguments_throw);
|
619
|
+
caller->set(0, *caller_throw);
|
620
|
+
caller->set(1, *caller_throw);
|
621
|
+
}
|
622
|
+
|
623
|
+
|
502
624
|
static void AddToWeakGlobalContextList(Context* context) {
|
503
625
|
ASSERT(context->IsGlobalContext());
|
626
|
+
Heap* heap = Isolate::Current()->heap();
|
504
627
|
#ifdef DEBUG
|
505
628
|
{ // NOLINT
|
506
629
|
ASSERT(context->get(Context::NEXT_CONTEXT_LINK)->IsUndefined());
|
507
630
|
// Check that context is not in the list yet.
|
508
|
-
for (Object* current =
|
631
|
+
for (Object* current = heap->global_contexts_list();
|
509
632
|
!current->IsUndefined();
|
510
633
|
current = Context::cast(current)->get(Context::NEXT_CONTEXT_LINK)) {
|
511
634
|
ASSERT(current != context);
|
512
635
|
}
|
513
636
|
}
|
514
637
|
#endif
|
515
|
-
context->set(Context::NEXT_CONTEXT_LINK,
|
516
|
-
|
638
|
+
context->set(Context::NEXT_CONTEXT_LINK, heap->global_contexts_list());
|
639
|
+
heap->set_global_contexts_list(context);
|
517
640
|
}
|
518
641
|
|
519
642
|
|
520
643
|
void Genesis::CreateRoots() {
|
644
|
+
Isolate* isolate = Isolate::Current();
|
521
645
|
// Allocate the global context FixedArray first and then patch the
|
522
646
|
// closure and extension object later (we need the empty function
|
523
647
|
// and the global object, but in order to create those, we need the
|
524
648
|
// global context).
|
525
|
-
global_context_ =
|
526
|
-
|
527
|
-
GlobalHandles::Create(*Factory::NewGlobalContext()));
|
649
|
+
global_context_ = Handle<Context>::cast(isolate->global_handles()->Create(
|
650
|
+
*isolate->factory()->NewGlobalContext()));
|
528
651
|
AddToWeakGlobalContextList(*global_context_);
|
529
|
-
|
652
|
+
isolate->set_context(*global_context());
|
530
653
|
|
531
654
|
// Allocate the message listeners object.
|
532
655
|
{
|
@@ -569,11 +692,16 @@ Handle<JSGlobalProxy> Genesis::CreateNewGlobals(
|
|
569
692
|
}
|
570
693
|
}
|
571
694
|
|
695
|
+
Isolate* isolate = Isolate::Current();
|
696
|
+
Factory* factory = isolate->factory();
|
697
|
+
Heap* heap = isolate->heap();
|
698
|
+
|
572
699
|
if (js_global_template.is_null()) {
|
573
|
-
Handle<String> name = Handle<String>(
|
574
|
-
Handle<Code> code = Handle<Code>(
|
700
|
+
Handle<String> name = Handle<String>(heap->empty_symbol());
|
701
|
+
Handle<Code> code = Handle<Code>(isolate->builtins()->builtin(
|
702
|
+
Builtins::kIllegal));
|
575
703
|
js_global_function =
|
576
|
-
|
704
|
+
factory->NewFunction(name, JS_GLOBAL_OBJECT_TYPE,
|
577
705
|
JSGlobalObject::kSize, code, true);
|
578
706
|
// Change the constructor property of the prototype of the
|
579
707
|
// hidden global function to refer to the Object function.
|
@@ -581,18 +709,21 @@ Handle<JSGlobalProxy> Genesis::CreateNewGlobals(
|
|
581
709
|
Handle<JSObject>(
|
582
710
|
JSObject::cast(js_global_function->instance_prototype()));
|
583
711
|
SetLocalPropertyNoThrow(
|
584
|
-
prototype,
|
712
|
+
prototype,
|
713
|
+
factory->constructor_symbol(),
|
714
|
+
isolate->object_function(),
|
715
|
+
NONE);
|
585
716
|
} else {
|
586
717
|
Handle<FunctionTemplateInfo> js_global_constructor(
|
587
718
|
FunctionTemplateInfo::cast(js_global_template->constructor()));
|
588
719
|
js_global_function =
|
589
|
-
|
590
|
-
|
720
|
+
factory->CreateApiFunction(js_global_constructor,
|
721
|
+
factory->InnerGlobalObject);
|
591
722
|
}
|
592
723
|
|
593
724
|
js_global_function->initial_map()->set_is_hidden_prototype();
|
594
725
|
Handle<GlobalObject> inner_global =
|
595
|
-
|
726
|
+
factory->NewGlobalObject(js_global_function);
|
596
727
|
if (inner_global_out != NULL) {
|
597
728
|
*inner_global_out = inner_global;
|
598
729
|
}
|
@@ -600,10 +731,11 @@ Handle<JSGlobalProxy> Genesis::CreateNewGlobals(
|
|
600
731
|
// Step 2: create or re-initialize the global proxy object.
|
601
732
|
Handle<JSFunction> global_proxy_function;
|
602
733
|
if (global_template.IsEmpty()) {
|
603
|
-
Handle<String> name = Handle<String>(
|
604
|
-
Handle<Code> code = Handle<Code>(
|
734
|
+
Handle<String> name = Handle<String>(heap->empty_symbol());
|
735
|
+
Handle<Code> code = Handle<Code>(isolate->builtins()->builtin(
|
736
|
+
Builtins::kIllegal));
|
605
737
|
global_proxy_function =
|
606
|
-
|
738
|
+
factory->NewFunction(name, JS_GLOBAL_PROXY_TYPE,
|
607
739
|
JSGlobalProxy::kSize, code, true);
|
608
740
|
} else {
|
609
741
|
Handle<ObjectTemplateInfo> data =
|
@@ -611,11 +743,11 @@ Handle<JSGlobalProxy> Genesis::CreateNewGlobals(
|
|
611
743
|
Handle<FunctionTemplateInfo> global_constructor(
|
612
744
|
FunctionTemplateInfo::cast(data->constructor()));
|
613
745
|
global_proxy_function =
|
614
|
-
|
615
|
-
|
746
|
+
factory->CreateApiFunction(global_constructor,
|
747
|
+
factory->OuterGlobalObject);
|
616
748
|
}
|
617
749
|
|
618
|
-
Handle<String> global_name =
|
750
|
+
Handle<String> global_name = factory->LookupAsciiSymbol("global");
|
619
751
|
global_proxy_function->shared()->set_instance_class_name(*global_name);
|
620
752
|
global_proxy_function->initial_map()->set_is_access_check_needed(true);
|
621
753
|
|
@@ -629,7 +761,7 @@ Handle<JSGlobalProxy> Genesis::CreateNewGlobals(
|
|
629
761
|
Handle<JSGlobalProxy>::cast(global_object));
|
630
762
|
} else {
|
631
763
|
return Handle<JSGlobalProxy>::cast(
|
632
|
-
|
764
|
+
factory->NewJSObject(global_proxy_function, TENURED));
|
633
765
|
}
|
634
766
|
}
|
635
767
|
|
@@ -654,7 +786,7 @@ void Genesis::HookUpInnerGlobal(Handle<GlobalObject> inner_global) {
|
|
654
786
|
static const PropertyAttributes attributes =
|
655
787
|
static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
|
656
788
|
ForceSetProperty(builtins_global,
|
657
|
-
|
789
|
+
FACTORY->LookupAsciiSymbol("global"),
|
658
790
|
inner_global,
|
659
791
|
attributes);
|
660
792
|
// Setup the reference from the global object to the builtins object.
|
@@ -682,33 +814,37 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
|
682
814
|
// object reinitialization.
|
683
815
|
global_context()->set_security_token(*inner_global);
|
684
816
|
|
685
|
-
|
817
|
+
Isolate* isolate = Isolate::Current();
|
818
|
+
Factory* factory = isolate->factory();
|
819
|
+
Heap* heap = isolate->heap();
|
820
|
+
|
821
|
+
Handle<String> object_name = Handle<String>(heap->Object_symbol());
|
686
822
|
SetLocalPropertyNoThrow(inner_global, object_name,
|
687
|
-
|
823
|
+
isolate->object_function(), DONT_ENUM);
|
688
824
|
|
689
825
|
Handle<JSObject> global = Handle<JSObject>(global_context()->global());
|
690
826
|
|
691
827
|
// Install global Function object
|
692
828
|
InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize,
|
693
|
-
empty_function, Builtins::
|
829
|
+
empty_function, Builtins::kIllegal, true); // ECMA native.
|
694
830
|
|
695
831
|
{ // --- A r r a y ---
|
696
832
|
Handle<JSFunction> array_function =
|
697
833
|
InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize,
|
698
|
-
|
699
|
-
true);
|
834
|
+
isolate->initial_object_prototype(),
|
835
|
+
Builtins::kArrayCode, true);
|
700
836
|
array_function->shared()->set_construct_stub(
|
701
|
-
|
837
|
+
isolate->builtins()->builtin(Builtins::kArrayConstructCode));
|
702
838
|
array_function->shared()->DontAdaptArguments();
|
703
839
|
|
704
840
|
// This seems a bit hackish, but we need to make sure Array.length
|
705
841
|
// is 1.
|
706
842
|
array_function->shared()->set_length(1);
|
707
843
|
Handle<DescriptorArray> array_descriptors =
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
844
|
+
factory->CopyAppendProxyDescriptor(
|
845
|
+
factory->empty_descriptor_array(),
|
846
|
+
factory->length_symbol(),
|
847
|
+
factory->NewProxy(&Accessors::ArrayLength),
|
712
848
|
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE));
|
713
849
|
|
714
850
|
// Cache the fast JavaScript array map
|
@@ -725,33 +861,33 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
|
725
861
|
{ // --- N u m b e r ---
|
726
862
|
Handle<JSFunction> number_fun =
|
727
863
|
InstallFunction(global, "Number", JS_VALUE_TYPE, JSValue::kSize,
|
728
|
-
|
729
|
-
true);
|
864
|
+
isolate->initial_object_prototype(),
|
865
|
+
Builtins::kIllegal, true);
|
730
866
|
global_context()->set_number_function(*number_fun);
|
731
867
|
}
|
732
868
|
|
733
869
|
{ // --- B o o l e a n ---
|
734
870
|
Handle<JSFunction> boolean_fun =
|
735
871
|
InstallFunction(global, "Boolean", JS_VALUE_TYPE, JSValue::kSize,
|
736
|
-
|
737
|
-
true);
|
872
|
+
isolate->initial_object_prototype(),
|
873
|
+
Builtins::kIllegal, true);
|
738
874
|
global_context()->set_boolean_function(*boolean_fun);
|
739
875
|
}
|
740
876
|
|
741
877
|
{ // --- S t r i n g ---
|
742
878
|
Handle<JSFunction> string_fun =
|
743
879
|
InstallFunction(global, "String", JS_VALUE_TYPE, JSValue::kSize,
|
744
|
-
|
745
|
-
true);
|
880
|
+
isolate->initial_object_prototype(),
|
881
|
+
Builtins::kIllegal, true);
|
746
882
|
string_fun->shared()->set_construct_stub(
|
747
|
-
|
883
|
+
isolate->builtins()->builtin(Builtins::kStringConstructCode));
|
748
884
|
global_context()->set_string_function(*string_fun);
|
749
885
|
// Add 'length' property to strings.
|
750
886
|
Handle<DescriptorArray> string_descriptors =
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
887
|
+
factory->CopyAppendProxyDescriptor(
|
888
|
+
factory->empty_descriptor_array(),
|
889
|
+
factory->length_symbol(),
|
890
|
+
factory->NewProxy(&Accessors::StringLength),
|
755
891
|
static_cast<PropertyAttributes>(DONT_ENUM |
|
756
892
|
DONT_DELETE |
|
757
893
|
READ_ONLY));
|
@@ -765,8 +901,8 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
|
765
901
|
// Builtin functions for Date.prototype.
|
766
902
|
Handle<JSFunction> date_fun =
|
767
903
|
InstallFunction(global, "Date", JS_VALUE_TYPE, JSValue::kSize,
|
768
|
-
|
769
|
-
true);
|
904
|
+
isolate->initial_object_prototype(),
|
905
|
+
Builtins::kIllegal, true);
|
770
906
|
|
771
907
|
global_context()->set_date_function(*date_fun);
|
772
908
|
}
|
@@ -776,8 +912,8 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
|
776
912
|
// Builtin functions for RegExp.prototype.
|
777
913
|
Handle<JSFunction> regexp_fun =
|
778
914
|
InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize,
|
779
|
-
|
780
|
-
true);
|
915
|
+
isolate->initial_object_prototype(),
|
916
|
+
Builtins::kIllegal, true);
|
781
917
|
global_context()->set_regexp_function(*regexp_fun);
|
782
918
|
|
783
919
|
ASSERT(regexp_fun->has_initial_map());
|
@@ -785,13 +921,13 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
|
785
921
|
|
786
922
|
ASSERT_EQ(0, initial_map->inobject_properties());
|
787
923
|
|
788
|
-
Handle<DescriptorArray> descriptors =
|
924
|
+
Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(5);
|
789
925
|
PropertyAttributes final =
|
790
926
|
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
|
791
927
|
int enum_index = 0;
|
792
928
|
{
|
793
929
|
// ECMA-262, section 15.10.7.1.
|
794
|
-
FieldDescriptor field(
|
930
|
+
FieldDescriptor field(heap->source_symbol(),
|
795
931
|
JSRegExp::kSourceFieldIndex,
|
796
932
|
final,
|
797
933
|
enum_index++);
|
@@ -799,7 +935,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
|
799
935
|
}
|
800
936
|
{
|
801
937
|
// ECMA-262, section 15.10.7.2.
|
802
|
-
FieldDescriptor field(
|
938
|
+
FieldDescriptor field(heap->global_symbol(),
|
803
939
|
JSRegExp::kGlobalFieldIndex,
|
804
940
|
final,
|
805
941
|
enum_index++);
|
@@ -807,7 +943,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
|
807
943
|
}
|
808
944
|
{
|
809
945
|
// ECMA-262, section 15.10.7.3.
|
810
|
-
FieldDescriptor field(
|
946
|
+
FieldDescriptor field(heap->ignore_case_symbol(),
|
811
947
|
JSRegExp::kIgnoreCaseFieldIndex,
|
812
948
|
final,
|
813
949
|
enum_index++);
|
@@ -815,7 +951,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
|
815
951
|
}
|
816
952
|
{
|
817
953
|
// ECMA-262, section 15.10.7.4.
|
818
|
-
FieldDescriptor field(
|
954
|
+
FieldDescriptor field(heap->multiline_symbol(),
|
819
955
|
JSRegExp::kMultilineFieldIndex,
|
820
956
|
final,
|
821
957
|
enum_index++);
|
@@ -825,7 +961,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
|
825
961
|
// ECMA-262, section 15.10.7.5.
|
826
962
|
PropertyAttributes writable =
|
827
963
|
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE);
|
828
|
-
FieldDescriptor field(
|
964
|
+
FieldDescriptor field(heap->last_index_symbol(),
|
829
965
|
JSRegExp::kLastIndexFieldIndex,
|
830
966
|
writable,
|
831
967
|
enum_index++);
|
@@ -844,13 +980,13 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
|
844
980
|
}
|
845
981
|
|
846
982
|
{ // -- J S O N
|
847
|
-
Handle<String> name =
|
848
|
-
Handle<JSFunction> cons =
|
983
|
+
Handle<String> name = factory->NewStringFromAscii(CStrVector("JSON"));
|
984
|
+
Handle<JSFunction> cons = factory->NewFunction(
|
849
985
|
name,
|
850
|
-
|
986
|
+
factory->the_hole_value());
|
851
987
|
cons->SetInstancePrototype(global_context()->initial_object_prototype());
|
852
988
|
cons->SetInstanceClassName(*name);
|
853
|
-
Handle<JSObject> json_object =
|
989
|
+
Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED);
|
854
990
|
ASSERT(json_object->IsJSObject());
|
855
991
|
SetLocalPropertyNoThrow(global, name, json_object, DONT_ENUM);
|
856
992
|
global_context()->set_json_object(*json_object);
|
@@ -860,14 +996,15 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
|
860
996
|
// Make sure we can recognize argument objects at runtime.
|
861
997
|
// This is done by introducing an anonymous function with
|
862
998
|
// class_name equals 'Arguments'.
|
863
|
-
Handle<String> symbol =
|
864
|
-
Handle<Code> code = Handle<Code>(
|
999
|
+
Handle<String> symbol = factory->LookupAsciiSymbol("Arguments");
|
1000
|
+
Handle<Code> code = Handle<Code>(
|
1001
|
+
isolate->builtins()->builtin(Builtins::kIllegal));
|
865
1002
|
Handle<JSObject> prototype =
|
866
1003
|
Handle<JSObject>(
|
867
1004
|
JSObject::cast(global_context()->object_function()->prototype()));
|
868
1005
|
|
869
1006
|
Handle<JSFunction> function =
|
870
|
-
|
1007
|
+
factory->NewFunctionWithPrototype(symbol,
|
871
1008
|
JS_OBJECT_TYPE,
|
872
1009
|
JSObject::kHeaderSize,
|
873
1010
|
prototype,
|
@@ -876,30 +1013,101 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
|
876
1013
|
ASSERT(!function->has_initial_map());
|
877
1014
|
function->shared()->set_instance_class_name(*symbol);
|
878
1015
|
function->shared()->set_expected_nof_properties(2);
|
879
|
-
Handle<JSObject> result =
|
1016
|
+
Handle<JSObject> result = factory->NewJSObject(function);
|
880
1017
|
|
881
1018
|
global_context()->set_arguments_boilerplate(*result);
|
882
|
-
// Note:
|
883
|
-
//
|
884
|
-
SetLocalPropertyNoThrow(result,
|
885
|
-
|
1019
|
+
// Note: length must be added as the first property and
|
1020
|
+
// callee must be added as the second property.
|
1021
|
+
SetLocalPropertyNoThrow(result, factory->length_symbol(),
|
1022
|
+
factory->undefined_value(),
|
886
1023
|
DONT_ENUM);
|
887
|
-
SetLocalPropertyNoThrow(result,
|
888
|
-
|
1024
|
+
SetLocalPropertyNoThrow(result, factory->callee_symbol(),
|
1025
|
+
factory->undefined_value(),
|
889
1026
|
DONT_ENUM);
|
890
1027
|
|
891
1028
|
#ifdef DEBUG
|
892
1029
|
LookupResult lookup;
|
893
|
-
result->LocalLookup(
|
1030
|
+
result->LocalLookup(heap->callee_symbol(), &lookup);
|
894
1031
|
ASSERT(lookup.IsProperty() && (lookup.type() == FIELD));
|
895
|
-
ASSERT(lookup.GetFieldIndex() == Heap::
|
1032
|
+
ASSERT(lookup.GetFieldIndex() == Heap::kArgumentsCalleeIndex);
|
896
1033
|
|
897
|
-
result->LocalLookup(
|
1034
|
+
result->LocalLookup(heap->length_symbol(), &lookup);
|
898
1035
|
ASSERT(lookup.IsProperty() && (lookup.type() == FIELD));
|
899
|
-
ASSERT(lookup.GetFieldIndex() == Heap::
|
1036
|
+
ASSERT(lookup.GetFieldIndex() == Heap::kArgumentsLengthIndex);
|
900
1037
|
|
901
|
-
ASSERT(result->map()->inobject_properties() > Heap::
|
902
|
-
ASSERT(result->map()->inobject_properties() > Heap::
|
1038
|
+
ASSERT(result->map()->inobject_properties() > Heap::kArgumentsCalleeIndex);
|
1039
|
+
ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex);
|
1040
|
+
|
1041
|
+
// Check the state of the object.
|
1042
|
+
ASSERT(result->HasFastProperties());
|
1043
|
+
ASSERT(result->HasFastElements());
|
1044
|
+
#endif
|
1045
|
+
}
|
1046
|
+
|
1047
|
+
{ // --- strict mode arguments boilerplate
|
1048
|
+
const PropertyAttributes attributes =
|
1049
|
+
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
|
1050
|
+
|
1051
|
+
// Create the ThrowTypeError functions.
|
1052
|
+
Handle<FixedArray> callee = factory->NewFixedArray(2, TENURED);
|
1053
|
+
Handle<FixedArray> caller = factory->NewFixedArray(2, TENURED);
|
1054
|
+
|
1055
|
+
Handle<JSFunction> callee_throw =
|
1056
|
+
CreateThrowTypeErrorFunction(Builtins::kStrictArgumentsCallee);
|
1057
|
+
Handle<JSFunction> caller_throw =
|
1058
|
+
CreateThrowTypeErrorFunction(Builtins::kStrictArgumentsCaller);
|
1059
|
+
|
1060
|
+
// Install the ThrowTypeError functions.
|
1061
|
+
callee->set(0, *callee_throw);
|
1062
|
+
callee->set(1, *callee_throw);
|
1063
|
+
caller->set(0, *caller_throw);
|
1064
|
+
caller->set(1, *caller_throw);
|
1065
|
+
|
1066
|
+
// Create the descriptor array for the arguments object.
|
1067
|
+
Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(3);
|
1068
|
+
{ // length
|
1069
|
+
FieldDescriptor d(*factory->length_symbol(), 0, DONT_ENUM);
|
1070
|
+
descriptors->Set(0, &d);
|
1071
|
+
}
|
1072
|
+
{ // callee
|
1073
|
+
CallbacksDescriptor d(*factory->callee_symbol(), *callee, attributes);
|
1074
|
+
descriptors->Set(1, &d);
|
1075
|
+
}
|
1076
|
+
{ // caller
|
1077
|
+
CallbacksDescriptor d(*factory->caller_symbol(), *caller, attributes);
|
1078
|
+
descriptors->Set(2, &d);
|
1079
|
+
}
|
1080
|
+
descriptors->Sort();
|
1081
|
+
|
1082
|
+
// Create the map. Allocate one in-object field for length.
|
1083
|
+
Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE,
|
1084
|
+
Heap::kArgumentsObjectSizeStrict);
|
1085
|
+
map->set_instance_descriptors(*descriptors);
|
1086
|
+
map->set_function_with_prototype(true);
|
1087
|
+
map->set_prototype(global_context()->object_function()->prototype());
|
1088
|
+
map->set_pre_allocated_property_fields(1);
|
1089
|
+
map->set_inobject_properties(1);
|
1090
|
+
|
1091
|
+
// Copy constructor from the non-strict arguments boilerplate.
|
1092
|
+
map->set_constructor(
|
1093
|
+
global_context()->arguments_boilerplate()->map()->constructor());
|
1094
|
+
|
1095
|
+
// Allocate the arguments boilerplate object.
|
1096
|
+
Handle<JSObject> result = factory->NewJSObjectFromMap(map);
|
1097
|
+
global_context()->set_strict_mode_arguments_boilerplate(*result);
|
1098
|
+
|
1099
|
+
// Add length property only for strict mode boilerplate.
|
1100
|
+
SetLocalPropertyNoThrow(result, factory->length_symbol(),
|
1101
|
+
factory->undefined_value(),
|
1102
|
+
DONT_ENUM);
|
1103
|
+
|
1104
|
+
#ifdef DEBUG
|
1105
|
+
LookupResult lookup;
|
1106
|
+
result->LocalLookup(heap->length_symbol(), &lookup);
|
1107
|
+
ASSERT(lookup.IsProperty() && (lookup.type() == FIELD));
|
1108
|
+
ASSERT(lookup.GetFieldIndex() == Heap::kArgumentsLengthIndex);
|
1109
|
+
|
1110
|
+
ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex);
|
903
1111
|
|
904
1112
|
// Check the state of the object.
|
905
1113
|
ASSERT(result->HasFastProperties());
|
@@ -909,15 +1117,16 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
|
909
1117
|
|
910
1118
|
{ // --- context extension
|
911
1119
|
// Create a function for the context extension objects.
|
912
|
-
Handle<Code> code = Handle<Code>(
|
1120
|
+
Handle<Code> code = Handle<Code>(
|
1121
|
+
isolate->builtins()->builtin(Builtins::kIllegal));
|
913
1122
|
Handle<JSFunction> context_extension_fun =
|
914
|
-
|
1123
|
+
factory->NewFunction(factory->empty_symbol(),
|
915
1124
|
JS_CONTEXT_EXTENSION_OBJECT_TYPE,
|
916
1125
|
JSObject::kHeaderSize,
|
917
1126
|
code,
|
918
1127
|
true);
|
919
1128
|
|
920
|
-
Handle<String> name =
|
1129
|
+
Handle<String> name = factory->LookupAsciiSymbol("context_extension");
|
921
1130
|
context_extension_fun->shared()->set_instance_class_name(*name);
|
922
1131
|
global_context()->set_context_extension_function(*context_extension_fun);
|
923
1132
|
}
|
@@ -926,9 +1135,10 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
|
926
1135
|
{
|
927
1136
|
// Setup the call-as-function delegate.
|
928
1137
|
Handle<Code> code =
|
929
|
-
Handle<Code>(
|
1138
|
+
Handle<Code>(isolate->builtins()->builtin(
|
1139
|
+
Builtins::kHandleApiCallAsFunction));
|
930
1140
|
Handle<JSFunction> delegate =
|
931
|
-
|
1141
|
+
factory->NewFunction(factory->empty_symbol(), JS_OBJECT_TYPE,
|
932
1142
|
JSObject::kHeaderSize, code, true);
|
933
1143
|
global_context()->set_call_as_function_delegate(*delegate);
|
934
1144
|
delegate->shared()->DontAdaptArguments();
|
@@ -937,44 +1147,47 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
|
937
1147
|
{
|
938
1148
|
// Setup the call-as-constructor delegate.
|
939
1149
|
Handle<Code> code =
|
940
|
-
Handle<Code>(
|
1150
|
+
Handle<Code>(isolate->builtins()->builtin(
|
1151
|
+
Builtins::kHandleApiCallAsConstructor));
|
941
1152
|
Handle<JSFunction> delegate =
|
942
|
-
|
1153
|
+
factory->NewFunction(factory->empty_symbol(), JS_OBJECT_TYPE,
|
943
1154
|
JSObject::kHeaderSize, code, true);
|
944
1155
|
global_context()->set_call_as_constructor_delegate(*delegate);
|
945
1156
|
delegate->shared()->DontAdaptArguments();
|
946
1157
|
}
|
947
1158
|
|
948
1159
|
// Initialize the out of memory slot.
|
949
|
-
global_context()->set_out_of_memory(
|
1160
|
+
global_context()->set_out_of_memory(heap->false_value());
|
950
1161
|
|
951
1162
|
// Initialize the data slot.
|
952
|
-
global_context()->set_data(
|
1163
|
+
global_context()->set_data(heap->undefined_value());
|
953
1164
|
}
|
954
1165
|
|
955
1166
|
|
956
1167
|
bool Genesis::CompileBuiltin(int index) {
|
957
1168
|
Vector<const char> name = Natives::GetScriptName(index);
|
958
|
-
Handle<String> source_code =
|
1169
|
+
Handle<String> source_code =
|
1170
|
+
Isolate::Current()->bootstrapper()->NativesSourceLookup(index);
|
959
1171
|
return CompileNative(name, source_code);
|
960
1172
|
}
|
961
1173
|
|
962
1174
|
|
963
1175
|
bool Genesis::CompileNative(Vector<const char> name, Handle<String> source) {
|
964
1176
|
HandleScope scope;
|
1177
|
+
Isolate* isolate = Isolate::Current();
|
965
1178
|
#ifdef ENABLE_DEBUGGER_SUPPORT
|
966
|
-
|
1179
|
+
isolate->debugger()->set_compiling_natives(true);
|
967
1180
|
#endif
|
968
1181
|
bool result = CompileScriptCached(name,
|
969
1182
|
source,
|
970
1183
|
NULL,
|
971
1184
|
NULL,
|
972
|
-
Handle<Context>(
|
1185
|
+
Handle<Context>(isolate->context()),
|
973
1186
|
true);
|
974
|
-
ASSERT(
|
975
|
-
if (!result)
|
1187
|
+
ASSERT(isolate->has_pending_exception() != result);
|
1188
|
+
if (!result) isolate->clear_pending_exception();
|
976
1189
|
#ifdef ENABLE_DEBUGGER_SUPPORT
|
977
|
-
|
1190
|
+
isolate->debugger()->set_compiling_natives(false);
|
978
1191
|
#endif
|
979
1192
|
return result;
|
980
1193
|
}
|
@@ -986,6 +1199,7 @@ bool Genesis::CompileScriptCached(Vector<const char> name,
|
|
986
1199
|
v8::Extension* extension,
|
987
1200
|
Handle<Context> top_context,
|
988
1201
|
bool use_runtime_context) {
|
1202
|
+
Factory* factory = Isolate::Current()->factory();
|
989
1203
|
HandleScope scope;
|
990
1204
|
Handle<SharedFunctionInfo> function_info;
|
991
1205
|
|
@@ -993,7 +1207,7 @@ bool Genesis::CompileScriptCached(Vector<const char> name,
|
|
993
1207
|
// function and insert it into the cache.
|
994
1208
|
if (cache == NULL || !cache->Lookup(name, &function_info)) {
|
995
1209
|
ASSERT(source->IsAsciiRepresentation());
|
996
|
-
Handle<String> script_name =
|
1210
|
+
Handle<String> script_name = factory->NewStringFromUtf8(name);
|
997
1211
|
function_info = Compiler::Compile(
|
998
1212
|
source,
|
999
1213
|
script_name,
|
@@ -1016,7 +1230,7 @@ bool Genesis::CompileScriptCached(Vector<const char> name,
|
|
1016
1230
|
? Handle<Context>(top_context->runtime_context())
|
1017
1231
|
: top_context);
|
1018
1232
|
Handle<JSFunction> fun =
|
1019
|
-
|
1233
|
+
factory->NewFunctionFromSharedFunctionInfo(function_info, context);
|
1020
1234
|
|
1021
1235
|
// Call function using either the runtime object or the global
|
1022
1236
|
// object as the receiver. Provide no parameters.
|
@@ -1032,12 +1246,15 @@ bool Genesis::CompileScriptCached(Vector<const char> name,
|
|
1032
1246
|
}
|
1033
1247
|
|
1034
1248
|
|
1035
|
-
#define INSTALL_NATIVE(Type, name, var)
|
1036
|
-
Handle<String> var##_name =
|
1037
|
-
|
1038
|
-
global_context()->builtins()->GetPropertyNoExceptionThrown(*var##_name)
|
1249
|
+
#define INSTALL_NATIVE(Type, name, var) \
|
1250
|
+
Handle<String> var##_name = factory->LookupAsciiSymbol(name); \
|
1251
|
+
Object* var##_native = \
|
1252
|
+
global_context()->builtins()->GetPropertyNoExceptionThrown(*var##_name); \
|
1253
|
+
global_context()->set_##var(Type::cast(var##_native));
|
1254
|
+
|
1039
1255
|
|
1040
1256
|
void Genesis::InstallNativeFunctions() {
|
1257
|
+
Factory* factory = Isolate::Current()->factory();
|
1041
1258
|
HandleScope scope;
|
1042
1259
|
INSTALL_NATIVE(JSFunction, "CreateDate", create_date_fun);
|
1043
1260
|
INSTALL_NATIVE(JSFunction, "ToNumber", to_number_fun);
|
@@ -1060,21 +1277,25 @@ void Genesis::InstallNativeFunctions() {
|
|
1060
1277
|
|
1061
1278
|
bool Genesis::InstallNatives() {
|
1062
1279
|
HandleScope scope;
|
1280
|
+
Isolate* isolate = Isolate::Current();
|
1281
|
+
Factory* factory = isolate->factory();
|
1282
|
+
Heap* heap = isolate->heap();
|
1063
1283
|
|
1064
1284
|
// Create a function for the builtins object. Allocate space for the
|
1065
1285
|
// JavaScript builtins, a reference to the builtins object
|
1066
1286
|
// (itself) and a reference to the global_context directly in the object.
|
1067
|
-
Handle<Code> code = Handle<Code>(
|
1287
|
+
Handle<Code> code = Handle<Code>(
|
1288
|
+
isolate->builtins()->builtin(Builtins::kIllegal));
|
1068
1289
|
Handle<JSFunction> builtins_fun =
|
1069
|
-
|
1290
|
+
factory->NewFunction(factory->empty_symbol(), JS_BUILTINS_OBJECT_TYPE,
|
1070
1291
|
JSBuiltinsObject::kSize, code, true);
|
1071
1292
|
|
1072
|
-
Handle<String> name =
|
1293
|
+
Handle<String> name = factory->LookupAsciiSymbol("builtins");
|
1073
1294
|
builtins_fun->shared()->set_instance_class_name(*name);
|
1074
1295
|
|
1075
1296
|
// Allocate the builtins object.
|
1076
1297
|
Handle<JSBuiltinsObject> builtins =
|
1077
|
-
Handle<JSBuiltinsObject>::cast(
|
1298
|
+
Handle<JSBuiltinsObject>::cast(factory->NewGlobalObject(builtins_fun));
|
1078
1299
|
builtins->set_builtins(*builtins);
|
1079
1300
|
builtins->set_global_context(*global_context());
|
1080
1301
|
builtins->set_global_receiver(*builtins);
|
@@ -1085,7 +1306,7 @@ bool Genesis::InstallNatives() {
|
|
1085
1306
|
// global object.
|
1086
1307
|
static const PropertyAttributes attributes =
|
1087
1308
|
static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
|
1088
|
-
Handle<String> global_symbol =
|
1309
|
+
Handle<String> global_symbol = factory->LookupAsciiSymbol("global");
|
1089
1310
|
Handle<Object> global_obj(global_context()->global());
|
1090
1311
|
SetLocalPropertyNoThrow(builtins, global_symbol, global_obj, attributes);
|
1091
1312
|
|
@@ -1094,12 +1315,12 @@ bool Genesis::InstallNatives() {
|
|
1094
1315
|
|
1095
1316
|
// Create a bridge function that has context in the global context.
|
1096
1317
|
Handle<JSFunction> bridge =
|
1097
|
-
|
1098
|
-
ASSERT(bridge->context() == *
|
1318
|
+
factory->NewFunction(factory->empty_symbol(), factory->undefined_value());
|
1319
|
+
ASSERT(bridge->context() == *isolate->global_context());
|
1099
1320
|
|
1100
1321
|
// Allocate the builtins context.
|
1101
1322
|
Handle<Context> context =
|
1102
|
-
|
1323
|
+
factory->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, bridge);
|
1103
1324
|
context->set_global(*builtins); // override builtins global object
|
1104
1325
|
|
1105
1326
|
global_context()->set_runtime_context(*context);
|
@@ -1108,113 +1329,113 @@ bool Genesis::InstallNatives() {
|
|
1108
1329
|
// Builtin functions for Script.
|
1109
1330
|
Handle<JSFunction> script_fun =
|
1110
1331
|
InstallFunction(builtins, "Script", JS_VALUE_TYPE, JSValue::kSize,
|
1111
|
-
|
1112
|
-
false);
|
1332
|
+
isolate->initial_object_prototype(),
|
1333
|
+
Builtins::kIllegal, false);
|
1113
1334
|
Handle<JSObject> prototype =
|
1114
|
-
|
1335
|
+
factory->NewJSObject(isolate->object_function(), TENURED);
|
1115
1336
|
SetPrototype(script_fun, prototype);
|
1116
1337
|
global_context()->set_script_function(*script_fun);
|
1117
1338
|
|
1118
1339
|
// Add 'source' and 'data' property to scripts.
|
1119
1340
|
PropertyAttributes common_attributes =
|
1120
1341
|
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
|
1121
|
-
Handle<Proxy> proxy_source =
|
1342
|
+
Handle<Proxy> proxy_source = factory->NewProxy(&Accessors::ScriptSource);
|
1122
1343
|
Handle<DescriptorArray> script_descriptors =
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1344
|
+
factory->CopyAppendProxyDescriptor(
|
1345
|
+
factory->empty_descriptor_array(),
|
1346
|
+
factory->LookupAsciiSymbol("source"),
|
1126
1347
|
proxy_source,
|
1127
1348
|
common_attributes);
|
1128
|
-
Handle<Proxy> proxy_name =
|
1349
|
+
Handle<Proxy> proxy_name = factory->NewProxy(&Accessors::ScriptName);
|
1129
1350
|
script_descriptors =
|
1130
|
-
|
1351
|
+
factory->CopyAppendProxyDescriptor(
|
1131
1352
|
script_descriptors,
|
1132
|
-
|
1353
|
+
factory->LookupAsciiSymbol("name"),
|
1133
1354
|
proxy_name,
|
1134
1355
|
common_attributes);
|
1135
|
-
Handle<Proxy> proxy_id =
|
1356
|
+
Handle<Proxy> proxy_id = factory->NewProxy(&Accessors::ScriptId);
|
1136
1357
|
script_descriptors =
|
1137
|
-
|
1358
|
+
factory->CopyAppendProxyDescriptor(
|
1138
1359
|
script_descriptors,
|
1139
|
-
|
1360
|
+
factory->LookupAsciiSymbol("id"),
|
1140
1361
|
proxy_id,
|
1141
1362
|
common_attributes);
|
1142
1363
|
Handle<Proxy> proxy_line_offset =
|
1143
|
-
|
1364
|
+
factory->NewProxy(&Accessors::ScriptLineOffset);
|
1144
1365
|
script_descriptors =
|
1145
|
-
|
1366
|
+
factory->CopyAppendProxyDescriptor(
|
1146
1367
|
script_descriptors,
|
1147
|
-
|
1368
|
+
factory->LookupAsciiSymbol("line_offset"),
|
1148
1369
|
proxy_line_offset,
|
1149
1370
|
common_attributes);
|
1150
1371
|
Handle<Proxy> proxy_column_offset =
|
1151
|
-
|
1372
|
+
factory->NewProxy(&Accessors::ScriptColumnOffset);
|
1152
1373
|
script_descriptors =
|
1153
|
-
|
1374
|
+
factory->CopyAppendProxyDescriptor(
|
1154
1375
|
script_descriptors,
|
1155
|
-
|
1376
|
+
factory->LookupAsciiSymbol("column_offset"),
|
1156
1377
|
proxy_column_offset,
|
1157
1378
|
common_attributes);
|
1158
|
-
Handle<Proxy> proxy_data =
|
1379
|
+
Handle<Proxy> proxy_data = factory->NewProxy(&Accessors::ScriptData);
|
1159
1380
|
script_descriptors =
|
1160
|
-
|
1381
|
+
factory->CopyAppendProxyDescriptor(
|
1161
1382
|
script_descriptors,
|
1162
|
-
|
1383
|
+
factory->LookupAsciiSymbol("data"),
|
1163
1384
|
proxy_data,
|
1164
1385
|
common_attributes);
|
1165
|
-
Handle<Proxy> proxy_type =
|
1386
|
+
Handle<Proxy> proxy_type = factory->NewProxy(&Accessors::ScriptType);
|
1166
1387
|
script_descriptors =
|
1167
|
-
|
1388
|
+
factory->CopyAppendProxyDescriptor(
|
1168
1389
|
script_descriptors,
|
1169
|
-
|
1390
|
+
factory->LookupAsciiSymbol("type"),
|
1170
1391
|
proxy_type,
|
1171
1392
|
common_attributes);
|
1172
1393
|
Handle<Proxy> proxy_compilation_type =
|
1173
|
-
|
1394
|
+
factory->NewProxy(&Accessors::ScriptCompilationType);
|
1174
1395
|
script_descriptors =
|
1175
|
-
|
1396
|
+
factory->CopyAppendProxyDescriptor(
|
1176
1397
|
script_descriptors,
|
1177
|
-
|
1398
|
+
factory->LookupAsciiSymbol("compilation_type"),
|
1178
1399
|
proxy_compilation_type,
|
1179
1400
|
common_attributes);
|
1180
1401
|
Handle<Proxy> proxy_line_ends =
|
1181
|
-
|
1402
|
+
factory->NewProxy(&Accessors::ScriptLineEnds);
|
1182
1403
|
script_descriptors =
|
1183
|
-
|
1404
|
+
factory->CopyAppendProxyDescriptor(
|
1184
1405
|
script_descriptors,
|
1185
|
-
|
1406
|
+
factory->LookupAsciiSymbol("line_ends"),
|
1186
1407
|
proxy_line_ends,
|
1187
1408
|
common_attributes);
|
1188
1409
|
Handle<Proxy> proxy_context_data =
|
1189
|
-
|
1410
|
+
factory->NewProxy(&Accessors::ScriptContextData);
|
1190
1411
|
script_descriptors =
|
1191
|
-
|
1412
|
+
factory->CopyAppendProxyDescriptor(
|
1192
1413
|
script_descriptors,
|
1193
|
-
|
1414
|
+
factory->LookupAsciiSymbol("context_data"),
|
1194
1415
|
proxy_context_data,
|
1195
1416
|
common_attributes);
|
1196
1417
|
Handle<Proxy> proxy_eval_from_script =
|
1197
|
-
|
1418
|
+
factory->NewProxy(&Accessors::ScriptEvalFromScript);
|
1198
1419
|
script_descriptors =
|
1199
|
-
|
1420
|
+
factory->CopyAppendProxyDescriptor(
|
1200
1421
|
script_descriptors,
|
1201
|
-
|
1422
|
+
factory->LookupAsciiSymbol("eval_from_script"),
|
1202
1423
|
proxy_eval_from_script,
|
1203
1424
|
common_attributes);
|
1204
1425
|
Handle<Proxy> proxy_eval_from_script_position =
|
1205
|
-
|
1426
|
+
factory->NewProxy(&Accessors::ScriptEvalFromScriptPosition);
|
1206
1427
|
script_descriptors =
|
1207
|
-
|
1428
|
+
factory->CopyAppendProxyDescriptor(
|
1208
1429
|
script_descriptors,
|
1209
|
-
|
1430
|
+
factory->LookupAsciiSymbol("eval_from_script_position"),
|
1210
1431
|
proxy_eval_from_script_position,
|
1211
1432
|
common_attributes);
|
1212
1433
|
Handle<Proxy> proxy_eval_from_function_name =
|
1213
|
-
|
1434
|
+
factory->NewProxy(&Accessors::ScriptEvalFromFunctionName);
|
1214
1435
|
script_descriptors =
|
1215
|
-
|
1436
|
+
factory->CopyAppendProxyDescriptor(
|
1216
1437
|
script_descriptors,
|
1217
|
-
|
1438
|
+
factory->LookupAsciiSymbol("eval_from_function_name"),
|
1218
1439
|
proxy_eval_from_function_name,
|
1219
1440
|
common_attributes);
|
1220
1441
|
|
@@ -1222,9 +1443,9 @@ bool Genesis::InstallNatives() {
|
|
1222
1443
|
script_map->set_instance_descriptors(*script_descriptors);
|
1223
1444
|
|
1224
1445
|
// Allocate the empty script.
|
1225
|
-
Handle<Script> script =
|
1446
|
+
Handle<Script> script = factory->NewScript(factory->empty_string());
|
1226
1447
|
script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
|
1227
|
-
|
1448
|
+
heap->public_set_empty_script(*script);
|
1228
1449
|
}
|
1229
1450
|
{
|
1230
1451
|
// Builtin function for OpaqueReference -- a JSValue-based object,
|
@@ -1232,14 +1453,52 @@ bool Genesis::InstallNatives() {
|
|
1232
1453
|
// objects, that JavaScript code may not access.
|
1233
1454
|
Handle<JSFunction> opaque_reference_fun =
|
1234
1455
|
InstallFunction(builtins, "OpaqueReference", JS_VALUE_TYPE,
|
1235
|
-
JSValue::kSize,
|
1236
|
-
|
1456
|
+
JSValue::kSize,
|
1457
|
+
isolate->initial_object_prototype(),
|
1458
|
+
Builtins::kIllegal, false);
|
1237
1459
|
Handle<JSObject> prototype =
|
1238
|
-
|
1460
|
+
factory->NewJSObject(isolate->object_function(), TENURED);
|
1239
1461
|
SetPrototype(opaque_reference_fun, prototype);
|
1240
1462
|
global_context()->set_opaque_reference_function(*opaque_reference_fun);
|
1241
1463
|
}
|
1242
1464
|
|
1465
|
+
{ // --- I n t e r n a l A r r a y ---
|
1466
|
+
// An array constructor on the builtins object that works like
|
1467
|
+
// the public Array constructor, except that its prototype
|
1468
|
+
// doesn't inherit from Object.prototype.
|
1469
|
+
// To be used only for internal work by builtins. Instances
|
1470
|
+
// must not be leaked to user code.
|
1471
|
+
// Only works correctly when called as a constructor. The normal
|
1472
|
+
// Array code uses Array.prototype as prototype when called as
|
1473
|
+
// a function.
|
1474
|
+
Handle<JSFunction> array_function =
|
1475
|
+
InstallFunction(builtins,
|
1476
|
+
"InternalArray",
|
1477
|
+
JS_ARRAY_TYPE,
|
1478
|
+
JSArray::kSize,
|
1479
|
+
isolate->initial_object_prototype(),
|
1480
|
+
Builtins::kArrayCode,
|
1481
|
+
true);
|
1482
|
+
Handle<JSObject> prototype =
|
1483
|
+
factory->NewJSObject(isolate->object_function(), TENURED);
|
1484
|
+
SetPrototype(array_function, prototype);
|
1485
|
+
|
1486
|
+
array_function->shared()->set_construct_stub(
|
1487
|
+
isolate->builtins()->builtin(Builtins::kArrayConstructCode));
|
1488
|
+
array_function->shared()->DontAdaptArguments();
|
1489
|
+
|
1490
|
+
// Make "length" magic on instances.
|
1491
|
+
Handle<DescriptorArray> array_descriptors =
|
1492
|
+
factory->CopyAppendProxyDescriptor(
|
1493
|
+
factory->empty_descriptor_array(),
|
1494
|
+
factory->length_symbol(),
|
1495
|
+
factory->NewProxy(&Accessors::ArrayLength),
|
1496
|
+
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE));
|
1497
|
+
|
1498
|
+
array_function->initial_map()->set_instance_descriptors(
|
1499
|
+
*array_descriptors);
|
1500
|
+
}
|
1501
|
+
|
1243
1502
|
if (FLAG_disable_native_files) {
|
1244
1503
|
PrintF("Warning: Running without installed natives!\n");
|
1245
1504
|
return true;
|
@@ -1270,9 +1529,9 @@ bool Genesis::InstallNatives() {
|
|
1270
1529
|
InstallBuiltinFunctionIds();
|
1271
1530
|
|
1272
1531
|
// Install Function.prototype.call and apply.
|
1273
|
-
{ Handle<String> key =
|
1532
|
+
{ Handle<String> key = factory->function_class_symbol();
|
1274
1533
|
Handle<JSFunction> function =
|
1275
|
-
Handle<JSFunction>::cast(GetProperty(
|
1534
|
+
Handle<JSFunction>::cast(GetProperty(isolate->global(), key));
|
1276
1535
|
Handle<JSObject> proto =
|
1277
1536
|
Handle<JSObject>(JSObject::cast(function->instance_prototype()));
|
1278
1537
|
|
@@ -1280,12 +1539,12 @@ bool Genesis::InstallNatives() {
|
|
1280
1539
|
Handle<JSFunction> call =
|
1281
1540
|
InstallFunction(proto, "call", JS_OBJECT_TYPE, JSObject::kHeaderSize,
|
1282
1541
|
Handle<JSObject>::null(),
|
1283
|
-
Builtins::
|
1542
|
+
Builtins::kFunctionCall,
|
1284
1543
|
false);
|
1285
1544
|
Handle<JSFunction> apply =
|
1286
1545
|
InstallFunction(proto, "apply", JS_OBJECT_TYPE, JSObject::kHeaderSize,
|
1287
1546
|
Handle<JSObject>::null(),
|
1288
|
-
Builtins::
|
1547
|
+
Builtins::kFunctionApply,
|
1289
1548
|
false);
|
1290
1549
|
|
1291
1550
|
// Make sure that Function.prototype.call appears to be compiled.
|
@@ -1314,7 +1573,7 @@ bool Genesis::InstallNatives() {
|
|
1314
1573
|
|
1315
1574
|
// Add initial map.
|
1316
1575
|
Handle<Map> initial_map =
|
1317
|
-
|
1576
|
+
factory->NewMap(JS_ARRAY_TYPE, JSRegExpResult::kSize);
|
1318
1577
|
initial_map->set_constructor(*array_constructor);
|
1319
1578
|
|
1320
1579
|
// Set prototype on map.
|
@@ -1328,13 +1587,13 @@ bool Genesis::InstallNatives() {
|
|
1328
1587
|
ASSERT_EQ(1, array_descriptors->number_of_descriptors());
|
1329
1588
|
|
1330
1589
|
Handle<DescriptorArray> reresult_descriptors =
|
1331
|
-
|
1590
|
+
factory->NewDescriptorArray(3);
|
1332
1591
|
|
1333
1592
|
reresult_descriptors->CopyFrom(0, *array_descriptors, 0);
|
1334
1593
|
|
1335
1594
|
int enum_index = 0;
|
1336
1595
|
{
|
1337
|
-
FieldDescriptor index_field(
|
1596
|
+
FieldDescriptor index_field(heap->index_symbol(),
|
1338
1597
|
JSRegExpResult::kIndexIndex,
|
1339
1598
|
NONE,
|
1340
1599
|
enum_index++);
|
@@ -1342,7 +1601,7 @@ bool Genesis::InstallNatives() {
|
|
1342
1601
|
}
|
1343
1602
|
|
1344
1603
|
{
|
1345
|
-
FieldDescriptor input_field(
|
1604
|
+
FieldDescriptor input_field(heap->input_symbol(),
|
1346
1605
|
JSRegExpResult::kInputIndex,
|
1347
1606
|
NONE,
|
1348
1607
|
enum_index++);
|
@@ -1358,6 +1617,7 @@ bool Genesis::InstallNatives() {
|
|
1358
1617
|
global_context()->set_regexp_result_map(*initial_map);
|
1359
1618
|
}
|
1360
1619
|
|
1620
|
+
|
1361
1621
|
#ifdef DEBUG
|
1362
1622
|
builtins->Verify();
|
1363
1623
|
#endif
|
@@ -1369,17 +1629,18 @@ bool Genesis::InstallNatives() {
|
|
1369
1629
|
static Handle<JSObject> ResolveBuiltinIdHolder(
|
1370
1630
|
Handle<Context> global_context,
|
1371
1631
|
const char* holder_expr) {
|
1632
|
+
Factory* factory = Isolate::Current()->factory();
|
1372
1633
|
Handle<GlobalObject> global(global_context->global());
|
1373
1634
|
const char* period_pos = strchr(holder_expr, '.');
|
1374
1635
|
if (period_pos == NULL) {
|
1375
1636
|
return Handle<JSObject>::cast(
|
1376
|
-
GetProperty(global,
|
1637
|
+
GetProperty(global, factory->LookupAsciiSymbol(holder_expr)));
|
1377
1638
|
}
|
1378
1639
|
ASSERT_EQ(".prototype", period_pos);
|
1379
1640
|
Vector<const char> property(holder_expr,
|
1380
1641
|
static_cast<int>(period_pos - holder_expr));
|
1381
1642
|
Handle<JSFunction> function = Handle<JSFunction>::cast(
|
1382
|
-
GetProperty(global,
|
1643
|
+
GetProperty(global, factory->LookupSymbol(property)));
|
1383
1644
|
return Handle<JSObject>(JSObject::cast(function->prototype()));
|
1384
1645
|
}
|
1385
1646
|
|
@@ -1387,7 +1648,7 @@ static Handle<JSObject> ResolveBuiltinIdHolder(
|
|
1387
1648
|
static void InstallBuiltinFunctionId(Handle<JSObject> holder,
|
1388
1649
|
const char* function_name,
|
1389
1650
|
BuiltinFunctionId id) {
|
1390
|
-
Handle<String> name =
|
1651
|
+
Handle<String> name = FACTORY->LookupAsciiSymbol(function_name);
|
1391
1652
|
Object* function_object = holder->GetProperty(*name)->ToObjectUnchecked();
|
1392
1653
|
Handle<JSFunction> function(JSFunction::cast(function_object));
|
1393
1654
|
function->shared()->set_function_data(Smi::FromInt(id));
|
@@ -1419,7 +1680,7 @@ static FixedArray* CreateCache(int size, JSFunction* factory) {
|
|
1419
1680
|
int array_size = JSFunctionResultCache::kEntriesIndex + 2 * size;
|
1420
1681
|
// Cannot use cast as object is not fully initialized yet.
|
1421
1682
|
JSFunctionResultCache* cache = reinterpret_cast<JSFunctionResultCache*>(
|
1422
|
-
*
|
1683
|
+
*FACTORY->NewFixedArrayWithHoles(array_size, TENURED));
|
1423
1684
|
cache->set(JSFunctionResultCache::kFactoryIndex, factory);
|
1424
1685
|
cache->MakeZeroSize();
|
1425
1686
|
return cache;
|
@@ -1433,7 +1694,7 @@ void Genesis::InstallJSFunctionResultCaches() {
|
|
1433
1694
|
#undef F
|
1434
1695
|
;
|
1435
1696
|
|
1436
|
-
Handle<FixedArray> caches =
|
1697
|
+
Handle<FixedArray> caches = FACTORY->NewFixedArray(kNumberOfCaches, TENURED);
|
1437
1698
|
|
1438
1699
|
int index = 0;
|
1439
1700
|
|
@@ -1452,19 +1713,17 @@ void Genesis::InstallJSFunctionResultCaches() {
|
|
1452
1713
|
|
1453
1714
|
void Genesis::InitializeNormalizedMapCaches() {
|
1454
1715
|
Handle<FixedArray> array(
|
1455
|
-
|
1716
|
+
FACTORY->NewFixedArray(NormalizedMapCache::kEntries, TENURED));
|
1456
1717
|
global_context()->set_normalized_map_cache(NormalizedMapCache::cast(*array));
|
1457
1718
|
}
|
1458
1719
|
|
1459
1720
|
|
1460
|
-
int BootstrapperActive::nesting_ = 0;
|
1461
|
-
|
1462
|
-
|
1463
1721
|
bool Bootstrapper::InstallExtensions(Handle<Context> global_context,
|
1464
1722
|
v8::ExtensionConfiguration* extensions) {
|
1723
|
+
Isolate* isolate = Isolate::Current();
|
1465
1724
|
BootstrapperActive active;
|
1466
|
-
SaveContext saved_context;
|
1467
|
-
|
1725
|
+
SaveContext saved_context(isolate);
|
1726
|
+
isolate->set_context(*global_context);
|
1468
1727
|
if (!Genesis::InstallExtensions(global_context, extensions)) return false;
|
1469
1728
|
Genesis::InstallSpecialObjects(global_context);
|
1470
1729
|
return true;
|
@@ -1472,20 +1731,21 @@ bool Bootstrapper::InstallExtensions(Handle<Context> global_context,
|
|
1472
1731
|
|
1473
1732
|
|
1474
1733
|
void Genesis::InstallSpecialObjects(Handle<Context> global_context) {
|
1734
|
+
Factory* factory = Isolate::Current()->factory();
|
1475
1735
|
HandleScope scope;
|
1476
1736
|
Handle<JSGlobalObject> js_global(
|
1477
1737
|
JSGlobalObject::cast(global_context->global()));
|
1478
1738
|
// Expose the natives in global if a name for it is specified.
|
1479
1739
|
if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) {
|
1480
1740
|
Handle<String> natives_string =
|
1481
|
-
|
1741
|
+
factory->LookupAsciiSymbol(FLAG_expose_natives_as);
|
1482
1742
|
SetLocalPropertyNoThrow(js_global, natives_string,
|
1483
1743
|
Handle<JSObject>(js_global->builtins()), DONT_ENUM);
|
1484
1744
|
}
|
1485
1745
|
|
1486
1746
|
Handle<Object> Error = GetProperty(js_global, "Error");
|
1487
1747
|
if (Error->IsJSObject()) {
|
1488
|
-
Handle<String> name =
|
1748
|
+
Handle<String> name = factory->LookupAsciiSymbol("stackTraceLimit");
|
1489
1749
|
SetLocalPropertyNoThrow(Handle<JSObject>::cast(Error),
|
1490
1750
|
name,
|
1491
1751
|
Handle<Smi>(Smi::FromInt(FLAG_stack_trace_limit)),
|
@@ -1495,18 +1755,19 @@ void Genesis::InstallSpecialObjects(Handle<Context> global_context) {
|
|
1495
1755
|
#ifdef ENABLE_DEBUGGER_SUPPORT
|
1496
1756
|
// Expose the debug global object in global if a name for it is specified.
|
1497
1757
|
if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) {
|
1758
|
+
Debug* debug = Isolate::Current()->debug();
|
1498
1759
|
// If loading fails we just bail out without installing the
|
1499
1760
|
// debugger but without tanking the whole context.
|
1500
|
-
if (!
|
1761
|
+
if (!debug->Load()) return;
|
1501
1762
|
// Set the security token for the debugger context to the same as
|
1502
1763
|
// the shell global context to allow calling between these (otherwise
|
1503
1764
|
// exposing debug global object doesn't make much sense).
|
1504
|
-
|
1765
|
+
debug->debug_context()->set_security_token(
|
1505
1766
|
global_context->security_token());
|
1506
1767
|
|
1507
1768
|
Handle<String> debug_string =
|
1508
|
-
|
1509
|
-
Handle<Object> global_proxy(
|
1769
|
+
factory->LookupAsciiSymbol(FLAG_expose_debug_as);
|
1770
|
+
Handle<Object> global_proxy(debug->debug_context()->global_proxy());
|
1510
1771
|
SetLocalPropertyNoThrow(js_global, debug_string, global_proxy, DONT_ENUM);
|
1511
1772
|
}
|
1512
1773
|
#endif
|
@@ -1515,6 +1776,10 @@ void Genesis::InstallSpecialObjects(Handle<Context> global_context) {
|
|
1515
1776
|
|
1516
1777
|
bool Genesis::InstallExtensions(Handle<Context> global_context,
|
1517
1778
|
v8::ExtensionConfiguration* extensions) {
|
1779
|
+
// TODO(isolates): Extensions on multiple isolates may take a little more
|
1780
|
+
// effort. (The external API reads 'ignore'-- does that mean
|
1781
|
+
// we can break the interface?)
|
1782
|
+
|
1518
1783
|
// Clear coloring of extension list
|
1519
1784
|
v8::RegisteredExtension* current = v8::RegisteredExtension::first_extension();
|
1520
1785
|
while (current != NULL) {
|
@@ -1582,17 +1847,18 @@ bool Genesis::InstallExtension(v8::RegisteredExtension* current) {
|
|
1582
1847
|
for (int i = 0; i < extension->dependency_count(); i++) {
|
1583
1848
|
if (!InstallExtension(extension->dependencies()[i])) return false;
|
1584
1849
|
}
|
1850
|
+
Isolate* isolate = Isolate::Current();
|
1585
1851
|
Vector<const char> source = CStrVector(extension->source());
|
1586
|
-
Handle<String> source_code =
|
1852
|
+
Handle<String> source_code = isolate->factory()->NewStringFromAscii(source);
|
1587
1853
|
bool result = CompileScriptCached(CStrVector(extension->name()),
|
1588
1854
|
source_code,
|
1589
|
-
|
1855
|
+
isolate->bootstrapper()->extensions_cache(),
|
1590
1856
|
extension,
|
1591
|
-
Handle<Context>(
|
1857
|
+
Handle<Context>(isolate->context()),
|
1592
1858
|
false);
|
1593
|
-
ASSERT(
|
1859
|
+
ASSERT(isolate->has_pending_exception() != result);
|
1594
1860
|
if (!result) {
|
1595
|
-
|
1861
|
+
isolate->clear_pending_exception();
|
1596
1862
|
}
|
1597
1863
|
current->set_state(v8::INSTALLED);
|
1598
1864
|
return result;
|
@@ -1603,7 +1869,7 @@ bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) {
|
|
1603
1869
|
HandleScope scope;
|
1604
1870
|
for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) {
|
1605
1871
|
Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i);
|
1606
|
-
Handle<String> name =
|
1872
|
+
Handle<String> name = FACTORY->LookupAsciiSymbol(Builtins::GetName(id));
|
1607
1873
|
Object* function_object = builtins->GetPropertyNoExceptionThrown(*name);
|
1608
1874
|
Handle<JSFunction> function
|
1609
1875
|
= Handle<JSFunction>(JSFunction::cast(function_object));
|
@@ -1652,12 +1918,13 @@ bool Genesis::ConfigureApiObject(Handle<JSObject> object,
|
|
1652
1918
|
ASSERT(object->IsInstanceOf(
|
1653
1919
|
FunctionTemplateInfo::cast(object_template->constructor())));
|
1654
1920
|
|
1921
|
+
Isolate* isolate = Isolate::Current();
|
1655
1922
|
bool pending_exception = false;
|
1656
1923
|
Handle<JSObject> obj =
|
1657
1924
|
Execution::InstantiateObject(object_template, &pending_exception);
|
1658
1925
|
if (pending_exception) {
|
1659
|
-
ASSERT(
|
1660
|
-
|
1926
|
+
ASSERT(isolate->has_pending_exception());
|
1927
|
+
isolate->clear_pending_exception();
|
1661
1928
|
return false;
|
1662
1929
|
}
|
1663
1930
|
TransferObject(obj, object);
|
@@ -1705,6 +1972,7 @@ void Genesis::TransferNamedProperties(Handle<JSObject> from,
|
|
1705
1972
|
break;
|
1706
1973
|
}
|
1707
1974
|
case MAP_TRANSITION:
|
1975
|
+
case EXTERNAL_ARRAY_TRANSITION:
|
1708
1976
|
case CONSTANT_TRANSITION:
|
1709
1977
|
case NULL_DESCRIPTOR:
|
1710
1978
|
// Ignore non-properties.
|
@@ -1748,7 +2016,7 @@ void Genesis::TransferIndexedProperties(Handle<JSObject> from,
|
|
1748
2016
|
// Cloning the elements array is sufficient.
|
1749
2017
|
Handle<FixedArray> from_elements =
|
1750
2018
|
Handle<FixedArray>(FixedArray::cast(from->elements()));
|
1751
|
-
Handle<FixedArray> to_elements =
|
2019
|
+
Handle<FixedArray> to_elements = FACTORY->CopyFixedArray(from_elements);
|
1752
2020
|
to->set_elements(*to_elements);
|
1753
2021
|
}
|
1754
2022
|
|
@@ -1764,29 +2032,31 @@ void Genesis::TransferObject(Handle<JSObject> from, Handle<JSObject> to) {
|
|
1764
2032
|
|
1765
2033
|
// Transfer the prototype (new map is needed).
|
1766
2034
|
Handle<Map> old_to_map = Handle<Map>(to->map());
|
1767
|
-
Handle<Map> new_to_map =
|
2035
|
+
Handle<Map> new_to_map = FACTORY->CopyMapDropTransitions(old_to_map);
|
1768
2036
|
new_to_map->set_prototype(from->map()->prototype());
|
1769
2037
|
to->set_map(*new_to_map);
|
1770
2038
|
}
|
1771
2039
|
|
1772
2040
|
|
1773
2041
|
void Genesis::MakeFunctionInstancePrototypeWritable() {
|
1774
|
-
//
|
1775
|
-
//
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1781
|
-
|
1782
|
-
|
1783
|
-
|
2042
|
+
// The maps with writable prototype are created in CreateEmptyFunction
|
2043
|
+
// and CreateStrictModeFunctionMaps respectively. Initially the maps are
|
2044
|
+
// created with read-only prototype for JS builtins processing.
|
2045
|
+
ASSERT(!function_instance_map_writable_prototype_.is_null());
|
2046
|
+
ASSERT(!strict_mode_function_instance_map_writable_prototype_.is_null());
|
2047
|
+
|
2048
|
+
// Replace function instance maps to make prototype writable.
|
2049
|
+
global_context()->set_function_map(
|
2050
|
+
*function_instance_map_writable_prototype_);
|
2051
|
+
global_context()->set_strict_mode_function_map(
|
2052
|
+
*strict_mode_function_instance_map_writable_prototype_);
|
1784
2053
|
}
|
1785
2054
|
|
1786
2055
|
|
1787
2056
|
Genesis::Genesis(Handle<Object> global_object,
|
1788
2057
|
v8::Handle<v8::ObjectTemplate> global_template,
|
1789
2058
|
v8::ExtensionConfiguration* extensions) {
|
2059
|
+
Isolate* isolate = Isolate::Current();
|
1790
2060
|
result_ = Handle<Context>::null();
|
1791
2061
|
// If V8 isn't running and cannot be initialized, just return.
|
1792
2062
|
if (!V8::IsRunning() && !V8::Initialize(NULL)) return;
|
@@ -1794,18 +2064,15 @@ Genesis::Genesis(Handle<Object> global_object,
|
|
1794
2064
|
// Before creating the roots we must save the context and restore it
|
1795
2065
|
// on all function exits.
|
1796
2066
|
HandleScope scope;
|
1797
|
-
SaveContext saved_context;
|
2067
|
+
SaveContext saved_context(isolate);
|
1798
2068
|
|
1799
2069
|
Handle<Context> new_context = Snapshot::NewContextFromSnapshot();
|
1800
2070
|
if (!new_context.is_null()) {
|
1801
2071
|
global_context_ =
|
1802
|
-
|
2072
|
+
Handle<Context>::cast(isolate->global_handles()->Create(*new_context));
|
1803
2073
|
AddToWeakGlobalContextList(*global_context_);
|
1804
|
-
|
1805
|
-
|
1806
|
-
JSFunction* empty_function =
|
1807
|
-
JSFunction::cast(global_context_->function_map()->prototype());
|
1808
|
-
empty_function_ = Handle<JSFunction>(empty_function);
|
2074
|
+
isolate->set_context(*global_context_);
|
2075
|
+
isolate->counters()->contexts_created_by_snapshot()->Increment();
|
1809
2076
|
Handle<GlobalObject> inner_global;
|
1810
2077
|
Handle<JSGlobalProxy> global_proxy =
|
1811
2078
|
CreateNewGlobals(global_template,
|
@@ -1820,6 +2087,7 @@ Genesis::Genesis(Handle<Object> global_object,
|
|
1820
2087
|
// We get here if there was no context snapshot.
|
1821
2088
|
CreateRoots();
|
1822
2089
|
Handle<JSFunction> empty_function = CreateEmptyFunction();
|
2090
|
+
CreateStrictModeFunctionMaps(empty_function);
|
1823
2091
|
Handle<GlobalObject> inner_global;
|
1824
2092
|
Handle<JSGlobalProxy> global_proxy =
|
1825
2093
|
CreateNewGlobals(global_template, global_object, &inner_global);
|
@@ -1832,7 +2100,7 @@ Genesis::Genesis(Handle<Object> global_object,
|
|
1832
2100
|
MakeFunctionInstancePrototypeWritable();
|
1833
2101
|
|
1834
2102
|
if (!ConfigureGlobalObjects(global_template)) return;
|
1835
|
-
|
2103
|
+
isolate->counters()->contexts_created_from_scratch()->Increment();
|
1836
2104
|
}
|
1837
2105
|
|
1838
2106
|
result_ = global_context_;
|
@@ -1843,46 +2111,28 @@ Genesis::Genesis(Handle<Object> global_object,
|
|
1843
2111
|
|
1844
2112
|
// Reserve space for statics needing saving and restoring.
|
1845
2113
|
int Bootstrapper::ArchiveSpacePerThread() {
|
1846
|
-
return
|
2114
|
+
return sizeof(NestingCounterType);
|
1847
2115
|
}
|
1848
2116
|
|
1849
2117
|
|
1850
2118
|
// Archive statics that are thread local.
|
1851
2119
|
char* Bootstrapper::ArchiveState(char* to) {
|
1852
|
-
|
2120
|
+
*reinterpret_cast<NestingCounterType*>(to) = nesting_;
|
2121
|
+
nesting_ = 0;
|
2122
|
+
return to + sizeof(NestingCounterType);
|
1853
2123
|
}
|
1854
2124
|
|
1855
2125
|
|
1856
2126
|
// Restore statics that are thread local.
|
1857
2127
|
char* Bootstrapper::RestoreState(char* from) {
|
1858
|
-
|
2128
|
+
nesting_ = *reinterpret_cast<NestingCounterType*>(from);
|
2129
|
+
return from + sizeof(NestingCounterType);
|
1859
2130
|
}
|
1860
2131
|
|
1861
2132
|
|
1862
2133
|
// Called when the top-level V8 mutex is destroyed.
|
1863
2134
|
void Bootstrapper::FreeThreadResources() {
|
1864
|
-
ASSERT(!
|
1865
|
-
}
|
1866
|
-
|
1867
|
-
|
1868
|
-
// Reserve space for statics needing saving and restoring.
|
1869
|
-
int BootstrapperActive::ArchiveSpacePerThread() {
|
1870
|
-
return sizeof(nesting_);
|
1871
|
-
}
|
1872
|
-
|
1873
|
-
|
1874
|
-
// Archive statics that are thread local.
|
1875
|
-
char* BootstrapperActive::ArchiveState(char* to) {
|
1876
|
-
*reinterpret_cast<int*>(to) = nesting_;
|
1877
|
-
nesting_ = 0;
|
1878
|
-
return to + sizeof(nesting_);
|
1879
|
-
}
|
1880
|
-
|
1881
|
-
|
1882
|
-
// Restore statics that are thread local.
|
1883
|
-
char* BootstrapperActive::RestoreState(char* from) {
|
1884
|
-
nesting_ = *reinterpret_cast<int*>(from);
|
1885
|
-
return from + sizeof(nesting_);
|
2135
|
+
ASSERT(!IsActive());
|
1886
2136
|
}
|
1887
2137
|
|
1888
2138
|
} } // namespace v8::internal
|