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