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

Side by Side Diff: vm/snapshot.cc

Issue 11648006: Create read only handles for empty_array and sentinel objects (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years 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 | « vm/parser.cc ('k') | vm/stub_code_ia32_test.cc » ('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/snapshot.h" 5 #include "vm/snapshot.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/bigint_operations.h" 8 #include "vm/bigint_operations.h"
9 #include "vm/bootstrap.h" 9 #include "vm/bootstrap.h"
10 #include "vm/exceptions.h" 10 #include "vm/exceptions.h"
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 } 649 }
650 650
651 651
652 RawObject* SnapshotReader::ReadVMIsolateObject(intptr_t header_value) { 652 RawObject* SnapshotReader::ReadVMIsolateObject(intptr_t header_value) {
653 intptr_t object_id = GetVMIsolateObjectId(header_value); 653 intptr_t object_id = GetVMIsolateObjectId(header_value);
654 if (object_id == kNullObject) { 654 if (object_id == kNullObject) {
655 // This is a singleton null object, return it. 655 // This is a singleton null object, return it.
656 return Object::null(); 656 return Object::null();
657 } 657 }
658 if (object_id == kSentinelObject) { 658 if (object_id == kSentinelObject) {
659 return Object::sentinel(); 659 return Object::sentinel().raw();
660 } 660 }
661 if (object_id == kEmptyArrayObject) { 661 if (object_id == kEmptyArrayObject) {
662 return Object::empty_array(); 662 return Object::empty_array().raw();
663 } 663 }
664 intptr_t class_id = ClassIdFromObjectId(object_id); 664 intptr_t class_id = ClassIdFromObjectId(object_id);
665 if (IsSingletonClassId(class_id)) { 665 if (IsSingletonClassId(class_id)) {
666 return isolate()->class_table()->At(class_id); // get singleton class. 666 return isolate()->class_table()->At(class_id); // get singleton class.
667 } else { 667 } else {
668 ASSERT(Symbols::IsVMSymbolId(object_id)); 668 ASSERT(Symbols::IsVMSymbolId(object_id));
669 return Symbols::GetVMSymbol(object_id); // return VM symbol. 669 return Symbols::GetVMSymbol(object_id); // return VM symbol.
670 } 670 }
671 UNREACHABLE(); 671 UNREACHABLE();
672 return Object::null(); 672 return Object::null();
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 794
795 795
796 void SnapshotWriter::HandleVMIsolateObject(RawObject* rawobj) { 796 void SnapshotWriter::HandleVMIsolateObject(RawObject* rawobj) {
797 // Check if it is a singleton null object. 797 // Check if it is a singleton null object.
798 if (rawobj == Object::null()) { 798 if (rawobj == Object::null()) {
799 WriteVMIsolateObject(kNullObject); 799 WriteVMIsolateObject(kNullObject);
800 return; 800 return;
801 } 801 }
802 802
803 // Check if it is a singleton sentinel object. 803 // Check if it is a singleton sentinel object.
804 if (rawobj == Object::sentinel()) { 804 if (rawobj == Object::sentinel().raw()) {
805 WriteVMIsolateObject(kSentinelObject); 805 WriteVMIsolateObject(kSentinelObject);
806 return; 806 return;
807 } 807 }
808 808
809 // Check if it is a singleton empty array object. 809 // Check if it is a singleton empty array object.
810 if (rawobj == Object::empty_array()) { 810 if (rawobj == Object::empty_array().raw()) {
811 WriteVMIsolateObject(kEmptyArrayObject); 811 WriteVMIsolateObject(kEmptyArrayObject);
812 return; 812 return;
813 } 813 }
814 814
815 // Check if it is a singleton class object which is shared by 815 // Check if it is a singleton class object which is shared by
816 // all isolates. 816 // all isolates.
817 intptr_t id = rawobj->GetClassId(); 817 intptr_t id = rawobj->GetClassId();
818 if (id == kClassCid) { 818 if (id == kClassCid) {
819 RawClass* raw_class = reinterpret_cast<RawClass*>(rawobj); 819 RawClass* raw_class = reinterpret_cast<RawClass*>(rawobj);
820 intptr_t class_id = raw_class->ptr()->id_; 820 intptr_t class_id = raw_class->ptr()->id_;
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 UnmarkAll(); 1315 UnmarkAll();
1316 isolate->set_long_jump_base(base); 1316 isolate->set_long_jump_base(base);
1317 } else { 1317 } else {
1318 isolate->set_long_jump_base(base); 1318 isolate->set_long_jump_base(base);
1319 ThrowException(exception_type(), exception_msg()); 1319 ThrowException(exception_type(), exception_msg());
1320 } 1320 }
1321 } 1321 }
1322 1322
1323 1323
1324 } // namespace dart 1324 } // namespace dart
OLDNEW
« no previous file with comments | « vm/parser.cc ('k') | vm/stub_code_ia32_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698