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

Side by Side Diff: runtime/vm/object.cc

Issue 257413002: - Remove some unnecessary classes from the object store. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/object_store.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 RegisterPrivateClass(cls, Symbols::_SendPortImpl(), isolate_lib); 1011 RegisterPrivateClass(cls, Symbols::_SendPortImpl(), isolate_lib);
1012 pending_classes.Add(cls); 1012 pending_classes.Add(cls);
1013 1013
1014 cls = Class::New<Stacktrace>(); 1014 cls = Class::New<Stacktrace>();
1015 object_store->set_stacktrace_class(cls); 1015 object_store->set_stacktrace_class(cls);
1016 RegisterClass(cls, Symbols::StackTrace(), core_lib); 1016 RegisterClass(cls, Symbols::StackTrace(), core_lib);
1017 pending_classes.Add(cls); 1017 pending_classes.Add(cls);
1018 // Super type set below, after Object is allocated. 1018 // Super type set below, after Object is allocated.
1019 1019
1020 cls = Class::New<JSRegExp>(); 1020 cls = Class::New<JSRegExp>();
1021 object_store->set_jsregexp_class(cls);
1022 RegisterPrivateClass(cls, Symbols::JSSyntaxRegExp(), core_lib); 1021 RegisterPrivateClass(cls, Symbols::JSSyntaxRegExp(), core_lib);
1023 pending_classes.Add(cls); 1022 pending_classes.Add(cls);
1024 1023
1025 // Initialize the base interfaces used by the core VM classes. 1024 // Initialize the base interfaces used by the core VM classes.
1026 1025
1027 // Allocate and initialize the pre-allocated classes in the core library. 1026 // Allocate and initialize the pre-allocated classes in the core library.
1028 // The script and token index of these pre-allocated classes is set up in 1027 // The script and token index of these pre-allocated classes is set up in
1029 // the parser when the corelib script is compiled (see 1028 // the parser when the corelib script is compiled (see
1030 // Parser::ParseClassDefinition). 1029 // Parser::ParseClassDefinition).
1031 cls = Class::New<Instance>(kInstanceCid); 1030 cls = Class::New<Instance>(kInstanceCid);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 if (lib.IsNull()) { 1121 if (lib.IsNull()) {
1123 lib = Library::NewLibraryHelper(Symbols::DartMirrors(), true); 1122 lib = Library::NewLibraryHelper(Symbols::DartMirrors(), true);
1124 lib.Register(); 1123 lib.Register();
1125 isolate->object_store()->set_bootstrap_library(ObjectStore::kMirrors, 1124 isolate->object_store()->set_bootstrap_library(ObjectStore::kMirrors,
1126 lib); 1125 lib);
1127 } 1126 }
1128 ASSERT(!lib.IsNull()); 1127 ASSERT(!lib.IsNull());
1129 ASSERT(lib.raw() == Library::MirrorsLibrary()); 1128 ASSERT(lib.raw() == Library::MirrorsLibrary());
1130 1129
1131 cls = Class::New<MirrorReference>(); 1130 cls = Class::New<MirrorReference>();
1132 object_store->set_mirror_reference_class(cls);
1133 RegisterPrivateClass(cls, Symbols::_MirrorReference(), lib); 1131 RegisterPrivateClass(cls, Symbols::_MirrorReference(), lib);
1134 1132
1135 // Pre-register the profiler library so we can place the vm class 1133 // Pre-register the profiler library so we can place the vm class
1136 // UserTag there rather than the core library. 1134 // UserTag there rather than the core library.
1137 lib = Library::LookupLibrary(Symbols::DartProfiler()); 1135 lib = Library::LookupLibrary(Symbols::DartProfiler());
1138 if (lib.IsNull()) { 1136 if (lib.IsNull()) {
1139 lib = Library::NewLibraryHelper(Symbols::DartProfiler(), true); 1137 lib = Library::NewLibraryHelper(Symbols::DartProfiler(), true);
1140 lib.Register(); 1138 lib.Register();
1141 isolate->object_store()->set_bootstrap_library(ObjectStore::kProfiler, 1139 isolate->object_store()->set_bootstrap_library(ObjectStore::kProfiler,
1142 lib); 1140 lib);
1143 } 1141 }
1144 ASSERT(!lib.IsNull()); 1142 ASSERT(!lib.IsNull());
1145 ASSERT(lib.raw() == Library::ProfilerLibrary()); 1143 ASSERT(lib.raw() == Library::ProfilerLibrary());
1146 1144
1147 lib = Library::LookupLibrary(Symbols::DartProfiler()); 1145 lib = Library::LookupLibrary(Symbols::DartProfiler());
1148 ASSERT(!lib.IsNull()); 1146 ASSERT(!lib.IsNull());
1149 cls = Class::New<UserTag>(); 1147 cls = Class::New<UserTag>();
1150 object_store->set_user_tag_class(cls);
1151 RegisterPrivateClass(cls, Symbols::_UserTag(), lib); 1148 RegisterPrivateClass(cls, Symbols::_UserTag(), lib);
1152 pending_classes.Add(cls); 1149 pending_classes.Add(cls);
1153 1150
1154 // Setup some default native field classes which can be extended for 1151 // Setup some default native field classes which can be extended for
1155 // specifying native fields in dart classes. 1152 // specifying native fields in dart classes.
1156 Library::InitNativeWrappersLibrary(isolate); 1153 Library::InitNativeWrappersLibrary(isolate);
1157 ASSERT(isolate->object_store()->native_wrappers_library() != Library::null()); 1154 ASSERT(isolate->object_store()->native_wrappers_library() != Library::null());
1158 1155
1159 // Pre-register the typed_data library so the native class implementations 1156 // Pre-register the typed_data library so the native class implementations
1160 // can be hooked up before compiling it. 1157 // can be hooked up before compiling it.
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
1434 object_store->set_null_class(cls); 1431 object_store->set_null_class(cls);
1435 1432
1436 cls = Class::New<Capability>(); 1433 cls = Class::New<Capability>();
1437 cls = Class::New<ReceivePort>(); 1434 cls = Class::New<ReceivePort>();
1438 cls = Class::New<SendPort>(); 1435 cls = Class::New<SendPort>();
1439 1436
1440 cls = Class::New<Stacktrace>(); 1437 cls = Class::New<Stacktrace>();
1441 object_store->set_stacktrace_class(cls); 1438 object_store->set_stacktrace_class(cls);
1442 1439
1443 cls = Class::New<JSRegExp>(); 1440 cls = Class::New<JSRegExp>();
1444 object_store->set_jsregexp_class(cls);
1445 1441
1446 // Some classes are not stored in the object store. Yet we still need to 1442 // Some classes are not stored in the object store. Yet we still need to
1447 // create their Class object so that they get put into the class_table 1443 // create their Class object so that they get put into the class_table
1448 // (as a side effect of Class::New()). 1444 // (as a side effect of Class::New()).
1449 cls = Class::New<Number>(); 1445 cls = Class::New<Number>();
1450 1446
1451 cls = Class::New<WeakProperty>(); 1447 cls = Class::New<WeakProperty>();
1452 object_store->set_weak_property_class(cls); 1448 object_store->set_weak_property_class(cls);
1453 1449
1454 cls = Class::New<MirrorReference>(); 1450 cls = Class::New<MirrorReference>();
1455 object_store->set_mirror_reference_class(cls);
1456 1451
1457 cls = Class::New<UserTag>(); 1452 cls = Class::New<UserTag>();
1458 object_store->set_user_tag_class(cls);
1459 } 1453 }
1460 1454
1461 1455
1462 void Object::Print() const { 1456 void Object::Print() const {
1463 OS::Print("%s\n", ToCString()); 1457 OS::Print("%s\n", ToCString());
1464 } 1458 }
1465 1459
1466 1460
1467 RawString* Object::DictionaryName() const { 1461 RawString* Object::DictionaryName() const {
1468 return String::null(); 1462 return String::null();
(...skipping 16762 matching lines...) Expand 10 before | Expand all | Expand 10 after
18231 StorePointer(&raw_ptr()->pattern_, pattern.raw()); 18225 StorePointer(&raw_ptr()->pattern_, pattern.raw());
18232 } 18226 }
18233 18227
18234 18228
18235 void JSRegExp::set_num_bracket_expressions(intptr_t value) const { 18229 void JSRegExp::set_num_bracket_expressions(intptr_t value) const {
18236 raw_ptr()->num_bracket_expressions_ = Smi::New(value); 18230 raw_ptr()->num_bracket_expressions_ = Smi::New(value);
18237 } 18231 }
18238 18232
18239 18233
18240 RawJSRegExp* JSRegExp::New(intptr_t len, Heap::Space space) { 18234 RawJSRegExp* JSRegExp::New(intptr_t len, Heap::Space space) {
18241 ASSERT(Isolate::Current()->object_store()->jsregexp_class() !=
18242 Class::null());
18243 if (len < 0 || len > kMaxElements) { 18235 if (len < 0 || len > kMaxElements) {
18244 // This should be caught before we reach here. 18236 // This should be caught before we reach here.
18245 FATAL1("Fatal error in JSRegexp::New: invalid len %" Pd "\n", len); 18237 FATAL1("Fatal error in JSRegexp::New: invalid len %" Pd "\n", len);
18246 } 18238 }
18247 JSRegExp& result = JSRegExp::Handle(); 18239 JSRegExp& result = JSRegExp::Handle();
18248 { 18240 {
18249 RawObject* raw = Object::Allocate(JSRegExp::kClassId, 18241 RawObject* raw = Object::Allocate(JSRegExp::kClassId,
18250 JSRegExp::InstanceSize(len), 18242 JSRegExp::InstanceSize(len),
18251 space); 18243 space);
18252 NoGCScope no_gc; 18244 NoGCScope no_gc;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
18380 18372
18381 18373
18382 RawTypeParameter* MirrorReference::GetTypeParameterReferent() const { 18374 RawTypeParameter* MirrorReference::GetTypeParameterReferent() const {
18383 ASSERT(Object::Handle(referent()).IsTypeParameter()); 18375 ASSERT(Object::Handle(referent()).IsTypeParameter());
18384 return TypeParameter::Cast(Object::Handle(referent())).raw(); 18376 return TypeParameter::Cast(Object::Handle(referent())).raw();
18385 } 18377 }
18386 18378
18387 18379
18388 RawMirrorReference* MirrorReference::New(const Object& referent, 18380 RawMirrorReference* MirrorReference::New(const Object& referent,
18389 Heap::Space space) { 18381 Heap::Space space) {
18390 ASSERT(Isolate::Current()->object_store()->mirror_reference_class()
18391 != Class::null());
18392 MirrorReference& result = MirrorReference::Handle(); 18382 MirrorReference& result = MirrorReference::Handle();
18393 { 18383 {
18394 RawObject* raw = Object::Allocate(MirrorReference::kClassId, 18384 RawObject* raw = Object::Allocate(MirrorReference::kClassId,
18395 MirrorReference::InstanceSize(), 18385 MirrorReference::InstanceSize(),
18396 space); 18386 space);
18397 NoGCScope no_gc; 18387 NoGCScope no_gc;
18398 result ^= raw; 18388 result ^= raw;
18399 } 18389 }
18400 result.set_referent(referent); 18390 result.set_referent(referent);
18401 return result.raw(); 18391 return result.raw();
(...skipping 19 matching lines...) Expand all
18421 18411
18422 void UserTag::ClearActive() { 18412 void UserTag::ClearActive() {
18423 Isolate* isolate = Isolate::Current(); 18413 Isolate* isolate = Isolate::Current();
18424 ASSERT(isolate != NULL); 18414 ASSERT(isolate != NULL);
18425 isolate->clear_current_tag(); 18415 isolate->clear_current_tag();
18426 } 18416 }
18427 18417
18428 18418
18429 RawUserTag* UserTag::New(const String& label, Heap::Space space) { 18419 RawUserTag* UserTag::New(const String& label, Heap::Space space) {
18430 Isolate* isolate = Isolate::Current(); 18420 Isolate* isolate = Isolate::Current();
18431 ASSERT(isolate->object_store()->user_tag_class() != Class::null());
18432 ASSERT(isolate->tag_table() != GrowableObjectArray::null()); 18421 ASSERT(isolate->tag_table() != GrowableObjectArray::null());
18433 // Canonicalize by name. 18422 // Canonicalize by name.
18434 UserTag& result = UserTag::Handle(FindTagInIsolate(isolate, label)); 18423 UserTag& result = UserTag::Handle(FindTagInIsolate(isolate, label));
18435 if (!result.IsNull()) { 18424 if (!result.IsNull()) {
18436 // Tag already exists, return existing instance. 18425 // Tag already exists, return existing instance.
18437 return result.raw(); 18426 return result.raw();
18438 } 18427 }
18439 if (TagTableIsFull(isolate)) { 18428 if (TagTableIsFull(isolate)) {
18440 const String& error = String::Handle( 18429 const String& error = String::Handle(
18441 String::NewFormatted("UserTag instance limit (%" Pd ") reached.", 18430 String::NewFormatted("UserTag instance limit (%" Pd ") reached.",
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
18531 return tag_label.ToCString(); 18520 return tag_label.ToCString();
18532 } 18521 }
18533 18522
18534 18523
18535 void UserTag::PrintToJSONStream(JSONStream* stream, bool ref) const { 18524 void UserTag::PrintToJSONStream(JSONStream* stream, bool ref) const {
18536 Instance::PrintToJSONStream(stream, ref); 18525 Instance::PrintToJSONStream(stream, ref);
18537 } 18526 }
18538 18527
18539 18528
18540 } // namespace dart 18529 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698