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

Unified Diff: src/compiler/wasm-compiler.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 | « no previous file | src/runtime/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/wasm-compiler.cc
diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc
index dac9eec7a75a9ee22c49e7ee7ec114822a7f86ef..b003e9968aca0a218ae7a6f9d11db072c80c1e99 100644
--- a/src/compiler/wasm-compiler.cc
+++ b/src/compiler/wasm-compiler.cc
@@ -2759,8 +2759,27 @@ Node* WasmGraphBuilder::MemBuffer(uint32_t offset) {
}
Node* WasmGraphBuilder::CurrentMemoryPages() {
- return graph()->NewNode(jsgraph()->machine()->Word32Shr(), MemSize(0),
- jsgraph()->Int32Constant(16));
+ Runtime::FunctionId function_id = Runtime::kWasmMemorySize;
+ const Runtime::Function* function = Runtime::FunctionForId(function_id);
+ CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor(
+ jsgraph()->zone(), function_id, function->nargs, Operator::kNoThrow,
+ CallDescriptor::kNoFlags);
+ wasm::ModuleEnv* module = module_;
+ Node* inputs[] = {
+ jsgraph()->CEntryStubConstant(function->result_size), // C entry
+ jsgraph()->ExternalConstant(
+ ExternalReference(function_id, jsgraph()->isolate())), // ref
+ jsgraph()->Int32Constant(function->nargs), // arity
+ jsgraph()->HeapConstant(module->instance->context), // context
+ *effect_,
+ *control_};
+ Node* call = graph()->NewNode(jsgraph()->common()->Call(desc),
+ static_cast<int>(arraysize(inputs)), inputs);
+
+ Node* result = BuildChangeSmiToInt32(call);
+
+ *effect_ = call;
+ return result;
}
Node* WasmGraphBuilder::MemSize(uint32_t offset) {
« no previous file with comments | « no previous file | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698