Chromium Code Reviews| Index: src/compiler/wasm-compiler.cc |
| diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc |
| index 4e9c03a711ef34b0ba57394e9c3950ae30f2722b..0fd64b3d05cff10d995ee09c79ac8f0f2634d668 100644 |
| --- a/src/compiler/wasm-compiler.cc |
| +++ b/src/compiler/wasm-compiler.cc |
| @@ -334,6 +334,10 @@ bool WasmGraphBuilder::IsPhiWithMerge(Node* phi, Node* merge) { |
| NodeProperties::GetControlInput(phi) == merge; |
| } |
| +bool WasmGraphBuilder::DoesNotThrow(Node* node) { |
| + return node->op()->HasProperty(compiler::Operator::kNoThrow); |
| +} |
| + |
| void WasmGraphBuilder::AppendToMerge(Node* merge, Node* from) { |
| DCHECK(IrOpcode::IsMergeOpcode(merge->opcode())); |
| merge->AppendInput(jsgraph()->zone(), from); |
| @@ -1726,6 +1730,50 @@ Node* WasmGraphBuilder::Throw(Node* input) { |
| arraysize(parameters), effect_, *control_); |
| } |
| +Node* WasmGraphBuilder::Catch(Node* input, wasm::WasmCodePosition position) { |
| + CommonOperatorBuilder* common = jsgraph()->common(); |
| + |
| + Node* parameters[] = {input}; // caught value |
| + Node* value = BuildCallToRuntime(Runtime::kWasmCatch, jsgraph(), |
|
bradnelson
2016/09/27 04:25:56
I think this might be a problem (defer to Ben / if
titzer
2016/09/28 12:53:31
The collector does walk WASM frames and process re
John
2016/09/28 13:37:18
Acknowledged.
|
| + module_->instance->context, parameters, |
| + arraysize(parameters), effect_, *control_); |
| + |
| + Node* is_smi; |
| + Node* is_heap; |
| + Branch(BuildTestNotSmi(value), &is_heap, &is_smi); |
| + |
| + // is_heap |
| + Node* heap_f64 = BuildLoadHeapNumberValue(value, is_heap); |
| + // *control_ needs to point to the current control dependency (is_heap) in |
| + // case BuildI32SConvertF64 needs to insert nodes that depend on the "current" |
| + // control node. |
| + *control_ = is_heap; |
| + Node* heap_i32 = BuildI32SConvertF64(heap_f64, position); |
| + // *control_ contains the control node that should be used when merging the |
| + // result for the catch clause. It may be different than *control_ because |
| + // BuildI32SConvertF64 may introduce a new control node (used for trapping if |
| + // heap_f64 cannot be converted to an i32. |
| + is_heap = *control_; |
| + |
| + // is_smi |
| + Node* smi_i32 = BuildChangeSmiToInt32(value); |
| + |
| + Node* merge = graph()->NewNode(common->Merge(2), is_heap, is_smi); |
| + Node* value_i32 = graph()->NewNode( |
| + common->Phi(MachineRepresentation::kWord32, 2), heap_i32, smi_i32, merge); |
| + |
| + *control_ = merge; |
| + return value_i32; |
| +} |
| + |
| +Node* WasmGraphBuilder::IfSuccess(Node* node) { |
| + return graph()->NewNode(jsgraph()->common()->IfSuccess(), node); |
| +} |
| + |
| +Node* WasmGraphBuilder::IfException(Node* node) { |
| + return graph()->NewNode(jsgraph()->common()->IfException(), node, node); |
| +} |
| + |
| Node* WasmGraphBuilder::BuildI32DivS(Node* left, Node* right, |
| wasm::WasmCodePosition position) { |
| MachineOperatorBuilder* m = jsgraph()->machine(); |