mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 21:20:36 +00:00
Avoid accessing the object store when checking for var class or void class.
Review URL: https://chromereviews.googleplex.com/3562016 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@249 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
05b0b0ba29
commit
820653338a
|
@ -48,6 +48,8 @@ RawInstance* Object::transition_sentinel_ =
|
|||
reinterpret_cast<RawInstance*>(RAW_NULL);
|
||||
RawClass* Object::class_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
|
||||
RawClass* Object::null_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
|
||||
RawClass* Object::var_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
|
||||
RawClass* Object::void_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
|
||||
RawClass* Object::type_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
|
||||
RawClass* Object::parameterized_type_class_ =
|
||||
reinterpret_cast<RawClass*>(RAW_NULL);
|
||||
|
@ -79,6 +81,10 @@ int Object::GetSingletonClassIndex(const RawClass* raw_class) {
|
|||
return kClassClass;
|
||||
} else if (raw_class == null_class()) {
|
||||
return kNullClass;
|
||||
} else if (raw_class == var_class()) {
|
||||
return kVarClass;
|
||||
} else if (raw_class == void_class()) {
|
||||
return kVoidClass;
|
||||
} else if (raw_class == type_class()) {
|
||||
return kTypeClass;
|
||||
} else if (raw_class == parameterized_type_class()) {
|
||||
|
@ -126,6 +132,8 @@ RawClass* Object::GetSingletonClass(int index) {
|
|||
switch (index) {
|
||||
case kClassClass: return class_class();
|
||||
case kNullClass: return null_class();
|
||||
case kVarClass: return var_class();
|
||||
case kVoidClass: return void_class();
|
||||
case kTypeClass: return type_class();
|
||||
case kParameterizedTypeClass: return parameterized_type_class();
|
||||
case kTypeParameterClass: return type_parameter_class();
|
||||
|
@ -157,6 +165,8 @@ const char* Object::GetSingletonClassName(int index) {
|
|||
switch (index) {
|
||||
case kClassClass: return "Class";
|
||||
case kNullClass: return "Null";
|
||||
case kVarClass: return "var";
|
||||
case kVoidClass: return "void";
|
||||
case kTypeClass: return "Type";
|
||||
case kParameterizedTypeClass: return "ParameterizedType";
|
||||
case kTypeParameterClass: return "TypeParameter";
|
||||
|
@ -243,8 +253,11 @@ void Object::InitOnce() {
|
|||
}
|
||||
|
||||
// Allocate the remaining VM internal classes.
|
||||
cls = Class::New<Type>();
|
||||
type_class_ = cls.raw();
|
||||
cls = Class::New<Instance>();
|
||||
var_class_ = cls.raw();
|
||||
|
||||
cls = Class::New<Instance>();
|
||||
void_class_ = cls.raw();
|
||||
|
||||
cls = Class::New<ParameterizedType>();
|
||||
parameterized_type_class_ = cls.raw();
|
||||
|
@ -537,24 +550,18 @@ void Object::Init(Isolate* isolate) {
|
|||
cls = Class::NewInterface(name, script);
|
||||
core_impl_lib.AddClass(cls);
|
||||
|
||||
// The 'null' class is not registered in the class dictionary and is not
|
||||
// named, but a corresponding type is stored in the object store.
|
||||
// The classes 'null', 'var', and 'void' are not registered in the class
|
||||
// dictionary and are not named, but corresponding types are stored in the
|
||||
// object store.
|
||||
cls = null_class_;
|
||||
type = Type::NewNonParameterizedType(cls);
|
||||
object_store->set_null_type(type);
|
||||
|
||||
// The 'var' and 'void' classes are not registered in the class dictionary,
|
||||
// but they are named and their corresponding types are stored in the object
|
||||
// store.
|
||||
name = String::NewSymbol("var");
|
||||
cls = Class::New<Instance>();
|
||||
cls.set_name(name);
|
||||
cls = var_class_;
|
||||
type = Type::NewNonParameterizedType(cls);
|
||||
object_store->set_var_type(type);
|
||||
|
||||
name = String::NewSymbol("void");
|
||||
cls = Class::New<Instance>();
|
||||
cls.set_name(name);
|
||||
cls = void_class_;
|
||||
type = Type::NewNonParameterizedType(cls);
|
||||
object_store->set_void_type(type);
|
||||
|
||||
|
@ -1140,11 +1147,6 @@ void Class::set_allocation_stub(const Code& value) const {
|
|||
}
|
||||
|
||||
|
||||
bool Class::IsVarClass() const {
|
||||
return raw() == Type::Handle(Type::VarType()).type_class();
|
||||
}
|
||||
|
||||
|
||||
bool Class::IsObjectClass() const {
|
||||
return raw() == Type::Handle(Type::ObjectType()).type_class();
|
||||
}
|
||||
|
@ -1603,21 +1605,6 @@ RawString* Type::ClassName() const {
|
|||
}
|
||||
|
||||
|
||||
bool Type::IsNullType() const {
|
||||
return raw() == Isolate::Current()->object_store()->null_type();
|
||||
}
|
||||
|
||||
|
||||
bool Type::IsVarType() const {
|
||||
return raw() == Isolate::Current()->object_store()->var_type();
|
||||
}
|
||||
|
||||
|
||||
bool Type::IsVoidType() const {
|
||||
return raw() == Isolate::Current()->object_store()->void_type();
|
||||
}
|
||||
|
||||
|
||||
bool Type::IsMoreSpecificThan(const Type& other) const {
|
||||
ASSERT(IsFinalized());
|
||||
ASSERT(other.IsFinalized());
|
||||
|
|
|
@ -117,6 +117,8 @@ class Object {
|
|||
kSentinelObject,
|
||||
kClassClass,
|
||||
kNullClass,
|
||||
kVarClass,
|
||||
kVoidClass,
|
||||
kTypeClass,
|
||||
kParameterizedTypeClass,
|
||||
kTypeParameterClass,
|
||||
|
@ -206,6 +208,8 @@ CLASS_LIST_NO_OBJECT(DEFINE_CLASS_TESTER);
|
|||
|
||||
static RawClass* class_class() { return class_class_; }
|
||||
static RawClass* null_class() { return null_class_; }
|
||||
static RawClass* var_class() { return var_class_; }
|
||||
static RawClass* void_class() { return void_class_; }
|
||||
static RawClass* type_class() { return type_class_; }
|
||||
static RawClass* parameterized_type_class() {
|
||||
return parameterized_type_class_;
|
||||
|
@ -307,9 +311,9 @@ CLASS_LIST_NO_OBJECT(DEFINE_CLASS_TESTER);
|
|||
static RawInstance* transition_sentinel_;
|
||||
|
||||
static RawClass* class_class_; // Class of the Class vm object.
|
||||
static RawClass* var_class_; // Represents the 'var' type.
|
||||
static RawClass* void_class_; // Represents the 'void' type.
|
||||
static RawClass* null_class_; // Class of the null object.
|
||||
static RawClass* var_class_; // Class of the 'var' type.
|
||||
static RawClass* void_class_; // Class of the 'void' type.
|
||||
static RawClass* type_class_; // Class of the Type vm object.
|
||||
static RawClass* parameterized_type_class_; // Class of ParameterizedType.
|
||||
static RawClass* type_parameter_class_; // Class of TypeParameter vm object.
|
||||
|
@ -456,7 +460,10 @@ class Class : public Object {
|
|||
bool IsNullClass() const { return raw() == Object::null_class(); }
|
||||
|
||||
// Check if this class represents the 'var' class.
|
||||
bool IsVarClass() const;
|
||||
bool IsVarClass() const { return raw() == Object::var_class(); }
|
||||
|
||||
// Check if this class represents the 'void' class.
|
||||
bool IsVoidClass() const { return raw() == Object::void_class(); }
|
||||
|
||||
// Check if this class represents the 'Object' class.
|
||||
bool IsObjectClass() const;
|
||||
|
@ -646,13 +653,19 @@ class Type : public Object {
|
|||
RawString* ClassName() const;
|
||||
|
||||
// Check if this type represents the 'null' type.
|
||||
bool IsNullType() const;
|
||||
bool IsNullType() const {
|
||||
return HasResolvedTypeClass() && (type_class() == Object::null_class());
|
||||
}
|
||||
|
||||
// Check if this type represents the 'var' type.
|
||||
bool IsVarType() const;
|
||||
bool IsVarType() const {
|
||||
return HasResolvedTypeClass() && (type_class() == Object::var_class());
|
||||
}
|
||||
|
||||
// Check if this type represents the 'void' type.
|
||||
bool IsVoidType() const;
|
||||
bool IsVoidType() const {
|
||||
return HasResolvedTypeClass() && (type_class() == Object::void_class());
|
||||
}
|
||||
|
||||
// Check if this type represents a function type.
|
||||
bool IsFunctionType() const {
|
||||
|
|
Loading…
Reference in a new issue