| OLD | NEW |
| 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/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
| (...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1182 | 1182 |
| 1183 CLASS_LIST_TYPED_DATA(REGISTER_EXT_TYPED_DATA_CLASS); | 1183 CLASS_LIST_TYPED_DATA(REGISTER_EXT_TYPED_DATA_CLASS); |
| 1184 #undef REGISTER_EXT_TYPED_DATA_CLASS | 1184 #undef REGISTER_EXT_TYPED_DATA_CLASS |
| 1185 // Register Float32x4 and Int32x4 in the object store. | 1185 // Register Float32x4 and Int32x4 in the object store. |
| 1186 cls = Class::New<Float32x4>(); | 1186 cls = Class::New<Float32x4>(); |
| 1187 object_store->set_float32x4_class(cls); | 1187 object_store->set_float32x4_class(cls); |
| 1188 RegisterPrivateClass(cls, Symbols::_Float32x4(), lib); | 1188 RegisterPrivateClass(cls, Symbols::_Float32x4(), lib); |
| 1189 cls = Class::New<Int32x4>(); | 1189 cls = Class::New<Int32x4>(); |
| 1190 object_store->set_int32x4_class(cls); | 1190 object_store->set_int32x4_class(cls); |
| 1191 RegisterPrivateClass(cls, Symbols::_Int32x4(), lib); | 1191 RegisterPrivateClass(cls, Symbols::_Int32x4(), lib); |
| 1192 cls = Class::New<Float64x2>(); |
| 1193 object_store->set_float64x2_class(cls); |
| 1194 RegisterPrivateClass(cls, Symbols::_Float64x2(), lib); |
| 1192 | 1195 |
| 1193 cls = Class::New<Instance>(kIllegalCid); | 1196 cls = Class::New<Instance>(kIllegalCid); |
| 1194 RegisterClass(cls, Symbols::Float32x4(), lib); | 1197 RegisterClass(cls, Symbols::Float32x4(), lib); |
| 1195 cls.set_num_type_arguments(0); | 1198 cls.set_num_type_arguments(0); |
| 1196 cls.set_num_own_type_arguments(0); | 1199 cls.set_num_own_type_arguments(0); |
| 1197 cls.set_is_prefinalized(); | 1200 cls.set_is_prefinalized(); |
| 1198 pending_classes.Add(cls); | 1201 pending_classes.Add(cls); |
| 1199 type = Type::NewNonParameterizedType(cls); | 1202 type = Type::NewNonParameterizedType(cls); |
| 1200 object_store->set_float32x4_type(type); | 1203 object_store->set_float32x4_type(type); |
| 1201 | 1204 |
| 1202 cls = Class::New<Instance>(kIllegalCid); | 1205 cls = Class::New<Instance>(kIllegalCid); |
| 1203 RegisterClass(cls, Symbols::Int32x4(), lib); | 1206 RegisterClass(cls, Symbols::Int32x4(), lib); |
| 1204 cls.set_num_type_arguments(0); | 1207 cls.set_num_type_arguments(0); |
| 1205 cls.set_num_own_type_arguments(0); | 1208 cls.set_num_own_type_arguments(0); |
| 1206 cls.set_is_prefinalized(); | 1209 cls.set_is_prefinalized(); |
| 1207 pending_classes.Add(cls); | 1210 pending_classes.Add(cls); |
| 1208 type = Type::NewNonParameterizedType(cls); | 1211 type = Type::NewNonParameterizedType(cls); |
| 1209 object_store->set_int32x4_type(type); | 1212 object_store->set_int32x4_type(type); |
| 1210 | 1213 |
| 1214 cls = Class::New<Instance>(kIllegalCid); |
| 1215 RegisterClass(cls, Symbols::Float64x2(), lib); |
| 1216 cls.set_num_type_arguments(0); |
| 1217 cls.set_num_own_type_arguments(0); |
| 1218 cls.set_is_prefinalized(); |
| 1219 pending_classes.Add(cls); |
| 1220 type = Type::NewNonParameterizedType(cls); |
| 1221 object_store->set_float64x2_type(type); |
| 1222 |
| 1211 object_store->set_typed_data_classes(typed_data_classes); | 1223 object_store->set_typed_data_classes(typed_data_classes); |
| 1212 | 1224 |
| 1213 // Set the super type of class Stacktrace to Object type so that the | 1225 // Set the super type of class Stacktrace to Object type so that the |
| 1214 // 'toString' method is implemented. | 1226 // 'toString' method is implemented. |
| 1215 cls = object_store->stacktrace_class(); | 1227 cls = object_store->stacktrace_class(); |
| 1216 type = object_store->object_type(); | 1228 type = object_store->object_type(); |
| 1217 cls.set_super_type(type); | 1229 cls.set_super_type(type); |
| 1218 | 1230 |
| 1219 // Abstract class that represents the Dart class Function. | 1231 // Abstract class that represents the Dart class Function. |
| 1220 cls = Class::New<Instance>(kIllegalCid); | 1232 cls = Class::New<Instance>(kIllegalCid); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1341 | 1353 |
| 1342 cls = Class::New<GrowableObjectArray>(); | 1354 cls = Class::New<GrowableObjectArray>(); |
| 1343 object_store->set_growable_object_array_class(cls); | 1355 object_store->set_growable_object_array_class(cls); |
| 1344 | 1356 |
| 1345 cls = Class::New<Float32x4>(); | 1357 cls = Class::New<Float32x4>(); |
| 1346 object_store->set_float32x4_class(cls); | 1358 object_store->set_float32x4_class(cls); |
| 1347 | 1359 |
| 1348 cls = Class::New<Int32x4>(); | 1360 cls = Class::New<Int32x4>(); |
| 1349 object_store->set_int32x4_class(cls); | 1361 object_store->set_int32x4_class(cls); |
| 1350 | 1362 |
| 1363 cls = Class::New<Float64x2>(); |
| 1364 object_store->set_float64x2_class(cls); |
| 1365 |
| 1351 #define REGISTER_TYPED_DATA_CLASS(clazz) \ | 1366 #define REGISTER_TYPED_DATA_CLASS(clazz) \ |
| 1352 cls = Class::NewTypedDataClass(kTypedData##clazz##Cid); | 1367 cls = Class::NewTypedDataClass(kTypedData##clazz##Cid); |
| 1353 CLASS_LIST_TYPED_DATA(REGISTER_TYPED_DATA_CLASS); | 1368 CLASS_LIST_TYPED_DATA(REGISTER_TYPED_DATA_CLASS); |
| 1354 #undef REGISTER_TYPED_DATA_CLASS | 1369 #undef REGISTER_TYPED_DATA_CLASS |
| 1355 #define REGISTER_TYPED_DATA_VIEW_CLASS(clazz) \ | 1370 #define REGISTER_TYPED_DATA_VIEW_CLASS(clazz) \ |
| 1356 cls = Class::NewTypedDataViewClass(kTypedData##clazz##ViewCid); | 1371 cls = Class::NewTypedDataViewClass(kTypedData##clazz##ViewCid); |
| 1357 CLASS_LIST_TYPED_DATA(REGISTER_TYPED_DATA_VIEW_CLASS); | 1372 CLASS_LIST_TYPED_DATA(REGISTER_TYPED_DATA_VIEW_CLASS); |
| 1358 cls = Class::NewTypedDataViewClass(kByteDataViewCid); | 1373 cls = Class::NewTypedDataViewClass(kByteDataViewCid); |
| 1359 #undef REGISTER_TYPED_DATA_VIEW_CLASS | 1374 #undef REGISTER_TYPED_DATA_VIEW_CLASS |
| 1360 #define REGISTER_EXT_TYPED_DATA_CLASS(clazz) \ | 1375 #define REGISTER_EXT_TYPED_DATA_CLASS(clazz) \ |
| (...skipping 14983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16344 } | 16359 } |
| 16345 result.set_x(v0); | 16360 result.set_x(v0); |
| 16346 result.set_y(v1); | 16361 result.set_y(v1); |
| 16347 result.set_z(v2); | 16362 result.set_z(v2); |
| 16348 result.set_w(v3); | 16363 result.set_w(v3); |
| 16349 return result.raw(); | 16364 return result.raw(); |
| 16350 } | 16365 } |
| 16351 | 16366 |
| 16352 | 16367 |
| 16353 RawFloat32x4* Float32x4::New(simd128_value_t value, Heap::Space space) { | 16368 RawFloat32x4* Float32x4::New(simd128_value_t value, Heap::Space space) { |
| 16354 ASSERT(Isolate::Current()->object_store()->float32x4_class() != | 16369 ASSERT(Isolate::Current()->object_store()->float32x4_class() != |
| 16355 Class::null()); | 16370 Class::null()); |
| 16356 Float32x4& result = Float32x4::Handle(); | 16371 Float32x4& result = Float32x4::Handle(); |
| 16357 { | 16372 { |
| 16358 RawObject* raw = Object::Allocate(Float32x4::kClassId, | 16373 RawObject* raw = Object::Allocate(Float32x4::kClassId, |
| 16359 Float32x4::InstanceSize(), | 16374 Float32x4::InstanceSize(), |
| 16360 space); | 16375 space); |
| 16361 NoGCScope no_gc; | 16376 NoGCScope no_gc; |
| 16362 result ^= raw; | 16377 result ^= raw; |
| 16363 } | 16378 } |
| 16364 result.set_value(value); | 16379 result.set_value(value); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16533 OS::SNPrint(chars, len, kFormat, _x, _y, _z, _w); | 16548 OS::SNPrint(chars, len, kFormat, _x, _y, _z, _w); |
| 16534 return chars; | 16549 return chars; |
| 16535 } | 16550 } |
| 16536 | 16551 |
| 16537 | 16552 |
| 16538 void Int32x4::PrintToJSONStream(JSONStream* stream, bool ref) const { | 16553 void Int32x4::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 16539 Instance::PrintToJSONStream(stream, ref); | 16554 Instance::PrintToJSONStream(stream, ref); |
| 16540 } | 16555 } |
| 16541 | 16556 |
| 16542 | 16557 |
| 16558 RawFloat64x2* Float64x2::New(double value0, double value1, Heap::Space space) { |
| 16559 ASSERT(Isolate::Current()->object_store()->float64x2_class() != |
| 16560 Class::null()); |
| 16561 Float64x2& result = Float64x2::Handle(); |
| 16562 { |
| 16563 RawObject* raw = Object::Allocate(Float64x2::kClassId, |
| 16564 Float64x2::InstanceSize(), |
| 16565 space); |
| 16566 NoGCScope no_gc; |
| 16567 result ^= raw; |
| 16568 } |
| 16569 result.set_x(value0); |
| 16570 result.set_y(value1); |
| 16571 return result.raw(); |
| 16572 } |
| 16573 |
| 16574 |
| 16575 RawFloat64x2* Float64x2::New(simd128_value_t value, Heap::Space space) { |
| 16576 ASSERT(Isolate::Current()->object_store()->float64x2_class() != |
| 16577 Class::null()); |
| 16578 Float64x2& result = Float64x2::Handle(); |
| 16579 { |
| 16580 RawObject* raw = Object::Allocate(Float64x2::kClassId, |
| 16581 Float64x2::InstanceSize(), |
| 16582 space); |
| 16583 NoGCScope no_gc; |
| 16584 result ^= raw; |
| 16585 } |
| 16586 result.set_value(value); |
| 16587 return result.raw(); |
| 16588 } |
| 16589 |
| 16590 |
| 16591 double Float64x2::x() const { |
| 16592 return raw_ptr()->value_[0]; |
| 16593 } |
| 16594 |
| 16595 |
| 16596 double Float64x2::y() const { |
| 16597 return raw_ptr()->value_[1]; |
| 16598 } |
| 16599 |
| 16600 |
| 16601 void Float64x2::set_x(double x) const { |
| 16602 raw_ptr()->value_[0] = x; |
| 16603 } |
| 16604 |
| 16605 |
| 16606 void Float64x2::set_y(double y) const { |
| 16607 raw_ptr()->value_[1] = y; |
| 16608 } |
| 16609 |
| 16610 |
| 16611 simd128_value_t Float64x2::value() const { |
| 16612 return simd128_value_t().readFrom(&raw_ptr()->value_[0]); |
| 16613 } |
| 16614 |
| 16615 |
| 16616 void Float64x2::set_value(simd128_value_t value) const { |
| 16617 value.writeTo(&raw_ptr()->value_[0]); |
| 16618 } |
| 16619 |
| 16620 |
| 16621 const char* Float64x2::ToCString() const { |
| 16622 const char* kFormat = "[%f, %f]"; |
| 16623 double _x = x(); |
| 16624 double _y = y(); |
| 16625 // Calculate the size of the string. |
| 16626 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y) + 1; |
| 16627 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 16628 OS::SNPrint(chars, len, kFormat, _x, _y); |
| 16629 return chars; |
| 16630 } |
| 16631 |
| 16632 |
| 16633 void Float64x2::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 16634 Instance::PrintToJSONStream(stream, ref); |
| 16635 } |
| 16636 |
| 16637 |
| 16543 const intptr_t TypedData::element_size[] = { | 16638 const intptr_t TypedData::element_size[] = { |
| 16544 1, // kTypedDataInt8ArrayCid. | 16639 1, // kTypedDataInt8ArrayCid. |
| 16545 1, // kTypedDataUint8ArrayCid. | 16640 1, // kTypedDataUint8ArrayCid. |
| 16546 1, // kTypedDataUint8ClampedArrayCid. | 16641 1, // kTypedDataUint8ClampedArrayCid. |
| 16547 2, // kTypedDataInt16ArrayCid. | 16642 2, // kTypedDataInt16ArrayCid. |
| 16548 2, // kTypedDataUint16ArrayCid. | 16643 2, // kTypedDataUint16ArrayCid. |
| 16549 4, // kTypedDataInt32ArrayCid. | 16644 4, // kTypedDataInt32ArrayCid. |
| 16550 4, // kTypedDataUint32ArrayCid. | 16645 4, // kTypedDataUint32ArrayCid. |
| 16551 8, // kTypedDataInt64ArrayCid. | 16646 8, // kTypedDataInt64ArrayCid. |
| 16552 8, // kTypedDataUint64ArrayCid. | 16647 8, // kTypedDataUint64ArrayCid. |
| 16553 4, // kTypedDataFloat32ArrayCid. | 16648 4, // kTypedDataFloat32ArrayCid. |
| 16554 8, // kTypedDataFloat64ArrayCid. | 16649 8, // kTypedDataFloat64ArrayCid. |
| 16555 16, // kTypedDataFloat32x4ArrayCid. | 16650 16, // kTypedDataFloat32x4ArrayCid. |
| 16556 16, // kTypedDataInt32x4ArrayCid. | 16651 16, // kTypedDataInt32x4ArrayCid. |
| 16652 16, // kTypedDataFloat64x2ArrayCid, |
| 16557 }; | 16653 }; |
| 16558 | 16654 |
| 16559 | 16655 |
| 16560 RawTypedData* TypedData::New(intptr_t class_id, | 16656 RawTypedData* TypedData::New(intptr_t class_id, |
| 16561 intptr_t len, | 16657 intptr_t len, |
| 16562 Heap::Space space) { | 16658 Heap::Space space) { |
| 16563 if (len < 0 || len > TypedData::MaxElements(class_id)) { | 16659 if (len < 0 || len > TypedData::MaxElements(class_id)) { |
| 16564 FATAL1("Fatal error in TypedData::New: invalid len %" Pd "\n", len); | 16660 FATAL1("Fatal error in TypedData::New: invalid len %" Pd "\n", len); |
| 16565 } | 16661 } |
| 16566 TypedData& result = TypedData::Handle(); | 16662 TypedData& result = TypedData::Handle(); |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17098 return "_MirrorReference"; | 17194 return "_MirrorReference"; |
| 17099 } | 17195 } |
| 17100 | 17196 |
| 17101 | 17197 |
| 17102 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 17198 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 17103 Instance::PrintToJSONStream(stream, ref); | 17199 Instance::PrintToJSONStream(stream, ref); |
| 17104 } | 17200 } |
| 17105 | 17201 |
| 17106 | 17202 |
| 17107 } // namespace dart | 17203 } // namespace dart |
| OLD | NEW |