Commit ba616de1 authored by Jaroslav Sevcik's avatar Jaroslav Sevcik Committed by Commit Bot

[turbofan] Remove the hacky Type::operator-> overload

This removes Type::operator-> which was used to split the change that
removed undefined misuse of Type* to represent integers.

Bug: v8:3770
Change-Id: I9a5bce5ccdc75461a7b939b4070cb58fe6040d99
Reviewed-on: https://chromium-review.googlesource.com/1033736Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Commit-Queue: Jaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52878}
parent 42392e83
......@@ -33,7 +33,7 @@ bool NoReturn(Node* node) {
return node->opcode() == IrOpcode::kDead ||
node->opcode() == IrOpcode::kUnreachable ||
node->opcode() == IrOpcode::kDeadValue ||
NodeProperties::GetTypeOrAny(node)->IsNone();
NodeProperties::GetTypeOrAny(node).IsNone();
}
Node* FindDeadInput(Node* node) {
......@@ -217,7 +217,7 @@ Reduction DeadCodeElimination::ReducePhi(Node* node) {
if (reduction.Changed()) return reduction;
MachineRepresentation rep = PhiRepresentationOf(node->op());
if (rep == MachineRepresentation::kNone ||
NodeProperties::GetTypeOrAny(node)->IsNone()) {
NodeProperties::GetTypeOrAny(node).IsNone()) {
return Replace(DeadValue(node, rep));
}
int input_count = node->op()->ValueInputCount();
......
......@@ -4072,7 +4072,7 @@ void EffectControlLinearizer::LowerTransitionAndStoreNonNumberElement(
// Our ElementsKind is HOLEY_ELEMENTS.
ElementAccess access = AccessBuilder::ForFixedArrayElement(HOLEY_ELEMENTS);
Type value_type = ValueTypeParameterOf(node->op());
if (value_type->Is(Type::BooleanOrNullOrUndefined())) {
if (value_type.Is(Type::BooleanOrNullOrUndefined())) {
access.type = value_type;
access.write_barrier_kind = kNoWriteBarrier;
}
......
......@@ -44,7 +44,7 @@ Reduction EscapeAnalysisReducer::ReplaceNode(Node* original,
}
Type const replacement_type = NodeProperties::GetType(replacement);
Type const original_type = NodeProperties::GetType(original);
if (replacement_type->Is(original_type)) {
if (replacement_type.Is(original_type)) {
RelaxEffectsAndControls(original);
return Replace(replacement);
}
......
......@@ -503,9 +503,9 @@ Maybe<int> OffsetOfElementsAccess(const Operator* op, Node* index_node) {
DCHECK(op->opcode() == IrOpcode::kLoadElement ||
op->opcode() == IrOpcode::kStoreElement);
Type index_type = NodeProperties::GetType(index_node);
if (!index_type->Is(Type::OrderedNumber())) return Nothing<int>();
double max = index_type->Max();
double min = index_type->Min();
if (!index_type.Is(Type::OrderedNumber())) return Nothing<int>();
double max = index_type.Max();
double min = index_type.Min();
int index = static_cast<int>(min);
if (!(index == min && index == max)) return Nothing<int>();
ElementAccess access = ElementAccessOf(op);
......@@ -649,8 +649,8 @@ void ReduceNode(const Operator* op, EscapeAnalysisTracker::Scope* current,
// types (which might confuse representation selection). We get
// around this by refusing to constant-fold and escape-analyze
// if the type is not inhabited.
if (!NodeProperties::GetType(left)->IsNone() &&
!NodeProperties::GetType(right)->IsNone()) {
if (!NodeProperties::GetType(left).IsNone() &&
!NodeProperties::GetType(right).IsNone()) {
current->SetReplacement(replacement);
} else {
current->SetEscaped(left);
......@@ -670,9 +670,9 @@ void ReduceNode(const Operator* op, EscapeAnalysisTracker::Scope* current,
current->Get(map_field).To(&map)) {
if (map) {
Type const map_type = NodeProperties::GetType(map);
if (map_type->IsHeapConstant() &&
if (map_type.IsHeapConstant() &&
params.maps().contains(
bit_cast<Handle<Map>>(map_type->AsHeapConstant()->Value()))) {
bit_cast<Handle<Map>>(map_type.AsHeapConstant()->Value()))) {
current->MarkForDeletion();
break;
}
......
......@@ -171,7 +171,7 @@ class JSONGraphNodeWriter {
if (NodeProperties::IsTyped(node)) {
Type type = NodeProperties::GetType(node);
std::ostringstream type_out;
type->PrintTo(type_out);
type.PrintTo(type_out);
os_ << ",\"type\":\"" << JSONEscaped(type_out) << "\"";
}
os_ << "}";
......@@ -401,8 +401,7 @@ void GraphC1Visualizer::PrintInputs(Node* node) {
void GraphC1Visualizer::PrintType(Node* node) {
if (NodeProperties::IsTyped(node)) {
Type type = NodeProperties::GetType(node);
os_ << " type:";
type->PrintTo(os_);
os_ << " type:" << type;
}
}
......@@ -708,9 +707,7 @@ std::ostream& operator<<(std::ostream& os, const AsRPO& ar) {
os << ")";
// Print the node type, if any.
if (NodeProperties::IsTyped(n)) {
os << " [Type: ";
NodeProperties::GetType(n)->PrintTo(os);
os << "]";
os << " [Type: " << NodeProperties::GetType(n) << "]";
}
os << std::endl;
}
......@@ -739,9 +736,7 @@ void PrintScheduledNode(std::ostream& os, int indent, Node* n) {
os << ")";
// Print the node type, if any.
if (NodeProperties::IsTyped(n)) {
os << " [Type: ";
NodeProperties::GetType(n)->PrintTo(os);
os << "]";
os << " [Type: " << NodeProperties::GetType(n) << "]";
}
}
......
......@@ -2140,7 +2140,7 @@ Node* JSCallReducer::DoFilterPostCallbackWork(ElementsKind kind, Node** control,
simplified()->LoadField(AccessBuilder::ForJSObjectElements()), a, etrue,
if_true);
DCHECK(TypeCache::Get().kFixedDoubleArrayLengthType->Is(
DCHECK(TypeCache::Get().kFixedDoubleArrayLengthType.Is(
TypeCache::Get().kFixedArrayLengthType));
Node* checked_to = etrue = graph()->NewNode(
common()->TypeGuard(TypeCache::Get().kFixedArrayLengthType), to, etrue,
......@@ -4844,7 +4844,7 @@ Reduction JSCallReducer::ReduceArrayIteratorPrototypeNext(Node* node) {
// We know that the {index} is range of the {length} now.
index = etrue = graph()->NewNode(
common()->TypeGuard(
Type::Range(0.0, length_access.type->Max() - 1.0, graph()->zone())),
Type::Range(0.0, length_access.type.Max() - 1.0, graph()->zone())),
index, etrue, if_true);
done_true = jsgraph()->FalseConstant();
......
......@@ -190,14 +190,14 @@ Reduction JSCreateLowering::ReduceJSCreate(Node* node) {
Node* const effect = NodeProperties::GetEffectInput(node);
Node* const control = NodeProperties::GetControlInput(node);
// Extract constructor and original constructor function.
if (target_type->IsHeapConstant() && new_target_type->IsHeapConstant() &&
target_type->AsHeapConstant()->Value()->IsJSFunction() &&
new_target_type->AsHeapConstant()->Value()->IsJSFunction()) {
if (target_type.IsHeapConstant() && new_target_type.IsHeapConstant() &&
target_type.AsHeapConstant()->Value()->IsJSFunction() &&
new_target_type.AsHeapConstant()->Value()->IsJSFunction()) {
Handle<JSFunction> constructor =
Handle<JSFunction>::cast(target_type->AsHeapConstant()->Value());
Handle<JSFunction>::cast(target_type.AsHeapConstant()->Value());
if (!constructor->IsConstructor()) return NoChange();
Handle<JSFunction> original_constructor =
Handle<JSFunction>::cast(new_target_type->AsHeapConstant()->Value());
Handle<JSFunction>::cast(new_target_type.AsHeapConstant()->Value());
if (!original_constructor->IsConstructor()) return NoChange();
// Check if we can inline the allocation.
......@@ -479,10 +479,10 @@ Reduction JSCreateLowering::ReduceJSCreateGeneratorObject(Node* node) {
Type const closure_type = NodeProperties::GetType(closure);
Node* effect = NodeProperties::GetEffectInput(node);
Node* const control = NodeProperties::GetControlInput(node);
if (closure_type->IsHeapConstant()) {
DCHECK(closure_type->AsHeapConstant()->Value()->IsJSFunction());
if (closure_type.IsHeapConstant()) {
DCHECK(closure_type.AsHeapConstant()->Value()->IsJSFunction());
Handle<JSFunction> js_function =
Handle<JSFunction>::cast(closure_type->AsHeapConstant()->Value());
Handle<JSFunction>::cast(closure_type.AsHeapConstant()->Value());
JSFunction::EnsureHasInitialMap(js_function);
// Force completion of inobject slack tracking before
......@@ -604,7 +604,7 @@ Reduction JSCreateLowering::ReduceNewArray(Node* node, Node* length,
// Determine the appropriate elements kind.
ElementsKind elements_kind = initial_map->elements_kind();
if (NodeProperties::GetType(length)->Max() > 0.0) {
if (NodeProperties::GetType(length).Max() > 0.0) {
elements_kind = GetHoleyElementsKind(elements_kind);
initial_map = Map::AsElementsKind(initial_map, elements_kind);
}
......@@ -653,14 +653,14 @@ Reduction JSCreateLowering::ReduceNewArray(Node* node,
// deoptimize in this case.
if (IsSmiElementsKind(elements_kind)) {
for (auto& value : values) {
if (!NodeProperties::GetType(value)->Is(Type::SignedSmall())) {
if (!NodeProperties::GetType(value).Is(Type::SignedSmall())) {
value = effect = graph()->NewNode(
simplified()->CheckSmi(VectorSlotPair()), value, effect, control);
}
}
} else if (IsDoubleElementsKind(elements_kind)) {
for (auto& value : values) {
if (!NodeProperties::GetType(value)->Is(Type::Number())) {
if (!NodeProperties::GetType(value).Is(Type::Number())) {
value = effect =
graph()->NewNode(simplified()->CheckNumber(VectorSlotPair()), value,
effect, control);
......@@ -712,7 +712,7 @@ Reduction JSCreateLowering::ReduceNewArrayToStubCall(
// The Array constructor can only trigger an observable side-effect
// if the new.target may be a proxy.
Operator::Properties const properties =
(new_target != target || new_target_type->Maybe(Type::Proxy()))
(new_target != target || new_target_type.Maybe(Type::Proxy()))
? Operator::kNoDeopt
: Operator::kNoDeopt | Operator::kNoWrite;
......@@ -768,10 +768,10 @@ Reduction JSCreateLowering::ReduceJSCreateArray(Node* node) {
: NodeProperties::GetType(new_target);
// Extract original constructor function.
if (new_target_type->IsHeapConstant() &&
new_target_type->AsHeapConstant()->Value()->IsJSFunction()) {
if (new_target_type.IsHeapConstant() &&
new_target_type.AsHeapConstant()->Value()->IsJSFunction()) {
Handle<JSFunction> original_constructor =
Handle<JSFunction>::cast(new_target_type->AsHeapConstant()->Value());
Handle<JSFunction>::cast(new_target_type.AsHeapConstant()->Value());
DCHECK(constructor->IsConstructor());
DCHECK(original_constructor->IsConstructor());
......@@ -812,7 +812,7 @@ Reduction JSCreateLowering::ReduceJSCreateArray(Node* node) {
} else if (arity == 1) {
Node* length = NodeProperties::GetValueInput(node, 2);
Type length_type = NodeProperties::GetType(length);
if (!length_type->Maybe(Type::Number())) {
if (!length_type.Maybe(Type::Number())) {
// Handle the single argument case, where we know that the value
// cannot be a valid Array length.
ElementsKind elements_kind = initial_map->elements_kind();
......@@ -824,13 +824,13 @@ Reduction JSCreateLowering::ReduceJSCreateArray(Node* node) {
return ReduceNewArray(node, std::vector<Node*>{length}, initial_map,
pretenure);
}
if (length_type->Is(Type::SignedSmall()) && length_type->Min() >= 0 &&
length_type->Max() <= kElementLoopUnrollLimit &&
length_type->Min() == length_type->Max()) {
int capacity = static_cast<int>(length_type->Max());
if (length_type.Is(Type::SignedSmall()) && length_type.Min() >= 0 &&
length_type.Max() <= kElementLoopUnrollLimit &&
length_type.Min() == length_type.Max()) {
int capacity = static_cast<int>(length_type.Max());
return ReduceNewArray(node, length, capacity, initial_map, pretenure);
}
if (length_type->Maybe(Type::UnsignedSmall()) && can_inline_call) {
if (length_type.Maybe(Type::UnsignedSmall()) && can_inline_call) {
return ReduceNewArray(node, length, initial_map, pretenure);
}
} else if (arity <= JSArray::kInitialMaxFastElementArray) {
......@@ -842,13 +842,13 @@ Reduction JSCreateLowering::ReduceJSCreateArray(Node* node) {
for (int i = 0; i < arity; ++i) {
Node* value = NodeProperties::GetValueInput(node, 2 + i);
Type value_type = NodeProperties::GetType(value);
if (!value_type->Is(Type::SignedSmall())) {
if (!value_type.Is(Type::SignedSmall())) {
values_all_smis = false;
}
if (!value_type->Is(Type::Number())) {
if (!value_type.Is(Type::Number())) {
values_all_numbers = false;
}
if (!value_type->Maybe(Type::Number())) {
if (!value_type.Maybe(Type::Number())) {
values_any_nonnumber = true;
}
values.push_back(value);
......
This diff is collapsed.
......@@ -36,7 +36,7 @@ Node* ResolveRenames(Node* node) {
bool MayAlias(Node* a, Node* b) {
if (a == b) return true;
if (!NodeProperties::GetType(a)->Maybe(NodeProperties::GetType(b))) {
if (!NodeProperties::GetType(a).Maybe(NodeProperties::GetType(b))) {
return false;
}
switch (b->opcode()) {
......@@ -252,7 +252,7 @@ LoadElimination::AbstractElements::Kill(Node* object, Node* index,
DCHECK_NOT_NULL(element.index);
DCHECK_NOT_NULL(element.value);
if (!MayAlias(object, element.object) ||
!NodeProperties::GetType(index)->Maybe(
!NodeProperties::GetType(index).Maybe(
NodeProperties::GetType(element.index))) {
that->elements_[that->next_index_++] = element;
}
......@@ -928,7 +928,7 @@ Reduction LoadElimination::ReduceLoadField(Node* node) {
// TODO(tebbi): We should insert a {TypeGuard} for the intersection of
// these two types here once we properly handle {Type::None} everywhere.
if (!replacement->IsDead() && NodeProperties::GetType(replacement)
->Is(NodeProperties::GetType(node))) {
.Is(NodeProperties::GetType(node))) {
ReplaceWithValue(node, replacement, effect);
return Replace(replacement);
}
......@@ -956,10 +956,10 @@ Reduction LoadElimination::ReduceStoreField(Node* node) {
// Kill all potential knowledge about the {object}s map.
state = state->KillMaps(object, zone());
Type const new_value_type = NodeProperties::GetType(new_value);
if (new_value_type->IsHeapConstant()) {
if (new_value_type.IsHeapConstant()) {
// Record the new {object} map information.
ZoneHandleSet<Map> object_maps(
bit_cast<Handle<Map>>(new_value_type->AsHeapConstant()->Value()));
bit_cast<Handle<Map>>(new_value_type.AsHeapConstant()->Value()));
state = state->SetMaps(object, object_maps, zone());
}
} else {
......@@ -1016,7 +1016,7 @@ Reduction LoadElimination::ReduceLoadElement(Node* node) {
// TODO(tebbi): We should insert a {TypeGuard} for the intersection of
// these two types here once we properly handle {Type::None} everywhere.
if (!replacement->IsDead() && NodeProperties::GetType(replacement)
->Is(NodeProperties::GetType(node))) {
.Is(NodeProperties::GetType(node))) {
ReplaceWithValue(node, replacement, effect);
return Replace(replacement);
}
......
......@@ -326,7 +326,7 @@ void LoopVariableOptimizer::ChangeToPhisAndInsertGuards() {
Node* backedge_value = induction_var->phi()->InputAt(1);
Type backedge_type = NodeProperties::GetType(backedge_value);
Type phi_type = NodeProperties::GetType(induction_var->phi());
if (!backedge_type->Is(phi_type)) {
if (!backedge_type.Is(phi_type)) {
Node* loop = NodeProperties::GetControlInput(induction_var->phi());
Node* backedge_control = loop->InputAt(1);
Node* backedge_effect =
......
This diff is collapsed.
......@@ -255,7 +255,7 @@ Reduction RedundancyElimination::TryReuseBoundsCheckForFirstInput(Node* node) {
if (Node* bounds_check = checks->LookupBoundsCheckFor(left)) {
// Only use the bounds checked type if it is better.
if (NodeProperties::GetType(bounds_check)
->Is(NodeProperties::GetType(left))) {
.Is(NodeProperties::GetType(left))) {
node->ReplaceInput(0, bounds_check);
}
}
......
This diff is collapsed.
......@@ -532,9 +532,7 @@ std::ostream& operator<<(std::ostream& os, const Schedule& s) {
for (Node* node : *block) {
os << " " << *node;
if (NodeProperties::IsTyped(node)) {
Type type = NodeProperties::GetType(node);
os << " : ";
type->PrintTo(os);
os << " : " << NodeProperties::GetType(node);
}
os << "\n";
}
......
This diff is collapsed.
......@@ -62,8 +62,8 @@ std::ostream& operator<<(std::ostream& os, FieldAccess const& access) {
os << Brief(*map) << ", ";
}
#endif
access.type->PrintTo(os);
os << ", " << access.machine_type << ", " << access.write_barrier_kind << "]";
os << access.type << ", " << access.machine_type << ", "
<< access.write_barrier_kind << "]";
return os;
}
......@@ -96,9 +96,9 @@ size_t hash_value(ElementAccess const& access) {
std::ostream& operator<<(std::ostream& os, ElementAccess const& access) {
os << access.base_is_tagged << ", " << access.header_size << ", ";
access.type->PrintTo(os);
os << ", " << access.machine_type << ", " << access.write_barrier_kind;
os << access.base_is_tagged << ", " << access.header_size << ", "
<< access.type << ", " << access.machine_type << ", "
<< access.write_barrier_kind;
return os;
}
......@@ -394,8 +394,8 @@ size_t hash_value(TransitionAndStoreNonNumberElementParameters parameters) {
std::ostream& operator<<(
std::ostream& os, TransitionAndStoreNonNumberElementParameters parameters) {
parameters.value_type()->PrintTo(os);
return os << ", fast-map" << Brief(*parameters.fast_map());
return os << parameters.value_type() << ", fast-map"
<< Brief(*parameters.fast_map());
}
} // namespace
......@@ -526,8 +526,7 @@ size_t hash_value(AllocateParameters info) {
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
AllocateParameters info) {
info.type()->PrintTo(os);
return os << ", " << info.pretenure();
return os << info.type() << ", " << info.pretenure();
}
bool operator==(AllocateParameters const& lhs, AllocateParameters const& rhs) {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -58,12 +58,12 @@ namespace compiler {
//
// There are two main functions for testing types:
//
// T1->Is(T2) -- tests whether T1 is included in T2 (i.e., T1 <= T2)
// T1->Maybe(T2) -- tests whether T1 and T2 overlap (i.e., T1 /\ T2 =/= 0)
// T1.Is(T2) -- tests whether T1 is included in T2 (i.e., T1 <= T2)
// T1.Maybe(T2) -- tests whether T1 and T2 overlap (i.e., T1 /\ T2 =/= 0)
//
// Typically, the former is to be used to select representations (e.g., via
// T->Is(SignedSmall())), and the latter to check whether a specific case needs
// handling (e.g., via T->Maybe(Number())).
// T.Is(SignedSmall())), and the latter to check whether a specific case needs
// handling (e.g., via T.Maybe(Number())).
//
// There is no functionality to discover whether a type is a leaf in the
// lattice. That is intentional. It should always be possible to refine the
......@@ -397,7 +397,7 @@ class V8_EXPORT_PRIVATE Type {
return payload_ == that.payload_ || this->SlowIs(that);
}
bool Maybe(Type that) const;
bool Equals(Type that) const { return this->Is(that) && that->Is(*this); }
bool Equals(Type that) const { return this->Is(that) && that.Is(*this); }
// Inspection.
bool IsBitset() const { return payload_ & 1; }
......@@ -433,11 +433,6 @@ class V8_EXPORT_PRIVATE Type {
static Type Invalid() { return Type(); }
// TODO(jarin) This is just a hack to make the transition from Type* to
// Type more incremental.
Type* operator->() { return this; }
const Type* operator->() const { return this; }
bool operator==(Type other) const { return payload_ == other.payload_; }
bool operator!=(Type other) const { return payload_ != other.payload_; }
......
......@@ -130,13 +130,13 @@ Reduction ValueNumberingReducer::ReplaceIfTypesMatch(Node* node,
if (NodeProperties::IsTyped(replacement) && NodeProperties::IsTyped(node)) {
Type replacement_type = NodeProperties::GetType(replacement);
Type node_type = NodeProperties::GetType(node);
if (!replacement_type->Is(node_type)) {
if (!replacement_type.Is(node_type)) {
// Ideally, we would set an intersection of {replacement_type} and
// {node_type} here. However, typing of NumberConstants assigns different
// types to constants with the same value (it creates a fresh heap
// number), which would make the intersection empty. To be safe, we use
// the smaller type if the types are comparable.
if (node_type->Is(replacement_type)) {
if (node_type.Is(replacement_type)) {
NodeProperties::SetType(replacement, node_type);
} else {
// Types are not comparable => do not replace.
......
......@@ -55,37 +55,29 @@ class Verifier::Visitor {
}
}
void CheckTypeIs(Node* node, Type type) {
if (typing == TYPED && !NodeProperties::GetType(node)->Is(type)) {
if (typing == TYPED && !NodeProperties::GetType(node).Is(type)) {
std::ostringstream str;
str << "TypeError: node #" << node->id() << ":" << *node->op()
<< " type ";
NodeProperties::GetType(node)->PrintTo(str);
str << " is not ";
type->PrintTo(str);
str << "TypeError: node #" << node->id() << ":" << *node->op() << " type "
<< NodeProperties::GetType(node) << " is not " << type;
FATAL("%s", str.str().c_str());
}
}
void CheckTypeMaybe(Node* node, Type type) {
if (typing == TYPED && !NodeProperties::GetType(node)->Maybe(type)) {
if (typing == TYPED && !NodeProperties::GetType(node).Maybe(type)) {
std::ostringstream str;
str << "TypeError: node #" << node->id() << ":" << *node->op()
<< " type ";
NodeProperties::GetType(node)->PrintTo(str);
str << " must intersect ";
type->PrintTo(str);
str << "TypeError: node #" << node->id() << ":" << *node->op() << " type "
<< NodeProperties::GetType(node) << " must intersect " << type;
FATAL("%s", str.str().c_str());
}
}
void CheckValueInputIs(Node* node, int i, Type type) {
Node* input = NodeProperties::GetValueInput(node, i);
if (typing == TYPED && !NodeProperties::GetType(input)->Is(type)) {
if (typing == TYPED && !NodeProperties::GetType(input).Is(type)) {
std::ostringstream str;
str << "TypeError: node #" << node->id() << ":" << *node->op()
<< "(input @" << i << " = " << input->opcode() << ":"
<< input->op()->mnemonic() << ") type ";
NodeProperties::GetType(input)->PrintTo(str);
str << " is not ";
type->PrintTo(str);
<< input->op()->mnemonic() << ") type "
<< NodeProperties::GetType(input) << " is not " << type;
FATAL("%s", str.str().c_str());
}
}
......@@ -544,7 +536,7 @@ void Verifier::Visitor::Check(Node* node, const AllNodes& all) {
// Type must be subsumed by input type.
if (typing == TYPED) {
Node* val = NodeProperties::GetValueInput(node, 0);
CHECK(NodeProperties::GetType(val)->Is(NodeProperties::GetType(node)));
CHECK(NodeProperties::GetType(val).Is(NodeProperties::GetType(node)));
}
break;
}
......
......@@ -278,8 +278,8 @@ static void CheckToI32(Node* old_input, Node* new_input, bool is_signed) {
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)) {
CHECK(new_type.Is(expected_type));
if (old_type.Is(expected_type)) {
CHECK_EQ(old_input, new_input);
} else if (new_input->opcode() == IrOpcode::kNumberConstant) {
double v = OpParameter<double>(new_input->op());
......@@ -436,7 +436,7 @@ TEST(JSToNumber_replacement) {
R.CheckEffectInput(c, effect_use);
Node* r = R.reduce(c);
if (types[i]->Is(Type::Number())) {
if (types[i].Is(Type::Number())) {
CHECK_EQ(n, r);
} else {
CHECK_EQ(IrOpcode::kNumberConstant, r->opcode());
......@@ -463,7 +463,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::GetType(n)->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);
......@@ -547,7 +547,7 @@ TEST(JSToString_replacement) {
R.CheckEffectInput(c, effect_use);
Node* r = R.reduce(c);
if (types[i]->Is(Type::String())) {
if (types[i].Is(Type::String())) {
CHECK_EQ(n, r);
} else {
CHECK_EQ(IrOpcode::kHeapConstant, r->opcode());
......@@ -598,7 +598,7 @@ TEST(StringComparison) {
static void CheckIsConvertedToNumber(Node* val, Node* converted) {
if (NodeProperties::GetType(val)->Is(Type::Number())) {
if (NodeProperties::GetType(val).Is(Type::Number())) {
CHECK_EQ(val, converted);
} else {
if (converted->opcode() == IrOpcode::kNumberConstant) return;
......@@ -656,12 +656,12 @@ TEST(MixedComparison1) {
R.javascript.LessThan(CompareOperationHint::kAny);
Node* cmp = R.Binop(less_than, p0, p1);
Node* r = R.reduce(cmp);
if (types[i]->Is(Type::String()) && types[j]->Is(Type::String())) {
if (types[i].Is(Type::String()) && types[j].Is(Type::String())) {
R.CheckBinop(R.simplified.StringLessThan(), r);
} else if ((types[i]->Is(Type::Number()) &&
types[j]->Is(Type::Number())) ||
(!types[i]->Maybe(Type::String()) ||
!types[j]->Maybe(Type::String()))) {
} else if ((types[i].Is(Type::Number()) &&
types[j].Is(Type::Number())) ||
(!types[i].Maybe(Type::String()) ||
!types[j].Maybe(Type::String()))) {
R.CheckBinop(R.simplified.NumberLessThan(), r);
} else {
// No reduction of mixed types.
......
......@@ -282,7 +282,7 @@ static void CheckChange(IrOpcode::Value expected, MachineRepresentation from,
if (expected == IrOpcode::kCheckedFloat64ToInt32) {
CheckForMinusZeroMode mode =
from_type->Maybe(Type::MinusZero())
from_type.Maybe(Type::MinusZero())
? use_info.minus_zero_check()
: CheckForMinusZeroMode::kDontCheckForMinusZero;
CHECK_EQ(mode, CheckMinusZeroParametersOf(c->op()).mode());
......
This diff is collapsed.
......@@ -172,7 +172,7 @@ class Types {
#define PICK_BITSET_TYPE(type, value) \
if (j-- == 0) { \
Type tmp = Type::Intersect(result, Type::type(), zone_); \
if (tmp->Is(Type::None()) && i != 0) { \
if (tmp.Is(Type::None()) && i != 0) { \
break; \
} else { \
result = tmp; \
......
......@@ -153,7 +153,7 @@ class TyperTest : public TypedGraphTest {
Type subtype;
do {
subtype = types_.Fuzz();
} while (!subtype->Is(type));
} while (!subtype.Is(type));
return subtype;
}
......@@ -175,7 +175,7 @@ class TyperTest : public TypedGraphTest {
double result_value = opfun(x1, x2);
Type result_type = Type::NewConstant(
isolate()->factory()->NewNumber(result_value), zone());
EXPECT_TRUE(result_type->Is(expected_type));
EXPECT_TRUE(result_type.Is(expected_type));
}
}
}
......@@ -191,12 +191,12 @@ class TyperTest : public TypedGraphTest {
Type r2 = RandomRange();
Type expected_type = TypeBinaryOp(op, r1, r2);
for (int i = 0; i < 10; i++) {
double x1 = RandomInt(r1->AsRange());
double x2 = RandomInt(r2->AsRange());
double x1 = RandomInt(r1.AsRange());
double x2 = RandomInt(r2.AsRange());
double result_value = opfun(x1, x2);
Type result_type = Type::NewConstant(
isolate()->factory()->NewNumber(result_value), zone());
EXPECT_TRUE(result_type->Is(expected_type));
EXPECT_TRUE(result_type.Is(expected_type));
}
}
// Test extreme cases.
......@@ -208,7 +208,7 @@ class TyperTest : public TypedGraphTest {
double result_value = opfun(x1, x2);
Type result_type = Type::NewConstant(
isolate()->factory()->NewNumber(result_value), zone());
EXPECT_TRUE(result_type->Is(expected_type));
EXPECT_TRUE(result_type.Is(expected_type));
}
template <class BinaryFunction>
......@@ -218,14 +218,14 @@ class TyperTest : public TypedGraphTest {
Type r2 = RandomRange();
Type expected_type = TypeBinaryOp(op, r1, r2);
for (int i = 0; i < 10; i++) {
double x1 = RandomInt(r1->AsRange());
double x2 = RandomInt(r2->AsRange());
double x1 = RandomInt(r1.AsRange());
double x2 = RandomInt(r2.AsRange());
bool result_value = opfun(x1, x2);
Type result_type = Type::NewConstant(
result_value ? isolate()->factory()->true_value()
: isolate()->factory()->false_value(),
zone());
EXPECT_TRUE(result_type->Is(expected_type));
EXPECT_TRUE(result_type.Is(expected_type));
}
}
}
......@@ -237,12 +237,12 @@ class TyperTest : public TypedGraphTest {
Type r2 = RandomRange(true);
Type expected_type = TypeBinaryOp(op, r1, r2);
for (int i = 0; i < 10; i++) {
int32_t x1 = static_cast<int32_t>(RandomInt(r1->AsRange()));
int32_t x2 = static_cast<int32_t>(RandomInt(r2->AsRange()));
int32_t x1 = static_cast<int32_t>(RandomInt(r1.AsRange()));
int32_t x2 = static_cast<int32_t>(RandomInt(r2.AsRange()));
double result_value = opfun(x1, x2);
Type result_type = Type::NewConstant(
isolate()->factory()->NewNumber(result_value), zone());
EXPECT_TRUE(result_type->Is(expected_type));
EXPECT_TRUE(result_type.Is(expected_type));
}
}
}
......@@ -252,28 +252,28 @@ class TyperTest : public TypedGraphTest {
void TestUnaryMonotonicity(UnaryTyper typer, Type upper1 = Type::Any()) {
Type type1 = Type::Intersect(types_.Fuzz(), upper1, zone());
DCHECK(type1->Is(upper1));
DCHECK(type1.Is(upper1));
Type type = typer(type1);
Type subtype1 = RandomSubtype(type1);
Type subtype = typer(subtype1);
EXPECT_TRUE(subtype->Is(type));
EXPECT_TRUE(subtype.Is(type));
}
void TestBinaryMonotonicity(BinaryTyper typer, Type upper1 = Type::Any(),
Type upper2 = Type::Any()) {
Type type1 = Type::Intersect(types_.Fuzz(), upper1, zone());
DCHECK(type1->Is(upper1));
DCHECK(type1.Is(upper1));
Type type2 = Type::Intersect(types_.Fuzz(), upper2, zone());
DCHECK(type2->Is(upper2));
DCHECK(type2.Is(upper2));
Type type = typer(type1, type2);
Type subtype1 = RandomSubtype(type1);
Type subtype2 = RandomSubtype(type2);
Type subtype = typer(subtype1, subtype2);
EXPECT_TRUE(subtype->Is(type));
EXPECT_TRUE(subtype.Is(type));
}
void TestUnaryMonotonicity(const Operator* op, Type upper1 = Type::Any()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment