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

Side by Side Diff: vm/snapshot.cc

Issue 10697055: Represent tokens as a compressed stream instead of an array. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 5 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
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/exceptions.h" 10 #include "vm/exceptions.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 SnapshotReader::SnapshotReader(const Snapshot* snapshot, Isolate* isolate) 75 SnapshotReader::SnapshotReader(const Snapshot* snapshot, Isolate* isolate)
76 : BaseReader(snapshot->content(), snapshot->length()), 76 : BaseReader(snapshot->content(), snapshot->length()),
77 kind_(snapshot->kind()), 77 kind_(snapshot->kind()),
78 isolate_(isolate), 78 isolate_(isolate),
79 cls_(Class::Handle()), 79 cls_(Class::Handle()),
80 obj_(Object::Handle()), 80 obj_(Object::Handle()),
81 str_(String::Handle()), 81 str_(String::Handle()),
82 library_(Library::Handle()), 82 library_(Library::Handle()),
83 type_(AbstractType::Handle()), 83 type_(AbstractType::Handle()),
84 type_arguments_(AbstractTypeArguments::Handle()), 84 type_arguments_(AbstractTypeArguments::Handle()),
85 tokens_(Array::Handle()),
85 backward_references_((snapshot->kind() == Snapshot::kFull) ? 86 backward_references_((snapshot->kind() == Snapshot::kFull) ?
86 kNumInitialReferencesInFullSnapshot : 87 kNumInitialReferencesInFullSnapshot :
87 kNumInitialReferences) { 88 kNumInitialReferences) {
88 } 89 }
89 90
90 91
91 RawObject* SnapshotReader::ReadObject() { 92 RawObject* SnapshotReader::ReadObject() {
92 Object& obj = Object::Handle(ReadObjectImpl()); 93 Object& obj = Object::Handle(ReadObjectImpl());
93 for (intptr_t i = 0; i < backward_references_.length(); i++) { 94 for (intptr_t i = 0; i < backward_references_.length(); i++) {
94 if (!backward_references_[i]->is_deserialized()) { 95 if (!backward_references_[i]->is_deserialized()) {
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 323
323 324
324 RawTypeArguments* SnapshotReader::NewTypeArguments(intptr_t len) { 325 RawTypeArguments* SnapshotReader::NewTypeArguments(intptr_t len) {
325 ALLOC_NEW_OBJECT_WITH_LEN(TypeArguments, 326 ALLOC_NEW_OBJECT_WITH_LEN(TypeArguments,
326 Object::type_arguments_class(), 327 Object::type_arguments_class(),
327 len); 328 len);
328 } 329 }
329 330
330 331
331 RawTokenStream* SnapshotReader::NewTokenStream(intptr_t len) { 332 RawTokenStream* SnapshotReader::NewTokenStream(intptr_t len) {
332 ALLOC_NEW_OBJECT_WITH_LEN(TokenStream, 333 ASSERT(kind_ == Snapshot::kFull);
333 Object::token_stream_class(), 334 ASSERT(isolate()->no_gc_scope_depth() != 0);
334 len); 335 cls_ = Object::token_stream_class();
336 RawTokenStream* obj = reinterpret_cast<RawTokenStream*>(
337 AllocateUninitialized(cls_, TokenStream::InstanceSize(len)));
338 obj->ptr()->length_ = len;
339 return obj;
335 } 340 }
336 341
337 342
338 RawContext* SnapshotReader::NewContext(intptr_t num_variables) { 343 RawContext* SnapshotReader::NewContext(intptr_t num_variables) {
339 ASSERT(kind_ == Snapshot::kFull); 344 ASSERT(kind_ == Snapshot::kFull);
340 ASSERT(isolate()->no_gc_scope_depth() != 0); 345 ASSERT(isolate()->no_gc_scope_depth() != 0);
341 cls_ = Object::context_class(); 346 cls_ = Object::context_class();
342 RawContext* obj = reinterpret_cast<RawContext*>( 347 RawContext* obj = reinterpret_cast<RawContext*>(
343 AllocateUninitialized(cls_, Context::InstanceSize(num_variables))); 348 AllocateUninitialized(cls_, Context::InstanceSize(num_variables)));
344 obj->ptr()->num_variables_ = num_variables; 349 obj->ptr()->num_variables_ = num_variables;
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 RawObject* raw_obj = *current; 1013 RawObject* raw_obj = *current;
1009 if (as_references_) { 1014 if (as_references_) {
1010 writer_->WriteObjectRef(raw_obj); 1015 writer_->WriteObjectRef(raw_obj);
1011 } else { 1016 } else {
1012 writer_->WriteObjectImpl(raw_obj); 1017 writer_->WriteObjectImpl(raw_obj);
1013 } 1018 }
1014 } 1019 }
1015 } 1020 }
1016 1021
1017 } // namespace dart 1022 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698