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

Side by Side Diff: src/objects.cc

Issue 455020: Remove some of the cache validity checks for for-in enumeration. We... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years 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/handles.cc ('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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 2615 matching lines...) Expand 10 before | Expand all | Expand 10 after
2626 return context->extension()->ReferencesObject(obj); 2626 return context->extension()->ReferencesObject(obj);
2627 } 2627 }
2628 } 2628 }
2629 2629
2630 // No references to object. 2630 // No references to object.
2631 return false; 2631 return false;
2632 } 2632 }
2633 2633
2634 2634
2635 // Tests for the fast common case for property enumeration: 2635 // Tests for the fast common case for property enumeration:
2636 // - this object has an enum cache 2636 // - This object and all prototypes has an enum cache (which means that it has
2637 // - this object has no elements 2637 // no interceptors and needs no access checks).
2638 // - no prototype has enumerable properties/elements 2638 // - This object has no elements.
2639 // - neither this object nor any prototype has interceptors 2639 // - No prototype has enumerable properties/elements.
2640 bool JSObject::IsSimpleEnum() { 2640 bool JSObject::IsSimpleEnum() {
2641 JSObject* arguments_boilerplate =
2642 Top::context()->global_context()->arguments_boilerplate();
2643 JSFunction* arguments_function =
2644 JSFunction::cast(arguments_boilerplate->map()->constructor());
2645 if (IsAccessCheckNeeded()) return false;
2646 if (map()->constructor() == arguments_function) return false;
2647
2648 for (Object* o = this; 2641 for (Object* o = this;
2649 o != Heap::null_value(); 2642 o != Heap::null_value();
2650 o = JSObject::cast(o)->GetPrototype()) { 2643 o = JSObject::cast(o)->GetPrototype()) {
2651 JSObject* curr = JSObject::cast(o); 2644 JSObject* curr = JSObject::cast(o);
2652 if (!curr->HasFastProperties()) return false;
2653 if (!curr->map()->instance_descriptors()->HasEnumCache()) return false; 2645 if (!curr->map()->instance_descriptors()->HasEnumCache()) return false;
2646 ASSERT(!curr->HasNamedInterceptor());
2647 ASSERT(!curr->HasIndexedInterceptor());
2648 ASSERT(!curr->IsAccessCheckNeeded());
2654 if (curr->NumberOfEnumElements() > 0) return false; 2649 if (curr->NumberOfEnumElements() > 0) return false;
Erik Corry 2009/12/01 10:21:08 Seems like it would be better to check this when c
2655 if (curr->HasNamedInterceptor()) return false;
2656 if (curr->HasIndexedInterceptor()) return false;
2657 if (curr != this) { 2650 if (curr != this) {
2658 FixedArray* curr_fixed_array = 2651 FixedArray* curr_fixed_array =
2659 FixedArray::cast(curr->map()->instance_descriptors()->GetEnumCache()); 2652 FixedArray::cast(curr->map()->instance_descriptors()->GetEnumCache());
2660 if (curr_fixed_array->length() > 0) { 2653 if (curr_fixed_array->length() > 0) return false;
2661 return false;
2662 }
2663 } 2654 }
2664 } 2655 }
2665 return true; 2656 return true;
2666 } 2657 }
2667 2658
2668 2659
2669 int Map::NumberOfDescribedProperties() { 2660 int Map::NumberOfDescribedProperties() {
2670 int result = 0; 2661 int result = 0;
2671 DescriptorArray* descs = instance_descriptors(); 2662 DescriptorArray* descs = instance_descriptors();
2672 for (int i = 0; i < descs->number_of_descriptors(); i++) { 2663 for (int i = 0; i < descs->number_of_descriptors(); i++) {
(...skipping 3798 matching lines...) Expand 10 before | Expand all | Expand 10 after
6471 } 6462 }
6472 } 6463 }
6473 6464
6474 6465
6475 int JSObject::NumberOfLocalElements(PropertyAttributes filter) { 6466 int JSObject::NumberOfLocalElements(PropertyAttributes filter) {
6476 return GetLocalElementKeys(NULL, filter); 6467 return GetLocalElementKeys(NULL, filter);
6477 } 6468 }
6478 6469
6479 6470
6480 int JSObject::NumberOfEnumElements() { 6471 int JSObject::NumberOfEnumElements() {
6472 // Fast case for objects with no elements.
6473 if (!IsJSValue() && HasFastElements()) {
6474 uint32_t length = IsJSArray() ?
6475 static_cast<uint32_t>(
6476 Smi::cast(JSArray::cast(this)->length())->value()) :
6477 static_cast<uint32_t>(FixedArray::cast(elements())->length());
6478 if (length == 0) return 0;
6479 }
6480 // Compute the number of enumerable elements.
6481 return NumberOfLocalElements(static_cast<PropertyAttributes>(DONT_ENUM)); 6481 return NumberOfLocalElements(static_cast<PropertyAttributes>(DONT_ENUM));
6482 } 6482 }
6483 6483
6484 6484
6485 int JSObject::GetLocalElementKeys(FixedArray* storage, 6485 int JSObject::GetLocalElementKeys(FixedArray* storage,
6486 PropertyAttributes filter) { 6486 PropertyAttributes filter) {
6487 int counter = 0; 6487 int counter = 0;
6488 switch (GetElementsKind()) { 6488 switch (GetElementsKind()) {
6489 case FAST_ELEMENTS: { 6489 case FAST_ELEMENTS: {
6490 int length = IsJSArray() ? 6490 int length = IsJSArray() ?
(...skipping 1797 matching lines...) Expand 10 before | Expand all | Expand 10 after
8288 if (break_point_objects()->IsUndefined()) return 0; 8288 if (break_point_objects()->IsUndefined()) return 0;
8289 // Single beak point. 8289 // Single beak point.
8290 if (!break_point_objects()->IsFixedArray()) return 1; 8290 if (!break_point_objects()->IsFixedArray()) return 1;
8291 // Multiple break points. 8291 // Multiple break points.
8292 return FixedArray::cast(break_point_objects())->length(); 8292 return FixedArray::cast(break_point_objects())->length();
8293 } 8293 }
8294 #endif 8294 #endif
8295 8295
8296 8296
8297 } } // namespace v8::internal 8297 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/handles.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698