Commit 58200418 authored by Ben L. Titzer's avatar Ben L. Titzer Committed by Commit Bot

[wasm] Use WasmContext in the WasmInterpreter.

With the introduction of the WasmContext, compiled code is no longer
specialized to the memory start and size (or recently, globals_start).
This CL uses the same WasmContext between the interpreter and compiled
code, removing the need for UpdateMemory() and cached instance info.

R=clemensh@chromium.org

Bug: 
Change-Id: I0bd52352c9b6f3029246e94e239dc29f635e7920
Reviewed-on: https://chromium-review.googlesource.com/712734
Commit-Queue: Ben Titzer <titzer@chromium.org>
Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48584}
parent 089dd7d2
......@@ -136,28 +136,12 @@ class InterpreterHandle {
return {bytes_str->GetChars(), static_cast<size_t>(bytes_str->length())};
}
static uint32_t GetMemSize(WasmDebugInfo* debug_info) {
DisallowHeapAllocation no_gc;
return debug_info->wasm_instance()->wasm_context()->get()->mem_size;
}
static byte* GetMemStart(WasmDebugInfo* debug_info) {
DisallowHeapAllocation no_gc;
return debug_info->wasm_instance()->wasm_context()->get()->mem_start;
}
static byte* GetGlobalsStart(WasmDebugInfo* debug_info) {
DisallowHeapAllocation no_gc;
return debug_info->wasm_instance()->wasm_context()->get()->globals_start;
}
public:
InterpreterHandle(Isolate* isolate, WasmDebugInfo* debug_info)
: isolate_(isolate),
module_(debug_info->wasm_instance()->compiled_module()->module()),
interpreter_(isolate, module_, GetBytes(debug_info),
GetGlobalsStart(debug_info), GetMemStart(debug_info),
GetMemSize(debug_info)) {}
debug_info->wasm_instance()->wasm_context()->get()) {}
~InterpreterHandle() { DCHECK_EQ(0, activations_.size()); }
......@@ -422,13 +406,6 @@ class InterpreterHandle {
return interpreter()->GetThread(0)->NumInterpretedCalls();
}
void UpdateMemory(JSArrayBuffer* new_memory) {
byte* mem_start = reinterpret_cast<byte*>(new_memory->backing_store());
uint32_t mem_size;
CHECK(new_memory->byte_length()->ToUint32(&mem_size));
interpreter()->UpdateMemory(mem_start, mem_size);
}
Handle<JSObject> GetGlobalScopeObject(wasm::InterpretedFrame* frame,
Handle<WasmDebugInfo> debug_info) {
Isolate* isolate = debug_info->GetIsolate();
......@@ -744,12 +721,6 @@ uint64_t WasmDebugInfo::NumInterpretedCalls() {
return handle ? handle->NumInterpretedCalls() : 0;
}
void WasmDebugInfo::UpdateMemory(JSArrayBuffer* new_memory) {
auto* interp_handle = GetInterpreterHandleOrNull(this);
if (!interp_handle) return;
interp_handle->UpdateMemory(new_memory);
}
// static
Handle<JSObject> WasmDebugInfo::GetScopeDetails(
Handle<WasmDebugInfo> debug_info, Address frame_pointer, int frame_index) {
......
This diff is collapsed.
......@@ -16,6 +16,7 @@ class AccountingAllocator;
namespace internal {
class WasmInstanceObject;
struct WasmContext;
namespace wasm {
......@@ -172,8 +173,7 @@ class V8_EXPORT_PRIVATE WasmInterpreter {
};
WasmInterpreter(Isolate* isolate, const WasmModule* module,
const ModuleWireBytes& wire_bytes, byte* globals_start,
byte* mem_start, uint32_t mem_size);
const ModuleWireBytes& wire_bytes, WasmContext* wasm_context);
~WasmInterpreter();
//==========================================================================
......@@ -198,11 +198,6 @@ class V8_EXPORT_PRIVATE WasmInterpreter {
int GetThreadCount();
Thread* GetThread(int id);
//==========================================================================
// Update the cached module env memory parameters after a grow memory event.
//==========================================================================
void UpdateMemory(byte* mem_start, uint32_t mem_size);
//==========================================================================
// Testing functionality.
//==========================================================================
......
......@@ -368,9 +368,6 @@ Handle<JSArrayBuffer> GrowMemoryBuffer(Isolate* isolate,
void SetInstanceMemory(Isolate* isolate, Handle<WasmInstanceObject> instance,
Handle<JSArrayBuffer> buffer) {
instance->set_memory_buffer(*buffer);
if (instance->has_debug_info()) {
instance->debug_info()->UpdateMemory(*buffer);
}
auto wasm_context = instance->wasm_context()->get();
wasm_context->mem_start = reinterpret_cast<byte*>(buffer->backing_store());
wasm_context->mem_size = buffer->byte_length()->Number();
......
......@@ -632,10 +632,6 @@ class WasmDebugInfo : public FixedArray {
// Returns the number of calls / function frames executed in the interpreter.
uint64_t NumInterpretedCalls();
// Update the memory view of the interpreter after executing GrowMemory in
// compiled code.
void UpdateMemory(JSArrayBuffer* new_memory);
// Get scope details for a specific interpreted frame.
// This returns a JSArray of length two: One entry for the global scope, one
// for the local scope. Both elements are JSArrays of size
......
......@@ -53,9 +53,6 @@ byte* TestingModuleBuilder::AddMemory(uint32_t size) {
CHECK(size == 0 || mem_start_);
memset(mem_start_, 0, size);
if (interpreter_) {
interpreter_->UpdateMemory(mem_start_, mem_size_);
}
// Create the WasmMemoryObject.
Handle<WasmMemoryObject> memory_object = WasmMemoryObject::New(
isolate_, new_buffer,
......
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