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

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

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

Powered by Google App Engine
This is Rietveld 408576698