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

Side by Side Diff: dart/runtime/vm/object.cc

Issue 59073003: Version 0.8.10.4 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dart/runtime/vm/object.h ('k') | dart/runtime/vm/object_store.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 class_class_ = reinterpret_cast<RawClass*>(address + kHeapObjectTag); 473 class_class_ = reinterpret_cast<RawClass*>(address + kHeapObjectTag);
474 InitializeObject(address, Class::kClassId, size); 474 InitializeObject(address, Class::kClassId, size);
475 475
476 Class fake; 476 Class fake;
477 // Initialization from Class::New<Class>. 477 // Initialization from Class::New<Class>.
478 // Directly set raw_ to break a circular dependency: SetRaw will attempt 478 // Directly set raw_ to break a circular dependency: SetRaw will attempt
479 // to lookup class class in the class table where it is not registered yet. 479 // to lookup class class in the class table where it is not registered yet.
480 cls.raw_ = class_class_; 480 cls.raw_ = class_class_;
481 cls.set_handle_vtable(fake.vtable()); 481 cls.set_handle_vtable(fake.vtable());
482 cls.set_instance_size(Class::InstanceSize()); 482 cls.set_instance_size(Class::InstanceSize());
483 cls.set_next_field_offset(Class::InstanceSize()); 483 cls.set_next_field_offset(Class::NextFieldOffset());
484 cls.set_id(Class::kClassId); 484 cls.set_id(Class::kClassId);
485 cls.set_state_bits(0); 485 cls.set_state_bits(0);
486 cls.set_is_finalized(); 486 cls.set_is_finalized();
487 cls.set_is_type_finalized(); 487 cls.set_is_type_finalized();
488 cls.set_type_arguments_field_offset_in_words(Class::kNoTypeArguments); 488 cls.set_type_arguments_field_offset_in_words(Class::kNoTypeArguments);
489 cls.set_num_type_arguments(0); 489 cls.set_num_type_arguments(0);
490 cls.set_num_own_type_arguments(0); 490 cls.set_num_own_type_arguments(0);
491 cls.set_num_native_fields(0); 491 cls.set_num_native_fields(0);
492 cls.InitEmptyFields(); 492 cls.InitEmptyFields();
493 isolate->RegisterClass(cls); 493 isolate->RegisterClass(cls);
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 pending_classes.Add(cls); 1141 pending_classes.Add(cls);
1142 #undef REGISTER_TYPED_DATA_VIEW_CLASS 1142 #undef REGISTER_TYPED_DATA_VIEW_CLASS
1143 #define REGISTER_EXT_TYPED_DATA_CLASS(clazz) \ 1143 #define REGISTER_EXT_TYPED_DATA_CLASS(clazz) \
1144 cls = Class::NewExternalTypedDataClass(kExternalTypedData##clazz##Cid); \ 1144 cls = Class::NewExternalTypedDataClass(kExternalTypedData##clazz##Cid); \
1145 index = kExternalTypedData##clazz##Cid - kTypedDataInt8ArrayCid; \ 1145 index = kExternalTypedData##clazz##Cid - kTypedDataInt8ArrayCid; \
1146 typed_data_classes.SetAt(index, cls); \ 1146 typed_data_classes.SetAt(index, cls); \
1147 RegisterPrivateClass(cls, Symbols::_External##clazz(), lib); \ 1147 RegisterPrivateClass(cls, Symbols::_External##clazz(), lib); \
1148 1148
1149 CLASS_LIST_TYPED_DATA(REGISTER_EXT_TYPED_DATA_CLASS); 1149 CLASS_LIST_TYPED_DATA(REGISTER_EXT_TYPED_DATA_CLASS);
1150 #undef REGISTER_EXT_TYPED_DATA_CLASS 1150 #undef REGISTER_EXT_TYPED_DATA_CLASS
1151 // Register Float32x4 and Uint32x4 in the object store. 1151 // Register Float32x4 and Int32x4 in the object store.
1152 cls = Class::New<Float32x4>(); 1152 cls = Class::New<Float32x4>();
1153 object_store->set_float32x4_class(cls); 1153 object_store->set_float32x4_class(cls);
1154 RegisterPrivateClass(cls, Symbols::_Float32x4(), lib); 1154 RegisterPrivateClass(cls, Symbols::_Float32x4(), lib);
1155 cls = Class::New<Uint32x4>(); 1155 cls = Class::New<Int32x4>();
1156 object_store->set_uint32x4_class(cls); 1156 object_store->set_int32x4_class(cls);
1157 RegisterPrivateClass(cls, Symbols::_Uint32x4(), lib); 1157 RegisterPrivateClass(cls, Symbols::_Int32x4(), lib);
1158 1158
1159 cls = Class::New<Instance>(kIllegalCid); 1159 cls = Class::New<Instance>(kIllegalCid);
1160 RegisterClass(cls, Symbols::Float32x4(), lib); 1160 RegisterClass(cls, Symbols::Float32x4(), lib);
1161 cls.set_num_type_arguments(0); 1161 cls.set_num_type_arguments(0);
1162 cls.set_num_own_type_arguments(0); 1162 cls.set_num_own_type_arguments(0);
1163 cls.set_is_prefinalized(); 1163 cls.set_is_prefinalized();
1164 pending_classes.Add(cls); 1164 pending_classes.Add(cls);
1165 type = Type::NewNonParameterizedType(cls); 1165 type = Type::NewNonParameterizedType(cls);
1166 object_store->set_float32x4_type(type); 1166 object_store->set_float32x4_type(type);
1167 1167
1168 cls = Class::New<Instance>(kIllegalCid); 1168 cls = Class::New<Instance>(kIllegalCid);
1169 RegisterClass(cls, Symbols::Uint32x4(), lib); 1169 RegisterClass(cls, Symbols::Int32x4(), lib);
1170 cls.set_num_type_arguments(0); 1170 cls.set_num_type_arguments(0);
1171 cls.set_num_own_type_arguments(0); 1171 cls.set_num_own_type_arguments(0);
1172 cls.set_is_prefinalized(); 1172 cls.set_is_prefinalized();
1173 pending_classes.Add(cls); 1173 pending_classes.Add(cls);
1174 type = Type::NewNonParameterizedType(cls); 1174 type = Type::NewNonParameterizedType(cls);
1175 object_store->set_uint32x4_type(type); 1175 object_store->set_int32x4_type(type);
1176 1176
1177 object_store->set_typed_data_classes(typed_data_classes); 1177 object_store->set_typed_data_classes(typed_data_classes);
1178 1178
1179 // Set the super type of class Stacktrace to Object type so that the 1179 // Set the super type of class Stacktrace to Object type so that the
1180 // 'toString' method is implemented. 1180 // 'toString' method is implemented.
1181 cls = object_store->stacktrace_class(); 1181 cls = object_store->stacktrace_class();
1182 type = object_store->object_type(); 1182 type = object_store->object_type();
1183 cls.set_super_type(type); 1183 cls.set_super_type(type);
1184 1184
1185 // Abstract class that represents the Dart class Function. 1185 // Abstract class that represents the Dart class Function.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 1301
1302 cls = Class::New<Array>(kImmutableArrayCid); 1302 cls = Class::New<Array>(kImmutableArrayCid);
1303 object_store->set_immutable_array_class(cls); 1303 object_store->set_immutable_array_class(cls);
1304 1304
1305 cls = Class::New<GrowableObjectArray>(); 1305 cls = Class::New<GrowableObjectArray>();
1306 object_store->set_growable_object_array_class(cls); 1306 object_store->set_growable_object_array_class(cls);
1307 1307
1308 cls = Class::New<Float32x4>(); 1308 cls = Class::New<Float32x4>();
1309 object_store->set_float32x4_class(cls); 1309 object_store->set_float32x4_class(cls);
1310 1310
1311 cls = Class::New<Uint32x4>(); 1311 cls = Class::New<Int32x4>();
1312 object_store->set_uint32x4_class(cls); 1312 object_store->set_int32x4_class(cls);
1313 1313
1314 #define REGISTER_TYPED_DATA_CLASS(clazz) \ 1314 #define REGISTER_TYPED_DATA_CLASS(clazz) \
1315 cls = Class::NewTypedDataClass(kTypedData##clazz##Cid); 1315 cls = Class::NewTypedDataClass(kTypedData##clazz##Cid);
1316 CLASS_LIST_TYPED_DATA(REGISTER_TYPED_DATA_CLASS); 1316 CLASS_LIST_TYPED_DATA(REGISTER_TYPED_DATA_CLASS);
1317 #undef REGISTER_TYPED_DATA_CLASS 1317 #undef REGISTER_TYPED_DATA_CLASS
1318 #define REGISTER_TYPED_DATA_VIEW_CLASS(clazz) \ 1318 #define REGISTER_TYPED_DATA_VIEW_CLASS(clazz) \
1319 cls = Class::NewTypedDataViewClass(kTypedData##clazz##ViewCid); 1319 cls = Class::NewTypedDataViewClass(kTypedData##clazz##ViewCid);
1320 CLASS_LIST_TYPED_DATA(REGISTER_TYPED_DATA_VIEW_CLASS); 1320 CLASS_LIST_TYPED_DATA(REGISTER_TYPED_DATA_VIEW_CLASS);
1321 cls = Class::NewTypedDataViewClass(kByteDataViewCid); 1321 cls = Class::NewTypedDataViewClass(kByteDataViewCid);
1322 #undef REGISTER_TYPED_DATA_VIEW_CLASS 1322 #undef REGISTER_TYPED_DATA_VIEW_CLASS
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 case kTwoByteStringCid: 1527 case kTwoByteStringCid:
1528 case kExternalOneByteStringCid: 1528 case kExternalOneByteStringCid:
1529 case kExternalTwoByteStringCid: 1529 case kExternalTwoByteStringCid:
1530 return Symbols::New("String"); 1530 return Symbols::New("String");
1531 case kArrayCid: 1531 case kArrayCid:
1532 case kImmutableArrayCid: 1532 case kImmutableArrayCid:
1533 case kGrowableObjectArrayCid: 1533 case kGrowableObjectArrayCid:
1534 return Symbols::List().raw(); 1534 return Symbols::List().raw();
1535 case kFloat32x4Cid: 1535 case kFloat32x4Cid:
1536 return Symbols::Float32x4().raw(); 1536 return Symbols::Float32x4().raw();
1537 case kUint32x4Cid: 1537 case kInt32x4Cid:
1538 return Symbols::Uint32x4().raw(); 1538 return Symbols::Int32x4().raw();
1539 case kTypedDataInt8ArrayCid: 1539 case kTypedDataInt8ArrayCid:
1540 case kExternalTypedDataInt8ArrayCid: 1540 case kExternalTypedDataInt8ArrayCid:
1541 return Symbols::Int8List().raw(); 1541 return Symbols::Int8List().raw();
1542 case kTypedDataUint8ArrayCid: 1542 case kTypedDataUint8ArrayCid:
1543 case kExternalTypedDataUint8ArrayCid: 1543 case kExternalTypedDataUint8ArrayCid:
1544 return Symbols::Uint8List().raw(); 1544 return Symbols::Uint8List().raw();
1545 case kTypedDataUint8ClampedArrayCid: 1545 case kTypedDataUint8ClampedArrayCid:
1546 case kExternalTypedDataUint8ClampedArrayCid: 1546 case kExternalTypedDataUint8ClampedArrayCid:
1547 return Symbols::Uint8ClampedList().raw(); 1547 return Symbols::Uint8ClampedList().raw();
1548 case kTypedDataInt16ArrayCid: 1548 case kTypedDataInt16ArrayCid:
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1655 { 1655 {
1656 RawObject* raw = Object::Allocate(Class::kClassId, 1656 RawObject* raw = Object::Allocate(Class::kClassId,
1657 Class::InstanceSize(), 1657 Class::InstanceSize(),
1658 Heap::kOld); 1658 Heap::kOld);
1659 NoGCScope no_gc; 1659 NoGCScope no_gc;
1660 result ^= raw; 1660 result ^= raw;
1661 } 1661 }
1662 FakeObject fake; 1662 FakeObject fake;
1663 result.set_handle_vtable(fake.vtable()); 1663 result.set_handle_vtable(fake.vtable());
1664 result.set_instance_size(FakeObject::InstanceSize()); 1664 result.set_instance_size(FakeObject::InstanceSize());
1665 result.set_next_field_offset(FakeObject::InstanceSize()); 1665 result.set_next_field_offset(FakeObject::NextFieldOffset());
1666 ASSERT((FakeObject::kClassId != kInstanceCid)); 1666 ASSERT((FakeObject::kClassId != kInstanceCid));
1667 result.set_id(FakeObject::kClassId); 1667 result.set_id(FakeObject::kClassId);
1668 result.set_state_bits(0); 1668 result.set_state_bits(0);
1669 // VM backed classes are almost ready: run checks and resolve class 1669 // VM backed classes are almost ready: run checks and resolve class
1670 // references, but do not recompute size. 1670 // references, but do not recompute size.
1671 result.set_is_prefinalized(); 1671 result.set_is_prefinalized();
1672 result.set_type_arguments_field_offset_in_words(kNoTypeArguments); 1672 result.set_type_arguments_field_offset_in_words(kNoTypeArguments);
1673 result.set_num_type_arguments(0); 1673 result.set_num_type_arguments(0);
1674 result.set_num_own_type_arguments(0); 1674 result.set_num_own_type_arguments(0);
1675 result.set_num_native_fields(0); 1675 result.set_num_native_fields(0);
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
2025 return TypeParameter::null(); 2025 return TypeParameter::null();
2026 } 2026 }
2027 2027
2028 2028
2029 void Class::CalculateFieldOffsets() const { 2029 void Class::CalculateFieldOffsets() const {
2030 Array& flds = Array::Handle(fields()); 2030 Array& flds = Array::Handle(fields());
2031 const Class& super = Class::Handle(SuperClass()); 2031 const Class& super = Class::Handle(SuperClass());
2032 intptr_t offset = 0; 2032 intptr_t offset = 0;
2033 intptr_t type_args_field_offset = kNoTypeArguments; 2033 intptr_t type_args_field_offset = kNoTypeArguments;
2034 if (super.IsNull()) { 2034 if (super.IsNull()) {
2035 offset = sizeof(RawObject); 2035 offset = Instance::NextFieldOffset();
2036 ASSERT(offset > 0);
2036 } else { 2037 } else {
2037 ASSERT(super.is_finalized() || super.is_prefinalized()); 2038 ASSERT(super.is_finalized() || super.is_prefinalized());
2038 type_args_field_offset = super.type_arguments_field_offset(); 2039 type_args_field_offset = super.type_arguments_field_offset();
2039 offset = super.next_field_offset(); 2040 offset = super.next_field_offset();
2040 ASSERT(offset > 0); 2041 ASSERT(offset > 0);
2041 // We should never call CalculateFieldOffsets for native wrapper 2042 // We should never call CalculateFieldOffsets for native wrapper
2042 // classes, assert this. 2043 // classes, assert this.
2043 ASSERT(num_native_fields() == 0); 2044 ASSERT(num_native_fields() == 0);
2044 set_num_native_fields(super.num_native_fields()); 2045 set_num_native_fields(super.num_native_fields());
2045 } 2046 }
2046 // If the super class is parameterized, use the same type_arguments field, 2047 // If the super class is parameterized, use the same type_arguments field,
2047 // otherwise, if this class is the first in the super chain to be 2048 // otherwise, if this class is the first in the super chain to be
2048 // parameterized, introduce a new type_arguments field. 2049 // parameterized, introduce a new type_arguments field.
2049 if (type_args_field_offset == kNoTypeArguments) { 2050 if (type_args_field_offset == kNoTypeArguments) {
2050 const TypeArguments& type_params = TypeArguments::Handle(type_parameters()); 2051 const TypeArguments& type_params = TypeArguments::Handle(type_parameters());
2051 if (!type_params.IsNull()) { 2052 if (!type_params.IsNull()) {
2052 ASSERT(type_params.Length() > 0); 2053 ASSERT(type_params.Length() > 0);
2053 // The instance needs a type_arguments field. 2054 // The instance needs a type_arguments field.
2054 type_args_field_offset = offset; 2055 type_args_field_offset = offset;
2055 offset += kWordSize; 2056 offset += kWordSize;
2056 } 2057 }
2057 } 2058 }
2058 set_type_arguments_field_offset(type_args_field_offset); 2059 set_type_arguments_field_offset(type_args_field_offset);
2059 ASSERT(offset != 0); 2060 ASSERT(offset > 0);
2060 Field& field = Field::Handle(); 2061 Field& field = Field::Handle();
2061 intptr_t len = flds.Length(); 2062 intptr_t len = flds.Length();
2062 for (intptr_t i = 0; i < len; i++) { 2063 for (intptr_t i = 0; i < len; i++) {
2063 field ^= flds.At(i); 2064 field ^= flds.At(i);
2064 // Offset is computed only for instance fields. 2065 // Offset is computed only for instance fields.
2065 if (!field.is_static()) { 2066 if (!field.is_static()) {
2066 ASSERT(field.Offset() == 0); 2067 ASSERT(field.Offset() == 0);
2067 field.SetOffset(offset); 2068 field.SetOffset(offset);
2068 offset += kWordSize; 2069 offset += kWordSize;
2069 } 2070 }
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
2387 RawObject* raw = Object::Allocate(Class::kClassId, 2388 RawObject* raw = Object::Allocate(Class::kClassId,
2388 Class::InstanceSize(), 2389 Class::InstanceSize(),
2389 Heap::kOld); 2390 Heap::kOld);
2390 NoGCScope no_gc; 2391 NoGCScope no_gc;
2391 result ^= raw; 2392 result ^= raw;
2392 } 2393 }
2393 FakeInstance fake; 2394 FakeInstance fake;
2394 ASSERT(fake.IsInstance()); 2395 ASSERT(fake.IsInstance());
2395 result.set_handle_vtable(fake.vtable()); 2396 result.set_handle_vtable(fake.vtable());
2396 result.set_instance_size(FakeInstance::InstanceSize()); 2397 result.set_instance_size(FakeInstance::InstanceSize());
2397 result.set_next_field_offset(FakeInstance::InstanceSize()); 2398 result.set_next_field_offset(FakeInstance::NextFieldOffset());
2398 result.set_id(index); 2399 result.set_id(index);
2399 result.set_state_bits(0); 2400 result.set_state_bits(0);
2400 result.set_type_arguments_field_offset_in_words(kNoTypeArguments); 2401 result.set_type_arguments_field_offset_in_words(kNoTypeArguments);
2401 result.set_num_type_arguments(kUnknownNumTypeArguments); 2402 result.set_num_type_arguments(kUnknownNumTypeArguments);
2402 result.set_num_own_type_arguments(kUnknownNumTypeArguments); 2403 result.set_num_own_type_arguments(kUnknownNumTypeArguments);
2403 result.set_num_native_fields(0); 2404 result.set_num_native_fields(0);
2404 result.set_token_pos(Scanner::kDummyTokenIndex); 2405 result.set_token_pos(Scanner::kDummyTokenIndex);
2405 result.InitEmptyFields(); 2406 result.InitEmptyFields();
2406 Isolate::Current()->RegisterClass(result); 2407 Isolate::Current()->RegisterClass(result);
2407 return result.raw(); 2408 return result.raw();
(...skipping 11 matching lines...) Expand all
2419 } 2420 }
2420 2421
2421 2422
2422 RawClass* Class::NewSignatureClass(const String& name, 2423 RawClass* Class::NewSignatureClass(const String& name,
2423 const Function& signature_function, 2424 const Function& signature_function,
2424 const Script& script, 2425 const Script& script,
2425 intptr_t token_pos) { 2426 intptr_t token_pos) {
2426 const Class& result = Class::Handle(New(name, script, token_pos)); 2427 const Class& result = Class::Handle(New(name, script, token_pos));
2427 // Instances of a signature class can only be closures. 2428 // Instances of a signature class can only be closures.
2428 result.set_instance_size(Closure::InstanceSize()); 2429 result.set_instance_size(Closure::InstanceSize());
2429 result.set_next_field_offset(Closure::InstanceSize()); 2430 result.set_next_field_offset(Closure::NextFieldOffset());
2430 // Signature classes extend the _FunctionImpl class. 2431 // Signature classes extend the _FunctionImpl class.
2431 result.set_super_type(Type::Handle( 2432 result.set_super_type(Type::Handle(
2432 Isolate::Current()->object_store()->function_impl_type())); 2433 Isolate::Current()->object_store()->function_impl_type()));
2433 result.set_is_synthesized_class(); 2434 result.set_is_synthesized_class();
2434 result.set_type_arguments_field_offset(Closure::type_arguments_offset()); 2435 result.set_type_arguments_field_offset(Closure::type_arguments_offset());
2435 if (!signature_function.IsNull()) { 2436 if (!signature_function.IsNull()) {
2436 result.PatchSignatureFunction(signature_function); 2437 result.PatchSignatureFunction(signature_function);
2437 } 2438 }
2438 return result.raw(); 2439 return result.raw();
2439 } 2440 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2491 int field_count) { 2492 int field_count) {
2492 Class& cls = Class::Handle(library.LookupClass(name)); 2493 Class& cls = Class::Handle(library.LookupClass(name));
2493 if (cls.IsNull()) { 2494 if (cls.IsNull()) {
2494 cls = New(name, Script::Handle(), Scanner::kDummyTokenIndex); 2495 cls = New(name, Script::Handle(), Scanner::kDummyTokenIndex);
2495 cls.SetFields(Object::empty_array()); 2496 cls.SetFields(Object::empty_array());
2496 cls.SetFunctions(Object::empty_array()); 2497 cls.SetFunctions(Object::empty_array());
2497 // Set super class to Object. 2498 // Set super class to Object.
2498 cls.set_super_type(Type::Handle(Type::ObjectType())); 2499 cls.set_super_type(Type::Handle(Type::ObjectType()));
2499 // Compute instance size. First word contains a pointer to a properly 2500 // Compute instance size. First word contains a pointer to a properly
2500 // sized typed array once the first native field has been set. 2501 // sized typed array once the first native field has been set.
2501 intptr_t instance_size = sizeof(RawObject) + kWordSize; 2502 intptr_t instance_size = sizeof(RawInstance) + kWordSize;
2502 cls.set_instance_size(RoundedAllocationSize(instance_size)); 2503 cls.set_instance_size(RoundedAllocationSize(instance_size));
2503 cls.set_next_field_offset(instance_size); 2504 cls.set_next_field_offset(instance_size);
2504 cls.set_num_native_fields(field_count); 2505 cls.set_num_native_fields(field_count);
2505 cls.set_is_finalized(); 2506 cls.set_is_finalized();
2506 cls.set_is_type_finalized(); 2507 cls.set_is_type_finalized();
2507 library.AddClass(cls); 2508 library.AddClass(cls);
2508 return cls.raw(); 2509 return cls.raw();
2509 } else { 2510 } else {
2510 return Class::null(); 2511 return Class::null();
2511 } 2512 }
2512 } 2513 }
2513 2514
2514 2515
2515 RawClass* Class::NewStringClass(intptr_t class_id) { 2516 RawClass* Class::NewStringClass(intptr_t class_id) {
2516 intptr_t instance_size; 2517 intptr_t instance_size;
2517 if (class_id == kOneByteStringCid) { 2518 if (class_id == kOneByteStringCid) {
2518 instance_size = OneByteString::InstanceSize(); 2519 instance_size = OneByteString::InstanceSize();
2519 } else if (class_id == kTwoByteStringCid) { 2520 } else if (class_id == kTwoByteStringCid) {
2520 instance_size = TwoByteString::InstanceSize(); 2521 instance_size = TwoByteString::InstanceSize();
2521 } else if (class_id == kExternalOneByteStringCid) { 2522 } else if (class_id == kExternalOneByteStringCid) {
2522 instance_size = ExternalOneByteString::InstanceSize(); 2523 instance_size = ExternalOneByteString::InstanceSize();
2523 } else { 2524 } else {
2524 ASSERT(class_id == kExternalTwoByteStringCid); 2525 ASSERT(class_id == kExternalTwoByteStringCid);
2525 instance_size = ExternalTwoByteString::InstanceSize(); 2526 instance_size = ExternalTwoByteString::InstanceSize();
2526 } 2527 }
2527 Class& result = Class::Handle(New<String>(class_id)); 2528 Class& result = Class::Handle(New<String>(class_id));
2528 result.set_instance_size(instance_size); 2529 result.set_instance_size(instance_size);
2529 result.set_next_field_offset(instance_size); 2530 result.set_next_field_offset(String::NextFieldOffset());
2530 result.set_is_prefinalized(); 2531 result.set_is_prefinalized();
2531 return result.raw(); 2532 return result.raw();
2532 } 2533 }
2533 2534
2534 2535
2535 RawClass* Class::NewTypedDataClass(intptr_t class_id) { 2536 RawClass* Class::NewTypedDataClass(intptr_t class_id) {
2536 ASSERT(RawObject::IsTypedDataClassId(class_id)); 2537 ASSERT(RawObject::IsTypedDataClassId(class_id));
2537 intptr_t instance_size = TypedData::InstanceSize(); 2538 intptr_t instance_size = TypedData::InstanceSize();
2538 Class& result = Class::Handle(New<TypedData>(class_id)); 2539 Class& result = Class::Handle(New<TypedData>(class_id));
2539 result.set_instance_size(instance_size); 2540 result.set_instance_size(instance_size);
2540 result.set_next_field_offset(instance_size); 2541 result.set_next_field_offset(TypedData::NextFieldOffset());
2541 result.set_is_prefinalized(); 2542 result.set_is_prefinalized();
2542 return result.raw(); 2543 return result.raw();
2543 } 2544 }
2544 2545
2545 2546
2546 RawClass* Class::NewTypedDataViewClass(intptr_t class_id) { 2547 RawClass* Class::NewTypedDataViewClass(intptr_t class_id) {
2547 ASSERT(RawObject::IsTypedDataViewClassId(class_id)); 2548 ASSERT(RawObject::IsTypedDataViewClassId(class_id));
2548 Class& result = Class::Handle(New<Instance>(class_id)); 2549 Class& result = Class::Handle(New<Instance>(class_id));
2549 result.set_instance_size(0); 2550 result.set_instance_size(0);
2550 result.set_next_field_offset(0); 2551 result.set_next_field_offset(-kWordSize);
2551 return result.raw(); 2552 return result.raw();
2552 } 2553 }
2553 2554
2554 2555
2555 RawClass* Class::NewExternalTypedDataClass(intptr_t class_id) { 2556 RawClass* Class::NewExternalTypedDataClass(intptr_t class_id) {
2556 ASSERT(RawObject::IsExternalTypedDataClassId(class_id)); 2557 ASSERT(RawObject::IsExternalTypedDataClassId(class_id));
2557 intptr_t instance_size = ExternalTypedData::InstanceSize(); 2558 intptr_t instance_size = ExternalTypedData::InstanceSize();
2558 Class& result = Class::Handle(New<ExternalTypedData>(class_id)); 2559 Class& result = Class::Handle(New<ExternalTypedData>(class_id));
2559 result.set_instance_size(instance_size); 2560 result.set_instance_size(instance_size);
2560 result.set_next_field_offset(instance_size); 2561 result.set_next_field_offset(ExternalTypedData::NextFieldOffset());
2561 result.set_is_prefinalized(); 2562 result.set_is_prefinalized();
2562 return result.raw(); 2563 return result.raw();
2563 } 2564 }
2564 2565
2565 2566
2566 void Class::set_name(const String& value) const { 2567 void Class::set_name(const String& value) const {
2567 ASSERT(value.IsSymbol()); 2568 ASSERT(value.IsSymbol());
2568 StorePointer(&raw_ptr()->name_, value.raw()); 2569 StorePointer(&raw_ptr()->name_, value.raw());
2569 } 2570 }
2570 2571
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
2729 return (!function.IsNull() && (function.signature_class() == raw())); 2730 return (!function.IsNull() && (function.signature_class() == raw()));
2730 } 2731 }
2731 2732
2732 2733
2733 // If test_kind == kIsSubtypeOf, checks if type S is a subtype of type T. 2734 // If test_kind == kIsSubtypeOf, checks if type S is a subtype of type T.
2734 // If test_kind == kIsMoreSpecificThan, checks if S is more specific than T. 2735 // If test_kind == kIsMoreSpecificThan, checks if S is more specific than T.
2735 // Type S is specified by this class parameterized with 'type_arguments', and 2736 // Type S is specified by this class parameterized with 'type_arguments', and
2736 // type T by class 'other' parameterized with 'other_type_arguments'. 2737 // type T by class 'other' parameterized with 'other_type_arguments'.
2737 // This class and class 'other' do not need to be finalized, however, they must 2738 // This class and class 'other' do not need to be finalized, however, they must
2738 // be resolved as well as their interfaces. 2739 // be resolved as well as their interfaces.
2740 bool Class::TypeTestNonRecursive(
2741 const Class& cls,
2742 Class::TypeTestKind test_kind,
2743 const AbstractTypeArguments& type_arguments,
2744 const Class& other,
2745 const AbstractTypeArguments& other_type_arguments,
2746 Error* bound_error) {
2747 // Use the thsi object as if it was the receiver of this method, but instead
2748 // of recursing reset it to the super class and loop.
2749 Class& thsi = Class::Handle(cls.raw());
2750 while (true) {
2751 ASSERT(!thsi.IsVoidClass());
2752 // Check for DynamicType.
2753 // Each occurrence of DynamicType in type T is interpreted as the dynamic
2754 // type, a supertype of all types.
2755 if (other.IsDynamicClass()) {
2756 return true;
2757 }
2758 // In the case of a subtype test, each occurrence of DynamicType in type S
2759 // is interpreted as the bottom type, a subtype of all types.
2760 // However, DynamicType is not more specific than any type.
2761 if (thsi.IsDynamicClass()) {
2762 return test_kind == Class::kIsSubtypeOf;
2763 }
2764 // Check for NullType, which is only a subtype of ObjectType, of
2765 // DynamicType, or of itself, and which is more specific than any type.
2766 if (thsi.IsNullClass()) {
2767 // We already checked for other.IsDynamicClass() above.
2768 return (test_kind == Class::kIsMoreSpecificThan) ||
2769 other.IsObjectClass() || other.IsNullClass();
2770 }
2771 // Check for ObjectType. Any type that is not NullType or DynamicType
2772 // (already checked above), is more specific than ObjectType.
2773 if (other.IsObjectClass()) {
2774 return true;
2775 }
2776 // Check for reflexivity.
2777 if (thsi.raw() == other.raw()) {
2778 const intptr_t len = thsi.NumTypeArguments();
2779 if (len == 0) {
2780 return true;
2781 }
2782 // Since we do not truncate the type argument vector of a subclass (see
2783 // below), we only check a prefix of the proper length.
2784 // Check for covariance.
2785 if (other_type_arguments.IsNull() || other_type_arguments.IsRaw(len)) {
2786 return true;
2787 }
2788 if (type_arguments.IsNull() || type_arguments.IsRaw(len)) {
2789 // Other type can't be more specific than this one because for that
2790 // it would have to have all dynamic type arguments which is checked
2791 // above.
2792 return test_kind == Class::kIsSubtypeOf;
2793 }
2794 return type_arguments.TypeTest(test_kind,
2795 other_type_arguments,
2796 len,
2797 bound_error);
2798 }
2799 const bool other_is_function_class = other.IsFunctionClass();
2800 if (other.IsSignatureClass() || other_is_function_class) {
2801 const Function& other_fun = Function::Handle(other.signature_function());
2802 if (thsi.IsSignatureClass()) {
2803 if (other_is_function_class) {
2804 return true;
2805 }
2806 // Check for two function types.
2807 const Function& fun = Function::Handle(thsi.signature_function());
2808 return fun.TypeTest(test_kind,
2809 type_arguments,
2810 other_fun,
2811 other_type_arguments,
2812 bound_error);
2813 }
2814 // Check if type S has a call() method of function type T.
2815 Function& function =
2816 Function::Handle(thsi.LookupDynamicFunction(Symbols::Call()));
2817 if (function.IsNull()) {
2818 // Walk up the super_class chain.
2819 Class& cls = Class::Handle(thsi.SuperClass());
2820 while (!cls.IsNull() && function.IsNull()) {
2821 function = cls.LookupDynamicFunction(Symbols::Call());
2822 cls = cls.SuperClass();
2823 }
2824 }
2825 if (!function.IsNull()) {
2826 if (other_is_function_class ||
2827 function.TypeTest(test_kind,
2828 type_arguments,
2829 other_fun,
2830 other_type_arguments,
2831 bound_error)) {
2832 return true;
2833 }
2834 }
2835 }
2836 // Check for 'direct super type' specified in the implements clause
2837 // and check for transitivity at the same time.
2838 Array& interfaces = Array::Handle(thsi.interfaces());
2839 AbstractType& interface = AbstractType::Handle();
2840 Class& interface_class = Class::Handle();
2841 AbstractTypeArguments& interface_args = AbstractTypeArguments::Handle();
2842 Error& error = Error::Handle();
2843 for (intptr_t i = 0; i < interfaces.Length(); i++) {
2844 interface ^= interfaces.At(i);
2845 if (!interface.IsFinalized()) {
2846 // We may be checking bounds at finalization time. Skipping this
2847 // unfinalized interface will postpone bound checking to run time.
2848 continue;
2849 }
2850 error = Error::null();
2851 if (interface.IsMalboundedWithError(&error)) {
2852 // Return the first bound error to the caller if it requests it.
2853 if ((bound_error != NULL) && bound_error->IsNull()) {
2854 ASSERT(!error.IsNull());
2855 *bound_error = error.raw();
2856 }
2857 continue; // Another interface may work better.
2858 }
2859 interface_class = interface.type_class();
2860 interface_args = interface.arguments();
2861 if (!interface_args.IsNull() && !interface_args.IsInstantiated()) {
2862 // This type class implements an interface that is parameterized with
2863 // generic type(s), e.g. it implements List<T>.
2864 // The uninstantiated type T must be instantiated using the type
2865 // parameters of this type before performing the type test.
2866 // The type arguments of this type that are referred to by the type
2867 // parameters of the interface are at the end of the type vector,
2868 // after the type arguments of the super type of this type.
2869 // The index of the type parameters is adjusted upon finalization.
2870 error = Error::null();
2871 interface_args = interface_args.InstantiateFrom(type_arguments, &error);
2872 if (!error.IsNull()) {
2873 // Return the first bound error to the caller if it requests it.
2874 if ((bound_error != NULL) && bound_error->IsNull()) {
2875 *bound_error = error.raw();
2876 }
2877 continue; // Another interface may work better.
2878 }
2879 }
2880 if (interface_class.TypeTest(test_kind,
2881 interface_args,
2882 other,
2883 other_type_arguments,
2884 bound_error)) {
2885 return true;
2886 }
2887 }
2888 // "Recurse" up the class hierarchy until we have reached the top.
2889 thsi = thsi.SuperClass();
2890 if (thsi.IsNull()) {
2891 return false;
2892 }
2893 }
2894 UNREACHABLE();
2895 return false;
2896 }
2897
2898
2899 // If test_kind == kIsSubtypeOf, checks if type S is a subtype of type T.
2900 // If test_kind == kIsMoreSpecificThan, checks if S is more specific than T.
2901 // Type S is specified by this class parameterized with 'type_arguments', and
2902 // type T by class 'other' parameterized with 'other_type_arguments'.
2903 // This class and class 'other' do not need to be finalized, however, they must
2904 // be resolved as well as their interfaces.
2739 bool Class::TypeTest( 2905 bool Class::TypeTest(
2740 TypeTestKind test_kind, 2906 TypeTestKind test_kind,
2741 const AbstractTypeArguments& type_arguments, 2907 const AbstractTypeArguments& type_arguments,
2742 const Class& other, 2908 const Class& other,
2743 const AbstractTypeArguments& other_type_arguments, 2909 const AbstractTypeArguments& other_type_arguments,
2744 Error* bound_error) const { 2910 Error* bound_error) const {
2745 ASSERT(!IsVoidClass()); 2911 return TypeTestNonRecursive(*this,
2746 // Check for DynamicType. 2912 test_kind,
2747 // Each occurrence of DynamicType in type T is interpreted as the dynamic
2748 // type, a supertype of all types.
2749 if (other.IsDynamicClass()) {
2750 return true;
2751 }
2752 // In the case of a subtype test, each occurrence of DynamicType in type S is
2753 // interpreted as the bottom type, a subtype of all types.
2754 // However, DynamicType is not more specific than any type.
2755 if (IsDynamicClass()) {
2756 return test_kind == kIsSubtypeOf;
2757 }
2758 // Check for NullType, which is only a subtype of ObjectType, of DynamicType,
2759 // or of itself, and which is more specific than any type.
2760 if (IsNullClass()) {
2761 // We already checked for other.IsDynamicClass() above.
2762 return (test_kind == kIsMoreSpecificThan) ||
2763 other.IsObjectClass() || other.IsNullClass();
2764 }
2765 // Check for ObjectType. Any type that is not NullType or DynamicType (already
2766 // checked above), is more specific than ObjectType.
2767 if (other.IsObjectClass()) {
2768 return true;
2769 }
2770 // Check for reflexivity.
2771 if (raw() == other.raw()) {
2772 const intptr_t len = NumTypeArguments();
2773 if (len == 0) {
2774 return true;
2775 }
2776 // Since we do not truncate the type argument vector of a subclass (see
2777 // below), we only check a prefix of the proper length.
2778 // Check for covariance.
2779 if (other_type_arguments.IsNull() || other_type_arguments.IsRaw(len)) {
2780 return true;
2781 }
2782 if (type_arguments.IsNull() || type_arguments.IsRaw(len)) {
2783 // Other type can't be more specific than this one because for that
2784 // it would have to have all dynamic type arguments which is checked
2785 // above.
2786 return test_kind == kIsSubtypeOf;
2787 }
2788 return type_arguments.TypeTest(test_kind,
2789 other_type_arguments,
2790 len,
2791 bound_error);
2792 }
2793 const bool other_is_function_class = other.IsFunctionClass();
2794 if (other.IsSignatureClass() || other_is_function_class) {
2795 const Function& other_fun = Function::Handle(other.signature_function());
2796 if (IsSignatureClass()) {
2797 if (other_is_function_class) {
2798 return true;
2799 }
2800 // Check for two function types.
2801 const Function& fun = Function::Handle(signature_function());
2802 return fun.TypeTest(test_kind,
2803 type_arguments,
2804 other_fun,
2805 other_type_arguments,
2806 bound_error);
2807 }
2808 // Check if type S has a call() method of function type T.
2809 Function& function =
2810 Function::Handle(LookupDynamicFunction(Symbols::Call()));
2811 if (function.IsNull()) {
2812 // Walk up the super_class chain.
2813 Class& cls = Class::Handle(SuperClass());
2814 while (!cls.IsNull() && function.IsNull()) {
2815 function = cls.LookupDynamicFunction(Symbols::Call());
2816 cls = cls.SuperClass();
2817 }
2818 }
2819 if (!function.IsNull()) {
2820 if (other_is_function_class ||
2821 function.TypeTest(test_kind,
2822 type_arguments,
2823 other_fun,
2824 other_type_arguments,
2825 bound_error)) {
2826 return true;
2827 }
2828 }
2829 }
2830 // Check for 'direct super type' specified in the implements clause
2831 // and check for transitivity at the same time.
2832 Array& interfaces = Array::Handle(this->interfaces());
2833 AbstractType& interface = AbstractType::Handle();
2834 Class& interface_class = Class::Handle();
2835 AbstractTypeArguments& interface_args = AbstractTypeArguments::Handle();
2836 Error& error = Error::Handle();
2837 for (intptr_t i = 0; i < interfaces.Length(); i++) {
2838 interface ^= interfaces.At(i);
2839 if (!interface.IsFinalized()) {
2840 // We may be checking bounds at finalization time. Skipping this
2841 // unfinalized interface will postpone bound checking to run time.
2842 continue;
2843 }
2844 error = Error::null();
2845 if (interface.IsMalboundedWithError(&error)) {
2846 // Return the first bound error to the caller if it requests it.
2847 if ((bound_error != NULL) && bound_error->IsNull()) {
2848 ASSERT(!error.IsNull());
2849 *bound_error = error.raw();
2850 }
2851 continue; // Another interface may work better.
2852 }
2853 interface_class = interface.type_class();
2854 interface_args = interface.arguments();
2855 if (!interface_args.IsNull() && !interface_args.IsInstantiated()) {
2856 // This type class implements an interface that is parameterized with
2857 // generic type(s), e.g. it implements List<T>.
2858 // The uninstantiated type T must be instantiated using the type
2859 // parameters of this type before performing the type test.
2860 // The type arguments of this type that are referred to by the type
2861 // parameters of the interface are at the end of the type vector,
2862 // after the type arguments of the super type of this type.
2863 // The index of the type parameters is adjusted upon finalization.
2864 error = Error::null();
2865 interface_args = interface_args.InstantiateFrom(type_arguments, &error);
2866 if (!error.IsNull()) {
2867 // Return the first bound error to the caller if it requests it.
2868 if ((bound_error != NULL) && bound_error->IsNull()) {
2869 *bound_error = error.raw();
2870 }
2871 continue; // Another interface may work better.
2872 }
2873 }
2874 if (interface_class.TypeTest(test_kind,
2875 interface_args,
2876 other,
2877 other_type_arguments,
2878 bound_error)) {
2879 return true;
2880 }
2881 }
2882 const Class& super_class = Class::Handle(SuperClass());
2883 if (super_class.IsNull()) {
2884 return false;
2885 }
2886 // Instead of truncating the type argument vector to the length of the super
2887 // type argument vector, we make sure that the code works with a vector that
2888 // is longer than necessary.
2889 return super_class.TypeTest(test_kind,
2890 type_arguments, 2913 type_arguments,
2891 other, 2914 other,
2892 other_type_arguments, 2915 other_type_arguments,
2893 bound_error); 2916 bound_error);
2894 } 2917 }
2895 2918
2896 2919
2897 bool Class::IsTopLevel() const { 2920 bool Class::IsTopLevel() const {
2898 return Name() == Symbols::TopLevel().raw(); 2921 return Name() == Symbols::TopLevel().raw();
2899 } 2922 }
(...skipping 7922 matching lines...) Expand 10 before | Expand all | Expand 10 after
10822 return false; 10845 return false;
10823 } 10846 }
10824 10847
10825 { 10848 {
10826 NoGCScope no_gc; 10849 NoGCScope no_gc;
10827 // Raw bits compare. 10850 // Raw bits compare.
10828 const intptr_t instance_size = Class::Handle(this->clazz()).instance_size(); 10851 const intptr_t instance_size = Class::Handle(this->clazz()).instance_size();
10829 ASSERT(instance_size != 0); 10852 ASSERT(instance_size != 0);
10830 uword this_addr = reinterpret_cast<uword>(this->raw_ptr()); 10853 uword this_addr = reinterpret_cast<uword>(this->raw_ptr());
10831 uword other_addr = reinterpret_cast<uword>(other.raw_ptr()); 10854 uword other_addr = reinterpret_cast<uword>(other.raw_ptr());
10832 for (intptr_t offset = sizeof(RawObject); 10855 for (intptr_t offset = Instance::NextFieldOffset();
10833 offset < instance_size; 10856 offset < instance_size;
10834 offset += kWordSize) { 10857 offset += kWordSize) {
10835 if ((*reinterpret_cast<RawObject**>(this_addr + offset)) != 10858 if ((*reinterpret_cast<RawObject**>(this_addr + offset)) !=
10836 (*reinterpret_cast<RawObject**>(other_addr + offset))) { 10859 (*reinterpret_cast<RawObject**>(other_addr + offset))) {
10837 return false; 10860 return false;
10838 } 10861 }
10839 } 10862 }
10840 } 10863 }
10841 return true; 10864 return true;
10842 } 10865 }
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
11402 (type_class() == Type::Handle(Type::Double()).type_class()); 11425 (type_class() == Type::Handle(Type::Double()).type_class());
11403 } 11426 }
11404 11427
11405 11428
11406 bool AbstractType::IsFloat32x4Type() const { 11429 bool AbstractType::IsFloat32x4Type() const {
11407 return HasResolvedTypeClass() && 11430 return HasResolvedTypeClass() &&
11408 (type_class() == Type::Handle(Type::Float32x4()).type_class()); 11431 (type_class() == Type::Handle(Type::Float32x4()).type_class());
11409 } 11432 }
11410 11433
11411 11434
11412 bool AbstractType::IsUint32x4Type() const { 11435 bool AbstractType::IsInt32x4Type() const {
11413 return HasResolvedTypeClass() && 11436 return HasResolvedTypeClass() &&
11414 (type_class() == Type::Handle(Type::Uint32x4()).type_class()); 11437 (type_class() == Type::Handle(Type::Int32x4()).type_class());
11415 } 11438 }
11416 11439
11417 11440
11418 bool AbstractType::IsNumberType() const { 11441 bool AbstractType::IsNumberType() const {
11419 return HasResolvedTypeClass() && 11442 return HasResolvedTypeClass() &&
11420 (type_class() == Type::Handle(Type::Number()).type_class()); 11443 (type_class() == Type::Handle(Type::Number()).type_class());
11421 } 11444 }
11422 11445
11423 11446
11424 bool AbstractType::IsStringType() const { 11447 bool AbstractType::IsStringType() const {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
11567 RawType* Type::Double() { 11590 RawType* Type::Double() {
11568 return Isolate::Current()->object_store()->double_type(); 11591 return Isolate::Current()->object_store()->double_type();
11569 } 11592 }
11570 11593
11571 11594
11572 RawType* Type::Float32x4() { 11595 RawType* Type::Float32x4() {
11573 return Isolate::Current()->object_store()->float32x4_type(); 11596 return Isolate::Current()->object_store()->float32x4_type();
11574 } 11597 }
11575 11598
11576 11599
11577 RawType* Type::Uint32x4() { 11600 RawType* Type::Int32x4() {
11578 return Isolate::Current()->object_store()->uint32x4_type(); 11601 return Isolate::Current()->object_store()->int32x4_type();
11579 } 11602 }
11580 11603
11581 11604
11582 RawType* Type::Number() { 11605 RawType* Type::Number() {
11583 return Isolate::Current()->object_store()->number_type(); 11606 return Isolate::Current()->object_store()->number_type();
11584 } 11607 }
11585 11608
11586 11609
11587 RawType* Type::StringType() { 11610 RawType* Type::StringType() {
11588 return Isolate::Current()->object_store()->string_type(); 11611 return Isolate::Current()->object_store()->string_type();
(...skipping 3456 matching lines...) Expand 10 before | Expand all | Expand 10 after
15045 OS::SNPrint(chars, len, kFormat, _x, _y, _z, _w); 15068 OS::SNPrint(chars, len, kFormat, _x, _y, _z, _w);
15046 return chars; 15069 return chars;
15047 } 15070 }
15048 15071
15049 15072
15050 void Float32x4::PrintToJSONStream(JSONStream* stream, bool ref) const { 15073 void Float32x4::PrintToJSONStream(JSONStream* stream, bool ref) const {
15051 JSONObject jsobj(stream); 15074 JSONObject jsobj(stream);
15052 } 15075 }
15053 15076
15054 15077
15055 RawUint32x4* Uint32x4::New(uint32_t v0, uint32_t v1, uint32_t v2, uint32_t v3, 15078 RawInt32x4* Int32x4::New(int32_t v0, int32_t v1, int32_t v2, int32_t v3,
15056 Heap::Space space) { 15079 Heap::Space space) {
15057 ASSERT(Isolate::Current()->object_store()->uint32x4_class() != 15080 ASSERT(Isolate::Current()->object_store()->int32x4_class() !=
15058 Class::null()); 15081 Class::null());
15059 Uint32x4& result = Uint32x4::Handle(); 15082 Int32x4& result = Int32x4::Handle();
15060 { 15083 {
15061 RawObject* raw = Object::Allocate(Uint32x4::kClassId, 15084 RawObject* raw = Object::Allocate(Int32x4::kClassId,
15062 Uint32x4::InstanceSize(), 15085 Int32x4::InstanceSize(),
15063 space); 15086 space);
15064 NoGCScope no_gc; 15087 NoGCScope no_gc;
15065 result ^= raw; 15088 result ^= raw;
15066 } 15089 }
15067 result.set_x(v0); 15090 result.set_x(v0);
15068 result.set_y(v1); 15091 result.set_y(v1);
15069 result.set_z(v2); 15092 result.set_z(v2);
15070 result.set_w(v3); 15093 result.set_w(v3);
15071 return result.raw(); 15094 return result.raw();
15072 } 15095 }
15073 15096
15074 15097
15075 RawUint32x4* Uint32x4::New(simd128_value_t value, Heap::Space space) { 15098 RawInt32x4* Int32x4::New(simd128_value_t value, Heap::Space space) {
15076 ASSERT(Isolate::Current()->object_store()->float32x4_class() != 15099 ASSERT(Isolate::Current()->object_store()->int32x4_class() !=
15077 Class::null()); 15100 Class::null());
15078 Uint32x4& result = Uint32x4::Handle(); 15101 Int32x4& result = Int32x4::Handle();
15079 { 15102 {
15080 RawObject* raw = Object::Allocate(Uint32x4::kClassId, 15103 RawObject* raw = Object::Allocate(Int32x4::kClassId,
15081 Uint32x4::InstanceSize(), 15104 Int32x4::InstanceSize(),
15082 space); 15105 space);
15083 NoGCScope no_gc; 15106 NoGCScope no_gc;
15084 result ^= raw; 15107 result ^= raw;
15085 } 15108 }
15086 result.set_value(value); 15109 result.set_value(value);
15087 return result.raw(); 15110 return result.raw();
15088 } 15111 }
15089 15112
15090 15113
15091 void Uint32x4::set_x(uint32_t value) const { 15114 void Int32x4::set_x(int32_t value) const {
15092 raw_ptr()->value_[0] = value; 15115 raw_ptr()->value_[0] = value;
15093 } 15116 }
15094 15117
15095 15118
15096 void Uint32x4::set_y(uint32_t value) const { 15119 void Int32x4::set_y(int32_t value) const {
15097 raw_ptr()->value_[1] = value; 15120 raw_ptr()->value_[1] = value;
15098 } 15121 }
15099 15122
15100 15123
15101 void Uint32x4::set_z(uint32_t value) const { 15124 void Int32x4::set_z(int32_t value) const {
15102 raw_ptr()->value_[2] = value; 15125 raw_ptr()->value_[2] = value;
15103 } 15126 }
15104 15127
15105 15128
15106 void Uint32x4::set_w(uint32_t value) const { 15129 void Int32x4::set_w(int32_t value) const {
15107 raw_ptr()->value_[3] = value; 15130 raw_ptr()->value_[3] = value;
15108 } 15131 }
15109 15132
15110 15133
15111 uint32_t Uint32x4::x() const { 15134 int32_t Int32x4::x() const {
15112 return raw_ptr()->value_[0]; 15135 return raw_ptr()->value_[0];
15113 } 15136 }
15114 15137
15115 15138
15116 uint32_t Uint32x4::y() const { 15139 int32_t Int32x4::y() const {
15117 return raw_ptr()->value_[1]; 15140 return raw_ptr()->value_[1];
15118 } 15141 }
15119 15142
15120 15143
15121 uint32_t Uint32x4::z() const { 15144 int32_t Int32x4::z() const {
15122 return raw_ptr()->value_[2]; 15145 return raw_ptr()->value_[2];
15123 } 15146 }
15124 15147
15125 15148
15126 uint32_t Uint32x4::w() const { 15149 int32_t Int32x4::w() const {
15127 return raw_ptr()->value_[3]; 15150 return raw_ptr()->value_[3];
15128 } 15151 }
15129 15152
15130 15153
15131 simd128_value_t Uint32x4::value() const { 15154 simd128_value_t Int32x4::value() const {
15132 return simd128_value_t().readFrom(&raw_ptr()->value_[0]); 15155 return simd128_value_t().readFrom(&raw_ptr()->value_[0]);
15133 } 15156 }
15134 15157
15135 15158
15136 void Uint32x4::set_value(simd128_value_t value) const { 15159 void Int32x4::set_value(simd128_value_t value) const {
15137 value.writeTo(&raw_ptr()->value_[0]); 15160 value.writeTo(&raw_ptr()->value_[0]);
15138 } 15161 }
15139 15162
15140 15163
15141 const char* Uint32x4::ToCString() const { 15164 const char* Int32x4::ToCString() const {
15142 const char* kFormat = "[%08x, %08x, %08x, %08x]"; 15165 const char* kFormat = "[%08x, %08x, %08x, %08x]";
15143 uint32_t _x = x(); 15166 int32_t _x = x();
15144 uint32_t _y = y(); 15167 int32_t _y = y();
15145 uint32_t _z = z(); 15168 int32_t _z = z();
15146 uint32_t _w = w(); 15169 int32_t _w = w();
15147 // Calculate the size of the string. 15170 // Calculate the size of the string.
15148 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y, _z, _w) + 1; 15171 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y, _z, _w) + 1;
15149 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 15172 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
15150 OS::SNPrint(chars, len, kFormat, _x, _y, _z, _w); 15173 OS::SNPrint(chars, len, kFormat, _x, _y, _z, _w);
15151 return chars; 15174 return chars;
15152 } 15175 }
15153 15176
15154 15177
15155 void Uint32x4::PrintToJSONStream(JSONStream* stream, bool ref) const { 15178 void Int32x4::PrintToJSONStream(JSONStream* stream, bool ref) const {
15156 JSONObject jsobj(stream); 15179 JSONObject jsobj(stream);
15157 } 15180 }
15158 15181
15159 15182
15160 const intptr_t TypedData::element_size[] = { 15183 const intptr_t TypedData::element_size[] = {
15161 1, // kTypedDataInt8ArrayCid. 15184 1, // kTypedDataInt8ArrayCid.
15162 1, // kTypedDataUint8ArrayCid. 15185 1, // kTypedDataUint8ArrayCid.
15163 1, // kTypedDataUint8ClampedArrayCid. 15186 1, // kTypedDataUint8ClampedArrayCid.
15164 2, // kTypedDataInt16ArrayCid. 15187 2, // kTypedDataInt16ArrayCid.
15165 2, // kTypedDataUint16ArrayCid. 15188 2, // kTypedDataUint16ArrayCid.
15166 4, // kTypedDataInt32ArrayCid. 15189 4, // kTypedDataInt32ArrayCid.
15167 4, // kTypedDataUint32ArrayCid. 15190 4, // kTypedDataUint32ArrayCid.
15168 8, // kTypedDataInt64ArrayCid. 15191 8, // kTypedDataInt64ArrayCid.
15169 8, // kTypedDataUint64ArrayCid. 15192 8, // kTypedDataUint64ArrayCid.
15170 4, // kTypedDataFloat32ArrayCid. 15193 4, // kTypedDataFloat32ArrayCid.
15171 8, // kTypedDataFloat64ArrayCid. 15194 8, // kTypedDataFloat64ArrayCid.
15172 16, // kTypedDataFloat32x4ArrayCid. 15195 16, // kTypedDataFloat32x4ArrayCid.
15173 16, // kTypedDataUint32x4ArrayCid. 15196 16, // kTypedDataInt32x4ArrayCid.
15174 }; 15197 };
15175 15198
15176 15199
15177 RawTypedData* TypedData::New(intptr_t class_id, 15200 RawTypedData* TypedData::New(intptr_t class_id,
15178 intptr_t len, 15201 intptr_t len,
15179 Heap::Space space) { 15202 Heap::Space space) {
15180 if (len < 0 || len > TypedData::MaxElements(class_id)) { 15203 if (len < 0 || len > TypedData::MaxElements(class_id)) {
15181 FATAL1("Fatal error in TypedData::New: invalid len %" Pd "\n", len); 15204 FATAL1("Fatal error in TypedData::New: invalid len %" Pd "\n", len);
15182 } 15205 }
15183 TypedData& result = TypedData::Handle(); 15206 TypedData& result = TypedData::Handle();
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
15716 return "_MirrorReference"; 15739 return "_MirrorReference";
15717 } 15740 }
15718 15741
15719 15742
15720 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 15743 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
15721 JSONObject jsobj(stream); 15744 JSONObject jsobj(stream);
15722 } 15745 }
15723 15746
15724 15747
15725 } // namespace dart 15748 } // namespace dart
OLDNEW
« no previous file with comments | « dart/runtime/vm/object.h ('k') | dart/runtime/vm/object_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698