OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 // - Failure (immediate for marking failed operation) | 47 // - Failure (immediate for marking failed operation) |
48 // - HeapObject (superclass for everything allocated in the heap) | 48 // - HeapObject (superclass for everything allocated in the heap) |
49 // - JSObject | 49 // - JSObject |
50 // - JSArray | 50 // - JSArray |
51 // - JSRegExp | 51 // - JSRegExp |
52 // - JSFunction | 52 // - JSFunction |
53 // - GlobalObject | 53 // - GlobalObject |
54 // - JSGlobalObject | 54 // - JSGlobalObject |
55 // - JSBuiltinsObject | 55 // - JSBuiltinsObject |
56 // - JSGlobalProxy | 56 // - JSGlobalProxy |
57 // - JSValue | 57 // - JSValue |
58 // - ByteArray | 58 // - Array |
59 // - PixelArray | 59 // - ByteArray |
60 // - ExternalArray | 60 // - PixelArray |
61 // - ExternalByteArray | 61 // - ExternalArray |
62 // - ExternalUnsignedByteArray | 62 // - ExternalByteArray |
63 // - ExternalShortArray | 63 // - ExternalUnsignedByteArray |
64 // - ExternalUnsignedShortArray | 64 // - ExternalShortArray |
65 // - ExternalIntArray | 65 // - ExternalUnsignedShortArray |
66 // - ExternalUnsignedIntArray | 66 // - ExternalIntArray |
67 // - ExternalFloatArray | 67 // - ExternalUnsignedIntArray |
68 // - FixedArray | 68 // - ExternalFloatArray |
69 // - DescriptorArray | 69 // - FixedArray |
70 // - HashTable | 70 // - DescriptorArray |
71 // - Dictionary | 71 // - HashTable |
72 // - SymbolTable | 72 // - Dictionary |
73 // - CompilationCacheTable | 73 // - SymbolTable |
74 // - CodeCacheHashTable | 74 // - CompilationCacheTable |
75 // - MapCache | 75 // - CodeCacheHashTable |
76 // - Context | 76 // - MapCache |
77 // - GlobalContext | 77 // - Context |
78 // - JSFunctionResultCache | 78 // - GlobalContext |
| 79 // - JSFunctionResultCache |
79 // - String | 80 // - String |
80 // - SeqString | 81 // - SeqString |
81 // - SeqAsciiString | 82 // - SeqAsciiString |
82 // - SeqTwoByteString | 83 // - SeqTwoByteString |
83 // - ConsString | 84 // - ConsString |
84 // - ExternalString | 85 // - ExternalString |
85 // - ExternalAsciiString | 86 // - ExternalAsciiString |
86 // - ExternalTwoByteString | 87 // - ExternalTwoByteString |
87 // - HeapNumber | 88 // - HeapNumber |
88 // - Code | 89 // - Code |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 Object* holder); | 669 Object* holder); |
669 Object* GetPropertyWithDefinedGetter(Object* receiver, | 670 Object* GetPropertyWithDefinedGetter(Object* receiver, |
670 JSFunction* getter); | 671 JSFunction* getter); |
671 | 672 |
672 inline Object* GetElement(uint32_t index); | 673 inline Object* GetElement(uint32_t index); |
673 Object* GetElementWithReceiver(Object* receiver, uint32_t index); | 674 Object* GetElementWithReceiver(Object* receiver, uint32_t index); |
674 | 675 |
675 // Return the object's prototype (might be Heap::null_value()). | 676 // Return the object's prototype (might be Heap::null_value()). |
676 Object* GetPrototype(); | 677 Object* GetPrototype(); |
677 | 678 |
678 // Tries to convert an object to an array index. Returns true and sets | |
679 // the output parameter if it succeeds. | |
680 inline bool ToArrayIndex(uint32_t* index); | |
681 | |
682 // Returns true if this is a JSValue containing a string and the index is | 679 // Returns true if this is a JSValue containing a string and the index is |
683 // < the length of the string. Used to implement [] on strings. | 680 // < the length of the string. Used to implement [] on strings. |
684 inline bool IsStringObjectWithCharacterAt(uint32_t index); | 681 inline bool IsStringObjectWithCharacterAt(uint32_t index); |
685 | 682 |
686 #ifdef DEBUG | 683 #ifdef DEBUG |
687 // Prints this object with details. | 684 // Prints this object with details. |
688 void Print(); | 685 void Print(); |
689 void PrintLn(); | 686 void PrintLn(); |
690 // Verifies the object. | 687 // Verifies the object. |
691 void Verify(); | 688 void Verify(); |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 // Mutate this object's map pointer to indicate that the object is | 1019 // Mutate this object's map pointer to indicate that the object is |
1023 // overflowed. | 1020 // overflowed. |
1024 inline void SetOverflow(); | 1021 inline void SetOverflow(); |
1025 | 1022 |
1026 // Mutate this object's map pointer to remove the indication that the | 1023 // Mutate this object's map pointer to remove the indication that the |
1027 // object is overflowed (ie, partially restore the map pointer). | 1024 // object is overflowed (ie, partially restore the map pointer). |
1028 inline void ClearOverflow(); | 1025 inline void ClearOverflow(); |
1029 | 1026 |
1030 // Returns the field at offset in obj, as a read/write Object* reference. | 1027 // Returns the field at offset in obj, as a read/write Object* reference. |
1031 // Does no checking, and is safe to use during GC, while maps are invalid. | 1028 // Does no checking, and is safe to use during GC, while maps are invalid. |
1032 // Does not invoke write barrier, so should only be assigned to | 1029 // Does not update remembered sets, so should only be assigned to |
1033 // during marking GC. | 1030 // during marking GC. |
1034 static inline Object** RawField(HeapObject* obj, int offset); | 1031 static inline Object** RawField(HeapObject* obj, int offset); |
1035 | 1032 |
1036 // Casting. | 1033 // Casting. |
1037 static inline HeapObject* cast(Object* obj); | 1034 static inline HeapObject* cast(Object* obj); |
1038 | 1035 |
1039 // Return the write barrier mode for this. Callers of this function | 1036 // Return the write barrier mode for this. Callers of this function |
1040 // must be able to present a reference to an AssertNoAllocation | 1037 // must be able to present a reference to an AssertNoAllocation |
1041 // object as a sign that they are not going to use this function | 1038 // object as a sign that they are not going to use this function |
1042 // from code that allocates and thus invalidates the returned write | 1039 // from code that allocates and thus invalidates the returned write |
1043 // barrier mode. | 1040 // barrier mode. |
1044 inline WriteBarrierMode GetWriteBarrierMode(const AssertNoAllocation&); | 1041 inline WriteBarrierMode GetWriteBarrierMode(const AssertNoAllocation&); |
1045 | 1042 |
1046 // Dispatched behavior. | 1043 // Dispatched behavior. |
1047 void HeapObjectShortPrint(StringStream* accumulator); | 1044 void HeapObjectShortPrint(StringStream* accumulator); |
1048 #ifdef DEBUG | 1045 #ifdef DEBUG |
1049 void HeapObjectPrint(); | 1046 void HeapObjectPrint(); |
1050 void HeapObjectVerify(); | 1047 void HeapObjectVerify(); |
1051 inline void VerifyObjectField(int offset); | 1048 inline void VerifyObjectField(int offset); |
1052 inline void VerifySmiField(int offset); | |
1053 | 1049 |
1054 void PrintHeader(const char* id); | 1050 void PrintHeader(const char* id); |
1055 | 1051 |
1056 // Verify a pointer is a valid HeapObject pointer that points to object | 1052 // Verify a pointer is a valid HeapObject pointer that points to object |
1057 // areas in the heap. | 1053 // areas in the heap. |
1058 static void VerifyHeapPointer(Object* p); | 1054 static void VerifyHeapPointer(Object* p); |
1059 #endif | 1055 #endif |
1060 | 1056 |
1061 // Layout description. | 1057 // Layout description. |
1062 // First field in a heap object is map. | 1058 // First field in a heap object is map. |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1147 EXTERNAL_BYTE_ELEMENTS, | 1143 EXTERNAL_BYTE_ELEMENTS, |
1148 EXTERNAL_UNSIGNED_BYTE_ELEMENTS, | 1144 EXTERNAL_UNSIGNED_BYTE_ELEMENTS, |
1149 EXTERNAL_SHORT_ELEMENTS, | 1145 EXTERNAL_SHORT_ELEMENTS, |
1150 EXTERNAL_UNSIGNED_SHORT_ELEMENTS, | 1146 EXTERNAL_UNSIGNED_SHORT_ELEMENTS, |
1151 EXTERNAL_INT_ELEMENTS, | 1147 EXTERNAL_INT_ELEMENTS, |
1152 EXTERNAL_UNSIGNED_INT_ELEMENTS, | 1148 EXTERNAL_UNSIGNED_INT_ELEMENTS, |
1153 EXTERNAL_FLOAT_ELEMENTS | 1149 EXTERNAL_FLOAT_ELEMENTS |
1154 }; | 1150 }; |
1155 | 1151 |
1156 // [properties]: Backing storage for properties. | 1152 // [properties]: Backing storage for properties. |
1157 // properties is a FixedArray in the fast case and a Dictionary in the | 1153 // properties is a FixedArray in the fast case, and a Dictionary in the |
1158 // slow case. | 1154 // slow case. |
1159 DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties. | 1155 DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties. |
1160 inline void initialize_properties(); | 1156 inline void initialize_properties(); |
1161 inline bool HasFastProperties(); | 1157 inline bool HasFastProperties(); |
1162 inline StringDictionary* property_dictionary(); // Gets slow properties. | 1158 inline StringDictionary* property_dictionary(); // Gets slow properties. |
1163 | 1159 |
1164 // [elements]: The elements (properties with names that are integers). | 1160 // [elements]: The elements (properties with names that are integers). |
1165 // elements is a FixedArray in the fast case, a Dictionary in the slow | 1161 // elements is a FixedArray in the fast case, and a Dictionary in the slow |
1166 // case, and a PixelArray or ExternalArray in special cases. | 1162 // case or a PixelArray in a special case. |
1167 DECL_ACCESSORS(elements, HeapObject) | 1163 DECL_ACCESSORS(elements, Array) // Get and set fast elements. |
1168 inline void initialize_elements(); | 1164 inline void initialize_elements(); |
1169 inline ElementsKind GetElementsKind(); | 1165 inline ElementsKind GetElementsKind(); |
1170 inline bool HasFastElements(); | 1166 inline bool HasFastElements(); |
1171 inline bool HasDictionaryElements(); | 1167 inline bool HasDictionaryElements(); |
1172 inline bool HasPixelElements(); | 1168 inline bool HasPixelElements(); |
1173 inline bool HasExternalArrayElements(); | 1169 inline bool HasExternalArrayElements(); |
1174 inline bool HasExternalByteElements(); | 1170 inline bool HasExternalByteElements(); |
1175 inline bool HasExternalUnsignedByteElements(); | 1171 inline bool HasExternalUnsignedByteElements(); |
1176 inline bool HasExternalShortElements(); | 1172 inline bool HasExternalShortElements(); |
1177 inline bool HasExternalUnsignedShortElements(); | 1173 inline bool HasExternalUnsignedShortElements(); |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1591 Object* structure, | 1587 Object* structure, |
1592 PropertyAttributes attributes); | 1588 PropertyAttributes attributes); |
1593 Object* DefineGetterSetter(String* name, PropertyAttributes attributes); | 1589 Object* DefineGetterSetter(String* name, PropertyAttributes attributes); |
1594 | 1590 |
1595 void LookupInDescriptor(String* name, LookupResult* result); | 1591 void LookupInDescriptor(String* name, LookupResult* result); |
1596 | 1592 |
1597 DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject); | 1593 DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject); |
1598 }; | 1594 }; |
1599 | 1595 |
1600 | 1596 |
1601 // FixedArray describes fixed-sized arrays with element type Object*. | 1597 // Abstract super class arrays. It provides length behavior. |
1602 class FixedArray: public HeapObject { | 1598 class Array: public HeapObject { |
1603 public: | 1599 public: |
1604 // [length]: length of the array. | 1600 // [length]: length of the array. |
1605 inline int length(); | 1601 inline int length(); |
1606 inline void set_length(int value); | 1602 inline void set_length(int value); |
1607 | 1603 |
| 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 |
1608 // Setter and getter for elements. | 1628 // Setter and getter for elements. |
1609 inline Object* get(int index); | 1629 inline Object* get(int index); |
1610 // Setter that uses write barrier. | 1630 // Setter that uses write barrier. |
1611 inline void set(int index, Object* value); | 1631 inline void set(int index, Object* value); |
1612 | 1632 |
1613 // Setter that doesn't need write barrier). | 1633 // Setter that doesn't need write barrier). |
1614 inline void set(int index, Smi* value); | 1634 inline void set(int index, Smi* value); |
1615 // Setter with explicit barrier mode. | 1635 // Setter with explicit barrier mode. |
1616 inline void set(int index, Object* value, WriteBarrierMode mode); | 1636 inline void set(int index, Object* value, WriteBarrierMode mode); |
1617 | 1637 |
(...skipping 20 matching lines...) Expand all Loading... |
1638 | 1658 |
1639 // Garbage collection support. | 1659 // Garbage collection support. |
1640 static int SizeFor(int length) { return kHeaderSize + length * kPointerSize; } | 1660 static int SizeFor(int length) { return kHeaderSize + length * kPointerSize; } |
1641 | 1661 |
1642 // Code Generation support. | 1662 // Code Generation support. |
1643 static int OffsetOfElementAt(int index) { return SizeFor(index); } | 1663 static int OffsetOfElementAt(int index) { return SizeFor(index); } |
1644 | 1664 |
1645 // Casting. | 1665 // Casting. |
1646 static inline FixedArray* cast(Object* obj); | 1666 static inline FixedArray* cast(Object* obj); |
1647 | 1667 |
1648 // Layout description. | 1668 static const int kHeaderSize = Array::kAlignedSize; |
1649 // Length is smi tagged when it is stored. | |
1650 static const int kLengthOffset = HeapObject::kHeaderSize; | |
1651 static const int kHeaderSize = kLengthOffset + kPointerSize; | |
1652 | 1669 |
1653 // Maximal allowed size, in bytes, of a single FixedArray. | 1670 // Maximal allowed size, in bytes, of a single FixedArray. |
1654 // Prevents overflowing size computations, as well as extreme memory | 1671 // Prevents overflowing size computations, as well as extreme memory |
1655 // consumption. | 1672 // consumption. |
1656 static const int kMaxSize = 512 * MB; | 1673 static const int kMaxSize = 512 * MB; |
1657 // Maximally allowed length of a FixedArray. | 1674 // Maximally allowed length of a FixedArray. |
1658 static const int kMaxLength = (kMaxSize - kHeaderSize) / kPointerSize; | 1675 static const int kMaxLength = (kMaxSize - kHeaderSize) / kPointerSize; |
1659 | 1676 |
1660 // Dispatched behavior. | 1677 // Dispatched behavior. |
1661 int FixedArraySize() { return SizeFor(length()); } | 1678 int FixedArraySize() { return SizeFor(length()); } |
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2340 | 2357 |
2341 #ifdef DEBUG | 2358 #ifdef DEBUG |
2342 void JSFunctionResultCacheVerify(); | 2359 void JSFunctionResultCacheVerify(); |
2343 #endif | 2360 #endif |
2344 }; | 2361 }; |
2345 | 2362 |
2346 | 2363 |
2347 // ByteArray represents fixed sized byte arrays. Used by the outside world, | 2364 // 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 | 2365 // such as PCRE, and also by the memory allocator and garbage collector to |
2349 // fill in free blocks in the heap. | 2366 // fill in free blocks in the heap. |
2350 class ByteArray: public HeapObject { | 2367 class ByteArray: public Array { |
2351 public: | 2368 public: |
2352 // [length]: length of the array. | |
2353 inline int length(); | |
2354 inline void set_length(int value); | |
2355 | |
2356 // Setter and getter. | 2369 // Setter and getter. |
2357 inline byte get(int index); | 2370 inline byte get(int index); |
2358 inline void set(int index, byte value); | 2371 inline void set(int index, byte value); |
2359 | 2372 |
2360 // Treat contents as an int array. | 2373 // Treat contents as an int array. |
2361 inline int get_int(int index); | 2374 inline int get_int(int index); |
2362 | 2375 |
2363 static int SizeFor(int length) { | 2376 static int SizeFor(int length) { |
2364 return OBJECT_POINTER_ALIGN(kHeaderSize + length); | 2377 return OBJECT_SIZE_ALIGN(kHeaderSize + length); |
2365 } | 2378 } |
2366 // We use byte arrays for free blocks in the heap. Given a desired size in | 2379 // We use byte arrays for free blocks in the heap. Given a desired size in |
2367 // bytes that is a multiple of the word size and big enough to hold a byte | 2380 // bytes that is a multiple of the word size and big enough to hold a byte |
2368 // array, this function returns the number of elements a byte array should | 2381 // array, this function returns the number of elements a byte array should |
2369 // have. | 2382 // have. |
2370 static int LengthFor(int size_in_bytes) { | 2383 static int LengthFor(int size_in_bytes) { |
2371 ASSERT(IsAligned(size_in_bytes, kPointerSize)); | 2384 ASSERT(IsAligned(size_in_bytes, kPointerSize)); |
2372 ASSERT(size_in_bytes >= kHeaderSize); | 2385 ASSERT(size_in_bytes >= kHeaderSize); |
2373 return size_in_bytes - kHeaderSize; | 2386 return size_in_bytes - kHeaderSize; |
2374 } | 2387 } |
2375 | 2388 |
2376 // Returns data start address. | 2389 // Returns data start address. |
2377 inline Address GetDataStartAddress(); | 2390 inline Address GetDataStartAddress(); |
2378 | 2391 |
2379 // Returns a pointer to the ByteArray object for a given data start address. | 2392 // Returns a pointer to the ByteArray object for a given data start address. |
2380 static inline ByteArray* FromDataStartAddress(Address address); | 2393 static inline ByteArray* FromDataStartAddress(Address address); |
2381 | 2394 |
2382 // Casting. | 2395 // Casting. |
2383 static inline ByteArray* cast(Object* obj); | 2396 static inline ByteArray* cast(Object* obj); |
2384 | 2397 |
2385 // Dispatched behavior. | 2398 // Dispatched behavior. |
2386 int ByteArraySize() { return SizeFor(length()); } | 2399 int ByteArraySize() { return SizeFor(length()); } |
2387 #ifdef DEBUG | 2400 #ifdef DEBUG |
2388 void ByteArrayPrint(); | 2401 void ByteArrayPrint(); |
2389 void ByteArrayVerify(); | 2402 void ByteArrayVerify(); |
2390 #endif | 2403 #endif |
2391 | 2404 |
2392 // Layout description. | 2405 // ByteArray headers are not quadword aligned. |
2393 // Length is smi tagged when it is stored. | 2406 static const int kHeaderSize = Array::kHeaderSize; |
2394 static const int kLengthOffset = HeapObject::kHeaderSize; | 2407 static const int kAlignedSize = Array::kAlignedSize; |
2395 static const int kHeaderSize = kLengthOffset + kPointerSize; | |
2396 | |
2397 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); | |
2398 | 2408 |
2399 // Maximal memory consumption for a single ByteArray. | 2409 // Maximal memory consumption for a single ByteArray. |
2400 static const int kMaxSize = 512 * MB; | 2410 static const int kMaxSize = 512 * MB; |
2401 // Maximal length of a single ByteArray. | 2411 // Maximal length of a single ByteArray. |
2402 static const int kMaxLength = kMaxSize - kHeaderSize; | 2412 static const int kMaxLength = kMaxSize - kHeaderSize; |
2403 | 2413 |
2404 private: | 2414 private: |
2405 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); | 2415 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); |
2406 }; | 2416 }; |
2407 | 2417 |
2408 | 2418 |
2409 // A PixelArray represents a fixed-size byte array with special semantics | 2419 // A PixelArray represents a fixed-size byte array with special semantics |
2410 // used for implementing the CanvasPixelArray object. Please see the | 2420 // used for implementing the CanvasPixelArray object. Please see the |
2411 // specification at: | 2421 // specification at: |
2412 // http://www.whatwg.org/specs/web-apps/current-work/ | 2422 // http://www.whatwg.org/specs/web-apps/current-work/ |
2413 // multipage/the-canvas-element.html#canvaspixelarray | 2423 // multipage/the-canvas-element.html#canvaspixelarray |
2414 // In particular, write access clamps the value written to 0 or 255 if the | 2424 // In particular, write access clamps the value written to 0 or 255 if the |
2415 // value written is outside this range. | 2425 // value written is outside this range. |
2416 class PixelArray: public HeapObject { | 2426 class PixelArray: public Array { |
2417 public: | 2427 public: |
2418 // [length]: length of the array. | |
2419 inline int length(); | |
2420 inline void set_length(int value); | |
2421 | |
2422 // [external_pointer]: The pointer to the external memory area backing this | 2428 // [external_pointer]: The pointer to the external memory area backing this |
2423 // pixel array. | 2429 // pixel array. |
2424 DECL_ACCESSORS(external_pointer, uint8_t) // Pointer to the data store. | 2430 DECL_ACCESSORS(external_pointer, uint8_t) // Pointer to the data store. |
2425 | 2431 |
2426 // Setter and getter. | 2432 // Setter and getter. |
2427 inline uint8_t get(int index); | 2433 inline uint8_t get(int index); |
2428 inline void set(int index, uint8_t value); | 2434 inline void set(int index, uint8_t value); |
2429 | 2435 |
2430 // This accessor applies the correct conversion from Smi, HeapNumber and | 2436 // This accessor applies the correct conversion from Smi, HeapNumber and |
2431 // undefined and clamps the converted value between 0 and 255. | 2437 // undefined and clamps the converted value between 0 and 255. |
2432 Object* SetValue(uint32_t index, Object* value); | 2438 Object* SetValue(uint32_t index, Object* value); |
2433 | 2439 |
2434 // Casting. | 2440 // Casting. |
2435 static inline PixelArray* cast(Object* obj); | 2441 static inline PixelArray* cast(Object* obj); |
2436 | 2442 |
2437 #ifdef DEBUG | 2443 #ifdef DEBUG |
2438 void PixelArrayPrint(); | 2444 void PixelArrayPrint(); |
2439 void PixelArrayVerify(); | 2445 void PixelArrayVerify(); |
2440 #endif // DEBUG | 2446 #endif // DEBUG |
2441 | 2447 |
2442 // Maximal acceptable length for a pixel array. | 2448 // Maximal acceptable length for a pixel array. |
2443 static const int kMaxLength = 0x3fffffff; | 2449 static const int kMaxLength = 0x3fffffff; |
2444 | 2450 |
2445 // PixelArray headers are not quadword aligned. | 2451 // PixelArray headers are not quadword aligned. |
2446 static const int kLengthOffset = HeapObject::kHeaderSize; | 2452 static const int kExternalPointerOffset = Array::kAlignedSize; |
2447 static const int kExternalPointerOffset = | |
2448 POINTER_SIZE_ALIGN(kLengthOffset + kIntSize); | |
2449 static const int kHeaderSize = kExternalPointerOffset + kPointerSize; | 2453 static const int kHeaderSize = kExternalPointerOffset + kPointerSize; |
2450 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); | 2454 static const int kAlignedSize = OBJECT_SIZE_ALIGN(kHeaderSize); |
2451 | 2455 |
2452 private: | 2456 private: |
2453 DISALLOW_IMPLICIT_CONSTRUCTORS(PixelArray); | 2457 DISALLOW_IMPLICIT_CONSTRUCTORS(PixelArray); |
2454 }; | 2458 }; |
2455 | 2459 |
2456 | 2460 |
2457 // An ExternalArray represents a fixed-size array of primitive values | 2461 // An ExternalArray represents a fixed-size array of primitive values |
2458 // which live outside the JavaScript heap. Its subclasses are used to | 2462 // which live outside the JavaScript heap. Its subclasses are used to |
2459 // implement the CanvasArray types being defined in the WebGL | 2463 // implement the CanvasArray types being defined in the WebGL |
2460 // specification. As of this writing the first public draft is not yet | 2464 // specification. As of this writing the first public draft is not yet |
2461 // available, but Khronos members can access the draft at: | 2465 // available, but Khronos members can access the draft at: |
2462 // https://cvs.khronos.org/svn/repos/3dweb/trunk/doc/spec/WebGL-spec.html | 2466 // https://cvs.khronos.org/svn/repos/3dweb/trunk/doc/spec/WebGL-spec.html |
2463 // | 2467 // |
2464 // The semantics of these arrays differ from CanvasPixelArray. | 2468 // The semantics of these arrays differ from CanvasPixelArray. |
2465 // Out-of-range values passed to the setter are converted via a C | 2469 // Out-of-range values passed to the setter are converted via a C |
2466 // cast, not clamping. Out-of-range indices cause exceptions to be | 2470 // cast, not clamping. Out-of-range indices cause exceptions to be |
2467 // raised rather than being silently ignored. | 2471 // raised rather than being silently ignored. |
2468 class ExternalArray: public HeapObject { | 2472 class ExternalArray: public Array { |
2469 public: | 2473 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 kLengthOffset = HeapObject::kHeaderSize; | 2485 static const int kExternalPointerOffset = Array::kAlignedSize; |
2486 static const int kExternalPointerOffset = | |
2487 POINTER_SIZE_ALIGN(kLengthOffset + kIntSize); | |
2488 static const int kHeaderSize = kExternalPointerOffset + kPointerSize; | 2486 static const int kHeaderSize = kExternalPointerOffset + kPointerSize; |
2489 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); | 2487 static const int kAlignedSize = OBJECT_SIZE_ALIGN(kHeaderSize); |
2490 | 2488 |
2491 private: | 2489 private: |
2492 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalArray); | 2490 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalArray); |
2493 }; | 2491 }; |
2494 | 2492 |
2495 | 2493 |
2496 class ExternalByteArray: public ExternalArray { | 2494 class ExternalByteArray: public ExternalArray { |
2497 public: | 2495 public: |
2498 // Setter and getter. | 2496 // Setter and getter. |
2499 inline int8_t get(int index); | 2497 inline int8_t get(int index); |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3033 | 3031 |
3034 // Layout description. | 3032 // Layout description. |
3035 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; | 3033 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; |
3036 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; | 3034 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; |
3037 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize; | 3035 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize; |
3038 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; | 3036 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; |
3039 static const int kInstanceDescriptorsOffset = | 3037 static const int kInstanceDescriptorsOffset = |
3040 kConstructorOffset + kPointerSize; | 3038 kConstructorOffset + kPointerSize; |
3041 static const int kCodeCacheOffset = kInstanceDescriptorsOffset + kPointerSize; | 3039 static const int kCodeCacheOffset = kInstanceDescriptorsOffset + kPointerSize; |
3042 static const int kPadStart = kCodeCacheOffset + kPointerSize; | 3040 static const int kPadStart = kCodeCacheOffset + kPointerSize; |
3043 static const int kSize = MAP_POINTER_ALIGN(kPadStart); | 3041 static const int kSize = MAP_SIZE_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; | |
3050 | 3042 |
3051 // Byte offsets within kInstanceSizesOffset. | 3043 // Byte offsets within kInstanceSizesOffset. |
3052 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; | 3044 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; |
3053 static const int kInObjectPropertiesByte = 1; | 3045 static const int kInObjectPropertiesByte = 1; |
3054 static const int kInObjectPropertiesOffset = | 3046 static const int kInObjectPropertiesOffset = |
3055 kInstanceSizesOffset + kInObjectPropertiesByte; | 3047 kInstanceSizesOffset + kInObjectPropertiesByte; |
3056 static const int kPreAllocatedPropertyFieldsByte = 2; | 3048 static const int kPreAllocatedPropertyFieldsByte = 2; |
3057 static const int kPreAllocatedPropertyFieldsOffset = | 3049 static const int kPreAllocatedPropertyFieldsOffset = |
3058 kInstanceSizesOffset + kPreAllocatedPropertyFieldsByte; | 3050 kInstanceSizesOffset + kPreAllocatedPropertyFieldsByte; |
3059 // The byte at position 3 is not in use at the moment. | 3051 // 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... |
3351 static const int kConstructStubOffset = kCodeOffset + kPointerSize; | 3343 static const int kConstructStubOffset = kCodeOffset + kPointerSize; |
3352 static const int kInstanceClassNameOffset = | 3344 static const int kInstanceClassNameOffset = |
3353 kConstructStubOffset + kPointerSize; | 3345 kConstructStubOffset + kPointerSize; |
3354 static const int kFunctionDataOffset = | 3346 static const int kFunctionDataOffset = |
3355 kInstanceClassNameOffset + kPointerSize; | 3347 kInstanceClassNameOffset + kPointerSize; |
3356 static const int kScriptOffset = kFunctionDataOffset + kPointerSize; | 3348 static const int kScriptOffset = kFunctionDataOffset + kPointerSize; |
3357 static const int kDebugInfoOffset = kScriptOffset + kPointerSize; | 3349 static const int kDebugInfoOffset = kScriptOffset + kPointerSize; |
3358 static const int kInferredNameOffset = kDebugInfoOffset + kPointerSize; | 3350 static const int kInferredNameOffset = kDebugInfoOffset + kPointerSize; |
3359 static const int kThisPropertyAssignmentsOffset = | 3351 static const int kThisPropertyAssignmentsOffset = |
3360 kInferredNameOffset + kPointerSize; | 3352 kInferredNameOffset + kPointerSize; |
3361 #if V8_HOST_ARCH_32_BIT | 3353 // Integer fields. |
3362 // Smi fields. | |
3363 static const int kLengthOffset = | 3354 static const int kLengthOffset = |
3364 kThisPropertyAssignmentsOffset + kPointerSize; | 3355 kThisPropertyAssignmentsOffset + kPointerSize; |
3365 static const int kFormalParameterCountOffset = kLengthOffset + kPointerSize; | 3356 static const int kFormalParameterCountOffset = kLengthOffset + kIntSize; |
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 | |
3397 static const int kExpectedNofPropertiesOffset = | 3357 static const int kExpectedNofPropertiesOffset = |
3398 kFormalParameterCountOffset + kIntSize; | 3358 kFormalParameterCountOffset + kIntSize; |
3399 static const int kNumLiteralsOffset = | 3359 static const int kNumLiteralsOffset = kExpectedNofPropertiesOffset + kIntSize; |
3400 kExpectedNofPropertiesOffset + kIntSize; | 3360 static const int kStartPositionAndTypeOffset = |
3401 | |
3402 static const int kEndPositionOffset = | |
3403 kNumLiteralsOffset + kIntSize; | 3361 kNumLiteralsOffset + kIntSize; |
3404 static const int kStartPositionAndTypeOffset = | 3362 static const int kEndPositionOffset = kStartPositionAndTypeOffset + kIntSize; |
3405 kEndPositionOffset + kIntSize; | 3363 static const int kFunctionTokenPositionOffset = kEndPositionOffset + kIntSize; |
3406 | |
3407 static const int kFunctionTokenPositionOffset = | |
3408 kStartPositionAndTypeOffset + kIntSize; | |
3409 static const int kCompilerHintsOffset = | 3364 static const int kCompilerHintsOffset = |
3410 kFunctionTokenPositionOffset + kIntSize; | 3365 kFunctionTokenPositionOffset + kIntSize; |
3411 | |
3412 static const int kThisPropertyAssignmentsCountOffset = | 3366 static const int kThisPropertyAssignmentsCountOffset = |
3413 kCompilerHintsOffset + kIntSize; | 3367 kCompilerHintsOffset + kIntSize; |
3414 | |
3415 // Total size. | 3368 // Total size. |
3416 static const int kSize = kThisPropertyAssignmentsCountOffset + kIntSize; | 3369 static const int kSize = kThisPropertyAssignmentsCountOffset + kIntSize; |
3417 | |
3418 #endif | |
3419 static const int kAlignedSize = POINTER_SIZE_ALIGN(kSize); | 3370 static const int kAlignedSize = POINTER_SIZE_ALIGN(kSize); |
3420 | 3371 |
3421 private: | 3372 private: |
3422 // Bit positions in start_position_and_type. | 3373 // Bit positions in start_position_and_type. |
3423 // The source code start position is in the 30 most significant bits of | 3374 // The source code start position is in the 30 most significant bits of |
3424 // the start_position_and_type field. | 3375 // the start_position_and_type field. |
3425 static const int kIsExpressionBit = 0; | 3376 static const int kIsExpressionBit = 0; |
3426 static const int kIsTopLevelBit = 1; | 3377 static const int kIsTopLevelBit = 1; |
3427 static const int kStartPositionShift = 2; | 3378 static const int kStartPositionShift = 2; |
3428 static const int kStartPositionMask = ~((1 << kStartPositionShift) - 1); | 3379 static const int kStartPositionMask = ~((1 << kStartPositionShift) - 1); |
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4164 void StringShortPrint(StringStream* accumulator); | 4115 void StringShortPrint(StringStream* accumulator); |
4165 #ifdef DEBUG | 4116 #ifdef DEBUG |
4166 void StringPrint(); | 4117 void StringPrint(); |
4167 void StringVerify(); | 4118 void StringVerify(); |
4168 #endif | 4119 #endif |
4169 inline bool IsFlat(); | 4120 inline bool IsFlat(); |
4170 | 4121 |
4171 // Layout description. | 4122 // Layout description. |
4172 static const int kLengthOffset = HeapObject::kHeaderSize; | 4123 static const int kLengthOffset = HeapObject::kHeaderSize; |
4173 static const int kHashFieldOffset = kLengthOffset + kPointerSize; | 4124 static const int kHashFieldOffset = kLengthOffset + kPointerSize; |
4174 static const int kSize = kHashFieldOffset + kPointerSize; | 4125 static const int kSize = kHashFieldOffset + kIntSize; |
| 4126 // Notice: kSize is not pointer-size aligned if pointers are 64-bit. |
4175 | 4127 |
4176 // Maximum number of characters to consider when trying to convert a string | 4128 // Maximum number of characters to consider when trying to convert a string |
4177 // value into an array index. | 4129 // value into an array index. |
4178 static const int kMaxArrayIndexSize = 10; | 4130 static const int kMaxArrayIndexSize = 10; |
4179 | 4131 |
4180 // Max ascii char code. | 4132 // Max ascii char code. |
4181 static const int kMaxAsciiCharCode = unibrow::Utf8::kMaxOneByteChar; | 4133 static const int kMaxAsciiCharCode = unibrow::Utf8::kMaxOneByteChar; |
4182 static const unsigned kMaxAsciiCharCodeU = unibrow::Utf8::kMaxOneByteChar; | 4134 static const unsigned kMaxAsciiCharCodeU = unibrow::Utf8::kMaxOneByteChar; |
4183 static const int kMaxUC16CharCode = 0xffff; | 4135 static const int kMaxUC16CharCode = 0xffff; |
4184 | 4136 |
4185 // Minimum length for a cons string. | 4137 // Minimum length for a cons string. |
4186 static const int kMinNonFlatLength = 13; | 4138 static const int kMinNonFlatLength = 13; |
4187 | 4139 |
4188 // Mask constant for checking if a string has a computed hash code | 4140 // Mask constant for checking if a string has a computed hash code |
4189 // and if it is an array index. The least significant bit indicates | 4141 // and if it is an array index. The least significant bit indicates |
4190 // whether a hash code has been computed. If the hash code has been | 4142 // whether a hash code has been computed. If the hash code has been |
4191 // computed the 2nd bit tells whether the string can be used as an | 4143 // computed the 2nd bit tells whether the string can be used as an |
4192 // array index. | 4144 // array index. |
4193 static const int kHashNotComputedMask = 1; | 4145 static const int kHashComputedMask = 1; |
4194 static const int kIsArrayIndexMask = 1 << 1; | 4146 static const int kIsArrayIndexMask = 1 << 1; |
4195 static const int kNofLengthBitFields = 2; | 4147 static const int kNofLengthBitFields = 2; |
4196 | 4148 |
4197 // Shift constant retrieving hash code from hash field. | 4149 // Shift constant retrieving hash code from hash field. |
4198 static const int kHashShift = kNofLengthBitFields; | 4150 static const int kHashShift = kNofLengthBitFields; |
4199 | 4151 |
4200 // Array index strings this short can keep their index in the hash | 4152 // Array index strings this short can keep their index in the hash |
4201 // field. | 4153 // field. |
4202 static const int kMaxCachedArrayIndexLength = 7; | 4154 static const int kMaxCachedArrayIndexLength = 7; |
4203 | 4155 |
4204 // For strings which are array indexes the hash value has the string length | 4156 // For strings which are array indexes the hash value has the string length |
4205 // mixed into the hash, mainly to avoid a hash value of zero which would be | 4157 // mixed into the hash, mainly to avoid a hash value of zero which would be |
4206 // the case for the string '0'. 24 bits are used for the array index value. | 4158 // the case for the string '0'. 24 bits are used for the array index value. |
4207 static const int kArrayIndexHashLengthShift = 24 + kNofLengthBitFields; | 4159 static const int kArrayIndexHashLengthShift = 24 + kNofLengthBitFields; |
4208 static const int kArrayIndexHashMask = (1 << kArrayIndexHashLengthShift) - 1; | 4160 static const int kArrayIndexHashMask = (1 << kArrayIndexHashLengthShift) - 1; |
4209 static const int kArrayIndexValueBits = | 4161 static const int kArrayIndexValueBits = |
4210 kArrayIndexHashLengthShift - kHashShift; | 4162 kArrayIndexHashLengthShift - kHashShift; |
4211 static const int kArrayIndexValueMask = | |
4212 ((1 << kArrayIndexValueBits) - 1) << kHashShift; | |
4213 | 4163 |
4214 // Value of empty hash field indicating that the hash is not computed. | 4164 // Value of empty hash field indicating that the hash is not computed. |
4215 static const int kEmptyHashField = kHashNotComputedMask; | 4165 static const int kEmptyHashField = 0; |
4216 | |
4217 // Value of hash field containing computed hash equal to zero. | |
4218 static const int kZeroHash = 0; | |
4219 | 4166 |
4220 // Maximal string length. | 4167 // Maximal string length. |
4221 static const int kMaxLength = (1 << (32 - 2)) - 1; | 4168 static const int kMaxLength = (1 << (32 - 2)) - 1; |
4222 | 4169 |
4223 // Max length for computing hash. For strings longer than this limit the | 4170 // Max length for computing hash. For strings longer than this limit the |
4224 // string length is used as the hash value. | 4171 // string length is used as the hash value. |
4225 static const int kMaxHashCalcLength = 16383; | 4172 static const int kMaxHashCalcLength = 16383; |
4226 | 4173 |
4227 // Limit for truncation in short printing. | 4174 // Limit for truncation in short printing. |
4228 static const int kMaxShortPrintLength = 1024; | 4175 static const int kMaxShortPrintLength = 1024; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4276 ReadBlockBuffer* buffer, | 4223 ReadBlockBuffer* buffer, |
4277 unsigned* offset_ptr, | 4224 unsigned* offset_ptr, |
4278 unsigned max_chars); | 4225 unsigned max_chars); |
4279 | 4226 |
4280 private: | 4227 private: |
4281 // Try to flatten the top level ConsString that is hiding behind this | 4228 // Try to flatten the top level ConsString that is hiding behind this |
4282 // string. This is a no-op unless the string is a ConsString. Flatten | 4229 // string. This is a no-op unless the string is a ConsString. Flatten |
4283 // mutates the ConsString and might return a failure. | 4230 // mutates the ConsString and might return a failure. |
4284 Object* SlowTryFlatten(PretenureFlag pretenure); | 4231 Object* SlowTryFlatten(PretenureFlag pretenure); |
4285 | 4232 |
4286 static inline bool IsHashFieldComputed(uint32_t field); | |
4287 | |
4288 // Slow case of String::Equals. This implementation works on any strings | 4233 // Slow case of String::Equals. This implementation works on any strings |
4289 // but it is most efficient on strings that are almost flat. | 4234 // but it is most efficient on strings that are almost flat. |
4290 bool SlowEquals(String* other); | 4235 bool SlowEquals(String* other); |
4291 | 4236 |
4292 // Slow case of AsArrayIndex. | 4237 // Slow case of AsArrayIndex. |
4293 bool SlowAsArrayIndex(uint32_t* index); | 4238 bool SlowAsArrayIndex(uint32_t* index); |
4294 | 4239 |
4295 // Compute and set the hash code. | 4240 // Compute and set the hash code. |
4296 uint32_t ComputeAndSetHash(); | 4241 uint32_t ComputeAndSetHash(); |
4297 | 4242 |
(...skipping 29 matching lines...) Expand all Loading... |
4327 // Casting | 4272 // Casting |
4328 static inline SeqAsciiString* cast(Object* obj); | 4273 static inline SeqAsciiString* cast(Object* obj); |
4329 | 4274 |
4330 // Garbage collection support. This method is called by the | 4275 // Garbage collection support. This method is called by the |
4331 // garbage collector to compute the actual size of an AsciiString | 4276 // garbage collector to compute the actual size of an AsciiString |
4332 // instance. | 4277 // instance. |
4333 inline int SeqAsciiStringSize(InstanceType instance_type); | 4278 inline int SeqAsciiStringSize(InstanceType instance_type); |
4334 | 4279 |
4335 // Computes the size for an AsciiString instance of a given length. | 4280 // Computes the size for an AsciiString instance of a given length. |
4336 static int SizeFor(int length) { | 4281 static int SizeFor(int length) { |
4337 return OBJECT_POINTER_ALIGN(kHeaderSize + length * kCharSize); | 4282 return OBJECT_SIZE_ALIGN(kHeaderSize + length * kCharSize); |
4338 } | 4283 } |
4339 | 4284 |
4340 // Layout description. | 4285 // Layout description. |
4341 static const int kHeaderSize = String::kSize; | 4286 static const int kHeaderSize = String::kSize; |
4342 static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize); | 4287 static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize); |
4343 | 4288 |
4344 // Maximal memory usage for a single sequential ASCII string. | 4289 // Maximal memory usage for a single sequential ASCII string. |
4345 static const int kMaxSize = 512 * MB; | 4290 static const int kMaxSize = 512 * MB; |
4346 // Maximal length of a single sequential ASCII string. | 4291 // Maximal length of a single sequential ASCII string. |
4347 // Q.v. String::kMaxLength which is the maximal size of concatenated strings. | 4292 // 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... |
4379 // Casting | 4324 // Casting |
4380 static inline SeqTwoByteString* cast(Object* obj); | 4325 static inline SeqTwoByteString* cast(Object* obj); |
4381 | 4326 |
4382 // Garbage collection support. This method is called by the | 4327 // Garbage collection support. This method is called by the |
4383 // garbage collector to compute the actual size of a TwoByteString | 4328 // garbage collector to compute the actual size of a TwoByteString |
4384 // instance. | 4329 // instance. |
4385 inline int SeqTwoByteStringSize(InstanceType instance_type); | 4330 inline int SeqTwoByteStringSize(InstanceType instance_type); |
4386 | 4331 |
4387 // Computes the size for a TwoByteString instance of a given length. | 4332 // Computes the size for a TwoByteString instance of a given length. |
4388 static int SizeFor(int length) { | 4333 static int SizeFor(int length) { |
4389 return OBJECT_POINTER_ALIGN(kHeaderSize + length * kShortSize); | 4334 return OBJECT_SIZE_ALIGN(kHeaderSize + length * kShortSize); |
4390 } | 4335 } |
4391 | 4336 |
4392 // Layout description. | 4337 // Layout description. |
4393 static const int kHeaderSize = String::kSize; | 4338 static const int kHeaderSize = String::kSize; |
4394 static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize); | 4339 static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize); |
4395 | 4340 |
4396 // Maximal memory usage for a single sequential two-byte string. | 4341 // Maximal memory usage for a single sequential two-byte string. |
4397 static const int kMaxSize = 512 * MB; | 4342 static const int kMaxSize = 512 * MB; |
4398 // Maximal length of a single sequential two-byte string. | 4343 // Maximal length of a single sequential two-byte string. |
4399 // Q.v. String::kMaxLength which is the maximal size of concatenated strings. | 4344 // 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... |
5251 } else { | 5196 } else { |
5252 value &= ~(1 << bit_position); | 5197 value &= ~(1 << bit_position); |
5253 } | 5198 } |
5254 return value; | 5199 return value; |
5255 } | 5200 } |
5256 }; | 5201 }; |
5257 | 5202 |
5258 } } // namespace v8::internal | 5203 } } // namespace v8::internal |
5259 | 5204 |
5260 #endif // V8_OBJECTS_H_ | 5205 #endif // V8_OBJECTS_H_ |
OLD | NEW |