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

Side by Side Diff: src/objects.h

Issue 2079823002: [stubs] Implementing CodeStubAssembler::GetOwnProperty(). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixing TryHasOwnProperty and addressing comments Created 4 years, 5 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/code-stubs.cc ('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 3216 matching lines...) Expand 10 before | Expand all | Expand 10 after
3227 3227
3228 // Find entry for key otherwise return kNotFound. 3228 // Find entry for key otherwise return kNotFound.
3229 inline int FindEntry(Key key); 3229 inline int FindEntry(Key key);
3230 inline int FindEntry(Isolate* isolate, Key key, int32_t hash); 3230 inline int FindEntry(Isolate* isolate, Key key, int32_t hash);
3231 int FindEntry(Isolate* isolate, Key key); 3231 int FindEntry(Isolate* isolate, Key key);
3232 3232
3233 // Rehashes the table in-place. 3233 // Rehashes the table in-place.
3234 void Rehash(Key key); 3234 void Rehash(Key key);
3235 3235
3236 // Returns the key at entry. 3236 // Returns the key at entry.
3237 Object* KeyAt(int entry) { return get(EntryToIndex(entry)); } 3237 Object* KeyAt(int entry) { return get(EntryToIndex(entry) + kEntryKeyIndex); }
3238 3238
3239 static const int kElementsStartIndex = kPrefixStartIndex + Shape::kPrefixSize; 3239 static const int kElementsStartIndex = kPrefixStartIndex + Shape::kPrefixSize;
3240 static const int kEntrySize = Shape::kEntrySize; 3240 static const int kEntrySize = Shape::kEntrySize;
3241 STATIC_ASSERT(kEntrySize > 0);
3242 static const int kEntryKeyIndex = 0;
3241 static const int kElementsStartOffset = 3243 static const int kElementsStartOffset =
3242 kHeaderSize + kElementsStartIndex * kPointerSize; 3244 kHeaderSize + kElementsStartIndex * kPointerSize;
3243 static const int kCapacityOffset = 3245 static const int kCapacityOffset =
3244 kHeaderSize + kCapacityIndex * kPointerSize; 3246 kHeaderSize + kCapacityIndex * kPointerSize;
3245 3247
3246 // Returns the index for an entry (of the key) 3248 // Returns the index for an entry (of the key)
3247 static inline int EntryToIndex(int entry) { 3249 static inline int EntryToIndex(int entry) {
3248 return (entry * kEntrySize) + kElementsStartIndex; 3250 return (entry * kEntrySize) + kElementsStartIndex;
3249 } 3251 }
3250 3252
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
3545 }; 3547 };
3546 3548
3547 3549
3548 template <typename Key> 3550 template <typename Key>
3549 class BaseDictionaryShape : public BaseShape<Key> { 3551 class BaseDictionaryShape : public BaseShape<Key> {
3550 public: 3552 public:
3551 template <typename Dictionary> 3553 template <typename Dictionary>
3552 static inline PropertyDetails DetailsAt(Dictionary* dict, int entry) { 3554 static inline PropertyDetails DetailsAt(Dictionary* dict, int entry) {
3553 STATIC_ASSERT(Dictionary::kEntrySize == 3); 3555 STATIC_ASSERT(Dictionary::kEntrySize == 3);
3554 DCHECK(entry >= 0); // Not found is -1, which is not caught by get(). 3556 DCHECK(entry >= 0); // Not found is -1, which is not caught by get().
3555 return PropertyDetails( 3557 return PropertyDetails(Smi::cast(dict->get(
3556 Smi::cast(dict->get(Dictionary::EntryToIndex(entry) + 2))); 3558 Dictionary::EntryToIndex(entry) + Dictionary::kEntryDetailsIndex)));
3557 } 3559 }
3558 3560
3559 template <typename Dictionary> 3561 template <typename Dictionary>
3560 static inline void DetailsAtPut(Dictionary* dict, int entry, 3562 static inline void DetailsAtPut(Dictionary* dict, int entry,
3561 PropertyDetails value) { 3563 PropertyDetails value) {
3562 STATIC_ASSERT(Dictionary::kEntrySize == 3); 3564 STATIC_ASSERT(Dictionary::kEntrySize == 3);
3563 dict->set(Dictionary::EntryToIndex(entry) + 2, value.AsSmi()); 3565 dict->set(Dictionary::EntryToIndex(entry) + Dictionary::kEntryDetailsIndex,
3566 value.AsSmi());
3564 } 3567 }
3565 3568
3566 template <typename Dictionary> 3569 template <typename Dictionary>
3567 static bool IsDeleted(Dictionary* dict, int entry) { 3570 static bool IsDeleted(Dictionary* dict, int entry) {
3568 return false; 3571 return false;
3569 } 3572 }
3570 3573
3571 template <typename Dictionary> 3574 template <typename Dictionary>
3572 static inline void SetEntry(Dictionary* dict, int entry, Handle<Object> key, 3575 static inline void SetEntry(Dictionary* dict, int entry, Handle<Object> key,
3573 Handle<Object> value, PropertyDetails details); 3576 Handle<Object> value, PropertyDetails details);
3574 }; 3577 };
3575 3578
3576 3579
3577 class NameDictionaryShape : public BaseDictionaryShape<Handle<Name> > { 3580 class NameDictionaryShape : public BaseDictionaryShape<Handle<Name> > {
3578 public: 3581 public:
3579 static inline bool IsMatch(Handle<Name> key, Object* other); 3582 static inline bool IsMatch(Handle<Name> key, Object* other);
3580 static inline uint32_t Hash(Handle<Name> key); 3583 static inline uint32_t Hash(Handle<Name> key);
3581 static inline uint32_t HashForObject(Handle<Name> key, Object* object); 3584 static inline uint32_t HashForObject(Handle<Name> key, Object* object);
3582 static inline Handle<Object> AsHandle(Isolate* isolate, Handle<Name> key); 3585 static inline Handle<Object> AsHandle(Isolate* isolate, Handle<Name> key);
3583 static const int kPrefixSize = 2; 3586 static const int kPrefixSize = 2;
3584 static const int kEntrySize = 3; 3587 static const int kEntrySize = 3;
3588 static const int kEntryValueIndex = 1;
3589 static const int kEntryDetailsIndex = 2;
3585 static const bool kIsEnumerable = true; 3590 static const bool kIsEnumerable = true;
3586 }; 3591 };
3587 3592
3588 3593
3589 class NameDictionary 3594 class NameDictionary
3590 : public NameDictionaryBase<NameDictionary, NameDictionaryShape> { 3595 : public NameDictionaryBase<NameDictionary, NameDictionaryShape> {
3591 typedef NameDictionaryBase<NameDictionary, NameDictionaryShape> 3596 typedef NameDictionaryBase<NameDictionary, NameDictionaryShape>
3592 DerivedDictionary; 3597 DerivedDictionary;
3593 3598
3594 public: 3599 public:
3595 DECLARE_CAST(NameDictionary) 3600 DECLARE_CAST(NameDictionary)
3596 3601
3597 inline static Handle<FixedArray> DoGenerateNewEnumerationIndices( 3602 inline static Handle<FixedArray> DoGenerateNewEnumerationIndices(
3598 Handle<NameDictionary> dictionary); 3603 Handle<NameDictionary> dictionary);
3604
3605 static const int kEntryValueIndex = 1;
3606 static const int kEntryDetailsIndex = 2;
3599 }; 3607 };
3600 3608
3601 3609
3602 class GlobalDictionaryShape : public NameDictionaryShape { 3610 class GlobalDictionaryShape : public NameDictionaryShape {
3603 public: 3611 public:
3604 static const int kEntrySize = 2; // Overrides NameDictionaryShape::kEntrySize 3612 static const int kEntrySize = 2; // Overrides NameDictionaryShape::kEntrySize
3605 3613
3606 template <typename Dictionary> 3614 template <typename Dictionary>
3607 static inline PropertyDetails DetailsAt(Dictionary* dict, int entry); 3615 static inline PropertyDetails DetailsAt(Dictionary* dict, int entry);
3608 3616
3609 template <typename Dictionary> 3617 template <typename Dictionary>
3610 static inline void DetailsAtPut(Dictionary* dict, int entry, 3618 static inline void DetailsAtPut(Dictionary* dict, int entry,
3611 PropertyDetails value); 3619 PropertyDetails value);
3612 3620
3613 template <typename Dictionary> 3621 template <typename Dictionary>
3614 static bool IsDeleted(Dictionary* dict, int entry); 3622 static bool IsDeleted(Dictionary* dict, int entry);
3615 3623
3616 template <typename Dictionary> 3624 template <typename Dictionary>
3617 static inline void SetEntry(Dictionary* dict, int entry, Handle<Object> key, 3625 static inline void SetEntry(Dictionary* dict, int entry, Handle<Object> key,
3618 Handle<Object> value, PropertyDetails details); 3626 Handle<Object> value, PropertyDetails details);
3619 }; 3627 };
3620 3628
3621 3629
3622 class GlobalDictionary 3630 class GlobalDictionary
3623 : public NameDictionaryBase<GlobalDictionary, GlobalDictionaryShape> { 3631 : public NameDictionaryBase<GlobalDictionary, GlobalDictionaryShape> {
3624 public: 3632 public:
3625 DECLARE_CAST(GlobalDictionary) 3633 DECLARE_CAST(GlobalDictionary)
3634
3635 static const int kEntryValueIndex = 1;
3626 }; 3636 };
3627 3637
3628 3638
3629 class NumberDictionaryShape : public BaseDictionaryShape<uint32_t> { 3639 class NumberDictionaryShape : public BaseDictionaryShape<uint32_t> {
3630 public: 3640 public:
3631 static inline bool IsMatch(uint32_t key, Object* other); 3641 static inline bool IsMatch(uint32_t key, Object* other);
3632 static inline Handle<Object> AsHandle(Isolate* isolate, uint32_t key); 3642 static inline Handle<Object> AsHandle(Isolate* isolate, uint32_t key);
3633 static const int kEntrySize = 3; 3643 static const int kEntrySize = 3;
3634 static const bool kIsEnumerable = false; 3644 static const bool kIsEnumerable = false;
3635 }; 3645 };
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
3689 // kRequiresSlowElementsLimit or set_requires_slow_elements() has been called 3699 // kRequiresSlowElementsLimit or set_requires_slow_elements() has been called
3690 // when defining a getter or setter with a number key. 3700 // when defining a getter or setter with a number key.
3691 inline bool requires_slow_elements(); 3701 inline bool requires_slow_elements();
3692 inline void set_requires_slow_elements(); 3702 inline void set_requires_slow_elements();
3693 3703
3694 // Get the value of the max number key that has been added to this 3704 // Get the value of the max number key that has been added to this
3695 // dictionary. max_number_key can only be called if 3705 // dictionary. max_number_key can only be called if
3696 // requires_slow_elements returns false. 3706 // requires_slow_elements returns false.
3697 inline uint32_t max_number_key(); 3707 inline uint32_t max_number_key();
3698 3708
3709 static const int kEntryValueIndex = 1;
3710 static const int kEntryDetailsIndex = 2;
3711
3699 // Bit masks. 3712 // Bit masks.
3700 static const int kRequiresSlowElementsMask = 1; 3713 static const int kRequiresSlowElementsMask = 1;
3701 static const int kRequiresSlowElementsTagSize = 1; 3714 static const int kRequiresSlowElementsTagSize = 1;
3702 static const uint32_t kRequiresSlowElementsLimit = (1 << 29) - 1; 3715 static const uint32_t kRequiresSlowElementsLimit = (1 << 29) - 1;
3703 }; 3716 };
3704 3717
3705 3718
3706 class UnseededNumberDictionary 3719 class UnseededNumberDictionary
3707 : public Dictionary<UnseededNumberDictionary, 3720 : public Dictionary<UnseededNumberDictionary,
3708 UnseededNumberDictionaryShape, 3721 UnseededNumberDictionaryShape,
(...skipping 10 matching lines...) Expand all
3719 Handle<UnseededNumberDictionary> dictionary, 3732 Handle<UnseededNumberDictionary> dictionary,
3720 uint32_t key, 3733 uint32_t key,
3721 Handle<Object> value); 3734 Handle<Object> value);
3722 3735
3723 // Set an existing entry or add a new one if needed. 3736 // Set an existing entry or add a new one if needed.
3724 // Return the updated dictionary. 3737 // Return the updated dictionary.
3725 MUST_USE_RESULT static Handle<UnseededNumberDictionary> Set( 3738 MUST_USE_RESULT static Handle<UnseededNumberDictionary> Set(
3726 Handle<UnseededNumberDictionary> dictionary, 3739 Handle<UnseededNumberDictionary> dictionary,
3727 uint32_t key, 3740 uint32_t key,
3728 Handle<Object> value); 3741 Handle<Object> value);
3742
3743 static const int kEntryValueIndex = 1;
3744 static const int kEntryDetailsIndex = 2;
3729 }; 3745 };
3730 3746
3731 3747
3732 class ObjectHashTableShape : public BaseShape<Handle<Object> > { 3748 class ObjectHashTableShape : public BaseShape<Handle<Object> > {
3733 public: 3749 public:
3734 static inline bool IsMatch(Handle<Object> key, Object* other); 3750 static inline bool IsMatch(Handle<Object> key, Object* other);
3735 static inline uint32_t Hash(Handle<Object> key); 3751 static inline uint32_t Hash(Handle<Object> key);
3736 static inline uint32_t HashForObject(Handle<Object> key, Object* object); 3752 static inline uint32_t HashForObject(Handle<Object> key, Object* object);
3737 static inline Handle<Object> AsHandle(Isolate* isolate, Handle<Object> key); 3753 static inline Handle<Object> AsHandle(Isolate* isolate, Handle<Object> key);
3738 static const int kPrefixSize = 0; 3754 static const int kPrefixSize = 0;
(...skipping 7067 matching lines...) Expand 10 before | Expand all | Expand 10 after
10806 } 10822 }
10807 return value; 10823 return value;
10808 } 10824 }
10809 }; 10825 };
10810 10826
10811 10827
10812 } // NOLINT, false-positive due to second-order macros. 10828 } // NOLINT, false-positive due to second-order macros.
10813 } // NOLINT, false-positive due to second-order macros. 10829 } // NOLINT, false-positive due to second-order macros.
10814 10830
10815 #endif // V8_OBJECTS_H_ 10831 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/code-stubs.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698