Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1268)

Unified Diff: src/runtime/runtime-wasm.cc

Issue 2386183004: [wasm] Call a runtime function for a MemorySize instruction. (Closed)
Patch Set: Comments addressed Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | src/wasm/wasm-module.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
« no previous file with comments | « src/runtime/runtime.h ('k') | src/wasm/wasm-module.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698