Chromium Code Reviews| Index: src/compiler/wasm-compiler.cc |
| diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc |
| index 0a13f98d8593f32e8990752d7d1a64451314ae6d..a6fb886d3726e13db7f7b8f7fb296c31c9817084 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 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_; |
| + *control_ptr = graph()->NewNode(jsgraph()->common()->Merge(1), *control_ptr); |
|
ahaas
2016/06/27 15:08:25
why do you create a Merge and an EffectPhi node he
gdeepti
2016/06/27 19:18:54
I misunderstood how control/effect pointers should
|
| + *effect_ptr = graph()->NewNode(jsgraph()->common()->EffectPhi(1), *effect_ptr, |
| + *control_ptr); |
| + 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 +2314,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 +2628,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); |
| } |