OLD | NEW |
---|---|
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/wasm-compiler.h" | 5 #include "src/compiler/wasm-compiler.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
10 | 10 |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
327 | 327 |
328 unsigned WasmGraphBuilder::InputCount(Node* node) { | 328 unsigned WasmGraphBuilder::InputCount(Node* node) { |
329 return static_cast<unsigned>(node->InputCount()); | 329 return static_cast<unsigned>(node->InputCount()); |
330 } | 330 } |
331 | 331 |
332 bool WasmGraphBuilder::IsPhiWithMerge(Node* phi, Node* merge) { | 332 bool WasmGraphBuilder::IsPhiWithMerge(Node* phi, Node* merge) { |
333 return phi && IrOpcode::IsPhiOpcode(phi->opcode()) && | 333 return phi && IrOpcode::IsPhiOpcode(phi->opcode()) && |
334 NodeProperties::GetControlInput(phi) == merge; | 334 NodeProperties::GetControlInput(phi) == merge; |
335 } | 335 } |
336 | 336 |
337 bool WasmGraphBuilder::DoesNotThrow(Node* node) { | |
338 return node->op()->HasProperty(compiler::Operator::kNoThrow); | |
339 } | |
340 | |
337 void WasmGraphBuilder::AppendToMerge(Node* merge, Node* from) { | 341 void WasmGraphBuilder::AppendToMerge(Node* merge, Node* from) { |
338 DCHECK(IrOpcode::IsMergeOpcode(merge->opcode())); | 342 DCHECK(IrOpcode::IsMergeOpcode(merge->opcode())); |
339 merge->AppendInput(jsgraph()->zone(), from); | 343 merge->AppendInput(jsgraph()->zone(), from); |
340 int new_size = merge->InputCount(); | 344 int new_size = merge->InputCount(); |
341 NodeProperties::ChangeOp( | 345 NodeProperties::ChangeOp( |
342 merge, jsgraph()->common()->ResizeMergeOrPhi(merge->op(), new_size)); | 346 merge, jsgraph()->common()->ResizeMergeOrPhi(merge->op(), new_size)); |
343 } | 347 } |
344 | 348 |
345 void WasmGraphBuilder::AppendToPhi(Node* phi, Node* from) { | 349 void WasmGraphBuilder::AppendToPhi(Node* phi, Node* from) { |
346 DCHECK(IrOpcode::IsPhiOpcode(phi->opcode())); | 350 DCHECK(IrOpcode::IsPhiOpcode(phi->opcode())); |
(...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1719 graph()->NewNode(machine->Word32Shr(), input, Int32Constant(16))); | 1723 graph()->NewNode(machine->Word32Shr(), input, Int32Constant(16))); |
1720 Node* lower = BuildChangeInt32ToSmi( | 1724 Node* lower = BuildChangeInt32ToSmi( |
1721 graph()->NewNode(machine->Word32And(), input, Int32Constant(0xFFFFu))); | 1725 graph()->NewNode(machine->Word32And(), input, Int32Constant(0xFFFFu))); |
1722 | 1726 |
1723 Node* parameters[] = {lower, upper}; // thrown value | 1727 Node* parameters[] = {lower, upper}; // thrown value |
1724 return BuildCallToRuntime(Runtime::kWasmThrow, jsgraph(), | 1728 return BuildCallToRuntime(Runtime::kWasmThrow, jsgraph(), |
1725 module_->instance->context, parameters, | 1729 module_->instance->context, parameters, |
1726 arraysize(parameters), effect_, *control_); | 1730 arraysize(parameters), effect_, *control_); |
1727 } | 1731 } |
1728 | 1732 |
1733 Node* WasmGraphBuilder::Catch(Node* input, wasm::WasmCodePosition position) { | |
1734 CommonOperatorBuilder* common = jsgraph()->common(); | |
1735 | |
1736 Node* parameters[] = {input}; // caught value | |
1737 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.
| |
1738 module_->instance->context, parameters, | |
1739 arraysize(parameters), effect_, *control_); | |
1740 | |
1741 Node* is_smi; | |
1742 Node* is_heap; | |
1743 Branch(BuildTestNotSmi(value), &is_heap, &is_smi); | |
1744 | |
1745 // is_heap | |
1746 Node* heap_f64 = BuildLoadHeapNumberValue(value, is_heap); | |
1747 // *control_ needs to point to the current control dependency (is_heap) in | |
1748 // case BuildI32SConvertF64 needs to insert nodes that depend on the "current" | |
1749 // control node. | |
1750 *control_ = is_heap; | |
1751 Node* heap_i32 = BuildI32SConvertF64(heap_f64, position); | |
1752 // *control_ contains the control node that should be used when merging the | |
1753 // result for the catch clause. It may be different than *control_ because | |
1754 // BuildI32SConvertF64 may introduce a new control node (used for trapping if | |
1755 // heap_f64 cannot be converted to an i32. | |
1756 is_heap = *control_; | |
1757 | |
1758 // is_smi | |
1759 Node* smi_i32 = BuildChangeSmiToInt32(value); | |
1760 | |
1761 Node* merge = graph()->NewNode(common->Merge(2), is_heap, is_smi); | |
1762 Node* value_i32 = graph()->NewNode( | |
1763 common->Phi(MachineRepresentation::kWord32, 2), heap_i32, smi_i32, merge); | |
1764 | |
1765 *control_ = merge; | |
1766 return value_i32; | |
1767 } | |
1768 | |
1769 Node* WasmGraphBuilder::IfSuccess(Node* node) { | |
1770 return graph()->NewNode(jsgraph()->common()->IfSuccess(), node); | |
1771 } | |
1772 | |
1773 Node* WasmGraphBuilder::IfException(Node* node) { | |
1774 return graph()->NewNode(jsgraph()->common()->IfException(), node, node); | |
1775 } | |
1776 | |
1729 Node* WasmGraphBuilder::BuildI32DivS(Node* left, Node* right, | 1777 Node* WasmGraphBuilder::BuildI32DivS(Node* left, Node* right, |
1730 wasm::WasmCodePosition position) { | 1778 wasm::WasmCodePosition position) { |
1731 MachineOperatorBuilder* m = jsgraph()->machine(); | 1779 MachineOperatorBuilder* m = jsgraph()->machine(); |
1732 trap_->ZeroCheck32(wasm::kTrapDivByZero, right, position); | 1780 trap_->ZeroCheck32(wasm::kTrapDivByZero, right, position); |
1733 Node* before = *control_; | 1781 Node* before = *control_; |
1734 Node* denom_is_m1; | 1782 Node* denom_is_m1; |
1735 Node* denom_is_not_m1; | 1783 Node* denom_is_not_m1; |
1736 Branch( | 1784 Branch( |
1737 graph()->NewNode(m->Word32Equal(), right, jsgraph()->Int32Constant(-1)), | 1785 graph()->NewNode(m->Word32Equal(), right, jsgraph()->Int32Constant(-1)), |
1738 &denom_is_m1, &denom_is_not_m1); | 1786 &denom_is_m1, &denom_is_not_m1); |
(...skipping 1559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3298 function_->code_start_offset), | 3346 function_->code_start_offset), |
3299 compile_ms); | 3347 compile_ms); |
3300 } | 3348 } |
3301 | 3349 |
3302 return code; | 3350 return code; |
3303 } | 3351 } |
3304 | 3352 |
3305 } // namespace compiler | 3353 } // namespace compiler |
3306 } // namespace internal | 3354 } // namespace internal |
3307 } // namespace v8 | 3355 } // namespace v8 |
OLD | NEW |