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

Unified Diff: runtime/vm/object.cc

Issue 16336021: Create specific null read only handles for the frequently used types (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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 | « runtime/vm/object.h ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 23557)
+++ runtime/vm/object.cc (working copy)
@@ -71,6 +71,10 @@
#endif
#define RAW_NULL kHeapObjectTag
Object* Object::null_object_ = NULL;
+Array* Object::null_array_ = NULL;
+String* Object::null_string_ = NULL;
+Instance* Object::null_instance_ = NULL;
+AbstractTypeArguments* Object::null_abstract_type_arguments_ = NULL;
Array* Object::empty_array_ = NULL;
Instance* Object::sentinel_ = NULL;
Instance* Object::transition_sentinel_ = NULL;
@@ -324,7 +328,11 @@
Heap* heap = isolate->heap();
// Allocate the read only object handles here.
- null_object_ = Array::ReadOnlyHandle();
+ null_object_ = Object::ReadOnlyHandle();
+ null_array_ = Array::ReadOnlyHandle();
+ null_string_ = String::ReadOnlyHandle();
+ null_instance_ = Instance::ReadOnlyHandle();
+ null_abstract_type_arguments_ = AbstractTypeArguments::ReadOnlyHandle();
empty_array_ = Array::ReadOnlyHandle();
sentinel_ = Instance::ReadOnlyHandle();
transition_sentinel_ = Instance::ReadOnlyHandle();
@@ -346,6 +354,10 @@
}
*null_object_ = null_;
+ *null_array_ ^= null_;
+ *null_string_ ^= null_;
+ *null_instance_ ^= null_;
+ *null_abstract_type_arguments_ ^= null_;
// Initialize the empty array handle to null_ in order to be able to check
// if the empty array was allocated (RAW_NULL is not available).
@@ -545,6 +557,14 @@
LanguageError::New(String::Handle(String::New("SnapshotWriter Error")));
ASSERT(!null_object_->IsSmi());
+ ASSERT(!null_array_->IsSmi());
+ ASSERT(null_array_->IsArray());
+ ASSERT(!null_string_->IsSmi());
+ ASSERT(null_string_->IsString());
+ ASSERT(!null_instance_->IsSmi());
+ ASSERT(null_instance_->IsInstance());
+ ASSERT(!null_abstract_type_arguments_->IsSmi());
+ ASSERT(null_abstract_type_arguments_->IsAbstractTypeArguments());
ASSERT(!empty_array_->IsSmi());
ASSERT(empty_array_->IsArray());
ASSERT(!sentinel_->IsSmi());
@@ -1064,7 +1084,7 @@
// Remove the Object superclass cycle by setting the super type to null (not
// to the type of null).
cls = object_store->object_class();
- cls.set_super_type(Type::null_object());
+ cls.set_super_type(AbstractType::Handle());
ClassFinalizer::VerifyBootstrapClasses();
MarkInvisibleFunctions();
@@ -1602,7 +1622,7 @@
}
num_type_args += cls.NumTypeParameters();
// Object is its own super class during bootstrap.
- if (cls.super_type() == Type::null() ||
+ if (cls.super_type() == AbstractType::null() ||
cls.super_type() == isolate->object_store()->object_type()) {
break;
}
@@ -1624,7 +1644,7 @@
RawClass* Class::SuperClass() const {
- if (super_type() == Type::null()) {
+ if (super_type() == AbstractType::null()) {
return Class::null();
}
const AbstractType& sup_type = AbstractType::Handle(super_type());
@@ -4880,7 +4900,7 @@
result.set_name(name);
result.set_is_static(is_static);
if (is_static) {
- result.set_value(Instance::null_object());
+ result.set_value(Object::null_instance());
} else {
result.SetOffset(0);
}
@@ -4891,7 +4911,7 @@
result.set_has_initializer(false);
result.set_guarded_cid(kIllegalCid);
result.set_is_nullable(false);
- result.set_dependent_code(Array::null_object());
+ result.set_dependent_code(Object::null_array());
return result.raw();
}
@@ -4904,7 +4924,7 @@
const PatchClass& clone_owner =
PatchClass::Handle(PatchClass::New(new_owner, owner));
clone.set_owner(clone_owner);
- clone.set_dependent_code(Array::null_object());
+ clone.set_dependent_code(Object::null_array());
if (!clone.is_static()) {
clone.SetOffset(0);
}
@@ -4998,7 +5018,7 @@
if (code_objects.IsNull()) {
return;
}
- set_dependent_code(Array::null_object());
+ set_dependent_code(Object::null_array());
// Deoptimize all dependent code on the stack.
Code& code = Code::Handle();
@@ -5643,7 +5663,7 @@
const Array& symbols = Array::Handle(isolate,
object_store->keyword_symbols());
ASSERT(!symbols.IsNull());
- ASSERT(symbols.At(kind - Token::kFirstKeyword) != String::null());
+ ASSERT(symbols.At(kind - Token::kFirstKeyword) != Object::null());
return String::RawCast(symbols.At(kind - Token::kFirstKeyword));
}
return Symbols::New(Token::Str(kind));
@@ -6528,7 +6548,7 @@
const Library& core_lib = Library::Handle(Library::CoreLibrary());
ASSERT(!core_lib.IsNull());
const Namespace& ns = Namespace::Handle(
- Namespace::New(core_lib, Array::null_object(), Array::null_object()));
+ Namespace::New(core_lib, Object::null_array(), Object::null_array()));
result.AddImport(ns);
}
return result.raw();
@@ -6546,7 +6566,7 @@
Library::Handle(Library::NewLibraryHelper(core_lib_url, false));
core_lib.Register();
isolate->object_store()->set_bootstrap_library(ObjectStore::kCore, core_lib);
- isolate->object_store()->set_root_library(Library::null_object());
+ isolate->object_store()->set_root_library(Library::Handle());
// Hook up predefined classes without setting their library pointers. These
// classes are coming from the VM isolate, and are shared between multiple
@@ -12570,7 +12590,7 @@
intptr_t index = Length() - 1;
const Array& contents = Array::Handle(data());
const Object& obj = Object::Handle(contents.At(index));
- contents.SetAt(index, null_object());
+ contents.SetAt(index, Object::null_object());
SetLength(index);
return obj.raw();
}
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698