Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1217)

Unified Diff: src/types.cc

Issue 230673002: Fix symmetry of Maybe() predicate. Fix bug in NowContains() predicate. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/cctest/cctest.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/types.cc
diff --git a/src/types.cc b/src/types.cc
index f6a430bbc962934128d089fb1af6baa2d1a51ab6..5a885826cf27fac0a90c85706d9e3af137504124 100644
--- a/src/types.cc
+++ b/src/types.cc
@@ -306,28 +306,23 @@ bool TypeImpl<Config>::SlowIs(TypeImpl* that) {
template<class Config>
bool TypeImpl<Config>::NowIs(TypeImpl* that) {
- if (this->Is(that)) return true;
- if (this->IsConstant() && this->AsConstant()->IsHeapObject()) {
- i::Handle<i::Map> map(i::HeapObject::cast(*this->AsConstant())->map());
- for (Iterator<i::Map> it = that->Classes(); !it.Done(); it.Advance()) {
- if (*it.Current() == *map) return true;
+ if (this->IsConstant()) {
+ DisallowHeapAllocation no_allocation;
+ i::Object* object = *this->AsConstant();
+ if (object->IsHeapObject()) {
+ i::Map* map = i::HeapObject::cast(object)->map();
+ for (Iterator<i::Map> it = that->Classes(); !it.Done(); it.Advance()) {
+ if (*it.Current() == map) return true;
+ }
}
}
- return false;
+ return this->Is(that);
}
// Check this overlaps that.
template<class Config>
bool TypeImpl<Config>::Maybe(TypeImpl* that) {
- // Fast path for bitsets.
- if (this->IsBitset()) {
- return IsInhabited(this->AsBitset() & that->LubBitset());
- }
- if (that->IsBitset()) {
- return IsInhabited(this->LubBitset() & that->AsBitset());
- }
-
// (T1 \/ ... \/ Tn) overlaps T <=> (T1 overlaps T) \/ ... \/ (Tn overlaps T)
if (this->IsUnion()) {
StructHandle unioned = this->AsUnion();
@@ -349,6 +344,13 @@ bool TypeImpl<Config>::Maybe(TypeImpl* that) {
}
ASSERT(!this->IsUnion() && !that->IsUnion());
+ if (this->IsBitset()) {
+ return IsInhabited(this->AsBitset() & that->LubBitset());
+ }
+ if (that->IsBitset()) {
+ return IsInhabited(this->LubBitset() & that->AsBitset());
+ }
+
if (this->IsClass()) {
return that->IsClass() && *this->AsClass() == *that->AsClass();
}
@@ -371,9 +373,14 @@ bool TypeImpl<Config>::Contains(i::Object* value) {
template<class Config>
bool TypeImpl<Config>::NowContains(i::Object* value) {
- return this->Contains(value) ||
- (this->IsClass() && value->IsHeapObject() &&
- *this->AsClass() == i::HeapObject::cast(value)->map());
+ if (value->IsHeapObject()) {
+ DisallowHeapAllocation no_allocation;
+ i::Map* map = i::HeapObject::cast(value)->map();
+ for (Iterator<i::Map> it = this->Classes(); !it.Done(); it.Advance()) {
+ if (*it.Current() == map) return true;
+ }
+ }
+ return this->Contains(value);
}
« no previous file with comments | « no previous file | test/cctest/cctest.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698