[turbofan] Remove left-over change bits from ChangeLowering.
Now ChangeLowering is only concerned with lowering memory access and allocation operations, and all changes are consistently lowered during the effect/control linearization pass. The next step is to move the left over lowerings to a pass dedicated to eliminate redundant loads and stores, eliminate write barriers, fold and inline allocations. Also remove the atomic regions now that we wire everything into the effect chain properly. This is an important step towards allocation inlining. Drive-by-fix: Rename ChangeBitToBool to ChangeBitToTagged, ChangeBoolToBit to ChangeTaggedToBit, and ChangeInt31ToTagged to ChangeInt31ToTaggedSigned for consistency. CQ_INCLUDE_TRYBOTS=tryserver.v8:v8_linux64_tsan_rel Review-Url: https://codereview.chromium.org/1941673002 Cr-Commit-Position: refs/heads/master@{#35924}
This commit is contained in:
parent
d9462d04a0
commit
ceca5ae308
@ -4,14 +4,12 @@
|
||||
|
||||
#include "src/compiler/change-lowering.h"
|
||||
|
||||
#include "src/address-map.h"
|
||||
#include "src/code-factory.h"
|
||||
#include "src/compiler/js-graph.h"
|
||||
#include "src/compiler/linkage.h"
|
||||
#include "src/compiler/machine-operator.h"
|
||||
#include "src/compiler/node-properties.h"
|
||||
#include "src/compiler/operator-properties.h"
|
||||
#include "src/compiler/simplified-operator.h"
|
||||
#include "src/conversions-inl.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -21,16 +19,7 @@ ChangeLowering::~ChangeLowering() {}
|
||||
|
||||
|
||||
Reduction ChangeLowering::Reduce(Node* node) {
|
||||
Node* control = graph()->start();
|
||||
switch (node->opcode()) {
|
||||
case IrOpcode::kChangeBitToBool:
|
||||
return ReduceChangeBitToBool(node->InputAt(0), control);
|
||||
case IrOpcode::kChangeBoolToBit:
|
||||
return ReduceChangeBoolToBit(node->InputAt(0));
|
||||
case IrOpcode::kChangeInt31ToTagged:
|
||||
return ReduceChangeInt31ToTagged(node->InputAt(0), control);
|
||||
case IrOpcode::kChangeTaggedSignedToInt32:
|
||||
return ReduceChangeTaggedSignedToInt32(node->InputAt(0));
|
||||
case IrOpcode::kLoadField:
|
||||
return ReduceLoadField(node);
|
||||
case IrOpcode::kStoreField:
|
||||
@ -41,8 +30,6 @@ Reduction ChangeLowering::Reduce(Node* node) {
|
||||
return ReduceStoreElement(node);
|
||||
case IrOpcode::kAllocate:
|
||||
return ReduceAllocate(node);
|
||||
case IrOpcode::kObjectIsSmi:
|
||||
return ReduceObjectIsSmi(node);
|
||||
default:
|
||||
return NoChange();
|
||||
}
|
||||
@ -50,50 +37,6 @@ Reduction ChangeLowering::Reduce(Node* node) {
|
||||
return NoChange();
|
||||
}
|
||||
|
||||
Node* ChangeLowering::SmiShiftBitsConstant() {
|
||||
return jsgraph()->IntPtrConstant(kSmiShiftSize + kSmiTagSize);
|
||||
}
|
||||
|
||||
Node* ChangeLowering::ChangeInt32ToSmi(Node* value) {
|
||||
if (machine()->Is64()) {
|
||||
value = graph()->NewNode(machine()->ChangeInt32ToInt64(), value);
|
||||
}
|
||||
return graph()->NewNode(machine()->WordShl(), value, SmiShiftBitsConstant());
|
||||
}
|
||||
|
||||
Node* ChangeLowering::ChangeSmiToWord32(Node* value) {
|
||||
value = graph()->NewNode(machine()->WordSar(), value, SmiShiftBitsConstant());
|
||||
if (machine()->Is64()) {
|
||||
value = graph()->NewNode(machine()->TruncateInt64ToInt32(), value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
Node* ChangeLowering::ChangeUint32ToFloat64(Node* value) {
|
||||
return graph()->NewNode(machine()->ChangeUint32ToFloat64(), value);
|
||||
}
|
||||
|
||||
Reduction ChangeLowering::ReduceChangeBitToBool(Node* value, Node* control) {
|
||||
return Replace(
|
||||
graph()->NewNode(common()->Select(MachineRepresentation::kTagged), value,
|
||||
jsgraph()->TrueConstant(), jsgraph()->FalseConstant()));
|
||||
}
|
||||
|
||||
Reduction ChangeLowering::ReduceChangeBoolToBit(Node* value) {
|
||||
return Replace(graph()->NewNode(machine()->WordEqual(), value,
|
||||
jsgraph()->TrueConstant()));
|
||||
}
|
||||
|
||||
Reduction ChangeLowering::ReduceChangeInt31ToTagged(Node* value,
|
||||
Node* control) {
|
||||
return Replace(ChangeInt32ToSmi(value));
|
||||
}
|
||||
|
||||
Reduction ChangeLowering::ReduceChangeTaggedSignedToInt32(Node* value) {
|
||||
return Replace(ChangeSmiToWord32(value));
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged,
|
||||
@ -205,15 +148,6 @@ Reduction ChangeLowering::ReduceAllocate(Node* node) {
|
||||
return Changed(node);
|
||||
}
|
||||
|
||||
Reduction ChangeLowering::ReduceObjectIsSmi(Node* node) {
|
||||
node->ReplaceInput(0,
|
||||
graph()->NewNode(machine()->WordAnd(), node->InputAt(0),
|
||||
jsgraph()->IntPtrConstant(kSmiTagMask)));
|
||||
node->AppendInput(graph()->zone(), jsgraph()->IntPtrConstant(kSmiTag));
|
||||
NodeProperties::ChangeOp(node, machine()->WordEqual());
|
||||
return Changed(node);
|
||||
}
|
||||
|
||||
Isolate* ChangeLowering::isolate() const { return jsgraph()->isolate(); }
|
||||
|
||||
|
||||
|
@ -27,25 +27,12 @@ class ChangeLowering final : public Reducer {
|
||||
Reduction Reduce(Node* node) final;
|
||||
|
||||
private:
|
||||
Node* SmiShiftBitsConstant();
|
||||
|
||||
Node* ChangeInt32ToSmi(Node* value);
|
||||
Node* ChangeSmiToWord32(Node* value);
|
||||
Node* ChangeUint32ToFloat64(Node* value);
|
||||
|
||||
Reduction ReduceChangeBitToBool(Node* value, Node* control);
|
||||
Reduction ReduceChangeBoolToBit(Node* value);
|
||||
Reduction ReduceChangeInt31ToTagged(Node* value, Node* control);
|
||||
Reduction ReduceChangeTaggedSignedToInt32(Node* value);
|
||||
|
||||
Reduction ReduceLoadField(Node* node);
|
||||
Reduction ReduceStoreField(Node* node);
|
||||
Reduction ReduceLoadElement(Node* node);
|
||||
Reduction ReduceStoreElement(Node* node);
|
||||
Reduction ReduceAllocate(Node* node);
|
||||
|
||||
Reduction ReduceObjectIsSmi(Node* node);
|
||||
|
||||
Node* ComputeIndex(const ElementAccess& access, Node* const key);
|
||||
Graph* graph() const;
|
||||
Isolate* isolate() const;
|
||||
|
@ -290,13 +290,8 @@ void EffectControlLinearizer::ProcessNode(Node* node, Node** effect,
|
||||
node->opcode() == IrOpcode::kBeginRegion) {
|
||||
// Update the value uses to the value input of the finish node and
|
||||
// the effect uses to the effect input.
|
||||
|
||||
// TODO(jarin) Enable this once we make sure everything with side effects
|
||||
// is marked as effectful.
|
||||
if (false) {
|
||||
return RemoveRegionNode(node);
|
||||
}
|
||||
}
|
||||
|
||||
if (node->opcode() == IrOpcode::kIfSuccess) {
|
||||
// We always schedule IfSuccess with its call, so skip it here.
|
||||
@ -346,6 +341,12 @@ bool EffectControlLinearizer::TryWireInStateEffect(Node* node, Node** effect,
|
||||
Node** control) {
|
||||
ValueEffectControl state(nullptr, nullptr, nullptr);
|
||||
switch (node->opcode()) {
|
||||
case IrOpcode::kChangeBitToTagged:
|
||||
state = LowerChangeBitToTagged(node, *effect, *control);
|
||||
break;
|
||||
case IrOpcode::kChangeInt31ToTaggedSigned:
|
||||
state = LowerChangeInt31ToTaggedSigned(node, *effect, *control);
|
||||
break;
|
||||
case IrOpcode::kChangeInt32ToTagged:
|
||||
state = LowerChangeInt32ToTagged(node, *effect, *control);
|
||||
break;
|
||||
@ -355,6 +356,12 @@ bool EffectControlLinearizer::TryWireInStateEffect(Node* node, Node** effect,
|
||||
case IrOpcode::kChangeFloat64ToTagged:
|
||||
state = LowerChangeFloat64ToTagged(node, *effect, *control);
|
||||
break;
|
||||
case IrOpcode::kChangeTaggedSignedToInt32:
|
||||
state = LowerChangeTaggedSignedToInt32(node, *effect, *control);
|
||||
break;
|
||||
case IrOpcode::kChangeTaggedToBit:
|
||||
state = LowerChangeTaggedToBit(node, *effect, *control);
|
||||
break;
|
||||
case IrOpcode::kChangeTaggedToInt32:
|
||||
state = LowerChangeTaggedToInt32(node, *effect, *control);
|
||||
break;
|
||||
@ -376,6 +383,9 @@ bool EffectControlLinearizer::TryWireInStateEffect(Node* node, Node** effect,
|
||||
case IrOpcode::kObjectIsReceiver:
|
||||
state = LowerObjectIsReceiver(node, *effect, *control);
|
||||
break;
|
||||
case IrOpcode::kObjectIsSmi:
|
||||
state = LowerObjectIsSmi(node, *effect, *control);
|
||||
break;
|
||||
case IrOpcode::kObjectIsString:
|
||||
state = LowerObjectIsString(node, *effect, *control);
|
||||
break;
|
||||
@ -460,6 +470,35 @@ EffectControlLinearizer::LowerChangeFloat64ToTagged(Node* node, Node* effect,
|
||||
return ValueEffectControl(value, effect, control);
|
||||
}
|
||||
|
||||
EffectControlLinearizer::ValueEffectControl
|
||||
EffectControlLinearizer::LowerChangeBitToTagged(Node* node, Node* effect,
|
||||
Node* control) {
|
||||
Node* value = node->InputAt(0);
|
||||
|
||||
Node* branch = graph()->NewNode(common()->Branch(), value, control);
|
||||
|
||||
Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
|
||||
Node* vtrue = jsgraph()->TrueConstant();
|
||||
|
||||
Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
|
||||
Node* vfalse = jsgraph()->FalseConstant();
|
||||
|
||||
control = graph()->NewNode(common()->Merge(2), if_true, if_false);
|
||||
value = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2),
|
||||
vtrue, vfalse, control);
|
||||
|
||||
return ValueEffectControl(value, effect, control);
|
||||
}
|
||||
|
||||
EffectControlLinearizer::ValueEffectControl
|
||||
EffectControlLinearizer::LowerChangeInt31ToTaggedSigned(Node* node,
|
||||
Node* effect,
|
||||
Node* control) {
|
||||
Node* value = node->InputAt(0);
|
||||
value = ChangeInt32ToSmi(value);
|
||||
return ValueEffectControl(value, effect, control);
|
||||
}
|
||||
|
||||
EffectControlLinearizer::ValueEffectControl
|
||||
EffectControlLinearizer::LowerChangeInt32ToTagged(Node* node, Node* effect,
|
||||
Node* control) {
|
||||
@ -517,19 +556,36 @@ EffectControlLinearizer::LowerChangeUint32ToTagged(Node* node, Node* effect,
|
||||
return ValueEffectControl(phi, ephi, merge);
|
||||
}
|
||||
|
||||
EffectControlLinearizer::ValueEffectControl
|
||||
EffectControlLinearizer::LowerChangeTaggedSignedToInt32(Node* node,
|
||||
Node* effect,
|
||||
Node* control) {
|
||||
Node* value = node->InputAt(0);
|
||||
value = ChangeSmiToInt32(value);
|
||||
return ValueEffectControl(value, effect, control);
|
||||
}
|
||||
|
||||
EffectControlLinearizer::ValueEffectControl
|
||||
EffectControlLinearizer::LowerChangeTaggedToBit(Node* node, Node* effect,
|
||||
Node* control) {
|
||||
Node* value = node->InputAt(0);
|
||||
value = graph()->NewNode(machine()->WordEqual(), value,
|
||||
jsgraph()->TrueConstant());
|
||||
return ValueEffectControl(value, effect, control);
|
||||
}
|
||||
|
||||
EffectControlLinearizer::ValueEffectControl
|
||||
EffectControlLinearizer::LowerChangeTaggedToInt32(Node* node, Node* effect,
|
||||
Node* control) {
|
||||
Node* value = node->InputAt(0);
|
||||
|
||||
Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value);
|
||||
Node* check = ObjectIsSmi(value);
|
||||
Node* branch =
|
||||
graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control);
|
||||
|
||||
Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
|
||||
Node* etrue = effect;
|
||||
Node* vtrue =
|
||||
graph()->NewNode(simplified()->ChangeTaggedSignedToInt32(), value);
|
||||
Node* vtrue = ChangeSmiToInt32(value);
|
||||
|
||||
Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
|
||||
Node* efalse = effect;
|
||||
@ -555,14 +611,13 @@ EffectControlLinearizer::LowerChangeTaggedToUint32(Node* node, Node* effect,
|
||||
Node* control) {
|
||||
Node* value = node->InputAt(0);
|
||||
|
||||
Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value);
|
||||
Node* check = ObjectIsSmi(value);
|
||||
Node* branch =
|
||||
graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control);
|
||||
|
||||
Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
|
||||
Node* etrue = effect;
|
||||
Node* vtrue =
|
||||
graph()->NewNode(simplified()->ChangeTaggedSignedToInt32(), value);
|
||||
Node* vtrue = ChangeSmiToInt32(value);
|
||||
|
||||
Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
|
||||
Node* efalse = effect;
|
||||
@ -588,7 +643,7 @@ EffectControlLinearizer::LowerChangeTaggedToFloat64(Node* node, Node* effect,
|
||||
Node* control) {
|
||||
Node* value = node->InputAt(0);
|
||||
|
||||
Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value);
|
||||
Node* check = ObjectIsSmi(value);
|
||||
Node* branch =
|
||||
graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control);
|
||||
|
||||
@ -596,7 +651,7 @@ EffectControlLinearizer::LowerChangeTaggedToFloat64(Node* node, Node* effect,
|
||||
Node* etrue = effect;
|
||||
Node* vtrue;
|
||||
{
|
||||
vtrue = graph()->NewNode(simplified()->ChangeTaggedSignedToInt32(), value);
|
||||
vtrue = ChangeSmiToInt32(value);
|
||||
vtrue = graph()->NewNode(machine()->ChangeInt32ToFloat64(), vtrue);
|
||||
}
|
||||
|
||||
@ -623,14 +678,13 @@ EffectControlLinearizer::LowerTruncateTaggedToWord32(Node* node, Node* effect,
|
||||
Node* control) {
|
||||
Node* value = node->InputAt(0);
|
||||
|
||||
Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value);
|
||||
Node* check = ObjectIsSmi(value);
|
||||
Node* branch =
|
||||
graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control);
|
||||
|
||||
Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
|
||||
Node* etrue = effect;
|
||||
Node* vtrue =
|
||||
graph()->NewNode(simplified()->ChangeTaggedSignedToInt32(), value);
|
||||
Node* vtrue = ChangeSmiToInt32(value);
|
||||
|
||||
Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
|
||||
Node* efalse = effect;
|
||||
@ -656,7 +710,7 @@ EffectControlLinearizer::LowerObjectIsCallable(Node* node, Node* effect,
|
||||
Node* control) {
|
||||
Node* value = node->InputAt(0);
|
||||
|
||||
Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value);
|
||||
Node* check = ObjectIsSmi(value);
|
||||
Node* branch =
|
||||
graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control);
|
||||
|
||||
@ -696,7 +750,7 @@ EffectControlLinearizer::LowerObjectIsNumber(Node* node, Node* effect,
|
||||
Node* control) {
|
||||
Node* value = node->InputAt(0);
|
||||
|
||||
Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value);
|
||||
Node* check = ObjectIsSmi(value);
|
||||
Node* branch = graph()->NewNode(common()->Branch(), check, control);
|
||||
|
||||
Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
|
||||
@ -727,7 +781,7 @@ EffectControlLinearizer::LowerObjectIsReceiver(Node* node, Node* effect,
|
||||
Node* control) {
|
||||
Node* value = node->InputAt(0);
|
||||
|
||||
Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value);
|
||||
Node* check = ObjectIsSmi(value);
|
||||
Node* branch =
|
||||
graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control);
|
||||
|
||||
@ -759,12 +813,20 @@ EffectControlLinearizer::LowerObjectIsReceiver(Node* node, Node* effect,
|
||||
return ValueEffectControl(value, effect, control);
|
||||
}
|
||||
|
||||
EffectControlLinearizer::ValueEffectControl
|
||||
EffectControlLinearizer::LowerObjectIsSmi(Node* node, Node* effect,
|
||||
Node* control) {
|
||||
Node* value = node->InputAt(0);
|
||||
value = ObjectIsSmi(value);
|
||||
return ValueEffectControl(value, effect, control);
|
||||
}
|
||||
|
||||
EffectControlLinearizer::ValueEffectControl
|
||||
EffectControlLinearizer::LowerObjectIsString(Node* node, Node* effect,
|
||||
Node* control) {
|
||||
Node* value = node->InputAt(0);
|
||||
|
||||
Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value);
|
||||
Node* check = ObjectIsSmi(value);
|
||||
Node* branch =
|
||||
graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control);
|
||||
|
||||
@ -799,7 +861,7 @@ EffectControlLinearizer::LowerObjectIsUndetectable(Node* node, Node* effect,
|
||||
Node* control) {
|
||||
Node* value = node->InputAt(0);
|
||||
|
||||
Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value);
|
||||
Node* check = ObjectIsSmi(value);
|
||||
Node* branch =
|
||||
graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control);
|
||||
|
||||
@ -838,7 +900,6 @@ EffectControlLinearizer::LowerObjectIsUndetectable(Node* node, Node* effect,
|
||||
EffectControlLinearizer::ValueEffectControl
|
||||
EffectControlLinearizer::AllocateHeapNumberWithValue(Node* value, Node* effect,
|
||||
Node* control) {
|
||||
effect = graph()->NewNode(common()->BeginRegion(), effect);
|
||||
Node* result = effect = graph()->NewNode(
|
||||
simplified()->Allocate(NOT_TENURED),
|
||||
jsgraph()->Int32Constant(HeapNumber::kSize), effect, control);
|
||||
@ -848,7 +909,6 @@ EffectControlLinearizer::AllocateHeapNumberWithValue(Node* value, Node* effect,
|
||||
effect = graph()->NewNode(
|
||||
simplified()->StoreField(AccessBuilder::ForHeapNumberValue()), result,
|
||||
value, effect, control);
|
||||
result = effect = graph()->NewNode(common()->FinishRegion(), result, effect);
|
||||
return ValueEffectControl(result, effect, control);
|
||||
}
|
||||
|
||||
@ -874,6 +934,22 @@ Node* EffectControlLinearizer::ChangeUint32ToFloat64(Node* value) {
|
||||
return graph()->NewNode(machine()->ChangeUint32ToFloat64(), value);
|
||||
}
|
||||
|
||||
Node* EffectControlLinearizer::ChangeSmiToInt32(Node* value) {
|
||||
value = graph()->NewNode(machine()->WordSar(), value, SmiShiftBitsConstant());
|
||||
if (machine()->Is64()) {
|
||||
value = graph()->NewNode(machine()->TruncateInt64ToInt32(), value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
Node* EffectControlLinearizer::ObjectIsSmi(Node* value) {
|
||||
return graph()->NewNode(
|
||||
machine()->WordEqual(),
|
||||
graph()->NewNode(machine()->WordAnd(), value,
|
||||
jsgraph()->IntPtrConstant(kSmiTagMask)),
|
||||
jsgraph()->IntPtrConstant(kSmiTag));
|
||||
}
|
||||
|
||||
Node* EffectControlLinearizer::SmiMaxValueConstant() {
|
||||
return jsgraph()->Int32Constant(Smi::kMaxValue);
|
||||
}
|
||||
|
@ -41,12 +41,20 @@ class EffectControlLinearizer {
|
||||
};
|
||||
|
||||
bool TryWireInStateEffect(Node* node, Node** effect, Node** control);
|
||||
ValueEffectControl LowerChangeBitToTagged(Node* node, Node* effect,
|
||||
Node* control);
|
||||
ValueEffectControl LowerChangeInt31ToTaggedSigned(Node* node, Node* effect,
|
||||
Node* control);
|
||||
ValueEffectControl LowerChangeInt32ToTagged(Node* node, Node* effect,
|
||||
Node* control);
|
||||
ValueEffectControl LowerChangeUint32ToTagged(Node* node, Node* effect,
|
||||
Node* control);
|
||||
ValueEffectControl LowerChangeFloat64ToTagged(Node* node, Node* effect,
|
||||
Node* control);
|
||||
ValueEffectControl LowerChangeTaggedSignedToInt32(Node* node, Node* effect,
|
||||
Node* control);
|
||||
ValueEffectControl LowerChangeTaggedToBit(Node* node, Node* effect,
|
||||
Node* control);
|
||||
ValueEffectControl LowerChangeTaggedToInt32(Node* node, Node* effect,
|
||||
Node* control);
|
||||
ValueEffectControl LowerChangeTaggedToUint32(Node* node, Node* effect,
|
||||
@ -61,6 +69,7 @@ class EffectControlLinearizer {
|
||||
Node* control);
|
||||
ValueEffectControl LowerObjectIsReceiver(Node* node, Node* effect,
|
||||
Node* control);
|
||||
ValueEffectControl LowerObjectIsSmi(Node* node, Node* effect, Node* control);
|
||||
ValueEffectControl LowerObjectIsString(Node* node, Node* effect,
|
||||
Node* control);
|
||||
ValueEffectControl LowerObjectIsUndetectable(Node* node, Node* effect,
|
||||
@ -72,6 +81,8 @@ class EffectControlLinearizer {
|
||||
Node* ChangeUint32ToSmi(Node* value);
|
||||
Node* ChangeInt32ToFloat64(Node* value);
|
||||
Node* ChangeUint32ToFloat64(Node* value);
|
||||
Node* ChangeSmiToInt32(Node* value);
|
||||
Node* ObjectIsSmi(Node* value);
|
||||
|
||||
Node* SmiMaxValueConstant();
|
||||
Node* SmiShiftBitsConstant();
|
||||
|
@ -200,12 +200,12 @@
|
||||
V(ChangeTaggedToInt32) \
|
||||
V(ChangeTaggedToUint32) \
|
||||
V(ChangeTaggedToFloat64) \
|
||||
V(ChangeInt31ToTagged) \
|
||||
V(ChangeInt31ToTaggedSigned) \
|
||||
V(ChangeInt32ToTagged) \
|
||||
V(ChangeUint32ToTagged) \
|
||||
V(ChangeFloat64ToTagged) \
|
||||
V(ChangeBoolToBit) \
|
||||
V(ChangeBitToBool) \
|
||||
V(ChangeTaggedToBit) \
|
||||
V(ChangeBitToTagged) \
|
||||
V(TruncateTaggedToWord32) \
|
||||
V(Allocate) \
|
||||
V(LoadField) \
|
||||
|
@ -188,10 +188,10 @@ Node* RepresentationChanger::GetTaggedRepresentationFor(
|
||||
// Select the correct X -> Tagged operator.
|
||||
const Operator* op;
|
||||
if (output_rep == MachineRepresentation::kBit) {
|
||||
op = simplified()->ChangeBitToBool();
|
||||
op = simplified()->ChangeBitToTagged();
|
||||
} else if (IsWord(output_rep)) {
|
||||
if (output_type->Is(Type::Signed31())) {
|
||||
op = simplified()->ChangeInt31ToTagged();
|
||||
op = simplified()->ChangeInt31ToTaggedSigned();
|
||||
} else if (output_type->Is(Type::Signed32())) {
|
||||
op = simplified()->ChangeInt32ToTagged();
|
||||
} else if (output_type->Is(Type::Unsigned32())) {
|
||||
@ -208,7 +208,7 @@ Node* RepresentationChanger::GetTaggedRepresentationFor(
|
||||
} else if (output_rep == MachineRepresentation::kFloat64) {
|
||||
if (output_type->Is(Type::Signed31())) { // float64 -> int32 -> tagged
|
||||
node = InsertChangeFloat64ToInt32(node);
|
||||
op = simplified()->ChangeInt31ToTagged();
|
||||
op = simplified()->ChangeInt31ToTaggedSigned();
|
||||
} else if (output_type->Is(
|
||||
Type::Signed32())) { // float64 -> int32 -> tagged
|
||||
node = InsertChangeFloat64ToInt32(node);
|
||||
@ -418,7 +418,7 @@ Node* RepresentationChanger::GetBitRepresentationFor(
|
||||
// Select the correct X -> Bit operator.
|
||||
const Operator* op;
|
||||
if (output_rep == MachineRepresentation::kTagged) {
|
||||
op = simplified()->ChangeBoolToBit();
|
||||
op = simplified()->ChangeTaggedToBit();
|
||||
} else {
|
||||
return TypeError(node, output_rep, output_type,
|
||||
MachineRepresentation::kBit);
|
||||
|
@ -31,17 +31,17 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
|
||||
if (m.IsBooleanNot()) return Replace(m.InputAt(0));
|
||||
break;
|
||||
}
|
||||
case IrOpcode::kChangeBitToBool: {
|
||||
case IrOpcode::kChangeBitToTagged: {
|
||||
Int32Matcher m(node->InputAt(0));
|
||||
if (m.Is(0)) return Replace(jsgraph()->FalseConstant());
|
||||
if (m.Is(1)) return Replace(jsgraph()->TrueConstant());
|
||||
if (m.IsChangeBoolToBit()) return Replace(m.InputAt(0));
|
||||
if (m.IsChangeTaggedToBit()) return Replace(m.InputAt(0));
|
||||
break;
|
||||
}
|
||||
case IrOpcode::kChangeBoolToBit: {
|
||||
case IrOpcode::kChangeTaggedToBit: {
|
||||
HeapObjectMatcher m(node->InputAt(0));
|
||||
if (m.HasValue()) return ReplaceInt32(m.Value()->BooleanValue());
|
||||
if (m.IsChangeBitToBool()) return Replace(m.InputAt(0));
|
||||
if (m.IsChangeBitToTagged()) return Replace(m.InputAt(0));
|
||||
break;
|
||||
}
|
||||
case IrOpcode::kChangeFloat64ToTagged: {
|
||||
@ -50,7 +50,7 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
|
||||
if (m.IsChangeTaggedToFloat64()) return Replace(m.node()->InputAt(0));
|
||||
break;
|
||||
}
|
||||
case IrOpcode::kChangeInt31ToTagged:
|
||||
case IrOpcode::kChangeInt31ToTaggedSigned:
|
||||
case IrOpcode::kChangeInt32ToTagged: {
|
||||
Int32Matcher m(node->InputAt(0));
|
||||
if (m.HasValue()) return ReplaceNumber(m.Value());
|
||||
@ -63,7 +63,7 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
|
||||
NumberMatcher m(node->InputAt(0));
|
||||
if (m.HasValue()) return ReplaceFloat64(m.Value());
|
||||
if (m.IsChangeFloat64ToTagged()) return Replace(m.node()->InputAt(0));
|
||||
if (m.IsChangeInt31ToTagged() || m.IsChangeInt32ToTagged()) {
|
||||
if (m.IsChangeInt31ToTaggedSigned() || m.IsChangeInt32ToTagged()) {
|
||||
return Change(node, machine()->ChangeInt32ToFloat64(), m.InputAt(0));
|
||||
}
|
||||
if (m.IsChangeUint32ToTagged()) {
|
||||
@ -77,7 +77,7 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
|
||||
if (m.IsChangeFloat64ToTagged()) {
|
||||
return Change(node, machine()->ChangeFloat64ToInt32(), m.InputAt(0));
|
||||
}
|
||||
if (m.IsChangeInt31ToTagged() || m.IsChangeInt32ToTagged()) {
|
||||
if (m.IsChangeInt31ToTaggedSigned() || m.IsChangeInt32ToTagged()) {
|
||||
return Replace(m.InputAt(0));
|
||||
}
|
||||
break;
|
||||
@ -99,7 +99,7 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
|
||||
case IrOpcode::kTruncateTaggedToWord32: {
|
||||
NumberMatcher m(node->InputAt(0));
|
||||
if (m.HasValue()) return ReplaceInt32(DoubleToInt32(m.Value()));
|
||||
if (m.IsChangeInt31ToTagged() || m.IsChangeInt32ToTagged() ||
|
||||
if (m.IsChangeInt31ToTaggedSigned() || m.IsChangeInt32ToTagged() ||
|
||||
m.IsChangeUint32ToTagged()) {
|
||||
return Replace(m.InputAt(0));
|
||||
}
|
||||
|
@ -186,12 +186,12 @@ const ElementAccess& ElementAccessOf(const Operator* op) {
|
||||
V(ChangeTaggedToInt32, Operator::kNoProperties, 1) \
|
||||
V(ChangeTaggedToUint32, Operator::kNoProperties, 1) \
|
||||
V(ChangeTaggedToFloat64, Operator::kNoProperties, 1) \
|
||||
V(ChangeInt31ToTagged, Operator::kNoProperties, 1) \
|
||||
V(ChangeInt31ToTaggedSigned, Operator::kNoProperties, 1) \
|
||||
V(ChangeInt32ToTagged, Operator::kNoProperties, 1) \
|
||||
V(ChangeUint32ToTagged, Operator::kNoProperties, 1) \
|
||||
V(ChangeFloat64ToTagged, Operator::kNoProperties, 1) \
|
||||
V(ChangeBoolToBit, Operator::kNoProperties, 1) \
|
||||
V(ChangeBitToBool, Operator::kNoProperties, 1) \
|
||||
V(ChangeTaggedToBit, Operator::kNoProperties, 1) \
|
||||
V(ChangeBitToTagged, Operator::kNoProperties, 1) \
|
||||
V(TruncateTaggedToWord32, Operator::kNoProperties, 1) \
|
||||
V(ObjectIsCallable, Operator::kNoProperties, 1) \
|
||||
V(ObjectIsNumber, Operator::kNoProperties, 1) \
|
||||
|
@ -163,12 +163,12 @@ class SimplifiedOperatorBuilder final : public ZoneObject {
|
||||
const Operator* ChangeTaggedToInt32();
|
||||
const Operator* ChangeTaggedToUint32();
|
||||
const Operator* ChangeTaggedToFloat64();
|
||||
const Operator* ChangeInt31ToTagged();
|
||||
const Operator* ChangeInt31ToTaggedSigned();
|
||||
const Operator* ChangeInt32ToTagged();
|
||||
const Operator* ChangeUint32ToTagged();
|
||||
const Operator* ChangeFloat64ToTagged();
|
||||
const Operator* ChangeBoolToBit();
|
||||
const Operator* ChangeBitToBool();
|
||||
const Operator* ChangeTaggedToBit();
|
||||
const Operator* ChangeBitToTagged();
|
||||
const Operator* TruncateTaggedToWord32();
|
||||
|
||||
const Operator* ObjectIsCallable();
|
||||
|
@ -1871,7 +1871,7 @@ Type* Typer::Visitor::TypeChangeTaggedToFloat64(Node* node) {
|
||||
return ChangeRepresentation(arg, Type::UntaggedFloat64(), zone());
|
||||
}
|
||||
|
||||
Type* Typer::Visitor::TypeChangeInt31ToTagged(Node* node) {
|
||||
Type* Typer::Visitor::TypeChangeInt31ToTaggedSigned(Node* node) {
|
||||
Type* arg = Operand(node, 0);
|
||||
// TODO(neis): DCHECK(arg->Is(Type::Signed31()));
|
||||
Type* rep =
|
||||
@ -1901,15 +1901,13 @@ Type* Typer::Visitor::TypeChangeFloat64ToTagged(Node* node) {
|
||||
return ChangeRepresentation(arg, Type::Tagged(), zone());
|
||||
}
|
||||
|
||||
|
||||
Type* Typer::Visitor::TypeChangeBoolToBit(Node* node) {
|
||||
Type* Typer::Visitor::TypeChangeTaggedToBit(Node* node) {
|
||||
Type* arg = Operand(node, 0);
|
||||
// TODO(neis): DCHECK(arg.upper->Is(Type::Boolean()));
|
||||
return ChangeRepresentation(arg, Type::UntaggedBit(), zone());
|
||||
}
|
||||
|
||||
|
||||
Type* Typer::Visitor::TypeChangeBitToBool(Node* node) {
|
||||
Type* Typer::Visitor::TypeChangeBitToTagged(Node* node) {
|
||||
Type* arg = Operand(node, 0);
|
||||
// TODO(neis): DCHECK(arg.upper->Is(Type::Boolean()));
|
||||
return ChangeRepresentation(arg, Type::TaggedPointer(), zone());
|
||||
|
@ -803,7 +803,7 @@ void Verifier::Visitor::Check(Node* node) {
|
||||
// CheckUpperIs(node, to));
|
||||
break;
|
||||
}
|
||||
case IrOpcode::kChangeInt31ToTagged: {
|
||||
case IrOpcode::kChangeInt31ToTaggedSigned: {
|
||||
// Signed31 /\ UntaggedInt32 -> Signed31 /\ Tagged
|
||||
// TODO(neis): Activate once ChangeRepresentation works in typer.
|
||||
// Type* from =Type::Intersect(Type::Signed31(), Type::UntaggedInt32());
|
||||
@ -839,7 +839,7 @@ void Verifier::Visitor::Check(Node* node) {
|
||||
// CheckUpperIs(node, to));
|
||||
break;
|
||||
}
|
||||
case IrOpcode::kChangeBoolToBit: {
|
||||
case IrOpcode::kChangeTaggedToBit: {
|
||||
// Boolean /\ TaggedPtr -> Boolean /\ UntaggedInt1
|
||||
// TODO(neis): Activate once ChangeRepresentation works in typer.
|
||||
// Type* from = Type::Intersect(Type::Boolean(), Type::TaggedPtr());
|
||||
@ -848,7 +848,7 @@ void Verifier::Visitor::Check(Node* node) {
|
||||
// CheckUpperIs(node, to));
|
||||
break;
|
||||
}
|
||||
case IrOpcode::kChangeBitToBool: {
|
||||
case IrOpcode::kChangeBitToTagged: {
|
||||
// Boolean /\ UntaggedInt1 -> Boolean /\ TaggedPtr
|
||||
// TODO(neis): Activate once ChangeRepresentation works in typer.
|
||||
// Type* from = Type::Intersect(Type::Boolean(), Type::UntaggedInt1());
|
||||
|
@ -51,7 +51,6 @@
|
||||
'compiler/graph-builder-tester.h',
|
||||
'compiler/test-basic-block-profiler.cc',
|
||||
'compiler/test-branch-combine.cc',
|
||||
'compiler/test-changes-lowering.cc',
|
||||
'compiler/test-code-stub-assembler.cc',
|
||||
'compiler/test-gap-resolver.cc',
|
||||
'compiler/test-graph-visualizer.cc',
|
||||
|
@ -168,11 +168,11 @@ class GraphBuilderTester : public HandleAndZoneScope,
|
||||
Node* ChangeFloat64ToTagged(Node* a) {
|
||||
return NewNode(simplified()->ChangeFloat64ToTagged(), a);
|
||||
}
|
||||
Node* ChangeBoolToBit(Node* a) {
|
||||
return NewNode(simplified()->ChangeBoolToBit(), a);
|
||||
Node* ChangeTaggedToBit(Node* a) {
|
||||
return NewNode(simplified()->ChangeTaggedToBit(), a);
|
||||
}
|
||||
Node* ChangeBitToBool(Node* a) {
|
||||
return NewNode(simplified()->ChangeBitToBool(), a);
|
||||
Node* ChangeBitToTagged(Node* a) {
|
||||
return NewNode(simplified()->ChangeBitToTagged(), a);
|
||||
}
|
||||
|
||||
Node* LoadField(const FieldAccess& access, Node* object) {
|
||||
|
@ -1,183 +0,0 @@
|
||||
// Copyright 2014 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include "src/ast/scopes.h"
|
||||
#include "src/compiler/change-lowering.h"
|
||||
#include "src/compiler/control-builders.h"
|
||||
#include "src/compiler/js-graph.h"
|
||||
#include "src/compiler/node-properties.h"
|
||||
#include "src/compiler/pipeline.h"
|
||||
#include "src/compiler/select-lowering.h"
|
||||
#include "src/compiler/simplified-lowering.h"
|
||||
#include "src/compiler/typer.h"
|
||||
#include "src/compiler/verifier.h"
|
||||
#include "src/execution.h"
|
||||
#include "src/globals.h"
|
||||
#include "src/parsing/parser.h"
|
||||
#include "src/parsing/rewriter.h"
|
||||
#include "test/cctest/cctest.h"
|
||||
#include "test/cctest/compiler/codegen-tester.h"
|
||||
#include "test/cctest/compiler/function-tester.h"
|
||||
#include "test/cctest/compiler/graph-builder-tester.h"
|
||||
#include "test/cctest/compiler/value-helper.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
namespace compiler {
|
||||
|
||||
template <typename ReturnType>
|
||||
class ChangesLoweringTester : public GraphBuilderTester<ReturnType> {
|
||||
public:
|
||||
explicit ChangesLoweringTester(MachineType p0 = MachineType::None())
|
||||
: GraphBuilderTester<ReturnType>(p0),
|
||||
javascript(this->zone()),
|
||||
jsgraph(this->isolate(), this->graph(), this->common(), &javascript,
|
||||
nullptr, this->machine()),
|
||||
function(Handle<JSFunction>::null()) {}
|
||||
|
||||
JSOperatorBuilder javascript;
|
||||
JSGraph jsgraph;
|
||||
Handle<JSFunction> function;
|
||||
|
||||
Node* start() { return this->graph()->start(); }
|
||||
|
||||
template <typename T>
|
||||
T* CallWithPotentialGC() {
|
||||
// TODO(titzer): we wrap the code in a JSFunction here to reuse the
|
||||
// JSEntryStub; that could be done with a special prologue or other stub.
|
||||
if (function.is_null()) {
|
||||
function = FunctionTester::ForMachineGraph(this->graph());
|
||||
}
|
||||
Handle<Object>* args = NULL;
|
||||
MaybeHandle<Object> result =
|
||||
Execution::Call(this->isolate(), function, factory()->undefined_value(),
|
||||
0, args, false);
|
||||
return T::cast(*result.ToHandleChecked());
|
||||
}
|
||||
|
||||
void StoreFloat64(Node* node, double* ptr) {
|
||||
Node* ptr_node = this->PointerConstant(ptr);
|
||||
this->Store(MachineType::Float64(), ptr_node, node);
|
||||
}
|
||||
|
||||
Node* LoadInt32(int32_t* ptr) {
|
||||
Node* ptr_node = this->PointerConstant(ptr);
|
||||
return this->Load(MachineType::Int32(), ptr_node);
|
||||
}
|
||||
|
||||
Node* LoadUint32(uint32_t* ptr) {
|
||||
Node* ptr_node = this->PointerConstant(ptr);
|
||||
return this->Load(MachineType::Uint32(), ptr_node);
|
||||
}
|
||||
|
||||
Node* LoadFloat64(double* ptr) {
|
||||
Node* ptr_node = this->PointerConstant(ptr);
|
||||
return this->Load(MachineType::Float64(), ptr_node);
|
||||
}
|
||||
|
||||
void CheckNumber(double expected, Object* number) {
|
||||
CHECK(this->isolate()->factory()->NewNumber(expected)->SameValue(number));
|
||||
}
|
||||
|
||||
void BuildAndLower(const Operator* op) {
|
||||
// We build a graph by hand here, because the raw machine assembler
|
||||
// does not add the correct control and effect nodes.
|
||||
Node* p0 = this->Parameter(0);
|
||||
Node* change = this->graph()->NewNode(op, p0);
|
||||
Node* ret = this->graph()->NewNode(this->common()->Return(), change,
|
||||
this->start(), this->start());
|
||||
Node* end = this->graph()->NewNode(this->common()->End(1), ret);
|
||||
this->graph()->SetEnd(end);
|
||||
LowerChange(change);
|
||||
}
|
||||
|
||||
void BuildStoreAndLower(const Operator* op, const Operator* store_op,
|
||||
void* location) {
|
||||
// We build a graph by hand here, because the raw machine assembler
|
||||
// does not add the correct control and effect nodes.
|
||||
Node* p0 = this->Parameter(0);
|
||||
Node* change = this->graph()->NewNode(op, p0);
|
||||
Node* store = this->graph()->NewNode(
|
||||
store_op, this->PointerConstant(location), this->Int32Constant(0),
|
||||
change, this->start(), this->start());
|
||||
Node* ret = this->graph()->NewNode(
|
||||
this->common()->Return(), this->Int32Constant(0), store, this->start());
|
||||
Node* end = this->graph()->NewNode(this->common()->End(1), ret);
|
||||
this->graph()->SetEnd(end);
|
||||
LowerChange(change);
|
||||
}
|
||||
|
||||
void BuildLoadAndLower(const Operator* op, const Operator* load_op,
|
||||
void* location) {
|
||||
// We build a graph by hand here, because the raw machine assembler
|
||||
// does not add the correct control and effect nodes.
|
||||
Node* load = this->graph()->NewNode(
|
||||
load_op, this->PointerConstant(location), this->Int32Constant(0),
|
||||
this->start(), this->start());
|
||||
Node* change = this->graph()->NewNode(op, load);
|
||||
Node* ret = this->graph()->NewNode(this->common()->Return(), change,
|
||||
this->start(), this->start());
|
||||
Node* end = this->graph()->NewNode(this->common()->End(1), ret);
|
||||
this->graph()->SetEnd(end);
|
||||
LowerChange(change);
|
||||
}
|
||||
|
||||
void LowerChange(Node* change) {
|
||||
// Run the graph reducer with changes lowering on a single node.
|
||||
Typer typer(this->isolate(), this->graph());
|
||||
typer.Run();
|
||||
ChangeLowering change_lowering(&jsgraph);
|
||||
SelectLowering select_lowering(this->graph(), this->common());
|
||||
GraphReducer reducer(this->zone(), this->graph());
|
||||
reducer.AddReducer(&change_lowering);
|
||||
reducer.AddReducer(&select_lowering);
|
||||
reducer.ReduceNode(change);
|
||||
Verifier::Run(this->graph(), Verifier::UNTYPED);
|
||||
}
|
||||
|
||||
Factory* factory() { return this->isolate()->factory(); }
|
||||
Heap* heap() { return this->isolate()->heap(); }
|
||||
};
|
||||
|
||||
|
||||
TEST(RunChangeBoolToBit) {
|
||||
ChangesLoweringTester<int32_t> t(MachineType::AnyTagged());
|
||||
t.BuildAndLower(t.simplified()->ChangeBoolToBit());
|
||||
|
||||
{
|
||||
Object* true_obj = t.heap()->true_value();
|
||||
int32_t result = t.Call(true_obj);
|
||||
CHECK_EQ(1, result);
|
||||
}
|
||||
|
||||
{
|
||||
Object* false_obj = t.heap()->false_value();
|
||||
int32_t result = t.Call(false_obj);
|
||||
CHECK_EQ(0, result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST(RunChangeBitToBool) {
|
||||
ChangesLoweringTester<Object*> t(MachineType::Int32());
|
||||
t.BuildAndLower(t.simplified()->ChangeBitToBool());
|
||||
|
||||
{
|
||||
Object* result = t.Call(1);
|
||||
Object* true_obj = t.heap()->true_value();
|
||||
CHECK_EQ(true_obj, result);
|
||||
}
|
||||
|
||||
{
|
||||
Object* result = t.Call(0);
|
||||
Object* false_obj = t.heap()->false_value();
|
||||
CHECK_EQ(false_obj, result);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace compiler
|
||||
} // namespace internal
|
||||
} // namespace v8
|
@ -439,13 +439,14 @@ static void CheckTwoChanges(IrOpcode::Value expected2,
|
||||
|
||||
|
||||
TEST(SingleChanges) {
|
||||
CheckChange(IrOpcode::kChangeBoolToBit, MachineRepresentation::kTagged,
|
||||
CheckChange(IrOpcode::kChangeTaggedToBit, MachineRepresentation::kTagged,
|
||||
Type::None(), MachineRepresentation::kBit);
|
||||
CheckChange(IrOpcode::kChangeBitToBool, MachineRepresentation::kBit,
|
||||
CheckChange(IrOpcode::kChangeBitToTagged, MachineRepresentation::kBit,
|
||||
Type::None(), MachineRepresentation::kTagged);
|
||||
|
||||
CheckChange(IrOpcode::kChangeInt31ToTagged, MachineRepresentation::kWord32,
|
||||
Type::Signed31(), MachineRepresentation::kTagged);
|
||||
CheckChange(IrOpcode::kChangeInt31ToTaggedSigned,
|
||||
MachineRepresentation::kWord32, Type::Signed31(),
|
||||
MachineRepresentation::kTagged);
|
||||
CheckChange(IrOpcode::kChangeInt32ToTagged, MachineRepresentation::kWord32,
|
||||
Type::Signed32(), MachineRepresentation::kTagged);
|
||||
CheckChange(IrOpcode::kChangeUint32ToTagged, MachineRepresentation::kWord32,
|
||||
@ -453,7 +454,7 @@ TEST(SingleChanges) {
|
||||
CheckChange(IrOpcode::kChangeFloat64ToTagged, MachineRepresentation::kFloat64,
|
||||
Type::Number(), MachineRepresentation::kTagged);
|
||||
CheckTwoChanges(IrOpcode::kChangeFloat64ToInt32,
|
||||
IrOpcode::kChangeInt31ToTagged,
|
||||
IrOpcode::kChangeInt31ToTaggedSigned,
|
||||
MachineRepresentation::kFloat64, Type::Signed31(),
|
||||
MachineRepresentation::kTagged);
|
||||
CheckTwoChanges(IrOpcode::kChangeFloat64ToInt32,
|
||||
|
@ -843,7 +843,7 @@ TEST(LowerBooleanNot_bit_tagged) {
|
||||
Node* use = t.Use(inv, MachineType::AnyTagged());
|
||||
t.Return(use);
|
||||
t.Lower();
|
||||
CHECK_EQ(IrOpcode::kChangeBitToBool, use->InputAt(0)->opcode());
|
||||
CHECK_EQ(IrOpcode::kChangeBitToTagged, use->InputAt(0)->opcode());
|
||||
Node* cmp = use->InputAt(0)->InputAt(0);
|
||||
CHECK_EQ(t.machine()->Word32Equal()->opcode(), cmp->opcode());
|
||||
CHECK(b == cmp->InputAt(0) || b == cmp->InputAt(1));
|
||||
@ -875,7 +875,7 @@ TEST(LowerBooleanNot_tagged_tagged) {
|
||||
Node* use = t.Use(inv, MachineType::AnyTagged());
|
||||
t.Return(use);
|
||||
t.Lower();
|
||||
CHECK_EQ(IrOpcode::kChangeBitToBool, use->InputAt(0)->opcode());
|
||||
CHECK_EQ(IrOpcode::kChangeBitToTagged, use->InputAt(0)->opcode());
|
||||
Node* cmp = use->InputAt(0)->InputAt(0);
|
||||
CHECK_EQ(t.machine()->WordEqual()->opcode(), cmp->opcode());
|
||||
CHECK(b == cmp->InputAt(0) || b == cmp->InputAt(1));
|
||||
@ -920,7 +920,7 @@ TEST(LowerBooleanToNumber_bit_tagged) {
|
||||
t.Return(use);
|
||||
t.Lower();
|
||||
CHECK_EQ(b, use->InputAt(0)->InputAt(0));
|
||||
CHECK_EQ(IrOpcode::kChangeInt31ToTagged, use->InputAt(0)->opcode());
|
||||
CHECK_EQ(IrOpcode::kChangeInt31ToTaggedSigned, use->InputAt(0)->opcode());
|
||||
}
|
||||
|
||||
|
||||
@ -933,7 +933,7 @@ TEST(LowerBooleanToNumber_tagged_tagged) {
|
||||
t.Return(use);
|
||||
t.Lower();
|
||||
CHECK_EQ(cnv, use->InputAt(0)->InputAt(0));
|
||||
CHECK_EQ(IrOpcode::kChangeInt31ToTagged, use->InputAt(0)->opcode());
|
||||
CHECK_EQ(IrOpcode::kChangeInt31ToTaggedSigned, use->InputAt(0)->opcode());
|
||||
CHECK_EQ(t.machine()->WordEqual()->opcode(), cnv->opcode());
|
||||
CHECK(b == cnv->InputAt(0) || b == cnv->InputAt(1));
|
||||
Node* c = t.jsgraph.TrueConstant();
|
||||
@ -1221,7 +1221,7 @@ TEST(InsertChangesAroundInt32Cmp) {
|
||||
|
||||
for (size_t i = 0; i < arraysize(ops); i++) {
|
||||
CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32,
|
||||
IrOpcode::kChangeBitToBool);
|
||||
IrOpcode::kChangeBitToTagged);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1234,7 +1234,7 @@ TEST(InsertChangesAroundUint32Cmp) {
|
||||
|
||||
for (size_t i = 0; i < arraysize(ops); i++) {
|
||||
CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToUint32,
|
||||
IrOpcode::kChangeBitToBool);
|
||||
IrOpcode::kChangeBitToTagged);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1264,7 +1264,7 @@ TEST(InsertChangesAroundFloat64Cmp) {
|
||||
|
||||
for (size_t i = 0; i < arraysize(ops); i++) {
|
||||
CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToFloat64,
|
||||
IrOpcode::kChangeBitToBool);
|
||||
IrOpcode::kChangeBitToTagged);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,33 +105,6 @@ class ChangeLoweringCommonTest
|
||||
MachineRepresentation WordRepresentation() const final { return GetParam(); }
|
||||
};
|
||||
|
||||
|
||||
TARGET_TEST_P(ChangeLoweringCommonTest, ChangeBitToBool) {
|
||||
Node* value = Parameter(Type::Boolean());
|
||||
Reduction r =
|
||||
Reduce(graph()->NewNode(simplified()->ChangeBitToBool(), value));
|
||||
ASSERT_TRUE(r.Changed());
|
||||
EXPECT_THAT(r.replacement(), IsSelect(MachineRepresentation::kTagged, value,
|
||||
IsTrueConstant(), IsFalseConstant()));
|
||||
}
|
||||
|
||||
|
||||
TARGET_TEST_P(ChangeLoweringCommonTest, ChangeBoolToBit) {
|
||||
Node* value = Parameter(Type::Number());
|
||||
Reduction r =
|
||||
Reduce(graph()->NewNode(simplified()->ChangeBoolToBit(), value));
|
||||
ASSERT_TRUE(r.Changed());
|
||||
EXPECT_THAT(r.replacement(), IsWordEqual(value, IsTrueConstant()));
|
||||
}
|
||||
|
||||
TARGET_TEST_P(ChangeLoweringCommonTest, ChangeInt31ToTagged) {
|
||||
Node* value = Parameter(Type::SignedSmall());
|
||||
Reduction r =
|
||||
Reduce(graph()->NewNode(simplified()->ChangeInt31ToTagged(), value));
|
||||
ASSERT_TRUE(r.Changed());
|
||||
EXPECT_THAT(r.replacement(), IsChangeInt32ToSmi(value));
|
||||
}
|
||||
|
||||
TARGET_TEST_P(ChangeLoweringCommonTest, StoreFieldSmi) {
|
||||
FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
|
||||
Handle<Name>::null(), Type::Any(),
|
||||
|
@ -150,60 +150,54 @@ TEST_F(SimplifiedOperatorReducerTest, BooleanNotWithTrueConstant) {
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// ChangeBoolToBit
|
||||
// ChangeTaggedToBit
|
||||
|
||||
|
||||
TEST_F(SimplifiedOperatorReducerTest, ChangeBitToBoolWithChangeBoolToBit) {
|
||||
TEST_F(SimplifiedOperatorReducerTest, ChangeBitToTaggedWithChangeTaggedToBit) {
|
||||
Node* param0 = Parameter(0);
|
||||
Reduction reduction = Reduce(graph()->NewNode(
|
||||
simplified()->ChangeBitToBool(),
|
||||
graph()->NewNode(simplified()->ChangeBoolToBit(), param0)));
|
||||
simplified()->ChangeBitToTagged(),
|
||||
graph()->NewNode(simplified()->ChangeTaggedToBit(), param0)));
|
||||
ASSERT_TRUE(reduction.Changed());
|
||||
EXPECT_EQ(param0, reduction.replacement());
|
||||
}
|
||||
|
||||
|
||||
TEST_F(SimplifiedOperatorReducerTest, ChangeBitToBoolWithZeroConstant) {
|
||||
TEST_F(SimplifiedOperatorReducerTest, ChangeBitToTaggedWithZeroConstant) {
|
||||
Reduction reduction = Reduce(
|
||||
graph()->NewNode(simplified()->ChangeBitToBool(), Int32Constant(0)));
|
||||
graph()->NewNode(simplified()->ChangeBitToTagged(), Int32Constant(0)));
|
||||
ASSERT_TRUE(reduction.Changed());
|
||||
EXPECT_THAT(reduction.replacement(), IsFalseConstant());
|
||||
}
|
||||
|
||||
|
||||
TEST_F(SimplifiedOperatorReducerTest, ChangeBitToBoolWithOneConstant) {
|
||||
TEST_F(SimplifiedOperatorReducerTest, ChangeBitToTaggedWithOneConstant) {
|
||||
Reduction reduction = Reduce(
|
||||
graph()->NewNode(simplified()->ChangeBitToBool(), Int32Constant(1)));
|
||||
graph()->NewNode(simplified()->ChangeBitToTagged(), Int32Constant(1)));
|
||||
ASSERT_TRUE(reduction.Changed());
|
||||
EXPECT_THAT(reduction.replacement(), IsTrueConstant());
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// ChangeBoolToBit
|
||||
// ChangeTaggedToBit
|
||||
|
||||
|
||||
TEST_F(SimplifiedOperatorReducerTest, ChangeBoolToBitWithFalseConstant) {
|
||||
TEST_F(SimplifiedOperatorReducerTest, ChangeTaggedToBitWithFalseConstant) {
|
||||
Reduction reduction = Reduce(
|
||||
graph()->NewNode(simplified()->ChangeBoolToBit(), FalseConstant()));
|
||||
graph()->NewNode(simplified()->ChangeTaggedToBit(), FalseConstant()));
|
||||
ASSERT_TRUE(reduction.Changed());
|
||||
EXPECT_THAT(reduction.replacement(), IsInt32Constant(0));
|
||||
}
|
||||
|
||||
|
||||
TEST_F(SimplifiedOperatorReducerTest, ChangeBoolToBitWithTrueConstant) {
|
||||
Reduction reduction =
|
||||
Reduce(graph()->NewNode(simplified()->ChangeBoolToBit(), TrueConstant()));
|
||||
TEST_F(SimplifiedOperatorReducerTest, ChangeTaggedToBitWithTrueConstant) {
|
||||
Reduction reduction = Reduce(
|
||||
graph()->NewNode(simplified()->ChangeTaggedToBit(), TrueConstant()));
|
||||
ASSERT_TRUE(reduction.Changed());
|
||||
EXPECT_THAT(reduction.replacement(), IsInt32Constant(1));
|
||||
}
|
||||
|
||||
|
||||
TEST_F(SimplifiedOperatorReducerTest, ChangeBoolToBitWithChangeBitToBool) {
|
||||
TEST_F(SimplifiedOperatorReducerTest, ChangeTaggedToBitWithChangeBitToTagged) {
|
||||
Node* param0 = Parameter(0);
|
||||
Reduction reduction = Reduce(graph()->NewNode(
|
||||
simplified()->ChangeBoolToBit(),
|
||||
graph()->NewNode(simplified()->ChangeBitToBool(), param0)));
|
||||
simplified()->ChangeTaggedToBit(),
|
||||
graph()->NewNode(simplified()->ChangeBitToTagged(), param0)));
|
||||
ASSERT_TRUE(reduction.Changed());
|
||||
EXPECT_EQ(param0, reduction.replacement());
|
||||
}
|
||||
|
@ -62,8 +62,8 @@ const PureOperator kPureOperators[] = {
|
||||
PURE(ChangeInt32ToTagged, Operator::kNoProperties, 1),
|
||||
PURE(ChangeUint32ToTagged, Operator::kNoProperties, 1),
|
||||
PURE(ChangeFloat64ToTagged, Operator::kNoProperties, 1),
|
||||
PURE(ChangeBoolToBit, Operator::kNoProperties, 1),
|
||||
PURE(ChangeBitToBool, Operator::kNoProperties, 1),
|
||||
PURE(ChangeTaggedToBit, Operator::kNoProperties, 1),
|
||||
PURE(ChangeBitToTagged, Operator::kNoProperties, 1),
|
||||
PURE(TruncateTaggedToWord32, Operator::kNoProperties, 1),
|
||||
PURE(ObjectIsNumber, Operator::kNoProperties, 1),
|
||||
PURE(ObjectIsReceiver, Operator::kNoProperties, 1),
|
||||
|
Loading…
Reference in New Issue
Block a user