Commit a36ff8f0 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Lower HeapNumber allocations to Allocate nodes.

First step towards unifying the allocation story in TurboFan.

R=jarin@chromium.org

Review URL: https://codereview.chromium.org/1900593002

Cr-Commit-Position: refs/heads/master@{#35577}
parent 973fc5b9
......@@ -433,24 +433,18 @@ EffectControlLinearizer::LowerChangeUint32ToTagged(Node* node, Node* effect,
EffectControlLinearizer::ValueEffectControl
EffectControlLinearizer::AllocateHeapNumberWithValue(Node* value, Node* effect,
Node* control) {
// The AllocateHeapNumberStub does not use the context, so we can safely pass
// in Smi zero here.
Callable callable = CodeFactory::AllocateHeapNumber(jsgraph()->isolate());
Node* target = jsgraph()->HeapConstant(callable.code());
Node* context = jsgraph()->NoContextConstant();
if (!allocate_heap_number_operator_.is_set()) {
CallDescriptor* descriptor = Linkage::GetStubCallDescriptor(
jsgraph()->isolate(), jsgraph()->zone(), callable.descriptor(), 0,
CallDescriptor::kNoFlags, Operator::kNoThrow);
allocate_heap_number_operator_.set(common()->Call(descriptor));
}
Node* heap_number = graph()->NewNode(allocate_heap_number_operator_.get(),
target, context, effect, control);
Node* store = graph()->NewNode(
machine()->Store(StoreRepresentation(MachineRepresentation::kFloat64,
kNoWriteBarrier)),
heap_number, HeapNumberValueIndexConstant(), value, heap_number, control);
return ValueEffectControl(heap_number, store, control);
effect = graph()->NewNode(common()->BeginRegion(), effect);
Node* result = effect =
graph()->NewNode(simplified()->Allocate(NOT_TENURED),
jsgraph()->Constant(HeapNumber::kSize), effect, control);
effect = graph()->NewNode(simplified()->StoreField(AccessBuilder::ForMap()),
result, jsgraph()->HeapNumberMapConstant(), effect,
control);
effect = graph()->NewNode(
simplified()->StoreField(AccessBuilder::ForHeapNumberValue()), result,
value, effect, control);
result = effect = graph()->NewNode(common()->FinishRegion(), result, effect);
return ValueEffectControl(result, effect, control);
}
Node* EffectControlLinearizer::ChangeInt32ToSmi(Node* value) {
......@@ -475,10 +469,6 @@ Node* EffectControlLinearizer::ChangeUint32ToFloat64(Node* value) {
return graph()->NewNode(machine()->ChangeUint32ToFloat64(), value);
}
Node* EffectControlLinearizer::HeapNumberValueIndexConstant() {
return jsgraph()->IntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag);
}
Node* EffectControlLinearizer::SmiMaxValueConstant() {
return jsgraph()->Int32Constant(Smi::kMaxValue);
}
......
......@@ -55,7 +55,6 @@ class EffectControlLinearizer {
Node* ChangeInt32ToFloat64(Node* value);
Node* ChangeUint32ToFloat64(Node* value);
Node* HeapNumberValueIndexConstant();
Node* SmiMaxValueConstant();
Node* SmiShiftBitsConstant();
......@@ -70,7 +69,6 @@ class EffectControlLinearizer {
JSGraph* js_graph_;
Schedule* schedule_;
Zone* temp_zone_;
SetOncePointer<const Operator> allocate_heap_number_operator_;
};
} // namespace compiler
......
......@@ -29,6 +29,11 @@ Node* JSGraph::EmptyFixedArrayConstant() {
HeapConstant(factory()->empty_fixed_array()));
}
Node* JSGraph::HeapNumberMapConstant() {
return CACHED(kHeapNumberMapConstant,
HeapConstant(factory()->heap_number_map()));
}
Node* JSGraph::OptimizedOutConstant() {
return CACHED(kOptimizedOutConstant,
HeapConstant(factory()->optimized_out()));
......
......@@ -41,6 +41,7 @@ class JSGraph : public ZoneObject {
// Canonicalized global constants.
Node* CEntryStubConstant(int result_size);
Node* EmptyFixedArrayConstant();
Node* HeapNumberMapConstant();
Node* OptimizedOutConstant();
Node* UndefinedConstant();
Node* TheHoleConstant();
......@@ -141,6 +142,7 @@ class JSGraph : public ZoneObject {
enum CachedNode {
kCEntryStubConstant,
kEmptyFixedArrayConstant,
kHeapNumberMapConstant,
kOptimizedOutConstant,
kUndefinedConstant,
kTheHoleConstant,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment