deps: update V8 to 9.3.345.16

PR-URL: https://github.com/nodejs/node/pull/39469
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Michaël Zasso 2021-08-29 14:20:49 +02:00
parent b63e449b2e
commit 50930a0fa0
No known key found for this signature in database
GPG Key ID: 770F7A9A5AE15600
2236 changed files with 66338 additions and 35664 deletions

26
deps/v8/.bazelrc vendored Normal file
View File

@ -0,0 +1,26 @@
# Copyright 2021 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# V8 bazel port only supports clang
build --action_env=BAZEL_COMPILER=clang
build --action_env=CC=clang
build --action_env=CXX=clang++
build --action_env=PATH
# V8 debug config
build:debug --compilation_mode=dbg
build:debug --config=v8_enable_debugging_features
build:debug --//:v8_enable_fast_mksnapshot
build:debug --//:v8_enable_backtrace
# v8_enable_debugging_features flags
build:v8_enable_debugging_features --//:v8_enable_verify_heap
build:v8_enable_debugging_features --//:v8_enable_object_print
build:v8_enable_debugging_features --//:v8_enable_disassembler
build:v8_enable_debugging_features --//:v8_enable_trace_maps
build:v8_enable_debugging_features --//:v8_enable_test_features
build:v8_enable_debugging_features --//:v8_enable_v8_checks
build:v8_enable_debugging_features --//:v8_code_comments
build:v8_enable_debugging_features --//:v8_enable_debug_code
build:v8_enable_debugging_features --//:v8_enable_snapshot_native_code_counters

6
deps/v8/.gitignore vendored
View File

@ -51,6 +51,7 @@
/test/benchmarks/data
/test/fuzzer/wasm_corpus
/test/fuzzer/wasm_corpus.tar.gz
!/test/mjsunit/tools/*.log
/test/mozilla/data
/test/test262/data
/test/test262/harness
@ -111,7 +112,10 @@ turbo*.cfg
turbo*.dot
turbo*.json
v8.ignition_dispatches_table.json
bazel-bin
bazel-out
bazel-testlogs
bazel-v8
!/third_party/jinja2
!/third_party/markupsafe
!/third_party/zlib

14
deps/v8/.mailmap vendored Normal file
View File

@ -0,0 +1,14 @@
# Copyright 2021 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# People change their names or email addresses for many reasons. This
# list makes sure peoples preferences are respected when using Git
# commands such as `git log` or `git blame`.
#
# See https://git-scm.com/docs/gitmailmap for more information.
#
# Please keep the list sorted.
Clemens Backes <clemensb@chromium.org> Clemens Hammacher <clemensh@chromium.org>
Timothy Gu <timothygu@chromium.org> <timothygu99@gmail.com>

6
deps/v8/AUTHORS vendored
View File

@ -86,7 +86,6 @@ Daniel Andersson <kodandersson@gmail.com>
Daniel Bevenius <daniel.bevenius@gmail.com>
Daniel Dromboski <dandromb@gmail.com>
Daniel James <dnljms@gmail.com>
Darshan Sen <raisinten@gmail.com>
David Carlier <devnexen@gmail.com>
David Manouchehri <david@davidmanouchehri.com>
Deepak Mohan <hop2deep@gmail.com>
@ -127,6 +126,7 @@ Jay Freeman <saurik@saurik.com>
James Pike <g00gle@chilon.net>
James M Snell <jasnell@gmail.com>
Javad Amiri <javad.amiri@anu.edu.au>
Jesper van den Ende <jespertheend@gmail.com>
Ji Qiu <qiuji@iscas.ac.cn>
Jianghua Yang <jianghua.yjh@alibaba-inc.com>
Jiawen Geng <technicalcute@gmail.com>
@ -164,6 +164,7 @@ Michael Lutz <michi@icosahedron.de>
Michael Mclaughlin <m8ch88l@gmail.com>
Michael Smith <mike@w3.org>
Michaël Zasso <mic.besace@gmail.com>
Mihir Shah <mihirshah.11204@gmail.com>
Mike Gilbert <floppymaster@gmail.com>
Mike Pennisi <mike@mikepennisi.com>
Mikhail Gusarov <dottedmag@dottedmag.net>
@ -213,6 +214,7 @@ Seo Sanghyeon <sanxiyn@gmail.com>
Shawn Anastasio <shawnanastasio@gmail.com>
Shawn Presser <shawnpresser@gmail.com>
Stefan Penner <stefan.penner@gmail.com>
Stephan Hartmann <stha09@googlemail.com>
Stephen Belanger <stephen.belanger@datadoghq.com>
Sylvestre Ledru <sledru@mozilla.com>
Taketoshi Aono <brn@b6n.ch>
@ -229,6 +231,7 @@ Victor Costan <costan@gmail.com>
Vlad Burlik <vladbph@gmail.com>
Vladimir Krivosheev <develar@gmail.com>
Vladimir Shutoff <vovan@shutoff.ru>
Wael Almattar <waelsy123@gmail.com>
Wei Wu <lazyparser@gmail.com>
Wenlu Wang <kingwenlu@gmail.com>
Wenyu Zhao <wenyu.zhao@anu.edu.au>
@ -247,6 +250,7 @@ Yuri Iozzelli <yuri@leaningtech.com>
Zac Hansen <xaxxon@gmail.com>
Zeynep Cankara <zeynepcankara402@gmail.com>
Zhao Jiazhong <kyslie3100@gmail.com>
Zheng Liu <i6122f@gmail.com>
Zhongping Wang <kewpie.w.zp@gmail.com>
柳荣一 <admin@web-tinker.com>
Tianping Yang <yangtianping@oppo.com>

3052
deps/v8/BUILD.bazel vendored Normal file

File diff suppressed because it is too large Load Diff

258
deps/v8/BUILD.gn vendored
View File

@ -79,6 +79,9 @@ declare_args() {
# Sets -dENABLE_VTUNE_TRACEMARK.
v8_enable_vtunetracemark = false
# Sets -dENABLE_HUGEPAGE
v8_enable_hugepage = false
# Sets -dENABLE_HANDLE_ZAPPING.
v8_enable_handle_zapping = is_debug
@ -150,6 +153,15 @@ declare_args() {
# v8_enable_concurrent_marking_state. See the default setting code below.
v8_enable_concurrent_marking = true
# Sets -dV8_IGNITION_DISPATCH_COUNTING.
# Enables counting frequencies of bytecode dispatches. After building in this
# configuration, subsequent runs of d8 can output frequencies for each pair
# of (current, next) bytecode instructions executed if you specify
# --trace-ignition-dispatches-output-file, or can generate a JS object with
# those frequencies if you run with --expose-ignition-statistics and call the
# extension function getIgnitionDispatchCounters().
v8_enable_ignition_dispatch_counting = false
# Runs mksnapshot with --turbo-profiling. After building in this
# configuration, any subsequent run of d8 will output information about usage
# of basic blocks in builtins.
@ -184,6 +196,11 @@ declare_args() {
# Sets -dV8_SHORT_BUILTIN_CALLS
v8_enable_short_builtin_calls = ""
# Enable support for external code range relative to the pointer compression
# cage.
# Sets -dV8_EXTERNAL_CODE_SPACE
v8_enable_external_code_space = ""
# With post mortem support enabled, metadata is embedded into libv8 that
# describes various parameters of the VM for use by debuggers. See
# tools/gen-postmortem-metadata.py for details.
@ -213,11 +230,8 @@ declare_args() {
# Enable mitigations for executing untrusted code.
# Disabled by default on ia32 due to conflicting requirements with embedded
# builtins. Enabled by default on Android since it doesn't support
# site-isolation in Chrome and on simulator builds which test code generation
# on these platforms.
v8_untrusted_code_mitigations =
v8_current_cpu != "x86" && (is_android || target_is_simulator)
# builtins.
v8_untrusted_code_mitigations = false
# Enable minor mark compact.
v8_enable_minor_mc = true
@ -283,6 +297,10 @@ declare_args() {
# TODO(v8:11785): Enable by default when running with the verifier.
cppgc_enable_verify_live_bytes = false
# Enable assignment checks for Members/Persistents during prefinalizer invocations.
# TODO(v8:11749): Enable by default after fixing any existing issues in Blink.
cppgc_enable_check_assignments_in_prefinalizers = false
# Enable young generation in cppgc.
cppgc_enable_young_generation = false
@ -317,6 +335,13 @@ declare_args() {
# Allow for JS promise hooks (instead of just C++).
v8_allow_javascript_in_promise_hooks = false
# Enable allocation folding globally (sets -dV8_ALLOCATION_FOLDING).
# When it's disabled, the --turbo-allocation-folding runtime flag will be ignored.
v8_enable_allocation_folding = true
# Enable global allocation site tracking.
v8_allocation_site_tracking = true
}
# Derived defaults.
@ -371,6 +396,9 @@ if (v8_enable_short_builtin_calls == "") {
v8_enable_short_builtin_calls =
v8_current_cpu == "x64" || (!is_android && v8_current_cpu == "arm64")
}
if (v8_enable_external_code_space == "") {
v8_enable_external_code_space = false
}
if (v8_enable_single_generation == "") {
v8_enable_single_generation = v8_disable_write_barriers
}
@ -386,6 +414,10 @@ if (v8_enable_third_party_heap) {
v8_enable_shared_ro_heap = false
v8_enable_pointer_compression = false
v8_enable_pointer_compression_shared_cage = false
v8_enable_allocation_folding = false
}
if (v8_enable_single_generation) {
v8_allocation_site_tracking = false
}
assert(!v8_enable_concurrent_marking || v8_enable_atomic_object_field_writes,
"Concurrent marking requires atomic object field writes.")
@ -448,13 +480,17 @@ assert(!v8_use_multi_snapshots || !v8_control_flow_integrity,
assert(!v8_enable_heap_sandbox || v8_enable_pointer_compression,
"V8 Heap Sandbox requires pointer compression")
assert(!v8_enable_heap_sandbox || !v8_enable_external_code_space,
"V8 Heap Sandbox is not compatible with external code space YET")
assert(
!v8_enable_pointer_compression_shared_cage || v8_enable_pointer_compression,
"Can't share a pointer compression cage if pointers aren't compressed")
assert(!v8_enable_pointer_compression_shared_cage || v8_current_cpu == "x64" ||
v8_current_cpu == "arm64",
"Sharing a pointer compression cage is only supported on x64 and arm64")
assert(
!v8_enable_pointer_compression_shared_cage || v8_current_cpu == "x64" ||
v8_current_cpu == "arm64" || v8_current_cpu == "riscv64",
"Sharing a pointer compression cage is only supported on x64,arm64 and riscv64")
assert(!v8_enable_unconditional_write_barriers || !v8_disable_write_barriers,
"Write barriers can't be both enabled and disabled")
@ -605,6 +641,7 @@ external_v8_defines = [
"V8_NO_ARGUMENTS_ADAPTOR",
"V8_USE_PERFETTO",
"V8_MAP_PACKING",
"V8_IS_TSAN",
]
enabled_external_v8_defines = []
@ -641,6 +678,9 @@ if (v8_use_perfetto) {
if (v8_enable_map_packing) {
enabled_external_v8_defines += [ "V8_MAP_PACKING" ]
}
if (is_tsan) {
enabled_external_v8_defines += [ "V8_IS_TSAN" ]
}
disabled_external_v8_defines = external_v8_defines - enabled_external_v8_defines
@ -711,6 +751,10 @@ config("features") {
defines += [ "CPPGC_VERIFY_LIVE_BYTES" ]
}
if (cppgc_enable_check_assignments_in_prefinalizers) {
defines += [ "CPPGC_CHECK_ASSIGNMENTS_IN_PREFINALIZERS" ]
}
if (v8_embedder_string != "") {
defines += [ "V8_EMBEDDER_STRING=\"$v8_embedder_string\"" ]
}
@ -743,6 +787,9 @@ config("features") {
if (v8_enable_vtunetracemark) {
defines += [ "ENABLE_VTUNE_TRACEMARK" ]
}
if (v8_enable_hugepage) {
defines += [ "ENABLE_HUGEPAGE" ]
}
if (v8_enable_minor_mc) {
defines += [ "ENABLE_MINOR_MC" ]
}
@ -805,6 +852,9 @@ config("features") {
if (v8_enable_atomic_marking_state) {
defines += [ "V8_ATOMIC_MARKING_STATE" ]
}
if (v8_enable_ignition_dispatch_counting) {
defines += [ "V8_IGNITION_DISPATCH_COUNTING" ]
}
if (v8_enable_lazy_source_positions) {
defines += [ "V8_ENABLE_LAZY_SOURCE_POSITIONS" ]
}
@ -841,6 +891,9 @@ config("features") {
if (v8_enable_short_builtin_calls) {
defines += [ "V8_SHORT_BUILTIN_CALLS" ]
}
if (v8_enable_external_code_space) {
defines += [ "V8_EXTERNAL_CODE_SPACE" ]
}
if (v8_enable_swiss_name_dictionary) {
defines += [ "V8_ENABLE_SWISS_NAME_DICTIONARY" ]
}
@ -859,6 +912,12 @@ config("features") {
if (v8_allow_javascript_in_promise_hooks) {
defines += [ "V8_ALLOW_JAVASCRIPT_IN_PROMISE_HOOKS" ]
}
if (v8_enable_allocation_folding) {
defines += [ "V8_ALLOCATION_FOLDING" ]
}
if (v8_allocation_site_tracking) {
defines += [ "V8_ALLOCATION_SITE_TRACKING" ]
}
}
config("toolchain") {
@ -2350,8 +2409,8 @@ v8_header_set("v8_internal_headers") {
"src/ast/variables.h",
"src/baseline/baseline-assembler-inl.h",
"src/baseline/baseline-assembler.h",
"src/baseline/baseline-batch-compiler.h",
"src/baseline/baseline-compiler.h",
"src/baseline/baseline-osr-inl.h",
"src/baseline/baseline.h",
"src/baseline/bytecode-offset-iterator.h",
"src/builtins/accessors.h",
@ -2458,6 +2517,7 @@ v8_header_set("v8_internal_headers") {
"src/compiler/effect-control-linearizer.h",
"src/compiler/escape-analysis-reducer.h",
"src/compiler/escape-analysis.h",
"src/compiler/fast-api-calls.h",
"src/compiler/feedback-source.h",
"src/compiler/frame-states.h",
"src/compiler/frame.h",
@ -2753,21 +2813,13 @@ v8_header_set("v8_internal_headers") {
"src/logging/log-utils.h",
"src/logging/log.h",
"src/logging/metrics.h",
"src/logging/runtime-call-stats-scope.h",
"src/logging/runtime-call-stats.h",
"src/logging/tracing-flags.h",
"src/numbers/bignum-dtoa.h",
"src/numbers/bignum.h",
"src/numbers/cached-powers.h",
"src/numbers/conversions-inl.h",
"src/numbers/conversions.h",
"src/numbers/diy-fp.h",
"src/numbers/double.h",
"src/numbers/dtoa.h",
"src/numbers/fast-dtoa.h",
"src/numbers/fixed-dtoa.h",
"src/numbers/hash-seed-inl.h",
"src/numbers/math-random.h",
"src/numbers/strtod.h",
"src/objects/all-objects-inl.h",
"src/objects/allocation-site-inl.h",
"src/objects/allocation-site-scopes-inl.h",
@ -2879,6 +2931,7 @@ v8_header_set("v8_internal_headers") {
"src/objects/object-list-macros.h",
"src/objects/object-macros-undef.h",
"src/objects/object-macros.h",
"src/objects/object-type.h",
"src/objects/objects-body-descriptors-inl.h",
"src/objects/objects-body-descriptors.h",
"src/objects/objects-inl.h",
@ -3057,8 +3110,6 @@ v8_header_set("v8_internal_headers") {
"src/tracing/trace-event.h",
"src/tracing/traced-value.h",
"src/tracing/tracing-category-observer.h",
"src/trap-handler/trap-handler-internal.h",
"src/trap-handler/trap-handler.h",
"src/utils/address-map.h",
"src/utils/allocation.h",
"src/utils/bit-vector.h",
@ -3073,7 +3124,6 @@ v8_header_set("v8_internal_headers") {
"src/utils/scoped-list.h",
"src/utils/utils-inl.h",
"src/utils/utils.h",
"src/utils/vector.h",
"src/utils/version.h",
"src/zone/accounting-allocator.h",
"src/zone/compressed-zone-ptr.h",
@ -3106,6 +3156,8 @@ v8_header_set("v8_internal_headers") {
"src/compiler/wasm-compiler.h",
"src/debug/debug-wasm-objects-inl.h",
"src/debug/debug-wasm-objects.h",
"src/trap-handler/trap-handler-internal.h",
"src/trap-handler/trap-handler.h",
"src/wasm/baseline/liftoff-assembler-defs.h",
"src/wasm/baseline/liftoff-assembler.h",
"src/wasm/baseline/liftoff-compiler.h",
@ -3117,6 +3169,7 @@ v8_header_set("v8_internal_headers") {
"src/wasm/function-body-decoder.h",
"src/wasm/function-compiler.h",
"src/wasm/graph-builder-interface.h",
"src/wasm/init-expr-interface.h",
"src/wasm/jump-table-assembler.h",
"src/wasm/leb-helper.h",
"src/wasm/local-decl-encoder.h",
@ -3156,6 +3209,12 @@ v8_header_set("v8_internal_headers") {
]
}
if (!v8_enable_third_party_heap) {
sources += filter_include(v8_third_party_heap_files, [ "*.h" ])
} else {
sources += [ "src/heap/third-party/heap-api.h" ]
}
if (v8_enable_i18n_support) {
sources += [
"src/objects/intl-objects.h",
@ -3248,16 +3307,19 @@ v8_header_set("v8_internal_headers") {
"src/wasm/baseline/x64/liftoff-assembler-x64.h",
]
# iOS Xcode simulator builds run on an x64 target. iOS and macOS are both
# based on Darwin and thus POSIX-compliant to a similar degree.
if (is_linux || is_chromeos || is_mac || is_ios || target_os == "freebsd") {
sources += [ "src/trap-handler/handler-inside-posix.h" ]
}
if (is_win) {
sources += [
"src/diagnostics/unwinding-info-win64.h",
"src/trap-handler/handler-inside-win.h",
]
sources += [ "src/diagnostics/unwinding-info-win64.h" ]
}
if (v8_enable_webassembly) {
# iOS Xcode simulator builds run on an x64 target. iOS and macOS are both
# based on Darwin and thus POSIX-compliant to a similar degree.
if (is_linux || is_chromeos || is_mac || is_ios ||
target_os == "freebsd") {
sources += [ "src/trap-handler/handler-inside-posix.h" ]
} else if (is_win) {
sources += [ "src/trap-handler/handler-inside-win.h" ]
}
}
} else if (v8_current_cpu == "arm") {
sources += [ ### gcmole(arch:arm) ###
@ -3302,7 +3364,7 @@ v8_header_set("v8_internal_headers") {
if (v8_control_flow_integrity) {
sources += [ "src/execution/arm64/pointer-authentication-arm64.h" ]
}
if (current_cpu == "arm64" && is_mac) {
if (v8_enable_webassembly && current_cpu == "arm64" && is_mac) {
sources += [ "src/trap-handler/handler-inside-posix.h" ]
}
if (is_win) {
@ -3456,6 +3518,7 @@ v8_compiler_sources = [
"src/compiler/effect-control-linearizer.cc",
"src/compiler/escape-analysis-reducer.cc",
"src/compiler/escape-analysis.cc",
"src/compiler/fast-api-calls.cc",
"src/compiler/feedback-source.cc",
"src/compiler/frame-states.cc",
"src/compiler/frame.cc",
@ -3630,6 +3693,7 @@ v8_source_set("v8_base_without_compiler") {
"src/ast/scopes.cc",
"src/ast/source-range-ast-visitor.cc",
"src/ast/variables.cc",
"src/baseline/baseline-batch-compiler.cc",
"src/baseline/baseline-compiler.cc",
"src/baseline/baseline.cc",
"src/baseline/bytecode-offset-iterator.cc",
@ -3845,16 +3909,8 @@ v8_source_set("v8_base_without_compiler") {
"src/logging/metrics.cc",
"src/logging/runtime-call-stats.cc",
"src/logging/tracing-flags.cc",
"src/numbers/bignum-dtoa.cc",
"src/numbers/bignum.cc",
"src/numbers/cached-powers.cc",
"src/numbers/conversions.cc",
"src/numbers/diy-fp.cc",
"src/numbers/dtoa.cc",
"src/numbers/fast-dtoa.cc",
"src/numbers/fixed-dtoa.cc",
"src/numbers/math-random.cc",
"src/numbers/strtod.cc",
"src/objects/backing-store.cc",
"src/objects/bigint.cc",
"src/objects/code-kind.cc",
@ -3892,6 +3948,7 @@ v8_source_set("v8_base_without_compiler") {
"src/objects/map-updater.cc",
"src/objects/map.cc",
"src/objects/module.cc",
"src/objects/object-type.cc",
"src/objects/objects.cc",
"src/objects/ordered-hash-table.cc",
"src/objects/osr-optimized-code-cache.cc",
@ -3908,6 +3965,7 @@ v8_source_set("v8_base_without_compiler") {
"src/objects/synthetic-module.cc",
"src/objects/tagged-impl.cc",
"src/objects/template-objects.cc",
"src/objects/templates.cc",
"src/objects/transitions.cc",
"src/objects/type-hints.cc",
"src/objects/value-serializer.cc",
@ -4021,9 +4079,6 @@ v8_source_set("v8_base_without_compiler") {
"src/tracing/trace-event.cc",
"src/tracing/traced-value.cc",
"src/tracing/tracing-category-observer.cc",
"src/trap-handler/handler-inside.cc",
"src/trap-handler/handler-outside.cc",
"src/trap-handler/handler-shared.cc",
"src/utils/address-map.cc",
"src/utils/allocation.cc",
"src/utils/bit-vector.cc",
@ -4050,11 +4105,16 @@ v8_source_set("v8_base_without_compiler") {
"src/debug/debug-wasm-objects.cc",
"src/runtime/runtime-test-wasm.cc",
"src/runtime/runtime-wasm.cc",
"src/trap-handler/handler-inside.cc",
"src/trap-handler/handler-outside.cc",
"src/trap-handler/handler-shared.cc",
"src/wasm/baseline/liftoff-assembler.cc",
"src/wasm/baseline/liftoff-compiler.cc",
"src/wasm/code-space-access.cc",
"src/wasm/function-body-decoder.cc",
"src/wasm/function-compiler.cc",
"src/wasm/graph-builder-interface.cc",
"src/wasm/init-expr-interface.cc",
"src/wasm/jump-table-assembler.cc",
"src/wasm/local-decl-encoder.cc",
"src/wasm/memory-protection-key.cc",
@ -4088,12 +4148,9 @@ v8_source_set("v8_base_without_compiler") {
}
if (v8_enable_third_party_heap) {
sources += v8_third_party_heap_files
sources += filter_exclude(v8_third_party_heap_files, [ "*.h" ])
} else {
sources += [
"src/heap/third-party/heap-api-stub.cc",
"src/heap/third-party/heap-api.h",
]
sources += [ "src/heap/third-party/heap-api-stub.cc" ]
}
if (v8_enable_conservative_stack_scanning) {
@ -4146,20 +4203,25 @@ v8_source_set("v8_base_without_compiler") {
"src/regexp/x64/regexp-macro-assembler-x64.cc",
]
# iOS Xcode simulator builds run on an x64 target. iOS and macOS are both
# based on Darwin and thus POSIX-compliant to a similar degree.
if (is_linux || is_chromeos || is_mac || is_ios || target_os == "freebsd") {
sources += [
"src/trap-handler/handler-inside-posix.cc",
"src/trap-handler/handler-outside-posix.cc",
]
}
if (is_win) {
sources += [
"src/diagnostics/unwinding-info-win64.cc",
"src/trap-handler/handler-inside-win.cc",
"src/trap-handler/handler-outside-win.cc",
]
sources += [ "src/diagnostics/unwinding-info-win64.cc" ]
}
if (v8_enable_webassembly) {
# iOS Xcode simulator builds run on an x64 target. iOS and macOS are both
# based on Darwin and thus POSIX-compliant to a similar degree.
if (is_linux || is_chromeos || is_mac || is_ios ||
target_os == "freebsd") {
sources += [
"src/trap-handler/handler-inside-posix.cc",
"src/trap-handler/handler-outside-posix.cc",
]
} else if (is_win) {
sources += [
"src/trap-handler/handler-inside-win.cc",
"src/trap-handler/handler-outside-win.cc",
]
}
}
} else if (v8_current_cpu == "arm") {
sources += [ ### gcmole(arch:arm) ###
@ -4203,7 +4265,7 @@ v8_source_set("v8_base_without_compiler") {
"src/execution/arm64/simulator-logic-arm64.cc",
"src/regexp/arm64/regexp-macro-assembler-arm64.cc",
]
if (current_cpu == "arm64" && is_mac) {
if (v8_enable_webassembly && current_cpu == "arm64" && is_mac) {
sources += [
"src/trap-handler/handler-inside-posix.cc",
"src/trap-handler/handler-outside-posix.cc",
@ -4447,6 +4509,8 @@ v8_source_set("torque_base") {
"src/torque/class-debug-reader-generator.cc",
"src/torque/constants.h",
"src/torque/contextual.h",
"src/torque/cpp-builder.cc",
"src/torque/cpp-builder.h",
"src/torque/csa-generator.cc",
"src/torque/csa-generator.h",
"src/torque/declarable.cc",
@ -4597,6 +4661,23 @@ v8_component("v8_libbase") {
"src/base/logging.h",
"src/base/macros.h",
"src/base/memory.h",
"src/base/numbers/bignum-dtoa.cc",
"src/base/numbers/bignum-dtoa.h",
"src/base/numbers/bignum.cc",
"src/base/numbers/bignum.h",
"src/base/numbers/cached-powers.cc",
"src/base/numbers/cached-powers.h",
"src/base/numbers/diy-fp.cc",
"src/base/numbers/diy-fp.h",
"src/base/numbers/double.h",
"src/base/numbers/dtoa.cc",
"src/base/numbers/dtoa.h",
"src/base/numbers/fast-dtoa.cc",
"src/base/numbers/fast-dtoa.h",
"src/base/numbers/fixed-dtoa.cc",
"src/base/numbers/fixed-dtoa.h",
"src/base/numbers/strtod.cc",
"src/base/numbers/strtod.h",
"src/base/once.cc",
"src/base/once.h",
"src/base/optional.h",
@ -4626,6 +4707,8 @@ v8_component("v8_libbase") {
"src/base/sanitizer/lsan.h",
"src/base/sanitizer/msan.h",
"src/base/small-vector.h",
"src/base/strings.cc",
"src/base/strings.h",
"src/base/sys-info.cc",
"src/base/sys-info.h",
"src/base/template-utils.h",
@ -4633,6 +4716,7 @@ v8_component("v8_libbase") {
"src/base/type-traits.h",
"src/base/utils/random-number-generator.cc",
"src/base/utils/random-number-generator.h",
"src/base/vector.h",
"src/base/vlq-base64.cc",
"src/base/vlq-base64.h",
"src/base/vlq.h",
@ -4869,11 +4953,27 @@ v8_source_set("v8_bigint") {
"src/bigint/bigint-internal.h",
"src/bigint/bigint.h",
"src/bigint/digit-arithmetic.h",
"src/bigint/div-burnikel.cc",
"src/bigint/div-helpers.cc",
"src/bigint/div-helpers.h",
"src/bigint/div-schoolbook.cc",
"src/bigint/mul-karatsuba.cc",
"src/bigint/mul-schoolbook.cc",
"src/bigint/tostring.cc",
"src/bigint/util.h",
"src/bigint/vector-arithmetic.cc",
"src/bigint/vector-arithmetic.h",
]
if (v8_advanced_bigint_algorithms) {
sources += [
"src/bigint/mul-fft.cc",
"src/bigint/mul-toom.cc",
]
defines = [ "V8_ADVANCED_BIGINT_ALGORITHMS" ]
}
configs = [ ":internal_config" ]
}
@ -4962,6 +5062,10 @@ v8_header_set("cppgc_headers") {
"include/cppgc/process-heap-statistics.h",
"include/cppgc/sentinel-pointer.h",
"include/cppgc/source-location.h",
# TODO(v8:11952): Remove the testing header here once depending on both,
# //v8:v8 and //v8:v8_for_testing does not result in ODR violations.
"include/cppgc/testing.h",
"include/cppgc/trace-trait.h",
"include/cppgc/type-traits.h",
"include/cppgc/visitor.h",
@ -5058,6 +5162,10 @@ v8_source_set("cppgc_base") {
"src/heap/cppgc/sweeper.cc",
"src/heap/cppgc/sweeper.h",
"src/heap/cppgc/task-handle.h",
# TODO(v8:11952): Remove the testing header here once depending on both,
# //v8:v8 and //v8:v8_for_testing does not result in ODR violations.
"src/heap/cppgc/testing.cc",
"src/heap/cppgc/trace-event.h",
"src/heap/cppgc/trace-trait.cc",
"src/heap/cppgc/virtual-memory.cc",
@ -5094,22 +5202,6 @@ v8_source_set("cppgc_base") {
}
}
v8_source_set("cppgc_base_for_testing") {
visibility = [ ":*" ]
sources = [
"include/cppgc/testing.h",
"src/heap/cppgc/testing.cc",
]
configs = [
":internal_config",
":cppgc_base_config",
]
public_deps = [ ":cppgc_base" ]
}
if (v8_check_header_includes) {
# This file will be generated by tools/generate-header-include-checks.py
# if the "check_v8_header_includes" gclient variable is set.
@ -5491,7 +5583,6 @@ if (is_component_build) {
sources = [ "src/utils/v8dll-main.cc" ]
public_deps = [
":cppgc_base_for_testing",
":torque_base",
":torque_ls_base",
":v8_base",
@ -5520,10 +5611,7 @@ if (is_component_build) {
v8_component("cppgc_for_testing") {
testonly = true
public_deps = [
":cppgc_base",
":cppgc_base_for_testing",
]
public_deps = [ ":cppgc_base" ]
configs = []
public_configs = [ ":external_config" ]
@ -5552,7 +5640,6 @@ if (is_component_build) {
testonly = true
public_deps = [
":cppgc_base_for_testing",
":torque_base",
":torque_ls_base",
":v8_base",
@ -5577,10 +5664,7 @@ if (is_component_build) {
group("cppgc_for_testing") {
testonly = true
public_deps = [
":cppgc_base",
":cppgc_base_for_testing",
]
public_deps = [ ":cppgc_base" ]
public_configs = [ ":external_config" ]
}

View File

@ -35,7 +35,6 @@ solanes@chromium.org
syg@chromium.org
szuend@chromium.org
thibaudm@chromium.org
ulan@chromium.org
vahl@chromium.org
verwaest@chromium.org
victorgomes@chromium.org

201
deps/v8/DEPS vendored
View File

@ -41,13 +41,18 @@ vars = {
'android_url': 'https://android.googlesource.com',
'download_gcmole': False,
'download_jsfunfuzz': False,
'download_prebuilt_bazel': False,
'check_v8_header_includes': False,
'checkout_reclient': False,
# reclient CIPD package version
'reclient_version': 're_client_version:0.33.0.3e223d5',
# GN CIPD package version.
'gn_version': 'git_revision:39a87c0b36310bdf06b692c098f199a0d97fc810',
'gn_version': 'git_revision:24e2f7df92641de0351a96096fb2c490b2436bb8',
# luci-go CIPD package version.
'luci_go': 'git_revision:22d464e2f8f3bd2bd33f69fe819326d63f881008',
'luci_go': 'git_revision:8b8a9a6040ca6debd30694a71a99a1eac97d72fd',
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling android_sdk_build-tools_version
@ -84,16 +89,12 @@ vars = {
}
deps = {
'base/trace_event/common':
Var('chromium_url') + '/chromium/src/base/trace_event/common.git' + '@' + 'd5bb24e5d9802c8c917fcaa4375d5239a586c168',
'build':
Var('chromium_url') + '/chromium/src/build.git' + '@' + '4036cf1b17581f5668b487a25e252d56e0321a7f',
'third_party/depot_tools':
Var('chromium_url') + '/chromium/tools/depot_tools.git' + '@' + '6b0a611c2c692684f94c0c3629f793feebd16b39',
'third_party/icu':
Var('chromium_url') + '/chromium/deps/icu.git' + '@' + 'f022e298b4f4a782486bb6d5ce6589c998b51fe2',
'third_party/instrumented_libraries':
Var('chromium_url') + '/chromium/src/third_party/instrumented_libraries.git' + '@' + '4ae2535e8e894c3cd81d46aacdaf151b5df30709',
Var('chromium_url') + '/chromium/src/build.git' + '@' + '2d999384c270a340f592cce0a0fb3f8f94c15290',
'buildtools':
Var('chromium_url') + '/chromium/src/buildtools.git' + '@' + '20b1d0fc13ebaa263a1248f08814f523a86e6bed',
Var('chromium_url') + '/chromium/src/buildtools.git' + '@' + '2500c1d8f3a20a66a7cbafe3f69079a2edb742dd',
'buildtools/clang_format/script':
Var('chromium_url') + '/external/github.com/llvm/llvm-project/clang/tools/clang-format.git' + '@' + '99803d74e35962f63a775f29477882afd4d57d94',
'buildtools/linux64': {
@ -117,11 +118,11 @@ deps = {
'condition': 'host_os == "mac"',
},
'buildtools/third_party/libc++/trunk':
Var('chromium_url') + '/external/github.com/llvm/llvm-project/libcxx.git' + '@' + '8fa87946779682841e21e2da977eccfb6cb3bded',
Var('chromium_url') + '/external/github.com/llvm/llvm-project/libcxx.git' + '@' + '79a2e924d96e2fc1e4b937c42efd08898fa472d7',
'buildtools/third_party/libc++abi/trunk':
Var('chromium_url') + '/external/github.com/llvm/llvm-project/libcxxabi.git' + '@' + '767de317f97343db64af048e3d198ab8b10fee5d',
Var('chromium_url') + '/external/github.com/llvm/llvm-project/libcxxabi.git' + '@' + '6803464b0f46df0a51862347d39e0791b59cf568',
'buildtools/third_party/libunwind/trunk':
Var('chromium_url') + '/external/github.com/llvm/llvm-project/libunwind.git' + '@' + '7846d256355e40273f7cc192c8f5893e8665a1f9',
Var('chromium_url') + '/external/github.com/llvm/llvm-project/libunwind.git' + '@' + 'a5feaf61658af4453e282142a76aeb6f9c045311',
'buildtools/win': {
'packages': [
{
@ -132,14 +133,50 @@ deps = {
'dep_type': 'cipd',
'condition': 'host_os == "win"',
},
'base/trace_event/common':
Var('chromium_url') + '/chromium/src/base/trace_event/common.git' + '@' + 'd5bb24e5d9802c8c917fcaa4375d5239a586c168',
'buildtools/reclient': {
'packages': [
{
'package': 'infra/rbe/client/${{platform}}',
'version': Var('reclient_version'),
}
],
'dep_type': 'cipd',
'condition': '(host_os == "linux" or host_os == "win") and checkout_reclient',
},
'test/benchmarks/data':
Var('chromium_url') + '/v8/deps/third_party/benchmarks.git' + '@' + '05d7188267b4560491ff9155c5ee13e207ecd65f',
'test/mozilla/data':
Var('chromium_url') + '/v8/deps/third_party/mozilla-tests.git' + '@' + 'f6c578a10ea707b1a8ab0b88943fe5115ce2b9be',
'test/test262/data':
Var('chromium_url') + '/external/github.com/tc39/test262.git' + '@' + 'ebb6c34fa5dd76a6bea01c54ed7b182596492176',
'test/test262/harness':
Var('chromium_url') + '/external/github.com/test262-utils/test262-harness-py.git' + '@' + '278bcfaed0dcaa13936831fb1769d15e7c1e3b2b',
'third_party/aemu-linux-x64': {
'packages': [
{
'package': 'fuchsia/third_party/aemu/linux-amd64',
'version': 'm4sM10idq7LeFHXpoLKLBtaOZsQzuj63Usa3Cl9af1YC'
},
],
'condition': 'host_os == "linux" and checkout_fuchsia',
'dep_type': 'cipd',
},
'third_party/aemu-mac-x64': {
'packages': [
{
'package': 'fuchsia/third_party/aemu/mac-amd64',
'version': 'T9bWxf8aUC5TwCFgPxpuW29Mfy-7Z9xCfXB9QO8MfU0C'
},
],
'condition': 'host_os == "mac" and checkout_fuchsia',
'dep_type': 'cipd',
},
'third_party/android_ndk': {
'url': Var('chromium_url') + '/android_ndk.git' + '@' + '401019bf85744311b26c88ced255cd53401af8b7',
'condition': 'checkout_android',
},
'third_party/android_platform': {
'url': Var('chromium_url') + '/chromium/src/third_party/android_platform.git' + '@' + 'fdaa5e5b9f6384c3011ca8479d672e47528f743f',
'url': Var('chromium_url') + '/chromium/src/third_party/android_platform.git' + '@' + 'b291e88d8e3e6774d6d46151e11dc3189ddeeb09',
'condition': 'checkout_android',
},
'third_party/android_sdk/public': {
@ -181,36 +218,46 @@ deps = {
'dep_type': 'cipd',
},
'third_party/catapult': {
'url': Var('chromium_url') + '/catapult.git' + '@' + 'c1e1d559b46476584ec0eb1d83bd7f43fa5a1b36',
'url': Var('chromium_url') + '/catapult.git' + '@' + '2814ff3716a8512518bee705a0f91425ce06b27b',
'condition': 'checkout_android',
},
'third_party/colorama/src': {
'url': Var('chromium_url') + '/external/colorama.git' + '@' + '799604a1041e9b3bc5d2789ecbd7e8db2e18e6b8',
'condition': 'checkout_android',
},
'third_party/depot_tools':
Var('chromium_url') + '/chromium/tools/depot_tools.git' + '@' + 'a806594b95a39141fdbf1f359087a44ffb2deaaf',
'third_party/fuchsia-sdk': {
'url': Var('chromium_url') + '/chromium/src/third_party/fuchsia-sdk.git' + '@' + 'efa46583d89ea8c97523281d9f52a0d96472114d',
'url': Var('chromium_url') + '/chromium/src/third_party/fuchsia-sdk.git' + '@' + '18896843130c33372c455c153ad07d2217bd2085',
'condition': 'checkout_fuchsia',
},
'third_party/googletest/src':
Var('chromium_url') + '/external/github.com/google/googletest.git' + '@' + '23ef29555ef4789f555f1ba8c51b4c52975f0907',
'third_party/google_benchmark/src': {
'url': Var('chromium_url') + '/external/github.com/google/benchmark.git' + '@' + '7d0d9061d83b663ce05d9de5da3d5865a3845b79',
'url': Var('chromium_url') + '/external/github.com/google/benchmark.git' + '@' + 'e451e50e9b8af453f076dec10bd6890847f1624e',
},
'third_party/googletest/src':
Var('chromium_url') + '/external/github.com/google/googletest.git' + '@' + '4ec4cd23f486bf70efcc5d2caa40f24368f752e3',
'third_party/icu':
Var('chromium_url') + '/chromium/deps/icu.git' + '@' + 'b9dfc58bf9b02ea0365509244aca13841322feb0',
'third_party/instrumented_libraries':
Var('chromium_url') + '/chromium/src/third_party/instrumented_libraries.git' + '@' + '4ae2535e8e894c3cd81d46aacdaf151b5df30709',
'third_party/ittapi': {
# Force checkout ittapi libraries to pass v8 header includes check on
# bots that has check_v8_header_includes enabled.
'url': Var('chromium_url') + '/external/github.com/intel/ittapi' + '@' + 'b4ae0122ba749163096058b4f1bb065bf4a7de94',
'condition': "checkout_ittapi or check_v8_header_includes",
},
'third_party/jinja2':
Var('chromium_url') + '/chromium/src/third_party/jinja2.git' + '@' + '11b6b3e5971d760bd2d310f77643f55a818a6d25',
Var('chromium_url') + '/chromium/src/third_party/jinja2.git' + '@' + '7c54c1f227727e0c4c1d3dc19dd71cd601a2db95',
'third_party/jsoncpp/source':
Var('chromium_url') + '/external/github.com/open-source-parsers/jsoncpp.git'+ '@' + '9059f5cad030ba11d37818847443a53918c327b1',
'third_party/logdog/logdog':
Var('chromium_url') + '/infra/luci/luci-py/client/libs/logdog' + '@' + '794d09a24c10401953880c253d0c7e267234ab75',
'third_party/markupsafe':
Var('chromium_url') + '/chromium/src/third_party/markupsafe.git' + '@' + '0944e71f4b2cb9a871bcbe353f95e889b64a611a',
'tools/swarming_client':
Var('chromium_url') + '/infra/luci/client-py.git' + '@' + 'a32a1607f6093d338f756c7e7c7b4333b0c50c9c',
'test/benchmarks/data':
Var('chromium_url') + '/v8/deps/third_party/benchmarks.git' + '@' + '05d7188267b4560491ff9155c5ee13e207ecd65f',
'test/mozilla/data':
Var('chromium_url') + '/v8/deps/third_party/mozilla-tests.git' + '@' + 'f6c578a10ea707b1a8ab0b88943fe5115ce2b9be',
'test/test262/data':
Var('chromium_url') + '/external/github.com/tc39/test262.git' + '@' + '6d353a4436747e2de8820efac27ae5ef7e601b60',
'test/test262/harness':
Var('chromium_url') + '/external/github.com/test262-utils/test262-harness-py.git' + '@' + '278bcfaed0dcaa13936831fb1769d15e7c1e3b2b',
Var('chromium_url') + '/chromium/src/third_party/markupsafe.git' + '@' + '1b882ef6372b58bfd55a3285f37ed801be9137cd',
'third_party/perfetto':
Var('android_url') + '/platform/external/perfetto.git' + '@' + 'aa4385bc5997ecad4c633885e1b331b1115012fb',
'third_party/protobuf':
Var('chromium_url') + '/external/github.com/google/protobuf'+ '@' + '6a59a2ad1f61d9696092f79b6d74368b4d7970a3',
'third_party/qemu-linux-x64': {
'packages': [
{
@ -231,28 +278,24 @@ deps = {
'condition': 'host_os == "mac" and checkout_fuchsia',
'dep_type': 'cipd',
},
'third_party/aemu-linux-x64': {
'packages': [
{
'package': 'fuchsia/third_party/aemu/linux-amd64',
'version': '-Sz2gSN_5yVSHDlitjxUlmZpHuz-F2kFDW6TnmggCZoC'
},
],
'condition': 'host_os == "linux" and checkout_fuchsia',
'dep_type': 'cipd',
},
'third_party/aemu-mac-x64': {
'packages': [
{
'package': 'fuchsia/third_party/aemu/mac-amd64',
'version': 'T9bWxf8aUC5TwCFgPxpuW29Mfy-7Z9xCfXB9QO8MfU0C'
},
],
'condition': 'host_os == "mac" and checkout_fuchsia',
'dep_type': 'cipd',
'third_party/requests': {
'url': Var('chromium_url') + '/external/github.com/kennethreitz/requests.git' + '@' + '2c2138e811487b13020eb331482fb991fd399d4e',
'condition': 'checkout_android',
},
'third_party/zlib':
Var('chromium_url') + '/chromium/src/third_party/zlib.git'+ '@' + 'dfbc590f5855bc2765256a743cad0abc56330a30',
'tools/clang':
Var('chromium_url') + '/chromium/src/tools/clang.git' + '@' + 'a38f01b956e091d5e698d2af484c81cd4e9a2a2d',
Var('chromium_url') + '/chromium/src/tools/clang.git' + '@' + '9d0a403e85d25b5b0d3016a342d4b83b12941fd5',
'tools/clang/dsymutil': {
'packages': [
{
'package': 'chromium/llvm-build-tools/dsymutil',
'version': 'M56jPzDv1620Rnm__jTMYS62Zi8rxHVq7yw0qeBFEgkC',
}
],
'condition': 'checkout_mac',
'dep_type': 'cipd',
},
'tools/luci-go': {
'packages': [
{
@ -271,34 +314,8 @@ deps = {
'condition': 'host_cpu != "s390" and host_os != "aix"',
'dep_type': 'cipd',
},
'tools/clang/dsymutil': {
'packages': [
{
'package': 'chromium/llvm-build-tools/dsymutil',
'version': 'M56jPzDv1620Rnm__jTMYS62Zi8rxHVq7yw0qeBFEgkC',
}
],
'condition': 'checkout_mac',
'dep_type': 'cipd',
},
'third_party/perfetto':
Var('android_url') + '/platform/external/perfetto.git' + '@' + 'aa4385bc5997ecad4c633885e1b331b1115012fb',
'third_party/protobuf':
Var('chromium_url') + '/external/github.com/google/protobuf'+ '@' + '6a59a2ad1f61d9696092f79b6d74368b4d7970a3',
'third_party/zlib':
Var('chromium_url') + '/chromium/src/third_party/zlib.git'+ '@' + '5b8d433953beb2a75a755ba321a3076b95f7cdb9',
'third_party/jsoncpp/source':
Var('chromium_url') + '/external/github.com/open-source-parsers/jsoncpp.git'+ '@' + '9059f5cad030ba11d37818847443a53918c327b1',
'third_party/ittapi': {
# Force checkout ittapi libraries to pass v8 header includes check on
# bots that has check_v8_header_includes enabled.
'url': Var('chromium_url') + '/external/github.com/intel/ittapi' + '@' + 'b4ae0122ba749163096058b4f1bb065bf4a7de94',
'condition': "checkout_ittapi or check_v8_header_includes",
},
'third_party/requests': {
'url': Var('chromium_url') + '/external/github.com/kennethreitz/requests.git' + '@' + '2c2138e811487b13020eb331482fb991fd399d4e',
'condition': 'checkout_android',
},
'tools/swarming_client':
Var('chromium_url') + '/infra/luci/client-py.git' + '@' + 'a32a1607f6093d338f756c7e7c7b4333b0c50c9c',
}
include_rules = [
@ -340,6 +357,17 @@ hooks = [
'tools/get_landmines.py',
],
},
{
'name': 'bazel',
'pattern': '.',
'condition': 'download_prebuilt_bazel',
'action': [ 'download_from_google_storage',
'--bucket', 'chromium-v8-prebuilt-bazel/linux',
'--no_resume',
'-s', 'tools/bazel/bazel.sha1',
'--platform=linux*',
],
},
# Pull clang-format binaries using checked-in hashes.
{
'name': 'clang_format_win',
@ -538,17 +566,6 @@ hooks = [
'--boot-images={checkout_fuchsia_boot_images}',
],
},
{
# Mac doesn't use lld so it's not included in the default clang bundle
# there. However, lld is need in Fuchsia cross builds, so
# download it there.
# Should run after the clang hook.
'name': 'lld/mac',
'pattern': '.',
'condition': 'host_os == "mac" and checkout_fuchsia',
'action': ['python', 'tools/clang/scripts/update.py',
'--package=lld_mac'],
},
{
# Mac does not have llvm-objdump, download it for cross builds in Fuchsia.
'name': 'llvm-objdump',

4
deps/v8/OWNERS vendored
View File

@ -10,9 +10,13 @@ per-file .git-blame-ignore-revs=file:INFRA_OWNERS
per-file .gitattributes=file:INFRA_OWNERS
per-file .gitignore=file:INFRA_OWNERS
per-file .gn=file:INFRA_OWNERS
per-file .mailmap=file:COMMON_OWNERS
per-file .vpython=file:INFRA_OWNERS
per-file .ycm_extra_conf.py=file:INFRA_OWNERS
per-file .bazelrc=file:COMMON_OWNERS
per-file BUILD.bazel=file:COMMON_OWNERS
per-file BUILD.gn=file:COMMON_OWNERS
per-file WORKSPACE=file:COMMON_OWNERS
per-file DEPS=file:INFRA_OWNERS
# For Test262 rolls.
per-file DEPS=mathias@chromium.org

11
deps/v8/WATCHLISTS vendored
View File

@ -97,7 +97,13 @@
},
'regexp': {
'filepath': 'src/.*regexp',
}
},
'bazel': {
'filepath': 'BUILD.gn' \
'|BUILD.bazel' \
'|WORKSPACE' \
'|bazel/'
},
},
'WATCHLISTS': {
@ -156,5 +162,8 @@
'jgruber+watch@chromium.org',
'pthier+watch@chromium.org'
],
'bazel' : [
'victorgomes+watch@chromium.org'
],
},
}

29
deps/v8/WORKSPACE vendored Normal file
View File

@ -0,0 +1,29 @@
# Copyright 2021 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
workspace(name = "v8")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "bazel_skylib",
urls = [
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
],
sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c",
)
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
bazel_skylib_workspace()
new_local_repository(
name = "zlib",
path = "third_party/zlib",
build_file = "bazel/BUILD.zlib",
)
new_local_repository(
name = "icu",
path = "third_party/icu",
build_file = "bazel/BUILD.icu",
)

76
deps/v8/bazel/BUILD.icu vendored Normal file
View File

@ -0,0 +1,76 @@
# Copyright 2021 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
filegroup(
name = "icudata",
srcs = [ "common/icudtl.dat" ]
)
cc_library(
name = "icuuc",
srcs = glob([
"source/common/**/*.h",
"source/common/**/*.cpp"
]),
defines = [
"U_COMMON_IMPLEMENTATION",
"U_ICUDATAENTRY_IN_COMMON",
"HAVE_DLOPEN=0",
"UCONFIG_ONLY_HTML_CONVERSION=1",
"U_CHARSET_IS_UTF8=1",
"U_USING_ICU_NAMESPACE=0",
"U_ENABLE_DYLOAD=0",
"USE_CHROMIUM_ICU=1",
"U_ENABLE_TRACING=1",
"U_ENABLE_RESOURCE_TRACING=0",
"UNISTR_FROM_STRING_EXPLICIT=",
"UNISTR_FROM_CHAR_EXPLICIT=",
"ICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE",
],
copts = [
"-Wno-unused-function",
"-Wno-parentheses",
"-Wno-unused-function",
"-Wno-unused-variable",
"-Wno-deprecated-declarations",
],
includes = [
"source/common",
"source/i18n",
],
tags = ["requires-rtti"],
data = [ ":icudata" ],
alwayslink = 1,
)
cc_library(
name = "icui18n",
srcs = glob([
"source/i18n/**/*.h",
"source/i18n/**/*.cpp"
]),
defines = [
"U_I18N_IMPLEMENTATION",
],
deps = [ ":icuuc" ],
alwayslink = 1,
)
cc_library(
name = "icu",
hdrs = glob([
"source/common/unicode/*.h",
"source/i18n/unicode/*.h",
]),
srcs = [
"source/stubdata/stubdata.cpp",
],
include_prefix = "third_party/icu",
deps = [
":icuuc",
":icui18n"
],
visibility = ["//visibility:public"],
alwayslink = 1,
)

52
deps/v8/bazel/BUILD.zlib vendored Normal file
View File

@ -0,0 +1,52 @@
# Copyright 2021 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
cc_library(
name = "zlib",
srcs = [
"adler32.c",
"chromeconf.h",
"compress.c",
"contrib/optimizations/insert_string.h",
"cpu_features.c",
"cpu_features.h",
"crc32.c",
"crc32.h",
"deflate.c",
"deflate.h",
"gzclose.c",
"gzguts.h",
"gzlib.c",
"gzread.c",
"gzwrite.c",
"infback.c",
"inffast.c",
"inffast.h",
"inffixed.h",
"inflate.c",
"inflate.h",
"inftrees.c",
"inftrees.h",
"trees.c",
"trees.h",
"uncompr.c",
"zconf.h",
"zlib.h",
"zutil.c",
"zutil.h",
"google/compression_utils_portable.h",
"google/compression_utils_portable.cc",
],
hdrs = [
"zlib.h",
"google/compression_utils_portable.h",
],
include_prefix = "third_party/zlib",
defines = [
"CHROMIUM_ZLIB_NO_CHROMECONF",
"HAVE_HIDDEN",
"CPU_NO_SIMD",
],
visibility = ["//visibility:public"],
)

5
deps/v8/bazel/OWNERS vendored Normal file
View File

@ -0,0 +1,5 @@
# Google3 V8 owners
ahaas@chromium.org
cbruni@chromium.org
delphick@chromium.org
victorgomes@chromium.org

239
deps/v8/bazel/defs.bzl vendored Normal file
View File

@ -0,0 +1,239 @@
# Copyright 2021 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
FlagInfo = provider(fields = ["value"])
def _options_impl(ctx):
return FlagInfo(value = ctx.build_setting_value)
_create_option_flag = rule(
implementation = _options_impl,
build_setting = config.bool(flag = True),
)
_create_option_string = rule(
implementation = _options_impl,
build_setting = config.string(flag = True),
)
_create_option_int = rule(
implementation = _options_impl,
build_setting = config.int(flag = True),
)
def v8_raw_flag(name, default = False):
_create_option_flag(name = name, build_setting_default = default)
native.config_setting(name = "raw_" + name, flag_values = {name: "True"})
def v8_flag(name, default = False):
_create_option_flag(name = name, build_setting_default = default)
native.config_setting(name = "is_" + name, flag_values = {name: "True"})
native.config_setting(name = "is_not_" + name, flag_values = {name: "False"})
def v8_string(name, default = ""):
_create_option_string(name = name, build_setting_default = default)
def v8_int(name, default = 0):
_create_option_int(name = name, build_setting_default = default)
def _custom_config_impl(ctx):
defs = []
defs.append("V8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=" +
str(ctx.attr._v8_typed_array_max_size_in_heap[FlagInfo].value))
context = cc_common.create_compilation_context(defines = depset(defs))
return [CcInfo(compilation_context = context)]
v8_custom_config = rule(
implementation = _custom_config_impl,
attrs = {
"_v8_typed_array_max_size_in_heap":
attr.label(default = ":v8_typed_array_max_size_in_heap"),
}
)
def _config_impl(ctx):
hdrs = []
# Add headers
for h in ctx.attr.hdrs:
hdrs += h[DefaultInfo].files.to_list()
defs = []
# Add conditional_defines
for f, d in ctx.attr.conditional_defines.items():
if f[FlagInfo].value:
defs.append(d)
# Add defines
for d in ctx.attr.defines:
defs.append(d)
context = cc_common.create_compilation_context(
defines = depset(
defs,
transitive = [dep[CcInfo].compilation_context.defines for dep in ctx.attr.deps],
),
headers = depset(
hdrs,
transitive = [dep[CcInfo].compilation_context.headers for dep in ctx.attr.deps],
),
)
return [CcInfo(compilation_context = context)]
v8_config = rule(
implementation = _config_impl,
attrs = {
"conditional_defines": attr.label_keyed_string_dict(),
"defines": attr.string_list(),
"deps": attr.label_list(),
"hdrs": attr.label_list(allow_files = True),
},
)
def _default_args(configs):
return struct(
deps = configs + [":define_flags"],
copts = [
"-fPIC",
"-Werror",
"-Wextra",
"-Wno-builtin-assume-aligned-alignment",
"-Wno-unused-parameter",
"-Wno-implicit-int-float-conversion",
"-Wno-deprecated-copy",
"-Wno-non-virtual-dtor",
"-std=c++17",
"-isystem .",
],
includes = ["include"],
linkopts = [
"-pthread"
] + select({
":is_macos": [],
"//conditions:default": [ "-Wl,--no-as-needed -ldl" ],
}) + select({
":should_add_rdynamic": [ "-rdynamic" ],
"//conditions:default": [],
}),
)
def v8_binary(
name,
srcs,
configs = [],
deps = [],
includes = [],
copts = [],
linkopts = [],
**kwargs):
default = _default_args(configs)
native.cc_binary(
name = name,
srcs = srcs,
deps = deps + default.deps,
includes = includes + default.includes,
copts = copts + default.copts,
linkopts = linkopts + default.linkopts,
**kwargs
)
def v8_library(
name,
srcs,
configs = [],
deps = [],
includes = [],
copts = [],
linkopts = [],
**kwargs):
default = _default_args(configs)
native.cc_library(
name = name,
srcs = srcs,
deps = deps + default.deps,
includes = includes + default.includes,
copts = copts + default.copts,
linkopts = linkopts + default.linkopts,
alwayslink = 1,
**kwargs
)
def _torque_impl(ctx):
v8root = ctx.attr.v8root[FlagInfo].value
# Arguments
args = []
args += ctx.attr.args
args.append("-o")
args.append(ctx.bin_dir.path + "/torque-generated")
args.append("-strip-v8-root")
args.append("-v8-root")
args.append(v8root)
# Sources
args += [f.path for f in ctx.files.srcs]
# Generate/declare output files
outs = []
for src in ctx.files.srcs:
root, period, ext = src.path.rpartition(".")
# Strip v8root
if root[:len(v8root)] == v8root:
root = root[len(v8root):]
file = "torque-generated/" + root
outs.append(ctx.actions.declare_file(file + "-tq-csa.cc"))
outs.append(ctx.actions.declare_file(file + "-tq-csa.h"))
outs.append(ctx.actions.declare_file(file + "-tq-inl.inc"))
outs.append(ctx.actions.declare_file(file + "-tq.inc"))
outs.append(ctx.actions.declare_file(file + "-tq.cc"))
outs += [ctx.actions.declare_file("torque-generated/" + f) for f in ctx.attr.extras]
ctx.actions.run(
outputs = outs,
inputs = ctx.files.srcs,
arguments = args,
executable = ctx.executable.tool,
progress_message = "Generating Torque files",
)
return [DefaultInfo(files = depset(outs))]
v8_torque = rule(
implementation = _torque_impl,
attrs = {
"srcs": attr.label_list(allow_files = True, mandatory = True),
"extras": attr.string_list(),
"tool": attr.label(
default = ":torque",
allow_files = True,
executable = True,
cfg = "host",
),
"args": attr.string_list(),
"v8root": attr.label(default = ":v8_root"),
},
)
def _mksnapshot(ctx):
outs = [
ctx.actions.declare_file("snapshot.cc"),
ctx.actions.declare_file("embedded.S"),
]
ctx.actions.run(
outputs = outs,
inputs = [],
arguments = [
"--embedded_variant=Default",
"--startup_src", outs[0].path,
"--embedded_src", outs[1].path,
] + ctx.attr.args,
executable = ctx.executable.tool,
progress_message = "Running mksnapshot"
)
return [DefaultInfo(files = depset(outs))]
v8_mksnapshot = rule(
implementation = _mksnapshot,
attrs = {
"args": attr.string_list(),
"tool": attr.label(
default = ":mksnapshot",
allow_files = True,
executable = True,
cfg = "host",
),
}
)

19
deps/v8/bazel/generate-inspector-files.sh vendored Executable file
View File

@ -0,0 +1,19 @@
# Copyright 2021 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
BAZEL_OUT=$1
# Create a default GN output folder
gn gen out/inspector
# Generate inspector files
autoninja -C out/inspector src/inspector:inspector
# Create directories in bazel output folder
mkdir -p $BAZEL_OUT/include/inspector
mkdir -p $BAZEL_OUT/src/inspector/protocol
# Copy generated files to bazel output folder
cp out/inspector/gen/include/inspector/* $BAZEL_OUT/include/inspector/
cp out/inspector/gen/src/inspector/protocol/* $BAZEL_OUT/src/inspector/protocol/

4
deps/v8/gni/v8.gni vendored
View File

@ -87,6 +87,10 @@ declare_args() {
v8_enable_google_benchmark = false
cppgc_is_standalone = false
# Enable advanced BigInt algorithms, costing about 10-30 KB binary size
# depending on platform. Disabled on Android to save binary size.
v8_advanced_bigint_algorithms = !is_android
}
if (v8_use_external_startup_data == "") {

View File

@ -2,7 +2,6 @@ adamk@chromium.org
cbruni@chromium.org
leszeks@chromium.org
mlippautz@chromium.org
ulan@chromium.org
verwaest@chromium.org
yangguo@chromium.org

View File

@ -5,25 +5,20 @@
#ifndef INCLUDE_CPPGC_ALLOCATION_H_
#define INCLUDE_CPPGC_ALLOCATION_H_
#include <stdint.h>
#include <atomic>
#include <cstddef>
#include <cstdint>
#include <new>
#include <type_traits>
#include "cppgc/custom-space.h"
#include "cppgc/garbage-collected.h"
#include "cppgc/internal/api-constants.h"
#include "cppgc/internal/gc-info.h"
#include "cppgc/type-traits.h"
#include "v8config.h" // NOLINT(build/include_directory)
namespace cppgc {
template <typename T>
class MakeGarbageCollectedTraitBase;
namespace internal {
class ObjectAllocator;
} // namespace internal
/**
* AllocationHandle is used to allocate garbage-collected objects.
*/

View File

@ -5,7 +5,8 @@
#ifndef INCLUDE_CPPGC_HEAP_STATISTICS_H_
#define INCLUDE_CPPGC_HEAP_STATISTICS_H_
#include <memory>
#include <cstddef>
#include <cstdint>
#include <string>
#include <vector>
@ -30,19 +31,17 @@ struct HeapStatistics final {
};
/**
* Statistics of object types. For each type the statistics record its name,
* how many objects of that type were allocated, and the overall size used by
* these objects.
* Object statistics for a single type.
*/
struct ObjectStatistics {
/** Number of distinct types in the heap. */
size_t num_types = 0;
/** Name of each type in the heap. */
std::vector<std::string> type_name;
/** Number of allocated objects per each type. */
std::vector<size_t> type_count;
/** Overall size of allocated objects per each type. */
std::vector<size_t> type_bytes;
struct ObjectStatsEntry {
/**
* Number of allocated bytes.
*/
size_t allocated_bytes;
/**
* Number of allocated objects.
*/
size_t object_count;
};
/**
@ -50,10 +49,15 @@ struct HeapStatistics final {
* allocated memory size and overall used memory size for the page.
*/
struct PageStatistics {
/** Overall amount of memory allocated for the page. */
size_t physical_size_bytes = 0;
/** Overall committed amount of memory for the page. */
size_t committed_size_bytes = 0;
/** Resident amount of memory held by the page. */
size_t resident_size_bytes = 0;
/** Amount of memory actually used on the page. */
size_t used_size_bytes = 0;
/** Statistics for object allocated on the page. Filled only when
* NameProvider::HideInternalNames() is false. */
std::vector<ObjectStatsEntry> object_statistics;
};
/**
@ -80,29 +84,35 @@ struct HeapStatistics final {
struct SpaceStatistics {
/** The space name */
std::string name;
/** Overall amount of memory allocated for the space. */
size_t physical_size_bytes = 0;
/** Overall committed amount of memory for the heap. */
size_t committed_size_bytes = 0;
/** Resident amount of memory held by the heap. */
size_t resident_size_bytes = 0;
/** Amount of memory actually used on the space. */
size_t used_size_bytes = 0;
/** Statistics for each of the pages in the space. */
std::vector<PageStatistics> page_stats;
/** Statistics for the freelist of the space. */
FreeListStatistics free_list_stats;
/** Statistics for object allocated on the space. Filled only when
* NameProvider::HideInternalNames() is false. */
ObjectStatistics object_stats;
};
/** Overall amount of memory allocated for the heap. */
size_t physical_size_bytes = 0;
/** Overall committed amount of memory for the heap. */
size_t committed_size_bytes = 0;
/** Resident amount of memory help by the heap. */
size_t resident_size_bytes = 0;
/** Amount of memory actually used on the heap. */
size_t used_size_bytes = 0;
/** Detail level of this HeapStatistics. */
DetailLevel detail_level;
/** Statistics for each of the spaces in the heap. Filled only when
* detail_level is kDetailed. */
* `detail_level` is `DetailLevel::kDetailed`. */
std::vector<SpaceStatistics> space_stats;
/**
* Vector of `cppgc::GarbageCollected` type names.
*/
std::vector<std::string> type_names;
};
} // namespace cppgc

View File

@ -5,6 +5,8 @@
#ifndef INCLUDE_CPPGC_HEAP_H_
#define INCLUDE_CPPGC_HEAP_H_
#include <cstddef>
#include <cstdint>
#include <memory>
#include <vector>

View File

@ -5,8 +5,8 @@
#ifndef INCLUDE_CPPGC_INTERNAL_API_CONSTANTS_H_
#define INCLUDE_CPPGC_INTERNAL_API_CONSTANTS_H_
#include <stddef.h>
#include <stdint.h>
#include <cstddef>
#include <cstdint>
#include "v8config.h" // NOLINT(build/include_directory)

View File

@ -7,6 +7,7 @@
#include <atomic>
#include <cstdint>
#include <type_traits>
#include "cppgc/internal/finalizer-trait.h"
#include "cppgc/internal/name-trait.h"

View File

@ -73,7 +73,7 @@ class NameTrait final : public NameTraitBase {
private:
static HeapObjectName GetNameFor(const NameProvider* name_provider) {
return {name_provider->GetName(), false};
return {name_provider->GetHumanReadableName(), false};
}
static HeapObjectName GetNameFor(...) {
@ -91,7 +91,7 @@ class NameTrait final : public NameTraitBase {
static const HeapObjectName leaky_name =
GetNameFromTypeSignature(PRETTY_FUNCTION_VALUE);
return leaky_name;
return {leaky_name, false};
#undef PRETTY_FUNCTION_VALUE

View File

@ -82,7 +82,7 @@ class V8_EXPORT EnabledCheckingPolicy {
class DisabledCheckingPolicy {
protected:
void CheckPointer(const void* raw) {}
void CheckPointer(const void*) {}
};
#if V8_ENABLE_CHECKS
@ -92,6 +92,10 @@ using DefaultPersistentCheckingPolicy = EnabledCheckingPolicy;
using DefaultMemberCheckingPolicy = DisabledCheckingPolicy;
using DefaultPersistentCheckingPolicy = DisabledCheckingPolicy;
#endif
// For CT(W)P neither marking information (for value), nor objectstart bitmap
// (for slot) are guaranteed to be present because there's no synchonization
// between heaps after marking.
using DefaultCrossThreadPersistentCheckingPolicy = DisabledCheckingPolicy;
class KeepLocationPolicy {
public:
@ -154,7 +158,7 @@ struct WeakCrossThreadPersistentPolicy {
// Forward declarations setting up the default policies.
template <typename T, typename WeaknessPolicy,
typename LocationPolicy = DefaultLocationPolicy,
typename CheckingPolicy = DisabledCheckingPolicy>
typename CheckingPolicy = DefaultCrossThreadPersistentCheckingPolicy>
class BasicCrossThreadPersistent;
template <typename T, typename WeaknessPolicy,
typename LocationPolicy = DefaultLocationPolicy,

View File

@ -5,6 +5,9 @@
#ifndef INCLUDE_CPPGC_INTERNAL_WRITE_BARRIER_H_
#define INCLUDE_CPPGC_INTERNAL_WRITE_BARRIER_H_
#include <cstddef>
#include <cstdint>
#include "cppgc/heap-state.h"
#include "cppgc/internal/api-constants.h"
#include "cppgc/internal/atomic-entry-flag.h"
@ -22,8 +25,11 @@ class HeapHandle;
namespace internal {
#if defined(CPPGC_CAGED_HEAP)
class WriteBarrierTypeForCagedHeapPolicy;
#else // !CPPGC_CAGED_HEAP
class WriteBarrierTypeForNonCagedHeapPolicy;
#endif // !CPPGC_CAGED_HEAP
class V8_EXPORT WriteBarrier final {
public:

View File

@ -5,7 +5,7 @@
#ifndef INCLUDE_CPPGC_MACROS_H_
#define INCLUDE_CPPGC_MACROS_H_
#include <stddef.h>
#include <cstddef>
#include "cppgc/internal/compiler-specific.h"

View File

@ -226,20 +226,20 @@ class BasicMember final : private MemberBase, private CheckingPolicy {
template <typename T1, typename WeaknessTag1, typename WriteBarrierPolicy1,
typename CheckingPolicy1, typename T2, typename WeaknessTag2,
typename WriteBarrierPolicy2, typename CheckingPolicy2>
bool operator==(
BasicMember<T1, WeaknessTag1, WriteBarrierPolicy1, CheckingPolicy1> member1,
BasicMember<T2, WeaknessTag2, WriteBarrierPolicy2, CheckingPolicy2>
member2) {
bool operator==(const BasicMember<T1, WeaknessTag1, WriteBarrierPolicy1,
CheckingPolicy1>& member1,
const BasicMember<T2, WeaknessTag2, WriteBarrierPolicy2,
CheckingPolicy2>& member2) {
return member1.Get() == member2.Get();
}
template <typename T1, typename WeaknessTag1, typename WriteBarrierPolicy1,
typename CheckingPolicy1, typename T2, typename WeaknessTag2,
typename WriteBarrierPolicy2, typename CheckingPolicy2>
bool operator!=(
BasicMember<T1, WeaknessTag1, WriteBarrierPolicy1, CheckingPolicy1> member1,
BasicMember<T2, WeaknessTag2, WriteBarrierPolicy2, CheckingPolicy2>
member2) {
bool operator!=(const BasicMember<T1, WeaknessTag1, WriteBarrierPolicy1,
CheckingPolicy1>& member1,
const BasicMember<T2, WeaknessTag2, WriteBarrierPolicy2,
CheckingPolicy2>& member2) {
return !(member1 == member2);
}

View File

@ -57,7 +57,7 @@ class V8_EXPORT NameProvider {
*
* @returns a human readable name for the object.
*/
virtual const char* GetName() const = 0;
virtual const char* GetHumanReadableName() const = 0;
};
} // namespace cppgc

View File

@ -141,7 +141,7 @@ class BasicPersistent final : public PersistentBase,
}
// Move assignment.
BasicPersistent& operator=(BasicPersistent&& other) {
BasicPersistent& operator=(BasicPersistent&& other) noexcept {
if (this == &other) return *this;
Clear();
PersistentBase::operator=(std::move(other));

View File

@ -5,6 +5,8 @@
#ifndef INCLUDE_CPPGC_PLATFORM_H_
#define INCLUDE_CPPGC_PLATFORM_H_
#include <memory>
#include "v8-platform.h" // NOLINT(build/include_directory)
#include "v8config.h" // NOLINT(build/include_directory)

View File

@ -5,6 +5,7 @@
#ifndef INCLUDE_CPPGC_SOURCE_LOCATION_H_
#define INCLUDE_CPPGC_SOURCE_LOCATION_H_
#include <cstddef>
#include <string>
#include "v8config.h" // NOLINT(build/include_directory)

View File

@ -175,7 +175,7 @@ domain Debugger
command enable
parameters
# The maximum size in bytes of collected scripts (not referenced by other heap objects)
# the debugger can hold. Puts no limit if paramter is omitted.
# the debugger can hold. Puts no limit if parameter is omitted.
experimental optional number maxScriptsCacheSize
returns
# Unique identifier of the debugger.
@ -714,7 +714,7 @@ experimental domain HeapProfiler
parameters
# If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken.
optional boolean reportProgress
# If true, a raw snapshot without artifical roots will be generated
# If true, a raw snapshot without artificial roots will be generated
optional boolean treatGlobalObjectsAsRoots
# If true, numerical values are included in the snapshot
optional boolean captureNumericValue
@ -972,13 +972,13 @@ domain Profiler
# Reports coverage delta since the last poll (either from an event like this, or from
# `takePreciseCoverage` for the current isolate. May only be sent if precise code
# coverage has been started. This event can be trigged by the embedder to, for example,
# trigger collection of coverage data immediatelly at a certain point in time.
# trigger collection of coverage data immediately at a certain point in time.
experimental event preciseCoverageDeltaUpdate
parameters
# Monotonically increasing time (in seconds) when the coverage update was taken in the backend.
number timestamp
# Identifier for distinguishing coverage events.
string occassion
string occasion
# Coverage data for the current isolate.
array of ScriptCoverage result
@ -1225,7 +1225,7 @@ domain Runtime
string origin
# Human readable name describing given context.
string name
# A system-unique execution context identifier. Unlike the id, this is unique accross
# A system-unique execution context identifier. Unlike the id, this is unique across
# multiple processes, so can be reliably used to identify specific context while backend
# performs a cross-process navigation.
experimental string uniqueId
@ -1254,6 +1254,10 @@ domain Runtime
optional RemoteObject exception
# Identifier of the context where exception happened.
optional ExecutionContextId executionContextId
# Dictionary with entries of meta data that the client associated
# with this exception, such as information about associated network
# requests, etc.
experimental optional object exceptionMetaData
# Number of milliseconds since epoch.
type Timestamp extends number
@ -1343,6 +1347,8 @@ domain Runtime
# Symbolic group name that can be used to release multiple objects. If objectGroup is not
# specified and objectId is, objectGroup will be inherited from object.
optional string objectGroup
# Whether to throw an exception if side effect cannot be ruled out during evaluation.
experimental optional boolean throwOnSideEffect
returns
# Call result.
RemoteObject result
@ -1422,9 +1428,9 @@ domain Runtime
# evaluation and allows unsafe-eval. Defaults to true.
experimental optional boolean allowUnsafeEvalBlockedByCSP
# An alternative way to specify the execution context to evaluate in.
# Compared to contextId that may be reused accross processes, this is guaranteed to be
# Compared to contextId that may be reused across processes, this is guaranteed to be
# system-unique, so it can be used to prevent accidental evaluation of the expression
# in context different than intended (e.g. as a result of navigation accross process
# in context different than intended (e.g. as a result of navigation across process
# boundaries).
# This is mutually exclusive with `contextId`.
experimental optional string uniqueContextId

View File

@ -156,6 +156,7 @@
* - float64_t
* Currently supported argument types:
* - pointer to an embedder type
* - JavaScript array of primitive types
* - bool
* - int32_t
* - uint32_t
@ -176,8 +177,43 @@
* passes NaN values as-is, i.e. doesn't normalize them.
*
* To be supported types:
* - arrays of C types
* - TypedArrays and ArrayBuffers
* - arrays of embedder types
*
*
* The API offers a limited support for function overloads:
*
* \code
* void FastMethod_2Args(int param, bool another_param);
* void FastMethod_3Args(int param, bool another_param, int third_param);
*
* v8::CFunction fast_method_2args_c_func =
* MakeV8CFunction(FastMethod_2Args);
* v8::CFunction fast_method_3args_c_func =
* MakeV8CFunction(FastMethod_3Args);
* const v8::CFunction fast_method_overloads[] = {fast_method_2args_c_func,
* fast_method_3args_c_func};
* Local<v8::FunctionTemplate> method_template =
* v8::FunctionTemplate::NewWithCFunctionOverloads(
* isolate, SlowCallback, data, signature, length,
* constructor_behavior, side_effect_type,
* {fast_method_overloads, 2});
* \endcode
*
* In this example a single FunctionTemplate is associated to multiple C++
* functions. The overload resolution is currently only based on the number of
* arguments passed in a call. For example, if this method_template is
* registered with a wrapper JS object as described above, a call with two
* arguments:
* obj.method(42, true);
* will result in a fast call to FastMethod_2Args, while a call with three or
* more arguments:
* obj.method(42, true, 11);
* will result in a fast call to FastMethod_3Args. Instead a call with less than
* two arguments, like:
* obj.method(42);
* would not result in a fast call but would fall back to executing the
* associated SlowCallback.
*/
#ifndef INCLUDE_V8_FAST_API_CALLS_H_
@ -217,22 +253,73 @@ class CTypeInfo {
// than any valid Type enum.
static constexpr Type kCallbackOptionsType = Type(255);
enum class Flags : uint8_t {
kNone = 0,
enum class SequenceType : uint8_t {
kScalar,
kIsSequence, // sequence<T>
kIsTypedArray, // TypedArray of T or any ArrayBufferView if T
// is void
kIsArrayBuffer // ArrayBuffer
};
explicit constexpr CTypeInfo(Type type, Flags flags = Flags::kNone)
: type_(type), flags_(flags) {}
enum class Flags : uint8_t {
kNone = 0,
kAllowSharedBit = 1 << 0, // Must be an ArrayBuffer or TypedArray
kEnforceRangeBit = 1 << 1, // T must be integral
kClampBit = 1 << 2, // T must be integral
kIsRestrictedBit = 1 << 3, // T must be float or double
};
explicit constexpr CTypeInfo(
Type type, SequenceType sequence_type = SequenceType::kScalar,
Flags flags = Flags::kNone)
: type_(type), sequence_type_(sequence_type), flags_(flags) {}
constexpr Type GetType() const { return type_; }
constexpr SequenceType GetSequenceType() const { return sequence_type_; }
constexpr Flags GetFlags() const { return flags_; }
static constexpr bool IsIntegralType(Type type) {
return type == Type::kInt32 || type == Type::kUint32 ||
type == Type::kInt64 || type == Type::kUint64;
}
static constexpr bool IsFloatingPointType(Type type) {
return type == Type::kFloat32 || type == Type::kFloat64;
}
static constexpr bool IsPrimitive(Type type) {
return IsIntegralType(type) || IsFloatingPointType(type) ||
type == Type::kBool;
}
private:
Type type_;
SequenceType sequence_type_;
Flags flags_;
};
template <typename T>
struct FastApiTypedArray {
T* data; // should include the typed array offset applied
size_t length; // length in number of elements
};
// Any TypedArray. It uses kTypedArrayBit with base type void
// Overloaded args of ArrayBufferView and TypedArray are not supported
// (for now) because the generic “any” ArrayBufferView doesnt have its
// own instance type. It could be supported if we specify that
// TypedArray<T> always has precedence over the generic ArrayBufferView,
// but this complicates overload resolution.
struct FastApiArrayBufferView {
void* data;
size_t byte_length;
};
struct FastApiArrayBuffer {
void* data;
size_t byte_length;
};
class V8_EXPORT CFunctionInfo {
public:
// Construct a struct to hold a CFunction's type information.
@ -284,6 +371,42 @@ class V8_EXPORT CFunction {
const void* GetAddress() const { return address_; }
const CFunctionInfo* GetTypeInfo() const { return type_info_; }
enum class OverloadResolution { kImpossible, kAtRuntime, kAtCompileTime };
// Returns whether an overload between this and the given CFunction can
// be resolved at runtime by the RTTI available for the arguments or at
// compile time for functions with different number of arguments.
OverloadResolution GetOverloadResolution(const CFunction* other) {
// Runtime overload resolution can only deal with functions with the
// same number of arguments. Functions with different arity are handled
// by compile time overload resolution though.
if (ArgumentCount() != other->ArgumentCount()) {
return OverloadResolution::kAtCompileTime;
}
// The functions can only differ by a single argument position.
int diff_index = -1;
for (unsigned int i = 0; i < ArgumentCount(); ++i) {
if (ArgumentInfo(i).GetSequenceType() !=
other->ArgumentInfo(i).GetSequenceType()) {
if (diff_index >= 0) {
return OverloadResolution::kImpossible;
}
diff_index = i;
// We only support overload resolution between sequence types.
if (ArgumentInfo(i).GetSequenceType() ==
CTypeInfo::SequenceType::kScalar ||
other->ArgumentInfo(i).GetSequenceType() ==
CTypeInfo::SequenceType::kScalar) {
return OverloadResolution::kImpossible;
}
}
}
return OverloadResolution::kAtRuntime;
}
template <typename F>
static CFunction Make(F* func) {
return ArgUnwrap<F*>::Make(func);
@ -314,7 +437,7 @@ class V8_EXPORT CFunction {
};
};
struct ApiObject {
struct V8_DEPRECATE_SOON("Use v8::Local<v8::Value> instead.") ApiObject {
uintptr_t address;
};
@ -412,28 +535,91 @@ struct TypeInfoHelper {
} \
\
static constexpr CTypeInfo::Type Type() { return CTypeInfo::Type::Enum; } \
static constexpr CTypeInfo::SequenceType SequenceType() { \
return CTypeInfo::SequenceType::kScalar; \
} \
};
#define BASIC_C_TYPES(V) \
V(void, kVoid) \
V(bool, kBool) \
V(int32_t, kInt32) \
V(uint32_t, kUint32) \
V(int64_t, kInt64) \
V(uint64_t, kUint64) \
V(float, kFloat32) \
V(double, kFloat64) \
V(ApiObject, kApiObject) \
V(v8::Local<v8::Value>, kV8Value) \
V(v8::Local<v8::Object>, kV8Value)
template <CTypeInfo::Type type>
struct CTypeInfoTraits {};
#define DEFINE_TYPE_INFO_TRAITS(CType, Enum) \
template <> \
struct CTypeInfoTraits<CTypeInfo::Type::Enum> { \
using ctype = CType; \
};
#define PRIMITIVE_C_TYPES(V) \
V(bool, kBool) \
V(int32_t, kInt32) \
V(uint32_t, kUint32) \
V(int64_t, kInt64) \
V(uint64_t, kUint64) \
V(float, kFloat32) \
V(double, kFloat64)
// Same as above, but includes deprecated types for compatibility.
#define ALL_C_TYPES(V) \
PRIMITIVE_C_TYPES(V) \
V(void, kVoid) \
V(v8::Local<v8::Value>, kV8Value) \
V(v8::Local<v8::Object>, kV8Value) \
V(ApiObject, kApiObject)
// ApiObject was a temporary solution to wrap the pointer to the v8::Value.
// Please use v8::Local<v8::Value> in new code for the arguments and
// v8::Local<v8::Object> for the receiver, as ApiObject will be deprecated.
BASIC_C_TYPES(SPECIALIZE_GET_TYPE_INFO_HELPER_FOR)
ALL_C_TYPES(SPECIALIZE_GET_TYPE_INFO_HELPER_FOR)
PRIMITIVE_C_TYPES(DEFINE_TYPE_INFO_TRAITS)
#undef BASIC_C_TYPES
#undef PRIMITIVE_C_TYPES
#undef ALL_C_TYPES
#define SPECIALIZE_GET_TYPE_INFO_HELPER_FOR_TA(T, Enum) \
template <> \
struct TypeInfoHelper<FastApiTypedArray<T>> { \
static constexpr CTypeInfo::Flags Flags() { \
return CTypeInfo::Flags::kNone; \
} \
\
static constexpr CTypeInfo::Type Type() { return CTypeInfo::Type::Enum; } \
static constexpr CTypeInfo::SequenceType SequenceType() { \
return CTypeInfo::SequenceType::kIsTypedArray; \
} \
};
#define TYPED_ARRAY_C_TYPES(V) \
V(int32_t, kInt32) \
V(uint32_t, kUint32) \
V(int64_t, kInt64) \
V(uint64_t, kUint64) \
V(float, kFloat32) \
V(double, kFloat64)
TYPED_ARRAY_C_TYPES(SPECIALIZE_GET_TYPE_INFO_HELPER_FOR_TA)
#undef TYPED_ARRAY_C_TYPES
template <>
struct TypeInfoHelper<v8::Local<v8::Array>> {
static constexpr CTypeInfo::Flags Flags() { return CTypeInfo::Flags::kNone; }
static constexpr CTypeInfo::Type Type() { return CTypeInfo::Type::kVoid; }
static constexpr CTypeInfo::SequenceType SequenceType() {
return CTypeInfo::SequenceType::kIsSequence;
}
};
template <>
struct TypeInfoHelper<v8::Local<v8::Uint32Array>> {
static constexpr CTypeInfo::Flags Flags() { return CTypeInfo::Flags::kNone; }
static constexpr CTypeInfo::Type Type() { return CTypeInfo::Type::kUint32; }
static constexpr CTypeInfo::SequenceType SequenceType() {
return CTypeInfo::SequenceType::kIsTypedArray;
}
};
template <>
struct TypeInfoHelper<FastApiCallbackOptions&> {
@ -442,26 +628,63 @@ struct TypeInfoHelper<FastApiCallbackOptions&> {
static constexpr CTypeInfo::Type Type() {
return CTypeInfo::kCallbackOptionsType;
}
static constexpr CTypeInfo::SequenceType SequenceType() {
return CTypeInfo::SequenceType::kScalar;
}
};
#define STATIC_ASSERT_IMPLIES(COND, ASSERTION, MSG) \
static_assert(((COND) == 0) || (ASSERTION), MSG)
template <typename T, CTypeInfo::Flags... Flags>
class CTypeInfoBuilder {
public:
using BaseType = T;
static constexpr CTypeInfo Build() {
// Get the flags and merge in any additional flags.
uint8_t flags = uint8_t(TypeInfoHelper<T>::Flags());
int unused[] = {0, (flags |= uint8_t(Flags), 0)...};
// With C++17, we could use a "..." fold expression over a parameter pack.
// Since we're still using C++14, we have to evaluate an OR expresion while
// constructing an unused list of 0's. This applies the binary operator
// for each value in Flags.
(void)unused;
constexpr CTypeInfo::Flags kFlags =
MergeFlags(TypeInfoHelper<T>::Flags(), Flags...);
constexpr CTypeInfo::Type kType = TypeInfoHelper<T>::Type();
constexpr CTypeInfo::SequenceType kSequenceType =
TypeInfoHelper<T>::SequenceType();
STATIC_ASSERT_IMPLIES(
uint8_t(kFlags) & uint8_t(CTypeInfo::Flags::kAllowSharedBit),
(kSequenceType == CTypeInfo::SequenceType::kIsTypedArray ||
kSequenceType == CTypeInfo::SequenceType::kIsArrayBuffer),
"kAllowSharedBit is only allowed for TypedArrays and ArrayBuffers.");
STATIC_ASSERT_IMPLIES(
uint8_t(kFlags) & uint8_t(CTypeInfo::Flags::kEnforceRangeBit),
CTypeInfo::IsIntegralType(kType),
"kEnforceRangeBit is only allowed for integral types.");
STATIC_ASSERT_IMPLIES(
uint8_t(kFlags) & uint8_t(CTypeInfo::Flags::kClampBit),
CTypeInfo::IsIntegralType(kType),
"kClampBit is only allowed for integral types.");
STATIC_ASSERT_IMPLIES(
uint8_t(kFlags) & uint8_t(CTypeInfo::Flags::kIsRestrictedBit),
CTypeInfo::IsFloatingPointType(kType),
"kIsRestrictedBit is only allowed for floating point types.");
STATIC_ASSERT_IMPLIES(kSequenceType == CTypeInfo::SequenceType::kIsSequence,
kType == CTypeInfo::Type::kVoid,
"Sequences are only supported from void type.");
STATIC_ASSERT_IMPLIES(
kSequenceType == CTypeInfo::SequenceType::kIsTypedArray,
CTypeInfo::IsPrimitive(kType) || kType == CTypeInfo::Type::kVoid,
"TypedArrays are only supported from primitive types or void.");
// Return the same type with the merged flags.
return CTypeInfo(TypeInfoHelper<T>::Type(), CTypeInfo::Flags(flags));
return CTypeInfo(TypeInfoHelper<T>::Type(),
TypeInfoHelper<T>::SequenceType(), kFlags);
}
private:
template <typename... Rest>
static constexpr CTypeInfo::Flags MergeFlags(CTypeInfo::Flags flags,
Rest... rest) {
return CTypeInfo::Flags(uint8_t(flags) | uint8_t(MergeFlags(rest...)));
}
static constexpr CTypeInfo::Flags MergeFlags() { return CTypeInfo::Flags(0); }
};
template <typename RetBuilder, typename... ArgBuilders>
@ -513,8 +736,9 @@ class CFunctionBuilderWithFunction {
Flags...>;
};
// Return a copy of the CFunctionBuilder, but merges the Flags on ArgBuilder
// index N with the new Flags passed in the template parameter pack.
// Return a copy of the CFunctionBuilder, but merges the Flags on
// ArgBuilder index N with the new Flags passed in the template parameter
// pack.
template <unsigned int N, CTypeInfo::Flags... Flags, size_t... I>
constexpr auto ArgImpl(std::index_sequence<I...>) {
return CFunctionBuilderWithFunction<
@ -546,6 +770,22 @@ CFunction CFunction::ArgUnwrap<R (*)(Args...)>::Make(R (*func)(Args...)) {
using CFunctionBuilder = internal::CFunctionBuilder;
/**
* Copies the contents of this JavaScript array to a C++ buffer with
* a given max_length. A CTypeInfo is passed as an argument,
* instructing different rules for conversion (e.g. restricted float/double).
* The element type T of the destination array must match the C type
* corresponding to the CTypeInfo (specified by CTypeInfoTraits).
* If the array length is larger than max_length or the array is of
* unsupported type, the operation will fail, returning false. Generally, an
* array which contains objects, undefined, null or anything not convertible
* to the requested destination type, is considered unsupported. The operation
* returns true on success. `type_info` will be used for conversions.
*/
template <const CTypeInfo* type_info, typename T>
bool CopyAndConvertArrayToCppBuffer(Local<Array> src, T* dst,
uint32_t max_length);
} // namespace v8
#endif // INCLUDE_V8_FAST_API_CALLS_H_

View File

@ -170,7 +170,7 @@ class V8_EXPORT V8InspectorSession {
v8::Local<v8::Context>*,
std::unique_ptr<StringBuffer>* objectGroup) = 0;
virtual void releaseObjectGroup(StringView) = 0;
virtual void triggerPreciseCoverageDeltaUpdate(StringView occassion) = 0;
virtual void triggerPreciseCoverageDeltaUpdate(StringView occasion) = 0;
};
class V8_EXPORT V8InspectorClient {
@ -301,6 +301,10 @@ class V8_EXPORT V8Inspector {
int scriptId) = 0;
virtual void exceptionRevoked(v8::Local<v8::Context>, unsigned exceptionId,
StringView message) = 0;
virtual bool associateExceptionData(v8::Local<v8::Context>,
v8::Local<v8::Value> exception,
v8::Local<v8::Name> key,
v8::Local<v8::Value> value) = 0;
// Connection.
class V8_EXPORT Channel {

View File

@ -146,6 +146,7 @@ enum ExternalPointerTag : uint64_t {
kForeignForeignAddressTag = 0x01f7000000000000, // 0b000000111110111
kNativeContextMicrotaskQueueTag = 0x01fb000000000000, // 0b000000111111011
kEmbedderDataSlotPayloadTag = 0x01fd000000000000, // 0b000000111111101
kCodeEntryPointTag = 0x01fe000000000000, // 0b000000111111110
};
constexpr uint64_t kExternalPointerTagMask = 0xffff000000000000;

View File

@ -50,11 +50,19 @@ struct GarbageCollectionFullMainThreadIncrementalMark {
int64_t cpp_wall_clock_duration_in_us = -1;
};
struct GarbageCollectionFullMainThreadBatchedIncrementalMark {
std::vector<GarbageCollectionFullMainThreadIncrementalMark> events;
};
struct GarbageCollectionFullMainThreadIncrementalSweep {
int64_t wall_clock_duration_in_us = -1;
int64_t cpp_wall_clock_duration_in_us = -1;
};
struct GarbageCollectionFullMainThreadBatchedIncrementalSweep {
std::vector<GarbageCollectionFullMainThreadIncrementalSweep> events;
};
struct GarbageCollectionYoungCycle {
int64_t total_wall_clock_duration_in_us = -1;
int64_t main_thread_wall_clock_duration_in_us = -1;
@ -70,6 +78,7 @@ struct WasmModuleDecoded {
size_t module_size_in_bytes = 0;
size_t function_count = 0;
int64_t wall_clock_duration_in_us = -1;
int64_t cpu_duration_in_us = -1;
};
struct WasmModuleCompiled {
@ -82,6 +91,7 @@ struct WasmModuleCompiled {
size_t code_size_in_bytes = 0;
size_t liftoff_bailout_count = 0;
int64_t wall_clock_duration_in_us = -1;
int64_t cpu_duration_in_us = -1;
};
struct WasmModuleInstantiated {
@ -95,20 +105,23 @@ struct WasmModuleTieredUp {
bool lazy = false;
size_t code_size_in_bytes = 0;
int64_t wall_clock_duration_in_us = -1;
int64_t cpu_duration_in_us = -1;
};
struct WasmModulesPerIsolate {
size_t count = 0;
};
#define V8_MAIN_THREAD_METRICS_EVENTS(V) \
V(GarbageCollectionFullCycle) \
V(GarbageCollectionFullMainThreadIncrementalMark) \
V(GarbageCollectionFullMainThreadIncrementalSweep) \
V(GarbageCollectionYoungCycle) \
V(WasmModuleDecoded) \
V(WasmModuleCompiled) \
V(WasmModuleInstantiated) \
#define V8_MAIN_THREAD_METRICS_EVENTS(V) \
V(GarbageCollectionFullCycle) \
V(GarbageCollectionFullMainThreadIncrementalMark) \
V(GarbageCollectionFullMainThreadBatchedIncrementalMark) \
V(GarbageCollectionFullMainThreadIncrementalSweep) \
V(GarbageCollectionFullMainThreadBatchedIncrementalSweep) \
V(GarbageCollectionYoungCycle) \
V(WasmModuleDecoded) \
V(WasmModuleCompiled) \
V(WasmModuleInstantiated) \
V(WasmModuleTieredUp)
#define V8_THREAD_SAFE_METRICS_EVENTS(V) V(WasmModulesPerIsolate)

View File

@ -9,9 +9,9 @@
// NOTE these macros are used by some of the tool scripts and the build
// system so their names cannot be changed without changing the scripts.
#define V8_MAJOR_VERSION 9
#define V8_MINOR_VERSION 2
#define V8_BUILD_NUMBER 230
#define V8_PATCH_LEVEL 21
#define V8_MINOR_VERSION 3
#define V8_BUILD_NUMBER 345
#define V8_PATCH_LEVEL 16
// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)

64
deps/v8/include/v8.h vendored
View File

@ -50,6 +50,7 @@ class CFunction;
class CallHandlerHelper;
class Context;
class CppHeap;
class CTypeInfo;
class Data;
class Date;
class EscapableHandleScope;
@ -885,6 +886,8 @@ class TracedReferenceBase {
std::memory_order_relaxed);
}
V8_EXPORT void CheckValue() const;
// val_ points to a GlobalHandles node.
internal::Address* val_ = nullptr;
@ -926,8 +929,18 @@ class BasicTracedReference : public TracedReferenceBase {
const_cast<BasicTracedReference<T>&>(*this));
}
T* operator->() const { return reinterpret_cast<T*>(val_); }
T* operator*() const { return reinterpret_cast<T*>(val_); }
T* operator->() const {
#ifdef V8_ENABLE_CHECKS
CheckValue();
#endif // V8_ENABLE_CHECKS
return reinterpret_cast<T*>(val_);
}
T* operator*() const {
#ifdef V8_ENABLE_CHECKS
CheckValue();
#endif // V8_ENABLE_CHECKS
return reinterpret_cast<T*>(val_);
}
private:
enum DestructionMode { kWithDestructor, kWithoutDestructor };
@ -1427,9 +1440,7 @@ class ScriptOriginOptions {
*/
class ScriptOrigin {
public:
#if defined(_MSC_VER) && _MSC_VER >= 1910 /* Disable on VS2015 */
V8_DEPRECATE_SOON("Use constructor with primitive C++ types")
#endif
V8_INLINE explicit ScriptOrigin(
Local<Value> resource_name, Local<Integer> resource_line_offset,
Local<Integer> resource_column_offset,
@ -1440,9 +1451,7 @@ class ScriptOrigin {
Local<Boolean> is_wasm = Local<Boolean>(),
Local<Boolean> is_module = Local<Boolean>(),
Local<PrimitiveArray> host_defined_options = Local<PrimitiveArray>());
#if defined(_MSC_VER) && _MSC_VER >= 1910 /* Disable on VS2015 */
V8_DEPRECATE_SOON("Use constructor that takes an isolate")
#endif
V8_INLINE explicit ScriptOrigin(
Local<Value> resource_name, int resource_line_offset = 0,
int resource_column_offset = 0,
@ -1653,7 +1662,7 @@ class V8_EXPORT Module : public Data {
*/
int GetIdentityHash() const;
using ResolveCallback =
using ResolveCallback V8_DEPRECATE_SOON("Use ResolveModuleCallback") =
MaybeLocal<Module> (*)(Local<Context> context, Local<String> specifier,
Local<Module> referrer);
using ResolveModuleCallback = MaybeLocal<Module> (*)(
@ -1944,11 +1953,9 @@ class V8_EXPORT ScriptCompiler {
public:
enum Encoding { ONE_BYTE, TWO_BYTE, UTF8, WINDOWS_1252 };
#if defined(_MSC_VER) && _MSC_VER >= 1910 /* Disable on VS2015 */
V8_DEPRECATED(
"This class takes ownership of source_stream, so use the constructor "
"taking a unique_ptr to make these semantics clearer")
#endif
StreamedSource(ExternalSourceStream* source_stream, Encoding encoding);
StreamedSource(std::unique_ptr<ExternalSourceStream> source_stream,
Encoding encoding);
@ -4425,6 +4432,7 @@ class V8_EXPORT Array : public Object {
static Local<Array> New(Isolate* isolate, Local<Value>* elements,
size_t length);
V8_INLINE static Array* Cast(Value* obj);
private:
Array();
static void CheckCast(Value* obj);
@ -4900,6 +4908,12 @@ class V8_EXPORT Promise : public Object {
*/
void MarkAsHandled();
/**
* Marks this promise as silent to prevent pausing the debugger when the
* promise is rejected.
*/
void MarkAsSilent();
V8_INLINE static Promise* Cast(Value* obj);
static const int kEmbedderFieldCount = V8_PROMISE_INTERNAL_FIELD_COUNT;
@ -6073,7 +6087,8 @@ class V8_EXPORT Template : public Data {
PropertyAttribute attributes = None);
void SetPrivate(Local<Private> name, Local<Data> value,
PropertyAttribute attributes = None);
V8_INLINE void Set(Isolate* isolate, const char* name, Local<Data> value);
V8_INLINE void Set(Isolate* isolate, const char* name, Local<Data> value,
PropertyAttribute attributes = None);
void SetAccessorProperty(
Local<Name> name,
@ -6503,7 +6518,9 @@ class V8_EXPORT FunctionTemplate : public Template {
Local<Signature> signature = Local<Signature>(), int length = 0,
ConstructorBehavior behavior = ConstructorBehavior::kAllow,
SideEffectType side_effect_type = SideEffectType::kHasSideEffect,
const CFunction* c_function = nullptr);
const CFunction* c_function = nullptr, uint8_t instance_type = 0,
uint8_t allowed_receiver_range_start = 0,
uint8_t allowed_receiver_range_end = 0);
/** Creates a function template for multiple overloaded fast API calls.*/
static Local<FunctionTemplate> NewWithCFunctionOverloads(
@ -7299,7 +7316,8 @@ using CallCompletedCallback = void (*)(Isolate*);
* fails (e.g. due to stack overflow), the embedder must propagate
* that exception by returning an empty MaybeLocal.
*/
using HostImportModuleDynamicallyCallback =
using HostImportModuleDynamicallyCallback V8_DEPRECATE_SOON(
"Use HostImportModuleDynamicallyWithImportAssertionsCallback instead") =
MaybeLocal<Promise> (*)(Local<Context> context,
Local<ScriptOrModule> referrer,
Local<String> specifier);
@ -8547,7 +8565,7 @@ class V8_EXPORT Isolate {
kDateToLocaleTimeString = 68,
kAttemptOverrideReadOnlyOnPrototypeSloppy = 69,
kAttemptOverrideReadOnlyOnPrototypeStrict = 70,
kOptimizedFunctionWithOneShotBytecode = 71,
kOptimizedFunctionWithOneShotBytecode = 71, // Unused.
kRegExpMatchIsTrueishOnNonJSRegExp = 72,
kRegExpMatchIsFalseishOnJSRegExp = 73,
kDateGetTimezoneOffset = 74, // Unused.
@ -8649,6 +8667,14 @@ class V8_EXPORT Isolate {
*/
static Isolate* GetCurrent();
/**
* Returns the entered isolate for the current thread or NULL in
* case there is no current isolate.
*
* No checks are performed by this method.
*/
static Isolate* TryGetCurrent();
/**
* Clears the set of objects held strongly by the heap. This set of
* objects are originally built when a WeakRef is created or
@ -8715,6 +8741,13 @@ class V8_EXPORT Isolate {
*/
void MemoryPressureNotification(MemoryPressureLevel level);
/**
* Drop non-essential caches. Should only be called from testing code.
* The method can potentially block for a long time and does not necessarily
* trigger GC.
*/
void ClearCachesForTesting();
/**
* Methods below this point require holding a lock (using Locker) in
* a multi-threaded environment.
@ -11585,10 +11618,11 @@ Local<Boolean> Boolean::New(Isolate* isolate, bool value) {
return value ? True(isolate) : False(isolate);
}
void Template::Set(Isolate* isolate, const char* name, Local<Data> value) {
void Template::Set(Isolate* isolate, const char* name, Local<Data> value,
PropertyAttribute attributes) {
Set(String::NewFromUtf8(isolate, name, NewStringType::kInternalized)
.ToLocalChecked(),
value);
value, attributes);
}
FunctionTemplate* FunctionTemplate::Cast(Data* data) {

View File

@ -62,8 +62,10 @@
'V8 Linux - verify csa': 'release_x86_verify_csa',
# Linux64.
'V8 Linux64 - builder': 'release_x64',
'V8 Linux64 - builder (reclient)': 'release_x64_reclient',
'V8 Linux64 - debug builder': 'debug_x64',
'V8 Linux64 - dict tracking - debug - builder': 'debug_x64_dict_tracking_trybot',
'V8 Linux64 - external code space - debug - builder': 'debug_x64_external_code_space',
'V8 Linux64 - custom snapshot - debug builder': 'debug_x64_custom',
'V8 Linux64 - heap sandbox - debug - builder': 'debug_x64_heap_sandbox',
'V8 Linux64 - internal snapshot': 'release_x64_internal',
@ -213,6 +215,7 @@
'release_simulate_arm64_pointer_compression',
'v8_linux64_dbg_ng': 'debug_x64_trybot',
'v8_linux64_dict_tracking_dbg_ng': 'debug_x64_dict_tracking_trybot',
'v8_linux64_external_code_space_dbg_ng': 'debug_x64_external_code_space',
'v8_linux64_gc_stress_custom_snapshot_dbg_ng': 'debug_x64_trybot_custom',
'v8_linux64_gcc_compile_dbg': 'debug_x64_gcc',
'v8_linux64_gcov_coverage': 'release_x64_gcc_coverage',
@ -475,8 +478,7 @@
'release_bot', 'x64', 'cfi_clusterfuzz'],
'release_x64_fuzzilli': [
'release_bot', 'x64', 'dcheck_always_on', 'v8_enable_slow_dchecks',
'v8_verify_heap', 'v8_verify_csa', 'v8_enable_verify_predictable',
'fuzzilli'],
'v8_verify_heap', 'v8_verify_csa', 'fuzzilli'],
'release_x64_msvc': [
'release_bot_no_goma', 'x64', 'minimal_symbols', 'msvc'],
'release_x64_correctness_fuzzer' : [
@ -499,6 +501,8 @@
'v8_disable_pointer_compression'],
'release_x64_pointer_compression_without_dchecks': [
'release_bot', 'x64', 'v8_disable_pointer_compression'],
'release_x64_reclient': [
'release_bot_reclient', 'x64'],
'release_x64_trybot': [
'release_trybot', 'x64'],
'release_x64_test_features_trybot': [
@ -537,6 +541,8 @@
'x64', 'asan'],
'debug_x64_custom': [
'debug_bot', 'x64', 'v8_snapshot_custom'],
'debug_x64_external_code_space': [
'debug_bot', 'x64', 'external_code_space'],
'debug_x64_fuchsia': [
'debug_bot', 'x64', 'fuchsia'],
'debug_x64_gcc': [
@ -692,6 +698,10 @@
'gn_args': 'chrome_pgo_phase=0',
},
'external_code_space': {
'gn_args': 'v8_enable_external_code_space=true',
},
'fuchsia': {
'gn_args': 'target_os="fuchsia"',
},
@ -764,6 +774,10 @@
'gn_args': 'v8_use_perfetto=true',
},
'reclient': {
'gn_args': 'use_rbe=true',
},
'release': {
'gn_args': 'is_debug=false',
},
@ -776,6 +790,10 @@
'mixins': ['release', 'static', 'no_goma'],
},
'release_bot_reclient': {
'mixins': ['release', 'static', 'no_goma', 'reclient'],
},
'release_trybot': {
'mixins': ['release_bot', 'minimal_symbols', 'dcheck_always_on'],
},

View File

@ -77,7 +77,7 @@
{'name': 'mozilla'},
{'name': 'mozilla', 'variant': 'extra'},
{'name': 'test262', 'variant': 'default', 'shards': 2},
{'name': 'test262', 'variant': 'extra', 'shards': 3},
{'name': 'test262', 'variant': 'extra', 'shards': 5},
{'name': 'v8testing', 'shards': 3},
{'name': 'v8testing', 'variant': 'extra', 'shards': 2},
# Noavx.
@ -347,7 +347,7 @@
{'name': 'mozilla'},
{'name': 'mozilla', 'variant': 'extra'},
{'name': 'test262', 'variant': 'default'},
{'name': 'test262', 'variant': 'extra', 'shards': 3},
{'name': 'test262', 'variant': 'extra', 'shards': 5},
{'name': 'v8testing', 'shards': 3},
{'name': 'v8testing', 'variant': 'extra', 'shards': 3},
{'name': 'v8testing', 'variant': 'minor_mc'},
@ -366,6 +366,15 @@
{'name': 'v8testing', 'shards': 3},
],
},
'v8_linux64_external_code_space_dbg_ng_triggered': {
'swarming_dimensions' : {
'cpu': 'x86-64-avx2',
'os': 'Ubuntu-18.04',
},
'tests': [
{'name': 'v8testing', 'shards': 3},
],
},
'v8_linux64_fuzzilli_ng_triggered': {
'swarming_dimensions' : {
'os': 'Ubuntu-18.04',
@ -504,13 +513,13 @@
'os': 'Ubuntu-18.04',
},
'tests': [
{'name': 'benchmarks'},
{'name': 'mozilla'},
{'name': 'test262', 'variant': 'default', 'shards': 3},
{'name': 'v8testing', 'shards': 5},
{'name': 'v8testing', 'variant': 'extra', 'shards': 3},
{'name': 'v8testing', 'variant': 'slow_path'},
{'name': 'v8testing', 'variant': 'stress_concurrent_allocation'},
{'name': 'benchmarks', 'shards': 2},
{'name': 'mozilla', 'shards': 2},
{'name': 'test262', 'variant': 'default', 'shards': 5},
{'name': 'v8testing', 'shards': 6},
{'name': 'v8testing', 'variant': 'extra', 'shards': 5},
{'name': 'v8testing', 'variant': 'slow_path', 'shards': 2},
{'name': 'v8testing', 'variant': 'stress_concurrent_allocation', 'shards': 2},
],
},
'v8_linux64_tsan_no_cm_rel_ng_triggered': {
@ -528,7 +537,7 @@
'test_args': ['--extra-flags=--future'],
'shards': 6,
},
{'name': 'v8testing', 'variant': 'stress_concurrent_inlining'},
{'name': 'v8testing', 'variant': 'stress_concurrent_inlining', 'shards': 2},
],
},
'v8_linux64_tsan_isolates_rel_ng_triggered': {
@ -752,7 +761,7 @@
'swarming_dimensions' : {
'cpu': 'arm64',
'os': 'Mac-11',
'pool': 'chromium.tests.mac-arm64',
'pool': 'chromium.tests',
},
'tests': [
{'name': 'v8testing'},
@ -762,7 +771,7 @@
'swarming_dimensions' : {
'cpu': 'arm64',
'os': 'Mac-11',
'pool': 'chromium.tests.mac-arm64',
'pool': 'chromium.tests',
},
'tests': [
{'name': 'v8testing'},
@ -772,7 +781,7 @@
'swarming_dimensions' : {
'cpu': 'arm64',
'os': 'Mac-11',
'pool': 'chromium.tests.mac-arm64',
'pool': 'chromium.tests',
},
'tests': [
{'name': 'v8testing'},
@ -935,7 +944,7 @@
{'name': 'optimize_for_size'},
{'name': 'test262', 'shards': 6},
{'name': 'test262', 'variant': 'code_serializer', 'shards': 2},
{'name': 'test262', 'variant': 'extra', 'shards': 3},
{'name': 'test262', 'variant': 'extra', 'shards': 5},
{'name': 'v8testing', 'shards': 3},
{
'name': 'v8testing',
@ -1023,7 +1032,7 @@
'os': 'Ubuntu-18.04',
},
'tests': [
{'name': 'v8testing', 'variant': 'default', 'shards': 4},
{'name': 'v8testing', 'variant': 'default', 'shards': 6},
],
},
'V8 Linux - gc stress': {
@ -1168,7 +1177,7 @@
{'name': 'mozilla', 'variant': 'extra'},
{'name': 'optimize_for_size'},
{'name': 'test262', 'shards': 5},
{'name': 'test262', 'variant': 'extra', 'shards': 3},
{'name': 'test262', 'variant': 'extra', 'shards': 5},
{'name': 'v8testing', 'shards': 2},
{'name': 'v8testing', 'variant': 'extra', 'shards': 2},
{'name': 'v8testing', 'variant': 'minor_mc'},
@ -1252,6 +1261,15 @@
{'name': 'v8testing', 'shards': 3},
],
},
'V8 Linux64 - external code space - debug': {
'swarming_dimensions' : {
'cpu': 'x86-64-avx2',
'os': 'Ubuntu-18.04',
},
'tests': [
{'name': 'v8testing', 'shards': 3},
],
},
'V8 Linux64 - fyi': {
'swarming_dimensions' : {
'os': 'Ubuntu-18.04',
@ -1350,13 +1368,13 @@
'os': 'Ubuntu-18.04',
},
'tests': [
{'name': 'benchmarks'},
{'name': 'mozilla'},
{'name': 'test262', 'variant': 'default', 'shards': 3},
{'name': 'v8testing', 'shards': 5},
{'name': 'v8testing', 'variant': 'extra', 'shards': 3},
{'name': 'v8testing', 'variant': 'slow_path', 'shards': 1},
{'name': 'v8testing', 'variant': 'stress_concurrent_allocation', 'shards': 1},
{'name': 'benchmarks', 'shards': 2},
{'name': 'mozilla', 'shards': 2},
{'name': 'test262', 'variant': 'default', 'shards': 5},
{'name': 'v8testing', 'shards': 6},
{'name': 'v8testing', 'variant': 'extra', 'shards': 5},
{'name': 'v8testing', 'variant': 'slow_path', 'shards': 2},
{'name': 'v8testing', 'variant': 'stress_concurrent_allocation', 'shards': 2},
],
},
'V8 Linux64 TSAN - stress-incremental-marking': {
@ -1372,16 +1390,18 @@
{
'name': 'benchmarks',
'test_args': ['--extra-flags=--stress-incremental-marking'],
'shards': 2,
},
{
'name': 'mozilla',
'test_args': ['--extra-flags=--stress-incremental-marking'],
'shards': 2,
},
{
'name': 'test262',
'variant': 'default',
'test_args': ['--extra-flags=--stress-incremental-marking'],
'shards': 4,
'shards': 5,
},
{
'name': 'v8testing',
@ -1413,7 +1433,7 @@
'test_args': ['--extra-flags=--future'],
'shards': 6,
},
{'name': 'v8testing', 'variant': 'stress_concurrent_inlining'},
{'name': 'v8testing', 'variant': 'stress_concurrent_inlining', 'shards': 2},
],
},
'V8 Linux64 UBSan': {
@ -1473,7 +1493,7 @@
'swarming_dimensions' : {
'os': 'Mac-11',
'cpu': 'arm64',
'pool': 'chromium.tests.mac-arm64',
'pool': 'chromium.tests',
},
'swarming_task_attrs': {
'expiration': 14400,
@ -1489,7 +1509,7 @@
'swarming_dimensions' : {
'os': 'Mac-11',
'cpu': 'arm64',
'pool': 'chromium.tests.mac-arm64',
'pool': 'chromium.tests',
},
'swarming_task_attrs': {
'expiration': 14400,

5
deps/v8/src/DEPS vendored
View File

@ -5,7 +5,7 @@ include_rules = [
"+src/asmjs/asm-js.h",
"-src/baseline",
"+src/baseline/baseline.h",
"+src/baseline/baseline-osr-inl.h",
"+src/baseline/baseline-batch-compiler.h",
"+src/baseline/bytecode-offset-iterator.h",
"-src/bigint",
"+src/bigint/bigint.h",
@ -72,6 +72,9 @@ specific_include_rules = {
"+include/libplatform/v8-tracing.h",
"+perfetto/tracing.h"
],
"d8-platforms\.cc": [
"+include/libplatform/libplatform.h",
],
"builtins-trace\.cc": [
"+protos/perfetto",
],

View File

@ -6,11 +6,10 @@
#define V8_API_API_ARGUMENTS_INL_H_
#include "src/api/api-arguments.h"
#include "src/api/api-inl.h"
#include "src/debug/debug.h"
#include "src/execution/vm-state-inl.h"
#include "src/logging/counters.h"
#include "src/logging/runtime-call-stats-scope.h"
#include "src/objects/api-callbacks.h"
#include "src/objects/slots-inl.h"
#include "src/tracing/trace-event.h"

View File

@ -5,10 +5,12 @@
#ifndef V8_API_API_INL_H_
#define V8_API_API_INL_H_
#include "include/v8-fast-api-calls.h"
#include "src/api/api.h"
#include "src/execution/interrupts-scope.h"
#include "src/execution/microtask-queue.h"
#include "src/handles/handles-inl.h"
#include "src/heap/heap-inl.h"
#include "src/objects/foreign-inl.h"
#include "src/objects/js-weak-refs.h"
#include "src/objects/objects-inl.h"
@ -239,6 +241,58 @@ inline bool IsExecutionTerminatingCheck(i::Isolate* isolate) {
return false;
}
template <typename T>
void CopySmiElementsToTypedBuffer(T* dst, uint32_t length,
i::FixedArray elements) {
for (uint32_t i = 0; i < length; ++i) {
double value = elements.get(static_cast<int>(i)).Number();
// TODO(mslekova): Avoid converting back-and-forth when possible, e.g
// avoid int->double->int conversions to boost performance.
dst[i] = i::ConvertDouble<T>(value);
}
}
template <typename T>
void CopyDoubleElementsToTypedBuffer(T* dst, uint32_t length,
i::FixedDoubleArray elements) {
for (uint32_t i = 0; i < length; ++i) {
double value = elements.get_scalar(static_cast<int>(i));
// TODO(mslekova): There are certain cases, e.g. double->double, in which
// we could do a memcpy directly.
dst[i] = i::ConvertDouble<T>(value);
}
}
template <const CTypeInfo* type_info, typename T>
bool CopyAndConvertArrayToCppBuffer(Local<Array> src, T* dst,
uint32_t max_length) {
static_assert(
std::is_same<
T, typename i::CTypeInfoTraits<type_info->GetType()>::ctype>::value,
"Type mismatch between the expected CTypeInfo::Type and the destination "
"array");
uint32_t length = src->Length();
if (length > max_length) {
return false;
}
i::DisallowGarbageCollection no_gc;
i::JSArray obj = *reinterpret_cast<i::JSArray*>(*src);
i::FixedArrayBase elements = obj.elements();
if (obj.HasSmiElements()) {
CopySmiElementsToTypedBuffer(dst, length, i::FixedArray::cast(elements));
return true;
} else if (obj.HasDoubleElements()) {
CopyDoubleElementsToTypedBuffer(dst, length,
i::FixedDoubleArray::cast(elements));
return true;
} else {
return false;
}
}
namespace internal {
Handle<Context> HandleScopeImplementer::LastEnteredContext() {

View File

@ -7,6 +7,8 @@
#include "src/api/api-inl.h"
#include "src/common/message-template.h"
#include "src/execution/isolate-inl.h"
#include "src/heap/heap-inl.h"
#include "src/logging/runtime-call-stats-scope.h"
#include "src/objects/api-callbacks.h"
#include "src/objects/hash-table-inl.h"
#include "src/objects/lookup.h"
@ -109,7 +111,7 @@ MaybeHandle<Object> DefineDataProperty(Isolate* isolate,
ASSIGN_RETURN_ON_EXCEPTION(isolate, value,
Instantiate(isolate, prop_data, name), Object);
LookupIterator::Key key(isolate, name);
PropertyKey key(isolate, name);
LookupIterator it(isolate, object, key, LookupIterator::OWN_SKIP_INTERCEPTOR);
#ifdef DEBUG

247
deps/v8/src/api/api.cc vendored
View File

@ -25,6 +25,7 @@
#include "src/base/platform/time.h"
#include "src/base/safe_conversions.h"
#include "src/base/utils/random-number-generator.h"
#include "src/baseline/baseline-batch-compiler.h"
#include "src/builtins/accessors.h"
#include "src/builtins/builtins-utils.h"
#include "src/codegen/compiler.h"
@ -58,6 +59,7 @@
#include "src/json/json-stringifier.h"
#include "src/logging/counters.h"
#include "src/logging/metrics.h"
#include "src/logging/runtime-call-stats-scope.h"
#include "src/logging/tracing-flags.h"
#include "src/numbers/conversions-inl.h"
#include "src/objects/api-callbacks.h"
@ -107,11 +109,11 @@
#include "src/strings/string-hasher.h"
#include "src/strings/unicode-inl.h"
#include "src/tracing/trace-event.h"
#include "src/trap-handler/trap-handler.h"
#include "src/utils/detachable-vector.h"
#include "src/utils/version.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/trap-handler/trap-handler.h"
#include "src/wasm/streaming-decoder.h"
#include "src/wasm/value-type.h"
#include "src/wasm/wasm-engine.h"
@ -409,6 +411,8 @@ SnapshotCreator::SnapshotCreator(Isolate* isolate,
internal_isolate->InitWithoutSnapshot();
}
data_ = data;
// Disable batch compilation during snapshot creation.
internal_isolate->baseline_batch_compiler()->set_enabled(false);
}
SnapshotCreator::SnapshotCreator(const intptr_t* external_references,
@ -1218,7 +1222,9 @@ static Local<FunctionTemplate> FunctionTemplateNew(
bool do_not_cache,
v8::Local<Private> cached_property_name = v8::Local<Private>(),
SideEffectType side_effect_type = SideEffectType::kHasSideEffect,
const MemorySpan<const CFunction>& c_function_overloads = {}) {
const MemorySpan<const CFunction>& c_function_overloads = {},
uint8_t instance_type = 0, uint8_t allowed_receiver_range_start = 0,
uint8_t allowed_receiver_range_end = 0) {
i::Handle<i::Struct> struct_obj = isolate->factory()->NewStruct(
i::FUNCTION_TEMPLATE_INFO_TYPE, i::AllocationType::kOld);
i::Handle<i::FunctionTemplateInfo> obj =
@ -1240,6 +1246,9 @@ static Local<FunctionTemplate> FunctionTemplateNew(
? i::ReadOnlyRoots(isolate).the_hole_value()
: *Utils::OpenHandle(*cached_property_name));
if (behavior == ConstructorBehavior::kThrow) raw.set_remove_prototype(true);
raw.SetInstanceType(instance_type);
raw.set_allowed_receiver_range_start(allowed_receiver_range_start);
raw.set_allowed_receiver_range_end(allowed_receiver_range_end);
}
if (callback != nullptr) {
Utils::ToLocal(obj)->SetCallHandler(callback, data, side_effect_type,
@ -1251,7 +1260,9 @@ static Local<FunctionTemplate> FunctionTemplateNew(
Local<FunctionTemplate> FunctionTemplate::New(
Isolate* isolate, FunctionCallback callback, v8::Local<Value> data,
v8::Local<Signature> signature, int length, ConstructorBehavior behavior,
SideEffectType side_effect_type, const CFunction* c_function) {
SideEffectType side_effect_type, const CFunction* c_function,
uint8_t instance_type, uint8_t allowed_receiver_range_start,
uint8_t allowed_receiver_range_end) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
// Changes to the environment cannot be captured in the snapshot. Expect no
// function templates when the isolate is created for serialization.
@ -1261,7 +1272,8 @@ Local<FunctionTemplate> FunctionTemplate::New(
i_isolate, callback, data, signature, length, behavior, false,
Local<Private>(), side_effect_type,
c_function ? MemorySpan<const CFunction>{c_function, 1}
: MemorySpan<const CFunction>{});
: MemorySpan<const CFunction>{},
instance_type, allowed_receiver_range_start, allowed_receiver_range_end);
}
Local<FunctionTemplate> FunctionTemplate::NewWithCFunctionOverloads(
@ -1269,6 +1281,15 @@ Local<FunctionTemplate> FunctionTemplate::NewWithCFunctionOverloads(
v8::Local<Signature> signature, int length, ConstructorBehavior behavior,
SideEffectType side_effect_type,
const MemorySpan<const CFunction>& c_function_overloads) {
// TODO(mslekova): Once runtime overload resolution between sequences is
// supported, check that if (c_function_overloads.size() == 2), then
// c_function_overloads.data()[0].
// CanResolveOverload(c_function_overloads.data()[1]). We won't support
// the case where the size is greater than 2 for runtime resolution, until
// we've added support for ArrayBuffers and ArrayBufferViews. OTOH the
// overloads list might contain more than 2 functions with different arity,
// the resolution between which is available at compile time.
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
LOG_API(i_isolate, FunctionTemplate, New);
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
@ -3234,7 +3255,8 @@ ValueDeserializer::Delegate::GetSharedArrayBufferFromId(Isolate* v8_isolate,
}
struct ValueDeserializer::PrivateData {
PrivateData(i::Isolate* i, i::Vector<const uint8_t> data, Delegate* delegate)
PrivateData(i::Isolate* i, base::Vector<const uint8_t> data,
Delegate* delegate)
: isolate(i), deserializer(i, data, delegate) {}
i::Isolate* isolate;
i::ValueDeserializer deserializer;
@ -3251,10 +3273,11 @@ ValueDeserializer::ValueDeserializer(Isolate* isolate, const uint8_t* data,
if (base::IsValueInRangeForNumericType<int>(size)) {
private_ = new PrivateData(
reinterpret_cast<i::Isolate*>(isolate),
i::Vector<const uint8_t>(data, static_cast<int>(size)), delegate);
base::Vector<const uint8_t>(data, static_cast<int>(size)), delegate);
} else {
private_ = new PrivateData(reinterpret_cast<i::Isolate*>(isolate),
i::Vector<const uint8_t>(nullptr, 0), nullptr);
private_ =
new PrivateData(reinterpret_cast<i::Isolate*>(isolate),
base::Vector<const uint8_t>(nullptr, 0), nullptr);
private_->has_aborted = true;
}
}
@ -4099,7 +4122,7 @@ Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context,
i::Handle<i::Name> key_obj = Utils::OpenHandle(*key);
i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
i::LookupIterator::Key lookup_key(isolate, key_obj);
i::PropertyKey lookup_key(isolate, key_obj);
i::LookupIterator it(isolate, self, lookup_key, i::LookupIterator::OWN);
if (self->IsJSProxy()) {
ENTER_V8(isolate, context, Object, CreateDataProperty, Nothing<bool>(),
@ -4775,7 +4798,7 @@ MaybeLocal<Value> v8::Object::GetRealNamedPropertyInPrototypeChain(
if (iter.IsAtEnd()) return MaybeLocal<Value>();
i::Handle<i::JSReceiver> proto =
i::PrototypeIterator::GetCurrent<i::JSReceiver>(iter);
i::LookupIterator::Key lookup_key(isolate, key_obj);
i::PropertyKey lookup_key(isolate, key_obj);
i::LookupIterator it(isolate, self, lookup_key, proto,
i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
Local<Value> result;
@ -4799,7 +4822,7 @@ v8::Object::GetRealNamedPropertyAttributesInPrototypeChain(
if (iter.IsAtEnd()) return Nothing<PropertyAttribute>();
i::Handle<i::JSReceiver> proto =
i::PrototypeIterator::GetCurrent<i::JSReceiver>(iter);
i::LookupIterator::Key lookup_key(isolate, key_obj);
i::PropertyKey lookup_key(isolate, key_obj);
i::LookupIterator it(isolate, self, lookup_key, proto,
i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
Maybe<i::PropertyAttributes> result =
@ -4816,7 +4839,7 @@ MaybeLocal<Value> v8::Object::GetRealNamedProperty(Local<Context> context,
PREPARE_FOR_EXECUTION(context, Object, GetRealNamedProperty, Value);
i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
i::Handle<i::Name> key_obj = Utils::OpenHandle(*key);
i::LookupIterator::Key lookup_key(isolate, key_obj);
i::PropertyKey lookup_key(isolate, key_obj);
i::LookupIterator it(isolate, self, lookup_key, self,
i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
Local<Value> result;
@ -4833,7 +4856,7 @@ Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes(
Nothing<PropertyAttribute>(), i::HandleScope);
i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
i::Handle<i::Name> key_obj = Utils::OpenHandle(*key);
i::LookupIterator::Key lookup_key(isolate, key_obj);
i::PropertyKey lookup_key(isolate, key_obj);
i::LookupIterator it(isolate, self, lookup_key, self,
i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
auto result = i::JSReceiver::GetPropertyAttributes(&it);
@ -5330,7 +5353,7 @@ namespace {
// units until the buffer capacity is reached, would be exceeded by the next
// unit, or all code units have been written out.
template <typename Char>
static int WriteUtf8Impl(i::Vector<const Char> string, char* write_start,
static int WriteUtf8Impl(base::Vector<const Char> string, char* write_start,
int write_capacity, int options,
int* utf16_chars_read_out) {
bool write_null = !(options & v8::String::NO_NULL_TERMINATION);
@ -5362,7 +5385,7 @@ static int WriteUtf8Impl(i::Vector<const Char> string, char* write_start,
for (int i = read_index; i < up_to; i++) char_mask |= read_start[i];
if ((char_mask & 0x80) == 0) {
int copy_length = up_to - read_index;
base::Memcpy(current_write, read_start + read_index, copy_length);
memcpy(current_write, read_start + read_index, copy_length);
current_write += copy_length;
read_index = up_to;
} else {
@ -5841,8 +5864,9 @@ bool TryHandleWebAssemblyTrapPosix(int sig_code, siginfo_t* info,
// code rather than the wasm code, so the trap handler cannot find the landing
// pad and lets the process crash. Therefore, only enable trap handlers if
// the host and target arch are the same.
#if (V8_TARGET_ARCH_X64 && !V8_OS_ANDROID) || \
(V8_HOST_ARCH_ARM64 && V8_TARGET_ARCH_ARM64 && V8_OS_MACOSX)
#if V8_ENABLE_WEBASSEMBLY && \
((V8_TARGET_ARCH_X64 && !V8_OS_ANDROID) || \
(V8_HOST_ARCH_ARM64 && V8_TARGET_ARCH_ARM64 && V8_OS_MACOSX))
return i::trap_handler::TryHandleSignal(sig_code, info, context);
#else
return false;
@ -5857,15 +5881,20 @@ bool V8::TryHandleSignal(int signum, void* info, void* context) {
#if V8_OS_WIN
bool TryHandleWebAssemblyTrapWindows(EXCEPTION_POINTERS* exception) {
#if V8_TARGET_ARCH_X64
#if V8_ENABLE_WEBASSEMBLY && V8_TARGET_ARCH_X64
return i::trap_handler::TryHandleWasmTrap(exception);
#endif
#else
return false;
#endif
}
#endif
bool V8::EnableWebAssemblyTrapHandler(bool use_v8_signal_handler) {
#if V8_ENABLE_WEBASSEMBLY
return v8::internal::trap_handler::EnableTrapHandler(use_v8_signal_handler);
#else
return false;
#endif
}
#if defined(V8_OS_WIN)
@ -6104,7 +6133,7 @@ Local<Context> NewContext(
// TODO(jkummerow): This is for crbug.com/713699. Remove it if it doesn't
// fail.
// Sanity-check that the isolate is initialized and usable.
CHECK(isolate->builtins()->builtin(i::Builtins::kIllegal).IsCode());
CHECK(isolate->builtins()->code(i::Builtin::kIllegal).IsCode());
TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.NewContext");
LOG_API(isolate, Context, New);
@ -6210,7 +6239,7 @@ v8::Local<v8::Object> Context::Global() {
i::Handle<i::Context> context = Utils::OpenHandle(this);
i::Isolate* isolate = context->GetIsolate();
i::Handle<i::Object> global(context->global_proxy(), isolate);
// TODO(dcarney): This should always return the global proxy
// TODO(chromium:324812): This should always return the global proxy
// but can't presently as calls to GetProtoype will return the wrong result.
if (i::Handle<i::JSGlobalProxy>::cast(global)->IsDetachedFrom(
context->global_object())) {
@ -6506,7 +6535,7 @@ inline int StringLength(const uint16_t* string) {
V8_WARN_UNUSED_RESULT
inline i::MaybeHandle<i::String> NewString(i::Factory* factory,
NewStringType type,
i::Vector<const char> string) {
base::Vector<const char> string) {
if (type == NewStringType::kInternalized) {
return factory->InternalizeUtf8String(string);
}
@ -6516,7 +6545,7 @@ inline i::MaybeHandle<i::String> NewString(i::Factory* factory,
V8_WARN_UNUSED_RESULT
inline i::MaybeHandle<i::String> NewString(i::Factory* factory,
NewStringType type,
i::Vector<const uint8_t> string) {
base::Vector<const uint8_t> string) {
if (type == NewStringType::kInternalized) {
return factory->InternalizeString(string);
}
@ -6524,9 +6553,9 @@ inline i::MaybeHandle<i::String> NewString(i::Factory* factory,
}
V8_WARN_UNUSED_RESULT
inline i::MaybeHandle<i::String> NewString(i::Factory* factory,
NewStringType type,
i::Vector<const uint16_t> string) {
inline i::MaybeHandle<i::String> NewString(
i::Factory* factory, NewStringType type,
base::Vector<const uint16_t> string) {
if (type == NewStringType::kInternalized) {
return factory->InternalizeString(string);
}
@ -6552,7 +6581,7 @@ STATIC_ASSERT(v8::String::kMaxLength == i::String::kMaxLength);
if (length < 0) length = StringLength(data); \
i::Handle<i::String> handle_result = \
NewString(i_isolate->factory(), type, \
i::Vector<const Char>(data, length)) \
base::Vector<const Char>(data, length)) \
.ToHandleChecked(); \
result = Utils::ToLocal(handle_result); \
}
@ -6565,7 +6594,7 @@ Local<String> String::NewFromUtf8Literal(Isolate* isolate, const char* literal,
LOG_API(i_isolate, String, NewFromUtf8Literal);
i::Handle<i::String> handle_result =
NewString(i_isolate->factory(), type,
i::Vector<const char>(literal, length))
base::Vector<const char>(literal, length))
.ToHandleChecked();
return Utils::ToLocal(handle_result);
}
@ -7003,7 +7032,7 @@ MaybeLocal<v8::RegExp> v8::RegExp::NewWithBacktrackLimit(
Local<v8::String> v8::RegExp::GetSource() const {
i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this);
return Utils::ToLocal(
i::Handle<i::String>(obj->Pattern(), obj->GetIsolate()));
i::Handle<i::String>(obj->EscapedPattern(), obj->GetIsolate()));
}
// Assert that the static flags cast in GetFlags is valid.
@ -7453,6 +7482,11 @@ void Promise::MarkAsHandled() {
js_promise->set_has_handler(true);
}
void Promise::MarkAsSilent() {
i::Handle<i::JSPromise> js_promise = Utils::OpenHandle(this);
js_promise->set_is_silent(true);
}
Local<Value> Proxy::GetTarget() {
i::Handle<i::JSProxy> self = Utils::OpenHandle(this);
i::Handle<i::Object> target(self->target(), self->GetIsolate());
@ -7511,7 +7545,7 @@ OwnedBuffer CompiledWasmModule::Serialize() {
MemorySpan<const uint8_t> CompiledWasmModule::GetWireBytesRef() {
#if V8_ENABLE_WEBASSEMBLY
i::Vector<const uint8_t> bytes_vec = native_module_->wire_bytes();
base::Vector<const uint8_t> bytes_vec = native_module_->wire_bytes();
return {bytes_vec.begin(), bytes_vec.size()};
#else
UNREACHABLE();
@ -7548,9 +7582,9 @@ MaybeLocal<WasmModuleObject> WasmModuleObject::FromCompiledModule(
#if V8_ENABLE_WEBASSEMBLY
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
i::Handle<i::WasmModuleObject> module_object =
i_isolate->wasm_engine()->ImportNativeModule(
i::wasm::GetWasmEngine()->ImportNativeModule(
i_isolate, compiled_module.native_module_,
i::VectorOf(compiled_module.source_url()));
base::VectorOf(compiled_module.source_url()));
return Local<WasmModuleObject>::Cast(
Utils::ToLocal(i::Handle<i::JSObject>::cast(module_object)));
#else
@ -7579,7 +7613,7 @@ void* v8::ArrayBuffer::Allocator::Reallocate(void* data, size_t old_length,
reinterpret_cast<uint8_t*>(AllocateUninitialized(new_length));
if (new_data == nullptr) return nullptr;
size_t bytes_to_copy = std::min(old_length, new_length);
base::Memcpy(new_data, data, bytes_to_copy);
memcpy(new_data, data, bytes_to_copy);
if (new_length > bytes_to_copy) {
memset(new_data + bytes_to_copy, 0, new_length - bytes_to_copy);
}
@ -7713,7 +7747,7 @@ size_t v8::ArrayBufferView::CopyContents(void* dest, size_t byte_length) {
isolate);
source = reinterpret_cast<char*>(typed_array->DataPtr());
}
base::Memcpy(dest, source + byte_offset, bytes_to_copy);
memcpy(dest, source + byte_offset, bytes_to_copy);
}
return bytes_to_copy;
}
@ -8209,7 +8243,7 @@ void Isolate::RequestInterrupt(InterruptCallback callback, void* data) {
bool Isolate::HasPendingBackgroundTasks() {
#if V8_ENABLE_WEBASSEMBLY
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
return isolate->wasm_engine()->HasRunningCompileJob(isolate);
return i::wasm::GetWasmEngine()->HasRunningCompileJob(isolate);
#else
return false;
#endif // V8_ENABLE_WEBASSEMBLY
@ -8236,6 +8270,11 @@ Isolate* Isolate::GetCurrent() {
return reinterpret_cast<Isolate*>(isolate);
}
Isolate* Isolate::TryGetCurrent() {
i::Isolate* isolate = i::Isolate::TryGetCurrent();
return reinterpret_cast<Isolate*>(isolate);
}
// static
Isolate* Isolate::Allocate() {
return reinterpret_cast<Isolate*>(i::Isolate::New());
@ -8264,23 +8303,6 @@ void Isolate::Initialize(Isolate* isolate,
} else {
i_isolate->set_snapshot_blob(i::Snapshot::DefaultSnapshotBlob());
}
auto code_event_handler = params.code_event_handler;
#ifdef ENABLE_GDB_JIT_INTERFACE
if (code_event_handler == nullptr && i::FLAG_gdbjit) {
code_event_handler = i::GDBJITInterface::EventHandler;
}
#endif // ENABLE_GDB_JIT_INTERFACE
#if defined(V8_OS_WIN) && defined(V8_ENABLE_SYSTEM_INSTRUMENTATION)
if (code_event_handler == nullptr && i::FLAG_enable_system_instrumentation) {
code_event_handler = i::ETWJITInterface::EventHandler;
}
#endif // defined(V8_OS_WIN)
if (code_event_handler) {
i_isolate->InitializeLoggingAndCounters();
i_isolate->logger()->SetCodeEventHandler(kJitCodeEventDefault,
code_event_handler);
}
if (params.counter_lookup_callback) {
isolate->SetCounterFunction(params.counter_lookup_callback);
}
@ -8305,22 +8327,40 @@ void Isolate::Initialize(Isolate* isolate,
}
// TODO(jochen): Once we got rid of Isolate::Current(), we can remove this.
Isolate::Scope isolate_scope(isolate);
if (i_isolate->snapshot_blob() == nullptr) {
FATAL(
"V8 snapshot blob was not set during initialization. This can mean "
"that the snapshot blob file is corrupted or missing.");
}
if (!i::Snapshot::Initialize(i_isolate)) {
// If snapshot data was provided and we failed to deserialize it must
// have been corrupted.
if (i_isolate->snapshot_blob() != nullptr) {
FATAL(
"Failed to deserialize the V8 snapshot blob. This can mean that the "
"snapshot blob file is corrupted or missing.");
FATAL(
"Failed to deserialize the V8 snapshot blob. This can mean that the "
"snapshot blob file is corrupted or missing.");
}
{
// Set up code event handlers. Needs to be after i::Snapshot::Initialize
// because that is where we add the isolate to WasmEngine.
auto code_event_handler = params.code_event_handler;
#ifdef ENABLE_GDB_JIT_INTERFACE
if (code_event_handler == nullptr && i::FLAG_gdbjit) {
code_event_handler = i::GDBJITInterface::EventHandler;
}
base::ElapsedTimer timer;
if (i::FLAG_profile_deserialization) timer.Start();
i_isolate->InitWithoutSnapshot();
if (i::FLAG_profile_deserialization) {
double ms = timer.Elapsed().InMillisecondsF();
i::PrintF("[Initializing isolate from scratch took %0.3f ms]\n", ms);
#endif // ENABLE_GDB_JIT_INTERFACE
#if defined(V8_OS_WIN) && defined(V8_ENABLE_SYSTEM_INSTRUMENTATION)
if (code_event_handler == nullptr &&
i::FLAG_enable_system_instrumentation) {
code_event_handler = i::ETWJITInterface::EventHandler;
}
#endif // defined(V8_OS_WIN)
if (code_event_handler) {
isolate->SetJitCodeEventHandler(kJitCodeEventDefault, code_event_handler);
}
}
i_isolate->set_only_terminate_in_safe_scope(
params.only_terminate_in_safe_scope);
i_isolate->set_embedder_wrapper_type_index(
@ -8534,7 +8574,12 @@ void Isolate::GetHeapStatistics(HeapStatistics* heap_statistics) {
heap_statistics->malloced_memory_ =
isolate->allocator()->GetCurrentMemoryUsage() +
isolate->string_table()->GetCurrentMemoryUsage();
heap_statistics->external_memory_ = isolate->heap()->backing_store_bytes();
// On 32-bit systems backing_store_bytes() might overflow size_t temporarily
// due to concurrent array buffer sweeping.
heap_statistics->external_memory_ =
isolate->heap()->backing_store_bytes() < SIZE_MAX
? static_cast<size_t>(isolate->heap()->backing_store_bytes())
: SIZE_MAX;
heap_statistics->peak_malloced_memory_ =
isolate->allocator()->GetMaxMemoryUsage();
heap_statistics->number_of_native_contexts_ = heap->NumberOfNativeContexts();
@ -8544,9 +8589,9 @@ void Isolate::GetHeapStatistics(HeapStatistics* heap_statistics) {
#if V8_ENABLE_WEBASSEMBLY
heap_statistics->malloced_memory_ +=
isolate->wasm_engine()->allocator()->GetCurrentMemoryUsage();
i::wasm::GetWasmEngine()->allocator()->GetCurrentMemoryUsage();
heap_statistics->peak_malloced_memory_ +=
isolate->wasm_engine()->allocator()->GetMaxMemoryUsage();
i::wasm::GetWasmEngine()->allocator()->GetMaxMemoryUsage();
#endif // V8_ENABLE_WEBASSEMBLY
}
@ -8824,7 +8869,7 @@ void Isolate::SetAddHistogramSampleFunction(
void Isolate::SetMetricsRecorder(
const std::shared_ptr<metrics::Recorder>& metrics_recorder) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
isolate->metrics_recorder()->SetRecorder(isolate, metrics_recorder);
isolate->metrics_recorder()->SetEmbedderRecorder(isolate, metrics_recorder);
}
void Isolate::SetAddCrashKeyCallback(AddCrashKeyCallback callback) {
@ -8860,7 +8905,7 @@ int Isolate::ContextDisposedNotification(bool dependant_context) {
// of that context.
// A handle scope for the native context.
i::HandleScope handle_scope(isolate);
isolate->wasm_engine()->DeleteCompileJobsOnContext(
i::wasm::GetWasmEngine()->DeleteCompileJobsOnContext(
isolate->native_context());
}
}
@ -8888,6 +8933,12 @@ void Isolate::MemoryPressureNotification(MemoryPressureLevel level) {
isolate->heap()->MemoryPressureNotification(level, on_isolate_thread);
}
void Isolate::ClearCachesForTesting() {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
isolate->AbortConcurrentOptimization(i::BlockingBehavior::kBlock);
isolate->ClearSerializerData();
}
void Isolate::EnableMemorySavingsMode() {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
isolate->EnableMemorySavingsMode();
@ -8951,10 +9002,10 @@ JSEntryStubs Isolate::GetJSEntryStubs() {
JSEntryStubs entry_stubs;
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
std::array<std::pair<i::Builtins::Name, JSEntryStub*>, 3> stubs = {
{{i::Builtins::kJSEntry, &entry_stubs.js_entry_stub},
{i::Builtins::kJSConstructEntry, &entry_stubs.js_construct_entry_stub},
{i::Builtins::kJSRunMicrotasksEntry,
std::array<std::pair<i::Builtin, JSEntryStub*>, 3> stubs = {
{{i::Builtin::kJSEntry, &entry_stubs.js_entry_stub},
{i::Builtin::kJSConstructEntry, &entry_stubs.js_construct_entry_stub},
{i::Builtin::kJSRunMicrotasksEntry,
&entry_stubs.js_run_microtasks_entry_stub}}};
for (auto& pair : stubs) {
i::Code js_entry = isolate->heap()->builtin(pair.first);
@ -9633,8 +9684,6 @@ const char* CodeEvent::GetCodeEventTypeName(CodeEventType code_event_type) {
}
// The execution should never pass here
UNREACHABLE();
// NOTE(mmarchini): Workaround to fix a compiler failure on GCC 4.9
return "Unknown";
}
CodeEventHandler::CodeEventHandler(Isolate* isolate) {
@ -9683,7 +9732,6 @@ Local<Value> HeapGraphEdge::GetName() const {
default:
UNREACHABLE();
}
return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
}
const HeapGraphNode* HeapGraphEdge::GetFromNode() const {
@ -9957,6 +10005,14 @@ void EmbedderHeapTracer::ResetHandleInNonTracingGC(
UNREACHABLE();
}
void TracedReferenceBase::CheckValue() const {
#ifdef V8_HOST_ARCH_64_BIT
if (!val_) return;
CHECK_NE(internal::kGlobalHandleZapValue, *reinterpret_cast<uint64_t*>(val_));
#endif // V8_HOST_ARCH_64_BIT
}
CFunction::CFunction(const void* address, const CFunctionInfo* type_info)
: address_(address), type_info_(type_info) {
CHECK_NOT_NULL(address_);
@ -10217,6 +10273,49 @@ void InvokeFinalizationRegistryCleanupFromTask(
}
}
template <>
EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
int32_t ConvertDouble(double d) {
return internal::DoubleToInt32(d);
}
template <>
EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
uint32_t ConvertDouble(double d) {
return internal::DoubleToUint32(d);
}
template <>
EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
float ConvertDouble(double d) {
return internal::DoubleToFloat32(d);
}
template <>
EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
double ConvertDouble(double d) {
return d;
}
template <>
EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
int64_t ConvertDouble(double d) {
return internal::DoubleToWebIDLInt64(d);
}
template <>
EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
uint64_t ConvertDouble(double d) {
return internal::DoubleToWebIDLUint64(d);
}
template <>
EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
bool ConvertDouble(double d) {
// Implements https://tc39.es/ecma262/#sec-toboolean.
return !std::isnan(d) && d != 0;
}
// Undefine macros for jumbo build.
#undef SET_FIELD_WRAPPED
#undef NEW_STRING

View File

@ -536,6 +536,10 @@ void InvokeFinalizationRegistryCleanupFromTask(
Handle<JSFinalizationRegistry> finalization_registry,
Handle<Object> callback);
template <typename T>
EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
T ConvertDouble(double d);
} // namespace internal
} // namespace v8

View File

@ -9,6 +9,7 @@
#include "src/ast/ast.h"
#include "src/base/optional.h"
#include "src/base/platform/elapsed-timer.h"
#include "src/base/vector.h"
#include "src/codegen/compiler.h"
#include "src/codegen/unoptimized-compilation-info.h"
#include "src/common/assert-scope.h"
@ -23,8 +24,6 @@
#include "src/parsing/parse-info.h"
#include "src/parsing/scanner-character-streams.h"
#include "src/parsing/scanner.h"
#include "src/utils/vector.h"
#include "src/wasm/wasm-engine.h"
#include "src/wasm/wasm-js.h"
#include "src/wasm/wasm-limits.h"
@ -42,7 +41,7 @@ namespace {
Handle<Object> StdlibMathMember(Isolate* isolate, Handle<JSReceiver> stdlib,
Handle<Name> name) {
Handle<Name> math_name(
isolate->factory()->InternalizeString(StaticCharVector("Math")));
isolate->factory()->InternalizeString(base::StaticCharVector("Math")));
Handle<Object> math = JSReceiver::GetDataProperty(stdlib, math_name);
if (!math->IsJSReceiver()) return isolate->factory()->undefined_value();
Handle<JSReceiver> math_receiver = Handle<JSReceiver>::cast(math);
@ -68,40 +67,40 @@ bool AreStdlibMembersValid(Isolate* isolate, Handle<JSReceiver> stdlib,
#define STDLIB_MATH_FUNC(fname, FName, ignore1, ignore2) \
if (members.contains(wasm::AsmJsParser::StandardMember::kMath##FName)) { \
members.Remove(wasm::AsmJsParser::StandardMember::kMath##FName); \
Handle<Name> name( \
isolate->factory()->InternalizeString(StaticCharVector(#fname))); \
Handle<Name> name(isolate->factory()->InternalizeString( \
base::StaticCharVector(#fname))); \
Handle<Object> value = StdlibMathMember(isolate, stdlib, name); \
if (!value->IsJSFunction()) return false; \
SharedFunctionInfo shared = Handle<JSFunction>::cast(value)->shared(); \
if (!shared.HasBuiltinId() || \
shared.builtin_id() != Builtins::kMath##FName) { \
shared.builtin_id() != Builtin::kMath##FName) { \
return false; \
} \
DCHECK_EQ(shared.GetCode(), \
isolate->builtins()->builtin(Builtins::kMath##FName)); \
isolate->builtins()->code(Builtin::kMath##FName)); \
}
STDLIB_MATH_FUNCTION_LIST(STDLIB_MATH_FUNC)
#undef STDLIB_MATH_FUNC
#define STDLIB_MATH_CONST(cname, const_value) \
if (members.contains(wasm::AsmJsParser::StandardMember::kMath##cname)) { \
members.Remove(wasm::AsmJsParser::StandardMember::kMath##cname); \
Handle<Name> name( \
isolate->factory()->InternalizeString(StaticCharVector(#cname))); \
Handle<Name> name(isolate->factory()->InternalizeString( \
base::StaticCharVector(#cname))); \
Handle<Object> value = StdlibMathMember(isolate, stdlib, name); \
if (!value->IsNumber() || value->Number() != const_value) return false; \
}
STDLIB_MATH_VALUE_LIST(STDLIB_MATH_CONST)
#undef STDLIB_MATH_CONST
#define STDLIB_ARRAY_TYPE(fname, FName) \
if (members.contains(wasm::AsmJsParser::StandardMember::k##FName)) { \
members.Remove(wasm::AsmJsParser::StandardMember::k##FName); \
*is_typed_array = true; \
Handle<Name> name( \
isolate->factory()->InternalizeString(StaticCharVector(#FName))); \
Handle<Object> value = JSReceiver::GetDataProperty(stdlib, name); \
if (!value->IsJSFunction()) return false; \
Handle<JSFunction> func = Handle<JSFunction>::cast(value); \
if (!func.is_identical_to(isolate->fname())) return false; \
#define STDLIB_ARRAY_TYPE(fname, FName) \
if (members.contains(wasm::AsmJsParser::StandardMember::k##FName)) { \
members.Remove(wasm::AsmJsParser::StandardMember::k##FName); \
*is_typed_array = true; \
Handle<Name> name(isolate->factory()->InternalizeString( \
base::StaticCharVector(#FName))); \
Handle<Object> value = JSReceiver::GetDataProperty(stdlib, name); \
if (!value->IsJSFunction()) return false; \
Handle<JSFunction> func = Handle<JSFunction>::cast(value); \
if (!func.is_identical_to(isolate->fname())) return false; \
}
STDLIB_ARRAY_TYPE(int8_array_fun, Int8Array)
STDLIB_ARRAY_TYPE(uint8_array_fun, Uint8Array)
@ -117,7 +116,7 @@ bool AreStdlibMembersValid(Isolate* isolate, Handle<JSReceiver> stdlib,
return true;
}
void Report(Handle<Script> script, int position, Vector<const char> text,
void Report(Handle<Script> script, int position, base::Vector<const char> text,
MessageTemplate message_template,
v8::Isolate::MessageErrorLevel level) {
Isolate* isolate = script->GetIsolate();
@ -134,7 +133,7 @@ void Report(Handle<Script> script, int position, Vector<const char> text,
void ReportCompilationSuccess(Handle<Script> script, int position,
double compile_time, size_t module_size) {
if (FLAG_suppress_asm_messages || !FLAG_trace_asm_time) return;
EmbeddedVector<char, 100> text;
base::EmbeddedVector<char, 100> text;
int length = SNPrintF(text, "success, compile time %0.3f ms, %zu bytes",
compile_time, module_size);
CHECK_NE(-1, length);
@ -155,7 +154,7 @@ void ReportCompilationFailure(ParseInfo* parse_info, int position,
void ReportInstantiationSuccess(Handle<Script> script, int position,
double instantiate_time) {
if (FLAG_suppress_asm_messages || !FLAG_trace_asm_time) return;
EmbeddedVector<char, 50> text;
base::EmbeddedVector<char, 50> text;
int length = SNPrintF(text, "success, %0.3f ms", instantiate_time);
CHECK_NE(-1, length);
text.Truncate(length);
@ -167,7 +166,7 @@ void ReportInstantiationSuccess(Handle<Script> script, int position,
void ReportInstantiationFailure(Handle<Script> script, int position,
const char* reason) {
if (FLAG_suppress_asm_messages) return;
Vector<const char> text = CStrVector(reason);
base::Vector<const char> text = base::CStrVector(reason);
Report(script, position, text, MessageTemplate::kAsmJsLinkingFailed,
v8::Isolate::kMessageWarning);
}
@ -266,11 +265,11 @@ UnoptimizedCompilationJob::Status AsmJsCompilationJob::FinalizeJobImpl(
// The result is a compiled module and serialized standard library uses.
wasm::ErrorThrower thrower(isolate, "AsmJs::Compile");
Handle<AsmWasmData> result =
isolate->wasm_engine()
wasm::GetWasmEngine()
->SyncCompileTranslatedAsmJs(
isolate, &thrower,
wasm::ModuleWireBytes(module_->begin(), module_->end()),
VectorOf(*asm_offsets_), uses_bitset,
base::VectorOf(*asm_offsets_), uses_bitset,
shared_info->language_mode())
.ToHandleChecked();
DCHECK(!thrower.error());
@ -300,9 +299,7 @@ inline bool IsValidAsmjsMemorySize(size_t size) {
// Enforce asm.js spec minimum size.
if (size < (1u << 12u)) return false;
// Enforce engine-limited and flag-limited maximum allocation size.
if (size > wasm::max_mem_pages() * uint64_t{wasm::kWasmPageSize}) {
return false;
}
if (size > wasm::max_mem_bytes()) return false;
// Enforce power-of-2 sizes for 2^12 - 2^24.
if (size < (1u << 24u)) {
uint32_t size32 = static_cast<uint32_t>(size);
@ -325,7 +322,7 @@ MaybeHandle<Object> AsmJs::InstantiateAsmWasm(Isolate* isolate,
instantiate_timer.Start();
Handle<HeapNumber> uses_bitset(wasm_data->uses_bitset(), isolate);
Handle<Script> script(Script::cast(shared->script()), isolate);
const auto& wasm_engine = isolate->wasm_engine();
auto* wasm_engine = wasm::GetWasmEngine();
// Allocate the WasmModuleObject.
Handle<WasmModuleObject> module =
@ -345,7 +342,8 @@ MaybeHandle<Object> AsmJs::InstantiateAsmWasm(Isolate* isolate,
// Check that all used stdlib members are valid.
bool stdlib_use_of_typed_array_present = false;
wasm::AsmJsParser::StdlibSet stdlib_uses =
wasm::AsmJsParser::StdlibSet::FromIntegral(uses_bitset->value_as_bits());
wasm::AsmJsParser::StdlibSet::FromIntegral(
uses_bitset->value_as_bits(kRelaxedLoad));
if (!stdlib_uses.empty()) { // No checking needed if no uses.
if (stdlib.is_null()) {
ReportInstantiationFailure(script, position, "Requires standard library");
@ -394,7 +392,7 @@ MaybeHandle<Object> AsmJs::InstantiateAsmWasm(Isolate* isolate,
// and bypass the {ErrorThrower}, this happens in case of a stack overflow.
if (isolate->has_pending_exception()) isolate->clear_pending_exception();
if (thrower.error()) {
ScopedVector<char> error_reason(100);
base::ScopedVector<char> error_reason(100);
SNPrintF(error_reason, "Internal wasm failure: %s", thrower.error_msg());
ReportInstantiationFailure(script, position, error_reason.begin());
} else {

View File

@ -200,14 +200,16 @@ wasm::AsmJsParser::VarInfo* AsmJsParser::GetVarInfo(
AsmJsScanner::token_t token) {
const bool is_global = AsmJsScanner::IsGlobal(token);
DCHECK(is_global || AsmJsScanner::IsLocal(token));
Vector<VarInfo>& var_info = is_global ? global_var_info_ : local_var_info_;
base::Vector<VarInfo>& var_info =
is_global ? global_var_info_ : local_var_info_;
size_t old_capacity = var_info.size();
size_t index = is_global ? AsmJsScanner::GlobalIndex(token)
: AsmJsScanner::LocalIndex(token);
if (is_global && index + 1 > num_globals_) num_globals_ = index + 1;
if (index + 1 > old_capacity) {
size_t new_size = std::max(2 * old_capacity, index + 1);
Vector<VarInfo> new_info{zone_->NewArray<VarInfo>(new_size), new_size};
base::Vector<VarInfo> new_info{zone_->NewArray<VarInfo>(new_size),
new_size};
std::uninitialized_fill(new_info.begin(), new_info.end(), VarInfo{});
std::copy(var_info.begin(), var_info.end(), new_info.begin());
var_info = new_info;
@ -220,7 +222,7 @@ uint32_t AsmJsParser::VarIndex(VarInfo* info) {
return info->index + static_cast<uint32_t>(global_imports_.size());
}
void AsmJsParser::AddGlobalImport(Vector<const char> name, AsmType* type,
void AsmJsParser::AddGlobalImport(base::Vector<const char> name, AsmType* type,
ValueType vtype, bool mutable_variable,
VarInfo* info) {
// Allocate a separate variable for the import.
@ -256,11 +258,11 @@ uint32_t AsmJsParser::TempVariable(int index) {
return function_temp_locals_offset_ + index;
}
Vector<const char> AsmJsParser::CopyCurrentIdentifierString() {
base::Vector<const char> AsmJsParser::CopyCurrentIdentifierString() {
const std::string& str = scanner_.GetIdentifierString();
char* buffer = zone()->NewArray<char>(str.size());
str.copy(buffer, str.size());
return Vector<const char>(buffer, static_cast<int>(str.size()));
return base::Vector<const char>(buffer, static_cast<int>(str.size()));
}
void AsmJsParser::SkipSemicolon() {
@ -539,13 +541,13 @@ void AsmJsParser::ValidateModuleVarImport(VarInfo* info,
if (Check('+')) {
EXPECT_TOKEN(foreign_name_);
EXPECT_TOKEN('.');
Vector<const char> name = CopyCurrentIdentifierString();
base::Vector<const char> name = CopyCurrentIdentifierString();
AddGlobalImport(name, AsmType::Double(), kWasmF64, mutable_variable, info);
scanner_.Next();
} else {
EXPECT_TOKEN(foreign_name_);
EXPECT_TOKEN('.');
Vector<const char> name = CopyCurrentIdentifierString();
base::Vector<const char> name = CopyCurrentIdentifierString();
scanner_.Next();
if (Check('|')) {
if (!CheckForZero()) {
@ -575,7 +577,6 @@ void AsmJsParser::ValidateModuleVarNewStdlib(VarInfo* info) {
#undef V
default:
FAIL("Expected ArrayBuffer view");
break;
}
EXPECT_TOKEN('(');
EXPECT_TOKEN(heap_name_);
@ -626,7 +627,7 @@ void AsmJsParser::ValidateExport() {
// clang-format on
if (Check('{')) {
for (;;) {
Vector<const char> name = CopyCurrentIdentifierString();
base::Vector<const char> name = CopyCurrentIdentifierString();
if (!scanner_.IsGlobal() && !scanner_.IsLocal()) {
FAIL("Illegal export name");
}
@ -656,7 +657,7 @@ void AsmJsParser::ValidateExport() {
if (info->kind != VarKind::kFunction) {
FAIL("Single function export must be a function");
}
module_builder_->AddExport(CStrVector(AsmJs::kSingleFunctionName),
module_builder_->AddExport(base::CStrVector(AsmJs::kSingleFunctionName),
info->function_builder);
}
}
@ -725,7 +726,7 @@ void AsmJsParser::ValidateFunction() {
FAIL("Expected function name");
}
Vector<const char> function_name_str = CopyCurrentIdentifierString();
base::Vector<const char> function_name_str = CopyCurrentIdentifierString();
AsmJsScanner::token_t function_name = Consume();
VarInfo* function_info = GetVarInfo(function_name);
if (function_info->kind == VarKind::kUnused) {

View File

@ -11,7 +11,7 @@
#include "src/asmjs/asm-scanner.h"
#include "src/asmjs/asm-types.h"
#include "src/base/enum-set.h"
#include "src/utils/vector.h"
#include "src/base/vector.h"
#include "src/wasm/wasm-module-builder.h"
#include "src/zone/zone-containers.h"
@ -82,11 +82,11 @@ class AsmJsParser {
// function is used with different signatures. {cache} keeps the wasm
// imports for the single asm.js import of name {function_name}.
struct FunctionImportInfo {
Vector<const char> function_name;
base::Vector<const char> function_name;
ZoneUnorderedMap<FunctionSig, uint32_t> cache;
// Constructor.
FunctionImportInfo(Vector<const char> name, Zone* zone)
FunctionImportInfo(base::Vector<const char> name, Zone* zone)
: function_name(name), cache(zone) {}
};
@ -102,7 +102,7 @@ class AsmJsParser {
};
struct GlobalImport {
Vector<const char> import_name;
base::Vector<const char> import_name;
ValueType value_type;
VarInfo* var_info;
};
@ -171,8 +171,8 @@ class AsmJsParser {
AsmType* return_type_ = nullptr;
uintptr_t stack_limit_;
StdlibSet stdlib_uses_;
Vector<VarInfo> global_var_info_;
Vector<VarInfo> local_var_info_;
base::Vector<VarInfo> global_var_info_;
base::Vector<VarInfo> local_var_info_;
size_t num_globals_ = 0;
CachedVectors<ValueType> cached_valuetype_vectors_{zone_};
@ -316,15 +316,15 @@ class AsmJsParser {
void DeclareGlobal(VarInfo* info, bool mutable_variable, AsmType* type,
ValueType vtype, WasmInitExpr init = WasmInitExpr());
void DeclareStdlibFunc(VarInfo* info, VarKind kind, AsmType* type);
void AddGlobalImport(Vector<const char> name, AsmType* type, ValueType vtype,
bool mutable_variable, VarInfo* info);
void AddGlobalImport(base::Vector<const char> name, AsmType* type,
ValueType vtype, bool mutable_variable, VarInfo* info);
// Allocates a temporary local variable. The given {index} is absolute within
// the function body, consider using {TemporaryVariableScope} when nesting.
uint32_t TempVariable(int index);
// Preserves a copy of the scanner's current identifier string in the zone.
Vector<const char> CopyCurrentIdentifierString();
base::Vector<const char> CopyCurrentIdentifierString();
// Use to set up block stack layers (including synthetic ones for if-else).
// Begin/Loop/End below are implemented with these plus code generation.

View File

@ -85,7 +85,7 @@ void AsmJsScanner::Next() {
for (;;) {
position_ = stream_->pos();
uc32 ch = stream_->Advance();
base::uc32 ch = stream_->Advance();
switch (ch) {
case ' ':
case '\t':
@ -223,7 +223,7 @@ void AsmJsScanner::Seek(size_t pos) {
Next();
}
void AsmJsScanner::ConsumeIdentifier(uc32 ch) {
void AsmJsScanner::ConsumeIdentifier(base::uc32 ch) {
// Consume characters while still part of the identifier.
identifier_string_.clear();
while (IsIdentifierPart(ch)) {
@ -271,7 +271,7 @@ void AsmJsScanner::ConsumeIdentifier(uc32 ch) {
}
}
void AsmJsScanner::ConsumeNumber(uc32 ch) {
void AsmJsScanner::ConsumeNumber(base::uc32 ch) {
std::string number;
number.assign(1, ch);
bool has_dot = ch == '.';
@ -310,7 +310,7 @@ void AsmJsScanner::ConsumeNumber(uc32 ch) {
}
// Decode numbers.
double_value_ = StringToDouble(
Vector<const uint8_t>::cast(VectorOf(number)),
base::Vector<const uint8_t>::cast(base::VectorOf(number)),
ALLOW_HEX | ALLOW_OCTAL | ALLOW_BINARY | ALLOW_IMPLICIT_OCTAL);
if (std::isnan(double_value_)) {
// Check if string to number conversion didn't consume all the characters.
@ -344,7 +344,7 @@ void AsmJsScanner::ConsumeNumber(uc32 ch) {
bool AsmJsScanner::ConsumeCComment() {
for (;;) {
uc32 ch = stream_->Advance();
base::uc32 ch = stream_->Advance();
while (ch == '*') {
ch = stream_->Advance();
if (ch == '/') {
@ -362,7 +362,7 @@ bool AsmJsScanner::ConsumeCComment() {
void AsmJsScanner::ConsumeCPPComment() {
for (;;) {
uc32 ch = stream_->Advance();
base::uc32 ch = stream_->Advance();
if (ch == '\n') {
preceded_by_newline_ = true;
return;
@ -373,11 +373,11 @@ void AsmJsScanner::ConsumeCPPComment() {
}
}
void AsmJsScanner::ConsumeString(uc32 quote) {
void AsmJsScanner::ConsumeString(base::uc32 quote) {
// Only string allowed is 'use asm' / "use asm".
const char* expected = "use asm";
for (; *expected != '\0'; ++expected) {
if (stream_->Advance() != static_cast<uc32>(*expected)) {
if (stream_->Advance() != static_cast<base::uc32>(*expected)) {
token_ = kParseError;
return;
}
@ -389,8 +389,8 @@ void AsmJsScanner::ConsumeString(uc32 quote) {
token_ = kToken_UseAsm;
}
void AsmJsScanner::ConsumeCompareOrShift(uc32 ch) {
uc32 next_ch = stream_->Advance();
void AsmJsScanner::ConsumeCompareOrShift(base::uc32 ch) {
base::uc32 next_ch = stream_->Advance();
if (next_ch == '=') {
switch (ch) {
case '<':
@ -423,14 +423,16 @@ void AsmJsScanner::ConsumeCompareOrShift(uc32 ch) {
}
}
bool AsmJsScanner::IsIdentifierStart(uc32 ch) {
bool AsmJsScanner::IsIdentifierStart(base::uc32 ch) {
return base::IsInRange(AsciiAlphaToLower(ch), 'a', 'z') || ch == '_' ||
ch == '$';
}
bool AsmJsScanner::IsIdentifierPart(uc32 ch) { return IsAsciiIdentifier(ch); }
bool AsmJsScanner::IsIdentifierPart(base::uc32 ch) {
return IsAsciiIdentifier(ch);
}
bool AsmJsScanner::IsNumberStart(uc32 ch) {
bool AsmJsScanner::IsNumberStart(base::uc32 ch) {
return ch == '.' || IsDecimalDigit(ch);
}

View File

@ -11,6 +11,7 @@
#include "src/asmjs/asm-names.h"
#include "src/base/logging.h"
#include "src/base/strings.h"
#include "src/common/globals.h"
namespace v8 {
@ -135,7 +136,8 @@ class V8_EXPORT_PRIVATE AsmJsScanner {
};
// clang-format on
static constexpr uc32 kEndOfInputU = static_cast<uc32>(kEndOfInput);
static constexpr base::uc32 kEndOfInputU =
static_cast<base::uc32>(kEndOfInput);
private:
Utf16CharacterStream* stream_;
@ -157,17 +159,17 @@ class V8_EXPORT_PRIVATE AsmJsScanner {
bool preceded_by_newline_;
// Consume multiple characters.
void ConsumeIdentifier(uc32 ch);
void ConsumeNumber(uc32 ch);
void ConsumeIdentifier(base::uc32 ch);
void ConsumeNumber(base::uc32 ch);
bool ConsumeCComment();
void ConsumeCPPComment();
void ConsumeString(uc32 quote);
void ConsumeCompareOrShift(uc32 ch);
void ConsumeString(base::uc32 quote);
void ConsumeCompareOrShift(base::uc32 ch);
// Classify character categories.
bool IsIdentifierStart(uc32 ch);
bool IsIdentifierPart(uc32 ch);
bool IsNumberStart(uc32 ch);
bool IsIdentifierStart(base::uc32 ch);
bool IsIdentifierPart(base::uc32 ch);
bool IsNumberStart(base::uc32 ch);
};
} // namespace internal

View File

@ -48,14 +48,14 @@ namespace {
// For using StringToIndex.
class OneByteStringStream {
public:
explicit OneByteStringStream(Vector<const byte> lb)
explicit OneByteStringStream(base::Vector<const byte> lb)
: literal_bytes_(lb), pos_(0) {}
bool HasMore() { return pos_ < literal_bytes_.length(); }
uint16_t GetNext() { return literal_bytes_[pos_++]; }
private:
Vector<const byte> literal_bytes_;
base::Vector<const byte> literal_bytes_;
int pos_;
};
@ -71,7 +71,7 @@ void AstRawString::Internalize(IsolateT* isolate) {
set_string(isolate->factory()->InternalizeStringWithKey(&key));
} else {
TwoByteStringKey key(raw_hash_field_,
Vector<const uint16_t>::cast(literal_bytes_));
base::Vector<const uint16_t>::cast(literal_bytes_));
set_string(isolate->factory()->InternalizeStringWithKey(&key));
}
}
@ -299,8 +299,9 @@ AstStringConstants::AstStringConstants(Isolate* isolate, uint64_t hash_seed)
#define F(name, str) \
{ \
const char* data = str; \
Vector<const uint8_t> literal(reinterpret_cast<const uint8_t*>(data), \
static_cast<int>(strlen(data))); \
base::Vector<const uint8_t> literal( \
reinterpret_cast<const uint8_t*>(data), \
static_cast<int>(strlen(data))); \
uint32_t raw_hash_field = StringHasher::HashSequentialString<uint8_t>( \
literal.begin(), literal.length(), hash_seed_); \
name##_string_ = zone_.New<AstRawString>(true, literal, raw_hash_field); \
@ -314,7 +315,7 @@ AstStringConstants::AstStringConstants(Isolate* isolate, uint64_t hash_seed)
}
const AstRawString* AstValueFactory::GetOneByteStringInternal(
Vector<const uint8_t> literal) {
base::Vector<const uint8_t> literal) {
if (literal.length() == 1 && literal[0] < kMaxOneCharStringValue) {
int key = literal[0];
if (V8_UNLIKELY(one_character_strings_[key] == nullptr)) {
@ -330,10 +331,11 @@ const AstRawString* AstValueFactory::GetOneByteStringInternal(
}
const AstRawString* AstValueFactory::GetTwoByteStringInternal(
Vector<const uint16_t> literal) {
base::Vector<const uint16_t> literal) {
uint32_t raw_hash_field = StringHasher::HashSequentialString<uint16_t>(
literal.begin(), literal.length(), hash_seed_);
return GetString(raw_hash_field, false, Vector<const byte>::cast(literal));
return GetString(raw_hash_field, false,
base::Vector<const byte>::cast(literal));
}
const AstRawString* AstValueFactory::GetString(Handle<String> literal) {
@ -351,9 +353,10 @@ const AstRawString* AstValueFactory::GetString(Handle<String> literal) {
const AstRawString* AstValueFactory::CloneFromOtherFactory(
const AstRawString* raw_string) {
const AstRawString* result = GetString(
raw_string->raw_hash_field(), raw_string->is_one_byte(),
Vector<const byte>(raw_string->raw_data(), raw_string->byte_length()));
const AstRawString* result =
GetString(raw_string->raw_hash_field(), raw_string->is_one_byte(),
base::Vector<const byte>(raw_string->raw_data(),
raw_string->byte_length()));
return result;
}
@ -392,7 +395,7 @@ template EXPORT_TEMPLATE_DEFINE(
const AstRawString* AstValueFactory::GetString(
uint32_t raw_hash_field, bool is_one_byte,
Vector<const byte> literal_bytes) {
base::Vector<const byte> literal_bytes) {
// literal_bytes here points to whatever the user passed, and this is OK
// because we use vector_compare (which checks the contents) to compare
// against the AstRawStrings which are in the string_table_. We should not
@ -404,9 +407,9 @@ const AstRawString* AstValueFactory::GetString(
// Copy literal contents for later comparison.
int length = literal_bytes.length();
byte* new_literal_bytes = zone()->NewArray<byte>(length);
base::Memcpy(new_literal_bytes, literal_bytes.begin(), length);
memcpy(new_literal_bytes, literal_bytes.begin(), length);
AstRawString* new_string = zone()->New<AstRawString>(
is_one_byte, Vector<const byte>(new_literal_bytes, length),
is_one_byte, base::Vector<const byte>(new_literal_bytes, length),
raw_hash_field);
CHECK_NOT_NULL(new_string);
AddString(new_string);

View File

@ -96,7 +96,7 @@ class AstRawString final : public ZoneObject {
friend Zone;
// Members accessed only by the AstValueFactory & related classes:
AstRawString(bool is_one_byte, const Vector<const byte>& literal_bytes,
AstRawString(bool is_one_byte, const base::Vector<const byte>& literal_bytes,
uint32_t raw_hash_field)
: next_(nullptr),
literal_bytes_(literal_bytes),
@ -125,7 +125,7 @@ class AstRawString final : public ZoneObject {
Handle<String> string_;
};
Vector<const byte> literal_bytes_; // Memory owned by Zone.
base::Vector<const byte> literal_bytes_; // Memory owned by Zone.
uint32_t raw_hash_field_;
bool is_one_byte_;
#ifdef DEBUG
@ -331,13 +331,13 @@ class AstValueFactory {
return zone_;
}
const AstRawString* GetOneByteString(Vector<const uint8_t> literal) {
const AstRawString* GetOneByteString(base::Vector<const uint8_t> literal) {
return GetOneByteStringInternal(literal);
}
const AstRawString* GetOneByteString(const char* string) {
return GetOneByteString(OneByteVector(string));
return GetOneByteString(base::OneByteVector(string));
}
const AstRawString* GetTwoByteString(Vector<const uint16_t> literal) {
const AstRawString* GetTwoByteString(base::Vector<const uint16_t> literal) {
return GetTwoByteStringInternal(literal);
}
const AstRawString* GetString(Handle<String> literal);
@ -376,10 +376,11 @@ class AstValueFactory {
strings_end_ = &strings_;
}
V8_EXPORT_PRIVATE const AstRawString* GetOneByteStringInternal(
Vector<const uint8_t> literal);
const AstRawString* GetTwoByteStringInternal(Vector<const uint16_t> literal);
base::Vector<const uint8_t> literal);
const AstRawString* GetTwoByteStringInternal(
base::Vector<const uint16_t> literal);
const AstRawString* GetString(uint32_t raw_hash_field, bool is_one_byte,
Vector<const byte> literal_bytes);
base::Vector<const byte> literal_bytes);
// All strings are copied here.
AstRawStringMap string_table_;

View File

@ -11,13 +11,13 @@
#include "src/ast/scopes.h"
#include "src/base/hashmap.h"
#include "src/base/logging.h"
#include "src/base/numbers/double.h"
#include "src/base/platform/wrappers.h"
#include "src/builtins/builtins-constructor.h"
#include "src/builtins/builtins.h"
#include "src/common/assert-scope.h"
#include "src/heap/local-factory-inl.h"
#include "src/numbers/conversions-inl.h"
#include "src/numbers/double.h"
#include "src/objects/contexts.h"
#include "src/objects/elements-kind.h"
#include "src/objects/elements.h"
@ -259,7 +259,7 @@ std::unique_ptr<char[]> FunctionLiteral::GetDebugName() const {
}
}
std::unique_ptr<char[]> result(new char[result_vec.size() + 1]);
base::Memcpy(result.get(), result_vec.data(), result_vec.size());
memcpy(result.get(), result_vec.data(), result_vec.size());
result[result_vec.size()] = '\0';
return result;
}
@ -482,9 +482,9 @@ void ObjectLiteral::BuildBoilerplateDescription(IsolateT* isolate) {
m_literal->BuildConstants(isolate);
}
// Add CONSTANT and COMPUTED properties to boilerplate. Use undefined
// value for COMPUTED properties, the real value is filled in at
// runtime. The enumeration order is maintained.
// Add CONSTANT and COMPUTED properties to boilerplate. Use the
// 'uninitialized' Oddball for COMPUTED properties, the real value is filled
// in at runtime. The enumeration order is maintained.
Literal* key_literal = property->key()->AsLiteral();
uint32_t element_index = 0;
Handle<Object> key =
@ -493,10 +493,7 @@ void ObjectLiteral::BuildBoilerplateDescription(IsolateT* isolate) {
->template NewNumberFromUint<AllocationType::kOld>(
element_index)
: Handle<Object>::cast(key_literal->AsRawPropertyName()->string());
Handle<Object> value = GetBoilerplateValue(property->value(), isolate);
// Add name, value pair to the fixed array.
boilerplate_description->set_key_value(position++, *key, *value);
}
@ -1040,14 +1037,25 @@ bool Literal::ToBooleanIsTrue() const {
}
uint32_t Literal::Hash() {
uint32_t index;
if (AsArrayIndex(&index)) {
// Treat array indices as numbers, so that array indices are de-duped
// correctly even if one of them is a string and the other is a number.
return ComputeLongHash(index);
}
return IsString() ? AsRawString()->Hash()
: ComputeLongHash(double_to_uint64(AsNumber()));
: ComputeLongHash(base::double_to_uint64(AsNumber()));
}
// static
bool Literal::Match(void* a, void* b) {
Literal* x = static_cast<Literal*>(a);
Literal* y = static_cast<Literal*>(b);
uint32_t index_x;
uint32_t index_y;
if (x->AsArrayIndex(&index_x)) {
return y->AsArrayIndex(&index_y) && index_x == index_y;
}
return (x->IsString() && y->IsString() &&
x->AsRawString() == y->AsRawString()) ||
(x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber());

41
deps/v8/src/ast/ast.h vendored
View File

@ -2137,10 +2137,6 @@ class FunctionLiteral final : public Expression {
return syntax_kind() == FunctionSyntaxKind::kAnonymousExpression;
}
void mark_as_oneshot_iife() {
bit_field_ = OneshotIIFEBit::update(bit_field_, true);
}
bool is_oneshot_iife() const { return OneshotIIFEBit::decode(bit_field_); }
bool is_toplevel() const {
return function_literal_id() == kFunctionLiteralIdTopLevel;
}
@ -2296,8 +2292,7 @@ class FunctionLiteral final : public Expression {
kHasDuplicateParameters) |
DontOptimizeReasonField::encode(BailoutReason::kNoReason) |
RequiresInstanceMembersInitializer::encode(false) |
HasBracesField::encode(has_braces) |
OneshotIIFEBit::encode(false);
HasBracesField::encode(has_braces);
if (eager_compile_hint == kShouldEagerCompile) SetShouldEagerCompile();
}
@ -2314,7 +2309,6 @@ class FunctionLiteral final : public Expression {
using HasStaticPrivateMethodsOrAccessorsField =
ClassScopeHasPrivateBrandField::Next<bool, 1>;
using HasBracesField = HasStaticPrivateMethodsOrAccessorsField::Next<bool, 1>;
using OneshotIIFEBit = HasBracesField::Next<bool, 1>;
// expected_property_count_ is the sum of instance fields and properties.
// It can vary depending on whether a function is lazily or eagerly parsed.
@ -2459,9 +2453,6 @@ class ClassLiteral final : public Expression {
ZonePtrList<Property>* private_members() const { return private_members_; }
int start_position() const { return position(); }
int end_position() const { return end_position_; }
bool has_name_static_property() const {
return HasNameStaticProperty::decode(bit_field_);
}
bool has_static_computed_names() const {
return HasStaticComputedNames::decode(bit_field_);
}
@ -2497,9 +2488,9 @@ class ClassLiteral final : public Expression {
FunctionLiteral* static_initializer,
FunctionLiteral* instance_members_initializer_function,
int start_position, int end_position,
bool has_name_static_property, bool has_static_computed_names,
bool is_anonymous, bool has_private_methods,
Variable* home_object, Variable* static_home_object)
bool has_static_computed_names, bool is_anonymous,
bool has_private_methods, Variable* home_object,
Variable* static_home_object)
: Expression(start_position, kClassLiteral),
end_position_(end_position),
scope_(scope),
@ -2512,8 +2503,7 @@ class ClassLiteral final : public Expression {
instance_members_initializer_function),
home_object_(home_object),
static_home_object_(static_home_object) {
bit_field_ |= HasNameStaticProperty::encode(has_name_static_property) |
HasStaticComputedNames::encode(has_static_computed_names) |
bit_field_ |= HasStaticComputedNames::encode(has_static_computed_names) |
IsAnonymousExpression::encode(is_anonymous) |
HasPrivateMethods::encode(has_private_methods);
}
@ -2526,8 +2516,7 @@ class ClassLiteral final : public Expression {
ZonePtrList<Property>* private_members_;
FunctionLiteral* static_initializer_;
FunctionLiteral* instance_members_initializer_function_;
using HasNameStaticProperty = Expression::NextBitField<bool, 1>;
using HasStaticComputedNames = HasNameStaticProperty::Next<bool, 1>;
using HasStaticComputedNames = Expression::NextBitField<bool, 1>;
using IsAnonymousExpression = HasStaticComputedNames::Next<bool, 1>;
using HasPrivateMethods = IsAnonymousExpression::Next<bool, 1>;
Variable* home_object_;
@ -2909,14 +2898,6 @@ class AstNodeFactory final {
HandlerTable::UNCAUGHT, pos);
}
TryCatchStatement* NewTryCatchStatementForDesugaring(Block* try_block,
Scope* scope,
Block* catch_block,
int pos) {
return zone_->New<TryCatchStatement>(try_block, scope, catch_block,
HandlerTable::DESUGARING, pos);
}
TryCatchStatement* NewTryCatchStatementForAsyncAwait(Block* try_block,
Scope* scope,
Block* catch_block,
@ -3257,16 +3238,14 @@ class AstNodeFactory final {
ZonePtrList<ClassLiteral::Property>* private_members,
FunctionLiteral* static_initializer,
FunctionLiteral* instance_members_initializer_function,
int start_position, int end_position, bool has_name_static_property,
bool has_static_computed_names, bool is_anonymous,
bool has_private_methods, Variable* home_object,
int start_position, int end_position, bool has_static_computed_names,
bool is_anonymous, bool has_private_methods, Variable* home_object,
Variable* static_home_object) {
return zone_->New<ClassLiteral>(
scope, extends, constructor, public_members, private_members,
static_initializer, instance_members_initializer_function,
start_position, end_position, has_name_static_property,
has_static_computed_names, is_anonymous, has_private_methods,
home_object, static_home_object);
start_position, end_position, has_static_computed_names, is_anonymous,
has_private_methods, home_object, static_home_object);
}
NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name,

View File

@ -6,6 +6,7 @@
#include "src/ast/ast-value-factory.h"
#include "src/ast/scopes.h"
#include "src/common/globals.h"
#include "src/heap/local-factory-inl.h"
#include "src/objects/module-inl.h"
#include "src/objects/objects-inl.h"
@ -130,8 +131,10 @@ Handle<ModuleRequest> SourceTextModuleDescriptor::AstModuleRequest::Serialize(
// The import assertions will be stored in this array in the form:
// [key1, value1, location1, key2, value2, location2, ...]
Handle<FixedArray> import_assertions_array =
isolate->factory()->NewFixedArray(static_cast<int>(
import_assertions()->size() * ModuleRequest::kAssertionEntrySize));
isolate->factory()->NewFixedArray(
static_cast<int>(import_assertions()->size() *
ModuleRequest::kAssertionEntrySize),
AllocationType::kOld);
int i = 0;
for (auto iter = import_assertions()->cbegin();
@ -189,7 +192,8 @@ Handle<FixedArray> SourceTextModuleDescriptor::SerializeRegularExports(
++count;
} while (next != regular_exports_.end() && next->first == it->first);
Handle<FixedArray> export_names = isolate->factory()->NewFixedArray(count);
Handle<FixedArray> export_names =
isolate->factory()->NewFixedArray(count, AllocationType::kOld);
data[index + SourceTextModuleInfo::kRegularExportLocalNameOffset] =
it->second->local_name->string();
data[index + SourceTextModuleInfo::kRegularExportCellIndexOffset] =
@ -213,7 +217,8 @@ Handle<FixedArray> SourceTextModuleDescriptor::SerializeRegularExports(
// We cannot create the FixedArray earlier because we only now know the
// precise size.
Handle<FixedArray> result = isolate->factory()->NewFixedArray(index);
Handle<FixedArray> result =
isolate->factory()->NewFixedArray(index, AllocationType::kOld);
for (int i = 0; i < index; ++i) {
result->set(i, *data[i]);
}

View File

@ -9,10 +9,11 @@
#include "src/ast/ast-value-factory.h"
#include "src/ast/scopes.h"
#include "src/base/platform/platform.h"
#include "src/base/strings.h"
#include "src/base/vector.h"
#include "src/common/globals.h"
#include "src/objects/objects-inl.h"
#include "src/strings/string-builder-inl.h"
#include "src/utils/vector.h"
namespace v8 {
namespace internal {
@ -648,9 +649,8 @@ void AstPrinter::Print(const char* format, ...) {
for (;;) {
va_list arguments;
va_start(arguments, format);
int n = VSNPrintF(Vector<char>(output_, size_) + pos_,
format,
arguments);
int n = base::VSNPrintF(base::Vector<char>(output_, size_) + pos_, format,
arguments);
va_end(arguments);
if (n >= 0) {
@ -802,7 +802,7 @@ void AstPrinter::PrintLiteralWithModeIndented(const char* info, Variable* var,
if (var == nullptr) {
PrintLiteralIndented(info, value, true);
} else {
EmbeddedVector<char, 256> buf;
base::EmbeddedVector<char, 256> buf;
int pos =
SNPrintF(buf, "%s (%p) (mode = %s, assigned = %s", info,
reinterpret_cast<void*>(var), VariableMode2String(var->mode()),
@ -1038,9 +1038,6 @@ void AstPrinter::VisitTryCatchStatement(TryCatchStatement* node) {
case HandlerTable::CAUGHT:
prediction = "CAUGHT";
break;
case HandlerTable::DESUGARING:
prediction = "DESUGARING";
break;
case HandlerTable::ASYNC_AWAIT:
prediction = "ASYNC_AWAIT";
break;
@ -1138,7 +1135,7 @@ void AstPrinter::PrintClassProperty(ClassLiteral::Property* property) {
prop_kind = "FIELD";
break;
}
EmbeddedVector<char, 128> buf;
base::EmbeddedVector<char, 128> buf;
SNPrintF(buf, "PROPERTY%s%s - %s", property->is_static() ? " - STATIC" : "",
property->is_private() ? " - PRIVATE" : " - PUBLIC", prop_kind);
IndentedScope prop(this, buf.begin());
@ -1191,7 +1188,7 @@ void AstPrinter::VisitRegExpLiteral(RegExpLiteral* node) {
IndentedScope indent(this, "REGEXP LITERAL", node->position());
PrintLiteralIndented("PATTERN", node->raw_pattern(), false);
int i = 0;
EmbeddedVector<char, 128> buf;
base::EmbeddedVector<char, 128> buf;
if (node->flags() & RegExp::kHasIndices) buf[i++] = 'd';
if (node->flags() & RegExp::kGlobal) buf[i++] = 'g';
if (node->flags() & RegExp::kIgnoreCase) buf[i++] = 'i';
@ -1239,7 +1236,7 @@ void AstPrinter::PrintObjectProperties(
prop_kind = "SPREAD";
break;
}
EmbeddedVector<char, 128> buf;
base::EmbeddedVector<char, 128> buf;
SNPrintF(buf, "PROPERTY - %s", prop_kind);
IndentedScope prop(this, buf.begin());
PrintIndentedVisit("KEY", properties->at(i)->key());
@ -1260,7 +1257,7 @@ void AstPrinter::VisitArrayLiteral(ArrayLiteral* node) {
void AstPrinter::VisitVariableProxy(VariableProxy* node) {
EmbeddedVector<char, 128> buf;
base::EmbeddedVector<char, 128> buf;
int pos = SNPrintF(buf, "VAR PROXY");
if (!node->is_resolved()) {
@ -1307,21 +1304,21 @@ void AstPrinter::VisitCompoundAssignment(CompoundAssignment* node) {
}
void AstPrinter::VisitYield(Yield* node) {
EmbeddedVector<char, 128> buf;
base::EmbeddedVector<char, 128> buf;
SNPrintF(buf, "YIELD");
IndentedScope indent(this, buf.begin(), node->position());
Visit(node->expression());
}
void AstPrinter::VisitYieldStar(YieldStar* node) {
EmbeddedVector<char, 128> buf;
base::EmbeddedVector<char, 128> buf;
SNPrintF(buf, "YIELD_STAR");
IndentedScope indent(this, buf.begin(), node->position());
Visit(node->expression());
}
void AstPrinter::VisitAwait(Await* node) {
EmbeddedVector<char, 128> buf;
base::EmbeddedVector<char, 128> buf;
SNPrintF(buf, "AWAIT");
IndentedScope indent(this, buf.begin(), node->position());
Visit(node->expression());
@ -1338,7 +1335,7 @@ void AstPrinter::VisitOptionalChain(OptionalChain* node) {
}
void AstPrinter::VisitProperty(Property* node) {
EmbeddedVector<char, 128> buf;
base::EmbeddedVector<char, 128> buf;
SNPrintF(buf, "PROPERTY");
IndentedScope indent(this, buf.begin(), node->position());
@ -1377,7 +1374,7 @@ void AstPrinter::VisitProperty(Property* node) {
}
void AstPrinter::VisitCall(Call* node) {
EmbeddedVector<char, 128> buf;
base::EmbeddedVector<char, 128> buf;
SNPrintF(buf, "CALL");
IndentedScope indent(this, buf.begin());
@ -1394,7 +1391,7 @@ void AstPrinter::VisitCallNew(CallNew* node) {
void AstPrinter::VisitCallRuntime(CallRuntime* node) {
EmbeddedVector<char, 128> buf;
base::EmbeddedVector<char, 128> buf;
SNPrintF(buf, "CALL RUNTIME %s%s", node->debug_name(),
node->is_jsruntime() ? " (JS function)" : "");
IndentedScope indent(this, buf.begin(), node->position());
@ -1409,7 +1406,7 @@ void AstPrinter::VisitUnaryOperation(UnaryOperation* node) {
void AstPrinter::VisitCountOperation(CountOperation* node) {
EmbeddedVector<char, 128> buf;
base::EmbeddedVector<char, 128> buf;
SNPrintF(buf, "%s %s", (node->is_prefix() ? "PRE" : "POST"),
Token::Name(node->op()));
IndentedScope indent(this, buf.begin(), node->position());

View File

@ -13,7 +13,7 @@
#include "src/common/message-template.h"
#include "src/heap/local-factory-inl.h"
#include "src/init/bootstrapper.h"
#include "src/logging/counters.h"
#include "src/logging/runtime-call-stats-scope.h"
#include "src/objects/module-inl.h"
#include "src/objects/objects-inl.h"
#include "src/objects/scope-info.h"
@ -241,15 +241,11 @@ Scope::Scope(Zone* zone, ScopeType scope_type,
if (scope_type == BLOCK_SCOPE) {
// Set is_block_scope_for_object_literal_ based on the existince of the home
// object variable (we don't store it explicitly).
VariableMode mode;
InitializationFlag init_flag;
MaybeAssignedFlag maybe_assigned_flag;
IsStaticFlag is_static_flag;
VariableLookupResult lookup_result;
DCHECK_NOT_NULL(ast_value_factory);
int home_object_index = ScopeInfo::ContextSlotIndex(
*scope_info, *(ast_value_factory->dot_home_object_string()->string()),
&mode, &init_flag, &maybe_assigned_flag, &is_static_flag);
&lookup_result);
DCHECK_IMPLIES(home_object_index >= 0,
scope_type == CLASS_SCOPE || scope_type == BLOCK_SCOPE);
if (home_object_index >= 0) {
@ -903,23 +899,20 @@ Variable* Scope::LookupInScopeInfo(const AstRawString* name, Scope* cache) {
VariableLocation location;
int index;
VariableMode mode;
InitializationFlag init_flag;
MaybeAssignedFlag maybe_assigned_flag;
IsStaticFlag is_static_flag;
VariableLookupResult lookup_result;
{
location = VariableLocation::CONTEXT;
index =
ScopeInfo::ContextSlotIndex(scope_info, name_handle, &mode, &init_flag,
&maybe_assigned_flag, &is_static_flag);
ScopeInfo::ContextSlotIndex(scope_info, name_handle, &lookup_result);
found = index >= 0;
}
if (!found && is_module_scope()) {
location = VariableLocation::MODULE;
index = scope_info.ModuleIndex(name_handle, &mode, &init_flag,
&maybe_assigned_flag);
index = scope_info.ModuleIndex(name_handle, &lookup_result.mode,
&lookup_result.init_flag,
&lookup_result.maybe_assigned_flag);
found = index != 0;
}
@ -938,7 +931,8 @@ Variable* Scope::LookupInScopeInfo(const AstRawString* name, Scope* cache) {
bool was_added;
Variable* var = cache->variables_.Declare(
zone(), this, name, mode, NORMAL_VARIABLE, init_flag, maybe_assigned_flag,
zone(), this, name, lookup_result.mode, NORMAL_VARIABLE,
lookup_result.init_flag, lookup_result.maybe_assigned_flag,
IsStaticFlag::kNotStatic, &was_added);
DCHECK(was_added);
var->AllocateTo(location, index);
@ -2753,25 +2747,22 @@ Variable* ClassScope::LookupPrivateNameInScopeInfo(const AstRawString* name) {
DisallowGarbageCollection no_gc;
String name_handle = *name->string();
VariableMode mode;
InitializationFlag init_flag;
MaybeAssignedFlag maybe_assigned_flag;
IsStaticFlag is_static_flag;
VariableLookupResult lookup_result;
int index =
ScopeInfo::ContextSlotIndex(*scope_info_, name_handle, &mode, &init_flag,
&maybe_assigned_flag, &is_static_flag);
ScopeInfo::ContextSlotIndex(*scope_info_, name_handle, &lookup_result);
if (index < 0) {
return nullptr;
}
DCHECK(IsConstVariableMode(mode));
DCHECK_EQ(init_flag, InitializationFlag::kNeedsInitialization);
DCHECK_EQ(maybe_assigned_flag, MaybeAssignedFlag::kNotAssigned);
DCHECK(IsConstVariableMode(lookup_result.mode));
DCHECK_EQ(lookup_result.init_flag, InitializationFlag::kNeedsInitialization);
DCHECK_EQ(lookup_result.maybe_assigned_flag, MaybeAssignedFlag::kNotAssigned);
// Add the found private name to the map to speed up subsequent
// lookups for the same name.
bool was_added;
Variable* var = DeclarePrivateName(name, mode, is_static_flag, &was_added);
Variable* var = DeclarePrivateName(name, lookup_result.mode,
lookup_result.is_static_flag, &was_added);
DCHECK(was_added);
var->AllocateTo(VariableLocation::CONTEXT, index);
return var;

View File

@ -6,6 +6,8 @@
#define V8_BASE_ATOMIC_UTILS_H_
#include <limits.h>
#include <atomic>
#include <type_traits>
#include "src/base/atomicops.h"
@ -189,16 +191,20 @@ using AsAtomicPointer = AsAtomicPointerImpl<base::AtomicWord>;
template <typename T,
typename = typename std::enable_if<std::is_unsigned<T>::value>::type>
inline void CheckedIncrement(std::atomic<T>* number, T amount) {
const T old = number->fetch_add(amount);
inline void CheckedIncrement(
std::atomic<T>* number, T amount,
std::memory_order order = std::memory_order_seq_cst) {
const T old = number->fetch_add(amount, order);
DCHECK_GE(old + amount, old);
USE(old);
}
template <typename T,
typename = typename std::enable_if<std::is_unsigned<T>::value>::type>
inline void CheckedDecrement(std::atomic<T>* number, T amount) {
const T old = number->fetch_sub(amount);
inline void CheckedDecrement(
std::atomic<T>* number, T amount,
std::memory_order order = std::memory_order_seq_cst) {
const T old = number->fetch_sub(amount, order);
DCHECK_GE(old, amount);
USE(old);
}

View File

@ -41,10 +41,6 @@
#if defined(V8_OS_STARBOARD)
#include "starboard/atomic.h"
#if SB_API_VERSION < 10
#error Your version of Starboard must support SbAtomic8 in order to use V8.
#endif // SB_API_VERSION < 10
#endif // V8_OS_STARBOARD
namespace v8 {

View File

@ -223,6 +223,12 @@ constexpr int kReturnAddressStackSlotCount =
#if defined(V8_TARGET_ARCH_PPC) || defined(V8_TARGET_ARCH_PPC64)
// PPC has large (64KB) physical pages.
const int kPageSizeBits = 19;
#elif defined(ENABLE_HUGEPAGE)
// When enabling huge pages, adjust V8 page size to take up exactly one huge
// page. This avoids huge-page-internal fragmentation for unused address ranges.
const int kHugePageBits = 21;
const int kHugePageSize = (1U) << kHugePageBits;
const int kPageSizeBits = kHugePageBits;
#else
// Arm64 supports up to 64k OS pages on Linux, however 4k pages are more common
// so we keep the V8 page size at 256k. Nonetheless, we need to make sure we

View File

@ -4,7 +4,7 @@
#include "src/base/cpu.h"
#if defined(STARBOARD)
#if defined(V8_OS_STARBOARD)
#include "starboard/cpu_features.h"
#endif
@ -316,7 +316,7 @@ class CPUInfo final {
size_t len = q - p;
char* result = new char[len + 1];
if (result != nullptr) {
base::Memcpy(result, p, len);
memcpy(result, p, len);
result[len] = '\0';
}
return result;
@ -356,10 +356,9 @@ static bool HasListItem(const char* list, const char* item) {
#endif // V8_HOST_ARCH_ARM || V8_HOST_ARCH_ARM64 ||
// V8_HOST_ARCH_MIPS || V8_HOST_ARCH_MIPS64
#if defined(STARBOARD)
#if defined(V8_OS_STARBOARD)
bool CPU::StarboardDetectCPU() {
#if (SB_API_VERSION >= 11)
SbCPUFeatures features;
if (!SbCPUFeaturesGet(&features)) {
return false;
@ -398,9 +397,6 @@ bool CPU::StarboardDetectCPU() {
}
return true;
#else // SB_API_VERSION >= 11
return false;
#endif
}
#endif
@ -448,9 +444,9 @@ CPU::CPU()
has_non_stop_time_stamp_counter_(false),
is_running_in_vm_(false),
has_msa_(false) {
base::Memcpy(vendor_, "Unknown", 8);
memcpy(vendor_, "Unknown", 8);
#if defined(STARBOARD)
#if defined(V8_OS_STARBOARD)
if (StarboardDetectCPU()) {
return;
}
@ -469,7 +465,7 @@ CPU::CPU()
__cpuid(cpu_info, 0);
unsigned num_ids = cpu_info[0];
std::swap(cpu_info[2], cpu_info[3]);
base::Memcpy(vendor_, cpu_info + 1, 12);
memcpy(vendor_, cpu_info + 1, 12);
vendor_[12] = '\0';
// Interpret CPU feature information.

View File

@ -120,6 +120,9 @@ class V8_BASE_EXPORT CPU final {
bool has_msa() const { return has_msa_; }
private:
#if defined(V8_OS_STARBOARD)
bool StarboardDetectCPU();
#endif
char vendor_[13];
int stepping_;
int model_;

View File

@ -22,8 +22,8 @@ std::unique_ptr<char[]> RelativePath(const char* exec_path, const char* name) {
}
size_t name_length = strlen(name);
auto buffer = std::make_unique<char[]>(basename_start + name_length + 1);
if (basename_start > 0) base::Memcpy(buffer.get(), exec_path, basename_start);
base::Memcpy(buffer.get() + basename_start, name, name_length);
if (basename_start > 0) memcpy(buffer.get(), exec_path, basename_start);
memcpy(buffer.get() + basename_start, name, name_length);
return buffer;
}

View File

@ -81,7 +81,7 @@ class Flags final {
constexpr operator mask_type() const { return mask_; }
constexpr bool operator!() const { return !mask_; }
Flags without(flag_type flag) { return *this & (~Flags(flag)); }
Flags without(flag_type flag) const { return *this & (~Flags(flag)); }
friend size_t hash_value(const Flags& flags) { return flags.mask_; }

View File

@ -198,7 +198,7 @@ TemplateHashMapImpl<Key, Value, MatchFun, AllocationPolicy>::
impl_.capacity_ = original->capacity();
impl_.occupancy_ = original->occupancy();
impl_.map_ = impl_.allocator().template NewArray<Entry>(capacity());
base::Memcpy(impl_.map_, original->impl_.map_, capacity() * sizeof(Entry));
memcpy(impl_.map_, original->impl_.map_, capacity() * sizeof(Entry));
}
template <typename Key, typename Value, typename MatchFun,

View File

@ -105,7 +105,7 @@ V8_INLINE Dest bit_cast(Source const& source) {
static_assert(sizeof(Dest) == sizeof(Source),
"source and dest must be same size");
Dest dest;
v8::base::Memcpy(&dest, &source, sizeof(dest));
memcpy(&dest, &source, sizeof(dest));
return dest;
}
@ -155,13 +155,6 @@ V8_INLINE Dest bit_cast(Source const& source) {
#endif
#endif
// Define DISABLE_ASAN macro.
#ifdef V8_USE_ADDRESS_SANITIZER
#define DISABLE_ASAN __attribute__((no_sanitize_address))
#else
#define DISABLE_ASAN
#endif
// Define V8_USE_MEMORY_SANITIZER macro.
#if defined(__has_feature)
#if __has_feature(memory_sanitizer)
@ -420,4 +413,18 @@ bool is_inbounds(float_t v) {
#define IF_WASM(V, ...)
#endif // V8_ENABLE_WEBASSEMBLY
// Defines IF_TSAN, to be used in macro lists for elements that should only be
// there if TSAN is enabled.
#ifdef V8_IS_TSAN
// EXPAND is needed to work around MSVC's broken __VA_ARGS__ expansion.
#define IF_TSAN(V, ...) EXPAND(V(__VA_ARGS__))
#else
#define IF_TSAN(V, ...)
#endif // V8_ENABLE_WEBASSEMBLY
#ifdef GOOGLE3
// Disable FRIEND_TEST macro in Google3.
#define FRIEND_TEST(test_case_name, test_name)
#endif
#endif // V8_BASE_MACROS_H_

View File

@ -32,14 +32,14 @@ template <typename V>
static inline V ReadUnalignedValue(Address p) {
ASSERT_TRIVIALLY_COPYABLE(V);
V r;
base::Memcpy(&r, reinterpret_cast<void*>(p), sizeof(V));
memcpy(&r, reinterpret_cast<void*>(p), sizeof(V));
return r;
}
template <typename V>
static inline void WriteUnalignedValue(Address p, V value) {
ASSERT_TRIVIALLY_COPYABLE(V);
base::Memcpy(reinterpret_cast<void*>(p), &value, sizeof(V));
memcpy(reinterpret_cast<void*>(p), &value, sizeof(V));
}
template <typename V>

View File

@ -2,17 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/numbers/bignum-dtoa.h"
#include "src/base/numbers/bignum-dtoa.h"
#include <cmath>
#include "src/base/logging.h"
#include "src/numbers/bignum.h"
#include "src/numbers/double.h"
#include "src/utils/utils.h"
#include "src/base/numbers/bignum.h"
#include "src/base/numbers/double.h"
namespace v8 {
namespace internal {
namespace base {
static int NormalizedExponent(uint64_t significand, int exponent) {
DCHECK_NE(significand, 0);
@ -604,5 +603,5 @@ static void FixupMultiply10(int estimated_power, bool is_even,
}
}
} // namespace internal
} // namespace base
} // namespace v8

View File

@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_NUMBERS_BIGNUM_DTOA_H_
#define V8_NUMBERS_BIGNUM_DTOA_H_
#ifndef V8_BASE_NUMBERS_BIGNUM_DTOA_H_
#define V8_BASE_NUMBERS_BIGNUM_DTOA_H_
#include "src/utils/vector.h"
#include "src/base/vector.h"
namespace v8 {
namespace internal {
namespace base {
enum BignumDtoaMode {
// Return the shortest correct representation.
@ -52,11 +52,11 @@ enum BignumDtoaMode {
// Halfway cases are again rounded up.
// 'BignumDtoa' expects the given buffer to be big enough to hold all digits
// and a terminating null-character.
V8_EXPORT_PRIVATE void BignumDtoa(double v, BignumDtoaMode mode,
int requested_digits, Vector<char> buffer,
int* length, int* point);
V8_BASE_EXPORT void BignumDtoa(double v, BignumDtoaMode mode,
int requested_digits, Vector<char> buffer,
int* length, int* point);
} // namespace internal
} // namespace base
} // namespace v8
#endif // V8_NUMBERS_BIGNUM_DTOA_H_
#endif // V8_BASE_NUMBERS_BIGNUM_DTOA_H_

View File

@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/numbers/bignum.h"
#include "src/utils/utils.h"
#include "src/base/numbers/bignum.h"
#include "src/base/strings.h"
namespace v8 {
namespace internal {
namespace base {
Bignum::Bignum()
: bigits_(bigits_buffer_, kBigitCapacity), used_digits_(0), exponent_(0) {
@ -712,5 +713,5 @@ void Bignum::SubtractTimes(const Bignum& other, int factor) {
DCHECK(Bignum::Equal(a, *this));
}
} // namespace internal
} // namespace base
} // namespace v8

View File

@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_NUMBERS_BIGNUM_H_
#define V8_NUMBERS_BIGNUM_H_
#ifndef V8_BASE_NUMBERS_BIGNUM_H_
#define V8_BASE_NUMBERS_BIGNUM_H_
#include "src/utils/vector.h"
#include "src/base/vector.h"
namespace v8 {
namespace internal {
namespace base {
class V8_EXPORT_PRIVATE Bignum {
class V8_BASE_EXPORT Bignum {
public:
// 3584 = 128 * 28. We can represent 2^3584 > 10^1000 accurately.
// This bignum can encode much bigger numbers, since it contains an
@ -115,7 +115,7 @@ class V8_EXPORT_PRIVATE Bignum {
int exponent_;
};
} // namespace internal
} // namespace base
} // namespace v8
#endif // V8_NUMBERS_BIGNUM_H_
#endif // V8_BASE_NUMBERS_BIGNUM_H_

View File

@ -2,18 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/numbers/cached-powers.h"
#include "src/base/numbers/cached-powers.h"
#include <limits.h>
#include <stdarg.h>
#include <stdint.h>
#include <cmath>
#include "src/base/logging.h"
#include "src/common/globals.h"
namespace v8 {
namespace internal {
namespace base {
struct CachedPower {
uint64_t significand;
@ -109,5 +109,5 @@ void PowersOfTenCache::GetCachedPowerForDecimalExponent(int requested_exponent,
DCHECK(requested_exponent < *found_exponent + kDecimalExponentDistance);
}
} // namespace internal
} // namespace base
} // namespace v8

View File

@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_NUMBERS_CACHED_POWERS_H_
#define V8_NUMBERS_CACHED_POWERS_H_
#ifndef V8_BASE_NUMBERS_CACHED_POWERS_H_
#define V8_BASE_NUMBERS_CACHED_POWERS_H_
#include "src/base/logging.h"
#include "src/numbers/diy-fp.h"
#include "src/base/numbers/diy-fp.h"
namespace v8 {
namespace internal {
namespace base {
class PowersOfTenCache {
public:
@ -37,7 +37,7 @@ class PowersOfTenCache {
int* found_exponent);
};
} // namespace internal
} // namespace base
} // namespace v8
#endif // V8_NUMBERS_CACHED_POWERS_H_
#endif // V8_BASE_NUMBERS_CACHED_POWERS_H_

View File

@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/numbers/diy-fp.h"
#include "src/base/numbers/diy-fp.h"
#include <stdint.h>
namespace v8 {
namespace internal {
namespace base {
void DiyFp::Multiply(const DiyFp& other) {
// Simply "emulates" a 128 bit multiplication.
@ -32,5 +32,5 @@ void DiyFp::Multiply(const DiyFp& other) {
f_ = result_f;
}
} // namespace internal
} // namespace base
} // namespace v8

View File

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_NUMBERS_DIY_FP_H_
#define V8_NUMBERS_DIY_FP_H_
#ifndef V8_BASE_NUMBERS_DIY_FP_H_
#define V8_BASE_NUMBERS_DIY_FP_H_
#include <stdint.h>
@ -11,7 +11,7 @@
#include "src/base/macros.h"
namespace v8 {
namespace internal {
namespace base {
// This "Do It Yourself Floating Point" class implements a floating-point number
// with a uint64 significand and an int exponent. Normalized DiyFp numbers will
@ -45,7 +45,7 @@ class DiyFp {
}
// this = this * other.
V8_EXPORT_PRIVATE void Multiply(const DiyFp& other);
V8_BASE_EXPORT void Multiply(const DiyFp& other);
// returns a * b;
static DiyFp Times(const DiyFp& a, const DiyFp& b) {
@ -93,7 +93,7 @@ class DiyFp {
int e_;
};
} // namespace internal
} // namespace base
} // namespace v8
#endif // V8_NUMBERS_DIY_FP_H_
#endif // V8_BASE_NUMBERS_DIY_FP_H_

View File

@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_NUMBERS_DOUBLE_H_
#define V8_NUMBERS_DOUBLE_H_
#ifndef V8_BASE_NUMBERS_DOUBLE_H_
#define V8_BASE_NUMBERS_DOUBLE_H_
#include "src/base/macros.h"
#include "src/numbers/diy-fp.h"
#include "src/base/numbers/diy-fp.h"
namespace v8 {
namespace internal {
namespace base {
// We assume that doubles and uint64_t have the same endianness.
inline uint64_t double_to_uint64(double d) { return bit_cast<uint64_t>(d); }
@ -204,7 +204,7 @@ class Double {
}
};
} // namespace internal
} // namespace base
} // namespace v8
#endif // V8_NUMBERS_DOUBLE_H_
#endif // V8_BASE_NUMBERS_DOUBLE_H_

View File

@ -2,20 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/base/numbers/dtoa.h"
#include <cmath>
#include "src/base/logging.h"
#include "src/utils/utils.h"
#include "src/numbers/dtoa.h"
#include "src/numbers/bignum-dtoa.h"
#include "src/numbers/double.h"
#include "src/numbers/fast-dtoa.h"
#include "src/numbers/fixed-dtoa.h"
#include "src/base/numbers/bignum-dtoa.h"
#include "src/base/numbers/double.h"
#include "src/base/numbers/fast-dtoa.h"
#include "src/base/numbers/fixed-dtoa.h"
namespace v8 {
namespace internal {
namespace base {
static BignumDtoaMode DtoaToBignumDtoaMode(DtoaMode dtoa_mode) {
switch (dtoa_mode) {
@ -79,5 +77,5 @@ void DoubleToAscii(double v, DtoaMode mode, int requested_digits,
buffer[*length] = '\0';
}
} // namespace internal
} // namespace base
} // namespace v8

View File

@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_NUMBERS_DTOA_H_
#define V8_NUMBERS_DTOA_H_
#ifndef V8_BASE_NUMBERS_DTOA_H_
#define V8_BASE_NUMBERS_DTOA_H_
#include "src/utils/vector.h"
#include "src/base/vector.h"
namespace v8 {
namespace internal {
namespace base {
enum DtoaMode {
// Return the shortest correct representation.
@ -61,11 +61,11 @@ const int kBase10MaximalLength = 17;
// and a terminating null-character. In SHORTEST-mode it expects a buffer of
// at least kBase10MaximalLength + 1. Otherwise, the size of the output is
// limited to requested_digits digits plus the null terminator.
V8_EXPORT_PRIVATE void DoubleToAscii(double v, DtoaMode mode,
int requested_digits, Vector<char> buffer,
int* sign, int* length, int* point);
V8_BASE_EXPORT void DoubleToAscii(double v, DtoaMode mode, int requested_digits,
Vector<char> buffer, int* sign, int* length,
int* point);
} // namespace internal
} // namespace base
} // namespace v8
#endif // V8_NUMBERS_DTOA_H_
#endif // V8_BASE_NUMBERS_DTOA_H_

View File

@ -2,18 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/base/numbers/fast-dtoa.h"
#include <stdint.h>
#include "src/base/logging.h"
#include "src/utils/utils.h"
#include "src/numbers/fast-dtoa.h"
#include "src/numbers/cached-powers.h"
#include "src/numbers/diy-fp.h"
#include "src/numbers/double.h"
#include "src/base/numbers/cached-powers.h"
#include "src/base/numbers/diy-fp.h"
#include "src/base/numbers/double.h"
#include "src/base/v8-fallthrough.h"
namespace v8 {
namespace internal {
namespace base {
// The minimal and maximal target exponent define the range of w's binary
// exponent, where 'w' is the result of multiplying the input by a cached power
@ -684,5 +684,5 @@ bool FastDtoa(double v, FastDtoaMode mode, int requested_digits,
return result;
}
} // namespace internal
} // namespace base
} // namespace v8

View File

@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_NUMBERS_FAST_DTOA_H_
#define V8_NUMBERS_FAST_DTOA_H_
#ifndef V8_BASE_NUMBERS_FAST_DTOA_H_
#define V8_BASE_NUMBERS_FAST_DTOA_H_
#include "src/utils/vector.h"
#include "src/base/vector.h"
namespace v8 {
namespace internal {
namespace base {
enum FastDtoaMode {
// Computes the shortest representation of the given input. The returned
@ -50,11 +50,11 @@ const int kFastDtoaMaximalLength = 17;
// If there are two values that are equally close, then FastDtoa returns
// false.
// For both modes the buffer must be large enough to hold the result.
V8_EXPORT_PRIVATE bool FastDtoa(double d, FastDtoaMode mode,
int requested_digits, Vector<char> buffer,
int* length, int* decimal_point);
V8_BASE_EXPORT bool FastDtoa(double d, FastDtoaMode mode, int requested_digits,
Vector<char> buffer, int* length,
int* decimal_point);
} // namespace internal
} // namespace base
} // namespace v8
#endif // V8_NUMBERS_FAST_DTOA_H_
#endif // V8_BASE_NUMBERS_FAST_DTOA_H_

View File

@ -2,18 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/base/numbers/fixed-dtoa.h"
#include <stdint.h>
#include <cmath>
#include "src/base/logging.h"
#include "src/utils/utils.h"
#include "src/numbers/double.h"
#include "src/numbers/fixed-dtoa.h"
#include "src/base/numbers/double.h"
namespace v8 {
namespace internal {
namespace base {
// Represents a 128bit type. This class should be replaced by a native type on
// platforms that support 128bit integers.
@ -368,5 +367,5 @@ bool FastFixedDtoa(double v, int fractional_count, Vector<char> buffer,
return true;
}
} // namespace internal
} // namespace base
} // namespace v8

View File

@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_NUMBERS_FIXED_DTOA_H_
#define V8_NUMBERS_FIXED_DTOA_H_
#ifndef V8_BASE_NUMBERS_FIXED_DTOA_H_
#define V8_BASE_NUMBERS_FIXED_DTOA_H_
#include "src/utils/vector.h"
#include "src/base/vector.h"
namespace v8 {
namespace internal {
namespace base {
// Produces digits necessary to print a given number with
// 'fractional_count' digits after the decimal point.
@ -26,11 +26,11 @@ namespace internal {
//
// This method only works for some parameters. If it can't handle the input it
// returns false. The output is null-terminated when the function succeeds.
V8_EXPORT_PRIVATE bool FastFixedDtoa(double v, int fractional_count,
Vector<char> buffer, int* length,
int* decimal_point);
V8_BASE_EXPORT bool FastFixedDtoa(double v, int fractional_count,
Vector<char> buffer, int* length,
int* decimal_point);
} // namespace internal
} // namespace base
} // namespace v8
#endif // V8_NUMBERS_FIXED_DTOA_H_
#endif // V8_BASE_NUMBERS_FIXED_DTOA_H_

View File

@ -2,19 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/numbers/strtod.h"
#include "src/base/numbers/strtod.h"
#include <stdarg.h>
#include <cmath>
#include "src/common/globals.h"
#include "src/numbers/bignum.h"
#include "src/numbers/cached-powers.h"
#include "src/numbers/double.h"
#include "src/utils/utils.h"
#include <cmath>
#include <limits>
#include "src/base/numbers/bignum.h"
#include "src/base/numbers/cached-powers.h"
#include "src/base/numbers/double.h"
namespace v8 {
namespace internal {
namespace base {
// 2^53 = 9007199254740992.
// Any integer with at most 15 decimal digits will hence fit into a double
@ -347,7 +347,7 @@ static bool DiyFpStrtod(Vector<const char> buffer, int exponent,
// buffer.length() <= kMaxDecimalSignificantDigits
static double BignumStrtod(Vector<const char> buffer, int exponent,
double guess) {
if (guess == V8_INFINITY) {
if (guess == std::numeric_limits<double>::infinity()) {
return guess;
}
@ -402,7 +402,8 @@ double Strtod(Vector<const char> buffer, int exponent) {
Vector<const char>(significant_buffer, kMaxSignificantDecimalDigits),
significant_exponent);
}
if (exponent + trimmed.length() - 1 >= kMaxDecimalPower) return V8_INFINITY;
if (exponent + trimmed.length() - 1 >= kMaxDecimalPower)
return std::numeric_limits<double>::infinity();
if (exponent + trimmed.length() <= kMinDecimalPower) return 0.0;
double guess;
@ -413,5 +414,5 @@ double Strtod(Vector<const char> buffer, int exponent) {
return BignumStrtod(trimmed, exponent, guess);
}
} // namespace internal
} // namespace base
} // namespace v8

View File

@ -2,19 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_NUMBERS_STRTOD_H_
#define V8_NUMBERS_STRTOD_H_
#ifndef V8_BASE_NUMBERS_STRTOD_H_
#define V8_BASE_NUMBERS_STRTOD_H_
#include "src/utils/vector.h"
#include "src/base/vector.h"
namespace v8 {
namespace internal {
namespace base {
// The buffer must only contain digits in the range [0-9]. It must not
// contain a dot or a sign. It must not start with '0', and must not be empty.
V8_EXPORT_PRIVATE double Strtod(Vector<const char> buffer, int exponent);
V8_BASE_EXPORT double Strtod(Vector<const char> buffer, int exponent);
} // namespace internal
} // namespace base
} // namespace v8
#endif // V8_NUMBERS_STRTOD_H_
#endif // V8_BASE_NUMBERS_STRTOD_H_

View File

@ -109,7 +109,7 @@ PageAllocator::AllocateSharedPages(size_t size, const void* original_address) {
void* ptr =
base::OS::AllocateShared(size, base::OS::MemoryPermission::kReadWrite);
CHECK_NOT_NULL(ptr);
base::Memcpy(ptr, original_address, size);
memcpy(ptr, original_address, size);
bool success = base::OS::SetPermissions(
ptr, size, base::OS::MemoryPermission::kReadWrite);
CHECK(success);

View File

@ -1,6 +1,5 @@
hpayer@chromium.org
mlippautz@chromium.org
ulan@chromium.org
victorgomes@chromium.org
per-file platform-fuchsia.cc=wez@chromium.org

View File

@ -167,6 +167,21 @@ void* Allocate(void* hint, size_t size, OS::MemoryPermission access,
int flags = GetFlagsForMemoryPermission(access, page_type);
void* result = mmap(hint, size, prot, flags, kMmapFd, kMmapFdOffset);
if (result == MAP_FAILED) return nullptr;
#if ENABLE_HUGEPAGE
if (result != nullptr && size >= kHugePageSize) {
const uintptr_t huge_start =
RoundUp(reinterpret_cast<uintptr_t>(result), kHugePageSize);
const uintptr_t huge_end =
RoundDown(reinterpret_cast<uintptr_t>(result) + size, kHugePageSize);
if (huge_end > huge_start) {
// Bail out in case the aligned addresses do not provide a block of at
// least kHugePageSize size.
madvise(reinterpret_cast<void*>(huge_start), huge_end - huge_start,
MADV_HUGEPAGE);
}
}
#endif
return result;
}
@ -1036,8 +1051,9 @@ Stack::StackSlot Stack::GetStackStart() {
// the start of the stack.
// See https://code.google.com/p/nativeclient/issues/detail?id=3431.
return __libc_stack_end;
#endif // !defined(V8_LIBC_GLIBC)
#else
return nullptr;
#endif // !defined(V8_LIBC_GLIBC)
}
#endif // !defined(V8_OS_FREEBSD) && !defined(V8_OS_MACOSX) &&

View File

@ -4,7 +4,7 @@
// Platform-specific code for Starboard goes here. Starboard is the platform
// abstraction layer for Cobalt, an HTML5 container used mainly by YouTube
// apps in the livingroom.
// apps in the living room.
#include "src/base/lazy-instance.h"
#include "src/base/macros.h"
@ -12,6 +12,7 @@
#include "src/base/platform/time.h"
#include "src/base/timezone-cache.h"
#include "src/base/utils/random-number-generator.h"
#include "starboard/client_porting/eztime/eztime.h"
#include "starboard/common/condition_variable.h"
#include "starboard/common/log.h"
#include "starboard/common/string.h"
@ -71,6 +72,8 @@ static LazyInstance<RandomNumberGenerator>::type
static LazyMutex rng_mutex = LAZY_MUTEX_INITIALIZER;
bool g_hard_abort = false;
// We only use this stack size to get the topmost stack frame.
const int kStackSize = 1;
} // namespace
@ -149,37 +152,6 @@ void* Allocate(void* address, size_t size, OS::MemoryPermission access) {
return result;
}
// The following code was taken from old v8 to deal with rounding up pointers.
namespace {
// Compute the 0-relative offset of some absolute value x of type T.
// This allows conversion of Addresses and integral types into
// 0-relative int offsets.
template <typename T>
constexpr inline intptr_t OffsetFrom(T x) {
return x - static_cast<T>(0);
}
// Compute the absolute value of type T for some 0-relative offset x.
// This allows conversion of 0-relative int offsets into Addresses and
// integral types.
template <typename T>
constexpr inline T AddressFrom(intptr_t x) {
return static_cast<T>(static_cast<T>(0) + x);
}
template <typename T>
inline T RoundDown(T x, intptr_t m) {
// m must be a power of two.
DCHECK(m != 0 && ((m & (m - 1)) == 0));
return AddressFrom<T>(OffsetFrom(x) & -m);
}
template <typename T>
inline T RoundUpOld(T x, intptr_t m) {
return RoundDown<T>(static_cast<T>(x + m - 1), m);
}
} // namespace
// static
void* OS::Allocate(void* address, size_t size, size_t alignment,
MemoryPermission access) {
@ -195,7 +167,8 @@ void* OS::Allocate(void* address, size_t size, size_t alignment,
// Unmap memory allocated before the aligned base address.
uint8_t* base = static_cast<uint8_t*>(result);
uint8_t* aligned_base = RoundUpOld(base, alignment);
uint8_t* aligned_base = reinterpret_cast<uint8_t*>(
RoundUp(reinterpret_cast<uintptr_t>(base), alignment));
if (aligned_base != base) {
DCHECK_LT(base, aligned_base);
size_t prefix_size = static_cast<size_t>(aligned_base - base);
@ -430,10 +403,11 @@ void Thread::set_name(const char* name) {
name_[sizeof(name_) - 1] = '\0';
}
void Thread::Start() {
bool Thread::Start() {
data_->thread_ =
SbThreadCreate(stack_size_, kSbThreadNoPriority, kSbThreadNoAffinity,
true, name_, ThreadEntry, this);
return SbThreadIsValid(data_->thread_);
}
void Thread::Join() { SbThreadJoin(data_->thread_, nullptr); }
@ -457,7 +431,6 @@ void Thread::SetThreadLocal(LocalStorageKey key, void* value) {
class StarboardTimezoneCache : public TimezoneCache {
public:
double DaylightSavingsOffset(double time_ms) override { return 0.0; }
void Clear(TimeZoneDetection time_zone_detection) override {}
~StarboardTimezoneCache() override {}
@ -471,7 +444,18 @@ class StarboardDefaultTimezoneCache : public StarboardTimezoneCache {
return SbTimeZoneGetName();
}
double LocalTimeOffset(double time_ms, bool is_utc) override {
return SbTimeZoneGetCurrent() * 60000.0;
// SbTimeZOneGetCurrent returns an offset west of Greenwich, which has the
// opposite sign V8 expects.
// The starboard function returns offset in minutes. We convert to return
// value in milliseconds.
return SbTimeZoneGetCurrent() * 60.0 * msPerSecond * (-1);
}
double DaylightSavingsOffset(double time_ms) override {
EzTimeValue value = EzTimeValueFromSbTime(SbTimeGetNow());
EzTimeExploded ez_exploded;
bool result =
EzTimeValueExplode(&value, kEzTimeZoneLocal, &ez_exploded, NULL);
return ez_exploded.tm_isdst > 0 ? 3600 * msPerSecond : 0;
}
~StarboardDefaultTimezoneCache() override {}
@ -495,5 +479,16 @@ bool OS::DiscardSystemPages(void* address, size_t size) {
return true;
}
// static
Stack::StackSlot Stack::GetCurrentStackPosition() {
void* addresses[kStackSize];
const size_t count = SbSystemGetStack(addresses, kStackSize);
if (count > 0) {
return addresses[0];
} else {
return nullptr;
}
}
} // namespace base
} // namespace v8

View File

@ -14,6 +14,7 @@
#if defined(V8_OS_STARBOARD)
#include "starboard/memory.h"
#include "starboard/string.h"
#endif
namespace v8 {
@ -33,9 +34,7 @@ inline void Free(void* memory) { return free(memory); }
inline void* Calloc(size_t count, size_t size) { return calloc(count, size); }
inline void* Memcpy(void* dest, const void* source, size_t count) {
return memcpy(dest, source, count);
}
inline char* Strdup(const char* source) { return strdup(source); }
inline FILE* Fopen(const char* filename, const char* mode) {
return fopen(filename, mode);
@ -45,7 +44,7 @@ inline int Fclose(FILE* stream) { return fclose(stream); }
#else // V8_OS_STARBOARD
inline void* Malloc(size_t size) { return SbMemoryAlloc(size); }
inline void* Malloc(size_t size) { return SbMemoryAllocate(size); }
inline void* Realloc(void* memory, size_t size) {
return SbMemoryReallocate(memory, size);
@ -57,9 +56,7 @@ inline void* Calloc(size_t count, size_t size) {
return SbMemoryCalloc(count, size);
}
inline void* Memcpy(void* dest, const void* source, size_t count) {
return SbMemoryCopy(dest, source, count);
}
inline char* Strdup(const char* source) { return SbStringDuplicate(source); }
inline FILE* Fopen(const char* filename, const char* mode) { return NULL; }

View File

@ -20,8 +20,23 @@
"ASAN_POISON_MEMORY_REGION and ASAN_UNPOISON_MEMORY_REGION must be defined"
#endif
#define DISABLE_ASAN __attribute__((no_sanitize_address))
// Check that all bytes in a memory region are poisoned. This is different from
// `__asan_region_is_poisoned()` which only requires a single byte in the region
// to be poisoned.
#define ASAN_CHECK_MEMORY_REGION_IS_POISONED(start, size) \
do { \
for (size_t i = 0; i < size; i++) { \
CHECK(__asan_address_is_poisoned(reinterpret_cast<const char*>(start) + \
i)); \
} \
} while (0)
#else // !V8_USE_ADDRESS_SANITIZER
#define DISABLE_ASAN
#define ASAN_POISON_MEMORY_REGION(start, size) \
static_assert(std::is_pointer<decltype(start)>::value, \
"static type violation"); \
@ -32,6 +47,9 @@
#define ASAN_UNPOISON_MEMORY_REGION(start, size) \
ASAN_POISON_MEMORY_REGION(start, size)
#define ASAN_CHECK_MEMORY_REGION_IS_POISONED(start, size) \
ASAN_POISON_MEMORY_REGION(start, size)
#endif // !V8_USE_ADDRESS_SANITIZER
#endif // V8_BASE_SANITIZER_ASAN_H_

View File

@ -34,7 +34,7 @@ class SmallVector {
SmallVector(SmallVector&& other) V8_NOEXCEPT { *this = std::move(other); }
SmallVector(std::initializer_list<T> init) {
resize_no_init(init.size());
base::Memcpy(begin_, init.begin(), sizeof(T) * init.size());
memcpy(begin_, init.begin(), sizeof(T) * init.size());
}
~SmallVector() {
@ -50,7 +50,7 @@ class SmallVector {
begin_ = reinterpret_cast<T*>(base::Malloc(sizeof(T) * other_size));
end_of_storage_ = begin_ + other_size;
}
base::Memcpy(begin_, other.begin_, sizeof(T) * other_size);
memcpy(begin_, other.begin_, sizeof(T) * other_size);
end_ = begin_ + other_size;
return *this;
}
@ -66,7 +66,7 @@ class SmallVector {
} else {
DCHECK_GE(capacity(), other.size()); // Sanity check.
size_t other_size = other.size();
base::Memcpy(begin_, other.begin_, sizeof(T) * other_size);
memcpy(begin_, other.begin_, sizeof(T) * other_size);
end_ = begin_ + other_size;
}
return *this;
@ -161,7 +161,7 @@ class SmallVector {
// crashes appropriately.
FATAL("Fatal process out of memory: base::SmallVector::Grow");
}
base::Memcpy(new_storage, begin_, sizeof(T) * in_use);
memcpy(new_storage, begin_, sizeof(T) * in_use);
if (is_big()) base::Free(begin_);
begin_ = new_storage;
end_ = new_storage + in_use;

33
deps/v8/src/base/strings.cc vendored Normal file
View File

@ -0,0 +1,33 @@
// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/base/strings.h"
#include <cstdint>
#include <cstring>
#include <limits>
#include "src/base/platform/platform.h"
namespace v8 {
namespace base {
int VSNPrintF(Vector<char> str, const char* format, va_list args) {
return OS::VSNPrintF(str.begin(), str.length(), format, args);
}
int SNPrintF(Vector<char> str, const char* format, ...) {
va_list args;
va_start(args, format);
int result = VSNPrintF(str, format, args);
va_end(args);
return result;
}
void StrNCpy(base::Vector<char> dest, const char* src, size_t n) {
base::OS::StrNCpy(dest.begin(), dest.length(), src, n);
}
} // namespace base
} // namespace v8

51
deps/v8/src/base/strings.h vendored Normal file
View File

@ -0,0 +1,51 @@
// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_BASE_STRINGS_H_
#define V8_BASE_STRINGS_H_
#include "src/base/base-export.h"
#include "src/base/macros.h"
#include "src/base/vector.h"
namespace v8 {
namespace base {
// Latin1/UTF-16 constants
// Code-point values in Unicode 4.0 are 21 bits wide.
// Code units in UTF-16 are 16 bits wide.
using uc16 = uint16_t;
using uc32 = uint32_t;
constexpr int kUC16Size = sizeof(uc16);
V8_BASE_EXPORT int PRINTF_FORMAT(2, 0)
VSNPrintF(Vector<char> str, const char* format, va_list args);
// Safe formatting print. Ensures that str is always null-terminated.
// Returns the number of chars written, or -1 if output was truncated.
V8_BASE_EXPORT int PRINTF_FORMAT(2, 3)
SNPrintF(Vector<char> str, const char* format, ...);
V8_BASE_EXPORT void StrNCpy(base::Vector<char> dest, const char* src, size_t n);
// Returns the value (0 .. 15) of a hexadecimal character c.
// If c is not a legal hexadecimal character, returns a value < 0.
inline int HexValue(uc32 c) {
c -= '0';
if (static_cast<unsigned>(c) <= 9) return c;
c = (c | 0x20) - ('a' - '0'); // detect 0x11..0x16 and 0x31..0x36.
if (static_cast<unsigned>(c) <= 5) return c + 10;
return -1;
}
inline char HexCharOfValue(int value) {
DCHECK(0 <= value && value <= 16);
if (value < 10) return value + '0';
return value - 10 + 'A';
}
} // namespace base
} // namespace v8
#endif // V8_BASE_STRINGS_H_

View File

@ -26,6 +26,10 @@
#include "src/base/win32-headers.h"
#endif
#if V8_OS_STARBOARD
#include "starboard/system.h"
#endif
namespace v8 {
namespace base {
@ -49,6 +53,8 @@ int SysInfo::NumberOfProcessors() {
SYSTEM_INFO system_info = {};
::GetNativeSystemInfo(&system_info);
return static_cast<int>(system_info.dwNumberOfProcessors);
#elif V8_OS_STARBOARD
return SbSystemGetNumberOfProcessors();
#endif
}
@ -97,6 +103,8 @@ int64_t SysInfo::AmountOfPhysicalMemory() {
return 0;
}
return static_cast<int64_t>(pages) * page_size;
#elif V8_OS_STARBOARD
return SbSystemGetTotalCPUMemory();
#endif
}
@ -112,6 +120,8 @@ int64_t SysInfo::AmountOfVirtualMemory() {
return 0;
}
return (rlim.rlim_cur == RLIM_INFINITY) ? 0 : rlim.rlim_cur;
#elif V8_OS_STARBOARD
return 0;
#endif
}

View File

@ -6,6 +6,9 @@
#include <stdio.h>
#include <stdlib.h>
#if defined(V8_OS_STARBOARD)
#include "starboard/system.h"
#endif // V8_OS_STARBOARD
#include <algorithm>
#include <new>
@ -59,6 +62,8 @@ RandomNumberGenerator::RandomNumberGenerator() {
int64_t seed;
arc4random_buf(&seed, sizeof(seed));
SetSeed(seed);
#elif V8_OS_STARBOARD
SetSeed(SbSystemGetRandomUInt64());
#else
// Gather entropy from /dev/urandom if available.
FILE* fp = base::Fopen("/dev/urandom", "rb");

View File

@ -2,21 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_UTILS_VECTOR_H_
#define V8_UTILS_VECTOR_H_
#ifndef V8_BASE_VECTOR_H_
#define V8_BASE_VECTOR_H_
#include <algorithm>
#include <cstring>
#include <iterator>
#include <limits>
#include <memory>
#include <type_traits>
#include "src/common/checks.h"
#include "src/common/globals.h"
#include "src/utils/allocation.h"
#include "src/base/logging.h"
#include "src/base/macros.h"
namespace v8 {
namespace internal {
namespace base {
template <typename T>
class Vector {
@ -32,7 +32,7 @@ class Vector {
}
static Vector<T> New(size_t length) {
return Vector<T>(NewArray<T>(length), length);
return Vector<T>(new T[length], length);
}
// Returns a vector using the same backing storage as this one,
@ -82,7 +82,7 @@ class Vector {
// Returns a clone of this vector with a new backing store.
Vector<T> Clone() const {
T* result = NewArray<T>(length_);
T* result = new T[length_];
for (size_t i = 0; i < length_; i++) result[i] = start_[i];
return Vector<T>(result, length_);
}
@ -95,7 +95,7 @@ class Vector {
// Releases the array underlying this vector. Once disposed the
// vector is empty.
void Dispose() {
DeleteArray(start_);
delete[] start_;
start_ = nullptr;
length_ = 0;
}
@ -143,9 +143,8 @@ class Vector {
template <typename T>
class V8_NODISCARD ScopedVector : public Vector<T> {
public:
explicit ScopedVector(size_t length)
: Vector<T>(NewArray<T>(length), length) {}
~ScopedVector() { DeleteArray(this->begin()); }
explicit ScopedVector(size_t length) : Vector<T>(new T[length], length) {}
~ScopedVector() { delete[] this->begin(); }
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedVector);
@ -318,7 +317,7 @@ class EmbeddedVector : public Vector<T> {
T buffer_[kSize];
};
} // namespace internal
} // namespace base
} // namespace v8
#endif // V8_UTILS_VECTOR_H_
#endif // V8_BASE_VECTOR_H_

View File

@ -97,9 +97,6 @@ void BaselineAssembler::JumpTarget() {
void BaselineAssembler::Jump(Label* target, Label::Distance distance) {
__ b(target);
}
void BaselineAssembler::JumpIf(Condition cc, Label* target, Label::Distance) {
__ b(AsMasmCondition(cc), target);
}
void BaselineAssembler::JumpIfRoot(Register value, RootIndex index,
Label* target, Label::Distance) {
__ JumpIfRoot(value, index, target);
@ -117,38 +114,49 @@ void BaselineAssembler::JumpIfNotSmi(Register value, Label* target,
__ JumpIfNotSmi(value, target);
}
void BaselineAssembler::CallBuiltin(Builtins::Name builtin) {
void BaselineAssembler::CallBuiltin(Builtin builtin) {
// __ CallBuiltin(static_cast<int>(builtin));
__ RecordCommentForOffHeapTrampoline(builtin);
ASM_CODE_COMMENT_STRING(masm_,
__ CommentForOffHeapTrampoline("call", builtin));
ScratchRegisterScope temps(this);
Register temp = temps.AcquireScratch();
__ LoadEntryFromBuiltinIndex(builtin, temp);
__ LoadEntryFromBuiltin(builtin, temp);
__ Call(temp);
__ RecordComment("]");
}
void BaselineAssembler::TailCallBuiltin(Builtins::Name builtin) {
__ RecordCommentForOffHeapTrampoline(builtin);
void BaselineAssembler::TailCallBuiltin(Builtin builtin) {
ASM_CODE_COMMENT_STRING(masm_,
__ CommentForOffHeapTrampoline("tail call", builtin));
ScratchRegisterScope temps(this);
Register temp = temps.AcquireScratch();
__ LoadEntryFromBuiltinIndex(builtin, temp);
__ LoadEntryFromBuiltin(builtin, temp);
__ Jump(temp);
__ RecordComment("]");
}
void BaselineAssembler::Test(Register value, int mask) {
void BaselineAssembler::TestAndBranch(Register value, int mask, Condition cc,
Label* target, Label::Distance) {
__ tst(value, Operand(mask));
__ b(AsMasmCondition(cc), target);
}
void BaselineAssembler::CmpObjectType(Register object,
InstanceType instance_type,
Register map) {
void BaselineAssembler::JumpIf(Condition cc, Register lhs, const Operand& rhs,
Label* target, Label::Distance) {
__ cmp(lhs, Operand(rhs));
__ b(AsMasmCondition(cc), target);
}
void BaselineAssembler::JumpIfObjectType(Condition cc, Register object,
InstanceType instance_type,
Register map, Label* target,
Label::Distance) {
ScratchRegisterScope temps(this);
Register type = temps.AcquireScratch();
__ CompareObjectType(object, map, type, instance_type);
__ LoadMap(map, object);
__ ldrh(type, FieldMemOperand(map, Map::kInstanceTypeOffset));
JumpIf(cc, type, Operand(instance_type), target);
}
void BaselineAssembler::CmpInstanceType(Register map,
InstanceType instance_type) {
void BaselineAssembler::JumpIfInstanceType(Condition cc, Register map,
InstanceType instance_type,
Label* target, Label::Distance) {
ScratchRegisterScope temps(this);
Register type = temps.AcquireScratch();
if (FLAG_debug_code) {
@ -156,36 +164,47 @@ void BaselineAssembler::CmpInstanceType(Register map,
__ CompareObjectType(map, type, type, MAP_TYPE);
__ Assert(eq, AbortReason::kUnexpectedValue);
}
__ CompareInstanceType(map, type, instance_type);
__ ldrh(type, FieldMemOperand(map, Map::kInstanceTypeOffset));
JumpIf(cc, type, Operand(instance_type), target);
}
void BaselineAssembler::Cmp(Register value, Smi smi) {
__ cmp(value, Operand(smi));
}
void BaselineAssembler::ComparePointer(Register value, MemOperand operand) {
void BaselineAssembler::JumpIfPointer(Condition cc, Register value,
MemOperand operand, Label* target,
Label::Distance) {
ScratchRegisterScope temps(this);
Register tmp = temps.AcquireScratch();
__ ldr(tmp, operand);
__ cmp(value, tmp);
JumpIf(cc, value, Operand(tmp), target);
}
void BaselineAssembler::SmiCompare(Register lhs, Register rhs) {
void BaselineAssembler::JumpIfSmi(Condition cc, Register value, Smi smi,
Label* target, Label::Distance) {
__ AssertSmi(value);
JumpIf(cc, value, Operand(smi), target);
}
void BaselineAssembler::JumpIfSmi(Condition cc, Register lhs, Register rhs,
Label* target, Label::Distance) {
__ AssertSmi(lhs);
__ AssertSmi(rhs);
__ cmp(lhs, rhs);
JumpIf(cc, lhs, Operand(rhs), target);
}
void BaselineAssembler::CompareTagged(Register value, MemOperand operand) {
void BaselineAssembler::JumpIfTagged(Condition cc, Register value,
MemOperand operand, Label* target,
Label::Distance) {
ScratchRegisterScope temps(this);
Register tmp = temps.AcquireScratch();
__ ldr(tmp, operand);
__ cmp(value, tmp);
JumpIf(cc, value, Operand(tmp), target);
}
void BaselineAssembler::CompareTagged(MemOperand operand, Register value) {
void BaselineAssembler::JumpIfTagged(Condition cc, MemOperand operand,
Register value, Label* target,
Label::Distance) {
ScratchRegisterScope temps(this);
Register tmp = temps.AcquireScratch();
__ ldr(tmp, operand);
__ cmp(tmp, value);
JumpIf(cc, tmp, Operand(value), target);
}
void BaselineAssembler::CompareByte(Register value, int32_t byte) {
__ cmp(value, Operand(byte));
void BaselineAssembler::JumpIfByte(Condition cc, Register value, int32_t byte,
Label* target, Label::Distance) {
JumpIf(cc, value, Operand(byte), target);
}
void BaselineAssembler::Move(interpreter::Register output, Register source) {
@ -341,6 +360,7 @@ void BaselineAssembler::LoadByteField(Register output, Register source,
}
void BaselineAssembler::StoreTaggedSignedField(Register target, int offset,
Smi value) {
ASM_CODE_COMMENT(masm_);
ScratchRegisterScope temps(this);
Register tmp = temps.AcquireScratch();
__ mov(tmp, Operand(value));
@ -349,6 +369,8 @@ void BaselineAssembler::StoreTaggedSignedField(Register target, int offset,
void BaselineAssembler::StoreTaggedFieldWithWriteBarrier(Register target,
int offset,
Register value) {
ASM_CODE_COMMENT(masm_);
DCHECK(!AreAliased(target, value));
__ str(value, FieldMemOperand(target, offset));
__ RecordWriteField(target, offset, value, kLRHasNotBeenSaved,
SaveFPRegsMode::kIgnore);
@ -359,7 +381,9 @@ void BaselineAssembler::StoreTaggedFieldNoWriteBarrier(Register target,
__ str(value, FieldMemOperand(target, offset));
}
void BaselineAssembler::AddToInterruptBudget(int32_t weight) {
void BaselineAssembler::AddToInterruptBudgetAndJumpIfNotExceeded(
int32_t weight, Label* skip_interrupt_label) {
ASM_CODE_COMMENT(masm_);
ScratchRegisterScope scratch_scope(this);
Register feedback_cell = scratch_scope.AcquireScratch();
LoadFunction(feedback_cell);
@ -373,9 +397,16 @@ void BaselineAssembler::AddToInterruptBudget(int32_t weight) {
__ add(interrupt_budget, interrupt_budget, Operand(weight), SetCC);
__ str(interrupt_budget,
FieldMemOperand(feedback_cell, FeedbackCell::kInterruptBudgetOffset));
if (skip_interrupt_label) {
// Use compare flags set by add
DCHECK_LT(weight, 0);
__ b(ge, skip_interrupt_label);
}
}
void BaselineAssembler::AddToInterruptBudget(Register weight) {
void BaselineAssembler::AddToInterruptBudgetAndJumpIfNotExceeded(
Register weight, Label* skip_interrupt_label) {
ASM_CODE_COMMENT(masm_);
ScratchRegisterScope scratch_scope(this);
Register feedback_cell = scratch_scope.AcquireScratch();
LoadFunction(feedback_cell);
@ -389,6 +420,7 @@ void BaselineAssembler::AddToInterruptBudget(Register weight) {
__ add(interrupt_budget, interrupt_budget, weight, SetCC);
__ str(interrupt_budget,
FieldMemOperand(feedback_cell, FeedbackCell::kInterruptBudgetOffset));
if (skip_interrupt_label) __ b(ge, skip_interrupt_label);
}
void BaselineAssembler::AddSmi(Register lhs, Smi rhs) {
@ -397,15 +429,16 @@ void BaselineAssembler::AddSmi(Register lhs, Smi rhs) {
void BaselineAssembler::Switch(Register reg, int case_value_base,
Label** labels, int num_labels) {
ASM_CODE_COMMENT(masm_);
Label fallthrough;
if (case_value_base > 0) {
if (case_value_base != 0) {
__ sub(reg, reg, Operand(case_value_base));
}
// Mostly copied from code-generator-arm.cc
ScratchRegisterScope scope(this);
__ cmp(reg, Operand(num_labels));
JumpIf(Condition::kUnsignedGreaterThanEqual, &fallthrough);
JumpIf(Condition::kUnsignedGreaterThanEqual, reg, Operand(num_labels),
&fallthrough);
// Ensure to emit the constant pool first if necessary.
__ CheckConstPool(true, true);
__ BlockConstPoolFor(num_labels);
@ -423,32 +456,32 @@ void BaselineAssembler::Switch(Register reg, int case_value_base,
#define __ basm.
void BaselineAssembler::EmitReturn(MacroAssembler* masm) {
ASM_CODE_COMMENT(masm);
BaselineAssembler basm(masm);
Register weight = BaselineLeaveFrameDescriptor::WeightRegister();
Register params_size = BaselineLeaveFrameDescriptor::ParamsSizeRegister();
__ RecordComment("[ Update Interrupt Budget");
__ AddToInterruptBudget(weight);
// Use compare flags set by add
Label skip_interrupt_label;
__ JumpIf(Condition::kGreaterThanEqual, &skip_interrupt_label);
{
__ masm()->SmiTag(params_size);
__ Push(params_size, kInterpreterAccumulatorRegister);
ASM_CODE_COMMENT_STRING(masm, "Update Interrupt Budget");
__ LoadContext(kContextRegister);
__ LoadFunction(kJSFunctionRegister);
__ Push(kJSFunctionRegister);
__ CallRuntime(Runtime::kBytecodeBudgetInterruptFromBytecode, 1);
Label skip_interrupt_label;
__ AddToInterruptBudgetAndJumpIfNotExceeded(weight, &skip_interrupt_label);
{
__ masm()->SmiTag(params_size);
__ Push(params_size, kInterpreterAccumulatorRegister);
__ Pop(kInterpreterAccumulatorRegister, params_size);
__ masm()->SmiUntag(params_size);
__ LoadContext(kContextRegister);
__ LoadFunction(kJSFunctionRegister);
__ Push(kJSFunctionRegister);
__ CallRuntime(Runtime::kBytecodeBudgetInterruptFromBytecode, 1);
__ Pop(kInterpreterAccumulatorRegister, params_size);
__ masm()->SmiUntag(params_size);
}
__ Bind(&skip_interrupt_label);
}
__ RecordComment("]");
__ Bind(&skip_interrupt_label);
BaselineAssembler::ScratchRegisterScope temps(&basm);
Register actual_params_size = temps.AcquireScratch();
@ -459,8 +492,8 @@ void BaselineAssembler::EmitReturn(MacroAssembler* masm) {
// If actual is bigger than formal, then we should use it to free up the stack
// arguments.
Label corrected_args_count;
__ masm()->cmp(params_size, actual_params_size);
__ JumpIf(Condition::kGreaterThanEqual, &corrected_args_count);
__ JumpIf(Condition::kGreaterThanEqual, params_size,
Operand(actual_params_size), &corrected_args_count);
__ masm()->mov(params_size, actual_params_size);
__ Bind(&corrected_args_count);

View File

@ -19,7 +19,7 @@ void BaselineCompiler::Prologue() {
__ masm()->EnterFrame(StackFrame::BASELINE);
DCHECK_EQ(kJSFunctionRegister, kJavaScriptCallTargetRegister);
int max_frame_size = bytecode_->frame_size() + max_call_args_;
CallBuiltin<Builtins::kBaselineOutOfLinePrologue>(
CallBuiltin<Builtin::kBaselineOutOfLinePrologue>(
kContextRegister, kJSFunctionRegister, kJavaScriptCallArgCountRegister,
max_frame_size, kJavaScriptCallNewTargetRegister, bytecode_);
@ -27,11 +27,15 @@ void BaselineCompiler::Prologue() {
}
void BaselineCompiler::PrologueFillFrame() {
__ RecordComment("[ Fill frame");
ASM_CODE_COMMENT(&masm_);
// Inlined register frame fill
interpreter::Register new_target_or_generator_register =
bytecode_->incoming_new_target_or_generator_register();
__ LoadRoot(kInterpreterAccumulatorRegister, RootIndex::kUndefinedValue);
if (FLAG_debug_code) {
__ masm()->CompareRoot(kInterpreterAccumulatorRegister,
RootIndex::kUndefinedValue);
__ masm()->Assert(eq, AbortReason::kUnexpectedValue);
}
int register_count = bytecode_->register_count();
// Magic value
const int kLoopUnrollSize = 8;
@ -71,9 +75,8 @@ void BaselineCompiler::PrologueFillFrame() {
__ Push(kInterpreterAccumulatorRegister);
}
__ masm()->sub(scratch, scratch, Operand(1), SetCC);
__ JumpIf(Condition::kGreaterThan, &loop);
__ masm()->b(gt, &loop);
}
__ RecordComment("]");
}
void BaselineCompiler::VerifyFrameSize() {

Some files were not shown because too many files have changed in this diff Show More