| Index: src/runtime/runtime-wasm.cc
|
| diff --git a/src/runtime/runtime-wasm.cc b/src/runtime/runtime-wasm.cc
|
| index 950c2dc8ede2f811d6669614d207aeeb28757030..46782cf575c1971bda284c87771f0a2017029948 100644
|
| --- a/src/runtime/runtime-wasm.cc
|
| +++ b/src/runtime/runtime-wasm.cc
|
| @@ -20,23 +20,25 @@
|
| namespace v8 {
|
| namespace internal {
|
|
|
| +namespace {
|
| +Handle<WasmInstanceObject> GetWasmInstanceOnStackTop(Isolate* isolate) {
|
| + DisallowHeapAllocation no_allocation;
|
| + const Address entry = Isolate::c_entry_fp(isolate->thread_local_top());
|
| + Address pc =
|
| + Memory::Address_at(entry + StandardFrameConstants::kCallerPCOffset);
|
| + Code* code = isolate->inner_pointer_to_code_cache()->GetCacheEntry(pc)->code;
|
| + DCHECK_EQ(Code::WASM_FUNCTION, code->kind());
|
| + WasmInstanceObject* owning_instance = wasm::GetOwningWasmInstance(code);
|
| + CHECK_NOT_NULL(owning_instance);
|
| + return handle(owning_instance, isolate);
|
| +}
|
| +} // namespace
|
| +
|
| RUNTIME_FUNCTION(Runtime_WasmMemorySize) {
|
| HandleScope scope(isolate);
|
| DCHECK_EQ(0, args.length());
|
|
|
| - Handle<WasmInstanceObject> instance;
|
| - {
|
| - // Get the module JSObject
|
| - DisallowHeapAllocation no_allocation;
|
| - const Address entry = Isolate::c_entry_fp(isolate->thread_local_top());
|
| - Address pc =
|
| - Memory::Address_at(entry + StandardFrameConstants::kCallerPCOffset);
|
| - Code* code =
|
| - isolate->inner_pointer_to_code_cache()->GetCacheEntry(pc)->code;
|
| - WasmInstanceObject* owning_instance = wasm::GetOwningWasmInstance(code);
|
| - CHECK_NOT_NULL(owning_instance);
|
| - instance = handle(owning_instance, isolate);
|
| - }
|
| + Handle<WasmInstanceObject> instance = GetWasmInstanceOnStackTop(isolate);
|
| return *isolate->factory()->NewNumberFromInt(
|
| wasm::GetInstanceMemorySize(isolate, instance));
|
| }
|
| @@ -45,19 +47,7 @@ RUNTIME_FUNCTION(Runtime_WasmGrowMemory) {
|
| HandleScope scope(isolate);
|
| DCHECK_EQ(1, args.length());
|
| CONVERT_UINT32_ARG_CHECKED(delta_pages, 0);
|
| - Handle<WasmInstanceObject> instance;
|
| - {
|
| - // Get the module JSObject
|
| - DisallowHeapAllocation no_allocation;
|
| - const Address entry = Isolate::c_entry_fp(isolate->thread_local_top());
|
| - Address pc =
|
| - Memory::Address_at(entry + StandardFrameConstants::kCallerPCOffset);
|
| - Code* code =
|
| - isolate->inner_pointer_to_code_cache()->GetCacheEntry(pc)->code;
|
| - WasmInstanceObject* owning_instance = wasm::GetOwningWasmInstance(code);
|
| - CHECK_NOT_NULL(owning_instance);
|
| - instance = handle(owning_instance, isolate);
|
| - }
|
| + Handle<WasmInstanceObject> instance = GetWasmInstanceOnStackTop(isolate);
|
| return *isolate->factory()->NewNumberFromInt(
|
| wasm::GrowMemory(isolate, instance, delta_pages));
|
| }
|
|
|