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) {
DCHECK_NULL(isolate->context());
isolate->set_context(instance->compiled_module()->native_context());
return *isolate->factory()->NewNumberFromInt(
WasmInstanceObject::GrowMemory(isolate, instance, delta_pages));
return *isolate->factory()->NewNumberFromInt(WasmMemoryObject::Grow(
isolate, handle(instance->memory_object(), isolate), delta_pages));
}
RUNTIME_FUNCTION(Runtime_ThrowWasmError) {
......
......@@ -994,10 +994,6 @@ class CodeMap {
DCHECK(has_instance());
return *instance_;
}
MaybeHandle<WasmInstanceObject> maybe_instance() const {
return has_instance() ? handle(instance())
: MaybeHandle<WasmInstanceObject>();
}
const wasm::WasmCode* GetImportedFunction(uint32_t function_index) {
DCHECK(has_instance());
......@@ -2129,12 +2125,12 @@ class ThreadImpl {
MemoryIndexOperand<Decoder::kNoValidate> operand(&decoder,
code->at(pc));
uint32_t delta_pages = Pop().to<uint32_t>();
Handle<WasmInstanceObject> instance =
codemap()->maybe_instance().ToHandleChecked();
DCHECK_EQ(wasm_context_, instance->wasm_context()->get());
Isolate* isolate = instance->GetIsolate();
int32_t result =
WasmInstanceObject::GrowMemory(isolate, instance, delta_pages);
Handle<WasmMemoryObject> memory(
codemap()->instance()->memory_object());
DCHECK_EQ(wasm_context_,
codemap()->instance()->wasm_context()->get());
Isolate* isolate = memory->GetIsolate();
int32_t result = WasmMemoryObject::Grow(isolate, memory, delta_pages);
Push(WasmValue(result));
len = 1 + operand.length;
// Treat one grow_memory instruction like 1000 other instructions,
......
......@@ -629,14 +629,6 @@ Handle<WasmInstanceObject> WasmInstanceObject::New(
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(
const wasm::WasmCode* code) {
DisallowHeapAllocation no_gc;
......@@ -762,13 +754,15 @@ bool WasmExportedFunction::IsWasmExportedFunction(Object* object) {
Handle<JSFunction> js_function(JSFunction::cast(object));
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
// function and hence will have a property holding the instance object.
DCHECK(JSObject::GetPropertyOrElement(
js_function,
js_function->GetIsolate()->factory()->wasm_instance_symbol())
.ToHandleChecked()
->IsWasmInstanceObject());
Handle<Symbol> symbol(
js_function->GetIsolate()->factory()->wasm_instance_symbol());
MaybeHandle<Object> result =
JSObject::GetPropertyOrElement(js_function, symbol);
DCHECK(result.ToHandleChecked()->IsWasmInstanceObject());
#endif
return true;
}
......
......@@ -254,9 +254,6 @@ class WasmInstanceObject : public JSObject {
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
// instance. Intended to be called from runtime functions. Returns nullptr on
// 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