OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 // - Failure (immediate for marking failed operation) | 47 // - Failure (immediate for marking failed operation) |
48 // - HeapObject (superclass for everything allocated in the heap) | 48 // - HeapObject (superclass for everything allocated in the heap) |
49 // - JSObject | 49 // - JSObject |
50 // - JSArray | 50 // - JSArray |
51 // - JSRegExp | 51 // - JSRegExp |
52 // - JSFunction | 52 // - JSFunction |
53 // - GlobalObject | 53 // - GlobalObject |
54 // - JSGlobalObject | 54 // - JSGlobalObject |
55 // - JSBuiltinsObject | 55 // - JSBuiltinsObject |
56 // - JSGlobalProxy | 56 // - JSGlobalProxy |
57 // - JSValue | 57 // - JSValue |
58 // - ByteArray | 58 // - Array |
59 // - PixelArray | 59 // - ByteArray |
60 // - ExternalArray | 60 // - PixelArray |
61 // - ExternalByteArray | 61 // - ExternalArray |
62 // - ExternalUnsignedByteArray | 62 // - ExternalByteArray |
63 // - ExternalShortArray | 63 // - ExternalUnsignedByteArray |
64 // - ExternalUnsignedShortArray | 64 // - ExternalShortArray |
65 // - ExternalIntArray | 65 // - ExternalUnsignedShortArray |
66 // - ExternalUnsignedIntArray | 66 // - ExternalIntArray |
67 // - ExternalFloatArray | 67 // - ExternalUnsignedIntArray |
68 // - FixedArray | 68 // - ExternalFloatArray |
69 // - DescriptorArray | 69 // - FixedArray |
70 // - HashTable | 70 // - DescriptorArray |
71 // - Dictionary | 71 // - HashTable |
72 // - SymbolTable | 72 // - Dictionary |
73 // - CompilationCacheTable | 73 // - SymbolTable |
74 // - CodeCacheHashTable | 74 // - CompilationCacheTable |
75 // - MapCache | 75 // - CodeCacheHashTable |
76 // - Context | 76 // - MapCache |
77 // - GlobalContext | 77 // - Context |
78 // - JSFunctionResultCache | 78 // - GlobalContext |
| 79 // - JSFunctionResultCache |
79 // - String | 80 // - String |
80 // - SeqString | 81 // - SeqString |
81 // - SeqAsciiString | 82 // - SeqAsciiString |
82 // - SeqTwoByteString | 83 // - SeqTwoByteString |
83 // - ConsString | 84 // - ConsString |
84 // - ExternalString | 85 // - ExternalString |
85 // - ExternalAsciiString | 86 // - ExternalAsciiString |
86 // - ExternalTwoByteString | 87 // - ExternalTwoByteString |
87 // - HeapNumber | 88 // - HeapNumber |
88 // - Code | 89 // - Code |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 Object* holder); | 669 Object* holder); |
669 Object* GetPropertyWithDefinedGetter(Object* receiver, | 670 Object* GetPropertyWithDefinedGetter(Object* receiver, |
670 JSFunction* getter); | 671 JSFunction* getter); |
671 | 672 |
672 inline Object* GetElement(uint32_t index); | 673 inline Object* GetElement(uint32_t index); |
673 Object* GetElementWithReceiver(Object* receiver, uint32_t index); | 674 Object* GetElementWithReceiver(Object* receiver, uint32_t index); |
674 | 675 |
675 // Return the object's prototype (might be Heap::null_value()). | 676 // Return the object's prototype (might be Heap::null_value()). |
676 Object* GetPrototype(); | 677 Object* GetPrototype(); |
677 | 678 |
678 // Tries to convert an object to an array index. Returns true and sets | |
679 // the output parameter if it succeeds. | |
680 inline bool ToArrayIndex(uint32_t* index); | |
681 | |
682 // Returns true if this is a JSValue containing a string and the index is | 679 // Returns true if this is a JSValue containing a string and the index is |
683 // < the length of the string. Used to implement [] on strings. | 680 // < the length of the string. Used to implement [] on strings. |
684 inline bool IsStringObjectWithCharacterAt(uint32_t index); | 681 inline bool IsStringObjectWithCharacterAt(uint32_t index); |
685 | 682 |
686 #ifdef DEBUG | 683 #ifdef DEBUG |
687 // Prints this object with details. | 684 // Prints this object with details. |
688 void Print(); | 685 void Print(); |
689 void PrintLn(); | 686 void PrintLn(); |
690 // Verifies the object. | 687 // Verifies the object. |
691 void Verify(); | 688 void Verify(); |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 // Mutate this object's map pointer to indicate that the object is | 1019 // Mutate this object's map pointer to indicate that the object is |
1023 // overflowed. | 1020 // overflowed. |
1024 inline void SetOverflow(); | 1021 inline void SetOverflow(); |
1025 | 1022 |
1026 // Mutate this object's map pointer to remove the indication that the | 1023 // Mutate this object's map pointer to remove the indication that the |
1027 // object is overflowed (ie, partially restore the map pointer). | 1024 // object is overflowed (ie, partially restore the map pointer). |
1028 inline void ClearOverflow(); | 1025 inline void ClearOverflow(); |
1029 | 1026 |
1030 // Returns the field at offset in obj, as a read/write Object* reference. | 1027 // Returns the field at offset in obj, as a read/write Object* reference. |
1031 // Does no checking, and is safe to use during GC, while maps are invalid. | 1028 // Does no checking, and is safe to use during GC, while maps are invalid. |
1032 // Does not invoke write barrier, so should only be assigned to | 1029 // Does not update remembered sets, so should only be assigned to |
1033 // during marking GC. | 1030 // during marking GC. |
1034 static inline Object** RawField(HeapObject* obj, int offset); | 1031 static inline Object** RawField(HeapObject* obj, int offset); |
1035 | 1032 |
1036 // Casting. | 1033 // Casting. |
1037 static inline HeapObject* cast(Object* obj); | 1034 static inline HeapObject* cast(Object* obj); |
1038 | 1035 |
1039 // Return the write barrier mode for this. Callers of this function | 1036 // Return the write barrier mode for this. Callers of this function |
1040 // must be able to present a reference to an AssertNoAllocation | 1037 // must be able to present a reference to an AssertNoAllocation |
1041 // object as a sign that they are not going to use this function | 1038 // object as a sign that they are not going to use this function |
1042 // from code that allocates and thus invalidates the returned write | 1039 // from code that allocates and thus invalidates the returned write |
1043 // barrier mode. | 1040 // barrier mode. |
1044 inline WriteBarrierMode GetWriteBarrierMode(const AssertNoAllocation&); | 1041 inline WriteBarrierMode GetWriteBarrierMode(const AssertNoAllocation&); |
1045 | 1042 |
1046 // Dispatched behavior. | 1043 // Dispatched behavior. |
1047 void HeapObjectShortPrint(StringStream* accumulator); | 1044 void HeapObjectShortPrint(StringStream* accumulator); |
1048 #ifdef DEBUG | 1045 #ifdef DEBUG |
1049 void HeapObjectPrint(); | 1046 void HeapObjectPrint(); |
1050 void HeapObjectVerify(); | 1047 void HeapObjectVerify(); |
1051 inline void VerifyObjectField(int offset); | 1048 inline void VerifyObjectField(int offset); |
1052 inline void VerifySmiField(int offset); | |
1053 | 1049 |
1054 void PrintHeader(const char* id); | 1050 void PrintHeader(const char* id); |
1055 | 1051 |
1056 // Verify a pointer is a valid HeapObject pointer that points to object | 1052 // Verify a pointer is a valid HeapObject pointer that points to object |
1057 // areas in the heap. | 1053 // areas in the heap. |
1058 static void VerifyHeapPointer(Object* p); | 1054 static void VerifyHeapPointer(Object* p); |
1059 #endif | 1055 #endif |
1060 | 1056 |
1061 // Layout description. | 1057 // Layout description. |
1062 // First field in a heap object is map. | 1058 // First field in a heap object is map. |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1147 EXTERNAL_BYTE_ELEMENTS, | 1143 EXTERNAL_BYTE_ELEMENTS, |
1148 EXTERNAL_UNSIGNED_BYTE_ELEMENTS, | 1144 EXTERNAL_UNSIGNED_BYTE_ELEMENTS, |
1149 EXTERNAL_SHORT_ELEMENTS, | 1145 EXTERNAL_SHORT_ELEMENTS, |
1150 EXTERNAL_UNSIGNED_SHORT_ELEMENTS, | 1146 EXTERNAL_UNSIGNED_SHORT_ELEMENTS, |
1151 EXTERNAL_INT_ELEMENTS, | 1147 EXTERNAL_INT_ELEMENTS, |
1152 EXTERNAL_UNSIGNED_INT_ELEMENTS, | 1148 EXTERNAL_UNSIGNED_INT_ELEMENTS, |
1153 EXTERNAL_FLOAT_ELEMENTS | 1149 EXTERNAL_FLOAT_ELEMENTS |
1154 }; | 1150 }; |
1155 | 1151 |
1156 // [properties]: Backing storage for properties. | 1152 // [properties]: Backing storage for properties. |
1157 // properties is a FixedArray in the fast case and a Dictionary in the | 1153 // properties is a FixedArray in the fast case, and a Dictionary in the |
1158 // slow case. | 1154 // slow case. |
1159 DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties. | 1155 DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties. |
1160 inline void initialize_properties(); | 1156 inline void initialize_properties(); |
1161 inline bool HasFastProperties(); | 1157 inline bool HasFastProperties(); |
1162 inline StringDictionary* property_dictionary(); // Gets slow properties. | 1158 inline StringDictionary* property_dictionary(); // Gets slow properties. |
1163 | 1159 |
1164 // [elements]: The elements (properties with names that are integers). | 1160 // [elements]: The elements (properties with names that are integers). |
1165 // elements is a FixedArray in the fast case, a Dictionary in the slow | 1161 // elements is a FixedArray in the fast case, and a Dictionary in the slow |
1166 // case, and a PixelArray or ExternalArray in special cases. | 1162 // case or a PixelArray in a special case. |
1167 DECL_ACCESSORS(elements, HeapObject) | 1163 DECL_ACCESSORS(elements, Array) // Get and set fast elements. |
1168 inline void initialize_elements(); | 1164 inline void initialize_elements(); |
1169 inline ElementsKind GetElementsKind(); | 1165 inline ElementsKind GetElementsKind(); |
1170 inline bool HasFastElements(); | 1166 inline bool HasFastElements(); |
1171 inline bool HasDictionaryElements(); | 1167 inline bool HasDictionaryElements(); |
1172 inline bool HasPixelElements(); | 1168 inline bool HasPixelElements(); |
1173 inline bool HasExternalArrayElements(); | 1169 inline bool HasExternalArrayElements(); |
1174 inline bool HasExternalByteElements(); | 1170 inline bool HasExternalByteElements(); |
1175 inline bool HasExternalUnsignedByteElements(); | 1171 inline bool HasExternalUnsignedByteElements(); |
1176 inline bool HasExternalShortElements(); | 1172 inline bool HasExternalShortElements(); |
1177 inline bool HasExternalUnsignedShortElements(); | 1173 inline bool HasExternalUnsignedShortElements(); |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1574 bool HasDenseElements(); | 1570 bool HasDenseElements(); |
1575 | 1571 |
1576 Object* DefineGetterSetter(String* name, PropertyAttributes attributes); | 1572 Object* DefineGetterSetter(String* name, PropertyAttributes attributes); |
1577 | 1573 |
1578 void LookupInDescriptor(String* name, LookupResult* result); | 1574 void LookupInDescriptor(String* name, LookupResult* result); |
1579 | 1575 |
1580 DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject); | 1576 DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject); |
1581 }; | 1577 }; |
1582 | 1578 |
1583 | 1579 |
1584 // FixedArray describes fixed-sized arrays with element type Object*. | 1580 // Abstract super class arrays. It provides length behavior. |
1585 class FixedArray: public HeapObject { | 1581 class Array: public HeapObject { |
1586 public: | 1582 public: |
1587 // [length]: length of the array. | 1583 // [length]: length of the array. |
1588 inline int length(); | 1584 inline int length(); |
1589 inline void set_length(int value); | 1585 inline void set_length(int value); |
1590 | 1586 |
| 1587 // Convert an object to an array index. |
| 1588 // Returns true if the conversion succeeded. |
| 1589 static inline bool IndexFromObject(Object* object, uint32_t* index); |
| 1590 |
| 1591 // Layout descriptor. |
| 1592 static const int kLengthOffset = HeapObject::kHeaderSize; |
| 1593 |
| 1594 protected: |
| 1595 // No code should use the Array class directly, only its subclasses. |
| 1596 // Use the kHeaderSize of the appropriate subclass, which may be aligned. |
| 1597 static const int kHeaderSize = kLengthOffset + kIntSize; |
| 1598 static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize); |
| 1599 |
| 1600 private: |
| 1601 DISALLOW_IMPLICIT_CONSTRUCTORS(Array); |
| 1602 }; |
| 1603 |
| 1604 |
| 1605 // FixedArray describes fixed sized arrays where element |
| 1606 // type is Object*. |
| 1607 |
| 1608 class FixedArray: public Array { |
| 1609 public: |
| 1610 |
1591 // Setter and getter for elements. | 1611 // Setter and getter for elements. |
1592 inline Object* get(int index); | 1612 inline Object* get(int index); |
1593 // Setter that uses write barrier. | 1613 // Setter that uses write barrier. |
1594 inline void set(int index, Object* value); | 1614 inline void set(int index, Object* value); |
1595 | 1615 |
1596 // Setter that doesn't need write barrier). | 1616 // Setter that doesn't need write barrier). |
1597 inline void set(int index, Smi* value); | 1617 inline void set(int index, Smi* value); |
1598 // Setter with explicit barrier mode. | 1618 // Setter with explicit barrier mode. |
1599 inline void set(int index, Object* value, WriteBarrierMode mode); | 1619 inline void set(int index, Object* value, WriteBarrierMode mode); |
1600 | 1620 |
(...skipping 20 matching lines...) Expand all Loading... |
1621 | 1641 |
1622 // Garbage collection support. | 1642 // Garbage collection support. |
1623 static int SizeFor(int length) { return kHeaderSize + length * kPointerSize; } | 1643 static int SizeFor(int length) { return kHeaderSize + length * kPointerSize; } |
1624 | 1644 |
1625 // Code Generation support. | 1645 // Code Generation support. |
1626 static int OffsetOfElementAt(int index) { return SizeFor(index); } | 1646 static int OffsetOfElementAt(int index) { return SizeFor(index); } |
1627 | 1647 |
1628 // Casting. | 1648 // Casting. |
1629 static inline FixedArray* cast(Object* obj); | 1649 static inline FixedArray* cast(Object* obj); |
1630 | 1650 |
1631 // Layout description. | 1651 static const int kHeaderSize = Array::kAlignedSize; |
1632 // Length is smi tagged when it is stored. | |
1633 static const int kLengthOffset = HeapObject::kHeaderSize; | |
1634 static const int kHeaderSize = kLengthOffset + kPointerSize; | |
1635 | 1652 |
1636 // Maximal allowed size, in bytes, of a single FixedArray. | 1653 // Maximal allowed size, in bytes, of a single FixedArray. |
1637 // Prevents overflowing size computations, as well as extreme memory | 1654 // Prevents overflowing size computations, as well as extreme memory |
1638 // consumption. | 1655 // consumption. |
1639 static const int kMaxSize = 512 * MB; | 1656 static const int kMaxSize = 512 * MB; |
1640 // Maximally allowed length of a FixedArray. | 1657 // Maximally allowed length of a FixedArray. |
1641 static const int kMaxLength = (kMaxSize - kHeaderSize) / kPointerSize; | 1658 static const int kMaxLength = (kMaxSize - kHeaderSize) / kPointerSize; |
1642 | 1659 |
1643 // Dispatched behavior. | 1660 // Dispatched behavior. |
1644 int FixedArraySize() { return SizeFor(length()); } | 1661 int FixedArraySize() { return SizeFor(length()); } |
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2323 | 2340 |
2324 #ifdef DEBUG | 2341 #ifdef DEBUG |
2325 void JSFunctionResultCacheVerify(); | 2342 void JSFunctionResultCacheVerify(); |
2326 #endif | 2343 #endif |
2327 }; | 2344 }; |
2328 | 2345 |
2329 | 2346 |
2330 // ByteArray represents fixed sized byte arrays. Used by the outside world, | 2347 // ByteArray represents fixed sized byte arrays. Used by the outside world, |
2331 // such as PCRE, and also by the memory allocator and garbage collector to | 2348 // such as PCRE, and also by the memory allocator and garbage collector to |
2332 // fill in free blocks in the heap. | 2349 // fill in free blocks in the heap. |
2333 class ByteArray: public HeapObject { | 2350 class ByteArray: public Array { |
2334 public: | 2351 public: |
2335 // [length]: length of the array. | |
2336 inline int length(); | |
2337 inline void set_length(int value); | |
2338 | |
2339 // Setter and getter. | 2352 // Setter and getter. |
2340 inline byte get(int index); | 2353 inline byte get(int index); |
2341 inline void set(int index, byte value); | 2354 inline void set(int index, byte value); |
2342 | 2355 |
2343 // Treat contents as an int array. | 2356 // Treat contents as an int array. |
2344 inline int get_int(int index); | 2357 inline int get_int(int index); |
2345 | 2358 |
2346 static int SizeFor(int length) { | 2359 static int SizeFor(int length) { |
2347 return OBJECT_POINTER_ALIGN(kHeaderSize + length); | 2360 return OBJECT_SIZE_ALIGN(kHeaderSize + length); |
2348 } | 2361 } |
2349 // We use byte arrays for free blocks in the heap. Given a desired size in | 2362 // We use byte arrays for free blocks in the heap. Given a desired size in |
2350 // bytes that is a multiple of the word size and big enough to hold a byte | 2363 // bytes that is a multiple of the word size and big enough to hold a byte |
2351 // array, this function returns the number of elements a byte array should | 2364 // array, this function returns the number of elements a byte array should |
2352 // have. | 2365 // have. |
2353 static int LengthFor(int size_in_bytes) { | 2366 static int LengthFor(int size_in_bytes) { |
2354 ASSERT(IsAligned(size_in_bytes, kPointerSize)); | 2367 ASSERT(IsAligned(size_in_bytes, kPointerSize)); |
2355 ASSERT(size_in_bytes >= kHeaderSize); | 2368 ASSERT(size_in_bytes >= kHeaderSize); |
2356 return size_in_bytes - kHeaderSize; | 2369 return size_in_bytes - kHeaderSize; |
2357 } | 2370 } |
2358 | 2371 |
2359 // Returns data start address. | 2372 // Returns data start address. |
2360 inline Address GetDataStartAddress(); | 2373 inline Address GetDataStartAddress(); |
2361 | 2374 |
2362 // Returns a pointer to the ByteArray object for a given data start address. | 2375 // Returns a pointer to the ByteArray object for a given data start address. |
2363 static inline ByteArray* FromDataStartAddress(Address address); | 2376 static inline ByteArray* FromDataStartAddress(Address address); |
2364 | 2377 |
2365 // Casting. | 2378 // Casting. |
2366 static inline ByteArray* cast(Object* obj); | 2379 static inline ByteArray* cast(Object* obj); |
2367 | 2380 |
2368 // Dispatched behavior. | 2381 // Dispatched behavior. |
2369 int ByteArraySize() { return SizeFor(length()); } | 2382 int ByteArraySize() { return SizeFor(length()); } |
2370 #ifdef DEBUG | 2383 #ifdef DEBUG |
2371 void ByteArrayPrint(); | 2384 void ByteArrayPrint(); |
2372 void ByteArrayVerify(); | 2385 void ByteArrayVerify(); |
2373 #endif | 2386 #endif |
2374 | 2387 |
2375 // Layout description. | 2388 // ByteArray headers are not quadword aligned. |
2376 // Length is smi tagged when it is stored. | 2389 static const int kHeaderSize = Array::kHeaderSize; |
2377 static const int kLengthOffset = HeapObject::kHeaderSize; | 2390 static const int kAlignedSize = Array::kAlignedSize; |
2378 static const int kHeaderSize = kLengthOffset + kPointerSize; | |
2379 | |
2380 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); | |
2381 | 2391 |
2382 // Maximal memory consumption for a single ByteArray. | 2392 // Maximal memory consumption for a single ByteArray. |
2383 static const int kMaxSize = 512 * MB; | 2393 static const int kMaxSize = 512 * MB; |
2384 // Maximal length of a single ByteArray. | 2394 // Maximal length of a single ByteArray. |
2385 static const int kMaxLength = kMaxSize - kHeaderSize; | 2395 static const int kMaxLength = kMaxSize - kHeaderSize; |
2386 | 2396 |
2387 private: | 2397 private: |
2388 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); | 2398 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); |
2389 }; | 2399 }; |
2390 | 2400 |
2391 | 2401 |
2392 // A PixelArray represents a fixed-size byte array with special semantics | 2402 // A PixelArray represents a fixed-size byte array with special semantics |
2393 // used for implementing the CanvasPixelArray object. Please see the | 2403 // used for implementing the CanvasPixelArray object. Please see the |
2394 // specification at: | 2404 // specification at: |
2395 // http://www.whatwg.org/specs/web-apps/current-work/ | 2405 // http://www.whatwg.org/specs/web-apps/current-work/ |
2396 // multipage/the-canvas-element.html#canvaspixelarray | 2406 // multipage/the-canvas-element.html#canvaspixelarray |
2397 // In particular, write access clamps the value written to 0 or 255 if the | 2407 // In particular, write access clamps the value written to 0 or 255 if the |
2398 // value written is outside this range. | 2408 // value written is outside this range. |
2399 class PixelArray: public HeapObject { | 2409 class PixelArray: public Array { |
2400 public: | 2410 public: |
2401 // [length]: length of the array. | |
2402 inline int length(); | |
2403 inline void set_length(int value); | |
2404 | |
2405 // [external_pointer]: The pointer to the external memory area backing this | 2411 // [external_pointer]: The pointer to the external memory area backing this |
2406 // pixel array. | 2412 // pixel array. |
2407 DECL_ACCESSORS(external_pointer, uint8_t) // Pointer to the data store. | 2413 DECL_ACCESSORS(external_pointer, uint8_t) // Pointer to the data store. |
2408 | 2414 |
2409 // Setter and getter. | 2415 // Setter and getter. |
2410 inline uint8_t get(int index); | 2416 inline uint8_t get(int index); |
2411 inline void set(int index, uint8_t value); | 2417 inline void set(int index, uint8_t value); |
2412 | 2418 |
2413 // This accessor applies the correct conversion from Smi, HeapNumber and | 2419 // This accessor applies the correct conversion from Smi, HeapNumber and |
2414 // undefined and clamps the converted value between 0 and 255. | 2420 // undefined and clamps the converted value between 0 and 255. |
2415 Object* SetValue(uint32_t index, Object* value); | 2421 Object* SetValue(uint32_t index, Object* value); |
2416 | 2422 |
2417 // Casting. | 2423 // Casting. |
2418 static inline PixelArray* cast(Object* obj); | 2424 static inline PixelArray* cast(Object* obj); |
2419 | 2425 |
2420 #ifdef DEBUG | 2426 #ifdef DEBUG |
2421 void PixelArrayPrint(); | 2427 void PixelArrayPrint(); |
2422 void PixelArrayVerify(); | 2428 void PixelArrayVerify(); |
2423 #endif // DEBUG | 2429 #endif // DEBUG |
2424 | 2430 |
2425 // Maximal acceptable length for a pixel array. | 2431 // Maximal acceptable length for a pixel array. |
2426 static const int kMaxLength = 0x3fffffff; | 2432 static const int kMaxLength = 0x3fffffff; |
2427 | 2433 |
2428 // PixelArray headers are not quadword aligned. | 2434 // PixelArray headers are not quadword aligned. |
2429 static const int kLengthOffset = HeapObject::kHeaderSize; | 2435 static const int kExternalPointerOffset = Array::kAlignedSize; |
2430 static const int kExternalPointerOffset = | |
2431 POINTER_SIZE_ALIGN(kLengthOffset + kIntSize); | |
2432 static const int kHeaderSize = kExternalPointerOffset + kPointerSize; | 2436 static const int kHeaderSize = kExternalPointerOffset + kPointerSize; |
2433 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); | 2437 static const int kAlignedSize = OBJECT_SIZE_ALIGN(kHeaderSize); |
2434 | 2438 |
2435 private: | 2439 private: |
2436 DISALLOW_IMPLICIT_CONSTRUCTORS(PixelArray); | 2440 DISALLOW_IMPLICIT_CONSTRUCTORS(PixelArray); |
2437 }; | 2441 }; |
2438 | 2442 |
2439 | 2443 |
2440 // An ExternalArray represents a fixed-size array of primitive values | 2444 // An ExternalArray represents a fixed-size array of primitive values |
2441 // which live outside the JavaScript heap. Its subclasses are used to | 2445 // which live outside the JavaScript heap. Its subclasses are used to |
2442 // implement the CanvasArray types being defined in the WebGL | 2446 // implement the CanvasArray types being defined in the WebGL |
2443 // specification. As of this writing the first public draft is not yet | 2447 // specification. As of this writing the first public draft is not yet |
2444 // available, but Khronos members can access the draft at: | 2448 // available, but Khronos members can access the draft at: |
2445 // https://cvs.khronos.org/svn/repos/3dweb/trunk/doc/spec/WebGL-spec.html | 2449 // https://cvs.khronos.org/svn/repos/3dweb/trunk/doc/spec/WebGL-spec.html |
2446 // | 2450 // |
2447 // The semantics of these arrays differ from CanvasPixelArray. | 2451 // The semantics of these arrays differ from CanvasPixelArray. |
2448 // Out-of-range values passed to the setter are converted via a C | 2452 // Out-of-range values passed to the setter are converted via a C |
2449 // cast, not clamping. Out-of-range indices cause exceptions to be | 2453 // cast, not clamping. Out-of-range indices cause exceptions to be |
2450 // raised rather than being silently ignored. | 2454 // raised rather than being silently ignored. |
2451 class ExternalArray: public HeapObject { | 2455 class ExternalArray: public Array { |
2452 public: | 2456 public: |
2453 // [length]: length of the array. | |
2454 inline int length(); | |
2455 inline void set_length(int value); | |
2456 | |
2457 // [external_pointer]: The pointer to the external memory area backing this | 2457 // [external_pointer]: The pointer to the external memory area backing this |
2458 // external array. | 2458 // external array. |
2459 DECL_ACCESSORS(external_pointer, void) // Pointer to the data store. | 2459 DECL_ACCESSORS(external_pointer, void) // Pointer to the data store. |
2460 | 2460 |
2461 // Casting. | 2461 // Casting. |
2462 static inline ExternalArray* cast(Object* obj); | 2462 static inline ExternalArray* cast(Object* obj); |
2463 | 2463 |
2464 // Maximal acceptable length for an external array. | 2464 // Maximal acceptable length for an external array. |
2465 static const int kMaxLength = 0x3fffffff; | 2465 static const int kMaxLength = 0x3fffffff; |
2466 | 2466 |
2467 // ExternalArray headers are not quadword aligned. | 2467 // ExternalArray headers are not quadword aligned. |
2468 static const int kLengthOffset = HeapObject::kHeaderSize; | 2468 static const int kExternalPointerOffset = Array::kAlignedSize; |
2469 static const int kExternalPointerOffset = | |
2470 POINTER_SIZE_ALIGN(kLengthOffset + kIntSize); | |
2471 static const int kHeaderSize = kExternalPointerOffset + kPointerSize; | 2469 static const int kHeaderSize = kExternalPointerOffset + kPointerSize; |
2472 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); | 2470 static const int kAlignedSize = OBJECT_SIZE_ALIGN(kHeaderSize); |
2473 | 2471 |
2474 private: | 2472 private: |
2475 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalArray); | 2473 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalArray); |
2476 }; | 2474 }; |
2477 | 2475 |
2478 | 2476 |
2479 class ExternalByteArray: public ExternalArray { | 2477 class ExternalByteArray: public ExternalArray { |
2480 public: | 2478 public: |
2481 // Setter and getter. | 2479 // Setter and getter. |
2482 inline int8_t get(int index); | 2480 inline int8_t get(int index); |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3016 | 3014 |
3017 // Layout description. | 3015 // Layout description. |
3018 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; | 3016 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; |
3019 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; | 3017 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; |
3020 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize; | 3018 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize; |
3021 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; | 3019 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; |
3022 static const int kInstanceDescriptorsOffset = | 3020 static const int kInstanceDescriptorsOffset = |
3023 kConstructorOffset + kPointerSize; | 3021 kConstructorOffset + kPointerSize; |
3024 static const int kCodeCacheOffset = kInstanceDescriptorsOffset + kPointerSize; | 3022 static const int kCodeCacheOffset = kInstanceDescriptorsOffset + kPointerSize; |
3025 static const int kPadStart = kCodeCacheOffset + kPointerSize; | 3023 static const int kPadStart = kCodeCacheOffset + kPointerSize; |
3026 static const int kSize = MAP_POINTER_ALIGN(kPadStart); | 3024 static const int kSize = MAP_SIZE_ALIGN(kPadStart); |
3027 | |
3028 // Layout of pointer fields. Heap iteration code relies on them | |
3029 // being continiously allocated. | |
3030 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset; | |
3031 static const int kPointerFieldsEndOffset = | |
3032 Map::kCodeCacheOffset + kPointerSize; | |
3033 | 3025 |
3034 // Byte offsets within kInstanceSizesOffset. | 3026 // Byte offsets within kInstanceSizesOffset. |
3035 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; | 3027 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; |
3036 static const int kInObjectPropertiesByte = 1; | 3028 static const int kInObjectPropertiesByte = 1; |
3037 static const int kInObjectPropertiesOffset = | 3029 static const int kInObjectPropertiesOffset = |
3038 kInstanceSizesOffset + kInObjectPropertiesByte; | 3030 kInstanceSizesOffset + kInObjectPropertiesByte; |
3039 static const int kPreAllocatedPropertyFieldsByte = 2; | 3031 static const int kPreAllocatedPropertyFieldsByte = 2; |
3040 static const int kPreAllocatedPropertyFieldsOffset = | 3032 static const int kPreAllocatedPropertyFieldsOffset = |
3041 kInstanceSizesOffset + kPreAllocatedPropertyFieldsByte; | 3033 kInstanceSizesOffset + kPreAllocatedPropertyFieldsByte; |
3042 // The byte at position 3 is not in use at the moment. | 3034 // The byte at position 3 is not in use at the moment. |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3334 static const int kConstructStubOffset = kCodeOffset + kPointerSize; | 3326 static const int kConstructStubOffset = kCodeOffset + kPointerSize; |
3335 static const int kInstanceClassNameOffset = | 3327 static const int kInstanceClassNameOffset = |
3336 kConstructStubOffset + kPointerSize; | 3328 kConstructStubOffset + kPointerSize; |
3337 static const int kFunctionDataOffset = | 3329 static const int kFunctionDataOffset = |
3338 kInstanceClassNameOffset + kPointerSize; | 3330 kInstanceClassNameOffset + kPointerSize; |
3339 static const int kScriptOffset = kFunctionDataOffset + kPointerSize; | 3331 static const int kScriptOffset = kFunctionDataOffset + kPointerSize; |
3340 static const int kDebugInfoOffset = kScriptOffset + kPointerSize; | 3332 static const int kDebugInfoOffset = kScriptOffset + kPointerSize; |
3341 static const int kInferredNameOffset = kDebugInfoOffset + kPointerSize; | 3333 static const int kInferredNameOffset = kDebugInfoOffset + kPointerSize; |
3342 static const int kThisPropertyAssignmentsOffset = | 3334 static const int kThisPropertyAssignmentsOffset = |
3343 kInferredNameOffset + kPointerSize; | 3335 kInferredNameOffset + kPointerSize; |
3344 #if V8_HOST_ARCH_32_BIT | 3336 // Integer fields. |
3345 // Smi fields. | |
3346 static const int kLengthOffset = | 3337 static const int kLengthOffset = |
3347 kThisPropertyAssignmentsOffset + kPointerSize; | 3338 kThisPropertyAssignmentsOffset + kPointerSize; |
3348 static const int kFormalParameterCountOffset = kLengthOffset + kPointerSize; | 3339 static const int kFormalParameterCountOffset = kLengthOffset + kIntSize; |
3349 static const int kExpectedNofPropertiesOffset = | |
3350 kFormalParameterCountOffset + kPointerSize; | |
3351 static const int kNumLiteralsOffset = | |
3352 kExpectedNofPropertiesOffset + kPointerSize; | |
3353 static const int kStartPositionAndTypeOffset = | |
3354 kNumLiteralsOffset + kPointerSize; | |
3355 static const int kEndPositionOffset = | |
3356 kStartPositionAndTypeOffset + kPointerSize; | |
3357 static const int kFunctionTokenPositionOffset = | |
3358 kEndPositionOffset + kPointerSize; | |
3359 static const int kCompilerHintsOffset = | |
3360 kFunctionTokenPositionOffset + kPointerSize; | |
3361 static const int kThisPropertyAssignmentsCountOffset = | |
3362 kCompilerHintsOffset + kPointerSize; | |
3363 // Total size. | |
3364 static const int kSize = kThisPropertyAssignmentsCountOffset + kPointerSize; | |
3365 #else | |
3366 // The only reason to use smi fields instead of int fields | |
3367 // is to allow interation without maps decoding during | |
3368 // garbage collections. | |
3369 // To avoid wasting space on 64-bit architectures we use | |
3370 // the following trick: we group integer fields into pairs | |
3371 // First integer in each pair is shifted left by 1. | |
3372 // By doing this we guarantee that LSB of each kPointerSize aligned | |
3373 // word is not set and thus this word cannot be treated as pointer | |
3374 // to HeapObject during old space traversal. | |
3375 static const int kLengthOffset = | |
3376 kThisPropertyAssignmentsOffset + kPointerSize; | |
3377 static const int kFormalParameterCountOffset = | |
3378 kLengthOffset + kIntSize; | |
3379 | |
3380 static const int kExpectedNofPropertiesOffset = | 3340 static const int kExpectedNofPropertiesOffset = |
3381 kFormalParameterCountOffset + kIntSize; | 3341 kFormalParameterCountOffset + kIntSize; |
3382 static const int kNumLiteralsOffset = | 3342 static const int kNumLiteralsOffset = kExpectedNofPropertiesOffset + kIntSize; |
3383 kExpectedNofPropertiesOffset + kIntSize; | 3343 static const int kStartPositionAndTypeOffset = |
3384 | |
3385 static const int kEndPositionOffset = | |
3386 kNumLiteralsOffset + kIntSize; | 3344 kNumLiteralsOffset + kIntSize; |
3387 static const int kStartPositionAndTypeOffset = | 3345 static const int kEndPositionOffset = kStartPositionAndTypeOffset + kIntSize; |
3388 kEndPositionOffset + kIntSize; | 3346 static const int kFunctionTokenPositionOffset = kEndPositionOffset + kIntSize; |
3389 | |
3390 static const int kFunctionTokenPositionOffset = | |
3391 kStartPositionAndTypeOffset + kIntSize; | |
3392 static const int kCompilerHintsOffset = | 3347 static const int kCompilerHintsOffset = |
3393 kFunctionTokenPositionOffset + kIntSize; | 3348 kFunctionTokenPositionOffset + kIntSize; |
3394 | |
3395 static const int kThisPropertyAssignmentsCountOffset = | 3349 static const int kThisPropertyAssignmentsCountOffset = |
3396 kCompilerHintsOffset + kIntSize; | 3350 kCompilerHintsOffset + kIntSize; |
3397 | |
3398 // Total size. | 3351 // Total size. |
3399 static const int kSize = kThisPropertyAssignmentsCountOffset + kIntSize; | 3352 static const int kSize = kThisPropertyAssignmentsCountOffset + kIntSize; |
3400 | |
3401 #endif | |
3402 static const int kAlignedSize = POINTER_SIZE_ALIGN(kSize); | 3353 static const int kAlignedSize = POINTER_SIZE_ALIGN(kSize); |
3403 | 3354 |
3404 private: | 3355 private: |
3405 // Bit positions in start_position_and_type. | 3356 // Bit positions in start_position_and_type. |
3406 // The source code start position is in the 30 most significant bits of | 3357 // The source code start position is in the 30 most significant bits of |
3407 // the start_position_and_type field. | 3358 // the start_position_and_type field. |
3408 static const int kIsExpressionBit = 0; | 3359 static const int kIsExpressionBit = 0; |
3409 static const int kIsTopLevelBit = 1; | 3360 static const int kIsTopLevelBit = 1; |
3410 static const int kStartPositionShift = 2; | 3361 static const int kStartPositionShift = 2; |
3411 static const int kStartPositionMask = ~((1 << kStartPositionShift) - 1); | 3362 static const int kStartPositionMask = ~((1 << kStartPositionShift) - 1); |
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4147 void StringShortPrint(StringStream* accumulator); | 4098 void StringShortPrint(StringStream* accumulator); |
4148 #ifdef DEBUG | 4099 #ifdef DEBUG |
4149 void StringPrint(); | 4100 void StringPrint(); |
4150 void StringVerify(); | 4101 void StringVerify(); |
4151 #endif | 4102 #endif |
4152 inline bool IsFlat(); | 4103 inline bool IsFlat(); |
4153 | 4104 |
4154 // Layout description. | 4105 // Layout description. |
4155 static const int kLengthOffset = HeapObject::kHeaderSize; | 4106 static const int kLengthOffset = HeapObject::kHeaderSize; |
4156 static const int kHashFieldOffset = kLengthOffset + kPointerSize; | 4107 static const int kHashFieldOffset = kLengthOffset + kPointerSize; |
4157 static const int kSize = kHashFieldOffset + kPointerSize; | 4108 static const int kSize = kHashFieldOffset + kIntSize; |
| 4109 // Notice: kSize is not pointer-size aligned if pointers are 64-bit. |
4158 | 4110 |
4159 // Maximum number of characters to consider when trying to convert a string | 4111 // Maximum number of characters to consider when trying to convert a string |
4160 // value into an array index. | 4112 // value into an array index. |
4161 static const int kMaxArrayIndexSize = 10; | 4113 static const int kMaxArrayIndexSize = 10; |
4162 | 4114 |
4163 // Max ascii char code. | 4115 // Max ascii char code. |
4164 static const int kMaxAsciiCharCode = unibrow::Utf8::kMaxOneByteChar; | 4116 static const int kMaxAsciiCharCode = unibrow::Utf8::kMaxOneByteChar; |
4165 static const unsigned kMaxAsciiCharCodeU = unibrow::Utf8::kMaxOneByteChar; | 4117 static const unsigned kMaxAsciiCharCodeU = unibrow::Utf8::kMaxOneByteChar; |
4166 static const int kMaxUC16CharCode = 0xffff; | 4118 static const int kMaxUC16CharCode = 0xffff; |
4167 | 4119 |
4168 // Minimum length for a cons string. | 4120 // Minimum length for a cons string. |
4169 static const int kMinNonFlatLength = 13; | 4121 static const int kMinNonFlatLength = 13; |
4170 | 4122 |
4171 // Mask constant for checking if a string has a computed hash code | 4123 // Mask constant for checking if a string has a computed hash code |
4172 // and if it is an array index. The least significant bit indicates | 4124 // and if it is an array index. The least significant bit indicates |
4173 // whether a hash code has been computed. If the hash code has been | 4125 // whether a hash code has been computed. If the hash code has been |
4174 // computed the 2nd bit tells whether the string can be used as an | 4126 // computed the 2nd bit tells whether the string can be used as an |
4175 // array index. | 4127 // array index. |
4176 static const int kHashNotComputedMask = 1; | 4128 static const int kHashComputedMask = 1; |
4177 static const int kIsArrayIndexMask = 1 << 1; | 4129 static const int kIsArrayIndexMask = 1 << 1; |
4178 static const int kNofLengthBitFields = 2; | 4130 static const int kNofLengthBitFields = 2; |
4179 | 4131 |
4180 // Shift constant retrieving hash code from hash field. | 4132 // Shift constant retrieving hash code from hash field. |
4181 static const int kHashShift = kNofLengthBitFields; | 4133 static const int kHashShift = kNofLengthBitFields; |
4182 | 4134 |
4183 // Array index strings this short can keep their index in the hash | 4135 // Array index strings this short can keep their index in the hash |
4184 // field. | 4136 // field. |
4185 static const int kMaxCachedArrayIndexLength = 7; | 4137 static const int kMaxCachedArrayIndexLength = 7; |
4186 | 4138 |
4187 // For strings which are array indexes the hash value has the string length | 4139 // For strings which are array indexes the hash value has the string length |
4188 // mixed into the hash, mainly to avoid a hash value of zero which would be | 4140 // mixed into the hash, mainly to avoid a hash value of zero which would be |
4189 // the case for the string '0'. 24 bits are used for the array index value. | 4141 // the case for the string '0'. 24 bits are used for the array index value. |
4190 static const int kArrayIndexHashLengthShift = 24 + kNofLengthBitFields; | 4142 static const int kArrayIndexHashLengthShift = 24 + kNofLengthBitFields; |
4191 static const int kArrayIndexHashMask = (1 << kArrayIndexHashLengthShift) - 1; | 4143 static const int kArrayIndexHashMask = (1 << kArrayIndexHashLengthShift) - 1; |
4192 static const int kArrayIndexValueBits = | 4144 static const int kArrayIndexValueBits = |
4193 kArrayIndexHashLengthShift - kHashShift; | 4145 kArrayIndexHashLengthShift - kHashShift; |
4194 static const int kArrayIndexValueMask = | |
4195 ((1 << kArrayIndexValueBits) - 1) << kHashShift; | |
4196 | 4146 |
4197 // Value of empty hash field indicating that the hash is not computed. | 4147 // Value of empty hash field indicating that the hash is not computed. |
4198 static const int kEmptyHashField = kHashNotComputedMask; | 4148 static const int kEmptyHashField = 0; |
4199 | |
4200 // Value of hash field containing computed hash equal to zero. | |
4201 static const int kZeroHash = 0; | |
4202 | 4149 |
4203 // Maximal string length. | 4150 // Maximal string length. |
4204 static const int kMaxLength = (1 << (32 - 2)) - 1; | 4151 static const int kMaxLength = (1 << (32 - 2)) - 1; |
4205 | 4152 |
4206 // Max length for computing hash. For strings longer than this limit the | 4153 // Max length for computing hash. For strings longer than this limit the |
4207 // string length is used as the hash value. | 4154 // string length is used as the hash value. |
4208 static const int kMaxHashCalcLength = 16383; | 4155 static const int kMaxHashCalcLength = 16383; |
4209 | 4156 |
4210 // Limit for truncation in short printing. | 4157 // Limit for truncation in short printing. |
4211 static const int kMaxShortPrintLength = 1024; | 4158 static const int kMaxShortPrintLength = 1024; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4259 ReadBlockBuffer* buffer, | 4206 ReadBlockBuffer* buffer, |
4260 unsigned* offset_ptr, | 4207 unsigned* offset_ptr, |
4261 unsigned max_chars); | 4208 unsigned max_chars); |
4262 | 4209 |
4263 private: | 4210 private: |
4264 // Try to flatten the top level ConsString that is hiding behind this | 4211 // Try to flatten the top level ConsString that is hiding behind this |
4265 // string. This is a no-op unless the string is a ConsString. Flatten | 4212 // string. This is a no-op unless the string is a ConsString. Flatten |
4266 // mutates the ConsString and might return a failure. | 4213 // mutates the ConsString and might return a failure. |
4267 Object* SlowTryFlatten(PretenureFlag pretenure); | 4214 Object* SlowTryFlatten(PretenureFlag pretenure); |
4268 | 4215 |
4269 static inline bool IsHashFieldComputed(uint32_t field); | |
4270 | |
4271 // Slow case of String::Equals. This implementation works on any strings | 4216 // Slow case of String::Equals. This implementation works on any strings |
4272 // but it is most efficient on strings that are almost flat. | 4217 // but it is most efficient on strings that are almost flat. |
4273 bool SlowEquals(String* other); | 4218 bool SlowEquals(String* other); |
4274 | 4219 |
4275 // Slow case of AsArrayIndex. | 4220 // Slow case of AsArrayIndex. |
4276 bool SlowAsArrayIndex(uint32_t* index); | 4221 bool SlowAsArrayIndex(uint32_t* index); |
4277 | 4222 |
4278 // Compute and set the hash code. | 4223 // Compute and set the hash code. |
4279 uint32_t ComputeAndSetHash(); | 4224 uint32_t ComputeAndSetHash(); |
4280 | 4225 |
(...skipping 29 matching lines...) Expand all Loading... |
4310 // Casting | 4255 // Casting |
4311 static inline SeqAsciiString* cast(Object* obj); | 4256 static inline SeqAsciiString* cast(Object* obj); |
4312 | 4257 |
4313 // Garbage collection support. This method is called by the | 4258 // Garbage collection support. This method is called by the |
4314 // garbage collector to compute the actual size of an AsciiString | 4259 // garbage collector to compute the actual size of an AsciiString |
4315 // instance. | 4260 // instance. |
4316 inline int SeqAsciiStringSize(InstanceType instance_type); | 4261 inline int SeqAsciiStringSize(InstanceType instance_type); |
4317 | 4262 |
4318 // Computes the size for an AsciiString instance of a given length. | 4263 // Computes the size for an AsciiString instance of a given length. |
4319 static int SizeFor(int length) { | 4264 static int SizeFor(int length) { |
4320 return OBJECT_POINTER_ALIGN(kHeaderSize + length * kCharSize); | 4265 return OBJECT_SIZE_ALIGN(kHeaderSize + length * kCharSize); |
4321 } | 4266 } |
4322 | 4267 |
4323 // Layout description. | 4268 // Layout description. |
4324 static const int kHeaderSize = String::kSize; | 4269 static const int kHeaderSize = String::kSize; |
4325 static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize); | 4270 static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize); |
4326 | 4271 |
4327 // Maximal memory usage for a single sequential ASCII string. | 4272 // Maximal memory usage for a single sequential ASCII string. |
4328 static const int kMaxSize = 512 * MB; | 4273 static const int kMaxSize = 512 * MB; |
4329 // Maximal length of a single sequential ASCII string. | 4274 // Maximal length of a single sequential ASCII string. |
4330 // Q.v. String::kMaxLength which is the maximal size of concatenated strings. | 4275 // Q.v. String::kMaxLength which is the maximal size of concatenated strings. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4362 // Casting | 4307 // Casting |
4363 static inline SeqTwoByteString* cast(Object* obj); | 4308 static inline SeqTwoByteString* cast(Object* obj); |
4364 | 4309 |
4365 // Garbage collection support. This method is called by the | 4310 // Garbage collection support. This method is called by the |
4366 // garbage collector to compute the actual size of a TwoByteString | 4311 // garbage collector to compute the actual size of a TwoByteString |
4367 // instance. | 4312 // instance. |
4368 inline int SeqTwoByteStringSize(InstanceType instance_type); | 4313 inline int SeqTwoByteStringSize(InstanceType instance_type); |
4369 | 4314 |
4370 // Computes the size for a TwoByteString instance of a given length. | 4315 // Computes the size for a TwoByteString instance of a given length. |
4371 static int SizeFor(int length) { | 4316 static int SizeFor(int length) { |
4372 return OBJECT_POINTER_ALIGN(kHeaderSize + length * kShortSize); | 4317 return OBJECT_SIZE_ALIGN(kHeaderSize + length * kShortSize); |
4373 } | 4318 } |
4374 | 4319 |
4375 // Layout description. | 4320 // Layout description. |
4376 static const int kHeaderSize = String::kSize; | 4321 static const int kHeaderSize = String::kSize; |
4377 static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize); | 4322 static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize); |
4378 | 4323 |
4379 // Maximal memory usage for a single sequential two-byte string. | 4324 // Maximal memory usage for a single sequential two-byte string. |
4380 static const int kMaxSize = 512 * MB; | 4325 static const int kMaxSize = 512 * MB; |
4381 // Maximal length of a single sequential two-byte string. | 4326 // Maximal length of a single sequential two-byte string. |
4382 // Q.v. String::kMaxLength which is the maximal size of concatenated strings. | 4327 // Q.v. String::kMaxLength which is the maximal size of concatenated strings. |
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5234 } else { | 5179 } else { |
5235 value &= ~(1 << bit_position); | 5180 value &= ~(1 << bit_position); |
5236 } | 5181 } |
5237 return value; | 5182 return value; |
5238 } | 5183 } |
5239 }; | 5184 }; |
5240 | 5185 |
5241 } } // namespace v8::internal | 5186 } } // namespace v8::internal |
5242 | 5187 |
5243 #endif // V8_OBJECTS_H_ | 5188 #endif // V8_OBJECTS_H_ |
OLD | NEW |