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

Side by Side Diff: vm/raw_object.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/raw_object.h" 5 #include "vm/raw_object.h"
6 6
7 #include "vm/class_table.h" 7 #include "vm/class_table.h"
8 #include "vm/freelist.h" 8 #include "vm/freelist.h"
9 #include "vm/isolate.h" 9 #include "vm/isolate.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 RawClass* raw_class = isolate->class_table()->At(GetClassId()); 54 RawClass* raw_class = isolate->class_table()->At(GetClassId());
55 intptr_t instance_size = raw_class->ptr()->instance_size_; 55 intptr_t instance_size = raw_class->ptr()->instance_size_;
56 ObjectKind instance_kind = raw_class->ptr()->instance_kind_; 56 ObjectKind instance_kind = raw_class->ptr()->instance_kind_;
57 57
58 if (instance_size == 0) { 58 if (instance_size == 0) {
59 switch (instance_kind) { 59 switch (instance_kind) {
60 case kTokenStream: { 60 case kTokenStream: {
61 const RawTokenStream* raw_tokens = 61 const RawTokenStream* raw_tokens =
62 reinterpret_cast<const RawTokenStream*>(this); 62 reinterpret_cast<const RawTokenStream*>(this);
63 intptr_t tokens_length = Smi::Value(raw_tokens->ptr()->length_); 63 intptr_t tokens_length = raw_tokens->ptr()->length_;
64 instance_size = TokenStream::InstanceSize(tokens_length); 64 instance_size = TokenStream::InstanceSize(tokens_length);
65 break; 65 break;
66 } 66 }
67 case kCode: { 67 case kCode: {
68 const RawCode* raw_code = reinterpret_cast<const RawCode*>(this); 68 const RawCode* raw_code = reinterpret_cast<const RawCode*>(this);
69 intptr_t pointer_offsets_length = 69 intptr_t pointer_offsets_length =
70 raw_code->ptr()->pointer_offsets_length_; 70 raw_code->ptr()->pointer_offsets_length_;
71 instance_size = Code::InstanceSize(pointer_offsets_length); 71 instance_size = Code::InstanceSize(pointer_offsets_length);
72 break; 72 break;
73 } 73 }
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 397
398 intptr_t RawLiteralToken::VisitLiteralTokenPointers( 398 intptr_t RawLiteralToken::VisitLiteralTokenPointers(
399 RawLiteralToken* raw_obj, ObjectPointerVisitor* visitor) { 399 RawLiteralToken* raw_obj, ObjectPointerVisitor* visitor) {
400 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 400 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
401 return LiteralToken::InstanceSize(); 401 return LiteralToken::InstanceSize();
402 } 402 }
403 403
404 404
405 intptr_t RawTokenStream::VisitTokenStreamPointers( 405 intptr_t RawTokenStream::VisitTokenStreamPointers(
406 RawTokenStream* raw_obj, ObjectPointerVisitor* visitor) { 406 RawTokenStream* raw_obj, ObjectPointerVisitor* visitor) {
407 intptr_t length = Smi::Value(raw_obj->ptr()->length_); 407 intptr_t length = raw_obj->ptr()->length_;
408 visitor->VisitPointers(raw_obj->from(), raw_obj->to(length)); 408 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
409 return TokenStream::InstanceSize(length); 409 return TokenStream::InstanceSize(length);
410 } 410 }
411 411
412 412
413 intptr_t RawScript::VisitScriptPointers(RawScript* raw_obj, 413 intptr_t RawScript::VisitScriptPointers(RawScript* raw_obj,
414 ObjectPointerVisitor* visitor) { 414 ObjectPointerVisitor* visitor) {
415 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 415 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
416 return Script::InstanceSize(); 416 return Script::InstanceSize();
417 } 417 }
418 418
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 intptr_t RawJSRegExp::VisitJSRegExpPointers(RawJSRegExp* raw_obj, 953 intptr_t RawJSRegExp::VisitJSRegExpPointers(RawJSRegExp* raw_obj,
954 ObjectPointerVisitor* visitor) { 954 ObjectPointerVisitor* visitor) {
955 // Make sure that we got here with the tagged pointer as this. 955 // Make sure that we got here with the tagged pointer as this.
956 ASSERT(raw_obj->IsHeapObject()); 956 ASSERT(raw_obj->IsHeapObject());
957 intptr_t length = Smi::Value(raw_obj->ptr()->data_length_); 957 intptr_t length = Smi::Value(raw_obj->ptr()->data_length_);
958 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 958 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
959 return JSRegExp::InstanceSize(length); 959 return JSRegExp::InstanceSize(length);
960 } 960 }
961 961
962 } // namespace dart 962 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698