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/code-factory.h" | |
7 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/linkage.h" | 9 #include "src/compiler/linkage.h" |
9 #include "src/compiler/machine-operator.h" | 10 #include "src/compiler/machine-operator.h" |
10 | 11 |
11 namespace v8 { | 12 namespace v8 { |
12 namespace internal { | 13 namespace internal { |
13 namespace compiler { | 14 namespace compiler { |
14 | 15 |
15 ChangeLowering::~ChangeLowering() {} | 16 ChangeLowering::~ChangeLowering() {} |
16 | 17 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 | 60 |
60 | 61 |
61 Node* ChangeLowering::SmiShiftBitsConstant() { | 62 Node* ChangeLowering::SmiShiftBitsConstant() { |
62 const int smi_shift_size = machine()->Is32() ? SmiTagging<4>::SmiShiftSize() | 63 const int smi_shift_size = machine()->Is32() ? SmiTagging<4>::SmiShiftSize() |
63 : SmiTagging<8>::SmiShiftSize(); | 64 : SmiTagging<8>::SmiShiftSize(); |
64 return jsgraph()->IntPtrConstant(smi_shift_size + kSmiTagSize); | 65 return jsgraph()->IntPtrConstant(smi_shift_size + kSmiTagSize); |
65 } | 66 } |
66 | 67 |
67 | 68 |
68 Node* ChangeLowering::AllocateHeapNumberWithValue(Node* value, Node* control) { | 69 Node* ChangeLowering::AllocateHeapNumberWithValue(Node* value, Node* control) { |
69 // The AllocateHeapNumber() runtime function does not use the context, so we | 70 // The AllocateHeapNumberStub does not use the context, so we can safely pass |
70 // can safely pass in Smi zero here. | 71 // in Smi zero here. |
72 Callable callable = CodeFactory::AllocateHeapNumber(isolate()); | |
73 CallDescriptor* descriptor = linkage()->GetStubCallDescriptor( | |
74 callable.descriptor(), 0, CallDescriptor::kPatchableCallSite); | |
Michael Starzinger
2014/11/04 12:56:05
Does this call-site really need to be patchable, t
Benedikt Meurer
2014/11/04 12:57:50
Done.
| |
75 Node* target = jsgraph()->HeapConstant(callable.code()); | |
71 Node* context = jsgraph()->ZeroConstant(); | 76 Node* context = jsgraph()->ZeroConstant(); |
72 Node* effect = graph()->NewNode(common()->ValueEffect(1), value); | 77 Node* effect = graph()->NewNode(common()->ValueEffect(1), value); |
73 const Runtime::Function* function = | 78 Node* heap_number = graph()->NewNode(common()->Call(descriptor), target, |
74 Runtime::FunctionForId(Runtime::kAllocateHeapNumber); | 79 context, effect, control); |
75 DCHECK_EQ(0, function->nargs); | |
76 CallDescriptor* desc = linkage()->GetRuntimeCallDescriptor( | |
77 function->function_id, 0, Operator::kNoProperties); | |
78 Node* heap_number = graph()->NewNode( | |
79 common()->Call(desc), jsgraph()->CEntryStubConstant(), | |
80 jsgraph()->ExternalConstant(ExternalReference(function, isolate())), | |
81 jsgraph()->Int32Constant(function->nargs), context, effect, control); | |
82 Node* store = graph()->NewNode( | 80 Node* store = graph()->NewNode( |
83 machine()->Store(StoreRepresentation(kMachFloat64, kNoWriteBarrier)), | 81 machine()->Store(StoreRepresentation(kMachFloat64, kNoWriteBarrier)), |
84 heap_number, HeapNumberValueIndexConstant(), value, heap_number, control); | 82 heap_number, HeapNumberValueIndexConstant(), value, heap_number, control); |
85 return graph()->NewNode(common()->Finish(1), heap_number, store); | 83 return graph()->NewNode(common()->Finish(1), heap_number, store); |
86 } | 84 } |
87 | 85 |
88 | 86 |
89 Node* ChangeLowering::ChangeSmiToInt32(Node* value) { | 87 Node* ChangeLowering::ChangeSmiToInt32(Node* value) { |
90 value = graph()->NewNode(machine()->WordSar(), value, SmiShiftBitsConstant()); | 88 value = graph()->NewNode(machine()->WordSar(), value, SmiShiftBitsConstant()); |
91 if (machine()->Is64()) { | 89 if (machine()->Is64()) { |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
251 } | 249 } |
252 | 250 |
253 | 251 |
254 MachineOperatorBuilder* ChangeLowering::machine() const { | 252 MachineOperatorBuilder* ChangeLowering::machine() const { |
255 return jsgraph()->machine(); | 253 return jsgraph()->machine(); |
256 } | 254 } |
257 | 255 |
258 } // namespace compiler | 256 } // namespace compiler |
259 } // namespace internal | 257 } // namespace internal |
260 } // namespace v8 | 258 } // namespace v8 |
OLD | NEW |