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

Side by Side Diff: runtime/vm/raw_object.cc

Issue 9195031: Add ByteArray interface and provide internal and external implementations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fewer templates Created 8 years, 11 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/freelist.h" 7 #include "vm/freelist.h"
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/visitor.h" 10 #include "vm/visitor.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 instance_size = FourByteString::InstanceSize(string_length); 109 instance_size = FourByteString::InstanceSize(string_length);
110 break; 110 break;
111 } 111 }
112 case kArray: 112 case kArray:
113 case kImmutableArray: { 113 case kImmutableArray: {
114 const RawArray* raw_array = reinterpret_cast<const RawArray*>(this); 114 const RawArray* raw_array = reinterpret_cast<const RawArray*>(this);
115 intptr_t array_length = Smi::Value(raw_array->ptr()->length_); 115 intptr_t array_length = Smi::Value(raw_array->ptr()->length_);
116 instance_size = Array::InstanceSize(array_length); 116 instance_size = Array::InstanceSize(array_length);
117 break; 117 break;
118 } 118 }
119 case kInternalByteArray: {
120 const RawInternalByteArray* raw_byte_array =
121 reinterpret_cast<const RawInternalByteArray*>(this);
122 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_);
123 instance_size = InternalByteArray::InstanceSize(byte_array_length);
124 break;
125 }
119 case kTypeArguments: { 126 case kTypeArguments: {
120 const RawTypeArguments* raw_array = 127 const RawTypeArguments* raw_array =
121 reinterpret_cast<const RawTypeArguments*>(this); 128 reinterpret_cast<const RawTypeArguments*>(this);
122 intptr_t array_length = Smi::Value(raw_array->ptr()->length_); 129 intptr_t array_length = Smi::Value(raw_array->ptr()->length_);
123 instance_size = TypeArguments::InstanceSize(array_length); 130 instance_size = TypeArguments::InstanceSize(array_length);
124 break; 131 break;
125 } 132 }
126 case kPcDescriptors: { 133 case kPcDescriptors: {
127 const RawPcDescriptors* raw_descriptors = 134 const RawPcDescriptors* raw_descriptors =
128 reinterpret_cast<const RawPcDescriptors*>(this); 135 reinterpret_cast<const RawPcDescriptors*>(this);
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 return Array::InstanceSize(length); 576 return Array::InstanceSize(length);
570 } 577 }
571 578
572 579
573 intptr_t RawImmutableArray::VisitImmutableArrayPointers( 580 intptr_t RawImmutableArray::VisitImmutableArrayPointers(
574 RawImmutableArray* raw_obj, ObjectPointerVisitor* visitor) { 581 RawImmutableArray* raw_obj, ObjectPointerVisitor* visitor) {
575 return RawArray::VisitArrayPointers(raw_obj, visitor); 582 return RawArray::VisitArrayPointers(raw_obj, visitor);
576 } 583 }
577 584
578 585
579 intptr_t RawByteBuffer::VisitByteBufferPointers( 586 intptr_t RawByteArray::VisitByteArrayPointers(RawByteArray* raw_obj,
580 RawByteBuffer* raw_obj, ObjectPointerVisitor* visitor) { 587 ObjectPointerVisitor* visitor) {
588 // ByteArray is an abstract class.
589 UNREACHABLE();
590 return 0;
591 }
592
593
594 intptr_t RawInternalByteArray::VisitInternalByteArrayPointers(
595 RawInternalByteArray* raw_obj, ObjectPointerVisitor* visitor) {
596 // Make sure that we got here with the tagged pointer as this.
597 ASSERT(raw_obj->IsHeapObject());
598 intptr_t length = Smi::Value(raw_obj->ptr()->length_);
599 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
600 return InternalByteArray::InstanceSize(length);
601 }
602
603
604 intptr_t RawExternalByteArray::VisitExternalByteArrayPointers(
605 RawExternalByteArray* raw_obj, ObjectPointerVisitor* visitor) {
581 // Make sure that we got here with the tagged pointer as this. 606 // Make sure that we got here with the tagged pointer as this.
582 ASSERT(raw_obj->IsHeapObject()); 607 ASSERT(raw_obj->IsHeapObject());
583 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 608 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
584 return ByteBuffer::InstanceSize(); 609 return ExternalByteArray::InstanceSize();
585 } 610 }
586 611
587 612
588 intptr_t RawClosure::VisitClosurePointers(RawClosure* raw_obj, 613 intptr_t RawClosure::VisitClosurePointers(RawClosure* raw_obj,
589 ObjectPointerVisitor* visitor) { 614 ObjectPointerVisitor* visitor) {
590 // Make sure that we got here with the tagged pointer as this. 615 // Make sure that we got here with the tagged pointer as this.
591 ASSERT(raw_obj->IsHeapObject()); 616 ASSERT(raw_obj->IsHeapObject());
592 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 617 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
593 return Closure::InstanceSize(); 618 return Closure::InstanceSize();
594 } 619 }
(...skipping 11 matching lines...) Expand all
606 intptr_t RawJSRegExp::VisitJSRegExpPointers(RawJSRegExp* raw_obj, 631 intptr_t RawJSRegExp::VisitJSRegExpPointers(RawJSRegExp* raw_obj,
607 ObjectPointerVisitor* visitor) { 632 ObjectPointerVisitor* visitor) {
608 // Make sure that we got here with the tagged pointer as this. 633 // Make sure that we got here with the tagged pointer as this.
609 ASSERT(raw_obj->IsHeapObject()); 634 ASSERT(raw_obj->IsHeapObject());
610 intptr_t length = Smi::Value(raw_obj->ptr()->data_length_); 635 intptr_t length = Smi::Value(raw_obj->ptr()->data_length_);
611 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 636 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
612 return JSRegExp::InstanceSize(length); 637 return JSRegExp::InstanceSize(length);
613 } 638 }
614 639
615 } // namespace dart 640 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698