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

Side by Side Diff: src/field-index-inl.h

Issue 2182103002: [KeyedLoadIC] Support Smi "handlers" for simple field loads (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebased Created 4 years, 4 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/field-index.h ('k') | src/full-codegen/full-codegen.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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_FIELD_INDEX_INL_H_ 5 #ifndef V8_FIELD_INDEX_INL_H_
6 #define V8_FIELD_INDEX_INL_H_ 6 #define V8_FIELD_INDEX_INL_H_
7 7
8 #include "src/field-index.h" 8 #include "src/field-index.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } else { 79 } else {
80 result -= FixedArray::kHeaderSize / kPointerSize; 80 result -= FixedArray::kHeaderSize / kPointerSize;
81 result = -result - 1; 81 result = -result - 1;
82 } 82 }
83 result <<= 1; 83 result <<= 1;
84 return is_double() ? (result | 1) : result; 84 return is_double() ? (result | 1) : result;
85 } 85 }
86 86
87 // Takes an offset as computed by GetLoadByFieldOffset and reconstructs a 87 // Takes an offset as computed by GetLoadByFieldOffset and reconstructs a
88 // FieldIndex object from it. 88 // FieldIndex object from it.
89 // static
89 inline FieldIndex FieldIndex::ForLoadByFieldOffset(Map* map, int offset) { 90 inline FieldIndex FieldIndex::ForLoadByFieldOffset(Map* map, int offset) {
90 bool is_double = offset & 1; 91 DCHECK(offset & 1); // Property marker (as opposed to element).
91 int field_index = (offset >> 1) / kPointerSize; 92 bool is_inobject = FieldOffsetIsInobject::decode(offset);
92 int is_inobject = true; 93 bool is_double = FieldOffsetIsDouble::decode(offset);
94 int field_index = FieldOffsetOffset::decode(offset) >> kPointerSizeLog2;
93 int first_inobject_offset = 0; 95 int first_inobject_offset = 0;
94 if (field_index < 0) { 96 if (is_inobject) {
95 field_index = -field_index;
96 is_inobject = false;
97 first_inobject_offset = FixedArray::kHeaderSize;
98 } else {
99 first_inobject_offset = 97 first_inobject_offset =
100 map->IsJSObjectMap() ? map->GetInObjectPropertyOffset(0) : 0; 98 map->IsJSObjectMap() ? map->GetInObjectPropertyOffset(0) : 0;
99 } else {
100 first_inobject_offset = FixedArray::kHeaderSize;
101 } 101 }
102 int inobject_properties = 102 int inobject_properties =
103 map->IsJSObjectMap() ? map->GetInObjectProperties() : 0; 103 map->IsJSObjectMap() ? map->GetInObjectProperties() : 0;
104 FieldIndex result(is_inobject, field_index, is_double, inobject_properties, 104 FieldIndex result(is_inobject, field_index, is_double, inobject_properties,
105 first_inobject_offset); 105 first_inobject_offset);
106 DCHECK(result.GetLoadByFieldOffset() == offset); 106 DCHECK(result.GetLoadByFieldOffset() == offset);
107 return result; 107 return result;
108 } 108 }
109 109
110 // Returns the offset format consumed by TurboFan stubs: 110 // Returns the offset format consumed by TurboFan stubs:
111 // In-object: zero-based from object start, 111 // (offset << 3) | (is_double << 2) | (is_inobject << 1) | is_property
112 // out-of-object: zero-based from FixedArray start. 112 // Where |offset| is relative to object start or FixedArray start, respectively.
113 inline int FieldIndex::GetLoadByFieldOffset() const { 113 inline int FieldIndex::GetLoadByFieldOffset() const {
114 // For efficiency, stubs consume an offset that is optimized for quick 114 return FieldOffsetIsInobject::encode(is_inobject()) |
115 // access. If the property is in-object, the offset is positive. 115 FieldOffsetIsDouble::encode(is_double()) |
116 // If it's out-of-object, the encoded offset is -raw_offset. 116 FieldOffsetOffset::encode(index() << kPointerSizeLog2) |
117 // In either case, the offset itself is shifted up by one bit, the lower-most 117 1; // Property marker (as opposed to element).
118 // bit signifying if the field is a mutable double box (1) or not (0).
119 int result = index() << kPointerSizeLog2;
120 if (!is_inobject()) result = -result;
121 return (result << 1) | (is_double() ? 1 : 0);
122 } 118 }
123 119
124 inline FieldIndex FieldIndex::ForDescriptor(Map* map, int descriptor_index) { 120 inline FieldIndex FieldIndex::ForDescriptor(Map* map, int descriptor_index) {
125 PropertyDetails details = 121 PropertyDetails details =
126 map->instance_descriptors()->GetDetails(descriptor_index); 122 map->instance_descriptors()->GetDetails(descriptor_index);
127 int field_index = details.field_index(); 123 int field_index = details.field_index();
128 return ForPropertyIndex(map, field_index, 124 return ForPropertyIndex(map, field_index,
129 details.representation().IsDouble()); 125 details.representation().IsDouble());
130 } 126 }
131 127
(...skipping 18 matching lines...) Expand all
150 } else { 146 } else {
151 return property_index(); 147 return property_index();
152 } 148 }
153 } 149 }
154 150
155 151
156 } // namespace internal 152 } // namespace internal
157 } // namespace v8 153 } // namespace v8
158 154
159 #endif 155 #endif
OLDNEW
« no previous file with comments | « src/field-index.h ('k') | src/full-codegen/full-codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698