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