Chromium Code Reviews| 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); |
| } |