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

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

Issue 370573003: Hydrogenized KeyedLoadGeneric stub: Fix FieldIndex::GetLoadByFieldIndex() (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/field-index.h ('k') | no next file » | 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 27 matching lines...) Expand all
38 } else { 38 } else {
39 first_inobject_offset = FixedArray::kHeaderSize; 39 first_inobject_offset = FixedArray::kHeaderSize;
40 property_index -= inobject_properties; 40 property_index -= inobject_properties;
41 } 41 }
42 return FieldIndex(is_inobject, 42 return FieldIndex(is_inobject,
43 property_index + first_inobject_offset / kPointerSize, 43 property_index + first_inobject_offset / kPointerSize,
44 is_double, inobject_properties, first_inobject_offset); 44 is_double, inobject_properties, first_inobject_offset);
45 } 45 }
46 46
47 47
48 // Takes an index as computed by GetLoadFieldByIndex and reconstructs a
49 // FieldIndex object from it.
48 inline FieldIndex FieldIndex::ForLoadByFieldIndex(Map* map, int orig_index) { 50 inline FieldIndex FieldIndex::ForLoadByFieldIndex(Map* map, int orig_index) {
49 int field_index = orig_index; 51 int field_index = orig_index;
50 int is_inobject = true; 52 int is_inobject = true;
51 bool is_double = field_index & 1; 53 bool is_double = field_index & 1;
52 int first_inobject_offset = 0; 54 int first_inobject_offset = 0;
53 field_index >>= 1; 55 field_index >>= 1;
54 if (field_index < 0) { 56 if (field_index < 0) {
55 field_index = -(field_index + 1); 57 field_index = -(field_index + 1);
56 is_inobject = false; 58 is_inobject = false;
57 first_inobject_offset = FixedArray::kHeaderSize; 59 first_inobject_offset = FixedArray::kHeaderSize;
58 field_index += FixedArray::kHeaderSize / kPointerSize; 60 field_index += FixedArray::kHeaderSize / kPointerSize;
59 } else { 61 } else {
60 first_inobject_offset = map->GetInObjectPropertyOffset(0); 62 first_inobject_offset = map->GetInObjectPropertyOffset(0);
61 field_index += JSObject::kHeaderSize / kPointerSize; 63 field_index += JSObject::kHeaderSize / kPointerSize;
62 } 64 }
63 return FieldIndex(is_inobject, field_index, is_double, 65 FieldIndex result(is_inobject, field_index, is_double,
64 map->inobject_properties(), first_inobject_offset); 66 map->inobject_properties(), first_inobject_offset);
67 ASSERT(result.GetLoadByFieldIndex() == orig_index);
68 return result;
65 } 69 }
66 70
67 71
72 // Returns the index format accepted by the HLoadFieldByIndex instruction.
73 // (In-object: zero-based from (object start + JSObject::kHeaderSize),
74 // out-of-object: zero-based from FixedArray::kHeaderSize.)
75 inline int FieldIndex::GetLoadByFieldIndex() const {
76 // For efficiency, the LoadByFieldIndex instruction takes an index that is
77 // optimized for quick access. If the property is inline, the index is
78 // positive. If it's out-of-line, the encoded index is -raw_index - 1 to
79 // disambiguate the zero out-of-line index from the zero inobject case.
80 // The index itself is shifted up by one bit, the lower-most bit
81 // signifying if the field is a mutable double box (1) or not (0).
82 int result = index();
83 if (is_inobject()) {
84 result -= JSObject::kHeaderSize / kPointerSize;
85 } else {
86 result -= FixedArray::kHeaderSize / kPointerSize;
87 result = -result - 1;
88 }
89 result <<= 1;
90 return is_double() ? (result | 1) : result;
91 }
92
93
68 inline FieldIndex FieldIndex::ForDescriptor(Map* map, int descriptor_index) { 94 inline FieldIndex FieldIndex::ForDescriptor(Map* map, int descriptor_index) {
69 PropertyDetails details = 95 PropertyDetails details =
70 map->instance_descriptors()->GetDetails(descriptor_index); 96 map->instance_descriptors()->GetDetails(descriptor_index);
71 int field_index = 97 int field_index =
72 map->instance_descriptors()->GetFieldIndex(descriptor_index); 98 map->instance_descriptors()->GetFieldIndex(descriptor_index);
73 return ForPropertyIndex(map, field_index, 99 return ForPropertyIndex(map, field_index,
74 details.representation().IsDouble()); 100 details.representation().IsDouble());
75 } 101 }
76 102
77 103
(...skipping 11 matching lines...) Expand all
89 return GetLoadByFieldIndex(); 115 return GetLoadByFieldIndex();
90 } else { 116 } else {
91 return property_index(); 117 return property_index();
92 } 118 }
93 } 119 }
94 120
95 121
96 } } // namespace v8::internal 122 } } // namespace v8::internal
97 123
98 #endif 124 #endif
OLDNEW
« no previous file with comments | « src/field-index.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698