Chromium Code Reviews

Side by Side Diff: src/property.h

Issue 856503002: Massive renaming of PropertyType values and other implied stuff. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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_PROPERTY_H_ 5 #ifndef V8_PROPERTY_H_
6 #define V8_PROPERTY_H_ 6 #define V8_PROPERTY_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 9
10 #include "src/factory.h" 10 #include "src/factory.h"
(...skipping 55 matching lines...)
66 details_(attributes, type, representation, field_index) { } 66 details_(attributes, type, representation, field_index) { }
67 67
68 friend class DescriptorArray; 68 friend class DescriptorArray;
69 friend class Map; 69 friend class Map;
70 }; 70 };
71 71
72 72
73 std::ostream& operator<<(std::ostream& os, const Descriptor& d); 73 std::ostream& operator<<(std::ostream& os, const Descriptor& d);
74 74
75 75
76 class FieldDescriptor FINAL : public Descriptor { 76 class DataFieldDescriptor FINAL : public Descriptor {
77 public: 77 public:
78 FieldDescriptor(Handle<Name> key, 78 DataFieldDescriptor(Handle<Name> key, int field_index,
79 int field_index, 79 PropertyAttributes attributes,
80 PropertyAttributes attributes, 80 Representation representation)
81 Representation representation)
82 : Descriptor(key, HeapType::Any(key->GetIsolate()), attributes, 81 : Descriptor(key, HeapType::Any(key->GetIsolate()), attributes,
83 FIELD, representation, field_index) {} 82 DATA_FIELD, representation, field_index) {}
84 FieldDescriptor(Handle<Name> key, 83 DataFieldDescriptor(Handle<Name> key, int field_index,
85 int field_index, 84 Handle<HeapType> field_type,
86 Handle<HeapType> field_type, 85 PropertyAttributes attributes,
87 PropertyAttributes attributes, 86 Representation representation)
88 Representation representation) 87 : Descriptor(key, field_type, attributes, DATA_FIELD, representation,
89 : Descriptor(key, field_type, attributes, FIELD, 88 field_index) {}
90 representation, field_index) { }
91 }; 89 };
92 90
93 91
94 class ConstantDescriptor FINAL : public Descriptor { 92 class DataConstantDescriptor FINAL : public Descriptor {
95 public: 93 public:
96 ConstantDescriptor(Handle<Name> key, 94 DataConstantDescriptor(Handle<Name> key, Handle<Object> value,
97 Handle<Object> value, 95 PropertyAttributes attributes)
98 PropertyAttributes attributes) 96 : Descriptor(key, value, attributes, DATA_CONSTANT,
99 : Descriptor(key, value, attributes, CONSTANT,
100 value->OptimalRepresentation()) {} 97 value->OptimalRepresentation()) {}
101 }; 98 };
102 99
103 100
104 class CallbacksDescriptor FINAL : public Descriptor { 101 class AccessorConstantDescriptor FINAL : public Descriptor {
105 public: 102 public:
106 CallbacksDescriptor(Handle<Name> key, 103 AccessorConstantDescriptor(Handle<Name> key, Handle<Object> foreign,
107 Handle<Object> foreign, 104 PropertyAttributes attributes)
108 PropertyAttributes attributes) 105 : Descriptor(key, foreign, attributes, ACCESSOR_CONSTANT,
109 : Descriptor(key, foreign, attributes, CALLBACKS,
110 Representation::Tagged()) {} 106 Representation::Tagged()) {}
111 }; 107 };
112 108
113 109
114 class LookupResult FINAL BASE_EMBEDDED { 110 class LookupResult FINAL BASE_EMBEDDED {
115 public: 111 public:
116 explicit LookupResult(Isolate* isolate) 112 explicit LookupResult(Isolate* isolate)
117 : isolate_(isolate), 113 : isolate_(isolate),
118 next_(isolate->top_lookup_result()), 114 next_(isolate->top_lookup_result()),
119 lookup_type_(NOT_FOUND), 115 lookup_type_(NOT_FOUND),
120 holder_(NULL), 116 holder_(NULL),
121 transition_(NULL), 117 transition_(NULL),
122 details_(NONE, FIELD, Representation::None()) { 118 details_(NONE, DATA_FIELD, Representation::None()) {
123 isolate->set_top_lookup_result(this); 119 isolate->set_top_lookup_result(this);
124 } 120 }
125 121
126 ~LookupResult() { 122 ~LookupResult() {
127 DCHECK(isolate()->top_lookup_result() == this); 123 DCHECK(isolate()->top_lookup_result() == this);
128 isolate()->set_top_lookup_result(next_); 124 isolate()->set_top_lookup_result(next_);
129 } 125 }
130 126
131 Isolate* isolate() const { return isolate_; } 127 Isolate* isolate() const { return isolate_; }
132 128
133 void DescriptorResult(JSObject* holder, PropertyDetails details, int number) { 129 void DescriptorResult(JSObject* holder, PropertyDetails details, int number) {
134 lookup_type_ = DESCRIPTOR_TYPE; 130 lookup_type_ = DESCRIPTOR_TYPE;
135 holder_ = holder; 131 holder_ = holder;
136 transition_ = NULL; 132 transition_ = NULL;
137 details_ = details; 133 details_ = details;
138 number_ = number; 134 number_ = number;
139 } 135 }
140 136
141 void TransitionResult(JSObject* holder, Map* target) { 137 void TransitionResult(JSObject* holder, Map* target) {
142 lookup_type_ = TRANSITION_TYPE; 138 lookup_type_ = TRANSITION_TYPE;
143 number_ = target->LastAdded(); 139 number_ = target->LastAdded();
144 details_ = target->instance_descriptors()->GetDetails(number_); 140 details_ = target->instance_descriptors()->GetDetails(number_);
145 holder_ = holder; 141 holder_ = holder;
146 transition_ = target; 142 transition_ = target;
147 } 143 }
148 144
149 void NotFound() { 145 void NotFound() {
150 lookup_type_ = NOT_FOUND; 146 lookup_type_ = NOT_FOUND;
151 details_ = PropertyDetails(NONE, FIELD, 0); 147 details_ = PropertyDetails(NONE, DATA_FIELD, 0);
152 holder_ = NULL; 148 holder_ = NULL;
153 transition_ = NULL; 149 transition_ = NULL;
154 } 150 }
155 151
156 Representation representation() const { 152 Representation representation() const {
157 DCHECK(IsFound()); 153 DCHECK(IsFound());
158 return details_.representation(); 154 return details_.representation();
159 } 155 }
160 156
161 // Property callbacks does not include transitions to callbacks. 157 // Property callbacks does not include transitions to callbacks.
162 bool IsPropertyCallbacks() const { 158 bool IsAccessorConstant() const {
163 return !IsTransition() && details_.type() == CALLBACKS; 159 return !IsTransition() && details_.type() == ACCESSOR_CONSTANT;
164 } 160 }
165 161
166 bool IsReadOnly() const { 162 bool IsReadOnly() const {
167 DCHECK(IsFound()); 163 DCHECK(IsFound());
168 return details_.IsReadOnly(); 164 return details_.IsReadOnly();
169 } 165 }
170 166
171 bool IsField() const { 167 bool IsDataField() const {
172 return lookup_type_ == DESCRIPTOR_TYPE && details_.type() == FIELD; 168 return lookup_type_ == DESCRIPTOR_TYPE && details_.type() == DATA_FIELD;
173 } 169 }
174 170
175 bool IsConstant() const { 171 bool IsDataConstant() const {
176 return lookup_type_ == DESCRIPTOR_TYPE && details_.type() == CONSTANT; 172 return lookup_type_ == DESCRIPTOR_TYPE && details_.type() == DATA_CONSTANT;
177 } 173 }
178 174
179 bool IsConfigurable() const { return details_.IsConfigurable(); } 175 bool IsConfigurable() const { return details_.IsConfigurable(); }
180 bool IsFound() const { return lookup_type_ != NOT_FOUND; } 176 bool IsFound() const { return lookup_type_ != NOT_FOUND; }
181 bool IsTransition() const { return lookup_type_ == TRANSITION_TYPE; } 177 bool IsTransition() const { return lookup_type_ == TRANSITION_TYPE; }
182 178
183 // Is the result is a property excluding transitions and the null descriptor? 179 // Is the result is a property excluding transitions and the null descriptor?
184 bool IsProperty() const { 180 bool IsProperty() const {
185 return IsFound() && !IsTransition(); 181 return IsFound() && !IsTransition();
186 } 182 }
187 183
188 Map* GetTransitionTarget() const { 184 Map* GetTransitionTarget() const {
189 DCHECK(IsTransition()); 185 DCHECK(IsTransition());
190 return transition_; 186 return transition_;
191 } 187 }
192 188
193 bool IsTransitionToField() const { 189 bool IsTransitionToDataField() const {
194 return IsTransition() && details_.type() == FIELD; 190 return IsTransition() && details_.type() == DATA_FIELD;
195 } 191 }
196 192
197 int GetLocalFieldIndexFromMap(Map* map) const { 193 int GetLocalFieldIndexFromMap(Map* map) const {
198 return GetFieldIndexFromMap(map) - map->inobject_properties(); 194 return GetFieldIndexFromMap(map) - map->inobject_properties();
199 } 195 }
200 196
201 Object* GetConstantFromMap(Map* map) const { 197 Object* GetConstantFromMap(Map* map) const {
202 DCHECK(details_.type() == CONSTANT); 198 DCHECK(details_.type() == DATA_CONSTANT);
203 return GetValueFromMap(map); 199 return GetValueFromMap(map);
204 } 200 }
205 201
206 Object* GetValueFromMap(Map* map) const { 202 Object* GetValueFromMap(Map* map) const {
207 DCHECK(lookup_type_ == DESCRIPTOR_TYPE || 203 DCHECK(lookup_type_ == DESCRIPTOR_TYPE ||
208 lookup_type_ == TRANSITION_TYPE); 204 lookup_type_ == TRANSITION_TYPE);
209 DCHECK(number_ < map->NumberOfOwnDescriptors()); 205 DCHECK(number_ < map->NumberOfOwnDescriptors());
210 return map->instance_descriptors()->GetValue(number_); 206 return map->instance_descriptors()->GetValue(number_);
211 } 207 }
212 208
(...skipping 30 matching lines...)
243 Map* transition_; 239 Map* transition_;
244 int number_; 240 int number_;
245 PropertyDetails details_; 241 PropertyDetails details_;
246 }; 242 };
247 243
248 244
249 std::ostream& operator<<(std::ostream& os, const LookupResult& r); 245 std::ostream& operator<<(std::ostream& os, const LookupResult& r);
250 } } // namespace v8::internal 246 } } // namespace v8::internal
251 247
252 #endif // V8_PROPERTY_H_ 248 #endif // V8_PROPERTY_H_
OLDNEW
« src/mirror-debugger.js ('K') | « src/objects-printer.cc ('k') | src/property.cc » ('j') | no next file with comments »

Powered by Google App Engine