OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/assert-scope.h" | 9 #include "src/assert-scope.h" |
10 #include "src/builtins.h" | 10 #include "src/builtins.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 STORE_NO_TRANSITION_HANDLE_COW | 161 STORE_NO_TRANSITION_HANDLE_COW |
162 }; | 162 }; |
163 | 163 |
164 | 164 |
165 enum ContextualMode { | 165 enum ContextualMode { |
166 NOT_CONTEXTUAL, | 166 NOT_CONTEXTUAL, |
167 CONTEXTUAL | 167 CONTEXTUAL |
168 }; | 168 }; |
169 | 169 |
170 | 170 |
171 enum MutableMode { | |
172 MUTABLE, | |
173 IMMUTABLE | |
174 }; | |
175 | |
176 | |
177 static const int kGrowICDelta = STORE_AND_GROW_NO_TRANSITION - | 171 static const int kGrowICDelta = STORE_AND_GROW_NO_TRANSITION - |
178 STANDARD_STORE; | 172 STANDARD_STORE; |
179 STATIC_ASSERT(STANDARD_STORE == 0); | 173 STATIC_ASSERT(STANDARD_STORE == 0); |
180 STATIC_ASSERT(kGrowICDelta == | 174 STATIC_ASSERT(kGrowICDelta == |
181 STORE_AND_GROW_TRANSITION_SMI_TO_OBJECT - | 175 STORE_AND_GROW_TRANSITION_SMI_TO_OBJECT - |
182 STORE_TRANSITION_SMI_TO_OBJECT); | 176 STORE_TRANSITION_SMI_TO_OBJECT); |
183 STATIC_ASSERT(kGrowICDelta == | 177 STATIC_ASSERT(kGrowICDelta == |
184 STORE_AND_GROW_TRANSITION_SMI_TO_DOUBLE - | 178 STORE_AND_GROW_TRANSITION_SMI_TO_DOUBLE - |
185 STORE_TRANSITION_SMI_TO_DOUBLE); | 179 STORE_TRANSITION_SMI_TO_DOUBLE); |
186 STATIC_ASSERT(kGrowICDelta == | 180 STATIC_ASSERT(kGrowICDelta == |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 \ | 345 \ |
352 V(SYMBOL_TYPE) \ | 346 V(SYMBOL_TYPE) \ |
353 \ | 347 \ |
354 V(MAP_TYPE) \ | 348 V(MAP_TYPE) \ |
355 V(CODE_TYPE) \ | 349 V(CODE_TYPE) \ |
356 V(ODDBALL_TYPE) \ | 350 V(ODDBALL_TYPE) \ |
357 V(CELL_TYPE) \ | 351 V(CELL_TYPE) \ |
358 V(PROPERTY_CELL_TYPE) \ | 352 V(PROPERTY_CELL_TYPE) \ |
359 \ | 353 \ |
360 V(HEAP_NUMBER_TYPE) \ | 354 V(HEAP_NUMBER_TYPE) \ |
361 V(MUTABLE_HEAP_NUMBER_TYPE) \ | |
362 V(FOREIGN_TYPE) \ | 355 V(FOREIGN_TYPE) \ |
363 V(BYTE_ARRAY_TYPE) \ | 356 V(BYTE_ARRAY_TYPE) \ |
364 V(FREE_SPACE_TYPE) \ | 357 V(FREE_SPACE_TYPE) \ |
365 /* Note: the order of these external array */ \ | 358 /* Note: the order of these external array */ \ |
366 /* types is relied upon in */ \ | 359 /* types is relied upon in */ \ |
367 /* Object::IsExternalArray(). */ \ | 360 /* Object::IsExternalArray(). */ \ |
368 V(EXTERNAL_INT8_ARRAY_TYPE) \ | 361 V(EXTERNAL_INT8_ARRAY_TYPE) \ |
369 V(EXTERNAL_UINT8_ARRAY_TYPE) \ | 362 V(EXTERNAL_UINT8_ARRAY_TYPE) \ |
370 V(EXTERNAL_INT16_ARRAY_TYPE) \ | 363 V(EXTERNAL_INT16_ARRAY_TYPE) \ |
371 V(EXTERNAL_UINT16_ARRAY_TYPE) \ | 364 V(EXTERNAL_UINT16_ARRAY_TYPE) \ |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 // Objects allocated in their own spaces (never in new space). | 673 // Objects allocated in their own spaces (never in new space). |
681 MAP_TYPE, | 674 MAP_TYPE, |
682 CODE_TYPE, | 675 CODE_TYPE, |
683 ODDBALL_TYPE, | 676 ODDBALL_TYPE, |
684 CELL_TYPE, | 677 CELL_TYPE, |
685 PROPERTY_CELL_TYPE, | 678 PROPERTY_CELL_TYPE, |
686 | 679 |
687 // "Data", objects that cannot contain non-map-word pointers to heap | 680 // "Data", objects that cannot contain non-map-word pointers to heap |
688 // objects. | 681 // objects. |
689 HEAP_NUMBER_TYPE, | 682 HEAP_NUMBER_TYPE, |
690 MUTABLE_HEAP_NUMBER_TYPE, | |
691 FOREIGN_TYPE, | 683 FOREIGN_TYPE, |
692 BYTE_ARRAY_TYPE, | 684 BYTE_ARRAY_TYPE, |
693 FREE_SPACE_TYPE, | 685 FREE_SPACE_TYPE, |
694 | 686 |
695 EXTERNAL_INT8_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE | 687 EXTERNAL_INT8_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE |
696 EXTERNAL_UINT8_ARRAY_TYPE, | 688 EXTERNAL_UINT8_ARRAY_TYPE, |
697 EXTERNAL_INT16_ARRAY_TYPE, | 689 EXTERNAL_INT16_ARRAY_TYPE, |
698 EXTERNAL_UINT16_ARRAY_TYPE, | 690 EXTERNAL_UINT16_ARRAY_TYPE, |
699 EXTERNAL_INT32_ARRAY_TYPE, | 691 EXTERNAL_INT32_ARRAY_TYPE, |
700 EXTERNAL_UINT32_ARRAY_TYPE, | 692 EXTERNAL_UINT32_ARRAY_TYPE, |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 #endif | 893 #endif |
902 | 894 |
903 | 895 |
904 #define OBJECT_TYPE_LIST(V) \ | 896 #define OBJECT_TYPE_LIST(V) \ |
905 V(Smi) \ | 897 V(Smi) \ |
906 V(HeapObject) \ | 898 V(HeapObject) \ |
907 V(Number) \ | 899 V(Number) \ |
908 | 900 |
909 #define HEAP_OBJECT_TYPE_LIST(V) \ | 901 #define HEAP_OBJECT_TYPE_LIST(V) \ |
910 V(HeapNumber) \ | 902 V(HeapNumber) \ |
911 V(MutableHeapNumber) \ | |
912 V(Name) \ | 903 V(Name) \ |
913 V(UniqueName) \ | 904 V(UniqueName) \ |
914 V(String) \ | 905 V(String) \ |
915 V(SeqString) \ | 906 V(SeqString) \ |
916 V(ExternalString) \ | 907 V(ExternalString) \ |
917 V(ConsString) \ | 908 V(ConsString) \ |
918 V(SlicedString) \ | 909 V(SlicedString) \ |
919 V(ExternalTwoByteString) \ | 910 V(ExternalTwoByteString) \ |
920 V(ExternalAsciiString) \ | 911 V(ExternalAsciiString) \ |
921 V(SeqTwoByteString) \ | 912 V(SeqTwoByteString) \ |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1429 return Representation::Tagged(); | 1420 return Representation::Tagged(); |
1430 } | 1421 } |
1431 } | 1422 } |
1432 | 1423 |
1433 inline bool FitsRepresentation(Representation representation) { | 1424 inline bool FitsRepresentation(Representation representation) { |
1434 if (FLAG_track_fields && representation.IsNone()) { | 1425 if (FLAG_track_fields && representation.IsNone()) { |
1435 return false; | 1426 return false; |
1436 } else if (FLAG_track_fields && representation.IsSmi()) { | 1427 } else if (FLAG_track_fields && representation.IsSmi()) { |
1437 return IsSmi(); | 1428 return IsSmi(); |
1438 } else if (FLAG_track_double_fields && representation.IsDouble()) { | 1429 } else if (FLAG_track_double_fields && representation.IsDouble()) { |
1439 return IsMutableHeapNumber() || IsNumber(); | 1430 return IsNumber(); |
1440 } else if (FLAG_track_heap_object_fields && representation.IsHeapObject()) { | 1431 } else if (FLAG_track_heap_object_fields && representation.IsHeapObject()) { |
1441 return IsHeapObject(); | 1432 return IsHeapObject(); |
1442 } | 1433 } |
1443 return true; | 1434 return true; |
1444 } | 1435 } |
1445 | 1436 |
1446 Handle<HeapType> OptimalType(Isolate* isolate, Representation representation); | 1437 Handle<HeapType> OptimalType(Isolate* isolate, Representation representation); |
1447 | 1438 |
1448 inline static Handle<Object> NewStorageFor(Isolate* isolate, | 1439 inline static Handle<Object> NewStorageFor(Isolate* isolate, |
1449 Handle<Object> object, | 1440 Handle<Object> object, |
1450 Representation representation); | 1441 Representation representation); |
1451 | 1442 |
1452 inline static Handle<Object> WrapForRead(Isolate* isolate, | |
1453 Handle<Object> object, | |
1454 Representation representation); | |
1455 | |
1456 // Returns true if the object is of the correct type to be used as a | 1443 // Returns true if the object is of the correct type to be used as a |
1457 // implementation of a JSObject's elements. | 1444 // implementation of a JSObject's elements. |
1458 inline bool HasValidElements(); | 1445 inline bool HasValidElements(); |
1459 | 1446 |
1460 inline bool HasSpecificClassOf(String* name); | 1447 inline bool HasSpecificClassOf(String* name); |
1461 | 1448 |
1462 bool BooleanValue(); // ECMA-262 9.2. | 1449 bool BooleanValue(); // ECMA-262 9.2. |
1463 | 1450 |
1464 // Convert to a JSObject if needed. | 1451 // Convert to a JSObject if needed. |
1465 // native_context is used when creating wrapper object. | 1452 // native_context is used when creating wrapper object. |
(...skipping 9714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11180 } else { | 11167 } else { |
11181 value &= ~(1 << bit_position); | 11168 value &= ~(1 << bit_position); |
11182 } | 11169 } |
11183 return value; | 11170 return value; |
11184 } | 11171 } |
11185 }; | 11172 }; |
11186 | 11173 |
11187 } } // namespace v8::internal | 11174 } } // namespace v8::internal |
11188 | 11175 |
11189 #endif // V8_OBJECTS_H_ | 11176 #endif // V8_OBJECTS_H_ |
OLD | NEW |