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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 } | 147 } |
148 } | 148 } |
149 ASSERT(holder != NULL); // Cannot handle null or undefined. | 149 ASSERT(holder != NULL); // Cannot handle null or undefined. |
150 JSReceiver::cast(holder)->Lookup(name, result); | 150 JSReceiver::cast(holder)->Lookup(name, result); |
151 } | 151 } |
152 | 152 |
153 | 153 |
154 MaybeObject* Object::GetPropertyWithReceiver(Object* receiver, | 154 MaybeObject* Object::GetPropertyWithReceiver(Object* receiver, |
155 String* name, | 155 String* name, |
156 PropertyAttributes* attributes) { | 156 PropertyAttributes* attributes) { |
157 LookupResult result; | 157 LookupResult result(name->GetIsolate()); |
158 Lookup(name, &result); | 158 Lookup(name, &result); |
159 MaybeObject* value = GetProperty(receiver, &result, name, attributes); | 159 MaybeObject* value = GetProperty(receiver, &result, name, attributes); |
160 ASSERT(*attributes <= ABSENT); | 160 ASSERT(*attributes <= ABSENT); |
161 return value; | 161 return value; |
162 } | 162 } |
163 | 163 |
164 | 164 |
165 MaybeObject* JSObject::GetPropertyWithCallback(Object* receiver, | 165 MaybeObject* JSObject::GetPropertyWithCallback(Object* receiver, |
166 Object* structure, | 166 Object* structure, |
167 String* name) { | 167 String* name) { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 return result->holder()->GetPropertyWithCallback( | 303 return result->holder()->GetPropertyWithCallback( |
304 receiver, result->GetCallbackObject(), name); | 304 receiver, result->GetCallbackObject(), name); |
305 } | 305 } |
306 } | 306 } |
307 break; | 307 break; |
308 } | 308 } |
309 case NORMAL: | 309 case NORMAL: |
310 case FIELD: | 310 case FIELD: |
311 case CONSTANT_FUNCTION: { | 311 case CONSTANT_FUNCTION: { |
312 // Search ALL_CAN_READ accessors in prototype chain. | 312 // Search ALL_CAN_READ accessors in prototype chain. |
313 LookupResult r; | 313 LookupResult r(GetIsolate()); |
314 result->holder()->LookupRealNamedPropertyInPrototypes(name, &r); | 314 result->holder()->LookupRealNamedPropertyInPrototypes(name, &r); |
315 if (r.IsProperty()) { | 315 if (r.IsProperty()) { |
316 return GetPropertyWithFailedAccessCheck(receiver, | 316 return GetPropertyWithFailedAccessCheck(receiver, |
317 &r, | 317 &r, |
318 name, | 318 name, |
319 attributes); | 319 attributes); |
320 } | 320 } |
321 break; | 321 break; |
322 } | 322 } |
323 case INTERCEPTOR: { | 323 case INTERCEPTOR: { |
324 // If the object has an interceptor, try real named properties. | 324 // If the object has an interceptor, try real named properties. |
325 // No access check in GetPropertyAttributeWithInterceptor. | 325 // No access check in GetPropertyAttributeWithInterceptor. |
326 LookupResult r; | 326 LookupResult r(GetIsolate()); |
327 result->holder()->LookupRealNamedProperty(name, &r); | 327 result->holder()->LookupRealNamedProperty(name, &r); |
328 if (r.IsProperty()) { | 328 if (r.IsProperty()) { |
329 return GetPropertyWithFailedAccessCheck(receiver, | 329 return GetPropertyWithFailedAccessCheck(receiver, |
330 &r, | 330 &r, |
331 name, | 331 name, |
332 attributes); | 332 attributes); |
333 } | 333 } |
334 break; | 334 break; |
335 } | 335 } |
336 default: | 336 default: |
(...skipping 26 matching lines...) Expand all Loading... |
363 } | 363 } |
364 } | 364 } |
365 break; | 365 break; |
366 } | 366 } |
367 | 367 |
368 case NORMAL: | 368 case NORMAL: |
369 case FIELD: | 369 case FIELD: |
370 case CONSTANT_FUNCTION: { | 370 case CONSTANT_FUNCTION: { |
371 if (!continue_search) break; | 371 if (!continue_search) break; |
372 // Search ALL_CAN_READ accessors in prototype chain. | 372 // Search ALL_CAN_READ accessors in prototype chain. |
373 LookupResult r; | 373 LookupResult r(GetIsolate()); |
374 result->holder()->LookupRealNamedPropertyInPrototypes(name, &r); | 374 result->holder()->LookupRealNamedPropertyInPrototypes(name, &r); |
375 if (r.IsProperty()) { | 375 if (r.IsProperty()) { |
376 return GetPropertyAttributeWithFailedAccessCheck(receiver, | 376 return GetPropertyAttributeWithFailedAccessCheck(receiver, |
377 &r, | 377 &r, |
378 name, | 378 name, |
379 continue_search); | 379 continue_search); |
380 } | 380 } |
381 break; | 381 break; |
382 } | 382 } |
383 | 383 |
384 case INTERCEPTOR: { | 384 case INTERCEPTOR: { |
385 // If the object has an interceptor, try real named properties. | 385 // If the object has an interceptor, try real named properties. |
386 // No access check in GetPropertyAttributeWithInterceptor. | 386 // No access check in GetPropertyAttributeWithInterceptor. |
387 LookupResult r; | 387 LookupResult r(GetIsolate()); |
388 if (continue_search) { | 388 if (continue_search) { |
389 result->holder()->LookupRealNamedProperty(name, &r); | 389 result->holder()->LookupRealNamedProperty(name, &r); |
390 } else { | 390 } else { |
391 result->holder()->LocalLookupRealNamedProperty(name, &r); | 391 result->holder()->LocalLookupRealNamedProperty(name, &r); |
392 } | 392 } |
393 if (r.IsProperty()) { | 393 if (r.IsProperty()) { |
394 return GetPropertyAttributeWithFailedAccessCheck(receiver, | 394 return GetPropertyAttributeWithFailedAccessCheck(receiver, |
395 &r, | 395 &r, |
396 name, | 396 name, |
397 continue_search); | 397 continue_search); |
398 } | 398 } |
399 break; | 399 break; |
400 } | 400 } |
401 | 401 |
402 default: | 402 default: |
403 UNREACHABLE(); | 403 UNREACHABLE(); |
404 } | 404 } |
405 } | 405 } |
406 | 406 |
407 GetHeap()->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); | 407 GetIsolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); |
408 return ABSENT; | 408 return ABSENT; |
409 } | 409 } |
410 | 410 |
411 | 411 |
412 Object* JSObject::GetNormalizedProperty(LookupResult* result) { | 412 Object* JSObject::GetNormalizedProperty(LookupResult* result) { |
413 ASSERT(!HasFastProperties()); | 413 ASSERT(!HasFastProperties()); |
414 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry()); | 414 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry()); |
415 if (IsGlobalObject()) { | 415 if (IsGlobalObject()) { |
416 value = JSGlobalPropertyCell::cast(value)->value(); | 416 value = JSGlobalPropertyCell::cast(value)->value(); |
417 } | 417 } |
(...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1651 return AddSlowProperty(name, value, attributes); | 1651 return AddSlowProperty(name, value, attributes); |
1652 } | 1652 } |
1653 | 1653 |
1654 | 1654 |
1655 MaybeObject* JSObject::SetPropertyPostInterceptor( | 1655 MaybeObject* JSObject::SetPropertyPostInterceptor( |
1656 String* name, | 1656 String* name, |
1657 Object* value, | 1657 Object* value, |
1658 PropertyAttributes attributes, | 1658 PropertyAttributes attributes, |
1659 StrictModeFlag strict_mode) { | 1659 StrictModeFlag strict_mode) { |
1660 // Check local property, ignore interceptor. | 1660 // Check local property, ignore interceptor. |
1661 LookupResult result; | 1661 LookupResult result(GetIsolate()); |
1662 LocalLookupRealNamedProperty(name, &result); | 1662 LocalLookupRealNamedProperty(name, &result); |
1663 if (result.IsFound()) { | 1663 if (result.IsFound()) { |
1664 // An existing property, a map transition or a null descriptor was | 1664 // An existing property, a map transition or a null descriptor was |
1665 // found. Use set property to handle all these cases. | 1665 // found. Use set property to handle all these cases. |
1666 return SetProperty(&result, name, value, attributes, strict_mode); | 1666 return SetProperty(&result, name, value, attributes, strict_mode); |
1667 } | 1667 } |
1668 bool found = false; | 1668 bool found = false; |
1669 MaybeObject* result_object; | 1669 MaybeObject* result_object; |
1670 result_object = SetPropertyWithCallbackSetterInPrototypes(name, | 1670 result_object = SetPropertyWithCallbackSetterInPrototypes(name, |
1671 value, | 1671 value, |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1833 strict_mode); | 1833 strict_mode); |
1834 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 1834 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
1835 return raw_result; | 1835 return raw_result; |
1836 } | 1836 } |
1837 | 1837 |
1838 | 1838 |
1839 MaybeObject* JSReceiver::SetProperty(String* name, | 1839 MaybeObject* JSReceiver::SetProperty(String* name, |
1840 Object* value, | 1840 Object* value, |
1841 PropertyAttributes attributes, | 1841 PropertyAttributes attributes, |
1842 StrictModeFlag strict_mode) { | 1842 StrictModeFlag strict_mode) { |
1843 LookupResult result; | 1843 LookupResult result(GetIsolate()); |
1844 LocalLookup(name, &result); | 1844 LocalLookup(name, &result); |
1845 return SetProperty(&result, name, value, attributes, strict_mode); | 1845 return SetProperty(&result, name, value, attributes, strict_mode); |
1846 } | 1846 } |
1847 | 1847 |
1848 | 1848 |
1849 MaybeObject* JSObject::SetPropertyWithCallback(Object* structure, | 1849 MaybeObject* JSObject::SetPropertyWithCallback(Object* structure, |
1850 String* name, | 1850 String* name, |
1851 Object* value, | 1851 Object* value, |
1852 JSObject* holder, | 1852 JSObject* holder, |
1853 StrictModeFlag strict_mode) { | 1853 StrictModeFlag strict_mode) { |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1999 *found = false; | 1999 *found = false; |
2000 return heap->the_hole_value(); | 2000 return heap->the_hole_value(); |
2001 } | 2001 } |
2002 | 2002 |
2003 MaybeObject* JSObject::SetPropertyWithCallbackSetterInPrototypes( | 2003 MaybeObject* JSObject::SetPropertyWithCallbackSetterInPrototypes( |
2004 String* name, | 2004 String* name, |
2005 Object* value, | 2005 Object* value, |
2006 PropertyAttributes attributes, | 2006 PropertyAttributes attributes, |
2007 bool* found, | 2007 bool* found, |
2008 StrictModeFlag strict_mode) { | 2008 StrictModeFlag strict_mode) { |
2009 LookupResult result; | 2009 Heap* heap = GetHeap(); |
| 2010 LookupResult result(heap->isolate()); |
2010 LookupCallbackSetterInPrototypes(name, &result); | 2011 LookupCallbackSetterInPrototypes(name, &result); |
2011 Heap* heap = GetHeap(); | |
2012 if (result.IsFound()) { | 2012 if (result.IsFound()) { |
2013 *found = true; | 2013 *found = true; |
2014 if (result.type() == CALLBACKS) { | 2014 if (result.type() == CALLBACKS) { |
2015 return SetPropertyWithCallback(result.GetCallbackObject(), | 2015 return SetPropertyWithCallback(result.GetCallbackObject(), |
2016 name, | 2016 name, |
2017 value, | 2017 value, |
2018 result.holder(), | 2018 result.holder(), |
2019 strict_mode); | 2019 strict_mode); |
2020 } else if (result.type() == HANDLER) { | 2020 } else if (result.type() == HANDLER) { |
2021 // We could not find a local property so let's check whether there is an | 2021 // We could not find a local property so let's check whether there is an |
2022 // accessor that wants to handle the property. | 2022 // accessor that wants to handle the property. |
2023 LookupResult accessor_result; | 2023 LookupResult accessor_result(heap->isolate()); |
2024 LookupCallbackSetterInPrototypes(name, &accessor_result); | 2024 LookupCallbackSetterInPrototypes(name, &accessor_result); |
2025 if (accessor_result.IsFound()) { | 2025 if (accessor_result.IsFound()) { |
2026 if (accessor_result.type() == CALLBACKS) { | 2026 if (accessor_result.type() == CALLBACKS) { |
2027 return SetPropertyWithCallback(accessor_result.GetCallbackObject(), | 2027 return SetPropertyWithCallback(accessor_result.GetCallbackObject(), |
2028 name, | 2028 name, |
2029 value, | 2029 value, |
2030 accessor_result.holder(), | 2030 accessor_result.holder(), |
2031 strict_mode); | 2031 strict_mode); |
2032 } else if (accessor_result.type() == HANDLER) { | 2032 } else if (accessor_result.type() == HANDLER) { |
2033 // There is a proxy in the prototype chain. Invoke its | 2033 // There is a proxy in the prototype chain. Invoke its |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2416 value, | 2416 value, |
2417 result->holder(), | 2417 result->holder(), |
2418 strict_mode); | 2418 strict_mode); |
2419 } | 2419 } |
2420 } | 2420 } |
2421 break; | 2421 break; |
2422 } | 2422 } |
2423 case INTERCEPTOR: { | 2423 case INTERCEPTOR: { |
2424 // Try lookup real named properties. Note that only property can be | 2424 // Try lookup real named properties. Note that only property can be |
2425 // set is callbacks marked as ALL_CAN_WRITE on the prototype chain. | 2425 // set is callbacks marked as ALL_CAN_WRITE on the prototype chain. |
2426 LookupResult r; | 2426 LookupResult r(GetIsolate()); |
2427 LookupRealNamedProperty(name, &r); | 2427 LookupRealNamedProperty(name, &r); |
2428 if (r.IsProperty()) { | 2428 if (r.IsProperty()) { |
2429 return SetPropertyWithFailedAccessCheck(&r, | 2429 return SetPropertyWithFailedAccessCheck(&r, |
2430 name, | 2430 name, |
2431 value, | 2431 value, |
2432 check_prototype, | 2432 check_prototype, |
2433 strict_mode); | 2433 strict_mode); |
2434 } | 2434 } |
2435 break; | 2435 break; |
2436 } | 2436 } |
2437 default: { | 2437 default: { |
2438 break; | 2438 break; |
2439 } | 2439 } |
2440 } | 2440 } |
2441 } | 2441 } |
2442 } | 2442 } |
2443 | 2443 |
2444 Heap* heap = GetHeap(); | 2444 Isolate* isolate = GetIsolate(); |
2445 HandleScope scope(heap->isolate()); | 2445 HandleScope scope(isolate); |
2446 Handle<Object> value_handle(value); | 2446 Handle<Object> value_handle(value); |
2447 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_SET); | 2447 isolate->ReportFailedAccessCheck(this, v8::ACCESS_SET); |
2448 return *value_handle; | 2448 return *value_handle; |
2449 } | 2449 } |
2450 | 2450 |
2451 | 2451 |
2452 MaybeObject* JSReceiver::SetProperty(LookupResult* result, | 2452 MaybeObject* JSReceiver::SetProperty(LookupResult* result, |
2453 String* key, | 2453 String* key, |
2454 Object* value, | 2454 Object* value, |
2455 PropertyAttributes attributes, | 2455 PropertyAttributes attributes, |
2456 StrictModeFlag strict_mode) { | 2456 StrictModeFlag strict_mode) { |
2457 if (result->IsFound() && result->type() == HANDLER) { | 2457 if (result->IsFound() && result->type() == HANDLER) { |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2858 // because ConvertDescriptorToField() which is called in "case CALLBACKS:" | 2858 // because ConvertDescriptorToField() which is called in "case CALLBACKS:" |
2859 // doesn't handle function prototypes correctly. | 2859 // doesn't handle function prototypes correctly. |
2860 MaybeObject* JSObject::SetLocalPropertyIgnoreAttributes( | 2860 MaybeObject* JSObject::SetLocalPropertyIgnoreAttributes( |
2861 String* name, | 2861 String* name, |
2862 Object* value, | 2862 Object* value, |
2863 PropertyAttributes attributes) { | 2863 PropertyAttributes attributes) { |
2864 | 2864 |
2865 // Make sure that the top context does not change when doing callbacks or | 2865 // Make sure that the top context does not change when doing callbacks or |
2866 // interceptor calls. | 2866 // interceptor calls. |
2867 AssertNoContextChange ncc; | 2867 AssertNoContextChange ncc; |
2868 LookupResult result; | 2868 Isolate* isolate = GetIsolate(); |
| 2869 LookupResult result(isolate); |
2869 LocalLookup(name, &result); | 2870 LocalLookup(name, &result); |
2870 // Check access rights if needed. | 2871 // Check access rights if needed. |
2871 if (IsAccessCheckNeeded()) { | 2872 if (IsAccessCheckNeeded()) { |
2872 Heap* heap = GetHeap(); | 2873 if (!isolate->MayNamedAccess(this, name, v8::ACCESS_SET)) { |
2873 if (!heap->isolate()->MayNamedAccess(this, name, v8::ACCESS_SET)) { | |
2874 return SetPropertyWithFailedAccessCheck(&result, | 2874 return SetPropertyWithFailedAccessCheck(&result, |
2875 name, | 2875 name, |
2876 value, | 2876 value, |
2877 false, | 2877 false, |
2878 kNonStrictMode); | 2878 kNonStrictMode); |
2879 } | 2879 } |
2880 } | 2880 } |
2881 | 2881 |
2882 if (IsJSGlobalProxy()) { | 2882 if (IsJSGlobalProxy()) { |
2883 Object* proto = GetPrototype(); | 2883 Object* proto = GetPrototype(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2934 UNREACHABLE(); | 2934 UNREACHABLE(); |
2935 return value; | 2935 return value; |
2936 } | 2936 } |
2937 | 2937 |
2938 | 2938 |
2939 PropertyAttributes JSObject::GetPropertyAttributePostInterceptor( | 2939 PropertyAttributes JSObject::GetPropertyAttributePostInterceptor( |
2940 JSObject* receiver, | 2940 JSObject* receiver, |
2941 String* name, | 2941 String* name, |
2942 bool continue_search) { | 2942 bool continue_search) { |
2943 // Check local property, ignore interceptor. | 2943 // Check local property, ignore interceptor. |
2944 LookupResult result; | 2944 LookupResult result(GetIsolate()); |
2945 LocalLookupRealNamedProperty(name, &result); | 2945 LocalLookupRealNamedProperty(name, &result); |
2946 if (result.IsProperty()) return result.GetAttributes(); | 2946 if (result.IsProperty()) return result.GetAttributes(); |
2947 | 2947 |
2948 if (continue_search) { | 2948 if (continue_search) { |
2949 // Continue searching via the prototype chain. | 2949 // Continue searching via the prototype chain. |
2950 Object* pt = GetPrototype(); | 2950 Object* pt = GetPrototype(); |
2951 if (!pt->IsNull()) { | 2951 if (!pt->IsNull()) { |
2952 return JSObject::cast(pt)-> | 2952 return JSObject::cast(pt)-> |
2953 GetPropertyAttributeWithReceiver(receiver, name); | 2953 GetPropertyAttributeWithReceiver(receiver, name); |
2954 } | 2954 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3010 | 3010 |
3011 PropertyAttributes JSReceiver::GetPropertyAttributeWithReceiver( | 3011 PropertyAttributes JSReceiver::GetPropertyAttributeWithReceiver( |
3012 JSReceiver* receiver, | 3012 JSReceiver* receiver, |
3013 String* key) { | 3013 String* key) { |
3014 uint32_t index = 0; | 3014 uint32_t index = 0; |
3015 if (IsJSObject() && key->AsArrayIndex(&index)) { | 3015 if (IsJSObject() && key->AsArrayIndex(&index)) { |
3016 return JSObject::cast(this)->HasElementWithReceiver(receiver, index) | 3016 return JSObject::cast(this)->HasElementWithReceiver(receiver, index) |
3017 ? NONE : ABSENT; | 3017 ? NONE : ABSENT; |
3018 } | 3018 } |
3019 // Named property. | 3019 // Named property. |
3020 LookupResult result; | 3020 LookupResult result(GetIsolate()); |
3021 Lookup(key, &result); | 3021 Lookup(key, &result); |
3022 return GetPropertyAttribute(receiver, &result, key, true); | 3022 return GetPropertyAttribute(receiver, &result, key, true); |
3023 } | 3023 } |
3024 | 3024 |
3025 | 3025 |
3026 PropertyAttributes JSReceiver::GetPropertyAttribute(JSReceiver* receiver, | 3026 PropertyAttributes JSReceiver::GetPropertyAttribute(JSReceiver* receiver, |
3027 LookupResult* result, | 3027 LookupResult* result, |
3028 String* name, | 3028 String* name, |
3029 bool continue_search) { | 3029 bool continue_search) { |
3030 // Check access rights if needed. | 3030 // Check access rights if needed. |
(...skipping 28 matching lines...) Expand all Loading... |
3059 | 3059 |
3060 | 3060 |
3061 PropertyAttributes JSReceiver::GetLocalPropertyAttribute(String* name) { | 3061 PropertyAttributes JSReceiver::GetLocalPropertyAttribute(String* name) { |
3062 // Check whether the name is an array index. | 3062 // Check whether the name is an array index. |
3063 uint32_t index = 0; | 3063 uint32_t index = 0; |
3064 if (IsJSObject() && name->AsArrayIndex(&index)) { | 3064 if (IsJSObject() && name->AsArrayIndex(&index)) { |
3065 if (JSObject::cast(this)->HasLocalElement(index)) return NONE; | 3065 if (JSObject::cast(this)->HasLocalElement(index)) return NONE; |
3066 return ABSENT; | 3066 return ABSENT; |
3067 } | 3067 } |
3068 // Named property. | 3068 // Named property. |
3069 LookupResult result; | 3069 LookupResult result(GetIsolate()); |
3070 LocalLookup(name, &result); | 3070 LocalLookup(name, &result); |
3071 return GetPropertyAttribute(this, &result, name, false); | 3071 return GetPropertyAttribute(this, &result, name, false); |
3072 } | 3072 } |
3073 | 3073 |
3074 | 3074 |
3075 MaybeObject* NormalizedMapCache::Get(JSObject* obj, | 3075 MaybeObject* NormalizedMapCache::Get(JSObject* obj, |
3076 PropertyNormalizationMode mode) { | 3076 PropertyNormalizationMode mode) { |
3077 Isolate* isolate = obj->GetIsolate(); | 3077 Isolate* isolate = obj->GetIsolate(); |
3078 Map* fast = obj->map(); | 3078 Map* fast = obj->map(); |
3079 int index = fast->Hash() % kEntries; | 3079 int index = fast->Hash() % kEntries; |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3566 DONT_ENUM, | 3566 DONT_ENUM, |
3567 kNonStrictMode); | 3567 kNonStrictMode); |
3568 if (store_result->IsFailure()) return store_result; | 3568 if (store_result->IsFailure()) return store_result; |
3569 return this; | 3569 return this; |
3570 } | 3570 } |
3571 | 3571 |
3572 | 3572 |
3573 MaybeObject* JSObject::DeletePropertyPostInterceptor(String* name, | 3573 MaybeObject* JSObject::DeletePropertyPostInterceptor(String* name, |
3574 DeleteMode mode) { | 3574 DeleteMode mode) { |
3575 // Check local property, ignore interceptor. | 3575 // Check local property, ignore interceptor. |
3576 LookupResult result; | 3576 LookupResult result(GetIsolate()); |
3577 LocalLookupRealNamedProperty(name, &result); | 3577 LocalLookupRealNamedProperty(name, &result); |
3578 if (!result.IsProperty()) return GetHeap()->true_value(); | 3578 if (!result.IsProperty()) return GetHeap()->true_value(); |
3579 | 3579 |
3580 // Normalize object if needed. | 3580 // Normalize object if needed. |
3581 Object* obj; | 3581 Object* obj; |
3582 { MaybeObject* maybe_obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); | 3582 { MaybeObject* maybe_obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); |
3583 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 3583 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
3584 } | 3584 } |
3585 | 3585 |
3586 return DeleteNormalizedProperty(name, mode); | 3586 return DeleteNormalizedProperty(name, mode); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3715 Object* proto = GetPrototype(); | 3715 Object* proto = GetPrototype(); |
3716 if (proto->IsNull()) return isolate->heap()->false_value(); | 3716 if (proto->IsNull()) return isolate->heap()->false_value(); |
3717 ASSERT(proto->IsJSGlobalObject()); | 3717 ASSERT(proto->IsJSGlobalObject()); |
3718 return JSGlobalObject::cast(proto)->DeleteProperty(name, mode); | 3718 return JSGlobalObject::cast(proto)->DeleteProperty(name, mode); |
3719 } | 3719 } |
3720 | 3720 |
3721 uint32_t index = 0; | 3721 uint32_t index = 0; |
3722 if (name->AsArrayIndex(&index)) { | 3722 if (name->AsArrayIndex(&index)) { |
3723 return DeleteElement(index, mode); | 3723 return DeleteElement(index, mode); |
3724 } else { | 3724 } else { |
3725 LookupResult result; | 3725 LookupResult result(isolate); |
3726 LocalLookup(name, &result); | 3726 LocalLookup(name, &result); |
3727 if (!result.IsProperty()) return isolate->heap()->true_value(); | 3727 if (!result.IsProperty()) return isolate->heap()->true_value(); |
3728 // Ignore attributes if forcing a deletion. | 3728 // Ignore attributes if forcing a deletion. |
3729 if (result.IsDontDelete() && mode != FORCE_DELETION) { | 3729 if (result.IsDontDelete() && mode != FORCE_DELETION) { |
3730 if (mode == STRICT_DELETION) { | 3730 if (mode == STRICT_DELETION) { |
3731 // Deleting a non-configurable property in strict mode. | 3731 // Deleting a non-configurable property in strict mode. |
3732 HandleScope scope(isolate); | 3732 HandleScope scope(isolate); |
3733 Handle<Object> args[2] = { Handle<Object>(name), Handle<Object>(this) }; | 3733 Handle<Object> args[2] = { Handle<Object>(name), Handle<Object>(this) }; |
3734 return isolate->Throw(*isolate->factory()->NewTypeError( | 3734 return isolate->Throw(*isolate->factory()->NewTypeError( |
3735 "strict_delete_property", HandleVector(args, 2))); | 3735 "strict_delete_property", HandleVector(args, 2))); |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4145 NumberDictionary* dictionary = NumberDictionary::cast(arguments); | 4145 NumberDictionary* dictionary = NumberDictionary::cast(arguments); |
4146 probe = FindGetterSetterInDictionary(dictionary, index, heap); | 4146 probe = FindGetterSetterInDictionary(dictionary, index, heap); |
4147 if (!probe->IsTheHole()) return probe; | 4147 if (!probe->IsTheHole()) return probe; |
4148 } | 4148 } |
4149 } | 4149 } |
4150 break; | 4150 break; |
4151 } | 4151 } |
4152 } | 4152 } |
4153 } else { | 4153 } else { |
4154 // Lookup the name. | 4154 // Lookup the name. |
4155 LookupResult result; | 4155 LookupResult result(heap->isolate()); |
4156 LocalLookup(name, &result); | 4156 LocalLookup(name, &result); |
4157 if (result.IsProperty()) { | 4157 if (result.IsProperty()) { |
4158 if (result.IsReadOnly()) return heap->undefined_value(); | 4158 if (result.IsReadOnly()) return heap->undefined_value(); |
4159 if (result.type() == CALLBACKS) { | 4159 if (result.type() == CALLBACKS) { |
4160 Object* obj = result.GetCallbackObject(); | 4160 Object* obj = result.GetCallbackObject(); |
4161 // Need to preserve old getters/setters. | 4161 // Need to preserve old getters/setters. |
4162 if (obj->IsFixedArray()) { | 4162 if (obj->IsFixedArray()) { |
4163 // Use set to update attributes. | 4163 // Use set to update attributes. |
4164 return SetPropertyCallback(name, obj, attributes); | 4164 return SetPropertyCallback(name, obj, attributes); |
4165 } | 4165 } |
4166 } | 4166 } |
4167 } | 4167 } |
4168 } | 4168 } |
4169 | 4169 |
4170 // Allocate the fixed array to hold getter and setter. | 4170 // Allocate the fixed array to hold getter and setter. |
4171 Object* structure; | 4171 Object* structure; |
4172 { MaybeObject* maybe_structure = heap->AllocateFixedArray(2, TENURED); | 4172 { MaybeObject* maybe_structure = heap->AllocateFixedArray(2, TENURED); |
4173 if (!maybe_structure->ToObject(&structure)) return maybe_structure; | 4173 if (!maybe_structure->ToObject(&structure)) return maybe_structure; |
4174 } | 4174 } |
4175 | 4175 |
4176 if (is_element) { | 4176 if (is_element) { |
4177 return SetElementCallback(index, structure, attributes); | 4177 return SetElementCallback(index, structure, attributes); |
4178 } else { | 4178 } else { |
4179 return SetPropertyCallback(name, structure, attributes); | 4179 return SetPropertyCallback(name, structure, attributes); |
4180 } | 4180 } |
4181 } | 4181 } |
4182 | 4182 |
4183 | 4183 |
4184 bool JSObject::CanSetCallback(String* name) { | 4184 bool JSObject::CanSetCallback(String* name) { |
4185 ASSERT(!IsAccessCheckNeeded() | 4185 ASSERT(!IsAccessCheckNeeded() || |
4186 || Isolate::Current()->MayNamedAccess(this, name, v8::ACCESS_SET)); | 4186 GetIsolate()->MayNamedAccess(this, name, v8::ACCESS_SET)); |
4187 | 4187 |
4188 // Check if there is an API defined callback object which prohibits | 4188 // Check if there is an API defined callback object which prohibits |
4189 // callback overwriting in this object or it's prototype chain. | 4189 // callback overwriting in this object or it's prototype chain. |
4190 // This mechanism is needed for instance in a browser setting, where | 4190 // This mechanism is needed for instance in a browser setting, where |
4191 // certain accessors such as window.location should not be allowed | 4191 // certain accessors such as window.location should not be allowed |
4192 // to be overwritten because allowing overwriting could potentially | 4192 // to be overwritten because allowing overwriting could potentially |
4193 // cause security problems. | 4193 // cause security problems. |
4194 LookupResult callback_result; | 4194 LookupResult callback_result(GetIsolate()); |
4195 LookupCallback(name, &callback_result); | 4195 LookupCallback(name, &callback_result); |
4196 if (callback_result.IsProperty()) { | 4196 if (callback_result.IsProperty()) { |
4197 Object* obj = callback_result.GetCallbackObject(); | 4197 Object* obj = callback_result.GetCallbackObject(); |
4198 if (obj->IsAccessorInfo() && | 4198 if (obj->IsAccessorInfo() && |
4199 AccessorInfo::cast(obj)->prohibits_overwriting()) { | 4199 AccessorInfo::cast(obj)->prohibits_overwriting()) { |
4200 return false; | 4200 return false; |
4201 } | 4201 } |
4202 } | 4202 } |
4203 | 4203 |
4204 return true; | 4204 return true; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4381 break; | 4381 break; |
4382 } | 4382 } |
4383 | 4383 |
4384 Object* ok; | 4384 Object* ok; |
4385 { MaybeObject* maybe_ok = | 4385 { MaybeObject* maybe_ok = |
4386 SetElementCallback(index, info, info->property_attributes()); | 4386 SetElementCallback(index, info, info->property_attributes()); |
4387 if (!maybe_ok->ToObject(&ok)) return maybe_ok; | 4387 if (!maybe_ok->ToObject(&ok)) return maybe_ok; |
4388 } | 4388 } |
4389 } else { | 4389 } else { |
4390 // Lookup the name. | 4390 // Lookup the name. |
4391 LookupResult result; | 4391 LookupResult result(isolate); |
4392 LocalLookup(name, &result); | 4392 LocalLookup(name, &result); |
4393 // ES5 forbids turning a property into an accessor if it's not | 4393 // ES5 forbids turning a property into an accessor if it's not |
4394 // configurable (that is IsDontDelete in ES3 and v8), see 8.6.1 (Table 5). | 4394 // configurable (that is IsDontDelete in ES3 and v8), see 8.6.1 (Table 5). |
4395 if (result.IsProperty() && (result.IsReadOnly() || result.IsDontDelete())) { | 4395 if (result.IsProperty() && (result.IsReadOnly() || result.IsDontDelete())) { |
4396 return isolate->heap()->undefined_value(); | 4396 return isolate->heap()->undefined_value(); |
4397 } | 4397 } |
4398 Object* ok; | 4398 Object* ok; |
4399 { MaybeObject* maybe_ok = | 4399 { MaybeObject* maybe_ok = |
4400 SetPropertyCallback(name, info, info->property_attributes()); | 4400 SetPropertyCallback(name, info, info->property_attributes()); |
4401 if (!maybe_ok->ToObject(&ok)) return maybe_ok; | 4401 if (!maybe_ok->ToObject(&ok)) return maybe_ok; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4439 return FixedArray::cast(element)->get(accessor_index); | 4439 return FixedArray::cast(element)->get(accessor_index); |
4440 } | 4440 } |
4441 } | 4441 } |
4442 } | 4442 } |
4443 } | 4443 } |
4444 } | 4444 } |
4445 } else { | 4445 } else { |
4446 for (Object* obj = this; | 4446 for (Object* obj = this; |
4447 obj != heap->null_value(); | 4447 obj != heap->null_value(); |
4448 obj = JSObject::cast(obj)->GetPrototype()) { | 4448 obj = JSObject::cast(obj)->GetPrototype()) { |
4449 LookupResult result; | 4449 LookupResult result(heap->isolate()); |
4450 JSObject::cast(obj)->LocalLookup(name, &result); | 4450 JSObject::cast(obj)->LocalLookup(name, &result); |
4451 if (result.IsProperty()) { | 4451 if (result.IsProperty()) { |
4452 if (result.IsReadOnly()) return heap->undefined_value(); | 4452 if (result.IsReadOnly()) return heap->undefined_value(); |
4453 if (result.type() == CALLBACKS) { | 4453 if (result.type() == CALLBACKS) { |
4454 Object* obj = result.GetCallbackObject(); | 4454 Object* obj = result.GetCallbackObject(); |
4455 if (obj->IsFixedArray()) { | 4455 if (obj->IsFixedArray()) { |
4456 return FixedArray::cast(obj)->get(accessor_index); | 4456 return FixedArray::cast(obj)->get(accessor_index); |
4457 } | 4457 } |
4458 } | 4458 } |
4459 } | 4459 } |
(...skipping 2621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7081 | 7081 |
7082 Heap* heap = GetHeap(); | 7082 Heap* heap = GetHeap(); |
7083 | 7083 |
7084 // Traverse the proposed prototype chain looking for setters for properties of | 7084 // Traverse the proposed prototype chain looking for setters for properties of |
7085 // the same names as are set by the inline constructor. | 7085 // the same names as are set by the inline constructor. |
7086 for (Object* obj = prototype; | 7086 for (Object* obj = prototype; |
7087 obj != heap->null_value(); | 7087 obj != heap->null_value(); |
7088 obj = obj->GetPrototype()) { | 7088 obj = obj->GetPrototype()) { |
7089 JSObject* js_object = JSObject::cast(obj); | 7089 JSObject* js_object = JSObject::cast(obj); |
7090 for (int i = 0; i < this_property_assignments_count(); i++) { | 7090 for (int i = 0; i < this_property_assignments_count(); i++) { |
7091 LookupResult result; | 7091 LookupResult result(heap->isolate()); |
7092 String* name = GetThisPropertyAssignmentName(i); | 7092 String* name = GetThisPropertyAssignmentName(i); |
7093 js_object->LocalLookupRealNamedProperty(name, &result); | 7093 js_object->LocalLookupRealNamedProperty(name, &result); |
7094 if (result.IsProperty() && result.type() == CALLBACKS) { | 7094 if (result.IsProperty() && result.type() == CALLBACKS) { |
7095 return false; | 7095 return false; |
7096 } | 7096 } |
7097 } | 7097 } |
7098 } | 7098 } |
7099 | 7099 |
7100 return true; | 7100 return true; |
7101 } | 7101 } |
(...skipping 2525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9627 constructor->shared()->get_api_func_data()->indexed_property_handler(); | 9627 constructor->shared()->get_api_func_data()->indexed_property_handler(); |
9628 return InterceptorInfo::cast(result); | 9628 return InterceptorInfo::cast(result); |
9629 } | 9629 } |
9630 | 9630 |
9631 | 9631 |
9632 MaybeObject* JSObject::GetPropertyPostInterceptor( | 9632 MaybeObject* JSObject::GetPropertyPostInterceptor( |
9633 JSReceiver* receiver, | 9633 JSReceiver* receiver, |
9634 String* name, | 9634 String* name, |
9635 PropertyAttributes* attributes) { | 9635 PropertyAttributes* attributes) { |
9636 // Check local property in holder, ignore interceptor. | 9636 // Check local property in holder, ignore interceptor. |
9637 LookupResult result; | 9637 LookupResult result(GetIsolate()); |
9638 LocalLookupRealNamedProperty(name, &result); | 9638 LocalLookupRealNamedProperty(name, &result); |
9639 if (result.IsProperty()) { | 9639 if (result.IsProperty()) { |
9640 return GetProperty(receiver, &result, name, attributes); | 9640 return GetProperty(receiver, &result, name, attributes); |
9641 } | 9641 } |
9642 // Continue searching via the prototype chain. | 9642 // Continue searching via the prototype chain. |
9643 Object* pt = GetPrototype(); | 9643 Object* pt = GetPrototype(); |
9644 *attributes = ABSENT; | 9644 *attributes = ABSENT; |
9645 if (pt->IsNull()) return GetHeap()->undefined_value(); | 9645 if (pt->IsNull()) return GetHeap()->undefined_value(); |
9646 return pt->GetPropertyWithReceiver(receiver, name, attributes); | 9646 return pt->GetPropertyWithReceiver(receiver, name, attributes); |
9647 } | 9647 } |
9648 | 9648 |
9649 | 9649 |
9650 MaybeObject* JSObject::GetLocalPropertyPostInterceptor( | 9650 MaybeObject* JSObject::GetLocalPropertyPostInterceptor( |
9651 JSReceiver* receiver, | 9651 JSReceiver* receiver, |
9652 String* name, | 9652 String* name, |
9653 PropertyAttributes* attributes) { | 9653 PropertyAttributes* attributes) { |
9654 // Check local property in holder, ignore interceptor. | 9654 // Check local property in holder, ignore interceptor. |
9655 LookupResult result; | 9655 LookupResult result(GetIsolate()); |
9656 LocalLookupRealNamedProperty(name, &result); | 9656 LocalLookupRealNamedProperty(name, &result); |
9657 if (result.IsProperty()) { | 9657 if (result.IsProperty()) { |
9658 return GetProperty(receiver, &result, name, attributes); | 9658 return GetProperty(receiver, &result, name, attributes); |
9659 } | 9659 } |
9660 return GetHeap()->undefined_value(); | 9660 return GetHeap()->undefined_value(); |
9661 } | 9661 } |
9662 | 9662 |
9663 | 9663 |
9664 MaybeObject* JSObject::GetPropertyWithInterceptor( | 9664 MaybeObject* JSObject::GetPropertyWithInterceptor( |
9665 JSReceiver* receiver, | 9665 JSReceiver* receiver, |
(...skipping 30 matching lines...) Expand all Loading... |
9696 *receiver_handle, | 9696 *receiver_handle, |
9697 *name_handle, | 9697 *name_handle, |
9698 attributes); | 9698 attributes); |
9699 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 9699 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
9700 return result; | 9700 return result; |
9701 } | 9701 } |
9702 | 9702 |
9703 | 9703 |
9704 bool JSObject::HasRealNamedProperty(String* key) { | 9704 bool JSObject::HasRealNamedProperty(String* key) { |
9705 // Check access rights if needed. | 9705 // Check access rights if needed. |
| 9706 Isolate* isolate = GetIsolate(); |
9706 if (IsAccessCheckNeeded()) { | 9707 if (IsAccessCheckNeeded()) { |
9707 Heap* heap = GetHeap(); | 9708 if (!isolate->MayNamedAccess(this, key, v8::ACCESS_HAS)) { |
9708 if (!heap->isolate()->MayNamedAccess(this, key, v8::ACCESS_HAS)) { | 9709 isolate->ReportFailedAccessCheck(this, v8::ACCESS_HAS); |
9709 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); | |
9710 return false; | 9710 return false; |
9711 } | 9711 } |
9712 } | 9712 } |
9713 | 9713 |
9714 LookupResult result; | 9714 LookupResult result(isolate); |
9715 LocalLookupRealNamedProperty(key, &result); | 9715 LocalLookupRealNamedProperty(key, &result); |
9716 return result.IsProperty() && (result.type() != INTERCEPTOR); | 9716 return result.IsProperty() && (result.type() != INTERCEPTOR); |
9717 } | 9717 } |
9718 | 9718 |
9719 | 9719 |
9720 bool JSObject::HasRealElementProperty(uint32_t index) { | 9720 bool JSObject::HasRealElementProperty(uint32_t index) { |
9721 // Check access rights if needed. | 9721 // Check access rights if needed. |
9722 if (IsAccessCheckNeeded()) { | 9722 if (IsAccessCheckNeeded()) { |
9723 Heap* heap = GetHeap(); | 9723 Heap* heap = GetHeap(); |
9724 if (!heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_HAS)) { | 9724 if (!heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_HAS)) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9773 break; | 9773 break; |
9774 } | 9774 } |
9775 // All possibilities have been handled above already. | 9775 // All possibilities have been handled above already. |
9776 UNREACHABLE(); | 9776 UNREACHABLE(); |
9777 return GetHeap()->null_value(); | 9777 return GetHeap()->null_value(); |
9778 } | 9778 } |
9779 | 9779 |
9780 | 9780 |
9781 bool JSObject::HasRealNamedCallbackProperty(String* key) { | 9781 bool JSObject::HasRealNamedCallbackProperty(String* key) { |
9782 // Check access rights if needed. | 9782 // Check access rights if needed. |
| 9783 Isolate* isolate = GetIsolate(); |
9783 if (IsAccessCheckNeeded()) { | 9784 if (IsAccessCheckNeeded()) { |
9784 Heap* heap = GetHeap(); | 9785 if (!isolate->MayNamedAccess(this, key, v8::ACCESS_HAS)) { |
9785 if (!heap->isolate()->MayNamedAccess(this, key, v8::ACCESS_HAS)) { | 9786 isolate->ReportFailedAccessCheck(this, v8::ACCESS_HAS); |
9786 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); | |
9787 return false; | 9787 return false; |
9788 } | 9788 } |
9789 } | 9789 } |
9790 | 9790 |
9791 LookupResult result; | 9791 LookupResult result(isolate); |
9792 LocalLookupRealNamedProperty(key, &result); | 9792 LocalLookupRealNamedProperty(key, &result); |
9793 return result.IsProperty() && (result.type() == CALLBACKS); | 9793 return result.IsProperty() && (result.type() == CALLBACKS); |
9794 } | 9794 } |
9795 | 9795 |
9796 | 9796 |
9797 int JSObject::NumberOfLocalProperties(PropertyAttributes filter) { | 9797 int JSObject::NumberOfLocalProperties(PropertyAttributes filter) { |
9798 if (HasFastProperties()) { | 9798 if (HasFastProperties()) { |
9799 DescriptorArray* descs = map()->instance_descriptors(); | 9799 DescriptorArray* descs = map()->instance_descriptors(); |
9800 int result = 0; | 9800 int result = 0; |
9801 for (int i = 0; i < descs->number_of_descriptors(); i++) { | 9801 for (int i = 0; i < descs->number_of_descriptors(); i++) { |
(...skipping 2501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12303 if (break_point_objects()->IsUndefined()) return 0; | 12303 if (break_point_objects()->IsUndefined()) return 0; |
12304 // Single break point. | 12304 // Single break point. |
12305 if (!break_point_objects()->IsFixedArray()) return 1; | 12305 if (!break_point_objects()->IsFixedArray()) return 1; |
12306 // Multiple break points. | 12306 // Multiple break points. |
12307 return FixedArray::cast(break_point_objects())->length(); | 12307 return FixedArray::cast(break_point_objects())->length(); |
12308 } | 12308 } |
12309 #endif // ENABLE_DEBUGGER_SUPPORT | 12309 #endif // ENABLE_DEBUGGER_SUPPORT |
12310 | 12310 |
12311 | 12311 |
12312 } } // namespace v8::internal | 12312 } } // namespace v8::internal |
OLD | NEW |