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

Unified Diff: runtime/vm/object.cc

Issue 148043003: Add Float64x2, Float64x2List, etc... with runtime and dart2js implementations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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 c5c9a41a7c8bf599b55cbacf8cfe9111149761ad..705432359fd6c69e77ac47798387c0acb18ed3d5 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -1189,6 +1189,9 @@ RawError* Object::Init(Isolate* isolate) {
cls = Class::New<Int32x4>();
object_store->set_int32x4_class(cls);
RegisterPrivateClass(cls, Symbols::_Int32x4(), lib);
+ cls = Class::New<Float64x2>();
+ object_store->set_float64x2_class(cls);
+ RegisterPrivateClass(cls, Symbols::_Float64x2(), lib);
cls = Class::New<Instance>(kIllegalCid);
RegisterClass(cls, Symbols::Float32x4(), lib);
@@ -1208,6 +1211,15 @@ RawError* Object::Init(Isolate* isolate) {
type = Type::NewNonParameterizedType(cls);
object_store->set_int32x4_type(type);
+ cls = Class::New<Instance>(kIllegalCid);
+ RegisterClass(cls, Symbols::Float64x2(), lib);
+ cls.set_num_type_arguments(0);
+ cls.set_num_own_type_arguments(0);
+ cls.set_is_prefinalized();
+ pending_classes.Add(cls);
+ type = Type::NewNonParameterizedType(cls);
+ object_store->set_float64x2_type(type);
+
object_store->set_typed_data_classes(typed_data_classes);
// Set the super type of class Stacktrace to Object type so that the
@@ -1348,6 +1360,9 @@ void Object::InitFromSnapshot(Isolate* isolate) {
cls = Class::New<Int32x4>();
object_store->set_int32x4_class(cls);
+ cls = Class::New<Float64x2>();
+ object_store->set_float64x2_class(cls);
+
#define REGISTER_TYPED_DATA_CLASS(clazz) \
cls = Class::NewTypedDataClass(kTypedData##clazz##Cid);
CLASS_LIST_TYPED_DATA(REGISTER_TYPED_DATA_CLASS);
@@ -16366,7 +16381,7 @@ RawFloat32x4* Float32x4::New(float v0, float v1, float v2, float v3,
RawFloat32x4* Float32x4::New(simd128_value_t value, Heap::Space space) {
-ASSERT(Isolate::Current()->object_store()->float32x4_class() !=
+ ASSERT(Isolate::Current()->object_store()->float32x4_class() !=
Class::null());
Float32x4& result = Float32x4::Handle();
{
@@ -16555,6 +16570,86 @@ void Int32x4::PrintToJSONStream(JSONStream* stream, bool ref) const {
}
+RawFloat64x2* Float64x2::New(double value0, double value1, Heap::Space space) {
+ ASSERT(Isolate::Current()->object_store()->float64x2_class() !=
+ Class::null());
+ Float64x2& result = Float64x2::Handle();
+ {
+ RawObject* raw = Object::Allocate(Float64x2::kClassId,
+ Float64x2::InstanceSize(),
+ space);
+ NoGCScope no_gc;
+ result ^= raw;
+ }
+ result.set_x(value0);
+ result.set_y(value1);
+ return result.raw();
+}
+
+
+RawFloat64x2* Float64x2::New(simd128_value_t value, Heap::Space space) {
+ ASSERT(Isolate::Current()->object_store()->float64x2_class() !=
+ Class::null());
+ Float64x2& result = Float64x2::Handle();
+ {
+ RawObject* raw = Object::Allocate(Float64x2::kClassId,
+ Float64x2::InstanceSize(),
+ space);
+ NoGCScope no_gc;
+ result ^= raw;
+ }
+ result.set_value(value);
+ return result.raw();
+}
+
+
+double Float64x2::x() const {
+ return raw_ptr()->value_[0];
+}
+
+
+double Float64x2::y() const {
+ return raw_ptr()->value_[1];
+}
+
+
+void Float64x2::set_x(double x) const {
+ raw_ptr()->value_[0] = x;
+}
+
+
+void Float64x2::set_y(double y) const {
+ raw_ptr()->value_[1] = y;
+}
+
+
+simd128_value_t Float64x2::value() const {
+ return simd128_value_t().readFrom(&raw_ptr()->value_[0]);
+}
+
+
+void Float64x2::set_value(simd128_value_t value) const {
+ value.writeTo(&raw_ptr()->value_[0]);
+}
+
+
+const char* Float64x2::ToCString() const {
+ const char* kFormat = "[%f, %f]";
+ double _x = x();
+ double _y = y();
+ // Calculate the size of the string.
+ intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y) + 1;
+ char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
+ OS::SNPrint(chars, len, kFormat, _x, _y);
+ return chars;
+}
+
+
+void Float64x2::PrintToJSONStream(JSONStream* stream, bool ref) const {
+ Instance::PrintToJSONStream(stream, ref);
+}
+
+
const intptr_t TypedData::element_size[] = {
1, // kTypedDataInt8ArrayCid.
1, // kTypedDataUint8ArrayCid.
@@ -16569,6 +16664,7 @@ const intptr_t TypedData::element_size[] = {
8, // kTypedDataFloat64ArrayCid.
16, // kTypedDataFloat32x4ArrayCid.
16, // kTypedDataInt32x4ArrayCid.
+ 16, // kTypedDataFloat64x2ArrayCid,
};

Powered by Google App Engine
This is Rietveld 408576698