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

Side by Side Diff: src/property.h

Issue 10626004: Cleaning up usage of lookup results. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 6 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/objects.cc ('k') | src/runtime.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 182
183 183
184 class LookupResult BASE_EMBEDDED { 184 class LookupResult BASE_EMBEDDED {
185 public: 185 public:
186 explicit LookupResult(Isolate* isolate) 186 explicit LookupResult(Isolate* isolate)
187 : isolate_(isolate), 187 : isolate_(isolate),
188 next_(isolate->top_lookup_result()), 188 next_(isolate->top_lookup_result()),
189 lookup_type_(NOT_FOUND), 189 lookup_type_(NOT_FOUND),
190 holder_(NULL), 190 holder_(NULL),
191 cacheable_(true), 191 cacheable_(true),
192 details_(NONE, NORMAL) { 192 details_(NONE, NONEXISTENT) {
193 isolate->SetTopLookupResult(this); 193 isolate->SetTopLookupResult(this);
194 } 194 }
195 195
196 ~LookupResult() { 196 ~LookupResult() {
197 ASSERT(isolate_->top_lookup_result() == this); 197 ASSERT(isolate_->top_lookup_result() == this);
198 isolate_->SetTopLookupResult(next_); 198 isolate_->SetTopLookupResult(next_);
199 } 199 }
200 200
201 void DescriptorResult(JSObject* holder, PropertyDetails details, int number) { 201 void DescriptorResult(JSObject* holder, PropertyDetails details, int number) {
202 lookup_type_ = DESCRIPTOR_TYPE; 202 lookup_type_ = DESCRIPTOR_TYPE;
(...skipping 27 matching lines...) Expand all
230 } 230 }
231 231
232 void InterceptorResult(JSObject* holder) { 232 void InterceptorResult(JSObject* holder) {
233 lookup_type_ = INTERCEPTOR_TYPE; 233 lookup_type_ = INTERCEPTOR_TYPE;
234 holder_ = holder; 234 holder_ = holder;
235 details_ = PropertyDetails(NONE, INTERCEPTOR); 235 details_ = PropertyDetails(NONE, INTERCEPTOR);
236 } 236 }
237 237
238 void NotFound() { 238 void NotFound() {
239 lookup_type_ = NOT_FOUND; 239 lookup_type_ = NOT_FOUND;
240 details_ = PropertyDetails(NONE, NONEXISTENT);
240 holder_ = NULL; 241 holder_ = NULL;
241 } 242 }
242 243
243 JSObject* holder() { 244 JSObject* holder() {
244 ASSERT(IsFound()); 245 ASSERT(IsFound());
245 return JSObject::cast(holder_); 246 return JSObject::cast(holder_);
246 } 247 }
247 248
248 JSProxy* proxy() { 249 JSProxy* proxy() {
249 ASSERT(IsFound()); 250 ASSERT(IsFound());
250 return JSProxy::cast(holder_); 251 return JSProxy::cast(holder_);
251 } 252 }
252 253
254
253 PropertyType type() { 255 PropertyType type() {
254 ASSERT(IsFound()); 256 ASSERT(IsFound());
255 return details_.type(); 257 return details_.type();
256 } 258 }
257 259
258 PropertyAttributes GetAttributes() { 260 PropertyAttributes GetAttributes() {
259 ASSERT(IsFound()); 261 ASSERT(IsFound());
260 return details_.attributes(); 262 return details_.attributes();
261 } 263 }
262 264
263 PropertyDetails GetPropertyDetails() { 265 PropertyDetails GetPropertyDetails() {
264 return details_; 266 return details_;
265 } 267 }
266 268
269 bool IsFastPropertyType() { return type() != NORMAL; }
danno 2012/06/21 14:34:30 Add asserts for (IsFound());
267 bool IsReadOnly() { return details_.IsReadOnly(); } 270 bool IsReadOnly() { return details_.IsReadOnly(); }
271 bool IsCallbacks() { return details_.type() == CALLBACKS; }
danno 2012/06/21 14:34:30 Add asserts for (IsFound());
268 bool IsDontDelete() { return details_.IsDontDelete(); } 272 bool IsDontDelete() { return details_.IsDontDelete(); }
269 bool IsDontEnum() { return details_.IsDontEnum(); } 273 bool IsDontEnum() { return details_.IsDontEnum(); }
270 bool IsDeleted() { return details_.IsDeleted(); } 274 bool IsDeleted() { return details_.IsDeleted(); }
271 bool IsFound() { return lookup_type_ != NOT_FOUND; } 275 bool IsFound() { return lookup_type_ != NOT_FOUND; }
272 bool IsHandler() { return lookup_type_ == HANDLER_TYPE; } 276 bool IsHandler() { return lookup_type_ == HANDLER_TYPE; }
277 bool IsInterceptor() { return lookup_type_ == INTERCEPTOR_TYPE; }
278 bool IsField() { return details_.type() == FIELD; }
danno 2012/06/21 14:34:30 Add asserts for (IsFound());
279 bool IsNormal() { return details_.type() == NORMAL; }
danno 2012/06/21 14:34:30 Add asserts for (IsFound());
280 bool IsConstantFunction() { return details_.type() == CONSTANT_FUNCTION; }
danno 2012/06/21 14:34:30 Add asserts for (IsFound());
273 281
274 // Is the result is a property excluding transitions and the null descriptor? 282 // Is the result is a property excluding transitions and the null descriptor?
275 bool IsProperty() { 283 bool IsProperty() {
276 return IsFound() && IsPropertyDescriptor(this); 284 return IsFound() && IsPropertyDescriptor(this);
277 } 285 }
278 286
279 bool IsCacheable() { return cacheable_; } 287 bool IsCacheable() { return cacheable_; }
280 void DisallowCaching() { cacheable_ = false; } 288 void DisallowCaching() { cacheable_ = false; }
281 289
282 Object* GetLazyValue() { 290 Object* GetLazyValue() {
283 switch (type()) { 291 switch (type()) {
284 case FIELD: 292 case FIELD:
285 return holder()->FastPropertyAt(GetFieldIndex()); 293 return holder()->FastPropertyAt(GetFieldIndex());
286 case NORMAL: { 294 case NORMAL: {
287 Object* value; 295 Object* value;
288 value = holder()->property_dictionary()->ValueAt(GetDictionaryEntry()); 296 value = holder()->property_dictionary()->ValueAt(GetDictionaryEntry());
289 if (holder()->IsGlobalObject()) { 297 if (holder()->IsGlobalObject()) {
290 value = JSGlobalPropertyCell::cast(value)->value(); 298 value = JSGlobalPropertyCell::cast(value)->value();
291 } 299 }
292 return value; 300 return value;
293 } 301 }
294 case CONSTANT_FUNCTION: 302 case CONSTANT_FUNCTION:
295 return GetConstantFunction(); 303 return GetConstantFunction();
296 default: 304 default:
297 return Smi::FromInt(0); 305 return Smi::FromInt(0);
298 } 306 }
299 } 307 }
300 308
301
302 Map* GetTransitionMap() { 309 Map* GetTransitionMap() {
303 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); 310 ASSERT(lookup_type_ == DESCRIPTOR_TYPE);
304 ASSERT(type() == MAP_TRANSITION || 311 ASSERT(type() == MAP_TRANSITION ||
305 type() == CONSTANT_TRANSITION); 312 type() == CONSTANT_TRANSITION);
306 return Map::cast(GetValue()); 313 return Map::cast(GetValue());
307 } 314 }
308 315
309 Map* GetTransitionMapFromMap(Map* map) { 316 Map* GetTransitionMapFromMap(Map* map) {
310 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); 317 ASSERT(lookup_type_ == DESCRIPTOR_TYPE);
311 ASSERT(type() == MAP_TRANSITION); 318 ASSERT(type() == MAP_TRANSITION);
312 return Map::cast(map->instance_descriptors()->GetValue(number_)); 319 return Map::cast(map->instance_descriptors()->GetValue(number_));
313 } 320 }
314 321
315 int GetFieldIndex() { 322 int GetFieldIndex() {
316 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); 323 ASSERT(lookup_type_ == DESCRIPTOR_TYPE);
317 ASSERT(type() == FIELD); 324 ASSERT(IsField());
318 return Descriptor::IndexFromValue(GetValue()); 325 return Descriptor::IndexFromValue(GetValue());
319 } 326 }
320 327
321 int GetLocalFieldIndexFromMap(Map* map) { 328 int GetLocalFieldIndexFromMap(Map* map) {
322 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); 329 ASSERT(lookup_type_ == DESCRIPTOR_TYPE);
323 ASSERT(type() == FIELD); 330 ASSERT(IsField());
324 return Descriptor::IndexFromValue( 331 return Descriptor::IndexFromValue(
325 map->instance_descriptors()->GetValue(number_)) - 332 map->instance_descriptors()->GetValue(number_)) -
326 map->inobject_properties(); 333 map->inobject_properties();
327 } 334 }
328 335
329 int GetDictionaryEntry() { 336 int GetDictionaryEntry() {
330 ASSERT(lookup_type_ == DICTIONARY_TYPE); 337 ASSERT(lookup_type_ == DICTIONARY_TYPE);
331 return number_; 338 return number_;
332 } 339 }
333 340
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 JSReceiver* holder_; 390 JSReceiver* holder_;
384 int number_; 391 int number_;
385 bool cacheable_; 392 bool cacheable_;
386 PropertyDetails details_; 393 PropertyDetails details_;
387 }; 394 };
388 395
389 396
390 } } // namespace v8::internal 397 } } // namespace v8::internal
391 398
392 #endif // V8_PROPERTY_H_ 399 #endif // V8_PROPERTY_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698