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

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: Fixes and ArrayIndex-related cleanup in objects.h/.cc Created 4 years, 7 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
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 3172 matching lines...) Expand 10 before | Expand all | Expand 10 after
3183 inline static uint32_t NextProbe( 3183 inline static uint32_t NextProbe(
3184 uint32_t last, uint32_t number, uint32_t size) { 3184 uint32_t last, uint32_t number, uint32_t size) {
3185 return (last + number) & (size - 1); 3185 return (last + number) & (size - 1);
3186 } 3186 }
3187 }; 3187 };
3188 3188
3189 3189
3190 template <typename Derived, typename Shape, typename Key> 3190 template <typename Derived, typename Shape, typename Key>
3191 class HashTable : public HashTableBase { 3191 class HashTable : public HashTableBase {
3192 public: 3192 public:
3193 typedef Shape ShapeT;
3194
3193 // Wrapper methods 3195 // Wrapper methods
3194 inline uint32_t Hash(Key key) { 3196 inline uint32_t Hash(Key key) {
3195 if (Shape::UsesSeed) { 3197 if (Shape::UsesSeed) {
3196 return Shape::SeededHash(key, GetHeap()->HashSeed()); 3198 return Shape::SeededHash(key, GetHeap()->HashSeed());
3197 } else { 3199 } else {
3198 return Shape::Hash(key); 3200 return Shape::Hash(key);
3199 } 3201 }
3200 } 3202 }
3201 3203
3202 inline uint32_t HashForObject(Key key, Object* object) { 3204 inline uint32_t HashForObject(Key key, Object* object) {
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
3469 int at_least_space_for, 3471 int at_least_space_for,
3470 PretenureFlag pretenure = NOT_TENURED); 3472 PretenureFlag pretenure = NOT_TENURED);
3471 3473
3472 // Ensures that a new dictionary is created when the capacity is checked. 3474 // Ensures that a new dictionary is created when the capacity is checked.
3473 void SetRequiresCopyOnCapacityChange(); 3475 void SetRequiresCopyOnCapacityChange();
3474 3476
3475 // Ensure enough space for n additional elements. 3477 // Ensure enough space for n additional elements.
3476 static Handle<Derived> EnsureCapacity(Handle<Derived> obj, int n, Key key); 3478 static Handle<Derived> EnsureCapacity(Handle<Derived> obj, int n, Key key);
3477 3479
3478 #ifdef OBJECT_PRINT 3480 #ifdef OBJECT_PRINT
3481 // For our gdb macros, we should perhaps change these in the future.
3482 void Print();
3483
3479 void Print(std::ostream& os); // NOLINT 3484 void Print(std::ostream& os); // NOLINT
3480 #endif 3485 #endif
3481 // Returns the key (slow). 3486 // Returns the key (slow).
3482 Object* SlowReverseLookup(Object* value); 3487 Object* SlowReverseLookup(Object* value);
3483 3488
3484 // Sets the entry to (key, value) pair. 3489 // Sets the entry to (key, value) pair.
3485 inline void SetEntry(int entry, 3490 inline void SetEntry(int entry,
3486 Handle<Object> key, 3491 Handle<Object> key,
3487 Handle<Object> value); 3492 Handle<Object> value);
3488 inline void SetEntry(int entry, 3493 inline void SetEntry(int entry,
(...skipping 5018 matching lines...) Expand 10 before | Expand all | Expand 10 after
8507 // Shift constant retrieving hash code from hash field. 8512 // Shift constant retrieving hash code from hash field.
8508 static const int kHashShift = kNofHashBitFields; 8513 static const int kHashShift = kNofHashBitFields;
8509 8514
8510 // Only these bits are relevant in the hash, since the top two are shifted 8515 // Only these bits are relevant in the hash, since the top two are shifted
8511 // out. 8516 // out.
8512 static const uint32_t kHashBitMask = 0xffffffffu >> kHashShift; 8517 static const uint32_t kHashBitMask = 0xffffffffu >> kHashShift;
8513 8518
8514 // Array index strings this short can keep their index in the hash field. 8519 // Array index strings this short can keep their index in the hash field.
8515 static const int kMaxCachedArrayIndexLength = 7; 8520 static const int kMaxCachedArrayIndexLength = 7;
8516 8521
8522 // Maximum number of characters to consider when trying to convert a string
8523 // value into an array index.
8524 static const int kMaxArrayIndexSize = 10;
8525
8517 // For strings which are array indexes the hash value has the string length 8526 // For strings which are array indexes the hash value has the string length
8518 // mixed into the hash, mainly to avoid a hash value of zero which would be 8527 // mixed into the hash, mainly to avoid a hash value of zero which would be
8519 // the case for the string '0'. 24 bits are used for the array index value. 8528 // the case for the string '0'. 24 bits are used for the array index value.
8520 static const int kArrayIndexValueBits = 24; 8529 static const int kArrayIndexValueBits = 24;
8521 static const int kArrayIndexLengthBits = 8530 static const int kArrayIndexLengthBits =
8522 kBitsPerInt - kArrayIndexValueBits - kNofHashBitFields; 8531 kBitsPerInt - kArrayIndexValueBits - kNofHashBitFields;
8523 8532
8524 STATIC_ASSERT((kArrayIndexLengthBits > 0)); 8533 STATIC_ASSERT(kArrayIndexLengthBits > 0);
8534 STATIC_ASSERT(kMaxArrayIndexSize < (1 << kArrayIndexLengthBits));
8525 8535
8526 class ArrayIndexValueBits : public BitField<unsigned int, kNofHashBitFields, 8536 class ArrayIndexValueBits : public BitField<unsigned int, kNofHashBitFields,
8527 kArrayIndexValueBits> {}; // NOLINT 8537 kArrayIndexValueBits> {}; // NOLINT
8528 class ArrayIndexLengthBits : public BitField<unsigned int, 8538 class ArrayIndexLengthBits : public BitField<unsigned int,
8529 kNofHashBitFields + kArrayIndexValueBits, 8539 kNofHashBitFields + kArrayIndexValueBits,
8530 kArrayIndexLengthBits> {}; // NOLINT 8540 kArrayIndexLengthBits> {}; // NOLINT
8531 8541
8532 // Check that kMaxCachedArrayIndexLength + 1 is a power of two so we 8542 // Check that kMaxCachedArrayIndexLength + 1 is a power of two so we
8533 // could use a mask to test if the length of string is less than or equal to 8543 // could use a mask to test if the length of string is less than or equal to
8534 // kMaxCachedArrayIndexLength. 8544 // kMaxCachedArrayIndexLength.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
8604 // Ecma-262: 8614 // Ecma-262:
8605 // 4.3.16 String Value 8615 // 4.3.16 String Value
8606 // A string value is a member of the type String and is a finite 8616 // A string value is a member of the type String and is a finite
8607 // ordered sequence of zero or more 16-bit unsigned integer values. 8617 // ordered sequence of zero or more 16-bit unsigned integer values.
8608 // 8618 //
8609 // All string values have a length field. 8619 // All string values have a length field.
8610 class String: public Name { 8620 class String: public Name {
8611 public: 8621 public:
8612 enum Encoding { ONE_BYTE_ENCODING, TWO_BYTE_ENCODING }; 8622 enum Encoding { ONE_BYTE_ENCODING, TWO_BYTE_ENCODING };
8613 8623
8614 // Array index strings this short can keep their index in the hash field.
8615 static const int kMaxCachedArrayIndexLength = 7;
8616
8617 // For strings which are array indexes the hash value has the string length
8618 // mixed into the hash, mainly to avoid a hash value of zero which would be
8619 // the case for the string '0'. 24 bits are used for the array index value.
8620 static const int kArrayIndexValueBits = 24;
8621 static const int kArrayIndexLengthBits =
8622 kBitsPerInt - kArrayIndexValueBits - kNofHashBitFields;
8623
8624 STATIC_ASSERT((kArrayIndexLengthBits > 0));
8625
8626 class ArrayIndexValueBits : public BitField<unsigned int, kNofHashBitFields,
8627 kArrayIndexValueBits> {}; // NOLINT
8628 class ArrayIndexLengthBits : public BitField<unsigned int,
8629 kNofHashBitFields + kArrayIndexValueBits,
8630 kArrayIndexLengthBits> {}; // NOLINT
8631
8632 // Check that kMaxCachedArrayIndexLength + 1 is a power of two so we
8633 // could use a mask to test if the length of string is less than or equal to
8634 // kMaxCachedArrayIndexLength.
8635 STATIC_ASSERT(IS_POWER_OF_TWO(kMaxCachedArrayIndexLength + 1));
8636
8637 static const unsigned int kContainsCachedArrayIndexMask =
8638 (~static_cast<unsigned>(kMaxCachedArrayIndexLength)
8639 << ArrayIndexLengthBits::kShift) |
8640 kIsNotArrayIndexMask;
8641
8642 class SubStringRange { 8624 class SubStringRange {
8643 public: 8625 public:
8644 explicit inline SubStringRange(String* string, int first = 0, 8626 explicit inline SubStringRange(String* string, int first = 0,
8645 int length = -1); 8627 int length = -1);
8646 class iterator; 8628 class iterator;
8647 inline iterator begin(); 8629 inline iterator begin();
8648 inline iterator end(); 8630 inline iterator end();
8649 8631
8650 private: 8632 private:
8651 String* string_; 8633 String* string_;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
8839 #endif 8821 #endif
8840 DECLARE_PRINTER(String) 8822 DECLARE_PRINTER(String)
8841 DECLARE_VERIFIER(String) 8823 DECLARE_VERIFIER(String)
8842 8824
8843 inline bool IsFlat(); 8825 inline bool IsFlat();
8844 8826
8845 // Layout description. 8827 // Layout description.
8846 static const int kLengthOffset = Name::kSize; 8828 static const int kLengthOffset = Name::kSize;
8847 static const int kSize = kLengthOffset + kPointerSize; 8829 static const int kSize = kLengthOffset + kPointerSize;
8848 8830
8849 // Maximum number of characters to consider when trying to convert a string
8850 // value into an array index.
8851 static const int kMaxArrayIndexSize = 10;
8852 STATIC_ASSERT(kMaxArrayIndexSize < (1 << kArrayIndexLengthBits));
8853
8854 // Max char codes. 8831 // Max char codes.
8855 static const int32_t kMaxOneByteCharCode = unibrow::Latin1::kMaxChar; 8832 static const int32_t kMaxOneByteCharCode = unibrow::Latin1::kMaxChar;
8856 static const uint32_t kMaxOneByteCharCodeU = unibrow::Latin1::kMaxChar; 8833 static const uint32_t kMaxOneByteCharCodeU = unibrow::Latin1::kMaxChar;
8857 static const int kMaxUtf16CodeUnit = 0xffff; 8834 static const int kMaxUtf16CodeUnit = 0xffff;
8858 static const uint32_t kMaxUtf16CodeUnitU = kMaxUtf16CodeUnit; 8835 static const uint32_t kMaxUtf16CodeUnitU = kMaxUtf16CodeUnit;
8859 static const uc32 kMaxCodePoint = 0x10ffff; 8836 static const uc32 kMaxCodePoint = 0x10ffff;
8860 8837
8861 // Maximal string length. 8838 // Maximal string length.
8862 static const int kMaxLength = (1 << 28) - 16; 8839 static const int kMaxLength = (1 << 28) - 16;
8863 8840
(...skipping 1885 matching lines...) Expand 10 before | Expand all | Expand 10 after
10749 } 10726 }
10750 return value; 10727 return value;
10751 } 10728 }
10752 }; 10729 };
10753 10730
10754 10731
10755 } // NOLINT, false-positive due to second-order macros. 10732 } // NOLINT, false-positive due to second-order macros.
10756 } // NOLINT, false-positive due to second-order macros. 10733 } // NOLINT, false-positive due to second-order macros.
10757 10734
10758 #endif // V8_OBJECTS_H_ 10735 #endif // V8_OBJECTS_H_
OLDNEW
« src/code-stub-assembler.cc ('K') | « src/compiler/code-assembler.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698