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, | |
419 reinterpret_cast<void*>(array), | |
cshapiro
2012/09/06 00:11:49
make line 419 a NULL instead of non-NULL
siva
2012/09/06 18:19:29
Done.
| |
420 NULL); | |
421 ASSERT(external_data != NULL); | |
422 data_ = reinterpret_cast<RawExternalUint8Array*>( | |
423 AllocateUninitialized(cls_, ExternalUint8Array::InstanceSize())); | |
424 data_.SetExternalData(external_data); | |
425 data_.SetLength(len); | |
426 stream_.SetStream(data_); | |
427 return stream_.raw(); | |
409 } | 428 } |
410 | 429 |
411 | 430 |
412 RawContext* SnapshotReader::NewContext(intptr_t num_variables) { | 431 RawContext* SnapshotReader::NewContext(intptr_t num_variables) { |
413 ASSERT(kind_ == Snapshot::kFull); | 432 ASSERT(kind_ == Snapshot::kFull); |
414 ASSERT(isolate()->no_gc_scope_depth() != 0); | 433 ASSERT(isolate()->no_gc_scope_depth() != 0); |
415 cls_ = Object::context_class(); | 434 cls_ = Object::context_class(); |
416 RawContext* obj = reinterpret_cast<RawContext*>( | 435 RawContext* obj = reinterpret_cast<RawContext*>( |
417 AllocateUninitialized(cls_, Context::InstanceSize(num_variables))); | 436 AllocateUninitialized(cls_, Context::InstanceSize(num_variables))); |
418 obj->ptr()->num_variables_ = num_variables; | 437 obj->ptr()->num_variables_ = num_variables; |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1153 | 1172 |
1154 | 1173 |
1155 void MessageWriter::WriteMessage(const Object& obj) { | 1174 void MessageWriter::WriteMessage(const Object& obj) { |
1156 ASSERT(kind() == Snapshot::kMessage); | 1175 ASSERT(kind() == Snapshot::kMessage); |
1157 WriteObject(obj.raw()); | 1176 WriteObject(obj.raw()); |
1158 UnmarkAll(); | 1177 UnmarkAll(); |
1159 } | 1178 } |
1160 | 1179 |
1161 | 1180 |
1162 } // namespace dart | 1181 } // namespace dart |
OLD | NEW |