Reland "[no-wasm] Exclude src/wasm from compilation"

This is a reland of 80f5dfda01. A condition
in pipeline.cc was inverted, which lead to a CSA verifier error.

Original change's description:
> [no-wasm] Exclude src/wasm from compilation
>
> This is the biggest chunk, including
> - all of src/wasm,
> - torque file for wasm objects,
> - torque file for wasm builtins,
> - wasm builtins,
> - wasm runtime functions,
> - int64 lowering,
> - simd scala lowering,
> - WasmGraphBuilder (TF graph construction for wasm),
> - wasm frame types,
> - wasm interrupts,
> - the JSWasmCall opcode,
> - wasm backing store allocation.
>
> Those components are all recursively entangled, so I found no way to
> split this change up further.
>
> Some includes that were recursively included by wasm headers needed to
> be added explicitly now.
>
> backing-store-unittest.cc is renamed to wasm-backing-store-unittest.cc
> because it only tests wasm backing stores. This file is excluded from
> no-wasm builds then.
>
> R=jkummerow@chromium.org, jgruber@chromium.org, mlippautz@chromium.org, petermarshall@chromium.org
>
> Bug: v8:11238
> Change-Id: I7558f2d12d2dd6c65128c4de7b79173668c80b2b
> Cq-Include-Trybots: luci.v8.try:v8_linux64_no_wasm_compile_rel
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2742955
> Commit-Queue: Clemens Backes <clemensb@chromium.org>
> Reviewed-by: Peter Marshall <petermarshall@chromium.org>
> Reviewed-by: Toon Verwaest <verwaest@chromium.org>
> Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
> Reviewed-by: Jakob Gruber <jgruber@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#73344}

TBR=jgruber@chromium.org

Bug: v8:11238
Change-Id: I20bd2847a59c68738b5a336cd42582b7b1499585
Cq-Include-Trybots: luci.v8.try:v8_linux64_no_wasm_compile_rel
Cq-Include-Trybots: luci.v8.try:v8_linux_verify_csa_rel_ng
Cq-Include-Trybots: luci.v8.try:v8_linux64_verify_csa_rel_ng
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2752867
Reviewed-by: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73348}
This commit is contained in:
Clemens Backes 2021-03-11 14:42:01 +01:00 committed by Commit Bot
parent 3b16162e50
commit 3f9ff062b0
137 changed files with 1717 additions and 1213 deletions

182
BUILD.gn
View File

@ -1371,7 +1371,6 @@ torque_files = [
"src/builtins/typed-array-subarray.tq",
"src/builtins/typed-array-values.tq",
"src/builtins/typed-array.tq",
"src/builtins/wasm.tq",
"src/builtins/weak-ref.tq",
"src/ic/handler-configuration.tq",
"src/objects/allocation-site.tq",
@ -1430,7 +1429,6 @@ torque_files = [
"src/objects/template-objects.tq",
"src/objects/templates.tq",
"src/objects/torque-defined-classes.tq",
"src/wasm/wasm-objects.tq",
"test/torque/test-torque.tq",
"third_party/v8/builtins/array-sort.tq",
]
@ -1454,7 +1452,11 @@ if (v8_enable_i18n_support) {
}
if (v8_enable_webassembly) {
torque_files += [ "src/debug/debug-wasm-objects.tq" ]
torque_files += [
"src/builtins/wasm.tq",
"src/debug/debug-wasm-objects.tq",
"src/wasm/wasm-objects.tq",
]
}
# Template for running torque
@ -1994,8 +1996,6 @@ v8_source_set("v8_initializers") {
"src/builtins/builtins-typed-array-gen.cc",
"src/builtins/builtins-typed-array-gen.h",
"src/builtins/builtins-utils-gen.h",
"src/builtins/builtins-wasm-gen.cc",
"src/builtins/builtins-wasm-gen.h",
"src/builtins/growable-fixed-array-gen.cc",
"src/builtins/growable-fixed-array-gen.h",
"src/builtins/profile-data-reader.cc",
@ -2021,6 +2021,13 @@ v8_source_set("v8_initializers") {
"src/interpreter/interpreter-intrinsics-generator.h",
]
if (v8_enable_webassembly) {
sources += [
"src/builtins/builtins-wasm-gen.cc",
"src/builtins/builtins-wasm-gen.h",
]
}
if (v8_current_cpu == "x86") {
sources += [
### gcmole(arch:ia32) ###
@ -2366,7 +2373,6 @@ v8_header_set("v8_internal_headers") {
"src/compiler/graph-visualizer.h",
"src/compiler/graph-zone-traits.h",
"src/compiler/graph.h",
"src/compiler/int64-lowering.h",
"src/compiler/js-call-reducer.h",
"src/compiler/js-context-specialization.h",
"src/compiler/js-create-lowering.h",
@ -2435,7 +2441,6 @@ v8_header_set("v8_internal_headers") {
"src/compiler/types.h",
"src/compiler/value-numbering-reducer.h",
"src/compiler/verifier.h",
"src/compiler/wasm-compiler.h",
"src/compiler/write-barrier-kind.h",
"src/compiler/zone-stats.h",
"src/date/date.h",
@ -2965,49 +2970,6 @@ v8_header_set("v8_internal_headers") {
"src/utils/utils.h",
"src/utils/vector.h",
"src/utils/version.h",
"src/wasm/baseline/liftoff-assembler-defs.h",
"src/wasm/baseline/liftoff-assembler.h",
"src/wasm/baseline/liftoff-compiler.h",
"src/wasm/baseline/liftoff-register.h",
"src/wasm/code-space-access.h",
"src/wasm/compilation-environment.h",
"src/wasm/decoder.h",
"src/wasm/function-body-decoder-impl.h",
"src/wasm/function-body-decoder.h",
"src/wasm/function-compiler.h",
"src/wasm/graph-builder-interface.h",
"src/wasm/jump-table-assembler.h",
"src/wasm/leb-helper.h",
"src/wasm/local-decl-encoder.h",
"src/wasm/memory-tracing.h",
"src/wasm/module-compiler.h",
"src/wasm/module-decoder.h",
"src/wasm/module-instantiate.h",
"src/wasm/object-access.h",
"src/wasm/signature-map.h",
"src/wasm/simd-shuffle.h",
"src/wasm/streaming-decoder.h",
"src/wasm/struct-types.h",
"src/wasm/value-type.h",
"src/wasm/wasm-arguments.h",
"src/wasm/wasm-code-manager.h",
"src/wasm/wasm-engine.h",
"src/wasm/wasm-external-refs.h",
"src/wasm/wasm-feature-flags.h",
"src/wasm/wasm-features.h",
"src/wasm/wasm-import-wrapper-cache.h",
"src/wasm/wasm-linkage.h",
"src/wasm/wasm-module-builder.h",
"src/wasm/wasm-module-sourcemap.h",
"src/wasm/wasm-module.h",
"src/wasm/wasm-objects-inl.h",
"src/wasm/wasm-objects.h",
"src/wasm/wasm-opcodes.h",
"src/wasm/wasm-result.h",
"src/wasm/wasm-serialization.h",
"src/wasm/wasm-subtyping.h",
"src/wasm/wasm-tier.h",
"src/wasm/wasm-value.h",
"src/zone/accounting-allocator.h",
"src/zone/compressed-zone-ptr.h",
"src/zone/type-stats.h",
@ -3035,9 +2997,54 @@ v8_header_set("v8_internal_headers") {
"src/asmjs/asm-parser.h",
"src/asmjs/asm-scanner.h",
"src/asmjs/asm-types.h",
"src/compiler/int64-lowering.h",
"src/compiler/wasm-compiler.h",
"src/debug/debug-wasm-objects-inl.h",
"src/debug/debug-wasm-objects.h",
"src/wasm/baseline/liftoff-assembler-defs.h",
"src/wasm/baseline/liftoff-assembler.h",
"src/wasm/baseline/liftoff-compiler.h",
"src/wasm/baseline/liftoff-register.h",
"src/wasm/code-space-access.h",
"src/wasm/compilation-environment.h",
"src/wasm/decoder.h",
"src/wasm/function-body-decoder-impl.h",
"src/wasm/function-body-decoder.h",
"src/wasm/function-compiler.h",
"src/wasm/graph-builder-interface.h",
"src/wasm/jump-table-assembler.h",
"src/wasm/leb-helper.h",
"src/wasm/local-decl-encoder.h",
"src/wasm/memory-tracing.h",
"src/wasm/module-compiler.h",
"src/wasm/module-decoder.h",
"src/wasm/module-instantiate.h",
"src/wasm/object-access.h",
"src/wasm/signature-map.h",
"src/wasm/simd-shuffle.h",
"src/wasm/streaming-decoder.h",
"src/wasm/struct-types.h",
"src/wasm/value-type.h",
"src/wasm/wasm-arguments.h",
"src/wasm/wasm-code-manager.h",
"src/wasm/wasm-engine.h",
"src/wasm/wasm-external-refs.h",
"src/wasm/wasm-feature-flags.h",
"src/wasm/wasm-features.h",
"src/wasm/wasm-import-wrapper-cache.h",
"src/wasm/wasm-js.h",
"src/wasm/wasm-linkage.h",
"src/wasm/wasm-module-builder.h",
"src/wasm/wasm-module-sourcemap.h",
"src/wasm/wasm-module.h",
"src/wasm/wasm-objects-inl.h",
"src/wasm/wasm-objects.h",
"src/wasm/wasm-opcodes.h",
"src/wasm/wasm-result.h",
"src/wasm/wasm-serialization.h",
"src/wasm/wasm-subtyping.h",
"src/wasm/wasm-tier.h",
"src/wasm/wasm-value.h",
]
}
@ -3344,7 +3351,6 @@ v8_compiler_sources = [
"src/compiler/graph-trimmer.cc",
"src/compiler/graph-visualizer.cc",
"src/compiler/graph.cc",
"src/compiler/int64-lowering.cc",
"src/compiler/js-call-reducer.cc",
"src/compiler/js-context-specialization.cc",
"src/compiler/js-create-lowering.cc",
@ -3395,7 +3401,6 @@ v8_compiler_sources = [
"src/compiler/scheduler.cc",
"src/compiler/select-lowering.cc",
"src/compiler/serializer-for-background-compilation.cc",
"src/compiler/simd-scalar-lowering.cc",
"src/compiler/simplified-lowering.cc",
"src/compiler/simplified-operator-reducer.cc",
"src/compiler/simplified-operator.cc",
@ -3408,10 +3413,17 @@ v8_compiler_sources = [
"src/compiler/types.cc",
"src/compiler/value-numbering-reducer.cc",
"src/compiler/verifier.cc",
"src/compiler/wasm-compiler.cc",
"src/compiler/zone-stats.cc",
]
if (v8_enable_webassembly) {
v8_compiler_sources += [
"src/compiler/int64-lowering.cc",
"src/compiler/simd-scalar-lowering.cc",
"src/compiler/wasm-compiler.cc",
]
}
# The src/compiler files with optimizations.
v8_source_set("v8_compiler_opt") {
visibility = [ ":*" ] # Only targets in this file can depend on this.
@ -3858,11 +3870,9 @@ v8_source_set("v8_base_without_compiler") {
"src/runtime/runtime-scopes.cc",
"src/runtime/runtime-strings.cc",
"src/runtime/runtime-symbol.cc",
"src/runtime/runtime-test-wasm.cc",
"src/runtime/runtime-test.cc",
"src/runtime/runtime-trace.cc",
"src/runtime/runtime-typedarray.cc",
"src/runtime/runtime-wasm.cc",
"src/runtime/runtime-weak-refs.cc",
"src/runtime/runtime.cc",
"src/sanitizer/lsan-page-allocator.cc",
@ -3910,36 +3920,6 @@ v8_source_set("v8_base_without_compiler") {
"src/utils/ostreams.cc",
"src/utils/utils.cc",
"src/utils/version.cc",
"src/wasm/baseline/liftoff-assembler.cc",
"src/wasm/baseline/liftoff-compiler.cc",
"src/wasm/function-body-decoder.cc",
"src/wasm/function-compiler.cc",
"src/wasm/graph-builder-interface.cc",
"src/wasm/jump-table-assembler.cc",
"src/wasm/local-decl-encoder.cc",
"src/wasm/memory-tracing.cc",
"src/wasm/module-compiler.cc",
"src/wasm/module-decoder.cc",
"src/wasm/module-instantiate.cc",
"src/wasm/signature-map.cc",
"src/wasm/simd-shuffle.cc",
"src/wasm/streaming-decoder.cc",
"src/wasm/sync-streaming-decoder.cc",
"src/wasm/value-type.cc",
"src/wasm/wasm-code-manager.cc",
"src/wasm/wasm-debug.cc",
"src/wasm/wasm-engine.cc",
"src/wasm/wasm-external-refs.cc",
"src/wasm/wasm-features.cc",
"src/wasm/wasm-import-wrapper-cache.cc",
"src/wasm/wasm-module-builder.cc",
"src/wasm/wasm-module-sourcemap.cc",
"src/wasm/wasm-module.cc",
"src/wasm/wasm-objects.cc",
"src/wasm/wasm-opcodes.cc",
"src/wasm/wasm-result.cc",
"src/wasm/wasm-serialization.cc",
"src/wasm/wasm-subtyping.cc",
"src/zone/accounting-allocator.cc",
"src/zone/type-stats.cc",
"src/zone/zone-segment.cc",
@ -3953,7 +3933,39 @@ v8_source_set("v8_base_without_compiler") {
"src/asmjs/asm-scanner.cc",
"src/asmjs/asm-types.cc",
"src/debug/debug-wasm-objects.cc",
"src/runtime/runtime-test-wasm.cc",
"src/runtime/runtime-wasm.cc",
"src/wasm/baseline/liftoff-assembler.cc",
"src/wasm/baseline/liftoff-compiler.cc",
"src/wasm/function-body-decoder.cc",
"src/wasm/function-compiler.cc",
"src/wasm/graph-builder-interface.cc",
"src/wasm/jump-table-assembler.cc",
"src/wasm/local-decl-encoder.cc",
"src/wasm/memory-tracing.cc",
"src/wasm/module-compiler.cc",
"src/wasm/module-decoder.cc",
"src/wasm/module-instantiate.cc",
"src/wasm/signature-map.cc",
"src/wasm/simd-shuffle.cc",
"src/wasm/streaming-decoder.cc",
"src/wasm/sync-streaming-decoder.cc",
"src/wasm/value-type.cc",
"src/wasm/wasm-code-manager.cc",
"src/wasm/wasm-debug.cc",
"src/wasm/wasm-engine.cc",
"src/wasm/wasm-external-refs.cc",
"src/wasm/wasm-features.cc",
"src/wasm/wasm-import-wrapper-cache.cc",
"src/wasm/wasm-js.cc",
"src/wasm/wasm-module-builder.cc",
"src/wasm/wasm-module-sourcemap.cc",
"src/wasm/wasm-module.cc",
"src/wasm/wasm-objects.cc",
"src/wasm/wasm-opcodes.cc",
"src/wasm/wasm-result.cc",
"src/wasm/wasm-serialization.cc",
"src/wasm/wasm-subtyping.cc",
]
}

View File

@ -6,6 +6,7 @@
#define V8_API_API_INL_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/objects/foreign-inl.h"

View File

@ -66,6 +66,7 @@
#include "src/objects/embedder-data-slot-inl.h"
#include "src/objects/hash-table-inl.h"
#include "src/objects/heap-object.h"
#include "src/objects/js-array-buffer-inl.h"
#include "src/objects/js-array-inl.h"
#include "src/objects/js-collection-inl.h"
#include "src/objects/js-promise-inl.h"
@ -3002,7 +3003,13 @@ bool StackFrame::IsConstructor() const {
return Utils::OpenHandle(this)->IsConstructor();
}
bool StackFrame::IsWasm() const { return Utils::OpenHandle(this)->IsWasm(); }
bool StackFrame::IsWasm() const {
#if V8_ENABLE_WEBASSEMBLY
return Utils::OpenHandle(this)->IsWasm();
#else
return false;
#endif // V8_ENABLE_WEBASSEMBLY
}
bool StackFrame::IsUserJavaScript() const {
return Utils::OpenHandle(this)->IsUserJavaScript();

View File

@ -5,6 +5,7 @@
#include "src/builtins/accessors.h"
#include "src/api/api-inl.h"
#include "src/debug/debug.h"
#include "src/deoptimizer/deoptimizer.h"
#include "src/execution/execution.h"
#include "src/execution/frames-inl.h"

View File

@ -22,8 +22,11 @@
#include "src/objects/objects-inl.h"
#include "src/objects/smi.h"
#include "src/runtime/runtime.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-linkage.h"
#include "src/wasm/wasm-objects.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {
@ -2309,6 +2312,7 @@ void Builtins::Generate_Construct(MacroAssembler* masm) {
RelocInfo::CODE_TARGET);
}
#if V8_ENABLE_WEBASSEMBLY
void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
// The function index was put in a register by the jump table trampoline.
// Convert to Smi for the runtime call.
@ -2391,6 +2395,12 @@ void Builtins::Generate_WasmDebugBreak(MacroAssembler* masm) {
__ Ret();
}
void Builtins::Generate_GenericJSToWasmWrapper(MacroAssembler* masm) {
// TODO(v8:10701): Implement for this platform.
__ Trap();
}
#endif // V8_ENABLE_WEBASSEMBLY
void Builtins::Generate_CEntry(MacroAssembler* masm, int result_size,
SaveFPRegsMode save_doubles, ArgvMode argv_mode,
bool builtin_exit_frame) {
@ -2639,11 +2649,6 @@ void Builtins::Generate_DoubleToI(MacroAssembler* masm) {
__ Ret();
}
void Builtins::Generate_GenericJSToWasmWrapper(MacroAssembler* masm) {
// TODO(v8:10701): Implement for this platform.
__ Trap();
}
namespace {
int AddressOffset(ExternalReference ref0, ExternalReference ref1) {

View File

@ -23,8 +23,11 @@
#include "src/objects/objects-inl.h"
#include "src/objects/smi.h"
#include "src/runtime/runtime.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-linkage.h"
#include "src/wasm/wasm-objects.h"
#endif // V8_ENABLE_WEBASSEMBLY
#if defined(V8_OS_WIN)
#include "src/diagnostics/unwinding-info-win64.h"
@ -2909,6 +2912,7 @@ void Builtins::Generate_Construct(MacroAssembler* masm) {
RelocInfo::CODE_TARGET);
}
#if V8_ENABLE_WEBASSEMBLY
void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
// The function index was put in w8 by the jump table trampoline.
// Sign extend and convert to Smi for the runtime call.
@ -2994,6 +2998,12 @@ void Builtins::Generate_WasmDebugBreak(MacroAssembler* masm) {
__ Ret();
}
void Builtins::Generate_GenericJSToWasmWrapper(MacroAssembler* masm) {
// TODO(v8:10701): Implement for this platform.
__ Trap();
}
#endif // V8_ENABLE_WEBASSEMBLY
void Builtins::Generate_CEntry(MacroAssembler* masm, int result_size,
SaveFPRegsMode save_doubles, ArgvMode argv_mode,
bool builtin_exit_frame) {
@ -3279,11 +3289,6 @@ void Builtins::Generate_DoubleToI(MacroAssembler* masm) {
__ Ret();
}
void Builtins::Generate_GenericJSToWasmWrapper(MacroAssembler* masm) {
// TODO(v8:10701): Implement for this platform.
__ Trap();
}
namespace {
// The number of register that CallApiFunctionAndReturn will need to save on

View File

@ -15,6 +15,7 @@
#include "src/objects/contexts.h"
#include "src/objects/elements-inl.h"
#include "src/objects/hash-table-inl.h"
#include "src/objects/js-array-buffer-inl.h"
#include "src/objects/js-array-inl.h"
#include "src/objects/lookup.h"
#include "src/objects/objects-inl.h"

View File

@ -121,9 +121,11 @@ BUILTIN(CallSitePrototypeGetThis) {
CHECK_CALLSITE(frame, "getThis");
if (frame->IsStrict()) return ReadOnlyRoots(isolate).undefined_value();
isolate->CountUsage(v8::Isolate::kCallSiteAPIGetThisSloppyCall);
#if V8_ENABLE_WEBASSEMBLY
if (frame->IsAsmJsWasm()) {
return frame->GetWasmInstance().native_context().global_proxy();
}
#endif // V8_ENABLE_WEBASSEMBLY
return frame->receiver_or_instance();
}

View File

@ -600,7 +600,7 @@ namespace internal {
TFS(IterableToListWithSymbolLookup, kIterable) \
TFS(IterableToFixedArrayWithSymbolLookupSlow, kIterable) \
TFS(IterableToListMayPreserveHoles, kIterable, kIteratorFn) \
TFS(IterableToFixedArrayForWasm, kIterable, kExpectedLength) \
IF_WASM(TFS, IterableToFixedArrayForWasm, kIterable, kExpectedLength) \
\
/* #sec-createstringlistfromiterable */ \
TFS(StringListFromIterable, kIterable) \
@ -855,14 +855,14 @@ namespace internal {
TFJ(TypedArrayPrototypeMap, kDontAdaptArgumentsSentinel) \
\
/* Wasm */ \
ASM(GenericJSToWasmWrapper, Dummy) \
ASM(WasmCompileLazy, Dummy) \
ASM(WasmDebugBreak, Dummy) \
TFC(WasmFloat32ToNumber, WasmFloat32ToNumber) \
TFC(WasmFloat64ToNumber, WasmFloat64ToNumber) \
TFC(WasmI32AtomicWait32, WasmI32AtomicWait32) \
TFC(WasmI64AtomicWait32, WasmI64AtomicWait32) \
TFC(JSToWasmLazyDeoptContinuation, SingleParameterOnStack) \
IF_WASM(ASM, GenericJSToWasmWrapper, Dummy) \
IF_WASM(ASM, WasmCompileLazy, Dummy) \
IF_WASM(ASM, WasmDebugBreak, Dummy) \
IF_WASM(TFC, WasmFloat32ToNumber, WasmFloat32ToNumber) \
IF_WASM(TFC, WasmFloat64ToNumber, WasmFloat64ToNumber) \
IF_WASM(TFC, WasmI32AtomicWait32, WasmI32AtomicWait32) \
IF_WASM(TFC, WasmI64AtomicWait32, WasmI64AtomicWait32) \
IF_WASM(TFC, JSToWasmLazyDeoptContinuation, SingleParameterOnStack) \
\
/* WeakMap */ \
TFJ(WeakMapConstructor, kDontAdaptArgumentsSentinel) \

View File

@ -194,6 +194,7 @@ TF_BUILTIN(IterableToFixedArray, IteratorBuiltinsAssembler) {
Return(IterableToFixedArray(context, iterable, iterator_fn));
}
#if V8_ENABLE_WEBASSEMBLY
TF_BUILTIN(IterableToFixedArrayForWasm, IteratorBuiltinsAssembler) {
auto context = Parameter<Context>(Descriptor::kContext);
auto iterable = Parameter<Object>(Descriptor::kIterable);
@ -215,6 +216,7 @@ TF_BUILTIN(IterableToFixedArrayForWasm, IteratorBuiltinsAssembler) {
BIND(&done);
Return(values.var_array()->value());
}
#endif // V8_ENABLE_WEBASSEMBLY
TNode<JSArray> IteratorBuiltinsAssembler::StringListFromIterable(
TNode<Context> context, TNode<Object> iterable) {

View File

@ -11,6 +11,7 @@
#include "src/execution/protectors.h"
#include "src/handles/handles-inl.h"
#include "src/heap/factory-inl.h"
#include "src/objects/js-array-buffer-inl.h"
namespace v8 {
namespace internal {

View File

@ -485,7 +485,9 @@ bool Builtins::CodeObjectIsExecutable(int builtin_index) {
case Builtins::kCall_ReceiverIsAny:
case Builtins::kHandleApiCall:
case Builtins::kInstantiateAsmJs:
#if V8_ENABLE_WEBASSEMBLY
case Builtins::kGenericJSToWasmWrapper:
#endif // V8_ENABLE_WEBASSEMBLY
// TODO(delphick): Remove this when calls to it have the trampoline inlined
// or are converted to use kCallBuiltinPointer.

View File

@ -23,8 +23,11 @@
#include "src/objects/js-generator.h"
#include "src/objects/objects-inl.h"
#include "src/objects/smi.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-linkage.h"
#include "src/wasm/wasm-objects.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {
@ -2776,6 +2779,7 @@ void Builtins::Generate_BaselineOnStackReplacement(MacroAssembler* masm) {
return OnStackReplacement(masm, false);
}
#if V8_ENABLE_WEBASSEMBLY
void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
// The function index was put in edi by the jump table trampoline.
// Convert to Smi for the runtime call.
@ -2876,6 +2880,12 @@ void Builtins::Generate_WasmDebugBreak(MacroAssembler* masm) {
__ ret(0);
}
void Builtins::Generate_GenericJSToWasmWrapper(MacroAssembler* masm) {
// TODO(v8:10701): Implement for this platform.
__ Trap();
}
#endif // V8_ENABLE_WEBASSEMBLY
void Builtins::Generate_CEntry(MacroAssembler* masm, int result_size,
SaveFPRegsMode save_doubles, ArgvMode argv_mode,
bool builtin_exit_frame) {
@ -3112,11 +3122,6 @@ void Builtins::Generate_DoubleToI(MacroAssembler* masm) {
__ ret(0);
}
void Builtins::Generate_GenericJSToWasmWrapper(MacroAssembler* masm) {
// TODO(v8:10701): Implement for this platform.
__ Trap();
}
namespace {
// Generates an Operand for saving parameters after PrepareCallApiFunction.

View File

@ -26,11 +26,14 @@
#include "src/objects/js-generator.h"
#include "src/objects/objects-inl.h"
#include "src/objects/smi.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/baseline/liftoff-assembler-defs.h"
#include "src/wasm/object-access.h"
#include "src/wasm/wasm-constants.h"
#include "src/wasm/wasm-linkage.h"
#include "src/wasm/wasm-objects.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {
@ -2675,6 +2678,7 @@ void Builtins::Generate_BaselineOnStackReplacement(MacroAssembler* masm) {
return OnStackReplacement(masm, false);
}
#if V8_ENABLE_WEBASSEMBLY
void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
// The function index was pushed to the stack by the caller as int32.
__ Pop(r11);
@ -2772,244 +2776,6 @@ void Builtins::Generate_WasmDebugBreak(MacroAssembler* masm) {
__ ret(0);
}
void Builtins::Generate_CEntry(MacroAssembler* masm, int result_size,
SaveFPRegsMode save_doubles, ArgvMode argv_mode,
bool builtin_exit_frame) {
// rax: number of arguments including receiver
// rbx: pointer to C function (C callee-saved)
// rbp: frame pointer of calling JS frame (restored after C call)
// rsp: stack pointer (restored after C call)
// rsi: current context (restored)
//
// If argv_mode == kArgvInRegister:
// r15: pointer to the first argument
#ifdef V8_TARGET_OS_WIN
// Windows 64-bit ABI passes arguments in rcx, rdx, r8, r9. It requires the
// stack to be aligned to 16 bytes. It only allows a single-word to be
// returned in register rax. Larger return sizes must be written to an address
// passed as a hidden first argument.
const Register kCCallArg0 = rcx;
const Register kCCallArg1 = rdx;
const Register kCCallArg2 = r8;
const Register kCCallArg3 = r9;
const int kArgExtraStackSpace = 2;
const int kMaxRegisterResultSize = 1;
#else
// GCC / Clang passes arguments in rdi, rsi, rdx, rcx, r8, r9. Simple results
// are returned in rax, and a struct of two pointers are returned in rax+rdx.
// Larger return sizes must be written to an address passed as a hidden first
// argument.
const Register kCCallArg0 = rdi;
const Register kCCallArg1 = rsi;
const Register kCCallArg2 = rdx;
const Register kCCallArg3 = rcx;
const int kArgExtraStackSpace = 0;
const int kMaxRegisterResultSize = 2;
#endif // V8_TARGET_OS_WIN
// Enter the exit frame that transitions from JavaScript to C++.
int arg_stack_space =
kArgExtraStackSpace +
(result_size <= kMaxRegisterResultSize ? 0 : result_size);
if (argv_mode == kArgvInRegister) {
DCHECK(save_doubles == kDontSaveFPRegs);
DCHECK(!builtin_exit_frame);
__ EnterApiExitFrame(arg_stack_space);
// Move argc into r12 (argv is already in r15).
__ movq(r12, rax);
} else {
__ EnterExitFrame(
arg_stack_space, save_doubles == kSaveFPRegs,
builtin_exit_frame ? StackFrame::BUILTIN_EXIT : StackFrame::EXIT);
}
// rbx: pointer to builtin function (C callee-saved).
// rbp: frame pointer of exit frame (restored after C call).
// rsp: stack pointer (restored after C call).
// r12: number of arguments including receiver (C callee-saved).
// r15: argv pointer (C callee-saved).
// Check stack alignment.
if (FLAG_debug_code) {
__ CheckStackAlignment();
}
// Call C function. The arguments object will be created by stubs declared by
// DECLARE_RUNTIME_FUNCTION().
if (result_size <= kMaxRegisterResultSize) {
// Pass a pointer to the Arguments object as the first argument.
// Return result in single register (rax), or a register pair (rax, rdx).
__ movq(kCCallArg0, r12); // argc.
__ movq(kCCallArg1, r15); // argv.
__ Move(kCCallArg2, ExternalReference::isolate_address(masm->isolate()));
} else {
DCHECK_LE(result_size, 2);
// Pass a pointer to the result location as the first argument.
__ leaq(kCCallArg0, StackSpaceOperand(kArgExtraStackSpace));
// Pass a pointer to the Arguments object as the second argument.
__ movq(kCCallArg1, r12); // argc.
__ movq(kCCallArg2, r15); // argv.
__ Move(kCCallArg3, ExternalReference::isolate_address(masm->isolate()));
}
__ call(rbx);
if (result_size > kMaxRegisterResultSize) {
// Read result values stored on stack. Result is stored
// above the the two Arguments object slots on Win64.
DCHECK_LE(result_size, 2);
__ movq(kReturnRegister0, StackSpaceOperand(kArgExtraStackSpace + 0));
__ movq(kReturnRegister1, StackSpaceOperand(kArgExtraStackSpace + 1));
}
// Result is in rax or rdx:rax - do not destroy these registers!
// Check result for exception sentinel.
Label exception_returned;
__ CompareRoot(rax, RootIndex::kException);
__ j(equal, &exception_returned);
// Check that there is no pending exception, otherwise we
// should have returned the exception sentinel.
if (FLAG_debug_code) {
Label okay;
__ LoadRoot(kScratchRegister, RootIndex::kTheHoleValue);
ExternalReference pending_exception_address = ExternalReference::Create(
IsolateAddressId::kPendingExceptionAddress, masm->isolate());
Operand pending_exception_operand =
masm->ExternalReferenceAsOperand(pending_exception_address);
__ cmp_tagged(kScratchRegister, pending_exception_operand);
__ j(equal, &okay, Label::kNear);
__ int3();
__ bind(&okay);
}
// Exit the JavaScript to C++ exit frame.
__ LeaveExitFrame(save_doubles == kSaveFPRegs, argv_mode == kArgvOnStack);
__ ret(0);
// Handling of exception.
__ bind(&exception_returned);
ExternalReference pending_handler_context_address = ExternalReference::Create(
IsolateAddressId::kPendingHandlerContextAddress, masm->isolate());
ExternalReference pending_handler_entrypoint_address =
ExternalReference::Create(
IsolateAddressId::kPendingHandlerEntrypointAddress, masm->isolate());
ExternalReference pending_handler_fp_address = ExternalReference::Create(
IsolateAddressId::kPendingHandlerFPAddress, masm->isolate());
ExternalReference pending_handler_sp_address = ExternalReference::Create(
IsolateAddressId::kPendingHandlerSPAddress, masm->isolate());
// Ask the runtime for help to determine the handler. This will set rax to
// contain the current pending exception, don't clobber it.
ExternalReference find_handler =
ExternalReference::Create(Runtime::kUnwindAndFindExceptionHandler);
{
FrameScope scope(masm, StackFrame::MANUAL);
__ movq(arg_reg_1, Immediate(0)); // argc.
__ movq(arg_reg_2, Immediate(0)); // argv.
__ Move(arg_reg_3, ExternalReference::isolate_address(masm->isolate()));
__ PrepareCallCFunction(3);
__ CallCFunction(find_handler, 3);
}
// Retrieve the handler context, SP and FP.
__ movq(rsi,
masm->ExternalReferenceAsOperand(pending_handler_context_address));
__ movq(rsp, masm->ExternalReferenceAsOperand(pending_handler_sp_address));
__ movq(rbp, masm->ExternalReferenceAsOperand(pending_handler_fp_address));
// If the handler is a JS frame, restore the context to the frame. Note that
// the context will be set to (rsi == 0) for non-JS frames.
Label skip;
__ testq(rsi, rsi);
__ j(zero, &skip, Label::kNear);
__ movq(Operand(rbp, StandardFrameConstants::kContextOffset), rsi);
__ bind(&skip);
// Reset the masking register. This is done independent of the underlying
// feature flag {FLAG_untrusted_code_mitigations} to make the snapshot work
// with both configurations. It is safe to always do this, because the
// underlying register is caller-saved and can be arbitrarily clobbered.
__ ResetSpeculationPoisonRegister();
// Clear c_entry_fp, like we do in `LeaveExitFrame`.
ExternalReference c_entry_fp_address = ExternalReference::Create(
IsolateAddressId::kCEntryFPAddress, masm->isolate());
Operand c_entry_fp_operand =
masm->ExternalReferenceAsOperand(c_entry_fp_address);
__ movq(c_entry_fp_operand, Immediate(0));
// Compute the handler entry address and jump to it.
__ movq(rdi,
masm->ExternalReferenceAsOperand(pending_handler_entrypoint_address));
__ jmp(rdi);
}
void Builtins::Generate_DoubleToI(MacroAssembler* masm) {
Label check_negative, process_64_bits, done;
// Account for return address and saved regs.
const int kArgumentOffset = 4 * kSystemPointerSize;
MemOperand mantissa_operand(MemOperand(rsp, kArgumentOffset));
MemOperand exponent_operand(
MemOperand(rsp, kArgumentOffset + kDoubleSize / 2));
// The result is returned on the stack.
MemOperand return_operand = mantissa_operand;
Register scratch1 = rbx;
// Since we must use rcx for shifts below, use some other register (rax)
// to calculate the result if ecx is the requested return register.
Register result_reg = rax;
// Save ecx if it isn't the return register and therefore volatile, or if it
// is the return register, then save the temp register we use in its stead
// for the result.
Register save_reg = rax;
__ pushq(rcx);
__ pushq(scratch1);
__ pushq(save_reg);
__ movl(scratch1, mantissa_operand);
__ Movsd(kScratchDoubleReg, mantissa_operand);
__ movl(rcx, exponent_operand);
__ andl(rcx, Immediate(HeapNumber::kExponentMask));
__ shrl(rcx, Immediate(HeapNumber::kExponentShift));
__ leal(result_reg, MemOperand(rcx, -HeapNumber::kExponentBias));
__ cmpl(result_reg, Immediate(HeapNumber::kMantissaBits));
__ j(below, &process_64_bits, Label::kNear);
// Result is entirely in lower 32-bits of mantissa
int delta = HeapNumber::kExponentBias + Double::kPhysicalSignificandSize;
__ subl(rcx, Immediate(delta));
__ xorl(result_reg, result_reg);
__ cmpl(rcx, Immediate(31));
__ j(above, &done, Label::kNear);
__ shll_cl(scratch1);
__ jmp(&check_negative, Label::kNear);
__ bind(&process_64_bits);
__ Cvttsd2siq(result_reg, kScratchDoubleReg);
__ jmp(&done, Label::kNear);
// If the double was negative, negate the integer result.
__ bind(&check_negative);
__ movl(result_reg, scratch1);
__ negl(result_reg);
__ cmpl(exponent_operand, Immediate(0));
__ cmovl(greater, result_reg, scratch1);
// Restore registers
__ bind(&done);
__ movl(return_operand, result_reg);
__ popq(save_reg);
__ popq(scratch1);
__ popq(rcx);
__ ret(0);
}
namespace {
// Helper functions for the GenericJSToWasmWrapper.
void PrepareForBuiltinCall(MacroAssembler* masm, MemOperand GCScanSlotPlace,
@ -3754,6 +3520,246 @@ void Builtins::Generate_GenericJSToWasmWrapper(MacroAssembler* masm) {
__ jmp(&compile_wrapper_done);
}
#endif // V8_ENABLE_WEBASSEMBLY
void Builtins::Generate_CEntry(MacroAssembler* masm, int result_size,
SaveFPRegsMode save_doubles, ArgvMode argv_mode,
bool builtin_exit_frame) {
// rax: number of arguments including receiver
// rbx: pointer to C function (C callee-saved)
// rbp: frame pointer of calling JS frame (restored after C call)
// rsp: stack pointer (restored after C call)
// rsi: current context (restored)
//
// If argv_mode == kArgvInRegister:
// r15: pointer to the first argument
#ifdef V8_TARGET_OS_WIN
// Windows 64-bit ABI passes arguments in rcx, rdx, r8, r9. It requires the
// stack to be aligned to 16 bytes. It only allows a single-word to be
// returned in register rax. Larger return sizes must be written to an address
// passed as a hidden first argument.
const Register kCCallArg0 = rcx;
const Register kCCallArg1 = rdx;
const Register kCCallArg2 = r8;
const Register kCCallArg3 = r9;
const int kArgExtraStackSpace = 2;
const int kMaxRegisterResultSize = 1;
#else
// GCC / Clang passes arguments in rdi, rsi, rdx, rcx, r8, r9. Simple results
// are returned in rax, and a struct of two pointers are returned in rax+rdx.
// Larger return sizes must be written to an address passed as a hidden first
// argument.
const Register kCCallArg0 = rdi;
const Register kCCallArg1 = rsi;
const Register kCCallArg2 = rdx;
const Register kCCallArg3 = rcx;
const int kArgExtraStackSpace = 0;
const int kMaxRegisterResultSize = 2;
#endif // V8_TARGET_OS_WIN
// Enter the exit frame that transitions from JavaScript to C++.
int arg_stack_space =
kArgExtraStackSpace +
(result_size <= kMaxRegisterResultSize ? 0 : result_size);
if (argv_mode == kArgvInRegister) {
DCHECK(save_doubles == kDontSaveFPRegs);
DCHECK(!builtin_exit_frame);
__ EnterApiExitFrame(arg_stack_space);
// Move argc into r12 (argv is already in r15).
__ movq(r12, rax);
} else {
__ EnterExitFrame(
arg_stack_space, save_doubles == kSaveFPRegs,
builtin_exit_frame ? StackFrame::BUILTIN_EXIT : StackFrame::EXIT);
}
// rbx: pointer to builtin function (C callee-saved).
// rbp: frame pointer of exit frame (restored after C call).
// rsp: stack pointer (restored after C call).
// r12: number of arguments including receiver (C callee-saved).
// r15: argv pointer (C callee-saved).
// Check stack alignment.
if (FLAG_debug_code) {
__ CheckStackAlignment();
}
// Call C function. The arguments object will be created by stubs declared by
// DECLARE_RUNTIME_FUNCTION().
if (result_size <= kMaxRegisterResultSize) {
// Pass a pointer to the Arguments object as the first argument.
// Return result in single register (rax), or a register pair (rax, rdx).
__ movq(kCCallArg0, r12); // argc.
__ movq(kCCallArg1, r15); // argv.
__ Move(kCCallArg2, ExternalReference::isolate_address(masm->isolate()));
} else {
DCHECK_LE(result_size, 2);
// Pass a pointer to the result location as the first argument.
__ leaq(kCCallArg0, StackSpaceOperand(kArgExtraStackSpace));
// Pass a pointer to the Arguments object as the second argument.
__ movq(kCCallArg1, r12); // argc.
__ movq(kCCallArg2, r15); // argv.
__ Move(kCCallArg3, ExternalReference::isolate_address(masm->isolate()));
}
__ call(rbx);
if (result_size > kMaxRegisterResultSize) {
// Read result values stored on stack. Result is stored
// above the the two Arguments object slots on Win64.
DCHECK_LE(result_size, 2);
__ movq(kReturnRegister0, StackSpaceOperand(kArgExtraStackSpace + 0));
__ movq(kReturnRegister1, StackSpaceOperand(kArgExtraStackSpace + 1));
}
// Result is in rax or rdx:rax - do not destroy these registers!
// Check result for exception sentinel.
Label exception_returned;
__ CompareRoot(rax, RootIndex::kException);
__ j(equal, &exception_returned);
// Check that there is no pending exception, otherwise we
// should have returned the exception sentinel.
if (FLAG_debug_code) {
Label okay;
__ LoadRoot(kScratchRegister, RootIndex::kTheHoleValue);
ExternalReference pending_exception_address = ExternalReference::Create(
IsolateAddressId::kPendingExceptionAddress, masm->isolate());
Operand pending_exception_operand =
masm->ExternalReferenceAsOperand(pending_exception_address);
__ cmp_tagged(kScratchRegister, pending_exception_operand);
__ j(equal, &okay, Label::kNear);
__ int3();
__ bind(&okay);
}
// Exit the JavaScript to C++ exit frame.
__ LeaveExitFrame(save_doubles == kSaveFPRegs, argv_mode == kArgvOnStack);
__ ret(0);
// Handling of exception.
__ bind(&exception_returned);
ExternalReference pending_handler_context_address = ExternalReference::Create(
IsolateAddressId::kPendingHandlerContextAddress, masm->isolate());
ExternalReference pending_handler_entrypoint_address =
ExternalReference::Create(
IsolateAddressId::kPendingHandlerEntrypointAddress, masm->isolate());
ExternalReference pending_handler_fp_address = ExternalReference::Create(
IsolateAddressId::kPendingHandlerFPAddress, masm->isolate());
ExternalReference pending_handler_sp_address = ExternalReference::Create(
IsolateAddressId::kPendingHandlerSPAddress, masm->isolate());
// Ask the runtime for help to determine the handler. This will set rax to
// contain the current pending exception, don't clobber it.
ExternalReference find_handler =
ExternalReference::Create(Runtime::kUnwindAndFindExceptionHandler);
{
FrameScope scope(masm, StackFrame::MANUAL);
__ movq(arg_reg_1, Immediate(0)); // argc.
__ movq(arg_reg_2, Immediate(0)); // argv.
__ Move(arg_reg_3, ExternalReference::isolate_address(masm->isolate()));
__ PrepareCallCFunction(3);
__ CallCFunction(find_handler, 3);
}
// Retrieve the handler context, SP and FP.
__ movq(rsi,
masm->ExternalReferenceAsOperand(pending_handler_context_address));
__ movq(rsp, masm->ExternalReferenceAsOperand(pending_handler_sp_address));
__ movq(rbp, masm->ExternalReferenceAsOperand(pending_handler_fp_address));
// If the handler is a JS frame, restore the context to the frame. Note that
// the context will be set to (rsi == 0) for non-JS frames.
Label skip;
__ testq(rsi, rsi);
__ j(zero, &skip, Label::kNear);
__ movq(Operand(rbp, StandardFrameConstants::kContextOffset), rsi);
__ bind(&skip);
// Reset the masking register. This is done independent of the underlying
// feature flag {FLAG_untrusted_code_mitigations} to make the snapshot work
// with both configurations. It is safe to always do this, because the
// underlying register is caller-saved and can be arbitrarily clobbered.
__ ResetSpeculationPoisonRegister();
// Clear c_entry_fp, like we do in `LeaveExitFrame`.
ExternalReference c_entry_fp_address = ExternalReference::Create(
IsolateAddressId::kCEntryFPAddress, masm->isolate());
Operand c_entry_fp_operand =
masm->ExternalReferenceAsOperand(c_entry_fp_address);
__ movq(c_entry_fp_operand, Immediate(0));
// Compute the handler entry address and jump to it.
__ movq(rdi,
masm->ExternalReferenceAsOperand(pending_handler_entrypoint_address));
__ jmp(rdi);
}
void Builtins::Generate_DoubleToI(MacroAssembler* masm) {
Label check_negative, process_64_bits, done;
// Account for return address and saved regs.
const int kArgumentOffset = 4 * kSystemPointerSize;
MemOperand mantissa_operand(MemOperand(rsp, kArgumentOffset));
MemOperand exponent_operand(
MemOperand(rsp, kArgumentOffset + kDoubleSize / 2));
// The result is returned on the stack.
MemOperand return_operand = mantissa_operand;
Register scratch1 = rbx;
// Since we must use rcx for shifts below, use some other register (rax)
// to calculate the result if ecx is the requested return register.
Register result_reg = rax;
// Save ecx if it isn't the return register and therefore volatile, or if it
// is the return register, then save the temp register we use in its stead
// for the result.
Register save_reg = rax;
__ pushq(rcx);
__ pushq(scratch1);
__ pushq(save_reg);
__ movl(scratch1, mantissa_operand);
__ Movsd(kScratchDoubleReg, mantissa_operand);
__ movl(rcx, exponent_operand);
__ andl(rcx, Immediate(HeapNumber::kExponentMask));
__ shrl(rcx, Immediate(HeapNumber::kExponentShift));
__ leal(result_reg, MemOperand(rcx, -HeapNumber::kExponentBias));
__ cmpl(result_reg, Immediate(HeapNumber::kMantissaBits));
__ j(below, &process_64_bits, Label::kNear);
// Result is entirely in lower 32-bits of mantissa
int delta = HeapNumber::kExponentBias + Double::kPhysicalSignificandSize;
__ subl(rcx, Immediate(delta));
__ xorl(result_reg, result_reg);
__ cmpl(rcx, Immediate(31));
__ j(above, &done, Label::kNear);
__ shll_cl(scratch1);
__ jmp(&check_negative, Label::kNear);
__ bind(&process_64_bits);
__ Cvttsd2siq(result_reg, kScratchDoubleReg);
__ jmp(&done, Label::kNear);
// If the double was negative, negate the integer result.
__ bind(&check_negative);
__ movl(result_reg, scratch1);
__ negl(result_reg);
__ cmpl(exponent_operand, Immediate(0));
__ cmovl(greater, result_reg, scratch1);
// Restore registers
__ bind(&done);
__ movl(return_operand, result_reg);
__ popq(save_reg);
__ popq(scratch1);
__ popq(rcx);
__ ret(0);
}
namespace {
int Offset(ExternalReference ref0, ExternalReference ref1) {

View File

@ -1918,11 +1918,12 @@ void TurboAssembler::TruncateDoubleToI(Isolate* isolate, Zone* zone,
AllocateStackSpace(kDoubleSize); // Put input on stack.
vstr(double_input, MemOperand(sp, 0));
if (stub_mode == StubCallMode::kCallWasmRuntimeStub) {
#if V8_ENABLE_WEBASSEMBLY
if (stub_mode == StubCallMode::kCallWasmRuntimeStub) {
Call(wasm::WasmCode::kDoubleToI, RelocInfo::WASM_STUB_CALL);
#else
UNREACHABLE();
// For balance.
if (false) {
#endif // V8_ENABLE_WEBASSEMBLY
} else if (options().inline_offheap_trampolines) {
CallBuiltin(Builtins::kDoubleToI);

View File

@ -2427,11 +2427,12 @@ void TurboAssembler::TruncateDoubleToI(Isolate* isolate, Zone* zone,
}
// DoubleToI preserves any registers it needs to clobber.
if (stub_mode == StubCallMode::kCallWasmRuntimeStub) {
#if V8_ENABLE_WEBASSEMBLY
if (stub_mode == StubCallMode::kCallWasmRuntimeStub) {
Call(wasm::WasmCode::kDoubleToI, RelocInfo::WASM_STUB_CALL);
#else
UNREACHABLE();
// For balance.
if (false) {
#endif // V8_ENABLE_WEBASSEMBLY
} else if (options().inline_offheap_trampolines) {
CallBuiltin(Builtins::kDoubleToI);

View File

@ -347,9 +347,13 @@ void RecordUnoptimizedFunctionCompilation(
abstract_code =
handle(AbstractCode::cast(shared->GetBytecodeArray(isolate)), isolate);
} else {
#if V8_ENABLE_WEBASSEMBLY
DCHECK(shared->HasAsmWasmData());
abstract_code =
Handle<AbstractCode>::cast(BUILTIN_CODE(isolate, InstantiateAsmJs));
#else
UNREACHABLE();
#endif // V8_ENABLE_WEBASSEMBLY
}
double time_taken_ms = time_taken_to_execute.InMillisecondsF() +
@ -565,11 +569,13 @@ void InstallUnoptimizedCode(UnoptimizedCompilationInfo* compilation_info,
DCHECK(!compilation_info->has_asm_wasm_data());
DCHECK(!shared_info->HasFeedbackMetadata());
#if V8_ENABLE_WEBASSEMBLY
// If the function failed asm-wasm compilation, mark asm_wasm as broken
// to ensure we don't try to compile as asm-wasm.
if (compilation_info->literal()->scope()->IsAsmModule()) {
shared_info->set_is_asm_wasm_broken(true);
}
#endif // V8_ENABLE_WEBASSEMBLY
shared_info->set_bytecode_array(*compilation_info->bytecode_array());
@ -1993,7 +1999,11 @@ bool Compiler::Compile(Isolate* isolate, Handle<JSFunction> function,
JSFunction::InitializeFeedbackCell(function, is_compiled_scope, true);
// Optimize now if --always-opt is enabled.
#if V8_ENABLE_WEBASSEMBLY
if (FLAG_always_opt && !function->shared().HasAsmWasmData()) {
#else
if (FLAG_always_opt) {
#endif // V8_ENABLE_WEBASSEMBLY
CompilerTracer::TraceOptimizeForAlwaysOpt(isolate, function,
CodeKindForTopTier());

View File

@ -30,7 +30,10 @@
#include "src/regexp/regexp-macro-assembler-arch.h"
#include "src/regexp/regexp-stack.h"
#include "src/strings/string-search.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-external-refs.h"
#endif // V8_ENABLE_WEBASSEMBLY
#ifdef V8_INTL_SUPPORT
#include "src/base/platform/wrappers.h"
@ -335,53 +338,66 @@ FUNCTION_REFERENCE(new_deoptimizer_function, Deoptimizer::New)
FUNCTION_REFERENCE(compute_output_frames_function,
Deoptimizer::ComputeOutputFrames)
FUNCTION_REFERENCE(wasm_f32_trunc, wasm::f32_trunc_wrapper)
FUNCTION_REFERENCE(wasm_f32_floor, wasm::f32_floor_wrapper)
FUNCTION_REFERENCE(wasm_f32_ceil, wasm::f32_ceil_wrapper)
FUNCTION_REFERENCE(wasm_f32_nearest_int, wasm::f32_nearest_int_wrapper)
FUNCTION_REFERENCE(wasm_f64_trunc, wasm::f64_trunc_wrapper)
FUNCTION_REFERENCE(wasm_f64_floor, wasm::f64_floor_wrapper)
FUNCTION_REFERENCE(wasm_f64_ceil, wasm::f64_ceil_wrapper)
FUNCTION_REFERENCE(wasm_f64_nearest_int, wasm::f64_nearest_int_wrapper)
FUNCTION_REFERENCE(wasm_int64_to_float32, wasm::int64_to_float32_wrapper)
FUNCTION_REFERENCE(wasm_uint64_to_float32, wasm::uint64_to_float32_wrapper)
FUNCTION_REFERENCE(wasm_int64_to_float64, wasm::int64_to_float64_wrapper)
FUNCTION_REFERENCE(wasm_uint64_to_float64, wasm::uint64_to_float64_wrapper)
FUNCTION_REFERENCE(wasm_float32_to_int64, wasm::float32_to_int64_wrapper)
FUNCTION_REFERENCE(wasm_float32_to_uint64, wasm::float32_to_uint64_wrapper)
FUNCTION_REFERENCE(wasm_float64_to_int64, wasm::float64_to_int64_wrapper)
FUNCTION_REFERENCE(wasm_float64_to_uint64, wasm::float64_to_uint64_wrapper)
FUNCTION_REFERENCE(wasm_float32_to_int64_sat,
wasm::float32_to_int64_sat_wrapper)
FUNCTION_REFERENCE(wasm_float32_to_uint64_sat,
wasm::float32_to_uint64_sat_wrapper)
FUNCTION_REFERENCE(wasm_float64_to_int64_sat,
wasm::float64_to_int64_sat_wrapper)
FUNCTION_REFERENCE(wasm_float64_to_uint64_sat,
wasm::float64_to_uint64_sat_wrapper)
FUNCTION_REFERENCE(wasm_int64_div, wasm::int64_div_wrapper)
FUNCTION_REFERENCE(wasm_int64_mod, wasm::int64_mod_wrapper)
FUNCTION_REFERENCE(wasm_uint64_div, wasm::uint64_div_wrapper)
FUNCTION_REFERENCE(wasm_uint64_mod, wasm::uint64_mod_wrapper)
FUNCTION_REFERENCE(wasm_word32_ctz, wasm::word32_ctz_wrapper)
FUNCTION_REFERENCE(wasm_word64_ctz, wasm::word64_ctz_wrapper)
FUNCTION_REFERENCE(wasm_word32_popcnt, wasm::word32_popcnt_wrapper)
FUNCTION_REFERENCE(wasm_word64_popcnt, wasm::word64_popcnt_wrapper)
FUNCTION_REFERENCE(wasm_word32_rol, wasm::word32_rol_wrapper)
FUNCTION_REFERENCE(wasm_word32_ror, wasm::word32_ror_wrapper)
FUNCTION_REFERENCE(wasm_word64_rol, wasm::word64_rol_wrapper)
FUNCTION_REFERENCE(wasm_word64_ror, wasm::word64_ror_wrapper)
FUNCTION_REFERENCE(wasm_f64x2_ceil, wasm::f64x2_ceil_wrapper)
FUNCTION_REFERENCE(wasm_f64x2_floor, wasm::f64x2_floor_wrapper)
FUNCTION_REFERENCE(wasm_f64x2_trunc, wasm::f64x2_trunc_wrapper)
FUNCTION_REFERENCE(wasm_f64x2_nearest_int, wasm::f64x2_nearest_int_wrapper)
FUNCTION_REFERENCE(wasm_f32x4_ceil, wasm::f32x4_ceil_wrapper)
FUNCTION_REFERENCE(wasm_f32x4_floor, wasm::f32x4_floor_wrapper)
FUNCTION_REFERENCE(wasm_f32x4_trunc, wasm::f32x4_trunc_wrapper)
FUNCTION_REFERENCE(wasm_f32x4_nearest_int, wasm::f32x4_nearest_int_wrapper)
FUNCTION_REFERENCE(wasm_memory_init, wasm::memory_init_wrapper)
FUNCTION_REFERENCE(wasm_memory_copy, wasm::memory_copy_wrapper)
FUNCTION_REFERENCE(wasm_memory_fill, wasm::memory_fill_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_f32_trunc, wasm::f32_trunc_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_f32_floor, wasm::f32_floor_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_f32_ceil, wasm::f32_ceil_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_f32_nearest_int, wasm::f32_nearest_int_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_f64_trunc, wasm::f64_trunc_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_f64_floor, wasm::f64_floor_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_f64_ceil, wasm::f64_ceil_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_f64_nearest_int, wasm::f64_nearest_int_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_int64_to_float32,
wasm::int64_to_float32_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_uint64_to_float32,
wasm::uint64_to_float32_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_int64_to_float64,
wasm::int64_to_float64_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_uint64_to_float64,
wasm::uint64_to_float64_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_float32_to_int64,
wasm::float32_to_int64_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_float32_to_uint64,
wasm::float32_to_uint64_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_float64_to_int64,
wasm::float64_to_int64_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_float64_to_uint64,
wasm::float64_to_uint64_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_float32_to_int64_sat,
wasm::float32_to_int64_sat_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_float32_to_uint64_sat,
wasm::float32_to_uint64_sat_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_float64_to_int64_sat,
wasm::float64_to_int64_sat_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_float64_to_uint64_sat,
wasm::float64_to_uint64_sat_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_int64_div, wasm::int64_div_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_int64_mod, wasm::int64_mod_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_uint64_div, wasm::uint64_div_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_uint64_mod, wasm::uint64_mod_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_word32_ctz, wasm::word32_ctz_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_word64_ctz, wasm::word64_ctz_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_word32_popcnt, wasm::word32_popcnt_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_word64_popcnt, wasm::word64_popcnt_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_word32_rol, wasm::word32_rol_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_word32_ror, wasm::word32_ror_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_word64_rol, wasm::word64_rol_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_word64_ror, wasm::word64_ror_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_f64x2_ceil, wasm::f64x2_ceil_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_f64x2_floor, wasm::f64x2_floor_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_f64x2_trunc, wasm::f64x2_trunc_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_f64x2_nearest_int,
wasm::f64x2_nearest_int_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_f32x4_ceil, wasm::f32x4_ceil_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_f32x4_floor, wasm::f32x4_floor_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_f32x4_trunc, wasm::f32x4_trunc_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_f32x4_nearest_int,
wasm::f32x4_nearest_int_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_memory_init, wasm::memory_init_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_memory_copy, wasm::memory_copy_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_memory_fill, wasm::memory_fill_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_float64_pow, wasm::float64_pow_wrapper)
IF_WASM(FUNCTION_REFERENCE, wasm_call_trap_callback_for_testing,
wasm::call_trap_callback_for_testing)
static void f64_acos_wrapper(Address data) {
double input = ReadUnalignedValue<double>(data);
@ -397,7 +413,6 @@ static void f64_asin_wrapper(Address data) {
FUNCTION_REFERENCE(f64_asin_wrapper_function, f64_asin_wrapper)
FUNCTION_REFERENCE(wasm_float64_pow, wasm::float64_pow_wrapper)
static void f64_mod_wrapper(Address data) {
double dividend = ReadUnalignedValue<double>(data);
@ -407,9 +422,6 @@ static void f64_mod_wrapper(Address data) {
FUNCTION_REFERENCE(f64_mod_wrapper_function, f64_mod_wrapper)
FUNCTION_REFERENCE(wasm_call_trap_callback_for_testing,
wasm::call_trap_callback_for_testing)
ExternalReference ExternalReference::isolate_root(Isolate* isolate) {
return ExternalReference(isolate->isolate_root());
}

View File

@ -198,52 +198,54 @@ class StatsCounter;
V(string_to_array_index_function, "String::ToArrayIndex") \
V(try_string_to_index_or_lookup_existing, \
"try_string_to_index_or_lookup_existing") \
V(wasm_call_trap_callback_for_testing, \
"wasm::call_trap_callback_for_testing") \
V(wasm_f32_ceil, "wasm::f32_ceil_wrapper") \
V(wasm_f32_floor, "wasm::f32_floor_wrapper") \
V(wasm_f32_nearest_int, "wasm::f32_nearest_int_wrapper") \
V(wasm_f32_trunc, "wasm::f32_trunc_wrapper") \
V(wasm_f64_ceil, "wasm::f64_ceil_wrapper") \
V(wasm_f64_floor, "wasm::f64_floor_wrapper") \
V(wasm_f64_nearest_int, "wasm::f64_nearest_int_wrapper") \
V(wasm_f64_trunc, "wasm::f64_trunc_wrapper") \
V(wasm_float32_to_int64, "wasm::float32_to_int64_wrapper") \
V(wasm_float32_to_uint64, "wasm::float32_to_uint64_wrapper") \
V(wasm_float32_to_int64_sat, "wasm::float32_to_int64_sat_wrapper") \
V(wasm_float32_to_uint64_sat, "wasm::float32_to_uint64_sat_wrapper") \
V(wasm_float64_pow, "wasm::float64_pow") \
V(wasm_float64_to_int64, "wasm::float64_to_int64_wrapper") \
V(wasm_float64_to_uint64, "wasm::float64_to_uint64_wrapper") \
V(wasm_float64_to_int64_sat, "wasm::float64_to_int64_sat_wrapper") \
V(wasm_float64_to_uint64_sat, "wasm::float64_to_uint64_sat_wrapper") \
V(wasm_int64_div, "wasm::int64_div") \
V(wasm_int64_mod, "wasm::int64_mod") \
V(wasm_int64_to_float32, "wasm::int64_to_float32_wrapper") \
V(wasm_int64_to_float64, "wasm::int64_to_float64_wrapper") \
V(wasm_uint64_div, "wasm::uint64_div") \
V(wasm_uint64_mod, "wasm::uint64_mod") \
V(wasm_uint64_to_float32, "wasm::uint64_to_float32_wrapper") \
V(wasm_uint64_to_float64, "wasm::uint64_to_float64_wrapper") \
V(wasm_word32_ctz, "wasm::word32_ctz") \
V(wasm_word32_popcnt, "wasm::word32_popcnt") \
V(wasm_word32_rol, "wasm::word32_rol") \
V(wasm_word32_ror, "wasm::word32_ror") \
V(wasm_word64_rol, "wasm::word64_rol") \
V(wasm_word64_ror, "wasm::word64_ror") \
V(wasm_word64_ctz, "wasm::word64_ctz") \
V(wasm_word64_popcnt, "wasm::word64_popcnt") \
V(wasm_f64x2_ceil, "wasm::f64x2_ceil_wrapper") \
V(wasm_f64x2_floor, "wasm::f64x2_floor_wrapper") \
V(wasm_f64x2_trunc, "wasm::f64x2_trunc_wrapper") \
V(wasm_f64x2_nearest_int, "wasm::f64x2_nearest_int_wrapper") \
V(wasm_f32x4_ceil, "wasm::f32x4_ceil_wrapper") \
V(wasm_f32x4_floor, "wasm::f32x4_floor_wrapper") \
V(wasm_f32x4_trunc, "wasm::f32x4_trunc_wrapper") \
V(wasm_f32x4_nearest_int, "wasm::f32x4_nearest_int_wrapper") \
V(wasm_memory_init, "wasm::memory_init") \
V(wasm_memory_copy, "wasm::memory_copy") \
V(wasm_memory_fill, "wasm::memory_fill") \
IF_WASM(V, wasm_call_trap_callback_for_testing, \
"wasm::call_trap_callback_for_testing") \
IF_WASM(V, wasm_f32_ceil, "wasm::f32_ceil_wrapper") \
IF_WASM(V, wasm_f32_floor, "wasm::f32_floor_wrapper") \
IF_WASM(V, wasm_f32_nearest_int, "wasm::f32_nearest_int_wrapper") \
IF_WASM(V, wasm_f32_trunc, "wasm::f32_trunc_wrapper") \
IF_WASM(V, wasm_f64_ceil, "wasm::f64_ceil_wrapper") \
IF_WASM(V, wasm_f64_floor, "wasm::f64_floor_wrapper") \
IF_WASM(V, wasm_f64_nearest_int, "wasm::f64_nearest_int_wrapper") \
IF_WASM(V, wasm_f64_trunc, "wasm::f64_trunc_wrapper") \
IF_WASM(V, wasm_float32_to_int64, "wasm::float32_to_int64_wrapper") \
IF_WASM(V, wasm_float32_to_uint64, "wasm::float32_to_uint64_wrapper") \
IF_WASM(V, wasm_float32_to_int64_sat, "wasm::float32_to_int64_sat_wrapper") \
IF_WASM(V, wasm_float32_to_uint64_sat, \
"wasm::float32_to_uint64_sat_wrapper") \
IF_WASM(V, wasm_float64_pow, "wasm::float64_pow") \
IF_WASM(V, wasm_float64_to_int64, "wasm::float64_to_int64_wrapper") \
IF_WASM(V, wasm_float64_to_uint64, "wasm::float64_to_uint64_wrapper") \
IF_WASM(V, wasm_float64_to_int64_sat, "wasm::float64_to_int64_sat_wrapper") \
IF_WASM(V, wasm_float64_to_uint64_sat, \
"wasm::float64_to_uint64_sat_wrapper") \
IF_WASM(V, wasm_int64_div, "wasm::int64_div") \
IF_WASM(V, wasm_int64_mod, "wasm::int64_mod") \
IF_WASM(V, wasm_int64_to_float32, "wasm::int64_to_float32_wrapper") \
IF_WASM(V, wasm_int64_to_float64, "wasm::int64_to_float64_wrapper") \
IF_WASM(V, wasm_uint64_div, "wasm::uint64_div") \
IF_WASM(V, wasm_uint64_mod, "wasm::uint64_mod") \
IF_WASM(V, wasm_uint64_to_float32, "wasm::uint64_to_float32_wrapper") \
IF_WASM(V, wasm_uint64_to_float64, "wasm::uint64_to_float64_wrapper") \
IF_WASM(V, wasm_word32_ctz, "wasm::word32_ctz") \
IF_WASM(V, wasm_word32_popcnt, "wasm::word32_popcnt") \
IF_WASM(V, wasm_word32_rol, "wasm::word32_rol") \
IF_WASM(V, wasm_word32_ror, "wasm::word32_ror") \
IF_WASM(V, wasm_word64_rol, "wasm::word64_rol") \
IF_WASM(V, wasm_word64_ror, "wasm::word64_ror") \
IF_WASM(V, wasm_word64_ctz, "wasm::word64_ctz") \
IF_WASM(V, wasm_word64_popcnt, "wasm::word64_popcnt") \
IF_WASM(V, wasm_f64x2_ceil, "wasm::f64x2_ceil_wrapper") \
IF_WASM(V, wasm_f64x2_floor, "wasm::f64x2_floor_wrapper") \
IF_WASM(V, wasm_f64x2_trunc, "wasm::f64x2_trunc_wrapper") \
IF_WASM(V, wasm_f64x2_nearest_int, "wasm::f64x2_nearest_int_wrapper") \
IF_WASM(V, wasm_f32x4_ceil, "wasm::f32x4_ceil_wrapper") \
IF_WASM(V, wasm_f32x4_floor, "wasm::f32x4_floor_wrapper") \
IF_WASM(V, wasm_f32x4_trunc, "wasm::f32x4_trunc_wrapper") \
IF_WASM(V, wasm_f32x4_nearest_int, "wasm::f32x4_nearest_int_wrapper") \
IF_WASM(V, wasm_memory_init, "wasm::memory_init") \
IF_WASM(V, wasm_memory_copy, "wasm::memory_copy") \
IF_WASM(V, wasm_memory_fill, "wasm::memory_fill") \
V(address_of_wasm_f64x2_convert_low_i32x4_u_int_mask, \
"wasm_f64x2_convert_low_i32x4_u_int_mask") \
V(supports_wasm_simd_128_address, "wasm::supports_wasm_simd_128_address") \

View File

@ -11,7 +11,10 @@
#include "src/codegen/assembler-inl.h"
#include "src/objects/code-inl.h"
#include "src/objects/objects-inl.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-code-manager.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {
@ -20,9 +23,11 @@ HandlerTable::HandlerTable(Code code)
: HandlerTable(code.HandlerTableAddress(), code.handler_table_size(),
kReturnAddressBasedEncoding) {}
#if V8_ENABLE_WEBASSEMBLY
HandlerTable::HandlerTable(const wasm::WasmCode* code)
: HandlerTable(code->handler_table(), code->handler_table_size(),
kReturnAddressBasedEncoding) {}
#endif // V8_ENABLE_WEBASSEMBLY
HandlerTable::HandlerTable(BytecodeArray bytecode_array)
: HandlerTable(bytecode_array.handler_table()) {}

View File

@ -58,7 +58,9 @@ class V8_EXPORT_PRIVATE HandlerTable {
// Constructors for the various encodings.
explicit HandlerTable(Code code);
explicit HandlerTable(ByteArray byte_array);
#if V8_ENABLE_WEBASSEMBLY
explicit HandlerTable(const wasm::WasmCode* code);
#endif // V8_ENABLE_WEBASSEMBLY
explicit HandlerTable(BytecodeArray bytecode_array);
HandlerTable(Address handler_table, int handler_table_size,
EncodingMode encoding_mode);

View File

@ -13,7 +13,10 @@
#include "src/objects/shared-function-info.h"
#include "src/tracing/trace-event.h"
#include "src/tracing/traced-value.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/function-compiler.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {
@ -193,6 +196,7 @@ void OptimizedCompilationInfo::SetCode(Handle<Code> code) {
code_ = code;
}
#if V8_ENABLE_WEBASSEMBLY
void OptimizedCompilationInfo::SetWasmCompilationResult(
std::unique_ptr<wasm::WasmCompilationResult> wasm_compilation_result) {
wasm_compilation_result_ = std::move(wasm_compilation_result);
@ -202,6 +206,7 @@ std::unique_ptr<wasm::WasmCompilationResult>
OptimizedCompilationInfo::ReleaseWasmCompilationResult() {
return std::move(wasm_compilation_result_);
}
#endif // V8_ENABLE_WEBASSEMBLY
bool OptimizedCompilationInfo::has_context() const {
return !closure().is_null();

View File

@ -142,8 +142,10 @@ class V8_EXPORT_PRIVATE OptimizedCompilationInfo final {
void SetCode(Handle<Code> code);
#if V8_ENABLE_WEBASSEMBLY
void SetWasmCompilationResult(std::unique_ptr<wasm::WasmCompilationResult>);
std::unique_ptr<wasm::WasmCompilationResult> ReleaseWasmCompilationResult();
#endif // V8_ENABLE_WEBASSEMBLY
bool has_context() const;
Context context() const;
@ -162,7 +164,9 @@ class V8_EXPORT_PRIVATE OptimizedCompilationInfo final {
return code_kind() == CodeKind::NATIVE_CONTEXT_INDEPENDENT;
}
bool IsTurboprop() const { return code_kind() == CodeKind::TURBOPROP; }
#if V8_ENABLE_WEBASSEMBLY
bool IsWasm() const { return code_kind() == CodeKind::WASM_FUNCTION; }
#endif // V8_ENABLE_WEBASSEMBLY
void SetOptimizingForOsr(BytecodeOffset osr_offset,
JavaScriptFrame* osr_frame) {
@ -283,8 +287,10 @@ class V8_EXPORT_PRIVATE OptimizedCompilationInfo final {
// Basic block profiling support.
BasicBlockProfilerData* profiler_data_ = nullptr;
#if V8_ENABLE_WEBASSEMBLY
// The WebAssembly compilation result, not published in the NativeModule yet.
std::unique_ptr<wasm::WasmCompilationResult> wasm_compilation_result_;
#endif // V8_ENABLE_WEBASSEMBLY
// Entry point when compiling for OSR, {BytecodeOffset::None} otherwise.
BytecodeOffset osr_offset_ = BytecodeOffset::None();

View File

@ -10,7 +10,10 @@
#include "src/diagnostics/disasm.h"
#include "src/execution/frames-inl.h"
#include "src/utils/ostreams.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-code-manager.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {
@ -19,10 +22,12 @@ SafepointTable::SafepointTable(Code code)
: SafepointTable(code.InstructionStart(), code.SafepointTableAddress(),
code.stack_slots(), true) {}
#if V8_ENABLE_WEBASSEMBLY
SafepointTable::SafepointTable(const wasm::WasmCode* code)
: SafepointTable(code->instruction_start(),
code->instruction_start() + code->safepoint_table_offset(),
code->stack_slots(), false) {}
#endif // V8_ENABLE_WEBASSEMBLY
SafepointTable::SafepointTable(Address instruction_start,
Address safepoint_table_address,

View File

@ -70,7 +70,9 @@ class SafepointEntry {
class SafepointTable {
public:
explicit SafepointTable(Code code);
#if V8_ENABLE_WEBASSEMBLY
explicit SafepointTable(const wasm::WasmCode* code);
#endif // V8_ENABLE_WEBASSEMBLY
SafepointTable(const SafepointTable&) = delete;
SafepointTable& operator=(const SafepointTable&) = delete;

View File

@ -1691,7 +1691,9 @@ enum IcCheckType { ELEMENT, PROPERTY };
// without going through the on-heap Code trampoline.
enum class StubCallMode {
kCallCodeObject,
#if V8_ENABLE_WEBASSEMBLY
kCallWasmRuntimeStub,
#endif // V8_ENABLE_WEBASSEMBLY
kCallBuiltinPointer,
};

View File

@ -3734,13 +3734,14 @@ void CodeGenerator::AssembleConstructFrame() {
auto call_descriptor = linkage()->GetIncomingDescriptor();
if (frame_access_state()->has_frame()) {
if (call_descriptor->IsCFunctionCall()) {
if (info()->GetOutputStackFrameType() == StackFrame::C_WASM_ENTRY) {
#if V8_ENABLE_WEBASSEMBLY
if (info()->GetOutputStackFrameType() == StackFrame::C_WASM_ENTRY) {
__ StubPrologue(StackFrame::C_WASM_ENTRY);
// Reserve stack space for saving the c_entry_fp later.
__ AllocateStackSpace(kSystemPointerSize);
#else
UNREACHABLE();
// For balance.
if (false) {
#endif // V8_ENABLE_WEBASSEMBLY
} else {
__ Push(lr, fp);

View File

@ -3631,14 +3631,15 @@ MulWithDupResult TryMatchMulWithDup(Node* node) {
// f64x2.mul(x, shuffle(x, y, indices)) => f64x2.mul(x, y, laneidx)
// where shuffle(x, y, indices) = dup(x[laneidx]) or dup(y[laneidx])
// f32x4.mul and f64x2.mul are commutative, so use BinopMatcher.
BinopWithShuffleMatcher m = BinopWithShuffleMatcher(node);
ShuffleMatcher left = m.left();
ShuffleMatcher right = m.right();
Node* input = nullptr;
Node* dup_node = nullptr;
int index = 0;
#if V8_ENABLE_WEBASSEMBLY
BinopWithShuffleMatcher m = BinopWithShuffleMatcher(node);
ShuffleMatcher left = m.left();
ShuffleMatcher right = m.right();
// TODO(zhin): We can canonicalize first to avoid checking index < LANES.
// e.g. shuffle(x, y, [16, 17, 18, 19...]) => shuffle(y, y, [0, 1, 2,
// 3]...). But doing so can mutate the inputs of the shuffle node without
@ -3657,6 +3658,7 @@ MulWithDupResult TryMatchMulWithDup(Node* node) {
dup_node = right.node()->InputAt(index < LANES ? 0 : 1);
input = left.node();
}
#endif // V8_ENABLE_WEBASSEMBLY
// Canonicalization would get rid of this too.
index %= LANES;

View File

@ -13,7 +13,6 @@
#include "src/compiler/globals.h"
#include "src/compiler/linkage.h"
#include "src/compiler/pipeline.h"
#include "src/compiler/wasm-compiler.h"
#include "src/diagnostics/eh-frame.h"
#include "src/execution/frames.h"
#include "src/logging/counters.h"
@ -910,7 +909,13 @@ void CodeGenerator::AssembleSourcePosition(SourcePosition source_position) {
source_position, false);
if (FLAG_code_comments) {
OptimizedCompilationInfo* info = this->info();
if (!info->IsOptimizing() && !info->IsWasm()) return;
if (!info->IsOptimizing()) {
#if V8_ENABLE_WEBASSEMBLY
if (!info->IsWasm()) return;
#else
return;
#endif // V8_ENABLE_WEBASSEMBLY
}
std::ostringstream buffer;
buffer << "-- ";
// Turbolizer only needs the source position, as it can reconstruct

View File

@ -37,9 +37,12 @@
#include "src/compiler/write-barrier-kind.h"
#include "src/flags/flags.h"
#include "src/utils/utils.h"
#include "src/wasm/simd-shuffle.h"
#include "src/zone/zone-containers.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/simd-shuffle.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {
namespace compiler {

View File

@ -1035,6 +1035,7 @@ void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer,
? g.UseFixed(callee, kJavaScriptCallCodeStartRegister)
: g.UseRegister(callee));
break;
#if V8_ENABLE_WEBASSEMBLY
case CallDescriptor::kCallWasmCapiFunction:
case CallDescriptor::kCallWasmFunction:
case CallDescriptor::kCallWasmImportWrapper:
@ -1047,6 +1048,7 @@ void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer,
? g.UseFixed(callee, kJavaScriptCallCodeStartRegister)
: g.UseRegister(callee));
break;
#endif // V8_ENABLE_WEBASSEMBLY
case CallDescriptor::kCallBuiltinPointer:
// The common case for builtin pointers is to have the target in a
// register. If we have a constant, we use a register anyway to simplify
@ -2981,16 +2983,13 @@ void InstructionSelector::VisitCall(Node* node, BasicBlock* handler) {
case CallDescriptor::kCallJSFunction:
opcode = EncodeCallDescriptorFlags(kArchCallJSFunction, flags);
break;
// TODO(clemensb): Remove these call descriptor kinds.
#if V8_ENABLE_WEBASSEMBLY
case CallDescriptor::kCallWasmCapiFunction:
case CallDescriptor::kCallWasmFunction:
case CallDescriptor::kCallWasmImportWrapper:
#if V8_ENABLE_WEBASSEMBLY
opcode = EncodeCallDescriptorFlags(kArchCallWasmFunction, flags);
#else
UNREACHABLE();
#endif // V8_ENABLE_WEBASSEMBLY
break;
#endif // V8_ENABLE_WEBASSEMBLY
case CallDescriptor::kCallBuiltinPointer:
opcode = EncodeCallDescriptorFlags(kArchCallBuiltinPointer, flags);
break;

View File

@ -16,9 +16,12 @@
#include "src/compiler/linkage.h"
#include "src/compiler/machine-operator.h"
#include "src/compiler/node.h"
#include "src/wasm/simd-shuffle.h"
#include "src/zone/zone-containers.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/simd-shuffle.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {

View File

@ -4725,7 +4725,13 @@ void CodeGenerator::PrepareForDeoptimizationExits(
void CodeGenerator::IncrementStackAccessCounter(
InstructionOperand* source, InstructionOperand* destination) {
DCHECK(FLAG_trace_turbo_stack_accesses);
if (!info()->IsOptimizing() && !info()->IsWasm()) return;
if (!info()->IsOptimizing()) {
#if V8_ENABLE_WEBASSEMBLY
if (!info()->IsWasm()) return;
#else
return;
#endif // V8_ENABLE_WEBASSEMBLY
}
DCHECK_NOT_NULL(debug_name_);
auto IncrementCounter = [&](ExternalReference counter) {
__ incl(__ ExternalReferenceAsOperand(counter));

View File

@ -17,7 +17,10 @@
#include "src/compiler/node-matchers.h"
#include "src/compiler/node-properties.h"
#include "src/roots/roots-inl.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/simd-shuffle.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {

View File

@ -76,6 +76,7 @@ bool Subsumes(MachineRepresentation from, MachineRepresentation to) {
inline bool IsFreshObject(Node* node) {
if (node->opcode() == IrOpcode::kAllocate) return true;
#if V8_ENABLE_WEBASSEMBLY
if (node->opcode() == IrOpcode::kCall) {
NumberMatcher matcher(node->InputAt(0));
if (matcher.HasResolvedValue()) {
@ -89,6 +90,7 @@ inline bool IsFreshObject(Node* node) {
callee == Builtins::kWasmAllocateStructWithRtt;
}
}
#endif // V8_ENABLE_WEBASSEMBLY
return false;
}

View File

@ -11,7 +11,10 @@
#include "src/compiler/node.h"
#include "src/handles/handles-inl.h"
#include "src/objects/objects-inl.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/value-type.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {
@ -128,6 +131,7 @@ FrameState CreateBuiltinContinuationFrameStateCommon(
: common->CreateFrameStateFunctionInfo(
frame_type, parameter_count, 0, shared);
#else
DCHECK_NULL(signature);
const FrameStateFunctionInfo* state_info =
common->CreateFrameStateFunctionInfo(frame_type, parameter_count, 0,
shared);

View File

@ -14,6 +14,11 @@
namespace v8 {
namespace internal {
namespace wasm {
class ValueType;
using FunctionSig = Signature<ValueType>;
} // namespace wasm
namespace compiler {
class JSGraph;
@ -105,6 +110,7 @@ class FrameStateFunctionInfo {
Handle<SharedFunctionInfo> const shared_info_;
};
#if V8_ENABLE_WEBASSEMBLY
class JSToWasmFrameStateFunctionInfo : public FrameStateFunctionInfo {
public:
JSToWasmFrameStateFunctionInfo(FrameStateType type, int parameter_count,
@ -121,6 +127,7 @@ class JSToWasmFrameStateFunctionInfo : public FrameStateFunctionInfo {
private:
const wasm::FunctionSig* const signature_;
};
#endif // V8_ENABLE_WEBASSEMBLY
class FrameStateInfo final {
public:

View File

@ -1251,8 +1251,10 @@ void JSGenericLowering::LowerJSCallRuntime(Node* node) {
ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity()));
}
#if V8_ENABLE_WEBASSEMBLY
// Will be lowered in SimplifiedLowering.
void JSGenericLowering::LowerJSWasmCall(Node* node) {}
#endif // V8_ENABLE_WEBASSEMBLY
void JSGenericLowering::LowerJSForInPrepare(Node* node) {
JSForInPrepareNode n(node);

View File

@ -674,7 +674,9 @@ Reduction JSInliningHeuristic::InlineCandidate(Candidate const& candidate,
bool small_function) {
int const num_calls = candidate.num_functions;
Node* const node = candidate.node;
#if V8_ENABLE_WEBASSEMBLY
DCHECK_NE(node->opcode(), IrOpcode::kJSWasmCall);
#endif // V8_ENABLE_WEBASSEMBLY
if (num_calls == 1) {
Reduction const reduction = inliner_.ReduceJSCall(node);
if (reduction.Changed()) {

View File

@ -20,11 +20,14 @@
#include "src/compiler/node-properties.h"
#include "src/compiler/operator-properties.h"
#include "src/compiler/simplified-operator.h"
#include "src/compiler/wasm-compiler.h"
#include "src/execution/isolate-inl.h"
#include "src/objects/feedback-cell-inl.h"
#include "src/parsing/parse-info.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/compiler/wasm-compiler.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {
namespace compiler {
@ -462,7 +465,9 @@ Reduction JSInliner::ReduceJSWasmCall(Node* node) {
Reduction JSInliner::ReduceJSCall(Node* node) {
DCHECK(IrOpcode::IsInlineeOpcode(node->opcode()));
#if V8_ENABLE_WEBASSEMBLY
DCHECK_NE(node->opcode(), IrOpcode::kJSWasmCall);
#endif // V8_ENABLE_WEBASSEMBLY
JSCallAccessor call(node);
// Determine the call target.

View File

@ -676,6 +676,7 @@ ForInParameters const& ForInParametersOf(const Operator* op) {
return OpParameter<ForInParameters>(op);
}
#if V8_ENABLE_WEBASSEMBLY
JSWasmCallParameters const& JSWasmCallParametersOf(const Operator* op) {
DCHECK_EQ(IrOpcode::kJSWasmCall, op->opcode());
return OpParameter<JSWasmCallParameters>(op);
@ -719,6 +720,7 @@ Type JSWasmCallNode::TypeForWasmReturnType(const wasm::ValueType& type) {
UNREACHABLE();
}
}
#endif // V8_ENABLE_WEBASSEMBLY
#define CACHED_OP_LIST(V) \
V(ToLength, Operator::kNoProperties, 1, 1) \
@ -918,6 +920,7 @@ const Operator* JSOperatorBuilder::CallRuntime(const Runtime::Function* f,
parameters); // parameter
}
#if V8_ENABLE_WEBASSEMBLY
const Operator* JSOperatorBuilder::CallWasm(
const wasm::WasmModule* wasm_module,
const wasm::FunctionSig* wasm_signature, FeedbackSource const& feedback) {
@ -928,6 +931,7 @@ const Operator* JSOperatorBuilder::CallWasm(
parameters.input_count(), 1, 1, 1, 1, 2, // inputs/outputs
parameters); // parameter
}
#endif // V8_ENABLE_WEBASSEMBLY
const Operator* JSOperatorBuilder::ConstructForwardVarargs(
size_t arity, uint32_t start_index) {

View File

@ -821,6 +821,7 @@ size_t hash_value(ForInParameters const&);
std::ostream& operator<<(std::ostream&, ForInParameters const&);
const ForInParameters& ForInParametersOf(const Operator* op);
#if V8_ENABLE_WEBASSEMBLY
class JSWasmCallParameters {
public:
explicit JSWasmCallParameters(const wasm::WasmModule* module,
@ -849,6 +850,7 @@ V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&,
JSWasmCallParameters const&);
size_t hash_value(JSWasmCallParameters const&);
bool operator==(JSWasmCallParameters const&, JSWasmCallParameters const&);
#endif // V8_ENABLE_WEBASSEMBLY
int RegisterCountOf(Operator const* op) V8_WARN_UNUSED_RESULT;
@ -959,9 +961,11 @@ class V8_EXPORT_PRIVATE JSOperatorBuilder final
const Operator* CallRuntime(Runtime::FunctionId id, size_t arity);
const Operator* CallRuntime(const Runtime::Function* function, size_t arity);
#if V8_ENABLE_WEBASSEMBLY
const Operator* CallWasm(const wasm::WasmModule* wasm_module,
const wasm::FunctionSig* wasm_signature,
FeedbackSource const& feedback);
#endif // V8_ENABLE_WEBASSEMBLY
const Operator* ConstructForwardVarargs(size_t arity, uint32_t start_index);
const Operator* Construct(uint32_t arity,
@ -1285,8 +1289,11 @@ class JSCallOrConstructNode : public JSNodeWrapperBase {
node->opcode() == IrOpcode::kJSCallWithSpread ||
node->opcode() == IrOpcode::kJSConstruct ||
node->opcode() == IrOpcode::kJSConstructWithArrayLike ||
node->opcode() == IrOpcode::kJSConstructWithSpread ||
node->opcode() == IrOpcode::kJSWasmCall);
node->opcode() == IrOpcode::kJSConstructWithSpread
#if V8_ENABLE_WEBASSEMBLY
|| node->opcode() == IrOpcode::kJSWasmCall
#endif // V8_ENABLE_WEBASSEMBLY
); // NOLINT(whitespace/parens)
}
#define INPUTS(V) \
@ -1394,6 +1401,7 @@ using JSCallNode = JSCallNodeBase<IrOpcode::kJSCall>;
using JSCallWithSpreadNode = JSCallNodeBase<IrOpcode::kJSCallWithSpread>;
using JSCallWithArrayLikeNode = JSCallNodeBase<IrOpcode::kJSCallWithArrayLike>;
#if V8_ENABLE_WEBASSEMBLY
class JSWasmCallNode final : public JSCallOrConstructNode {
public:
explicit constexpr JSWasmCallNode(Node* node) : JSCallOrConstructNode(node) {
@ -1422,6 +1430,7 @@ class JSWasmCallNode final : public JSCallOrConstructNode {
static Type TypeForWasmReturnType(const wasm::ValueType& type);
};
#endif // V8_ENABLE_WEBASSEMBLY
template <int kOpcode>
class JSConstructNodeBase final : public JSCallOrConstructNode {

View File

@ -43,6 +43,7 @@ std::ostream& operator<<(std::ostream& os, const CallDescriptor::Kind& k) {
case CallDescriptor::kCallAddress:
os << "Addr";
break;
#if V8_ENABLE_WEBASSEMBLY
case CallDescriptor::kCallWasmCapiFunction:
os << "WasmExit";
break;
@ -52,6 +53,7 @@ std::ostream& operator<<(std::ostream& os, const CallDescriptor::Kind& k) {
case CallDescriptor::kCallWasmImportWrapper:
os << "WasmImportWrapper";
break;
#endif // V8_ENABLE_WEBASSEMBLY
case CallDescriptor::kCallBuiltinPointer:
os << "BuiltinPointer";
break;
@ -174,26 +176,34 @@ int CallDescriptor::CalculateFixedFrameSize(CodeKind code_kind) const {
case kCallJSFunction:
return StandardFrameConstants::kFixedSlotCount;
case kCallAddress:
#if V8_ENABLE_WEBASSEMBLY
if (code_kind == CodeKind::C_WASM_ENTRY) {
return CWasmEntryFrameConstants::kFixedSlotCount;
}
#endif // V8_ENABLE_WEBASSEMBLY
return CommonFrameConstants::kFixedSlotCountAboveFp +
CommonFrameConstants::kCPSlotCount;
case kCallCodeObject:
case kCallBuiltinPointer:
return TypedFrameConstants::kFixedSlotCount;
#if V8_ENABLE_WEBASSEMBLY
case kCallWasmFunction:
case kCallWasmImportWrapper:
return WasmFrameConstants::kFixedSlotCount;
case kCallWasmCapiFunction:
return WasmExitFrameConstants::kFixedSlotCount;
#endif // V8_ENABLE_WEBASSEMBLY
}
UNREACHABLE();
}
CallDescriptor* Linkage::ComputeIncoming(Zone* zone,
OptimizedCompilationInfo* info) {
#if V8_ENABLE_WEBASSEMBLY
DCHECK(info->IsOptimizing() || info->IsWasm());
#else
DCHECK(info->IsOptimizing());
#endif // V8_ENABLE_WEBASSEMBLY
if (!info->closure().is_null()) {
// If we are compiling a JS function, use a JS call descriptor,
// plus the receiver.
@ -468,10 +478,12 @@ CallDescriptor* Linkage::GetStubCallDescriptor(
kind = CallDescriptor::kCallCodeObject;
target_type = MachineType::AnyTagged();
break;
#if V8_ENABLE_WEBASSEMBLY
case StubCallMode::kCallWasmRuntimeStub:
kind = CallDescriptor::kCallWasmFunction;
target_type = MachineType::Pointer();
break;
#endif // V8_ENABLE_WEBASSEMBLY
case StubCallMode::kCallBuiltinPointer:
kind = CallDescriptor::kCallBuiltinPointer;
target_type = MachineType::AnyTagged();

View File

@ -199,9 +199,11 @@ class V8_EXPORT_PRIVATE CallDescriptor final
kCallCodeObject, // target is a Code object
kCallJSFunction, // target is a JSFunction object
kCallAddress, // target is a machine pointer
#if V8_ENABLE_WEBASSEMBLY // ↓ WebAssembly only
kCallWasmCapiFunction, // target is a Wasm C API function
kCallWasmFunction, // target is a wasm function
kCallWasmImportWrapper, // target is a wasm import wrapper
#endif // ↑ WebAssembly only
kCallBuiltinPointer, // target is a builtin pointer
};
@ -288,6 +290,7 @@ class V8_EXPORT_PRIVATE CallDescriptor final
// Returns {true} if this descriptor is a call to a JSFunction.
bool IsJSFunctionCall() const { return kind_ == kCallJSFunction; }
#if V8_ENABLE_WEBASSEMBLY
// Returns {true} if this descriptor is a call to a WebAssembly function.
bool IsWasmFunctionCall() const { return kind_ == kCallWasmFunction; }
@ -296,9 +299,14 @@ class V8_EXPORT_PRIVATE CallDescriptor final
// Returns {true} if this descriptor is a call to a Wasm C API function.
bool IsWasmCapiFunction() const { return kind_ == kCallWasmCapiFunction; }
#endif // V8_ENABLE_WEBASSEMBLY
bool RequiresFrameAsIncoming() const {
return IsCFunctionCall() || IsJSFunctionCall() || IsWasmFunctionCall();
if (IsCFunctionCall() || IsJSFunctionCall()) return true;
#if V8_ENABLE_WEBASSEMBLY
if (IsWasmFunctionCall()) return true;
#endif // V8_ENABLE_WEBASSEMBLY
return false;
}
// The number of return values from this call.

View File

@ -197,7 +197,7 @@
V(JSCallForwardVarargs) \
V(JSCallWithArrayLike) \
V(JSCallWithSpread) \
V(JSWasmCall)
IF_WASM(V, JSWasmCall)
#define JS_CONSTRUCT_OP_LIST(V) \
V(JSConstructForwardVarargs) \

View File

@ -224,7 +224,9 @@ bool OperatorProperties::HasFrameStateInput(const Operator* op) {
case IrOpcode::kJSCall:
case IrOpcode::kJSCallWithArrayLike:
case IrOpcode::kJSCallWithSpread:
#if V8_ENABLE_WEBASSEMBLY
case IrOpcode::kJSWasmCall:
#endif // V8_ENABLE_WEBASSEMBLY
// Misc operations
case IrOpcode::kJSAsyncFunctionEnter:

View File

@ -80,7 +80,6 @@
#include "src/compiler/typer.h"
#include "src/compiler/value-numbering-reducer.h"
#include "src/compiler/verifier.h"
#include "src/compiler/wasm-compiler.h"
#include "src/compiler/zone-stats.h"
#include "src/diagnostics/code-tracer.h"
#include "src/diagnostics/disassembler.h"
@ -96,6 +95,7 @@
#include "src/utils/utils.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/compiler/wasm-compiler.h"
#include "src/wasm/function-body-decoder.h"
#include "src/wasm/function-compiler.h"
#include "src/wasm/wasm-engine.h"
@ -1421,6 +1421,7 @@ struct InliningPhase {
}
};
#if V8_ENABLE_WEBASSEMBLY
struct WasmInliningPhase {
DECL_PIPELINE_PHASE_CONSTANTS(WasmInlining)
void Run(PipelineData* data, Zone* temp_zone) {
@ -1444,6 +1445,7 @@ struct WasmInliningPhase {
graph_reducer.ReduceGraph();
}
};
#endif // V8_ENABLE_WEBASSEMBLY
struct TyperPhase {
DECL_PIPELINE_PHASE_CONSTANTS(Typer)
@ -1676,6 +1678,7 @@ struct LoopPeelingPhase {
}
};
#if V8_ENABLE_WEBASSEMBLY
struct WasmLoopUnrollingPhase {
DECL_PIPELINE_PHASE_CONSTANTS(WasmLoopUnrolling)
@ -1709,6 +1712,7 @@ struct WasmLoopUnrollingPhase {
}
}
};
#endif // V8_ENABLE_WEBASSEMBLY
struct LoopExitEliminationPhase {
DECL_PIPELINE_PHASE_CONSTANTS(LoopExitElimination)
@ -2593,20 +2597,6 @@ CompilationJob::Status WasmHeapStubCompilationJob::FinalizeJobImpl(
}
return FAILED;
}
#else
// TODO(clemensb): Remove these methods once src/wasm is excluded from no-wasm
// builds.
// static
std::unique_ptr<OptimizedCompilationJob>
Pipeline::NewWasmHeapStubCompilationJob(
Isolate* isolate, wasm::WasmEngine* wasm_engine,
CallDescriptor* call_descriptor, std::unique_ptr<Zone> zone, Graph* graph,
CodeKind kind, std::unique_ptr<char[]> debug_name,
const AssemblerOptions& options, SourcePositionTable* source_positions) {
UNREACHABLE();
}
#endif // V8_ENABLE_WEBASSEMBLY
void PipelineImpl::RunPrintAndVerify(const char* phase, bool untyped) {
@ -2743,11 +2733,13 @@ bool PipelineImpl::OptimizeGraph(Linkage* linkage) {
Run<SimplifiedLoweringPhase>(linkage);
RunPrintAndVerify(SimplifiedLoweringPhase::phase_name(), true);
#if V8_ENABLE_WEBASSEMBLY
if (data->has_js_wasm_calls()) {
DCHECK(FLAG_turbo_inline_js_wasm_calls);
Run<WasmInliningPhase>();
RunPrintAndVerify(WasmInliningPhase::phase_name(), true);
}
#endif // V8_ENABLE_WEBASSEMBLY
// From now on it is invalid to look at types on the nodes, because the types
// on the nodes might not make sense after representation selection due to the
@ -3299,27 +3291,6 @@ void Pipeline::GenerateCodeForWasmFunction(
DCHECK(result->succeeded());
info->SetWasmCompilationResult(std::move(result));
}
#else // V8_ENABLE_WEBASSEMBLY
// TODO(clemensb): Remove these methods once src/wasm is excluded from no-wasm
// builds.
// static
wasm::WasmCompilationResult Pipeline::GenerateCodeForWasmNativeStub(
wasm::WasmEngine* wasm_engine, CallDescriptor* call_descriptor,
MachineGraph* mcgraph, CodeKind kind, int wasm_kind, const char* debug_name,
const AssemblerOptions& options, SourcePositionTable* source_positions) {
UNREACHABLE();
}
// static
void Pipeline::GenerateCodeForWasmFunction(
OptimizedCompilationInfo* info, wasm::WasmEngine* wasm_engine,
MachineGraph* mcgraph, CallDescriptor* call_descriptor,
SourcePositionTable* source_positions, NodeOriginTable* node_origins,
wasm::FunctionBody function_body, const wasm::WasmModule* module,
int function_index, std::vector<compiler::WasmLoopInfo>* loop_info) {
UNREACHABLE();
}
#endif // V8_ENABLE_WEBASSEMBLY
// static
@ -3514,8 +3485,10 @@ bool PipelineImpl::SelectInstructions(Linkage* linkage) {
}
// TODO(jgruber): The parameter is called is_stub but actually contains
// something different. Update either the name or its contents.
const bool is_stub =
!data->info()->IsOptimizing() && !data->info()->IsWasm();
bool is_stub = !data->info()->IsOptimizing();
#if V8_ENABLE_WEBASSEMBLY
if (data->info()->IsWasm()) is_stub = false;
#endif // V8_ENABLE_WEBASSEMBLY
Zone temp_zone(data->allocator(), kMachineGraphVerifierZoneName);
MachineGraphVerifier::Run(data->graph(), data->schedule(), linkage, is_stub,
data->debug_name(), &temp_zone);

View File

@ -28,7 +28,10 @@
#include "src/numbers/conversions-inl.h"
#include "src/objects/objects.h"
#include "src/utils/address-map.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/value-type.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {
@ -1804,6 +1807,7 @@ class RepresentationSelector {
SetOutput<T>(node, MachineRepresentation::kTagged);
}
#if V8_ENABLE_WEBASSEMBLY
static MachineType MachineTypeForWasmReturnType(wasm::ValueType type) {
switch (type.kind()) {
case wasm::kI32:
@ -1902,6 +1906,7 @@ class RepresentationSelector {
// The actual lowering of JSWasmCall nodes happens later, in the subsequent
// "wasm-inlining" phase.
}
#endif // V8_ENABLE_WEBASSEMBLY
// Dispatching routine for visiting the node {node} with the usage {use}.
// Depending on the operator, propagate new usage info to the inputs.
@ -3831,9 +3836,11 @@ class RepresentationSelector {
case IrOpcode::kJSToObject:
case IrOpcode::kJSToString:
case IrOpcode::kJSParseInt:
#if V8_ENABLE_WEBASSEMBLY
if (node->opcode() == IrOpcode::kJSWasmCall) {
return VisitJSWasmCall<T>(node, lowering);
}
#endif // V8_ENABLE_WEBASSEMBLY
VisitInputs<T>(node);
// Assume the output is tagged.
return SetOutput<T>(node, MachineRepresentation::kTagged);

View File

@ -989,6 +989,7 @@ Type Typer::Visitor::TypeCall(Node* node) { return Type::Any(); }
Type Typer::Visitor::TypeFastApiCall(Node* node) { return Type::Any(); }
#if V8_ENABLE_WEBASSEMBLY
Type Typer::Visitor::TypeJSWasmCall(Node* node) {
const JSWasmCallParameters& op_params = JSWasmCallParametersOf(node->op());
const wasm::FunctionSig* wasm_signature = op_params.signature();
@ -997,6 +998,7 @@ Type Typer::Visitor::TypeJSWasmCall(Node* node) {
}
return Type::Any();
}
#endif // V8_ENABLE_WEBASSEMBLY
Type Typer::Visitor::TypeProjection(Node* node) {
Type const type = Operand(node, 0);

View File

@ -1617,11 +1617,13 @@ void Verifier::Visitor::Check(Node* node, const AllNodes& all) {
CheckValueInputIs(node, 0, Type::ExternalPointer()); // callee
CheckValueInputIs(node, 1, Type::Any()); // receiver
break;
#if V8_ENABLE_WEBASSEMBLY
case IrOpcode::kJSWasmCall:
CHECK_GE(value_count, 3);
CheckTypeIs(node, Type::Any());
CheckValueInputIs(node, 0, Type::Any()); // callee
break;
#endif // V8_ENABLE_WEBASSEMBLY
// Machine operators
// -----------------------

View File

@ -2,6 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#if !V8_ENABLE_WEBASSEMBLY
#error This header should only be included if WebAssembly is enabled.
#endif // !V8_ENABLE_WEBASSEMBLY
#ifndef V8_COMPILER_WASM_COMPILER_H_
#define V8_COMPILER_WASM_COMPILER_H_

View File

@ -59,7 +59,6 @@
#include "src/trap-handler/trap-handler.h"
#include "src/utils/ostreams.h"
#include "src/utils/utils.h"
#include "src/wasm/wasm-engine.h"
#ifdef V8_FUZZILLI
#include "src/d8/cov.h"
@ -4648,12 +4647,14 @@ int Shell::Main(int argc, char* argv[]) {
create_params.add_histogram_sample_callback = AddHistogramSample;
}
#if V8_ENABLE_WEBASSEMBLY
if (V8_TRAP_HANDLER_SUPPORTED && i::FLAG_wasm_trap_handler) {
constexpr bool use_default_trap_handler = true;
if (!v8::V8::EnableWebAssemblyTrapHandler(use_default_trap_handler)) {
FATAL("Could not register trap handler");
}
}
#endif // V8_ENABLE_WEBASSEMBLY
Isolate* isolate = Isolate::New(create_params);

View File

@ -29,9 +29,13 @@ FrameInspector::FrameInspector(CommonFrame* frame, int inlined_frame_index,
function_ = summary.AsJavaScript().function();
}
#if V8_ENABLE_WEBASSEMBLY
JavaScriptFrame* js_frame =
frame->is_java_script() ? javascript_frame() : nullptr;
DCHECK(js_frame || frame->is_wasm());
#else
JavaScriptFrame* js_frame = javascript_frame();
#endif // V8_ENABLE_WEBASSEMBLY
is_optimized_ = frame_->is_optimized();
// Calculate the deoptimized frame.
@ -66,7 +70,9 @@ Handle<Object> FrameInspector::GetContext() {
: handle(frame_->context(), isolate_);
}
#if V8_ENABLE_WEBASSEMBLY
bool FrameInspector::IsWasm() { return frame_->is_wasm(); }
#endif // V8_ENABLE_WEBASSEMBLY
bool FrameInspector::IsJavaScript() { return frame_->is_java_script(); }

View File

@ -38,7 +38,9 @@ class FrameInspector {
Handle<String> GetFunctionName() { return function_name_; }
#if V8_ENABLE_WEBASSEMBLY
bool IsWasm();
#endif // V8_ENABLE_WEBASSEMBLY
bool IsJavaScript();
JavaScriptFrame* javascript_frame();

View File

@ -122,9 +122,11 @@ v8::MaybeLocal<v8::Value> DebugStackTraceIterator::GetReceiver() const {
v8::Local<v8::Value> DebugStackTraceIterator::GetReturnValue() const {
CHECK(!Done());
#if V8_ENABLE_WEBASSEMBLY
if (frame_inspector_ && frame_inspector_->IsWasm()) {
return v8::Local<v8::Value>();
}
#endif // V8_ENABLE_WEBASSEMBLY
CHECK_NOT_NULL(iterator_.frame());
bool is_optimized = iterator_.frame()->is_optimized();
if (is_optimized || !is_top_frame_ ||
@ -172,7 +174,9 @@ DebugStackTraceIterator::GetScopeIterator() const {
bool DebugStackTraceIterator::Restart() {
DCHECK(!Done());
#if V8_ENABLE_WEBASSEMBLY
if (iterator_.is_wasm()) return false;
#endif // V8_ENABLE_WEBASSEMBLY
return LiveEdit::RestartFrame(iterator_.javascript_frame());
}

View File

@ -1079,8 +1079,8 @@ void Debug::PrepareStep(StepAction step_action) {
thread_local_.last_frame_count_ = current_frame_count;
// No longer perform the current async step.
clear_suspended_generator();
} else if (frame->is_wasm() && step_action != StepOut) {
#if V8_ENABLE_WEBASSEMBLY
} else if (frame->is_wasm() && step_action != StepOut) {
// Handle stepping in wasm.
WasmFrame* wasm_frame = WasmFrame::cast(frame);
auto* debug_info = wasm_frame->native_module()->GetDebugInfo();
@ -1088,12 +1088,12 @@ void Debug::PrepareStep(StepAction step_action) {
UpdateHookOnFunctionCall();
return;
}
#endif // V8_ENABLE_WEBASSEMBLY
// If the wasm code is not debuggable or will return after this step
// (indicated by {PrepareStep} returning false), then step out of that frame
// instead.
step_action = StepOut;
UpdateHookOnFunctionCall();
#endif // V8_ENABLE_WEBASSEMBLY
}
switch (step_action) {
@ -1866,7 +1866,9 @@ bool Debug::IsExceptionBlackboxed(bool uncaught) {
// Uncaught exception is blackboxed if all current frames are blackboxed,
// caught exception if top frame is blackboxed.
StackTraceFrameIterator it(isolate_);
#if V8_ENABLE_WEBASSEMBLY
while (!it.done() && it.is_wasm()) it.Advance();
#endif // V8_ENABLE_WEBASSEMBLY
bool is_top_frame_blackboxed =
!it.done() ? IsFrameBlackboxed(it.javascript_frame()) : true;
if (!uncaught || !is_top_frame_blackboxed) return is_top_frame_blackboxed;

View File

@ -29,6 +29,7 @@
#include "src/objects/function-kind.h"
#include "src/objects/hash-table-inl.h"
#include "src/objects/instance-type.h"
#include "src/objects/js-array-buffer-inl.h"
#include "src/objects/js-array-inl.h"
#include "src/objects/objects-inl.h"
#include "src/objects/objects.h"
@ -74,11 +75,11 @@
#include "src/objects/transitions-inl.h"
#include "src/regexp/regexp.h"
#include "src/utils/ostreams.h"
#include "src/wasm/wasm-objects-inl.h"
#include "torque-generated/class-verifiers.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/debug/debug-wasm-objects-inl.h"
#include "src/wasm/wasm-objects-inl.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
@ -229,10 +230,10 @@ void HeapObject::HeapObjectVerify(Isolate* isolate) {
case JS_TYPED_ARRAY_PROTOTYPE_TYPE:
JSObject::cast(*this).JSObjectVerify(isolate);
break;
#if V8_ENABLE_WEBASSEMBLY
case WASM_INSTANCE_OBJECT_TYPE:
WasmInstanceObject::cast(*this).WasmInstanceObjectVerify(isolate);
break;
#if V8_ENABLE_WEBASSEMBLY
case WASM_VALUE_OBJECT_TYPE:
WasmValueObject::cast(*this).WasmValueObjectVerify(isolate);
break;
@ -842,11 +843,15 @@ void SharedFunctionInfo::SharedFunctionInfoVerify(ReadOnlyRoots roots) {
CHECK_NE(value, roots.empty_scope_info());
}
CHECK(HasWasmExportedFunctionData() || IsApiFunction() ||
HasBytecodeArray() || HasAsmWasmData() || HasBuiltinId() ||
#if V8_ENABLE_WEBASSEMBLY
bool is_wasm = HasWasmExportedFunctionData() || HasAsmWasmData() ||
HasWasmJSFunctionData() || HasWasmCapiFunctionData();
#else
bool is_wasm = false;
#endif // V8_ENABLE_WEBASSEMBLY
CHECK(is_wasm || IsApiFunction() || HasBytecodeArray() || HasBuiltinId() ||
HasUncompiledDataWithPreparseData() ||
HasUncompiledDataWithoutPreparseData() || HasWasmJSFunctionData() ||
HasWasmCapiFunctionData());
HasUncompiledDataWithoutPreparseData());
{
auto script = script_or_debug_info(kAcquireLoad);
@ -1590,6 +1595,7 @@ void ObjectBoilerplateDescription::ObjectBoilerplateDescriptionVerify(
}
}
#if V8_ENABLE_WEBASSEMBLY
USE_TORQUE_VERIFIER(AsmWasmData)
void WasmInstanceObject::WasmInstanceObjectVerify(Isolate* isolate) {
@ -1605,12 +1611,10 @@ void WasmInstanceObject::WasmInstanceObjectVerify(Isolate* isolate) {
}
}
#if V8_ENABLE_WEBASSEMBLY
void WasmValueObject::WasmValueObjectVerify(Isolate* isolate) {
JSObjectVerify(isolate);
CHECK(IsWasmValueObject());
}
#endif // V8_ENABLE_WEBASSEMBLY
void WasmExportedFunctionData::WasmExportedFunctionDataVerify(
Isolate* isolate) {
@ -1631,6 +1635,11 @@ USE_TORQUE_VERIFIER(WasmGlobalObject)
USE_TORQUE_VERIFIER(WasmExceptionObject)
USE_TORQUE_VERIFIER(WasmJSFunctionData)
USE_TORQUE_VERIFIER(WasmIndirectFunctionTable)
#endif // V8_ENABLE_WEBASSEMBLY
void DataHandler::DataHandlerVerify(Isolate* isolate) {
TorqueGeneratedClassVerifiers::DataHandlerVerify(*this, isolate);
CHECK_IMPLIES(!smi_handler().IsSmi(),
@ -1666,10 +1675,6 @@ void CallHandlerInfo::CallHandlerInfoVerify(Isolate* isolate) {
.next_call_side_effect_free_call_handler_info_map());
}
USE_TORQUE_VERIFIER(WasmJSFunctionData)
USE_TORQUE_VERIFIER(WasmIndirectFunctionTable)
void AllocationSite::AllocationSiteVerify(Isolate* isolate) {
CHECK(IsAllocationSite());
CHECK(dependent_code().IsDependentCode());
@ -1721,12 +1726,14 @@ USE_TORQUE_VERIFIER(InterpreterData)
void StackFrameInfo::StackFrameInfoVerify(Isolate* isolate) {
TorqueGeneratedClassVerifiers::StackFrameInfoVerify(*this, isolate);
#if V8_ENABLE_WEBASSEMBLY
CHECK_IMPLIES(IsAsmJsWasm(), IsWasm());
CHECK_IMPLIES(IsWasm(), receiver_or_instance().IsWasmInstanceObject());
CHECK_IMPLIES(IsWasm(), function().IsSmi());
CHECK_IMPLIES(!IsWasm(), function().IsJSFunction());
CHECK_IMPLIES(IsAsync(), !IsWasm());
CHECK_IMPLIES(IsConstructor(), !IsWasm());
#endif // V8_ENABLE_WEBASSEMBLY
}
#endif // VERIFY_HEAP

View File

@ -18,12 +18,12 @@
#include "src/regexp/regexp.h"
#include "src/snapshot/embedded/embedded-data.h"
#include "src/utils/ostreams.h"
#include "src/wasm/wasm-code-manager.h"
#include "src/wasm/wasm-engine.h"
#include "src/wasm/wasm-objects-inl.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/debug/debug-wasm-objects-inl.h"
#include "src/wasm/wasm-code-manager.h"
#include "src/wasm/wasm-engine.h"
#include "src/wasm/wasm-objects-inl.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
@ -183,10 +183,10 @@ void HeapObject::HeapObjectPrint(std::ostream& os) { // NOLINT
case JS_TYPED_ARRAY_PROTOTYPE_TYPE:
JSObject::cast(*this).JSObjectPrint(os);
break;
#if V8_ENABLE_WEBASSEMBLY
case WASM_INSTANCE_OBJECT_TYPE:
WasmInstanceObject::cast(*this).WasmInstanceObjectPrint(os);
break;
#if V8_ENABLE_WEBASSEMBLY
case WASM_VALUE_OBJECT_TYPE:
WasmValueObject::cast(*this).WasmValueObjectPrint(os);
break;
@ -1487,6 +1487,7 @@ void JSFunction::JSFunctionPrint(std::ostream& os) { // NOLINT
os << "\n - bytecode: " << shared().GetBytecodeArray(isolate);
}
}
#if V8_ENABLE_WEBASSEMBLY
if (WasmExportedFunction::IsWasmExportedFunction(*this)) {
WasmExportedFunction function = WasmExportedFunction::cast(*this);
os << "\n - Wasm instance: " << Brief(function.instance());
@ -1496,6 +1497,7 @@ void JSFunction::JSFunctionPrint(std::ostream& os) { // NOLINT
WasmJSFunction function = WasmJSFunction::cast(*this);
os << "\n - Wasm wrapper around: " << Brief(function.GetCallable());
}
#endif // V8_ENABLE_WEBASSEMBLY
shared().PrintSourceCode(os);
JSObjectPrintBody(os, *this);
os << " - feedback vector: ";
@ -1795,6 +1797,7 @@ void RegExpBoilerplateDescription::RegExpBoilerplateDescriptionPrint(
os << "\n";
}
#if V8_ENABLE_WEBASSEMBLY
void AsmWasmData::AsmWasmDataPrint(std::ostream& os) { // NOLINT
PrintHeader(os, "AsmWasmData");
os << "\n - native module: " << Brief(managed_native_module());
@ -1975,14 +1978,6 @@ void WasmTableObject::WasmTableObjectPrint(std::ostream& os) { // NOLINT
os << "\n";
}
#if V8_ENABLE_WEBASSEMBLY
void WasmValueObject::WasmValueObjectPrint(std::ostream& os) { // NOLINT
PrintHeader(os, "WasmValueObject");
os << "\n - value: " << Brief(value());
os << "\n";
}
#endif // V8_ENABLE_WEBASSEMBLY
void WasmGlobalObject::WasmGlobalObjectPrint(std::ostream& os) { // NOLINT
PrintHeader(os, "WasmGlobalObject");
if (type().is_reference()) {
@ -2014,6 +2009,27 @@ void WasmExceptionObject::WasmExceptionObjectPrint(
os << "\n";
}
void WasmIndirectFunctionTable::WasmIndirectFunctionTablePrint(
std::ostream& os) {
PrintHeader(os, "WasmIndirectFunctionTable");
os << "\n - size: " << size();
os << "\n - sig_ids: " << static_cast<void*>(sig_ids());
os << "\n - targets: " << static_cast<void*>(targets());
if (has_managed_native_allocations()) {
os << "\n - managed_native_allocations: "
<< Brief(managed_native_allocations());
}
os << "\n - refs: " << Brief(refs());
os << "\n";
}
void WasmValueObject::WasmValueObjectPrint(std::ostream& os) { // NOLINT
PrintHeader(os, "WasmValueObject");
os << "\n - value: " << Brief(value());
os << "\n";
}
#endif // V8_ENABLE_WEBASSEMBLY
void LoadHandler::LoadHandlerPrint(std::ostream& os) { // NOLINT
PrintHeader(os, "LoadHandler");
// TODO(ishell): implement printing based on handler kind
@ -2085,20 +2101,6 @@ void FunctionTemplateInfo::FunctionTemplateInfoPrint(
os << "\n";
}
void WasmIndirectFunctionTable::WasmIndirectFunctionTablePrint(
std::ostream& os) {
PrintHeader(os, "WasmIndirectFunctionTable");
os << "\n - size: " << size();
os << "\n - sig_ids: " << static_cast<void*>(sig_ids());
os << "\n - targets: " << static_cast<void*>(targets());
if (has_managed_native_allocations()) {
os << "\n - managed_native_allocations: "
<< Brief(managed_native_allocations());
}
os << "\n - refs: " << Brief(refs());
os << "\n";
}
void ObjectTemplateInfo::ObjectTemplateInfoPrint(std::ostream& os) { // NOLINT
PrintHeader(os, "ObjectTemplateInfo");
os << "\n - tag: " << tag();
@ -2768,6 +2770,7 @@ V8_EXPORT_PRIVATE extern void _v8_internal_Print_Code(void* object) {
i::Address address = reinterpret_cast<i::Address>(object);
i::Isolate* isolate = i::Isolate::Current();
#if V8_ENABLE_WEBASSEMBLY
{
i::wasm::WasmCodeRefScope scope;
i::wasm::WasmCode* wasm_code =
@ -2778,6 +2781,7 @@ V8_EXPORT_PRIVATE extern void _v8_internal_Print_Code(void* object) {
return;
}
}
#endif // V8_ENABLE_WEBASSEMBLY
if (!isolate->heap()->InSpaceSlow(address, i::CODE_SPACE) &&
!isolate->heap()->InSpaceSlow(address, i::CODE_LO_SPACE) &&

View File

@ -5,12 +5,16 @@
#include "src/execution/execution.h"
#include "src/api/api-inl.h"
#include "src/compiler/wasm-compiler.h" // Only for static asserts.
#include "src/debug/debug.h"
#include "src/execution/frames.h"
#include "src/execution/isolate-inl.h"
#include "src/execution/vm-state-inl.h"
#include "src/logging/counters.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/compiler/wasm-compiler.h" // Only for static asserts.
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {
@ -517,6 +521,7 @@ STATIC_ASSERT(offsetof(StackHandlerMarker, padding) ==
StackHandlerConstants::kPaddingOffset);
STATIC_ASSERT(sizeof(StackHandlerMarker) == StackHandlerConstants::kSize);
#if V8_ENABLE_WEBASSEMBLY
void Execution::CallWasm(Isolate* isolate, Handle<Code> wrapper_code,
Address wasm_call_target, Handle<Object> object_ref,
Address packed_args) {
@ -570,6 +575,7 @@ void Execution::CallWasm(Isolate* isolate, Handle<Code> wrapper_code,
}
*isolate->c_entry_fp_address() = saved_c_entry_fp;
}
#endif // V8_ENABLE_WEBASSEMBLY
} // namespace internal
} // namespace v8

View File

@ -60,6 +60,7 @@ class Execution final : public AllStatic {
Isolate* isolate, MicrotaskQueue* microtask_queue,
MaybeHandle<Object>* exception_out);
#if V8_ENABLE_WEBASSEMBLY
// Call a Wasm function identified by {wasm_call_target} through the
// provided {wrapper_code}, which must match the function's signature.
// Upon return, either isolate->has_pending_exception() is true, or
@ -69,6 +70,7 @@ class Execution final : public AllStatic {
Address wasm_call_target,
Handle<Object> object_ref,
Address packed_args);
#endif // V8_ENABLE_WEBASSEMBLY
};
} // namespace internal

View File

@ -216,6 +216,7 @@ class ConstructFrameConstants : public TypedFrameConstants {
DEFINE_TYPED_FRAME_SIZES(5);
};
#if V8_ENABLE_WEBASSEMBLY
class CWasmEntryFrameConstants : public TypedFrameConstants {
public:
// FP-relative:
@ -236,6 +237,7 @@ class WasmExitFrameConstants : public WasmFrameConstants {
static const int kCallingPCOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1);
DEFINE_TYPED_FRAME_SIZES(2);
};
#endif // V8_ENABLE_WEBASSEMBLY
class BuiltinContinuationFrameConstants : public TypedFrameConstants {
public:

View File

@ -222,6 +222,7 @@ inline BaselineFrame::BaselineFrame(StackFrameIteratorBase* iterator)
inline BuiltinFrame::BuiltinFrame(StackFrameIteratorBase* iterator)
: TypedFrameWithJSLinkage(iterator) {}
#if V8_ENABLE_WEBASSEMBLY
inline WasmFrame::WasmFrame(StackFrameIteratorBase* iterator)
: TypedFrame(iterator) {}
@ -244,6 +245,7 @@ inline CWasmEntryFrame::CWasmEntryFrame(StackFrameIteratorBase* iterator)
inline WasmCompileLazyFrame::WasmCompileLazyFrame(
StackFrameIteratorBase* iterator)
: TypedFrame(iterator) {}
#endif // V8_ENABLE_WEBASSEMBLY
inline InternalFrame::InternalFrame(StackFrameIteratorBase* iterator)
: TypedFrame(iterator) {}
@ -287,7 +289,11 @@ inline JavaScriptFrame* JavaScriptFrameIterator::Reframe() {
inline CommonFrame* StackTraceFrameIterator::frame() const {
StackFrame* frame = iterator_.frame();
#if V8_ENABLE_WEBASSEMBLY
DCHECK(frame->is_java_script() || frame->is_wasm());
#else
DCHECK(frame->is_java_script());
#endif // V8_ENABLE_WEBASSEMBLY
return static_cast<CommonFrame*>(frame);
}
@ -300,7 +306,9 @@ bool StackTraceFrameIterator::is_javascript() const {
return frame()->is_java_script();
}
#if V8_ENABLE_WEBASSEMBLY
bool StackTraceFrameIterator::is_wasm() const { return frame()->is_wasm(); }
#endif // V8_ENABLE_WEBASSEMBLY
JavaScriptFrame* StackTraceFrameIterator::javascript_frame() const {
return JavaScriptFrame::cast(frame());
@ -308,9 +316,14 @@ JavaScriptFrame* StackTraceFrameIterator::javascript_frame() const {
inline StackFrame* SafeStackFrameIterator::frame() const {
DCHECK(!done());
#if V8_ENABLE_WEBASSEMBLY
DCHECK(frame_->is_java_script() || frame_->is_exit() ||
frame_->is_builtin_exit() || frame_->is_wasm() ||
frame_->is_wasm_to_js() || frame_->is_js_to_wasm());
#else
DCHECK(frame_->is_java_script() || frame_->is_exit() ||
frame_->is_builtin_exit());
#endif // V8_ENABLE_WEBASSEMBLY
return frame_;
}

View File

@ -24,10 +24,13 @@
#include "src/objects/visitors.h"
#include "src/snapshot/embedded/embedded-data.h"
#include "src/strings/string-stream.h"
#include "src/zone/zone-containers.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-code-manager.h"
#include "src/wasm/wasm-engine.h"
#include "src/wasm/wasm-objects-inl.h"
#include "src/zone/zone-containers.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {
@ -60,12 +63,12 @@ class StackHandlerIterator {
: limit_(frame->fp()), handler_(handler) {
// Make sure the handler has already been unwound to this frame.
DCHECK(frame->sp() <= AddressOf(handler));
#if V8_ENABLE_WEBASSEMBLY
// For CWasmEntry frames, the handler was registered by the last C++
// frame (Execution::CallWasm), so even though its address is already
// beyond the limit, we know we always want to unwind one handler.
if (frame->type() == StackFrame::C_WASM_ENTRY) {
handler_ = handler_->next();
}
if (frame->is_c_wasm_entry()) handler_ = handler_->next();
#endif // V8_ENABLE_WEBASSEMBLY
}
StackHandler* handler() const { return handler_; }
@ -210,7 +213,10 @@ bool StackTraceFrameIterator::IsValidFrame(StackFrame* frame) const {
return js_frame->function().shared().IsSubjectToDebugging();
}
// Apart from JavaScript frames, only Wasm frames are valid.
return frame->is_wasm();
#if V8_ENABLE_WEBASSEMBLY
if (frame->is_wasm()) return true;
#endif // V8_ENABLE_WEBASSEMBLY
return false;
}
// -------------------------------------------------------------------------
@ -471,10 +477,13 @@ void SafeStackFrameIterator::Advance() {
last_callback_scope = external_callback_scope_;
external_callback_scope_ = external_callback_scope_->previous();
}
if (frame_->is_java_script() || frame_->is_wasm() ||
frame_->is_wasm_to_js() || frame_->is_js_to_wasm()) {
if (frame_->is_java_script()) break;
#if V8_ENABLE_WEBASSEMBLY
if (frame_->is_wasm() || frame_->is_wasm_to_js() ||
frame_->is_js_to_wasm()) {
break;
}
#endif // V8_ENABLE_WEBASSEMBLY
if (frame_->is_exit() || frame_->is_builtin_exit()) {
// Some of the EXIT frames may have ExternalCallbackScope allocated on
// top of them. In that case the scope corresponds to the first EXIT
@ -607,6 +616,7 @@ StackFrame::Type StackFrame::ComputeType(const StackFrameIteratorBase* iterator,
return OPTIMIZED;
case CodeKind::BASELINE:
return Type::BASELINE;
#if V8_ENABLE_WEBASSEMBLY
case CodeKind::JS_TO_WASM_FUNCTION:
return JS_TO_WASM;
case CodeKind::JS_TO_JS_FUNCTION:
@ -619,6 +629,7 @@ StackFrame::Type StackFrame::ComputeType(const StackFrameIteratorBase* iterator,
case CodeKind::WASM_TO_CAPI_FUNCTION:
// Never appear as on-heap {Code} objects.
UNREACHABLE();
#endif // V8_ENABLE_WEBASSEMBLY
default:
// All other types should have an explicit marker
break;
@ -640,12 +651,14 @@ StackFrame::Type StackFrame::ComputeType(const StackFrameIteratorBase* iterator,
case STUB:
case INTERNAL:
case CONSTRUCT:
#if V8_ENABLE_WEBASSEMBLY
case WASM_TO_JS:
case WASM:
case WASM_COMPILE_LAZY:
case WASM_EXIT:
case WASM_DEBUG_BREAK:
case JS_TO_WASM:
#endif // V8_ENABLE_WEBASSEMBLY
return candidate;
case OPTIMIZED:
case INTERPRETED:
@ -696,11 +709,13 @@ StackFrame::Type EntryFrame::GetCallerState(State* state) const {
return ExitFrame::GetStateForFramePointer(fp, state);
}
#if V8_ENABLE_WEBASSEMBLY
StackFrame::Type CWasmEntryFrame::GetCallerState(State* state) const {
const int offset = CWasmEntryFrameConstants::kCEntryFPOffset;
Address fp = Memory<Address>(this->fp() + offset);
return ExitFrame::GetStateForFramePointer(fp, state);
}
#endif // V8_ENABLE_WEBASSEMBLY
Code ConstructEntryFrame::unchecked_code() const {
return isolate()->heap()->builtin(Builtins::kJSConstructEntry);
@ -728,8 +743,12 @@ void ExitFrame::Iterate(RootVisitor* v) const {
StackFrame::Type ExitFrame::GetStateForFramePointer(Address fp, State* state) {
if (fp == 0) return NONE;
StackFrame::Type type = ComputeFrameType(fp);
Address sp = (type == WASM_EXIT) ? WasmExitFrame::ComputeStackPointer(fp)
: ExitFrame::ComputeStackPointer(fp);
#if V8_ENABLE_WEBASSEMBLY
Address sp = type == WASM_EXIT ? WasmExitFrame::ComputeStackPointer(fp)
: ExitFrame::ComputeStackPointer(fp);
#else
Address sp = ExitFrame::ComputeStackPointer(fp);
#endif // V8_ENABLE_WEBASSEMBLY
FillState(fp, sp, state);
DCHECK_NE(*state->pc_address, kNullAddress);
return type;
@ -748,12 +767,16 @@ StackFrame::Type ExitFrame::ComputeFrameType(Address fp) {
intptr_t marker_int = bit_cast<intptr_t>(marker);
StackFrame::Type frame_type = static_cast<StackFrame::Type>(marker_int >> 1);
if (frame_type == EXIT || frame_type == BUILTIN_EXIT ||
frame_type == WASM_EXIT) {
return frame_type;
switch (frame_type) {
case BUILTIN_EXIT:
return BUILTIN_EXIT;
#if V8_ENABLE_WEBASSEMBLY
case WASM_EXIT:
return WASM_EXIT;
#endif // V8_ENABLE_WEBASSEMBLY
default:
return EXIT;
}
return EXIT;
}
Address ExitFrame::ComputeStackPointer(Address fp) {
@ -762,6 +785,7 @@ Address ExitFrame::ComputeStackPointer(Address fp) {
return Memory<Address>(fp + ExitFrameConstants::kSPOffset);
}
#if V8_ENABLE_WEBASSEMBLY
Address WasmExitFrame::ComputeStackPointer(Address fp) {
// For WASM_EXIT frames, {sp} is only needed for finding the PC slot,
// everything else is handled via safepoint information.
@ -770,6 +794,7 @@ Address WasmExitFrame::ComputeStackPointer(Address fp) {
fp + WasmExitFrameConstants::kCallingPCOffset);
return sp;
}
#endif // V8_ENABLE_WEBASSEMBLY
void ExitFrame::FillState(Address fp, Address sp, State* state) {
state->sp = sp;
@ -981,11 +1006,14 @@ void CommonFrame::IterateCompiledFrame(RootVisitor* v) const {
case STUB:
case INTERNAL:
case CONSTRUCT:
#if V8_ENABLE_WEBASSEMBLY
case JS_TO_WASM:
case C_WASM_ENTRY:
case WASM_DEBUG_BREAK:
#endif // V8_ENABLE_WEBASSEMBLY
frame_header_size = TypedFrameConstants::kFixedFrameSizeFromFp;
break;
#if V8_ENABLE_WEBASSEMBLY
case WASM_TO_JS:
case WASM:
case WASM_COMPILE_LAZY:
@ -999,6 +1027,7 @@ void CommonFrame::IterateCompiledFrame(RootVisitor* v) const {
"WasmExitFrame has one slot more than WasmFrame");
frame_header_size = WasmFrameConstants::kFixedFrameSizeFromFp;
break;
#endif // V8_ENABLE_WEBASSEMBLY
case OPTIMIZED:
case INTERPRETED:
case BASELINE:
@ -1423,6 +1452,7 @@ Handle<Context> FrameSummary::JavaScriptFrameSummary::native_context() const {
return handle(function_->context().native_context(), isolate());
}
#if V8_ENABLE_WEBASSEMBLY
FrameSummary::WasmFrameSummary::WasmFrameSummary(
Isolate* isolate, Handle<WasmInstanceObject> instance, wasm::WasmCode* code,
int code_offset, bool at_to_number_conversion)
@ -1465,6 +1495,7 @@ Handle<String> FrameSummary::WasmFrameSummary::FunctionName() const {
Handle<Context> FrameSummary::WasmFrameSummary::native_context() const {
return handle(wasm_instance()->native_context(), isolate());
}
#endif // V8_ENABLE_WEBASSEMBLY
FrameSummary::~FrameSummary() {
#define FRAME_SUMMARY_DESTR(kind, type, field, desc) \
@ -1505,6 +1536,7 @@ FrameSummary FrameSummary::Get(const CommonFrame* frame, int index) {
return frames[index];
}
#if V8_ENABLE_WEBASSEMBLY
#define FRAME_SUMMARY_DISPATCH(ret, name) \
ret FrameSummary::name() const { \
switch (base_.kind()) { \
@ -1516,6 +1548,13 @@ FrameSummary FrameSummary::Get(const CommonFrame* frame, int index) {
UNREACHABLE(); \
} \
}
#else
#define FRAME_SUMMARY_DISPATCH(ret, name) \
ret FrameSummary::name() const { \
DCHECK_EQ(JAVA_SCRIPT, base_.kind()); \
return java_script_summary_.name(); \
}
#endif // V8_ENABLE_WEBASSEMBLY
FRAME_SUMMARY_DISPATCH(Handle<Object>, receiver)
FRAME_SUMMARY_DISPATCH(int, code_offset)
@ -1818,6 +1857,7 @@ int BuiltinFrame::ComputeParametersCount() const {
return Smi::ToInt(Object(base::Memory<Address>(fp() + offset)));
}
#if V8_ENABLE_WEBASSEMBLY
void WasmFrame::Print(StringStream* accumulator, PrintMode mode,
int index) const {
wasm::WasmCodeRefScope code_ref_scope;
@ -1994,6 +2034,7 @@ void WasmCompileLazyFrame::Iterate(RootVisitor* v) const {
v->VisitRootPointers(Root::kTop, nullptr, base, limit);
v->VisitRootPointer(Root::kTop, nullptr, wasm_instance_slot());
}
#endif // V8_ENABLE_WEBASSEMBLY
namespace {

View File

@ -96,13 +96,13 @@ class StackHandler {
V(ENTRY, EntryFrame) \
V(CONSTRUCT_ENTRY, ConstructEntryFrame) \
V(EXIT, ExitFrame) \
V(WASM, WasmFrame) \
V(WASM_TO_JS, WasmToJsFrame) \
V(JS_TO_WASM, JsToWasmFrame) \
V(WASM_DEBUG_BREAK, WasmDebugBreakFrame) \
V(C_WASM_ENTRY, CWasmEntryFrame) \
V(WASM_EXIT, WasmExitFrame) \
V(WASM_COMPILE_LAZY, WasmCompileLazyFrame) \
IF_WASM(V, WASM, WasmFrame) \
IF_WASM(V, WASM_TO_JS, WasmToJsFrame) \
IF_WASM(V, JS_TO_WASM, JsToWasmFrame) \
IF_WASM(V, WASM_DEBUG_BREAK, WasmDebugBreakFrame) \
IF_WASM(V, C_WASM_ENTRY, CWasmEntryFrame) \
IF_WASM(V, WASM_EXIT, WasmExitFrame) \
IF_WASM(V, WASM_COMPILE_LAZY, WasmCompileLazyFrame) \
V(INTERPRETED, InterpretedFrame) \
V(BASELINE, BaselineFrame) \
V(OPTIMIZED, OptimizedFrame) \
@ -216,9 +216,14 @@ class StackFrame {
}
bool is_interpreted() const { return type() == INTERPRETED; }
bool is_baseline() const { return type() == BASELINE; }
#if V8_ENABLE_WEBASSEMBLY
bool is_wasm() const { return this->type() == WASM; }
bool is_c_wasm_entry() const { return type() == C_WASM_ENTRY; }
bool is_wasm_compile_lazy() const { return type() == WASM_COMPILE_LAZY; }
bool is_wasm_debug_break() const { return type() == WASM_DEBUG_BREAK; }
bool is_wasm_to_js() const { return type() == WASM_TO_JS; }
bool is_js_to_wasm() const { return type() == JS_TO_WASM; }
#endif // V8_ENABLE_WEBASSEMBLY
bool is_builtin() const { return type() == BUILTIN; }
bool is_internal() const { return type() == INTERNAL; }
bool is_builtin_continuation() const {
@ -239,8 +244,6 @@ class StackFrame {
return t >= INTERPRETED && t <= OPTIMIZED;
}
bool is_java_script() const { return IsJavaScript(type()); }
bool is_wasm_to_js() const { return type() == WASM_TO_JS; }
bool is_js_to_wasm() const { return type() == JS_TO_WASM; }
// Accessors.
Address sp() const { return state_.sp; }
@ -348,7 +351,7 @@ class V8_EXPORT_PRIVATE FrameSummary {
// Subclasses for the different summary kinds:
#define FRAME_SUMMARY_VARIANTS(F) \
F(JAVA_SCRIPT, JavaScriptFrameSummary, java_script_summary_, JavaScript) \
F(WASM, WasmFrameSummary, wasm_summary_, Wasm)
IF_WASM(F, WASM, WasmFrameSummary, wasm_summary_, Wasm)
#define FRAME_SUMMARY_KIND(kind, type, field, desc) kind,
enum Kind { FRAME_SUMMARY_VARIANTS(FRAME_SUMMARY_KIND) };
@ -398,6 +401,7 @@ class V8_EXPORT_PRIVATE FrameSummary {
Handle<FixedArray> parameters_;
};
#if V8_ENABLE_WEBASSEMBLY
class WasmFrameSummary : public FrameSummaryBase {
public:
WasmFrameSummary(Isolate*, Handle<WasmInstanceObject>, wasm::WasmCode*,
@ -424,6 +428,7 @@ class V8_EXPORT_PRIVATE FrameSummary {
wasm::WasmCode* const code_;
int code_offset_;
};
#endif // V8_ENABLE_WEBASSEMBLY
#define FRAME_SUMMARY_CONS(kind, type, field, desc) \
FrameSummary(type summ) : field(summ) {} // NOLINT
@ -943,6 +948,7 @@ class BuiltinFrame final : public TypedFrameWithJSLinkage {
friend class StackFrameIteratorBase;
};
#if V8_ENABLE_WEBASSEMBLY
class WasmFrame : public TypedFrame {
public:
Type type() const override { return WASM; }
@ -1074,6 +1080,7 @@ class WasmCompileLazyFrame : public TypedFrame {
private:
friend class StackFrameIteratorBase;
};
#endif // V8_ENABLE_WEBASSEMBLY
class InternalFrame : public TypedFrame {
public:
@ -1266,7 +1273,9 @@ class V8_EXPORT_PRIVATE StackTraceFrameIterator {
inline CommonFrame* Reframe();
inline bool is_javascript() const;
#if V8_ENABLE_WEBASSEMBLY
inline bool is_wasm() const;
#endif // V8_ENABLE_WEBASSEMBLY
inline JavaScriptFrame* javascript_frame() const;
private:

View File

@ -7,6 +7,7 @@
#include "src/execution/isolate.h"
#include "src/objects/cell-inl.h"
#include "src/objects/contexts-inl.h"
#include "src/objects/js-function.h"
#include "src/objects/objects-inl.h"
#include "src/objects/oddball.h"

View File

@ -65,6 +65,7 @@
#include "src/objects/elements.h"
#include "src/objects/feedback-vector.h"
#include "src/objects/hash-table-inl.h"
#include "src/objects/js-array-buffer-inl.h"
#include "src/objects/js-array-inl.h"
#include "src/objects/js-generator-inl.h"
#include "src/objects/js-weak-refs-inl.h"
@ -2658,6 +2659,15 @@ void Isolate::SetWasmEngine(std::shared_ptr<wasm::WasmEngine> engine) {
wasm_engine_ = std::move(engine);
wasm_engine_->AddIsolate(this);
}
void Isolate::AddSharedWasmMemory(Handle<WasmMemoryObject> memory_object) {
HandleScope scope(this);
Handle<WeakArrayList> shared_wasm_memories =
factory()->shared_wasm_memories();
shared_wasm_memories = WeakArrayList::AddToEnd(
this, shared_wasm_memories, MaybeObjectHandle::Weak(memory_object));
heap()->set_shared_wasm_memories(*shared_wasm_memories);
}
#endif // V8_ENABLE_WEBASSEMBLY
// NOLINTNEXTLINE
@ -3009,6 +3019,8 @@ void Isolate::Deinit() {
#if V8_ENABLE_WEBASSEMBLY
wasm_engine()->DeleteCompileJobsOnIsolate(this);
BackingStore::RemoveSharedWasmMemoryObjects(this);
#endif // V8_ENABLE_WEBASSEMBLY
if (concurrent_recompilation_enabled()) {
@ -3017,8 +3029,6 @@ void Isolate::Deinit() {
optimizing_compile_dispatcher_ = nullptr;
}
BackingStore::RemoveSharedWasmMemoryObjects(this);
// Help sweeper threads complete sweeping to stop faster.
heap_.mark_compact_collector()->DrainSweepingWorklists();
heap_.mark_compact_collector()->sweeper()->EnsureIterabilityCompleted();
@ -4522,15 +4532,6 @@ void Isolate::AddDetachedContext(Handle<Context> context) {
heap()->set_detached_contexts(*detached_contexts);
}
void Isolate::AddSharedWasmMemory(Handle<WasmMemoryObject> memory_object) {
HandleScope scope(this);
Handle<WeakArrayList> shared_wasm_memories =
factory()->shared_wasm_memories();
shared_wasm_memories = WeakArrayList::AddToEnd(
this, shared_wasm_memories, MaybeObjectHandle::Weak(memory_object));
heap()->set_shared_wasm_memories(*shared_wasm_memories);
}
void Isolate::CheckDetachedContextsAfterGC() {
HandleScope scope(this);
Handle<WeakArrayList> detached_contexts = factory()->detached_contexts();

View File

@ -1454,8 +1454,6 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {
void AddDetachedContext(Handle<Context> context);
void CheckDetachedContextsAfterGC();
void AddSharedWasmMemory(Handle<WasmMemoryObject> memory_object);
std::vector<Object>* startup_object_cache() { return &startup_object_cache_; }
bool IsGeneratingEmbeddedBuiltins() const {
@ -1634,9 +1632,8 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {
#if V8_ENABLE_WEBASSEMBLY
wasm::WasmEngine* wasm_engine() const { return wasm_engine_.get(); }
void SetWasmEngine(std::shared_ptr<wasm::WasmEngine> engine);
#else
// TODO(clemensb): Remove this method.
wasm::WasmEngine* wasm_engine() const { return nullptr; }
void AddSharedWasmMemory(Handle<WasmMemoryObject> memory_object);
#endif // V8_ENABLE_WEBASSEMBLY
const v8::Context::BackupIncumbentScope* top_backup_incumbent_scope() const {

View File

@ -23,8 +23,6 @@
#include "src/parsing/parsing.h"
#include "src/roots/roots.h"
#include "src/strings/string-builder-inl.h"
#include "src/wasm/wasm-code-manager.h"
#include "src/wasm/wasm-objects.h"
namespace v8 {
namespace internal {
@ -368,8 +366,6 @@ MaybeHandle<Object> ErrorUtils::FormatStackTrace(Isolate* isolate,
RETURN_ON_EXCEPTION(isolate, AppendErrorString(isolate, error, &builder),
Object);
wasm::WasmCodeRefScope wasm_code_ref_scope;
for (int i = 0; i < elems->length(); ++i) {
builder.AppendCString("\n at ");

View File

@ -13,7 +13,10 @@
#include "src/objects/backing-store.h"
#include "src/roots/roots-inl.h"
#include "src/utils/memcopy.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-engine.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {
@ -285,11 +288,23 @@ Object StackGuard::HandleInterrupts() {
isolate_->heap()->HandleGCRequest();
}
#if V8_ENABLE_WEBASSEMBLY
if (TestAndClear(&interrupt_flags, GROW_SHARED_MEMORY)) {
TRACE_EVENT0("v8.wasm", "V8.WasmGrowSharedMemory");
BackingStore::UpdateSharedWasmMemoryObjects(isolate_);
}
if (TestAndClear(&interrupt_flags, LOG_WASM_CODE)) {
TRACE_EVENT0("v8.wasm", "V8.LogCode");
isolate_->wasm_engine()->LogOutstandingCodesForIsolate(isolate_);
}
if (TestAndClear(&interrupt_flags, WASM_CODE_GC)) {
TRACE_EVENT0("v8.wasm", "V8.WasmCodeGC");
isolate_->wasm_engine()->ReportLiveCodeFromStackForGC(isolate_);
}
#endif // V8_ENABLE_WEBASSEMBLY
if (TestAndClear(&interrupt_flags, DEOPT_MARKED_ALLOCATION_SITES)) {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.gc"),
"V8.GCDeoptMarkedAllocationSites");
@ -309,16 +324,6 @@ Object StackGuard::HandleInterrupts() {
isolate_->InvokeApiInterruptCallbacks();
}
if (TestAndClear(&interrupt_flags, LOG_WASM_CODE)) {
TRACE_EVENT0("v8.wasm", "V8.LogCode");
isolate_->wasm_engine()->LogOutstandingCodesForIsolate(isolate_);
}
if (TestAndClear(&interrupt_flags, WASM_CODE_GC)) {
TRACE_EVENT0("v8.wasm", "V8.WasmCodeGC");
isolate_->wasm_engine()->ReportLiveCodeFromStackForGC(isolate_);
}
isolate_->counters()->stack_interrupts()->Increment();
return ReadOnlyRoots(isolate_).undefined_value();

View File

@ -27,6 +27,7 @@
#include "src/objects/data-handler-inl.h"
#include "src/objects/embedder-data-array-inl.h"
#include "src/objects/hash-table-inl.h"
#include "src/objects/js-array-buffer-inl.h"
#include "src/objects/slots-inl.h"
#include "src/objects/transitions-inl.h"
#include "src/utils/utils-inl.h"
@ -110,9 +111,11 @@ class ConcurrentMarkingVisitor final
return VisitJSObjectSubclassFast(map, object);
}
#if V8_ENABLE_WEBASSEMBLY
int VisitWasmInstanceObject(Map map, WasmInstanceObject object) {
return VisitJSObjectSubclass(map, object);
}
#endif // V8_ENABLE_WEBASSEMBLY
int VisitJSWeakCollection(Map map, JSWeakCollection object) {
return VisitJSObjectSubclass(map, object);

View File

@ -45,6 +45,7 @@
#include "src/objects/fixed-array-inl.h"
#include "src/objects/foreign-inl.h"
#include "src/objects/instance-type-inl.h"
#include "src/objects/js-array-buffer-inl.h"
#include "src/objects/js-array-inl.h"
#include "src/objects/js-collection-inl.h"
#include "src/objects/js-generator-inl.h"
@ -1354,6 +1355,7 @@ Handle<Foreign> Factory::NewForeign(Address addr) {
return foreign;
}
#if V8_ENABLE_WEBASSEMBLY
Handle<WasmTypeInfo> Factory::NewWasmTypeInfo(Address type_address,
Handle<Map> opt_parent) {
Handle<ArrayList> subtypes = ArrayList::New(isolate(), 0);
@ -1376,6 +1378,24 @@ Handle<WasmTypeInfo> Factory::NewWasmTypeInfo(Address type_address,
return info;
}
Handle<SharedFunctionInfo>
Factory::NewSharedFunctionInfoForWasmExportedFunction(
Handle<String> name, Handle<WasmExportedFunctionData> data) {
return NewSharedFunctionInfo(name, data, Builtins::kNoBuiltinId);
}
Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfoForWasmJSFunction(
Handle<String> name, Handle<WasmJSFunctionData> data) {
return NewSharedFunctionInfo(name, data, Builtins::kNoBuiltinId);
}
Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfoForWasmCapiFunction(
Handle<WasmCapiFunctionData> data) {
return NewSharedFunctionInfo(MaybeHandle<String>(), data,
Builtins::kNoBuiltinId, kConciseMethod);
}
#endif // V8_ENABLE_WEBASSEMBLY
Handle<Cell> Factory::NewCell(Handle<Object> value) {
STATIC_ASSERT(Cell::kSize <= kMaxRegularHeapObjectSize);
HeapObject result = AllocateRawWithImmortalMap(
@ -1543,17 +1563,22 @@ Handle<JSObject> Factory::CopyJSObjectWithAllocationSite(
// We can only clone regexps, normal objects, api objects, errors or arrays.
// Copying anything else will break invariants.
CHECK(map->instance_type() == JS_REG_EXP_TYPE ||
map->instance_type() == JS_OBJECT_TYPE ||
map->instance_type() == JS_ERROR_TYPE ||
map->instance_type() == JS_ARRAY_TYPE ||
map->instance_type() == JS_API_OBJECT_TYPE ||
map->instance_type() == WASM_GLOBAL_OBJECT_TYPE ||
map->instance_type() == WASM_INSTANCE_OBJECT_TYPE ||
map->instance_type() == WASM_MEMORY_OBJECT_TYPE ||
map->instance_type() == WASM_MODULE_OBJECT_TYPE ||
map->instance_type() == WASM_TABLE_OBJECT_TYPE ||
map->instance_type() == JS_SPECIAL_API_OBJECT_TYPE);
bool is_clonable_js_type = map->instance_type() == JS_REG_EXP_TYPE ||
map->instance_type() == JS_OBJECT_TYPE ||
map->instance_type() == JS_ERROR_TYPE ||
map->instance_type() == JS_ARRAY_TYPE ||
map->instance_type() == JS_API_OBJECT_TYPE ||
map->instance_type() == JS_SPECIAL_API_OBJECT_TYPE;
bool is_clonable_wasm_type = false;
#if V8_ENABLE_WEBASSEMBLY
is_clonable_wasm_type = map->instance_type() == WASM_GLOBAL_OBJECT_TYPE ||
map->instance_type() == WASM_INSTANCE_OBJECT_TYPE ||
map->instance_type() == WASM_MEMORY_OBJECT_TYPE ||
map->instance_type() == WASM_MODULE_OBJECT_TYPE ||
map->instance_type() == WASM_TABLE_OBJECT_TYPE;
#endif // V8_ENABLE_WEBASSEMBLY
CHECK(is_clonable_js_type || is_clonable_wasm_type);
DCHECK(site.is_null() || AllocationSite::CanTrack(map->instance_type()));
int object_size = map->instance_size();
@ -2780,23 +2805,6 @@ Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfoForApiFunction(
return shared;
}
Handle<SharedFunctionInfo>
Factory::NewSharedFunctionInfoForWasmExportedFunction(
Handle<String> name, Handle<WasmExportedFunctionData> data) {
return NewSharedFunctionInfo(name, data, Builtins::kNoBuiltinId);
}
Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfoForWasmJSFunction(
Handle<String> name, Handle<WasmJSFunctionData> data) {
return NewSharedFunctionInfo(name, data, Builtins::kNoBuiltinId);
}
Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfoForWasmCapiFunction(
Handle<WasmCapiFunctionData> data) {
return NewSharedFunctionInfo(MaybeHandle<String>(), data,
Builtins::kNoBuiltinId, kConciseMethod);
}
Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfoForBuiltin(
MaybeHandle<String> maybe_name, int builtin_index, FunctionKind kind) {
Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(

View File

@ -555,9 +555,18 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> {
Handle<JSModuleNamespace> NewJSModuleNamespace();
#if V8_ENABLE_WEBASSEMBLY
Handle<WasmTypeInfo> NewWasmTypeInfo(Address type_address,
Handle<Map> opt_parent);
Handle<SharedFunctionInfo> NewSharedFunctionInfoForWasmExportedFunction(
Handle<String> name, Handle<WasmExportedFunctionData> data);
Handle<SharedFunctionInfo> NewSharedFunctionInfoForWasmJSFunction(
Handle<String> name, Handle<WasmJSFunctionData> data);
Handle<SharedFunctionInfo> NewSharedFunctionInfoForWasmCapiFunction(
Handle<WasmCapiFunctionData> data);
#endif // V8_ENABLE_WEBASSEMBLY
Handle<SourceTextModule> NewSourceTextModule(Handle<SharedFunctionInfo> code);
Handle<SyntheticModule> NewSyntheticModule(
Handle<String> module_name, Handle<FixedArray> export_names,
@ -683,13 +692,6 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> {
MaybeHandle<String> maybe_name,
Handle<FunctionTemplateInfo> function_template_info, FunctionKind kind);
Handle<SharedFunctionInfo> NewSharedFunctionInfoForWasmExportedFunction(
Handle<String> name, Handle<WasmExportedFunctionData> data);
Handle<SharedFunctionInfo> NewSharedFunctionInfoForWasmJSFunction(
Handle<String> name, Handle<WasmJSFunctionData> data);
Handle<SharedFunctionInfo> NewSharedFunctionInfoForWasmCapiFunction(
Handle<WasmCapiFunctionData> data);
Handle<SharedFunctionInfo> NewSharedFunctionInfoForBuiltin(
MaybeHandle<String> name, int builtin_index,
FunctionKind kind = kNormalFunction);

View File

@ -46,6 +46,7 @@
#include "src/objects/embedder-data-array-inl.h"
#include "src/objects/foreign.h"
#include "src/objects/hash-table-inl.h"
#include "src/objects/js-array-buffer-inl.h"
#include "src/objects/js-objects-inl.h"
#include "src/objects/maybe-object.h"
#include "src/objects/slots-inl.h"

View File

@ -6,16 +6,13 @@
#include "include/v8.h"
#include "src/api/api-inl.h"
#include "src/api/api.h"
#include "src/execution/isolate-inl.h"
#include "src/execution/isolate.h"
#include "src/heap/factory-inl.h"
#include "src/heap/factory.h"
#include "src/heap/incremental-marking.h"
#include "src/heap/marking-worklist.h"
#include "src/logging/counters.h"
#include "src/objects/js-array-buffer-inl.h"
#include "src/objects/js-promise-inl.h"
#include "src/objects/js-promise.h"
#include "src/tasks/task-utils.h"
namespace v8 {

View File

@ -18,7 +18,10 @@
#include "src/objects/ordered-hash-table.h"
#include "src/objects/synthetic-module-inl.h"
#include "src/objects/torque-defined-classes.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-objects.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {

View File

@ -14,48 +14,48 @@
namespace v8 {
namespace internal {
#define TYPED_VISITOR_ID_LIST(V) \
V(AllocationSite) \
V(BigInt) \
V(ByteArray) \
V(BytecodeArray) \
V(Cell) \
V(Code) \
V(CodeDataContainer) \
V(CoverageInfo) \
V(DataHandler) \
V(EmbedderDataArray) \
V(EphemeronHashTable) \
V(FeedbackCell) \
V(FeedbackMetadata) \
V(FixedDoubleArray) \
V(JSArrayBuffer) \
V(JSDataView) \
V(JSFunction) \
V(JSObject) \
V(JSTypedArray) \
V(WeakCell) \
V(JSWeakCollection) \
V(JSWeakRef) \
V(Map) \
V(NativeContext) \
V(PreparseData) \
V(PropertyArray) \
V(PropertyCell) \
V(PrototypeInfo) \
V(SmallOrderedHashMap) \
V(SmallOrderedHashSet) \
V(SmallOrderedNameDictionary) \
V(SourceTextModule) \
V(SwissNameDictionary) \
V(Symbol) \
V(SyntheticModule) \
V(TransitionArray) \
V(WasmArray) \
V(WasmIndirectFunctionTable) \
V(WasmInstanceObject) \
V(WasmStruct) \
V(WasmTypeInfo)
#define TYPED_VISITOR_ID_LIST(V) \
V(AllocationSite) \
V(BigInt) \
V(ByteArray) \
V(BytecodeArray) \
V(Cell) \
V(Code) \
V(CodeDataContainer) \
V(CoverageInfo) \
V(DataHandler) \
V(EmbedderDataArray) \
V(EphemeronHashTable) \
V(FeedbackCell) \
V(FeedbackMetadata) \
V(FixedDoubleArray) \
V(JSArrayBuffer) \
V(JSDataView) \
V(JSFunction) \
V(JSObject) \
V(JSTypedArray) \
V(WeakCell) \
V(JSWeakCollection) \
V(JSWeakRef) \
V(Map) \
V(NativeContext) \
V(PreparseData) \
V(PropertyArray) \
V(PropertyCell) \
V(PrototypeInfo) \
V(SmallOrderedHashMap) \
V(SmallOrderedHashSet) \
V(SmallOrderedNameDictionary) \
V(SourceTextModule) \
V(SwissNameDictionary) \
V(Symbol) \
V(SyntheticModule) \
V(TransitionArray) \
IF_WASM(V, WasmArray) \
IF_WASM(V, WasmIndirectFunctionTable) \
IF_WASM(V, WasmInstanceObject) \
IF_WASM(V, WasmStruct) \
IF_WASM(V, WasmTypeInfo)
#define FORWARD_DECLARE(TypeName) class TypeName;
TYPED_VISITOR_ID_LIST(FORWARD_DECLARE)

View File

@ -18,6 +18,7 @@
#include "src/heap/sweeper.h"
#include "src/objects/data-handler-inl.h"
#include "src/objects/embedder-data-array-inl.h"
#include "src/objects/js-array-buffer-inl.h"
#include "src/objects/objects-body-descriptors-inl.h"
#include "src/objects/transitions-inl.h"
#include "src/utils/utils-inl.h"

View File

@ -43,7 +43,10 @@
#include "src/objects/template-objects-inl.h"
#include "src/objects/torque-defined-classes-inl.h"
#include "src/regexp/regexp.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-objects.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {
@ -125,8 +128,11 @@ AllocationResult Heap::AllocateMap(InstanceType instance_type,
int inobject_properties) {
STATIC_ASSERT(LAST_JS_OBJECT_TYPE == LAST_TYPE);
bool is_js_object = InstanceTypeChecker::IsJSObject(instance_type);
bool is_wasm_object =
(instance_type == WASM_STRUCT_TYPE || instance_type == WASM_ARRAY_TYPE);
bool is_wasm_object = false;
#if V8_ENABLE_WEBASSEMBLY
is_wasm_object =
instance_type == WASM_STRUCT_TYPE || instance_type == WASM_ARRAY_TYPE;
#endif // V8_ENABLE_WEBASSEMBLY
DCHECK_IMPLIES(is_js_object &&
!Map::CanHaveFastTransitionableElementsKind(instance_type),
IsDictionaryElementsKind(elements_kind) ||
@ -494,7 +500,8 @@ bool Heap::CreateInitialMaps() {
ALLOCATE_MAP(CODE_DATA_CONTAINER_TYPE, CodeDataContainer::kSize,
code_data_container)
ALLOCATE_MAP(WASM_TYPE_INFO_TYPE, WasmTypeInfo::kSize, wasm_type_info)
IF_WASM(ALLOCATE_MAP, WASM_TYPE_INFO_TYPE, WasmTypeInfo::kSize,
wasm_type_info)
ALLOCATE_MAP(WEAK_CELL_TYPE, WeakCell::kSize, weak_cell)

View File

@ -31,6 +31,7 @@
#include "src/objects/field-type.h"
#include "src/objects/hash-table-inl.h"
#include "src/objects/heap-number-inl.h"
#include "src/objects/js-array-buffer-inl.h"
#include "src/objects/js-array-inl.h"
#include "src/objects/module-inl.h"
#include "src/objects/prototype.h"

View File

@ -11,10 +11,13 @@
#include "src/handles/global-handles.h"
#include "src/logging/counters.h"
#include "src/trap-handler/trap-handler.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-constants.h"
#include "src/wasm/wasm-engine.h"
#include "src/wasm/wasm-limits.h"
#include "src/wasm/wasm-objects-inl.h"
#endif // V8_ENABLE_WEBASSEMBLY
#define TRACE_BS(...) \
do { \
@ -25,6 +28,15 @@ namespace v8 {
namespace internal {
namespace {
#if V8_ENABLE_WEBASSEMBLY
// Trying to allocate 4 GiB on a 32-bit platform is guaranteed to fail.
// We don't lower the official max_mem_pages() limit because that would be
// observable upon instantiation; this way the effective limit on 32-bit
// platforms is defined by the allocator.
constexpr size_t kPlatformMaxPages =
std::numeric_limits<size_t>::max() / wasm::kWasmPageSize;
#if V8_TARGET_ARCH_MIPS64
// MIPS64 has a user space of 2^40 bytes on most processors,
// address space limits needs to be smaller.
@ -98,6 +110,7 @@ void RecordStatus(Isolate* isolate, AllocationStatus status) {
isolate->counters()->wasm_memory_allocation_result()->AddSample(
static_cast<int>(status));
}
#endif // V8_ENABLE_WEBASSEMBLY
inline void DebugCheckZero(void* start, size_t byte_length) {
#if DEBUG
@ -119,25 +132,6 @@ inline void DebugCheckZero(void* start, size_t byte_length) {
}
} // namespace
bool BackingStore::ReserveAddressSpace(uint64_t num_bytes) {
uint64_t reservation_limit = kAddressSpaceLimit;
uint64_t old_count = reserved_address_space_.load(std::memory_order_relaxed);
while (true) {
if (old_count > reservation_limit) return false;
if (reservation_limit - old_count < num_bytes) return false;
if (reserved_address_space_.compare_exchange_weak(
old_count, old_count + num_bytes, std::memory_order_acq_rel)) {
return true;
}
}
}
void BackingStore::ReleaseReservation(uint64_t num_bytes) {
uint64_t old_reserved = reserved_address_space_.fetch_sub(num_bytes);
USE(old_reserved);
DCHECK_LE(num_bytes, old_reserved);
}
// The backing store for a Wasm shared memory remembers all the isolates
// with which it has been shared.
struct SharedWasmMemoryData {
@ -164,6 +158,7 @@ BackingStore::~BackingStore() {
return;
}
#if V8_ENABLE_WEBASSEMBLY
if (is_wasm_memory_) {
DCHECK(free_on_destruct_);
DCHECK(!custom_deleter_);
@ -192,6 +187,8 @@ BackingStore::~BackingStore() {
Clear();
return;
}
#endif // V8_ENABLE_WEBASSEMBLY
if (custom_deleter_) {
DCHECK(free_on_destruct_);
TRACE_BS("BS:custom deleter bs=%p mem=%p (length=%zu, capacity=%zu)\n",
@ -271,13 +268,6 @@ std::unique_ptr<BackingStore> BackingStore::Allocate(
return std::unique_ptr<BackingStore>(result);
}
// Trying to allocate 4 GiB on a 32-bit platform is guaranteed to fail.
// We don't lower the official max_mem_pages() limit because that would be
// observable upon instantiation; this way the effective limit on 32-bit
// platforms is defined by the allocator.
constexpr size_t kPlatformMaxPages =
std::numeric_limits<size_t>::max() / wasm::kWasmPageSize;
void BackingStore::SetAllocatorFromIsolate(Isolate* isolate) {
if (auto allocator_shared = isolate->array_buffer_allocator_shared()) {
holds_shared_ptr_to_allocator_ = true;
@ -290,6 +280,26 @@ void BackingStore::SetAllocatorFromIsolate(Isolate* isolate) {
}
}
#if V8_ENABLE_WEBASSEMBLY
bool BackingStore::ReserveAddressSpace(uint64_t num_bytes) {
uint64_t reservation_limit = kAddressSpaceLimit;
uint64_t old_count = reserved_address_space_.load(std::memory_order_relaxed);
while (true) {
if (old_count > reservation_limit) return false;
if (reservation_limit - old_count < num_bytes) return false;
if (reserved_address_space_.compare_exchange_weak(
old_count, old_count + num_bytes, std::memory_order_acq_rel)) {
return true;
}
}
}
void BackingStore::ReleaseReservation(uint64_t num_bytes) {
uint64_t old_reserved = reserved_address_space_.fetch_sub(num_bytes);
USE(old_reserved);
DCHECK_LE(num_bytes, old_reserved);
}
// Allocate a backing store for a Wasm memory. Always use the page allocator
// and add guard regions.
std::unique_ptr<BackingStore> BackingStore::TryAllocateWasmMemory(
@ -571,6 +581,7 @@ void BackingStore::RemoveSharedWasmMemoryObjects(Isolate* isolate) {
void BackingStore::UpdateSharedWasmMemoryObjects(Isolate* isolate) {
GlobalBackingStoreRegistry::UpdateSharedWasmMemoryObjects(isolate);
}
#endif // V8_ENABLE_WEBASSEMBLY
std::unique_ptr<BackingStore> BackingStore::WrapAllocation(
Isolate* isolate, void* allocation_base, size_t allocation_length,
@ -756,6 +767,7 @@ void GlobalBackingStoreRegistry::Purge(Isolate* isolate) {
}
}
#if V8_ENABLE_WEBASSEMBLY
void GlobalBackingStoreRegistry::AddSharedWasmMemoryObject(
Isolate* isolate, BackingStore* backing_store,
Handle<WasmMemoryObject> memory_object) {
@ -815,6 +827,7 @@ void GlobalBackingStoreRegistry::UpdateSharedWasmMemoryObjects(
memory_object->update_instances(isolate, new_buffer);
}
}
#endif // V8_ENABLE_WEBASSEMBLY
} // namespace internal
} // namespace v8

View File

@ -48,11 +48,13 @@ class V8_EXPORT_PRIVATE BackingStore : public BackingStoreBase {
SharedFlag shared,
InitializedFlag initialized);
#if V8_ENABLE_WEBASSEMBLY
// Allocate the backing store for a Wasm memory.
static std::unique_ptr<BackingStore> AllocateWasmMemory(Isolate* isolate,
size_t initial_pages,
size_t maximum_pages,
SharedFlag shared);
#endif // V8_ENABLE_WEBASSEMBLY
// Create a backing store that wraps existing allocated memory.
// If {free_on_destruct} is {true}, the memory will be freed using the
@ -84,14 +86,15 @@ class V8_EXPORT_PRIVATE BackingStore : public BackingStoreBase {
bool has_guard_regions() const { return has_guard_regions_; }
bool free_on_destruct() const { return free_on_destruct_; }
// Wrapper around ArrayBuffer::Allocator::Reallocate.
bool Reallocate(Isolate* isolate, size_t new_byte_length);
#if V8_ENABLE_WEBASSEMBLY
// Attempt to grow this backing store in place.
base::Optional<size_t> GrowWasmMemoryInPlace(Isolate* isolate,
size_t delta_pages,
size_t max_pages);
// Wrapper around ArrayBuffer::Allocator::Reallocate.
bool Reallocate(Isolate* isolate, size_t new_byte_length);
// Allocate a new, larger, backing store for this Wasm memory and copy the
// contents of this backing store into it.
std::unique_ptr<BackingStore> CopyWasmMemory(Isolate* isolate,
@ -120,6 +123,7 @@ class V8_EXPORT_PRIVATE BackingStore : public BackingStoreBase {
// Update all shared memory objects in this isolate (after a grow operation).
static void UpdateSharedWasmMemoryObjects(Isolate* isolate);
#endif // V8_ENABLE_WEBASSEMBLY
// Returns the size of the external memory owned by this backing store.
// It is used for triggering GCs based on the external memory pressure.
@ -208,9 +212,11 @@ class V8_EXPORT_PRIVATE BackingStore : public BackingStoreBase {
SharedWasmMemoryData* get_shared_wasm_memory_data();
void Clear(); // Internally clears fields after deallocation.
#if V8_ENABLE_WEBASSEMBLY
static std::unique_ptr<BackingStore> TryAllocateWasmMemory(
Isolate* isolate, size_t initial_pages, size_t maximum_pages,
SharedFlag shared);
#endif // V8_ENABLE_WEBASSEMBLY
};
// A global, per-process mapping from buffer addresses to backing stores.

View File

@ -5,13 +5,17 @@
#ifndef V8_OBJECTS_JS_FUNCTION_INL_H_
#define V8_OBJECTS_JS_FUNCTION_INL_H_
#include "src/objects/js-function.h"
// Include other inline headers *after* including js-function.h, such that e.g.
// the definition of JSFunction is available (and this comment prevents
// clang-format from merging that include into the following ones).
#include "src/codegen/compiler.h"
#include "src/diagnostics/code-tracer.h"
#include "src/heap/heap-inl.h"
#include "src/ic/ic.h"
#include "src/init/bootstrapper.h"
#include "src/objects/feedback-cell-inl.h"
#include "src/objects/js-function.h"
#include "src/strings/string-builder-inl.h"
// Has to be the last include (doesn't have include guards):

View File

@ -283,7 +283,9 @@ void JSFunction::EnsureClosureFeedbackCellArray(
Isolate* const isolate = function->GetIsolate();
DCHECK(function->shared().is_compiled());
DCHECK(function->shared().HasFeedbackMetadata());
#if V8_ENABLE_WEBASSEMBLY
if (function->shared().HasAsmWasmData()) return;
#endif // V8_ENABLE_WEBASSEMBLY
Handle<SharedFunctionInfo> shared(function->shared(), isolate);
DCHECK(function->shared().HasBytecodeArray());
@ -333,7 +335,9 @@ void JSFunction::EnsureFeedbackVector(Handle<JSFunction> function,
DCHECK(is_compiled_scope->is_compiled());
DCHECK(function->shared().HasFeedbackMetadata());
if (function->has_feedback_vector()) return;
#if V8_ENABLE_WEBASSEMBLY
if (function->shared().HasAsmWasmData()) return;
#endif // V8_ENABLE_WEBASSEMBLY
Handle<SharedFunctionInfo> shared(function->shared(), isolate);
DCHECK(function->shared().HasBytecodeArray());
@ -609,12 +613,12 @@ bool CanSubclassHaveInobjectProperties(InstanceType instance_type) {
case JS_WEAK_MAP_TYPE:
case JS_WEAK_REF_TYPE:
case JS_WEAK_SET_TYPE:
#if V8_ENABLE_WEBASSEMBLY
case WASM_GLOBAL_OBJECT_TYPE:
case WASM_INSTANCE_OBJECT_TYPE:
case WASM_MEMORY_OBJECT_TYPE:
case WASM_MODULE_OBJECT_TYPE:
case WASM_TABLE_OBJECT_TYPE:
#if V8_ENABLE_WEBASSEMBLY
case WASM_VALUE_OBJECT_TYPE:
#endif // V8_ENABLE_WEBASSEMBLY
return true;
@ -924,6 +928,7 @@ Handle<String> JSFunction::ToString(Handle<JSFunction> function) {
// If this function was compiled from asm.js, use the recorded offset
// information.
#if V8_ENABLE_WEBASSEMBLY
if (shared_info->HasWasmExportedFunctionData()) {
Handle<WasmExportedFunctionData> function_data(
shared_info->wasm_exported_function_data(), isolate);
@ -938,6 +943,7 @@ Handle<String> JSFunction::ToString(Handle<JSFunction> function) {
offsets.second);
}
}
#endif // V8_ENABLE_WEBASSEMBLY
if (shared_info->function_token_position() == kNoSourcePosition) {
// If the function token position isn't valid, return [native code] to

View File

@ -26,7 +26,7 @@
#include "src/objects/field-type.h"
#include "src/objects/fixed-array.h"
#include "src/objects/heap-number.h"
#include "src/objects/js-array-buffer.h"
#include "src/objects/js-array-buffer-inl.h"
#include "src/objects/js-array-inl.h"
#include "src/objects/lookup.h"
#include "src/objects/objects-inl.h"
@ -70,7 +70,10 @@
#include "src/strings/string-builder-inl.h"
#include "src/strings/string-stream.h"
#include "src/utils/ostreams.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-objects.h"
#endif // V8_ENABLE_WEBASSEMBLY
#if V8_ENABLE_WEBASSEMBLY
#include "src/debug/debug-wasm-objects.h"
@ -2292,6 +2295,7 @@ int JSObject::GetHeaderSize(InstanceType type,
case JS_SEGMENTS_TYPE:
return JSSegments::kHeaderSize;
#endif // V8_INTL_SUPPORT
#if V8_ENABLE_WEBASSEMBLY
case WASM_GLOBAL_OBJECT_TYPE:
return WasmGlobalObject::kHeaderSize;
case WASM_INSTANCE_OBJECT_TYPE:
@ -2302,12 +2306,11 @@ int JSObject::GetHeaderSize(InstanceType type,
return WasmModuleObject::kHeaderSize;
case WASM_TABLE_OBJECT_TYPE:
return WasmTableObject::kHeaderSize;
#if V8_ENABLE_WEBASSEMBLY
case WASM_VALUE_OBJECT_TYPE:
return WasmValueObject::kHeaderSize;
#endif // V8_ENABLE_WEBASSEMBLY
case WASM_EXCEPTION_OBJECT_TYPE:
return WasmExceptionObject::kHeaderSize;
#endif // V8_ENABLE_WEBASSEMBLY
default:
UNREACHABLE();
}

View File

@ -20,7 +20,10 @@
#include "src/objects/templates-inl.h"
#include "src/objects/transitions-inl.h"
#include "src/objects/transitions.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-objects-inl.h"
#endif // V8_ENABLE_WEBASSEMBLY
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
@ -680,9 +683,11 @@ ACCESSORS_CHECKED2(Map, constructor_or_back_pointer, Object,
ACCESSORS_CHECKED(Map, native_context, NativeContext,
kConstructorOrBackPointerOrNativeContextOffset,
IsContextMap())
#if V8_ENABLE_WEBASSEMBLY
ACCESSORS_CHECKED(Map, wasm_type_info, WasmTypeInfo,
kConstructorOrBackPointerOrNativeContextOffset,
IsWasmStructMap() || IsWasmArrayMap())
#endif // V8_ENABLE_WEBASSEMBLY
bool Map::IsPrototypeValidityCellValid() const {
Object validity_cell = prototype_validity_cell();

View File

@ -247,9 +247,6 @@ VisitorId Map::GetVisitorId(Map map) {
case CODE_DATA_CONTAINER_TYPE:
return kVisitCodeDataContainer;
case WASM_INSTANCE_OBJECT_TYPE:
return kVisitWasmInstanceObject;
case PREPARSE_DATA_TYPE:
return kVisitPreparseData;
@ -306,12 +303,12 @@ VisitorId Map::GetVisitorId(Map map) {
case JS_SEGMENTER_TYPE:
case JS_SEGMENTS_TYPE:
#endif // V8_INTL_SUPPORT
#if V8_ENABLE_WEBASSEMBLY
case WASM_EXCEPTION_OBJECT_TYPE:
case WASM_GLOBAL_OBJECT_TYPE:
case WASM_MEMORY_OBJECT_TYPE:
case WASM_MODULE_OBJECT_TYPE:
case WASM_TABLE_OBJECT_TYPE:
#if V8_ENABLE_WEBASSEMBLY
case WASM_VALUE_OBJECT_TYPE:
#endif // V8_ENABLE_WEBASSEMBLY
case JS_BOUND_FUNCTION_TYPE: {
@ -348,12 +345,14 @@ VisitorId Map::GetVisitorId(Map map) {
if (instance_type == PROTOTYPE_INFO_TYPE) {
return kVisitPrototypeInfo;
}
#if V8_ENABLE_WEBASSEMBLY
if (instance_type == WASM_CAPI_FUNCTION_DATA_TYPE) {
return kVisitWasmCapiFunctionData;
}
if (instance_type == WASM_INDIRECT_FUNCTION_TABLE_TYPE) {
return kVisitWasmIndirectFunctionTable;
}
#endif // V8_ENABLE_WEBASSEMBLY
return kVisitStruct;
case LOAD_HANDLER_TYPE:
@ -365,12 +364,16 @@ VisitorId Map::GetVisitorId(Map map) {
case SYNTHETIC_MODULE_TYPE:
return kVisitSyntheticModule;
#if V8_ENABLE_WEBASSEMBLY
case WASM_INSTANCE_OBJECT_TYPE:
return kVisitWasmInstanceObject;
case WASM_ARRAY_TYPE:
return kVisitWasmArray;
case WASM_STRUCT_TYPE:
return kVisitWasmStruct;
case WASM_TYPE_INFO_TYPE:
return kVisitWasmTypeInfo;
#endif // V8_ENABLE_WEBASSEMBLY
#define MAKE_TQ_CASE(TYPE, Name) \
case TYPE: \

View File

@ -32,47 +32,47 @@ enum InstanceType : uint16_t;
V(FeedbackMetadata) \
V(FixedDoubleArray)
#define POINTER_VISITOR_ID_LIST(V) \
V(AllocationSite) \
V(BytecodeArray) \
V(Cell) \
V(Code) \
V(CodeDataContainer) \
V(DataHandler) \
V(EmbedderDataArray) \
V(EphemeronHashTable) \
V(FeedbackCell) \
V(FreeSpace) \
V(JSApiObject) \
V(JSArrayBuffer) \
V(JSDataView) \
V(JSFunction) \
V(JSObject) \
V(JSObjectFast) \
V(JSTypedArray) \
V(JSWeakRef) \
V(JSWeakCollection) \
V(Map) \
V(NativeContext) \
V(PreparseData) \
V(PropertyArray) \
V(PropertyCell) \
V(PrototypeInfo) \
V(ShortcutCandidate) \
V(SmallOrderedHashMap) \
V(SmallOrderedHashSet) \
V(SmallOrderedNameDictionary) \
V(SourceTextModule) \
V(Struct) \
V(SwissNameDictionary) \
V(Symbol) \
V(SyntheticModule) \
V(TransitionArray) \
V(WasmIndirectFunctionTable) \
V(WasmInstanceObject) \
V(WasmArray) \
V(WasmStruct) \
V(WasmTypeInfo) \
#define POINTER_VISITOR_ID_LIST(V) \
V(AllocationSite) \
V(BytecodeArray) \
V(Cell) \
V(Code) \
V(CodeDataContainer) \
V(DataHandler) \
V(EmbedderDataArray) \
V(EphemeronHashTable) \
V(FeedbackCell) \
V(FreeSpace) \
V(JSApiObject) \
V(JSArrayBuffer) \
V(JSDataView) \
V(JSFunction) \
V(JSObject) \
V(JSObjectFast) \
V(JSTypedArray) \
V(JSWeakRef) \
V(JSWeakCollection) \
V(Map) \
V(NativeContext) \
V(PreparseData) \
V(PropertyArray) \
V(PropertyCell) \
V(PrototypeInfo) \
V(ShortcutCandidate) \
V(SmallOrderedHashMap) \
V(SmallOrderedHashSet) \
V(SmallOrderedNameDictionary) \
V(SourceTextModule) \
V(Struct) \
V(SwissNameDictionary) \
V(Symbol) \
V(SyntheticModule) \
V(TransitionArray) \
IF_WASM(V, WasmIndirectFunctionTable) \
IF_WASM(V, WasmInstanceObject) \
IF_WASM(V, WasmArray) \
IF_WASM(V, WasmStruct) \
IF_WASM(V, WasmTypeInfo) \
V(WeakCell)
#define TORQUE_VISITOR_ID_LIST(V) \

View File

@ -214,16 +214,16 @@ class ZoneForwardList;
V(TransitionArray) \
V(Undetectable) \
V(UniqueName) \
V(WasmArray) \
V(WasmExceptionObject) \
V(WasmExceptionPackage) \
V(WasmGlobalObject) \
V(WasmInstanceObject) \
V(WasmMemoryObject) \
V(WasmModuleObject) \
V(WasmStruct) \
V(WasmTypeInfo) \
V(WasmTableObject) \
IF_WASM(V, WasmArray) \
IF_WASM(V, WasmExceptionObject) \
IF_WASM(V, WasmExceptionPackage) \
IF_WASM(V, WasmGlobalObject) \
IF_WASM(V, WasmInstanceObject) \
IF_WASM(V, WasmMemoryObject) \
IF_WASM(V, WasmModuleObject) \
IF_WASM(V, WasmStruct) \
IF_WASM(V, WasmTypeInfo) \
IF_WASM(V, WasmTableObject) \
IF_WASM(V, WasmValueObject) \
V(WeakFixedArray) \
V(WeakArrayList) \

View File

@ -23,7 +23,10 @@
#include "src/objects/synthetic-module.h"
#include "src/objects/torque-defined-classes-inl.h"
#include "src/objects/transitions.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-objects-inl.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {
@ -560,6 +563,7 @@ class Foreign::BodyDescriptor final : public BodyDescriptorBase {
static inline int SizeOf(Map map, HeapObject object) { return kSize; }
};
#if V8_ENABLE_WEBASSEMBLY
class WasmTypeInfo::BodyDescriptor final : public BodyDescriptorBase {
public:
static bool IsValidSlot(Map map, HeapObject obj, int offset) {
@ -578,6 +582,85 @@ class WasmTypeInfo::BodyDescriptor final : public BodyDescriptorBase {
static inline int SizeOf(Map map, HeapObject object) { return kSize; }
};
class WasmInstanceObject::BodyDescriptor final : public BodyDescriptorBase {
public:
static bool IsValidSlot(Map map, HeapObject obj, int offset) {
SLOW_DCHECK(std::is_sorted(std::begin(kTaggedFieldOffsets),
std::end(kTaggedFieldOffsets)));
STATIC_ASSERT(sizeof(*kTaggedFieldOffsets) == sizeof(uint16_t));
if (offset < int{8 * sizeof(*kTaggedFieldOffsets)} &&
std::binary_search(std::begin(kTaggedFieldOffsets),
std::end(kTaggedFieldOffsets),
static_cast<uint16_t>(offset))) {
return true;
}
return IsValidJSObjectSlotImpl(map, obj, offset);
}
template <typename ObjectVisitor>
static inline void IterateBody(Map map, HeapObject obj, int object_size,
ObjectVisitor* v) {
IteratePointers(obj, kPropertiesOrHashOffset, JSObject::kHeaderSize, v);
for (uint16_t offset : kTaggedFieldOffsets) {
IteratePointer(obj, offset, v);
}
IterateJSObjectBodyImpl(map, obj, kHeaderSize, object_size, v);
}
static inline int SizeOf(Map map, HeapObject object) {
return map.instance_size();
}
};
class WasmArray::BodyDescriptor final : public BodyDescriptorBase {
public:
static bool IsValidSlot(Map map, HeapObject obj, int offset) {
// Fields in WasmArrays never change their types in place, so
// there should never be a need to call this function.
UNREACHABLE();
return false;
}
template <typename ObjectVisitor>
static inline void IterateBody(Map map, HeapObject obj, int object_size,
ObjectVisitor* v) {
if (!WasmArray::GcSafeType(map)->element_type().is_reference()) return;
IteratePointers(obj, WasmArray::kHeaderSize, object_size, v);
}
static inline int SizeOf(Map map, HeapObject object) {
return WasmArray::GcSafeSizeFor(map, WasmArray::cast(object).length());
}
};
class WasmStruct::BodyDescriptor final : public BodyDescriptorBase {
public:
static bool IsValidSlot(Map map, HeapObject obj, int offset) {
// Fields in WasmStructs never change their types in place, so
// there should never be a need to call this function.
UNREACHABLE();
return false;
}
template <typename ObjectVisitor>
static inline void IterateBody(Map map, HeapObject obj, int object_size,
ObjectVisitor* v) {
WasmStruct wasm_struct = WasmStruct::cast(obj);
wasm::StructType* type = WasmStruct::GcSafeType(map);
for (uint32_t i = 0; i < type->field_count(); i++) {
if (!type->field(i).is_reference()) continue;
int offset = static_cast<int>(type->field_offset(i));
v->VisitPointer(wasm_struct, wasm_struct.RawField(offset));
}
}
static inline int SizeOf(Map map, HeapObject object) {
return map.instance_size();
}
};
#endif // V8_ENABLE_WEBASSEMBLY
class ExternalOneByteString::BodyDescriptor final : public BodyDescriptorBase {
public:
static bool IsValidSlot(Map map, HeapObject obj, int offset) { return false; }
@ -660,36 +743,6 @@ class Code::BodyDescriptor final : public BodyDescriptorBase {
}
};
class WasmInstanceObject::BodyDescriptor final : public BodyDescriptorBase {
public:
static bool IsValidSlot(Map map, HeapObject obj, int offset) {
SLOW_DCHECK(std::is_sorted(std::begin(kTaggedFieldOffsets),
std::end(kTaggedFieldOffsets)));
STATIC_ASSERT(sizeof(*kTaggedFieldOffsets) == sizeof(uint16_t));
if (offset < int{8 * sizeof(*kTaggedFieldOffsets)} &&
std::binary_search(std::begin(kTaggedFieldOffsets),
std::end(kTaggedFieldOffsets),
static_cast<uint16_t>(offset))) {
return true;
}
return IsValidJSObjectSlotImpl(map, obj, offset);
}
template <typename ObjectVisitor>
static inline void IterateBody(Map map, HeapObject obj, int object_size,
ObjectVisitor* v) {
IteratePointers(obj, kPropertiesOrHashOffset, JSObject::kHeaderSize, v);
for (uint16_t offset : kTaggedFieldOffsets) {
IteratePointer(obj, offset, v);
}
IterateJSObjectBodyImpl(map, obj, kHeaderSize, object_size, v);
}
static inline int SizeOf(Map map, HeapObject object) {
return map.instance_size();
}
};
class Map::BodyDescriptor final : public BodyDescriptorBase {
public:
static bool IsValidSlot(Map map, HeapObject obj, int offset) {
@ -776,53 +829,6 @@ class CodeDataContainer::BodyDescriptor final : public BodyDescriptorBase {
}
};
class WasmArray::BodyDescriptor final : public BodyDescriptorBase {
public:
static bool IsValidSlot(Map map, HeapObject obj, int offset) {
// Fields in WasmArrays never change their types in place, so
// there should never be a need to call this function.
UNREACHABLE();
return false;
}
template <typename ObjectVisitor>
static inline void IterateBody(Map map, HeapObject obj, int object_size,
ObjectVisitor* v) {
if (!WasmArray::GcSafeType(map)->element_type().is_reference()) return;
IteratePointers(obj, WasmArray::kHeaderSize, object_size, v);
}
static inline int SizeOf(Map map, HeapObject object) {
return WasmArray::GcSafeSizeFor(map, WasmArray::cast(object).length());
}
};
class WasmStruct::BodyDescriptor final : public BodyDescriptorBase {
public:
static bool IsValidSlot(Map map, HeapObject obj, int offset) {
// Fields in WasmStructs never change their types in place, so
// there should never be a need to call this function.
UNREACHABLE();
return false;
}
template <typename ObjectVisitor>
static inline void IterateBody(Map map, HeapObject obj, int object_size,
ObjectVisitor* v) {
WasmStruct wasm_struct = WasmStruct::cast(obj);
wasm::StructType* type = WasmStruct::GcSafeType(map);
for (uint32_t i = 0; i < type->field_count(); i++) {
if (!type->field(i).is_reference()) continue;
int offset = static_cast<int>(type->field_offset(i));
v->VisitPointer(wasm_struct, wasm_struct.RawField(offset));
}
}
static inline int SizeOf(Map map, HeapObject object) {
return map.instance_size();
}
};
class EmbedderDataArray::BodyDescriptor final : public BodyDescriptorBase {
public:
static bool IsValidSlot(Map map, HeapObject obj, int offset) {
@ -935,12 +941,14 @@ ReturnType BodyDescriptorApply(InstanceType type, T1 p1, T2 p2, T3 p3, T4 p4) {
return Op::template apply<FeedbackCell::BodyDescriptor>(p1, p2, p3, p4);
case COVERAGE_INFO_TYPE:
return Op::template apply<CoverageInfo::BodyDescriptor>(p1, p2, p3, p4);
#if V8_ENABLE_WEBASSEMBLY
case WASM_ARRAY_TYPE:
return Op::template apply<WasmArray::BodyDescriptor>(p1, p2, p3, p4);
case WASM_STRUCT_TYPE:
return Op::template apply<WasmStruct::BodyDescriptor>(p1, p2, p3, p4);
case WASM_TYPE_INFO_TYPE:
return Op::template apply<WasmTypeInfo::BodyDescriptor>(p1, p2, p3, p4);
#endif // V8_ENABLE_WEBASSEMBLY
case JS_API_OBJECT_TYPE:
case JS_ARGUMENTS_OBJECT_TYPE:
case JS_ARRAY_ITERATOR_PROTOTYPE_TYPE:
@ -996,18 +1004,20 @@ ReturnType BodyDescriptorApply(InstanceType type, T1 p1, T2 p2, T3 p3, T4 p4) {
case JS_SEGMENTER_TYPE:
case JS_SEGMENTS_TYPE:
#endif // V8_INTL_SUPPORT
#if V8_ENABLE_WEBASSEMBLY
case WASM_EXCEPTION_OBJECT_TYPE:
case WASM_GLOBAL_OBJECT_TYPE:
case WASM_MEMORY_OBJECT_TYPE:
case WASM_MODULE_OBJECT_TYPE:
case WASM_TABLE_OBJECT_TYPE:
#if V8_ENABLE_WEBASSEMBLY
case WASM_VALUE_OBJECT_TYPE:
#endif // V8_ENABLE_WEBASSEMBLY
return Op::template apply<JSObject::BodyDescriptor>(p1, p2, p3, p4);
#if V8_ENABLE_WEBASSEMBLY
case WASM_INSTANCE_OBJECT_TYPE:
return Op::template apply<WasmInstanceObject::BodyDescriptor>(p1, p2, p3,
p4);
#endif // V8_ENABLE_WEBASSEMBLY
case JS_WEAK_MAP_TYPE:
case JS_WEAK_SET_TYPE:
return Op::template apply<JSWeakCollection::BodyDescriptor>(p1, p2, p3,
@ -1084,15 +1094,18 @@ ReturnType BodyDescriptorApply(InstanceType type, T1 p1, T2 p2, T3 p3, T4 p4) {
if (type == PROTOTYPE_INFO_TYPE) {
return Op::template apply<PrototypeInfo::BodyDescriptor>(p1, p2, p3,
p4);
} else if (type == WASM_CAPI_FUNCTION_DATA_TYPE) {
}
#if V8_ENABLE_WEBASSEMBLY
if (type == WASM_CAPI_FUNCTION_DATA_TYPE) {
return Op::template apply<WasmCapiFunctionData::BodyDescriptor>(p1, p2,
p3, p4);
} else if (type == WASM_INDIRECT_FUNCTION_TABLE_TYPE) {
}
if (type == WASM_INDIRECT_FUNCTION_TABLE_TYPE) {
return Op::template apply<WasmIndirectFunctionTable::BodyDescriptor>(
p1, p2, p3, p4);
} else {
return Op::template apply<StructBodyDescriptor>(p1, p2, p3, p4);
}
#endif // V8_ENABLE_WEBASSEMBLY
return Op::template apply<StructBodyDescriptor>(p1, p2, p3, p4);
case CALL_HANDLER_INFO_TYPE:
return Op::template apply<StructBodyDescriptor>(p1, p2, p3, p4);
case LOAD_HANDLER_TYPE:

View File

@ -101,62 +101,63 @@ namespace internal {
// code for the class including allocation and garbage collection routines,
// casts and predicates. All you need to define is the class, methods and
// object verification routines. Easy, no?
#define STRUCT_LIST_GENERATOR_BASE(V, _) \
V(_, PROMISE_FULFILL_REACTION_JOB_TASK_TYPE, PromiseFulfillReactionJobTask, \
promise_fulfill_reaction_job_task) \
V(_, PROMISE_REJECT_REACTION_JOB_TASK_TYPE, PromiseRejectReactionJobTask, \
promise_reject_reaction_job_task) \
V(_, CALLABLE_TASK_TYPE, CallableTask, callable_task) \
V(_, CALLBACK_TASK_TYPE, CallbackTask, callback_task) \
V(_, PROMISE_RESOLVE_THENABLE_JOB_TASK_TYPE, PromiseResolveThenableJobTask, \
promise_resolve_thenable_job_task) \
V(_, FUNCTION_TEMPLATE_INFO_TYPE, FunctionTemplateInfo, \
function_template_info) \
V(_, OBJECT_TEMPLATE_INFO_TYPE, ObjectTemplateInfo, object_template_info) \
V(_, ACCESS_CHECK_INFO_TYPE, AccessCheckInfo, access_check_info) \
V(_, ACCESSOR_INFO_TYPE, AccessorInfo, accessor_info) \
V(_, ACCESSOR_PAIR_TYPE, AccessorPair, accessor_pair) \
V(_, ALIASED_ARGUMENTS_ENTRY_TYPE, AliasedArgumentsEntry, \
aliased_arguments_entry) \
V(_, ALLOCATION_MEMENTO_TYPE, AllocationMemento, allocation_memento) \
V(_, ARRAY_BOILERPLATE_DESCRIPTION_TYPE, ArrayBoilerplateDescription, \
array_boilerplate_description) \
V(_, ASM_WASM_DATA_TYPE, AsmWasmData, asm_wasm_data) \
V(_, ASYNC_GENERATOR_REQUEST_TYPE, AsyncGeneratorRequest, \
async_generator_request) \
V(_, BASELINE_DATA_TYPE, BaselineData, baseline_data) \
V(_, BREAK_POINT_TYPE, BreakPoint, break_point) \
V(_, BREAK_POINT_INFO_TYPE, BreakPointInfo, break_point_info) \
V(_, CACHED_TEMPLATE_OBJECT_TYPE, CachedTemplateObject, \
cached_template_object) \
V(_, CLASS_POSITIONS_TYPE, ClassPositions, class_positions) \
V(_, DEBUG_INFO_TYPE, DebugInfo, debug_info) \
V(_, ENUM_CACHE_TYPE, EnumCache, enum_cache) \
V(_, FUNCTION_TEMPLATE_RARE_DATA_TYPE, FunctionTemplateRareData, \
function_template_rare_data) \
V(_, INTERCEPTOR_INFO_TYPE, InterceptorInfo, interceptor_info) \
V(_, INTERPRETER_DATA_TYPE, InterpreterData, interpreter_data) \
V(_, MODULE_REQUEST_TYPE, ModuleRequest, module_request) \
V(_, PROMISE_CAPABILITY_TYPE, PromiseCapability, promise_capability) \
V(_, PROMISE_REACTION_TYPE, PromiseReaction, promise_reaction) \
V(_, PROPERTY_DESCRIPTOR_OBJECT_TYPE, PropertyDescriptorObject, \
property_descriptor_object) \
V(_, PROTOTYPE_INFO_TYPE, PrototypeInfo, prototype_info) \
V(_, REG_EXP_BOILERPLATE_DESCRIPTION_TYPE, RegExpBoilerplateDescription, \
regexp_boilerplate_description) \
V(_, SCRIPT_TYPE, Script, script) \
V(_, SOURCE_TEXT_MODULE_INFO_ENTRY_TYPE, SourceTextModuleInfoEntry, \
module_info_entry) \
V(_, STACK_FRAME_INFO_TYPE, StackFrameInfo, stack_frame_info) \
V(_, TEMPLATE_OBJECT_DESCRIPTION_TYPE, TemplateObjectDescription, \
template_object_description) \
V(_, TUPLE2_TYPE, Tuple2, tuple2) \
V(_, WASM_EXCEPTION_TAG_TYPE, WasmExceptionTag, wasm_exception_tag) \
V(_, WASM_EXPORTED_FUNCTION_DATA_TYPE, WasmExportedFunctionData, \
wasm_exported_function_data) \
V(_, WASM_INDIRECT_FUNCTION_TABLE_TYPE, WasmIndirectFunctionTable, \
wasm_indirect_function_table) \
V(_, WASM_JS_FUNCTION_DATA_TYPE, WasmJSFunctionData, wasm_js_function_data)
#define STRUCT_LIST_GENERATOR_BASE(V, _) \
V(_, PROMISE_FULFILL_REACTION_JOB_TASK_TYPE, PromiseFulfillReactionJobTask, \
promise_fulfill_reaction_job_task) \
V(_, PROMISE_REJECT_REACTION_JOB_TASK_TYPE, PromiseRejectReactionJobTask, \
promise_reject_reaction_job_task) \
V(_, CALLABLE_TASK_TYPE, CallableTask, callable_task) \
V(_, CALLBACK_TASK_TYPE, CallbackTask, callback_task) \
V(_, PROMISE_RESOLVE_THENABLE_JOB_TASK_TYPE, PromiseResolveThenableJobTask, \
promise_resolve_thenable_job_task) \
V(_, FUNCTION_TEMPLATE_INFO_TYPE, FunctionTemplateInfo, \
function_template_info) \
V(_, OBJECT_TEMPLATE_INFO_TYPE, ObjectTemplateInfo, object_template_info) \
V(_, ACCESS_CHECK_INFO_TYPE, AccessCheckInfo, access_check_info) \
V(_, ACCESSOR_INFO_TYPE, AccessorInfo, accessor_info) \
V(_, ACCESSOR_PAIR_TYPE, AccessorPair, accessor_pair) \
V(_, ALIASED_ARGUMENTS_ENTRY_TYPE, AliasedArgumentsEntry, \
aliased_arguments_entry) \
V(_, ALLOCATION_MEMENTO_TYPE, AllocationMemento, allocation_memento) \
V(_, ARRAY_BOILERPLATE_DESCRIPTION_TYPE, ArrayBoilerplateDescription, \
array_boilerplate_description) \
IF_WASM(V, _, ASM_WASM_DATA_TYPE, AsmWasmData, asm_wasm_data) \
V(_, ASYNC_GENERATOR_REQUEST_TYPE, AsyncGeneratorRequest, \
async_generator_request) \
V(_, BASELINE_DATA_TYPE, BaselineData, baseline_data) \
V(_, BREAK_POINT_TYPE, BreakPoint, break_point) \
V(_, BREAK_POINT_INFO_TYPE, BreakPointInfo, break_point_info) \
V(_, CACHED_TEMPLATE_OBJECT_TYPE, CachedTemplateObject, \
cached_template_object) \
V(_, CLASS_POSITIONS_TYPE, ClassPositions, class_positions) \
V(_, DEBUG_INFO_TYPE, DebugInfo, debug_info) \
V(_, ENUM_CACHE_TYPE, EnumCache, enum_cache) \
V(_, FUNCTION_TEMPLATE_RARE_DATA_TYPE, FunctionTemplateRareData, \
function_template_rare_data) \
V(_, INTERCEPTOR_INFO_TYPE, InterceptorInfo, interceptor_info) \
V(_, INTERPRETER_DATA_TYPE, InterpreterData, interpreter_data) \
V(_, MODULE_REQUEST_TYPE, ModuleRequest, module_request) \
V(_, PROMISE_CAPABILITY_TYPE, PromiseCapability, promise_capability) \
V(_, PROMISE_REACTION_TYPE, PromiseReaction, promise_reaction) \
V(_, PROPERTY_DESCRIPTOR_OBJECT_TYPE, PropertyDescriptorObject, \
property_descriptor_object) \
V(_, PROTOTYPE_INFO_TYPE, PrototypeInfo, prototype_info) \
V(_, REG_EXP_BOILERPLATE_DESCRIPTION_TYPE, RegExpBoilerplateDescription, \
regexp_boilerplate_description) \
V(_, SCRIPT_TYPE, Script, script) \
V(_, SOURCE_TEXT_MODULE_INFO_ENTRY_TYPE, SourceTextModuleInfoEntry, \
module_info_entry) \
V(_, STACK_FRAME_INFO_TYPE, StackFrameInfo, stack_frame_info) \
V(_, TEMPLATE_OBJECT_DESCRIPTION_TYPE, TemplateObjectDescription, \
template_object_description) \
V(_, TUPLE2_TYPE, Tuple2, tuple2) \
IF_WASM(V, _, WASM_EXCEPTION_TAG_TYPE, WasmExceptionTag, wasm_exception_tag) \
IF_WASM(V, _, WASM_EXPORTED_FUNCTION_DATA_TYPE, WasmExportedFunctionData, \
wasm_exported_function_data) \
IF_WASM(V, _, WASM_INDIRECT_FUNCTION_TABLE_TYPE, WasmIndirectFunctionTable, \
wasm_indirect_function_table) \
IF_WASM(V, _, WASM_JS_FUNCTION_DATA_TYPE, WasmJSFunctionData, \
wasm_js_function_data)
#define STRUCT_LIST_GENERATOR(V, _) STRUCT_LIST_GENERATOR_BASE(V, _)

View File

@ -30,7 +30,7 @@
#include "src/objects/literal-objects.h"
#include "src/objects/lookup-inl.h" // TODO(jkummerow): Drop.
#include "src/objects/objects.h"
#include "src/objects/oddball.h"
#include "src/objects/oddball-inl.h"
#include "src/objects/property-details.h"
#include "src/objects/property.h"
#include "src/objects/regexp-match-info.h"
@ -358,11 +358,13 @@ DEF_GETTER(HeapObject, IsObjectHashTable, bool) { return IsHashTable(isolate); }
DEF_GETTER(HeapObject, IsHashTableBase, bool) { return IsHashTable(isolate); }
#if V8_ENABLE_WEBASSEMBLY
DEF_GETTER(HeapObject, IsWasmExceptionPackage, bool) {
// It is not possible to check for the existence of certain properties on the
// underlying {JSReceiver} here because that requires calling handlified code.
return IsJSReceiver(isolate);
}
#endif // V8_ENABLE_WEBASSEMBLY
bool Object::IsPrimitive() const {
if (IsSmi()) return true;

View File

@ -63,6 +63,7 @@
#include "src/objects/function-kind.h"
#include "src/objects/hash-table-inl.h"
#include "src/objects/instance-type.h"
#include "src/objects/js-array-buffer-inl.h"
#include "src/objects/js-array-inl.h"
#include "src/objects/keys.h"
#include "src/objects/lookup-inl.h"
@ -123,10 +124,12 @@
#include "src/strings/unicode-inl.h"
#include "src/utils/ostreams.h"
#include "src/utils/utils-inl.h"
#include "src/wasm/wasm-engine.h"
#include "src/wasm/wasm-objects.h"
#include "src/zone/zone.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-objects.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {
@ -2324,9 +2327,11 @@ int HeapObject::SizeFromMap(Map map) const {
return CoverageInfo::SizeFor(
CoverageInfo::unchecked_cast(*this).slot_count());
}
#if V8_ENABLE_WEBASSEMBLY
if (instance_type == WASM_ARRAY_TYPE) {
return WasmArray::GcSafeSizeFor(map, WasmArray::cast(*this).length());
}
#endif // V8_ENABLE_WEBASSEMBLY
DCHECK_EQ(instance_type, EMBEDDER_DATA_ARRAY_TYPE);
return EmbedderDataArray::SizeFor(
EmbedderDataArray::unchecked_cast(*this).length());
@ -4770,12 +4775,14 @@ bool Script::GetPositionInfo(Handle<Script> script, int position,
bool Script::IsUserJavaScript() const { return type() == Script::TYPE_NORMAL; }
bool Script::ContainsAsmModule() {
#if V8_ENABLE_WEBASSEMBLY
DisallowGarbageCollection no_gc;
SharedFunctionInfo::ScriptIterator iter(this->GetIsolate(), *this);
for (SharedFunctionInfo info = iter.Next(); !info.is_null();
info = iter.Next()) {
if (info.HasAsmWasmData()) return true;
}
#endif // V8_ENABLE_WEBASSEMBLY
return false;
}
@ -4823,6 +4830,7 @@ bool Script::GetPositionInfo(int position, PositionInfo* info,
OffsetFlag offset_flag) const {
DisallowGarbageCollection no_gc;
#if V8_ENABLE_WEBASSEMBLY
// For wasm, we use the byte offset as the column.
if (type() == Script::TYPE_WASM) {
DCHECK_LE(0, position);
@ -4835,6 +4843,7 @@ bool Script::GetPositionInfo(int position, PositionInfo* info,
info->line_end = module->functions.back().code.end_offset();
return true;
}
#endif // V8_ENABLE_WEBASSEMBLY
if (line_ends().IsUndefined()) {
// Slow mode: we do not have line_ends. We have to iterate through source.

View File

@ -15,8 +15,11 @@
#include "src/objects/scope-info.h"
#include "src/objects/shared-function-info.h"
#include "src/objects/templates.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-objects-inl.h"
#endif // V8_ENABLE_WEBASSEMBLY
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
@ -245,8 +248,10 @@ BIT_FIELD_ACCESSORS(SharedFunctionInfo, flags, has_duplicate_parameters,
BIT_FIELD_ACCESSORS(SharedFunctionInfo, flags, native,
SharedFunctionInfo::IsNativeBit)
#if V8_ENABLE_WEBASSEMBLY
BIT_FIELD_ACCESSORS(SharedFunctionInfo, flags, is_asm_wasm_broken,
SharedFunctionInfo::IsAsmWasmBrokenBit)
#endif // V8_ENABLE_WEBASSEMBLY
BIT_FIELD_ACCESSORS(SharedFunctionInfo, flags,
requires_instance_members_initializer,
SharedFunctionInfo::RequiresInstanceMembersInitializerBit)
@ -355,8 +360,10 @@ void SharedFunctionInfo::UpdateFunctionMapIndex() {
}
void SharedFunctionInfo::DontAdaptArguments() {
#if V8_ENABLE_WEBASSEMBLY
// TODO(leszeks): Revise this DCHECK now that the code field is gone.
DCHECK(!HasWasmExportedFunctionData());
#endif // V8_ENABLE_WEBASSEMBLY
set_internal_formal_parameter_count(kDontAdaptArgumentsSentinel);
}
@ -618,10 +625,23 @@ void SharedFunctionInfo::flush_baseline_data() {
set_function_data(baseline_data().data(), kReleaseStore);
}
#if V8_ENABLE_WEBASSEMBLY
bool SharedFunctionInfo::HasAsmWasmData() const {
return function_data(kAcquireLoad).IsAsmWasmData();
}
bool SharedFunctionInfo::HasWasmExportedFunctionData() const {
return function_data(kAcquireLoad).IsWasmExportedFunctionData();
}
bool SharedFunctionInfo::HasWasmJSFunctionData() const {
return function_data(kAcquireLoad).IsWasmJSFunctionData();
}
bool SharedFunctionInfo::HasWasmCapiFunctionData() const {
return function_data(kAcquireLoad).IsWasmCapiFunctionData();
}
AsmWasmData SharedFunctionInfo::asm_wasm_data() const {
DCHECK(HasAsmWasmData());
return AsmWasmData::cast(function_data(kAcquireLoad));
@ -633,6 +653,23 @@ void SharedFunctionInfo::set_asm_wasm_data(AsmWasmData data) {
set_function_data(data, kReleaseStore);
}
const wasm::WasmModule* SharedFunctionInfo::wasm_module() const {
if (!HasWasmExportedFunctionData()) return nullptr;
const WasmExportedFunctionData& function_data = wasm_exported_function_data();
const WasmInstanceObject& wasm_instance = function_data.instance();
const WasmModuleObject& wasm_module_object = wasm_instance.module_object();
return wasm_module_object.module();
}
const wasm::FunctionSig* SharedFunctionInfo::wasm_function_signature() const {
const wasm::WasmModule* module = wasm_module();
if (!module) return nullptr;
const WasmExportedFunctionData& function_data = wasm_exported_function_data();
DCHECK_LT(function_data.function_index(), module->functions.size());
return module->functions[function_data.function_index()].sig;
}
#endif // V8_ENABLE_WEBASSEMBLY
bool SharedFunctionInfo::HasBuiltinId() const {
return function_data(kAcquireLoad).IsSmi();
}
@ -727,34 +764,6 @@ void UncompiledData::InitAfterBytecodeFlush(
set_end_position(end_position);
}
bool SharedFunctionInfo::HasWasmExportedFunctionData() const {
return function_data(kAcquireLoad).IsWasmExportedFunctionData();
}
bool SharedFunctionInfo::HasWasmJSFunctionData() const {
return function_data(kAcquireLoad).IsWasmJSFunctionData();
}
const wasm::WasmModule* SharedFunctionInfo::wasm_module() const {
if (!HasWasmExportedFunctionData()) return nullptr;
const WasmExportedFunctionData& function_data = wasm_exported_function_data();
const WasmInstanceObject& wasm_instance = function_data.instance();
const WasmModuleObject& wasm_module_object = wasm_instance.module_object();
return wasm_module_object.module();
}
const wasm::FunctionSig* SharedFunctionInfo::wasm_function_signature() const {
const wasm::WasmModule* module = wasm_module();
if (!module) return nullptr;
const WasmExportedFunctionData& function_data = wasm_exported_function_data();
DCHECK_LT(function_data.function_index(), module->functions.size());
return module->functions[function_data.function_index()].sig;
}
bool SharedFunctionInfo::HasWasmCapiFunctionData() const {
return function_data(kAcquireLoad).IsWasmCapiFunctionData();
}
HeapObject SharedFunctionInfo::script() const {
HeapObject maybe_script = script_or_debug_info(kAcquireLoad);
if (maybe_script.IsDebugInfo()) {
@ -822,14 +831,18 @@ bool SharedFunctionInfo::IsUserJavaScript() const {
}
bool SharedFunctionInfo::IsSubjectToDebugging() const {
return IsUserJavaScript() && !HasAsmWasmData();
#if V8_ENABLE_WEBASSEMBLY
if (HasAsmWasmData()) return false;
#endif // V8_ENABLE_WEBASSEMBLY
return IsUserJavaScript();
}
bool SharedFunctionInfo::CanDiscardCompiled() const {
bool can_decompile =
(HasBytecodeArray() || HasAsmWasmData() ||
HasUncompiledDataWithPreparseData() || HasBaselineData());
return can_decompile;
#if V8_ENABLE_WEBASSEMBLY
if (HasAsmWasmData()) return true;
#endif // V8_ENABLE_WEBASSEMBLY
return HasBytecodeArray() || HasUncompiledDataWithPreparseData() ||
HasBaselineData();
}
bool SharedFunctionInfo::is_class_constructor() const {

View File

@ -78,43 +78,55 @@ Code SharedFunctionInfo::GetCode() const {
// Holding a Smi means we are a builtin.
DCHECK(HasBuiltinId());
return isolate->builtins()->builtin(builtin_id());
} else if (data.IsBytecodeArray()) {
}
if (data.IsBytecodeArray()) {
// Having a bytecode array means we are a compiled, interpreted function.
DCHECK(HasBytecodeArray());
return isolate->builtins()->builtin(Builtins::kInterpreterEntryTrampoline);
} else if (data.IsBaselineData()) {
}
if (data.IsBaselineData()) {
// Having BaselineData means we are a compiled, baseline function.
DCHECK(HasBaselineData());
return baseline_data().baseline_code();
} else if (data.IsAsmWasmData()) {
}
#if V8_ENABLE_WEBASSEMBLY
if (data.IsAsmWasmData()) {
// Having AsmWasmData means we are an asm.js/wasm function.
DCHECK(HasAsmWasmData());
return isolate->builtins()->builtin(Builtins::kInstantiateAsmJs);
} else if (data.IsUncompiledData()) {
// Having uncompiled data (with or without scope) means we need to compile.
DCHECK(HasUncompiledData());
return isolate->builtins()->builtin(Builtins::kCompileLazy);
} else if (data.IsFunctionTemplateInfo()) {
// Having a function template info means we are an API function.
DCHECK(IsApiFunction());
return isolate->builtins()->builtin(Builtins::kHandleApiCall);
} else if (data.IsWasmExportedFunctionData()) {
}
if (data.IsWasmExportedFunctionData()) {
// Having a WasmExportedFunctionData means the code is in there.
DCHECK(HasWasmExportedFunctionData());
return wasm_exported_function_data().wrapper_code();
} else if (data.IsInterpreterData()) {
}
if (data.IsWasmJSFunctionData()) {
return wasm_js_function_data().wrapper_code();
}
if (data.IsWasmCapiFunctionData()) {
return wasm_capi_function_data().wrapper_code();
}
#endif // V8_ENABLE_WEBASSEMBLY
if (data.IsUncompiledData()) {
// Having uncompiled data (with or without scope) means we need to compile.
DCHECK(HasUncompiledData());
return isolate->builtins()->builtin(Builtins::kCompileLazy);
}
if (data.IsFunctionTemplateInfo()) {
// Having a function template info means we are an API function.
DCHECK(IsApiFunction());
return isolate->builtins()->builtin(Builtins::kHandleApiCall);
}
if (data.IsInterpreterData()) {
Code code = InterpreterTrampoline();
DCHECK(code.IsCode());
DCHECK(code.is_interpreter_trampoline_builtin());
return code;
} else if (data.IsWasmJSFunctionData()) {
return wasm_js_function_data().wrapper_code();
} else if (data.IsWasmCapiFunctionData()) {
return wasm_capi_function_data().wrapper_code();
}
UNREACHABLE();
}
#if V8_ENABLE_WEBASSEMBLY
WasmExportedFunctionData SharedFunctionInfo::wasm_exported_function_data()
const {
DCHECK(HasWasmExportedFunctionData());
@ -130,6 +142,7 @@ WasmCapiFunctionData SharedFunctionInfo::wasm_capi_function_data() const {
DCHECK(HasWasmCapiFunctionData());
return WasmCapiFunctionData::cast(function_data(kAcquireLoad));
}
#endif // V8_ENABLE_WEBASSEMBLY
SharedFunctionInfo::ScriptIterator::ScriptIterator(Isolate* isolate,
Script script)
@ -238,10 +251,12 @@ CoverageInfo SharedFunctionInfo::GetCoverageInfo() const {
}
std::unique_ptr<char[]> SharedFunctionInfo::DebugNameCStr() {
#if V8_ENABLE_WEBASSEMBLY
if (HasWasmExportedFunctionData()) {
return WasmExportedFunction::GetDebugName(
wasm_exported_function_data().sig());
}
#endif // V8_ENABLE_WEBASSEMBLY
DisallowGarbageCollection no_gc;
String function_name = Name();
if (function_name.length() == 0) function_name = inferred_name();
@ -251,12 +266,14 @@ std::unique_ptr<char[]> SharedFunctionInfo::DebugNameCStr() {
// static
Handle<String> SharedFunctionInfo::DebugName(
Handle<SharedFunctionInfo> shared) {
#if V8_ENABLE_WEBASSEMBLY
if (shared->HasWasmExportedFunctionData()) {
return shared->GetIsolate()
->factory()
->NewStringFromUtf8(CStrVector(shared->DebugNameCStr().get()))
.ToHandleChecked();
}
#endif // V8_ENABLE_WEBASSEMBLY
DisallowHeapAllocation no_gc;
String function_name = shared->Name();
if (function_name.length() == 0) function_name = shared->inferred_name();
@ -597,12 +614,14 @@ int SharedFunctionInfo::StartPosition() const {
DCHECK_IMPLIES(HasBuiltinId(), builtin_id() != Builtins::kCompileLazy);
return 0;
}
#if V8_ENABLE_WEBASSEMBLY
if (HasWasmExportedFunctionData()) {
WasmInstanceObject instance = wasm_exported_function_data().instance();
int func_index = wasm_exported_function_data().function_index();
auto& function = instance.module()->functions[func_index];
return static_cast<int>(function.code.offset());
}
#endif // V8_ENABLE_WEBASSEMBLY
return kNoSourcePosition;
}
@ -622,12 +641,14 @@ int SharedFunctionInfo::EndPosition() const {
DCHECK_IMPLIES(HasBuiltinId(), builtin_id() != Builtins::kCompileLazy);
return 0;
}
#if V8_ENABLE_WEBASSEMBLY
if (HasWasmExportedFunctionData()) {
WasmInstanceObject instance = wasm_exported_function_data().instance();
int func_index = wasm_exported_function_data().function_index();
auto& function = instance.module()->functions[func_index];
return static_cast<int>(function.code.end_offset());
}
#endif // V8_ENABLE_WEBASSEMBLY
return kNoSourcePosition;
}

View File

@ -18,7 +18,6 @@
#include "src/objects/smi.h"
#include "src/objects/struct.h"
#include "src/roots/roots.h"
#include "src/wasm/value-type.h"
#include "testing/gtest/include/gtest/gtest_prod.h" // nogncheck
#include "torque-generated/bit-fields.h"
#include "torque-generated/field-offsets.h"
@ -43,6 +42,8 @@ class WasmJSFunctionData;
namespace wasm {
struct WasmModule;
class ValueType;
using FunctionSig = Signature<ValueType>;
} // namespace wasm
#include "torque-generated/src/objects/shared-function-info-tq.inc"
@ -314,10 +315,24 @@ class SharedFunctionInfo
inline void flush_baseline_data();
inline BytecodeArray GetActiveBytecodeArray() const;
inline void SetActiveBytecodeArray(BytecodeArray bytecode);
#if V8_ENABLE_WEBASSEMBLY
inline bool HasAsmWasmData() const;
inline bool HasWasmExportedFunctionData() const;
inline bool HasWasmJSFunctionData() const;
inline bool HasWasmCapiFunctionData() const;
inline AsmWasmData asm_wasm_data() const;
inline void set_asm_wasm_data(AsmWasmData data);
V8_EXPORT_PRIVATE WasmExportedFunctionData
wasm_exported_function_data() const;
WasmJSFunctionData wasm_js_function_data() const;
WasmCapiFunctionData wasm_capi_function_data() const;
inline const wasm::WasmModule* wasm_module() const;
inline const wasm::FunctionSig* wasm_function_signature() const;
#endif // V8_ENABLE_WEBASSEMBLY
// builtin_id corresponds to the auto-generated Builtins::Name id.
inline bool HasBuiltinId() const;
inline int builtin_id() const;
@ -331,16 +346,6 @@ class SharedFunctionInfo
inline void set_uncompiled_data_with_preparse_data(
UncompiledDataWithPreparseData data);
inline bool HasUncompiledDataWithoutPreparseData() const;
inline bool HasWasmExportedFunctionData() const;
V8_EXPORT_PRIVATE WasmExportedFunctionData
wasm_exported_function_data() const;
inline bool HasWasmJSFunctionData() const;
WasmJSFunctionData wasm_js_function_data() const;
inline bool HasWasmCapiFunctionData() const;
WasmCapiFunctionData wasm_capi_function_data() const;
inline const wasm::WasmModule* wasm_module() const;
inline const wasm::FunctionSig* wasm_function_signature() const;
// Clear out pre-parsed scope data from UncompiledDataWithPreparseData,
// turning it into UncompiledDataWithoutPreparseData.
@ -446,8 +451,10 @@ class SharedFunctionInfo
// global object.
DECL_BOOLEAN_ACCESSORS(native)
#if V8_ENABLE_WEBASSEMBLY
// Indicates that asm->wasm conversion failed and should not be re-attempted.
DECL_BOOLEAN_ACCESSORS(is_asm_wasm_broken)
#endif // V8_ENABLE_WEBASSEMBLY
// Indicates that the function was created by the Function function.
// Though it's anonymous, toString should treat it as if it had the name

View File

@ -22,12 +22,14 @@ namespace internal {
TQ_OBJECT_CONSTRUCTORS_IMPL(StackFrameInfo)
NEVER_READ_ONLY_SPACE_IMPL(StackFrameInfo)
#if V8_ENABLE_WEBASSEMBLY
BOOL_GETTER(StackFrameInfo, flags, IsWasm, IsWasmBit::kShift)
BOOL_GETTER(StackFrameInfo, flags, IsAsmJsWasm, IsAsmJsWasmBit::kShift)
BOOL_GETTER(StackFrameInfo, flags, IsStrict, IsStrictBit::kShift)
BOOL_GETTER(StackFrameInfo, flags, IsConstructor, IsConstructorBit::kShift)
BOOL_GETTER(StackFrameInfo, flags, IsAsmJsAtNumberConversion,
IsAsmJsAtNumberConversionBit::kShift)
#endif // V8_ENABLE_WEBASSEMBLY
BOOL_GETTER(StackFrameInfo, flags, IsStrict, IsStrictBit::kShift)
BOOL_GETTER(StackFrameInfo, flags, IsConstructor, IsConstructorBit::kShift)
BOOL_GETTER(StackFrameInfo, flags, IsAsync, IsAsyncBit::kShift)
} // namespace internal

View File

@ -38,11 +38,17 @@ bool StackFrameInfo::IsEval() const {
}
bool StackFrameInfo::IsUserJavaScript() const {
return !IsWasm() && GetSharedFunctionInfo().IsUserJavaScript();
#if V8_ENABLE_WEBASSEMBLY
if (IsWasm()) return false;
#endif // V8_ENABLE_WEBASSEMBLY
return GetSharedFunctionInfo().IsUserJavaScript();
}
bool StackFrameInfo::IsMethodCall() const {
return !IsWasm() && !IsToplevel() && !IsConstructor();
#if V8_ENABLE_WEBASSEMBLY
if (IsWasm()) return false;
#endif // V8_ENABLE_WEBASSEMBLY
return !IsToplevel() && !IsConstructor();
}
bool StackFrameInfo::IsToplevel() const {
@ -53,9 +59,11 @@ bool StackFrameInfo::IsToplevel() const {
// static
int StackFrameInfo::GetLineNumber(Handle<StackFrameInfo> info) {
Isolate* isolate = info->GetIsolate();
#if V8_ENABLE_WEBASSEMBLY
if (info->IsWasm() && !info->IsAsmJsWasm()) {
return 1;
}
#endif // V8_ENABLE_WEBASSEMBLY
Handle<Script> script;
if (GetScript(isolate, info).ToHandle(&script)) {
int position = GetSourcePosition(info);
@ -68,9 +76,11 @@ int StackFrameInfo::GetLineNumber(Handle<StackFrameInfo> info) {
int StackFrameInfo::GetColumnNumber(Handle<StackFrameInfo> info) {
Isolate* isolate = info->GetIsolate();
int position = GetSourcePosition(info);
#if V8_ENABLE_WEBASSEMBLY
if (info->IsWasm() && !info->IsAsmJsWasm()) {
return position + 1;
}
#endif // V8_ENABLE_WEBASSEMBLY
Handle<Script> script;
if (GetScript(isolate, info).ToHandle(&script)) {
return Script::GetColumnNumber(script, position) + 1;
@ -81,47 +91,53 @@ int StackFrameInfo::GetColumnNumber(Handle<StackFrameInfo> info) {
// static
int StackFrameInfo::GetEnclosingLineNumber(Handle<StackFrameInfo> info) {
Isolate* isolate = info->GetIsolate();
#if V8_ENABLE_WEBASSEMBLY
if (info->IsWasm() && !info->IsAsmJsWasm()) {
return 1;
}
#endif // V8_ENABLE_WEBASSEMBLY
Handle<Script> script;
if (GetScript(isolate, info).ToHandle(&script)) {
int position;
if (info->IsAsmJsWasm()) {
auto module = info->GetWasmInstance().module();
auto func_index = info->GetWasmFunctionIndex();
position = wasm::GetSourcePosition(module, func_index, 0,
info->IsAsmJsAtNumberConversion());
} else {
position = info->GetSharedFunctionInfo().function_token_position();
}
if (!GetScript(isolate, info).ToHandle(&script)) {
return Message::kNoLineNumberInfo;
}
#if V8_ENABLE_WEBASSEMBLY
if (info->IsAsmJsWasm()) {
auto module = info->GetWasmInstance().module();
auto func_index = info->GetWasmFunctionIndex();
int position = wasm::GetSourcePosition(module, func_index, 0,
info->IsAsmJsAtNumberConversion());
return Script::GetLineNumber(script, position) + 1;
}
return Message::kNoLineNumberInfo;
#endif // V8_ENABLE_WEBASSEMBLY
int position = info->GetSharedFunctionInfo().function_token_position();
return Script::GetLineNumber(script, position) + 1;
}
// static
int StackFrameInfo::GetEnclosingColumnNumber(Handle<StackFrameInfo> info) {
Isolate* isolate = info->GetIsolate();
#if V8_ENABLE_WEBASSEMBLY
if (info->IsWasm() && !info->IsAsmJsWasm()) {
auto module = info->GetWasmInstance().module();
auto func_index = info->GetWasmFunctionIndex();
return GetWasmFunctionOffset(module, func_index);
}
#endif // V8_ENABLE_WEBASSEMBLY
Handle<Script> script;
if (GetScript(isolate, info).ToHandle(&script)) {
int position;
if (info->IsAsmJsWasm()) {
auto module = info->GetWasmInstance().module();
auto func_index = info->GetWasmFunctionIndex();
position = wasm::GetSourcePosition(module, func_index, 0,
info->IsAsmJsAtNumberConversion());
} else {
position = info->GetSharedFunctionInfo().function_token_position();
}
if (!GetScript(isolate, info).ToHandle(&script)) {
return Message::kNoColumnInfo;
}
#if V8_ENABLE_WEBASSEMBLY
if (info->IsAsmJsWasm()) {
auto module = info->GetWasmInstance().module();
auto func_index = info->GetWasmFunctionIndex();
int position = wasm::GetSourcePosition(module, func_index, 0,
info->IsAsmJsAtNumberConversion());
return Script::GetColumnNumber(script, position) + 1;
}
return Message::kNoColumnInfo;
#endif // V8_ENABLE_WEBASSEMBLY
int position = info->GetSharedFunctionInfo().function_token_position();
return Script::GetColumnNumber(script, position) + 1;
}
int StackFrameInfo::GetScriptId() const {
@ -229,6 +245,7 @@ Handle<PrimitiveHeapObject> StackFrameInfo::GetEvalOrigin(
// static
Handle<Object> StackFrameInfo::GetFunctionName(Handle<StackFrameInfo> info) {
Isolate* isolate = info->GetIsolate();
#if V8_ENABLE_WEBASSEMBLY
if (info->IsWasm()) {
Handle<WasmModuleObject> module_object(
info->GetWasmInstance().module_object(), isolate);
@ -239,12 +256,13 @@ Handle<Object> StackFrameInfo::GetFunctionName(Handle<StackFrameInfo> info) {
.ToHandle(&name)) {
return name;
}
} else {
Handle<JSFunction> function(JSFunction::cast(info->function()), isolate);
Handle<String> name = JSFunction::GetDebugName(function);
if (name->length() != 0) return name;
if (info->IsEval()) return isolate->factory()->eval_string();
return isolate->factory()->null_value();
}
#endif // V8_ENABLE_WEBASSEMBLY
Handle<JSFunction> function(JSFunction::cast(info->function()), isolate);
Handle<String> name = JSFunction::GetDebugName(function);
if (name->length() != 0) return name;
if (info->IsEval()) return isolate->factory()->eval_string();
return isolate->factory()->null_value();
}
@ -344,7 +362,10 @@ PrimitiveHeapObject InferMethodName(Isolate* isolate, JSReceiver receiver,
Handle<Object> StackFrameInfo::GetMethodName(Handle<StackFrameInfo> info) {
Isolate* isolate = info->GetIsolate();
Handle<Object> receiver_or_instance(info->receiver_or_instance(), isolate);
if (info->IsWasm() || receiver_or_instance->IsNullOrUndefined(isolate)) {
#if V8_ENABLE_WEBASSEMBLY
if (info->IsWasm()) return isolate->factory()->null_value();
#endif // V8_ENABLE_WEBASSEMBLY
if (receiver_or_instance->IsNullOrUndefined(isolate)) {
return isolate->factory()->null_value();
}
@ -419,6 +440,7 @@ Handle<Object> StackFrameInfo::GetTypeName(Handle<StackFrameInfo> info) {
return JSReceiver::GetConstructorName(receiver);
}
#if V8_ENABLE_WEBASSEMBLY
uint32_t StackFrameInfo::GetWasmFunctionIndex() const {
DCHECK(IsWasm());
return Smi::ToInt(Smi::cast(function()));
@ -429,6 +451,22 @@ WasmInstanceObject StackFrameInfo::GetWasmInstance() const {
return WasmInstanceObject::cast(receiver_or_instance());
}
// static
Handle<Object> StackFrameInfo::GetWasmModuleName(Handle<StackFrameInfo> info) {
Isolate* isolate = info->GetIsolate();
if (info->IsWasm()) {
Handle<String> name;
auto module_object =
handle(info->GetWasmInstance().module_object(), isolate);
if (WasmModuleObject::GetModuleNameOrNull(isolate, module_object)
.ToHandle(&name)) {
return name;
}
}
return isolate->factory()->null_value();
}
#endif // V8_ENABLE_WEBASSEMBLY
// static
int StackFrameInfo::GetSourcePosition(Handle<StackFrameInfo> info) {
if (info->flags() & kIsSourcePositionComputed) {
@ -447,6 +485,7 @@ int StackFrameInfo::GetSourcePosition(Handle<StackFrameInfo> info) {
bool StackFrameInfo::ComputeLocation(Handle<StackFrameInfo> info,
MessageLocation* location) {
Isolate* isolate = info->GetIsolate();
#if V8_ENABLE_WEBASSEMBLY
if (info->IsWasm()) {
int pos = GetSourcePosition(info);
Handle<Script> script(info->GetWasmInstance().module_object().script(),
@ -454,6 +493,7 @@ bool StackFrameInfo::ComputeLocation(Handle<StackFrameInfo> info,
*location = MessageLocation(script, pos, pos + 1);
return true;
}
#endif // V8_ENABLE_WEBASSEMBLY
Handle<SharedFunctionInfo> shared(info->GetSharedFunctionInfo(), isolate);
if (!shared->IsSubjectToDebugging()) return false;
@ -475,6 +515,7 @@ bool StackFrameInfo::ComputeLocation(Handle<StackFrameInfo> info,
int StackFrameInfo::ComputeSourcePosition(Handle<StackFrameInfo> info,
int offset) {
Isolate* isolate = info->GetIsolate();
#if V8_ENABLE_WEBASSEMBLY
if (info->IsWasm()) {
auto code_ref = Managed<wasm::GlobalWasmCodeRef>::cast(info->code_object());
int byte_offset = code_ref.get()->code()->GetSourcePositionBefore(offset);
@ -483,37 +524,27 @@ int StackFrameInfo::ComputeSourcePosition(Handle<StackFrameInfo> info,
return wasm::GetSourcePosition(module, func_index, byte_offset,
info->IsAsmJsAtNumberConversion());
}
#endif // V8_ENABLE_WEBASSEMBLY
Handle<SharedFunctionInfo> shared(info->GetSharedFunctionInfo(), isolate);
SharedFunctionInfo::EnsureSourcePositionsAvailable(isolate, shared);
return AbstractCode::cast(info->code_object()).SourcePosition(offset);
}
// static
Handle<Object> StackFrameInfo::GetWasmModuleName(Handle<StackFrameInfo> info) {
Isolate* isolate = info->GetIsolate();
if (info->IsWasm()) {
Handle<String> name;
auto module_object =
handle(info->GetWasmInstance().module_object(), isolate);
if (WasmModuleObject::GetModuleNameOrNull(isolate, module_object)
.ToHandle(&name)) {
return name;
}
}
return isolate->factory()->null_value();
}
base::Optional<Script> StackFrameInfo::GetScript() const {
#if V8_ENABLE_WEBASSEMBLY
if (IsWasm()) {
return GetWasmInstance().module_object().script();
}
#endif // V8_ENABLE_WEBASSEMBLY
Object script = GetSharedFunctionInfo().script();
if (script.IsScript()) return Script::cast(script);
return base::nullopt;
}
SharedFunctionInfo StackFrameInfo::GetSharedFunctionInfo() const {
#if V8_ENABLE_WEBASSEMBLY
DCHECK(!IsWasm());
#endif // V8_ENABLE_WEBASSEMBLY
return JSFunction::cast(function()).shared();
}
@ -675,6 +706,7 @@ void SerializeJSStackFrame(Isolate* isolate, Handle<StackFrameInfo> frame,
builder->AppendCString(")");
}
#if V8_ENABLE_WEBASSEMBLY
bool IsAnonymousWasmScript(Isolate* isolate, Handle<Object> url) {
Handle<String> prefix =
isolate->factory()->NewStringFromStaticChars("wasm://wasm/");
@ -719,19 +751,19 @@ void SerializeWasmStackFrame(Isolate* isolate, Handle<StackFrameInfo> frame,
if (has_name) builder->AppendCString(")");
}
#endif // V8_ENABLE_WEBASSEMBLY
} // namespace
void SerializeStackFrameInfo(Isolate* isolate, Handle<StackFrameInfo> frame,
IncrementalStringBuilder* builder) {
// Ordering here is important, as AsmJs frames are also marked as Wasm.
if (frame->IsAsmJsWasm()) {
SerializeJSStackFrame(isolate, frame, builder);
} else if (frame->IsWasm()) {
#if V8_ENABLE_WEBASSEMBLY
if (frame->IsWasm() && !frame->IsAsmJsWasm()) {
SerializeWasmStackFrame(isolate, frame, builder);
} else {
SerializeJSStackFrame(isolate, frame, builder);
return;
}
#endif // V8_ENABLE_WEBASSEMBLY
SerializeJSStackFrame(isolate, frame, builder);
}
MaybeHandle<String> SerializeStackFrameInfo(Isolate* isolate,

View File

@ -24,11 +24,14 @@ class StackFrameInfo
public:
NEVER_READ_ONLY_SPACE
#if V8_ENABLE_WEBASSEMBLY
inline bool IsWasm() const;
inline bool IsAsmJsWasm() const;
inline bool IsAsmJsAtNumberConversion() const;
#endif // V8_ENABLE_WEBASSEMBLY
inline bool IsStrict() const;
inline bool IsConstructor() const;
inline bool IsAsmJsAtNumberConversion() const;
inline bool IsAsync() const;
bool IsEval() const;
bool IsUserJavaScript() const;
@ -64,10 +67,12 @@ class StackFrameInfo
static Handle<Object> GetMethodName(Handle<StackFrameInfo> info);
static Handle<Object> GetTypeName(Handle<StackFrameInfo> info);
#if V8_ENABLE_WEBASSEMBLY
// These methods are only valid for Wasm and asm.js Wasm frames.
uint32_t GetWasmFunctionIndex() const;
WasmInstanceObject GetWasmInstance() const;
static Handle<Object> GetWasmModuleName(Handle<StackFrameInfo> info);
#endif // V8_ENABLE_WEBASSEMBLY
// Returns the 0-based source position, which is the offset into the
// Script in case of JavaScript and Asm.js, and the bytecode offset

View File

@ -18,6 +18,7 @@
#include "src/heap/factory.h"
#include "src/numbers/conversions.h"
#include "src/objects/heap-number-inl.h"
#include "src/objects/js-array-buffer-inl.h"
#include "src/objects/js-array-inl.h"
#include "src/objects/js-collection-inl.h"
#include "src/objects/js-regexp-inl.h"
@ -30,10 +31,10 @@
#include "src/objects/smi.h"
#include "src/objects/transitions-inl.h"
#include "src/snapshot/code-serializer.h"
#include "src/wasm/wasm-engine.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-objects-inl.h"
#include "src/wasm/wasm-result.h"
#include "src/wasm/wasm-serialization.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {
@ -571,6 +572,7 @@ Maybe<bool> ValueSerializer::WriteJSReceiver(Handle<JSReceiver> receiver) {
return WriteJSArrayBufferView(JSArrayBufferView::cast(*receiver));
case JS_ERROR_TYPE:
return WriteJSError(Handle<JSObject>::cast(receiver));
#if V8_ENABLE_WEBASSEMBLY
case WASM_MODULE_OBJECT_TYPE:
return WriteWasmModule(Handle<WasmModuleObject>::cast(receiver));
case WASM_MEMORY_OBJECT_TYPE: {
@ -580,6 +582,7 @@ Maybe<bool> ValueSerializer::WriteJSReceiver(Handle<JSReceiver> receiver) {
}
break;
}
#endif // V8_ENABLE_WEBASSEMBLY
default:
break;
}
@ -983,6 +986,7 @@ Maybe<bool> ValueSerializer::WriteJSError(Handle<JSObject> error) {
return ThrowIfOutOfMemory();
}
#if V8_ENABLE_WEBASSEMBLY
Maybe<bool> ValueSerializer::WriteWasmModule(Handle<WasmModuleObject> object) {
if (delegate_ == nullptr) {
ThrowDataCloneError(MessageTemplate::kDataCloneError, object);
@ -1017,6 +1021,7 @@ Maybe<bool> ValueSerializer::WriteWasmMemory(Handle<WasmMemoryObject> object) {
WriteZigZag<int32_t>(object->maximum_pages());
return WriteJSReceiver(Handle<JSReceiver>(object->array_buffer(), isolate_));
}
#endif // V8_ENABLE_WEBASSEMBLY
Maybe<bool> ValueSerializer::WriteHostObject(Handle<JSObject> object) {
WriteTag(SerializationTag::kHostObject);
@ -1341,10 +1346,12 @@ MaybeHandle<Object> ValueDeserializer::ReadObjectInternal() {
}
case SerializationTag::kError:
return ReadJSError();
#if V8_ENABLE_WEBASSEMBLY
case SerializationTag::kWasmModuleTransfer:
return ReadWasmModuleTransfer();
case SerializationTag::kWasmMemoryTransfer:
return ReadWasmMemory();
#endif // V8_ENABLE_WEBASSEMBLY
case SerializationTag::kHostObject:
return ReadHostObject();
default:
@ -1927,6 +1934,7 @@ MaybeHandle<Object> ValueDeserializer::ReadJSError() {
return error;
}
#if V8_ENABLE_WEBASSEMBLY
MaybeHandle<JSObject> ValueDeserializer::ReadWasmModuleTransfer() {
uint32_t transfer_id = 0;
Local<Value> module_value;
@ -1975,6 +1983,7 @@ MaybeHandle<WasmMemoryObject> ValueDeserializer::ReadWasmMemory() {
AddObjectWithID(id, result);
return result;
}
#endif // V8_ENABLE_WEBASSEMBLY
MaybeHandle<JSObject> ValueDeserializer::ReadHostObject() {
if (!delegate_) return MaybeHandle<JSObject>();

View File

@ -129,10 +129,12 @@ class ValueSerializer {
V8_WARN_UNUSED_RESULT;
Maybe<bool> WriteJSArrayBufferView(JSArrayBufferView array_buffer);
Maybe<bool> WriteJSError(Handle<JSObject> error) V8_WARN_UNUSED_RESULT;
#if V8_ENABLE_WEBASSEMBLY
Maybe<bool> WriteWasmModule(Handle<WasmModuleObject> object)
V8_WARN_UNUSED_RESULT;
Maybe<bool> WriteWasmMemory(Handle<WasmMemoryObject> object)
V8_WARN_UNUSED_RESULT;
#endif // V8_ENABLE_WEBASSEMBLY
Maybe<bool> WriteHostObject(Handle<JSObject> object) V8_WARN_UNUSED_RESULT;
/*
@ -274,8 +276,10 @@ class ValueDeserializer {
MaybeHandle<JSArrayBufferView> ReadJSArrayBufferView(
Handle<JSArrayBuffer> buffer) V8_WARN_UNUSED_RESULT;
MaybeHandle<Object> ReadJSError() V8_WARN_UNUSED_RESULT;
#if V8_ENABLE_WEBASSEMBLY
MaybeHandle<JSObject> ReadWasmModuleTransfer() V8_WARN_UNUSED_RESULT;
MaybeHandle<WasmMemoryObject> ReadWasmMemory() V8_WARN_UNUSED_RESULT;
#endif // V8_ENABLE_WEBASSEMBLY
MaybeHandle<JSObject> ReadHostObject() V8_WARN_UNUSED_RESULT;
/*

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