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

Unified Diff: runtime/vm/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, 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/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index bdc65c38a698bec8702cf669e5bc4fd959896399..25f14cd419428a7c3317e72978fffe458916d5b0 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -453,6 +453,19 @@ void Object::RegisterClass(const Class& cls,
}
+void Object::RegisterPrivateClass(const Class& cls,
+ const char* public_class_name,
+ const Script& script,
+ const Library& lib) {
+ String& str = String::Handle();
+ str ^= String::NewSymbol(public_class_name);
+ str ^= lib.PrivateName(str);
+ cls.set_name(str);
+ cls.set_script(script);
+ lib.AddClass(cls);
+}
+
+
RawError* Object::Init(Isolate* isolate) {
TIMERSCOPE(time_bootstrap);
ObjectStore* object_store = isolate->object_store();
@@ -604,8 +617,8 @@ RawError* Object::Init(Isolate* isolate) {
// Initialize the base interfaces used by the core VM classes.
const Script& script = Script::Handle(Bootstrap::LoadScript());
- // Allocate and initialize the Object class and type.
- // The Object and ExternalByteArray classes are the only pre-allocated
+ // Allocate and initialize the Object class and type. The Object
+ // class and ByteArray subclasses are the only pre-allocated,
// non-interface classes in the core library.
cls = Class::New<Instance>();
object_store->set_object_class(cls);
@@ -617,20 +630,85 @@ RawError* Object::Init(Isolate* isolate) {
type = Type::NewNonParameterizedType(cls);
object_store->set_object_type(type);
- cls = Class::New<InternalByteArray>();
- object_store->set_internal_byte_array_class(cls);
- String& public_class_name = String::Handle();
- public_class_name = String::New("_InternalByteArray");
- cls.set_name(String::Handle(core_lib.PrivateName(public_class_name)));
- cls.set_script(script);
- core_lib.AddClass(cls);
+ cls = Class::New<Int8Array>();
+ object_store->set_int8_array_class(cls);
+ RegisterPrivateClass(cls, "_Int8Array", script, core_lib);
- cls = Class::New<ExternalByteArray>();
- object_store->set_external_byte_array_class(cls);
- public_class_name = String::New("_ExternalByteArray");
- cls.set_name(String::Handle(core_lib.PrivateName(public_class_name)));
- cls.set_script(script);
- core_lib.AddClass(cls);
+ cls = Class::New<Uint8Array>();
+ object_store->set_uint8_array_class(cls);
+ RegisterPrivateClass(cls, "_Uint8Array", script, core_lib);
+
+ cls = Class::New<Int16Array>();
+ object_store->set_int16_array_class(cls);
+ RegisterPrivateClass(cls, "_Int16Array", script, core_lib);
+
+ cls = Class::New<Uint16Array>();
+ object_store->set_uint16_array_class(cls);
+ RegisterPrivateClass(cls, "_Uint16Array", script, core_lib);
+
+ cls = Class::New<Int32Array>();
+ object_store->set_int32_array_class(cls);
+ RegisterPrivateClass(cls, "_Int32Array", script, core_lib);
+
+ cls = Class::New<Uint32Array>();
+ object_store->set_uint32_array_class(cls);
+ RegisterPrivateClass(cls, "_Uint32Array", script, core_lib);
+
+ cls = Class::New<Int64Array>();
+ object_store->set_int64_array_class(cls);
+ RegisterPrivateClass(cls, "_Int64Array", script, core_lib);
+
+ cls = Class::New<Uint64Array>();
+ object_store->set_uint64_array_class(cls);
+ RegisterPrivateClass(cls, "_Uint64Array", script, core_lib);
+
+ cls = Class::New<Float32Array>();
+ object_store->set_float32_array_class(cls);
+ RegisterPrivateClass(cls, "_Float32Array", script, core_lib);
+
+ cls = Class::New<Float64Array>();
+ object_store->set_float64_array_class(cls);
+ RegisterPrivateClass(cls, "_Float64Array", script, core_lib);
+
+ cls = Class::New<ExternalInt8Array>();
+ object_store->set_external_int8_array_class(cls);
+ RegisterPrivateClass(cls, "_ExternalInt8Array", script, core_lib);
+
+ cls = Class::New<ExternalUint8Array>();
+ object_store->set_external_uint8_array_class(cls);
+ RegisterPrivateClass(cls, "_ExternalUint8Array", script, core_lib);
+
+ cls = Class::New<ExternalInt16Array>();
+ object_store->set_external_int16_array_class(cls);
+ RegisterPrivateClass(cls, "_ExternalInt16Array", script, core_lib);
+
+ cls = Class::New<ExternalUint16Array>();
+ object_store->set_external_uint16_array_class(cls);
+ RegisterPrivateClass(cls, "_ExternalUint16Array", script, core_lib);
+
+ cls = Class::New<ExternalInt32Array>();
+ object_store->set_external_int32_array_class(cls);
+ RegisterPrivateClass(cls, "_ExternalInt32Array", script, core_lib);
+
+ cls = Class::New<ExternalUint32Array>();
+ object_store->set_external_uint32_array_class(cls);
+ RegisterPrivateClass(cls, "_ExternalUint32Array", script, core_lib);
+
+ cls = Class::New<ExternalInt64Array>();
+ object_store->set_external_int64_array_class(cls);
+ RegisterPrivateClass(cls, "_ExternalInt64Array", script, core_lib);
+
+ cls = Class::New<ExternalUint64Array>();
+ object_store->set_external_uint64_array_class(cls);
+ RegisterPrivateClass(cls, "_ExternalUint64Array", script, core_lib);
+
+ cls = Class::New<ExternalFloat32Array>();
+ object_store->set_external_float32_array_class(cls);
+ RegisterPrivateClass(cls, "_ExternalFloat32Array", script, core_lib);
+
+ cls = Class::New<ExternalFloat64Array>();
+ object_store->set_external_float64_array_class(cls);
+ RegisterPrivateClass(cls, "_ExternalFloat64Array", script, core_lib);
// Set the super type of class Stacktrace to Object type so that the
// 'toString' method is implemented.
@@ -771,11 +849,65 @@ void Object::InitFromSnapshot(Isolate* isolate) {
cls = Class::New<GrowableObjectArray>();
object_store->set_growable_object_array_class(cls);
- cls = Class::New<InternalByteArray>();
- object_store->set_internal_byte_array_class(cls);
+ cls = Class::New<Int8Array>();
+ object_store->set_int8_array_class(cls);
+
+ cls = Class::New<Uint8Array>();
+ object_store->set_uint8_array_class(cls);
+
+ cls = Class::New<Int16Array>();
+ object_store->set_int16_array_class(cls);
+
+ cls = Class::New<Uint16Array>();
+ object_store->set_uint16_array_class(cls);
+
+ cls = Class::New<Int32Array>();
+ object_store->set_int32_array_class(cls);
+
+ cls = Class::New<Uint32Array>();
+ object_store->set_uint32_array_class(cls);
+
+ cls = Class::New<Int64Array>();
+ object_store->set_int64_array_class(cls);
+
+ cls = Class::New<Uint64Array>();
+ object_store->set_uint64_array_class(cls);
+
+ cls = Class::New<Float32Array>();
+ object_store->set_float32_array_class(cls);
+
+ cls = Class::New<Float64Array>();
+ object_store->set_float64_array_class(cls);
+
+ cls = Class::New<ExternalInt8Array>();
+ object_store->set_external_int8_array_class(cls);
+
+ cls = Class::New<ExternalUint8Array>();
+ object_store->set_external_uint8_array_class(cls);
+
+ cls = Class::New<ExternalInt16Array>();
+ object_store->set_external_int16_array_class(cls);
- cls = Class::New<ExternalByteArray>();
- object_store->set_external_byte_array_class(cls);
+ cls = Class::New<ExternalUint16Array>();
+ object_store->set_external_uint16_array_class(cls);
+
+ cls = Class::New<ExternalInt32Array>();
+ object_store->set_external_int32_array_class(cls);
+
+ cls = Class::New<ExternalUint32Array>();
+ object_store->set_external_uint32_array_class(cls);
+
+ cls = Class::New<ExternalInt64Array>();
+ object_store->set_external_int64_array_class(cls);
+
+ cls = Class::New<ExternalUint64Array>();
+ object_store->set_external_uint64_array_class(cls);
+
+ cls = Class::New<ExternalFloat32Array>();
+ object_store->set_external_float32_array_class(cls);
+
+ cls = Class::New<ExternalFloat64Array>();
+ object_store->set_external_float64_array_class(cls);
cls = Class::New<Smi>();
object_store->set_smi_class(cls);
@@ -963,6 +1095,19 @@ void Class::InitEmptyFields() {
StorePointer(&raw_ptr()->fields_, empty_array.raw());
}
+
+bool Class::HasInstanceFields() const {
+ const Array& field_array = Array::Handle(fields());
+ Field& field = Field::Handle();
+ for (intptr_t i = 0; i < field_array.Length(); ++i) {
+ field ^= field_array.At(i);
+ if (!field.is_static()) {
+ return true;
+ }
+ }
+ return false;
+}
+
void Class::SetFunctions(const Array& value) const {
ASSERT(!value.IsNull());
// Bind all the functions in the array to this class.
@@ -1393,12 +1538,66 @@ RawClass* Class::GetClass(ObjectKind kind) {
case kGrowableObjectArray:
ASSERT(object_store->growable_object_array_class() != Class::null());
return object_store->growable_object_array_class();
- case kInternalByteArray:
- ASSERT(object_store->internal_byte_array_class() != Class::null());
- return object_store->internal_byte_array_class();
- case kExternalByteArray:
- ASSERT(object_store->external_byte_array_class() != Class::null());
- return object_store->external_byte_array_class();
+ case kInt8Array:
+ ASSERT(object_store->int8_array_class() != Class::null());
+ return object_store->int8_array_class();
+ case kUint8Array:
+ ASSERT(object_store->uint8_array_class() != Class::null());
+ return object_store->uint8_array_class();
+ case kInt16Array:
+ ASSERT(object_store->int16_array_class() != Class::null());
+ return object_store->int16_array_class();
+ case kUint16Array:
+ ASSERT(object_store->uint16_array_class() != Class::null());
+ return object_store->uint16_array_class();
+ case kInt32Array:
+ ASSERT(object_store->int32_array_class() != Class::null());
+ return object_store->int32_array_class();
+ case kUint32Array:
+ ASSERT(object_store->uint32_array_class() != Class::null());
+ return object_store->uint32_array_class();
+ case kInt64Array:
+ ASSERT(object_store->int64_array_class() != Class::null());
+ return object_store->int64_array_class();
+ case kUint64Array:
+ ASSERT(object_store->uint64_array_class() != Class::null());
+ return object_store->uint64_array_class();
+ case kFloat32Array:
+ ASSERT(object_store->float32_array_class() != Class::null());
+ return object_store->float32_array_class();
+ case kFloat64Array:
+ ASSERT(object_store->float64_array_class() != Class::null());
+ return object_store->float64_array_class();
+ case kExternalInt8Array:
+ ASSERT(object_store->external_int8_array_class() != Class::null());
+ return object_store->external_int8_array_class();
+ case kExternalUint8Array:
+ ASSERT(object_store->external_uint8_array_class() != Class::null());
+ return object_store->external_uint8_array_class();
+ case kExternalInt16Array:
+ ASSERT(object_store->external_int16_array_class() != Class::null());
+ return object_store->external_int16_array_class();
+ case kExternalUint16Array:
+ ASSERT(object_store->external_uint16_array_class() != Class::null());
+ return object_store->external_uint16_array_class();
+ case kExternalInt32Array:
+ ASSERT(object_store->external_int32_array_class() != Class::null());
+ return object_store->external_int32_array_class();
+ case kExternalUint32Array:
+ ASSERT(object_store->external_uint32_array_class() != Class::null());
+ return object_store->external_uint32_array_class();
+ case kExternalInt64Array:
+ ASSERT(object_store->external_int64_array_class() != Class::null());
+ return object_store->external_int64_array_class();
+ case kExternalUint64Array:
+ ASSERT(object_store->external_uint64_array_class() != Class::null());
+ return object_store->external_uint64_array_class();
+ case kExternalFloat32Array:
+ ASSERT(object_store->external_float32_array_class() != Class::null());
+ return object_store->external_float32_array_class();
+ case kExternalFloat64Array:
+ ASSERT(object_store->external_float64_array_class() != Class::null());
+ return object_store->external_float64_array_class();
case kStacktrace:
ASSERT(object_store->stacktrace_class() != Class::null());
return object_store->stacktrace_class();
@@ -8939,18 +9138,11 @@ const char* GrowableObjectArray::ToCString() const {
}
-intptr_t ByteArray::Length() const {
- // ByteArray is an abstract class.
- UNREACHABLE();
- return 0;
-}
-
-
-void ByteArray::Copy(uint8_t* dst,
+void ByteArray::Copy(void* dst,
const ByteArray& src,
intptr_t src_offset,
intptr_t length) {
- ASSERT(Utils::RangeCheck(src_offset, length, src.Length()));
+ ASSERT(Utils::RangeCheck(src_offset, length, src.ByteLength()));
{
NoGCScope no_gc;
if (length > 0) {
@@ -8962,9 +9154,9 @@ void ByteArray::Copy(uint8_t* dst,
void ByteArray::Copy(const ByteArray& dst,
intptr_t dst_offset,
- const uint8_t* src,
+ const void* src,
intptr_t length) {
- ASSERT(Utils::RangeCheck(dst_offset, length, dst.Length()));
+ ASSERT(Utils::RangeCheck(dst_offset, length, dst.ByteLength()));
{
NoGCScope no_gc;
if (length > 0) {
@@ -8979,8 +9171,8 @@ void ByteArray::Copy(const ByteArray& dst,
const ByteArray& src,
intptr_t src_offset,
intptr_t length) {
- ASSERT(Utils::RangeCheck(src_offset, length, src.Length()));
- ASSERT(Utils::RangeCheck(dst_offset, length, dst.Length()));
+ ASSERT(Utils::RangeCheck(src_offset, length, src.ByteLength()));
+ ASSERT(Utils::RangeCheck(dst_offset, length, dst.ByteLength()));
{
NoGCScope no_gc;
if (length > 0) {
@@ -8990,6 +9182,42 @@ void ByteArray::Copy(const ByteArray& dst,
}
+template<typename T>
+static void ExternalByteArrayFinalize(Dart_Handle handle, void* peer) {
+ delete reinterpret_cast<ExternalByteArrayData<T>*>(peer);
+ DeleteWeakPersistentHandle(handle);
+}
+
+
+template<typename HandleT, typename RawT, typename ElementT>
+RawT* ByteArray::NewExternalImpl(const Class& cls,
+ ElementT* data,
+ intptr_t len,
+ void* peer,
+ Dart_PeerFinalizer callback,
+ Heap::Space space) {
+ HandleT& result = HandleT::Handle();
+ ExternalByteArrayData<ElementT>* external_data =
+ new ExternalByteArrayData<ElementT>(data, peer, callback);
+ {
+ RawObject* raw = Object::Allocate(cls, HandleT::InstanceSize(), space);
+ NoGCScope no_gc;
+ result ^= raw;
+ result.SetLength(len);
+ result.SetExternalData(external_data);
+ }
+ AddFinalizer(result, external_data, ExternalByteArrayFinalize<ElementT>);
+ return result.raw();
+}
+
+
+intptr_t ByteArray::ByteLength() const {
+ // ByteArray is an abstract class.
+ UNREACHABLE();
+ return 0;
+}
+
+
uint8_t* ByteArray::ByteAddr(intptr_t byte_offset) const {
// ByteArray is an abstract class.
UNREACHABLE();
@@ -9004,83 +9232,452 @@ const char* ByteArray::ToCString() const {
}
-RawInternalByteArray* InternalByteArray::New(intptr_t len,
- Heap::Space space) {
- Isolate* isolate = Isolate::Current();
- const Class& internal_byte_array_class =
- Class::Handle(isolate->object_store()->internal_byte_array_class());
- InternalByteArray& result = InternalByteArray::Handle();
+template<typename HandleT, typename RawT>
+RawT* ByteArray::NewImpl(const Class& cls, intptr_t len, Heap::Space space) {
+ HandleT& result = HandleT::Handle();
{
- RawObject* raw = Object::Allocate(internal_byte_array_class,
- InternalByteArray::InstanceSize(len),
- space);
+ RawObject* raw = Object::Allocate(cls, HandleT::InstanceSize(len), space);
NoGCScope no_gc;
result ^= raw;
result.SetLength(len);
if (len > 0) {
- memset(result.Addr<uint8_t>(0), 0, len);
+ memset(result.ByteAddr(0), 0, result.ByteLength());
}
}
return result.raw();
}
-RawInternalByteArray* InternalByteArray::New(const uint8_t* data,
- intptr_t len,
- Heap::Space space) {
- InternalByteArray& result =
- InternalByteArray::Handle(InternalByteArray::New(len, space));
+template<typename HandleT, typename RawT, typename ElementT>
+RawT* ByteArray::NewImpl(const Class& cls,
+ const ElementT* data,
+ intptr_t len,
+ Heap::Space space) {
+ HandleT& result = HandleT::Handle();
{
+ RawObject* raw = Object::Allocate(cls, HandleT::InstanceSize(len), space);
NoGCScope no_gc;
+ result ^= raw;
+ result.SetLength(len);
if (len > 0) {
- memmove(result.Addr<uint8_t>(0), data, len);
+ memmove(result.ByteAddr(0), data, result.ByteLength());
}
}
return result.raw();
}
-const char* InternalByteArray::ToCString() const {
- return "_InternalByteArray";
+RawInt8Array* Int8Array::New(intptr_t len, Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->int8_array_class());
+ return NewImpl<Int8Array, RawInt8Array>(cls, len, space);
}
-void ExternalByteArray::Finalize(Dart_Handle handle, void* peer) {
- delete reinterpret_cast<ExternalByteArrayData*>(peer);
- DeleteWeakPersistentHandle(handle);
+RawInt8Array* Int8Array::New(const int8_t* data,
+ intptr_t len,
+ Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->int8_array_class());
+ return NewImpl<Int8Array, RawInt8Array>(cls, data, len, space);
+}
+
+
+const char* Int8Array::ToCString() const {
+ return "_Int8Array";
+}
+
+
+RawUint8Array* Uint8Array::New(intptr_t len, Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->uint8_array_class());
+ return NewImpl<Uint8Array, RawUint8Array>(cls, len, space);
+}
+
+
+RawUint8Array* Uint8Array::New(const uint8_t* data,
+ intptr_t len,
+ Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->uint8_array_class());
+ return NewImpl<Uint8Array, RawUint8Array>(cls, data, len, space);
+}
+
+
+const char* Uint8Array::ToCString() const {
+ return "_Uint8Array";
+}
+
+
+RawInt16Array* Int16Array::New(intptr_t len, Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->int16_array_class());
+ return NewImpl<Int16Array, RawInt16Array>(cls, len, space);
+}
+
+
+RawInt16Array* Int16Array::New(const int16_t* data,
+ intptr_t len,
+ Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->int16_array_class());
+ return NewImpl<Int16Array, RawInt16Array>(cls, data, len, space);
+}
+
+
+const char* Int16Array::ToCString() const {
+ return "_Int16Array";
+}
+
+
+RawUint16Array* Uint16Array::New(intptr_t len, Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->uint16_array_class());
+ return NewImpl<Uint16Array, RawUint16Array>(cls, len, space);
+}
+
+
+RawUint16Array* Uint16Array::New(const uint16_t* data,
+ intptr_t len,
+ Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->uint16_array_class());
+ return NewImpl<Uint16Array, RawUint16Array>(cls, data, len, space);
+}
+
+
+const char* Uint16Array::ToCString() const {
+ return "_Uint16Array";
+}
+
+
+RawInt32Array* Int32Array::New(intptr_t len, Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->int32_array_class());
+ return NewImpl<Int32Array, RawInt32Array>(cls, len, space);
+}
+
+
+RawInt32Array* Int32Array::New(const int32_t* data,
+ intptr_t len,
+ Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->int32_array_class());
+ return NewImpl<Int32Array, RawInt32Array>(cls, data, len, space);
+}
+
+
+const char* Int32Array::ToCString() const {
+ return "_Int32Array";
}
-RawExternalByteArray* ExternalByteArray::New(uint8_t* data,
+RawUint32Array* Uint32Array::New(intptr_t len, Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->uint32_array_class());
+ return NewImpl<Uint32Array, RawUint32Array>(cls, len, space);
+}
+
+
+RawUint32Array* Uint32Array::New(const uint32_t* data,
+ intptr_t len,
+ Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->uint32_array_class());
+ return NewImpl<Uint32Array, RawUint32Array>(cls, data, len, space);
+}
+
+
+const char* Uint32Array::ToCString() const {
+ return "_Uint32Array";
+}
+
+
+RawInt64Array* Int64Array::New(intptr_t len, Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->int64_array_class());
+ return NewImpl<Int64Array, RawInt64Array>(cls, len, space);
+}
+
+
+RawInt64Array* Int64Array::New(const int64_t* data,
+ intptr_t len,
+ Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->int64_array_class());
+ return NewImpl<Int64Array, RawInt64Array>(cls, data, len, space);
+}
+
+
+const char* Int64Array::ToCString() const {
+ return "_Int64Array";
+}
+
+
+RawUint64Array* Uint64Array::New(intptr_t len, Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->uint64_array_class());
+ return NewImpl<Uint64Array, RawUint64Array>(cls, len, space);
+}
+
+
+RawUint64Array* Uint64Array::New(const uint64_t* data,
+ intptr_t len,
+ Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->uint64_array_class());
+ return NewImpl<Uint64Array, RawUint64Array>(cls, data, len, space);
+}
+
+
+const char* Uint64Array::ToCString() const {
+ return "_Uint64Array";
+}
+
+
+RawFloat32Array* Float32Array::New(intptr_t len, Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->float32_array_class());
+ return NewImpl<Float32Array, RawFloat32Array>(cls, len, space);
+}
+
+
+RawFloat32Array* Float32Array::New(const float* data,
+ intptr_t len,
+ Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->float32_array_class());
+ return NewImpl<Float32Array, RawFloat32Array>(cls, data, len, space);
+}
+
+
+const char* Float32Array::ToCString() const {
+ return "_Float32Array";
+}
+
+
+RawFloat64Array* Float64Array::New(intptr_t len, Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->float64_array_class());
+ return NewImpl<Float64Array, RawFloat64Array>(cls, len, space);
+}
+
+
+RawFloat64Array* Float64Array::New(const double* data,
+ intptr_t len,
+ Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->float64_array_class());
+ return NewImpl<Float64Array, RawFloat64Array>(cls, data, len, space);
+}
+
+
+const char* Float64Array::ToCString() const {
+ return "_Float64Array";
+}
+
+
+RawExternalInt8Array* ExternalInt8Array::New(int8_t* data,
intptr_t len,
void* peer,
Dart_PeerFinalizer callback,
Heap::Space space) {
Isolate* isolate = Isolate::Current();
- const Class& external_byte_array_class =
- Class::Handle(isolate->object_store()->external_byte_array_class());
- ExternalByteArray& result = ExternalByteArray::Handle();
- ExternalByteArrayData* external_data =
- new ExternalByteArrayData(data, peer, callback);
- {
- RawObject* raw = Object::Allocate(external_byte_array_class,
- ExternalByteArray::InstanceSize(),
- space);
- NoGCScope no_gc;
- result ^= raw;
- result.SetLength(len);
- result.SetExternalData(external_data);
- }
- AddFinalizer(result, external_data, ExternalByteArray::Finalize);
- return result.raw();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->external_int8_array_class());
+ return NewExternalImpl<ExternalInt8Array, RawExternalInt8Array>(
+ cls, data, len, peer, callback, space);
+}
+
+
+const char* ExternalInt8Array::ToCString() const {
+ return "_ExternalInt8Array";
+}
+
+
+RawExternalUint8Array* ExternalUint8Array::New(uint8_t* data,
+ intptr_t len,
+ void* peer,
+ Dart_PeerFinalizer callback,
+ Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->external_uint8_array_class());
+ return NewExternalImpl<ExternalUint8Array, RawExternalUint8Array>(
+ cls, data, len, peer, callback, space);
+}
+
+
+const char* ExternalUint8Array::ToCString() const {
+ return "_ExternalUint8Array";
+}
+
+
+RawExternalInt16Array* ExternalInt16Array::New(int16_t* data,
+ intptr_t len,
+ void* peer,
+ Dart_PeerFinalizer callback,
+ Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->external_int16_array_class());
+ return NewExternalImpl<ExternalInt16Array, RawExternalInt16Array>(
+ cls, data, len, peer, callback, space);
+}
+
+
+const char* ExternalInt16Array::ToCString() const {
+ return "_ExternalInt16Array";
+}
+
+
+RawExternalUint16Array* ExternalUint16Array::New(uint16_t* data,
+ intptr_t len,
+ void* peer,
+ Dart_PeerFinalizer callback,
+ Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->external_uint16_array_class());
+ return NewExternalImpl<ExternalUint16Array, RawExternalUint16Array>(
+ cls, data, len, peer, callback, space);
+}
+
+
+const char* ExternalUint16Array::ToCString() const {
+ return "_ExternalUint16Array";
+}
+
+
+RawExternalInt32Array* ExternalInt32Array::New(int32_t* data,
+ intptr_t len,
+ void* peer,
+ Dart_PeerFinalizer callback,
+ Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->external_int32_array_class());
+ return NewExternalImpl<ExternalInt32Array, RawExternalInt32Array>(
+ cls, data, len, peer, callback, space);
+}
+
+
+const char* ExternalInt32Array::ToCString() const {
+ return "_ExternalInt32Array";
+}
+
+
+RawExternalUint32Array* ExternalUint32Array::New(uint32_t* data,
+ intptr_t len,
+ void* peer,
+ Dart_PeerFinalizer callback,
+ Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->external_uint32_array_class());
+ return NewExternalImpl<ExternalUint32Array, RawExternalUint32Array>(
+ cls, data, len, peer, callback, space);
+}
+
+
+const char* ExternalUint32Array::ToCString() const {
+ return "_ExternalUint32Array";
+}
+
+
+RawExternalInt64Array* ExternalInt64Array::New(int64_t* data,
+ intptr_t len,
+ void* peer,
+ Dart_PeerFinalizer callback,
+ Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->external_int64_array_class());
+ return NewExternalImpl<ExternalInt64Array, RawExternalInt64Array>(
+ cls, data, len, peer, callback, space);
+}
+
+
+const char* ExternalInt64Array::ToCString() const {
+ return "_ExternalInt64Array";
}
-const char* ExternalByteArray::ToCString() const {
- return "_ExternalByteArray";
+RawExternalUint64Array* ExternalUint64Array::New(uint64_t* data,
+ intptr_t len,
+ void* peer,
+ Dart_PeerFinalizer callback,
+ Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->external_uint64_array_class());
+ return NewExternalImpl<ExternalUint64Array, RawExternalUint64Array>(
+ cls, data, len, peer, callback, space);
}
+const char* ExternalUint64Array::ToCString() const {
+ return "_ExternalUint64Array";
+}
+
+
+RawExternalFloat32Array* ExternalFloat32Array::New(float* data,
+ intptr_t len,
+ void* peer,
+ Dart_PeerFinalizer callback,
+ Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->external_float32_array_class());
+ return NewExternalImpl<ExternalFloat32Array, RawExternalFloat32Array>(
+ cls, data, len, peer, callback, space);
+}
+
+
+const char* ExternalFloat32Array::ToCString() const {
+ return "_ExternalFloat32Array";
+}
+
+
+RawExternalFloat64Array* ExternalFloat64Array::New(double* data,
+ intptr_t len,
+ void* peer,
+ Dart_PeerFinalizer callback,
+ Heap::Space space) {
+ Isolate* isolate = Isolate::Current();
+ const Class& cls =
+ Class::Handle(isolate->object_store()->external_float64_array_class());
+ return NewExternalImpl<ExternalFloat64Array, RawExternalFloat64Array>(
+ cls, data, len, peer, callback, space);
+}
+
+
+const char* ExternalFloat64Array::ToCString() const {
+ return "_ExternalFloat64Array";
+}
+
+
+
RawClosure* Closure::New(const Function& function,
const Context& context,
Heap::Space space) {
« runtime/include/dart_api.h ('K') | « runtime/vm/object.h ('k') | runtime/vm/object_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698