Commit c87b273c authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[no-wasm] Remove wasm engine from isolate

This removes the {wasm_engine_} field from the isolate if
v8_enable_webassembly=false. This avoids any includes from src/wasm in
isolate.{h,cc}.
Unconditional access to the wasm engine in other parts are also #if'ed
out to avoid nullptr accesses.
Long-term, the {Isolate::wasm_engine()} method will be fully removed,
but this can only be done once src/wasm is excluded from compilation.

R=jkummerow@chromium.org, petermarshall@chromium.org

Bug: v8:11238
Change-Id: Ie3738884ec17ccc0a3027b91a2415c2c633ca774
Cq-Include-Trybots: luci.v8.try:v8_linux64_no_wasm_compile_rel
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2737298Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73230}
parent c1908c13
...@@ -23,8 +23,11 @@ ...@@ -23,8 +23,11 @@
#include "src/snapshot/embedded/embedded-data.h" #include "src/snapshot/embedded/embedded-data.h"
#include "src/strings/string-stream.h" #include "src/strings/string-stream.h"
#include "src/utils/vector.h" #include "src/utils/vector.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-code-manager.h" #include "src/wasm/wasm-code-manager.h"
#include "src/wasm/wasm-engine.h" #include "src/wasm/wasm-engine.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -94,6 +97,7 @@ const char* V8NameConverter::NameOfAddress(byte* pc) const { ...@@ -94,6 +97,7 @@ const char* V8NameConverter::NameOfAddress(byte* pc) const {
return v8_buffer_.begin(); return v8_buffer_.begin();
} }
#if V8_ENABLE_WEBASSEMBLY
wasm::WasmCodeRefScope wasm_code_ref_scope; wasm::WasmCodeRefScope wasm_code_ref_scope;
wasm::WasmCode* wasm_code = wasm::WasmCode* wasm_code =
isolate_ ? isolate_->wasm_engine()->code_manager()->LookupCode( isolate_ ? isolate_->wasm_engine()->code_manager()->LookupCode(
...@@ -104,6 +108,7 @@ const char* V8NameConverter::NameOfAddress(byte* pc) const { ...@@ -104,6 +108,7 @@ const char* V8NameConverter::NameOfAddress(byte* pc) const {
wasm::GetWasmCodeKindAsString(wasm_code->kind())); wasm::GetWasmCodeKindAsString(wasm_code->kind()));
return v8_buffer_.begin(); return v8_buffer_.begin();
} }
#endif // V8_ENABLE_WEBASSEMBLY
} }
return disasm::NameConverter::NameOfAddress(pc); return disasm::NameConverter::NameOfAddress(pc);
...@@ -247,12 +252,14 @@ static void PrintRelocInfo(StringBuilder* out, Isolate* isolate, ...@@ -247,12 +252,14 @@ static void PrintRelocInfo(StringBuilder* out, Isolate* isolate,
} else { } else {
out->AddFormatted(" %s", CodeKindToString(kind)); out->AddFormatted(" %s", CodeKindToString(kind));
} }
#if V8_ENABLE_WEBASSEMBLY
} else if (RelocInfo::IsWasmStubCall(rmode) && host.is_wasm_code()) { } else if (RelocInfo::IsWasmStubCall(rmode) && host.is_wasm_code()) {
// Host is isolate-independent, try wasm native module instead. // Host is isolate-independent, try wasm native module instead.
const char* runtime_stub_name = GetRuntimeStubName( const char* runtime_stub_name = GetRuntimeStubName(
host.as_wasm_code()->native_module()->GetRuntimeStubId( host.as_wasm_code()->native_module()->GetRuntimeStubId(
relocinfo->wasm_stub_call_address())); relocinfo->wasm_stub_call_address()));
out->AddFormatted(" ;; wasm stub: %s", runtime_stub_name); out->AddFormatted(" ;; wasm stub: %s", runtime_stub_name);
#endif // V8_ENABLE_WEBASSEMBLY
} else if (RelocInfo::IsRuntimeEntry(rmode) && isolate != nullptr) { } else if (RelocInfo::IsRuntimeEntry(rmode) && isolate != nullptr) {
// A runtime entry relocinfo might be a deoptimization bailout. // A runtime entry relocinfo might be a deoptimization bailout.
Address addr = relocinfo->target_address(); Address addr = relocinfo->target_address();
......
...@@ -561,12 +561,13 @@ StackFrame::Type StackFrame::ComputeType(const StackFrameIteratorBase* iterator, ...@@ -561,12 +561,13 @@ StackFrame::Type StackFrame::ComputeType(const StackFrameIteratorBase* iterator,
} }
} }
} else { } else {
#if V8_ENABLE_WEBASSEMBLY
// If the {pc} does not point into WebAssembly code we can rely on the // If the {pc} does not point into WebAssembly code we can rely on the
// returned {wasm_code} to be null and fall back to {GetContainingCode}. // returned {wasm_code} to be null and fall back to {GetContainingCode}.
wasm::WasmCodeRefScope code_ref_scope; wasm::WasmCodeRefScope code_ref_scope;
wasm::WasmCode* wasm_code = if (wasm::WasmCode* wasm_code =
iterator->isolate()->wasm_engine()->code_manager()->LookupCode(pc); iterator->isolate()->wasm_engine()->code_manager()->LookupCode(
if (wasm_code != nullptr) { pc)) {
switch (wasm_code->kind()) { switch (wasm_code->kind()) {
case wasm::WasmCode::kFunction: case wasm::WasmCode::kFunction:
return WASM; return WASM;
...@@ -577,52 +578,53 @@ StackFrame::Type StackFrame::ComputeType(const StackFrameIteratorBase* iterator, ...@@ -577,52 +578,53 @@ StackFrame::Type StackFrame::ComputeType(const StackFrameIteratorBase* iterator,
default: default:
UNREACHABLE(); UNREACHABLE();
} }
} else { }
// Look up the code object to figure out the type of the stack frame. #endif // V8_ENABLE_WEBASSEMBLY
Code code_obj = GetContainingCode(iterator->isolate(), pc);
if (!code_obj.is_null()) { // Look up the code object to figure out the type of the stack frame.
switch (code_obj.kind()) { Code code_obj = GetContainingCode(iterator->isolate(), pc);
case CodeKind::BUILTIN: if (!code_obj.is_null()) {
if (StackFrame::IsTypeMarker(marker)) break; switch (code_obj.kind()) {
if (code_obj.is_interpreter_trampoline_builtin()) { case CodeKind::BUILTIN:
return INTERPRETED; if (StackFrame::IsTypeMarker(marker)) break;
} if (code_obj.is_interpreter_trampoline_builtin()) {
if (code_obj.is_baseline_leave_frame_builtin()) { return INTERPRETED;
return BASELINE; }
} if (code_obj.is_baseline_leave_frame_builtin()) {
if (code_obj.is_turbofanned()) { return BASELINE;
// TODO(bmeurer): We treat frames for BUILTIN Code objects as }
// OptimizedFrame for now (all the builtins with JavaScript if (code_obj.is_turbofanned()) {
// linkage are actually generated with TurboFan currently, so // TODO(bmeurer): We treat frames for BUILTIN Code objects as
// this is sound). // OptimizedFrame for now (all the builtins with JavaScript
return OPTIMIZED; // linkage are actually generated with TurboFan currently, so
} // this is sound).
return BUILTIN;
case CodeKind::TURBOFAN:
case CodeKind::NATIVE_CONTEXT_INDEPENDENT:
case CodeKind::TURBOPROP:
return OPTIMIZED; return OPTIMIZED;
case CodeKind::BASELINE: }
return Type::BASELINE; return BUILTIN;
case CodeKind::JS_TO_WASM_FUNCTION: case CodeKind::TURBOFAN:
return JS_TO_WASM; case CodeKind::NATIVE_CONTEXT_INDEPENDENT:
case CodeKind::JS_TO_JS_FUNCTION: case CodeKind::TURBOPROP:
return STUB; return OPTIMIZED;
case CodeKind::C_WASM_ENTRY: case CodeKind::BASELINE:
return C_WASM_ENTRY; return Type::BASELINE;
case CodeKind::WASM_TO_JS_FUNCTION: case CodeKind::JS_TO_WASM_FUNCTION:
return WASM_TO_JS; return JS_TO_WASM;
case CodeKind::WASM_FUNCTION: case CodeKind::JS_TO_JS_FUNCTION:
case CodeKind::WASM_TO_CAPI_FUNCTION: return STUB;
// Never appear as on-heap {Code} objects. case CodeKind::C_WASM_ENTRY:
UNREACHABLE(); return C_WASM_ENTRY;
default: case CodeKind::WASM_TO_JS_FUNCTION:
// All other types should have an explicit marker return WASM_TO_JS;
break; case CodeKind::WASM_FUNCTION:
} case CodeKind::WASM_TO_CAPI_FUNCTION:
} else { // Never appear as on-heap {Code} objects.
return NATIVE; UNREACHABLE();
default:
// All other types should have an explicit marker
break;
} }
} else {
return NATIVE;
} }
} }
DCHECK(StackFrame::IsTypeMarker(marker)); DCHECK(StackFrame::IsTypeMarker(marker));
...@@ -911,14 +913,17 @@ void CommonFrame::IterateCompiledFrame(RootVisitor* v) const { ...@@ -911,14 +913,17 @@ void CommonFrame::IterateCompiledFrame(RootVisitor* v) const {
// Find the code and compute the safepoint information. // Find the code and compute the safepoint information.
Address inner_pointer = pc(); Address inner_pointer = pc();
const wasm::WasmCode* wasm_code =
isolate()->wasm_engine()->code_manager()->LookupCode(inner_pointer);
SafepointEntry safepoint_entry; SafepointEntry safepoint_entry;
uint32_t stack_slots; uint32_t stack_slots = 0;
Code code; Code code;
bool has_tagged_outgoing_params = false; bool has_tagged_outgoing_params = false;
uint32_t tagged_parameter_slots = 0; uint32_t tagged_parameter_slots = 0;
if (wasm_code != nullptr) { bool is_wasm = false;
#if V8_ENABLE_WEBASSEMBLY
if (auto* wasm_code =
isolate()->wasm_engine()->code_manager()->LookupCode(inner_pointer)) {
is_wasm = true;
SafepointTable table(wasm_code); SafepointTable table(wasm_code);
safepoint_entry = table.FindEntry(inner_pointer); safepoint_entry = table.FindEntry(inner_pointer);
stack_slots = wasm_code->stack_slots(); stack_slots = wasm_code->stack_slots();
...@@ -926,7 +931,10 @@ void CommonFrame::IterateCompiledFrame(RootVisitor* v) const { ...@@ -926,7 +931,10 @@ void CommonFrame::IterateCompiledFrame(RootVisitor* v) const {
wasm_code->kind() != wasm::WasmCode::kFunction && wasm_code->kind() != wasm::WasmCode::kFunction &&
wasm_code->kind() != wasm::WasmCode::kWasmToCapiWrapper; wasm_code->kind() != wasm::WasmCode::kWasmToCapiWrapper;
tagged_parameter_slots = wasm_code->tagged_parameter_slots(); tagged_parameter_slots = wasm_code->tagged_parameter_slots();
} else { }
#endif // V8_ENABLE_WEBASSEMBLY
if (!is_wasm) {
InnerPointerToCodeCache::InnerPointerToCodeCacheEntry* entry = InnerPointerToCodeCache::InnerPointerToCodeCacheEntry* entry =
isolate()->inner_pointer_to_code_cache()->GetCacheEntry(inner_pointer); isolate()->inner_pointer_to_code_cache()->GetCacheEntry(inner_pointer);
if (!entry->safepoint_entry.is_valid()) { if (!entry->safepoint_entry.is_valid()) {
...@@ -941,15 +949,17 @@ void CommonFrame::IterateCompiledFrame(RootVisitor* v) const { ...@@ -941,15 +949,17 @@ void CommonFrame::IterateCompiledFrame(RootVisitor* v) const {
safepoint_entry = entry->safepoint_entry; safepoint_entry = entry->safepoint_entry;
stack_slots = code.stack_slots(); stack_slots = code.stack_slots();
has_tagged_outgoing_params = code.has_tagged_outgoing_params();
#if V8_ENABLE_WEBASSEMBLY
// With inlined JS-to-Wasm calls, we can be in an OptimizedFrame and // With inlined JS-to-Wasm calls, we can be in an OptimizedFrame and
// directly call a Wasm function from JavaScript. In this case the // directly call a Wasm function from JavaScript. In this case the
// parameters we pass to the callee are not tagged. // parameters we pass to the callee are not tagged.
wasm::WasmCode* wasm_callee = wasm::WasmCode* wasm_callee =
isolate()->wasm_engine()->code_manager()->LookupCode(callee_pc()); isolate()->wasm_engine()->code_manager()->LookupCode(callee_pc());
bool is_wasm_call = (wasm_callee != nullptr); bool is_wasm_call = (wasm_callee != nullptr);
if (is_wasm_call) has_tagged_outgoing_params = false;
has_tagged_outgoing_params = #endif // V8_ENABLE_WEBASSEMBLY
!is_wasm_call && code.has_tagged_outgoing_params();
} }
uint32_t slot_space = stack_slots * kSystemPointerSize; uint32_t slot_space = stack_slots * kSystemPointerSize;
...@@ -1808,6 +1818,7 @@ int BuiltinFrame::ComputeParametersCount() const { ...@@ -1808,6 +1818,7 @@ int BuiltinFrame::ComputeParametersCount() const {
void WasmFrame::Print(StringStream* accumulator, PrintMode mode, void WasmFrame::Print(StringStream* accumulator, PrintMode mode,
int index) const { int index) const {
wasm::WasmCodeRefScope code_ref_scope;
PrintIndex(accumulator, mode, index); PrintIndex(accumulator, mode, index);
accumulator->Add("WASM ["); accumulator->Add("WASM [");
accumulator->PrintName(script().name()); accumulator->PrintName(script().name());
......
...@@ -90,16 +90,19 @@ ...@@ -90,16 +90,19 @@
#include "src/utils/address-map.h" #include "src/utils/address-map.h"
#include "src/utils/ostreams.h" #include "src/utils/ostreams.h"
#include "src/utils/version.h" #include "src/utils/version.h"
#include "src/wasm/wasm-code-manager.h"
#include "src/wasm/wasm-engine.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-objects.h"
#include "src/zone/accounting-allocator.h" #include "src/zone/accounting-allocator.h"
#include "src/zone/type-stats.h" #include "src/zone/type-stats.h"
#ifdef V8_INTL_SUPPORT #ifdef V8_INTL_SUPPORT
#include "unicode/uobject.h" #include "unicode/uobject.h"
#endif // V8_INTL_SUPPORT #endif // V8_INTL_SUPPORT
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-code-manager.h"
#include "src/wasm/wasm-engine.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-objects.h"
#endif // V8_ENABLE_WEBASSEMBLY
#if defined(V8_OS_WIN64) #if defined(V8_OS_WIN64)
#include "src/diagnostics/unwinding-info-win64.h" #include "src/diagnostics/unwinding-info-win64.h"
#endif // V8_OS_WIN64 #endif // V8_OS_WIN64
...@@ -527,7 +530,9 @@ void Isolate::Iterate(RootVisitor* v, ThreadLocalTop* thread) { ...@@ -527,7 +530,9 @@ void Isolate::Iterate(RootVisitor* v, ThreadLocalTop* thread) {
#endif #endif
// Iterate over pointers on native execution stack. // Iterate over pointers on native execution stack.
#if V8_ENABLE_WEBASSEMBLY
wasm::WasmCodeRefScope wasm_code_ref_scope; wasm::WasmCodeRefScope wasm_code_ref_scope;
#endif // V8_ENABLE_WEBASSEMBLY
for (StackFrameIterator it(this, thread); !it.done(); it.Advance()) { for (StackFrameIterator it(this, thread); !it.done(); it.Advance()) {
it.frame()->Iterate(v); it.frame()->Iterate(v);
} }
...@@ -694,6 +699,7 @@ class StackTraceBuilder { ...@@ -694,6 +699,7 @@ class StackTraceBuilder {
summary.code_offset(), flags, summary.parameters()); summary.code_offset(), flags, summary.parameters());
} }
#if V8_ENABLE_WEBASSEMBLY
void AppendWasmFrame(FrameSummary::WasmFrameSummary const& summary) { void AppendWasmFrame(FrameSummary::WasmFrameSummary const& summary) {
if (summary.code()->kind() != wasm::WasmCode::kFunction) return; if (summary.code()->kind() != wasm::WasmCode::kFunction) return;
Handle<WasmInstanceObject> instance = summary.wasm_instance(); Handle<WasmInstanceObject> instance = summary.wasm_instance();
...@@ -713,6 +719,7 @@ class StackTraceBuilder { ...@@ -713,6 +719,7 @@ class StackTraceBuilder {
summary.code_offset(), flags, summary.code_offset(), flags,
isolate_->factory()->empty_fixed_array()); isolate_->factory()->empty_fixed_array());
} }
#endif // V8_ENABLE_WEBASSEMBLY
void AppendBuiltinExitFrame(BuiltinExitFrame* exit_frame) { void AppendBuiltinExitFrame(BuiltinExitFrame* exit_frame) {
Handle<JSFunction> function(exit_frame->function(), isolate_); Handle<JSFunction> function(exit_frame->function(), isolate_);
...@@ -1000,7 +1007,10 @@ Handle<FixedArray> CaptureStackTrace(Isolate* isolate, Handle<Object> caller, ...@@ -1000,7 +1007,10 @@ Handle<FixedArray> CaptureStackTrace(Isolate* isolate, Handle<Object> caller,
TRACE_EVENT_BEGIN1(TRACE_DISABLED_BY_DEFAULT("v8.stack_trace"), TRACE_EVENT_BEGIN1(TRACE_DISABLED_BY_DEFAULT("v8.stack_trace"),
"CaptureStackTrace", "maxFrameCount", options.limit); "CaptureStackTrace", "maxFrameCount", options.limit);
#if V8_ENABLE_WEBASSEMBLY
wasm::WasmCodeRefScope code_ref_scope; wasm::WasmCodeRefScope code_ref_scope;
#endif // V8_ENABLE_WEBASSEMBLY
StackTraceBuilder builder(isolate, options.skip_mode, options.limit, caller, StackTraceBuilder builder(isolate, options.skip_mode, options.limit, caller,
options.filter_mode); options.filter_mode);
...@@ -1017,7 +1027,10 @@ Handle<FixedArray> CaptureStackTrace(Isolate* isolate, Handle<Object> caller, ...@@ -1017,7 +1027,10 @@ Handle<FixedArray> CaptureStackTrace(Isolate* isolate, Handle<Object> caller,
case StackFrame::INTERPRETED: case StackFrame::INTERPRETED:
case StackFrame::BASELINE: case StackFrame::BASELINE:
case StackFrame::BUILTIN: case StackFrame::BUILTIN:
case StackFrame::WASM: { #if V8_ENABLE_WEBASSEMBLY
case StackFrame::WASM:
#endif // V8_ENABLE_WEBASSEMBLY
{
// A standard frame may include many summarized frames (due to // A standard frame may include many summarized frames (due to
// inlining). // inlining).
std::vector<FrameSummary> frames; std::vector<FrameSummary> frames;
...@@ -1035,12 +1048,14 @@ Handle<FixedArray> CaptureStackTrace(Isolate* isolate, Handle<Object> caller, ...@@ -1035,12 +1048,14 @@ Handle<FixedArray> CaptureStackTrace(Isolate* isolate, Handle<Object> caller,
//========================================================= //=========================================================
auto const& java_script = summary.AsJavaScript(); auto const& java_script = summary.AsJavaScript();
builder.AppendJavaScriptFrame(java_script); builder.AppendJavaScriptFrame(java_script);
#if V8_ENABLE_WEBASSEMBLY
} else if (summary.IsWasm()) { } else if (summary.IsWasm()) {
//========================================================= //=========================================================
// Handle a Wasm frame. // Handle a Wasm frame.
//========================================================= //=========================================================
auto const& wasm = summary.AsWasm(); auto const& wasm = summary.AsWasm();
builder.AppendWasmFrame(wasm); builder.AppendWasmFrame(wasm);
#endif // V8_ENABLE_WEBASSEMBLY
} }
} }
break; break;
...@@ -1275,7 +1290,6 @@ static void PrintFrames(Isolate* isolate, StringStream* accumulator, ...@@ -1275,7 +1290,6 @@ static void PrintFrames(Isolate* isolate, StringStream* accumulator,
void Isolate::PrintStack(StringStream* accumulator, PrintStackMode mode) { void Isolate::PrintStack(StringStream* accumulator, PrintStackMode mode) {
HandleScope scope(this); HandleScope scope(this);
wasm::WasmCodeRefScope wasm_code_ref_scope;
DCHECK(accumulator->IsMentionedObjectCacheClear(this)); DCHECK(accumulator->IsMentionedObjectCacheClear(this));
// Avoid printing anything if there are no frames. // Avoid printing anything if there are no frames.
...@@ -1688,7 +1702,6 @@ Object Isolate::UnwindAndFindHandler() { ...@@ -1688,7 +1702,6 @@ Object Isolate::UnwindAndFindHandler() {
// Special handling of termination exceptions, uncatchable by JavaScript and // Special handling of termination exceptions, uncatchable by JavaScript and
// Wasm code, we unwind the handlers until the top ENTRY handler is found. // Wasm code, we unwind the handlers until the top ENTRY handler is found.
bool catchable_by_js = is_catchable_by_javascript(exception); bool catchable_by_js = is_catchable_by_javascript(exception);
bool catchable_by_wasm = is_catchable_by_wasm(exception);
// Compute handler and stack unwinding information by performing a full walk // Compute handler and stack unwinding information by performing a full walk
// over the stack and dispatching according to the frame type. // over the stack and dispatching according to the frame type.
...@@ -1716,6 +1729,7 @@ Object Isolate::UnwindAndFindHandler() { ...@@ -1716,6 +1729,7 @@ Object Isolate::UnwindAndFindHandler() {
0); 0);
} }
#if V8_ENABLE_WEBASSEMBLY
case StackFrame::C_WASM_ENTRY: { case StackFrame::C_WASM_ENTRY: {
StackHandler* handler = frame->top_handler(); StackHandler* handler = frame->top_handler();
thread_local_top()->handler_ = handler->next_address(); thread_local_top()->handler_ = handler->next_address();
...@@ -1735,7 +1749,7 @@ Object Isolate::UnwindAndFindHandler() { ...@@ -1735,7 +1749,7 @@ Object Isolate::UnwindAndFindHandler() {
} }
case StackFrame::WASM: { case StackFrame::WASM: {
if (!catchable_by_wasm) break; if (!is_catchable_by_wasm(exception)) break;
// For WebAssembly frames we perform a lookup in the handler table. // For WebAssembly frames we perform a lookup in the handler table.
// This code ref scope is here to avoid a check failure when looking up // This code ref scope is here to avoid a check failure when looking up
...@@ -1767,6 +1781,7 @@ Object Isolate::UnwindAndFindHandler() { ...@@ -1767,6 +1781,7 @@ Object Isolate::UnwindAndFindHandler() {
DCHECK(FLAG_wasm_lazy_validation); DCHECK(FLAG_wasm_lazy_validation);
break; break;
} }
#endif // V8_ENABLE_WEBASSEMBLY
case StackFrame::OPTIMIZED: { case StackFrame::OPTIMIZED: {
// For optimized frames we perform a lookup in the handler table. // For optimized frames we perform a lookup in the handler table.
...@@ -1800,10 +1815,10 @@ Object Isolate::UnwindAndFindHandler() { ...@@ -1800,10 +1815,10 @@ Object Isolate::UnwindAndFindHandler() {
// Some stubs are able to handle exceptions. // Some stubs are able to handle exceptions.
if (!catchable_by_js) break; if (!catchable_by_js) break;
StubFrame* stub_frame = static_cast<StubFrame*>(frame); StubFrame* stub_frame = static_cast<StubFrame*>(frame);
#ifdef DEBUG #if defined(DEBUG) && V8_ENABLE_WEBASSEMBLY
wasm::WasmCodeRefScope code_ref_scope; wasm::WasmCodeRefScope code_ref_scope;
DCHECK_NULL(wasm_engine()->code_manager()->LookupCode(frame->pc())); DCHECK_NULL(wasm_engine()->code_manager()->LookupCode(frame->pc()));
#endif // DEBUG #endif // defined(DEBUG) && V8_ENABLE_WEBASSEMBLY
Code code = stub_frame->LookupCode(); Code code = stub_frame->LookupCode();
if (!code.IsCode() || code.kind() != CodeKind::BUILTIN || if (!code.IsCode() || code.kind() != CodeKind::BUILTIN ||
!code.has_handler_table() || !code.is_turbofanned()) { !code.has_handler_table() || !code.is_turbofanned()) {
...@@ -2112,7 +2127,9 @@ bool Isolate::ComputeLocation(MessageLocation* target) { ...@@ -2112,7 +2127,9 @@ bool Isolate::ComputeLocation(MessageLocation* target) {
// baseline code. For optimized code this will use the deoptimization // baseline code. For optimized code this will use the deoptimization
// information to get canonical location information. // information to get canonical location information.
std::vector<FrameSummary> frames; std::vector<FrameSummary> frames;
#if V8_ENABLE_WEBASSEMBLY
wasm::WasmCodeRefScope code_ref_scope; wasm::WasmCodeRefScope code_ref_scope;
#endif // V8_ENABLE_WEBASSEMBLY
frame->Summarize(&frames); frame->Summarize(&frames);
FrameSummary& summary = frames.back(); FrameSummary& summary = frames.back();
Handle<SharedFunctionInfo> shared; Handle<SharedFunctionInfo> shared;
...@@ -2635,11 +2652,13 @@ void Isolate::UnregisterManagedPtrDestructor(ManagedPtrDestructor* destructor) { ...@@ -2635,11 +2652,13 @@ void Isolate::UnregisterManagedPtrDestructor(ManagedPtrDestructor* destructor) {
destructor->next_ = nullptr; destructor->next_ = nullptr;
} }
#if V8_ENABLE_WEBASSEMBLY
void Isolate::SetWasmEngine(std::shared_ptr<wasm::WasmEngine> engine) { void Isolate::SetWasmEngine(std::shared_ptr<wasm::WasmEngine> engine) {
DCHECK_NULL(wasm_engine_); // Only call once before {Init}. DCHECK_NULL(wasm_engine_); // Only call once before {Init}.
wasm_engine_ = std::move(engine); wasm_engine_ = std::move(engine);
wasm_engine_->AddIsolate(this); wasm_engine_->AddIsolate(this);
} }
#endif // V8_ENABLE_WEBASSEMBLY
// NOLINTNEXTLINE // NOLINTNEXTLINE
Isolate::PerIsolateThreadData::~PerIsolateThreadData() { Isolate::PerIsolateThreadData::~PerIsolateThreadData() {
...@@ -2988,7 +3007,9 @@ void Isolate::Deinit() { ...@@ -2988,7 +3007,9 @@ void Isolate::Deinit() {
debug()->Unload(); debug()->Unload();
#if V8_ENABLE_WEBASSEMBLY
wasm_engine()->DeleteCompileJobsOnIsolate(this); wasm_engine()->DeleteCompileJobsOnIsolate(this);
#endif // V8_ENABLE_WEBASSEMBLY
if (concurrent_recompilation_enabled()) { if (concurrent_recompilation_enabled()) {
optimizing_compile_dispatcher_->Stop(); optimizing_compile_dispatcher_->Stop();
...@@ -3051,10 +3072,12 @@ void Isolate::Deinit() { ...@@ -3051,10 +3072,12 @@ void Isolate::Deinit() {
FILE* logfile = logger_->TearDownAndGetLogFile(); FILE* logfile = logger_->TearDownAndGetLogFile();
if (logfile != nullptr) base::Fclose(logfile); if (logfile != nullptr) base::Fclose(logfile);
#if V8_ENABLE_WEBASSEMBLY
if (wasm_engine_) { if (wasm_engine_) {
wasm_engine_->RemoveIsolate(this); wasm_engine_->RemoveIsolate(this);
wasm_engine_.reset(); wasm_engine_.reset();
} }
#endif // V8_ENABLE_WEBASSEMBLY
TearDownEmbeddedBlob(); TearDownEmbeddedBlob();
...@@ -3484,11 +3507,13 @@ bool Isolate::Init(SnapshotData* startup_snapshot_data, ...@@ -3484,11 +3507,13 @@ bool Isolate::Init(SnapshotData* startup_snapshot_data,
isolate_data_.external_reference_table()->Init(this); isolate_data_.external_reference_table()->Init(this);
#if V8_ENABLE_WEBASSEMBLY
// Setup the wasm engine. // Setup the wasm engine.
if (wasm_engine_ == nullptr) { if (wasm_engine_ == nullptr) {
SetWasmEngine(wasm::WasmEngine::GetWasmEngine()); SetWasmEngine(wasm::WasmEngine::GetWasmEngine());
} }
DCHECK_NOT_NULL(wasm_engine_); DCHECK_NOT_NULL(wasm_engine_);
#endif // V8_ENABLE_WEBASSEMBLY
if (setup_delegate_ == nullptr) { if (setup_delegate_ == nullptr) {
setup_delegate_ = new SetupIsolateDelegate(create_heap_objects); setup_delegate_ = new SetupIsolateDelegate(create_heap_objects);
...@@ -3761,11 +3786,13 @@ void Isolate::DumpAndResetStats() { ...@@ -3761,11 +3786,13 @@ void Isolate::DumpAndResetStats() {
delete turbo_statistics_; delete turbo_statistics_;
turbo_statistics_ = nullptr; turbo_statistics_ = nullptr;
} }
#if V8_ENABLE_WEBASSEMBLY
// TODO(7424): There is no public API for the {WasmEngine} yet. So for now we // TODO(7424): There is no public API for the {WasmEngine} yet. So for now we
// just dump and reset the engines statistics together with the Isolate. // just dump and reset the engines statistics together with the Isolate.
if (FLAG_turbo_stats_wasm) { if (FLAG_turbo_stats_wasm) {
wasm_engine()->DumpAndResetTurboStatistics(); wasm_engine()->DumpAndResetTurboStatistics();
} }
#endif // V8_ENABLE_WEBASSEMBLY
if (V8_UNLIKELY(TracingFlags::runtime_stats.load(std::memory_order_relaxed) == if (V8_UNLIKELY(TracingFlags::runtime_stats.load(std::memory_order_relaxed) ==
v8::tracing::TracingCategoryObserver::ENABLED_BY_NATIVE)) { v8::tracing::TracingCategoryObserver::ENABLED_BY_NATIVE)) {
counters()->worker_thread_runtime_call_stats()->AddToMainTable( counters()->worker_thread_runtime_call_stats()->AddToMainTable(
......
...@@ -1631,8 +1631,13 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory { ...@@ -1631,8 +1631,13 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {
elements_deletion_counter_ = value; elements_deletion_counter_ = value;
} }
#if V8_ENABLE_WEBASSEMBLY
wasm::WasmEngine* wasm_engine() const { return wasm_engine_.get(); } wasm::WasmEngine* wasm_engine() const { return wasm_engine_.get(); }
void SetWasmEngine(std::shared_ptr<wasm::WasmEngine> engine); void SetWasmEngine(std::shared_ptr<wasm::WasmEngine> engine);
#else
// TODO(clemensb): Remove this method.
wasm::WasmEngine* wasm_engine() const { return nullptr; }
#endif // V8_ENABLE_WEBASSEMBLY
const v8::Context::BackupIncumbentScope* top_backup_incumbent_scope() const { const v8::Context::BackupIncumbentScope* top_backup_incumbent_scope() const {
return top_backup_incumbent_scope_; return top_backup_incumbent_scope_;
...@@ -2037,7 +2042,9 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory { ...@@ -2037,7 +2042,9 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {
size_t elements_deletion_counter_ = 0; size_t elements_deletion_counter_ = 0;
#if V8_ENABLE_WEBASSEMBLY
std::shared_ptr<wasm::WasmEngine> wasm_engine_; std::shared_ptr<wasm::WasmEngine> wasm_engine_;
#endif // V8_ENABLE_WEBASSEMBLY
std::unique_ptr<TracingCpuProfilerImpl> tracing_cpu_profiler_; std::unique_ptr<TracingCpuProfilerImpl> tracing_cpu_profiler_;
......
...@@ -20,7 +20,10 @@ ...@@ -20,7 +20,10 @@
#include "src/profiler/profiler-stats.h" #include "src/profiler/profiler-stats.h"
#include "src/profiler/symbolizer.h" #include "src/profiler/symbolizer.h"
#include "src/utils/locked-queue-inl.h" #include "src/utils/locked-queue-inl.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-engine.h" #include "src/wasm/wasm-engine.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -72,7 +75,9 @@ ProfilingScope::ProfilingScope(Isolate* isolate, ProfilerListener* listener) ...@@ -72,7 +75,9 @@ ProfilingScope::ProfilingScope(Isolate* isolate, ProfilerListener* listener)
profiler_count++; profiler_count++;
isolate_->set_num_cpu_profilers(profiler_count); isolate_->set_num_cpu_profilers(profiler_count);
isolate_->set_is_profiling(true); isolate_->set_is_profiling(true);
#if V8_ENABLE_WEBASSEMBLY
isolate_->wasm_engine()->EnableCodeLogging(isolate_); isolate_->wasm_engine()->EnableCodeLogging(isolate_);
#endif // V8_ENABLE_WEBASSEMBLY
Logger* logger = isolate_->logger(); Logger* logger = isolate_->logger();
logger->AddCodeEventListener(listener_); logger->AddCodeEventListener(listener_);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment