Index: src/runtime/runtime-wasm.cc |
diff --git a/src/runtime/runtime-wasm.cc b/src/runtime/runtime-wasm.cc |
index 4be8fa57184e71535bd8108b4dc3737c364db359..ab69046c457255e8f44974fa4798370b5b31cefd 100644 |
--- a/src/runtime/runtime-wasm.cc |
+++ b/src/runtime/runtime-wasm.cc |
@@ -18,6 +18,27 @@ |
namespace v8 { |
namespace internal { |
+RUNTIME_FUNCTION(Runtime_WasmMemorySize) { |
+ HandleScope scope(isolate); |
+ DCHECK_EQ(0, args.length()); |
+ |
+ Handle<JSObject> module_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; |
+ Object* owning_instance = wasm::GetOwningWasmInstance(code); |
+ CHECK_NOT_NULL(owning_instance); |
+ module_instance = handle(JSObject::cast(owning_instance), isolate); |
+ } |
+ return *isolate->factory()->NewNumberFromInt( |
+ wasm::GetInstanceMemorySize(isolate, module_instance)); |
+} |
+ |
RUNTIME_FUNCTION(Runtime_WasmGrowMemory) { |
HandleScope scope(isolate); |
DCHECK_EQ(1, args.length()); |