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

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: address review comments 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 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 716
654 717
655 intptr_t RawByteArray::VisitByteArrayPointers(RawByteArray* raw_obj, 718 intptr_t RawByteArray::VisitByteArrayPointers(RawByteArray* raw_obj,
656 ObjectPointerVisitor* visitor) { 719 ObjectPointerVisitor* visitor) {
657 // ByteArray is an abstract class. 720 // ByteArray is an abstract class.
658 UNREACHABLE(); 721 UNREACHABLE();
659 return 0; 722 return 0;
660 } 723 }
661 724
662 725
663 intptr_t RawInternalByteArray::VisitInternalByteArrayPointers( 726 intptr_t RawInt8Array::VisitInt8ArrayPointers(
664 RawInternalByteArray* raw_obj, ObjectPointerVisitor* visitor) { 727 RawInt8Array *raw_obj, ObjectPointerVisitor* visitor) {
665 // Make sure that we got here with the tagged pointer as this. 728 // Make sure that we got here with the tagged pointer as this.
666 ASSERT(raw_obj->IsHeapObject()); 729 ASSERT(raw_obj->IsHeapObject());
667 intptr_t length = Smi::Value(raw_obj->ptr()->length_); 730 intptr_t length = Smi::Value(raw_obj->ptr()->length_);
668 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 731 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
669 return InternalByteArray::InstanceSize(length); 732 return Int8Array::InstanceSize(length);
670 } 733 }
671 734
672 735
673 intptr_t RawExternalByteArray::VisitExternalByteArrayPointers( 736 intptr_t RawUint8Array::VisitUint8ArrayPointers(
674 RawExternalByteArray* raw_obj, ObjectPointerVisitor* visitor) { 737 RawUint8Array *raw_obj, ObjectPointerVisitor* visitor) {
738 // Make sure that we got here with the tagged pointer as this.
739 ASSERT(raw_obj->IsHeapObject());
740 intptr_t length = Smi::Value(raw_obj->ptr()->length_);
741 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
742 return Uint8Array::InstanceSize(length);
743 }
744
745
746 intptr_t RawInt16Array::VisitInt16ArrayPointers(
747 RawInt16Array *raw_obj, ObjectPointerVisitor* visitor) {
748 // Make sure that we got here with the tagged pointer as this.
749 ASSERT(raw_obj->IsHeapObject());
750 intptr_t length = Smi::Value(raw_obj->ptr()->length_);
751 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
752 return Int16Array::InstanceSize(length);
753 }
754
755
756 intptr_t RawUint16Array::VisitUint16ArrayPointers(
757 RawUint16Array *raw_obj, ObjectPointerVisitor* visitor) {
758 // Make sure that we got here with the tagged pointer as this.
759 ASSERT(raw_obj->IsHeapObject());
760 intptr_t length = Smi::Value(raw_obj->ptr()->length_);
761 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
762 return Uint16Array::InstanceSize(length);
763 }
764
765
766 intptr_t RawInt32Array::VisitInt32ArrayPointers(
767 RawInt32Array *raw_obj, ObjectPointerVisitor* visitor) {
768 // Make sure that we got here with the tagged pointer as this.
769 ASSERT(raw_obj->IsHeapObject());
770 intptr_t length = Smi::Value(raw_obj->ptr()->length_);
771 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
772 return Int32Array::InstanceSize(length);
773 }
774
775
776 intptr_t RawUint32Array::VisitUint32ArrayPointers(
777 RawUint32Array *raw_obj, ObjectPointerVisitor* visitor) {
778 // Make sure that we got here with the tagged pointer as this.
779 ASSERT(raw_obj->IsHeapObject());
780 intptr_t length = Smi::Value(raw_obj->ptr()->length_);
781 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
782 return Uint32Array::InstanceSize(length);
783 }
784
785
786 intptr_t RawInt64Array::VisitInt64ArrayPointers(
787 RawInt64Array *raw_obj, ObjectPointerVisitor* visitor) {
788 // Make sure that we got here with the tagged pointer as this.
789 ASSERT(raw_obj->IsHeapObject());
790 intptr_t length = Smi::Value(raw_obj->ptr()->length_);
791 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
792 return Int64Array::InstanceSize(length);
793 }
794
795
796 intptr_t RawUint64Array::VisitUint64ArrayPointers(
797 RawUint64Array *raw_obj, ObjectPointerVisitor* visitor) {
798 // Make sure that we got here with the tagged pointer as this.
799 ASSERT(raw_obj->IsHeapObject());
800 intptr_t length = Smi::Value(raw_obj->ptr()->length_);
801 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
802 return Uint64Array::InstanceSize(length);
803 }
804
805
806 intptr_t RawFloat32Array::VisitFloat32ArrayPointers(
807 RawFloat32Array *raw_obj, ObjectPointerVisitor* visitor) {
808 // Make sure that we got here with the tagged pointer as this.
809 ASSERT(raw_obj->IsHeapObject());
810 intptr_t length = Smi::Value(raw_obj->ptr()->length_);
811 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
812 return Float32Array::InstanceSize(length);
813 }
814
815
816 intptr_t RawFloat64Array::VisitFloat64ArrayPointers(
817 RawFloat64Array *raw_obj, ObjectPointerVisitor* visitor) {
818 // Make sure that we got here with the tagged pointer as this.
819 ASSERT(raw_obj->IsHeapObject());
820 intptr_t length = Smi::Value(raw_obj->ptr()->length_);
821 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
822 return Float64Array::InstanceSize(length);
823 }
824
825
826 intptr_t RawExternalInt8Array::VisitExternalInt8ArrayPointers(
827 RawExternalInt8Array* raw_obj, ObjectPointerVisitor* visitor) {
675 // Make sure that we got here with the tagged pointer as this. 828 // Make sure that we got here with the tagged pointer as this.
676 ASSERT(raw_obj->IsHeapObject()); 829 ASSERT(raw_obj->IsHeapObject());
677 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 830 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
678 return ExternalByteArray::InstanceSize(); 831 return ExternalInt8Array::InstanceSize();
679 } 832 }
680 833
681 834
835 intptr_t RawExternalUint8Array::VisitExternalUint8ArrayPointers(
836 RawExternalUint8Array* raw_obj, ObjectPointerVisitor* visitor) {
837 // Make sure that we got here with the tagged pointer as this.
838 ASSERT(raw_obj->IsHeapObject());
839 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
840 return ExternalUint8Array::InstanceSize();
841 }
842
843
844 intptr_t RawExternalInt16Array::VisitExternalInt16ArrayPointers(
845 RawExternalInt16Array* raw_obj, ObjectPointerVisitor* visitor) {
846 // Make sure that we got here with the tagged pointer as this.
847 ASSERT(raw_obj->IsHeapObject());
848 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
849 return ExternalInt16Array::InstanceSize();
850 }
851
852
853 intptr_t RawExternalUint16Array::VisitExternalUint16ArrayPointers(
854 RawExternalUint16Array* raw_obj, ObjectPointerVisitor* visitor) {
855 // Make sure that we got here with the tagged pointer as this.
856 ASSERT(raw_obj->IsHeapObject());
857 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
858 return ExternalUint16Array::InstanceSize();
859 }
860
861
862 intptr_t RawExternalInt32Array::VisitExternalInt32ArrayPointers(
863 RawExternalInt32Array* raw_obj, ObjectPointerVisitor* visitor) {
864 // Make sure that we got here with the tagged pointer as this.
865 ASSERT(raw_obj->IsHeapObject());
866 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
867 return ExternalInt32Array::InstanceSize();
868 }
869
870
871 intptr_t RawExternalUint32Array::VisitExternalUint32ArrayPointers(
872 RawExternalUint32Array* raw_obj, ObjectPointerVisitor* visitor) {
873 // Make sure that we got here with the tagged pointer as this.
874 ASSERT(raw_obj->IsHeapObject());
875 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
876 return ExternalUint32Array::InstanceSize();
877 }
878
879
880 intptr_t RawExternalInt64Array::VisitExternalInt64ArrayPointers(
881 RawExternalInt64Array* raw_obj, ObjectPointerVisitor* visitor) {
882 // Make sure that we got here with the tagged pointer as this.
883 ASSERT(raw_obj->IsHeapObject());
884 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
885 return ExternalInt64Array::InstanceSize();
886 }
887
888
889 intptr_t RawExternalUint64Array::VisitExternalUint64ArrayPointers(
890 RawExternalUint64Array* raw_obj, ObjectPointerVisitor* visitor) {
891 // Make sure that we got here with the tagged pointer as this.
892 ASSERT(raw_obj->IsHeapObject());
893 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
894 return ExternalUint64Array::InstanceSize();
895 }
896
897
898 intptr_t RawExternalFloat32Array::VisitExternalFloat32ArrayPointers(
899 RawExternalFloat32Array* raw_obj, ObjectPointerVisitor* visitor) {
900 // Make sure that we got here with the tagged pointer as this.
901 ASSERT(raw_obj->IsHeapObject());
902 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
903 return ExternalFloat32Array::InstanceSize();
904 }
905
906
907 intptr_t RawExternalFloat64Array::VisitExternalFloat64ArrayPointers(
908 RawExternalFloat64Array* raw_obj, ObjectPointerVisitor* visitor) {
909 // Make sure that we got here with the tagged pointer as this.
910 ASSERT(raw_obj->IsHeapObject());
911 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
912 return ExternalFloat64Array::InstanceSize();
913 }
914
915
682 intptr_t RawClosure::VisitClosurePointers(RawClosure* raw_obj, 916 intptr_t RawClosure::VisitClosurePointers(RawClosure* raw_obj,
683 ObjectPointerVisitor* visitor) { 917 ObjectPointerVisitor* visitor) {
684 // Make sure that we got here with the tagged pointer as this. 918 // Make sure that we got here with the tagged pointer as this.
685 ASSERT(raw_obj->IsHeapObject()); 919 ASSERT(raw_obj->IsHeapObject());
686 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 920 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
687 return Closure::InstanceSize(); 921 return Closure::InstanceSize();
688 } 922 }
689 923
690 924
691 intptr_t RawStacktrace::VisitStacktracePointers(RawStacktrace* raw_obj, 925 intptr_t RawStacktrace::VisitStacktracePointers(RawStacktrace* raw_obj,
692 ObjectPointerVisitor* visitor) { 926 ObjectPointerVisitor* visitor) {
693 // Make sure that we got here with the tagged pointer as this. 927 // Make sure that we got here with the tagged pointer as this.
694 ASSERT(raw_obj->IsHeapObject()); 928 ASSERT(raw_obj->IsHeapObject());
695 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 929 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
696 return Stacktrace::InstanceSize(); 930 return Stacktrace::InstanceSize();
697 } 931 }
698 932
699 933
700 intptr_t RawJSRegExp::VisitJSRegExpPointers(RawJSRegExp* raw_obj, 934 intptr_t RawJSRegExp::VisitJSRegExpPointers(RawJSRegExp* raw_obj,
701 ObjectPointerVisitor* visitor) { 935 ObjectPointerVisitor* visitor) {
702 // Make sure that we got here with the tagged pointer as this. 936 // Make sure that we got here with the tagged pointer as this.
703 ASSERT(raw_obj->IsHeapObject()); 937 ASSERT(raw_obj->IsHeapObject());
704 intptr_t length = Smi::Value(raw_obj->ptr()->data_length_); 938 intptr_t length = Smi::Value(raw_obj->ptr()->data_length_);
705 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 939 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
706 return JSRegExp::InstanceSize(length); 940 return JSRegExp::InstanceSize(length);
707 } 941 }
708 942
709 } // namespace dart 943 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698