Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Side by Side Diff: src/objects.h

Issue 1995453002: [stubs] Extend HasProperty stub with dictionary-mode and double-elements objects support. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Drive-by fix: replace Load()s with LoadObjectField()s Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/globals.h ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_OBJECTS_H_ 5 #ifndef V8_OBJECTS_H_
6 #define V8_OBJECTS_H_ 6 #define V8_OBJECTS_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 9
10 #include "src/assert-scope.h" 10 #include "src/assert-scope.h"
(...skipping 3171 matching lines...) Expand 10 before | Expand all | Expand 10 after
3182 inline static uint32_t NextProbe( 3182 inline static uint32_t NextProbe(
3183 uint32_t last, uint32_t number, uint32_t size) { 3183 uint32_t last, uint32_t number, uint32_t size) {
3184 return (last + number) & (size - 1); 3184 return (last + number) & (size - 1);
3185 } 3185 }
3186 }; 3186 };
3187 3187
3188 3188
3189 template <typename Derived, typename Shape, typename Key> 3189 template <typename Derived, typename Shape, typename Key>
3190 class HashTable : public HashTableBase { 3190 class HashTable : public HashTableBase {
3191 public: 3191 public:
3192 typedef Shape ShapeT;
3193
3192 // Wrapper methods 3194 // Wrapper methods
3193 inline uint32_t Hash(Key key) { 3195 inline uint32_t Hash(Key key) {
3194 if (Shape::UsesSeed) { 3196 if (Shape::UsesSeed) {
3195 return Shape::SeededHash(key, GetHeap()->HashSeed()); 3197 return Shape::SeededHash(key, GetHeap()->HashSeed());
3196 } else { 3198 } else {
3197 return Shape::Hash(key); 3199 return Shape::Hash(key);
3198 } 3200 }
3199 } 3201 }
3200 3202
3201 inline uint32_t HashForObject(Key key, Object* object) { 3203 inline uint32_t HashForObject(Key key, Object* object) {
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
3468 int at_least_space_for, 3470 int at_least_space_for,
3469 PretenureFlag pretenure = NOT_TENURED); 3471 PretenureFlag pretenure = NOT_TENURED);
3470 3472
3471 // Ensures that a new dictionary is created when the capacity is checked. 3473 // Ensures that a new dictionary is created when the capacity is checked.
3472 void SetRequiresCopyOnCapacityChange(); 3474 void SetRequiresCopyOnCapacityChange();
3473 3475
3474 // Ensure enough space for n additional elements. 3476 // Ensure enough space for n additional elements.
3475 static Handle<Derived> EnsureCapacity(Handle<Derived> obj, int n, Key key); 3477 static Handle<Derived> EnsureCapacity(Handle<Derived> obj, int n, Key key);
3476 3478
3477 #ifdef OBJECT_PRINT 3479 #ifdef OBJECT_PRINT
3480 // For our gdb macros, we should perhaps change these in the future.
3481 void Print();
3482
3478 void Print(std::ostream& os); // NOLINT 3483 void Print(std::ostream& os); // NOLINT
3479 #endif 3484 #endif
3480 // Returns the key (slow). 3485 // Returns the key (slow).
3481 Object* SlowReverseLookup(Object* value); 3486 Object* SlowReverseLookup(Object* value);
3482 3487
3483 // Sets the entry to (key, value) pair. 3488 // Sets the entry to (key, value) pair.
3484 inline void SetEntry(int entry, 3489 inline void SetEntry(int entry,
3485 Handle<Object> key, 3490 Handle<Object> key,
3486 Handle<Object> value); 3491 Handle<Object> value);
3487 inline void SetEntry(int entry, 3492 inline void SetEntry(int entry,
(...skipping 5072 matching lines...) Expand 10 before | Expand all | Expand 10 after
8560 // Shift constant retrieving hash code from hash field. 8565 // Shift constant retrieving hash code from hash field.
8561 static const int kHashShift = kNofHashBitFields; 8566 static const int kHashShift = kNofHashBitFields;
8562 8567
8563 // Only these bits are relevant in the hash, since the top two are shifted 8568 // Only these bits are relevant in the hash, since the top two are shifted
8564 // out. 8569 // out.
8565 static const uint32_t kHashBitMask = 0xffffffffu >> kHashShift; 8570 static const uint32_t kHashBitMask = 0xffffffffu >> kHashShift;
8566 8571
8567 // Array index strings this short can keep their index in the hash field. 8572 // Array index strings this short can keep their index in the hash field.
8568 static const int kMaxCachedArrayIndexLength = 7; 8573 static const int kMaxCachedArrayIndexLength = 7;
8569 8574
8575 // Maximum number of characters to consider when trying to convert a string
8576 // value into an array index.
8577 static const int kMaxArrayIndexSize = 10;
8578
8570 // For strings which are array indexes the hash value has the string length 8579 // For strings which are array indexes the hash value has the string length
8571 // mixed into the hash, mainly to avoid a hash value of zero which would be 8580 // mixed into the hash, mainly to avoid a hash value of zero which would be
8572 // the case for the string '0'. 24 bits are used for the array index value. 8581 // the case for the string '0'. 24 bits are used for the array index value.
8573 static const int kArrayIndexValueBits = 24; 8582 static const int kArrayIndexValueBits = 24;
8574 static const int kArrayIndexLengthBits = 8583 static const int kArrayIndexLengthBits =
8575 kBitsPerInt - kArrayIndexValueBits - kNofHashBitFields; 8584 kBitsPerInt - kArrayIndexValueBits - kNofHashBitFields;
8576 8585
8577 STATIC_ASSERT((kArrayIndexLengthBits > 0)); 8586 STATIC_ASSERT(kArrayIndexLengthBits > 0);
8587 STATIC_ASSERT(kMaxArrayIndexSize < (1 << kArrayIndexLengthBits));
8578 8588
8579 class ArrayIndexValueBits : public BitField<unsigned int, kNofHashBitFields, 8589 class ArrayIndexValueBits : public BitField<unsigned int, kNofHashBitFields,
8580 kArrayIndexValueBits> {}; // NOLINT 8590 kArrayIndexValueBits> {}; // NOLINT
8581 class ArrayIndexLengthBits : public BitField<unsigned int, 8591 class ArrayIndexLengthBits : public BitField<unsigned int,
8582 kNofHashBitFields + kArrayIndexValueBits, 8592 kNofHashBitFields + kArrayIndexValueBits,
8583 kArrayIndexLengthBits> {}; // NOLINT 8593 kArrayIndexLengthBits> {}; // NOLINT
8584 8594
8585 // Check that kMaxCachedArrayIndexLength + 1 is a power of two so we 8595 // Check that kMaxCachedArrayIndexLength + 1 is a power of two so we
8586 // could use a mask to test if the length of string is less than or equal to 8596 // could use a mask to test if the length of string is less than or equal to
8587 // kMaxCachedArrayIndexLength. 8597 // kMaxCachedArrayIndexLength.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
8657 // Ecma-262: 8667 // Ecma-262:
8658 // 4.3.16 String Value 8668 // 4.3.16 String Value
8659 // A string value is a member of the type String and is a finite 8669 // A string value is a member of the type String and is a finite
8660 // ordered sequence of zero or more 16-bit unsigned integer values. 8670 // ordered sequence of zero or more 16-bit unsigned integer values.
8661 // 8671 //
8662 // All string values have a length field. 8672 // All string values have a length field.
8663 class String: public Name { 8673 class String: public Name {
8664 public: 8674 public:
8665 enum Encoding { ONE_BYTE_ENCODING, TWO_BYTE_ENCODING }; 8675 enum Encoding { ONE_BYTE_ENCODING, TWO_BYTE_ENCODING };
8666 8676
8667 // Array index strings this short can keep their index in the hash field.
8668 static const int kMaxCachedArrayIndexLength = 7;
8669
8670 // For strings which are array indexes the hash value has the string length
8671 // mixed into the hash, mainly to avoid a hash value of zero which would be
8672 // the case for the string '0'. 24 bits are used for the array index value.
8673 static const int kArrayIndexValueBits = 24;
8674 static const int kArrayIndexLengthBits =
8675 kBitsPerInt - kArrayIndexValueBits - kNofHashBitFields;
8676
8677 STATIC_ASSERT((kArrayIndexLengthBits > 0));
8678
8679 class ArrayIndexValueBits : public BitField<unsigned int, kNofHashBitFields,
8680 kArrayIndexValueBits> {}; // NOLINT
8681 class ArrayIndexLengthBits : public BitField<unsigned int,
8682 kNofHashBitFields + kArrayIndexValueBits,
8683 kArrayIndexLengthBits> {}; // NOLINT
8684
8685 // Check that kMaxCachedArrayIndexLength + 1 is a power of two so we
8686 // could use a mask to test if the length of string is less than or equal to
8687 // kMaxCachedArrayIndexLength.
8688 STATIC_ASSERT(IS_POWER_OF_TWO(kMaxCachedArrayIndexLength + 1));
8689
8690 static const unsigned int kContainsCachedArrayIndexMask =
8691 (~static_cast<unsigned>(kMaxCachedArrayIndexLength)
8692 << ArrayIndexLengthBits::kShift) |
8693 kIsNotArrayIndexMask;
8694
8695 class SubStringRange { 8677 class SubStringRange {
8696 public: 8678 public:
8697 explicit inline SubStringRange(String* string, int first = 0, 8679 explicit inline SubStringRange(String* string, int first = 0,
8698 int length = -1); 8680 int length = -1);
8699 class iterator; 8681 class iterator;
8700 inline iterator begin(); 8682 inline iterator begin();
8701 inline iterator end(); 8683 inline iterator end();
8702 8684
8703 private: 8685 private:
8704 String* string_; 8686 String* string_;
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
8896 #endif 8878 #endif
8897 DECLARE_PRINTER(String) 8879 DECLARE_PRINTER(String)
8898 DECLARE_VERIFIER(String) 8880 DECLARE_VERIFIER(String)
8899 8881
8900 inline bool IsFlat(); 8882 inline bool IsFlat();
8901 8883
8902 // Layout description. 8884 // Layout description.
8903 static const int kLengthOffset = Name::kSize; 8885 static const int kLengthOffset = Name::kSize;
8904 static const int kSize = kLengthOffset + kPointerSize; 8886 static const int kSize = kLengthOffset + kPointerSize;
8905 8887
8906 // Maximum number of characters to consider when trying to convert a string
8907 // value into an array index.
8908 static const int kMaxArrayIndexSize = 10;
8909 STATIC_ASSERT(kMaxArrayIndexSize < (1 << kArrayIndexLengthBits));
8910
8911 // Max char codes. 8888 // Max char codes.
8912 static const int32_t kMaxOneByteCharCode = unibrow::Latin1::kMaxChar; 8889 static const int32_t kMaxOneByteCharCode = unibrow::Latin1::kMaxChar;
8913 static const uint32_t kMaxOneByteCharCodeU = unibrow::Latin1::kMaxChar; 8890 static const uint32_t kMaxOneByteCharCodeU = unibrow::Latin1::kMaxChar;
8914 static const int kMaxUtf16CodeUnit = 0xffff; 8891 static const int kMaxUtf16CodeUnit = 0xffff;
8915 static const uint32_t kMaxUtf16CodeUnitU = kMaxUtf16CodeUnit; 8892 static const uint32_t kMaxUtf16CodeUnitU = kMaxUtf16CodeUnit;
8916 static const uc32 kMaxCodePoint = 0x10ffff; 8893 static const uc32 kMaxCodePoint = 0x10ffff;
8917 8894
8918 // Maximal string length. 8895 // Maximal string length.
8919 static const int kMaxLength = (1 << 28) - 16; 8896 static const int kMaxLength = (1 << 28) - 16;
8920 8897
(...skipping 1885 matching lines...) Expand 10 before | Expand all | Expand 10 after
10806 } 10783 }
10807 return value; 10784 return value;
10808 } 10785 }
10809 }; 10786 };
10810 10787
10811 10788
10812 } // NOLINT, false-positive due to second-order macros. 10789 } // NOLINT, false-positive due to second-order macros.
10813 } // NOLINT, false-positive due to second-order macros. 10790 } // NOLINT, false-positive due to second-order macros.
10814 10791
10815 #endif // V8_OBJECTS_H_ 10792 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/globals.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698