Chromium Code Reviews| Index: src/compiler/wasm-compiler.cc |
| diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc |
| index b457efec4ec3e0e34ddd7305b16f1539a29fc631..0b6e36d6799753c057e24e24c2a63aa51e8c2ac1 100644 |
| --- a/src/compiler/wasm-compiler.cc |
| +++ b/src/compiler/wasm-compiler.cc |
| @@ -374,6 +374,63 @@ Node* WasmGraphBuilder::Int64Constant(int64_t value) { |
| return jsgraph()->Int64Constant(value); |
| } |
| +void WasmGraphBuilder::InitStackCheck(wasm::WasmCodePosition position) { |
| + // We do not generate stack checks for cctests. |
| + if (module_ && !module_->instance->context.is_null()) { |
| + Node* limit = graph()->NewNode( |
| + jsgraph()->machine()->Load(MachineType::Pointer()), |
| + jsgraph()->ExternalConstant( |
| + ExternalReference::address_of_stack_limit(jsgraph()->isolate())), |
| + jsgraph()->IntPtrConstant(0), *effect_, *control_); |
| + Node* pointer = graph()->NewNode(jsgraph()->machine()->LoadStackPointer()); |
| + |
| + Node* check = |
| + graph()->NewNode(jsgraph()->machine()->UintLessThan(), limit, pointer); |
| + |
| + Node* branch = graph()->NewNode( |
|
titzer
2016/08/17 11:17:23
Can use a Diamond here?
ahaas
2016/08/17 16:12:57
Done.
|
| + jsgraph()->common()->Branch(BranchHint::kTrue), check, *control_); |
| + |
| + Node* if_true = graph()->NewNode(jsgraph()->common()->IfTrue(), branch); |
| + Node* effect_true = *effect_; |
| + |
| + Node* if_false = graph()->NewNode(jsgraph()->common()->IfFalse(), branch); |
| + Node* effect_false; |
| + |
| + // Generate a call to the runtime if there is a stack overflow. |
| + { |
| + // Use the module context to call the runtime to throw an exception. |
| + Runtime::FunctionId f = Runtime::kStackGuard; |
| + const Runtime::Function* fun = Runtime::FunctionForId(f); |
| + CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor( |
| + jsgraph()->zone(), f, fun->nargs, Operator::kNoProperties, |
| + CallDescriptor::kNoFlags); |
| + // CEntryStubConstant nodes have to be created and cached in the main |
| + // thread. At the moment this is only done for CEntryStubConstant(1). |
| + Node* inputs[] = { |
| + jsgraph()->CEntryStubConstant(fun->result_size), // C entry |
| + jsgraph()->ExternalConstant( |
| + ExternalReference(f, jsgraph()->isolate())), // ref |
| + jsgraph()->Int32Constant(fun->nargs), // arity |
| + HeapConstant(module_->instance->context), // context |
| + *effect_, |
| + if_false}; |
| + |
| + Node* node = |
| + graph()->NewNode(jsgraph()->common()->Call(desc), |
| + static_cast<int>(arraysize(inputs)), inputs); |
| + effect_false = node; |
| + } |
| + |
| + Node* merge = |
| + graph()->NewNode(jsgraph()->common()->Merge(2), if_true, if_false); |
| + Node* ephi = graph()->NewNode(jsgraph()->common()->EffectPhi(2), |
| + effect_true, effect_false, merge); |
| + |
| + *control_ = merge; |
| + *effect_ = ephi; |
| + } |
| +} |
| + |
| Node* WasmGraphBuilder::Binop(wasm::WasmOpcode opcode, Node* left, Node* right, |
| wasm::WasmCodePosition position) { |
| const Operator* op; |