Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Unified Diff: src/wasm/wasm-debug.cc

Issue 2651793003: [wasm] Test argument passing in the interpreter entry (Closed)
Patch Set: Naming Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/wasm/wasm-interpreter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-debug.cc
diff --git a/src/wasm/wasm-debug.cc b/src/wasm/wasm-debug.cc
index 33135c4ffc46a67fadc0496b0226ebe930b22830..8ffaa9d2365a2df3462191d009f82292ebe24b45 100644
--- a/src/wasm/wasm-debug.cc
+++ b/src/wasm/wasm-debug.cc
@@ -273,6 +273,11 @@ class InterpreterHandle {
return std::unique_ptr<wasm::InterpretedFrame>(
new wasm::InterpretedFrame(thread->GetMutableFrame(idx)));
}
+
+ uint64_t NumInterpretedCalls() {
+ DCHECK_EQ(1, interpreter()->GetThreadCount());
+ return interpreter()->GetThread(0)->NumInterpretedCalls();
+ }
};
InterpreterHandle* GetOrCreateInterpreterHandle(
@@ -294,6 +299,12 @@ InterpreterHandle* GetInterpreterHandle(WasmDebugInfo* debug_info) {
return Managed<InterpreterHandle>::cast(handle_obj)->get();
}
+InterpreterHandle* GetInterpreterHandleOrNull(WasmDebugInfo* debug_info) {
+ Object* handle_obj = debug_info->get(WasmDebugInfo::kInterpreterHandle);
+ if (handle_obj->IsUndefined(debug_info->GetIsolate())) return nullptr;
+ return Managed<InterpreterHandle>::cast(handle_obj)->get();
+}
+
int GetNumFunctions(WasmInstanceObject* instance) {
size_t num_functions =
instance->compiled_module()->module()->functions.size();
@@ -345,26 +356,6 @@ void RedirectCallsitesInInstance(Isolate* isolate, WasmInstanceObject* instance,
}
}
-void EnsureRedirectToInterpreter(Isolate* isolate,
- Handle<WasmDebugInfo> debug_info,
- int func_index) {
- Handle<FixedArray> interpreted_functions =
- GetOrCreateInterpretedFunctions(isolate, debug_info);
- if (!interpreted_functions->get(func_index)->IsUndefined(isolate)) return;
-
- Handle<WasmInstanceObject> instance(debug_info->wasm_instance(), isolate);
- Handle<Code> new_code = compiler::CompileWasmInterpreterEntry(
- isolate, func_index,
- instance->compiled_module()->module()->functions[func_index].sig,
- instance);
-
- Handle<FixedArray> code_table = instance->compiled_module()->code_table();
- Handle<Code> old_code(Code::cast(code_table->get(func_index)), isolate);
- interpreted_functions->set(func_index, *new_code);
-
- RedirectCallsitesInInstance(isolate, *instance, *old_code, *new_code);
-}
-
} // namespace
Handle<WasmDebugInfo> WasmDebugInfo::New(Handle<WasmInstanceObject> instance) {
@@ -400,12 +391,34 @@ void WasmDebugInfo::SetBreakpoint(Handle<WasmDebugInfo> debug_info,
int func_index, int offset) {
Isolate* isolate = debug_info->GetIsolate();
InterpreterHandle* handle = GetOrCreateInterpreterHandle(isolate, debug_info);
- WasmInterpreter* interpreter = handle->interpreter();
- DCHECK_LE(0, func_index);
- DCHECK_GT(handle->module()->functions.size(), func_index);
+ RedirectToInterpreter(debug_info, func_index);
const WasmFunction* func = &handle->module()->functions[func_index];
- interpreter->SetBreakpoint(func, offset, true);
- EnsureRedirectToInterpreter(isolate, debug_info, func_index);
+ handle->interpreter()->SetBreakpoint(func, offset, true);
+}
+
+void WasmDebugInfo::RedirectToInterpreter(Handle<WasmDebugInfo> debug_info,
+ int func_index) {
+ Isolate* isolate = debug_info->GetIsolate();
+ DCHECK_LE(0, func_index);
+ DCHECK_GT(debug_info->wasm_instance()->module()->functions.size(),
+ func_index);
+ Handle<FixedArray> interpreted_functions =
+ GetOrCreateInterpretedFunctions(isolate, debug_info);
+ if (!interpreted_functions->get(func_index)->IsUndefined(isolate)) return;
+
+ // Ensure that the interpreter is instantiated.
+ GetOrCreateInterpreterHandle(isolate, debug_info);
+ Handle<WasmInstanceObject> instance(debug_info->wasm_instance(), isolate);
+ Handle<Code> new_code = compiler::CompileWasmInterpreterEntry(
+ isolate, func_index,
+ instance->compiled_module()->module()->functions[func_index].sig,
+ instance);
+
+ Handle<FixedArray> code_table = instance->compiled_module()->code_table();
+ Handle<Code> old_code(Code::cast(code_table->get(func_index)), isolate);
+ interpreted_functions->set(func_index, *new_code);
+
+ RedirectCallsitesInInstance(isolate, *instance, *old_code, *new_code);
}
void WasmDebugInfo::PrepareStep(StepAction step_action) {
@@ -427,3 +440,8 @@ std::unique_ptr<wasm::InterpretedFrame> WasmDebugInfo::GetInterpretedFrame(
Address frame_pointer, int idx) {
return GetInterpreterHandle(this)->GetInterpretedFrame(frame_pointer, idx);
}
+
+uint64_t WasmDebugInfo::NumInterpretedCalls() {
+ auto handle = GetInterpreterHandleOrNull(this);
+ return handle ? handle->NumInterpretedCalls() : 0;
+}
« no previous file with comments | « no previous file | src/wasm/wasm-interpreter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698