Chromium Code Reviews| Index: src/property.h |
| diff --git a/src/property.h b/src/property.h |
| index 3faa28b85ed08ae6dedd0b68ce43e0caf8a9d9e3..14e3d006767d1ef924df445d8731a066a6ed206d 100644 |
| --- a/src/property.h |
| +++ b/src/property.h |
| @@ -132,6 +132,44 @@ class CallbacksDescriptor: public Descriptor { |
| }; |
| +// Hold a property index value distinguishing if it is a field index or an |
|
Jakob Kummerow
2012/11/13 10:44:43
nit: s/Hold/Holds/
|
| +// index inside the object header. |
| +class PropertyIndex { |
| + public: |
| + static PropertyIndex NewFieldIndex(int index) { |
| + return PropertyIndex(index, false); |
| + } |
| + static PropertyIndex NewHeaderIndex(int index) { |
| + return PropertyIndex(index, true); |
| + } |
| + |
| + bool IsFieldIndex() { return (index_ & kHeaderIndexBit) == 0; } |
|
Jakob Kummerow
2012/11/13 10:44:43
nit: I think for this and the next three methods,
|
| + bool IsHeaderIndex() { return (index_ & kHeaderIndexBit) != 0; } |
| + |
| + int FieldIndex() { |
| + ASSERT(IsFieldIndex()); |
| + return value(); |
| + } |
| + int HeaderIndex() { |
| + ASSERT(IsHeaderIndex()); |
| + return value(); |
| + } |
| + |
| + int RawIndex() { return index_; } |
|
Jakob Kummerow
2012/11/13 10:44:43
I don't see this ever getting called.
|
| + |
| + private: |
| + static const int kHeaderIndexBit = 1 << 31; |
| + static const int kIndexMask = ~kHeaderIndexBit; |
| + |
| + int value() { return index_ & kIndexMask; } |
| + |
| + int index_; |
| + PropertyIndex(int index, bool isHeaderBased) : |
|
Jakob Kummerow
2012/11/13 10:44:43
nit1: ':' should be on the second line (see e.g. t
|
| + index_(index | (isHeaderBased ? kHeaderIndexBit : 0)) { |
| + ASSERT(index <= kIndexMask); |
| + } |
| +}; |
| + |
|
Jakob Kummerow
2012/11/13 10:44:43
nit: two lines of whitespace between top-level def
|
| class LookupResult BASE_EMBEDDED { |
| public: |
| explicit LookupResult(Isolate* isolate) |
| @@ -278,7 +316,7 @@ class LookupResult BASE_EMBEDDED { |
| Object* GetLazyValue() { |
| switch (type()) { |
| case FIELD: |
| - return holder()->FastPropertyAt(GetFieldIndex()); |
| + return holder()->FastPropertyAt(GetFieldIndex().FieldIndex()); |
| case NORMAL: { |
| Object* value; |
| value = holder()->property_dictionary()->ValueAt(GetDictionaryEntry()); |
| @@ -334,10 +372,11 @@ class LookupResult BASE_EMBEDDED { |
| return number_; |
| } |
| - int GetFieldIndex() { |
| + PropertyIndex GetFieldIndex() { |
| ASSERT(lookup_type_ == DESCRIPTOR_TYPE); |
| ASSERT(IsField()); |
| - return Descriptor::IndexFromValue(GetValue()); |
| + return PropertyIndex::NewFieldIndex( |
| + Descriptor::IndexFromValue(GetValue())); |
| } |
| int GetLocalFieldIndexFromMap(Map* map) { |