Provide Type::Contains methods.
Also, rename all *Currently methods to Now*. R=bmeurer@chromium.org BUG= Review URL: https://codereview.chromium.org/219523003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20405 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
9e54d6175a
commit
5d5adbc452
@ -634,7 +634,7 @@ bool IC::UpdatePolymorphicIC(Handle<HeapType> type,
|
||||
if (current_type->IsClass() && current_type->AsClass()->is_deprecated()) {
|
||||
// Filter out deprecated maps to ensure their instances get migrated.
|
||||
++deprecated_types;
|
||||
} else if (type->IsCurrently(current_type)) {
|
||||
} else if (type->NowIs(current_type)) {
|
||||
// If the receiver type is already in the polymorphic IC, this indicates
|
||||
// there was a prototoype chain failure. In that case, just overwrite the
|
||||
// handler.
|
||||
@ -658,7 +658,7 @@ bool IC::UpdatePolymorphicIC(Handle<HeapType> type,
|
||||
number_of_valid_types++;
|
||||
if (handler_to_overwrite >= 0) {
|
||||
handlers.Set(handler_to_overwrite, code);
|
||||
if (!type->IsCurrently(types.at(handler_to_overwrite))) {
|
||||
if (!type->NowIs(types.at(handler_to_overwrite))) {
|
||||
types.Set(handler_to_overwrite, type);
|
||||
}
|
||||
} else {
|
||||
@ -676,7 +676,7 @@ bool IC::UpdatePolymorphicIC(Handle<HeapType> type,
|
||||
Handle<HeapType> IC::CurrentTypeOf(Handle<Object> object, Isolate* isolate) {
|
||||
return object->IsJSGlobalObject()
|
||||
? HeapType::Constant(Handle<JSGlobalObject>::cast(object), isolate)
|
||||
: HeapType::OfCurrently(object, isolate);
|
||||
: HeapType::NowOf(object, isolate);
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,9 +5,10 @@
|
||||
#ifndef V8_TYPES_INL_H_
|
||||
#define V8_TYPES_INL_H_
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include "factory.h"
|
||||
#include "handles-inl.h"
|
||||
#include "types.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -233,6 +234,7 @@ int ZoneTypeConfig::lub_bitset(Type* type) {
|
||||
return static_cast<int>(tagged_get<intptr_t>(as_tagged(type), 0));
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
// static
|
||||
i::Handle<HeapTypeConfig::Type> HeapTypeConfig::handle(Type* type) {
|
||||
|
21
src/types.cc
21
src/types.cc
@ -248,7 +248,7 @@ int TypeImpl<Config>::GlbBitset() {
|
||||
|
||||
// Most precise _current_ type of a value (usually its class).
|
||||
template<class Config>
|
||||
typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::OfCurrently(
|
||||
typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::NowOf(
|
||||
i::Handle<i::Object> value, Region* region) {
|
||||
if (value->IsSmi() ||
|
||||
i::HeapObject::cast(*value)->map()->instance_type() == HEAP_NUMBER_TYPE ||
|
||||
@ -303,7 +303,7 @@ bool TypeImpl<Config>::SlowIs(TypeImpl* that) {
|
||||
|
||||
|
||||
template<class Config>
|
||||
bool TypeImpl<Config>::IsCurrently(TypeImpl* that) {
|
||||
bool TypeImpl<Config>::NowIs(TypeImpl* that) {
|
||||
return this->Is(that) ||
|
||||
(this->IsConstant() && that->IsClass() &&
|
||||
this->AsConstant()->IsHeapObject() &&
|
||||
@ -354,6 +354,23 @@ bool TypeImpl<Config>::Maybe(TypeImpl* that) {
|
||||
}
|
||||
|
||||
|
||||
template<class Config>
|
||||
bool TypeImpl<Config>::Contains(i::Object* value) {
|
||||
if (this->IsConstant()) {
|
||||
return *this->AsConstant() == value;
|
||||
}
|
||||
return Config::from_bitset(LubBitset(value))->Is(this);
|
||||
}
|
||||
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
template<class Config>
|
||||
bool TypeImpl<Config>::InUnion(UnionedHandle unioned, int current_size) {
|
||||
ASSERT(!this->IsUnion());
|
||||
|
22
src/types.h
22
src/types.h
@ -220,16 +220,23 @@ class TypeImpl : public Config::Base {
|
||||
bool Is(TypeImpl* that) { return this == that || this->SlowIs(that); }
|
||||
template<class TypeHandle>
|
||||
bool Is(TypeHandle that) { return this->Is(*that); }
|
||||
|
||||
bool Maybe(TypeImpl* that);
|
||||
template<class TypeHandle>
|
||||
bool Maybe(TypeHandle that) { return this->Maybe(*that); }
|
||||
|
||||
// Equivalent to Constant(value)->Is(this), but avoiding allocation.
|
||||
bool Contains(i::Object* val);
|
||||
bool Contains(i::Handle<i::Object> val) { return this->Contains(*val); }
|
||||
|
||||
// State-dependent versions of Of and Is that consider subtyping between
|
||||
// a constant and its map class.
|
||||
static TypeHandle OfCurrently(i::Handle<i::Object> value, Region* region);
|
||||
bool IsCurrently(TypeImpl* that);
|
||||
static TypeHandle NowOf(i::Handle<i::Object> value, Region* region);
|
||||
bool NowIs(TypeImpl* that);
|
||||
template<class TypeHandle>
|
||||
bool IsCurrently(TypeHandle that) { return this->IsCurrently(*that); }
|
||||
bool NowIs(TypeHandle that) { return this->NowIs(*that); }
|
||||
bool NowContains(i::Object* val);
|
||||
bool NowContains(i::Handle<i::Object> val) { return this->NowContains(*val); }
|
||||
|
||||
bool IsClass() { return Config::is_class(this); }
|
||||
bool IsConstant() { return Config::is_constant(this); }
|
||||
@ -359,10 +366,8 @@ struct ZoneTypeConfig {
|
||||
static inline Tagged* tagged_create(Tag tag, int size, Zone* zone);
|
||||
static inline void tagged_shrink(Tagged* tagged, int size);
|
||||
static inline Tag tagged_tag(Tagged* tagged);
|
||||
template<class T>
|
||||
static inline T tagged_get(Tagged* tagged, int i);
|
||||
template<class T>
|
||||
static inline void tagged_set(Tagged* tagged, int i, T value);
|
||||
template<class T> static inline T tagged_get(Tagged* tagged, int i);
|
||||
template<class T> static inline void tagged_set(Tagged* tagged, int i, T val);
|
||||
static inline int tagged_length(Tagged* tagged);
|
||||
|
||||
public:
|
||||
@ -402,6 +407,8 @@ struct ZoneTypeConfig {
|
||||
static inline int lub_bitset(Type* type);
|
||||
};
|
||||
|
||||
typedef TypeImpl<ZoneTypeConfig> Type;
|
||||
|
||||
|
||||
// Heap-allocated types are either smis for bitsets, maps for classes, boxes for
|
||||
// constants, or fixed arrays for unions.
|
||||
@ -437,7 +444,6 @@ struct HeapTypeConfig {
|
||||
static inline int lub_bitset(Type* type);
|
||||
};
|
||||
|
||||
typedef TypeImpl<ZoneTypeConfig> Type;
|
||||
typedef TypeImpl<HeapTypeConfig> HeapType;
|
||||
|
||||
|
||||
|
@ -83,7 +83,7 @@ void AstTyper::Run(CompilationInfo* info) {
|
||||
|
||||
|
||||
Effect AstTyper::ObservedOnStack(Object* value) {
|
||||
Type* lower = Type::OfCurrently(handle(value, isolate()), zone());
|
||||
Type* lower = Type::NowOf(handle(value, isolate()), zone());
|
||||
return Effect(Bounds(lower, Type::Any(zone())));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user