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/exceptions.h" | 10 #include "vm/exceptions.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 : BaseReader(buffer, size), | 149 : BaseReader(buffer, size), |
150 kind_(kind), | 150 kind_(kind), |
151 isolate_(isolate), | 151 isolate_(isolate), |
152 cls_(Class::Handle()), | 152 cls_(Class::Handle()), |
153 obj_(Object::Handle()), | 153 obj_(Object::Handle()), |
154 str_(String::Handle()), | 154 str_(String::Handle()), |
155 library_(Library::Handle()), | 155 library_(Library::Handle()), |
156 type_(AbstractType::Handle()), | 156 type_(AbstractType::Handle()), |
157 type_arguments_(AbstractTypeArguments::Handle()), | 157 type_arguments_(AbstractTypeArguments::Handle()), |
158 tokens_(Array::Handle()), | 158 tokens_(Array::Handle()), |
| 159 stream_(TokenStream::Handle()), |
| 160 data_(ExternalUint8Array::Handle()), |
159 backward_references_((kind == Snapshot::kFull) ? | 161 backward_references_((kind == Snapshot::kFull) ? |
160 kNumInitialReferencesInFullSnapshot : | 162 kNumInitialReferencesInFullSnapshot : |
161 kNumInitialReferences) { | 163 kNumInitialReferences) { |
162 } | 164 } |
163 | 165 |
164 | 166 |
165 RawObject* SnapshotReader::ReadObject() { | 167 RawObject* SnapshotReader::ReadObject() { |
166 Object& obj = Object::Handle(ReadObjectImpl()); | 168 Object& obj = Object::Handle(ReadObjectImpl()); |
167 for (intptr_t i = 0; i < backward_references_.length(); i++) { | 169 for (intptr_t i = 0; i < backward_references_.length(); i++) { |
168 if (!backward_references_[i]->is_deserialized()) { | 170 if (!backward_references_[i]->is_deserialized()) { |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 | 398 |
397 | 399 |
398 RawTypeArguments* SnapshotReader::NewTypeArguments(intptr_t len) { | 400 RawTypeArguments* SnapshotReader::NewTypeArguments(intptr_t len) { |
399 ALLOC_NEW_OBJECT_WITH_LEN(TypeArguments, | 401 ALLOC_NEW_OBJECT_WITH_LEN(TypeArguments, |
400 Object::type_arguments_class(), | 402 Object::type_arguments_class(), |
401 len); | 403 len); |
402 } | 404 } |
403 | 405 |
404 | 406 |
405 RawTokenStream* SnapshotReader::NewTokenStream(intptr_t len) { | 407 RawTokenStream* SnapshotReader::NewTokenStream(intptr_t len) { |
406 ALLOC_NEW_OBJECT_WITH_LEN(TokenStream, | 408 ASSERT(kind_ == Snapshot::kFull); |
407 Object::token_stream_class(), | 409 ASSERT(isolate()->no_gc_scope_depth() != 0); |
408 len); | 410 cls_ = Object::token_stream_class(); |
| 411 stream_ = reinterpret_cast<RawTokenStream*>( |
| 412 AllocateUninitialized(cls_, TokenStream::InstanceSize())); |
| 413 cls_ = object_store()->external_int8_array_class(); |
| 414 uint8_t* array = const_cast<uint8_t*>(CurrentBufferAddress()); |
| 415 ASSERT(array != NULL); |
| 416 Advance(len); |
| 417 ExternalByteArrayData<uint8_t>* external_data = |
| 418 new ExternalByteArrayData<uint8_t>(array, NULL, NULL); |
| 419 ASSERT(external_data != NULL); |
| 420 data_ = reinterpret_cast<RawExternalUint8Array*>( |
| 421 AllocateUninitialized(cls_, ExternalUint8Array::InstanceSize())); |
| 422 data_.SetExternalData(external_data); |
| 423 data_.SetLength(len); |
| 424 stream_.SetStream(data_); |
| 425 return stream_.raw(); |
409 } | 426 } |
410 | 427 |
411 | 428 |
412 RawContext* SnapshotReader::NewContext(intptr_t num_variables) { | 429 RawContext* SnapshotReader::NewContext(intptr_t num_variables) { |
413 ASSERT(kind_ == Snapshot::kFull); | 430 ASSERT(kind_ == Snapshot::kFull); |
414 ASSERT(isolate()->no_gc_scope_depth() != 0); | 431 ASSERT(isolate()->no_gc_scope_depth() != 0); |
415 cls_ = Object::context_class(); | 432 cls_ = Object::context_class(); |
416 RawContext* obj = reinterpret_cast<RawContext*>( | 433 RawContext* obj = reinterpret_cast<RawContext*>( |
417 AllocateUninitialized(cls_, Context::InstanceSize(num_variables))); | 434 AllocateUninitialized(cls_, Context::InstanceSize(num_variables))); |
418 obj->ptr()->num_variables_ = num_variables; | 435 obj->ptr()->num_variables_ = num_variables; |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1153 | 1170 |
1154 | 1171 |
1155 void MessageWriter::WriteMessage(const Object& obj) { | 1172 void MessageWriter::WriteMessage(const Object& obj) { |
1156 ASSERT(kind() == Snapshot::kMessage); | 1173 ASSERT(kind() == Snapshot::kMessage); |
1157 WriteObject(obj.raw()); | 1174 WriteObject(obj.raw()); |
1158 UnmarkAll(); | 1175 UnmarkAll(); |
1159 } | 1176 } |
1160 | 1177 |
1161 | 1178 |
1162 } // namespace dart | 1179 } // namespace dart |
OLD | NEW |