From a53c763c16eeabb0901a05dbcf38a72fa96d2f26 Mon Sep 17 00:00:00 2001 From: Timothy J Fontaine Date: Tue, 22 Oct 2013 15:14:25 -0700 Subject: [PATCH] v8: upgrade 3.21.18.3 --- deps/v8/ChangeLog | 215 +- deps/v8/build/toolchain.gypi | 22 +- deps/v8/include/v8-debug.h | 46 +- deps/v8/include/v8-profiler.h | 54 +- deps/v8/include/v8.h | 1519 ++++++------ deps/v8/include/v8config.h | 451 ++++ deps/v8/include/v8stdint.h | 6 +- deps/v8/samples/process.cc | 5 +- deps/v8/src/accessors.cc | 175 +- deps/v8/src/accessors.h | 98 +- deps/v8/src/api.cc | 951 +++----- deps/v8/src/api.h | 12 +- deps/v8/src/apinatives.js | 65 +- deps/v8/src/arguments.cc | 138 +- deps/v8/src/arguments.h | 118 +- deps/v8/src/arm/assembler-arm-inl.h | 5 +- deps/v8/src/arm/assembler-arm.cc | 162 +- deps/v8/src/arm/assembler-arm.h | 9 +- deps/v8/src/arm/builtins-arm.cc | 182 +- deps/v8/src/arm/code-stubs-arm.cc | 529 ++--- deps/v8/src/arm/code-stubs-arm.h | 38 +- deps/v8/src/arm/codegen-arm.h | 6 +- deps/v8/src/arm/constants-arm.h | 2 + deps/v8/src/arm/cpu-arm.cc | 9 - deps/v8/src/arm/debug-arm.cc | 6 +- deps/v8/src/arm/deoptimizer-arm.cc | 203 +- deps/v8/src/arm/disasm-arm.cc | 3 - deps/v8/src/arm/full-codegen-arm.cc | 38 +- deps/v8/src/arm/ic-arm.cc | 8 +- deps/v8/src/arm/lithium-arm.cc | 152 +- deps/v8/src/arm/lithium-arm.h | 507 ++-- deps/v8/src/arm/lithium-codegen-arm.cc | 333 +-- deps/v8/src/arm/lithium-codegen-arm.h | 12 +- deps/v8/src/arm/lithium-gap-resolver-arm.h | 2 +- deps/v8/src/arm/macro-assembler-arm.cc | 242 +- deps/v8/src/arm/macro-assembler-arm.h | 67 +- deps/v8/src/arm/regexp-macro-assembler-arm.cc | 119 +- deps/v8/src/arm/regexp-macro-assembler-arm.h | 11 - deps/v8/src/arm/simulator-arm.cc | 95 +- deps/v8/src/arm/stub-cache-arm.cc | 678 +----- deps/v8/src/assembler.cc | 11 +- deps/v8/src/assembler.h | 34 +- deps/v8/src/ast.cc | 38 +- deps/v8/src/ast.h | 518 ++-- deps/v8/src/bootstrapper.cc | 163 +- deps/v8/src/bootstrapper.h | 4 +- deps/v8/src/builtins.cc | 51 +- deps/v8/src/builtins.h | 28 +- deps/v8/src/checks.cc | 28 +- deps/v8/src/checks.h | 17 +- deps/v8/src/circular-queue-inl.h | 62 +- deps/v8/src/circular-queue.cc | 125 - deps/v8/src/circular-queue.h | 72 +- deps/v8/src/code-stubs-hydrogen.cc | 309 ++- deps/v8/src/code-stubs.cc | 34 +- deps/v8/src/code-stubs.h | 136 +- deps/v8/src/codegen.cc | 17 +- deps/v8/src/compiler.cc | 186 +- deps/v8/src/compiler.h | 54 +- deps/v8/src/contexts.cc | 43 +- deps/v8/src/contexts.h | 22 +- deps/v8/src/counters.cc | 10 +- deps/v8/src/counters.h | 14 +- deps/v8/src/cpu-profiler-inl.h | 21 +- deps/v8/src/cpu-profiler.cc | 137 +- deps/v8/src/cpu-profiler.h | 37 +- deps/v8/src/cpu.cc | 466 ++++ deps/v8/src/cpu.h | 91 +- deps/v8/src/d8-debug.cc | 22 +- deps/v8/src/d8-debug.h | 7 +- deps/v8/src/d8.cc | 41 +- deps/v8/src/d8.h | 14 +- deps/v8/src/debug-agent.cc | 111 +- deps/v8/src/debug-agent.h | 36 +- deps/v8/src/debug-debugger.js | 9 +- deps/v8/src/debug.cc | 179 +- deps/v8/src/debug.h | 38 +- deps/v8/src/deoptimizer.cc | 710 ++---- deps/v8/src/deoptimizer.h | 128 +- deps/v8/src/disassembler.cc | 6 +- deps/v8/src/effects.h | 2 +- deps/v8/src/elements.cc | 12 +- deps/v8/src/execution.cc | 119 +- deps/v8/src/execution.h | 51 +- .../externalize-string-extension.cc | 6 +- deps/v8/src/extensions/gc-extension.cc | 5 +- deps/v8/src/extensions/i18n/break-iterator.cc | 333 --- deps/v8/src/extensions/i18n/break-iterator.h | 85 - deps/v8/src/extensions/i18n/break-iterator.js | 197 -- deps/v8/src/extensions/i18n/collator.js | 209 -- deps/v8/src/extensions/i18n/date-format.js | 474 ---- deps/v8/src/extensions/i18n/globals.js | 168 -- deps/v8/src/extensions/i18n/i18n-extension.cc | 77 - deps/v8/src/extensions/i18n/i18n-utils.cc | 177 -- deps/v8/src/extensions/i18n/i18n-utils.h | 91 - deps/v8/src/extensions/i18n/i18n-utils.js | 536 ----- deps/v8/src/extensions/i18n/locale.js | 190 -- deps/v8/src/extensions/i18n/number-format.js | 289 --- deps/v8/src/extensions/i18n/overrides.js | 220 -- .../v8/src/extensions/statistics-extension.cc | 2 +- deps/v8/src/factory.cc | 93 +- deps/v8/src/factory.h | 21 +- deps/v8/src/flag-definitions.h | 90 +- deps/v8/src/flags.cc | 11 +- deps/v8/src/flags.h | 3 + deps/v8/src/frames.cc | 7 +- deps/v8/src/full-codegen.cc | 22 +- deps/v8/src/full-codegen.h | 8 +- deps/v8/src/gdb-jit.cc | 8 +- deps/v8/src/global-handles.cc | 74 +- deps/v8/src/global-handles.h | 20 +- deps/v8/src/globals.h | 135 +- deps/v8/src/handles-inl.h | 11 +- deps/v8/src/handles.cc | 34 +- deps/v8/src/handles.h | 5 - deps/v8/src/heap-inl.h | 58 +- deps/v8/src/heap-snapshot-generator.cc | 51 +- deps/v8/src/heap-snapshot-generator.h | 9 +- deps/v8/src/heap.cc | 165 +- deps/v8/src/heap.h | 30 +- deps/v8/src/hydrogen-alias-analysis.h | 105 + deps/v8/src/hydrogen-bce.cc | 55 +- deps/v8/src/hydrogen-bce.h | 2 + deps/v8/src/hydrogen-bch.cc | 40 +- deps/v8/src/hydrogen-canonicalize.cc | 4 + deps/v8/src/hydrogen-escape-analysis.cc | 117 +- deps/v8/src/hydrogen-escape-analysis.h | 13 +- deps/v8/src/hydrogen-infer-representation.cc | 34 +- deps/v8/src/hydrogen-instructions.cc | 101 +- deps/v8/src/hydrogen-instructions.h | 1486 ++++++------ deps/v8/src/hydrogen-osr.cc | 19 +- deps/v8/src/hydrogen-osr.h | 9 +- .../v8/src/hydrogen-representation-changes.cc | 70 +- deps/v8/src/hydrogen.cc | 1403 +++++------ deps/v8/src/hydrogen.h | 277 +-- deps/v8/src/i18n.cc | 144 +- deps/v8/src/i18n.h | 31 +- deps/v8/src/i18n.js | 2116 +++++++++++++++++ deps/v8/src/ia32/assembler-ia32-inl.h | 10 +- deps/v8/src/ia32/assembler-ia32.cc | 118 +- deps/v8/src/ia32/assembler-ia32.h | 8 +- deps/v8/src/ia32/builtins-ia32.cc | 166 +- deps/v8/src/ia32/code-stubs-ia32.cc | 468 ++-- deps/v8/src/ia32/code-stubs-ia32.h | 4 +- deps/v8/src/ia32/codegen-ia32.cc | 57 +- deps/v8/src/ia32/codegen-ia32.h | 2 +- deps/v8/src/ia32/cpu-ia32.cc | 14 - deps/v8/src/ia32/debug-ia32.cc | 6 +- deps/v8/src/ia32/deoptimizer-ia32.cc | 257 +- deps/v8/src/ia32/disasm-ia32.cc | 16 +- deps/v8/src/ia32/full-codegen-ia32.cc | 33 +- deps/v8/src/ia32/ic-ia32.cc | 6 +- deps/v8/src/ia32/lithium-codegen-ia32.cc | 948 ++++---- deps/v8/src/ia32/lithium-codegen-ia32.h | 102 +- deps/v8/src/ia32/lithium-gap-resolver-ia32.h | 2 +- deps/v8/src/ia32/lithium-ia32.cc | 144 +- deps/v8/src/ia32/lithium-ia32.h | 544 +++-- deps/v8/src/ia32/macro-assembler-ia32.cc | 301 ++- deps/v8/src/ia32/macro-assembler-ia32.h | 20 +- .../src/ia32/regexp-macro-assembler-ia32.cc | 5 +- deps/v8/src/ia32/stub-cache-ia32.cc | 684 +----- deps/v8/src/ic-inl.h | 1 - deps/v8/src/ic.cc | 209 +- deps/v8/src/ic.h | 75 +- deps/v8/src/isolate-inl.h | 18 +- deps/v8/src/isolate.cc | 126 +- deps/v8/src/isolate.h | 113 +- deps/v8/src/json-stringifier.h | 19 +- deps/v8/src/jsregexp.cc | 128 +- deps/v8/src/jsregexp.h | 47 +- deps/v8/src/lazy-instance.h | 19 +- deps/v8/src/lithium-allocator.cc | 2 +- deps/v8/src/lithium.cc | 10 +- deps/v8/src/lithium.h | 30 +- deps/v8/src/liveedit.cc | 130 +- deps/v8/src/log-utils.cc | 12 +- deps/v8/src/log-utils.h | 4 +- deps/v8/src/log.cc | 129 +- deps/v8/src/log.h | 24 +- deps/v8/src/macros.py | 8 +- deps/v8/src/mark-compact-inl.h | 2 +- deps/v8/src/mark-compact.cc | 86 +- deps/v8/src/mark-compact.h | 2 +- deps/v8/src/marking-thread.cc | 20 +- deps/v8/src/marking-thread.h | 13 +- deps/v8/src/mips/assembler-mips-inl.h | 5 +- deps/v8/src/mips/assembler-mips.cc | 11 +- deps/v8/src/mips/builtins-mips.cc | 178 +- deps/v8/src/mips/code-stubs-mips.cc | 954 +++----- deps/v8/src/mips/code-stubs-mips.h | 134 +- deps/v8/src/mips/codegen-mips.h | 6 +- deps/v8/src/mips/cpu-mips.cc | 8 - deps/v8/src/mips/debug-mips.cc | 4 +- deps/v8/src/mips/deoptimizer-mips.cc | 202 +- deps/v8/src/mips/disasm-mips.cc | 3 - deps/v8/src/mips/full-codegen-mips.cc | 40 +- deps/v8/src/mips/ic-mips.cc | 9 +- deps/v8/src/mips/lithium-codegen-mips.cc | 300 ++- deps/v8/src/mips/lithium-codegen-mips.h | 12 +- deps/v8/src/mips/lithium-gap-resolver-mips.h | 2 +- deps/v8/src/mips/lithium-mips.cc | 109 +- deps/v8/src/mips/lithium-mips.h | 493 ++-- deps/v8/src/mips/macro-assembler-mips.cc | 433 ++-- deps/v8/src/mips/macro-assembler-mips.h | 110 +- .../src/mips/regexp-macro-assembler-mips.cc | 3 +- deps/v8/src/mips/simulator-mips.cc | 140 +- deps/v8/src/mips/stub-cache-mips.cc | 803 +------ deps/v8/src/mksnapshot.cc | 18 +- deps/v8/src/natives.h | 3 +- deps/v8/src/object-observe.js | 440 ++-- deps/v8/src/objects-debug.cc | 46 +- deps/v8/src/objects-inl.h | 233 +- deps/v8/src/objects-printer.cc | 4 + deps/v8/src/objects-visiting-inl.h | 5 +- deps/v8/src/objects.cc | 1833 +++++++------- deps/v8/src/objects.h | 464 ++-- deps/v8/src/optimizing-compiler-thread.cc | 151 +- deps/v8/src/optimizing-compiler-thread.h | 62 +- deps/v8/src/parser.cc | 73 +- deps/v8/src/parser.h | 6 +- deps/v8/src/platform-cygwin.cc | 126 +- deps/v8/src/platform-freebsd.cc | 111 +- deps/v8/src/platform-linux.cc | 304 +-- deps/v8/src/platform-macos.cc | 96 +- deps/v8/src/platform-nullos.cc | 573 ----- deps/v8/src/platform-openbsd.cc | 117 +- deps/v8/src/platform-posix.cc | 273 +-- deps/v8/src/platform-solaris.cc | 131 +- deps/v8/src/platform-win32.cc | 495 +--- deps/v8/src/platform.h | 251 +- deps/v8/src/platform/condition-variable.cc | 345 +++ deps/v8/src/platform/condition-variable.h | 140 ++ deps/v8/src/platform/elapsed-timer.h | 120 + deps/v8/src/platform/mutex.cc | 214 ++ deps/v8/src/platform/mutex.h | 238 ++ deps/v8/src/platform/semaphore.cc | 214 ++ deps/v8/src/platform/semaphore.h | 126 + deps/v8/src/platform/socket.cc | 224 ++ deps/v8/src/platform/socket.h | 101 + deps/v8/src/platform/time.cc | 613 +++++ deps/v8/src/platform/time.h | 413 ++++ deps/v8/src/preparser.h | 5 - deps/v8/src/prettyprinter.cc | 10 +- deps/v8/src/prettyprinter.h | 6 +- deps/v8/src/profile-generator-inl.h | 8 +- deps/v8/src/profile-generator.cc | 99 +- deps/v8/src/profile-generator.h | 37 +- deps/v8/src/property-details.h | 2 +- deps/v8/src/property.h | 5 +- deps/v8/src/regexp-macro-assembler.cc | 3 - deps/v8/src/regexp-stack.cc | 1 - deps/v8/src/rewriter.cc | 4 +- deps/v8/src/runtime-profiler.cc | 41 +- deps/v8/src/runtime.cc | 833 +++++-- deps/v8/src/runtime.h | 27 +- deps/v8/src/sampler.cc | 321 ++- deps/v8/src/sampler.h | 19 +- deps/v8/src/scopeinfo.cc | 8 +- deps/v8/src/scopes.cc | 34 +- deps/v8/src/serialize.cc | 61 +- deps/v8/src/serialize.h | 28 +- deps/v8/src/snapshot-common.cc | 4 +- deps/v8/src/snapshot.h | 2 +- deps/v8/src/spaces-inl.h | 8 +- deps/v8/src/spaces.cc | 76 +- deps/v8/src/spaces.h | 46 +- deps/v8/src/store-buffer-inl.h | 2 +- deps/v8/src/store-buffer.cc | 14 +- deps/v8/src/string-stream.cc | 112 +- deps/v8/src/string-stream.h | 10 +- deps/v8/src/stub-cache.cc | 233 +- deps/v8/src/stub-cache.h | 74 +- deps/v8/src/sweeper-thread.cc | 20 +- deps/v8/src/sweeper-thread.h | 13 +- deps/v8/src/transitions.cc | 20 +- deps/v8/src/transitions.h | 3 +- deps/v8/src/type-info.cc | 9 +- deps/v8/src/types.h | 2 +- deps/v8/src/typing.cc | 2 +- deps/v8/src/unique.h | 266 +++ deps/v8/src/utils/random-number-generator.cc | 136 ++ deps/v8/src/utils/random-number-generator.h | 106 + deps/v8/src/v8-counters.cc | 14 +- deps/v8/src/v8.cc | 105 +- deps/v8/src/v8.h | 26 - deps/v8/src/v8dll-main.cc | 6 +- deps/v8/src/v8globals.h | 35 +- deps/v8/src/v8threads.cc | 19 +- deps/v8/src/v8threads.h | 6 +- deps/v8/src/version.cc | 6 +- deps/v8/src/win32-headers.h | 9 +- deps/v8/src/win32-math.cc | 2 - deps/v8/src/x64/assembler-x64-inl.h | 5 +- deps/v8/src/x64/assembler-x64.cc | 123 +- deps/v8/src/x64/assembler-x64.h | 4 +- deps/v8/src/x64/builtins-x64.cc | 185 +- deps/v8/src/x64/code-stubs-x64.cc | 597 ++--- deps/v8/src/x64/code-stubs-x64.h | 4 +- deps/v8/src/x64/codegen-x64.cc | 22 + deps/v8/src/x64/codegen-x64.h | 73 +- deps/v8/src/x64/cpu-x64.cc | 12 - deps/v8/src/x64/debug-x64.cc | 19 +- deps/v8/src/x64/deoptimizer-x64.cc | 206 +- deps/v8/src/x64/disasm-x64.cc | 74 +- deps/v8/src/x64/full-codegen-x64.cc | 47 +- deps/v8/src/x64/ic-x64.cc | 37 +- deps/v8/src/x64/lithium-codegen-x64.cc | 368 ++- deps/v8/src/x64/lithium-codegen-x64.h | 14 +- deps/v8/src/x64/lithium-gap-resolver-x64.h | 2 +- deps/v8/src/x64/lithium-x64.cc | 85 +- deps/v8/src/x64/lithium-x64.h | 480 ++-- deps/v8/src/x64/macro-assembler-x64.cc | 229 +- deps/v8/src/x64/macro-assembler-x64.h | 35 +- deps/v8/src/x64/regexp-macro-assembler-x64.cc | 7 +- deps/v8/src/x64/stub-cache-x64.cc | 867 ++----- deps/v8/test/cctest/cctest.cc | 14 +- deps/v8/test/cctest/cctest.gyp | 14 +- deps/v8/test/cctest/cctest.h | 16 +- deps/v8/test/cctest/cctest.status | 14 +- .../cctest/log-eq-of-logging-and-traversal.js | 8 +- deps/v8/test/cctest/test-accessors.cc | 120 +- deps/v8/test/cctest/test-alloc.cc | 22 +- deps/v8/test/cctest/test-api.cc | 844 +++++-- deps/v8/test/cctest/test-assembler-arm.cc | 71 + deps/v8/test/cctest/test-assembler-x64.cc | 7 - deps/v8/test/cctest/test-circular-queue.cc | 157 +- deps/v8/test/cctest/test-code-stubs-arm.cc | 185 ++ deps/v8/test/cctest/test-code-stubs-ia32.cc | 53 +- deps/v8/test/cctest/test-code-stubs-x64.cc | 4 +- deps/v8/test/cctest/test-code-stubs.cc | 29 +- deps/v8/test/cctest/test-code-stubs.h | 5 + deps/v8/test/cctest/test-compiler.cc | 52 +- .../v8/test/cctest/test-condition-variable.cc | 304 +++ .../cctest/test-cpu-ia32.cc} | 21 +- deps/v8/test/cctest/test-cpu-profiler.cc | 69 +- .../footer.js => test/cctest/test-cpu-x64.cc} | 26 +- deps/v8/test/cctest/test-cpu.cc | 55 + deps/v8/test/cctest/test-debug.cc | 693 +++--- .../test/cctest/test-declarative-accessors.cc | 12 +- deps/v8/test/cctest/test-decls.cc | 2 +- deps/v8/test/cctest/test-deoptimization.cc | 34 +- deps/v8/test/cctest/test-dictionary.cc | 57 +- deps/v8/test/cctest/test-disasm-ia32.cc | 11 +- deps/v8/test/cctest/test-disasm-x64.cc | 5 - deps/v8/test/cctest/test-global-handles.cc | 42 +- deps/v8/test/cctest/test-heap-profiler.cc | 53 +- deps/v8/test/cctest/test-heap.cc | 93 +- deps/v8/test/cctest/test-lock.cc | 89 - deps/v8/test/cctest/test-lockers.cc | 13 +- deps/v8/test/cctest/test-log.cc | 105 +- deps/v8/test/cctest/test-mark-compact.cc | 68 +- deps/v8/test/cctest/test-mutex.cc | 118 + deps/v8/test/cctest/test-object-observe.cc | 287 ++- deps/v8/test/cctest/test-parsing.cc | 15 +- deps/v8/test/cctest/test-platform-linux.cc | 54 - deps/v8/test/cctest/test-platform-nullos.cc | 105 - deps/v8/test/cctest/test-platform-win32.cc | 2 - deps/v8/test/cctest/test-platform.cc | 5 - deps/v8/test/cctest/test-profile-generator.cc | 103 +- .../cctest/test-random-number-generator.cc | 92 + deps/v8/test/cctest/test-random.cc | 30 +- deps/v8/test/cctest/test-semaphore.cc | 155 ++ deps/v8/test/cctest/test-serialize.cc | 55 +- .../{test-sockets.cc => test-socket.cc} | 29 +- deps/v8/test/cctest/test-spaces.cc | 4 - deps/v8/test/cctest/test-strings.cc | 8 +- deps/v8/test/cctest/test-strtod.cc | 7 +- .../v8/test/cctest/test-thread-termination.cc | 76 +- deps/v8/test/cctest/test-threads.cc | 2 +- deps/v8/test/cctest/test-time.cc | 144 ++ deps/v8/test/cctest/test-unique.cc | 488 ++++ deps/v8/test/cctest/test-utils.cc | 1 - deps/v8/test/cctest/test-weakmaps.cc | 2 +- deps/v8/test/cctest/test-weaksets.cc | 2 +- .../test/mjsunit/array-push-non-smi-value.js | 36 + deps/v8/test/mjsunit/array-store-and-grow.js | 47 + deps/v8/test/mjsunit/assert-opt-and-deopt.js | 6 +- .../test/mjsunit/compiler/escape-analysis.js | 141 +- .../compiler/increment-typefeedback.js} | 32 +- .../test/mjsunit/compiler/optimized-for-in.js | 1 + deps/v8/test/mjsunit/compiler/osr-assert.js | 41 + deps/v8/test/mjsunit/compiler/osr-sar.js | 49 + deps/v8/test/mjsunit/compiler/osr-uint32.js | 39 + .../osr-warm.js} | 33 +- .../mjsunit/compiler/parallel-proto-change.js | 14 +- deps/v8/test/mjsunit/debug-script.js | 6 +- deps/v8/test/mjsunit/debug-step-4-in-frame.js | 132 + .../v8/test/mjsunit/debug-stepin-positions.js | 113 +- .../v8/test/mjsunit/external-array-no-sse2.js | 34 + deps/v8/test/mjsunit/external-array.js | 34 + deps/v8/test/mjsunit/fast-literal.js | 42 + deps/v8/test/mjsunit/fuzz-natives-part1.js | 3 +- deps/v8/test/mjsunit/fuzz-natives-part2.js | 4 +- deps/v8/test/mjsunit/fuzz-natives-part3.js | 3 +- deps/v8/test/mjsunit/fuzz-natives-part4.js | 3 +- .../v8/test/mjsunit/harmony/object-observe.js | 58 +- deps/v8/test/mjsunit/lithium/MulI.js | 70 + .../test/mjsunit/manual-parallel-recompile.js | 16 +- deps/v8/test/mjsunit/mjsunit.js | 2 +- deps/v8/test/mjsunit/mjsunit.status | 3 - .../parallel-initial-prototype-change.js | 8 +- .../parallel-invalidate-transition-map.js | 8 +- .../mjsunit/parallel-optimize-disabled.js | 8 +- .../regress/post-increment-close-context.js | 42 + deps/v8/test/mjsunit/regress/regress-2594.js | 104 + deps/v8/test/mjsunit/regress/regress-2829.js | 53 + deps/v8/test/mjsunit/regress/regress-2855.js | 57 + .../regress-convert-function-to-double.js | 36 + .../regress-debug-deopt-while-recompile.js | 4 +- .../regress/regress-embedded-cons-string.js | 16 +- .../regress/regress-map-invalidation-2.js | 19 +- .../regress/regress-merge-descriptors.js | 92 + .../regress/regress-opt-after-debug-deopt.js | 12 +- .../regress-prepare-break-while-recompile.js | 12 +- .../regress/regress-store-uncacheable.js | 40 + deps/v8/test/mjsunit/regress/regress-x87.js | 48 + .../regress-crbug-282736.js => smi-mul.js} | 62 +- deps/v8/test/mjsunit/track-fields.js | 1 - deps/v8/tools/SourceMap.js | 371 +++ deps/v8/tools/grokdump.py | 2 +- deps/v8/tools/gyp/v8.gyp | 128 +- deps/v8/tools/linux-tick-processor | 1 + deps/v8/tools/plot-timer-events | 11 +- deps/v8/tools/profviz/composer.js | 75 +- deps/v8/tools/profviz/profviz.html | 7 +- deps/v8/tools/profviz/profviz.js | 22 +- deps/v8/tools/profviz/stdio.js | 6 +- deps/v8/tools/profviz/worker.js | 8 +- deps/v8/tools/run-deopt-fuzzer.py | 4 +- deps/v8/tools/tickprocessor-driver.js | 20 +- deps/v8/tools/tickprocessor.js | 50 +- deps/v8/tools/v8heapconst.py | 20 +- deps/v8/tools/windows-tick-processor.bat | 2 +- 433 files changed, 27647 insertions(+), 25358 deletions(-) create mode 100644 deps/v8/include/v8config.h delete mode 100644 deps/v8/src/circular-queue.cc create mode 100644 deps/v8/src/cpu.cc delete mode 100644 deps/v8/src/extensions/i18n/break-iterator.cc delete mode 100644 deps/v8/src/extensions/i18n/break-iterator.h delete mode 100644 deps/v8/src/extensions/i18n/break-iterator.js delete mode 100644 deps/v8/src/extensions/i18n/collator.js delete mode 100644 deps/v8/src/extensions/i18n/date-format.js delete mode 100644 deps/v8/src/extensions/i18n/globals.js delete mode 100644 deps/v8/src/extensions/i18n/i18n-extension.cc delete mode 100644 deps/v8/src/extensions/i18n/i18n-utils.cc delete mode 100644 deps/v8/src/extensions/i18n/i18n-utils.h delete mode 100644 deps/v8/src/extensions/i18n/i18n-utils.js delete mode 100644 deps/v8/src/extensions/i18n/locale.js delete mode 100644 deps/v8/src/extensions/i18n/number-format.js delete mode 100644 deps/v8/src/extensions/i18n/overrides.js create mode 100644 deps/v8/src/hydrogen-alias-analysis.h create mode 100644 deps/v8/src/i18n.js delete mode 100644 deps/v8/src/platform-nullos.cc create mode 100644 deps/v8/src/platform/condition-variable.cc create mode 100644 deps/v8/src/platform/condition-variable.h create mode 100644 deps/v8/src/platform/elapsed-timer.h create mode 100644 deps/v8/src/platform/mutex.cc create mode 100644 deps/v8/src/platform/mutex.h create mode 100644 deps/v8/src/platform/semaphore.cc create mode 100644 deps/v8/src/platform/semaphore.h create mode 100644 deps/v8/src/platform/socket.cc create mode 100644 deps/v8/src/platform/socket.h create mode 100644 deps/v8/src/platform/time.cc create mode 100644 deps/v8/src/platform/time.h create mode 100644 deps/v8/src/unique.h create mode 100644 deps/v8/src/utils/random-number-generator.cc create mode 100644 deps/v8/src/utils/random-number-generator.h create mode 100644 deps/v8/test/cctest/test-code-stubs-arm.cc create mode 100644 deps/v8/test/cctest/test-condition-variable.cc rename deps/v8/{src/extensions/i18n/header.js => test/cctest/test-cpu-ia32.cc} (79%) rename deps/v8/{src/extensions/i18n/footer.js => test/cctest/test-cpu-x64.cc} (79%) create mode 100644 deps/v8/test/cctest/test-cpu.cc delete mode 100644 deps/v8/test/cctest/test-lock.cc create mode 100644 deps/v8/test/cctest/test-mutex.cc delete mode 100644 deps/v8/test/cctest/test-platform-nullos.cc create mode 100644 deps/v8/test/cctest/test-random-number-generator.cc create mode 100644 deps/v8/test/cctest/test-semaphore.cc rename deps/v8/test/cctest/{test-sockets.cc => test-socket.cc} (90%) create mode 100644 deps/v8/test/cctest/test-time.cc create mode 100644 deps/v8/test/cctest/test-unique.cc create mode 100644 deps/v8/test/mjsunit/array-push-non-smi-value.js rename deps/v8/{src/extensions/i18n/i18n-extension.h => test/mjsunit/compiler/increment-typefeedback.js} (77%) create mode 100644 deps/v8/test/mjsunit/compiler/osr-assert.js create mode 100644 deps/v8/test/mjsunit/compiler/osr-sar.js create mode 100644 deps/v8/test/mjsunit/compiler/osr-uint32.js rename deps/v8/test/mjsunit/{regress/regress-crbug-298392.js => compiler/osr-warm.js} (82%) create mode 100644 deps/v8/test/mjsunit/debug-step-4-in-frame.js create mode 100644 deps/v8/test/mjsunit/fast-literal.js create mode 100644 deps/v8/test/mjsunit/lithium/MulI.js create mode 100644 deps/v8/test/mjsunit/regress/post-increment-close-context.js create mode 100644 deps/v8/test/mjsunit/regress/regress-2594.js create mode 100644 deps/v8/test/mjsunit/regress/regress-2829.js create mode 100644 deps/v8/test/mjsunit/regress/regress-2855.js create mode 100644 deps/v8/test/mjsunit/regress/regress-convert-function-to-double.js create mode 100644 deps/v8/test/mjsunit/regress/regress-merge-descriptors.js create mode 100644 deps/v8/test/mjsunit/regress/regress-store-uncacheable.js create mode 100644 deps/v8/test/mjsunit/regress/regress-x87.js rename deps/v8/test/mjsunit/{regress/regress-crbug-282736.js => smi-mul.js} (68%) create mode 100644 deps/v8/tools/SourceMap.js diff --git a/deps/v8/ChangeLog b/deps/v8/ChangeLog index d824cec0d6..b3eba3661a 100644 --- a/deps/v8/ChangeLog +++ b/deps/v8/ChangeLog @@ -1,3 +1,216 @@ +2013-09-18: Version 3.21.17 + + Implemented local load/store elimination on basic blocks. + + Added mutex when accessing concurrent recompilation output queue. + (Chromium issue 291236) + + Don't lookup the cache for the result of Function::New. + (Chromium issue 272579) + + Tweaked HConstant::EmitAtUses() to eliminate useless constant + generation. + (Chromium issue 2881) + + Performance and stability improvements on all platforms. + + +2013-09-16: Version 3.21.16 + + Every place where AllocationMemento is initialized with an + AllocationSite is now checked to be sure a valid Site goes in. This is + temporary code to diagnose chromium bug 284577. + + Performance and stability improvements on all platforms. + + +2013-09-13: Version 3.21.15 + + Non-JSObject heap objects are now handled using slow-path IC stub + guarded by the map. + (Chromium issue 280632) + + i18n Javascript code added to the snapshot. + (V8 issue 2745) + + Performance and stability improvements on all platforms. + +2013-09-12: Version 3.21.14 + + Added access check for observed objects. + (V8 issue 2778) + + Cleaned up v8::ArrayBuffer::Allocator interface. + (V8 issue 2823) + + Performance and stability improvements on all platforms. + +2013-09-11: Version 3.21.13 + + Added a ResourceConstraint for the embedder to specify that V8 is + running on a memory constrained device. + (Chromium issue 280984) + + Removed HandleScope default ctor. + (Chromium issue 236173) + + Enabled escape analysis for Hydrogen. + + Correctly stringified mixed encoding indirect strings. + (Chromium issue 287476) + + Performance and stability improvements on all platforms. + + +2013-09-09: Version 3.21.12 + + Fixed bitwise negation on x64. + (Chromium issue 285355) + + Dropped GetCurrentThreadId() and TerminateExecution(int) from + the external API. + + Fixed polymorphic INTERCEPTOR StoreICs on ARM/MIPS. + (Chromium issue 284998) + + Added check if timeout has expired after processing each sample. + (issue 2814,v8:2871) + + Removed obsolete global V8::has_been_fooed flags. + (issue 2744) + + Performance and stability improvements on all platforms. + + +2013-09-05: Version 3.21.11 + + Performance and stability improvements on all platforms. + + +2013-09-04: Version 3.21.10 + + Fixed Eternal::IsEmpty logic (issue 2870). + + Performance and stability improvements on all platforms. + + +2013-09-03: Version 3.21.9 + + Deprecated Persistent functions which were marked to be deprecated. + + Allowed uncacheable identifiers to go generic (issue 2867). + + Performance and stability improvements on all platforms. + + +2013-09-02: Version 3.21.8 + + Added scriptId to StackTrace frames (issue 2865). + + Performance and stability improvements on all platforms. + + +2013-08-30: Version 3.21.7 + + Fixed casts of eternal handles. + + Turned on global handle zapping. + + Always visit branches during HGraph building (Chromium issue 280333). + + Profiler changes: removed deprecated API, support higher sampling + rate on Windows. + + Performance and stability improvements on all platforms. + + +2013-08-29: Version 3.21.6 + + Fixed inlined 'throw' statements interfering with live range + computation. (issue 2843) + + Performance and stability improvements on all platforms. + + +2013-08-28: Version 3.21.5 + + Fixed compilation with recent MinGW64 versions. (issue 2300) + + Added RemovePrototype to FunctionTemplate. (Chromium issue 272440) + + Performance and stability improvements on all platforms. + + +2013-08-26: Version 3.21.4 + + Lowered kInitialMaxFastElementArray constant to 95K (issue 2790). + + Use signals for cpu profiling on Mac OS X (issue 2814). + + Deprecated CpuProfileNode::GetSelfSamplesCount (Chromium issue 267595). + + Added support for higher CPU profiler sampling rate on posix systems + (issue 2814). + + Worked around 'inlining failed' build error with older GCC 4.x releases. + + Added source map support to tick processor. + + Stability improvements on all platforms. + + +2013-08-23: Version 3.21.3 + + Temporarily disabled optimization for StringWrappers to use native + valueOf. (issue 2855) + + Fixed crash on function declarations in eval inside non-trivial local + scope. (issue 2594) + + Rewrote SamplingCircularQueue. (issue 2814) + + Fixed hidden properties on object with frozen prototype. (issue 2829) + + Fix deoptimization bug. (Chromium issue 274164) + + Stability improvements on all platforms. + + +2013-08-22: Version 3.21.2 + + Stability improvements on all platforms. + + +2013-08-21: Version 3.21.1 + + Promoted ArrayBuffer, DataView and typed arrays to non-experimental. + (Chromium issue 270527) + + Replaced OS::MemCopy with memcpy in typed array initialization. + (Chromium issue 270642) + + Moved i18n break iterator C++ code to runtime (issue 2745) + + Fixed invalid out-of-bounds store in MacroAssembler::Allocate. + (Chromium issue 263515) + + Fixed register misuse in Allocate() on ARM. (issue 2851) + + Fixed empty handle dereference in Runtime_InternalNumberFormat. + (Chromium issue 275467) + + Performance and stability improvements on all platforms. + + +2013-08-19: Version 3.21.0 + + Fixed GC-related crasher (Chromium issue 274438) + + Reverted making Intl non-enumerable. + + Performance and stability improvements on all platforms. + + 2013-08-14: Version 3.20.17 Fixed Math.round/floor that had bogus Smi representation @@ -31,7 +244,7 @@ Performance and stability improvements on all platforms. -2013-08-07: Version 3.20.14 +2013-08-07: Version 3.20.15 Exposed eternal handle api. diff --git a/deps/v8/build/toolchain.gypi b/deps/v8/build/toolchain.gypi index ddb8aafad0..c1066ebe94 100644 --- a/deps/v8/build/toolchain.gypi +++ b/deps/v8/build/toolchain.gypi @@ -561,13 +561,21 @@ 'cflags!': [ '-O0', '-O1', - '-O2', '-Os', ], 'cflags': [ '-fdata-sections', '-ffunction-sections', - '-O3', + ], + 'conditions': [ + # TODO(crbug.com/272548): Avoid -O3 in NaCl + ['nacl_target_arch=="none"', { + 'cflags': ['-O3'], + 'cflags!': ['-O2'], + }, { + 'cflags': ['-O2'], + 'cflags!': ['-O3'], + }], ], }], ['v8_optimized_debug!=0 and gcc_version==44 and clang==0', { @@ -614,13 +622,11 @@ 'conditions': [ ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd"', { 'cflags!': [ - '-O2', '-Os', ], 'cflags': [ '-fdata-sections', '-ffunction-sections', - '-O3', '<(wno_array_bounds)', ], 'conditions': [ @@ -630,6 +636,14 @@ '-fno-tree-vrp', ], }], + # TODO(crbug.com/272548): Avoid -O3 in NaCl + ['nacl_target_arch=="none"', { + 'cflags': ['-O3'], + 'cflags!': ['-O2'], + }, { + 'cflags': ['-O2'], + 'cflags!': ['-O3'], + }], ], }], ['OS=="android"', { diff --git a/deps/v8/include/v8-debug.h b/deps/v8/include/v8-debug.h index bacccb61dd..053b81d2c5 100755 --- a/deps/v8/include/v8-debug.h +++ b/deps/v8/include/v8-debug.h @@ -106,6 +106,8 @@ class V8_EXPORT Debug { */ virtual ClientData* GetClientData() const = 0; + virtual Isolate* GetIsolate() const = 0; + virtual ~Message() {} }; @@ -150,21 +152,6 @@ class V8_EXPORT Debug { virtual ~EventDetails() {} }; - - /** - * Debug event callback function. - * - * \param event the type of the debug event that triggered the callback - * (enum DebugEvent) - * \param exec_state execution state (JavaScript object) - * \param event_data event specific data (JavaScript object) - * \param data value passed by the user to SetDebugEventListener - */ - typedef void (*EventCallback)(DebugEvent event, - Handle exec_state, - Handle event_data, - Handle data); - /** * Debug event callback function. * @@ -175,27 +162,12 @@ class V8_EXPORT Debug { */ typedef void (*EventCallback2)(const EventDetails& event_details); - /** - * Debug message callback function. - * - * \param message the debug message handler message object - * \param length length of the message - * \param client_data the data value passed when registering the message handler - - * A MessageHandler does not take possession of the message string, - * and must not rely on the data persisting after the handler returns. - * - * This message handler is deprecated. Use MessageHandler2 instead. - */ - typedef void (*MessageHandler)(const uint16_t* message, int length, - ClientData* client_data); - /** * Debug message callback function. * * \param message the debug message handler message object * - * A MessageHandler does not take possession of the message data, + * A MessageHandler2 does not take possession of the message data, * and must not rely on the data persisting after the handler returns. */ typedef void (*MessageHandler2)(const Message& message); @@ -210,10 +182,6 @@ class V8_EXPORT Debug { */ typedef void (*DebugMessageDispatchHandler)(); - // Set a C debug event listener. - V8_DEPRECATED(static bool SetDebugEventListener( - EventCallback that, - Handle data = Handle())); static bool SetDebugEventListener2(EventCallback2 that, Handle data = Handle()); @@ -234,16 +202,12 @@ class V8_EXPORT Debug { // Break execution of JavaScript in the given isolate (this method // can be invoked from a non-VM thread) for further client command // execution on a VM thread. Client data is then passed in - // EventDetails to EventCallback at the moment when the VM actually + // EventDetails to EventCallback2 at the moment when the VM actually // stops. If no isolate is provided the default isolate is used. static void DebugBreakForCommand(ClientData* data = NULL, Isolate* isolate = NULL); - // Message based interface. The message protocol is JSON. NOTE the message - // handler thread is not supported any more parameter must be false. - V8_DEPRECATED(static void SetMessageHandler( - MessageHandler handler, - bool message_handler_thread = false)); + // Message based interface. The message protocol is JSON. static void SetMessageHandler2(MessageHandler2 handler); // If no isolate is provided the default isolate is diff --git a/deps/v8/include/v8-profiler.h b/deps/v8/include/v8-profiler.h index e538f4a840..217a938329 100644 --- a/deps/v8/include/v8-profiler.h +++ b/deps/v8/include/v8-profiler.h @@ -57,25 +57,15 @@ class V8_EXPORT CpuProfileNode { */ int GetLineNumber() const; - /** - * Returns total (self + children) execution time of the function, - * in milliseconds, estimated by samples count. - */ - V8_DEPRECATED(double GetTotalTime() const); - - /** - * Returns self execution time of the function, in milliseconds, - * estimated by samples count. - */ - V8_DEPRECATED(double GetSelfTime() const); - - /** Returns the count of samples where function exists. */ - V8_DEPRECATED(double GetTotalSamplesCount() const); + /** Returns bailout reason for the function + * if the optimization was disabled for it. + */ + const char* GetBailoutReason() const; /** DEPRECATED. Please use GetHitCount instead. * Returns the count of samples where function was currently executing. */ - double GetSelfSamplesCount() const; + V8_DEPRECATED(double GetSelfSamplesCount() const); /** * Returns the count of samples where the function was currently executing. @@ -156,13 +146,11 @@ class V8_EXPORT CpuProfile { class V8_EXPORT CpuProfiler { public: /** - * A note on security tokens usage. As scripts from different - * origins can run inside a single V8 instance, it is possible to - * have functions from different security contexts intermixed in a - * single CPU profile. To avoid exposing function names belonging to - * other contexts, filtering by security token is performed while - * obtaining profiling results. + * Changes default CPU profiler sampling interval to the specified number + * of microseconds. Default interval is 1000us. This method must be called + * when there are no profiles being recorded. */ + void SetSamplingInterval(int us); /** * Returns the number of profiles collected (doesn't include @@ -258,17 +246,19 @@ class V8_EXPORT HeapGraphEdge { class V8_EXPORT HeapGraphNode { public: enum Type { - kHidden = 0, // Hidden node, may be filtered when shown to user. - kArray = 1, // An array of elements. - kString = 2, // A string. - kObject = 3, // A JS object (except for arrays and strings). - kCode = 4, // Compiled code. - kClosure = 5, // Function closure. - kRegExp = 6, // RegExp. - kHeapNumber = 7, // Number stored in the heap. - kNative = 8, // Native object (not from V8 heap). - kSynthetic = 9 // Synthetic object, usualy used for grouping - // snapshot items together. + kHidden = 0, // Hidden node, may be filtered when shown to user. + kArray = 1, // An array of elements. + kString = 2, // A string. + kObject = 3, // A JS object (except for arrays and strings). + kCode = 4, // Compiled code. + kClosure = 5, // Function closure. + kRegExp = 6, // RegExp. + kHeapNumber = 7, // Number stored in the heap. + kNative = 8, // Native object (not from V8 heap). + kSynthetic = 9, // Synthetic object, usualy used for grouping + // snapshot items together. + kConsString = 10, // Concatenated string. A pair of pointers to strings. + kSlicedString = 11 // Sliced string. A fragment of another string. }; /** Returns node type (see HeapGraphNode::Type). */ diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h index 3252602bcf..de2733838f 100644 --- a/deps/v8/include/v8.h +++ b/deps/v8/include/v8.h @@ -43,7 +43,7 @@ // We reserve the V8_* prefix for macros defined in V8 public API and // assume there are no name conflicts with the embedder's code. -#ifdef _WIN32 +#ifdef V8_OS_WIN // Setup for Windows DLL export/import. When building the V8 DLL the // BUILDING_V8_SHARED needs to be defined. When building a program which uses @@ -56,59 +56,33 @@ #endif #ifdef BUILDING_V8_SHARED -#define V8_EXPORT __declspec(dllexport) +# define V8_EXPORT __declspec(dllexport) #elif USING_V8_SHARED -#define V8_EXPORT __declspec(dllimport) +# define V8_EXPORT __declspec(dllimport) #else -#define V8_EXPORT +# define V8_EXPORT #endif // BUILDING_V8_SHARED -#else // _WIN32 +#else // V8_OS_WIN // Setup for Linux shared library export. -#if defined(__GNUC__) && ((__GNUC__ >= 4) || \ - (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(V8_SHARED) -#ifdef BUILDING_V8_SHARED -#define V8_EXPORT __attribute__ ((visibility("default"))) -#else -#define V8_EXPORT -#endif -#else -#define V8_EXPORT -#endif - -#endif // _WIN32 - -#if defined(__GNUC__) && !defined(DEBUG) -#define V8_INLINE(declarator) inline __attribute__((always_inline)) declarator -#elif defined(_MSC_VER) && !defined(DEBUG) -#define V8_INLINE(declarator) __forceinline declarator -#else -#define V8_INLINE(declarator) inline declarator -#endif - -#if defined(__GNUC__) && !V8_DISABLE_DEPRECATIONS -#define V8_DEPRECATED(declarator) declarator __attribute__ ((deprecated)) -#elif defined(_MSC_VER) && !V8_DISABLE_DEPRECATIONS -#define V8_DEPRECATED(declarator) __declspec(deprecated) declarator +#if V8_HAS_ATTRIBUTE_VISIBILITY && defined(V8_SHARED) +# ifdef BUILDING_V8_SHARED +# define V8_EXPORT __attribute__ ((visibility("default"))) +# else +# define V8_EXPORT +# endif #else -#define V8_DEPRECATED(declarator) declarator +# define V8_EXPORT #endif -#if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) - #define V8_UNLIKELY(condition) __builtin_expect((condition), 0) - #define V8_LIKELY(condition) __builtin_expect((condition), 1) -#else - #define V8_UNLIKELY(condition) (condition) - #define V8_LIKELY(condition) (condition) -#endif +#endif // V8_OS_WIN /** * The v8 JavaScript engine. */ namespace v8 { -class AccessorInfo; class AccessorSignature; class Array; class Boolean; @@ -145,11 +119,14 @@ class Utils; class Value; template class Handle; template class Local; -template class Persistent; +template class Eternal; +template class NonCopyablePersistentTraits; +template > class Persistent; +template class WeakCallbackObject; class FunctionTemplate; class ObjectTemplate; class Data; -class AccessorInfo; template class PropertyCallbackInfo; class StackTrace; class StackFrame; @@ -168,6 +145,7 @@ class Object; template class CustomArguments; class PropertyCallbackArguments; class FunctionCallbackArguments; +class GlobalHandles; } @@ -195,27 +173,6 @@ class UniqueId { intptr_t data_; }; - -// --- Weak Handles --- - - -/** - * A weak reference callback function. - * - * This callback should either explicitly invoke Dispose on |object| if - * V8 wrapper is not needed anymore, or 'revive' it by invocation of MakeWeak. - * - * \param object the weak global object to be reclaimed by the garbage collector - * \param parameter the value passed in when making the weak global object - */ -template -class WeakReferenceCallbacks { - public: - typedef void (*Revivable)(Isolate* isolate, - Persistent* object, - P* parameter); -}; - // --- Handles --- #define TYPE_CHECK(T, S) \ @@ -254,14 +211,7 @@ template class Handle { /** * Creates an empty handle. */ - V8_INLINE(Handle()) : val_(0) {} - -#ifdef V8_USE_UNSAFE_HANDLES - /** - * Creates a new handle for the specified value. - */ - V8_INLINE(explicit Handle(T* val)) : val_(val) {} -#endif + V8_INLINE Handle() : val_(0) {} /** * Creates a handle for the contents of the specified handle. This @@ -273,7 +223,7 @@ template class Handle { * Handle to a variable declared as Handle, is legal * because String is a subclass of Value. */ - template V8_INLINE(Handle(Handle that)) + template V8_INLINE Handle(Handle that) : val_(reinterpret_cast(*that)) { /** * This check fails when trying to convert between incompatible @@ -286,16 +236,16 @@ template class Handle { /** * Returns true if the handle is empty. */ - V8_INLINE(bool IsEmpty() const) { return val_ == 0; } + V8_INLINE bool IsEmpty() const { return val_ == 0; } /** * Sets the handle to be empty. IsEmpty() will then return true. */ - V8_INLINE(void Clear()) { val_ = 0; } + V8_INLINE void Clear() { val_ = 0; } - V8_INLINE(T* operator->() const) { return val_; } + V8_INLINE T* operator->() const { return val_; } - V8_INLINE(T* operator*() const) { return val_; } + V8_INLINE T* operator*() const { return val_; } /** * Checks whether two handles are the same. @@ -303,7 +253,7 @@ template class Handle { * to which they refer are identical. * The handles' references are not checked. */ - template V8_INLINE(bool operator==(const Handle that) const) { + template V8_INLINE bool operator==(const Handle& that) const { internal::Object** a = reinterpret_cast(**this); internal::Object** b = reinterpret_cast(*that); if (a == 0) return b == 0; @@ -311,16 +261,14 @@ template class Handle { return *a == *b; } -#ifndef V8_USE_UNSAFE_HANDLES - template V8_INLINE( - bool operator==(const Persistent& that) const) { + template V8_INLINE bool operator==( + const Persistent& that) const { internal::Object** a = reinterpret_cast(**this); internal::Object** b = reinterpret_cast(*that); if (a == 0) return b == 0; if (b == 0) return false; return *a == *b; } -#endif /** * Checks whether two handles are different. @@ -328,11 +276,16 @@ template class Handle { * the objects to which they refer are different. * The handles' references are not checked. */ - template V8_INLINE(bool operator!=(Handle that) const) { + template V8_INLINE bool operator!=(const Handle& that) const { return !operator==(that); } - template V8_INLINE(static Handle Cast(Handle that)) { + template V8_INLINE bool operator!=( + const Persistent& that) const { + return !operator==(that); + } + + template V8_INLINE static Handle Cast(Handle that) { #ifdef V8_ENABLE_CHECKS // If we're going to perform the type check then we have to check // that the handle isn't empty before doing the checked cast. @@ -341,16 +294,14 @@ template class Handle { return Handle(T::Cast(*that)); } - template V8_INLINE(Handle As()) { + template V8_INLINE Handle As() { return Handle::Cast(*this); } -#ifndef V8_USE_UNSAFE_HANDLES - V8_INLINE(static Handle New(Isolate* isolate, Handle that)) { + V8_INLINE static Handle New(Isolate* isolate, Handle that) { return New(isolate, that.val_); } - // TODO(dcarney): remove before cutover - V8_INLINE(static Handle New(Isolate* isolate, const Persistent& that)) { + V8_INLINE static Handle New(Isolate* isolate, const Persistent& that) { return New(isolate, that.val_); } @@ -361,18 +312,15 @@ template class Handle { /** * Creates a new handle for the specified value. */ - V8_INLINE(explicit Handle(T* val)) : val_(val) {} -#endif + V8_INLINE explicit Handle(T* val) : val_(val) {} private: friend class Utils; - template friend class Persistent; + template friend class Persistent; template friend class Local; - friend class Arguments; template friend class FunctionCallbackInfo; template friend class PropertyCallbackInfo; template friend class internal::CustomArguments; - friend class AccessorInfo; friend Handle Undefined(Isolate* isolate); friend Handle Null(Isolate* isolate); friend Handle True(Isolate* isolate); @@ -380,19 +328,12 @@ template class Handle { friend class Context; friend class HandleScope; -#ifndef V8_USE_UNSAFE_HANDLES - V8_INLINE(static Handle New(Isolate* isolate, T* that)); -#endif + V8_INLINE static Handle New(Isolate* isolate, T* that); T* val_; }; -// A value which will never be returned by Local::Eternalize -// Useful for static initialization -const int kUninitializedEternalIndex = -1; - - /** * A light-weight stack-allocated object handle. All operations * that return objects from within v8 return them in local handles. They @@ -400,11 +341,10 @@ const int kUninitializedEternalIndex = -1; * handle scope are destroyed when the handle scope is destroyed. Hence it * is not necessary to explicitly deallocate local handles. */ -// TODO(dcarney): deprecate entire class template class Local : public Handle { public: - V8_INLINE(Local()); - template V8_INLINE(Local(Local that)) + V8_INLINE Local(); + template V8_INLINE Local(Local that) : Handle(reinterpret_cast(*that)) { /** * This check fails when trying to convert between incompatible @@ -415,11 +355,7 @@ template class Local : public Handle { } -#ifdef V8_USE_UNSAFE_HANDLES - template V8_INLINE(Local(S* that) : Handle(that)) { } -#endif - - template V8_INLINE(static Local Cast(Local that)) { + template V8_INLINE static Local Cast(Local that) { #ifdef V8_ENABLE_CHECKS // If we're going to perform the type check then we have to check // that the handle isn't empty before doing the checked cast. @@ -427,57 +363,122 @@ template class Local : public Handle { #endif return Local(T::Cast(*that)); } -#ifndef V8_USE_UNSAFE_HANDLES - template V8_INLINE(Local(Handle that)) + template V8_INLINE Local(Handle that) : Handle(reinterpret_cast(*that)) { TYPE_CHECK(T, S); } -#endif - template V8_INLINE(Local As()) { + template V8_INLINE Local As() { return Local::Cast(*this); } - // Keep this Local alive for the lifetime of the Isolate. - // It remains retrievable via the returned index, - V8_INLINE(int Eternalize(Isolate* isolate)); - V8_INLINE(static Local GetEternal(Isolate* isolate, int index)); - /** * Create a local handle for the content of another handle. * The referee is kept alive by the local handle even when * the original handle is destroyed/disposed. */ - V8_INLINE(static Local New(Handle that)); - V8_INLINE(static Local New(Isolate* isolate, Handle that)); -#ifndef V8_USE_UNSAFE_HANDLES - // TODO(dcarney): remove before cutover - V8_INLINE(static Local New(Isolate* isolate, const Persistent& that)); + V8_INLINE static Local New(Handle that); + V8_INLINE static Local New(Isolate* isolate, Handle that); + template + V8_INLINE static Local New(Isolate* isolate, + const Persistent& that); #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR private: #endif - template V8_INLINE(Local(S* that) : Handle(that)) { } -#endif + template V8_INLINE Local(S* that) : Handle(that) { } private: friend class Utils; - template friend class Persistent; + template friend class Eternal; + template friend class Persistent; template friend class Handle; - friend class Arguments; template friend class FunctionCallbackInfo; template friend class PropertyCallbackInfo; friend class String; friend class Object; - friend class AccessorInfo; friend class Context; template friend class internal::CustomArguments; friend class HandleScope; - V8_INLINE(static Local New(Isolate* isolate, T* that)); + V8_INLINE static Local New(Isolate* isolate, T* that); }; + +// Eternal handles are set-once handles that live for the life of the isolate. +template class Eternal { + public: + V8_INLINE Eternal() : index_(kInitialValue) { } + template + V8_INLINE Eternal(Isolate* isolate, Local handle) : index_(kInitialValue) { + Set(isolate, handle); + } + // Can only be safely called if already set. + V8_INLINE Local Get(Isolate* isolate); + V8_INLINE bool IsEmpty() { return index_ == kInitialValue; } + template V8_INLINE void Set(Isolate* isolate, Local handle); + + private: + static const int kInitialValue = -1; + int index_; +}; + + +template +class WeakCallbackData { + public: + typedef void (*Callback)(const WeakCallbackData& data); + + V8_INLINE Isolate* GetIsolate() const { return isolate_; } + V8_INLINE Local GetValue() const { return handle_; } + V8_INLINE P* GetParameter() const { return parameter_; } + + private: + friend class internal::GlobalHandles; + WeakCallbackData(Isolate* isolate, Local handle, P* parameter) + : isolate_(isolate), handle_(handle), parameter_(parameter) { } + Isolate* isolate_; + Local handle_; + P* parameter_; +}; + + +// TODO(dcarney): Remove this class. +template > +class WeakReferenceCallbacks { + public: + typedef void (*Revivable)(Isolate* isolate, + Persistent* object, + P* parameter); +}; + + +/** + * Default traits for Persistent. This class does not allow + * use of the copy constructor or assignment operator. + * At present kResetInDestructor is not set, but that will change in a future + * version. + */ +template +class NonCopyablePersistentTraits { + public: + typedef Persistent > NonCopyablePersistent; + static const bool kResetInDestructor = false; + template + V8_INLINE static void Copy(const Persistent& source, + NonCopyablePersistent* dest) { + Uncompilable(); + } + // TODO(dcarney): come up with a good compile error here. + template V8_INLINE static void Uncompilable() { + TYPE_CHECK(O, Primitive); + } +}; + + /** * An object reference that is independent of any handle scope. Where * a Local handle only lives as long as the HandleScope in which it was @@ -487,108 +488,94 @@ template class Local : public Handle { * A persistent handle contains a reference to a storage cell within * the v8 engine which holds an object value and which is updated by * the garbage collector whenever the object is moved. A new storage - * cell can be created using Persistent::New and existing handles can - * be disposed using Persistent::Dispose. Since persistent handles - * are passed by value you may have many persistent handle objects - * that point to the same storage cell. For instance, if you pass a - * persistent handle as an argument to a function you will not get two - * different storage cells but rather two references to the same - * storage cell. + * cell can be created using the constructor or Persistent::Reset and + * existing handles can be disposed using Persistent::Reset. + * + * Copy, assignment and destructor bevavior is controlled by the traits + * class M. */ -template class Persistent // NOLINT -#ifdef V8_USE_UNSAFE_HANDLES - : public Handle { -#else - { // NOLINT -#endif +template class Persistent { public: -#ifndef V8_USE_UNSAFE_HANDLES - V8_INLINE(Persistent()) : val_(0) { } - // TODO(dcarney): add this back before cutover. -// V8_INLINE(~Persistent()) { -// Dispose(); -// } - V8_INLINE(bool IsEmpty() const) { return val_ == 0; } - // TODO(dcarney): remove somehow before cutover - // The handle should either be 0, or a pointer to a live cell. - V8_INLINE(void Clear()) { val_ = 0; } - /** - * A constructor that creates a new global cell pointing to that. In contrast - * to the copy constructor, this creates a new persistent handle which needs - * to be separately disposed. + * A Persistent with no storage cell. */ - template V8_INLINE(Persistent(Isolate* isolate, Handle that)) - : val_(New(isolate, *that)) { } - - template V8_INLINE(Persistent(Isolate* isolate, - const Persistent& that)) // NOLINT - : val_(New(isolate, *that)) { } - -#else + V8_INLINE Persistent() : val_(0) { } /** - * Creates an empty persistent handle that doesn't point to any - * storage cell. + * Construct a Persistent from a Handle. + * When the Handle is non-empty, a new storage cell is created + * pointing to the same object, and no flags are set. */ - V8_INLINE(Persistent()) : Handle() { } - + template V8_INLINE Persistent(Isolate* isolate, Handle that) + : val_(New(isolate, *that)) { + TYPE_CHECK(T, S); + } /** - * Creates a persistent handle for the same storage cell as the - * specified handle. This constructor allows you to pass persistent - * handles as arguments by value and to assign between persistent - * handles. However, attempting to assign between incompatible - * persistent handles, for instance from a Persistent to a - * Persistent will cause a compile-time error. Assigning - * between compatible persistent handles, for instance assigning a - * Persistent to a variable declared as Persistent, - * is allowed as String is a subclass of Value. + * Construct a Persistent from a Persistent. + * When the Persistent is non-empty, a new storage cell is created + * pointing to the same object, and no flags are set. */ - template V8_INLINE(Persistent(Persistent that)) - : Handle(reinterpret_cast(*that)) { - /** - * This check fails when trying to convert between incompatible - * handles. For example, converting from a Handle to a - * Handle. - */ + template + V8_INLINE Persistent(Isolate* isolate, const Persistent& that) + : val_(New(isolate, *that)) { TYPE_CHECK(T, S); } - - template V8_INLINE(Persistent(S* that)) : Handle(that) { } - /** - * A constructor that creates a new global cell pointing to that. In contrast - * to the copy constructor, this creates a new persistent handle which needs - * to be separately disposed. + * The copy constructors and assignment operator create a Persistent + * exactly as the Persistent constructor, but the Copy function from the + * traits class is called, allowing the setting of flags based on the + * copied Persistent. */ - template V8_INLINE(Persistent(Isolate* isolate, Handle that)) - : Handle(New(isolate, that)) { } - + V8_INLINE Persistent(const Persistent& that) : val_(0) { + Copy(that); + } + template + V8_INLINE Persistent(const Persistent& that) : val_(0) { + Copy(that); + } + V8_INLINE Persistent& operator=(const Persistent& that) { // NOLINT + Copy(that); + return *this; + } + template + V8_INLINE Persistent& operator=(const Persistent& that) { // NOLINT + Copy(that); + return *this; + } /** - * "Casts" a plain handle which is known to be a persistent handle - * to a persistent handle. + * The destructor will dispose the Persistent based on the + * kResetInDestructor flags in the traits class. Since not calling dispose + * can result in a memory leak, it is recommended to always set this flag. */ - template explicit V8_INLINE(Persistent(Handle that)) - : Handle(*that) { } - -#endif - -#ifdef V8_USE_UNSAFE_HANDLES - template V8_INLINE(static Persistent Cast(Persistent that)) { -#ifdef V8_ENABLE_CHECKS - // If we're going to perform the type check then we have to check - // that the handle isn't empty before doing the checked cast. - if (that.IsEmpty()) return Persistent(); -#endif - return Persistent(T::Cast(*that)); + V8_INLINE ~Persistent() { + if (M::kResetInDestructor) Reset(); } - template V8_INLINE(Persistent As()) { - return Persistent::Cast(*this); - } + /** + * If non-empty, destroy the underlying storage cell + * IsEmpty() will return true after this call. + */ + V8_INLINE void Reset(); + /** + * If non-empty, destroy the underlying storage cell + * and create a new one with the contents of other if other is non empty + */ + template + V8_INLINE void Reset(Isolate* isolate, const Handle& other); + /** + * If non-empty, destroy the underlying storage cell + * and create a new one with the contents of other if other is non empty + */ + template + V8_INLINE void Reset(Isolate* isolate, const Persistent& other); + // TODO(dcarney): deprecate + V8_INLINE void Dispose() { Reset(); } + V8_DEPRECATED(V8_INLINE void Dispose(Isolate* isolate)) { Reset(); } -#else + V8_INLINE bool IsEmpty() const { return val_ == 0; } + + // TODO(dcarney): this is pretty useless, fix or remove template - V8_INLINE(static Persistent& Cast(Persistent& that)) { // NOLINT + V8_INLINE static Persistent& Cast(Persistent& that) { // NOLINT #ifdef V8_ENABLE_CHECKS // If we're going to perform the type check then we have to check // that the handle isn't empty before doing the checked cast. @@ -597,20 +584,13 @@ template class Persistent // NOLINT return reinterpret_cast&>(that); } - template V8_INLINE(Persistent& As()) { // NOLINT + // TODO(dcarney): this is pretty useless, fix or remove + template V8_INLINE Persistent& As() { // NOLINT return Persistent::Cast(*this); } -#endif -#ifdef V8_USE_UNSAFE_HANDLES - V8_DEPRECATED(static Persistent New(Handle that)); - V8_INLINE(static Persistent New(Isolate* isolate, Handle that)); - V8_INLINE(static Persistent New(Isolate* isolate, Persistent that)); -#endif - -#ifndef V8_USE_UNSAFE_HANDLES - template V8_INLINE( - bool operator==(const Persistent& that) const) { + template + V8_INLINE bool operator==(const Persistent& that) const { internal::Object** a = reinterpret_cast(**this); internal::Object** b = reinterpret_cast(*that); if (a == 0) return b == 0; @@ -618,58 +598,48 @@ template class Persistent // NOLINT return *a == *b; } - template V8_INLINE(bool operator==(const Handle that) const) { + template V8_INLINE bool operator==(const Handle& that) const { internal::Object** a = reinterpret_cast(**this); internal::Object** b = reinterpret_cast(*that); if (a == 0) return b == 0; if (b == 0) return false; return *a == *b; } -#endif - - V8_INLINE(void Dispose()); - /** - * Releases the storage cell referenced by this persistent handle. - * Does not remove the reference to the cell from any handles. - * This handle's reference, and any other references to the storage - * cell remain and IsEmpty will still return false. - */ - // TODO(dcarney): deprecate - V8_INLINE(void Dispose(Isolate* isolate)) { Dispose(); } + template + V8_INLINE bool operator!=(const Persistent& that) const { + return !operator==(that); + } - /** - * Make the reference to this object weak. When only weak handles - * refer to the object, the garbage collector will perform a - * callback to the given V8::NearDeathCallback function, passing - * it the object reference and the given parameters. - */ - template - V8_INLINE(void MakeWeak( - P* parameters, - typename WeakReferenceCallbacks::Revivable callback)); + template V8_INLINE bool operator!=(const Handle& that) const { + return !operator==(that); + } template - V8_INLINE(void MakeWeak( - P* parameters, - typename WeakReferenceCallbacks::Revivable callback)); + V8_INLINE void SetWeak( + P* parameter, + typename WeakCallbackData::Callback callback); template - V8_DEPRECATED(void MakeWeak( - Isolate* isolate, - P* parameters, - typename WeakReferenceCallbacks::Revivable callback)); + V8_INLINE void SetWeak( + P* parameter, + typename WeakCallbackData::Callback callback); + + // TODO(dcarney): deprecate + template + V8_INLINE void MakeWeak( + P* parameter, + typename WeakReferenceCallbacks::Revivable callback); + // TODO(dcarney): deprecate template - V8_DEPRECATED(void MakeWeak( - Isolate* isolate, - P* parameters, - typename WeakReferenceCallbacks::Revivable callback)); + V8_INLINE void MakeWeak( + P* parameter, + typename WeakReferenceCallbacks::Revivable callback); - V8_INLINE(void ClearWeak()); + V8_INLINE void ClearWeak(); - // TODO(dcarney): deprecate - V8_INLINE(void ClearWeak(Isolate* isolate)) { ClearWeak(); } + V8_DEPRECATED(V8_INLINE void ClearWeak(Isolate* isolate)) { ClearWeak(); } /** * Marks the reference to this object independent. Garbage collector is free @@ -677,10 +647,11 @@ template class Persistent // NOLINT * independent handle should not assume that it will be preceded by a global * GC prologue callback or followed by a global GC epilogue callback. */ - V8_INLINE(void MarkIndependent()); + V8_INLINE void MarkIndependent(); - // TODO(dcarney): deprecate - V8_INLINE(void MarkIndependent(Isolate* isolate)) { MarkIndependent(); } + V8_DEPRECATED(V8_INLINE void MarkIndependent(Isolate* isolate)) { + MarkIndependent(); + } /** * Marks the reference to this object partially dependent. Partially dependent @@ -690,40 +661,40 @@ template class Persistent // NOLINT * external dependencies. This mark is automatically cleared after each * garbage collection. */ - V8_INLINE(void MarkPartiallyDependent()); + V8_INLINE void MarkPartiallyDependent(); - // TODO(dcarney): deprecate - V8_INLINE(void MarkPartiallyDependent(Isolate* isolate)) { + V8_DEPRECATED(V8_INLINE void MarkPartiallyDependent(Isolate* isolate)) { MarkPartiallyDependent(); } - V8_INLINE(bool IsIndependent() const); + V8_INLINE bool IsIndependent() const; - // TODO(dcarney): deprecate - V8_INLINE(bool IsIndependent(Isolate* isolate) const) { + V8_DEPRECATED(V8_INLINE bool IsIndependent(Isolate* isolate) const) { return IsIndependent(); } /** Checks if the handle holds the only reference to an object. */ - V8_INLINE(bool IsNearDeath() const); + V8_INLINE bool IsNearDeath() const; - // TODO(dcarney): deprecate - V8_INLINE(bool IsNearDeath(Isolate* isolate) const) { return IsNearDeath(); } + V8_DEPRECATED(V8_INLINE bool IsNearDeath(Isolate* isolate) const) { + return IsNearDeath(); + } /** Returns true if the handle's reference is weak. */ - V8_INLINE(bool IsWeak() const); + V8_INLINE bool IsWeak() const; - // TODO(dcarney): deprecate - V8_INLINE(bool IsWeak(Isolate* isolate) const) { return IsWeak(); } + V8_DEPRECATED(V8_INLINE bool IsWeak(Isolate* isolate) const) { + return IsWeak(); + } /** * Assigns a wrapper class ID to the handle. See RetainedObjectInfo interface * description in v8-profiler.h for details. */ - V8_INLINE(void SetWrapperClassId(uint16_t class_id)); + V8_INLINE void SetWrapperClassId(uint16_t class_id); - // TODO(dcarney): deprecate - V8_INLINE(void SetWrapperClassId(Isolate* isolate, uint16_t class_id)) { + V8_DEPRECATED( + V8_INLINE void SetWrapperClassId(Isolate * isolate, uint16_t class_id)) { SetWrapperClassId(class_id); } @@ -731,75 +702,41 @@ template class Persistent // NOLINT * Returns the class ID previously assigned to this handle or 0 if no class ID * was previously assigned. */ - V8_INLINE(uint16_t WrapperClassId() const); + V8_INLINE uint16_t WrapperClassId() const; - // TODO(dcarney): deprecate - V8_INLINE(uint16_t WrapperClassId(Isolate* isolate) const) { + V8_DEPRECATED(V8_INLINE uint16_t WrapperClassId(Isolate* isolate) const) { return WrapperClassId(); } - /** - * Disposes the current contents of the handle and replaces it. - */ - V8_INLINE(void Reset(Isolate* isolate, const Handle& other)); + // TODO(dcarney): remove + V8_INLINE T* ClearAndLeak(); -#ifndef V8_USE_UNSAFE_HANDLES - V8_INLINE(void Reset(Isolate* isolate, const Persistent& other)); -#endif + // TODO(dcarney): remove + V8_INLINE void Clear() { val_ = 0; } - /** - * Returns the underlying raw pointer and clears the handle. The caller is - * responsible of eventually destroying the underlying object (by creating a - * Persistent handle which points to it and Disposing it). In the future, - * destructing a Persistent will also Dispose it. With this function, the - * embedder can let the Persistent go out of scope without it getting - * disposed. - */ - V8_INLINE(T* ClearAndLeak()); - -#ifndef V8_USE_UNSAFE_HANDLES - - private: - // TODO(dcarney): make unlinkable before cutover - V8_INLINE(Persistent(const Persistent& that)) : val_(that.val_) {} - // TODO(dcarney): make unlinkable before cutover - V8_INLINE(Persistent& operator=(const Persistent& that)) { // NOLINT - this->val_ = that.val_; - return *this; - } - - public: + // TODO(dcarney): remove #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR private: #endif - // TODO(dcarney): remove before cutover - template V8_INLINE(Persistent(S* that)) : val_(that) { } + template V8_INLINE Persistent(S* that) : val_(that) { } - // TODO(dcarney): remove before cutover - V8_INLINE(T* operator*() const) { return val_; } - - private: - // TODO(dcarney): remove before cutover - V8_INLINE(T* operator->() const) { return val_; } - public: -#endif + V8_INLINE T* operator*() const { return val_; } private: friend class Utils; template friend class Handle; template friend class Local; - template friend class Persistent; + template friend class Persistent; template friend class ReturnValue; - V8_INLINE(static T* New(Isolate* isolate, T* that)); + V8_INLINE static T* New(Isolate* isolate, T* that); + template + V8_INLINE void Copy(const Persistent& that); -#ifndef V8_USE_UNSAFE_HANDLES T* val_; -#endif }; - /** * A stack-allocated class that governs a number of local handles. * After a handle scope has been created, all local handles will be @@ -816,9 +753,6 @@ template class Persistent // NOLINT */ class V8_EXPORT HandleScope { public: - // TODO(svenpanne) Deprecate me when Chrome is fixed! - HandleScope(); - HandleScope(Isolate* isolate); ~HandleScope(); @@ -858,7 +792,7 @@ class V8_EXPORT HandleScope { internal::Object** next; internal::Object** limit; int level; - V8_INLINE(void Initialize()) { + V8_INLINE void Initialize() { next = limit = NULL; level = 0; } @@ -880,6 +814,21 @@ class V8_EXPORT HandleScope { }; +/** + * A simple Maybe type, representing an object which may or may not have a + * value. + */ +template +struct Maybe { + Maybe() : has_value(false) {} + explicit Maybe(T t) : has_value(true), value(t) {} + Maybe(bool has, T t) : has_value(has), value(t) {} + + bool has_value; + T value; +}; + + // --- Special objects --- @@ -952,19 +901,19 @@ class V8_EXPORT ScriptData { // NOLINT */ class ScriptOrigin { public: - V8_INLINE(ScriptOrigin( + V8_INLINE ScriptOrigin( Handle resource_name, Handle resource_line_offset = Handle(), Handle resource_column_offset = Handle(), - Handle resource_is_shared_cross_origin = Handle())) + Handle resource_is_shared_cross_origin = Handle()) : resource_name_(resource_name), resource_line_offset_(resource_line_offset), resource_column_offset_(resource_column_offset), resource_is_shared_cross_origin_(resource_is_shared_cross_origin) { } - V8_INLINE(Handle ResourceName() const); - V8_INLINE(Handle ResourceLineOffset() const); - V8_INLINE(Handle ResourceColumnOffset() const); - V8_INLINE(Handle ResourceIsSharedCrossOrigin() const); + V8_INLINE Handle ResourceName() const; + V8_INLINE Handle ResourceLineOffset() const; + V8_INLINE Handle ResourceColumnOffset() const; + V8_INLINE Handle ResourceIsSharedCrossOrigin() const; private: Handle resource_name_; Handle resource_line_offset_; @@ -1158,6 +1107,7 @@ class V8_EXPORT Message { static const int kNoLineNumberInfo = 0; static const int kNoColumnInfo = 0; + static const int kNoScriptIdInfo = 0; }; @@ -1180,6 +1130,7 @@ class V8_EXPORT StackTrace { kIsEval = 1 << 4, kIsConstructor = 1 << 5, kScriptNameOrSourceURL = 1 << 6, + kScriptId = 1 << 7, kOverview = kLineNumber | kColumnOffset | kScriptName | kFunctionName, kDetailed = kOverview | kIsEval | kIsConstructor | kScriptNameOrSourceURL }; @@ -1234,6 +1185,14 @@ class V8_EXPORT StackFrame { */ int GetColumn() const; + /** + * Returns the id of the script for the function for this StackFrame. + * This method will return Message::kNoScriptIdInfo if it is unable to + * retrieve the script id, or if kScriptId was not passed as an option when + * capturing the StackTrace. + */ + int GetScriptId() const; + /** * Returns the name of the resource that contains the script for the * function for this StackFrame. @@ -1295,13 +1254,13 @@ class V8_EXPORT Value : public Data { * Returns true if this value is the undefined value. See ECMA-262 * 4.3.10. */ - V8_INLINE(bool IsUndefined() const); + V8_INLINE bool IsUndefined() const; /** * Returns true if this value is the null value. See ECMA-262 * 4.3.11. */ - V8_INLINE(bool IsNull() const); + V8_INLINE bool IsNull() const; /** * Returns true if this value is true. @@ -1317,7 +1276,7 @@ class V8_EXPORT Value : public Data { * Returns true if this value is an instance of the String type. * See ECMA-262 8.4. */ - V8_INLINE(bool IsString() const); + V8_INLINE bool IsString() const; /** * Returns true if this value is a symbol. @@ -1505,12 +1464,12 @@ class V8_EXPORT Value : public Data { bool Equals(Handle that) const; bool StrictEquals(Handle that) const; - template V8_INLINE(static Value* Cast(T* value)); + template V8_INLINE static Value* Cast(T* value); private: - V8_INLINE(bool QuickIsUndefined() const); - V8_INLINE(bool QuickIsNull() const); - V8_INLINE(bool QuickIsString() const); + V8_INLINE bool QuickIsUndefined() const; + V8_INLINE bool QuickIsNull() const; + V8_INLINE bool QuickIsString() const; bool FullIsUndefined() const; bool FullIsNull() const; bool FullIsString() const; @@ -1530,7 +1489,7 @@ class V8_EXPORT Primitive : public Value { }; class V8_EXPORT Boolean : public Primitive { public: bool Value() const; - V8_INLINE(static Handle New(bool value)); + V8_INLINE static Handle New(bool value); }; @@ -1559,7 +1518,7 @@ class V8_EXPORT String : public Primitive { /** * This function is no longer useful. */ - V8_DEPRECATED(V8_INLINE(bool MayContainNonAscii()) const) { return true; } + V8_DEPRECATED(V8_INLINE bool MayContainNonAscii() const) { return true; } /** * Returns whether this string is known to contain only one byte data. @@ -1631,7 +1590,7 @@ class V8_EXPORT String : public Primitive { * A zero length string. */ static v8::Local Empty(); - V8_INLINE(static v8::Local Empty(Isolate* isolate)); + V8_INLINE static v8::Local Empty(Isolate* isolate); /** * Returns true if the string is external @@ -1729,14 +1688,14 @@ class V8_EXPORT String : public Primitive { * regardless of the encoding, otherwise return NULL. The encoding of the * string is returned in encoding_out. */ - V8_INLINE(ExternalStringResourceBase* GetExternalStringResourceBase( - Encoding* encoding_out) const); + V8_INLINE ExternalStringResourceBase* GetExternalStringResourceBase( + Encoding* encoding_out) const; /** * Get the ExternalStringResource for an external string. Returns * NULL if IsExternal() doesn't return true. */ - V8_INLINE(ExternalStringResource* GetExternalStringResource() const); + V8_INLINE ExternalStringResource* GetExternalStringResource() const; /** * Get the ExternalAsciiStringResource for an external ASCII string. @@ -1744,7 +1703,7 @@ class V8_EXPORT String : public Primitive { */ const ExternalAsciiStringResource* GetExternalAsciiStringResource() const; - V8_INLINE(static String* Cast(v8::Value* obj)); + V8_INLINE static String* Cast(v8::Value* obj); // TODO(dcarney): deprecate /** @@ -1752,18 +1711,18 @@ class V8_EXPORT String : public Primitive { * The second parameter 'length' gives the buffer length. If omitted, * the function calls 'strlen' to determine the buffer length. */ - V8_INLINE(static Local New(const char* data, int length = -1)); + V8_INLINE static Local New(const char* data, int length = -1); // TODO(dcarney): deprecate /** Allocates a new string from 16-bit character codes.*/ - V8_INLINE(static Local New(const uint16_t* data, int length = -1)); + V8_INLINE static Local New(const uint16_t* data, int length = -1); // TODO(dcarney): deprecate /** * Creates an internalized string (historically called a "symbol", * not to be confused with ES6 symbols). Returns one if it exists already. */ - V8_INLINE(static Local NewSymbol(const char* data, int length = -1)); + V8_INLINE static Local NewSymbol(const char* data, int length = -1); enum NewStringType { kNormalString, kInternalizedString, kUndetectableString @@ -1844,13 +1803,13 @@ class V8_EXPORT String : public Primitive { // TODO(dcarney): deprecate /** Creates an undetectable string from the supplied ASCII or UTF-8 data.*/ - V8_INLINE( - static Local NewUndetectable(const char* data, int length = -1)); + V8_INLINE static Local NewUndetectable(const char* data, + int length = -1); // TODO(dcarney): deprecate /** Creates an undetectable string from the supplied 16-bit character codes.*/ - V8_INLINE(static Local NewUndetectable( - const uint16_t* data, int length = -1)); + V8_INLINE static Local NewUndetectable(const uint16_t* data, + int length = -1); /** * Converts an object to a UTF-8-encoded character array. Useful if @@ -1945,7 +1904,7 @@ class V8_EXPORT Symbol : public Primitive { // Create a symbol with a print name. static Local New(Isolate *isolate, const char* data, int length = -1); - V8_INLINE(static Symbol* Cast(v8::Value* obj)); + V8_INLINE static Symbol* Cast(v8::Value* obj); private: Symbol(); static void CheckCast(v8::Value* obj); @@ -1960,7 +1919,7 @@ class V8_EXPORT Number : public Primitive { double Value() const; static Local New(double value); static Local New(Isolate* isolate, double value); - V8_INLINE(static Number* Cast(v8::Value* obj)); + V8_INLINE static Number* Cast(v8::Value* obj); private: Number(); static void CheckCast(v8::Value* obj); @@ -1977,7 +1936,7 @@ class V8_EXPORT Integer : public Number { static Local New(int32_t value, Isolate*); static Local NewFromUnsigned(uint32_t value, Isolate*); int64_t Value() const; - V8_INLINE(static Integer* Cast(v8::Value* obj)); + V8_INLINE static Integer* Cast(v8::Value* obj); private: Integer(); static void CheckCast(v8::Value* obj); @@ -2030,16 +1989,11 @@ enum ExternalArrayType { * setting|getting a particular property. See Object and ObjectTemplate's * method SetAccessor. */ -typedef Handle (*AccessorGetter)(Local property, - const AccessorInfo& info); typedef void (*AccessorGetterCallback)( Local property, const PropertyCallbackInfo& info); -typedef void (*AccessorSetter)(Local property, - Local value, - const AccessorInfo& info); typedef void (*AccessorSetterCallback)( Local property, Local value, @@ -2113,12 +2067,6 @@ class V8_EXPORT Object : public Value { bool Delete(uint32_t index); - V8_DEPRECATED(bool SetAccessor(Handle name, - AccessorGetter getter, - AccessorSetter setter = 0, - Handle data = Handle(), - AccessControl settings = DEFAULT, - PropertyAttribute attribute = None)); bool SetAccessor(Handle name, AccessorGetterCallback getter, AccessorSetterCallback setter = 0, @@ -2127,10 +2075,10 @@ class V8_EXPORT Object : public Value { PropertyAttribute attribute = None); // This function is not yet stable and should not be used at this time. - bool SetAccessor(Handle name, - Handle descriptor, - AccessControl settings = DEFAULT, - PropertyAttribute attribute = None); + bool SetDeclaredAccessor(Local name, + Local descriptor, + PropertyAttribute attribute = None, + AccessControl settings = DEFAULT); /** * Returns an array containing the names of the enumerable properties @@ -2189,7 +2137,7 @@ class V8_EXPORT Object : public Value { int InternalFieldCount(); /** Gets the value from an internal field. */ - V8_INLINE(Local GetInternalField(int index)); + V8_INLINE Local GetInternalField(int index); /** Sets the value in an internal field. */ void SetInternalField(int index, Handle value); @@ -2199,7 +2147,7 @@ class V8_EXPORT Object : public Value { * must have been set by SetAlignedPointerInInternalField, everything else * leads to undefined behavior. */ - V8_INLINE(void* GetAlignedPointerFromInternalField(int index)); + V8_INLINE void* GetAlignedPointerFromInternalField(int index); /** * Sets a 2-byte-aligned native pointer in an internal field. To retrieve such @@ -2329,7 +2277,7 @@ class V8_EXPORT Object : public Value { Local CallAsConstructor(int argc, Handle argv[]); static Local New(); - V8_INLINE(static Object* Cast(Value* obj)); + V8_INLINE static Object* Cast(Value* obj); private: Object(); @@ -2358,18 +2306,135 @@ class V8_EXPORT Array : public Object { */ static Local New(int length = 0); - V8_INLINE(static Array* Cast(Value* obj)); + V8_INLINE static Array* Cast(Value* obj); private: Array(); static void CheckCast(Value* obj); }; +template +class ReturnValue { + public: + template V8_INLINE ReturnValue(const ReturnValue& that) + : value_(that.value_) { + TYPE_CHECK(T, S); + } + // Handle setters + template V8_INLINE void Set(const Persistent& handle); + template V8_INLINE void Set(const Handle handle); + // Fast primitive setters + V8_INLINE void Set(bool value); + V8_INLINE void Set(double i); + V8_INLINE void Set(int32_t i); + V8_INLINE void Set(uint32_t i); + // Fast JS primitive setters + V8_INLINE void SetNull(); + V8_INLINE void SetUndefined(); + V8_INLINE void SetEmptyString(); + // Convenience getter for Isolate + V8_INLINE Isolate* GetIsolate(); + + private: + template friend class ReturnValue; + template friend class FunctionCallbackInfo; + template friend class PropertyCallbackInfo; + V8_INLINE internal::Object* GetDefaultValue(); + V8_INLINE explicit ReturnValue(internal::Object** slot); + internal::Object** value_; +}; + + +/** + * The argument information given to function call callbacks. This + * class provides access to information about the context of the call, + * including the receiver, the number and values of arguments, and + * the holder of the function. + */ +template +class FunctionCallbackInfo { + public: + V8_INLINE int Length() const; + V8_INLINE Local operator[](int i) const; + V8_INLINE Local Callee() const; + V8_INLINE Local This() const; + V8_INLINE Local Holder() const; + V8_INLINE bool IsConstructCall() const; + V8_INLINE Local Data() const; + V8_INLINE Isolate* GetIsolate() const; + V8_INLINE ReturnValue GetReturnValue() const; + // This shouldn't be public, but the arm compiler needs it. + static const int kArgsLength = 6; + + protected: + friend class internal::FunctionCallbackArguments; + friend class internal::CustomArguments; + static const int kReturnValueIndex = 0; + static const int kReturnValueDefaultValueIndex = -1; + static const int kIsolateIndex = -2; + static const int kDataIndex = -3; + static const int kCalleeIndex = -4; + static const int kHolderIndex = -5; + + V8_INLINE FunctionCallbackInfo(internal::Object** implicit_args, + internal::Object** values, + int length, + bool is_construct_call); + internal::Object** implicit_args_; + internal::Object** values_; + int length_; + bool is_construct_call_; +}; + + +/** + * The information passed to a property callback about the context + * of the property access. + */ +template +class PropertyCallbackInfo { + public: + V8_INLINE Isolate* GetIsolate() const; + V8_INLINE Local Data() const; + V8_INLINE Local This() const; + V8_INLINE Local Holder() const; + V8_INLINE ReturnValue GetReturnValue() const; + // This shouldn't be public, but the arm compiler needs it. + static const int kArgsLength = 6; + + protected: + friend class MacroAssembler; + friend class internal::PropertyCallbackArguments; + friend class internal::CustomArguments; + static const int kThisIndex = 0; + static const int kDataIndex = -1; + static const int kReturnValueIndex = -2; + static const int kReturnValueDefaultValueIndex = -3; + static const int kIsolateIndex = -4; + static const int kHolderIndex = -5; + + V8_INLINE PropertyCallbackInfo(internal::Object** args) : args_(args) {} + internal::Object** args_; +}; + + +typedef void (*FunctionCallback)(const FunctionCallbackInfo& info); + + /** * A JavaScript function object (ECMA-262, 15.3). */ class V8_EXPORT Function : public Object { public: + /** + * Create a function in the current execution context + * for a given FunctionCallback. + */ + static Local New(Isolate* isolate, + FunctionCallback callback, + Local data = Local(), + int length = 0); + Local NewInstance() const; Local NewInstance(int argc, Handle argv[]) const; Local Call(Handle recv, int argc, Handle argv[]); @@ -2407,7 +2472,7 @@ class V8_EXPORT Function : public Object { int ScriptId() const; ScriptOrigin GetScriptOrigin() const; - V8_INLINE(static Function* Cast(Value* obj)); + V8_INLINE static Function* Cast(Value* obj); static const int kLineOffsetNotFound; private: @@ -2447,27 +2512,12 @@ class V8_EXPORT ArrayBuffer : public Object { * Allocate |length| bytes. Return NULL if allocation is not successful. * Memory does not have to be initialized. */ - virtual void* AllocateUninitialized(size_t length) { - // Override with call to |Allocate| for compatibility - // with legacy version. - return Allocate(length); - } - + virtual void* AllocateUninitialized(size_t length) = 0; /** * Free the memory block of size |length|, pointed to by |data|. * That memory is guaranteed to be previously allocated by |Allocate|. */ - virtual void Free(void* data, size_t length) { - // Override with call to |Free(void*)| for compatibility - // with legacy version. - Free(data); - } - - /** - * Deprecated. Never called directly by V8. - * For compatibility with legacy version of this interface. - */ - virtual void Free(void* data); + virtual void Free(void* data, size_t length) = 0; }; /** @@ -2541,7 +2591,7 @@ class V8_EXPORT ArrayBuffer : public Object { */ Contents Externalize(); - V8_INLINE(static ArrayBuffer* Cast(Value* obj)); + V8_INLINE static ArrayBuffer* Cast(Value* obj); static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT; @@ -2582,7 +2632,7 @@ class V8_EXPORT ArrayBufferView : public Object { */ void* BaseAddress(); - V8_INLINE(static ArrayBufferView* Cast(Value* obj)); + V8_INLINE static ArrayBufferView* Cast(Value* obj); static const int kInternalFieldCount = V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT; @@ -2606,7 +2656,7 @@ class V8_EXPORT TypedArray : public ArrayBufferView { */ size_t Length(); - V8_INLINE(static TypedArray* Cast(Value* obj)); + V8_INLINE static TypedArray* Cast(Value* obj); private: TypedArray(); @@ -2622,7 +2672,7 @@ class V8_EXPORT Uint8Array : public TypedArray { public: static Local New(Handle array_buffer, size_t byte_offset, size_t length); - V8_INLINE(static Uint8Array* Cast(Value* obj)); + V8_INLINE static Uint8Array* Cast(Value* obj); private: Uint8Array(); @@ -2638,7 +2688,7 @@ class V8_EXPORT Uint8ClampedArray : public TypedArray { public: static Local New(Handle array_buffer, size_t byte_offset, size_t length); - V8_INLINE(static Uint8ClampedArray* Cast(Value* obj)); + V8_INLINE static Uint8ClampedArray* Cast(Value* obj); private: Uint8ClampedArray(); @@ -2653,7 +2703,7 @@ class V8_EXPORT Int8Array : public TypedArray { public: static Local New(Handle array_buffer, size_t byte_offset, size_t length); - V8_INLINE(static Int8Array* Cast(Value* obj)); + V8_INLINE static Int8Array* Cast(Value* obj); private: Int8Array(); @@ -2669,7 +2719,7 @@ class V8_EXPORT Uint16Array : public TypedArray { public: static Local New(Handle array_buffer, size_t byte_offset, size_t length); - V8_INLINE(static Uint16Array* Cast(Value* obj)); + V8_INLINE static Uint16Array* Cast(Value* obj); private: Uint16Array(); @@ -2685,7 +2735,7 @@ class V8_EXPORT Int16Array : public TypedArray { public: static Local New(Handle array_buffer, size_t byte_offset, size_t length); - V8_INLINE(static Int16Array* Cast(Value* obj)); + V8_INLINE static Int16Array* Cast(Value* obj); private: Int16Array(); @@ -2701,7 +2751,7 @@ class V8_EXPORT Uint32Array : public TypedArray { public: static Local New(Handle array_buffer, size_t byte_offset, size_t length); - V8_INLINE(static Uint32Array* Cast(Value* obj)); + V8_INLINE static Uint32Array* Cast(Value* obj); private: Uint32Array(); @@ -2717,7 +2767,7 @@ class V8_EXPORT Int32Array : public TypedArray { public: static Local New(Handle array_buffer, size_t byte_offset, size_t length); - V8_INLINE(static Int32Array* Cast(Value* obj)); + V8_INLINE static Int32Array* Cast(Value* obj); private: Int32Array(); @@ -2733,7 +2783,7 @@ class V8_EXPORT Float32Array : public TypedArray { public: static Local New(Handle array_buffer, size_t byte_offset, size_t length); - V8_INLINE(static Float32Array* Cast(Value* obj)); + V8_INLINE static Float32Array* Cast(Value* obj); private: Float32Array(); @@ -2749,7 +2799,7 @@ class V8_EXPORT Float64Array : public TypedArray { public: static Local New(Handle array_buffer, size_t byte_offset, size_t length); - V8_INLINE(static Float64Array* Cast(Value* obj)); + V8_INLINE static Float64Array* Cast(Value* obj); private: Float64Array(); @@ -2765,7 +2815,7 @@ class V8_EXPORT DataView : public ArrayBufferView { public: static Local New(Handle array_buffer, size_t byte_offset, size_t length); - V8_INLINE(static DataView* Cast(Value* obj)); + V8_INLINE static DataView* Cast(Value* obj); private: DataView(); @@ -2790,7 +2840,7 @@ class V8_EXPORT Date : public Object { */ double ValueOf() const; - V8_INLINE(static Date* Cast(v8::Value* obj)); + V8_INLINE static Date* Cast(v8::Value* obj); /** * Notification that the embedder has changed the time zone, @@ -2827,7 +2877,7 @@ class V8_EXPORT NumberObject : public Object { */ double ValueOf() const; - V8_INLINE(static NumberObject* Cast(v8::Value* obj)); + V8_INLINE static NumberObject* Cast(v8::Value* obj); private: static void CheckCast(v8::Value* obj); @@ -2850,7 +2900,7 @@ class V8_EXPORT BooleanObject : public Object { */ bool ValueOf() const; - V8_INLINE(static BooleanObject* Cast(v8::Value* obj)); + V8_INLINE static BooleanObject* Cast(v8::Value* obj); private: static void CheckCast(v8::Value* obj); @@ -2873,7 +2923,7 @@ class V8_EXPORT StringObject : public Object { */ Local ValueOf() const; - V8_INLINE(static StringObject* Cast(v8::Value* obj)); + V8_INLINE static StringObject* Cast(v8::Value* obj); private: static void CheckCast(v8::Value* obj); @@ -2898,7 +2948,7 @@ class V8_EXPORT SymbolObject : public Object { */ Local ValueOf() const; - V8_INLINE(static SymbolObject* Cast(v8::Value* obj)); + V8_INLINE static SymbolObject* Cast(v8::Value* obj); private: static void CheckCast(v8::Value* obj); @@ -2944,7 +2994,7 @@ class V8_EXPORT RegExp : public Object { */ Flags GetFlags() const; - V8_INLINE(static RegExp* Cast(v8::Value* obj)); + V8_INLINE static RegExp* Cast(v8::Value* obj); private: static void CheckCast(v8::Value* obj); @@ -2958,7 +3008,7 @@ class V8_EXPORT RegExp : public Object { class V8_EXPORT External : public Value { public: static Local New(void* value); - V8_INLINE(static External* Cast(Value* obj)); + V8_INLINE static External* Cast(Value* obj); void* Value() const; private: static void CheckCast(v8::Value* obj); @@ -2976,147 +3026,72 @@ class V8_EXPORT Template : public Data { /** Adds a property to each instance created by this template.*/ void Set(Handle name, Handle value, PropertyAttribute attributes = None); - V8_INLINE(void Set(const char* name, Handle value)); - private: - Template(); + V8_INLINE void Set(const char* name, Handle value); - friend class ObjectTemplate; - friend class FunctionTemplate; -}; - - -template -class ReturnValue { - public: - template V8_INLINE(ReturnValue(const ReturnValue& that)) - : value_(that.value_) { - TYPE_CHECK(T, S); - } - // Handle setters - template V8_INLINE(void Set(const Persistent& handle)); - template V8_INLINE(void Set(const Handle handle)); - // Fast primitive setters - V8_INLINE(void Set(bool value)); - V8_INLINE(void Set(double i)); - V8_INLINE(void Set(int32_t i)); - V8_INLINE(void Set(uint32_t i)); - // Fast JS primitive setters - V8_INLINE(void SetNull()); - V8_INLINE(void SetUndefined()); - V8_INLINE(void SetEmptyString()); - // Convenience getter for Isolate - V8_INLINE(Isolate* GetIsolate()); - - private: - template friend class ReturnValue; - template friend class FunctionCallbackInfo; - template friend class PropertyCallbackInfo; - V8_INLINE(internal::Object* GetDefaultValue()); - V8_INLINE(explicit ReturnValue(internal::Object** slot)); - internal::Object** value_; -}; - - -/** - * The argument information given to function call callbacks. This - * class provides access to information about the context of the call, - * including the receiver, the number and values of arguments, and - * the holder of the function. - */ -template -class FunctionCallbackInfo { - public: - V8_INLINE(int Length() const); - V8_INLINE(Local operator[](int i) const); - V8_INLINE(Local Callee() const); - V8_INLINE(Local This() const); - V8_INLINE(Local Holder() const); - V8_INLINE(bool IsConstructCall() const); - V8_INLINE(Local Data() const); - V8_INLINE(Isolate* GetIsolate() const); - V8_INLINE(ReturnValue GetReturnValue() const); - // This shouldn't be public, but the arm compiler needs it. - static const int kArgsLength = 6; - - protected: - friend class internal::FunctionCallbackArguments; - friend class internal::CustomArguments; - static const int kReturnValueIndex = 0; - static const int kReturnValueDefaultValueIndex = -1; - static const int kIsolateIndex = -2; - static const int kDataIndex = -3; - static const int kCalleeIndex = -4; - static const int kHolderIndex = -5; + void SetAccessorProperty( + Local name, + Local getter = Local(), + Local setter = Local(), + PropertyAttribute attribute = None, + AccessControl settings = DEFAULT); - V8_INLINE(FunctionCallbackInfo(internal::Object** implicit_args, - internal::Object** values, - int length, - bool is_construct_call)); - internal::Object** implicit_args_; - internal::Object** values_; - int length_; - bool is_construct_call_; -}; + /** + * Whenever the property with the given name is accessed on objects + * created from this Template the getter and setter callbacks + * are called instead of getting and setting the property directly + * on the JavaScript object. + * + * \param name The name of the property for which an accessor is added. + * \param getter The callback to invoke when getting the property. + * \param setter The callback to invoke when setting the property. + * \param data A piece of data that will be passed to the getter and setter + * callbacks whenever they are invoked. + * \param settings Access control settings for the accessor. This is a bit + * field consisting of one of more of + * DEFAULT = 0, ALL_CAN_READ = 1, or ALL_CAN_WRITE = 2. + * The default is to not allow cross-context access. + * ALL_CAN_READ means that all cross-context reads are allowed. + * ALL_CAN_WRITE means that all cross-context writes are allowed. + * The combination ALL_CAN_READ | ALL_CAN_WRITE can be used to allow all + * cross-context access. + * \param attribute The attributes of the property for which an accessor + * is added. + * \param signature The signature describes valid receivers for the accessor + * and is used to perform implicit instance checks against them. If the + * receiver is incompatible (i.e. is not an instance of the constructor as + * defined by FunctionTemplate::HasInstance()), an implicit TypeError is + * thrown and no callback is invoked. + */ + void SetNativeDataProperty(Local name, + AccessorGetterCallback getter, + AccessorSetterCallback setter = 0, + // TODO(dcarney): gcc can't handle Local below + Handle data = Handle(), + PropertyAttribute attribute = None, + Local signature = + Local(), + AccessControl settings = DEFAULT); + // This function is not yet stable and should not be used at this time. + bool SetDeclaredAccessor(Local name, + Local descriptor, + PropertyAttribute attribute = None, + Local signature = + Local(), + AccessControl settings = DEFAULT); -class V8_EXPORT Arguments : public FunctionCallbackInfo { private: - friend class internal::FunctionCallbackArguments; - V8_INLINE(Arguments(internal::Object** implicit_args, - internal::Object** values, - int length, - bool is_construct_call)); -}; - -/** - * The information passed to a property callback about the context - * of the property access. - */ -template -class PropertyCallbackInfo { - public: - V8_INLINE(Isolate* GetIsolate() const); - V8_INLINE(Local Data() const); - V8_INLINE(Local This() const); - V8_INLINE(Local Holder() const); - V8_INLINE(ReturnValue GetReturnValue() const); - // This shouldn't be public, but the arm compiler needs it. - static const int kArgsLength = 6; - - protected: - friend class MacroAssembler; - friend class internal::PropertyCallbackArguments; - friend class internal::CustomArguments; - static const int kThisIndex = 0; - static const int kHolderIndex = -1; - static const int kDataIndex = -2; - static const int kReturnValueIndex = -3; - static const int kReturnValueDefaultValueIndex = -4; - static const int kIsolateIndex = -5; - - V8_INLINE(PropertyCallbackInfo(internal::Object** args)) - : args_(args) { } - internal::Object** args_; -}; - + Template(); -class V8_EXPORT AccessorInfo : public PropertyCallbackInfo { - private: - friend class internal::PropertyCallbackArguments; - V8_INLINE(AccessorInfo(internal::Object** args)) - : PropertyCallbackInfo(args) { } + friend class ObjectTemplate; + friend class FunctionTemplate; }; -typedef Handle (*InvocationCallback)(const Arguments& args); -typedef void (*FunctionCallback)(const FunctionCallbackInfo& info); - /** * NamedProperty[Getter|Setter] are used as interceptors on object. * See ObjectTemplate::SetNamedPropertyHandler. */ -typedef Handle (*NamedPropertyGetter)(Local property, - const AccessorInfo& info); typedef void (*NamedPropertyGetterCallback)( Local property, const PropertyCallbackInfo& info); @@ -3126,9 +3101,6 @@ typedef void (*NamedPropertyGetterCallback)( * Returns the value if the setter intercepts the request. * Otherwise, returns an empty handle. */ -typedef Handle (*NamedPropertySetter)(Local property, - Local value, - const AccessorInfo& info); typedef void (*NamedPropertySetterCallback)( Local property, Local value, @@ -3140,8 +3112,6 @@ typedef void (*NamedPropertySetterCallback)( * The result is an integer encoding property attributes (like v8::None, * v8::DontEnum, etc.) */ -typedef Handle (*NamedPropertyQuery)(Local property, - const AccessorInfo& info); typedef void (*NamedPropertyQueryCallback)( Local property, const PropertyCallbackInfo& info); @@ -3152,8 +3122,6 @@ typedef void (*NamedPropertyQueryCallback)( * The return value is true if the property could be deleted and false * otherwise. */ -typedef Handle (*NamedPropertyDeleter)(Local property, - const AccessorInfo& info); typedef void (*NamedPropertyDeleterCallback)( Local property, const PropertyCallbackInfo& info); @@ -3163,7 +3131,6 @@ typedef void (*NamedPropertyDeleterCallback)( * Returns an array containing the names of the properties the named * property getter intercepts. */ -typedef Handle (*NamedPropertyEnumerator)(const AccessorInfo& info); typedef void (*NamedPropertyEnumeratorCallback)( const PropertyCallbackInfo& info); @@ -3172,8 +3139,6 @@ typedef void (*NamedPropertyEnumeratorCallback)( * Returns the value of the property if the getter intercepts the * request. Otherwise, returns an empty handle. */ -typedef Handle (*IndexedPropertyGetter)(uint32_t index, - const AccessorInfo& info); typedef void (*IndexedPropertyGetterCallback)( uint32_t index, const PropertyCallbackInfo& info); @@ -3183,9 +3148,6 @@ typedef void (*IndexedPropertyGetterCallback)( * Returns the value if the setter intercepts the request. * Otherwise, returns an empty handle. */ -typedef Handle (*IndexedPropertySetter)(uint32_t index, - Local value, - const AccessorInfo& info); typedef void (*IndexedPropertySetterCallback)( uint32_t index, Local value, @@ -3196,8 +3158,6 @@ typedef void (*IndexedPropertySetterCallback)( * Returns a non-empty handle if the interceptor intercepts the request. * The result is an integer encoding property attributes. */ -typedef Handle (*IndexedPropertyQuery)(uint32_t index, - const AccessorInfo& info); typedef void (*IndexedPropertyQueryCallback)( uint32_t index, const PropertyCallbackInfo& info); @@ -3208,8 +3168,6 @@ typedef void (*IndexedPropertyQueryCallback)( * The return value is true if the property could be deleted and false * otherwise. */ -typedef Handle (*IndexedPropertyDeleter)(uint32_t index, - const AccessorInfo& info); typedef void (*IndexedPropertyDeleterCallback)( uint32_t index, const PropertyCallbackInfo& info); @@ -3219,7 +3177,6 @@ typedef void (*IndexedPropertyDeleterCallback)( * Returns an array containing the indices of the properties the * indexed property getter intercepts. */ -typedef Handle (*IndexedPropertyEnumerator)(const AccessorInfo& info); typedef void (*IndexedPropertyEnumeratorCallback)( const PropertyCallbackInfo& info); @@ -3351,11 +3308,6 @@ typedef bool (*IndexedSecurityCallback)(Local host, class V8_EXPORT FunctionTemplate : public Template { public: /** Creates a function template.*/ - V8_DEPRECATED(static Local New( - InvocationCallback callback, - Handle data = Handle(), - Handle signature = Handle(), - int length = 0)); static Local New( FunctionCallback callback = 0, Handle data = Handle(), @@ -3370,8 +3322,6 @@ class V8_EXPORT FunctionTemplate : public Template { * callback is called whenever the function created from this * FunctionTemplate is called. */ - V8_DEPRECATED(void SetCallHandler(InvocationCallback callback, - Handle data = Handle())); void SetCallHandler(FunctionCallback callback, Handle data = Handle()); @@ -3417,6 +3367,12 @@ class V8_EXPORT FunctionTemplate : public Template { */ void ReadOnlyPrototype(); + /** + * Removes the prototype property from functions created from this + * FunctionTemplate. + */ + void RemovePrototype(); + /** * Returns true if the given object is an instance of this function * template. @@ -3425,9 +3381,6 @@ class V8_EXPORT FunctionTemplate : public Template { private: FunctionTemplate(); - // TODO(dcarney): Remove with SetCallHandler. - friend class v8::CallHandlerHelper; - void SetCallHandlerInternal(InvocationCallback callback, Handle data); friend class Context; friend class ObjectTemplate; }; @@ -3476,14 +3429,6 @@ class V8_EXPORT ObjectTemplate : public Template { * defined by FunctionTemplate::HasInstance()), an implicit TypeError is * thrown and no callback is invoked. */ - V8_DEPRECATED(void SetAccessor(Handle name, - AccessorGetter getter, - AccessorSetter setter = 0, - Handle data = Handle(), - AccessControl settings = DEFAULT, - PropertyAttribute attribute = None, - Handle signature = - Handle())); void SetAccessor(Handle name, AccessorGetterCallback getter, AccessorSetterCallback setter = 0, @@ -3493,14 +3438,6 @@ class V8_EXPORT ObjectTemplate : public Template { Handle signature = Handle()); - // This function is not yet stable and should not be used at this time. - bool SetAccessor(Handle name, - Handle descriptor, - AccessControl settings = DEFAULT, - PropertyAttribute attribute = None, - Handle signature = - Handle()); - /** * Sets a named property handler on the object template. * @@ -3518,13 +3455,6 @@ class V8_EXPORT ObjectTemplate : public Template { * \param data A piece of data that will be passed to the callbacks * whenever they are invoked. */ - V8_DEPRECATED(void SetNamedPropertyHandler( - NamedPropertyGetter getter, - NamedPropertySetter setter = 0, - NamedPropertyQuery query = 0, - NamedPropertyDeleter deleter = 0, - NamedPropertyEnumerator enumerator = 0, - Handle data = Handle())); void SetNamedPropertyHandler( NamedPropertyGetterCallback getter, NamedPropertySetterCallback setter = 0, @@ -3549,13 +3479,6 @@ class V8_EXPORT ObjectTemplate : public Template { * \param data A piece of data that will be passed to the callbacks * whenever they are invoked. */ - V8_DEPRECATED(void SetIndexedPropertyHandler( - IndexedPropertyGetter getter, - IndexedPropertySetter setter = 0, - IndexedPropertyQuery query = 0, - IndexedPropertyDeleter deleter = 0, - IndexedPropertyEnumerator enumerator = 0, - Handle data = Handle())); void SetIndexedPropertyHandler( IndexedPropertyGetterCallback getter, IndexedPropertySetterCallback setter = 0, @@ -3570,9 +3493,6 @@ class V8_EXPORT ObjectTemplate : public Template { * behave like normal JavaScript objects that cannot be called as a * function. */ - V8_DEPRECATED(void SetCallAsFunctionHandler( - InvocationCallback callback, - Handle data = Handle())); void SetCallAsFunctionHandler(FunctionCallback callback, Handle data = Handle()); @@ -3783,7 +3703,7 @@ void V8_EXPORT RegisterExtension(Extension* extension); */ class V8_EXPORT DeclareExtension { public: - V8_INLINE(DeclareExtension(Extension* extension)) { + V8_INLINE DeclareExtension(Extension* extension) { RegisterExtension(extension); } }; @@ -3797,10 +3717,10 @@ Handle V8_EXPORT Null(); Handle V8_EXPORT True(); Handle V8_EXPORT False(); -V8_INLINE(Handle Undefined(Isolate* isolate)); -V8_INLINE(Handle Null(Isolate* isolate)); -V8_INLINE(Handle True(Isolate* isolate)); -V8_INLINE(Handle False(Isolate* isolate)); +V8_INLINE Handle Undefined(Isolate* isolate); +V8_INLINE Handle Null(Isolate* isolate); +V8_INLINE Handle True(Isolate* isolate); +V8_INLINE Handle False(Isolate* isolate); /** @@ -3824,11 +3744,20 @@ class V8_EXPORT ResourceConstraints { uint32_t* stack_limit() const { return stack_limit_; } // Sets an address beyond which the VM's stack may not grow. void set_stack_limit(uint32_t* value) { stack_limit_ = value; } + Maybe is_memory_constrained() const { return is_memory_constrained_; } + // If set to true, V8 will limit it's memory usage, at the potential cost of + // lower performance. Note, this option is a tentative addition to the API + // and may be removed or modified without warning. + void set_memory_constrained(bool value) { + is_memory_constrained_ = Maybe(value); + } + private: int max_young_space_size_; int max_old_space_size_; int max_executable_size_; uint32_t* stack_limit_; + Maybe is_memory_constrained_; }; @@ -4049,13 +3978,13 @@ class V8_EXPORT Isolate { /** * Associate embedder-specific data with the isolate */ - V8_INLINE(void SetData(void* data)); + V8_INLINE void SetData(void* data); /** * Retrieve embedder-specific data from the isolate. * Returns NULL if SetData has never been called. */ - V8_INLINE(void* GetData()); + V8_INLINE void* GetData(); /** * Get statistics about the heap memory usage. @@ -4327,7 +4256,7 @@ class V8_EXPORT PersistentHandleVisitor { // NOLINT class V8_EXPORT AssertNoGCScope { #ifndef DEBUG // TODO(yangguo): remove isolate argument. - V8_INLINE(AssertNoGCScope(Isolate* isolate)) { } + V8_INLINE AssertNoGCScope(Isolate* isolate) {} #else AssertNoGCScope(Isolate* isolate); ~AssertNoGCScope(); @@ -4617,62 +4546,6 @@ class V8_EXPORT V8 { static intptr_t AdjustAmountOfExternalAllocatedMemory( intptr_t change_in_bytes); - /** - * Suspends recording of tick samples in the profiler. - * When the V8 profiling mode is enabled (usually via command line - * switches) this function suspends recording of tick samples. - * Profiling ticks are discarded until ResumeProfiler() is called. - * - * See also the --prof and --prof_auto command line switches to - * enable V8 profiling. - */ - V8_DEPRECATED(static void PauseProfiler()); - - /** - * Resumes recording of tick samples in the profiler. - * See also PauseProfiler(). - */ - V8_DEPRECATED(static void ResumeProfiler()); - - /** - * Return whether profiler is currently paused. - */ - V8_DEPRECATED(static bool IsProfilerPaused()); - - /** - * Retrieve the V8 thread id of the calling thread. - * - * The thread id for a thread should only be retrieved after the V8 - * lock has been acquired with a Locker object with that thread. - */ - static int GetCurrentThreadId(); - - /** - * Forcefully terminate execution of a JavaScript thread. This can - * be used to terminate long-running scripts. - * - * TerminateExecution should only be called when then V8 lock has - * been acquired with a Locker object. Therefore, in order to be - * able to terminate long-running threads, preemption must be - * enabled to allow the user of TerminateExecution to acquire the - * lock. - * - * The termination is achieved by throwing an exception that is - * uncatchable by JavaScript exception handlers. Termination - * exceptions act as if they were caught by a C++ TryCatch exception - * handler. If forceful termination is used, any C++ TryCatch - * exception handler that catches an exception should check if that - * exception is a termination exception and immediately return if - * that is the case. Returning immediately in that case will - * continue the propagation of the termination exception if needed. - * - * The thread id passed to TerminateExecution must have been - * obtained by calling GetCurrentThreadId on the thread in question. - * - * \param thread_id The thread id of the thread to terminate. - */ - static void TerminateExecution(int thread_id); - /** * Forcefully terminate the current thread of JavaScript execution * in the given isolate. If no isolate is provided, the default @@ -4791,19 +4664,24 @@ class V8_EXPORT V8 { static internal::Object** GlobalizeReference(internal::Isolate* isolate, internal::Object** handle); + static internal::Object** CopyPersistent(internal::Object** handle); static void DisposeGlobal(internal::Object** global_handle); typedef WeakReferenceCallbacks::Revivable RevivableCallback; + typedef WeakCallbackData::Callback WeakCallback; static void MakeWeak(internal::Object** global_handle, void* data, + WeakCallback weak_callback, RevivableCallback weak_reference_callback); static void ClearWeak(internal::Object** global_handle); - static int Eternalize(internal::Isolate* isolate, - internal::Object** handle); - static internal::Object** GetEternal(internal::Isolate* isolate, int index); + static void Eternalize(Isolate* isolate, + Value* handle, + int* index); + static Local GetEternal(Isolate* isolate, int index); template friend class Handle; template friend class Local; - template friend class Persistent; + template friend class Eternal; + template friend class Persistent; friend class Context; }; @@ -5081,7 +4959,7 @@ class V8_EXPORT Context { * previous call to SetEmbedderData with the same index. Note that index 0 * currently has a special meaning for Chrome's debugger. */ - V8_INLINE(Local GetEmbedderData(int index)); + V8_INLINE Local GetEmbedderData(int index); /** * Sets the embedder data with the given index, growing the data as @@ -5096,7 +4974,7 @@ class V8_EXPORT Context { * SetAlignedPointerInEmbedderData with the same index. Note that index 0 * currently has a special meaning for Chrome's debugger. */ - V8_INLINE(void* GetAlignedPointerFromEmbedderData(int index)); + V8_INLINE void* GetAlignedPointerFromEmbedderData(int index); /** * Sets a 2-byte-aligned native pointer in the embedder data with the given @@ -5139,19 +5017,15 @@ class V8_EXPORT Context { */ class Scope { public: - explicit V8_INLINE(Scope(Handle context)) : context_(context) { + explicit V8_INLINE Scope(Handle context) : context_(context) { context_->Enter(); } // TODO(dcarney): deprecate - V8_INLINE(Scope(Isolate* isolate, Persistent& context)) // NOLINT -#ifndef V8_USE_UNSAFE_HANDLES + V8_INLINE Scope(Isolate* isolate, Persistent& context) // NOLINT : context_(Handle::New(isolate, context)) { -#else - : context_(Local::New(isolate, context)) { -#endif context_->Enter(); } - V8_INLINE(~Scope()) { context_->Exit(); } + V8_INLINE ~Scope() { context_->Exit(); } private: Handle context_; @@ -5249,7 +5123,7 @@ class V8_EXPORT Unlocker { /** * Initialize Unlocker for a given Isolate. */ - V8_INLINE(explicit Unlocker(Isolate* isolate)) { Initialize(isolate); } + V8_INLINE explicit Unlocker(Isolate* isolate) { Initialize(isolate); } /** Deprecated. Use Isolate version instead. */ V8_DEPRECATED(Unlocker()); @@ -5267,7 +5141,7 @@ class V8_EXPORT Locker { /** * Initialize Locker for a given Isolate. */ - V8_INLINE(explicit Locker(Isolate* isolate)) { Initialize(isolate); } + V8_INLINE explicit Locker(Isolate* isolate) { Initialize(isolate); } /** Deprecated. Use Isolate version instead. */ V8_DEPRECATED(Locker()); @@ -5396,7 +5270,7 @@ const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1; template struct SmiTagging; template -V8_INLINE(internal::Object* IntToSmi(int value)) { +V8_INLINE internal::Object* IntToSmi(int value) { int smi_shift_bits = kSmiTagSize + kSmiShiftSize; intptr_t tagged_value = (static_cast(value) << smi_shift_bits) | kSmiTag; @@ -5407,15 +5281,15 @@ V8_INLINE(internal::Object* IntToSmi(int value)) { template <> struct SmiTagging<4> { static const int kSmiShiftSize = 0; static const int kSmiValueSize = 31; - V8_INLINE(static int SmiToInt(internal::Object* value)) { + V8_INLINE static int SmiToInt(internal::Object* value) { int shift_bits = kSmiTagSize + kSmiShiftSize; // Throw away top 32 bits and shift down (requires >> to be sign extending). return static_cast(reinterpret_cast(value)) >> shift_bits; } - V8_INLINE(static internal::Object* IntToSmi(int value)) { + V8_INLINE static internal::Object* IntToSmi(int value) { return internal::IntToSmi(value); } - V8_INLINE(static bool IsValidSmi(intptr_t value)) { + V8_INLINE static bool IsValidSmi(intptr_t value) { // To be representable as an tagged small integer, the two // most-significant bits of 'value' must be either 00 or 11 due to // sign-extension. To check this we add 01 to the two @@ -5435,15 +5309,15 @@ template <> struct SmiTagging<4> { template <> struct SmiTagging<8> { static const int kSmiShiftSize = 31; static const int kSmiValueSize = 32; - V8_INLINE(static int SmiToInt(internal::Object* value)) { + V8_INLINE static int SmiToInt(internal::Object* value) { int shift_bits = kSmiTagSize + kSmiShiftSize; // Shift down and throw away top 32 bits. return static_cast(reinterpret_cast(value) >> shift_bits); } - V8_INLINE(static internal::Object* IntToSmi(int value)) { + V8_INLINE static internal::Object* IntToSmi(int value) { return internal::IntToSmi(value); } - V8_INLINE(static bool IsValidSmi(intptr_t value)) { + V8_INLINE static bool IsValidSmi(intptr_t value) { // To be representable as a long smi, the value must be a 32-bit integer. return (value == static_cast(value)); } @@ -5452,6 +5326,8 @@ template <> struct SmiTagging<8> { typedef SmiTagging PlatformSmiTagging; const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize; const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize; +V8_INLINE static bool SmiValuesAre31Bits() { return kSmiValueSize == 31; } +V8_INLINE static bool SmiValuesAre32Bits() { return kSmiValueSize == 32; } /** * This class exports constants and functionality from within v8 that @@ -5483,7 +5359,7 @@ class Internals { static const int kNullValueRootIndex = 7; static const int kTrueValueRootIndex = 8; static const int kFalseValueRootIndex = 9; - static const int kEmptyStringRootIndex = 133; + static const int kEmptyStringRootIndex = 131; static const int kNodeClassIdOffset = 1 * kApiPointerSize; static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3; @@ -5503,94 +5379,93 @@ class Internals { static const int kNullOddballKind = 3; static void CheckInitializedImpl(v8::Isolate* isolate); - V8_INLINE(static void CheckInitialized(v8::Isolate* isolate)) { + V8_INLINE static void CheckInitialized(v8::Isolate* isolate) { #ifdef V8_ENABLE_CHECKS CheckInitializedImpl(isolate); #endif } - V8_INLINE(static bool HasHeapObjectTag(internal::Object* value)) { + V8_INLINE static bool HasHeapObjectTag(internal::Object* value) { return ((reinterpret_cast(value) & kHeapObjectTagMask) == kHeapObjectTag); } - V8_INLINE(static int SmiValue(internal::Object* value)) { + V8_INLINE static int SmiValue(internal::Object* value) { return PlatformSmiTagging::SmiToInt(value); } - V8_INLINE(static internal::Object* IntToSmi(int value)) { + V8_INLINE static internal::Object* IntToSmi(int value) { return PlatformSmiTagging::IntToSmi(value); } - V8_INLINE(static bool IsValidSmi(intptr_t value)) { + V8_INLINE static bool IsValidSmi(intptr_t value) { return PlatformSmiTagging::IsValidSmi(value); } - V8_INLINE(static int GetInstanceType(internal::Object* obj)) { + V8_INLINE static int GetInstanceType(internal::Object* obj) { typedef internal::Object O; O* map = ReadField(obj, kHeapObjectMapOffset); return ReadField(map, kMapInstanceTypeOffset); } - V8_INLINE(static int GetOddballKind(internal::Object* obj)) { + V8_INLINE static int GetOddballKind(internal::Object* obj) { typedef internal::Object O; return SmiValue(ReadField(obj, kOddballKindOffset)); } - V8_INLINE(static bool IsExternalTwoByteString(int instance_type)) { + V8_INLINE static bool IsExternalTwoByteString(int instance_type) { int representation = (instance_type & kFullStringRepresentationMask); return representation == kExternalTwoByteRepresentationTag; } - V8_INLINE(static uint8_t GetNodeFlag(internal::Object** obj, int shift)) { + V8_INLINE static uint8_t GetNodeFlag(internal::Object** obj, int shift) { uint8_t* addr = reinterpret_cast(obj) + kNodeFlagsOffset; return *addr & static_cast(1U << shift); } - V8_INLINE(static void UpdateNodeFlag(internal::Object** obj, - bool value, int shift)) { + V8_INLINE static void UpdateNodeFlag(internal::Object** obj, + bool value, int shift) { uint8_t* addr = reinterpret_cast(obj) + kNodeFlagsOffset; uint8_t mask = static_cast(1 << shift); *addr = static_cast((*addr & ~mask) | (value << shift)); } - V8_INLINE(static uint8_t GetNodeState(internal::Object** obj)) { + V8_INLINE static uint8_t GetNodeState(internal::Object** obj) { uint8_t* addr = reinterpret_cast(obj) + kNodeFlagsOffset; return *addr & kNodeStateMask; } - V8_INLINE(static void UpdateNodeState(internal::Object** obj, - uint8_t value)) { + V8_INLINE static void UpdateNodeState(internal::Object** obj, + uint8_t value) { uint8_t* addr = reinterpret_cast(obj) + kNodeFlagsOffset; *addr = static_cast((*addr & ~kNodeStateMask) | value); } - V8_INLINE(static void SetEmbedderData(v8::Isolate* isolate, void* data)) { + V8_INLINE static void SetEmbedderData(v8::Isolate* isolate, void* data) { uint8_t* addr = reinterpret_cast(isolate) + kIsolateEmbedderDataOffset; *reinterpret_cast(addr) = data; } - V8_INLINE(static void* GetEmbedderData(v8::Isolate* isolate)) { + V8_INLINE static void* GetEmbedderData(v8::Isolate* isolate) { uint8_t* addr = reinterpret_cast(isolate) + kIsolateEmbedderDataOffset; return *reinterpret_cast(addr); } - V8_INLINE(static internal::Object** GetRoot(v8::Isolate* isolate, - int index)) { + V8_INLINE static internal::Object** GetRoot(v8::Isolate* isolate, + int index) { uint8_t* addr = reinterpret_cast(isolate) + kIsolateRootsOffset; return reinterpret_cast(addr + index * kApiPointerSize); } - template - V8_INLINE(static T ReadField(Object* ptr, int offset)) { + template V8_INLINE static T ReadField(Object* ptr, int offset) { uint8_t* addr = reinterpret_cast(ptr) + offset - kHeapObjectTag; return *reinterpret_cast(addr); } template - V8_INLINE(static T ReadEmbedderData(Context* context, int index)) { + V8_INLINE static T ReadEmbedderData(Context* context, int index) { typedef internal::Object O; typedef internal::Internals I; O* ctx = *reinterpret_cast(context); @@ -5602,13 +5477,13 @@ class Internals { return I::ReadField(embedder_data, value_offset); } - V8_INLINE(static bool CanCastToHeapObject(void* o)) { return false; } - V8_INLINE(static bool CanCastToHeapObject(Context* o)) { return true; } - V8_INLINE(static bool CanCastToHeapObject(String* o)) { return true; } - V8_INLINE(static bool CanCastToHeapObject(Object* o)) { return true; } - V8_INLINE(static bool CanCastToHeapObject(Message* o)) { return true; } - V8_INLINE(static bool CanCastToHeapObject(StackTrace* o)) { return true; } - V8_INLINE(static bool CanCastToHeapObject(StackFrame* o)) { return true; } + V8_INLINE static bool CanCastToHeapObject(void* o) { return false; } + V8_INLINE static bool CanCastToHeapObject(Context* o) { return true; } + V8_INLINE static bool CanCastToHeapObject(String* o) { return true; } + V8_INLINE static bool CanCastToHeapObject(Object* o) { return true; } + V8_INLINE static bool CanCastToHeapObject(Message* o) { return true; } + V8_INLINE static bool CanCastToHeapObject(StackTrace* o) { return true; } + V8_INLINE static bool CanCastToHeapObject(StackFrame* o) { return true; } }; } // namespace internal @@ -5636,9 +5511,9 @@ Local Local::New(Isolate* isolate, Handle that) { return New(isolate, that.val_); } -#ifndef V8_USE_UNSAFE_HANDLES template -Local Local::New(Isolate* isolate, const Persistent& that) { +template +Local Local::New(Isolate* isolate, const Persistent& that) { return New(isolate, that.val_); } @@ -5650,7 +5525,6 @@ Handle Handle::New(Isolate* isolate, T* that) { return Handle(reinterpret_cast(HandleScope::CreateHandle( reinterpret_cast(isolate), *p))); } -#endif template @@ -5664,41 +5538,21 @@ Local Local::New(Isolate* isolate, T* that) { template -int Local::Eternalize(Isolate* isolate) { - return V8::Eternalize(reinterpret_cast(isolate), - reinterpret_cast(this->val_)); +template +void Eternal::Set(Isolate* isolate, Local handle) { + TYPE_CHECK(T, S); + V8::Eternalize(isolate, reinterpret_cast(*handle), &this->index_); } template -Local Local::GetEternal(Isolate* isolate, int index) { - internal::Object** handle = - V8::GetEternal(reinterpret_cast(isolate), index); - return Local(T::Cast(reinterpret_cast(handle))); -} - - -#ifdef V8_USE_UNSAFE_HANDLES -template -Persistent Persistent::New(Handle that) { - return New(Isolate::GetCurrent(), that.val_); +Local Eternal::Get(Isolate* isolate) { + return Local(reinterpret_cast(*V8::GetEternal(isolate, index_))); } -template -Persistent Persistent::New(Isolate* isolate, Handle that) { - return New(Isolate::GetCurrent(), that.val_); -} - -template -Persistent Persistent::New(Isolate* isolate, Persistent that) { - return New(Isolate::GetCurrent(), that.val_); -} -#endif - - -template -T* Persistent::New(Isolate* isolate, T* that) { +template +T* Persistent::New(Isolate* isolate, T* that) { if (that == NULL) return NULL; internal::Object** p = reinterpret_cast(that); return reinterpret_cast( @@ -5707,8 +5561,20 @@ T* Persistent::New(Isolate* isolate, T* that) { } -template -bool Persistent::IsIndependent() const { +template +template +void Persistent::Copy(const Persistent& that) { + TYPE_CHECK(T, S); + Reset(); + if (that.IsEmpty()) return; + internal::Object** p = reinterpret_cast(that.val_); + this->val_ = reinterpret_cast(V8::CopyPersistent(p)); + M::Copy(that, this); +} + + +template +bool Persistent::IsIndependent() const { typedef internal::Internals I; if (this->IsEmpty()) return false; return I::GetNodeFlag(reinterpret_cast(this->val_), @@ -5716,8 +5582,8 @@ bool Persistent::IsIndependent() const { } -template -bool Persistent::IsNearDeath() const { +template +bool Persistent::IsNearDeath() const { typedef internal::Internals I; if (this->IsEmpty()) return false; uint8_t node_state = @@ -5727,8 +5593,8 @@ bool Persistent::IsNearDeath() const { } -template -bool Persistent::IsWeak() const { +template +bool Persistent::IsWeak() const { typedef internal::Internals I; if (this->IsEmpty()) return false; return I::GetNodeState(reinterpret_cast(this->val_)) == @@ -5736,66 +5602,89 @@ bool Persistent::IsWeak() const { } -template -void Persistent::Dispose() { +template +void Persistent::Reset() { if (this->IsEmpty()) return; V8::DisposeGlobal(reinterpret_cast(this->val_)); -#ifndef V8_USE_UNSAFE_HANDLES val_ = 0; -#endif } -template +template +template +void Persistent::Reset(Isolate* isolate, const Handle& other) { + TYPE_CHECK(T, S); + Reset(); + if (other.IsEmpty()) return; + this->val_ = New(isolate, other.val_); +} + + +template +template +void Persistent::Reset(Isolate* isolate, + const Persistent& other) { + TYPE_CHECK(T, S); + Reset(); + if (other.IsEmpty()) return; + this->val_ = New(isolate, other.val_); +} + + +template template -void Persistent::MakeWeak( - P* parameters, - typename WeakReferenceCallbacks::Revivable callback) { +void Persistent::SetWeak( + P* parameter, + typename WeakCallbackData::Callback callback) { TYPE_CHECK(S, T); - typedef typename WeakReferenceCallbacks::Revivable Revivable; + typedef typename WeakCallbackData::Callback Callback; V8::MakeWeak(reinterpret_cast(this->val_), - parameters, - reinterpret_cast(callback)); + parameter, + reinterpret_cast(callback), + NULL); } -template +template template -void Persistent::MakeWeak( - P* parameters, - typename WeakReferenceCallbacks::Revivable callback) { - MakeWeak(parameters, callback); +void Persistent::SetWeak( + P* parameter, + typename WeakCallbackData::Callback callback) { + SetWeak(parameter, callback); } -template +template template -void Persistent::MakeWeak( - Isolate* isolate, +void Persistent::MakeWeak( P* parameters, typename WeakReferenceCallbacks::Revivable callback) { - MakeWeak(parameters, callback); + TYPE_CHECK(S, T); + typedef typename WeakReferenceCallbacks::Revivable Revivable; + V8::MakeWeak(reinterpret_cast(this->val_), + parameters, + NULL, + reinterpret_cast(callback)); } -template -template -void Persistent::MakeWeak( - Isolate* isolate, +template +template +void Persistent::MakeWeak( P* parameters, typename WeakReferenceCallbacks::Revivable callback) { - MakeWeak

(parameters, callback); + MakeWeak(parameters, callback); } -template -void Persistent::ClearWeak() { +template +void Persistent::ClearWeak() { V8::ClearWeak(reinterpret_cast(this->val_)); } -template -void Persistent::MarkIndependent() { +template +void Persistent::MarkIndependent() { typedef internal::Internals I; if (this->IsEmpty()) return; I::UpdateNodeFlag(reinterpret_cast(this->val_), @@ -5804,8 +5693,8 @@ void Persistent::MarkIndependent() { } -template -void Persistent::MarkPartiallyDependent() { +template +void Persistent::MarkPartiallyDependent() { typedef internal::Internals I; if (this->IsEmpty()) return; I::UpdateNodeFlag(reinterpret_cast(this->val_), @@ -5814,54 +5703,17 @@ void Persistent::MarkPartiallyDependent() { } -template -void Persistent::Reset(Isolate* isolate, const Handle& other) { - Dispose(isolate); -#ifdef V8_USE_UNSAFE_HANDLES - *this = *New(isolate, other); -#else - if (other.IsEmpty()) { - this->val_ = NULL; - return; - } - internal::Object** p = reinterpret_cast(other.val_); - this->val_ = reinterpret_cast( - V8::GlobalizeReference(reinterpret_cast(isolate), p)); -#endif -} - - -#ifndef V8_USE_UNSAFE_HANDLES -template -void Persistent::Reset(Isolate* isolate, const Persistent& other) { - Dispose(isolate); - if (other.IsEmpty()) { - this->val_ = NULL; - return; - } - internal::Object** p = reinterpret_cast(other.val_); - this->val_ = reinterpret_cast( - V8::GlobalizeReference(reinterpret_cast(isolate), p)); -} -#endif - - -template -T* Persistent::ClearAndLeak() { +template +T* Persistent::ClearAndLeak() { T* old; -#ifdef V8_USE_UNSAFE_HANDLES - old = **this; - *this = Persistent(); -#else old = val_; val_ = NULL; -#endif return old; } -template -void Persistent::SetWrapperClassId(uint16_t class_id) { +template +void Persistent::SetWrapperClassId(uint16_t class_id) { typedef internal::Internals I; if (this->IsEmpty()) return; internal::Object** obj = reinterpret_cast(this->val_); @@ -5870,8 +5722,8 @@ void Persistent::SetWrapperClassId(uint16_t class_id) { } -template -uint16_t Persistent::WrapperClassId() const { +template +uint16_t Persistent::WrapperClassId() const { typedef internal::Internals I; if (this->IsEmpty()) return 0; internal::Object** obj = reinterpret_cast(this->val_); @@ -5993,13 +5845,6 @@ FunctionCallbackInfo::FunctionCallbackInfo(internal::Object** implicit_args, is_construct_call_(is_construct_call) { } -Arguments::Arguments(internal::Object** args, - internal::Object** values, - int length, - bool is_construct_call) - : FunctionCallbackInfo(args, values, length, is_construct_call) { } - - template Local FunctionCallbackInfo::operator[](int i) const { if (i < 0 || length_ <= i) return Local(*Undefined()); diff --git a/deps/v8/include/v8config.h b/deps/v8/include/v8config.h new file mode 100644 index 0000000000..6fe5c5aabc --- /dev/null +++ b/deps/v8/include/v8config.h @@ -0,0 +1,451 @@ +// Copyright 2013 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef V8CONFIG_H_ +#define V8CONFIG_H_ + +// Platform headers for feature detection below. +#if defined(__ANDROID__) +# include +#elif defined(__APPLE__) +# include +#elif defined(__linux__) +# include +#endif + + +// This macro allows to test for the version of the GNU C library (or +// a compatible C library that masquerades as glibc). It evaluates to +// 0 if libc is not GNU libc or compatible. +// Use like: +// #if V8_GLIBC_PREREQ(2, 3) +// ... +// #endif +#if defined(__GLIBC__) && defined(__GLIBC_MINOR__) +# define V8_GLIBC_PREREQ(major, minor) \ + ((__GLIBC__ * 100 + __GLIBC_MINOR__) >= ((major) * 100 + (minor))) +#else +# define V8_GLIBC_PREREQ(major, minor) 0 +#endif + + +// This macro allows to test for the version of the GNU C++ compiler. +// Note that this also applies to compilers that masquerade as GCC, +// for example clang and the Intel C++ compiler for Linux. +// Use like: +// #if V8_GNUC_PREREQ(4, 3, 1) +// ... +// #endif +#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) +# define V8_GNUC_PREREQ(major, minor, patchlevel) \ + ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= \ + ((major) * 10000 + (minor) * 100 + (patchlevel))) +#elif defined(__GNUC__) && defined(__GNUC_MINOR__) +# define V8_GNUC_PREREQ(major, minor, patchlevel) \ + ((__GNUC__ * 10000 + __GNUC_MINOR__) >= \ + ((major) * 10000 + (minor) * 100 + (patchlevel))) +#else +# define V8_GNUC_PREREQ(major, minor, patchlevel) 0 +#endif + + + +// ----------------------------------------------------------------------------- +// Operating system detection +// +// V8_OS_ANDROID - Android +// V8_OS_BSD - BSDish (Mac OS X, Net/Free/Open/DragonFlyBSD) +// V8_OS_CYGWIN - Cygwin +// V8_OS_DRAGONFLYBSD - DragonFlyBSD +// V8_OS_FREEBSD - FreeBSD +// V8_OS_LINUX - Linux +// V8_OS_MACOSX - Mac OS X +// V8_OS_NACL - Native Client +// V8_OS_NETBSD - NetBSD +// V8_OS_OPENBSD - OpenBSD +// V8_OS_POSIX - POSIX compatible (mostly everything except Windows) +// V8_OS_SOLARIS - Sun Solaris and OpenSolaris +// V8_OS_WIN - Microsoft Windows + +#if defined(__ANDROID__) +# define V8_OS_ANDROID 1 +# define V8_OS_LINUX 1 +# define V8_OS_POSIX 1 +#elif defined(__APPLE__) +# define V8_OS_BSD 1 +# define V8_OS_MACOSX 1 +# define V8_OS_POSIX 1 +#elif defined(__native_client__) +# define V8_OS_NACL 1 +# define V8_OS_POSIX 1 +#elif defined(__CYGWIN__) +# define V8_OS_CYGWIN 1 +# define V8_OS_POSIX 1 +#elif defined(__linux__) +# define V8_OS_LINUX 1 +# define V8_OS_POSIX 1 +#elif defined(__sun) +# define V8_OS_POSIX 1 +# define V8_OS_SOLARIS 1 +#elif defined(__FreeBSD__) +# define V8_OS_BSD 1 +# define V8_OS_FREEBSD 1 +# define V8_OS_POSIX 1 +#elif defined(__DragonFly__) +# define V8_OS_BSD 1 +# define V8_OS_DRAGONFLYBSD 1 +# define V8_OS_POSIX 1 +#elif defined(__NetBSD__) +# define V8_OS_BSD 1 +# define V8_OS_NETBSD 1 +# define V8_OS_POSIX 1 +#elif defined(__OpenBSD__) +# define V8_OS_BSD 1 +# define V8_OS_OPENBSD 1 +# define V8_OS_POSIX 1 +#elif defined(_WIN32) +# define V8_OS_WIN 1 +#endif + + +// ----------------------------------------------------------------------------- +// C library detection +// +// V8_LIBC_BIONIC - Bionic libc +// V8_LIBC_BSD - BSD libc derivate +// V8_LIBC_GLIBC - GNU C library +// V8_LIBC_UCLIBC - uClibc +// +// Note that testing for libc must be done using #if not #ifdef. For example, +// to test for the GNU C library, use: +// #if V8_LIBC_GLIBC +// ... +// #endif + +#if defined(__BIONIC__) +# define V8_LIBC_BIONIC 1 +# define V8_LIBC_BSD 1 +#elif defined(__UCLIBC__) +# define V8_LIBC_UCLIBC 1 +#elif defined(__GLIBC__) || defined(__GNU_LIBRARY__) +# define V8_LIBC_GLIBC 1 +#else +# define V8_LIBC_BSD V8_OS_BSD +#endif + + +// ----------------------------------------------------------------------------- +// Compiler detection +// +// V8_CC_CLANG - Clang +// V8_CC_GNU - GNU C++ +// V8_CC_INTEL - Intel C++ +// V8_CC_MINGW - Minimalist GNU for Windows +// V8_CC_MINGW32 - Minimalist GNU for Windows (mingw32) +// V8_CC_MINGW64 - Minimalist GNU for Windows (mingw-w64) +// V8_CC_MSVC - Microsoft Visual C/C++ +// +// C++11 feature detection +// +// V8_HAS_CXX11_ALIGNAS - alignas specifier supported +// V8_HAS_CXX11_ALIGNOF - alignof(type) operator supported +// V8_HAS_CXX11_STATIC_ASSERT - static_assert() supported +// V8_HAS_CXX11_DELETE - deleted functions supported +// V8_HAS_CXX11_FINAL - final marker supported +// V8_HAS_CXX11_OVERRIDE - override marker supported +// +// Compiler-specific feature detection +// +// V8_HAS___ALIGNOF - __alignof(type) operator supported +// V8_HAS___ALIGNOF__ - __alignof__(type) operator supported +// V8_HAS_ATTRIBUTE_ALIGNED - __attribute__((aligned(n))) supported +// V8_HAS_ATTRIBUTE_ALWAYS_INLINE - __attribute__((always_inline)) +// supported +// V8_HAS_ATTRIBUTE_DEPRECATED - __attribute__((deprecated)) supported +// V8_HAS_ATTRIBUTE_NOINLINE - __attribute__((noinline)) supported +// V8_HAS_ATTRIBUTE_VISIBILITY - __attribute__((visibility)) supported +// V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT - __attribute__((warn_unused_result)) +// supported +// V8_HAS_BUILTIN_EXPECT - __builtin_expect() supported +// V8_HAS_DECLSPEC_ALIGN - __declspec(align(n)) supported +// V8_HAS_DECLSPEC_DEPRECATED - __declspec(deprecated) supported +// V8_HAS_DECLSPEC_NOINLINE - __declspec(noinline) supported +// V8_HAS___FINAL - __final supported in non-C++11 mode +// V8_HAS___FORCEINLINE - __forceinline supported +// V8_HAS_SEALED - MSVC style sealed marker supported +// +// Note that testing for compilers and/or features must be done using #if +// not #ifdef. For example, to test for Intel C++ Compiler, use: +// #if V8_CC_INTEL +// ... +// #endif + +#if defined(__clang__) + +# define V8_CC_CLANG 1 + +// Clang defines __alignof__ as alias for __alignof +# define V8_HAS___ALIGNOF 1 +# define V8_HAS___ALIGNOF__ V8_HAS___ALIGNOF + +# define V8_HAS_ATTRIBUTE_ALIGNED (__has_attribute(aligned)) +# define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline)) +# define V8_HAS_ATTRIBUTE_DEPRECATED (__has_attribute(deprecated)) +# define V8_HAS_ATTRIBUTE_NOINLINE (__has_attribute(noinline)) +# define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility)) +# define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \ + (__has_attribute(warn_unused_result)) + +# define V8_HAS_BUILTIN_EXPECT (__has_builtin(__builtin_expect)) + +# define V8_HAS_CXX11_ALIGNAS (__has_feature(cxx_alignas)) +# define V8_HAS_CXX11_STATIC_ASSERT (__has_feature(cxx_static_assert)) +# define V8_HAS_CXX11_DELETE (__has_feature(cxx_deleted_functions)) +# define V8_HAS_CXX11_FINAL (__has_feature(cxx_override_control)) +# define V8_HAS_CXX11_OVERRIDE (__has_feature(cxx_override_control)) + +#elif defined(__GNUC__) + +# define V8_CC_GNU 1 +// Intel C++ also masquerades as GCC 3.2.0 +# define V8_CC_INTEL (defined(__INTEL_COMPILER)) +# define V8_CC_MINGW32 (defined(__MINGW32__)) +# define V8_CC_MINGW64 (defined(__MINGW64__)) +# define V8_CC_MINGW (V8_CC_MINGW32 || V8_CC_MINGW64) + +# define V8_HAS___ALIGNOF__ (V8_GNUC_PREREQ(4, 3, 0)) + +# define V8_HAS_ATTRIBUTE_ALIGNED (V8_GNUC_PREREQ(2, 95, 0)) +// always_inline is available in gcc 4.0 but not very reliable until 4.4. +// Works around "sorry, unimplemented: inlining failed" build errors with +// older compilers. +# define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (V8_GNUC_PREREQ(4, 4, 0)) +# define V8_HAS_ATTRIBUTE_DEPRECATED (V8_GNUC_PREREQ(3, 4, 0)) +# define V8_HAS_ATTRIBUTE_NOINLINE (V8_GNUC_PREREQ(3, 4, 0)) +# define V8_HAS_ATTRIBUTE_VISIBILITY (V8_GNUC_PREREQ(4, 3, 0)) +# define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \ + (!V8_CC_INTEL && V8_GNUC_PREREQ(4, 1, 0)) + +# define V8_HAS_BUILTIN_EXPECT (V8_GNUC_PREREQ(2, 96, 0)) + +// g++ requires -std=c++0x or -std=gnu++0x to support C++11 functionality +// without warnings (functionality used by the macros below). These modes +// are detectable by checking whether __GXX_EXPERIMENTAL_CXX0X__ is defined or, +// more standardly, by checking whether __cplusplus has a C++11 or greater +// value. Current versions of g++ do not correctly set __cplusplus, so we check +// both for forward compatibility. +# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L +# define V8_HAS_CXX11_ALIGNAS (V8_GNUC_PREREQ(4, 8, 0)) +# define V8_HAS_CXX11_ALIGNOF (V8_GNUC_PREREQ(4, 8, 0)) +# define V8_HAS_CXX11_STATIC_ASSERT (V8_GNUC_PREREQ(4, 3, 0)) +# define V8_HAS_CXX11_DELETE (V8_GNUC_PREREQ(4, 4, 0)) +# define V8_HAS_CXX11_OVERRIDE (V8_GNUC_PREREQ(4, 7, 0)) +# define V8_HAS_CXX11_FINAL (V8_GNUC_PREREQ(4, 7, 0)) +# else +// '__final' is a non-C++11 GCC synonym for 'final', per GCC r176655. +# define V8_HAS___FINAL (V8_GNUC_PREREQ(4, 7, 0)) +# endif + +#elif defined(_MSC_VER) + +# define V8_CC_MSVC 1 + +# define V8_HAS___ALIGNOF 1 + +// Override control was added with Visual Studio 2005, but +// Visual Studio 2010 and earlier spell "final" as "sealed". +# define V8_HAS_CXX11_FINAL (_MSC_VER >= 1700) +# define V8_HAS_CXX11_OVERRIDE (_MSC_VER >= 1400) +# define V8_HAS_SEALED (_MSC_VER >= 1400) + +# define V8_HAS_DECLSPEC_ALIGN 1 +# define V8_HAS_DECLSPEC_DEPRECATED (_MSC_VER >= 1300) +# define V8_HAS_DECLSPEC_NOINLINE 1 + +# define V8_HAS___FORCEINLINE 1 + +#endif + + +// ----------------------------------------------------------------------------- +// Helper macros + +// A macro used to make better inlining. Don't bother for debug builds. +// Use like: +// V8_INLINE int GetZero() { return 0; } +#if !defined(DEBUG) && V8_HAS_ATTRIBUTE_ALWAYS_INLINE +# define V8_INLINE inline __attribute__((always_inline)) +#elif !defined(DEBUG) && V8_HAS___FORCEINLINE +# define V8_INLINE __forceinline +#else +# define V8_INLINE inline +#endif + + +// A macro used to tell the compiler to never inline a particular function. +// Don't bother for debug builds. +// Use like: +// V8_NOINLINE int GetMinusOne() { return -1; } +#if !defined(DEBUG) && V8_HAS_ATTRIBUTE_NOINLINE +# define V8_NOINLINE __attribute__((noinline)) +#elif !defined(DEBUG) && V8_HAS_DECLSPEC_NOINLINE +# define V8_NOINLINE __declspec(noinline) +#else +# define V8_NOINLINE /* NOT SUPPORTED */ +#endif + + +// A macro to mark classes or functions as deprecated. +#if !V8_DISABLE_DEPRECATIONS && V8_HAS_ATTRIBUTE_DEPRECATED +# define V8_DEPRECATED(declarator) declarator __attribute__((deprecated)) +#elif !V8_DISABLE_DEPRECATIONS && V8_HAS_DECLSPEC_DEPRECATED +# define V8_DEPRECATED(declarator) __declspec(deprecated) declarator +#else +# define V8_DEPRECATED(declarator) declarator +#endif + + +// Annotate a function indicating the caller must examine the return value. +// Use like: +// int foo() V8_WARN_UNUSED_RESULT; +#if V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT +# define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) +#else +# define V8_WARN_UNUSED_RESULT /* NOT SUPPORTED */ +#endif + + +// A macro to provide the compiler with branch prediction information. +#if V8_HAS_BUILTIN_EXPECT +# define V8_UNLIKELY(condition) (__builtin_expect(!!(condition), 0)) +# define V8_LIKELY(condition) (__builtin_expect(!!(condition), 1)) +#else +# define V8_UNLIKELY(condition) (condition) +# define V8_LIKELY(condition) (condition) +#endif + + +// A macro to specify that a method is deleted from the corresponding class. +// Any attempt to use the method will always produce an error at compile time +// when this macro can be implemented (i.e. if the compiler supports C++11). +// If the current compiler does not support C++11, use of the annotated method +// will still cause an error, but the error will most likely occur at link time +// rather than at compile time. As a backstop, method declarations using this +// macro should be private. +// Use like: +// class A { +// private: +// A(const A& other) V8_DELETE; +// A& operator=(const A& other) V8_DELETE; +// }; +#if V8_HAS_CXX11_DELETE +# define V8_DELETE = delete +#else +# define V8_DELETE /* NOT SUPPORTED */ +#endif + + +// Annotate a virtual method indicating it must be overriding a virtual +// method in the parent class. +// Use like: +// virtual void bar() V8_OVERRIDE; +#if V8_HAS_CXX11_OVERRIDE +# define V8_OVERRIDE override +#else +# define V8_OVERRIDE /* NOT SUPPORTED */ +#endif + + +// Annotate a virtual method indicating that subclasses must not override it, +// or annotate a class to indicate that it cannot be subclassed. +// Use like: +// class B V8_FINAL : public A {}; +// virtual void bar() V8_FINAL; +#if V8_HAS_CXX11_FINAL +# define V8_FINAL final +#elif V8_HAS___FINAL +# define V8_FINAL __final +#elif V8_HAS_SEALED +# define V8_FINAL sealed +#else +# define V8_FINAL /* NOT SUPPORTED */ +#endif + + +// This macro allows to specify memory alignment for structs, classes, etc. +// Use like: +// class V8_ALIGNED(16) MyClass { ... }; +// V8_ALIGNED(32) int array[42]; +#if V8_HAS_CXX11_ALIGNAS +# define V8_ALIGNED(n) alignas(n) +#elif V8_HAS_ATTRIBUTE_ALIGNED +# define V8_ALIGNED(n) __attribute__((aligned(n))) +#elif V8_HAS_DECLSPEC_ALIGN +# define V8_ALIGNED(n) __declspec(align(n)) +#else +# define V8_ALIGNED(n) /* NOT SUPPORTED */ +#endif + + +// This macro is similar to V8_ALIGNED(), but takes a type instead of size +// in bytes. If the compiler does not supports using the alignment of the +// |type|, it will align according to the |alignment| instead. For example, +// Visual Studio C++ cannot combine __declspec(align) and __alignof. The +// |alignment| must be a literal that is used as a kind of worst-case fallback +// alignment. +// Use like: +// struct V8_ALIGNAS(AnotherClass, 16) NewClass { ... }; +// V8_ALIGNAS(double, 8) int array[100]; +#if V8_HAS_CXX11_ALIGNAS +# define V8_ALIGNAS(type, alignment) alignas(type) +#elif V8_HAS___ALIGNOF__ && V8_HAS_ATTRIBUTE_ALIGNED +# define V8_ALIGNAS(type, alignment) __attribute__((aligned(__alignof__(type)))) +#else +# define V8_ALIGNAS(type, alignment) V8_ALIGNED(alignment) +#endif + + +// This macro returns alignment in bytes (an integer power of two) required for +// any instance of the given type, which is either complete type, an array type, +// or a reference type. +// Use like: +// size_t alignment = V8_ALIGNOF(double); +#if V8_HAS_CXX11_ALIGNOF +# define V8_ALIGNOF(type) alignof(type) +#elif V8_HAS___ALIGNOF +# define V8_ALIGNOF(type) __alignof(type) +#elif V8_HAS___ALIGNOF__ +# define V8_ALIGNOF(type) __alignof__(type) +#else +// Note that alignment of a type within a struct can be less than the +// alignment of the type stand-alone (because of ancient ABIs), so this +// should only be used as a last resort. +namespace v8 { template class AlignOfHelper { char c; T t; }; } +# define V8_ALIGNOF(type) (sizeof(::v8::AlignOfHelper) - sizeof(type)) +#endif + +#endif // V8CONFIG_H_ diff --git a/deps/v8/include/v8stdint.h b/deps/v8/include/v8stdint.h index 7c12e1f490..0b49b37918 100644 --- a/deps/v8/include/v8stdint.h +++ b/deps/v8/include/v8stdint.h @@ -33,7 +33,9 @@ #include #include -#if defined(_WIN32) && !defined(__MINGW32__) +#include "v8config.h" + +#if V8_OS_WIN && !V8_CC_MINGW typedef signed char int8_t; typedef unsigned char uint8_t; @@ -47,7 +49,7 @@ typedef unsigned __int64 uint64_t; #else -#include +#include // NOLINT #endif diff --git a/deps/v8/samples/process.cc b/deps/v8/samples/process.cc index 844aee3d45..e6f2ee3add 100644 --- a/deps/v8/samples/process.cc +++ b/deps/v8/samples/process.cc @@ -291,9 +291,8 @@ JsHttpRequestProcessor::~JsHttpRequestProcessor() { // Dispose the persistent handles. When noone else has any // references to the objects stored in the handles they will be // automatically reclaimed. - Isolate* isolate = GetIsolate(); - context_.Dispose(isolate); - process_.Dispose(isolate); + context_.Dispose(); + process_.Dispose(); } diff --git a/deps/v8/src/accessors.cc b/deps/v8/src/accessors.cc index a43eb78b87..669c02baf3 100644 --- a/deps/v8/src/accessors.cc +++ b/deps/v8/src/accessors.cc @@ -51,19 +51,27 @@ static C* FindInstanceOf(Isolate* isolate, Object* obj) { // Entry point that never should be called. -MaybeObject* Accessors::IllegalSetter(JSObject*, Object*, void*) { +MaybeObject* Accessors::IllegalSetter(Isolate* isolate, + JSObject*, + Object*, + void*) { UNREACHABLE(); return NULL; } -Object* Accessors::IllegalGetAccessor(Object* object, void*) { +Object* Accessors::IllegalGetAccessor(Isolate* isolate, + Object* object, + void*) { UNREACHABLE(); return object; } -MaybeObject* Accessors::ReadOnlySetAccessor(JSObject*, Object* value, void*) { +MaybeObject* Accessors::ReadOnlySetAccessor(Isolate* isolate, + JSObject*, + Object* value, + void*) { // According to ECMA-262, section 8.6.2.2, page 28, setting // read-only properties must be silently ignored. return value; @@ -75,38 +83,41 @@ MaybeObject* Accessors::ReadOnlySetAccessor(JSObject*, Object* value, void*) { // -MaybeObject* Accessors::ArrayGetLength(Object* object, void*) { +MaybeObject* Accessors::ArrayGetLength(Isolate* isolate, + Object* object, + void*) { // Traverse the prototype chain until we reach an array. - JSArray* holder = FindInstanceOf(Isolate::Current(), object); + JSArray* holder = FindInstanceOf(isolate, object); return holder == NULL ? Smi::FromInt(0) : holder->length(); } // The helper function will 'flatten' Number objects. -Object* Accessors::FlattenNumber(Object* value) { +Object* Accessors::FlattenNumber(Isolate* isolate, Object* value) { if (value->IsNumber() || !value->IsJSValue()) return value; JSValue* wrapper = JSValue::cast(value); - ASSERT(Isolate::Current()->context()->native_context()->number_function()-> + ASSERT(wrapper->GetIsolate()->context()->native_context()->number_function()-> has_initial_map()); - Map* number_map = Isolate::Current()->context()->native_context()-> + Map* number_map = isolate->context()->native_context()-> number_function()->initial_map(); if (wrapper->map() == number_map) return wrapper->value(); return value; } -MaybeObject* Accessors::ArraySetLength(JSObject* object, Object* value, void*) { - Isolate* isolate = object->GetIsolate(); - +MaybeObject* Accessors::ArraySetLength(Isolate* isolate, + JSObject* object, + Object* value, + void*) { // This means one of the object's prototypes is a JSArray and the // object does not have a 'length' property. Calling SetProperty // causes an infinite loop. if (!object->IsJSArray()) { - return object->SetLocalPropertyIgnoreAttributes( + return object->SetLocalPropertyIgnoreAttributesTrampoline( isolate->heap()->length_string(), value, NONE); } - value = FlattenNumber(value); + value = FlattenNumber(isolate, value); // Need to call methods that may trigger GC. HandleScope scope(isolate); @@ -116,9 +127,11 @@ MaybeObject* Accessors::ArraySetLength(JSObject* object, Object* value, void*) { Handle value_handle(value, isolate); bool has_exception; - Handle uint32_v = Execution::ToUint32(value_handle, &has_exception); + Handle uint32_v = + Execution::ToUint32(isolate, value_handle, &has_exception); if (has_exception) return Failure::Exception(); - Handle number_v = Execution::ToNumber(value_handle, &has_exception); + Handle number_v = + Execution::ToNumber(isolate, value_handle, &has_exception); if (has_exception) return Failure::Exception(); if (uint32_v->Number() == number_v->Number()) { @@ -142,7 +155,9 @@ const AccessorDescriptor Accessors::ArrayLength = { // -MaybeObject* Accessors::StringGetLength(Object* object, void*) { +MaybeObject* Accessors::StringGetLength(Isolate* isolate, + Object* object, + void*) { Object* value = object; if (object->IsJSValue()) value = JSValue::cast(object)->value(); if (value->IsString()) return Smi::FromInt(String::cast(value)->length()); @@ -164,7 +179,9 @@ const AccessorDescriptor Accessors::StringLength = { // -MaybeObject* Accessors::ScriptGetSource(Object* object, void*) { +MaybeObject* Accessors::ScriptGetSource(Isolate* isolate, + Object* object, + void*) { Object* script = JSValue::cast(object)->value(); return Script::cast(script)->source(); } @@ -182,7 +199,9 @@ const AccessorDescriptor Accessors::ScriptSource = { // -MaybeObject* Accessors::ScriptGetName(Object* object, void*) { +MaybeObject* Accessors::ScriptGetName(Isolate* isolate, + Object* object, + void*) { Object* script = JSValue::cast(object)->value(); return Script::cast(script)->name(); } @@ -200,7 +219,7 @@ const AccessorDescriptor Accessors::ScriptName = { // -MaybeObject* Accessors::ScriptGetId(Object* object, void*) { +MaybeObject* Accessors::ScriptGetId(Isolate* isolate, Object* object, void*) { Object* script = JSValue::cast(object)->value(); return Script::cast(script)->id(); } @@ -218,7 +237,9 @@ const AccessorDescriptor Accessors::ScriptId = { // -MaybeObject* Accessors::ScriptGetLineOffset(Object* object, void*) { +MaybeObject* Accessors::ScriptGetLineOffset(Isolate* isolate, + Object* object, + void*) { Object* script = JSValue::cast(object)->value(); return Script::cast(script)->line_offset(); } @@ -236,7 +257,9 @@ const AccessorDescriptor Accessors::ScriptLineOffset = { // -MaybeObject* Accessors::ScriptGetColumnOffset(Object* object, void*) { +MaybeObject* Accessors::ScriptGetColumnOffset(Isolate* isolate, + Object* object, + void*) { Object* script = JSValue::cast(object)->value(); return Script::cast(script)->column_offset(); } @@ -254,7 +277,9 @@ const AccessorDescriptor Accessors::ScriptColumnOffset = { // -MaybeObject* Accessors::ScriptGetData(Object* object, void*) { +MaybeObject* Accessors::ScriptGetData(Isolate* isolate, + Object* object, + void*) { Object* script = JSValue::cast(object)->value(); return Script::cast(script)->data(); } @@ -272,7 +297,9 @@ const AccessorDescriptor Accessors::ScriptData = { // -MaybeObject* Accessors::ScriptGetType(Object* object, void*) { +MaybeObject* Accessors::ScriptGetType(Isolate* isolate, + Object* object, + void*) { Object* script = JSValue::cast(object)->value(); return Script::cast(script)->type(); } @@ -290,7 +317,9 @@ const AccessorDescriptor Accessors::ScriptType = { // -MaybeObject* Accessors::ScriptGetCompilationType(Object* object, void*) { +MaybeObject* Accessors::ScriptGetCompilationType(Isolate* isolate, + Object* object, + void*) { Object* script = JSValue::cast(object)->value(); return Smi::FromInt(Script::cast(script)->compilation_type()); } @@ -308,9 +337,10 @@ const AccessorDescriptor Accessors::ScriptCompilationType = { // -MaybeObject* Accessors::ScriptGetLineEnds(Object* object, void*) { +MaybeObject* Accessors::ScriptGetLineEnds(Isolate* isolate, + Object* object, + void*) { JSValue* wrapper = JSValue::cast(object); - Isolate* isolate = wrapper->GetIsolate(); HandleScope scope(isolate); Handle