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 #include "src/compiler/linkage.h" | 8 #include "src/compiler/linkage.h" |
9 #include "src/compiler/machine-operator.h" | 9 #include "src/compiler/machine-operator.h" |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 } | 39 } |
40 UNREACHABLE(); | 40 UNREACHABLE(); |
41 return NoChange(); | 41 return NoChange(); |
42 } | 42 } |
43 | 43 |
44 | 44 |
45 Node* ChangeLowering::HeapNumberValueIndexConstant() { | 45 Node* ChangeLowering::HeapNumberValueIndexConstant() { |
46 STATIC_ASSERT(HeapNumber::kValueOffset % kPointerSize == 0); | 46 STATIC_ASSERT(HeapNumber::kValueOffset % kPointerSize == 0); |
47 const int heap_number_value_offset = | 47 const int heap_number_value_offset = |
48 ((HeapNumber::kValueOffset / kPointerSize) * (machine()->Is64() ? 8 : 4)); | 48 ((HeapNumber::kValueOffset / kPointerSize) * (machine()->Is64() ? 8 : 4)); |
49 return jsgraph()->Int32Constant(heap_number_value_offset - kHeapObjectTag); | 49 return jsgraph()->IntPtrConstant(heap_number_value_offset - kHeapObjectTag); |
50 } | 50 } |
51 | 51 |
52 | 52 |
53 Node* ChangeLowering::SmiMaxValueConstant() { | 53 Node* ChangeLowering::SmiMaxValueConstant() { |
54 const int smi_value_size = machine()->Is32() ? SmiTagging<4>::SmiValueSize() | 54 const int smi_value_size = machine()->Is32() ? SmiTagging<4>::SmiValueSize() |
55 : SmiTagging<8>::SmiValueSize(); | 55 : SmiTagging<8>::SmiValueSize(); |
56 return jsgraph()->Int32Constant( | 56 return jsgraph()->IntPtrConstant( |
57 -(static_cast<int>(0xffffffffu << (smi_value_size - 1)) + 1)); | 57 -(static_cast<int>(0xffffffffu << (smi_value_size - 1)) + 1)); |
58 } | 58 } |
59 | 59 |
60 | 60 |
61 Node* ChangeLowering::SmiShiftBitsConstant() { | 61 Node* ChangeLowering::SmiShiftBitsConstant() { |
62 const int smi_shift_size = machine()->Is32() ? SmiTagging<4>::SmiShiftSize() | 62 const int smi_shift_size = machine()->Is32() ? SmiTagging<4>::SmiShiftSize() |
63 : SmiTagging<8>::SmiShiftSize(); | 63 : SmiTagging<8>::SmiShiftSize(); |
64 return jsgraph()->Int32Constant(smi_shift_size + kSmiTagSize); | 64 return jsgraph()->IntPtrConstant(smi_shift_size + kSmiTagSize); |
65 } | 65 } |
66 | 66 |
67 | 67 |
68 Node* ChangeLowering::AllocateHeapNumberWithValue(Node* value, Node* control) { | 68 Node* ChangeLowering::AllocateHeapNumberWithValue(Node* value, Node* control) { |
69 // The AllocateHeapNumber() runtime function does not use the context, so we | 69 // The AllocateHeapNumber() runtime function does not use the context, so we |
70 // can safely pass in Smi zero here. | 70 // can safely pass in Smi zero here. |
71 Node* context = jsgraph()->ZeroConstant(); | 71 Node* context = jsgraph()->ZeroConstant(); |
72 Node* effect = graph()->NewNode(common()->ValueEffect(1), value); | 72 Node* effect = graph()->NewNode(common()->ValueEffect(1), value); |
73 const Runtime::Function* function = | 73 const Runtime::Function* function = |
74 Runtime::FunctionForId(Runtime::kAllocateHeapNumber); | 74 Runtime::FunctionForId(Runtime::kAllocateHeapNumber); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 return Replace(phi); | 159 return Replace(phi); |
160 } | 160 } |
161 | 161 |
162 | 162 |
163 Reduction ChangeLowering::ChangeTaggedToUI32(Node* val, Node* control, | 163 Reduction ChangeLowering::ChangeTaggedToUI32(Node* val, Node* control, |
164 Signedness signedness) { | 164 Signedness signedness) { |
165 STATIC_ASSERT(kSmiTag == 0); | 165 STATIC_ASSERT(kSmiTag == 0); |
166 STATIC_ASSERT(kSmiTagMask == 1); | 166 STATIC_ASSERT(kSmiTagMask == 1); |
167 | 167 |
168 Node* tag = graph()->NewNode(machine()->WordAnd(), val, | 168 Node* tag = graph()->NewNode(machine()->WordAnd(), val, |
169 jsgraph()->Int32Constant(kSmiTagMask)); | 169 jsgraph()->IntPtrConstant(kSmiTagMask)); |
170 Node* branch = graph()->NewNode(common()->Branch(), tag, control); | 170 Node* branch = graph()->NewNode(common()->Branch(), tag, control); |
171 | 171 |
172 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | 172 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
173 const Operator* op = (signedness == kSigned) | 173 const Operator* op = (signedness == kSigned) |
174 ? machine()->ChangeFloat64ToInt32() | 174 ? machine()->ChangeFloat64ToInt32() |
175 : machine()->ChangeFloat64ToUint32(); | 175 : machine()->ChangeFloat64ToUint32(); |
176 Node* change = graph()->NewNode(op, LoadHeapNumberValue(val, if_true)); | 176 Node* change = graph()->NewNode(op, LoadHeapNumberValue(val, if_true)); |
177 | 177 |
178 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 178 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
179 Node* number = ChangeSmiToInt32(val); | 179 Node* number = ChangeSmiToInt32(val); |
180 | 180 |
181 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); | 181 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); |
182 Node* phi = graph()->NewNode( | 182 Node* phi = graph()->NewNode( |
183 common()->Phi((signedness == kSigned) ? kMachInt32 : kMachUint32, 2), | 183 common()->Phi((signedness == kSigned) ? kMachInt32 : kMachUint32, 2), |
184 change, number, merge); | 184 change, number, merge); |
185 | 185 |
186 return Replace(phi); | 186 return Replace(phi); |
187 } | 187 } |
188 | 188 |
189 | 189 |
190 Reduction ChangeLowering::ChangeTaggedToFloat64(Node* val, Node* control) { | 190 Reduction ChangeLowering::ChangeTaggedToFloat64(Node* val, Node* control) { |
191 STATIC_ASSERT(kSmiTag == 0); | 191 STATIC_ASSERT(kSmiTag == 0); |
192 STATIC_ASSERT(kSmiTagMask == 1); | 192 STATIC_ASSERT(kSmiTagMask == 1); |
193 | 193 |
194 Node* tag = graph()->NewNode(machine()->WordAnd(), val, | 194 Node* tag = graph()->NewNode(machine()->WordAnd(), val, |
195 jsgraph()->Int32Constant(kSmiTagMask)); | 195 jsgraph()->IntPtrConstant(kSmiTagMask)); |
196 Node* branch = graph()->NewNode(common()->Branch(), tag, control); | 196 Node* branch = graph()->NewNode(common()->Branch(), tag, control); |
197 | 197 |
198 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | 198 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
199 Node* load = LoadHeapNumberValue(val, if_true); | 199 Node* load = LoadHeapNumberValue(val, if_true); |
200 | 200 |
201 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 201 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
202 Node* number = graph()->NewNode(machine()->ChangeInt32ToFloat64(), | 202 Node* number = graph()->NewNode(machine()->ChangeInt32ToFloat64(), |
203 ChangeSmiToInt32(val)); | 203 ChangeSmiToInt32(val)); |
204 | 204 |
205 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); | 205 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 } | 250 } |
251 | 251 |
252 | 252 |
253 MachineOperatorBuilder* ChangeLowering::machine() const { | 253 MachineOperatorBuilder* ChangeLowering::machine() const { |
254 return jsgraph()->machine(); | 254 return jsgraph()->machine(); |
255 } | 255 } |
256 | 256 |
257 } // namespace compiler | 257 } // namespace compiler |
258 } // namespace internal | 258 } // namespace internal |
259 } // namespace v8 | 259 } // namespace v8 |
OLD | NEW |