Commit 1fd8f2ec authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Move breakpoint functions onto {WasmScript}.

R=clemensb@chromium.org
BUG=v8:6847,chromium:893069

Change-Id: I5b5ada546e1d0b9d42ea8f7278671bf2b128bef8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1862570Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64308}
parent 0d7889d0
...@@ -9265,8 +9265,8 @@ bool debug::Script::GetPossibleBreakpoints( ...@@ -9265,8 +9265,8 @@ bool debug::Script::GetPossibleBreakpoints(
if (script->type() == i::Script::TYPE_WASM && if (script->type() == i::Script::TYPE_WASM &&
this->SourceMappingURL().IsEmpty()) { this->SourceMappingURL().IsEmpty()) {
i::wasm::NativeModule* native_module = script->wasm_native_module(); i::wasm::NativeModule* native_module = script->wasm_native_module();
return i::WasmModuleObject::GetPossibleBreakpoints(native_module, start, return i::WasmScript::GetPossibleBreakpoints(native_module, start, end,
end, locations); locations);
} }
i::Script::InitLineEnds(script); i::Script::InitLineEnds(script);
......
...@@ -622,8 +622,7 @@ bool Debug::SetBreakPointForScript(Handle<Script> script, ...@@ -622,8 +622,7 @@ bool Debug::SetBreakPointForScript(Handle<Script> script,
Handle<BreakPoint> break_point = Handle<BreakPoint> break_point =
isolate_->factory()->NewBreakPoint(*id, condition); isolate_->factory()->NewBreakPoint(*id, condition);
if (script->type() == Script::TYPE_WASM) { if (script->type() == Script::TYPE_WASM) {
return WasmModuleObject::SetBreakPoint(script, source_position, return WasmScript::SetBreakPoint(script, source_position, break_point);
break_point);
} }
HandleScope scope(isolate_); HandleScope scope(isolate_);
......
...@@ -536,7 +536,7 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() { ...@@ -536,7 +536,7 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() {
// Debugging support. // Debugging support.
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// Set all breakpoints that were set on the shared module. // Set all breakpoints that were set on the shared module.
WasmModuleObject::SetBreakpointsOnNewInstance( WasmScript::SetBreakpointsOnNewInstance(
handle(module_object_->script(), isolate_), instance); handle(module_object_->script(), isolate_), instance);
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
......
This diff is collapsed.
This diff is collapsed.
...@@ -152,30 +152,9 @@ class WasmModuleObject : public JSObject { ...@@ -152,30 +152,9 @@ class WasmModuleObject : public JSObject {
Handle<Script> script, Handle<FixedArray> export_wrappers, Handle<Script> script, Handle<FixedArray> export_wrappers,
size_t code_size_estimate); size_t code_size_estimate);
// TODO(mstarzinger): The below breakpoint handling methods taking a {Script}
// instead of a {WasmModuleObject} as first argument should be moved onto a
// separate {WasmScript} class, implementation move to wasm-debug.cc then.
// Set a breakpoint on the given byte position inside the given module.
// This will affect all live and future instances of the module.
// The passed position might be modified to point to the next breakable
// location inside the same function.
// If it points outside a function, or behind the last breakable location,
// this function returns false and does not set any breakpoint.
V8_EXPORT_PRIVATE static bool SetBreakPoint(Handle<Script>, int* position,
Handle<BreakPoint> break_point);
// Remove a previously set breakpoint at the given byte position inside the
// given module. If this breakpoint is not found this function returns false.
V8_EXPORT_PRIVATE static bool ClearBreakPoint(Handle<Script>, int position,
Handle<BreakPoint> break_point);
// Check whether this module was generated from asm.js source. // Check whether this module was generated from asm.js source.
inline bool is_asm_js(); inline bool is_asm_js();
static void SetBreakpointsOnNewInstance(Handle<Script>,
Handle<WasmInstanceObject>);
// Get the module name, if set. Returns an empty handle otherwise. // Get the module name, if set. Returns an empty handle otherwise.
static MaybeHandle<String> GetModuleNameOrNull(Isolate*, static MaybeHandle<String> GetModuleNameOrNull(Isolate*,
Handle<WasmModuleObject>); Handle<WasmModuleObject>);
...@@ -214,25 +193,7 @@ class WasmModuleObject : public JSObject { ...@@ -214,25 +193,7 @@ class WasmModuleObject : public JSObject {
Isolate* isolate, Vector<const uint8_t> wire_byte, Isolate* isolate, Vector<const uint8_t> wire_byte,
wasm::WireBytesRef ref); wasm::WireBytesRef ref);
// Get a list of all possible breakpoints within a given range of this module.
V8_EXPORT_PRIVATE static bool GetPossibleBreakpoints(
wasm::NativeModule* native_module, const debug::Location& start,
const debug::Location& end, std::vector<debug::BreakLocation>* locations);
// Return an empty handle if no breakpoint is hit at that location, or a
// FixedArray with all hit breakpoint objects.
static MaybeHandle<FixedArray> CheckBreakPoints(Isolate*, Handle<Script>,
int position);
OBJECT_CONSTRUCTORS(WasmModuleObject, JSObject); OBJECT_CONSTRUCTORS(WasmModuleObject, JSObject);
private:
// Helper functions that update the breakpoint info list.
static void AddBreakpointToInfo(Handle<Script>, int position,
Handle<BreakPoint> break_point);
static bool RemoveBreakpointFromInfo(Handle<Script>, int position,
Handle<BreakPoint> break_point);
}; };
// Representation of a WebAssembly.Table JavaScript-level object. // Representation of a WebAssembly.Table JavaScript-level object.
...@@ -915,6 +876,44 @@ class WasmDebugInfo : public Struct { ...@@ -915,6 +876,44 @@ class WasmDebugInfo : public Struct {
OBJECT_CONSTRUCTORS(WasmDebugInfo, Struct); OBJECT_CONSTRUCTORS(WasmDebugInfo, Struct);
}; };
class WasmScript : public AllStatic {
public:
// Set a breakpoint on the given byte position inside the given module.
// This will affect all live and future instances of the module.
// The passed position might be modified to point to the next breakable
// location inside the same function.
// If it points outside a function, or behind the last breakable location,
// this function returns false and does not set any breakpoint.
V8_EXPORT_PRIVATE static bool SetBreakPoint(Handle<Script>, int* position,
Handle<BreakPoint> break_point);
// Remove a previously set breakpoint at the given byte position inside the
// given module. If this breakpoint is not found this function returns false.
V8_EXPORT_PRIVATE static bool ClearBreakPoint(Handle<Script>, int position,
Handle<BreakPoint> break_point);
static void SetBreakpointsOnNewInstance(Handle<Script>,
Handle<WasmInstanceObject>);
// Get a list of all possible breakpoints within a given range of this module.
V8_EXPORT_PRIVATE static bool GetPossibleBreakpoints(
wasm::NativeModule* native_module, const debug::Location& start,
const debug::Location& end, std::vector<debug::BreakLocation>* locations);
// Return an empty handle if no breakpoint is hit at that location, or a
// FixedArray with all hit breakpoint objects.
static MaybeHandle<FixedArray> CheckBreakPoints(Isolate*, Handle<Script>,
int position);
private:
// Helper functions that update the breakpoint info list.
static void AddBreakpointToInfo(Handle<Script>, int position,
Handle<BreakPoint> break_point);
static bool RemoveBreakpointFromInfo(Handle<Script>, int position,
Handle<BreakPoint> break_point);
};
// Tags provide an object identity for each exception defined in a wasm module // Tags provide an object identity for each exception defined in a wasm module
// header. They are referenced by the following fields: // header. They are referenced by the following fields:
// - {WasmExceptionObject::exception_tag} : The tag of the exception object. // - {WasmExceptionObject::exception_tag} : The tag of the exception object.
......
...@@ -25,8 +25,8 @@ void CheckLocations( ...@@ -25,8 +25,8 @@ void CheckLocations(
NativeModule* native_module, debug::Location start, debug::Location end, NativeModule* native_module, debug::Location start, debug::Location end,
std::initializer_list<debug::Location> expected_locations_init) { std::initializer_list<debug::Location> expected_locations_init) {
std::vector<debug::BreakLocation> locations; std::vector<debug::BreakLocation> locations;
bool success = WasmModuleObject::GetPossibleBreakpoints(native_module, start, bool success =
end, &locations); WasmScript::GetPossibleBreakpoints(native_module, start, end, &locations);
CHECK(success); CHECK(success);
printf("got %d locations: ", static_cast<int>(locations.size())); printf("got %d locations: ", static_cast<int>(locations.size()));
...@@ -49,8 +49,8 @@ void CheckLocations( ...@@ -49,8 +49,8 @@ void CheckLocations(
void CheckLocationsFail(NativeModule* native_module, debug::Location start, void CheckLocationsFail(NativeModule* native_module, debug::Location start,
debug::Location end) { debug::Location end) {
std::vector<debug::BreakLocation> locations; std::vector<debug::BreakLocation> locations;
bool success = WasmModuleObject::GetPossibleBreakpoints(native_module, start, bool success =
end, &locations); WasmScript::GetPossibleBreakpoints(native_module, start, end, &locations);
CHECK(!success); CHECK(!success);
} }
...@@ -133,7 +133,7 @@ Handle<BreakPoint> SetBreakpoint(WasmRunnerBase* runner, int function_index, ...@@ -133,7 +133,7 @@ Handle<BreakPoint> SetBreakpoint(WasmRunnerBase* runner, int function_index,
Handle<BreakPoint> break_point = Handle<BreakPoint> break_point =
runner->main_isolate()->factory()->NewBreakPoint( runner->main_isolate()->factory()->NewBreakPoint(
break_index++, runner->main_isolate()->factory()->empty_string()); break_index++, runner->main_isolate()->factory()->empty_string());
CHECK(WasmModuleObject::SetBreakPoint(script, &code_offset, break_point)); CHECK(WasmScript::SetBreakPoint(script, &code_offset, break_point));
int set_byte_offset = code_offset - func_offset; int set_byte_offset = code_offset - func_offset;
CHECK_EQ(expected_set_byte_offset, set_byte_offset); CHECK_EQ(expected_set_byte_offset, set_byte_offset);
// Also set breakpoint on the debug info of the instance directly, since the // Also set breakpoint on the debug info of the instance directly, since the
...@@ -153,7 +153,7 @@ void ClearBreakpoint(WasmRunnerBase* runner, int function_index, ...@@ -153,7 +153,7 @@ void ClearBreakpoint(WasmRunnerBase* runner, int function_index,
Handle<WasmInstanceObject> instance = runner->builder().instance_object(); Handle<WasmInstanceObject> instance = runner->builder().instance_object();
Handle<Script> script(instance->module_object().script(), Handle<Script> script(instance->module_object().script(),
runner->main_isolate()); runner->main_isolate());
CHECK(WasmModuleObject::ClearBreakPoint(script, code_offset, break_point)); CHECK(WasmScript::ClearBreakPoint(script, code_offset, break_point));
// Also clear breakpoint on the debug info of the instance directly, since the // Also clear breakpoint on the debug info of the instance directly, since the
// instance chain is not setup properly in tests. // instance chain is not setup properly in tests.
Handle<WasmDebugInfo> debug_info = Handle<WasmDebugInfo> debug_info =
......
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