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

Side by Side Diff: src/field-index.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 | « no previous file | src/field-index-inl.h » ('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_H_ 5 #ifndef V8_FIELD_INDEX_H_
6 #define V8_FIELD_INDEX_H_ 6 #define V8_FIELD_INDEX_H_
7 7
8 #include "src/property-details.h" 8 #include "src/property-details.h"
9 #include "src/utils.h" 9 #include "src/utils.h"
10 10
(...skipping 10 matching lines...) Expand all
21 public: 21 public:
22 static FieldIndex ForPropertyIndex(Map* map, 22 static FieldIndex ForPropertyIndex(Map* map,
23 int index, 23 int index,
24 bool is_double = false); 24 bool is_double = false);
25 static FieldIndex ForInObjectOffset(int offset, Map* map = NULL); 25 static FieldIndex ForInObjectOffset(int offset, Map* map = NULL);
26 static FieldIndex ForLookupResult(const LookupResult* result); 26 static FieldIndex ForLookupResult(const LookupResult* result);
27 static FieldIndex ForDescriptor(Map* map, int descriptor_index); 27 static FieldIndex ForDescriptor(Map* map, int descriptor_index);
28 static FieldIndex ForLoadByFieldIndex(Map* map, int index); 28 static FieldIndex ForLoadByFieldIndex(Map* map, int index);
29 static FieldIndex ForKeyedLookupCacheIndex(Map* map, int index); 29 static FieldIndex ForKeyedLookupCacheIndex(Map* map, int index);
30 30
31 int GetLoadByFieldIndex() const;
32
31 bool is_inobject() const { 33 bool is_inobject() const {
32 return IsInObjectBits::decode(bit_field_); 34 return IsInObjectBits::decode(bit_field_);
33 } 35 }
34 36
35 bool is_double() const { 37 bool is_double() const {
36 return IsDoubleBits::decode(bit_field_); 38 return IsDoubleBits::decode(bit_field_);
37 } 39 }
38 40
39 int offset() const { 41 int offset() const {
40 return index() * kPointerSize; 42 return index() * kPointerSize;
41 } 43 }
42 44
45 // Zero-indexed from beginning of the object.
43 int index() const { 46 int index() const {
44 return IndexBits::decode(bit_field_); 47 return IndexBits::decode(bit_field_);
45 } 48 }
46 49
47 int outobject_array_index() const { 50 int outobject_array_index() const {
48 ASSERT(!is_inobject()); 51 ASSERT(!is_inobject());
49 return index() - first_inobject_property_offset() / kPointerSize; 52 return index() - first_inobject_property_offset() / kPointerSize;
50 } 53 }
51 54
55 // Zero-based from the first inobject property. Overflows to out-of-object
56 // properties.
52 int property_index() const { 57 int property_index() const {
53 ASSERT(!IsHiddenField::decode(bit_field_)); 58 ASSERT(!IsHiddenField::decode(bit_field_));
54 int result = index() - first_inobject_property_offset() / kPointerSize; 59 int result = index() - first_inobject_property_offset() / kPointerSize;
55 if (!is_inobject()) { 60 if (!is_inobject()) {
56 result += InObjectPropertyBits::decode(bit_field_); 61 result += InObjectPropertyBits::decode(bit_field_);
57 } 62 }
58 return result; 63 return result;
59 } 64 }
60 65
61 int GetLoadByFieldIndex() const {
62 // For efficiency, the LoadByFieldIndex instruction takes an index that is
63 // optimized for quick access. If the property is inline, the index is
64 // positive. If it's out-of-line, the encoded index is -raw_index - 1 to
65 // disambiguate the zero out-of-line index from the zero inobject case.
66 // The index itself is shifted up by one bit, the lower-most bit
67 // signifying if the field is a mutable double box (1) or not (0).
68 int result = index() - first_inobject_property_offset() / kPointerSize;
69 if (!is_inobject()) {
70 result = -result - 1;
71 }
72 result <<= 1;
73 return is_double() ? (result | 1) : result;
74 }
75
76 int GetKeyedLookupCacheIndex() const; 66 int GetKeyedLookupCacheIndex() const;
77 67
78 int GetLoadFieldStubKey() const { 68 int GetLoadFieldStubKey() const {
79 return bit_field_ & 69 return bit_field_ &
80 (IsInObjectBits::kMask | IsDoubleBits::kMask | IndexBits::kMask); 70 (IsInObjectBits::kMask | IsDoubleBits::kMask | IndexBits::kMask);
81 } 71 }
82 72
83 private: 73 private:
84 FieldIndex(bool is_inobject, int local_index, bool is_double, 74 FieldIndex(bool is_inobject, int local_index, bool is_double,
85 int inobject_properties, int first_inobject_property_offset, 75 int inobject_properties, int first_inobject_property_offset,
86 bool is_hidden = false) { 76 bool is_hidden = false) {
87 ASSERT((first_inobject_property_offset & (kPointerSize - 1)) == 0); 77 ASSERT((first_inobject_property_offset & (kPointerSize - 1)) == 0);
88 bit_field_ = IsInObjectBits::encode(is_inobject) | 78 bit_field_ = IsInObjectBits::encode(is_inobject) |
89 IsDoubleBits::encode(is_double) | 79 IsDoubleBits::encode(is_double) |
90 FirstInobjectPropertyOffsetBits::encode(first_inobject_property_offset) | 80 FirstInobjectPropertyOffsetBits::encode(first_inobject_property_offset) |
91 IsHiddenField::encode(is_hidden) | 81 IsHiddenField::encode(is_hidden) |
92 IndexBits::encode(local_index) | 82 IndexBits::encode(local_index) |
93 InObjectPropertyBits::encode(inobject_properties); 83 InObjectPropertyBits::encode(inobject_properties);
94 } 84 }
95 85
96 int first_inobject_property_offset() const { 86 int first_inobject_property_offset() const {
97 ASSERT(!IsHiddenField::decode(bit_field_)); 87 ASSERT(!IsHiddenField::decode(bit_field_));
98 return FirstInobjectPropertyOffsetBits::decode(bit_field_); 88 return FirstInobjectPropertyOffsetBits::decode(bit_field_);
99 } 89 }
100 90
101 static const int kIndexBitsSize = kDescriptorIndexBitCount + 1; 91 static const int kIndexBitsSize = kDescriptorIndexBitCount + 1;
102 92
93 // Index from beginning of object.
103 class IndexBits: public BitField<int, 0, kIndexBitsSize> {}; 94 class IndexBits: public BitField<int, 0, kIndexBitsSize> {};
104 class IsInObjectBits: public BitField<bool, IndexBits::kNext, 1> {}; 95 class IsInObjectBits: public BitField<bool, IndexBits::kNext, 1> {};
105 class IsDoubleBits: public BitField<bool, IsInObjectBits::kNext, 1> {}; 96 class IsDoubleBits: public BitField<bool, IsInObjectBits::kNext, 1> {};
97 // Number of inobject properties.
106 class InObjectPropertyBits: public BitField<int, IsDoubleBits::kNext, 98 class InObjectPropertyBits: public BitField<int, IsDoubleBits::kNext,
107 kDescriptorIndexBitCount> {}; 99 kDescriptorIndexBitCount> {};
100 // Offset of first inobject property from beginning of object.
108 class FirstInobjectPropertyOffsetBits: 101 class FirstInobjectPropertyOffsetBits:
109 public BitField<int, InObjectPropertyBits::kNext, 7> {}; 102 public BitField<int, InObjectPropertyBits::kNext, 7> {};
110 class IsHiddenField: 103 class IsHiddenField:
111 public BitField<bool, FirstInobjectPropertyOffsetBits::kNext, 1> {}; 104 public BitField<bool, FirstInobjectPropertyOffsetBits::kNext, 1> {};
112 STATIC_ASSERT(IsHiddenField::kNext <= 32); 105 STATIC_ASSERT(IsHiddenField::kNext <= 32);
113 106
114 int bit_field_; 107 int bit_field_;
115 }; 108 };
116 109
117 } } // namespace v8::internal 110 } } // namespace v8::internal
118 111
119 #endif 112 #endif
OLDNEW
« no previous file with comments | « no previous file | src/field-index-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698