| 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 14998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16359 } | 16374 } |
| 16360 result.set_x(v0); | 16375 result.set_x(v0); |
| 16361 result.set_y(v1); | 16376 result.set_y(v1); |
| 16362 result.set_z(v2); | 16377 result.set_z(v2); |
| 16363 result.set_w(v3); | 16378 result.set_w(v3); |
| 16364 return result.raw(); | 16379 return result.raw(); |
| 16365 } | 16380 } |
| 16366 | 16381 |
| 16367 | 16382 |
| 16368 RawFloat32x4* Float32x4::New(simd128_value_t value, Heap::Space space) { | 16383 RawFloat32x4* Float32x4::New(simd128_value_t value, Heap::Space space) { |
| 16369 ASSERT(Isolate::Current()->object_store()->float32x4_class() != | 16384 ASSERT(Isolate::Current()->object_store()->float32x4_class() != |
| 16370 Class::null()); | 16385 Class::null()); |
| 16371 Float32x4& result = Float32x4::Handle(); | 16386 Float32x4& result = Float32x4::Handle(); |
| 16372 { | 16387 { |
| 16373 RawObject* raw = Object::Allocate(Float32x4::kClassId, | 16388 RawObject* raw = Object::Allocate(Float32x4::kClassId, |
| 16374 Float32x4::InstanceSize(), | 16389 Float32x4::InstanceSize(), |
| 16375 space); | 16390 space); |
| 16376 NoGCScope no_gc; | 16391 NoGCScope no_gc; |
| 16377 result ^= raw; | 16392 result ^= raw; |
| 16378 } | 16393 } |
| 16379 result.set_value(value); | 16394 result.set_value(value); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16548 OS::SNPrint(chars, len, kFormat, _x, _y, _z, _w); | 16563 OS::SNPrint(chars, len, kFormat, _x, _y, _z, _w); |
| 16549 return chars; | 16564 return chars; |
| 16550 } | 16565 } |
| 16551 | 16566 |
| 16552 | 16567 |
| 16553 void Int32x4::PrintToJSONStream(JSONStream* stream, bool ref) const { | 16568 void Int32x4::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 16554 Instance::PrintToJSONStream(stream, ref); | 16569 Instance::PrintToJSONStream(stream, ref); |
| 16555 } | 16570 } |
| 16556 | 16571 |
| 16557 | 16572 |
| 16573 RawFloat64x2* Float64x2::New(double value0, double value1, Heap::Space space) { |
| 16574 ASSERT(Isolate::Current()->object_store()->float64x2_class() != |
| 16575 Class::null()); |
| 16576 Float64x2& result = Float64x2::Handle(); |
| 16577 { |
| 16578 RawObject* raw = Object::Allocate(Float64x2::kClassId, |
| 16579 Float64x2::InstanceSize(), |
| 16580 space); |
| 16581 NoGCScope no_gc; |
| 16582 result ^= raw; |
| 16583 } |
| 16584 result.set_x(value0); |
| 16585 result.set_y(value1); |
| 16586 return result.raw(); |
| 16587 } |
| 16588 |
| 16589 |
| 16590 RawFloat64x2* Float64x2::New(simd128_value_t value, Heap::Space space) { |
| 16591 ASSERT(Isolate::Current()->object_store()->float64x2_class() != |
| 16592 Class::null()); |
| 16593 Float64x2& result = Float64x2::Handle(); |
| 16594 { |
| 16595 RawObject* raw = Object::Allocate(Float64x2::kClassId, |
| 16596 Float64x2::InstanceSize(), |
| 16597 space); |
| 16598 NoGCScope no_gc; |
| 16599 result ^= raw; |
| 16600 } |
| 16601 result.set_value(value); |
| 16602 return result.raw(); |
| 16603 } |
| 16604 |
| 16605 |
| 16606 double Float64x2::x() const { |
| 16607 return raw_ptr()->value_[0]; |
| 16608 } |
| 16609 |
| 16610 |
| 16611 double Float64x2::y() const { |
| 16612 return raw_ptr()->value_[1]; |
| 16613 } |
| 16614 |
| 16615 |
| 16616 void Float64x2::set_x(double x) const { |
| 16617 raw_ptr()->value_[0] = x; |
| 16618 } |
| 16619 |
| 16620 |
| 16621 void Float64x2::set_y(double y) const { |
| 16622 raw_ptr()->value_[1] = y; |
| 16623 } |
| 16624 |
| 16625 |
| 16626 simd128_value_t Float64x2::value() const { |
| 16627 return simd128_value_t().readFrom(&raw_ptr()->value_[0]); |
| 16628 } |
| 16629 |
| 16630 |
| 16631 void Float64x2::set_value(simd128_value_t value) const { |
| 16632 value.writeTo(&raw_ptr()->value_[0]); |
| 16633 } |
| 16634 |
| 16635 |
| 16636 const char* Float64x2::ToCString() const { |
| 16637 const char* kFormat = "[%f, %f]"; |
| 16638 double _x = x(); |
| 16639 double _y = y(); |
| 16640 // Calculate the size of the string. |
| 16641 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y) + 1; |
| 16642 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 16643 OS::SNPrint(chars, len, kFormat, _x, _y); |
| 16644 return chars; |
| 16645 } |
| 16646 |
| 16647 |
| 16648 void Float64x2::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 16649 Instance::PrintToJSONStream(stream, ref); |
| 16650 } |
| 16651 |
| 16652 |
| 16558 const intptr_t TypedData::element_size[] = { | 16653 const intptr_t TypedData::element_size[] = { |
| 16559 1, // kTypedDataInt8ArrayCid. | 16654 1, // kTypedDataInt8ArrayCid. |
| 16560 1, // kTypedDataUint8ArrayCid. | 16655 1, // kTypedDataUint8ArrayCid. |
| 16561 1, // kTypedDataUint8ClampedArrayCid. | 16656 1, // kTypedDataUint8ClampedArrayCid. |
| 16562 2, // kTypedDataInt16ArrayCid. | 16657 2, // kTypedDataInt16ArrayCid. |
| 16563 2, // kTypedDataUint16ArrayCid. | 16658 2, // kTypedDataUint16ArrayCid. |
| 16564 4, // kTypedDataInt32ArrayCid. | 16659 4, // kTypedDataInt32ArrayCid. |
| 16565 4, // kTypedDataUint32ArrayCid. | 16660 4, // kTypedDataUint32ArrayCid. |
| 16566 8, // kTypedDataInt64ArrayCid. | 16661 8, // kTypedDataInt64ArrayCid. |
| 16567 8, // kTypedDataUint64ArrayCid. | 16662 8, // kTypedDataUint64ArrayCid. |
| 16568 4, // kTypedDataFloat32ArrayCid. | 16663 4, // kTypedDataFloat32ArrayCid. |
| 16569 8, // kTypedDataFloat64ArrayCid. | 16664 8, // kTypedDataFloat64ArrayCid. |
| 16570 16, // kTypedDataFloat32x4ArrayCid. | 16665 16, // kTypedDataFloat32x4ArrayCid. |
| 16571 16, // kTypedDataInt32x4ArrayCid. | 16666 16, // kTypedDataInt32x4ArrayCid. |
| 16667 16, // kTypedDataFloat64x2ArrayCid, |
| 16572 }; | 16668 }; |
| 16573 | 16669 |
| 16574 | 16670 |
| 16575 RawTypedData* TypedData::New(intptr_t class_id, | 16671 RawTypedData* TypedData::New(intptr_t class_id, |
| 16576 intptr_t len, | 16672 intptr_t len, |
| 16577 Heap::Space space) { | 16673 Heap::Space space) { |
| 16578 if (len < 0 || len > TypedData::MaxElements(class_id)) { | 16674 if (len < 0 || len > TypedData::MaxElements(class_id)) { |
| 16579 FATAL1("Fatal error in TypedData::New: invalid len %" Pd "\n", len); | 16675 FATAL1("Fatal error in TypedData::New: invalid len %" Pd "\n", len); |
| 16580 } | 16676 } |
| 16581 TypedData& result = TypedData::Handle(); | 16677 TypedData& result = TypedData::Handle(); |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17113 return "_MirrorReference"; | 17209 return "_MirrorReference"; |
| 17114 } | 17210 } |
| 17115 | 17211 |
| 17116 | 17212 |
| 17117 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 17213 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 17118 Instance::PrintToJSONStream(stream, ref); | 17214 Instance::PrintToJSONStream(stream, ref); |
| 17119 } | 17215 } |
| 17120 | 17216 |
| 17121 | 17217 |
| 17122 } // namespace dart | 17218 } // namespace dart |
| OLD | NEW |