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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1587 Object* structure, | 1591 Object* structure, |
1588 PropertyAttributes attributes); | 1592 PropertyAttributes attributes); |
1589 Object* DefineGetterSetter(String* name, PropertyAttributes attributes); | 1593 Object* DefineGetterSetter(String* name, PropertyAttributes attributes); |
1590 | 1594 |
1591 void LookupInDescriptor(String* name, LookupResult* result); | 1595 void LookupInDescriptor(String* name, LookupResult* result); |
1592 | 1596 |
1593 DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject); | 1597 DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject); |
1594 }; | 1598 }; |
1595 | 1599 |
1596 | 1600 |
1597 // Abstract super class arrays. It provides length behavior. | 1601 // FixedArray describes fixed-sized arrays with element type Object*. |
1598 class Array: public HeapObject { | 1602 class FixedArray: public HeapObject { |
1599 public: | 1603 public: |
1600 // [length]: length of the array. | 1604 // [length]: length of the array. |
1601 inline int length(); | 1605 inline int length(); |
1602 inline void set_length(int value); | 1606 inline void set_length(int value); |
1603 | 1607 |
1604 // Convert an object to an array index. | |
1605 // Returns true if the conversion succeeded. | |
1606 static inline bool IndexFromObject(Object* object, uint32_t* index); | |
1607 | |
1608 // Layout descriptor. | |
1609 static const int kLengthOffset = HeapObject::kHeaderSize; | |
1610 | |
1611 protected: | |
1612 // No code should use the Array class directly, only its subclasses. | |
1613 // Use the kHeaderSize of the appropriate subclass, which may be aligned. | |
1614 static const int kHeaderSize = kLengthOffset + kIntSize; | |
1615 static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize); | |
1616 | |
1617 private: | |
1618 DISALLOW_IMPLICIT_CONSTRUCTORS(Array); | |
1619 }; | |
1620 | |
1621 | |
1622 // FixedArray describes fixed sized arrays where element | |
1623 // type is Object*. | |
1624 | |
1625 class FixedArray: public Array { | |
1626 public: | |
1627 | |
1628 // Setter and getter for elements. | 1608 // Setter and getter for elements. |
1629 inline Object* get(int index); | 1609 inline Object* get(int index); |
1630 // Setter that uses write barrier. | 1610 // Setter that uses write barrier. |
1631 inline void set(int index, Object* value); | 1611 inline void set(int index, Object* value); |
1632 | 1612 |
1633 // Setter that doesn't need write barrier). | 1613 // Setter that doesn't need write barrier). |
1634 inline void set(int index, Smi* value); | 1614 inline void set(int index, Smi* value); |
1635 // Setter with explicit barrier mode. | 1615 // Setter with explicit barrier mode. |
1636 inline void set(int index, Object* value, WriteBarrierMode mode); | 1616 inline void set(int index, Object* value, WriteBarrierMode mode); |
1637 | 1617 |
(...skipping 20 matching lines...) Expand all Loading... |
1658 | 1638 |
1659 // Garbage collection support. | 1639 // Garbage collection support. |
1660 static int SizeFor(int length) { return kHeaderSize + length * kPointerSize; } | 1640 static int SizeFor(int length) { return kHeaderSize + length * kPointerSize; } |
1661 | 1641 |
1662 // Code Generation support. | 1642 // Code Generation support. |
1663 static int OffsetOfElementAt(int index) { return SizeFor(index); } | 1643 static int OffsetOfElementAt(int index) { return SizeFor(index); } |
1664 | 1644 |
1665 // Casting. | 1645 // Casting. |
1666 static inline FixedArray* cast(Object* obj); | 1646 static inline FixedArray* cast(Object* obj); |
1667 | 1647 |
1668 static const int kHeaderSize = Array::kAlignedSize; | 1648 // Layout description. |
| 1649 // Length is smi tagged when it is stored. |
| 1650 static const int kLengthOffset = HeapObject::kHeaderSize; |
| 1651 static const int kHeaderSize = kLengthOffset + kPointerSize; |
1669 | 1652 |
1670 // Maximal allowed size, in bytes, of a single FixedArray. | 1653 // Maximal allowed size, in bytes, of a single FixedArray. |
1671 // Prevents overflowing size computations, as well as extreme memory | 1654 // Prevents overflowing size computations, as well as extreme memory |
1672 // consumption. | 1655 // consumption. |
1673 static const int kMaxSize = 512 * MB; | 1656 static const int kMaxSize = 512 * MB; |
1674 // Maximally allowed length of a FixedArray. | 1657 // Maximally allowed length of a FixedArray. |
1675 static const int kMaxLength = (kMaxSize - kHeaderSize) / kPointerSize; | 1658 static const int kMaxLength = (kMaxSize - kHeaderSize) / kPointerSize; |
1676 | 1659 |
1677 // Dispatched behavior. | 1660 // Dispatched behavior. |
1678 int FixedArraySize() { return SizeFor(length()); } | 1661 int FixedArraySize() { return SizeFor(length()); } |
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2357 | 2340 |
2358 #ifdef DEBUG | 2341 #ifdef DEBUG |
2359 void JSFunctionResultCacheVerify(); | 2342 void JSFunctionResultCacheVerify(); |
2360 #endif | 2343 #endif |
2361 }; | 2344 }; |
2362 | 2345 |
2363 | 2346 |
2364 // ByteArray represents fixed sized byte arrays. Used by the outside world, | 2347 // ByteArray represents fixed sized byte arrays. Used by the outside world, |
2365 // 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 |
2366 // fill in free blocks in the heap. | 2349 // fill in free blocks in the heap. |
2367 class ByteArray: public Array { | 2350 class ByteArray: public HeapObject { |
2368 public: | 2351 public: |
| 2352 // [length]: length of the array. |
| 2353 inline int length(); |
| 2354 inline void set_length(int value); |
| 2355 |
2369 // Setter and getter. | 2356 // Setter and getter. |
2370 inline byte get(int index); | 2357 inline byte get(int index); |
2371 inline void set(int index, byte value); | 2358 inline void set(int index, byte value); |
2372 | 2359 |
2373 // Treat contents as an int array. | 2360 // Treat contents as an int array. |
2374 inline int get_int(int index); | 2361 inline int get_int(int index); |
2375 | 2362 |
2376 static int SizeFor(int length) { | 2363 static int SizeFor(int length) { |
2377 return OBJECT_SIZE_ALIGN(kHeaderSize + length); | 2364 return OBJECT_POINTER_ALIGN(kHeaderSize + length); |
2378 } | 2365 } |
2379 // We use byte arrays for free blocks in the heap. Given a desired size in | 2366 // We use byte arrays for free blocks in the heap. Given a desired size in |
2380 // bytes that is a multiple of the word size and big enough to hold a byte | 2367 // bytes that is a multiple of the word size and big enough to hold a byte |
2381 // array, this function returns the number of elements a byte array should | 2368 // array, this function returns the number of elements a byte array should |
2382 // have. | 2369 // have. |
2383 static int LengthFor(int size_in_bytes) { | 2370 static int LengthFor(int size_in_bytes) { |
2384 ASSERT(IsAligned(size_in_bytes, kPointerSize)); | 2371 ASSERT(IsAligned(size_in_bytes, kPointerSize)); |
2385 ASSERT(size_in_bytes >= kHeaderSize); | 2372 ASSERT(size_in_bytes >= kHeaderSize); |
2386 return size_in_bytes - kHeaderSize; | 2373 return size_in_bytes - kHeaderSize; |
2387 } | 2374 } |
2388 | 2375 |
2389 // Returns data start address. | 2376 // Returns data start address. |
2390 inline Address GetDataStartAddress(); | 2377 inline Address GetDataStartAddress(); |
2391 | 2378 |
2392 // Returns a pointer to the ByteArray object for a given data start address. | 2379 // Returns a pointer to the ByteArray object for a given data start address. |
2393 static inline ByteArray* FromDataStartAddress(Address address); | 2380 static inline ByteArray* FromDataStartAddress(Address address); |
2394 | 2381 |
2395 // Casting. | 2382 // Casting. |
2396 static inline ByteArray* cast(Object* obj); | 2383 static inline ByteArray* cast(Object* obj); |
2397 | 2384 |
2398 // Dispatched behavior. | 2385 // Dispatched behavior. |
2399 int ByteArraySize() { return SizeFor(length()); } | 2386 int ByteArraySize() { return SizeFor(length()); } |
2400 #ifdef DEBUG | 2387 #ifdef DEBUG |
2401 void ByteArrayPrint(); | 2388 void ByteArrayPrint(); |
2402 void ByteArrayVerify(); | 2389 void ByteArrayVerify(); |
2403 #endif | 2390 #endif |
2404 | 2391 |
2405 // ByteArray headers are not quadword aligned. | 2392 // Layout description. |
2406 static const int kHeaderSize = Array::kHeaderSize; | 2393 // Length is smi tagged when it is stored. |
2407 static const int kAlignedSize = Array::kAlignedSize; | 2394 static const int kLengthOffset = HeapObject::kHeaderSize; |
| 2395 static const int kHeaderSize = kLengthOffset + kPointerSize; |
| 2396 |
| 2397 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); |
2408 | 2398 |
2409 // Maximal memory consumption for a single ByteArray. | 2399 // Maximal memory consumption for a single ByteArray. |
2410 static const int kMaxSize = 512 * MB; | 2400 static const int kMaxSize = 512 * MB; |
2411 // Maximal length of a single ByteArray. | 2401 // Maximal length of a single ByteArray. |
2412 static const int kMaxLength = kMaxSize - kHeaderSize; | 2402 static const int kMaxLength = kMaxSize - kHeaderSize; |
2413 | 2403 |
2414 private: | 2404 private: |
2415 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); | 2405 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); |
2416 }; | 2406 }; |
2417 | 2407 |
2418 | 2408 |
2419 // A PixelArray represents a fixed-size byte array with special semantics | 2409 // A PixelArray represents a fixed-size byte array with special semantics |
2420 // used for implementing the CanvasPixelArray object. Please see the | 2410 // used for implementing the CanvasPixelArray object. Please see the |
2421 // specification at: | 2411 // specification at: |
2422 // http://www.whatwg.org/specs/web-apps/current-work/ | 2412 // http://www.whatwg.org/specs/web-apps/current-work/ |
2423 // multipage/the-canvas-element.html#canvaspixelarray | 2413 // multipage/the-canvas-element.html#canvaspixelarray |
2424 // In particular, write access clamps the value written to 0 or 255 if the | 2414 // In particular, write access clamps the value written to 0 or 255 if the |
2425 // value written is outside this range. | 2415 // value written is outside this range. |
2426 class PixelArray: public Array { | 2416 class PixelArray: public HeapObject { |
2427 public: | 2417 public: |
| 2418 // [length]: length of the array. |
| 2419 inline int length(); |
| 2420 inline void set_length(int value); |
| 2421 |
2428 // [external_pointer]: The pointer to the external memory area backing this | 2422 // [external_pointer]: The pointer to the external memory area backing this |
2429 // pixel array. | 2423 // pixel array. |
2430 DECL_ACCESSORS(external_pointer, uint8_t) // Pointer to the data store. | 2424 DECL_ACCESSORS(external_pointer, uint8_t) // Pointer to the data store. |
2431 | 2425 |
2432 // Setter and getter. | 2426 // Setter and getter. |
2433 inline uint8_t get(int index); | 2427 inline uint8_t get(int index); |
2434 inline void set(int index, uint8_t value); | 2428 inline void set(int index, uint8_t value); |
2435 | 2429 |
2436 // This accessor applies the correct conversion from Smi, HeapNumber and | 2430 // This accessor applies the correct conversion from Smi, HeapNumber and |
2437 // undefined and clamps the converted value between 0 and 255. | 2431 // undefined and clamps the converted value between 0 and 255. |
2438 Object* SetValue(uint32_t index, Object* value); | 2432 Object* SetValue(uint32_t index, Object* value); |
2439 | 2433 |
2440 // Casting. | 2434 // Casting. |
2441 static inline PixelArray* cast(Object* obj); | 2435 static inline PixelArray* cast(Object* obj); |
2442 | 2436 |
2443 #ifdef DEBUG | 2437 #ifdef DEBUG |
2444 void PixelArrayPrint(); | 2438 void PixelArrayPrint(); |
2445 void PixelArrayVerify(); | 2439 void PixelArrayVerify(); |
2446 #endif // DEBUG | 2440 #endif // DEBUG |
2447 | 2441 |
2448 // Maximal acceptable length for a pixel array. | 2442 // Maximal acceptable length for a pixel array. |
2449 static const int kMaxLength = 0x3fffffff; | 2443 static const int kMaxLength = 0x3fffffff; |
2450 | 2444 |
2451 // PixelArray headers are not quadword aligned. | 2445 // PixelArray headers are not quadword aligned. |
2452 static const int kExternalPointerOffset = Array::kAlignedSize; | 2446 static const int kLengthOffset = HeapObject::kHeaderSize; |
| 2447 static const int kExternalPointerOffset = |
| 2448 POINTER_SIZE_ALIGN(kLengthOffset + kIntSize); |
2453 static const int kHeaderSize = kExternalPointerOffset + kPointerSize; | 2449 static const int kHeaderSize = kExternalPointerOffset + kPointerSize; |
2454 static const int kAlignedSize = OBJECT_SIZE_ALIGN(kHeaderSize); | 2450 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); |
2455 | 2451 |
2456 private: | 2452 private: |
2457 DISALLOW_IMPLICIT_CONSTRUCTORS(PixelArray); | 2453 DISALLOW_IMPLICIT_CONSTRUCTORS(PixelArray); |
2458 }; | 2454 }; |
2459 | 2455 |
2460 | 2456 |
2461 // An ExternalArray represents a fixed-size array of primitive values | 2457 // An ExternalArray represents a fixed-size array of primitive values |
2462 // which live outside the JavaScript heap. Its subclasses are used to | 2458 // which live outside the JavaScript heap. Its subclasses are used to |
2463 // implement the CanvasArray types being defined in the WebGL | 2459 // implement the CanvasArray types being defined in the WebGL |
2464 // specification. As of this writing the first public draft is not yet | 2460 // specification. As of this writing the first public draft is not yet |
2465 // available, but Khronos members can access the draft at: | 2461 // available, but Khronos members can access the draft at: |
2466 // https://cvs.khronos.org/svn/repos/3dweb/trunk/doc/spec/WebGL-spec.html | 2462 // https://cvs.khronos.org/svn/repos/3dweb/trunk/doc/spec/WebGL-spec.html |
2467 // | 2463 // |
2468 // The semantics of these arrays differ from CanvasPixelArray. | 2464 // The semantics of these arrays differ from CanvasPixelArray. |
2469 // Out-of-range values passed to the setter are converted via a C | 2465 // Out-of-range values passed to the setter are converted via a C |
2470 // cast, not clamping. Out-of-range indices cause exceptions to be | 2466 // cast, not clamping. Out-of-range indices cause exceptions to be |
2471 // raised rather than being silently ignored. | 2467 // raised rather than being silently ignored. |
2472 class ExternalArray: public Array { | 2468 class ExternalArray: public HeapObject { |
2473 public: | 2469 public: |
| 2470 // [length]: length of the array. |
| 2471 inline int length(); |
| 2472 inline void set_length(int value); |
| 2473 |
2474 // [external_pointer]: The pointer to the external memory area backing this | 2474 // [external_pointer]: The pointer to the external memory area backing this |
2475 // external array. | 2475 // external array. |
2476 DECL_ACCESSORS(external_pointer, void) // Pointer to the data store. | 2476 DECL_ACCESSORS(external_pointer, void) // Pointer to the data store. |
2477 | 2477 |
2478 // Casting. | 2478 // Casting. |
2479 static inline ExternalArray* cast(Object* obj); | 2479 static inline ExternalArray* cast(Object* obj); |
2480 | 2480 |
2481 // Maximal acceptable length for an external array. | 2481 // Maximal acceptable length for an external array. |
2482 static const int kMaxLength = 0x3fffffff; | 2482 static const int kMaxLength = 0x3fffffff; |
2483 | 2483 |
2484 // ExternalArray headers are not quadword aligned. | 2484 // ExternalArray headers are not quadword aligned. |
2485 static const int kExternalPointerOffset = Array::kAlignedSize; | 2485 static const int kLengthOffset = HeapObject::kHeaderSize; |
| 2486 static const int kExternalPointerOffset = |
| 2487 POINTER_SIZE_ALIGN(kLengthOffset + kIntSize); |
2486 static const int kHeaderSize = kExternalPointerOffset + kPointerSize; | 2488 static const int kHeaderSize = kExternalPointerOffset + kPointerSize; |
2487 static const int kAlignedSize = OBJECT_SIZE_ALIGN(kHeaderSize); | 2489 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); |
2488 | 2490 |
2489 private: | 2491 private: |
2490 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalArray); | 2492 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalArray); |
2491 }; | 2493 }; |
2492 | 2494 |
2493 | 2495 |
2494 class ExternalByteArray: public ExternalArray { | 2496 class ExternalByteArray: public ExternalArray { |
2495 public: | 2497 public: |
2496 // Setter and getter. | 2498 // Setter and getter. |
2497 inline int8_t get(int index); | 2499 inline int8_t get(int index); |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3031 | 3033 |
3032 // Layout description. | 3034 // Layout description. |
3033 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; | 3035 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; |
3034 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; | 3036 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; |
3035 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize; | 3037 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize; |
3036 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; | 3038 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; |
3037 static const int kInstanceDescriptorsOffset = | 3039 static const int kInstanceDescriptorsOffset = |
3038 kConstructorOffset + kPointerSize; | 3040 kConstructorOffset + kPointerSize; |
3039 static const int kCodeCacheOffset = kInstanceDescriptorsOffset + kPointerSize; | 3041 static const int kCodeCacheOffset = kInstanceDescriptorsOffset + kPointerSize; |
3040 static const int kPadStart = kCodeCacheOffset + kPointerSize; | 3042 static const int kPadStart = kCodeCacheOffset + kPointerSize; |
3041 static const int kSize = MAP_SIZE_ALIGN(kPadStart); | 3043 static const int kSize = MAP_POINTER_ALIGN(kPadStart); |
| 3044 |
| 3045 // Layout of pointer fields. Heap iteration code relies on them |
| 3046 // being continiously allocated. |
| 3047 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset; |
| 3048 static const int kPointerFieldsEndOffset = |
| 3049 Map::kCodeCacheOffset + kPointerSize; |
3042 | 3050 |
3043 // Byte offsets within kInstanceSizesOffset. | 3051 // Byte offsets within kInstanceSizesOffset. |
3044 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; | 3052 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; |
3045 static const int kInObjectPropertiesByte = 1; | 3053 static const int kInObjectPropertiesByte = 1; |
3046 static const int kInObjectPropertiesOffset = | 3054 static const int kInObjectPropertiesOffset = |
3047 kInstanceSizesOffset + kInObjectPropertiesByte; | 3055 kInstanceSizesOffset + kInObjectPropertiesByte; |
3048 static const int kPreAllocatedPropertyFieldsByte = 2; | 3056 static const int kPreAllocatedPropertyFieldsByte = 2; |
3049 static const int kPreAllocatedPropertyFieldsOffset = | 3057 static const int kPreAllocatedPropertyFieldsOffset = |
3050 kInstanceSizesOffset + kPreAllocatedPropertyFieldsByte; | 3058 kInstanceSizesOffset + kPreAllocatedPropertyFieldsByte; |
3051 // The byte at position 3 is not in use at the moment. | 3059 // 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... |
3343 static const int kConstructStubOffset = kCodeOffset + kPointerSize; | 3351 static const int kConstructStubOffset = kCodeOffset + kPointerSize; |
3344 static const int kInstanceClassNameOffset = | 3352 static const int kInstanceClassNameOffset = |
3345 kConstructStubOffset + kPointerSize; | 3353 kConstructStubOffset + kPointerSize; |
3346 static const int kFunctionDataOffset = | 3354 static const int kFunctionDataOffset = |
3347 kInstanceClassNameOffset + kPointerSize; | 3355 kInstanceClassNameOffset + kPointerSize; |
3348 static const int kScriptOffset = kFunctionDataOffset + kPointerSize; | 3356 static const int kScriptOffset = kFunctionDataOffset + kPointerSize; |
3349 static const int kDebugInfoOffset = kScriptOffset + kPointerSize; | 3357 static const int kDebugInfoOffset = kScriptOffset + kPointerSize; |
3350 static const int kInferredNameOffset = kDebugInfoOffset + kPointerSize; | 3358 static const int kInferredNameOffset = kDebugInfoOffset + kPointerSize; |
3351 static const int kThisPropertyAssignmentsOffset = | 3359 static const int kThisPropertyAssignmentsOffset = |
3352 kInferredNameOffset + kPointerSize; | 3360 kInferredNameOffset + kPointerSize; |
3353 // Integer fields. | 3361 #if V8_HOST_ARCH_32_BIT |
| 3362 // Smi fields. |
3354 static const int kLengthOffset = | 3363 static const int kLengthOffset = |
3355 kThisPropertyAssignmentsOffset + kPointerSize; | 3364 kThisPropertyAssignmentsOffset + kPointerSize; |
3356 static const int kFormalParameterCountOffset = kLengthOffset + kIntSize; | 3365 static const int kFormalParameterCountOffset = kLengthOffset + kPointerSize; |
| 3366 static const int kExpectedNofPropertiesOffset = |
| 3367 kFormalParameterCountOffset + kPointerSize; |
| 3368 static const int kNumLiteralsOffset = |
| 3369 kExpectedNofPropertiesOffset + kPointerSize; |
| 3370 static const int kStartPositionAndTypeOffset = |
| 3371 kNumLiteralsOffset + kPointerSize; |
| 3372 static const int kEndPositionOffset = |
| 3373 kStartPositionAndTypeOffset + kPointerSize; |
| 3374 static const int kFunctionTokenPositionOffset = |
| 3375 kEndPositionOffset + kPointerSize; |
| 3376 static const int kCompilerHintsOffset = |
| 3377 kFunctionTokenPositionOffset + kPointerSize; |
| 3378 static const int kThisPropertyAssignmentsCountOffset = |
| 3379 kCompilerHintsOffset + kPointerSize; |
| 3380 // Total size. |
| 3381 static const int kSize = kThisPropertyAssignmentsCountOffset + kPointerSize; |
| 3382 #else |
| 3383 // The only reason to use smi fields instead of int fields |
| 3384 // is to allow interation without maps decoding during |
| 3385 // garbage collections. |
| 3386 // To avoid wasting space on 64-bit architectures we use |
| 3387 // the following trick: we group integer fields into pairs |
| 3388 // First integer in each pair is shifted left by 1. |
| 3389 // By doing this we guarantee that LSB of each kPointerSize aligned |
| 3390 // word is not set and thus this word cannot be treated as pointer |
| 3391 // to HeapObject during old space traversal. |
| 3392 static const int kLengthOffset = |
| 3393 kThisPropertyAssignmentsOffset + kPointerSize; |
| 3394 static const int kFormalParameterCountOffset = |
| 3395 kLengthOffset + kIntSize; |
| 3396 |
3357 static const int kExpectedNofPropertiesOffset = | 3397 static const int kExpectedNofPropertiesOffset = |
3358 kFormalParameterCountOffset + kIntSize; | 3398 kFormalParameterCountOffset + kIntSize; |
3359 static const int kNumLiteralsOffset = kExpectedNofPropertiesOffset + kIntSize; | 3399 static const int kNumLiteralsOffset = |
| 3400 kExpectedNofPropertiesOffset + kIntSize; |
| 3401 |
| 3402 static const int kEndPositionOffset = |
| 3403 kNumLiteralsOffset + kIntSize; |
3360 static const int kStartPositionAndTypeOffset = | 3404 static const int kStartPositionAndTypeOffset = |
3361 kNumLiteralsOffset + kIntSize; | 3405 kEndPositionOffset + kIntSize; |
3362 static const int kEndPositionOffset = kStartPositionAndTypeOffset + kIntSize; | 3406 |
3363 static const int kFunctionTokenPositionOffset = kEndPositionOffset + kIntSize; | 3407 static const int kFunctionTokenPositionOffset = |
| 3408 kStartPositionAndTypeOffset + kIntSize; |
3364 static const int kCompilerHintsOffset = | 3409 static const int kCompilerHintsOffset = |
3365 kFunctionTokenPositionOffset + kIntSize; | 3410 kFunctionTokenPositionOffset + kIntSize; |
| 3411 |
3366 static const int kThisPropertyAssignmentsCountOffset = | 3412 static const int kThisPropertyAssignmentsCountOffset = |
3367 kCompilerHintsOffset + kIntSize; | 3413 kCompilerHintsOffset + kIntSize; |
| 3414 |
3368 // Total size. | 3415 // Total size. |
3369 static const int kSize = kThisPropertyAssignmentsCountOffset + kIntSize; | 3416 static const int kSize = kThisPropertyAssignmentsCountOffset + kIntSize; |
| 3417 |
| 3418 #endif |
3370 static const int kAlignedSize = POINTER_SIZE_ALIGN(kSize); | 3419 static const int kAlignedSize = POINTER_SIZE_ALIGN(kSize); |
3371 | 3420 |
3372 private: | 3421 private: |
3373 // Bit positions in start_position_and_type. | 3422 // Bit positions in start_position_and_type. |
3374 // The source code start position is in the 30 most significant bits of | 3423 // The source code start position is in the 30 most significant bits of |
3375 // the start_position_and_type field. | 3424 // the start_position_and_type field. |
3376 static const int kIsExpressionBit = 0; | 3425 static const int kIsExpressionBit = 0; |
3377 static const int kIsTopLevelBit = 1; | 3426 static const int kIsTopLevelBit = 1; |
3378 static const int kStartPositionShift = 2; | 3427 static const int kStartPositionShift = 2; |
3379 static const int kStartPositionMask = ~((1 << kStartPositionShift) - 1); | 3428 static const int kStartPositionMask = ~((1 << kStartPositionShift) - 1); |
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4115 void StringShortPrint(StringStream* accumulator); | 4164 void StringShortPrint(StringStream* accumulator); |
4116 #ifdef DEBUG | 4165 #ifdef DEBUG |
4117 void StringPrint(); | 4166 void StringPrint(); |
4118 void StringVerify(); | 4167 void StringVerify(); |
4119 #endif | 4168 #endif |
4120 inline bool IsFlat(); | 4169 inline bool IsFlat(); |
4121 | 4170 |
4122 // Layout description. | 4171 // Layout description. |
4123 static const int kLengthOffset = HeapObject::kHeaderSize; | 4172 static const int kLengthOffset = HeapObject::kHeaderSize; |
4124 static const int kHashFieldOffset = kLengthOffset + kPointerSize; | 4173 static const int kHashFieldOffset = kLengthOffset + kPointerSize; |
4125 static const int kSize = kHashFieldOffset + kIntSize; | 4174 static const int kSize = kHashFieldOffset + kPointerSize; |
4126 // Notice: kSize is not pointer-size aligned if pointers are 64-bit. | |
4127 | 4175 |
4128 // Maximum number of characters to consider when trying to convert a string | 4176 // Maximum number of characters to consider when trying to convert a string |
4129 // value into an array index. | 4177 // value into an array index. |
4130 static const int kMaxArrayIndexSize = 10; | 4178 static const int kMaxArrayIndexSize = 10; |
4131 | 4179 |
4132 // Max ascii char code. | 4180 // Max ascii char code. |
4133 static const int kMaxAsciiCharCode = unibrow::Utf8::kMaxOneByteChar; | 4181 static const int kMaxAsciiCharCode = unibrow::Utf8::kMaxOneByteChar; |
4134 static const unsigned kMaxAsciiCharCodeU = unibrow::Utf8::kMaxOneByteChar; | 4182 static const unsigned kMaxAsciiCharCodeU = unibrow::Utf8::kMaxOneByteChar; |
4135 static const int kMaxUC16CharCode = 0xffff; | 4183 static const int kMaxUC16CharCode = 0xffff; |
4136 | 4184 |
4137 // Minimum length for a cons string. | 4185 // Minimum length for a cons string. |
4138 static const int kMinNonFlatLength = 13; | 4186 static const int kMinNonFlatLength = 13; |
4139 | 4187 |
4140 // Mask constant for checking if a string has a computed hash code | 4188 // Mask constant for checking if a string has a computed hash code |
4141 // and if it is an array index. The least significant bit indicates | 4189 // and if it is an array index. The least significant bit indicates |
4142 // whether a hash code has been computed. If the hash code has been | 4190 // whether a hash code has been computed. If the hash code has been |
4143 // computed the 2nd bit tells whether the string can be used as an | 4191 // computed the 2nd bit tells whether the string can be used as an |
4144 // array index. | 4192 // array index. |
4145 static const int kHashComputedMask = 1; | 4193 static const int kHashNotComputedMask = 1; |
4146 static const int kIsArrayIndexMask = 1 << 1; | 4194 static const int kIsArrayIndexMask = 1 << 1; |
4147 static const int kNofLengthBitFields = 2; | 4195 static const int kNofLengthBitFields = 2; |
4148 | 4196 |
4149 // Shift constant retrieving hash code from hash field. | 4197 // Shift constant retrieving hash code from hash field. |
4150 static const int kHashShift = kNofLengthBitFields; | 4198 static const int kHashShift = kNofLengthBitFields; |
4151 | 4199 |
4152 // Array index strings this short can keep their index in the hash | 4200 // Array index strings this short can keep their index in the hash |
4153 // field. | 4201 // field. |
4154 static const int kMaxCachedArrayIndexLength = 7; | 4202 static const int kMaxCachedArrayIndexLength = 7; |
4155 | 4203 |
4156 // For strings which are array indexes the hash value has the string length | 4204 // For strings which are array indexes the hash value has the string length |
4157 // mixed into the hash, mainly to avoid a hash value of zero which would be | 4205 // mixed into the hash, mainly to avoid a hash value of zero which would be |
4158 // the case for the string '0'. 24 bits are used for the array index value. | 4206 // the case for the string '0'. 24 bits are used for the array index value. |
4159 static const int kArrayIndexHashLengthShift = 24 + kNofLengthBitFields; | 4207 static const int kArrayIndexHashLengthShift = 24 + kNofLengthBitFields; |
4160 static const int kArrayIndexHashMask = (1 << kArrayIndexHashLengthShift) - 1; | 4208 static const int kArrayIndexHashMask = (1 << kArrayIndexHashLengthShift) - 1; |
4161 static const int kArrayIndexValueBits = | 4209 static const int kArrayIndexValueBits = |
4162 kArrayIndexHashLengthShift - kHashShift; | 4210 kArrayIndexHashLengthShift - kHashShift; |
| 4211 static const int kArrayIndexValueMask = |
| 4212 ((1 << kArrayIndexValueBits) - 1) << kHashShift; |
4163 | 4213 |
4164 // Value of empty hash field indicating that the hash is not computed. | 4214 // Value of empty hash field indicating that the hash is not computed. |
4165 static const int kEmptyHashField = 0; | 4215 static const int kEmptyHashField = kHashNotComputedMask; |
| 4216 |
| 4217 // Value of hash field containing computed hash equal to zero. |
| 4218 static const int kZeroHash = 0; |
4166 | 4219 |
4167 // Maximal string length. | 4220 // Maximal string length. |
4168 static const int kMaxLength = (1 << (32 - 2)) - 1; | 4221 static const int kMaxLength = (1 << (32 - 2)) - 1; |
4169 | 4222 |
4170 // Max length for computing hash. For strings longer than this limit the | 4223 // Max length for computing hash. For strings longer than this limit the |
4171 // string length is used as the hash value. | 4224 // string length is used as the hash value. |
4172 static const int kMaxHashCalcLength = 16383; | 4225 static const int kMaxHashCalcLength = 16383; |
4173 | 4226 |
4174 // Limit for truncation in short printing. | 4227 // Limit for truncation in short printing. |
4175 static const int kMaxShortPrintLength = 1024; | 4228 static const int kMaxShortPrintLength = 1024; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4223 ReadBlockBuffer* buffer, | 4276 ReadBlockBuffer* buffer, |
4224 unsigned* offset_ptr, | 4277 unsigned* offset_ptr, |
4225 unsigned max_chars); | 4278 unsigned max_chars); |
4226 | 4279 |
4227 private: | 4280 private: |
4228 // Try to flatten the top level ConsString that is hiding behind this | 4281 // Try to flatten the top level ConsString that is hiding behind this |
4229 // string. This is a no-op unless the string is a ConsString. Flatten | 4282 // string. This is a no-op unless the string is a ConsString. Flatten |
4230 // mutates the ConsString and might return a failure. | 4283 // mutates the ConsString and might return a failure. |
4231 Object* SlowTryFlatten(PretenureFlag pretenure); | 4284 Object* SlowTryFlatten(PretenureFlag pretenure); |
4232 | 4285 |
| 4286 static inline bool IsHashFieldComputed(uint32_t field); |
| 4287 |
4233 // Slow case of String::Equals. This implementation works on any strings | 4288 // Slow case of String::Equals. This implementation works on any strings |
4234 // but it is most efficient on strings that are almost flat. | 4289 // but it is most efficient on strings that are almost flat. |
4235 bool SlowEquals(String* other); | 4290 bool SlowEquals(String* other); |
4236 | 4291 |
4237 // Slow case of AsArrayIndex. | 4292 // Slow case of AsArrayIndex. |
4238 bool SlowAsArrayIndex(uint32_t* index); | 4293 bool SlowAsArrayIndex(uint32_t* index); |
4239 | 4294 |
4240 // Compute and set the hash code. | 4295 // Compute and set the hash code. |
4241 uint32_t ComputeAndSetHash(); | 4296 uint32_t ComputeAndSetHash(); |
4242 | 4297 |
(...skipping 29 matching lines...) Expand all Loading... |
4272 // Casting | 4327 // Casting |
4273 static inline SeqAsciiString* cast(Object* obj); | 4328 static inline SeqAsciiString* cast(Object* obj); |
4274 | 4329 |
4275 // Garbage collection support. This method is called by the | 4330 // Garbage collection support. This method is called by the |
4276 // garbage collector to compute the actual size of an AsciiString | 4331 // garbage collector to compute the actual size of an AsciiString |
4277 // instance. | 4332 // instance. |
4278 inline int SeqAsciiStringSize(InstanceType instance_type); | 4333 inline int SeqAsciiStringSize(InstanceType instance_type); |
4279 | 4334 |
4280 // Computes the size for an AsciiString instance of a given length. | 4335 // Computes the size for an AsciiString instance of a given length. |
4281 static int SizeFor(int length) { | 4336 static int SizeFor(int length) { |
4282 return OBJECT_SIZE_ALIGN(kHeaderSize + length * kCharSize); | 4337 return OBJECT_POINTER_ALIGN(kHeaderSize + length * kCharSize); |
4283 } | 4338 } |
4284 | 4339 |
4285 // Layout description. | 4340 // Layout description. |
4286 static const int kHeaderSize = String::kSize; | 4341 static const int kHeaderSize = String::kSize; |
4287 static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize); | 4342 static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize); |
4288 | 4343 |
4289 // Maximal memory usage for a single sequential ASCII string. | 4344 // Maximal memory usage for a single sequential ASCII string. |
4290 static const int kMaxSize = 512 * MB; | 4345 static const int kMaxSize = 512 * MB; |
4291 // Maximal length of a single sequential ASCII string. | 4346 // Maximal length of a single sequential ASCII string. |
4292 // Q.v. String::kMaxLength which is the maximal size of concatenated strings. | 4347 // 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... |
4324 // Casting | 4379 // Casting |
4325 static inline SeqTwoByteString* cast(Object* obj); | 4380 static inline SeqTwoByteString* cast(Object* obj); |
4326 | 4381 |
4327 // Garbage collection support. This method is called by the | 4382 // Garbage collection support. This method is called by the |
4328 // garbage collector to compute the actual size of a TwoByteString | 4383 // garbage collector to compute the actual size of a TwoByteString |
4329 // instance. | 4384 // instance. |
4330 inline int SeqTwoByteStringSize(InstanceType instance_type); | 4385 inline int SeqTwoByteStringSize(InstanceType instance_type); |
4331 | 4386 |
4332 // Computes the size for a TwoByteString instance of a given length. | 4387 // Computes the size for a TwoByteString instance of a given length. |
4333 static int SizeFor(int length) { | 4388 static int SizeFor(int length) { |
4334 return OBJECT_SIZE_ALIGN(kHeaderSize + length * kShortSize); | 4389 return OBJECT_POINTER_ALIGN(kHeaderSize + length * kShortSize); |
4335 } | 4390 } |
4336 | 4391 |
4337 // Layout description. | 4392 // Layout description. |
4338 static const int kHeaderSize = String::kSize; | 4393 static const int kHeaderSize = String::kSize; |
4339 static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize); | 4394 static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize); |
4340 | 4395 |
4341 // Maximal memory usage for a single sequential two-byte string. | 4396 // Maximal memory usage for a single sequential two-byte string. |
4342 static const int kMaxSize = 512 * MB; | 4397 static const int kMaxSize = 512 * MB; |
4343 // Maximal length of a single sequential two-byte string. | 4398 // Maximal length of a single sequential two-byte string. |
4344 // Q.v. String::kMaxLength which is the maximal size of concatenated strings. | 4399 // 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... |
5196 } else { | 5251 } else { |
5197 value &= ~(1 << bit_position); | 5252 value &= ~(1 << bit_position); |
5198 } | 5253 } |
5199 return value; | 5254 return value; |
5200 } | 5255 } |
5201 }; | 5256 }; |
5202 | 5257 |
5203 } } // namespace v8::internal | 5258 } } // namespace v8::internal |
5204 | 5259 |
5205 #endif // V8_OBJECTS_H_ | 5260 #endif // V8_OBJECTS_H_ |
OLD | NEW |