| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/change-lowering.h" | 5 #include "src/compiler/change-lowering.h" |
| 6 | 6 |
| 7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 | 82 |
| 83 Reduction ChangeLowering::ChangeFloat64ToTagged(Node* val, Node* control) { | 83 Reduction ChangeLowering::ChangeFloat64ToTagged(Node* val, Node* control) { |
| 84 return Replace(AllocateHeapNumberWithValue(val, control)); | 84 return Replace(AllocateHeapNumberWithValue(val, control)); |
| 85 } | 85 } |
| 86 | 86 |
| 87 | 87 |
| 88 Reduction ChangeLowering::ChangeInt32ToTagged(Node* val, Node* control) { | 88 Reduction ChangeLowering::ChangeInt32ToTagged(Node* val, Node* control) { |
| 89 if (machine()->is64()) { | 89 if (machine()->is64()) { |
| 90 return Replace( | 90 return Replace( |
| 91 graph()->NewNode(machine()->WordShl(), val, SmiShiftBitsConstant())); | 91 graph()->NewNode(machine()->Word64Shl(), |
| 92 graph()->NewNode(machine()->ChangeInt32ToInt64(), val), |
| 93 SmiShiftBitsConstant())); |
| 92 } | 94 } |
| 93 | 95 |
| 94 Node* add = graph()->NewNode(machine()->Int32AddWithOverflow(), val, val); | 96 Node* add = graph()->NewNode(machine()->Int32AddWithOverflow(), val, val); |
| 95 Node* ovf = graph()->NewNode(common()->Projection(1), add); | 97 Node* ovf = graph()->NewNode(common()->Projection(1), add); |
| 96 | 98 |
| 97 Node* branch = graph()->NewNode(common()->Branch(), ovf, control); | 99 Node* branch = graph()->NewNode(common()->Branch(), ovf, control); |
| 98 | 100 |
| 99 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | 101 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
| 100 Node* heap_number = AllocateHeapNumberWithValue( | 102 Node* heap_number = AllocateHeapNumberWithValue( |
| 101 graph()->NewNode(machine()->ChangeInt32ToFloat64(), val), if_true); | 103 graph()->NewNode(machine()->ChangeInt32ToFloat64(), val), if_true); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 122 Node* load = graph()->NewNode( | 124 Node* load = graph()->NewNode( |
| 123 machine()->Load(kMachFloat64), val, HeapNumberValueIndexConstant(), | 125 machine()->Load(kMachFloat64), val, HeapNumberValueIndexConstant(), |
| 124 graph()->NewNode(common()->ControlEffect(), if_true)); | 126 graph()->NewNode(common()->ControlEffect(), if_true)); |
| 125 Node* change = graph()->NewNode(machine()->ChangeFloat64ToInt32(), load); | 127 Node* change = graph()->NewNode(machine()->ChangeFloat64ToInt32(), load); |
| 126 | 128 |
| 127 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 129 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 128 Node* integer = | 130 Node* integer = |
| 129 graph()->NewNode(machine()->WordSar(), val, SmiShiftBitsConstant()); | 131 graph()->NewNode(machine()->WordSar(), val, SmiShiftBitsConstant()); |
| 130 Node* number = | 132 Node* number = |
| 131 machine()->is64() | 133 machine()->is64() |
| 132 ? graph()->NewNode(machine()->ConvertInt64ToInt32(), integer) | 134 ? graph()->NewNode(machine()->TruncateInt64ToInt32(), integer) |
| 133 : integer; | 135 : integer; |
| 134 | 136 |
| 135 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); | 137 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); |
| 136 Node* phi = graph()->NewNode(common()->Phi(2), change, number, merge); | 138 Node* phi = graph()->NewNode(common()->Phi(2), change, number, merge); |
| 137 | 139 |
| 138 return Replace(phi); | 140 return Replace(phi); |
| 139 } | 141 } |
| 140 | 142 |
| 141 | 143 |
| 142 Reduction ChangeLowering::ChangeTaggedToFloat64(Node* val, Node* control) { | 144 Reduction ChangeLowering::ChangeTaggedToFloat64(Node* val, Node* control) { |
| 143 STATIC_ASSERT(kSmiTag == 0); | 145 STATIC_ASSERT(kSmiTag == 0); |
| 144 STATIC_ASSERT(kSmiTagMask == 1); | 146 STATIC_ASSERT(kSmiTagMask == 1); |
| 145 | 147 |
| 146 Node* tag = graph()->NewNode(machine()->WordAnd(), val, | 148 Node* tag = graph()->NewNode(machine()->WordAnd(), val, |
| 147 jsgraph()->Int32Constant(kSmiTagMask)); | 149 jsgraph()->Int32Constant(kSmiTagMask)); |
| 148 Node* branch = graph()->NewNode(common()->Branch(), tag, control); | 150 Node* branch = graph()->NewNode(common()->Branch(), tag, control); |
| 149 | 151 |
| 150 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | 152 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
| 151 Node* load = graph()->NewNode( | 153 Node* load = graph()->NewNode( |
| 152 machine()->Load(kMachFloat64), val, HeapNumberValueIndexConstant(), | 154 machine()->Load(kMachFloat64), val, HeapNumberValueIndexConstant(), |
| 153 graph()->NewNode(common()->ControlEffect(), if_true)); | 155 graph()->NewNode(common()->ControlEffect(), if_true)); |
| 154 | 156 |
| 155 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 157 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 156 Node* integer = | 158 Node* integer = |
| 157 graph()->NewNode(machine()->WordSar(), val, SmiShiftBitsConstant()); | 159 graph()->NewNode(machine()->WordSar(), val, SmiShiftBitsConstant()); |
| 158 Node* number = graph()->NewNode( | 160 Node* number = graph()->NewNode( |
| 159 machine()->ChangeInt32ToFloat64(), | 161 machine()->ChangeInt32ToFloat64(), |
| 160 machine()->is64() | 162 machine()->is64() |
| 161 ? graph()->NewNode(machine()->ConvertInt64ToInt32(), integer) | 163 ? graph()->NewNode(machine()->TruncateInt64ToInt32(), integer) |
| 162 : integer); | 164 : integer); |
| 163 | 165 |
| 164 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); | 166 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); |
| 165 Node* phi = graph()->NewNode(common()->Phi(2), load, number, merge); | 167 Node* phi = graph()->NewNode(common()->Phi(2), load, number, merge); |
| 166 | 168 |
| 167 return Replace(phi); | 169 return Replace(phi); |
| 168 } | 170 } |
| 169 | 171 |
| 170 | 172 |
| 171 Isolate* ChangeLowering::isolate() const { return jsgraph()->isolate(); } | 173 Isolate* ChangeLowering::isolate() const { return jsgraph()->isolate(); } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 195 jsgraph()->Int32Constant(function->nargs), context, effect, control); | 197 jsgraph()->Int32Constant(function->nargs), context, effect, control); |
| 196 Node* store = graph()->NewNode( | 198 Node* store = graph()->NewNode( |
| 197 machine()->Store(kMachFloat64, kNoWriteBarrier), heap_number, | 199 machine()->Store(kMachFloat64, kNoWriteBarrier), heap_number, |
| 198 HeapNumberValueIndexConstant(), value, heap_number, control); | 200 HeapNumberValueIndexConstant(), value, heap_number, control); |
| 199 return graph()->NewNode(common()->Finish(1), heap_number, store); | 201 return graph()->NewNode(common()->Finish(1), heap_number, store); |
| 200 } | 202 } |
| 201 | 203 |
| 202 } // namespace compiler | 204 } // namespace compiler |
| 203 } // namespace internal | 205 } // namespace internal |
| 204 } // namespace v8 | 206 } // namespace v8 |
| OLD | NEW |