Chromium Code Reviews| Index: src/field-index-inl.h |
| diff --git a/src/field-index-inl.h b/src/field-index-inl.h |
| index 6811891d4852a9d5785076a9fbbfe950724c083b..670c16ec423a40a2d85af1c93a4e7ca642cea8bd 100644 |
| --- a/src/field-index-inl.h |
| +++ b/src/field-index-inl.h |
| @@ -86,18 +86,18 @@ inline int FieldIndex::GetLoadByFieldIndex() const { |
| // Takes an offset as computed by GetLoadByFieldOffset and reconstructs a |
| // FieldIndex object from it. |
| +// static |
| inline FieldIndex FieldIndex::ForLoadByFieldOffset(Map* map, int offset) { |
| - bool is_double = offset & 1; |
| - int field_index = (offset >> 1) / kPointerSize; |
| - int is_inobject = true; |
| + DCHECK(offset & 1); // Property marker (as opposed to element). |
| + bool is_inobject = offset & 2; |
|
Igor Sheludko
2016/07/26 16:25:11
Same here.
Jakob Kummerow
2016/07/26 17:10:40
Done.
|
| + bool is_double = offset & 4; |
| + int field_index = (offset >> 3) / kPointerSize; |
| int first_inobject_offset = 0; |
| - if (field_index < 0) { |
| - field_index = -field_index; |
| - is_inobject = false; |
| - first_inobject_offset = FixedArray::kHeaderSize; |
| - } else { |
| + if (is_inobject) { |
| first_inobject_offset = |
| map->IsJSObjectMap() ? map->GetInObjectPropertyOffset(0) : 0; |
| + } else { |
| + first_inobject_offset = FixedArray::kHeaderSize; |
| } |
| int inobject_properties = |
| map->IsJSObjectMap() ? map->GetInObjectProperties() : 0; |
| @@ -108,17 +108,13 @@ inline FieldIndex FieldIndex::ForLoadByFieldOffset(Map* map, int offset) { |
| } |
| // Returns the offset format consumed by TurboFan stubs: |
| -// In-object: zero-based from object start, |
| -// out-of-object: zero-based from FixedArray start. |
| +// (offset << 3) | (is_double << 2) | (is_inobject << 1) | is_property |
| +// Where |offset| is relative to object start or FixedArray start, respectively. |
| inline int FieldIndex::GetLoadByFieldOffset() const { |
| - // For efficiency, stubs consume an offset that is optimized for quick |
| - // access. If the property is in-object, the offset is positive. |
| - // If it's out-of-object, the encoded offset is -raw_offset. |
| - // In either case, the offset itself is shifted up by one bit, the lower-most |
| - // bit signifying if the field is a mutable double box (1) or not (0). |
| - int result = index() << kPointerSizeLog2; |
| - if (!is_inobject()) result = -result; |
| - return (result << 1) | (is_double() ? 1 : 0); |
| + int offset = index() << kPointerSizeLog2; |
| + return (offset << 3) | ((is_double() ? 1 : 0) << 2) | |
|
Igor Sheludko
2016/07/26 16:25:11
And here.
Jakob Kummerow
2016/07/26 17:10:40
Done.
|
| + ((is_inobject() ? 1 : 0) << 1) | |
| + 1; // Property marker (as opposed to element). |
| } |
| inline FieldIndex FieldIndex::ForDescriptor(Map* map, int descriptor_index) { |