| 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 2130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2141 return heap->the_hole_value(); | 2141 return heap->the_hole_value(); |
| 2142 } | 2142 } |
| 2143 | 2143 |
| 2144 MaybeObject* JSObject::SetPropertyWithCallbackSetterInPrototypes( | 2144 MaybeObject* JSObject::SetPropertyWithCallbackSetterInPrototypes( |
| 2145 String* name, | 2145 String* name, |
| 2146 Object* value, | 2146 Object* value, |
| 2147 PropertyAttributes attributes, | 2147 PropertyAttributes attributes, |
| 2148 bool* found, | 2148 bool* found, |
| 2149 StrictModeFlag strict_mode) { | 2149 StrictModeFlag strict_mode) { |
| 2150 Heap* heap = GetHeap(); | 2150 Heap* heap = GetHeap(); |
| 2151 LookupResult result(heap->isolate()); | 2151 // We could not find a local property so let's check whether there is an |
| 2152 LookupCallbackSetterInPrototypes(name, &result); | 2152 // accessor that wants to handle the property. |
| 2153 if (result.IsFound()) { | 2153 LookupResult accessor_result(heap->isolate()); |
| 2154 LookupCallbackSetterInPrototypes(name, &accessor_result); |
| 2155 if (accessor_result.IsFound()) { |
| 2154 *found = true; | 2156 *found = true; |
| 2155 if (result.type() == CALLBACKS) { | 2157 if (accessor_result.type() == CALLBACKS) { |
| 2156 return SetPropertyWithCallback(result.GetCallbackObject(), | 2158 return SetPropertyWithCallback(accessor_result.GetCallbackObject(), |
| 2157 name, | 2159 name, |
| 2158 value, | 2160 value, |
| 2159 result.holder(), | 2161 accessor_result.holder(), |
| 2160 strict_mode); | 2162 strict_mode); |
| 2161 } else if (result.type() == HANDLER) { | 2163 } else if (accessor_result.type() == HANDLER) { |
| 2162 // We could not find a local property so let's check whether there is an | 2164 // There is a proxy in the prototype chain. Invoke its |
| 2163 // accessor that wants to handle the property. | 2165 // getPropertyDescriptor trap. |
| 2164 LookupResult accessor_result(heap->isolate()); | 2166 bool found = false; |
| 2165 LookupCallbackSetterInPrototypes(name, &accessor_result); | 2167 // SetPropertyWithHandlerIfDefiningSetter can cause GC, |
| 2166 if (accessor_result.IsFound()) { | 2168 // make sure to use the handlified references after calling |
| 2167 if (accessor_result.type() == CALLBACKS) { | 2169 // the function. |
| 2168 return SetPropertyWithCallback(accessor_result.GetCallbackObject(), | 2170 Handle<JSObject> self(this); |
| 2169 name, | 2171 Handle<String> hname(name); |
| 2170 value, | 2172 Handle<Object> hvalue(value); |
| 2171 accessor_result.holder(), | 2173 MaybeObject* result = |
| 2172 strict_mode); | 2174 accessor_result.proxy()->SetPropertyWithHandlerIfDefiningSetter( |
| 2173 } else if (accessor_result.type() == HANDLER) { | 2175 name, value, attributes, strict_mode, &found); |
| 2174 // There is a proxy in the prototype chain. Invoke its | 2176 if (found) return result; |
| 2175 // getPropertyDescriptor trap. | 2177 // The proxy does not define the property as an accessor. |
| 2176 bool found = false; | 2178 // Consequently, it has no effect on setting the receiver. |
| 2177 // SetPropertyWithHandlerIfDefiningSetter can cause GC, | 2179 return self->AddProperty(*hname, *hvalue, attributes, strict_mode); |
| 2178 // make sure to use the handlified references after calling | |
| 2179 // the function. | |
| 2180 Handle<JSObject> self(this); | |
| 2181 Handle<String> hname(name); | |
| 2182 Handle<Object> hvalue(value); | |
| 2183 MaybeObject* result = | |
| 2184 accessor_result.proxy()->SetPropertyWithHandlerIfDefiningSetter( | |
| 2185 name, value, attributes, strict_mode, &found); | |
| 2186 if (found) return result; | |
| 2187 // The proxy does not define the property as an accessor. | |
| 2188 // Consequently, it has no effect on setting the receiver. | |
| 2189 return self->AddProperty(*hname, *hvalue, attributes, strict_mode); | |
| 2190 } | |
| 2191 } | |
| 2192 } | 2180 } |
| 2193 } | 2181 } |
| 2194 *found = false; | 2182 *found = false; |
| 2195 return heap->the_hole_value(); | 2183 return heap->the_hole_value(); |
| 2196 } | 2184 } |
| 2197 | 2185 |
| 2198 | 2186 |
| 2199 void JSObject::LookupInDescriptor(String* name, LookupResult* result) { | 2187 void JSObject::LookupInDescriptor(String* name, LookupResult* result) { |
| 2200 DescriptorArray* descriptors = map()->instance_descriptors(); | 2188 DescriptorArray* descriptors = map()->instance_descriptors(); |
| 2201 int number = descriptors->SearchWithCache(name); | 2189 int number = descriptors->SearchWithCache(name); |
| (...skipping 10550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12752 if (break_point_objects()->IsUndefined()) return 0; | 12740 if (break_point_objects()->IsUndefined()) return 0; |
| 12753 // Single break point. | 12741 // Single break point. |
| 12754 if (!break_point_objects()->IsFixedArray()) return 1; | 12742 if (!break_point_objects()->IsFixedArray()) return 1; |
| 12755 // Multiple break points. | 12743 // Multiple break points. |
| 12756 return FixedArray::cast(break_point_objects())->length(); | 12744 return FixedArray::cast(break_point_objects())->length(); |
| 12757 } | 12745 } |
| 12758 #endif // ENABLE_DEBUGGER_SUPPORT | 12746 #endif // ENABLE_DEBUGGER_SUPPORT |
| 12759 | 12747 |
| 12760 | 12748 |
| 12761 } } // namespace v8::internal | 12749 } } // namespace v8::internal |
| OLD | NEW |