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

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

Issue 22902002: Ensure the classes void and dynamic have empty arrays for fields, functions, etc. Move their Types … (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: remove redudant mirror asserts, fix test Created 7 years, 4 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 | « runtime/vm/object_test.cc ('k') | tests/language/dynamic_test.dart » ('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/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 ASSERT((class_id > kIllegalCid) && (class_id < kNumPredefinedCids)); 58 ASSERT((class_id > kIllegalCid) && (class_id < kNumPredefinedCids));
59 ASSERT(!RawObject::IsTypedDataViewClassId(class_id)); 59 ASSERT(!RawObject::IsTypedDataViewClassId(class_id));
60 return (class_id + kClassIdsOffset); 60 return (class_id + kClassIdsOffset);
61 } 61 }
62 62
63 63
64 static RawType* GetType(ObjectStore* object_store, int index) { 64 static RawType* GetType(ObjectStore* object_store, int index) {
65 switch (index) { 65 switch (index) {
66 case kObjectType: return object_store->object_type(); 66 case kObjectType: return object_store->object_type();
67 case kNullType: return object_store->null_type(); 67 case kNullType: return object_store->null_type();
68 case kDynamicType: return object_store->dynamic_type();
69 case kVoidType: return object_store->void_type();
70 case kFunctionType: return object_store->function_type(); 68 case kFunctionType: return object_store->function_type();
71 case kNumberType: return object_store->number_type(); 69 case kNumberType: return object_store->number_type();
72 case kSmiType: return object_store->smi_type(); 70 case kSmiType: return object_store->smi_type();
73 case kMintType: return object_store->mint_type(); 71 case kMintType: return object_store->mint_type();
74 case kDoubleType: return object_store->double_type(); 72 case kDoubleType: return object_store->double_type();
75 case kIntType: return object_store->int_type(); 73 case kIntType: return object_store->int_type();
76 case kBoolType: return object_store->bool_type(); 74 case kBoolType: return object_store->bool_type();
77 case kStringType: return object_store->string_type(); 75 case kStringType: return object_store->string_type();
78 case kArrayType: return object_store->array_type(); 76 case kArrayType: return object_store->array_type();
79 default: break; 77 default: break;
80 } 78 }
81 UNREACHABLE(); 79 UNREACHABLE();
82 return Type::null(); 80 return Type::null();
83 } 81 }
84 82
85 83
86 static int GetTypeIndex(ObjectStore* object_store, const RawType* raw_type) { 84 static int GetTypeIndex(ObjectStore* object_store, const RawType* raw_type) {
87 ASSERT(raw_type->IsHeapObject()); 85 ASSERT(raw_type->IsHeapObject());
88 if (raw_type == object_store->object_type()) { 86 if (raw_type == object_store->object_type()) {
89 return kObjectType; 87 return kObjectType;
90 } else if (raw_type == object_store->null_type()) { 88 } else if (raw_type == object_store->null_type()) {
91 return kNullType; 89 return kNullType;
92 } else if (raw_type == object_store->dynamic_type()) {
93 return kDynamicType;
94 } else if (raw_type == object_store->void_type()) {
95 return kVoidType;
96 } else if (raw_type == object_store->function_type()) { 90 } else if (raw_type == object_store->function_type()) {
97 return kFunctionType; 91 return kFunctionType;
98 } else if (raw_type == object_store->number_type()) { 92 } else if (raw_type == object_store->number_type()) {
99 return kNumberType; 93 return kNumberType;
100 } else if (raw_type == object_store->smi_type()) { 94 } else if (raw_type == object_store->smi_type()) {
101 return kSmiType; 95 return kSmiType;
102 } else if (raw_type == object_store->mint_type()) { 96 } else if (raw_type == object_store->mint_type()) {
103 return kMintType; 97 return kMintType;
104 } else if (raw_type == object_store->double_type()) { 98 } else if (raw_type == object_store->double_type()) {
105 return kDoubleType; 99 return kDoubleType;
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 if (object_id == kNullObject) { 713 if (object_id == kNullObject) {
720 // This is a singleton null object, return it. 714 // This is a singleton null object, return it.
721 return Object::null(); 715 return Object::null();
722 } 716 }
723 if (object_id == kSentinelObject) { 717 if (object_id == kSentinelObject) {
724 return Object::sentinel().raw(); 718 return Object::sentinel().raw();
725 } 719 }
726 if (object_id == kEmptyArrayObject) { 720 if (object_id == kEmptyArrayObject) {
727 return Object::empty_array().raw(); 721 return Object::empty_array().raw();
728 } 722 }
723 if (object_id == kDynamicType) {
724 return Object::dynamic_type();
725 }
726 if (object_id == kVoidType) {
727 return Object::void_type();
728 }
729 if (object_id == kTrueValue) { 729 if (object_id == kTrueValue) {
730 return Bool::True().raw(); 730 return Bool::True().raw();
731 } 731 }
732 if (object_id == kFalseValue) { 732 if (object_id == kFalseValue) {
733 return Bool::False().raw(); 733 return Bool::False().raw();
734 } 734 }
735 intptr_t class_id = ClassIdFromObjectId(object_id); 735 intptr_t class_id = ClassIdFromObjectId(object_id);
736 if (IsSingletonClassId(class_id)) { 736 if (IsSingletonClassId(class_id)) {
737 return isolate()->class_table()->At(class_id); // get singleton class. 737 return isolate()->class_table()->At(class_id); // get singleton class.
738 } else { 738 } else {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 WriteVMIsolateObject(kSentinelObject); 886 WriteVMIsolateObject(kSentinelObject);
887 return; 887 return;
888 } 888 }
889 889
890 // Check if it is a singleton empty array object. 890 // Check if it is a singleton empty array object.
891 if (rawobj == Object::empty_array().raw()) { 891 if (rawobj == Object::empty_array().raw()) {
892 WriteVMIsolateObject(kEmptyArrayObject); 892 WriteVMIsolateObject(kEmptyArrayObject);
893 return; 893 return;
894 } 894 }
895 895
896 // Check if it is a singleton dyanmic Type object.
897 if (rawobj == Object::dynamic_type()) {
898 WriteVMIsolateObject(kDynamicType);
899 return;
900 }
901
902 // Check if it is a singleton void Type object.
903 if (rawobj == Object::void_type()) {
904 WriteVMIsolateObject(kVoidType);
905 return;
906 }
907
896 // Check if it is a singleton boolean true object. 908 // Check if it is a singleton boolean true object.
897 if (rawobj == Bool::True().raw()) { 909 if (rawobj == Bool::True().raw()) {
898 WriteVMIsolateObject(kTrueValue); 910 WriteVMIsolateObject(kTrueValue);
899 return; 911 return;
900 } 912 }
901 913
902 // Check if it is a singleton boolean false object. 914 // Check if it is a singleton boolean false object.
903 if (rawobj == Bool::False().raw()) { 915 if (rawobj == Bool::False().raw()) {
904 WriteVMIsolateObject(kFalseValue); 916 WriteVMIsolateObject(kFalseValue);
905 return; 917 return;
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 UnmarkAll(); 1485 UnmarkAll();
1474 isolate->set_long_jump_base(base); 1486 isolate->set_long_jump_base(base);
1475 } else { 1487 } else {
1476 isolate->set_long_jump_base(base); 1488 isolate->set_long_jump_base(base);
1477 ThrowException(exception_type(), exception_msg()); 1489 ThrowException(exception_type(), exception_msg());
1478 } 1490 }
1479 } 1491 }
1480 1492
1481 1493
1482 } // namespace dart 1494 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object_test.cc ('k') | tests/language/dynamic_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698