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/bootstrap.h" | 8 #include "vm/bootstrap.h" |
9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 intptr_t class_header = Read<int32_t>(); | 246 intptr_t class_header = Read<int32_t>(); |
247 ASSERT((class_header & kSmiTagMask) != kSmiTag); | 247 ASSERT((class_header & kSmiTagMask) != kSmiTag); |
248 ASSERT(!IsVMIsolateObject(class_header) || | 248 ASSERT(!IsVMIsolateObject(class_header) || |
249 !IsSingletonClassId(GetVMIsolateObjectId(class_header))); | 249 !IsSingletonClassId(GetVMIsolateObjectId(class_header))); |
250 ASSERT((SerializedHeaderTag::decode(class_header) != kObjectId) || | 250 ASSERT((SerializedHeaderTag::decode(class_header) != kObjectId) || |
251 !IsObjectStoreClassId(SerializedHeaderData::decode(class_header))); | 251 !IsObjectStoreClassId(SerializedHeaderData::decode(class_header))); |
252 Class& cls = Class::ZoneHandle(zone(), Class::null()); | 252 Class& cls = Class::ZoneHandle(zone(), Class::null()); |
253 AddBackRef(object_id, &cls, kIsDeserialized); | 253 AddBackRef(object_id, &cls, kIsDeserialized); |
254 // Read the library/class information and lookup the class. | 254 // Read the library/class information and lookup the class. |
255 str_ ^= ReadObjectImpl(class_header, kAsInlinedObject, kInvalidPatchIndex, 0); | 255 str_ ^= ReadObjectImpl(class_header, kAsInlinedObject, kInvalidPatchIndex, 0); |
256 library_ = Library::LookupLibrary(str_); | 256 library_ = Library::LookupLibrary(thread(), str_); |
257 if (library_.IsNull() || !library_.Loaded()) { | 257 if (library_.IsNull() || !library_.Loaded()) { |
258 SetReadException("Invalid object found in message."); | 258 SetReadException("Invalid object found in message."); |
259 } | 259 } |
260 str_ ^= ReadObjectImpl(kAsInlinedObject); | 260 str_ ^= ReadObjectImpl(kAsInlinedObject); |
261 cls = library_.LookupClass(str_); | 261 cls = library_.LookupClass(str_); |
262 if (cls.IsNull()) { | 262 if (cls.IsNull()) { |
263 SetReadException("Invalid object found in message."); | 263 SetReadException("Invalid object found in message."); |
264 } | 264 } |
265 cls.EnsureIsFinalized(thread()); | 265 cls.EnsureIsFinalized(thread()); |
266 return cls.raw(); | 266 return cls.raw(); |
267 } | 267 } |
268 | 268 |
269 | 269 |
270 RawFunction* SnapshotReader::ReadFunctionId(intptr_t object_id) { | 270 RawFunction* SnapshotReader::ReadFunctionId(intptr_t object_id) { |
271 ASSERT(kind_ == Snapshot::kScript); | 271 ASSERT(kind_ == Snapshot::kScript); |
272 // Read the function header information and lookup the function. | 272 // Read the function header information and lookup the function. |
273 intptr_t func_header = Read<int32_t>(); | 273 intptr_t func_header = Read<int32_t>(); |
274 ASSERT((func_header & kSmiTagMask) != kSmiTag); | 274 ASSERT((func_header & kSmiTagMask) != kSmiTag); |
275 ASSERT(!IsVMIsolateObject(func_header) || | 275 ASSERT(!IsVMIsolateObject(func_header) || |
276 !IsSingletonClassId(GetVMIsolateObjectId(func_header))); | 276 !IsSingletonClassId(GetVMIsolateObjectId(func_header))); |
277 ASSERT((SerializedHeaderTag::decode(func_header) != kObjectId) || | 277 ASSERT((SerializedHeaderTag::decode(func_header) != kObjectId) || |
278 !IsObjectStoreClassId(SerializedHeaderData::decode(func_header))); | 278 !IsObjectStoreClassId(SerializedHeaderData::decode(func_header))); |
279 Function& func = Function::ZoneHandle(zone(), Function::null()); | 279 Function& func = Function::ZoneHandle(zone(), Function::null()); |
280 AddBackRef(object_id, &func, kIsDeserialized); | 280 AddBackRef(object_id, &func, kIsDeserialized); |
281 // Read the library/class/function information and lookup the function. | 281 // Read the library/class/function information and lookup the function. |
282 str_ ^= ReadObjectImpl(func_header, kAsInlinedObject, kInvalidPatchIndex, 0); | 282 str_ ^= ReadObjectImpl(func_header, kAsInlinedObject, kInvalidPatchIndex, 0); |
283 library_ = Library::LookupLibrary(str_); | 283 library_ = Library::LookupLibrary(thread(), str_); |
284 if (library_.IsNull() || !library_.Loaded()) { | 284 if (library_.IsNull() || !library_.Loaded()) { |
285 SetReadException("Expected a library name, but found an invalid name."); | 285 SetReadException("Expected a library name, but found an invalid name."); |
286 } | 286 } |
287 str_ ^= ReadObjectImpl(kAsInlinedObject); | 287 str_ ^= ReadObjectImpl(kAsInlinedObject); |
288 if (str_.Equals(Symbols::TopLevel(), 0, Symbols::TopLevel().Length())) { | 288 if (str_.Equals(Symbols::TopLevel(), 0, Symbols::TopLevel().Length())) { |
289 str_ ^= ReadObjectImpl(kAsInlinedObject); | 289 str_ ^= ReadObjectImpl(kAsInlinedObject); |
290 func ^= library_.LookupLocalFunction(str_); | 290 func ^= library_.LookupLocalFunction(str_); |
291 } else { | 291 } else { |
292 cls_ = library_.LookupClass(str_); | 292 cls_ = library_.LookupClass(str_); |
293 if (cls_.IsNull()) { | 293 if (cls_.IsNull()) { |
(...skipping 15 matching lines...) Expand all Loading... |
309 ASSERT(!Snapshot::IsFull(kind_)); | 309 ASSERT(!Snapshot::IsFull(kind_)); |
310 | 310 |
311 // First create a function object and associate it with the specified | 311 // First create a function object and associate it with the specified |
312 // 'object_id'. | 312 // 'object_id'. |
313 Function& func = Function::Handle(zone(), Function::null()); | 313 Function& func = Function::Handle(zone(), Function::null()); |
314 Instance& obj = Instance::ZoneHandle(zone(), Instance::null()); | 314 Instance& obj = Instance::ZoneHandle(zone(), Instance::null()); |
315 AddBackRef(object_id, &obj, kIsDeserialized); | 315 AddBackRef(object_id, &obj, kIsDeserialized); |
316 | 316 |
317 // Read the library/class/function information and lookup the function. | 317 // Read the library/class/function information and lookup the function. |
318 str_ ^= ReadObjectImpl(kAsInlinedObject); | 318 str_ ^= ReadObjectImpl(kAsInlinedObject); |
319 library_ = Library::LookupLibrary(str_); | 319 library_ = Library::LookupLibrary(thread(), str_); |
320 if (library_.IsNull() || !library_.Loaded()) { | 320 if (library_.IsNull() || !library_.Loaded()) { |
321 SetReadException("Invalid Library object found in message."); | 321 SetReadException("Invalid Library object found in message."); |
322 } | 322 } |
323 str_ ^= ReadObjectImpl(kAsInlinedObject); | 323 str_ ^= ReadObjectImpl(kAsInlinedObject); |
324 if (str_.Equals(Symbols::TopLevel())) { | 324 if (str_.Equals(Symbols::TopLevel())) { |
325 str_ ^= ReadObjectImpl(kAsInlinedObject); | 325 str_ ^= ReadObjectImpl(kAsInlinedObject); |
326 func = library_.LookupFunctionAllowPrivate(str_); | 326 func = library_.LookupFunctionAllowPrivate(str_); |
327 } else { | 327 } else { |
328 cls_ = library_.LookupClassAllowPrivate(str_); | 328 cls_ = library_.LookupClassAllowPrivate(str_); |
329 if (cls_.IsNull()) { | 329 if (cls_.IsNull()) { |
(...skipping 2456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2786 if (setjmp(*jump.Set()) == 0) { | 2786 if (setjmp(*jump.Set()) == 0) { |
2787 NoSafepointScope no_safepoint; | 2787 NoSafepointScope no_safepoint; |
2788 WriteObject(obj.raw()); | 2788 WriteObject(obj.raw()); |
2789 } else { | 2789 } else { |
2790 ThrowException(exception_type(), exception_msg()); | 2790 ThrowException(exception_type(), exception_msg()); |
2791 } | 2791 } |
2792 } | 2792 } |
2793 | 2793 |
2794 | 2794 |
2795 } // namespace dart | 2795 } // namespace dart |
OLD | NEW |