OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 | 399 |
400 case INTERCEPTOR: { | 400 case INTERCEPTOR: { |
401 // If the object has an interceptor, try real named properties. | 401 // If the object has an interceptor, try real named properties. |
402 // No access check in GetPropertyAttributeWithInterceptor. | 402 // No access check in GetPropertyAttributeWithInterceptor. |
403 LookupResult r(GetIsolate()); | 403 LookupResult r(GetIsolate()); |
404 if (continue_search) { | 404 if (continue_search) { |
405 result->holder()->LookupRealNamedProperty(name, &r); | 405 result->holder()->LookupRealNamedProperty(name, &r); |
406 } else { | 406 } else { |
407 result->holder()->LocalLookupRealNamedProperty(name, &r); | 407 result->holder()->LocalLookupRealNamedProperty(name, &r); |
408 } | 408 } |
409 if (r.IsProperty()) { | 409 if (!r.IsFound()) break; |
410 return GetPropertyAttributeWithFailedAccessCheck(receiver, | 410 return GetPropertyAttributeWithFailedAccessCheck(receiver, |
411 &r, | 411 &r, |
412 name, | 412 name, |
413 continue_search); | 413 continue_search); |
414 } | |
415 break; | |
416 } | 414 } |
417 | 415 |
418 case HANDLER: | 416 case HANDLER: |
419 case TRANSITION: | 417 case TRANSITION: |
420 case NONEXISTENT: | 418 case NONEXISTENT: |
421 UNREACHABLE(); | 419 UNREACHABLE(); |
422 } | 420 } |
423 } | 421 } |
424 | 422 |
425 GetIsolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); | 423 GetIsolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); |
(...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1740 | 1738 |
1741 MaybeObject* JSObject::SetPropertyPostInterceptor( | 1739 MaybeObject* JSObject::SetPropertyPostInterceptor( |
1742 String* name, | 1740 String* name, |
1743 Object* value, | 1741 Object* value, |
1744 PropertyAttributes attributes, | 1742 PropertyAttributes attributes, |
1745 StrictModeFlag strict_mode, | 1743 StrictModeFlag strict_mode, |
1746 ExtensibilityCheck extensibility_check) { | 1744 ExtensibilityCheck extensibility_check) { |
1747 // Check local property, ignore interceptor. | 1745 // Check local property, ignore interceptor. |
1748 LookupResult result(GetIsolate()); | 1746 LookupResult result(GetIsolate()); |
1749 LocalLookupRealNamedProperty(name, &result); | 1747 LocalLookupRealNamedProperty(name, &result); |
| 1748 if (!result.IsFound()) map()->LookupTransition(this, name, &result); |
1750 if (result.IsFound()) { | 1749 if (result.IsFound()) { |
1751 // An existing property, a map transition or a null descriptor was | 1750 // An existing property or a map transition was found. Use set property to |
1752 // found. Use set property to handle all these cases. | 1751 // handle all these cases. |
1753 return SetProperty(&result, name, value, attributes, strict_mode); | 1752 return SetProperty(&result, name, value, attributes, strict_mode); |
1754 } | 1753 } |
1755 bool done = false; | 1754 bool done = false; |
1756 MaybeObject* result_object; | 1755 MaybeObject* result_object; |
1757 result_object = | 1756 result_object = |
1758 SetPropertyViaPrototypes(name, value, attributes, strict_mode, &done); | 1757 SetPropertyViaPrototypes(name, value, attributes, strict_mode, &done); |
1759 if (done) return result_object; | 1758 if (done) return result_object; |
1760 // Add a new real property. | 1759 // Add a new real property. |
1761 return AddProperty(name, value, attributes, strict_mode, | 1760 return AddProperty(name, value, attributes, strict_mode, |
1762 MAY_BE_STORE_FROM_KEYED, extensibility_check); | 1761 MAY_BE_STORE_FROM_KEYED, extensibility_check); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1907 } | 1906 } |
1908 | 1907 |
1909 | 1908 |
1910 MaybeObject* JSReceiver::SetProperty(String* name, | 1909 MaybeObject* JSReceiver::SetProperty(String* name, |
1911 Object* value, | 1910 Object* value, |
1912 PropertyAttributes attributes, | 1911 PropertyAttributes attributes, |
1913 StrictModeFlag strict_mode, | 1912 StrictModeFlag strict_mode, |
1914 JSReceiver::StoreFromKeyed store_mode) { | 1913 JSReceiver::StoreFromKeyed store_mode) { |
1915 LookupResult result(GetIsolate()); | 1914 LookupResult result(GetIsolate()); |
1916 LocalLookup(name, &result); | 1915 LocalLookup(name, &result); |
| 1916 if (!result.IsFound()) { |
| 1917 map()->LookupTransition(JSObject::cast(this), name, &result); |
| 1918 } |
1917 return SetProperty(&result, name, value, attributes, strict_mode, store_mode); | 1919 return SetProperty(&result, name, value, attributes, strict_mode, store_mode); |
1918 } | 1920 } |
1919 | 1921 |
1920 | 1922 |
1921 MaybeObject* JSObject::SetPropertyWithCallback(Object* structure, | 1923 MaybeObject* JSObject::SetPropertyWithCallback(Object* structure, |
1922 String* name, | 1924 String* name, |
1923 Object* value, | 1925 Object* value, |
1924 JSObject* holder, | 1926 JSObject* holder, |
1925 StrictModeFlag strict_mode) { | 1927 StrictModeFlag strict_mode) { |
1926 Isolate* isolate = GetIsolate(); | 1928 Isolate* isolate = GetIsolate(); |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2347 LookupResult* result) { | 2349 LookupResult* result) { |
2348 if (IsJSGlobalProxy()) { | 2350 if (IsJSGlobalProxy()) { |
2349 Object* proto = GetPrototype(); | 2351 Object* proto = GetPrototype(); |
2350 if (proto->IsNull()) return result->NotFound(); | 2352 if (proto->IsNull()) return result->NotFound(); |
2351 ASSERT(proto->IsJSGlobalObject()); | 2353 ASSERT(proto->IsJSGlobalObject()); |
2352 // A GlobalProxy's prototype should always be a proper JSObject. | 2354 // A GlobalProxy's prototype should always be a proper JSObject. |
2353 return JSObject::cast(proto)->LocalLookupRealNamedProperty(name, result); | 2355 return JSObject::cast(proto)->LocalLookupRealNamedProperty(name, result); |
2354 } | 2356 } |
2355 | 2357 |
2356 if (HasFastProperties()) { | 2358 if (HasFastProperties()) { |
2357 map()->LookupTransitionOrDescriptor(this, name, result); | 2359 map()->LookupDescriptor(this, name, result); |
2358 // A property or a map transition was found. We return all of these result | 2360 // A property or a map transition was found. We return all of these result |
2359 // types because LocalLookupRealNamedProperty is used when setting | 2361 // types because LocalLookupRealNamedProperty is used when setting |
2360 // properties where map transitions are handled. | 2362 // properties where map transitions are handled. |
2361 ASSERT(!result->IsFound() || | 2363 ASSERT(!result->IsFound() || |
2362 (result->holder() == this && result->IsFastPropertyType())); | 2364 (result->holder() == this && result->IsFastPropertyType())); |
2363 // Disallow caching for uninitialized constants. These can only | 2365 // Disallow caching for uninitialized constants. These can only |
2364 // occur as fields. | 2366 // occur as fields. |
2365 if (result->IsField() && | 2367 if (result->IsField() && |
2366 result->IsReadOnly() && | 2368 result->IsReadOnly() && |
2367 FastPropertyAt(result->GetFieldIndex())->IsTheHole()) { | 2369 FastPropertyAt(result->GetFieldIndex())->IsTheHole()) { |
(...skipping 19 matching lines...) Expand all Loading... |
2387 result->DictionaryResult(this, entry); | 2389 result->DictionaryResult(this, entry); |
2388 return; | 2390 return; |
2389 } | 2391 } |
2390 | 2392 |
2391 result->NotFound(); | 2393 result->NotFound(); |
2392 } | 2394 } |
2393 | 2395 |
2394 | 2396 |
2395 void JSObject::LookupRealNamedProperty(String* name, LookupResult* result) { | 2397 void JSObject::LookupRealNamedProperty(String* name, LookupResult* result) { |
2396 LocalLookupRealNamedProperty(name, result); | 2398 LocalLookupRealNamedProperty(name, result); |
2397 if (result->IsProperty()) return; | 2399 if (result->IsFound()) return; |
2398 | 2400 |
2399 LookupRealNamedPropertyInPrototypes(name, result); | 2401 LookupRealNamedPropertyInPrototypes(name, result); |
2400 } | 2402 } |
2401 | 2403 |
2402 | 2404 |
2403 void JSObject::LookupRealNamedPropertyInPrototypes(String* name, | 2405 void JSObject::LookupRealNamedPropertyInPrototypes(String* name, |
2404 LookupResult* result) { | 2406 LookupResult* result) { |
2405 Heap* heap = GetHeap(); | 2407 Heap* heap = GetHeap(); |
2406 for (Object* pt = GetPrototype(); | 2408 for (Object* pt = GetPrototype(); |
2407 pt != heap->null_value(); | 2409 pt != heap->null_value(); |
2408 pt = pt->GetPrototype()) { | 2410 pt = pt->GetPrototype()) { |
2409 if (pt->IsJSProxy()) { | 2411 if (pt->IsJSProxy()) { |
2410 return result->HandlerResult(JSProxy::cast(pt)); | 2412 return result->HandlerResult(JSProxy::cast(pt)); |
2411 } | 2413 } |
2412 JSObject::cast(pt)->LocalLookupRealNamedProperty(name, result); | 2414 JSObject::cast(pt)->LocalLookupRealNamedProperty(name, result); |
2413 ASSERT(!(result->IsProperty() && result->type() == INTERCEPTOR)); | 2415 ASSERT(!(result->IsFound() && result->type() == INTERCEPTOR)); |
2414 if (result->IsProperty()) return; | 2416 if (result->IsFound()) return; |
2415 } | 2417 } |
2416 result->NotFound(); | 2418 result->NotFound(); |
2417 } | 2419 } |
2418 | 2420 |
2419 | 2421 |
2420 // We only need to deal with CALLBACKS and INTERCEPTORS | 2422 // We only need to deal with CALLBACKS and INTERCEPTORS |
2421 MaybeObject* JSObject::SetPropertyWithFailedAccessCheck( | 2423 MaybeObject* JSObject::SetPropertyWithFailedAccessCheck( |
2422 LookupResult* result, | 2424 LookupResult* result, |
2423 String* name, | 2425 String* name, |
2424 Object* value, | 2426 Object* value, |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2926 MaybeObject* JSObject::SetLocalPropertyIgnoreAttributes( | 2928 MaybeObject* JSObject::SetLocalPropertyIgnoreAttributes( |
2927 String* name, | 2929 String* name, |
2928 Object* value, | 2930 Object* value, |
2929 PropertyAttributes attributes) { | 2931 PropertyAttributes attributes) { |
2930 // Make sure that the top context does not change when doing callbacks or | 2932 // Make sure that the top context does not change when doing callbacks or |
2931 // interceptor calls. | 2933 // interceptor calls. |
2932 AssertNoContextChange ncc; | 2934 AssertNoContextChange ncc; |
2933 Isolate* isolate = GetIsolate(); | 2935 Isolate* isolate = GetIsolate(); |
2934 LookupResult result(isolate); | 2936 LookupResult result(isolate); |
2935 LocalLookup(name, &result); | 2937 LocalLookup(name, &result); |
| 2938 if (!result.IsFound()) map()->LookupTransition(this, name, &result); |
2936 // Check access rights if needed. | 2939 // Check access rights if needed. |
2937 if (IsAccessCheckNeeded()) { | 2940 if (IsAccessCheckNeeded()) { |
2938 if (!isolate->MayNamedAccess(this, name, v8::ACCESS_SET)) { | 2941 if (!isolate->MayNamedAccess(this, name, v8::ACCESS_SET)) { |
2939 return SetPropertyWithFailedAccessCheck(&result, | 2942 return SetPropertyWithFailedAccessCheck(&result, |
2940 name, | 2943 name, |
2941 value, | 2944 value, |
2942 false, | 2945 false, |
2943 kNonStrictMode); | 2946 kNonStrictMode); |
2944 } | 2947 } |
2945 } | 2948 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3014 } | 3017 } |
3015 | 3018 |
3016 | 3019 |
3017 PropertyAttributes JSObject::GetPropertyAttributePostInterceptor( | 3020 PropertyAttributes JSObject::GetPropertyAttributePostInterceptor( |
3018 JSObject* receiver, | 3021 JSObject* receiver, |
3019 String* name, | 3022 String* name, |
3020 bool continue_search) { | 3023 bool continue_search) { |
3021 // Check local property, ignore interceptor. | 3024 // Check local property, ignore interceptor. |
3022 LookupResult result(GetIsolate()); | 3025 LookupResult result(GetIsolate()); |
3023 LocalLookupRealNamedProperty(name, &result); | 3026 LocalLookupRealNamedProperty(name, &result); |
3024 if (result.IsProperty()) return result.GetAttributes(); | 3027 if (result.IsFound()) return result.GetAttributes(); |
3025 | 3028 |
3026 if (continue_search) { | 3029 if (continue_search) { |
3027 // Continue searching via the prototype chain. | 3030 // Continue searching via the prototype chain. |
3028 Object* pt = GetPrototype(); | 3031 Object* pt = GetPrototype(); |
3029 if (!pt->IsNull()) { | 3032 if (!pt->IsNull()) { |
3030 return JSObject::cast(pt)-> | 3033 return JSObject::cast(pt)-> |
3031 GetPropertyAttributeWithReceiver(receiver, name); | 3034 GetPropertyAttributeWithReceiver(receiver, name); |
3032 } | 3035 } |
3033 } | 3036 } |
3034 return ABSENT; | 3037 return ABSENT; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3107 bool continue_search) { | 3110 bool continue_search) { |
3108 // Check access rights if needed. | 3111 // Check access rights if needed. |
3109 if (IsAccessCheckNeeded()) { | 3112 if (IsAccessCheckNeeded()) { |
3110 JSObject* this_obj = JSObject::cast(this); | 3113 JSObject* this_obj = JSObject::cast(this); |
3111 Heap* heap = GetHeap(); | 3114 Heap* heap = GetHeap(); |
3112 if (!heap->isolate()->MayNamedAccess(this_obj, name, v8::ACCESS_HAS)) { | 3115 if (!heap->isolate()->MayNamedAccess(this_obj, name, v8::ACCESS_HAS)) { |
3113 return this_obj->GetPropertyAttributeWithFailedAccessCheck( | 3116 return this_obj->GetPropertyAttributeWithFailedAccessCheck( |
3114 receiver, result, name, continue_search); | 3117 receiver, result, name, continue_search); |
3115 } | 3118 } |
3116 } | 3119 } |
3117 if (result->IsProperty()) { | 3120 if (result->IsFound()) { |
3118 switch (result->type()) { | 3121 switch (result->type()) { |
3119 case NORMAL: // fall through | 3122 case NORMAL: // fall through |
3120 case FIELD: | 3123 case FIELD: |
3121 case CONSTANT_FUNCTION: | 3124 case CONSTANT_FUNCTION: |
3122 case CALLBACKS: | 3125 case CALLBACKS: |
3123 return result->GetAttributes(); | 3126 return result->GetAttributes(); |
3124 case HANDLER: { | 3127 case HANDLER: { |
3125 return JSProxy::cast(result->proxy())->GetPropertyAttributeWithHandler( | 3128 return JSProxy::cast(result->proxy())->GetPropertyAttributeWithHandler( |
3126 receiver, name); | 3129 receiver, name); |
3127 } | 3130 } |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3693 if (store_result->IsFailure()) return store_result; | 3696 if (store_result->IsFailure()) return store_result; |
3694 return this; | 3697 return this; |
3695 } | 3698 } |
3696 | 3699 |
3697 | 3700 |
3698 MaybeObject* JSObject::DeletePropertyPostInterceptor(String* name, | 3701 MaybeObject* JSObject::DeletePropertyPostInterceptor(String* name, |
3699 DeleteMode mode) { | 3702 DeleteMode mode) { |
3700 // Check local property, ignore interceptor. | 3703 // Check local property, ignore interceptor. |
3701 LookupResult result(GetIsolate()); | 3704 LookupResult result(GetIsolate()); |
3702 LocalLookupRealNamedProperty(name, &result); | 3705 LocalLookupRealNamedProperty(name, &result); |
3703 if (!result.IsProperty()) return GetHeap()->true_value(); | 3706 if (!result.IsFound()) return GetHeap()->true_value(); |
3704 | 3707 |
3705 // Normalize object if needed. | 3708 // Normalize object if needed. |
3706 Object* obj; | 3709 Object* obj; |
3707 { MaybeObject* maybe_obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); | 3710 { MaybeObject* maybe_obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); |
3708 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 3711 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
3709 } | 3712 } |
3710 | 3713 |
3711 return DeleteNormalizedProperty(name, mode); | 3714 return DeleteNormalizedProperty(name, mode); |
3712 } | 3715 } |
3713 | 3716 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3842 ASSERT(proto->IsJSGlobalObject()); | 3845 ASSERT(proto->IsJSGlobalObject()); |
3843 return JSGlobalObject::cast(proto)->DeleteProperty(name, mode); | 3846 return JSGlobalObject::cast(proto)->DeleteProperty(name, mode); |
3844 } | 3847 } |
3845 | 3848 |
3846 uint32_t index = 0; | 3849 uint32_t index = 0; |
3847 if (name->AsArrayIndex(&index)) { | 3850 if (name->AsArrayIndex(&index)) { |
3848 return DeleteElement(index, mode); | 3851 return DeleteElement(index, mode); |
3849 } else { | 3852 } else { |
3850 LookupResult result(isolate); | 3853 LookupResult result(isolate); |
3851 LocalLookup(name, &result); | 3854 LocalLookup(name, &result); |
3852 if (!result.IsProperty()) return isolate->heap()->true_value(); | 3855 if (!result.IsFound()) return isolate->heap()->true_value(); |
3853 // Ignore attributes if forcing a deletion. | 3856 // Ignore attributes if forcing a deletion. |
3854 if (result.IsDontDelete() && mode != FORCE_DELETION) { | 3857 if (result.IsDontDelete() && mode != FORCE_DELETION) { |
3855 if (mode == STRICT_DELETION) { | 3858 if (mode == STRICT_DELETION) { |
3856 // Deleting a non-configurable property in strict mode. | 3859 // Deleting a non-configurable property in strict mode. |
3857 HandleScope scope(isolate); | 3860 HandleScope scope(isolate); |
3858 Handle<Object> args[2] = { Handle<Object>(name), Handle<Object>(this) }; | 3861 Handle<Object> args[2] = { Handle<Object>(name), Handle<Object>(this) }; |
3859 return isolate->Throw(*isolate->factory()->NewTypeError( | 3862 return isolate->Throw(*isolate->factory()->NewTypeError( |
3860 "strict_delete_property", HandleVector(args, 2))); | 3863 "strict_delete_property", HandleVector(args, 2))); |
3861 } | 3864 } |
3862 return isolate->heap()->false_value(); | 3865 return isolate->heap()->false_value(); |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4192 if (js_object->HasNamedInterceptor() && | 4195 if (js_object->HasNamedInterceptor() && |
4193 !heap->isolate()->bootstrapper()->IsActive()) { | 4196 !heap->isolate()->bootstrapper()->IsActive()) { |
4194 result->InterceptorResult(js_object); | 4197 result->InterceptorResult(js_object); |
4195 return; | 4198 return; |
4196 } | 4199 } |
4197 | 4200 |
4198 js_object->LocalLookupRealNamedProperty(name, result); | 4201 js_object->LocalLookupRealNamedProperty(name, result); |
4199 } | 4202 } |
4200 | 4203 |
4201 | 4204 |
4202 void JSReceiver::Lookup(String* name, LookupResult* result) { | 4205 void JSReceiver::Lookup(String* name, |
| 4206 LookupResult* result) { |
4203 // Ecma-262 3rd 8.6.2.4 | 4207 // Ecma-262 3rd 8.6.2.4 |
4204 Heap* heap = GetHeap(); | 4208 Heap* heap = GetHeap(); |
4205 for (Object* current = this; | 4209 for (Object* current = this; |
4206 current != heap->null_value(); | 4210 current != heap->null_value(); |
4207 current = JSObject::cast(current)->GetPrototype()) { | 4211 current = JSObject::cast(current)->GetPrototype()) { |
4208 JSReceiver::cast(current)->LocalLookup(name, result); | 4212 JSReceiver::cast(current)->LocalLookup(name, result); |
4209 if (result->IsProperty()) return; | 4213 if (result->IsFound()) return; |
4210 } | 4214 } |
4211 result->NotFound(); | 4215 result->NotFound(); |
4212 } | 4216 } |
4213 | 4217 |
4214 | 4218 |
4215 // Search object and its prototype chain for callback properties. | 4219 // Search object and its prototype chain for callback properties. |
4216 void JSObject::LookupCallback(String* name, LookupResult* result) { | 4220 void JSObject::LookupCallbackProperty(String* name, LookupResult* result) { |
4217 Heap* heap = GetHeap(); | 4221 Heap* heap = GetHeap(); |
4218 for (Object* current = this; | 4222 for (Object* current = this; |
4219 current != heap->null_value() && current->IsJSObject(); | 4223 current != heap->null_value() && current->IsJSObject(); |
4220 current = JSObject::cast(current)->GetPrototype()) { | 4224 current = JSObject::cast(current)->GetPrototype()) { |
4221 JSObject::cast(current)->LocalLookupRealNamedProperty(name, result); | 4225 JSObject::cast(current)->LocalLookupRealNamedProperty(name, result); |
4222 if (result->IsPropertyCallbacks()) return; | 4226 if (result->IsPropertyCallbacks()) return; |
4223 } | 4227 } |
4224 result->NotFound(); | 4228 result->NotFound(); |
4225 } | 4229 } |
4226 | 4230 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4377 ASSERT(!IsAccessCheckNeeded() || | 4381 ASSERT(!IsAccessCheckNeeded() || |
4378 GetIsolate()->MayNamedAccess(this, name, v8::ACCESS_SET)); | 4382 GetIsolate()->MayNamedAccess(this, name, v8::ACCESS_SET)); |
4379 | 4383 |
4380 // Check if there is an API defined callback object which prohibits | 4384 // Check if there is an API defined callback object which prohibits |
4381 // callback overwriting in this object or its prototype chain. | 4385 // callback overwriting in this object or its prototype chain. |
4382 // This mechanism is needed for instance in a browser setting, where | 4386 // This mechanism is needed for instance in a browser setting, where |
4383 // certain accessors such as window.location should not be allowed | 4387 // certain accessors such as window.location should not be allowed |
4384 // to be overwritten because allowing overwriting could potentially | 4388 // to be overwritten because allowing overwriting could potentially |
4385 // cause security problems. | 4389 // cause security problems. |
4386 LookupResult callback_result(GetIsolate()); | 4390 LookupResult callback_result(GetIsolate()); |
4387 LookupCallback(name, &callback_result); | 4391 LookupCallbackProperty(name, &callback_result); |
4388 if (callback_result.IsProperty()) { | 4392 if (callback_result.IsFound()) { |
4389 Object* obj = callback_result.GetCallbackObject(); | 4393 Object* obj = callback_result.GetCallbackObject(); |
4390 if (obj->IsAccessorInfo() && | 4394 if (obj->IsAccessorInfo() && |
4391 AccessorInfo::cast(obj)->prohibits_overwriting()) { | 4395 AccessorInfo::cast(obj)->prohibits_overwriting()) { |
4392 return false; | 4396 return false; |
4393 } | 4397 } |
4394 } | 4398 } |
4395 | 4399 |
4396 return true; | 4400 return true; |
4397 } | 4401 } |
4398 | 4402 |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4686 // Ignore getters and setters on pixel and external array | 4690 // Ignore getters and setters on pixel and external array |
4687 // elements. | 4691 // elements. |
4688 return isolate->heap()->undefined_value(); | 4692 return isolate->heap()->undefined_value(); |
4689 case DICTIONARY_ELEMENTS: | 4693 case DICTIONARY_ELEMENTS: |
4690 break; | 4694 break; |
4691 case NON_STRICT_ARGUMENTS_ELEMENTS: | 4695 case NON_STRICT_ARGUMENTS_ELEMENTS: |
4692 UNIMPLEMENTED(); | 4696 UNIMPLEMENTED(); |
4693 break; | 4697 break; |
4694 } | 4698 } |
4695 | 4699 |
4696 { MaybeObject* maybe_ok = | 4700 MaybeObject* maybe_ok = |
4697 SetElementCallback(index, info, info->property_attributes()); | 4701 SetElementCallback(index, info, info->property_attributes()); |
4698 if (maybe_ok->IsFailure()) return maybe_ok; | 4702 if (maybe_ok->IsFailure()) return maybe_ok; |
4699 } | |
4700 } else { | 4703 } else { |
4701 // Lookup the name. | 4704 // Lookup the name. |
4702 LookupResult result(isolate); | 4705 LookupResult result(isolate); |
4703 LocalLookup(name, &result); | 4706 LocalLookup(name, &result); |
4704 // ES5 forbids turning a property into an accessor if it's not | 4707 // ES5 forbids turning a property into an accessor if it's not |
4705 // configurable (that is IsDontDelete in ES3 and v8), see 8.6.1 (Table 5). | 4708 // configurable (that is IsDontDelete in ES3 and v8), see 8.6.1 (Table 5). |
4706 if (result.IsProperty() && (result.IsReadOnly() || result.IsDontDelete())) { | 4709 if (result.IsFound() && (result.IsReadOnly() || result.IsDontDelete())) { |
4707 return isolate->heap()->undefined_value(); | 4710 return isolate->heap()->undefined_value(); |
4708 } | 4711 } |
4709 { MaybeObject* maybe_ok = | 4712 |
4710 SetPropertyCallback(name, info, info->property_attributes()); | 4713 MaybeObject* maybe_ok = |
4711 if (maybe_ok->IsFailure()) return maybe_ok; | 4714 SetPropertyCallback(name, info, info->property_attributes()); |
4712 } | 4715 if (maybe_ok->IsFailure()) return maybe_ok; |
4713 } | 4716 } |
4714 | 4717 |
4715 return this; | 4718 return this; |
4716 } | 4719 } |
4717 | 4720 |
4718 | 4721 |
4719 Object* JSObject::LookupAccessor(String* name, AccessorComponent component) { | 4722 Object* JSObject::LookupAccessor(String* name, AccessorComponent component) { |
4720 Heap* heap = GetHeap(); | 4723 Heap* heap = GetHeap(); |
4721 | 4724 |
4722 // Make sure that the top context does not change when doing callbacks or | 4725 // Make sure that the top context does not change when doing callbacks or |
(...skipping 25 matching lines...) Expand all Loading... |
4748 } | 4751 } |
4749 } | 4752 } |
4750 } | 4753 } |
4751 } | 4754 } |
4752 } else { | 4755 } else { |
4753 for (Object* obj = this; | 4756 for (Object* obj = this; |
4754 obj != heap->null_value(); | 4757 obj != heap->null_value(); |
4755 obj = JSReceiver::cast(obj)->GetPrototype()) { | 4758 obj = JSReceiver::cast(obj)->GetPrototype()) { |
4756 LookupResult result(heap->isolate()); | 4759 LookupResult result(heap->isolate()); |
4757 JSReceiver::cast(obj)->LocalLookup(name, &result); | 4760 JSReceiver::cast(obj)->LocalLookup(name, &result); |
4758 if (result.IsProperty()) { | 4761 if (result.IsFound()) { |
4759 if (result.IsReadOnly()) return heap->undefined_value(); | 4762 if (result.IsReadOnly()) return heap->undefined_value(); |
4760 if (result.IsPropertyCallbacks()) { | 4763 if (result.IsPropertyCallbacks()) { |
4761 Object* obj = result.GetCallbackObject(); | 4764 Object* obj = result.GetCallbackObject(); |
4762 if (obj->IsAccessorPair()) { | 4765 if (obj->IsAccessorPair()) { |
4763 return AccessorPair::cast(obj)->GetComponent(component); | 4766 return AccessorPair::cast(obj)->GetComponent(component); |
4764 } | 4767 } |
4765 } | 4768 } |
4766 } | 4769 } |
4767 } | 4770 } |
4768 } | 4771 } |
(...skipping 2865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7634 // Traverse the proposed prototype chain looking for properties of the | 7637 // Traverse the proposed prototype chain looking for properties of the |
7635 // same names as are set by the inline constructor. | 7638 // same names as are set by the inline constructor. |
7636 for (Object* obj = prototype; | 7639 for (Object* obj = prototype; |
7637 obj != heap->null_value(); | 7640 obj != heap->null_value(); |
7638 obj = obj->GetPrototype()) { | 7641 obj = obj->GetPrototype()) { |
7639 JSReceiver* receiver = JSReceiver::cast(obj); | 7642 JSReceiver* receiver = JSReceiver::cast(obj); |
7640 for (int i = 0; i < this_property_assignments_count(); i++) { | 7643 for (int i = 0; i < this_property_assignments_count(); i++) { |
7641 LookupResult result(heap->isolate()); | 7644 LookupResult result(heap->isolate()); |
7642 String* name = GetThisPropertyAssignmentName(i); | 7645 String* name = GetThisPropertyAssignmentName(i); |
7643 receiver->LocalLookup(name, &result); | 7646 receiver->LocalLookup(name, &result); |
7644 if (result.IsProperty()) { | 7647 if (result.IsFound()) { |
7645 switch (result.type()) { | 7648 switch (result.type()) { |
7646 case NORMAL: | 7649 case NORMAL: |
7647 case FIELD: | 7650 case FIELD: |
7648 case CONSTANT_FUNCTION: | 7651 case CONSTANT_FUNCTION: |
7649 break; | 7652 break; |
7650 case INTERCEPTOR: | 7653 case INTERCEPTOR: |
7651 case CALLBACKS: | 7654 case CALLBACKS: |
7652 case HANDLER: | 7655 case HANDLER: |
7653 return false; | 7656 return false; |
7654 case TRANSITION: | 7657 case TRANSITION: |
(...skipping 2512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10167 } | 10170 } |
10168 | 10171 |
10169 | 10172 |
10170 MaybeObject* JSObject::GetPropertyPostInterceptor( | 10173 MaybeObject* JSObject::GetPropertyPostInterceptor( |
10171 JSReceiver* receiver, | 10174 JSReceiver* receiver, |
10172 String* name, | 10175 String* name, |
10173 PropertyAttributes* attributes) { | 10176 PropertyAttributes* attributes) { |
10174 // Check local property in holder, ignore interceptor. | 10177 // Check local property in holder, ignore interceptor. |
10175 LookupResult result(GetIsolate()); | 10178 LookupResult result(GetIsolate()); |
10176 LocalLookupRealNamedProperty(name, &result); | 10179 LocalLookupRealNamedProperty(name, &result); |
10177 if (result.IsProperty()) { | 10180 if (result.IsFound()) { |
10178 return GetProperty(receiver, &result, name, attributes); | 10181 return GetProperty(receiver, &result, name, attributes); |
10179 } | 10182 } |
10180 // Continue searching via the prototype chain. | 10183 // Continue searching via the prototype chain. |
10181 Object* pt = GetPrototype(); | 10184 Object* pt = GetPrototype(); |
10182 *attributes = ABSENT; | 10185 *attributes = ABSENT; |
10183 if (pt->IsNull()) return GetHeap()->undefined_value(); | 10186 if (pt->IsNull()) return GetHeap()->undefined_value(); |
10184 return pt->GetPropertyWithReceiver(receiver, name, attributes); | 10187 return pt->GetPropertyWithReceiver(receiver, name, attributes); |
10185 } | 10188 } |
10186 | 10189 |
10187 | 10190 |
10188 MaybeObject* JSObject::GetLocalPropertyPostInterceptor( | 10191 MaybeObject* JSObject::GetLocalPropertyPostInterceptor( |
10189 JSReceiver* receiver, | 10192 JSReceiver* receiver, |
10190 String* name, | 10193 String* name, |
10191 PropertyAttributes* attributes) { | 10194 PropertyAttributes* attributes) { |
10192 // Check local property in holder, ignore interceptor. | 10195 // Check local property in holder, ignore interceptor. |
10193 LookupResult result(GetIsolate()); | 10196 LookupResult result(GetIsolate()); |
10194 LocalLookupRealNamedProperty(name, &result); | 10197 LocalLookupRealNamedProperty(name, &result); |
10195 if (result.IsProperty()) { | 10198 if (result.IsFound()) { |
10196 return GetProperty(receiver, &result, name, attributes); | 10199 return GetProperty(receiver, &result, name, attributes); |
10197 } | 10200 } |
10198 return GetHeap()->undefined_value(); | 10201 return GetHeap()->undefined_value(); |
10199 } | 10202 } |
10200 | 10203 |
10201 | 10204 |
10202 MaybeObject* JSObject::GetPropertyWithInterceptor( | 10205 MaybeObject* JSObject::GetPropertyWithInterceptor( |
10203 JSReceiver* receiver, | 10206 JSReceiver* receiver, |
10204 String* name, | 10207 String* name, |
10205 PropertyAttributes* attributes) { | 10208 PropertyAttributes* attributes) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10244 Isolate* isolate = GetIsolate(); | 10247 Isolate* isolate = GetIsolate(); |
10245 if (IsAccessCheckNeeded()) { | 10248 if (IsAccessCheckNeeded()) { |
10246 if (!isolate->MayNamedAccess(this, key, v8::ACCESS_HAS)) { | 10249 if (!isolate->MayNamedAccess(this, key, v8::ACCESS_HAS)) { |
10247 isolate->ReportFailedAccessCheck(this, v8::ACCESS_HAS); | 10250 isolate->ReportFailedAccessCheck(this, v8::ACCESS_HAS); |
10248 return false; | 10251 return false; |
10249 } | 10252 } |
10250 } | 10253 } |
10251 | 10254 |
10252 LookupResult result(isolate); | 10255 LookupResult result(isolate); |
10253 LocalLookupRealNamedProperty(key, &result); | 10256 LocalLookupRealNamedProperty(key, &result); |
10254 return result.IsProperty() && !result.IsInterceptor(); | 10257 return result.IsFound() && !result.IsInterceptor(); |
10255 } | 10258 } |
10256 | 10259 |
10257 | 10260 |
10258 bool JSObject::HasRealElementProperty(uint32_t index) { | 10261 bool JSObject::HasRealElementProperty(uint32_t index) { |
10259 // Check access rights if needed. | 10262 // Check access rights if needed. |
10260 if (IsAccessCheckNeeded()) { | 10263 if (IsAccessCheckNeeded()) { |
10261 Heap* heap = GetHeap(); | 10264 Heap* heap = GetHeap(); |
10262 if (!heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_HAS)) { | 10265 if (!heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_HAS)) { |
10263 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); | 10266 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); |
10264 return false; | 10267 return false; |
(...skipping 2849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13114 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13117 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
13115 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13118 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
13116 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13119 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
13117 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13120 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
13118 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13121 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
13119 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13122 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
13120 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13123 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
13121 } | 13124 } |
13122 | 13125 |
13123 } } // namespace v8::internal | 13126 } } // namespace v8::internal |
OLD | NEW |