| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 2465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2476 // Check for lookup interceptor except when bootstrapping. | 2476 // Check for lookup interceptor except when bootstrapping. |
| 2477 if (HasNamedInterceptor() && !Bootstrapper::IsActive()) { | 2477 if (HasNamedInterceptor() && !Bootstrapper::IsActive()) { |
| 2478 result->InterceptorResult(this); | 2478 result->InterceptorResult(this); |
| 2479 return; | 2479 return; |
| 2480 } | 2480 } |
| 2481 | 2481 |
| 2482 LocalLookupRealNamedProperty(name, result); | 2482 LocalLookupRealNamedProperty(name, result); |
| 2483 } | 2483 } |
| 2484 | 2484 |
| 2485 | 2485 |
| 2486 bool JSObject::HasLocalPropertyWithType(PropertyType type) { | |
| 2487 if (IsJSGlobalProxy()) { | |
| 2488 Object* proto = GetPrototype(); | |
| 2489 if (proto->IsNull()) return false; | |
| 2490 ASSERT(proto->IsJSGlobalObject()); | |
| 2491 return JSObject::cast(proto)->HasLocalPropertyWithType(type); | |
| 2492 } | |
| 2493 | |
| 2494 if (HasFastProperties()) { | |
| 2495 DescriptorArray* descriptors = map()->instance_descriptors(); | |
| 2496 int length = descriptors->number_of_descriptors(); | |
| 2497 for (int i = 0; i < length; i++) { | |
| 2498 PropertyDetails details(descriptors->GetDetails(i)); | |
| 2499 if (details.type() == type) | |
| 2500 return true; | |
| 2501 } | |
| 2502 } else { | |
| 2503 Handle<Dictionary> properties = Handle<Dictionary>(property_dictionary()); | |
| 2504 int capacity = properties->Capacity(); | |
| 2505 for (int i = 0; i < capacity; i++) { | |
| 2506 if (properties->IsKey(properties->KeyAt(i))) { | |
| 2507 PropertyDetails details = properties->DetailsAt(i); | |
| 2508 if (details.type() == type) | |
| 2509 return true; | |
| 2510 } | |
| 2511 } | |
| 2512 } | |
| 2513 | |
| 2514 return false; | |
| 2515 } | |
| 2516 | |
| 2517 | |
| 2518 void JSObject::Lookup(String* name, LookupResult* result) { | 2486 void JSObject::Lookup(String* name, LookupResult* result) { |
| 2519 // Ecma-262 3rd 8.6.2.4 | 2487 // Ecma-262 3rd 8.6.2.4 |
| 2520 for (Object* current = this; | 2488 for (Object* current = this; |
| 2521 current != Heap::null_value(); | 2489 current != Heap::null_value(); |
| 2522 current = JSObject::cast(current)->GetPrototype()) { | 2490 current = JSObject::cast(current)->GetPrototype()) { |
| 2523 JSObject::cast(current)->LocalLookup(name, result); | 2491 JSObject::cast(current)->LocalLookup(name, result); |
| 2524 if (result->IsValid() && !result->IsTransitionType()) return; | 2492 if (result->IsValid() && !result->IsTransitionType()) return; |
| 2525 } | 2493 } |
| 2526 result->NotFound(); | 2494 result->NotFound(); |
| 2527 } | 2495 } |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2635 if (dict->IsFailure()) return dict; | 2603 if (dict->IsFailure()) return dict; |
| 2636 | 2604 |
| 2637 // Set the potential new dictionary on the object. | 2605 // Set the potential new dictionary on the object. |
| 2638 set_properties(Dictionary::cast(dict)); | 2606 set_properties(Dictionary::cast(dict)); |
| 2639 } | 2607 } |
| 2640 | 2608 |
| 2641 return structure; | 2609 return structure; |
| 2642 } | 2610 } |
| 2643 | 2611 |
| 2644 | 2612 |
| 2645 Object* JSObject::DefineAccessor(String* name, | 2613 Object* JSObject::DefineAccessor(String* name, bool is_getter, JSFunction* fun, |
| 2646 bool is_getter, | 2614 PropertyAttributes attributes) { |
| 2647 JSFunction* fun, | |
| 2648 PropertyAttributes attributes, | |
| 2649 bool never_used) { | |
| 2650 // Check access rights if needed. | 2615 // Check access rights if needed. |
| 2651 if (IsAccessCheckNeeded() && | 2616 if (IsAccessCheckNeeded() && |
| 2652 !Top::MayNamedAccess(this, name, v8::ACCESS_HAS)) { | 2617 !Top::MayNamedAccess(this, name, v8::ACCESS_HAS)) { |
| 2653 Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS); | 2618 Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS); |
| 2654 return Heap::undefined_value(); | 2619 return Heap::undefined_value(); |
| 2655 } | 2620 } |
| 2656 | 2621 |
| 2657 if (IsJSGlobalProxy()) { | 2622 if (IsJSGlobalProxy()) { |
| 2658 Object* proto = GetPrototype(); | 2623 Object* proto = GetPrototype(); |
| 2659 if (proto->IsNull()) return this; | 2624 if (proto->IsNull()) return this; |
| 2660 ASSERT(proto->IsJSGlobalObject()); | 2625 ASSERT(proto->IsJSGlobalObject()); |
| 2661 return JSObject::cast(proto)->DefineAccessor(name, | 2626 return JSObject::cast(proto)->DefineAccessor(name, is_getter, |
| 2662 is_getter, | 2627 fun, attributes); |
| 2663 fun, | |
| 2664 attributes, | |
| 2665 never_used); | |
| 2666 } | 2628 } |
| 2667 | 2629 |
| 2668 Object* array = DefineGetterSetter(name, attributes); | 2630 Object* array = DefineGetterSetter(name, attributes); |
| 2669 if (array->IsFailure() || array->IsUndefined()) return array; | 2631 if (array->IsFailure() || array->IsUndefined()) return array; |
| 2670 FixedArray::cast(array)->set(is_getter ? 0 : 1, fun); | 2632 FixedArray::cast(array)->set(is_getter ? 0 : 1, fun); |
| 2671 | |
| 2672 // Because setters are nonlocal (they're accessible through the | |
| 2673 // prototype chain) but our inline caches are local we clear them | |
| 2674 // when a new setter is introduced. | |
| 2675 if (!(is_getter || never_used)) Heap::ClearStoreICs(); | |
| 2676 | |
| 2677 return this; | 2633 return this; |
| 2678 } | 2634 } |
| 2679 | 2635 |
| 2680 | 2636 |
| 2681 Object* JSObject::LookupAccessor(String* name, bool is_getter) { | 2637 Object* JSObject::LookupAccessor(String* name, bool is_getter) { |
| 2682 // Make sure that the top context does not change when doing callbacks or | 2638 // Make sure that the top context does not change when doing callbacks or |
| 2683 // interceptor calls. | 2639 // interceptor calls. |
| 2684 AssertNoContextChange ncc; | 2640 AssertNoContextChange ncc; |
| 2685 | 2641 |
| 2686 // Check access rights if needed. | 2642 // Check access rights if needed. |
| (...skipping 4677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7364 // No break point. | 7320 // No break point. |
| 7365 if (break_point_objects()->IsUndefined()) return 0; | 7321 if (break_point_objects()->IsUndefined()) return 0; |
| 7366 // Single beak point. | 7322 // Single beak point. |
| 7367 if (!break_point_objects()->IsFixedArray()) return 1; | 7323 if (!break_point_objects()->IsFixedArray()) return 1; |
| 7368 // Multiple break points. | 7324 // Multiple break points. |
| 7369 return FixedArray::cast(break_point_objects())->length(); | 7325 return FixedArray::cast(break_point_objects())->length(); |
| 7370 } | 7326 } |
| 7371 | 7327 |
| 7372 | 7328 |
| 7373 } } // namespace v8::internal | 7329 } } // namespace v8::internal |
| OLD | NEW |