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