Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 | 47 |
| 48 static intptr_t ClassIdFromObjectId(intptr_t object_id) { | 48 static intptr_t ClassIdFromObjectId(intptr_t object_id) { |
| 49 ASSERT(object_id > kClassIdsOffset); | 49 ASSERT(object_id > kClassIdsOffset); |
| 50 intptr_t class_id = (object_id - kClassIdsOffset); | 50 intptr_t class_id = (object_id - kClassIdsOffset); |
| 51 return class_id; | 51 return class_id; |
| 52 } | 52 } |
| 53 | 53 |
| 54 | 54 |
| 55 static intptr_t ObjectIdFromClassId(intptr_t class_id) { | 55 static intptr_t ObjectIdFromClassId(intptr_t class_id) { |
| 56 ASSERT((class_id > kIllegalCid) && (class_id < kNumPredefinedCids)); | 56 ASSERT((class_id > kIllegalCid) && (class_id < kNumPredefinedCids)); |
| 57 ASSERT(!RawObject::IsTypedDataViewClassId(class_id)); | |
| 57 return (class_id + kClassIdsOffset); | 58 return (class_id + kClassIdsOffset); |
| 58 } | 59 } |
| 59 | 60 |
| 60 | 61 |
| 61 static RawType* GetType(ObjectStore* object_store, int index) { | 62 static RawType* GetType(ObjectStore* object_store, int index) { |
| 62 switch (index) { | 63 switch (index) { |
| 63 case kObjectType: return object_store->object_type(); | 64 case kObjectType: return object_store->object_type(); |
| 64 case kNullType: return object_store->null_type(); | 65 case kNullType: return object_store->null_type(); |
| 65 case kDynamicType: return object_store->dynamic_type(); | 66 case kDynamicType: return object_store->dynamic_type(); |
| 66 case kVoidType: return object_store->void_type(); | 67 case kVoidType: return object_store->void_type(); |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 918 void SnapshotWriter::WriteObjectRef(RawObject* raw) { | 919 void SnapshotWriter::WriteObjectRef(RawObject* raw) { |
| 919 // First check if object can be written as a simple predefined type. | 920 // First check if object can be written as a simple predefined type. |
| 920 if (CheckAndWritePredefinedObject(raw)) { | 921 if (CheckAndWritePredefinedObject(raw)) { |
| 921 return; | 922 return; |
| 922 } | 923 } |
| 923 | 924 |
| 924 NoGCScope no_gc; | 925 NoGCScope no_gc; |
| 925 RawClass* cls = class_table_->At(raw->GetClassId()); | 926 RawClass* cls = class_table_->At(raw->GetClassId()); |
| 926 intptr_t class_id = cls->ptr()->id_; | 927 intptr_t class_id = cls->ptr()->id_; |
| 927 ASSERT(class_id == raw->GetClassId()); | 928 ASSERT(class_id == raw->GetClassId()); |
| 928 if (class_id >= kNumPredefinedCids) { | 929 if (class_id >= kNumPredefinedCids || |
| 930 RawObject::IsTypedDataViewClassId(class_id)) { | |
| 929 if (Class::IsSignatureClass(cls)) { | 931 if (Class::IsSignatureClass(cls)) { |
| 930 // We do not allow closure objects in an isolate message. | 932 // We do not allow closure objects in an isolate message. |
| 931 set_exception_type(Exceptions::kArgument); | 933 set_exception_type(Exceptions::kArgument); |
| 932 // TODO(6726): Allocate these constant strings once in the VM isolate. | 934 // TODO(6726): Allocate these constant strings once in the VM isolate. |
| 933 set_exception_msg("Illegal argument in isolate message" | 935 set_exception_msg("Illegal argument in isolate message" |
| 934 " : (object is a closure)"); | 936 " : (object is a closure)"); |
| 935 Isolate::Current()->long_jump_base()->Jump(1, *ErrorHandle()); | 937 Isolate::Current()->long_jump_base()->Jump(1, *ErrorHandle()); |
| 936 } | 938 } |
| 937 // Object is being referenced, add it to the forward ref list and mark | 939 // Object is being referenced, add it to the forward ref list and mark |
| 938 // it so that future references to this object in the snapshot will use | 940 // it so that future references to this object in the snapshot will use |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1190 // serialized fields of the object | 1192 // serialized fields of the object |
| 1191 // ...... | 1193 // ...... |
| 1192 NoGCScope no_gc; | 1194 NoGCScope no_gc; |
| 1193 uword tags = raw->ptr()->tags_; | 1195 uword tags = raw->ptr()->tags_; |
| 1194 ASSERT(SerializedHeaderTag::decode(tags) == kObjectId); | 1196 ASSERT(SerializedHeaderTag::decode(tags) == kObjectId); |
| 1195 intptr_t object_id = SerializedHeaderData::decode(tags); | 1197 intptr_t object_id = SerializedHeaderData::decode(tags); |
| 1196 tags = forward_list_[object_id - kMaxPredefinedObjectIds]->tags(); | 1198 tags = forward_list_[object_id - kMaxPredefinedObjectIds]->tags(); |
| 1197 RawClass* cls = class_table_->At(RawObject::ClassIdTag::decode(tags)); | 1199 RawClass* cls = class_table_->At(RawObject::ClassIdTag::decode(tags)); |
| 1198 intptr_t class_id = cls->ptr()->id_; | 1200 intptr_t class_id = cls->ptr()->id_; |
| 1199 | 1201 |
| 1200 if (class_id >= kNumPredefinedCids) { | 1202 if (class_id >= kNumPredefinedCids || |
| 1203 RawObject::IsTypedDataViewClassId(class_id)) { | |
|
Ivan Posva
2013/03/22 04:50:01
ditto
siva
2013/03/25 17:20:35
Made the same code changes.
On 2013/03/22 04:50:0
| |
| 1201 if (Class::IsSignatureClass(cls)) { | 1204 if (Class::IsSignatureClass(cls)) { |
| 1202 // We do not allow closure objects in an isolate message. | 1205 // We do not allow closure objects in an isolate message. |
| 1203 set_exception_type(Exceptions::kArgument); | 1206 set_exception_type(Exceptions::kArgument); |
| 1204 // TODO(6726): Allocate these constant strings once in the VM isolate. | 1207 // TODO(6726): Allocate these constant strings once in the VM isolate. |
| 1205 set_exception_msg("Illegal argument in isolate message" | 1208 set_exception_msg("Illegal argument in isolate message" |
| 1206 " : (object is a closure)"); | 1209 " : (object is a closure)"); |
| 1207 Isolate::Current()->long_jump_base()->Jump(1, *ErrorHandle()); | 1210 Isolate::Current()->long_jump_base()->Jump(1, *ErrorHandle()); |
| 1208 } | 1211 } |
| 1209 if (cls->ptr()->num_native_fields_ != 0) { | 1212 if (cls->ptr()->num_native_fields_ != 0) { |
| 1210 // We do not allow objects with native fields in an isolate message. | 1213 // We do not allow objects with native fields in an isolate message. |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1414 UnmarkAll(); | 1417 UnmarkAll(); |
| 1415 isolate->set_long_jump_base(base); | 1418 isolate->set_long_jump_base(base); |
| 1416 } else { | 1419 } else { |
| 1417 isolate->set_long_jump_base(base); | 1420 isolate->set_long_jump_base(base); |
| 1418 ThrowException(exception_type(), exception_msg()); | 1421 ThrowException(exception_type(), exception_msg()); |
| 1419 } | 1422 } |
| 1420 } | 1423 } |
| 1421 | 1424 |
| 1422 | 1425 |
| 1423 } // namespace dart | 1426 } // namespace dart |
| OLD | NEW |