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