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

Unified Diff: runtime/vm/raw_object.h

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, 8 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/raw_object.h
diff --git a/runtime/vm/raw_object.h b/runtime/vm/raw_object.h
index deef9986ab82252a6e60a1ff89c48f7ae593e4a8..f7bf58d4bf47bec0363a9691a5a3b05c02cae1d2 100644
--- a/runtime/vm/raw_object.h
+++ b/runtime/vm/raw_object.h
@@ -66,8 +66,26 @@ namespace dart {
V(ImmutableArray) \
V(GrowableObjectArray) \
V(ByteArray) \
- V(InternalByteArray) \
- V(ExternalByteArray) \
+ V(Int8Array) \
+ V(Uint8Array) \
+ V(Int16Array) \
+ V(Uint16Array) \
+ V(Int32Array) \
+ V(Uint32Array) \
+ V(Int64Array) \
+ V(Uint64Array) \
+ V(Float32Array) \
+ V(Float64Array) \
+ V(ExternalInt8Array) \
+ V(ExternalUint8Array) \
+ V(ExternalInt16Array) \
+ V(ExternalUint16Array) \
+ V(ExternalInt32Array) \
+ V(ExternalUint32Array) \
+ V(ExternalInt64Array) \
+ V(ExternalUint64Array) \
+ V(ExternalFloat32Array) \
+ V(ExternalFloat64Array) \
V(Closure) \
V(Stacktrace) \
V(JSRegExp) \
@@ -1113,20 +1131,90 @@ class RawByteArray : public RawInstance {
};
-class RawInternalByteArray : public RawByteArray {
- RAW_HEAP_OBJECT_IMPLEMENTATION(InternalByteArray);
+class RawInt8Array: public RawByteArray {
+ RAW_HEAP_OBJECT_IMPLEMENTATION(Int8Array);
// Variable length data follows here.
- uint8_t* data() {
- uword address_of_length = reinterpret_cast<uword>(&length_);
- return reinterpret_cast<uint8_t*>(address_of_length + kWordSize);
- }
+ int8_t data_[0];
+};
+
+
+class RawUint8Array: public RawByteArray {
+ RAW_HEAP_OBJECT_IMPLEMENTATION(Uint8Array);
+
+ // Variable length data follows here.
+ uint8_t data_[0];
+};
+
+
+class RawInt16Array: public RawByteArray {
+ RAW_HEAP_OBJECT_IMPLEMENTATION(Int16Array);
+
+ // Variable length data follows here.
+ int16_t data_[0];
+};
+
+
+class RawUint16Array: public RawByteArray {
+ RAW_HEAP_OBJECT_IMPLEMENTATION(Uint16Array);
+
+ // Variable length data follows here.
+ uint16_t data_[0];
+};
+
+
+class RawInt32Array: public RawByteArray {
+ RAW_HEAP_OBJECT_IMPLEMENTATION(Int32Array);
+
+ // Variable length data follows here.
+ int32_t data_[0];
+};
+
+
+class RawUint32Array: public RawByteArray {
+ RAW_HEAP_OBJECT_IMPLEMENTATION(Uint32Array);
+
+ // Variable length data follows here.
+ uint32_t data_[0];
+};
+
+
+class RawInt64Array: public RawByteArray {
+ RAW_HEAP_OBJECT_IMPLEMENTATION(Int64Array);
+
+ // Variable length data follows here.
+ int64_t data_[0];
+};
+
+
+class RawUint64Array: public RawByteArray {
+ RAW_HEAP_OBJECT_IMPLEMENTATION(Uint64Array);
+
+ // Variable length data follows here.
+ uint64_t data_[0];
+};
+
+
+class RawFloat32Array: public RawByteArray {
+ RAW_HEAP_OBJECT_IMPLEMENTATION(Float32Array);
+
+ // Variable length data follows here.
+ float data_[0];
};
+class RawFloat64Array: public RawByteArray {
+ RAW_HEAP_OBJECT_IMPLEMENTATION(Float64Array);
+
+ // Variable length data follows here.
+ double data_[0];
+};
+
+
+template<typename T>
class ExternalByteArrayData {
public:
- ExternalByteArrayData(uint8_t* data,
+ ExternalByteArrayData(T* data,
void* peer,
Dart_PeerFinalizer callback) :
data_(data), peer_(peer), callback_(callback) {
@@ -1135,7 +1223,7 @@ class ExternalByteArrayData {
if (callback_ != NULL) (*callback_)(peer_);
}
- uint8_t* data() {
+ T* data() {
return data_;
}
void* peer() {
@@ -1143,16 +1231,79 @@ class ExternalByteArrayData {
}
private:
- uint8_t* data_;
+ T* data_;
void* peer_;
Dart_PeerFinalizer callback_;
};
-class RawExternalByteArray : public RawByteArray {
- RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalByteArray);
+class RawExternalInt8Array: public RawByteArray {
+ RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalInt8Array);
+
+ ExternalByteArrayData<int8_t>* external_data_;
+};
+
+
+class RawExternalUint8Array: public RawByteArray {
+ RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalUint8Array);
+
+ ExternalByteArrayData<uint8_t>* external_data_;
+};
+
+
+class RawExternalInt16Array: public RawByteArray {
+ RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalInt16Array);
+
+ ExternalByteArrayData<int16_t>* external_data_;
+};
+
+
+class RawExternalUint16Array: public RawByteArray {
+ RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalUint16Array);
+
+ ExternalByteArrayData<uint16_t>* external_data_;
+};
+
+
+class RawExternalInt32Array: public RawByteArray {
+ RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalInt32Array);
+
+ ExternalByteArrayData<int32_t>* external_data_;
+};
+
+
+class RawExternalUint32Array: public RawByteArray {
+ RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalUint32Array);
+
+ ExternalByteArrayData<uint32_t>* external_data_;
+};
+
+
+class RawExternalInt64Array: public RawByteArray {
+ RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalInt64Array);
+
+ ExternalByteArrayData<int64_t>* external_data_;
+};
+
+
+class RawExternalUint64Array: public RawByteArray {
+ RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalUint64Array);
+
+ ExternalByteArrayData<uint64_t>* external_data_;
+};
+
+
+class RawExternalFloat32Array: public RawByteArray {
+ RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalFloat32Array);
+
+ ExternalByteArrayData<float>* external_data_;
+};
+
+
+class RawExternalFloat64Array: public RawByteArray {
+ RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalFloat64Array);
- ExternalByteArrayData* external_data_;
+ ExternalByteArrayData<double>* external_data_;
};

Powered by Google App Engine
This is Rietveld 408576698