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

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

Issue 2051043002: Implement Wasm GrowMemory opcode as a wasm runtime call (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Review changes Created 4 years, 6 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/compiler/wasm-compiler.h ('k') | src/messages.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 0a13f98d8593f32e8990752d7d1a64451314ae6d..e8346399c4f512ddcff19fc882151d31cd6ac440 100644
--- a/src/compiler/wasm-compiler.cc
+++ b/src/compiler/wasm-compiler.cc
@@ -881,6 +881,8 @@ Node* WasmGraphBuilder::Unop(wasm::WasmOpcode opcode, Node* input,
return BuildI64UConvertF32(input, position);
case wasm::kExprI64UConvertF64:
return BuildI64UConvertF64(input, position);
+ case wasm::kExprGrowMemory:
+ return BuildGrowMemory(input);
case wasm::kExprI32AsmjsLoadMem8S:
return BuildAsmjsLoadMem(MachineType::Int8(), input);
case wasm::kExprI32AsmjsLoadMem8U:
@@ -1571,6 +1573,32 @@ Node* WasmGraphBuilder::BuildFloatToIntConversionInstruction(
return load;
}
+Node* WasmGraphBuilder::BuildGrowMemory(Node* input) {
+ Runtime::FunctionId function_id = Runtime::kWasmGrowMemory;
+ const Runtime::Function* function = Runtime::FunctionForId(function_id);
+ CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor(
+ jsgraph()->zone(), function_id, function->nargs, Operator::kNoProperties,
+ CallDescriptor::kNoFlags);
+ Node** control_ptr = control_;
+ Node** effect_ptr = effect_;
+ wasm::ModuleEnv* module = module_;
+ input = BuildChangeUint32ToSmi(input);
+ Node* inputs[] = {
+ jsgraph()->CEntryStubConstant(function->result_size), input, // C entry
+ jsgraph()->ExternalConstant(
+ ExternalReference(function_id, jsgraph()->isolate())), // ref
+ jsgraph()->Int32Constant(function->nargs), // arity
+ jsgraph()->HeapConstant(module->instance->context), // context
+ *effect_ptr,
+ *control_ptr};
+ Node* node = graph()->NewNode(jsgraph()->common()->Call(desc),
+ static_cast<int>(arraysize(inputs)), inputs);
+ *control_ptr = node;
+ *effect_ptr = node;
+ node = BuildChangeSmiToInt32(node);
+ return node;
+}
+
Node* WasmGraphBuilder::BuildI32DivS(Node* left, Node* right,
wasm::WasmCodePosition position) {
MachineOperatorBuilder* m = jsgraph()->machine();
@@ -2283,6 +2311,15 @@ Node* WasmGraphBuilder::BuildChangeSmiToInt32(Node* value) {
return value;
}
+Node* WasmGraphBuilder::BuildChangeUint32ToSmi(Node* value) {
+ if (jsgraph()->machine()->Is64()) {
+ value =
+ graph()->NewNode(jsgraph()->machine()->ChangeUint32ToUint64(), value);
+ }
+ return graph()->NewNode(jsgraph()->machine()->WordShl(), value,
+ BuildSmiShiftBitsConstant());
+}
+
Node* WasmGraphBuilder::BuildChangeSmiToFloat64(Node* value) {
return graph()->NewNode(jsgraph()->machine()->ChangeInt32ToFloat64(),
BuildChangeSmiToInt32(value));
@@ -2588,7 +2625,6 @@ void WasmGraphBuilder::BoundsCheckMem(MachineType memtype, Node* index,
jsgraph()->RelocatableInt32Constant(
static_cast<uint32_t>(effective_size),
RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
-
trap_->AddTrapIfFalse(wasm::kTrapMemOutOfBounds, cond, position);
}
« no previous file with comments | « src/compiler/wasm-compiler.h ('k') | src/messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698