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

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

Issue 9958046: Implement {Int,Uint}{8,16,32,64} and Float{32,64} typed arrays. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: add view classes and their tests Created 8 years, 7 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: { 119 case kInt8Array: {
120 const RawInternalByteArray* raw_byte_array = 120 const RawInt8Array* raw_byte_array =
121 reinterpret_cast<const RawInternalByteArray*>(this); 121 reinterpret_cast<const RawInt8Array*>(this);
122 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); 122 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_);
123 instance_size = InternalByteArray::InstanceSize(byte_array_length); 123 instance_size = Int8Array::InstanceSize(byte_array_length);
124 break;
125 }
126 case kUint8Array: {
127 const RawUint8Array* raw_byte_array =
128 reinterpret_cast<const RawUint8Array*>(this);
129 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_);
130 instance_size = Uint8Array::InstanceSize(byte_array_length);
131 break;
132 }
133 case kInt16Array: {
134 const RawInt16Array* raw_byte_array =
135 reinterpret_cast<const RawInt16Array*>(this);
136 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_);
137 instance_size = Int16Array::InstanceSize(byte_array_length);
138 break;
139 }
140 case kUint16Array: {
141 const RawUint16Array* raw_byte_array =
142 reinterpret_cast<const RawUint16Array*>(this);
143 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_);
144 instance_size = Uint16Array::InstanceSize(byte_array_length);
145 break;
146 }
147 case kInt32Array: {
148 const RawInt32Array* raw_byte_array =
149 reinterpret_cast<const RawInt32Array*>(this);
150 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_);
151 instance_size = Int32Array::InstanceSize(byte_array_length);
152 break;
153 }
154 case kUint32Array: {
155 const RawUint32Array* raw_byte_array =
156 reinterpret_cast<const RawUint32Array*>(this);
157 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_);
158 instance_size = Uint32Array::InstanceSize(byte_array_length);
159 break;
160 }
161 case kInt64Array: {
162 const RawInt64Array* raw_byte_array =
163 reinterpret_cast<const RawInt64Array*>(this);
164 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_);
165 instance_size = Int64Array::InstanceSize(byte_array_length);
166 break;
167 }
168 case kUint64Array: {
169 const RawUint64Array* raw_byte_array =
170 reinterpret_cast<const RawUint64Array*>(this);
171 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_);
172 instance_size = Uint64Array::InstanceSize(byte_array_length);
173 break;
174 }
175 case kFloat32Array: {
176 const RawFloat32Array* raw_byte_array =
177 reinterpret_cast<const RawFloat32Array*>(this);
178 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_);
179 instance_size = Float32Array::InstanceSize(byte_array_length);
180 break;
181 }
182 case kFloat64Array: {
183 const RawFloat64Array* raw_byte_array =
184 reinterpret_cast<const RawFloat64Array*>(this);
185 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_);
186 instance_size = Float64Array::InstanceSize(byte_array_length);
124 break; 187 break;
125 } 188 }
126 case kTypeArguments: { 189 case kTypeArguments: {
127 const RawTypeArguments* raw_array = 190 const RawTypeArguments* raw_array =
128 reinterpret_cast<const RawTypeArguments*>(this); 191 reinterpret_cast<const RawTypeArguments*>(this);
129 intptr_t array_length = Smi::Value(raw_array->ptr()->length_); 192 intptr_t array_length = Smi::Value(raw_array->ptr()->length_);
130 instance_size = TypeArguments::InstanceSize(array_length); 193 instance_size = TypeArguments::InstanceSize(array_length);
131 break; 194 break;
132 } 195 }
133 case kPcDescriptors: { 196 case kPcDescriptors: {
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 709
647 710
648 intptr_t RawByteArray::VisitByteArrayPointers(RawByteArray* raw_obj, 711 intptr_t RawByteArray::VisitByteArrayPointers(RawByteArray* raw_obj,
649 ObjectPointerVisitor* visitor) { 712 ObjectPointerVisitor* visitor) {
650 // ByteArray is an abstract class. 713 // ByteArray is an abstract class.
651 UNREACHABLE(); 714 UNREACHABLE();
652 return 0; 715 return 0;
653 } 716 }
654 717
655 718
656 intptr_t RawInternalByteArray::VisitInternalByteArrayPointers( 719 intptr_t RawInt8Array::VisitInt8ArrayPointers(
657 RawInternalByteArray* raw_obj, ObjectPointerVisitor* visitor) { 720 RawInt8Array *raw_obj, ObjectPointerVisitor* visitor) {
658 // Make sure that we got here with the tagged pointer as this. 721 // Make sure that we got here with the tagged pointer as this.
659 ASSERT(raw_obj->IsHeapObject()); 722 ASSERT(raw_obj->IsHeapObject());
660 intptr_t length = Smi::Value(raw_obj->ptr()->length_); 723 intptr_t length = Smi::Value(raw_obj->ptr()->length_);
661 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 724 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
662 return InternalByteArray::InstanceSize(length); 725 return Int8Array::InstanceSize(length);
663 } 726 }
664 727
665 728
666 intptr_t RawExternalByteArray::VisitExternalByteArrayPointers( 729 intptr_t RawUint8Array::VisitUint8ArrayPointers(
667 RawExternalByteArray* raw_obj, ObjectPointerVisitor* visitor) { 730 RawUint8Array *raw_obj, ObjectPointerVisitor* visitor) {
731 // Make sure that we got here with the tagged pointer as this.
732 ASSERT(raw_obj->IsHeapObject());
733 intptr_t length = Smi::Value(raw_obj->ptr()->length_);
734 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
735 return Uint8Array::InstanceSize(length);
736 }
737
738
739 intptr_t RawInt16Array::VisitInt16ArrayPointers(
740 RawInt16Array *raw_obj, ObjectPointerVisitor* visitor) {
741 // Make sure that we got here with the tagged pointer as this.
742 ASSERT(raw_obj->IsHeapObject());
743 intptr_t length = Smi::Value(raw_obj->ptr()->length_);
744 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
745 return Int16Array::InstanceSize(length);
746 }
747
748
749 intptr_t RawUint16Array::VisitUint16ArrayPointers(
750 RawUint16Array *raw_obj, ObjectPointerVisitor* visitor) {
751 // Make sure that we got here with the tagged pointer as this.
752 ASSERT(raw_obj->IsHeapObject());
753 intptr_t length = Smi::Value(raw_obj->ptr()->length_);
754 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
755 return Uint16Array::InstanceSize(length);
756 }
757
758
759 intptr_t RawInt32Array::VisitInt32ArrayPointers(
760 RawInt32Array *raw_obj, ObjectPointerVisitor* visitor) {
761 // Make sure that we got here with the tagged pointer as this.
762 ASSERT(raw_obj->IsHeapObject());
763 intptr_t length = Smi::Value(raw_obj->ptr()->length_);
764 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
765 return Int32Array::InstanceSize(length);
766 }
767
768
769 intptr_t RawUint32Array::VisitUint32ArrayPointers(
770 RawUint32Array *raw_obj, ObjectPointerVisitor* visitor) {
771 // Make sure that we got here with the tagged pointer as this.
772 ASSERT(raw_obj->IsHeapObject());
773 intptr_t length = Smi::Value(raw_obj->ptr()->length_);
774 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
775 return Uint32Array::InstanceSize(length);
776 }
777
778
779 intptr_t RawInt64Array::VisitInt64ArrayPointers(
780 RawInt64Array *raw_obj, ObjectPointerVisitor* visitor) {
781 // Make sure that we got here with the tagged pointer as this.
782 ASSERT(raw_obj->IsHeapObject());
783 intptr_t length = Smi::Value(raw_obj->ptr()->length_);
784 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
785 return Int64Array::InstanceSize(length);
786 }
787
788
789 intptr_t RawUint64Array::VisitUint64ArrayPointers(
790 RawUint64Array *raw_obj, ObjectPointerVisitor* visitor) {
791 // Make sure that we got here with the tagged pointer as this.
792 ASSERT(raw_obj->IsHeapObject());
793 intptr_t length = Smi::Value(raw_obj->ptr()->length_);
794 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
795 return Uint64Array::InstanceSize(length);
796 }
797
798
799 intptr_t RawFloat32Array::VisitFloat32ArrayPointers(
800 RawFloat32Array *raw_obj, ObjectPointerVisitor* visitor) {
801 // Make sure that we got here with the tagged pointer as this.
802 ASSERT(raw_obj->IsHeapObject());
803 intptr_t length = Smi::Value(raw_obj->ptr()->length_);
804 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
805 return Float32Array::InstanceSize(length);
806 }
807
808
809 intptr_t RawFloat64Array::VisitFloat64ArrayPointers(
810 RawFloat64Array *raw_obj, ObjectPointerVisitor* visitor) {
811 // Make sure that we got here with the tagged pointer as this.
812 ASSERT(raw_obj->IsHeapObject());
813 intptr_t length = Smi::Value(raw_obj->ptr()->length_);
814 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
815 return Float64Array::InstanceSize(length);
816 }
817
818
819 intptr_t RawExternalInt8Array::VisitExternalInt8ArrayPointers(
820 RawExternalInt8Array* raw_obj, ObjectPointerVisitor* visitor) {
668 // Make sure that we got here with the tagged pointer as this. 821 // Make sure that we got here with the tagged pointer as this.
669 ASSERT(raw_obj->IsHeapObject()); 822 ASSERT(raw_obj->IsHeapObject());
670 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 823 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
671 return ExternalByteArray::InstanceSize(); 824 return ExternalInt8Array::InstanceSize();
672 } 825 }
673 826
674 827
828 intptr_t RawExternalUint8Array::VisitExternalUint8ArrayPointers(
829 RawExternalUint8Array* raw_obj, ObjectPointerVisitor* visitor) {
830 // Make sure that we got here with the tagged pointer as this.
831 ASSERT(raw_obj->IsHeapObject());
832 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
833 return ExternalUint8Array::InstanceSize();
834 }
835
836
837 intptr_t RawExternalInt16Array::VisitExternalInt16ArrayPointers(
838 RawExternalInt16Array* raw_obj, ObjectPointerVisitor* visitor) {
839 // Make sure that we got here with the tagged pointer as this.
840 ASSERT(raw_obj->IsHeapObject());
841 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
842 return ExternalInt16Array::InstanceSize();
843 }
844
845
846 intptr_t RawExternalUint16Array::VisitExternalUint16ArrayPointers(
847 RawExternalUint16Array* raw_obj, ObjectPointerVisitor* visitor) {
848 // Make sure that we got here with the tagged pointer as this.
849 ASSERT(raw_obj->IsHeapObject());
850 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
851 return ExternalUint16Array::InstanceSize();
852 }
853
854
855 intptr_t RawExternalInt32Array::VisitExternalInt32ArrayPointers(
856 RawExternalInt32Array* raw_obj, ObjectPointerVisitor* visitor) {
857 // Make sure that we got here with the tagged pointer as this.
858 ASSERT(raw_obj->IsHeapObject());
859 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
860 return ExternalInt32Array::InstanceSize();
861 }
862
863
864 intptr_t RawExternalUint32Array::VisitExternalUint32ArrayPointers(
865 RawExternalUint32Array* raw_obj, ObjectPointerVisitor* visitor) {
866 // Make sure that we got here with the tagged pointer as this.
867 ASSERT(raw_obj->IsHeapObject());
868 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
869 return ExternalUint32Array::InstanceSize();
870 }
871
872
873 intptr_t RawExternalInt64Array::VisitExternalInt64ArrayPointers(
874 RawExternalInt64Array* raw_obj, ObjectPointerVisitor* visitor) {
875 // Make sure that we got here with the tagged pointer as this.
876 ASSERT(raw_obj->IsHeapObject());
877 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
878 return ExternalInt64Array::InstanceSize();
879 }
880
881
882 intptr_t RawExternalUint64Array::VisitExternalUint64ArrayPointers(
883 RawExternalUint64Array* raw_obj, ObjectPointerVisitor* visitor) {
884 // Make sure that we got here with the tagged pointer as this.
885 ASSERT(raw_obj->IsHeapObject());
886 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
887 return ExternalUint64Array::InstanceSize();
888 }
889
890
891 intptr_t RawExternalFloat32Array::VisitExternalFloat32ArrayPointers(
892 RawExternalFloat32Array* raw_obj, ObjectPointerVisitor* visitor) {
893 // Make sure that we got here with the tagged pointer as this.
894 ASSERT(raw_obj->IsHeapObject());
895 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
896 return ExternalFloat32Array::InstanceSize();
897 }
898
899
900 intptr_t RawExternalFloat64Array::VisitExternalFloat64ArrayPointers(
901 RawExternalFloat64Array* raw_obj, ObjectPointerVisitor* visitor) {
902 // Make sure that we got here with the tagged pointer as this.
903 ASSERT(raw_obj->IsHeapObject());
904 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
905 return ExternalFloat64Array::InstanceSize();
906 }
907
908
675 intptr_t RawClosure::VisitClosurePointers(RawClosure* raw_obj, 909 intptr_t RawClosure::VisitClosurePointers(RawClosure* raw_obj,
676 ObjectPointerVisitor* visitor) { 910 ObjectPointerVisitor* visitor) {
677 // Make sure that we got here with the tagged pointer as this. 911 // Make sure that we got here with the tagged pointer as this.
678 ASSERT(raw_obj->IsHeapObject()); 912 ASSERT(raw_obj->IsHeapObject());
679 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 913 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
680 return Closure::InstanceSize(); 914 return Closure::InstanceSize();
681 } 915 }
682 916
683 917
684 intptr_t RawStacktrace::VisitStacktracePointers(RawStacktrace* raw_obj, 918 intptr_t RawStacktrace::VisitStacktracePointers(RawStacktrace* raw_obj,
685 ObjectPointerVisitor* visitor) { 919 ObjectPointerVisitor* visitor) {
686 // Make sure that we got here with the tagged pointer as this. 920 // Make sure that we got here with the tagged pointer as this.
687 ASSERT(raw_obj->IsHeapObject()); 921 ASSERT(raw_obj->IsHeapObject());
688 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 922 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
689 return Stacktrace::InstanceSize(); 923 return Stacktrace::InstanceSize();
690 } 924 }
691 925
692 926
693 intptr_t RawJSRegExp::VisitJSRegExpPointers(RawJSRegExp* raw_obj, 927 intptr_t RawJSRegExp::VisitJSRegExpPointers(RawJSRegExp* raw_obj,
694 ObjectPointerVisitor* visitor) { 928 ObjectPointerVisitor* visitor) {
695 // Make sure that we got here with the tagged pointer as this. 929 // Make sure that we got here with the tagged pointer as this.
696 ASSERT(raw_obj->IsHeapObject()); 930 ASSERT(raw_obj->IsHeapObject());
697 intptr_t length = Smi::Value(raw_obj->ptr()->data_length_); 931 intptr_t length = Smi::Value(raw_obj->ptr()->data_length_);
698 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 932 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
699 return JSRegExp::InstanceSize(length); 933 return JSRegExp::InstanceSize(length);
700 } 934 }
701 935
702 } // namespace dart 936 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698