OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1657 PropertyAttributes attributes, | 1657 PropertyAttributes attributes, |
1658 StrictModeFlag strict_mode) { | 1658 StrictModeFlag strict_mode) { |
1659 // Check local property, ignore interceptor. | 1659 // Check local property, ignore interceptor. |
1660 LookupResult result; | 1660 LookupResult result; |
1661 LocalLookupRealNamedProperty(name, &result); | 1661 LocalLookupRealNamedProperty(name, &result); |
1662 if (result.IsFound()) { | 1662 if (result.IsFound()) { |
1663 // An existing property, a map transition or a null descriptor was | 1663 // An existing property, a map transition or a null descriptor was |
1664 // found. Use set property to handle all these cases. | 1664 // found. Use set property to handle all these cases. |
1665 return SetProperty(&result, name, value, attributes, strict_mode); | 1665 return SetProperty(&result, name, value, attributes, strict_mode); |
1666 } | 1666 } |
| 1667 bool found = false; |
| 1668 MaybeObject* result_object; |
| 1669 result_object = SetPropertyWithCallbackSetterInPrototypes(name, |
| 1670 value, |
| 1671 attributes, |
| 1672 &found, |
| 1673 strict_mode); |
| 1674 if (found) return result_object; |
1667 // Add a new real property. | 1675 // Add a new real property. |
1668 return AddProperty(name, value, attributes, strict_mode); | 1676 return AddProperty(name, value, attributes, strict_mode); |
1669 } | 1677 } |
1670 | 1678 |
1671 | 1679 |
1672 MaybeObject* JSObject::ReplaceSlowProperty(String* name, | 1680 MaybeObject* JSObject::ReplaceSlowProperty(String* name, |
1673 Object* value, | 1681 Object* value, |
1674 PropertyAttributes attributes) { | 1682 PropertyAttributes attributes) { |
1675 StringDictionary* dictionary = property_dictionary(); | 1683 StringDictionary* dictionary = property_dictionary(); |
1676 int old_index = dictionary->FindEntry(name); | 1684 int old_index = dictionary->FindEntry(name); |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1984 value, | 1992 value, |
1985 JSObject::cast(pt), | 1993 JSObject::cast(pt), |
1986 strict_mode); | 1994 strict_mode); |
1987 } | 1995 } |
1988 } | 1996 } |
1989 } | 1997 } |
1990 *found = false; | 1998 *found = false; |
1991 return heap->the_hole_value(); | 1999 return heap->the_hole_value(); |
1992 } | 2000 } |
1993 | 2001 |
| 2002 MaybeObject* JSObject::SetPropertyWithCallbackSetterInPrototypes( |
| 2003 String* name, |
| 2004 Object* value, |
| 2005 PropertyAttributes attributes, |
| 2006 bool* found, |
| 2007 StrictModeFlag strict_mode) { |
| 2008 LookupResult result; |
| 2009 LookupCallbackSetterInPrototypes(name, &result); |
| 2010 Heap* heap = GetHeap(); |
| 2011 if (result.IsFound()) { |
| 2012 *found = true; |
| 2013 if (result.type() == CALLBACKS) { |
| 2014 return SetPropertyWithCallback(result.GetCallbackObject(), |
| 2015 name, |
| 2016 value, |
| 2017 result.holder(), |
| 2018 strict_mode); |
| 2019 } else if (result.type() == HANDLER) { |
| 2020 // We could not find a local property so let's check whether there is an |
| 2021 // accessor that wants to handle the property. |
| 2022 LookupResult accessor_result; |
| 2023 LookupCallbackSetterInPrototypes(name, &accessor_result); |
| 2024 if (accessor_result.IsFound()) { |
| 2025 if (accessor_result.type() == CALLBACKS) { |
| 2026 return SetPropertyWithCallback(accessor_result.GetCallbackObject(), |
| 2027 name, |
| 2028 value, |
| 2029 accessor_result.holder(), |
| 2030 strict_mode); |
| 2031 } else if (accessor_result.type() == HANDLER) { |
| 2032 // There is a proxy in the prototype chain. Invoke its |
| 2033 // getOwnPropertyDescriptor trap. |
| 2034 bool found = false; |
| 2035 // SetPropertyWithHandlerIfDefiningSetter can cause GC, |
| 2036 // make sure to use the handlified references after calling |
| 2037 // the function. |
| 2038 Handle<JSObject> self(this); |
| 2039 Handle<String> hname(name); |
| 2040 Handle<Object> hvalue(value); |
| 2041 MaybeObject* result = |
| 2042 accessor_result.proxy()->SetPropertyWithHandlerIfDefiningSetter( |
| 2043 name, value, attributes, strict_mode, &found); |
| 2044 if (found) return result; |
| 2045 // The proxy does not define the property as an accessor. |
| 2046 // Consequently, it has no effect on setting the receiver. |
| 2047 return self->AddProperty(*hname, *hvalue, attributes, strict_mode); |
| 2048 } |
| 2049 } |
| 2050 } |
| 2051 } |
| 2052 *found = false; |
| 2053 return heap->the_hole_value(); |
| 2054 } |
| 2055 |
1994 | 2056 |
1995 void JSObject::LookupInDescriptor(String* name, LookupResult* result) { | 2057 void JSObject::LookupInDescriptor(String* name, LookupResult* result) { |
1996 DescriptorArray* descriptors = map()->instance_descriptors(); | 2058 DescriptorArray* descriptors = map()->instance_descriptors(); |
1997 int number = descriptors->SearchWithCache(name); | 2059 int number = descriptors->SearchWithCache(name); |
1998 if (number != DescriptorArray::kNotFound) { | 2060 if (number != DescriptorArray::kNotFound) { |
1999 result->DescriptorResult(this, descriptors->GetDetails(number), number); | 2061 result->DescriptorResult(this, descriptors->GetDetails(number), number); |
2000 } else { | 2062 } else { |
2001 result->NotFound(); | 2063 result->NotFound(); |
2002 } | 2064 } |
2003 } | 2065 } |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2616 | 2678 |
2617 if (IsJSGlobalProxy()) { | 2679 if (IsJSGlobalProxy()) { |
2618 Object* proto = GetPrototype(); | 2680 Object* proto = GetPrototype(); |
2619 if (proto->IsNull()) return value; | 2681 if (proto->IsNull()) return value; |
2620 ASSERT(proto->IsJSGlobalObject()); | 2682 ASSERT(proto->IsJSGlobalObject()); |
2621 return JSObject::cast(proto)->SetPropertyForResult( | 2683 return JSObject::cast(proto)->SetPropertyForResult( |
2622 result, name, value, attributes, strict_mode); | 2684 result, name, value, attributes, strict_mode); |
2623 } | 2685 } |
2624 | 2686 |
2625 if (!result->IsProperty() && !IsJSContextExtensionObject()) { | 2687 if (!result->IsProperty() && !IsJSContextExtensionObject()) { |
2626 // We could not find a local property so let's check whether there is an | 2688 bool found = false; |
2627 // accessor that wants to handle the property. | 2689 MaybeObject* result_object; |
2628 LookupResult accessor_result; | 2690 result_object = SetPropertyWithCallbackSetterInPrototypes(name, |
2629 LookupCallbackSetterInPrototypes(name, &accessor_result); | 2691 value, |
2630 if (accessor_result.IsFound()) { | 2692 attributes, |
2631 if (accessor_result.type() == CALLBACKS) { | 2693 &found, |
2632 return SetPropertyWithCallback(accessor_result.GetCallbackObject(), | 2694 strict_mode); |
2633 name, | 2695 if (found) return result_object; |
2634 value, | |
2635 accessor_result.holder(), | |
2636 strict_mode); | |
2637 } else if (accessor_result.type() == HANDLER) { | |
2638 // There is a proxy in the prototype chain. Invoke its | |
2639 // getOwnPropertyDescriptor trap. | |
2640 bool found = false; | |
2641 Handle<JSObject> self(this); | |
2642 Handle<String> hname(name); | |
2643 Handle<Object> hvalue(value); | |
2644 MaybeObject* result = | |
2645 accessor_result.proxy()->SetPropertyWithHandlerIfDefiningSetter( | |
2646 name, value, attributes, strict_mode, &found); | |
2647 if (found) return result; | |
2648 // The proxy does not define the property as an accessor. | |
2649 // Consequently, it has no effect on setting the receiver. | |
2650 // Make sure to use the handlified references at this point! | |
2651 return self->AddProperty(*hname, *hvalue, attributes, strict_mode); | |
2652 } | |
2653 } | |
2654 } | 2696 } |
2655 | 2697 |
2656 // At this point, no GC should have happened, as this would invalidate | 2698 // At this point, no GC should have happened, as this would invalidate |
2657 // 'result', which we cannot handlify! | 2699 // 'result', which we cannot handlify! |
2658 | 2700 |
2659 if (!result->IsFound()) { | 2701 if (!result->IsFound()) { |
2660 // Neither properties nor transitions found. | 2702 // Neither properties nor transitions found. |
2661 return AddProperty(name, value, attributes, strict_mode); | 2703 return AddProperty(name, value, attributes, strict_mode); |
2662 } | 2704 } |
2663 if (result->IsReadOnly() && result->IsProperty()) { | 2705 if (result->IsReadOnly() && result->IsProperty()) { |
(...skipping 9355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12019 if (break_point_objects()->IsUndefined()) return 0; | 12061 if (break_point_objects()->IsUndefined()) return 0; |
12020 // Single break point. | 12062 // Single break point. |
12021 if (!break_point_objects()->IsFixedArray()) return 1; | 12063 if (!break_point_objects()->IsFixedArray()) return 1; |
12022 // Multiple break points. | 12064 // Multiple break points. |
12023 return FixedArray::cast(break_point_objects())->length(); | 12065 return FixedArray::cast(break_point_objects())->length(); |
12024 } | 12066 } |
12025 #endif | 12067 #endif |
12026 | 12068 |
12027 | 12069 |
12028 } } // namespace v8::internal | 12070 } } // namespace v8::internal |
OLD | NEW |