[turbofan] Get rid of type lower bounds.

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

Cr-Commit-Position: refs/heads/master@{#30764}
This commit is contained in:
jarin 2015-09-16 04:55:27 -07:00 committed by Commit bot
parent 1025d34acf
commit 92903d0a19
20 changed files with 580 additions and 824 deletions

View File

@ -157,7 +157,7 @@ Reduction ChangeLowering::ChangeFloat64ToTagged(Node* value, Node* control) {
Reduction ChangeLowering::ChangeInt32ToTagged(Node* value, Node* control) {
if (machine()->Is64() ||
NodeProperties::GetBounds(value).upper->Is(Type::SignedSmall())) {
NodeProperties::GetType(value)->Is(Type::SignedSmall())) {
return Replace(ChangeInt32ToSmi(value));
}
@ -184,7 +184,7 @@ Reduction ChangeLowering::ChangeInt32ToTagged(Node* value, Node* control) {
Reduction ChangeLowering::ChangeTaggedToUI32(Node* value, Node* control,
Signedness signedness) {
if (NodeProperties::GetBounds(value).upper->Is(Type::TaggedSigned())) {
if (NodeProperties::GetType(value)->Is(Type::TaggedSigned())) {
return Replace(ChangeSmiToInt32(value));
}
@ -193,7 +193,7 @@ Reduction ChangeLowering::ChangeTaggedToUI32(Node* value, Node* control,
? machine()->ChangeFloat64ToInt32()
: machine()->ChangeFloat64ToUint32();
if (NodeProperties::GetBounds(value).upper->Is(Type::TaggedPointer())) {
if (NodeProperties::GetType(value)->Is(Type::TaggedPointer())) {
return Replace(graph()->NewNode(op, LoadHeapNumberValue(value, control)));
}
@ -312,7 +312,7 @@ Reduction ChangeLowering::ChangeTaggedToFloat64(Node* value, Node* control) {
Reduction ChangeLowering::ChangeUint32ToTagged(Node* value, Node* control) {
if (NodeProperties::GetBounds(value).upper->Is(Type::UnsignedSmall())) {
if (NodeProperties::GetType(value)->Is(Type::UnsignedSmall())) {
return Replace(ChangeUint32ToSmi(value));
}

View File

@ -127,13 +127,10 @@ class JSONGraphNodeWriter {
os_ << ",\"control\":" << (NodeProperties::IsControl(node) ? "true"
: "false");
if (NodeProperties::IsTyped(node)) {
Bounds bounds = NodeProperties::GetBounds(node);
std::ostringstream upper;
bounds.upper->PrintTo(upper);
std::ostringstream lower;
bounds.lower->PrintTo(lower);
os_ << ",\"upper_type\":\"" << Escaped(upper, "\"") << "\"";
os_ << ",\"lower_type\":\"" << Escaped(lower, "\"") << "\"";
Type* type = NodeProperties::GetType(node);
std::ostringstream type_out;
type->PrintTo(type_out);
os_ << ",\"type\":\"" << Escaped(type_out, "\"") << "\"";
}
os_ << "}";
}
@ -302,12 +299,10 @@ void GraphVisualizer::PrintNode(Node* node, bool gray) {
os_ << "}";
if (FLAG_trace_turbo_types && NodeProperties::IsTyped(node)) {
Bounds bounds = NodeProperties::GetBounds(node);
std::ostringstream upper;
bounds.upper->PrintTo(upper);
std::ostringstream lower;
bounds.lower->PrintTo(lower);
os_ << "|" << Escaped(upper) << "|" << Escaped(lower);
Type* type = NodeProperties::GetType(node);
std::ostringstream type_out;
type->PrintTo(type_out);
os_ << "|" << Escaped(type_out);
}
os_ << "}\"\n";
@ -545,11 +540,9 @@ void GraphC1Visualizer::PrintInputs(Node* node) {
void GraphC1Visualizer::PrintType(Node* node) {
if (NodeProperties::IsTyped(node)) {
Bounds bounds = NodeProperties::GetBounds(node);
Type* type = NodeProperties::GetType(node);
os_ << " type:";
bounds.upper->PrintTo(os_);
os_ << "..";
bounds.lower->PrintTo(os_);
type->PrintTo(os_);
}
}

View File

@ -45,20 +45,20 @@ class JSCallReduction {
// Determines whether the call takes one input of the given type.
bool InputsMatchOne(Type* t1) {
return GetJSCallArity() == 1 &&
NodeProperties::GetBounds(GetJSCallInput(0)).upper->Is(t1);
NodeProperties::GetType(GetJSCallInput(0))->Is(t1);
}
// Determines whether the call takes two inputs of the given types.
bool InputsMatchTwo(Type* t1, Type* t2) {
return GetJSCallArity() == 2 &&
NodeProperties::GetBounds(GetJSCallInput(0)).upper->Is(t1) &&
NodeProperties::GetBounds(GetJSCallInput(1)).upper->Is(t2);
NodeProperties::GetType(GetJSCallInput(0))->Is(t1) &&
NodeProperties::GetType(GetJSCallInput(1))->Is(t2);
}
// Determines whether the call takes inputs all of the given type.
bool InputsMatchAll(Type* t) {
for (int i = 0; i < GetJSCallArity(); i++) {
if (!NodeProperties::GetBounds(GetJSCallInput(i)).upper->Is(t)) {
if (!NodeProperties::GetType(GetJSCallInput(i))->Is(t)) {
return false;
}
}

View File

@ -309,7 +309,7 @@ Reduction JSIntrinsicLowering::ReduceSeqStringSetChar(
node->ReplaceInput(3, effect);
node->ReplaceInput(4, control);
node->TrimInputCount(5);
NodeProperties::RemoveBounds(node);
NodeProperties::RemoveType(node);
ReplaceWithValue(node, string, node);
return Changed(node);
}

View File

@ -36,7 +36,7 @@ Reduction JSTypeFeedbackLowering::Reduce(Node* node) {
Reduction JSTypeFeedbackLowering::ReduceJSLoadNamed(Node* node) {
DCHECK_EQ(IrOpcode::kJSLoadNamed, node->opcode());
Node* receiver = NodeProperties::GetValueInput(node, 0);
Type* receiver_type = NodeProperties::GetBounds(receiver).upper;
Type* receiver_type = NodeProperties::GetType(receiver);
Node* frame_state = NodeProperties::GetFrameStateInput(node, 1);
Node* effect = NodeProperties::GetEffectInput(node);
Node* control = NodeProperties::GetControlInput(node);

View File

@ -167,8 +167,8 @@ class JSBinopReduction final {
// TODO(jarin): Replace the explicit typing hack with a call to some method
// that encapsulates changing the operator and re-typing.
Bounds const bounds = NodeProperties::GetBounds(node_);
NodeProperties::SetBounds(node_, Bounds::NarrowUpper(bounds, type, zone()));
Type* node_type = NodeProperties::GetType(node_);
NodeProperties::SetType(node_, Type::Intersect(node_type, type, zone()));
if (invert) {
// Insert an boolean not to invert the value.
@ -206,12 +206,8 @@ class JSBinopReduction final {
Node* context() { return NodeProperties::GetContextInput(node_); }
Node* left() { return NodeProperties::GetValueInput(node_, 0); }
Node* right() { return NodeProperties::GetValueInput(node_, 1); }
Type* left_type() {
return NodeProperties::GetBounds(node_->InputAt(0)).upper;
}
Type* right_type() {
return NodeProperties::GetBounds(node_->InputAt(1)).upper;
}
Type* left_type() { return NodeProperties::GetType(node_->InputAt(0)); }
Type* right_type() { return NodeProperties::GetType(node_->InputAt(1)); }
SimplifiedOperatorBuilder* simplified() { return lowering_->simplified(); }
Graph* graph() const { return lowering_->graph(); }
@ -305,7 +301,7 @@ class JSBinopReduction final {
}
Node* ConvertPlainPrimitiveToNumber(Node* node) {
DCHECK(NodeProperties::GetBounds(node).upper->Is(Type::PlainPrimitive()));
DCHECK(NodeProperties::GetType(node)->Is(Type::PlainPrimitive()));
// Avoid inserting too many eager ToNumber() operations.
Reduction const reduction = lowering_->ReduceJSToNumberInput(node);
if (reduction.Changed()) return reduction.replacement();
@ -316,7 +312,7 @@ class JSBinopReduction final {
}
Node* ConvertSingleInputToNumber(Node* node, Node* frame_state) {
DCHECK(!NodeProperties::GetBounds(node).upper->Is(Type::PlainPrimitive()));
DCHECK(!NodeProperties::GetType(node)->Is(Type::PlainPrimitive()));
Node* const n = graph()->NewNode(javascript()->ToNumber(), node, context(),
frame_state, effect(), control());
NodeProperties::ReplaceUses(node_, node_, node_, n, n);
@ -363,7 +359,7 @@ class JSBinopReduction final {
if (NodeProperties::IsEffectEdge(edge)) edge.UpdateTo(exception_effect);
if (NodeProperties::IsValueEdge(edge)) edge.UpdateTo(exception_value);
}
NodeProperties::RemoveBounds(exception_merge);
NodeProperties::RemoveType(exception_merge);
exception_merge->ReplaceInput(0, left_exception);
exception_merge->ReplaceInput(1, right_exception);
exception_merge->set_op(common()->Merge(2));
@ -374,7 +370,7 @@ class JSBinopReduction final {
Node* ConvertToUI32(Node* node, Signedness signedness) {
// Avoid introducing too many eager NumberToXXnt32() operations.
Type* type = NodeProperties::GetBounds(node).upper;
Type* type = NodeProperties::GetType(node);
if (signedness == kSigned) {
if (!type->Is(Type::Signed32())) {
node = graph()->NewNode(simplified()->NumberToInt32(), node);
@ -630,7 +626,7 @@ Reduction JSTypedLowering::ReduceJSStrictEqual(Node* node, bool invert) {
Reduction JSTypedLowering::ReduceJSUnaryNot(Node* node) {
Node* const input = node->InputAt(0);
Type* const input_type = NodeProperties::GetBounds(input).upper;
Type* const input_type = NodeProperties::GetType(input);
if (input_type->Is(Type::Boolean())) {
// JSUnaryNot(x:boolean) => BooleanNot(x)
node->set_op(simplified()->BooleanNot());
@ -662,7 +658,7 @@ Reduction JSTypedLowering::ReduceJSUnaryNot(Node* node) {
Reduction JSTypedLowering::ReduceJSToBoolean(Node* node) {
Node* const input = node->InputAt(0);
Type* const input_type = NodeProperties::GetBounds(input).upper;
Type* const input_type = NodeProperties::GetType(input);
if (input_type->Is(Type::Boolean())) {
// JSToBoolean(x:boolean) => x
return Replace(input);
@ -698,7 +694,7 @@ Reduction JSTypedLowering::ReduceJSToNumberInput(Node* input) {
return Changed(input); // JSToNumber(JSToNumber(x)) => JSToNumber(x)
}
// Check if we have a cached conversion.
Type* input_type = NodeProperties::GetBounds(input).upper;
Type* input_type = NodeProperties::GetType(input);
if (input_type->Is(Type::Number())) {
// JSToNumber(x:number) => x
return Changed(input);
@ -728,7 +724,7 @@ Reduction JSTypedLowering::ReduceJSToNumber(Node* node) {
ReplaceWithValue(node, reduction.replacement());
return reduction;
}
Type* const input_type = NodeProperties::GetBounds(input).upper;
Type* const input_type = NodeProperties::GetType(input);
if (input_type->Is(Type::PlainPrimitive())) {
if (NodeProperties::GetContextInput(node) !=
jsgraph()->NoContextConstant() ||
@ -757,7 +753,7 @@ Reduction JSTypedLowering::ReduceJSToStringInput(Node* input) {
if (result.Changed()) return result;
return Changed(input); // JSToString(JSToString(x)) => JSToString(x)
}
Type* input_type = NodeProperties::GetBounds(input).upper;
Type* input_type = NodeProperties::GetType(input);
if (input_type->Is(Type::String())) {
return Changed(input); // JSToString(x:string) => x
}
@ -801,7 +797,7 @@ Reduction JSTypedLowering::ReduceJSLoadGlobal(Node* node) {
Reduction JSTypedLowering::ReduceJSLoadNamed(Node* node) {
DCHECK_EQ(IrOpcode::kJSLoadNamed, node->opcode());
Node* receiver = NodeProperties::GetValueInput(node, 0);
Type* receiver_type = NodeProperties::GetBounds(receiver).upper;
Type* receiver_type = NodeProperties::GetType(receiver);
Node* effect = NodeProperties::GetEffectInput(node);
Node* control = NodeProperties::GetControlInput(node);
Handle<Name> name = LoadNamedParametersOf(node->op()).name();
@ -822,7 +818,7 @@ Reduction JSTypedLowering::ReduceJSLoadNamed(Node* node) {
Reduction JSTypedLowering::ReduceJSLoadProperty(Node* node) {
Node* key = NodeProperties::GetValueInput(node, 1);
Node* base = NodeProperties::GetValueInput(node, 0);
Type* key_type = NodeProperties::GetBounds(key).upper;
Type* key_type = NodeProperties::GetType(key);
HeapObjectMatcher mbase(base);
if (mbase.HasValue() && mbase.Value()->IsJSTypedArray()) {
Handle<JSTypedArray> const array =
@ -867,8 +863,8 @@ Reduction JSTypedLowering::ReduceJSStoreProperty(Node* node) {
Node* key = NodeProperties::GetValueInput(node, 1);
Node* base = NodeProperties::GetValueInput(node, 0);
Node* value = NodeProperties::GetValueInput(node, 2);
Type* key_type = NodeProperties::GetBounds(key).upper;
Type* value_type = NodeProperties::GetBounds(value).upper;
Type* key_type = NodeProperties::GetType(key);
Type* value_type = NodeProperties::GetType(value);
HeapObjectMatcher mbase(base);
if (mbase.HasValue() && mbase.Value()->IsJSTypedArray()) {
Handle<JSTypedArray> const array =
@ -1190,7 +1186,7 @@ Reduction JSTypedLowering::ReduceJSCreateLiteralObject(Node* node) {
Reduction JSTypedLowering::ReduceJSCreateWithContext(Node* node) {
DCHECK_EQ(IrOpcode::kJSCreateWithContext, node->opcode());
Node* const input = NodeProperties::GetValueInput(node, 0);
Type* input_type = NodeProperties::GetBounds(input).upper;
Type* input_type = NodeProperties::GetType(input);
if (FLAG_turbo_allocate && input_type->Is(Type::Receiver())) {
// JSCreateWithContext(o:receiver, f)
Node* const effect = NodeProperties::GetEffectInput(node);
@ -1209,7 +1205,7 @@ Reduction JSTypedLowering::ReduceJSCreateWithContext(Node* node) {
a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), input);
a.Store(AccessBuilder::ForContextSlot(Context::GLOBAL_OBJECT_INDEX), load);
// TODO(mstarzinger): We could mutate {node} into the allocation instead.
NodeProperties::SetBounds(a.allocation(), NodeProperties::GetBounds(node));
NodeProperties::SetType(a.allocation(), NodeProperties::GetType(node));
ReplaceWithValue(node, node, a.effect());
node->ReplaceInput(0, a.allocation());
node->ReplaceInput(1, a.effect());
@ -1248,7 +1244,7 @@ Reduction JSTypedLowering::ReduceJSCreateBlockContext(Node* node) {
a.Store(AccessBuilder::ForContextSlot(i), jsgraph()->TheHoleConstant());
}
// TODO(mstarzinger): We could mutate {node} into the allocation instead.
NodeProperties::SetBounds(a.allocation(), NodeProperties::GetBounds(node));
NodeProperties::SetType(a.allocation(), NodeProperties::GetType(node));
ReplaceWithValue(node, node, a.effect());
node->ReplaceInput(0, a.allocation());
node->ReplaceInput(1, a.effect());
@ -1265,9 +1261,9 @@ Reduction JSTypedLowering::ReduceJSCallFunction(Node* node) {
CallFunctionParameters const& p = CallFunctionParametersOf(node->op());
int const arity = static_cast<int>(p.arity() - 2);
Node* const function = NodeProperties::GetValueInput(node, 0);
Type* const function_type = NodeProperties::GetBounds(function).upper;
Type* const function_type = NodeProperties::GetType(function);
Node* const receiver = NodeProperties::GetValueInput(node, 1);
Type* const receiver_type = NodeProperties::GetBounds(receiver).upper;
Type* const receiver_type = NodeProperties::GetType(receiver);
Node* const effect = NodeProperties::GetEffectInput(node);
Node* const control = NodeProperties::GetControlInput(node);
@ -1567,7 +1563,7 @@ Reduction JSTypedLowering::Reduce(Node* node) {
// result value and can simply replace the node if it's eliminable.
if (!NodeProperties::IsConstant(node) && NodeProperties::IsTyped(node) &&
node->op()->HasProperty(Operator::kEliminatable)) {
Type* upper = NodeProperties::GetBounds(node).upper;
Type* upper = NodeProperties::GetType(node);
if (upper->IsConstant()) {
Node* replacement = jsgraph()->Constant(upper->AsConstant()->Value());
ReplaceWithValue(node, replacement);

View File

@ -108,23 +108,18 @@ class NodeProperties final {
// ---------------------------------------------------------------------------
// Type Bounds.
// Type.
static bool IsTyped(Node* node) {
Bounds const bounds = node->bounds();
DCHECK(!bounds.lower == !bounds.upper);
return bounds.upper;
}
static Bounds GetBounds(Node* node) {
static bool IsTyped(Node* node) { return node->type() != nullptr; }
static Type* GetType(Node* node) {
DCHECK(IsTyped(node));
return node->bounds();
return node->type();
}
static void SetBounds(Node* node, Bounds bounds) {
DCHECK_NOT_NULL(bounds.lower);
DCHECK_NOT_NULL(bounds.upper);
node->set_bounds(bounds);
static void SetType(Node* node, Type* type) {
DCHECK_NOT_NULL(type);
node->set_type(type);
}
static void RemoveBounds(Node* node) { node->set_bounds(Bounds()); }
static void RemoveType(Node* node) { node->set_type(nullptr); }
static bool AllValueInputsAreTyped(Node* node);
private:

View File

@ -112,7 +112,7 @@ Node* Node::Clone(Zone* zone, NodeId id, const Node* node) {
? node->inputs_.inline_
: node->inputs_.outline_->inputs_;
Node* const clone = New(zone, id, node->op(), input_count, inputs, false);
clone->set_bounds(node->bounds());
clone->set_type(node->type());
return clone;
}
@ -273,6 +273,7 @@ bool Node::OwnedBy(Node const* owner1, Node const* owner2) const {
Node::Node(NodeId id, const Operator* op, int inline_count, int inline_capacity)
: op_(op),
type_(nullptr),
mark_(0),
bit_field_(IdField::encode(id) | InlineCountField::encode(inline_count) |
InlineCapacityField::encode(inline_capacity)),

View File

@ -284,9 +284,9 @@ class Node final {
void* operator new(size_t, void* location) { return location; }
// Only NodeProperties should manipulate the bounds.
Bounds bounds() const { return bounds_; }
void set_bounds(Bounds b) { bounds_ = b; }
// Only NodeProperties should manipulate the type.
Type* type() const { return type_; }
void set_type(Type* type) { type_ = type; }
// Only NodeMarkers should manipulate the marks on nodes.
Mark mark() { return mark_; }
@ -306,7 +306,7 @@ class Node final {
static const int kMaxInlineCapacity = InlineCapacityField::kMax - 1;
const Operator* op_;
Bounds bounds_;
Type* type_;
Mark mark_;
uint32_t bit_field_;
Use* first_use_;

View File

@ -99,7 +99,7 @@ static void PeelOuterLoopsForOsr(Graph* graph, CommonOperatorBuilder* common,
}
copy = graph->NewNode(orig->op(), orig->InputCount(), &tmp_inputs[0]);
if (NodeProperties::IsTyped(orig)) {
NodeProperties::SetBounds(copy, NodeProperties::GetBounds(orig));
NodeProperties::SetType(copy, NodeProperties::GetType(orig));
}
mapping->at(orig->id()) = copy;
TRACE(" copy #%d:%s -> #%d\n", orig->id(), orig->op()->mnemonic(),

View File

@ -30,7 +30,9 @@ class RepresentationChanger {
type_error_(false) {}
// TODO(titzer): should Word64 also be implicitly convertable to others?
static const MachineTypeUnion rWord = kRepWord8 | kRepWord16 | kRepWord32;
static bool IsWord(MachineTypeUnion type) {
return (type & (kRepWord8 | kRepWord16 | kRepWord32)) != 0;
}
Node* GetRepresentationFor(Node* node, MachineTypeUnion output_type,
MachineTypeUnion use_type) {
@ -42,7 +44,7 @@ class RepresentationChanger {
// Representations are the same. That's a no-op.
return node;
}
if ((use_type & rWord) && (output_type & rWord)) {
if (IsWord(use_type) && IsWord(output_type)) {
// Both are words less than or equal to 32-bits.
// Since loads of integers from memory implicitly sign or zero extend the
// value to the full machine word size and stores implicitly truncate,
@ -57,7 +59,7 @@ class RepresentationChanger {
return GetFloat64RepresentationFor(node, output_type);
} else if (use_type & kRepBit) {
return GetBitRepresentationFor(node, output_type);
} else if (use_type & rWord) {
} else if (IsWord(use_type)) {
return GetWord32RepresentationFor(node, output_type,
use_type & kTypeUint32);
} else if (use_type & kRepWord64) {
@ -97,7 +99,7 @@ class RepresentationChanger {
const Operator* op;
if (output_type & kRepBit) {
op = simplified()->ChangeBitToBool();
} else if (output_type & rWord) {
} else if (IsWord(output_type)) {
if (output_type & kTypeUint32) {
op = simplified()->ChangeUint32ToTagged();
} else if (output_type & kTypeInt32) {
@ -140,7 +142,7 @@ class RepresentationChanger {
const Operator* op;
if (output_type & kRepBit) {
return TypeError(node, output_type, kRepFloat32);
} else if (output_type & rWord) {
} else if (IsWord(output_type)) {
if (output_type & kTypeUint32) {
op = machine()->ChangeUint32ToFloat64();
} else {
@ -186,7 +188,7 @@ class RepresentationChanger {
const Operator* op;
if (output_type & kRepBit) {
return TypeError(node, output_type, kRepFloat64);
} else if (output_type & rWord) {
} else if (IsWord(output_type)) {
if (output_type & kTypeUint32) {
op = machine()->ChangeUint32ToFloat64();
} else {

View File

@ -345,13 +345,9 @@ std::ostream& operator<<(std::ostream& os, const Schedule& s) {
for (Node* node : *block) {
os << " " << *node;
if (NodeProperties::IsTyped(node)) {
Bounds bounds = NodeProperties::GetBounds(node);
Type* type = NodeProperties::GetType(node);
os << " : ";
bounds.lower->PrintTo(os);
if (!bounds.upper->Is(bounds.lower)) {
os << "..";
bounds.upper->PrintTo(os);
}
type->PrintTo(os);
}
os << "\n";
}

View File

@ -178,8 +178,8 @@ class RepresentationSelector {
bool BothInputsAre(Node* node, Type* type) {
DCHECK_EQ(2, node->InputCount());
return NodeProperties::GetBounds(node->InputAt(0)).upper->Is(type) &&
NodeProperties::GetBounds(node->InputAt(1)).upper->Is(type);
return NodeProperties::GetType(node->InputAt(0))->Is(type) &&
NodeProperties::GetType(node->InputAt(1))->Is(type);
}
void ProcessTruncateWord32Input(Node* node, int index, MachineTypeUnion use) {
@ -313,7 +313,7 @@ class RepresentationSelector {
// Infer representation for phi-like nodes.
MachineType GetRepresentationForPhi(Node* node, MachineTypeUnion use) {
// Phis adapt to the output representation their uses demand.
Type* upper = NodeProperties::GetBounds(node).upper;
Type* upper = NodeProperties::GetType(node);
if ((use & kRepMask) == kRepFloat32) {
// only float32 uses.
return kRepFloat32;
@ -355,7 +355,7 @@ class RepresentationSelector {
ProcessInput(node, 0, kRepBit);
MachineType output = GetRepresentationForPhi(node, use);
Type* upper = NodeProperties::GetBounds(node).upper;
Type* upper = NodeProperties::GetType(node);
MachineType output_type =
static_cast<MachineType>(changer_->TypeFromUpperBound(upper) | output);
SetOutput(node, output_type);
@ -385,7 +385,7 @@ class RepresentationSelector {
SimplifiedLowering* lowering) {
MachineType output = GetRepresentationForPhi(node, use);
Type* upper = NodeProperties::GetBounds(node).upper;
Type* upper = NodeProperties::GetType(node);
MachineType output_type =
static_cast<MachineType>(changer_->TypeFromUpperBound(upper) | output);
SetOutput(node, output_type);
@ -470,7 +470,7 @@ class RepresentationSelector {
bool CanLowerToInt32Binop(Node* node, MachineTypeUnion use) {
return BothInputsAre(node, Type::Signed32()) &&
(!CanObserveNonInt32(use) ||
NodeProperties::GetBounds(node).upper->Is(Type::Signed32()));
NodeProperties::GetType(node)->Is(Type::Signed32()));
}
bool CanLowerToInt32AdditiveBinop(Node* node, MachineTypeUnion use) {
@ -481,7 +481,7 @@ class RepresentationSelector {
bool CanLowerToUint32Binop(Node* node, MachineTypeUnion use) {
return BothInputsAre(node, Type::Unsigned32()) &&
(!CanObserveNonUint32(use) ||
NodeProperties::GetBounds(node).upper->Is(Type::Unsigned32()));
NodeProperties::GetType(node)->Is(Type::Unsigned32()));
}
bool CanLowerToUint32AdditiveBinop(Node* node, MachineTypeUnion use) {
@ -523,7 +523,7 @@ class RepresentationSelector {
return VisitLeaf(node, 0);
case IrOpcode::kParameter: {
// TODO(titzer): use representation from linkage.
Type* upper = NodeProperties::GetBounds(node).upper;
Type* upper = NodeProperties::GetType(node);
ProcessInput(node, 0, 0);
SetOutput(node, kRepTagged | changer_->TypeFromUpperBound(upper));
return;
@ -731,7 +731,7 @@ class RepresentationSelector {
case IrOpcode::kNumberToInt32: {
MachineTypeUnion use_rep = use & kRepMask;
Node* input = node->InputAt(0);
Type* in_upper = NodeProperties::GetBounds(input).upper;
Type* in_upper = NodeProperties::GetType(input);
MachineTypeUnion in = GetInfo(input)->output;
if (in_upper->Is(Type::Signed32())) {
// If the input has type int32, pass through representation.
@ -761,7 +761,7 @@ class RepresentationSelector {
case IrOpcode::kNumberToUint32: {
MachineTypeUnion use_rep = use & kRepMask;
Node* input = node->InputAt(0);
Type* in_upper = NodeProperties::GetBounds(input).upper;
Type* in_upper = NodeProperties::GetType(input);
MachineTypeUnion in = GetInfo(input)->output;
if (in_upper->Is(Type::Unsigned32())) {
// If the input has type uint32, pass through representation.
@ -1228,7 +1228,7 @@ void SimplifiedLowering::DoLoadField(Node* node) {
void SimplifiedLowering::DoStoreField(Node* node) {
const FieldAccess& access = FieldAccessOf(node->op());
Type* type = NodeProperties::GetBounds(node->InputAt(1)).upper;
Type* type = NodeProperties::GetType(node->InputAt(1));
WriteBarrierKind kind =
ComputeWriteBarrierKind(access.base_is_tagged, access.machine_type, type);
node->set_op(
@ -1335,7 +1335,7 @@ void SimplifiedLowering::DoLoadElement(Node* node) {
void SimplifiedLowering::DoStoreElement(Node* node) {
const ElementAccess& access = ElementAccessOf(node->op());
Type* type = NodeProperties::GetBounds(node->InputAt(2)).upper;
Type* type = NodeProperties::GetType(node->InputAt(2));
node->set_op(machine()->Store(
StoreRepresentation(access.machine_type,
ComputeWriteBarrierKind(access.base_is_tagged,
@ -1614,7 +1614,7 @@ Node* SimplifiedLowering::Uint32Mod(Node* const node) {
void SimplifiedLowering::DoShift(Node* node, Operator const* op) {
node->set_op(op);
Node* const rhs = NodeProperties::GetValueInput(node, 1);
Type* const rhs_type = NodeProperties::GetBounds(rhs).upper;
Type* const rhs_type = NodeProperties::GetType(rhs);
if (!rhs_type->Is(zero_thirtyone_range_)) {
node->ReplaceInput(1, graph()->NewNode(machine()->Word32And(), rhs,
jsgraph()->Int32Constant(0x1f)));

File diff suppressed because it is too large Load Diff

View File

@ -52,7 +52,7 @@ class Verifier::Visitor {
private:
// TODO(rossberg): Get rid of these once we got rid of NodeProperties.
Bounds bounds(Node* node) { return NodeProperties::GetBounds(node); }
Type* type_of(Node* node) { return NodeProperties::GetType(node); }
Node* ValueInput(Node* node, int i = 0) {
return NodeProperties::GetValueInput(node, i);
}
@ -65,22 +65,22 @@ class Verifier::Visitor {
}
}
void CheckUpperIs(Node* node, Type* type) {
if (typing == TYPED && !bounds(node).upper->Is(type)) {
if (typing == TYPED && !type_of(node)->Is(type)) {
std::ostringstream str;
str << "TypeError: node #" << node->id() << ":" << *node->op()
<< " upper bound ";
bounds(node).upper->PrintTo(str);
<< " type ";
type_of(node)->PrintTo(str);
str << " is not ";
type->PrintTo(str);
FATAL(str.str().c_str());
}
}
void CheckUpperMaybe(Node* node, Type* type) {
if (typing == TYPED && !bounds(node).upper->Maybe(type)) {
if (typing == TYPED && !type_of(node)->Maybe(type)) {
std::ostringstream str;
str << "TypeError: node #" << node->id() << ":" << *node->op()
<< " upper bound ";
bounds(node).upper->PrintTo(str);
<< " type ";
type_of(node)->PrintTo(str);
str << " must intersect ";
type->PrintTo(str);
FATAL(str.str().c_str());
@ -88,12 +88,12 @@ class Verifier::Visitor {
}
void CheckValueInputIs(Node* node, int i, Type* type) {
Node* input = ValueInput(node, i);
if (typing == TYPED && !bounds(input).upper->Is(type)) {
if (typing == TYPED && !type_of(input)->Is(type)) {
std::ostringstream str;
str << "TypeError: node #" << node->id() << ":" << *node->op()
<< "(input @" << i << " = " << input->opcode() << ":"
<< input->op()->mnemonic() << ") upper bound ";
bounds(input).upper->PrintTo(str);
<< input->op()->mnemonic() << ") type ";
type_of(input)->PrintTo(str);
str << " is not ";
type->PrintTo(str);
FATAL(str.str().c_str());
@ -398,9 +398,7 @@ void Verifier::Visitor::Check(Node* node) {
// TODO(rossberg): for now at least, narrowing does not really hold.
/*
for (int i = 0; i < value_count; ++i) {
// TODO(rossberg, jarin): Figure out what to do about lower bounds.
// CHECK(bounds(node).lower->Is(bounds(ValueInput(node, i)).lower));
CHECK(bounds(ValueInput(node, i)).upper->Is(bounds(node).upper));
CHECK(type_of(ValueInput(node, i))->Is(type_of(node)));
}
*/
break;
@ -427,8 +425,7 @@ void Verifier::Visitor::Check(Node* node) {
// TODO(rossberg): what are the constraints on these?
// Type must be subsumed by input type.
if (typing == TYPED) {
CHECK(bounds(ValueInput(node)).lower->Is(bounds(node).lower));
CHECK(bounds(ValueInput(node)).upper->Is(bounds(node).upper));
CHECK(type_of(ValueInput(node))->Is(type_of(node)));
}
break;
}
@ -568,7 +565,7 @@ void Verifier::Visitor::Check(Node* node) {
// TODO(rossberg): This should really be Is(Internal), but the typer
// currently can't do backwards propagation.
CheckUpperMaybe(context, Type::Internal());
if (typing == TYPED) CHECK(bounds(node).upper->IsContext());
if (typing == TYPED) CHECK(type_of(node)->IsContext());
break;
}

View File

@ -45,7 +45,7 @@ class JSConstantCacheTester : public HandleAndZoneScope,
main_typer_.Run();
}
Type* upper(Node* node) { return NodeProperties::GetBounds(node).upper; }
Type* TypeOf(Node* node) { return NodeProperties::GetType(node); }
Handle<HeapObject> handle(Node* node) {
CHECK_EQ(IrOpcode::kHeapConstant, node->opcode());
@ -69,7 +69,7 @@ TEST(ZeroConstant1) {
CHECK_NE(zero, T.Float64Constant(0));
CHECK_NE(zero, T.Int32Constant(0));
Type* t = T.upper(zero);
Type* t = T.TypeOf(zero);
CHECK(t->Is(Type::Number()));
CHECK(t->Is(Type::Integral32()));
@ -90,7 +90,7 @@ TEST(MinusZeroConstant) {
CHECK_EQ(minus_zero, T.Constant(-0.0));
CHECK_NE(zero, minus_zero);
Type* t = T.upper(minus_zero);
Type* t = T.TypeOf(minus_zero);
CHECK(t->Is(Type::Number()));
CHECK(t->Is(Type::MinusZero()));
@ -123,7 +123,7 @@ TEST(ZeroConstant2) {
CHECK_NE(zero, T.Float64Constant(0));
CHECK_NE(zero, T.Int32Constant(0));
Type* t = T.upper(zero);
Type* t = T.TypeOf(zero);
CHECK(t->Is(Type::Number()));
CHECK(t->Is(Type::Integral32()));
@ -148,7 +148,7 @@ TEST(OneConstant1) {
CHECK_NE(one, T.Float64Constant(1.0));
CHECK_NE(one, T.Int32Constant(1));
Type* t = T.upper(one);
Type* t = T.TypeOf(one);
CHECK(t->Is(Type::Number()));
CHECK(t->Is(Type::Integral32()));
@ -173,7 +173,7 @@ TEST(OneConstant2) {
CHECK_NE(one, T.Float64Constant(1.0));
CHECK_NE(one, T.Int32Constant(1));
Type* t = T.upper(one);
Type* t = T.TypeOf(one);
CHECK(t->Is(Type::Number()));
CHECK(t->Is(Type::Integral32()));
@ -233,7 +233,7 @@ TEST(NumberTypes) {
FOR_FLOAT64_INPUTS(i) {
double value = *i;
Node* node = T.Constant(value);
CHECK(T.upper(node)->Is(Type::Of(value, T.main_zone())));
CHECK(T.TypeOf(node)->Is(Type::Of(value, T.main_zone())));
}
}
@ -280,15 +280,15 @@ TEST(OddballValues) {
TEST(OddballTypes) {
JSConstantCacheTester T;
CHECK(T.upper(T.UndefinedConstant())->Is(Type::Undefined()));
CHECK(T.TypeOf(T.UndefinedConstant())->Is(Type::Undefined()));
// TODO(dcarney): figure this out.
// CHECK(T.upper(T.TheHoleConstant())->Is(Type::Internal()));
CHECK(T.upper(T.TrueConstant())->Is(Type::Boolean()));
CHECK(T.upper(T.FalseConstant())->Is(Type::Boolean()));
CHECK(T.upper(T.NullConstant())->Is(Type::Null()));
CHECK(T.upper(T.ZeroConstant())->Is(Type::Number()));
CHECK(T.upper(T.OneConstant())->Is(Type::Number()));
CHECK(T.upper(T.NaNConstant())->Is(Type::NaN()));
// CHECK(T.TypeOf(T.TheHoleConstant())->Is(Type::Internal()));
CHECK(T.TypeOf(T.TrueConstant())->Is(Type::Boolean()));
CHECK(T.TypeOf(T.FalseConstant())->Is(Type::Boolean()));
CHECK(T.TypeOf(T.NullConstant())->Is(Type::Null()));
CHECK(T.TypeOf(T.ZeroConstant())->Is(Type::Number()));
CHECK(T.TypeOf(T.OneConstant())->Is(Type::Number()));
CHECK(T.TypeOf(T.NaNConstant())->Is(Type::NaN()));
}

View File

@ -58,7 +58,7 @@ class JSTypedLoweringTester : public HandleAndZoneScope {
Node* Parameter(Type* t, int32_t index = 0) {
Node* n = graph.NewNode(common.Parameter(index), graph.start());
NodeProperties::SetBounds(n, Bounds(Type::None(), t));
NodeProperties::SetType(n, t);
return n;
}
@ -296,8 +296,8 @@ TEST_WITH_STRONG(NumberBinops) {
static void CheckToI32(Node* old_input, Node* new_input, bool is_signed) {
Type* old_type = NodeProperties::GetBounds(old_input).upper;
Type* new_type = NodeProperties::GetBounds(new_input).upper;
Type* old_type = NodeProperties::GetType(old_input);
Type* new_type = NodeProperties::GetType(new_input);
Type* expected_type = I32Type(is_signed);
CHECK(new_type->Is(expected_type));
if (old_type->Is(expected_type)) {
@ -489,7 +489,7 @@ TEST(JSToNumberOfConstant) {
// Note that either outcome below is correct. It only depends on whether
// the types of constants are eagerly computed or only computed by the
// typing pass.
if (NodeProperties::GetBounds(n).upper->Is(Type::Number())) {
if (NodeProperties::GetType(n)->Is(Type::Number())) {
// If number constants are eagerly typed, then reduction should
// remove the ToNumber.
CHECK_EQ(n, r);
@ -624,9 +624,9 @@ TEST_WITH_STRONG(StringComparison) {
static void CheckIsConvertedToNumber(Node* val, Node* converted) {
if (NodeProperties::GetBounds(val).upper->Is(Type::Number())) {
if (NodeProperties::GetType(val)->Is(Type::Number())) {
CHECK_EQ(val, converted);
} else if (NodeProperties::GetBounds(val).upper->Is(Type::Boolean())) {
} else if (NodeProperties::GetType(val)->Is(Type::Boolean())) {
CHECK_EQ(IrOpcode::kBooleanToNumber, converted->opcode());
CHECK_EQ(val, converted->InputAt(0));
} else {

View File

@ -101,7 +101,7 @@ TEST(RunNumberToInt32_float64) {
FieldAccess load = {kUntaggedBase, 0, Handle<Name>(), Type::Number(),
kMachFloat64};
Node* loaded = t.LoadField(load, t.PointerConstant(&input));
NodeProperties::SetBounds(loaded, Bounds(Type::Number()));
NodeProperties::SetType(loaded, Type::Number());
Node* convert = t.NumberToInt32(loaded);
FieldAccess store = {kUntaggedBase, 0, Handle<Name>(), Type::Signed32(),
kMachInt32};
@ -128,7 +128,7 @@ TEST(RunNumberToUint32_float64) {
FieldAccess load = {kUntaggedBase, 0, Handle<Name>(), Type::Number(),
kMachFloat64};
Node* loaded = t.LoadField(load, t.PointerConstant(&input));
NodeProperties::SetBounds(loaded, Bounds(Type::Number()));
NodeProperties::SetType(loaded, Type::Number());
Node* convert = t.NumberToUint32(loaded);
FieldAccess store = {kUntaggedBase, 0, Handle<Name>(), Type::Unsigned32(),
kMachUint32};
@ -687,9 +687,9 @@ class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders {
p1 = graph()->NewNode(common()->Parameter(1), start);
p2 = graph()->NewNode(common()->Parameter(2), start);
typer.Run();
NodeProperties::SetBounds(p0, Bounds(p0_type));
NodeProperties::SetBounds(p1, Bounds(p1_type));
NodeProperties::SetBounds(p2, Bounds(p2_type));
NodeProperties::SetType(p0, p0_type);
NodeProperties::SetType(p1, p1_type);
NodeProperties::SetType(p2, p2_type);
}
void CheckLoweringBinop(IrOpcode::Value expected, const Operator* op) {
@ -1120,7 +1120,7 @@ TEST(LowerNumberToUint32_to_TruncateFloat64ToInt32) {
TestingGraph t(Type::Number());
Node* p0 = t.ExampleWithOutput(kMachFloat64);
// TODO(titzer): run the typer here, or attach machine type to param.
NodeProperties::SetBounds(p0, Bounds(Type::Number()));
NodeProperties::SetType(p0, Type::Number());
Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), p0);
Node* use = t.Use(trunc, kMachUint32);
t.Return(use);
@ -1981,8 +1981,8 @@ TEST(PhiRepresentation) {
Node* phi =
t.graph()->NewNode(t.common()->Phi(kMachAnyTagged, 2), t.p0, t.p1, m);
Bounds phi_bounds = Bounds::Either(Bounds(d.arg1), Bounds(d.arg2), z);
NodeProperties::SetBounds(phi, phi_bounds);
Type* phi_type = Type::Union(d.arg1, d.arg2, z);
NodeProperties::SetType(phi, phi_type);
Node* use = t.Use(phi, d.use);
t.Return(use);

View File

@ -55,7 +55,7 @@ Node* GraphTest::NumberConstant(volatile double value) {
Node* GraphTest::HeapConstant(const Handle<HeapObject>& value) {
Node* node = graph()->NewNode(common()->HeapConstant(value));
Type* type = Type::Constant(value, zone());
NodeProperties::SetBounds(node, Bounds(type));
NodeProperties::SetType(node, type);
return node;
}
@ -109,7 +109,7 @@ TypedGraphTest::~TypedGraphTest() {}
Node* TypedGraphTest::Parameter(Type* type, int32_t index) {
Node* node = GraphTest::Parameter(index);
NodeProperties::SetBounds(node, Bounds(type));
NodeProperties::SetType(node, type);
return node;
}

View File

@ -58,11 +58,11 @@ class TyperTest : public TypedGraphTest {
Type* TypeBinaryOp(const Operator* op, Type* lhs, Type* rhs) {
Node* p0 = Parameter(0);
Node* p1 = Parameter(1);
NodeProperties::SetBounds(p0, Bounds(lhs));
NodeProperties::SetBounds(p1, Bounds(rhs));
NodeProperties::SetType(p0, lhs);
NodeProperties::SetType(p1, rhs);
Node* n = graph()->NewNode(op, p0, p1, context_node_, graph()->start(),
graph()->start());
return NodeProperties::GetBounds(n).upper;
return NodeProperties::GetType(n);
}
Type* RandomRange(bool int32 = false) {
@ -399,7 +399,7 @@ TEST_F(TyperTest, TypeRegressInt32Constant) {
int values[] = {-5, 10};
for (auto i : values) {
Node* c = graph()->NewNode(common()->Int32Constant(i));
Type* type = NodeProperties::GetBounds(c).upper;
Type* type = NodeProperties::GetType(c);
EXPECT_TRUE(type->Is(NewRange(i, i)));
}
}