[no-wasm] Remove wasm debugging support

This removes all wasm includes from src/debug and src/inspector if
webassembly is disabled (v8_enable_webassembly=false). It also removes
the definition of {WasmValueObject} and {v8::debug::WasmScript}.
This will allow to later fully exclude the src/wasm directory from
compilation (once other components are fixed).

R=bmeurer@chromium.org, machenbach@chromium.org

Bug: v8:11238
Change-Id: I41a1d83d01fbb6c015cdfd6cc063bad90052505d
Cq-Include-Trybots: luci.v8.try:v8_linux64_no_wasm_compile_rel
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2726506
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: Maya Lekova <mslekova@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73138}
This commit is contained in:
Clemens Backes 2021-03-01 17:41:31 +01:00 committed by Commit Bot
parent 1dd8624b52
commit 8890bb21f9
24 changed files with 213 additions and 74 deletions

View File

@ -1360,7 +1360,6 @@ torque_files = [
"src/builtins/typed-array.tq",
"src/builtins/wasm.tq",
"src/builtins/weak-ref.tq",
"src/debug/debug-wasm-objects.tq",
"src/ic/handler-configuration.tq",
"src/objects/allocation-site.tq",
"src/objects/api-callbacks.tq",
@ -1441,6 +1440,10 @@ if (v8_enable_i18n_support) {
]
}
if (v8_enable_webassembly) {
torque_files += [ "src/debug/debug-wasm-objects.tq" ]
}
# Template for running torque
# When building with v8_verify_torque_generation_invariance=true we need
# to be able to run torque for both 32 and 64 bits in the same build
@ -2427,8 +2430,6 @@ v8_header_set("v8_internal_headers") {
"src/debug/debug-scopes.h",
"src/debug/debug-stack-trace-iterator.h",
"src/debug/debug-type-profile.h",
"src/debug/debug-wasm-objects-inl.h",
"src/debug/debug-wasm-objects.h",
"src/debug/debug.h",
"src/debug/interface-types.h",
"src/debug/liveedit.h",
@ -3015,6 +3016,8 @@ v8_header_set("v8_internal_headers") {
"src/asmjs/asm-parser.h",
"src/asmjs/asm-scanner.h",
"src/asmjs/asm-types.h",
"src/debug/debug-wasm-objects-inl.h",
"src/debug/debug-wasm-objects.h",
]
}
@ -3557,7 +3560,6 @@ v8_source_set("v8_base_without_compiler") {
"src/debug/debug-scopes.cc",
"src/debug/debug-stack-trace-iterator.cc",
"src/debug/debug-type-profile.cc",
"src/debug/debug-wasm-objects.cc",
"src/debug/debug.cc",
"src/debug/liveedit.cc",
"src/deoptimizer/deoptimize-reason.cc",
@ -3929,6 +3931,7 @@ v8_source_set("v8_base_without_compiler") {
"src/asmjs/asm-parser.cc",
"src/asmjs/asm-scanner.cc",
"src/asmjs/asm-types.cc",
"src/debug/debug-wasm-objects.cc",
]
}

View File

@ -263,7 +263,9 @@ Type::bitset BitsetType::Lub(const MapRefLike& map) {
case WASM_MODULE_OBJECT_TYPE:
case WASM_STRUCT_TYPE:
case WASM_TABLE_OBJECT_TYPE:
#if V8_ENABLE_WEBASSEMBLY
case WASM_VALUE_OBJECT_TYPE:
#endif // V8_ENABLE_WEBASSEMBLY
case WEAK_CELL_TYPE:
DCHECK(!map.is_callable());
DCHECK(!map.is_undetectable());

View File

@ -10,7 +10,6 @@
#include "src/common/globals.h"
#include "src/debug/debug-frames.h"
#include "src/debug/debug-scopes.h"
#include "src/debug/debug-wasm-objects.h"
#include "src/debug/debug.h"
#include "src/execution/frames-inl.h"
#include "src/execution/isolate-inl.h"
@ -19,6 +18,10 @@
#include "src/objects/contexts.h"
#include "src/snapshot/snapshot.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/debug/debug-wasm-objects.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {
@ -77,26 +80,8 @@ MaybeHandle<Object> DebugEvaluate::Local(Isolate* isolate,
// Get the frame where the debugging is performed.
StackTraceFrameIterator it(isolate, frame_id);
if (it.is_javascript()) {
JavaScriptFrame* frame = it.javascript_frame();
// This is not a lot different than DebugEvaluate::Global, except that
// variables accessible by the function we are evaluating from are
// materialized and included on top of the native context. Changes to
// the materialized object are written back afterwards.
// Note that the native context is taken from the original context chain,
// which may not be the current native context of the isolate.
ContextBuilder context_builder(isolate, frame, inlined_jsframe_index);
if (isolate->has_pending_exception()) return {};
Handle<Context> context = context_builder.evaluation_context();
Handle<JSObject> receiver(context->global_proxy(), isolate);
MaybeHandle<Object> maybe_result =
Evaluate(isolate, context_builder.outer_info(), context, receiver,
source, throw_on_side_effect);
if (!maybe_result.is_null()) context_builder.UpdateValues();
return maybe_result;
} else {
CHECK(it.is_wasm());
#if V8_ENABLE_WEBASSEMBLY
if (it.is_wasm()) {
WasmFrame* frame = WasmFrame::cast(it.frame());
Handle<SharedFunctionInfo> outer_info(
isolate->native_context()->empty_function().shared(), isolate);
@ -108,6 +93,26 @@ MaybeHandle<Object> DebugEvaluate::Local(Isolate* isolate,
return Evaluate(isolate, outer_info, context, context_extension, source,
throw_on_side_effect);
}
#endif // V8_ENABLE_WEBASSEMBLY
CHECK(it.is_javascript());
JavaScriptFrame* frame = it.javascript_frame();
// This is not a lot different than DebugEvaluate::Global, except that
// variables accessible by the function we are evaluating from are
// materialized and included on top of the native context. Changes to
// the materialized object are written back afterwards.
// Note that the native context is taken from the original context chain,
// which may not be the current native context of the isolate.
ContextBuilder context_builder(isolate, frame, inlined_jsframe_index);
if (isolate->has_pending_exception()) return {};
Handle<Context> context = context_builder.evaluation_context();
Handle<JSObject> receiver(context->global_proxy(), isolate);
MaybeHandle<Object> maybe_result =
Evaluate(isolate, context_builder.outer_info(), context, receiver, source,
throw_on_side_effect);
if (!maybe_result.is_null()) context_builder.UpdateValues();
return maybe_result;
}
MaybeHandle<Object> DebugEvaluate::WithTopmostArguments(Isolate* isolate,

View File

@ -6,7 +6,6 @@
#include "src/builtins/accessors.h"
#include "src/execution/frames-inl.h"
#include "src/wasm/wasm-objects-inl.h"
namespace v8 {
namespace internal {

View File

@ -9,12 +9,16 @@
#include "src/debug/debug-evaluate.h"
#include "src/debug/debug-property-iterator.h"
#include "src/debug/debug-type-profile.h"
#include "src/debug/debug-wasm-objects-inl.h"
#include "src/debug/debug.h"
#include "src/execution/vm-state-inl.h"
#include "src/objects/js-generator-inl.h"
#include "src/regexp/regexp-stack.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/debug/debug-wasm-objects-inl.h"
#include "src/wasm/wasm-engine.h"
#endif // V8_ENABLE_WEBASSEMBLY
// Has to be the last include (doesn't have include guards):
#include "src/api/api-macros.h"
@ -374,11 +378,13 @@ bool Script::GetPossibleBreakpoints(
std::vector<BreakLocation>* locations) const {
CHECK(!start.IsEmpty());
i::Handle<i::Script> script = Utils::OpenHandle(this);
#if V8_ENABLE_WEBASSEMBLY
if (script->type() == i::Script::TYPE_WASM) {
i::wasm::NativeModule* native_module = script->wasm_native_module();
return i::WasmScript::GetPossibleBreakpoints(native_module, start, end,
locations);
}
#endif // V8_ENABLE_WEBASSEMBLY
i::Isolate* isolate = script->GetIsolate();
i::Script::InitLineEnds(isolate, script);
@ -479,11 +485,13 @@ bool Script::SetBreakpoint(Local<String> condition, Location* location,
bool Script::SetBreakpointOnScriptEntry(BreakpointId* id) const {
i::Handle<i::Script> script = Utils::OpenHandle(this);
i::Isolate* isolate = script->GetIsolate();
#if V8_ENABLE_WEBASSEMBLY
if (script->type() == i::Script::TYPE_WASM) {
int position = i::WasmScript::kOnEntryBreakpointPosition;
return isolate->debug()->SetBreakPointForScript(
script, isolate->factory()->empty_string(), &position, id);
}
#endif // V8_ENABLE_WEBASSEMBLY
i::SharedFunctionInfo::ScriptIterator it(isolate, *script);
for (i::SharedFunctionInfo sfi = it.Next(); !sfi.is_null(); sfi = it.Next()) {
if (sfi.is_toplevel()) {
@ -494,11 +502,13 @@ bool Script::SetBreakpointOnScriptEntry(BreakpointId* id) const {
return false;
}
#if V8_ENABLE_WEBASSEMBLY
void Script::RemoveWasmBreakpoint(BreakpointId id) {
i::Handle<i::Script> script = Utils::OpenHandle(this);
i::Isolate* isolate = script->GetIsolate();
isolate->debug()->RemoveBreakpointForWasmScript(script, id);
}
#endif // V8_ENABLE_WEBASSEMBLY
void RemoveBreakpoint(Isolate* v8_isolate, BreakpointId id) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
@ -516,6 +526,7 @@ void ForceGarbageCollection(
isolate->LowMemoryNotification();
}
#if V8_ENABLE_WEBASSEMBLY
WasmScript* WasmScript::Cast(Script* script) {
CHECK(script->IsWasm());
return static_cast<WasmScript*>(script);
@ -632,6 +643,7 @@ int WasmScript::CodeOffset() const {
module->code.offset() != 0);
return module->code.offset();
}
#endif // V8_ENABLE_WEBASSEMBLY
Location::Location(int line_number, int column_number)
: line_number_(line_number),
@ -698,6 +710,7 @@ MaybeLocal<UnboundScript> CompileInspectorScript(Isolate* v8_isolate,
RETURN_ESCAPED(ToApiHandle<UnboundScript>(result));
}
#if V8_ENABLE_WEBASSEMBLY
void TierDownAllModulesPerIsolate(Isolate* v8_isolate) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
isolate->wasm_engine()->TierDownAllModulesPerIsolate(isolate);
@ -707,6 +720,7 @@ void TierUpAllModulesPerIsolate(Isolate* v8_isolate) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
isolate->wasm_engine()->TierUpAllModulesPerIsolate(isolate);
}
#endif // V8_ENABLE_WEBASSEMBLY
void SetDebugDelegate(Isolate* v8_isolate, DebugDelegate* delegate) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
@ -746,12 +760,19 @@ void AccessorPair::CheckCast(Value* that) {
"Value is not a v8::debug::AccessorPair");
}
#if V8_ENABLE_WEBASSEMBLY
void WasmValueObject::CheckCast(Value* that) {
i::Handle<i::Object> obj = Utils::OpenHandle(that);
Utils::ApiCheck(obj->IsWasmValueObject(), "v8::debug::WasmValueObject::Cast",
"Value is not a v8::debug::WasmValueObject");
}
bool WasmValueObject::IsWasmValueObject(Local<Value> that) {
i::Handle<i::Object> obj = Utils::OpenHandle(*that);
return obj->IsWasmValueObject();
}
#endif // V8_ENABLE_WEBASSEMBLY
Local<Function> GetBuiltin(Isolate* v8_isolate, Builtin builtin) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
@ -1114,11 +1135,6 @@ bool AccessorPair::IsAccessorPair(Local<Value> that) {
return obj->IsAccessorPair();
}
bool WasmValueObject::IsWasmValueObject(Local<Value> that) {
i::Handle<i::Object> obj = Utils::OpenHandle(*that);
return obj->IsWasmValueObject();
}
MaybeLocal<Message> GetMessageFromPromise(Local<Promise> p) {
i::Handle<i::JSPromise> promise = Utils::OpenHandle(*p);
i::Isolate* isolate = promise->GetIsolate();

View File

@ -166,10 +166,13 @@ class V8_EXPORT_PRIVATE Script {
LiveEditResult* result) const;
bool SetBreakpoint(v8::Local<v8::String> condition, debug::Location* location,
BreakpointId* id) const;
#if V8_ENABLE_WEBASSEMBLY
void RemoveWasmBreakpoint(BreakpointId id);
#endif // V8_ENABLE_WEBASSEMBLY
bool SetBreakpointOnScriptEntry(BreakpointId* id) const;
};
#if V8_ENABLE_WEBASSEMBLY
// Specialization for wasm Scripts.
class WasmScript : public Script {
public:
@ -190,6 +193,7 @@ class WasmScript : public Script {
int CodeOffset() const;
int CodeLength() const;
};
#endif // V8_ENABLE_WEBASSEMBLY
V8_EXPORT_PRIVATE void GetLoadedScripts(
Isolate* isolate,
@ -228,8 +232,10 @@ class DebugDelegate {
V8_EXPORT_PRIVATE void SetDebugDelegate(Isolate* isolate,
DebugDelegate* listener);
#if V8_ENABLE_WEBASSEMBLY
V8_EXPORT_PRIVATE void TierDownAllModulesPerIsolate(Isolate* isolate);
V8_EXPORT_PRIVATE void TierUpAllModulesPerIsolate(Isolate* isolate);
#endif // V8_ENABLE_WEBASSEMBLY
class AsyncEventDelegate {
public:
@ -616,15 +622,22 @@ class PropertyIterator {
virtual bool is_array_index() = 0;
};
#if V8_ENABLE_WEBASSEMBLY
class V8_EXPORT_PRIVATE WasmValueObject : public v8::Object {
public:
WasmValueObject() = delete;
static bool IsWasmValueObject(v8::Local<v8::Value> obj);
V8_INLINE static WasmValueObject* Cast(v8::Value* obj);
static WasmValueObject* Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<WasmValueObject*>(value);
}
private:
static void CheckCast(v8::Value* obj);
};
#endif // V8_ENABLE_WEBASSEMBLY
AccessorPair* AccessorPair::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
@ -633,13 +646,6 @@ AccessorPair* AccessorPair::Cast(v8::Value* value) {
return static_cast<AccessorPair*>(value);
}
WasmValueObject* WasmValueObject::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<WasmValueObject*>(value);
}
MaybeLocal<Message> GetMessageFromPromise(Local<Promise> promise);
} // namespace debug

View File

@ -7,12 +7,15 @@
#include "src/api/api-inl.h"
#include "src/debug/debug-evaluate.h"
#include "src/debug/debug-scope-iterator.h"
#include "src/debug/debug-wasm-objects.h"
#include "src/debug/debug.h"
#include "src/debug/liveedit.h"
#include "src/execution/frames-inl.h"
#include "src/execution/isolate.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/debug/debug-wasm-objects.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
std::unique_ptr<debug::StackTraceIterator> debug::StackTraceIterator::Create(
@ -159,10 +162,11 @@ v8::Local<v8::Function> DebugStackTraceIterator::GetFunction() const {
std::unique_ptr<v8::debug::ScopeIterator>
DebugStackTraceIterator::GetScopeIterator() const {
DCHECK(!Done());
CommonFrame* frame = iterator_.frame();
if (frame->is_wasm()) {
return GetWasmScopeIterator(WasmFrame::cast(frame));
#if V8_ENABLE_WEBASSEMBLY
if (iterator_.frame()->is_wasm()) {
return GetWasmScopeIterator(WasmFrame::cast(iterator_.frame()));
}
#endif // V8_ENABLE_WEBASSEMBLY
return std::make_unique<DebugScopeIterator>(isolate_, frame_inspector_.get());
}

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_DEBUG_DEBUG_WASM_OBJECTS_H_
#define V8_DEBUG_DEBUG_WASM_OBJECTS_H_

View File

@ -36,8 +36,11 @@
#include "src/objects/js-promise-inl.h"
#include "src/objects/slots.h"
#include "src/snapshot/snapshot.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-debug.h"
#include "src/wasm/wasm-objects-inl.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {
@ -562,7 +565,6 @@ bool Debug::IsMutedAtCurrentLocation(JavaScriptFrame* frame) {
// break location, we also do not trigger one for debugger statements, nor
// an exception event on exception at this location.
FrameSummary summary = FrameSummary::GetTop(frame);
DCHECK(!summary.IsWasm());
Handle<JSFunction> function = summary.AsJavaScript().function();
if (!function->shared().HasBreakInfo()) return false;
Handle<DebugInfo> debug_info(function->shared().GetDebugInfo(), isolate_);
@ -644,10 +646,12 @@ bool Debug::SetBreakPointForScript(Handle<Script> script,
*id = ++thread_local_.last_breakpoint_id_;
Handle<BreakPoint> break_point =
isolate_->factory()->NewBreakPoint(*id, condition);
#if V8_ENABLE_WEBASSEMBLY
if (script->type() == Script::TYPE_WASM) {
RecordWasmScriptWithBreakpoints(script);
return WasmScript::SetBreakPoint(script, source_position, break_point);
}
#endif // V8_ENABLE_WEBASSEMBLY
HandleScope scope(isolate_);
@ -750,6 +754,7 @@ bool Debug::SetBreakpointForFunction(Handle<SharedFunctionInfo> shared,
Handle<BreakPoint> breakpoint =
isolate_->factory()->NewBreakPoint(*id, condition);
int source_position = 0;
#if V8_ENABLE_WEBASSEMBLY
// Handle wasm function.
if (shared->HasWasmExportedFunctionData()) {
int func_index = shared->wasm_exported_function_data().function_index();
@ -760,6 +765,7 @@ bool Debug::SetBreakpointForFunction(Handle<SharedFunctionInfo> shared,
return WasmScript::SetBreakPointOnFirstBreakableForFunction(
script, func_index, breakpoint);
}
#endif // V8_ENABLE_WEBASSEMBLY
return SetBreakpoint(shared, breakpoint, &source_position);
}
@ -769,6 +775,7 @@ void Debug::RemoveBreakpoint(int id) {
ClearBreakPoint(breakpoint);
}
#if V8_ENABLE_WEBASSEMBLY
void Debug::RemoveBreakpointForWasmScript(Handle<Script> script, int id) {
if (script->type() == Script::TYPE_WASM) {
WasmScript::ClearBreakPointById(script, id);
@ -802,6 +809,7 @@ void Debug::RecordWasmScriptWithBreakpoints(Handle<Script> script) {
isolate_->global_handles()->Create(*new_list);
}
}
#endif // V8_ENABLE_WEBASSEMBLY
// Clear out all the debug break code.
void Debug::ClearAllBreakPoints() {
@ -809,6 +817,7 @@ void Debug::ClearAllBreakPoints() {
ClearBreakPoints(info);
info->ClearBreakInfo(isolate_);
});
#if V8_ENABLE_WEBASSEMBLY
// Clear all wasm breakpoints.
if (!wasm_scripts_with_breakpoints_.is_null()) {
DisallowGarbageCollection no_gc;
@ -825,6 +834,7 @@ void Debug::ClearAllBreakPoints() {
}
wasm_scripts_with_breakpoints_ = Handle<WeakArrayList>{};
}
#endif // V8_ENABLE_WEBASSEMBLY
}
void Debug::FloodWithOneShot(Handle<SharedFunctionInfo> shared,
@ -1070,6 +1080,7 @@ void Debug::PrepareStep(StepAction step_action) {
// No longer perform the current async step.
clear_suspended_generator();
} else if (frame->is_wasm() && step_action != StepOut) {
#if V8_ENABLE_WEBASSEMBLY
// Handle stepping in wasm.
WasmFrame* wasm_frame = WasmFrame::cast(frame);
auto* debug_info = wasm_frame->native_module()->GetDebugInfo();
@ -1077,6 +1088,7 @@ 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.
@ -1104,6 +1116,7 @@ void Debug::PrepareStep(StepAction step_action) {
// and deoptimize every frame along the way.
bool in_current_frame = true;
for (; !frames_it.done(); frames_it.Advance()) {
#if V8_ENABLE_WEBASSEMBLY
if (frames_it.frame()->is_wasm()) {
if (in_current_frame) {
in_current_frame = false;
@ -1115,6 +1128,7 @@ void Debug::PrepareStep(StepAction step_action) {
debug_info->PrepareStepOutTo(wasm_frame);
return;
}
#endif // V8_ENABLE_WEBASSEMBLY
JavaScriptFrame* frame = JavaScriptFrame::cast(frames_it.frame());
if (last_step_action() == StepIn) {
// Deoptimize frame to ensure calls are checked for step-in.

View File

@ -245,9 +245,11 @@ class V8_EXPORT_PRIVATE Debug {
bool SetBreakpointForFunction(Handle<SharedFunctionInfo> shared,
Handle<String> condition, int* id);
void RemoveBreakpoint(int id);
#if V8_ENABLE_WEBASSEMBLY
void RemoveBreakpointForWasmScript(Handle<Script> script, int id);
void RecordWasmScriptWithBreakpoints(Handle<Script> script);
#endif // V8_ENABLE_WEBASSEMBLY
// Find breakpoints from the debug info and the break location and check
// whether they are hit. Return an empty handle if not, or a FixedArray with
@ -554,8 +556,10 @@ class V8_EXPORT_PRIVATE Debug {
// Storage location for registers when handling debug break calls
ThreadLocal thread_local_;
#if V8_ENABLE_WEBASSEMBLY
// This is a global handle, lazily initialized.
Handle<WeakArrayList> wasm_scripts_with_breakpoints_;
#endif // V8_ENABLE_WEBASSEMBLY
Isolate* isolate_;

View File

@ -5,7 +5,6 @@
#include "src/codegen/assembler-inl.h"
#include "src/common/globals.h"
#include "src/date/date.h"
#include "src/debug/debug-wasm-objects-inl.h"
#include "src/diagnostics/disasm.h"
#include "src/diagnostics/disassembler.h"
#include "src/heap/combined-heap.h"
@ -78,6 +77,10 @@
#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"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {
@ -229,9 +232,11 @@ void HeapObject::HeapObjectVerify(Isolate* isolate) {
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;
#endif // V8_ENABLE_WEBASSEMBLY
case JS_SET_KEY_VALUE_ITERATOR_TYPE:
case JS_SET_VALUE_ITERATOR_TYPE:
JSSetIterator::cast(*this).JSSetIteratorVerify(isolate);
@ -1614,10 +1619,12 @@ 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) {

View File

@ -6,7 +6,6 @@
#include <memory>
#include "src/common/globals.h"
#include "src/debug/debug-wasm-objects-inl.h"
#include "src/diagnostics/disasm.h"
#include "src/diagnostics/disassembler.h"
#include "src/heap/heap-inl.h" // For InOldSpace.
@ -22,6 +21,10 @@
#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"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {
@ -175,9 +178,11 @@ void HeapObject::HeapObjectPrint(std::ostream& os) { // NOLINT
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;
#endif // V8_ENABLE_WEBASSEMBLY
case CODE_TYPE:
Code::cast(*this).CodePrint(os);
break;
@ -1962,11 +1967,13 @@ 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");

View File

@ -66,6 +66,7 @@ static const intptr_t kBreakpointHintMaxSearchOffset = 80 * 10;
// the maximum length of a message in mojo (see https://crbug.com/1105172).
static const size_t kMaxNumBreakpoints = 1000;
#if V8_ENABLE_WEBASSEMBLY
// TODO(1099680): getScriptSource and getWasmBytecode return Wasm wire bytes
// as protocol::Binary, which is encoded as JSON string in the communication
// to the DevTools front-end and hence leads to either crashing the renderer
@ -73,9 +74,11 @@ static const size_t kMaxNumBreakpoints = 1000;
// allow arbitrarily big Wasm byte sequences here. Ideally we would find a
// different way to transfer the wire bytes (middle- to long-term), but as a
// short-term solution, we should at least not crash.
static const size_t kWasmBytecodeMaxLength = (v8::String::kMaxLength / 4) * 3;
static const char kWasmBytecodeExceedsTransferLimit[] =
static constexpr size_t kWasmBytecodeMaxLength =
(v8::String::kMaxLength / 4) * 3;
static constexpr const char kWasmBytecodeExceedsTransferLimit[] =
"WebAssembly bytecode exceeds the transfer limit";
#endif // V8_ENABLE_WEBASSEMBLY
namespace {
@ -706,9 +709,11 @@ void V8DebuggerAgentImpl::removeBreakpointImpl(
return;
}
for (const auto& id : debuggerBreakpointIdsIterator->second) {
#if V8_ENABLE_WEBASSEMBLY
for (auto& script : scripts) {
script->removeWasmBreakpoint(id);
}
#endif // V8_ENABLE_WEBASSEMBLY
v8::debug::RemoveBreakpoint(m_isolate, id);
m_debuggerBreakpointIdToBreakpointId.erase(id);
}
@ -1043,6 +1048,7 @@ Response V8DebuggerAgentImpl::getScriptSource(
if (it == m_scripts.end())
return Response::ServerError("No script for id: " + scriptId.utf8());
*scriptSource = it->second->source(0);
#if V8_ENABLE_WEBASSEMBLY
v8::MemorySpan<const uint8_t> span;
if (it->second->wasmBytecode().To(&span)) {
if (span.size() > kWasmBytecodeMaxLength) {
@ -1050,11 +1056,13 @@ Response V8DebuggerAgentImpl::getScriptSource(
}
*bytecode = protocol::Binary::fromSpan(span.data(), span.size());
}
#endif // V8_ENABLE_WEBASSEMBLY
return Response::Success();
}
Response V8DebuggerAgentImpl::getWasmBytecode(const String16& scriptId,
protocol::Binary* bytecode) {
#if V8_ENABLE_WEBASSEMBLY
if (!enabled()) return Response::ServerError(kDebuggerNotEnabled);
ScriptsMap::iterator it = m_scripts.find(scriptId);
if (it == m_scripts.end())
@ -1068,6 +1076,9 @@ Response V8DebuggerAgentImpl::getWasmBytecode(const String16& scriptId,
}
*bytecode = protocol::Binary::fromSpan(span.data(), span.size());
return Response::Success();
#else
return Response::ServerError("WebAssembly is disabled");
#endif // V8_ENABLE_WEBASSEMBLY
}
void V8DebuggerAgentImpl::pushBreakDetails(
@ -1505,6 +1516,7 @@ static String16 getScriptLanguage(const V8DebuggerScript& script) {
}
}
#if V8_ENABLE_WEBASSEMBLY
static const char* getDebugSymbolTypeName(
v8::debug::WasmScript::DebugSymbolsType type) {
switch (type) {
@ -1537,6 +1549,7 @@ static std::unique_ptr<protocol::Debugger::DebugSymbols> getDebugSymbols(
}
return debugSymbols;
}
#endif // V8_ENABLE_WEBASSEMBLY
void V8DebuggerAgentImpl::didParseSource(
std::unique_ptr<V8DebuggerScript> script, bool success) {
@ -1571,10 +1584,12 @@ void V8DebuggerAgentImpl::didParseSource(
String16 embedderName = script->embedderName();
String16 scriptLanguage = getScriptLanguage(*script);
Maybe<int> codeOffset;
std::unique_ptr<protocol::Debugger::DebugSymbols> debugSymbols;
#if V8_ENABLE_WEBASSEMBLY
if (script->getLanguage() == V8DebuggerScript::Language::WebAssembly)
codeOffset = script->codeOffset();
std::unique_ptr<protocol::Debugger::DebugSymbols> debugSymbols =
getDebugSymbols(*script);
debugSymbols = getDebugSymbols(*script);
#endif // V8_ENABLE_WEBASSEMBLY
m_scripts[scriptId] = std::move(script);
// Release the strong reference to get notified when debugger is the only

View File

@ -116,13 +116,16 @@ class ActualScript : public V8DebuggerScript {
static_cast<int>(pos), static_cast<int>(substringLength));
return String16(buffer.get(), substringLength);
}
Language getLanguage() const override { return m_language; }
#if V8_ENABLE_WEBASSEMBLY
v8::Maybe<v8::MemorySpan<const uint8_t>> wasmBytecode() const override {
v8::HandleScope scope(m_isolate);
auto script = this->script();
if (!script->IsWasm()) return v8::Nothing<v8::MemorySpan<const uint8_t>>();
return v8::Just(v8::debug::WasmScript::Cast(*script)->Bytecode());
}
Language getLanguage() const override { return m_language; }
v8::Maybe<v8::debug::WasmScript::DebugSymbolsType> getDebugSymbolsType()
const override {
auto script = this->script();
@ -130,6 +133,7 @@ class ActualScript : public V8DebuggerScript {
return v8::Nothing<v8::debug::WasmScript::DebugSymbolsType>();
return v8::Just(v8::debug::WasmScript::Cast(*script)->GetDebugSymbolType());
}
v8::Maybe<String16> getExternalDebugSymbolsURL() const override {
auto script = this->script();
if (!script->IsWasm()) return v8::Nothing<String16>();
@ -138,22 +142,29 @@ class ActualScript : public V8DebuggerScript {
if (external_url.size() == 0) return v8::Nothing<String16>();
return v8::Just(String16(external_url.data(), external_url.size()));
}
#endif // V8_ENABLE_WEBASSEMBLY
int startLine() const override { return m_startLine; }
int startColumn() const override { return m_startColumn; }
int endLine() const override { return m_endLine; }
int endColumn() const override { return m_endColumn; }
int codeOffset() const override {
auto script = this->script();
if (!script->IsWasm()) return 0;
return v8::debug::WasmScript::Cast(*script)->CodeOffset();
#if V8_ENABLE_WEBASSEMBLY
if (script()->IsWasm()) {
return v8::debug::WasmScript::Cast(*script())->CodeOffset();
}
#endif // V8_ENABLE_WEBASSEMBLY
return 0;
}
bool isSourceLoadedLazily() const override { return false; }
int length() const override {
auto script = this->script();
#if V8_ENABLE_WEBASSEMBLY
if (script->IsWasm()) {
return static_cast<int>(
v8::debug::WasmScript::Cast(*script)->Bytecode().size());
}
#endif // V8_ENABLE_WEBASSEMBLY
v8::HandleScope scope(m_isolate);
v8::Local<v8::String> v8Source;
return script->Source().ToLocal(&v8Source) ? v8Source->Length() : 0;
@ -305,23 +316,26 @@ class ActualScript : public V8DebuggerScript {
} else {
m_endColumn = source_length + m_startColumn;
}
#if V8_ENABLE_WEBASSEMBLY
} else if (script->IsWasm()) {
DCHECK_EQ(0, m_startLine);
DCHECK_EQ(0, m_startColumn);
m_endLine = 0;
m_endColumn = static_cast<int>(
v8::debug::WasmScript::Cast(*script)->Bytecode().size());
#endif // V8_ENABLE_WEBASSEMBLY
} else {
m_endLine = m_startLine;
m_endColumn = m_startColumn;
}
USE(script->ContextId().To(&m_executionContextId));
m_language = V8DebuggerScript::Language::JavaScript;
#if V8_ENABLE_WEBASSEMBLY
if (script->IsWasm()) {
m_language = V8DebuggerScript::Language::WebAssembly;
} else {
m_language = V8DebuggerScript::Language::JavaScript;
}
#endif // V8_ENABLE_WEBASSEMBLY
m_isModule = script->IsModule();
@ -387,9 +401,11 @@ bool V8DebuggerScript::setBreakpoint(const String16& condition,
return script()->SetBreakpoint(toV8String(m_isolate, condition), loc, id);
}
#if V8_ENABLE_WEBASSEMBLY
void V8DebuggerScript::removeWasmBreakpoint(int id) {
v8::HandleScope scope(m_isolate);
script()->RemoveWasmBreakpoint(id);
}
#endif // V8_ENABLE_WEBASSEMBLY
} // namespace v8_inspector

View File

@ -62,11 +62,7 @@ class V8DebuggerScript {
virtual const String16& sourceMappingURL() const = 0;
virtual String16 source(size_t pos, size_t len = UINT_MAX) const = 0;
virtual v8::Maybe<v8::MemorySpan<const uint8_t>> wasmBytecode() const = 0;
virtual Language getLanguage() const = 0;
virtual v8::Maybe<String16> getExternalDebugSymbolsURL() const = 0;
virtual v8::Maybe<v8::debug::WasmScript::DebugSymbolsType>
getDebugSymbolsType() const = 0;
virtual const String16& hash() const = 0;
virtual int startLine() const = 0;
virtual int startColumn() const = 0;
@ -96,10 +92,17 @@ class V8DebuggerScript {
virtual bool setBreakpoint(const String16& condition,
v8::debug::Location* location, int* id) const = 0;
void removeWasmBreakpoint(int id);
virtual void MakeWeak() = 0;
virtual bool setBreakpointOnRun(int* id) const = 0;
#if V8_ENABLE_WEBASSEMBLY
virtual v8::Maybe<v8::MemorySpan<const uint8_t>> wasmBytecode() const = 0;
virtual v8::Maybe<v8::debug::WasmScript::DebugSymbolsType>
getDebugSymbolsType() const = 0;
virtual v8::Maybe<String16> getExternalDebugSymbolsURL() const = 0;
void removeWasmBreakpoint(int id);
#endif // V8_ENABLE_WEBASSEMBLY
protected:
V8DebuggerScript(v8::Isolate*, String16 id, String16 url,
String16 embedderName);

View File

@ -90,7 +90,9 @@ void V8Debugger::enable() {
m_isolate->AddNearHeapLimitCallback(&V8Debugger::nearHeapLimitCallback, this);
v8::debug::ChangeBreakOnException(m_isolate, v8::debug::NoBreakOnException);
m_pauseOnExceptionsState = v8::debug::NoBreakOnException;
#if V8_ENABLE_WEBASSEMBLY
v8::debug::TierDownAllModulesPerIsolate(m_isolate);
#endif // V8_ENABLE_WEBASSEMBLY
}
void V8Debugger::disable() {
@ -113,7 +115,9 @@ void V8Debugger::disable() {
m_taskWithScheduledBreakPauseRequested = false;
m_pauseOnNextCallRequested = false;
m_pauseOnAsyncCall = false;
#if V8_ENABLE_WEBASSEMBLY
v8::debug::TierUpAllModulesPerIsolate(m_isolate);
#endif // V8_ENABLE_WEBASSEMBLY
v8::debug::SetDebugDelegate(m_isolate, nullptr);
m_isolate->RemoveNearHeapLimitCallback(&V8Debugger::nearHeapLimitCallback,
m_originalHeapLimit);

View File

@ -793,8 +793,10 @@ bool getPropertiesForPreview(v8::Local<v8::Context> context,
if (object->IsArray() || isArrayLike(context, object, &length) ||
object->IsStringObject()) {
blocklist.push_back("length");
#if V8_ENABLE_WEBASSEMBLY
} else if (v8::debug::WasmValueObject::IsWasmValueObject(object)) {
blocklist.push_back("type");
#endif // V8_ENABLE_WEBASSEMBLY
} else {
auto clientSubtype = clientFor(context)->valueSubtype(object);
if (clientSubtype && toString16(clientSubtype->string()) == "array") {
@ -1693,6 +1695,7 @@ std::unique_ptr<ValueMirror> ValueMirror::create(v8::Local<v8::Context> context,
descriptionForCollection(
isolate, memory, memory->Buffer()->ByteLength() / kWasmPageSize));
}
#if V8_ENABLE_WEBASSEMBLY
if (v8::debug::WasmValueObject::IsWasmValueObject(value)) {
v8::Local<v8::debug::WasmValueObject> object =
value.As<v8::debug::WasmValueObject>();
@ -1700,6 +1703,7 @@ std::unique_ptr<ValueMirror> ValueMirror::create(v8::Local<v8::Context> context,
value, RemoteObject::SubtypeEnum::Wasmvalue,
descriptionForObject(isolate, object));
}
#endif // V8_ENABLE_WEBASSEMBLY
V8InternalValueType internalType =
v8InternalValueTypeFrom(context, value.As<v8::Object>());
if (value->IsArray() && internalType == V8InternalValueType::kScopeList) {

View File

@ -614,7 +614,9 @@ bool CanSubclassHaveInobjectProperties(InstanceType instance_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;
case BIGINT_TYPE:

View File

@ -7,7 +7,6 @@
#include "src/api/api-arguments-inl.h"
#include "src/common/globals.h"
#include "src/date/date.h"
#include "src/debug/debug-wasm-objects.h"
#include "src/execution/arguments.h"
#include "src/execution/frames.h"
#include "src/execution/isolate.h"
@ -72,6 +71,10 @@
#include "src/utils/ostreams.h"
#include "src/wasm/wasm-objects.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/debug/debug-wasm-objects.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {
@ -2299,8 +2302,10 @@ 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;
default:

View File

@ -311,7 +311,9 @@ VisitorId Map::GetVisitorId(Map map) {
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: {
const bool has_raw_data_fields =
COMPRESS_POINTERS_BOOL && JSObject::GetEmbedderFieldCount(map) > 0;

View File

@ -224,7 +224,7 @@ class ZoneForwardList;
V(WasmStruct) \
V(WasmTypeInfo) \
V(WasmTableObject) \
V(WasmValueObject) \
IF_WASM(V, WasmValueObject) \
V(WeakFixedArray) \
V(WeakArrayList) \
V(WeakCell) \

View File

@ -1002,7 +1002,9 @@ ReturnType BodyDescriptorApply(InstanceType type, T1 p1, T2 p2, T3 p3, T4 p4) {
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);
case WASM_INSTANCE_OBJECT_TYPE:
return Op::template apply<WasmInstanceObject::BodyDescriptor>(p1, p2, p3,

View File

@ -10,7 +10,6 @@
#include "src/debug/debug-evaluate.h"
#include "src/debug/debug-frames.h"
#include "src/debug/debug-scopes.h"
#include "src/debug/debug-wasm-objects.h"
#include "src/debug/debug.h"
#include "src/debug/liveedit.h"
#include "src/execution/arguments-inl.h"
@ -32,6 +31,10 @@
#include "src/snapshot/snapshot.h"
#include "src/wasm/wasm-objects-inl.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/debug/debug-wasm-objects.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {
@ -221,13 +224,16 @@ MaybeHandle<JSArray> Runtime::GetInternalProperties(Isolate* isolate,
factory->NewJSArrayWithElements(bound_arguments);
result->set(5, *arguments_array);
return factory->NewJSArrayWithElements(result);
} else if (object->IsJSMapIterator()) {
}
if (object->IsJSMapIterator()) {
Handle<JSMapIterator> iterator = Handle<JSMapIterator>::cast(object);
return GetIteratorInternalProperties(isolate, iterator);
} else if (object->IsJSSetIterator()) {
}
if (object->IsJSSetIterator()) {
Handle<JSSetIterator> iterator = Handle<JSSetIterator>::cast(object);
return GetIteratorInternalProperties(isolate, iterator);
} else if (object->IsJSGeneratorObject()) {
}
if (object->IsJSGeneratorObject()) {
Handle<JSGeneratorObject> generator =
Handle<JSGeneratorObject>::cast(object);
@ -257,7 +263,8 @@ MaybeHandle<JSArray> Runtime::GetInternalProperties(Isolate* isolate,
result->set(4, *receiver);
result->set(5, generator->receiver());
return factory->NewJSArrayWithElements(result);
} else if (object->IsJSPromise()) {
}
if (object->IsJSPromise()) {
Handle<JSPromise> promise = Handle<JSPromise>::cast(object);
const char* status = JSPromise::Status(promise->status());
Handle<FixedArray> result = factory->NewFixedArray(2 * 2);
@ -276,7 +283,8 @@ MaybeHandle<JSArray> Runtime::GetInternalProperties(Isolate* isolate,
result->set(2, *promise_value);
result->set(3, *value_obj);
return factory->NewJSArrayWithElements(result);
} else if (object->IsJSProxy()) {
}
if (object->IsJSProxy()) {
Handle<JSProxy> js_proxy = Handle<JSProxy>::cast(object);
Handle<FixedArray> result = factory->NewFixedArray(3 * 2);
@ -295,7 +303,8 @@ MaybeHandle<JSArray> Runtime::GetInternalProperties(Isolate* isolate,
result->set(4, *is_revoked_str);
result->set(5, isolate->heap()->ToBoolean(js_proxy->IsRevoked()));
return factory->NewJSArrayWithElements(result);
} else if (object->IsJSPrimitiveWrapper()) {
}
if (object->IsJSPrimitiveWrapper()) {
Handle<JSPrimitiveWrapper> js_value =
Handle<JSPrimitiveWrapper>::cast(object);
@ -305,7 +314,8 @@ MaybeHandle<JSArray> Runtime::GetInternalProperties(Isolate* isolate,
result->set(0, *primitive_value);
result->set(1, js_value->value());
return factory->NewJSArrayWithElements(result);
} else if (object->IsJSArrayBuffer()) {
}
if (object->IsJSArrayBuffer()) {
Handle<JSArrayBuffer> js_array_buffer = Handle<JSArrayBuffer>::cast(object);
if (js_array_buffer->was_detached()) {
// Mark a detached JSArrayBuffer and such and don't even try to
@ -379,13 +389,17 @@ MaybeHandle<JSArray> Runtime::GetInternalProperties(Isolate* isolate,
}
return factory->NewJSArrayWithElements(result, PACKED_ELEMENTS, index);
} else if (object->IsWasmInstanceObject()) {
}
#if V8_ENABLE_WEBASSEMBLY
if (object->IsWasmInstanceObject()) {
return GetWasmInstanceObjectInternalProperties(
Handle<WasmInstanceObject>::cast(object));
} else if (object->IsWasmModuleObject()) {
}
if (object->IsWasmModuleObject()) {
return GetWasmModuleObjectInternalProperties(
Handle<WasmModuleObject>::cast(object));
}
#endif // V8_ENABLE_WEBASSEMBLY
return factory->NewJSArray(0);
}

View File

@ -99,6 +99,7 @@ def MakeClangCommandLine(plugin, plugin_args, arch_cfg, clang_bin_dir,
arch_cfg.arch_define,
"-DENABLE_DEBUGGER_SUPPORT",
"-DV8_INTL_SUPPORT",
"-DV8_ENABLE_WEBASSEMBLY",
"-I./",
"-Iinclude/",
"-Iout/build/gen",