Commit 70bb9377 authored by mvstanton's avatar mvstanton Committed by Commit bot

[turbofan] HeapConstant types should compare by handle address

And not by pointer address.

BUG=

Review-Url: https://codereview.chromium.org/2390823011
Cr-Commit-Position: refs/heads/master@{#40106}
parent f12d66bf
......@@ -1031,10 +1031,8 @@ class RepresentationSelector {
// undefined, because these special oddballs are always in the root set.
return kNoWriteBarrier;
}
if (value_type->IsHeapConstant() &&
value_type->AsHeapConstant()->Value()->IsHeapObject()) {
Handle<HeapObject> value_object =
Handle<HeapObject>::cast(value_type->AsHeapConstant()->Value());
if (value_type->IsHeapConstant()) {
Handle<HeapObject> value_object = value_type->AsHeapConstant()->Value();
RootIndexMap root_index_map(jsgraph_->isolate());
int root_index = root_index_map.Lookup(*value_object);
if (root_index != RootIndexMap::kInvalidRootIndex &&
......
......@@ -98,11 +98,8 @@ Reduction TypedOptimization::Reduce(Node* node) {
namespace {
MaybeHandle<Map> GetStableMapFromObjectType(Type* object_type) {
if (object_type->IsHeapConstant() &&
object_type->AsHeapConstant()->Value()->IsHeapObject()) {
Handle<Map> object_map(
Handle<HeapObject>::cast(object_type->AsHeapConstant()->Value())
->map());
if (object_type->IsHeapConstant()) {
Handle<Map> object_map(object_type->AsHeapConstant()->Value()->map());
if (object_map->is_stable()) return object_map;
}
return MaybeHandle<Map>();
......
......@@ -1288,7 +1288,6 @@ Type* Typer::Visitor::TypeJSCallConstruct(Node* node) {
return Type::Receiver();
}
Type* Typer::Visitor::JSCallFunctionTyper(Type* fun, Typer* t) {
if (fun->IsHeapConstant() && fun->AsHeapConstant()->Value()->IsJSFunction()) {
Handle<JSFunction> function =
......
......@@ -403,11 +403,9 @@ bool OtherNumberConstantType::IsOtherNumberConstant(Object* value) {
}
HeapConstantType::HeapConstantType(BitsetType::bitset bitset,
i::Handle<i::Object> object)
i::Handle<i::HeapObject> object)
: TypeBase(kHeapConstant), bitset_(bitset), object_(object) {
// All number types should be expressed as Ranges, OtherNumberConstants,
// or bitsets (nan, negative-zero).
DCHECK(!object->IsSmi() && !object->IsHeapNumber());
DCHECK(!object->IsHeapNumber());
}
// -----------------------------------------------------------------------------
......@@ -417,7 +415,8 @@ bool Type::SimplyEquals(Type* that) {
DisallowHeapAllocation no_allocation;
if (this->IsHeapConstant()) {
return that->IsHeapConstant() &&
*this->AsHeapConstant()->Value() == *that->AsHeapConstant()->Value();
this->AsHeapConstant()->Value().address() ==
that->AsHeapConstant()->Value().address();
}
if (this->IsOtherNumberConstant()) {
return that->IsOtherNumberConstant() &&
......@@ -783,7 +782,7 @@ Type* Type::NewConstant(i::Handle<i::Object> value, Zone* zone) {
} else if (value->IsHeapNumber()) {
return NewConstant(value->Number(), zone);
}
return HeapConstant(value, zone);
return HeapConstant(i::Handle<i::HeapObject>::cast(value), zone);
}
Type* Type::Union(Type* type1, Type* type2, Zone* zone) {
......
......@@ -320,13 +320,13 @@ class OtherNumberConstantType : public TypeBase {
class HeapConstantType : public TypeBase {
public:
i::Handle<i::Object> Value() { return object_; }
i::Handle<i::HeapObject> Value() { return object_; }
private:
friend class Type;
friend class BitsetType;
static Type* New(i::Handle<i::Object> value, Zone* zone) {
static Type* New(i::Handle<i::HeapObject> value, Zone* zone) {
BitsetType::bitset bitset = BitsetType::Lub(*value);
return AsType(new (zone->New(sizeof(HeapConstantType)))
HeapConstantType(bitset, value));
......@@ -337,12 +337,12 @@ class HeapConstantType : public TypeBase {
return static_cast<HeapConstantType*>(FromType(type));
}
HeapConstantType(BitsetType::bitset bitset, i::Handle<i::Object> object);
HeapConstantType(BitsetType::bitset bitset, i::Handle<i::HeapObject> object);
BitsetType::bitset Lub() { return bitset_; }
BitsetType::bitset bitset_;
Handle<i::Object> object_;
Handle<i::HeapObject> object_;
};
// -----------------------------------------------------------------------------
......@@ -506,7 +506,7 @@ class Type {
static Type* OtherNumberConstant(double value, Zone* zone) {
return OtherNumberConstantType::New(value, zone);
}
static Type* HeapConstant(i::Handle<i::Object> value, Zone* zone) {
static Type* HeapConstant(i::Handle<i::HeapObject> value, Zone* zone) {
return HeapConstantType::New(value, zone);
}
static Type* Range(double min, double max, Zone* zone) {
......
......@@ -195,7 +195,7 @@ struct Tests {
Handle<i::Object> value = *vt;
Type* type = T.NewConstant(value);
if (type->IsHeapConstant()) {
CHECK(*value == *type->AsHeapConstant()->Value());
CHECK(value.address() == type->AsHeapConstant()->Value().address());
} else if (type->IsOtherNumberConstant()) {
CHECK(value->IsHeapNumber());
CHECK(value->Number() == type->AsOtherNumberConstant()->Value());
......
......@@ -147,7 +147,7 @@ class Types {
return Type::NewConstant(value, zone_);
}
Type* HeapConstant(Handle<i::Object> value) {
Type* HeapConstant(Handle<i::HeapObject> value) {
return Type::HeapConstant(value, zone_);
}
......
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