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 #ifndef VM_RAW_OBJECT_H_ | 5 #ifndef VM_RAW_OBJECT_H_ |
6 #define VM_RAW_OBJECT_H_ | 6 #define VM_RAW_OBJECT_H_ |
7 | 7 |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
10 #include "vm/token.h" | 10 #include "vm/token.h" |
11 #include "vm/snapshot.h" | 11 #include "vm/snapshot.h" |
12 | 12 |
13 namespace dart { | 13 namespace dart { |
14 | 14 |
15 // Macrobatics to define the Object hierarchy of VM implementation classes. | 15 // Macrobatics to define the Object hierarchy of VM implementation classes. |
16 #define CLASS_LIST_NO_OBJECT_NOR_STRING_NOR_ARRAY(V) \ | 16 #define CLASS_LIST_NO_OBJECT_NOR_STRING_NOR_ARRAY(V) \ |
17 V(Class) \ | 17 V(Class) \ |
18 V(UnresolvedClass) \ | 18 V(UnresolvedClass) \ |
19 V(AbstractTypeArguments) \ | 19 V(TypeArguments) \ |
20 V(TypeArguments) \ | |
21 V(InstantiatedTypeArguments) \ | |
22 V(PatchClass) \ | 20 V(PatchClass) \ |
23 V(Function) \ | 21 V(Function) \ |
24 V(ClosureData) \ | 22 V(ClosureData) \ |
25 V(RedirectionData) \ | 23 V(RedirectionData) \ |
26 V(Field) \ | 24 V(Field) \ |
27 V(LiteralToken) \ | 25 V(LiteralToken) \ |
28 V(TokenStream) \ | 26 V(TokenStream) \ |
29 V(Script) \ | 27 V(Script) \ |
30 V(Library) \ | 28 V(Library) \ |
31 V(LibraryPrefix) \ | 29 V(LibraryPrefix) \ |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 } | 528 } |
531 RawLibraryPrefix* library_prefix_; // Library prefix qualifier for the ident. | 529 RawLibraryPrefix* library_prefix_; // Library prefix qualifier for the ident. |
532 RawString* ident_; // Name of the unresolved identifier. | 530 RawString* ident_; // Name of the unresolved identifier. |
533 RawObject** to() { | 531 RawObject** to() { |
534 return reinterpret_cast<RawObject**>(&ptr()->ident_); | 532 return reinterpret_cast<RawObject**>(&ptr()->ident_); |
535 } | 533 } |
536 intptr_t token_pos_; | 534 intptr_t token_pos_; |
537 }; | 535 }; |
538 | 536 |
539 | 537 |
540 class RawAbstractTypeArguments : public RawObject { | 538 class RawTypeArguments : public RawObject { |
541 private: | |
542 RAW_HEAP_OBJECT_IMPLEMENTATION(AbstractTypeArguments); | |
543 }; | |
544 | |
545 | |
546 class RawTypeArguments : public RawAbstractTypeArguments { | |
547 private: | 539 private: |
548 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeArguments); | 540 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeArguments); |
549 | 541 |
550 RawObject** from() { | 542 RawObject** from() { |
551 return reinterpret_cast<RawObject**>(&ptr()->length_); | 543 return reinterpret_cast<RawObject**>(&ptr()->instantiations_); |
552 } | 544 } |
| 545 // The instantiations_ array remains empty for instantiated type arguments. |
| 546 RawArray* instantiations_; // Array of paired canonical vectors: |
| 547 // Even index: instantiator. |
| 548 // Odd index: instantiated (without bound error). |
| 549 // Instantiations leading to bound errors do not get cached. |
553 RawSmi* length_; | 550 RawSmi* length_; |
554 | 551 |
555 // Variable length data follows here. | 552 // Variable length data follows here. |
556 RawAbstractType* types_[0]; | 553 RawAbstractType* types_[0]; |
557 RawObject** to(intptr_t length) { | 554 RawObject** to(intptr_t length) { |
558 return reinterpret_cast<RawObject**>(&ptr()->types_[length - 1]); | 555 return reinterpret_cast<RawObject**>(&ptr()->types_[length - 1]); |
559 } | 556 } |
560 | 557 |
561 friend class SnapshotReader; | 558 friend class SnapshotReader; |
562 }; | 559 }; |
563 | 560 |
564 | 561 |
565 class RawInstantiatedTypeArguments : public RawAbstractTypeArguments { | |
566 private: | |
567 RAW_HEAP_OBJECT_IMPLEMENTATION(InstantiatedTypeArguments); | |
568 | |
569 RawObject** from() { | |
570 return reinterpret_cast<RawObject**>( | |
571 &ptr()->uninstantiated_type_arguments_); | |
572 } | |
573 RawAbstractTypeArguments* uninstantiated_type_arguments_; | |
574 RawAbstractTypeArguments* instantiator_type_arguments_; | |
575 RawObject** to() { | |
576 return reinterpret_cast<RawObject**>(&ptr()->instantiator_type_arguments_); | |
577 } | |
578 }; | |
579 | |
580 | |
581 class RawPatchClass : public RawObject { | 562 class RawPatchClass : public RawObject { |
582 private: | 563 private: |
583 RAW_HEAP_OBJECT_IMPLEMENTATION(PatchClass); | 564 RAW_HEAP_OBJECT_IMPLEMENTATION(PatchClass); |
584 | 565 |
585 RawObject** from() { | 566 RawObject** from() { |
586 return reinterpret_cast<RawObject**>(&ptr()->patched_class_); | 567 return reinterpret_cast<RawObject**>(&ptr()->patched_class_); |
587 } | 568 } |
588 RawClass* patched_class_; | 569 RawClass* patched_class_; |
589 RawClass* source_class_; | 570 RawClass* source_class_; |
590 RawObject** to() { | 571 RawObject** to() { |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1167 | 1148 |
1168 | 1149 |
1169 class RawType : public RawAbstractType { | 1150 class RawType : public RawAbstractType { |
1170 private: | 1151 private: |
1171 RAW_HEAP_OBJECT_IMPLEMENTATION(Type); | 1152 RAW_HEAP_OBJECT_IMPLEMENTATION(Type); |
1172 | 1153 |
1173 RawObject** from() { | 1154 RawObject** from() { |
1174 return reinterpret_cast<RawObject**>(&ptr()->type_class_); | 1155 return reinterpret_cast<RawObject**>(&ptr()->type_class_); |
1175 } | 1156 } |
1176 RawObject* type_class_; // Either resolved class or unresolved class. | 1157 RawObject* type_class_; // Either resolved class or unresolved class. |
1177 RawAbstractTypeArguments* arguments_; | 1158 RawTypeArguments* arguments_; |
1178 RawLanguageError* error_; // Error object if type is malformed or malbounded. | 1159 RawLanguageError* error_; // Error object if type is malformed or malbounded. |
1179 RawObject** to() { | 1160 RawObject** to() { |
1180 return reinterpret_cast<RawObject**>(&ptr()->error_); | 1161 return reinterpret_cast<RawObject**>(&ptr()->error_); |
1181 } | 1162 } |
1182 intptr_t token_pos_; | 1163 intptr_t token_pos_; |
1183 int8_t type_state_; | 1164 int8_t type_state_; |
1184 }; | 1165 }; |
1185 | 1166 |
1186 | 1167 |
1187 class RawTypeRef : public RawAbstractType { | 1168 class RawTypeRef : public RawAbstractType { |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1378 bool value_; | 1359 bool value_; |
1379 }; | 1360 }; |
1380 | 1361 |
1381 | 1362 |
1382 class RawArray : public RawInstance { | 1363 class RawArray : public RawInstance { |
1383 RAW_HEAP_OBJECT_IMPLEMENTATION(Array); | 1364 RAW_HEAP_OBJECT_IMPLEMENTATION(Array); |
1384 | 1365 |
1385 RawObject** from() { | 1366 RawObject** from() { |
1386 return reinterpret_cast<RawObject**>(&ptr()->type_arguments_); | 1367 return reinterpret_cast<RawObject**>(&ptr()->type_arguments_); |
1387 } | 1368 } |
1388 RawAbstractTypeArguments* type_arguments_; | 1369 RawTypeArguments* type_arguments_; |
1389 RawSmi* length_; | 1370 RawSmi* length_; |
1390 // Variable length data follows here. | 1371 // Variable length data follows here. |
1391 RawObject** data() { | 1372 RawObject** data() { |
1392 uword address_of_length = reinterpret_cast<uword>(&length_); | 1373 uword address_of_length = reinterpret_cast<uword>(&length_); |
1393 return reinterpret_cast<RawObject**>(address_of_length + kWordSize); | 1374 return reinterpret_cast<RawObject**>(address_of_length + kWordSize); |
1394 } | 1375 } |
1395 RawObject** to(intptr_t length) { | 1376 RawObject** to(intptr_t length) { |
1396 return reinterpret_cast<RawObject**>(&ptr()->data()[length - 1]); | 1377 return reinterpret_cast<RawObject**>(&ptr()->data()[length - 1]); |
1397 } | 1378 } |
1398 | 1379 |
(...skipping 11 matching lines...) Expand all Loading... |
1410 friend class SnapshotReader; | 1391 friend class SnapshotReader; |
1411 }; | 1392 }; |
1412 | 1393 |
1413 | 1394 |
1414 class RawGrowableObjectArray : public RawInstance { | 1395 class RawGrowableObjectArray : public RawInstance { |
1415 RAW_HEAP_OBJECT_IMPLEMENTATION(GrowableObjectArray); | 1396 RAW_HEAP_OBJECT_IMPLEMENTATION(GrowableObjectArray); |
1416 | 1397 |
1417 RawObject** from() { | 1398 RawObject** from() { |
1418 return reinterpret_cast<RawObject**>(&ptr()->type_arguments_); | 1399 return reinterpret_cast<RawObject**>(&ptr()->type_arguments_); |
1419 } | 1400 } |
1420 RawAbstractTypeArguments* type_arguments_; | 1401 RawTypeArguments* type_arguments_; |
1421 RawSmi* length_; | 1402 RawSmi* length_; |
1422 RawArray* data_; | 1403 RawArray* data_; |
1423 RawObject** to() { | 1404 RawObject** to() { |
1424 return reinterpret_cast<RawObject**>(&ptr()->data_); | 1405 return reinterpret_cast<RawObject**>(&ptr()->data_); |
1425 } | 1406 } |
1426 | 1407 |
1427 friend class SnapshotReader; | 1408 friend class SnapshotReader; |
1428 }; | 1409 }; |
1429 | 1410 |
1430 | 1411 |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1789 // Make sure this is updated when new TypedData types are added. | 1770 // Make sure this is updated when new TypedData types are added. |
1790 ASSERT(kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 14); | 1771 ASSERT(kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 14); |
1791 ASSERT(kExternalTypedDataInt8ArrayCid == kTypedDataInt8ArrayViewCid + 15); | 1772 ASSERT(kExternalTypedDataInt8ArrayCid == kTypedDataInt8ArrayViewCid + 15); |
1792 ASSERT(kNullCid == kExternalTypedDataInt8ArrayCid + 14); | 1773 ASSERT(kNullCid == kExternalTypedDataInt8ArrayCid + 14); |
1793 return (kNullCid - kTypedDataInt8ArrayCid); | 1774 return (kNullCid - kTypedDataInt8ArrayCid); |
1794 } | 1775 } |
1795 | 1776 |
1796 } // namespace dart | 1777 } // namespace dart |
1797 | 1778 |
1798 #endif // VM_RAW_OBJECT_H_ | 1779 #endif // VM_RAW_OBJECT_H_ |
OLD | NEW |