Commit 9f015e7e authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Inline {WasmInstanceObject::GrowMemory} everywhere.

R=titzer@chromium.org

Change-Id: I9d2bc2fdaec03b109cb6620371e70fc74a1a5ed4
Reviewed-on: https://chromium-review.googlesource.com/966283
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52000}
parent c7d68161
...@@ -76,8 +76,8 @@ RUNTIME_FUNCTION(Runtime_WasmGrowMemory) { ...@@ -76,8 +76,8 @@ RUNTIME_FUNCTION(Runtime_WasmGrowMemory) {
DCHECK_NULL(isolate->context()); DCHECK_NULL(isolate->context());
isolate->set_context(instance->compiled_module()->native_context()); isolate->set_context(instance->compiled_module()->native_context());
return *isolate->factory()->NewNumberFromInt( return *isolate->factory()->NewNumberFromInt(WasmMemoryObject::Grow(
WasmInstanceObject::GrowMemory(isolate, instance, delta_pages)); isolate, handle(instance->memory_object(), isolate), delta_pages));
} }
RUNTIME_FUNCTION(Runtime_ThrowWasmError) { RUNTIME_FUNCTION(Runtime_ThrowWasmError) {
......
...@@ -994,10 +994,6 @@ class CodeMap { ...@@ -994,10 +994,6 @@ class CodeMap {
DCHECK(has_instance()); DCHECK(has_instance());
return *instance_; return *instance_;
} }
MaybeHandle<WasmInstanceObject> maybe_instance() const {
return has_instance() ? handle(instance())
: MaybeHandle<WasmInstanceObject>();
}
const wasm::WasmCode* GetImportedFunction(uint32_t function_index) { const wasm::WasmCode* GetImportedFunction(uint32_t function_index) {
DCHECK(has_instance()); DCHECK(has_instance());
...@@ -2129,12 +2125,12 @@ class ThreadImpl { ...@@ -2129,12 +2125,12 @@ class ThreadImpl {
MemoryIndexOperand<Decoder::kNoValidate> operand(&decoder, MemoryIndexOperand<Decoder::kNoValidate> operand(&decoder,
code->at(pc)); code->at(pc));
uint32_t delta_pages = Pop().to<uint32_t>(); uint32_t delta_pages = Pop().to<uint32_t>();
Handle<WasmInstanceObject> instance = Handle<WasmMemoryObject> memory(
codemap()->maybe_instance().ToHandleChecked(); codemap()->instance()->memory_object());
DCHECK_EQ(wasm_context_, instance->wasm_context()->get()); DCHECK_EQ(wasm_context_,
Isolate* isolate = instance->GetIsolate(); codemap()->instance()->wasm_context()->get());
int32_t result = Isolate* isolate = memory->GetIsolate();
WasmInstanceObject::GrowMemory(isolate, instance, delta_pages); int32_t result = WasmMemoryObject::Grow(isolate, memory, delta_pages);
Push(WasmValue(result)); Push(WasmValue(result));
len = 1 + operand.length; len = 1 + operand.length;
// Treat one grow_memory instruction like 1000 other instructions, // Treat one grow_memory instruction like 1000 other instructions,
......
...@@ -629,14 +629,6 @@ Handle<WasmInstanceObject> WasmInstanceObject::New( ...@@ -629,14 +629,6 @@ Handle<WasmInstanceObject> WasmInstanceObject::New(
return instance; return instance;
} }
int32_t WasmInstanceObject::GrowMemory(Isolate* isolate,
Handle<WasmInstanceObject> instance,
uint32_t pages) {
DCHECK(instance->has_memory_object());
return WasmMemoryObject::Grow(
isolate, handle(instance->memory_object(), isolate), pages);
}
WasmInstanceObject* WasmInstanceObject::GetOwningInstance( WasmInstanceObject* WasmInstanceObject::GetOwningInstance(
const wasm::WasmCode* code) { const wasm::WasmCode* code) {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
...@@ -762,13 +754,15 @@ bool WasmExportedFunction::IsWasmExportedFunction(Object* object) { ...@@ -762,13 +754,15 @@ bool WasmExportedFunction::IsWasmExportedFunction(Object* object) {
Handle<JSFunction> js_function(JSFunction::cast(object)); Handle<JSFunction> js_function(JSFunction::cast(object));
if (Code::JS_TO_WASM_FUNCTION != js_function->code()->kind()) return false; if (Code::JS_TO_WASM_FUNCTION != js_function->code()->kind()) return false;
#ifdef DEBUG
// Any function having code of {JS_TO_WASM_FUNCTION} kind must be an exported // Any function having code of {JS_TO_WASM_FUNCTION} kind must be an exported
// function and hence will have a property holding the instance object. // function and hence will have a property holding the instance object.
DCHECK(JSObject::GetPropertyOrElement( Handle<Symbol> symbol(
js_function, js_function->GetIsolate()->factory()->wasm_instance_symbol());
js_function->GetIsolate()->factory()->wasm_instance_symbol()) MaybeHandle<Object> result =
.ToHandleChecked() JSObject::GetPropertyOrElement(js_function, symbol);
->IsWasmInstanceObject()); DCHECK(result.ToHandleChecked()->IsWasmInstanceObject());
#endif
return true; return true;
} }
......
...@@ -254,9 +254,6 @@ class WasmInstanceObject : public JSObject { ...@@ -254,9 +254,6 @@ class WasmInstanceObject : public JSObject {
static Handle<WasmInstanceObject> New(Isolate*, Handle<WasmCompiledModule>); static Handle<WasmInstanceObject> New(Isolate*, Handle<WasmCompiledModule>);
static int32_t GrowMemory(Isolate*, Handle<WasmInstanceObject>,
uint32_t pages);
// Assumed to be called with a code object associated to a wasm module // Assumed to be called with a code object associated to a wasm module
// instance. Intended to be called from runtime functions. Returns nullptr on // instance. Intended to be called from runtime functions. Returns nullptr on
// failing to get owning instance. // failing to get owning instance.
......
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