| 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 1739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1750 int number_of_fast_used_elements_; | 1750 int number_of_fast_used_elements_; |
| 1751 int number_of_fast_unused_elements_; | 1751 int number_of_fast_unused_elements_; |
| 1752 int number_of_slow_used_elements_; | 1752 int number_of_slow_used_elements_; |
| 1753 int number_of_slow_unused_elements_; | 1753 int number_of_slow_unused_elements_; |
| 1754 }; | 1754 }; |
| 1755 | 1755 |
| 1756 void IncrementSpillStatistics(SpillInformation* info); | 1756 void IncrementSpillStatistics(SpillInformation* info); |
| 1757 #endif | 1757 #endif |
| 1758 Object* SlowReverseLookup(Object* value); | 1758 Object* SlowReverseLookup(Object* value); |
| 1759 | 1759 |
| 1760 // Maximal number of elements (numbered 0 .. kMaxElementCount - 1). |
| 1761 // Also maximal value of JSArray's length property. |
| 1762 static const uint32_t kMaxElementCount = 0xffffffffu; |
| 1763 |
| 1760 static const uint32_t kMaxGap = 1024; | 1764 static const uint32_t kMaxGap = 1024; |
| 1761 static const int kMaxFastElementsLength = 5000; | 1765 static const int kMaxFastElementsLength = 5000; |
| 1762 static const int kInitialMaxFastElementArray = 100000; | 1766 static const int kInitialMaxFastElementArray = 100000; |
| 1763 static const int kMaxFastProperties = 8; | 1767 static const int kMaxFastProperties = 8; |
| 1764 static const int kMaxInstanceSize = 255 * kPointerSize; | 1768 static const int kMaxInstanceSize = 255 * kPointerSize; |
| 1765 // When extending the backing storage for property values, we increase | 1769 // When extending the backing storage for property values, we increase |
| 1766 // its size by more than the 1 entry necessary, so sequentially adding fields | 1770 // its size by more than the 1 entry necessary, so sequentially adding fields |
| 1767 // to the same object requires fewer allocations and copies. | 1771 // to the same object requires fewer allocations and copies. |
| 1768 static const int kFieldsAdded = 3; | 1772 static const int kFieldsAdded = 3; |
| 1769 | 1773 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1876 | 1880 |
| 1877 // Garbage collection support. | 1881 // Garbage collection support. |
| 1878 static int SizeFor(int length) { return kHeaderSize + length * kPointerSize; } | 1882 static int SizeFor(int length) { return kHeaderSize + length * kPointerSize; } |
| 1879 | 1883 |
| 1880 // Code Generation support. | 1884 // Code Generation support. |
| 1881 static int OffsetOfElementAt(int index) { return SizeFor(index); } | 1885 static int OffsetOfElementAt(int index) { return SizeFor(index); } |
| 1882 | 1886 |
| 1883 // Casting. | 1887 // Casting. |
| 1884 static inline FixedArray* cast(Object* obj); | 1888 static inline FixedArray* cast(Object* obj); |
| 1885 | 1889 |
| 1886 // Align data at kPointerSize, even if Array.kHeaderSize isn't aligned. | 1890 static const int kHeaderSize = Array::kAlignedSize; |
| 1887 static const int kHeaderSize = POINTER_SIZE_ALIGN(Array::kHeaderSize); | 1891 |
| 1892 // Maximal allowed size, in bytes, of a single FixedArray. |
| 1893 // Prevents overflowing size computations, as well as extreme memory |
| 1894 // consumption. |
| 1895 static const int kMaxSize = 512 * MB; |
| 1896 // Maximally allowed length of a FixedArray. |
| 1897 static const int kMaxLength = (kMaxSize - kHeaderSize) / kPointerSize; |
| 1888 | 1898 |
| 1889 // Dispatched behavior. | 1899 // Dispatched behavior. |
| 1890 int FixedArraySize() { return SizeFor(length()); } | 1900 int FixedArraySize() { return SizeFor(length()); } |
| 1891 void FixedArrayIterateBody(ObjectVisitor* v); | 1901 void FixedArrayIterateBody(ObjectVisitor* v); |
| 1892 #ifdef DEBUG | 1902 #ifdef DEBUG |
| 1893 void FixedArrayPrint(); | 1903 void FixedArrayPrint(); |
| 1894 void FixedArrayVerify(); | 1904 void FixedArrayVerify(); |
| 1895 // Checks if two FixedArrays have identical contents. | 1905 // Checks if two FixedArrays have identical contents. |
| 1896 bool IsEqualTo(FixedArray* other); | 1906 bool IsEqualTo(FixedArray* other); |
| 1897 #endif | 1907 #endif |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2187 static const int kPrefixStartIndex = 3; | 2197 static const int kPrefixStartIndex = 3; |
| 2188 static const int kElementsStartIndex = | 2198 static const int kElementsStartIndex = |
| 2189 kPrefixStartIndex + Shape::kPrefixSize; | 2199 kPrefixStartIndex + Shape::kPrefixSize; |
| 2190 static const int kEntrySize = Shape::kEntrySize; | 2200 static const int kEntrySize = Shape::kEntrySize; |
| 2191 static const int kElementsStartOffset = | 2201 static const int kElementsStartOffset = |
| 2192 kHeaderSize + kElementsStartIndex * kPointerSize; | 2202 kHeaderSize + kElementsStartIndex * kPointerSize; |
| 2193 | 2203 |
| 2194 // Constant used for denoting a absent entry. | 2204 // Constant used for denoting a absent entry. |
| 2195 static const int kNotFound = -1; | 2205 static const int kNotFound = -1; |
| 2196 | 2206 |
| 2207 // Maximal capacity of HashTable. Based on maximal length of underlying |
| 2208 // FixedArray. Staying below kMaxCapacity also ensures that EntryToIndex |
| 2209 // cannot overflow. |
| 2210 static const int kMaxCapacity = |
| 2211 (FixedArray::kMaxLength - kElementsStartOffset) / kEntrySize; |
| 2212 |
| 2197 // Find entry for key otherwise return -1. | 2213 // Find entry for key otherwise return -1. |
| 2198 int FindEntry(Key key); | 2214 int FindEntry(Key key); |
| 2199 | 2215 |
| 2200 protected: | 2216 protected: |
| 2201 | 2217 |
| 2202 // Find the entry at which to insert element with the given key that | 2218 // Find the entry at which to insert element with the given key that |
| 2203 // has the given hash value. | 2219 // has the given hash value. |
| 2204 uint32_t FindInsertionEntry(uint32_t hash); | 2220 uint32_t FindInsertionEntry(uint32_t hash); |
| 2205 | 2221 |
| 2206 // Returns the index for an entry (of the key) | 2222 // Returns the index for an entry (of the key) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2217 void SetNumberOfDeletedElements(int nod) { | 2233 void SetNumberOfDeletedElements(int nod) { |
| 2218 fast_set(this, kNumberOfDeletedElementsIndex, Smi::FromInt(nod)); | 2234 fast_set(this, kNumberOfDeletedElementsIndex, Smi::FromInt(nod)); |
| 2219 } | 2235 } |
| 2220 | 2236 |
| 2221 // Sets the capacity of the hash table. | 2237 // Sets the capacity of the hash table. |
| 2222 void SetCapacity(int capacity) { | 2238 void SetCapacity(int capacity) { |
| 2223 // To scale a computed hash code to fit within the hash table, we | 2239 // To scale a computed hash code to fit within the hash table, we |
| 2224 // use bit-wise AND with a mask, so the capacity must be positive | 2240 // use bit-wise AND with a mask, so the capacity must be positive |
| 2225 // and non-zero. | 2241 // and non-zero. |
| 2226 ASSERT(capacity > 0); | 2242 ASSERT(capacity > 0); |
| 2243 ASSERT(capacity <= kMaxCapacity); |
| 2227 fast_set(this, kCapacityIndex, Smi::FromInt(capacity)); | 2244 fast_set(this, kCapacityIndex, Smi::FromInt(capacity)); |
| 2228 } | 2245 } |
| 2229 | 2246 |
| 2230 | 2247 |
| 2231 // Returns probe entry. | 2248 // Returns probe entry. |
| 2232 static uint32_t GetProbe(uint32_t hash, uint32_t number, uint32_t size) { | 2249 static uint32_t GetProbe(uint32_t hash, uint32_t number, uint32_t size) { |
| 2233 ASSERT(IsPowerOf2(size)); | 2250 ASSERT(IsPowerOf2(size)); |
| 2234 return (hash + GetProbeOffset(number)) & (size - 1); | 2251 return (hash + GetProbeOffset(number)) & (size - 1); |
| 2235 } | 2252 } |
| 2236 | 2253 |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2555 int ByteArraySize() { return SizeFor(length()); } | 2572 int ByteArraySize() { return SizeFor(length()); } |
| 2556 #ifdef DEBUG | 2573 #ifdef DEBUG |
| 2557 void ByteArrayPrint(); | 2574 void ByteArrayPrint(); |
| 2558 void ByteArrayVerify(); | 2575 void ByteArrayVerify(); |
| 2559 #endif | 2576 #endif |
| 2560 | 2577 |
| 2561 // ByteArray headers are not quadword aligned. | 2578 // ByteArray headers are not quadword aligned. |
| 2562 static const int kHeaderSize = Array::kHeaderSize; | 2579 static const int kHeaderSize = Array::kHeaderSize; |
| 2563 static const int kAlignedSize = Array::kAlignedSize; | 2580 static const int kAlignedSize = Array::kAlignedSize; |
| 2564 | 2581 |
| 2582 // Maximal memory consumption for a single ByteArray. |
| 2583 static const int kMaxSize = 512 * MB; |
| 2584 // Maximal length of a single ByteArray. |
| 2585 static const int kMaxLength = kMaxSize - kHeaderSize; |
| 2586 |
| 2565 private: | 2587 private: |
| 2566 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); | 2588 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); |
| 2567 }; | 2589 }; |
| 2568 | 2590 |
| 2569 | 2591 |
| 2570 // A PixelArray represents a fixed-size byte array with special semantics | 2592 // A PixelArray represents a fixed-size byte array with special semantics |
| 2571 // used for implementing the CanvasPixelArray object. Please see the | 2593 // used for implementing the CanvasPixelArray object. Please see the |
| 2572 // specification at: | 2594 // specification at: |
| 2573 // http://www.whatwg.org/specs/web-apps/current-work/ | 2595 // http://www.whatwg.org/specs/web-apps/current-work/ |
| 2574 // multipage/the-canvas-element.html#canvaspixelarray | 2596 // multipage/the-canvas-element.html#canvaspixelarray |
| (...skipping 1685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4260 | 4282 |
| 4261 // Computes the size for an AsciiString instance of a given length. | 4283 // Computes the size for an AsciiString instance of a given length. |
| 4262 static int SizeFor(int length) { | 4284 static int SizeFor(int length) { |
| 4263 return OBJECT_SIZE_ALIGN(kHeaderSize + length * kCharSize); | 4285 return OBJECT_SIZE_ALIGN(kHeaderSize + length * kCharSize); |
| 4264 } | 4286 } |
| 4265 | 4287 |
| 4266 // Layout description. | 4288 // Layout description. |
| 4267 static const int kHeaderSize = String::kSize; | 4289 static const int kHeaderSize = String::kSize; |
| 4268 static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize); | 4290 static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize); |
| 4269 | 4291 |
| 4292 // Maximal memory usage for a single sequential ASCII string. |
| 4293 static const int kMaxSize = 512 * MB; |
| 4294 // Maximal length of a single sequential ASCII string. |
| 4295 // Q.v. String::kMaxLength which is the maximal size of concatenated strings. |
| 4296 static const int kMaxLength = (kMaxSize - kHeaderSize); |
| 4297 |
| 4270 // Support for StringInputBuffer. | 4298 // Support for StringInputBuffer. |
| 4271 inline void SeqAsciiStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, | 4299 inline void SeqAsciiStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, |
| 4272 unsigned* offset, | 4300 unsigned* offset, |
| 4273 unsigned chars); | 4301 unsigned chars); |
| 4274 inline const unibrow::byte* SeqAsciiStringReadBlock(unsigned* remaining, | 4302 inline const unibrow::byte* SeqAsciiStringReadBlock(unsigned* remaining, |
| 4275 unsigned* offset, | 4303 unsigned* offset, |
| 4276 unsigned chars); | 4304 unsigned chars); |
| 4277 | 4305 |
| 4278 private: | 4306 private: |
| 4279 DISALLOW_IMPLICIT_CONSTRUCTORS(SeqAsciiString); | 4307 DISALLOW_IMPLICIT_CONSTRUCTORS(SeqAsciiString); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 4306 | 4334 |
| 4307 // Computes the size for a TwoByteString instance of a given length. | 4335 // Computes the size for a TwoByteString instance of a given length. |
| 4308 static int SizeFor(int length) { | 4336 static int SizeFor(int length) { |
| 4309 return OBJECT_SIZE_ALIGN(kHeaderSize + length * kShortSize); | 4337 return OBJECT_SIZE_ALIGN(kHeaderSize + length * kShortSize); |
| 4310 } | 4338 } |
| 4311 | 4339 |
| 4312 // Layout description. | 4340 // Layout description. |
| 4313 static const int kHeaderSize = String::kSize; | 4341 static const int kHeaderSize = String::kSize; |
| 4314 static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize); | 4342 static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize); |
| 4315 | 4343 |
| 4344 // Maximal memory usage for a single sequential two-byte string. |
| 4345 static const int kMaxSize = 512 * MB; |
| 4346 // Maximal length of a single sequential two-byte string. |
| 4347 // Q.v. String::kMaxLength which is the maximal size of concatenated strings. |
| 4348 static const int kMaxLength = (kMaxSize - kHeaderSize) / sizeof(uint16_t); |
| 4349 |
| 4316 // Support for StringInputBuffer. | 4350 // Support for StringInputBuffer. |
| 4317 inline void SeqTwoByteStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, | 4351 inline void SeqTwoByteStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, |
| 4318 unsigned* offset_ptr, | 4352 unsigned* offset_ptr, |
| 4319 unsigned chars); | 4353 unsigned chars); |
| 4320 | 4354 |
| 4321 private: | 4355 private: |
| 4322 DISALLOW_IMPLICIT_CONSTRUCTORS(SeqTwoByteString); | 4356 DISALLOW_IMPLICIT_CONSTRUCTORS(SeqTwoByteString); |
| 4323 }; | 4357 }; |
| 4324 | 4358 |
| 4325 | 4359 |
| (...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5183 } else { | 5217 } else { |
| 5184 value &= ~(1 << bit_position); | 5218 value &= ~(1 << bit_position); |
| 5185 } | 5219 } |
| 5186 return value; | 5220 return value; |
| 5187 } | 5221 } |
| 5188 }; | 5222 }; |
| 5189 | 5223 |
| 5190 } } // namespace v8::internal | 5224 } } // namespace v8::internal |
| 5191 | 5225 |
| 5192 #endif // V8_OBJECTS_H_ | 5226 #endif // V8_OBJECTS_H_ |
| OLD | NEW |