From b4c3864ba4e00a7572ada083a90461d6a059a453 Mon Sep 17 00:00:00 2001 From: machenbach Date: Mon, 2 May 2016 02:28:47 -0700 Subject: [PATCH] Revert of [turbofan] Remove left-over change bits from ChangeLowering. (patchset #2 id:20001 of https://codereview.chromium.org/1941673002/ ) Reason for revert: [Sheriff] Breaks mac gc stress: https://build.chromium.org/p/client.v8/builders/V8%20Mac%20GC%20Stress/builds/5821 Original issue's description: > [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 > > Committed: https://crrev.com/ceca5ae308bddda166651c654f96d71d74f617d0 > Cr-Commit-Position: refs/heads/master@{#35924} TBR=ishell@chromium.org,bmeurer@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review-Url: https://codereview.chromium.org/1942733002 Cr-Commit-Position: refs/heads/master@{#35927} --- src/compiler/change-lowering.cc | 68 ++++++- src/compiler/change-lowering.h | 13 ++ src/compiler/effect-control-linearizer.cc | 124 +++--------- src/compiler/effect-control-linearizer.h | 11 -- src/compiler/opcodes.h | 6 +- src/compiler/representation-change.cc | 8 +- src/compiler/simplified-operator-reducer.cc | 16 +- src/compiler/simplified-operator.cc | 6 +- src/compiler/simplified-operator.h | 6 +- src/compiler/typer.cc | 8 +- src/compiler/verifier.cc | 6 +- test/cctest/cctest.gyp | 1 + test/cctest/compiler/graph-builder-tester.h | 8 +- test/cctest/compiler/test-changes-lowering.cc | 183 ++++++++++++++++++ .../compiler/test-representation-change.cc | 11 +- .../compiler/test-simplified-lowering.cc | 14 +- .../compiler/change-lowering-unittest.cc | 27 +++ .../simplified-operator-reducer-unittest.cc | 40 ++-- .../compiler/simplified-operator-unittest.cc | 4 +- 19 files changed, 385 insertions(+), 175 deletions(-) create mode 100644 test/cctest/compiler/test-changes-lowering.cc diff --git a/src/compiler/change-lowering.cc b/src/compiler/change-lowering.cc index d2afdf5b4e..4b77ea1dd0 100644 --- a/src/compiler/change-lowering.cc +++ b/src/compiler/change-lowering.cc @@ -4,12 +4,14 @@ #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 { @@ -19,7 +21,16 @@ 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: @@ -30,6 +41,8 @@ Reduction ChangeLowering::Reduce(Node* node) { return ReduceStoreElement(node); case IrOpcode::kAllocate: return ReduceAllocate(node); + case IrOpcode::kObjectIsSmi: + return ReduceObjectIsSmi(node); default: return NoChange(); } @@ -37,6 +50,50 @@ 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, @@ -148,6 +205,15 @@ 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(); } diff --git a/src/compiler/change-lowering.h b/src/compiler/change-lowering.h index a79cb9c7a6..064b38fd5b 100644 --- a/src/compiler/change-lowering.h +++ b/src/compiler/change-lowering.h @@ -27,12 +27,25 @@ 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; diff --git a/src/compiler/effect-control-linearizer.cc b/src/compiler/effect-control-linearizer.cc index ddcf1c1514..763aaea841 100644 --- a/src/compiler/effect-control-linearizer.cc +++ b/src/compiler/effect-control-linearizer.cc @@ -290,7 +290,12 @@ 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. - return RemoveRegionNode(node); + + // 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) { @@ -341,12 +346,6 @@ 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; @@ -356,12 +355,6 @@ 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; @@ -383,9 +376,6 @@ 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; @@ -470,35 +460,6 @@ 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) { @@ -556,36 +517,19 @@ 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 = ObjectIsSmi(value); + Node* check = graph()->NewNode(simplified()->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 = ChangeSmiToInt32(value); + Node* vtrue = + graph()->NewNode(simplified()->ChangeTaggedSignedToInt32(), value); Node* if_false = graph()->NewNode(common()->IfFalse(), branch); Node* efalse = effect; @@ -611,13 +555,14 @@ EffectControlLinearizer::LowerChangeTaggedToUint32(Node* node, Node* effect, Node* control) { Node* value = node->InputAt(0); - Node* check = ObjectIsSmi(value); + Node* check = graph()->NewNode(simplified()->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 = ChangeSmiToInt32(value); + Node* vtrue = + graph()->NewNode(simplified()->ChangeTaggedSignedToInt32(), value); Node* if_false = graph()->NewNode(common()->IfFalse(), branch); Node* efalse = effect; @@ -643,7 +588,7 @@ EffectControlLinearizer::LowerChangeTaggedToFloat64(Node* node, Node* effect, Node* control) { Node* value = node->InputAt(0); - Node* check = ObjectIsSmi(value); + Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); Node* branch = graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); @@ -651,7 +596,7 @@ EffectControlLinearizer::LowerChangeTaggedToFloat64(Node* node, Node* effect, Node* etrue = effect; Node* vtrue; { - vtrue = ChangeSmiToInt32(value); + vtrue = graph()->NewNode(simplified()->ChangeTaggedSignedToInt32(), value); vtrue = graph()->NewNode(machine()->ChangeInt32ToFloat64(), vtrue); } @@ -678,13 +623,14 @@ EffectControlLinearizer::LowerTruncateTaggedToWord32(Node* node, Node* effect, Node* control) { Node* value = node->InputAt(0); - Node* check = ObjectIsSmi(value); + Node* check = graph()->NewNode(simplified()->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 = ChangeSmiToInt32(value); + Node* vtrue = + graph()->NewNode(simplified()->ChangeTaggedSignedToInt32(), value); Node* if_false = graph()->NewNode(common()->IfFalse(), branch); Node* efalse = effect; @@ -710,7 +656,7 @@ EffectControlLinearizer::LowerObjectIsCallable(Node* node, Node* effect, Node* control) { Node* value = node->InputAt(0); - Node* check = ObjectIsSmi(value); + Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); Node* branch = graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control); @@ -750,7 +696,7 @@ EffectControlLinearizer::LowerObjectIsNumber(Node* node, Node* effect, Node* control) { Node* value = node->InputAt(0); - Node* check = ObjectIsSmi(value); + Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); Node* branch = graph()->NewNode(common()->Branch(), check, control); Node* if_true = graph()->NewNode(common()->IfTrue(), branch); @@ -781,7 +727,7 @@ EffectControlLinearizer::LowerObjectIsReceiver(Node* node, Node* effect, Node* control) { Node* value = node->InputAt(0); - Node* check = ObjectIsSmi(value); + Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); Node* branch = graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control); @@ -813,20 +759,12 @@ 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 = ObjectIsSmi(value); + Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); Node* branch = graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control); @@ -861,7 +799,7 @@ EffectControlLinearizer::LowerObjectIsUndetectable(Node* node, Node* effect, Node* control) { Node* value = node->InputAt(0); - Node* check = ObjectIsSmi(value); + Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); Node* branch = graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control); @@ -900,6 +838,7 @@ 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); @@ -909,6 +848,7 @@ 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); } @@ -934,22 +874,6 @@ 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); } diff --git a/src/compiler/effect-control-linearizer.h b/src/compiler/effect-control-linearizer.h index 95c653e776..687a38cacb 100644 --- a/src/compiler/effect-control-linearizer.h +++ b/src/compiler/effect-control-linearizer.h @@ -41,20 +41,12 @@ 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, @@ -69,7 +61,6 @@ 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, @@ -81,8 +72,6 @@ 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(); diff --git a/src/compiler/opcodes.h b/src/compiler/opcodes.h index cfe6452c6e..9273090f2d 100644 --- a/src/compiler/opcodes.h +++ b/src/compiler/opcodes.h @@ -200,12 +200,12 @@ V(ChangeTaggedToInt32) \ V(ChangeTaggedToUint32) \ V(ChangeTaggedToFloat64) \ - V(ChangeInt31ToTaggedSigned) \ + V(ChangeInt31ToTagged) \ V(ChangeInt32ToTagged) \ V(ChangeUint32ToTagged) \ V(ChangeFloat64ToTagged) \ - V(ChangeTaggedToBit) \ - V(ChangeBitToTagged) \ + V(ChangeBoolToBit) \ + V(ChangeBitToBool) \ V(TruncateTaggedToWord32) \ V(Allocate) \ V(LoadField) \ diff --git a/src/compiler/representation-change.cc b/src/compiler/representation-change.cc index d2dc2004dc..8a75cef24e 100644 --- a/src/compiler/representation-change.cc +++ b/src/compiler/representation-change.cc @@ -188,10 +188,10 @@ Node* RepresentationChanger::GetTaggedRepresentationFor( // Select the correct X -> Tagged operator. const Operator* op; if (output_rep == MachineRepresentation::kBit) { - op = simplified()->ChangeBitToTagged(); + op = simplified()->ChangeBitToBool(); } else if (IsWord(output_rep)) { if (output_type->Is(Type::Signed31())) { - op = simplified()->ChangeInt31ToTaggedSigned(); + op = simplified()->ChangeInt31ToTagged(); } 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()->ChangeInt31ToTaggedSigned(); + op = simplified()->ChangeInt31ToTagged(); } 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()->ChangeTaggedToBit(); + op = simplified()->ChangeBoolToBit(); } else { return TypeError(node, output_rep, output_type, MachineRepresentation::kBit); diff --git a/src/compiler/simplified-operator-reducer.cc b/src/compiler/simplified-operator-reducer.cc index 004ce9acae..192c6476a0 100644 --- a/src/compiler/simplified-operator-reducer.cc +++ b/src/compiler/simplified-operator-reducer.cc @@ -31,17 +31,17 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) { if (m.IsBooleanNot()) return Replace(m.InputAt(0)); break; } - case IrOpcode::kChangeBitToTagged: { + case IrOpcode::kChangeBitToBool: { Int32Matcher m(node->InputAt(0)); if (m.Is(0)) return Replace(jsgraph()->FalseConstant()); if (m.Is(1)) return Replace(jsgraph()->TrueConstant()); - if (m.IsChangeTaggedToBit()) return Replace(m.InputAt(0)); + if (m.IsChangeBoolToBit()) return Replace(m.InputAt(0)); break; } - case IrOpcode::kChangeTaggedToBit: { + case IrOpcode::kChangeBoolToBit: { HeapObjectMatcher m(node->InputAt(0)); if (m.HasValue()) return ReplaceInt32(m.Value()->BooleanValue()); - if (m.IsChangeBitToTagged()) return Replace(m.InputAt(0)); + if (m.IsChangeBitToBool()) 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::kChangeInt31ToTaggedSigned: + case IrOpcode::kChangeInt31ToTagged: 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.IsChangeInt31ToTaggedSigned() || m.IsChangeInt32ToTagged()) { + if (m.IsChangeInt31ToTagged() || 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.IsChangeInt31ToTaggedSigned() || m.IsChangeInt32ToTagged()) { + if (m.IsChangeInt31ToTagged() || 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.IsChangeInt31ToTaggedSigned() || m.IsChangeInt32ToTagged() || + if (m.IsChangeInt31ToTagged() || m.IsChangeInt32ToTagged() || m.IsChangeUint32ToTagged()) { return Replace(m.InputAt(0)); } diff --git a/src/compiler/simplified-operator.cc b/src/compiler/simplified-operator.cc index f383ace587..e720343fb3 100644 --- a/src/compiler/simplified-operator.cc +++ b/src/compiler/simplified-operator.cc @@ -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(ChangeInt31ToTaggedSigned, Operator::kNoProperties, 1) \ + V(ChangeInt31ToTagged, Operator::kNoProperties, 1) \ V(ChangeInt32ToTagged, Operator::kNoProperties, 1) \ V(ChangeUint32ToTagged, Operator::kNoProperties, 1) \ V(ChangeFloat64ToTagged, Operator::kNoProperties, 1) \ - V(ChangeTaggedToBit, Operator::kNoProperties, 1) \ - V(ChangeBitToTagged, Operator::kNoProperties, 1) \ + V(ChangeBoolToBit, Operator::kNoProperties, 1) \ + V(ChangeBitToBool, Operator::kNoProperties, 1) \ V(TruncateTaggedToWord32, Operator::kNoProperties, 1) \ V(ObjectIsCallable, Operator::kNoProperties, 1) \ V(ObjectIsNumber, Operator::kNoProperties, 1) \ diff --git a/src/compiler/simplified-operator.h b/src/compiler/simplified-operator.h index 0828441c1d..12eba02b74 100644 --- a/src/compiler/simplified-operator.h +++ b/src/compiler/simplified-operator.h @@ -163,12 +163,12 @@ class SimplifiedOperatorBuilder final : public ZoneObject { const Operator* ChangeTaggedToInt32(); const Operator* ChangeTaggedToUint32(); const Operator* ChangeTaggedToFloat64(); - const Operator* ChangeInt31ToTaggedSigned(); + const Operator* ChangeInt31ToTagged(); const Operator* ChangeInt32ToTagged(); const Operator* ChangeUint32ToTagged(); const Operator* ChangeFloat64ToTagged(); - const Operator* ChangeTaggedToBit(); - const Operator* ChangeBitToTagged(); + const Operator* ChangeBoolToBit(); + const Operator* ChangeBitToBool(); const Operator* TruncateTaggedToWord32(); const Operator* ObjectIsCallable(); diff --git a/src/compiler/typer.cc b/src/compiler/typer.cc index ba26eea148..7957425cda 100644 --- a/src/compiler/typer.cc +++ b/src/compiler/typer.cc @@ -1871,7 +1871,7 @@ Type* Typer::Visitor::TypeChangeTaggedToFloat64(Node* node) { return ChangeRepresentation(arg, Type::UntaggedFloat64(), zone()); } -Type* Typer::Visitor::TypeChangeInt31ToTaggedSigned(Node* node) { +Type* Typer::Visitor::TypeChangeInt31ToTagged(Node* node) { Type* arg = Operand(node, 0); // TODO(neis): DCHECK(arg->Is(Type::Signed31())); Type* rep = @@ -1901,13 +1901,15 @@ Type* Typer::Visitor::TypeChangeFloat64ToTagged(Node* node) { return ChangeRepresentation(arg, Type::Tagged(), zone()); } -Type* Typer::Visitor::TypeChangeTaggedToBit(Node* node) { + +Type* Typer::Visitor::TypeChangeBoolToBit(Node* node) { Type* arg = Operand(node, 0); // TODO(neis): DCHECK(arg.upper->Is(Type::Boolean())); return ChangeRepresentation(arg, Type::UntaggedBit(), zone()); } -Type* Typer::Visitor::TypeChangeBitToTagged(Node* node) { + +Type* Typer::Visitor::TypeChangeBitToBool(Node* node) { Type* arg = Operand(node, 0); // TODO(neis): DCHECK(arg.upper->Is(Type::Boolean())); return ChangeRepresentation(arg, Type::TaggedPointer(), zone()); diff --git a/src/compiler/verifier.cc b/src/compiler/verifier.cc index 54d62be18c..a5ff400ee8 100644 --- a/src/compiler/verifier.cc +++ b/src/compiler/verifier.cc @@ -803,7 +803,7 @@ void Verifier::Visitor::Check(Node* node) { // CheckUpperIs(node, to)); break; } - case IrOpcode::kChangeInt31ToTaggedSigned: { + case IrOpcode::kChangeInt31ToTagged: { // 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::kChangeTaggedToBit: { + case IrOpcode::kChangeBoolToBit: { // 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::kChangeBitToTagged: { + case IrOpcode::kChangeBitToBool: { // Boolean /\ UntaggedInt1 -> Boolean /\ TaggedPtr // TODO(neis): Activate once ChangeRepresentation works in typer. // Type* from = Type::Intersect(Type::Boolean(), Type::UntaggedInt1()); diff --git a/test/cctest/cctest.gyp b/test/cctest/cctest.gyp index c258c779dd..d85c882f8a 100644 --- a/test/cctest/cctest.gyp +++ b/test/cctest/cctest.gyp @@ -51,6 +51,7 @@ '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', diff --git a/test/cctest/compiler/graph-builder-tester.h b/test/cctest/compiler/graph-builder-tester.h index e4cccda7f3..7ec54f76ab 100644 --- a/test/cctest/compiler/graph-builder-tester.h +++ b/test/cctest/compiler/graph-builder-tester.h @@ -168,11 +168,11 @@ class GraphBuilderTester : public HandleAndZoneScope, Node* ChangeFloat64ToTagged(Node* a) { return NewNode(simplified()->ChangeFloat64ToTagged(), a); } - Node* ChangeTaggedToBit(Node* a) { - return NewNode(simplified()->ChangeTaggedToBit(), a); + Node* ChangeBoolToBit(Node* a) { + return NewNode(simplified()->ChangeBoolToBit(), a); } - Node* ChangeBitToTagged(Node* a) { - return NewNode(simplified()->ChangeBitToTagged(), a); + Node* ChangeBitToBool(Node* a) { + return NewNode(simplified()->ChangeBitToBool(), a); } Node* LoadField(const FieldAccess& access, Node* object) { diff --git a/test/cctest/compiler/test-changes-lowering.cc b/test/cctest/compiler/test-changes-lowering.cc new file mode 100644 index 0000000000..6a39cb03d6 --- /dev/null +++ b/test/cctest/compiler/test-changes-lowering.cc @@ -0,0 +1,183 @@ +// 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 + +#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 +class ChangesLoweringTester : public GraphBuilderTester { + public: + explicit ChangesLoweringTester(MachineType p0 = MachineType::None()) + : GraphBuilderTester(p0), + javascript(this->zone()), + jsgraph(this->isolate(), this->graph(), this->common(), &javascript, + nullptr, this->machine()), + function(Handle::null()) {} + + JSOperatorBuilder javascript; + JSGraph jsgraph; + Handle function; + + Node* start() { return this->graph()->start(); } + + template + 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* args = NULL; + MaybeHandle 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 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 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 diff --git a/test/cctest/compiler/test-representation-change.cc b/test/cctest/compiler/test-representation-change.cc index 76aa390491..22c56fc8ad 100644 --- a/test/cctest/compiler/test-representation-change.cc +++ b/test/cctest/compiler/test-representation-change.cc @@ -439,14 +439,13 @@ static void CheckTwoChanges(IrOpcode::Value expected2, TEST(SingleChanges) { - CheckChange(IrOpcode::kChangeTaggedToBit, MachineRepresentation::kTagged, + CheckChange(IrOpcode::kChangeBoolToBit, MachineRepresentation::kTagged, Type::None(), MachineRepresentation::kBit); - CheckChange(IrOpcode::kChangeBitToTagged, MachineRepresentation::kBit, + CheckChange(IrOpcode::kChangeBitToBool, MachineRepresentation::kBit, Type::None(), MachineRepresentation::kTagged); - CheckChange(IrOpcode::kChangeInt31ToTaggedSigned, - MachineRepresentation::kWord32, Type::Signed31(), - MachineRepresentation::kTagged); + CheckChange(IrOpcode::kChangeInt31ToTagged, MachineRepresentation::kWord32, + Type::Signed31(), MachineRepresentation::kTagged); CheckChange(IrOpcode::kChangeInt32ToTagged, MachineRepresentation::kWord32, Type::Signed32(), MachineRepresentation::kTagged); CheckChange(IrOpcode::kChangeUint32ToTagged, MachineRepresentation::kWord32, @@ -454,7 +453,7 @@ TEST(SingleChanges) { CheckChange(IrOpcode::kChangeFloat64ToTagged, MachineRepresentation::kFloat64, Type::Number(), MachineRepresentation::kTagged); CheckTwoChanges(IrOpcode::kChangeFloat64ToInt32, - IrOpcode::kChangeInt31ToTaggedSigned, + IrOpcode::kChangeInt31ToTagged, MachineRepresentation::kFloat64, Type::Signed31(), MachineRepresentation::kTagged); CheckTwoChanges(IrOpcode::kChangeFloat64ToInt32, diff --git a/test/cctest/compiler/test-simplified-lowering.cc b/test/cctest/compiler/test-simplified-lowering.cc index 3f98ec66fa..97b0786572 100644 --- a/test/cctest/compiler/test-simplified-lowering.cc +++ b/test/cctest/compiler/test-simplified-lowering.cc @@ -843,7 +843,7 @@ TEST(LowerBooleanNot_bit_tagged) { Node* use = t.Use(inv, MachineType::AnyTagged()); t.Return(use); t.Lower(); - CHECK_EQ(IrOpcode::kChangeBitToTagged, use->InputAt(0)->opcode()); + CHECK_EQ(IrOpcode::kChangeBitToBool, 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::kChangeBitToTagged, use->InputAt(0)->opcode()); + CHECK_EQ(IrOpcode::kChangeBitToBool, 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::kChangeInt31ToTaggedSigned, use->InputAt(0)->opcode()); + CHECK_EQ(IrOpcode::kChangeInt31ToTagged, 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::kChangeInt31ToTaggedSigned, use->InputAt(0)->opcode()); + CHECK_EQ(IrOpcode::kChangeInt31ToTagged, 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::kChangeBitToTagged); + IrOpcode::kChangeBitToBool); } } @@ -1234,7 +1234,7 @@ TEST(InsertChangesAroundUint32Cmp) { for (size_t i = 0; i < arraysize(ops); i++) { CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToUint32, - IrOpcode::kChangeBitToTagged); + IrOpcode::kChangeBitToBool); } } @@ -1264,7 +1264,7 @@ TEST(InsertChangesAroundFloat64Cmp) { for (size_t i = 0; i < arraysize(ops); i++) { CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToFloat64, - IrOpcode::kChangeBitToTagged); + IrOpcode::kChangeBitToBool); } } diff --git a/test/unittests/compiler/change-lowering-unittest.cc b/test/unittests/compiler/change-lowering-unittest.cc index 582ef0a1bb..a78055dd69 100644 --- a/test/unittests/compiler/change-lowering-unittest.cc +++ b/test/unittests/compiler/change-lowering-unittest.cc @@ -105,6 +105,33 @@ 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::null(), Type::Any(), diff --git a/test/unittests/compiler/simplified-operator-reducer-unittest.cc b/test/unittests/compiler/simplified-operator-reducer-unittest.cc index eec39abb42..eed25f4b1c 100644 --- a/test/unittests/compiler/simplified-operator-reducer-unittest.cc +++ b/test/unittests/compiler/simplified-operator-reducer-unittest.cc @@ -150,54 +150,60 @@ TEST_F(SimplifiedOperatorReducerTest, BooleanNotWithTrueConstant) { // ----------------------------------------------------------------------------- -// ChangeTaggedToBit +// ChangeBoolToBit -TEST_F(SimplifiedOperatorReducerTest, ChangeBitToTaggedWithChangeTaggedToBit) { + +TEST_F(SimplifiedOperatorReducerTest, ChangeBitToBoolWithChangeBoolToBit) { Node* param0 = Parameter(0); Reduction reduction = Reduce(graph()->NewNode( - simplified()->ChangeBitToTagged(), - graph()->NewNode(simplified()->ChangeTaggedToBit(), param0))); + simplified()->ChangeBitToBool(), + graph()->NewNode(simplified()->ChangeBoolToBit(), param0))); ASSERT_TRUE(reduction.Changed()); EXPECT_EQ(param0, reduction.replacement()); } -TEST_F(SimplifiedOperatorReducerTest, ChangeBitToTaggedWithZeroConstant) { + +TEST_F(SimplifiedOperatorReducerTest, ChangeBitToBoolWithZeroConstant) { Reduction reduction = Reduce( - graph()->NewNode(simplified()->ChangeBitToTagged(), Int32Constant(0))); + graph()->NewNode(simplified()->ChangeBitToBool(), Int32Constant(0))); ASSERT_TRUE(reduction.Changed()); EXPECT_THAT(reduction.replacement(), IsFalseConstant()); } -TEST_F(SimplifiedOperatorReducerTest, ChangeBitToTaggedWithOneConstant) { + +TEST_F(SimplifiedOperatorReducerTest, ChangeBitToBoolWithOneConstant) { Reduction reduction = Reduce( - graph()->NewNode(simplified()->ChangeBitToTagged(), Int32Constant(1))); + graph()->NewNode(simplified()->ChangeBitToBool(), Int32Constant(1))); ASSERT_TRUE(reduction.Changed()); EXPECT_THAT(reduction.replacement(), IsTrueConstant()); } // ----------------------------------------------------------------------------- -// ChangeTaggedToBit +// ChangeBoolToBit -TEST_F(SimplifiedOperatorReducerTest, ChangeTaggedToBitWithFalseConstant) { + +TEST_F(SimplifiedOperatorReducerTest, ChangeBoolToBitWithFalseConstant) { Reduction reduction = Reduce( - graph()->NewNode(simplified()->ChangeTaggedToBit(), FalseConstant())); + graph()->NewNode(simplified()->ChangeBoolToBit(), FalseConstant())); ASSERT_TRUE(reduction.Changed()); EXPECT_THAT(reduction.replacement(), IsInt32Constant(0)); } -TEST_F(SimplifiedOperatorReducerTest, ChangeTaggedToBitWithTrueConstant) { - Reduction reduction = Reduce( - graph()->NewNode(simplified()->ChangeTaggedToBit(), TrueConstant())); + +TEST_F(SimplifiedOperatorReducerTest, ChangeBoolToBitWithTrueConstant) { + Reduction reduction = + Reduce(graph()->NewNode(simplified()->ChangeBoolToBit(), TrueConstant())); ASSERT_TRUE(reduction.Changed()); EXPECT_THAT(reduction.replacement(), IsInt32Constant(1)); } -TEST_F(SimplifiedOperatorReducerTest, ChangeTaggedToBitWithChangeBitToTagged) { + +TEST_F(SimplifiedOperatorReducerTest, ChangeBoolToBitWithChangeBitToBool) { Node* param0 = Parameter(0); Reduction reduction = Reduce(graph()->NewNode( - simplified()->ChangeTaggedToBit(), - graph()->NewNode(simplified()->ChangeBitToTagged(), param0))); + simplified()->ChangeBoolToBit(), + graph()->NewNode(simplified()->ChangeBitToBool(), param0))); ASSERT_TRUE(reduction.Changed()); EXPECT_EQ(param0, reduction.replacement()); } diff --git a/test/unittests/compiler/simplified-operator-unittest.cc b/test/unittests/compiler/simplified-operator-unittest.cc index 49e8b058d2..1245f50828 100644 --- a/test/unittests/compiler/simplified-operator-unittest.cc +++ b/test/unittests/compiler/simplified-operator-unittest.cc @@ -62,8 +62,8 @@ const PureOperator kPureOperators[] = { PURE(ChangeInt32ToTagged, Operator::kNoProperties, 1), PURE(ChangeUint32ToTagged, Operator::kNoProperties, 1), PURE(ChangeFloat64ToTagged, Operator::kNoProperties, 1), - PURE(ChangeTaggedToBit, Operator::kNoProperties, 1), - PURE(ChangeBitToTagged, Operator::kNoProperties, 1), + PURE(ChangeBoolToBit, Operator::kNoProperties, 1), + PURE(ChangeBitToBool, Operator::kNoProperties, 1), PURE(TruncateTaggedToWord32, Operator::kNoProperties, 1), PURE(ObjectIsNumber, Operator::kNoProperties, 1), PURE(ObjectIsReceiver, Operator::kNoProperties, 1),