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

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: Rebase 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
Index: src/compiler/wasm-compiler.cc
diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc
index 511367ee2a4f541a362e1f5523f49499c23e0dad..e4b11316e86613247154427968c218614f388fe0 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,35 @@ Node* WasmGraphBuilder::BuildFloatToIntConversionInstruction(
return load;
}
+Node* WasmGraphBuilder::BuildGrowMemory(Node* input) {
+ Runtime::FunctionId f = Runtime::kWasmGrowMemory;
ahaas 2016/06/24 11:10:15 personal preference: would it be possible to use b
gdeepti 2016/06/25 00:28:41 Done.
+ const Runtime::Function* fun = Runtime::FunctionForId(f);
+ CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor(
+ jsgraph()->zone(), f, fun->nargs, Operator::kNoProperties,
+ CallDescriptor::kNoFlags);
+ Node** control_ptr = control_;
+ Node** effect_ptr = effect_;
+ wasm::ModuleEnv* module = module_;
+ *control_ptr = graph()->NewNode(jsgraph()->common()->Merge(1), *control_ptr);
+ *effect_ptr = graph()->NewNode(jsgraph()->common()->EffectPhi(1), *effect_ptr,
+ *control_ptr);
+ input = BuildChangeUint32ToSmi(input);
+ Node* inputs[] = {
+ jsgraph()->CEntryStubConstant(fun->result_size), input, // C entry
+ jsgraph()->ExternalConstant(
+ ExternalReference(f, jsgraph()->isolate())), // ref
+ jsgraph()->Int32Constant(fun->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();
@@ -2282,6 +2313,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));
@@ -2587,7 +2627,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') | src/runtime/runtime-wasm.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698