| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdlib.h> | 5 #include <stdlib.h> |
| 6 #include <limits> | 6 #include <limits> |
| 7 | 7 |
| 8 #include "v8.h" | 8 #include "v8.h" |
| 9 | 9 |
| 10 #include "accessors.h" | 10 #include "accessors.h" |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 uint32_t element_index = 0; | 270 uint32_t element_index = 0; |
| 271 StoreMode mode = value->IsJSObject() ? FORCE_FIELD : ALLOW_AS_CONSTANT; | 271 StoreMode mode = value->IsJSObject() ? FORCE_FIELD : ALLOW_AS_CONSTANT; |
| 272 if (key->IsInternalizedString()) { | 272 if (key->IsInternalizedString()) { |
| 273 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) { | 273 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) { |
| 274 // Array index as string (uint32). | 274 // Array index as string (uint32). |
| 275 maybe_result = JSObject::SetOwnElement( | 275 maybe_result = JSObject::SetOwnElement( |
| 276 boilerplate, element_index, value, SLOPPY); | 276 boilerplate, element_index, value, SLOPPY); |
| 277 } else { | 277 } else { |
| 278 Handle<String> name(String::cast(*key)); | 278 Handle<String> name(String::cast(*key)); |
| 279 ASSERT(!name->AsArrayIndex(&element_index)); | 279 ASSERT(!name->AsArrayIndex(&element_index)); |
| 280 maybe_result = JSObject::SetLocalPropertyIgnoreAttributes( | 280 maybe_result = JSObject::SetOwnPropertyIgnoreAttributes( |
| 281 boilerplate, name, value, NONE, | 281 boilerplate, name, value, NONE, |
| 282 Object::OPTIMAL_REPRESENTATION, mode); | 282 Object::OPTIMAL_REPRESENTATION, mode); |
| 283 } | 283 } |
| 284 } else if (key->ToArrayIndex(&element_index)) { | 284 } else if (key->ToArrayIndex(&element_index)) { |
| 285 // Array index (uint32). | 285 // Array index (uint32). |
| 286 maybe_result = JSObject::SetOwnElement( | 286 maybe_result = JSObject::SetOwnElement( |
| 287 boilerplate, element_index, value, SLOPPY); | 287 boilerplate, element_index, value, SLOPPY); |
| 288 } else { | 288 } else { |
| 289 // Non-uint32 number. | 289 // Non-uint32 number. |
| 290 ASSERT(key->IsNumber()); | 290 ASSERT(key->IsNumber()); |
| 291 double num = key->Number(); | 291 double num = key->Number(); |
| 292 char arr[100]; | 292 char arr[100]; |
| 293 Vector<char> buffer(arr, ARRAY_SIZE(arr)); | 293 Vector<char> buffer(arr, ARRAY_SIZE(arr)); |
| 294 const char* str = DoubleToCString(num, buffer); | 294 const char* str = DoubleToCString(num, buffer); |
| 295 Handle<String> name = isolate->factory()->NewStringFromAsciiChecked(str); | 295 Handle<String> name = isolate->factory()->NewStringFromAsciiChecked(str); |
| 296 maybe_result = JSObject::SetLocalPropertyIgnoreAttributes( | 296 maybe_result = JSObject::SetOwnPropertyIgnoreAttributes( |
| 297 boilerplate, name, value, NONE, | 297 boilerplate, name, value, NONE, |
| 298 Object::OPTIMAL_REPRESENTATION, mode); | 298 Object::OPTIMAL_REPRESENTATION, mode); |
| 299 } | 299 } |
| 300 // If setting the property on the boilerplate throws an | 300 // If setting the property on the boilerplate throws an |
| 301 // exception, the exception is converted to an empty handle in | 301 // exception, the exception is converted to an empty handle in |
| 302 // the handle based operations. In that case, we need to | 302 // the handle based operations. In that case, we need to |
| 303 // convert back to an exception. | 303 // convert back to an exception. |
| 304 RETURN_ON_EXCEPTION(isolate, maybe_result, Object); | 304 RETURN_ON_EXCEPTION(isolate, maybe_result, Object); |
| 305 } | 305 } |
| 306 | 306 |
| (...skipping 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1953 obj, obj, index, access_type, &Isolate::MayIndexedAccess)) { | 1953 obj, obj, index, access_type, &Isolate::MayIndexedAccess)) { |
| 1954 return ACCESS_ALLOWED; | 1954 return ACCESS_ALLOWED; |
| 1955 } | 1955 } |
| 1956 | 1956 |
| 1957 obj->GetIsolate()->ReportFailedAccessCheck(obj, access_type); | 1957 obj->GetIsolate()->ReportFailedAccessCheck(obj, access_type); |
| 1958 return ACCESS_FORBIDDEN; | 1958 return ACCESS_FORBIDDEN; |
| 1959 } | 1959 } |
| 1960 | 1960 |
| 1961 Isolate* isolate = obj->GetIsolate(); | 1961 Isolate* isolate = obj->GetIsolate(); |
| 1962 LookupResult lookup(isolate); | 1962 LookupResult lookup(isolate); |
| 1963 obj->LocalLookup(name, &lookup, true); | 1963 obj->LookupOwn(name, &lookup, true); |
| 1964 | 1964 |
| 1965 if (!lookup.IsProperty()) return ACCESS_ABSENT; | 1965 if (!lookup.IsProperty()) return ACCESS_ABSENT; |
| 1966 Handle<JSObject> holder(lookup.holder(), isolate); | 1966 Handle<JSObject> holder(lookup.holder(), isolate); |
| 1967 if (CheckGenericAccess<Handle<Object> >( | 1967 if (CheckGenericAccess<Handle<Object> >( |
| 1968 obj, holder, name, access_type, &Isolate::MayNamedAccess)) { | 1968 obj, holder, name, access_type, &Isolate::MayNamedAccess)) { |
| 1969 return ACCESS_ALLOWED; | 1969 return ACCESS_ALLOWED; |
| 1970 } | 1970 } |
| 1971 | 1971 |
| 1972 // Access check callback denied the access, but some properties | 1972 // Access check callback denied the access, but some properties |
| 1973 // can have a special permissions which override callbacks descision | 1973 // can have a special permissions which override callbacks descision |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2020 // more than one access failure here. | 2020 // more than one access failure here. |
| 2021 AccessCheckResult access_check_result = | 2021 AccessCheckResult access_check_result = |
| 2022 CheckPropertyAccess(obj, name, v8::ACCESS_HAS); | 2022 CheckPropertyAccess(obj, name, v8::ACCESS_HAS); |
| 2023 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); | 2023 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 2024 switch (access_check_result) { | 2024 switch (access_check_result) { |
| 2025 case ACCESS_FORBIDDEN: return factory->false_value(); | 2025 case ACCESS_FORBIDDEN: return factory->false_value(); |
| 2026 case ACCESS_ALLOWED: break; | 2026 case ACCESS_ALLOWED: break; |
| 2027 case ACCESS_ABSENT: return factory->undefined_value(); | 2027 case ACCESS_ABSENT: return factory->undefined_value(); |
| 2028 } | 2028 } |
| 2029 | 2029 |
| 2030 PropertyAttributes attrs = JSReceiver::GetLocalPropertyAttribute(obj, name); | 2030 PropertyAttributes attrs = JSReceiver::GetOwnPropertyAttribute(obj, name); |
| 2031 if (attrs == ABSENT) { | 2031 if (attrs == ABSENT) { |
| 2032 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); | 2032 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 2033 return factory->undefined_value(); | 2033 return factory->undefined_value(); |
| 2034 } | 2034 } |
| 2035 ASSERT(!isolate->has_scheduled_exception()); | 2035 ASSERT(!isolate->has_scheduled_exception()); |
| 2036 Handle<AccessorPair> accessors; | 2036 Handle<AccessorPair> accessors; |
| 2037 bool has_accessors = | 2037 bool has_accessors = |
| 2038 JSObject::GetLocalPropertyAccessorPair(obj, name).ToHandle(&accessors); | 2038 JSObject::GetOwnPropertyAccessorPair(obj, name).ToHandle(&accessors); |
| 2039 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE); | 2039 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE); |
| 2040 elms->set(ENUMERABLE_INDEX, heap->ToBoolean((attrs & DONT_ENUM) == 0)); | 2040 elms->set(ENUMERABLE_INDEX, heap->ToBoolean((attrs & DONT_ENUM) == 0)); |
| 2041 elms->set(CONFIGURABLE_INDEX, heap->ToBoolean((attrs & DONT_DELETE) == 0)); | 2041 elms->set(CONFIGURABLE_INDEX, heap->ToBoolean((attrs & DONT_DELETE) == 0)); |
| 2042 elms->set(IS_ACCESSOR_INDEX, heap->ToBoolean(has_accessors)); | 2042 elms->set(IS_ACCESSOR_INDEX, heap->ToBoolean(has_accessors)); |
| 2043 | 2043 |
| 2044 if (!has_accessors) { | 2044 if (!has_accessors) { |
| 2045 elms->set(WRITABLE_INDEX, heap->ToBoolean((attrs & READ_ONLY) == 0)); | 2045 elms->set(WRITABLE_INDEX, heap->ToBoolean((attrs & READ_ONLY) == 0)); |
| 2046 // Runtime::GetObjectProperty does access check. | 2046 // Runtime::GetObjectProperty does access check. |
| 2047 Handle<Object> value; | 2047 Handle<Object> value; |
| 2048 ASSIGN_RETURN_ON_EXCEPTION( | 2048 ASSIGN_RETURN_ON_EXCEPTION( |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2270 // assign to it when evaluating the assignment for "const x = | 2270 // assign to it when evaluating the assignment for "const x = |
| 2271 // <expr>" the initial value is the hole. | 2271 // <expr>" the initial value is the hole. |
| 2272 bool is_var = value->IsUndefined(); | 2272 bool is_var = value->IsUndefined(); |
| 2273 bool is_const = value->IsTheHole(); | 2273 bool is_const = value->IsTheHole(); |
| 2274 bool is_function = value->IsSharedFunctionInfo(); | 2274 bool is_function = value->IsSharedFunctionInfo(); |
| 2275 ASSERT(is_var + is_const + is_function == 1); | 2275 ASSERT(is_var + is_const + is_function == 1); |
| 2276 | 2276 |
| 2277 if (is_var || is_const) { | 2277 if (is_var || is_const) { |
| 2278 // Lookup the property in the global object, and don't set the | 2278 // Lookup the property in the global object, and don't set the |
| 2279 // value of the variable if the property is already there. | 2279 // value of the variable if the property is already there. |
| 2280 // Do the lookup locally only, see ES5 erratum. | 2280 // Do the lookup own properties only, see ES5 erratum. |
| 2281 LookupResult lookup(isolate); | 2281 LookupResult lookup(isolate); |
| 2282 global->LocalLookup(name, &lookup, true); | 2282 global->LookupOwn(name, &lookup, true); |
| 2283 if (lookup.IsFound()) { | 2283 if (lookup.IsFound()) { |
| 2284 // We found an existing property. Unless it was an interceptor | 2284 // We found an existing property. Unless it was an interceptor |
| 2285 // that claims the property is absent, skip this declaration. | 2285 // that claims the property is absent, skip this declaration. |
| 2286 if (!lookup.IsInterceptor()) continue; | 2286 if (!lookup.IsInterceptor()) continue; |
| 2287 if (JSReceiver::GetPropertyAttribute(global, name) != ABSENT) continue; | 2287 if (JSReceiver::GetPropertyAttribute(global, name) != ABSENT) continue; |
| 2288 // Fall-through and introduce the absent property by using | 2288 // Fall-through and introduce the absent property by using |
| 2289 // SetProperty. | 2289 // SetProperty. |
| 2290 } | 2290 } |
| 2291 } else if (is_function) { | 2291 } else if (is_function) { |
| 2292 // Copy the function and update its context. Use it as value. | 2292 // Copy the function and update its context. Use it as value. |
| 2293 Handle<SharedFunctionInfo> shared = | 2293 Handle<SharedFunctionInfo> shared = |
| 2294 Handle<SharedFunctionInfo>::cast(value); | 2294 Handle<SharedFunctionInfo>::cast(value); |
| 2295 Handle<JSFunction> function = | 2295 Handle<JSFunction> function = |
| 2296 isolate->factory()->NewFunctionFromSharedFunctionInfo( | 2296 isolate->factory()->NewFunctionFromSharedFunctionInfo( |
| 2297 shared, context, TENURED); | 2297 shared, context, TENURED); |
| 2298 value = function; | 2298 value = function; |
| 2299 } | 2299 } |
| 2300 | 2300 |
| 2301 LookupResult lookup(isolate); | 2301 LookupResult lookup(isolate); |
| 2302 global->LocalLookup(name, &lookup, true); | 2302 global->LookupOwn(name, &lookup, true); |
| 2303 | 2303 |
| 2304 // Compute the property attributes. According to ECMA-262, | 2304 // Compute the property attributes. According to ECMA-262, |
| 2305 // the property must be non-configurable except in eval. | 2305 // the property must be non-configurable except in eval. |
| 2306 int attr = NONE; | 2306 int attr = NONE; |
| 2307 bool is_eval = DeclareGlobalsEvalFlag::decode(flags); | 2307 bool is_eval = DeclareGlobalsEvalFlag::decode(flags); |
| 2308 if (!is_eval) { | 2308 if (!is_eval) { |
| 2309 attr |= DONT_DELETE; | 2309 attr |= DONT_DELETE; |
| 2310 } | 2310 } |
| 2311 bool is_native = DeclareGlobalsNativeFlag::decode(flags); | 2311 bool is_native = DeclareGlobalsNativeFlag::decode(flags); |
| 2312 if (is_const || (is_native && is_function)) { | 2312 if (is_const || (is_native && is_function)) { |
| 2313 attr |= READ_ONLY; | 2313 attr |= READ_ONLY; |
| 2314 } | 2314 } |
| 2315 | 2315 |
| 2316 StrictMode strict_mode = DeclareGlobalsStrictMode::decode(flags); | 2316 StrictMode strict_mode = DeclareGlobalsStrictMode::decode(flags); |
| 2317 | 2317 |
| 2318 if (!lookup.IsFound() || is_function) { | 2318 if (!lookup.IsFound() || is_function) { |
| 2319 // If the local property exists, check that we can reconfigure it | 2319 // If the own property exists, check that we can reconfigure it |
| 2320 // as required for function declarations. | 2320 // as required for function declarations. |
| 2321 if (lookup.IsFound() && lookup.IsDontDelete()) { | 2321 if (lookup.IsFound() && lookup.IsDontDelete()) { |
| 2322 if (lookup.IsReadOnly() || lookup.IsDontEnum() || | 2322 if (lookup.IsReadOnly() || lookup.IsDontEnum() || |
| 2323 lookup.IsPropertyCallbacks()) { | 2323 lookup.IsPropertyCallbacks()) { |
| 2324 return ThrowRedeclarationError(isolate, name); | 2324 return ThrowRedeclarationError(isolate, name); |
| 2325 } | 2325 } |
| 2326 // If the existing property is not configurable, keep its attributes. | 2326 // If the existing property is not configurable, keep its attributes. |
| 2327 attr = lookup.GetAttributes(); | 2327 attr = lookup.GetAttributes(); |
| 2328 } | 2328 } |
| 2329 // Define or redefine own property. | 2329 // Define or redefine own property. |
| 2330 RETURN_FAILURE_ON_EXCEPTION(isolate, | 2330 RETURN_FAILURE_ON_EXCEPTION(isolate, |
| 2331 JSObject::SetLocalPropertyIgnoreAttributes( | 2331 JSObject::SetOwnPropertyIgnoreAttributes( |
| 2332 global, name, value, static_cast<PropertyAttributes>(attr))); | 2332 global, name, value, static_cast<PropertyAttributes>(attr))); |
| 2333 } else { | 2333 } else { |
| 2334 // Do a [[Put]] on the existing (own) property. | 2334 // Do a [[Put]] on the existing (own) property. |
| 2335 RETURN_FAILURE_ON_EXCEPTION( | 2335 RETURN_FAILURE_ON_EXCEPTION( |
| 2336 isolate, | 2336 isolate, |
| 2337 JSObject::SetProperty( | 2337 JSObject::SetProperty( |
| 2338 global, name, value, static_cast<PropertyAttributes>(attr), | 2338 global, name, value, static_cast<PropertyAttributes>(attr), |
| 2339 strict_mode)); | 2339 strict_mode)); |
| 2340 } | 2340 } |
| 2341 } | 2341 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2407 ASSERT(context->IsFunctionContext()); | 2407 ASSERT(context->IsFunctionContext()); |
| 2408 object = isolate->factory()->NewJSObject( | 2408 object = isolate->factory()->NewJSObject( |
| 2409 isolate->context_extension_function()); | 2409 isolate->context_extension_function()); |
| 2410 context->set_extension(*object); | 2410 context->set_extension(*object); |
| 2411 } | 2411 } |
| 2412 ASSERT(*object != NULL); | 2412 ASSERT(*object != NULL); |
| 2413 | 2413 |
| 2414 // Declare the property by setting it to the initial value if provided, | 2414 // Declare the property by setting it to the initial value if provided, |
| 2415 // or undefined, and use the correct mode (e.g. READ_ONLY attribute for | 2415 // or undefined, and use the correct mode (e.g. READ_ONLY attribute for |
| 2416 // constant declarations). | 2416 // constant declarations). |
| 2417 ASSERT(!JSReceiver::HasLocalProperty(object, name)); | 2417 ASSERT(!JSReceiver::HasOwnProperty(object, name)); |
| 2418 Handle<Object> value(isolate->heap()->undefined_value(), isolate); | 2418 Handle<Object> value(isolate->heap()->undefined_value(), isolate); |
| 2419 if (*initial_value != NULL) value = initial_value; | 2419 if (*initial_value != NULL) value = initial_value; |
| 2420 // Declaring a const context slot is a conflicting declaration if | 2420 // Declaring a const context slot is a conflicting declaration if |
| 2421 // there is a callback with that name in a prototype. It is | 2421 // there is a callback with that name in a prototype. It is |
| 2422 // allowed to introduce const variables in | 2422 // allowed to introduce const variables in |
| 2423 // JSContextExtensionObjects. They are treated specially in | 2423 // JSContextExtensionObjects. They are treated specially in |
| 2424 // SetProperty and no setters are invoked for those since they are | 2424 // SetProperty and no setters are invoked for those since they are |
| 2425 // not real JSObjects. | 2425 // not real JSObjects. |
| 2426 if (initial_value->IsTheHole() && | 2426 if (initial_value->IsTheHole() && |
| 2427 !object->IsJSContextExtensionObject()) { | 2427 !object->IsJSContextExtensionObject()) { |
| 2428 LookupResult lookup(isolate); | 2428 LookupResult lookup(isolate); |
| 2429 object->Lookup(name, &lookup); | 2429 object->Lookup(name, &lookup); |
| 2430 if (lookup.IsPropertyCallbacks()) { | 2430 if (lookup.IsPropertyCallbacks()) { |
| 2431 return ThrowRedeclarationError(isolate, name); | 2431 return ThrowRedeclarationError(isolate, name); |
| 2432 } | 2432 } |
| 2433 } | 2433 } |
| 2434 if (object->IsJSGlobalObject()) { | 2434 if (object->IsJSGlobalObject()) { |
| 2435 // Define own property on the global object. | 2435 // Define own property on the global object. |
| 2436 RETURN_FAILURE_ON_EXCEPTION(isolate, | 2436 RETURN_FAILURE_ON_EXCEPTION(isolate, |
| 2437 JSObject::SetLocalPropertyIgnoreAttributes(object, name, value, mode)); | 2437 JSObject::SetOwnPropertyIgnoreAttributes(object, name, value, mode)); |
| 2438 } else { | 2438 } else { |
| 2439 RETURN_FAILURE_ON_EXCEPTION(isolate, | 2439 RETURN_FAILURE_ON_EXCEPTION(isolate, |
| 2440 JSReceiver::SetProperty(object, name, value, mode, SLOPPY)); | 2440 JSReceiver::SetProperty(object, name, value, mode, SLOPPY)); |
| 2441 } | 2441 } |
| 2442 } | 2442 } |
| 2443 | 2443 |
| 2444 return isolate->heap()->undefined_value(); | 2444 return isolate->heap()->undefined_value(); |
| 2445 } | 2445 } |
| 2446 | 2446 |
| 2447 | 2447 |
| 2448 RUNTIME_FUNCTION(Runtime_InitializeVarGlobal) { | 2448 RUNTIME_FUNCTION(Runtime_InitializeVarGlobal) { |
| 2449 HandleScope scope(isolate); | 2449 HandleScope scope(isolate); |
| 2450 // args[0] == name | 2450 // args[0] == name |
| 2451 // args[1] == language_mode | 2451 // args[1] == language_mode |
| 2452 // args[2] == value (optional) | 2452 // args[2] == value (optional) |
| 2453 | 2453 |
| 2454 // Determine if we need to assign to the variable if it already | 2454 // Determine if we need to assign to the variable if it already |
| 2455 // exists (based on the number of arguments). | 2455 // exists (based on the number of arguments). |
| 2456 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3); | 2456 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3); |
| 2457 bool assign = args.length() == 3; | 2457 bool assign = args.length() == 3; |
| 2458 | 2458 |
| 2459 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 2459 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
| 2460 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 1); | 2460 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 1); |
| 2461 | 2461 |
| 2462 // According to ECMA-262, section 12.2, page 62, the property must | 2462 // According to ECMA-262, section 12.2, page 62, the property must |
| 2463 // not be deletable. | 2463 // not be deletable. |
| 2464 PropertyAttributes attributes = DONT_DELETE; | 2464 PropertyAttributes attributes = DONT_DELETE; |
| 2465 | 2465 |
| 2466 // Lookup the property locally in the global object. If it isn't | 2466 // Lookup the property as own on the global object. If it isn't |
| 2467 // there, there is a property with this name in the prototype chain. | 2467 // there, there is a property with this name in the prototype chain. |
| 2468 // We follow Safari and Firefox behavior and only set the property | 2468 // We follow Safari and Firefox behavior and only set the property |
| 2469 // locally if there is an explicit initialization value that we have | 2469 // if there is an explicit initialization value that we have |
| 2470 // to assign to the property. | 2470 // to assign to the property. |
| 2471 // Note that objects can have hidden prototypes, so we need to traverse | 2471 // Note that objects can have hidden prototypes, so we need to traverse |
| 2472 // the whole chain of hidden prototypes to do a 'local' lookup. | 2472 // the whole chain of hidden prototypes to do an 'own' lookup. |
| 2473 LookupResult lookup(isolate); | 2473 LookupResult lookup(isolate); |
| 2474 isolate->context()->global_object()->LocalLookup(name, &lookup, true); | 2474 isolate->context()->global_object()->LookupOwn(name, &lookup, true); |
| 2475 if (lookup.IsInterceptor()) { | 2475 if (lookup.IsInterceptor()) { |
| 2476 Handle<JSObject> holder(lookup.holder()); | 2476 Handle<JSObject> holder(lookup.holder()); |
| 2477 PropertyAttributes intercepted = | 2477 PropertyAttributes intercepted = |
| 2478 JSReceiver::GetPropertyAttribute(holder, name); | 2478 JSReceiver::GetPropertyAttribute(holder, name); |
| 2479 if (intercepted != ABSENT && (intercepted & READ_ONLY) == 0) { | 2479 if (intercepted != ABSENT && (intercepted & READ_ONLY) == 0) { |
| 2480 // Found an interceptor that's not read only. | 2480 // Found an interceptor that's not read only. |
| 2481 if (assign) { | 2481 if (assign) { |
| 2482 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 2482 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
| 2483 Handle<Object> result; | 2483 Handle<Object> result; |
| 2484 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2484 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2515 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); | 2515 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); |
| 2516 | 2516 |
| 2517 // Get the current global object from top. | 2517 // Get the current global object from top. |
| 2518 GlobalObject* global = isolate->context()->global_object(); | 2518 GlobalObject* global = isolate->context()->global_object(); |
| 2519 | 2519 |
| 2520 // According to ECMA-262, section 12.2, page 62, the property must | 2520 // According to ECMA-262, section 12.2, page 62, the property must |
| 2521 // not be deletable. Since it's a const, it must be READ_ONLY too. | 2521 // not be deletable. Since it's a const, it must be READ_ONLY too. |
| 2522 PropertyAttributes attributes = | 2522 PropertyAttributes attributes = |
| 2523 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY); | 2523 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY); |
| 2524 | 2524 |
| 2525 // Lookup the property locally in the global object. If it isn't | 2525 // Lookup the property as own on the global object. If it isn't |
| 2526 // there, we add the property and take special precautions to always | 2526 // there, we add the property and take special precautions to always |
| 2527 // add it as a local property even in case of callbacks in the | 2527 // add it even in case of callbacks in the prototype chain (this rules |
| 2528 // prototype chain (this rules out using SetProperty). | 2528 // out using SetProperty). We use SetOwnPropertyIgnoreAttributes instead |
| 2529 // We use SetLocalPropertyIgnoreAttributes instead | |
| 2530 LookupResult lookup(isolate); | 2529 LookupResult lookup(isolate); |
| 2531 global->LocalLookup(name, &lookup); | 2530 global->LookupOwn(name, &lookup); |
| 2532 if (!lookup.IsFound()) { | 2531 if (!lookup.IsFound()) { |
| 2533 HandleScope handle_scope(isolate); | 2532 HandleScope handle_scope(isolate); |
| 2534 Handle<GlobalObject> global(isolate->context()->global_object()); | 2533 Handle<GlobalObject> global(isolate->context()->global_object()); |
| 2535 RETURN_FAILURE_ON_EXCEPTION( | 2534 RETURN_FAILURE_ON_EXCEPTION( |
| 2536 isolate, | 2535 isolate, |
| 2537 JSObject::SetLocalPropertyIgnoreAttributes(global, name, value, | 2536 JSObject::SetOwnPropertyIgnoreAttributes(global, name, value, |
| 2538 attributes)); | 2537 attributes)); |
| 2539 return *value; | 2538 return *value; |
| 2540 } | 2539 } |
| 2541 | 2540 |
| 2542 if (!lookup.IsReadOnly()) { | 2541 if (!lookup.IsReadOnly()) { |
| 2543 // Restore global object from context (in case of GC) and continue | 2542 // Restore global object from context (in case of GC) and continue |
| 2544 // with setting the value. | 2543 // with setting the value. |
| 2545 HandleScope handle_scope(isolate); | 2544 HandleScope handle_scope(isolate); |
| 2546 Handle<GlobalObject> global(isolate->context()->global_object()); | 2545 Handle<GlobalObject> global(isolate->context()->global_object()); |
| 2547 | 2546 |
| 2548 // BUG 1213575: Handle the case where we have to set a read-only | 2547 // BUG 1213575: Handle the case where we have to set a read-only |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2637 // function f() { eval("delete x; const x;"); } | 2636 // function f() { eval("delete x; const x;"); } |
| 2638 // | 2637 // |
| 2639 // In that case, the initialization behaves like a normal assignment. | 2638 // In that case, the initialization behaves like a normal assignment. |
| 2640 Handle<JSObject> object = Handle<JSObject>::cast(holder); | 2639 Handle<JSObject> object = Handle<JSObject>::cast(holder); |
| 2641 | 2640 |
| 2642 if (*object == context->extension()) { | 2641 if (*object == context->extension()) { |
| 2643 // This is the property that was introduced by the const declaration. | 2642 // This is the property that was introduced by the const declaration. |
| 2644 // Set it if it hasn't been set before. NOTE: We cannot use | 2643 // Set it if it hasn't been set before. NOTE: We cannot use |
| 2645 // GetProperty() to get the current value as it 'unholes' the value. | 2644 // GetProperty() to get the current value as it 'unholes' the value. |
| 2646 LookupResult lookup(isolate); | 2645 LookupResult lookup(isolate); |
| 2647 object->LocalLookupRealNamedProperty(name, &lookup); | 2646 object->LookupOwnRealNamedProperty(name, &lookup); |
| 2648 ASSERT(lookup.IsFound()); // the property was declared | 2647 ASSERT(lookup.IsFound()); // the property was declared |
| 2649 ASSERT(lookup.IsReadOnly()); // and it was declared as read-only | 2648 ASSERT(lookup.IsReadOnly()); // and it was declared as read-only |
| 2650 | 2649 |
| 2651 if (lookup.IsField()) { | 2650 if (lookup.IsField()) { |
| 2652 FixedArray* properties = object->properties(); | 2651 FixedArray* properties = object->properties(); |
| 2653 int index = lookup.GetFieldIndex().field_index(); | 2652 int index = lookup.GetFieldIndex().field_index(); |
| 2654 if (properties->get(index)->IsTheHole()) { | 2653 if (properties->get(index)->IsTheHole()) { |
| 2655 properties->set(index, *value); | 2654 properties->set(index, *value); |
| 2656 } | 2655 } |
| 2657 } else if (lookup.IsNormal()) { | 2656 } else if (lookup.IsNormal()) { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2770 return *regexp; | 2769 return *regexp; |
| 2771 } | 2770 } |
| 2772 | 2771 |
| 2773 // Map has changed, so use generic, but slower, method. | 2772 // Map has changed, so use generic, but slower, method. |
| 2774 PropertyAttributes final = | 2773 PropertyAttributes final = |
| 2775 static_cast<PropertyAttributes>(READ_ONLY | DONT_ENUM | DONT_DELETE); | 2774 static_cast<PropertyAttributes>(READ_ONLY | DONT_ENUM | DONT_DELETE); |
| 2776 PropertyAttributes writable = | 2775 PropertyAttributes writable = |
| 2777 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); | 2776 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); |
| 2778 Handle<Object> zero(Smi::FromInt(0), isolate); | 2777 Handle<Object> zero(Smi::FromInt(0), isolate); |
| 2779 Factory* factory = isolate->factory(); | 2778 Factory* factory = isolate->factory(); |
| 2780 JSObject::SetLocalPropertyIgnoreAttributes( | 2779 JSObject::SetOwnPropertyIgnoreAttributes( |
| 2781 regexp, factory->source_string(), source, final).Check(); | 2780 regexp, factory->source_string(), source, final).Check(); |
| 2782 JSObject::SetLocalPropertyIgnoreAttributes( | 2781 JSObject::SetOwnPropertyIgnoreAttributes( |
| 2783 regexp, factory->global_string(), global, final).Check(); | 2782 regexp, factory->global_string(), global, final).Check(); |
| 2784 JSObject::SetLocalPropertyIgnoreAttributes( | 2783 JSObject::SetOwnPropertyIgnoreAttributes( |
| 2785 regexp, factory->ignore_case_string(), ignoreCase, final).Check(); | 2784 regexp, factory->ignore_case_string(), ignoreCase, final).Check(); |
| 2786 JSObject::SetLocalPropertyIgnoreAttributes( | 2785 JSObject::SetOwnPropertyIgnoreAttributes( |
| 2787 regexp, factory->multiline_string(), multiline, final).Check(); | 2786 regexp, factory->multiline_string(), multiline, final).Check(); |
| 2788 JSObject::SetLocalPropertyIgnoreAttributes( | 2787 JSObject::SetOwnPropertyIgnoreAttributes( |
| 2789 regexp, factory->last_index_string(), zero, writable).Check(); | 2788 regexp, factory->last_index_string(), zero, writable).Check(); |
| 2790 return *regexp; | 2789 return *regexp; |
| 2791 } | 2790 } |
| 2792 | 2791 |
| 2793 | 2792 |
| 2794 RUNTIME_FUNCTION(Runtime_FinishArrayPrototypeSetup) { | 2793 RUNTIME_FUNCTION(Runtime_FinishArrayPrototypeSetup) { |
| 2795 HandleScope scope(isolate); | 2794 HandleScope scope(isolate); |
| 2796 ASSERT(args.length() == 1); | 2795 ASSERT(args.length() == 1); |
| 2797 CONVERT_ARG_HANDLE_CHECKED(JSArray, prototype, 0); | 2796 CONVERT_ARG_HANDLE_CHECKED(JSArray, prototype, 0); |
| 2798 Object* length = prototype->length(); | 2797 Object* length = prototype->length(); |
| (...skipping 2251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5050 RUNTIME_FUNCTION(Runtime_KeyedGetProperty) { | 5049 RUNTIME_FUNCTION(Runtime_KeyedGetProperty) { |
| 5051 HandleScope scope(isolate); | 5050 HandleScope scope(isolate); |
| 5052 ASSERT(args.length() == 2); | 5051 ASSERT(args.length() == 2); |
| 5053 | 5052 |
| 5054 CONVERT_ARG_HANDLE_CHECKED(Object, receiver_obj, 0); | 5053 CONVERT_ARG_HANDLE_CHECKED(Object, receiver_obj, 0); |
| 5055 CONVERT_ARG_HANDLE_CHECKED(Object, key_obj, 1); | 5054 CONVERT_ARG_HANDLE_CHECKED(Object, key_obj, 1); |
| 5056 | 5055 |
| 5057 // Fast cases for getting named properties of the receiver JSObject | 5056 // Fast cases for getting named properties of the receiver JSObject |
| 5058 // itself. | 5057 // itself. |
| 5059 // | 5058 // |
| 5060 // The global proxy objects has to be excluded since LocalLookup on | 5059 // The global proxy objects has to be excluded since LookupOwn on |
| 5061 // the global proxy object can return a valid result even though the | 5060 // the global proxy object can return a valid result even though the |
| 5062 // global proxy object never has properties. This is the case | 5061 // global proxy object never has properties. This is the case |
| 5063 // because the global proxy object forwards everything to its hidden | 5062 // because the global proxy object forwards everything to its hidden |
| 5064 // prototype including local lookups. | 5063 // prototype including own lookups. |
| 5065 // | 5064 // |
| 5066 // Additionally, we need to make sure that we do not cache results | 5065 // Additionally, we need to make sure that we do not cache results |
| 5067 // for objects that require access checks. | 5066 // for objects that require access checks. |
| 5068 if (receiver_obj->IsJSObject()) { | 5067 if (receiver_obj->IsJSObject()) { |
| 5069 if (!receiver_obj->IsJSGlobalProxy() && | 5068 if (!receiver_obj->IsJSGlobalProxy() && |
| 5070 !receiver_obj->IsAccessCheckNeeded() && | 5069 !receiver_obj->IsAccessCheckNeeded() && |
| 5071 key_obj->IsName()) { | 5070 key_obj->IsName()) { |
| 5072 DisallowHeapAllocation no_allocation; | 5071 DisallowHeapAllocation no_allocation; |
| 5073 Handle<JSObject> receiver = Handle<JSObject>::cast(receiver_obj); | 5072 Handle<JSObject> receiver = Handle<JSObject>::cast(receiver_obj); |
| 5074 Handle<Name> key = Handle<Name>::cast(key_obj); | 5073 Handle<Name> key = Handle<Name>::cast(key_obj); |
| 5075 if (receiver->HasFastProperties()) { | 5074 if (receiver->HasFastProperties()) { |
| 5076 // Attempt to use lookup cache. | 5075 // Attempt to use lookup cache. |
| 5077 Handle<Map> receiver_map(receiver->map(), isolate); | 5076 Handle<Map> receiver_map(receiver->map(), isolate); |
| 5078 KeyedLookupCache* keyed_lookup_cache = isolate->keyed_lookup_cache(); | 5077 KeyedLookupCache* keyed_lookup_cache = isolate->keyed_lookup_cache(); |
| 5079 int offset = keyed_lookup_cache->Lookup(receiver_map, key); | 5078 int offset = keyed_lookup_cache->Lookup(receiver_map, key); |
| 5080 if (offset != -1) { | 5079 if (offset != -1) { |
| 5081 // Doubles are not cached, so raw read the value. | 5080 // Doubles are not cached, so raw read the value. |
| 5082 Object* value = receiver->RawFastPropertyAt(offset); | 5081 Object* value = receiver->RawFastPropertyAt(offset); |
| 5083 return value->IsTheHole() | 5082 return value->IsTheHole() |
| 5084 ? isolate->heap()->undefined_value() | 5083 ? isolate->heap()->undefined_value() |
| 5085 : value; | 5084 : value; |
| 5086 } | 5085 } |
| 5087 // Lookup cache miss. Perform lookup and update the cache if | 5086 // Lookup cache miss. Perform lookup and update the cache if |
| 5088 // appropriate. | 5087 // appropriate. |
| 5089 LookupResult result(isolate); | 5088 LookupResult result(isolate); |
| 5090 receiver->LocalLookup(key, &result); | 5089 receiver->LookupOwn(key, &result); |
| 5091 if (result.IsField()) { | 5090 if (result.IsField()) { |
| 5092 int offset = result.GetFieldIndex().field_index(); | 5091 int offset = result.GetFieldIndex().field_index(); |
| 5093 // Do not track double fields in the keyed lookup cache. Reading | 5092 // Do not track double fields in the keyed lookup cache. Reading |
| 5094 // double values requires boxing. | 5093 // double values requires boxing. |
| 5095 if (!result.representation().IsDouble()) { | 5094 if (!result.representation().IsDouble()) { |
| 5096 keyed_lookup_cache->Update(receiver_map, key, offset); | 5095 keyed_lookup_cache->Update(receiver_map, key, offset); |
| 5097 } | 5096 } |
| 5098 AllowHeapAllocation allow_allocation; | 5097 AllowHeapAllocation allow_allocation; |
| 5099 return *JSObject::FastPropertyAt( | 5098 return *JSObject::FastPropertyAt( |
| 5100 receiver, result.representation(), offset); | 5099 receiver, result.representation(), offset); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5205 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 5204 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
| 5206 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); | 5205 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); |
| 5207 | 5206 |
| 5208 // Check access rights if needed. | 5207 // Check access rights if needed. |
| 5209 if (js_object->IsAccessCheckNeeded() && | 5208 if (js_object->IsAccessCheckNeeded() && |
| 5210 !isolate->MayNamedAccess(js_object, name, v8::ACCESS_SET)) { | 5209 !isolate->MayNamedAccess(js_object, name, v8::ACCESS_SET)) { |
| 5211 return isolate->heap()->undefined_value(); | 5210 return isolate->heap()->undefined_value(); |
| 5212 } | 5211 } |
| 5213 | 5212 |
| 5214 LookupResult lookup(isolate); | 5213 LookupResult lookup(isolate); |
| 5215 js_object->LocalLookupRealNamedProperty(name, &lookup); | 5214 js_object->LookupOwnRealNamedProperty(name, &lookup); |
| 5216 | 5215 |
| 5217 // Special case for callback properties. | 5216 // Special case for callback properties. |
| 5218 if (lookup.IsPropertyCallbacks()) { | 5217 if (lookup.IsPropertyCallbacks()) { |
| 5219 Handle<Object> callback(lookup.GetCallbackObject(), isolate); | 5218 Handle<Object> callback(lookup.GetCallbackObject(), isolate); |
| 5220 // Avoid redefining callback as data property, just use the stored | 5219 // Avoid redefining callback as data property, just use the stored |
| 5221 // setter to update the value instead. | 5220 // setter to update the value instead. |
| 5222 // TODO(mstarzinger): So far this only works if property attributes don't | 5221 // TODO(mstarzinger): So far this only works if property attributes don't |
| 5223 // change, this should be fixed once we cleanup the underlying code. | 5222 // change, this should be fixed once we cleanup the underlying code. |
| 5224 ASSERT(!callback->IsForeign()); | 5223 ASSERT(!callback->IsForeign()); |
| 5225 if (callback->IsAccessorInfo() && | 5224 if (callback->IsAccessorInfo() && |
| (...skipping 24 matching lines...) Expand all Loading... |
| 5250 // Since the result is a property, the prototype will exist so | 5249 // Since the result is a property, the prototype will exist so |
| 5251 // we don't have to check for null. | 5250 // we don't have to check for null. |
| 5252 js_object = Handle<JSObject>(JSObject::cast(js_object->GetPrototype())); | 5251 js_object = Handle<JSObject>(JSObject::cast(js_object->GetPrototype())); |
| 5253 } | 5252 } |
| 5254 JSObject::NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0); | 5253 JSObject::NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0); |
| 5255 // Use IgnoreAttributes version since a readonly property may be | 5254 // Use IgnoreAttributes version since a readonly property may be |
| 5256 // overridden and SetProperty does not allow this. | 5255 // overridden and SetProperty does not allow this. |
| 5257 Handle<Object> result; | 5256 Handle<Object> result; |
| 5258 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 5257 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 5259 isolate, result, | 5258 isolate, result, |
| 5260 JSObject::SetLocalPropertyIgnoreAttributes( | 5259 JSObject::SetOwnPropertyIgnoreAttributes( |
| 5261 js_object, name, obj_value, attr)); | 5260 js_object, name, obj_value, attr)); |
| 5262 return *result; | 5261 return *result; |
| 5263 } | 5262 } |
| 5264 | 5263 |
| 5265 Handle<Object> result; | 5264 Handle<Object> result; |
| 5266 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 5265 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 5267 isolate, result, | 5266 isolate, result, |
| 5268 Runtime::ForceSetObjectProperty( | 5267 Runtime::ForceSetObjectProperty( |
| 5269 js_object, name, obj_value, attr, | 5268 js_object, name, obj_value, attr, |
| 5270 JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED)); | 5269 JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED)); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5404 SLOPPY, false, DEFINE_PROPERTY); | 5403 SLOPPY, false, DEFINE_PROPERTY); |
| 5405 } | 5404 } |
| 5406 | 5405 |
| 5407 if (key->IsName()) { | 5406 if (key->IsName()) { |
| 5408 Handle<Name> name = Handle<Name>::cast(key); | 5407 Handle<Name> name = Handle<Name>::cast(key); |
| 5409 if (name->AsArrayIndex(&index)) { | 5408 if (name->AsArrayIndex(&index)) { |
| 5410 return JSObject::SetElement(js_object, index, value, attr, | 5409 return JSObject::SetElement(js_object, index, value, attr, |
| 5411 SLOPPY, false, DEFINE_PROPERTY); | 5410 SLOPPY, false, DEFINE_PROPERTY); |
| 5412 } else { | 5411 } else { |
| 5413 if (name->IsString()) name = String::Flatten(Handle<String>::cast(name)); | 5412 if (name->IsString()) name = String::Flatten(Handle<String>::cast(name)); |
| 5414 return JSObject::SetLocalPropertyIgnoreAttributes( | 5413 return JSObject::SetOwnPropertyIgnoreAttributes( |
| 5415 js_object, name, value, attr, Object::OPTIMAL_REPRESENTATION, | 5414 js_object, name, value, attr, Object::OPTIMAL_REPRESENTATION, |
| 5416 ALLOW_AS_CONSTANT, JSReceiver::PERFORM_EXTENSIBILITY_CHECK, | 5415 ALLOW_AS_CONSTANT, JSReceiver::PERFORM_EXTENSIBILITY_CHECK, |
| 5417 store_from_keyed); | 5416 store_from_keyed); |
| 5418 } | 5417 } |
| 5419 } | 5418 } |
| 5420 | 5419 |
| 5421 // Call-back into JavaScript to convert the key to a string. | 5420 // Call-back into JavaScript to convert the key to a string. |
| 5422 Handle<Object> converted; | 5421 Handle<Object> converted; |
| 5423 ASSIGN_RETURN_ON_EXCEPTION( | 5422 ASSIGN_RETURN_ON_EXCEPTION( |
| 5424 isolate, converted, Execution::ToString(isolate, key), Object); | 5423 isolate, converted, Execution::ToString(isolate, key), Object); |
| 5425 Handle<String> name = Handle<String>::cast(converted); | 5424 Handle<String> name = Handle<String>::cast(converted); |
| 5426 | 5425 |
| 5427 if (name->AsArrayIndex(&index)) { | 5426 if (name->AsArrayIndex(&index)) { |
| 5428 return JSObject::SetElement(js_object, index, value, attr, | 5427 return JSObject::SetElement(js_object, index, value, attr, |
| 5429 SLOPPY, false, DEFINE_PROPERTY); | 5428 SLOPPY, false, DEFINE_PROPERTY); |
| 5430 } else { | 5429 } else { |
| 5431 return JSObject::SetLocalPropertyIgnoreAttributes( | 5430 return JSObject::SetOwnPropertyIgnoreAttributes( |
| 5432 js_object, name, value, attr, Object::OPTIMAL_REPRESENTATION, | 5431 js_object, name, value, attr, Object::OPTIMAL_REPRESENTATION, |
| 5433 ALLOW_AS_CONSTANT, JSReceiver::PERFORM_EXTENSIBILITY_CHECK, | 5432 ALLOW_AS_CONSTANT, JSReceiver::PERFORM_EXTENSIBILITY_CHECK, |
| 5434 store_from_keyed); | 5433 store_from_keyed); |
| 5435 } | 5434 } |
| 5436 } | 5435 } |
| 5437 | 5436 |
| 5438 | 5437 |
| 5439 MaybeHandle<Object> Runtime::DeleteObjectProperty(Isolate* isolate, | 5438 MaybeHandle<Object> Runtime::DeleteObjectProperty(Isolate* isolate, |
| 5440 Handle<JSReceiver> receiver, | 5439 Handle<JSReceiver> receiver, |
| 5441 Handle<Object> key, | 5440 Handle<Object> key, |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5654 | 5653 |
| 5655 | 5654 |
| 5656 RUNTIME_FUNCTION(Runtime_DebugPromiseHandleEpilogue) { | 5655 RUNTIME_FUNCTION(Runtime_DebugPromiseHandleEpilogue) { |
| 5657 ASSERT(args.length() == 0); | 5656 ASSERT(args.length() == 0); |
| 5658 SealHandleScope shs(isolate); | 5657 SealHandleScope shs(isolate); |
| 5659 isolate->debug()->PromiseHandleEpilogue(); | 5658 isolate->debug()->PromiseHandleEpilogue(); |
| 5660 return isolate->heap()->undefined_value(); | 5659 return isolate->heap()->undefined_value(); |
| 5661 } | 5660 } |
| 5662 | 5661 |
| 5663 | 5662 |
| 5664 // Set a local property, even if it is READ_ONLY. If the property does not | 5663 // Set an own property, even if it is READ_ONLY. If the property does not |
| 5665 // exist, it will be added with attributes NONE. | 5664 // exist, it will be added with attributes NONE. |
| 5666 RUNTIME_FUNCTION(Runtime_IgnoreAttributesAndSetProperty) { | 5665 RUNTIME_FUNCTION(Runtime_IgnoreAttributesAndSetProperty) { |
| 5667 HandleScope scope(isolate); | 5666 HandleScope scope(isolate); |
| 5668 RUNTIME_ASSERT(args.length() == 3 || args.length() == 4); | 5667 RUNTIME_ASSERT(args.length() == 3 || args.length() == 4); |
| 5669 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 5668 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 5670 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 5669 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| 5671 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 5670 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
| 5672 // Compute attributes. | 5671 // Compute attributes. |
| 5673 PropertyAttributes attributes = NONE; | 5672 PropertyAttributes attributes = NONE; |
| 5674 if (args.length() == 4) { | 5673 if (args.length() == 4) { |
| 5675 CONVERT_SMI_ARG_CHECKED(unchecked_value, 3); | 5674 CONVERT_SMI_ARG_CHECKED(unchecked_value, 3); |
| 5676 // Only attribute bits should be set. | 5675 // Only attribute bits should be set. |
| 5677 RUNTIME_ASSERT( | 5676 RUNTIME_ASSERT( |
| 5678 (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 5677 (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
| 5679 attributes = static_cast<PropertyAttributes>(unchecked_value); | 5678 attributes = static_cast<PropertyAttributes>(unchecked_value); |
| 5680 } | 5679 } |
| 5681 Handle<Object> result; | 5680 Handle<Object> result; |
| 5682 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 5681 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 5683 isolate, result, | 5682 isolate, result, |
| 5684 JSObject::SetLocalPropertyIgnoreAttributes( | 5683 JSObject::SetOwnPropertyIgnoreAttributes( |
| 5685 object, name, value, attributes)); | 5684 object, name, value, attributes)); |
| 5686 return *result; | 5685 return *result; |
| 5687 } | 5686 } |
| 5688 | 5687 |
| 5689 | 5688 |
| 5690 RUNTIME_FUNCTION(Runtime_DeleteProperty) { | 5689 RUNTIME_FUNCTION(Runtime_DeleteProperty) { |
| 5691 HandleScope scope(isolate); | 5690 HandleScope scope(isolate); |
| 5692 ASSERT(args.length() == 3); | 5691 ASSERT(args.length() == 3); |
| 5693 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); | 5692 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); |
| 5694 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); | 5693 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); |
| 5695 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 2); | 5694 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 2); |
| 5696 JSReceiver::DeleteMode delete_mode = strict_mode == STRICT | 5695 JSReceiver::DeleteMode delete_mode = strict_mode == STRICT |
| 5697 ? JSReceiver::STRICT_DELETION : JSReceiver::NORMAL_DELETION; | 5696 ? JSReceiver::STRICT_DELETION : JSReceiver::NORMAL_DELETION; |
| 5698 Handle<Object> result; | 5697 Handle<Object> result; |
| 5699 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 5698 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 5700 isolate, result, | 5699 isolate, result, |
| 5701 JSReceiver::DeleteProperty(object, key, delete_mode)); | 5700 JSReceiver::DeleteProperty(object, key, delete_mode)); |
| 5702 return *result; | 5701 return *result; |
| 5703 } | 5702 } |
| 5704 | 5703 |
| 5705 | 5704 |
| 5706 static Object* HasLocalPropertyImplementation(Isolate* isolate, | 5705 static Object* HasOwnPropertyImplementation(Isolate* isolate, |
| 5707 Handle<JSObject> object, | 5706 Handle<JSObject> object, |
| 5708 Handle<Name> key) { | 5707 Handle<Name> key) { |
| 5709 if (JSReceiver::HasLocalProperty(object, key)) { | 5708 if (JSReceiver::HasOwnProperty(object, key)) { |
| 5710 return isolate->heap()->true_value(); | 5709 return isolate->heap()->true_value(); |
| 5711 } | 5710 } |
| 5712 // Handle hidden prototypes. If there's a hidden prototype above this thing | 5711 // Handle hidden prototypes. If there's a hidden prototype above this thing |
| 5713 // then we have to check it for properties, because they are supposed to | 5712 // then we have to check it for properties, because they are supposed to |
| 5714 // look like they are on this object. | 5713 // look like they are on this object. |
| 5715 Handle<Object> proto(object->GetPrototype(), isolate); | 5714 Handle<Object> proto(object->GetPrototype(), isolate); |
| 5716 if (proto->IsJSObject() && | 5715 if (proto->IsJSObject() && |
| 5717 Handle<JSObject>::cast(proto)->map()->is_hidden_prototype()) { | 5716 Handle<JSObject>::cast(proto)->map()->is_hidden_prototype()) { |
| 5718 return HasLocalPropertyImplementation(isolate, | 5717 return HasOwnPropertyImplementation(isolate, |
| 5719 Handle<JSObject>::cast(proto), | 5718 Handle<JSObject>::cast(proto), |
| 5720 key); | 5719 key); |
| 5721 } | 5720 } |
| 5722 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 5721 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
| 5723 return isolate->heap()->false_value(); | 5722 return isolate->heap()->false_value(); |
| 5724 } | 5723 } |
| 5725 | 5724 |
| 5726 | 5725 |
| 5727 RUNTIME_FUNCTION(Runtime_HasLocalProperty) { | 5726 RUNTIME_FUNCTION(Runtime_HasOwnProperty) { |
| 5728 HandleScope scope(isolate); | 5727 HandleScope scope(isolate); |
| 5729 ASSERT(args.length() == 2); | 5728 ASSERT(args.length() == 2); |
| 5730 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0) | 5729 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0) |
| 5731 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); | 5730 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); |
| 5732 | 5731 |
| 5733 uint32_t index; | 5732 uint32_t index; |
| 5734 const bool key_is_array_index = key->AsArrayIndex(&index); | 5733 const bool key_is_array_index = key->AsArrayIndex(&index); |
| 5735 | 5734 |
| 5736 // Only JS objects can have properties. | 5735 // Only JS objects can have properties. |
| 5737 if (object->IsJSObject()) { | 5736 if (object->IsJSObject()) { |
| 5738 Handle<JSObject> js_obj = Handle<JSObject>::cast(object); | 5737 Handle<JSObject> js_obj = Handle<JSObject>::cast(object); |
| 5739 // Fast case: either the key is a real named property or it is not | 5738 // Fast case: either the key is a real named property or it is not |
| 5740 // an array index and there are no interceptors or hidden | 5739 // an array index and there are no interceptors or hidden |
| 5741 // prototypes. | 5740 // prototypes. |
| 5742 if (JSObject::HasRealNamedProperty(js_obj, key)) { | 5741 if (JSObject::HasRealNamedProperty(js_obj, key)) { |
| 5743 ASSERT(!isolate->has_scheduled_exception()); | 5742 ASSERT(!isolate->has_scheduled_exception()); |
| 5744 return isolate->heap()->true_value(); | 5743 return isolate->heap()->true_value(); |
| 5745 } else { | 5744 } else { |
| 5746 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 5745 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
| 5747 } | 5746 } |
| 5748 Map* map = js_obj->map(); | 5747 Map* map = js_obj->map(); |
| 5749 if (!key_is_array_index && | 5748 if (!key_is_array_index && |
| 5750 !map->has_named_interceptor() && | 5749 !map->has_named_interceptor() && |
| 5751 !HeapObject::cast(map->prototype())->map()->is_hidden_prototype()) { | 5750 !HeapObject::cast(map->prototype())->map()->is_hidden_prototype()) { |
| 5752 return isolate->heap()->false_value(); | 5751 return isolate->heap()->false_value(); |
| 5753 } | 5752 } |
| 5754 // Slow case. | 5753 // Slow case. |
| 5755 return HasLocalPropertyImplementation(isolate, | 5754 return HasOwnPropertyImplementation(isolate, |
| 5756 Handle<JSObject>(js_obj), | 5755 Handle<JSObject>(js_obj), |
| 5757 Handle<Name>(key)); | 5756 Handle<Name>(key)); |
| 5758 } else if (object->IsString() && key_is_array_index) { | 5757 } else if (object->IsString() && key_is_array_index) { |
| 5759 // Well, there is one exception: Handle [] on strings. | 5758 // Well, there is one exception: Handle [] on strings. |
| 5760 Handle<String> string = Handle<String>::cast(object); | 5759 Handle<String> string = Handle<String>::cast(object); |
| 5761 if (index < static_cast<uint32_t>(string->length())) { | 5760 if (index < static_cast<uint32_t>(string->length())) { |
| 5762 return isolate->heap()->true_value(); | 5761 return isolate->heap()->true_value(); |
| 5763 } | 5762 } |
| 5764 } | 5763 } |
| 5765 return isolate->heap()->false_value(); | 5764 return isolate->heap()->false_value(); |
| 5766 } | 5765 } |
| 5767 | 5766 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 5791 } | 5790 } |
| 5792 | 5791 |
| 5793 | 5792 |
| 5794 RUNTIME_FUNCTION(Runtime_IsPropertyEnumerable) { | 5793 RUNTIME_FUNCTION(Runtime_IsPropertyEnumerable) { |
| 5795 HandleScope scope(isolate); | 5794 HandleScope scope(isolate); |
| 5796 ASSERT(args.length() == 2); | 5795 ASSERT(args.length() == 2); |
| 5797 | 5796 |
| 5798 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 5797 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 5799 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); | 5798 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); |
| 5800 | 5799 |
| 5801 PropertyAttributes att = JSReceiver::GetLocalPropertyAttribute(object, key); | 5800 PropertyAttributes att = JSReceiver::GetOwnPropertyAttribute(object, key); |
| 5802 if (att == ABSENT || (att & DONT_ENUM) != 0) { | 5801 if (att == ABSENT || (att & DONT_ENUM) != 0) { |
| 5803 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 5802 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
| 5804 return isolate->heap()->false_value(); | 5803 return isolate->heap()->false_value(); |
| 5805 } | 5804 } |
| 5806 ASSERT(!isolate->has_scheduled_exception()); | 5805 ASSERT(!isolate->has_scheduled_exception()); |
| 5807 return isolate->heap()->true_value(); | 5806 return isolate->heap()->true_value(); |
| 5808 } | 5807 } |
| 5809 | 5808 |
| 5810 | 5809 |
| 5811 RUNTIME_FUNCTION(Runtime_GetPropertyNames) { | 5810 RUNTIME_FUNCTION(Runtime_GetPropertyNames) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5843 isolate, content, | 5842 isolate, content, |
| 5844 JSReceiver::GetKeys(object, JSReceiver::INCLUDE_PROTOS)); | 5843 JSReceiver::GetKeys(object, JSReceiver::INCLUDE_PROTOS)); |
| 5845 | 5844 |
| 5846 // Test again, since cache may have been built by preceding call. | 5845 // Test again, since cache may have been built by preceding call. |
| 5847 if (object->IsSimpleEnum()) return object->map(); | 5846 if (object->IsSimpleEnum()) return object->map(); |
| 5848 | 5847 |
| 5849 return *content; | 5848 return *content; |
| 5850 } | 5849 } |
| 5851 | 5850 |
| 5852 | 5851 |
| 5853 // Find the length of the prototype chain that is to to handled as one. If a | 5852 // Find the length of the prototype chain that is to be handled as one. If a |
| 5854 // prototype object is hidden it is to be viewed as part of the the object it | 5853 // prototype object is hidden it is to be viewed as part of the the object it |
| 5855 // is prototype for. | 5854 // is prototype for. |
| 5856 static int LocalPrototypeChainLength(JSObject* obj) { | 5855 static int OwnPrototypeChainLength(JSObject* obj) { |
| 5857 int count = 1; | 5856 int count = 1; |
| 5858 Object* proto = obj->GetPrototype(); | 5857 Object* proto = obj->GetPrototype(); |
| 5859 while (proto->IsJSObject() && | 5858 while (proto->IsJSObject() && |
| 5860 JSObject::cast(proto)->map()->is_hidden_prototype()) { | 5859 JSObject::cast(proto)->map()->is_hidden_prototype()) { |
| 5861 count++; | 5860 count++; |
| 5862 proto = JSObject::cast(proto)->GetPrototype(); | 5861 proto = JSObject::cast(proto)->GetPrototype(); |
| 5863 } | 5862 } |
| 5864 return count; | 5863 return count; |
| 5865 } | 5864 } |
| 5866 | 5865 |
| 5867 | 5866 |
| 5868 // Return the names of the local named properties. | 5867 // Return the names of the own named properties. |
| 5869 // args[0]: object | 5868 // args[0]: object |
| 5870 // args[1]: PropertyAttributes as int | 5869 // args[1]: PropertyAttributes as int |
| 5871 RUNTIME_FUNCTION(Runtime_GetLocalPropertyNames) { | 5870 RUNTIME_FUNCTION(Runtime_GetOwnPropertyNames) { |
| 5872 HandleScope scope(isolate); | 5871 HandleScope scope(isolate); |
| 5873 ASSERT(args.length() == 2); | 5872 ASSERT(args.length() == 2); |
| 5874 if (!args[0]->IsJSObject()) { | 5873 if (!args[0]->IsJSObject()) { |
| 5875 return isolate->heap()->undefined_value(); | 5874 return isolate->heap()->undefined_value(); |
| 5876 } | 5875 } |
| 5877 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 5876 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
| 5878 CONVERT_SMI_ARG_CHECKED(filter_value, 1); | 5877 CONVERT_SMI_ARG_CHECKED(filter_value, 1); |
| 5879 PropertyAttributes filter = static_cast<PropertyAttributes>(filter_value); | 5878 PropertyAttributes filter = static_cast<PropertyAttributes>(filter_value); |
| 5880 | 5879 |
| 5881 // Skip the global proxy as it has no properties and always delegates to the | 5880 // Skip the global proxy as it has no properties and always delegates to the |
| 5882 // real global object. | 5881 // real global object. |
| 5883 if (obj->IsJSGlobalProxy()) { | 5882 if (obj->IsJSGlobalProxy()) { |
| 5884 // Only collect names if access is permitted. | 5883 // Only collect names if access is permitted. |
| 5885 if (obj->IsAccessCheckNeeded() && | 5884 if (obj->IsAccessCheckNeeded() && |
| 5886 !isolate->MayNamedAccess( | 5885 !isolate->MayNamedAccess( |
| 5887 obj, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) { | 5886 obj, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) { |
| 5888 isolate->ReportFailedAccessCheck(obj, v8::ACCESS_KEYS); | 5887 isolate->ReportFailedAccessCheck(obj, v8::ACCESS_KEYS); |
| 5889 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 5888 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
| 5890 return *isolate->factory()->NewJSArray(0); | 5889 return *isolate->factory()->NewJSArray(0); |
| 5891 } | 5890 } |
| 5892 obj = Handle<JSObject>(JSObject::cast(obj->GetPrototype())); | 5891 obj = Handle<JSObject>(JSObject::cast(obj->GetPrototype())); |
| 5893 } | 5892 } |
| 5894 | 5893 |
| 5895 // Find the number of objects making up this. | 5894 // Find the number of objects making up this. |
| 5896 int length = LocalPrototypeChainLength(*obj); | 5895 int length = OwnPrototypeChainLength(*obj); |
| 5897 | 5896 |
| 5898 // Find the number of local properties for each of the objects. | 5897 // Find the number of own properties for each of the objects. |
| 5899 ScopedVector<int> local_property_count(length); | 5898 ScopedVector<int> own_property_count(length); |
| 5900 int total_property_count = 0; | 5899 int total_property_count = 0; |
| 5901 Handle<JSObject> jsproto = obj; | 5900 Handle<JSObject> jsproto = obj; |
| 5902 for (int i = 0; i < length; i++) { | 5901 for (int i = 0; i < length; i++) { |
| 5903 // Only collect names if access is permitted. | 5902 // Only collect names if access is permitted. |
| 5904 if (jsproto->IsAccessCheckNeeded() && | 5903 if (jsproto->IsAccessCheckNeeded() && |
| 5905 !isolate->MayNamedAccess( | 5904 !isolate->MayNamedAccess( |
| 5906 jsproto, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) { | 5905 jsproto, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) { |
| 5907 isolate->ReportFailedAccessCheck(jsproto, v8::ACCESS_KEYS); | 5906 isolate->ReportFailedAccessCheck(jsproto, v8::ACCESS_KEYS); |
| 5908 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 5907 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
| 5909 return *isolate->factory()->NewJSArray(0); | 5908 return *isolate->factory()->NewJSArray(0); |
| 5910 } | 5909 } |
| 5911 int n; | 5910 int n; |
| 5912 n = jsproto->NumberOfLocalProperties(filter); | 5911 n = jsproto->NumberOfOwnProperties(filter); |
| 5913 local_property_count[i] = n; | 5912 own_property_count[i] = n; |
| 5914 total_property_count += n; | 5913 total_property_count += n; |
| 5915 if (i < length - 1) { | 5914 if (i < length - 1) { |
| 5916 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); | 5915 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); |
| 5917 } | 5916 } |
| 5918 } | 5917 } |
| 5919 | 5918 |
| 5920 // Allocate an array with storage for all the property names. | 5919 // Allocate an array with storage for all the property names. |
| 5921 Handle<FixedArray> names = | 5920 Handle<FixedArray> names = |
| 5922 isolate->factory()->NewFixedArray(total_property_count); | 5921 isolate->factory()->NewFixedArray(total_property_count); |
| 5923 | 5922 |
| 5924 // Get the property names. | 5923 // Get the property names. |
| 5925 jsproto = obj; | 5924 jsproto = obj; |
| 5926 int next_copy_index = 0; | 5925 int next_copy_index = 0; |
| 5927 int hidden_strings = 0; | 5926 int hidden_strings = 0; |
| 5928 for (int i = 0; i < length; i++) { | 5927 for (int i = 0; i < length; i++) { |
| 5929 jsproto->GetLocalPropertyNames(*names, next_copy_index, filter); | 5928 jsproto->GetOwnPropertyNames(*names, next_copy_index, filter); |
| 5930 if (i > 0) { | 5929 if (i > 0) { |
| 5931 // Names from hidden prototypes may already have been added | 5930 // Names from hidden prototypes may already have been added |
| 5932 // for inherited function template instances. Count the duplicates | 5931 // for inherited function template instances. Count the duplicates |
| 5933 // and stub them out; the final copy pass at the end ignores holes. | 5932 // and stub them out; the final copy pass at the end ignores holes. |
| 5934 for (int j = next_copy_index; | 5933 for (int j = next_copy_index; |
| 5935 j < next_copy_index + local_property_count[i]; | 5934 j < next_copy_index + own_property_count[i]; |
| 5936 j++) { | 5935 j++) { |
| 5937 Object* name_from_hidden_proto = names->get(j); | 5936 Object* name_from_hidden_proto = names->get(j); |
| 5938 for (int k = 0; k < next_copy_index; k++) { | 5937 for (int k = 0; k < next_copy_index; k++) { |
| 5939 if (names->get(k) != isolate->heap()->hidden_string()) { | 5938 if (names->get(k) != isolate->heap()->hidden_string()) { |
| 5940 Object* name = names->get(k); | 5939 Object* name = names->get(k); |
| 5941 if (name_from_hidden_proto == name) { | 5940 if (name_from_hidden_proto == name) { |
| 5942 names->set(j, isolate->heap()->hidden_string()); | 5941 names->set(j, isolate->heap()->hidden_string()); |
| 5943 hidden_strings++; | 5942 hidden_strings++; |
| 5944 break; | 5943 break; |
| 5945 } | 5944 } |
| 5946 } | 5945 } |
| 5947 } | 5946 } |
| 5948 } | 5947 } |
| 5949 } | 5948 } |
| 5950 next_copy_index += local_property_count[i]; | 5949 next_copy_index += own_property_count[i]; |
| 5951 | 5950 |
| 5952 // Hidden properties only show up if the filter does not skip strings. | 5951 // Hidden properties only show up if the filter does not skip strings. |
| 5953 if ((filter & STRING) == 0 && JSObject::HasHiddenProperties(jsproto)) { | 5952 if ((filter & STRING) == 0 && JSObject::HasHiddenProperties(jsproto)) { |
| 5954 hidden_strings++; | 5953 hidden_strings++; |
| 5955 } | 5954 } |
| 5956 if (i < length - 1) { | 5955 if (i < length - 1) { |
| 5957 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); | 5956 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); |
| 5958 } | 5957 } |
| 5959 } | 5958 } |
| 5960 | 5959 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 5973 } | 5972 } |
| 5974 names->set(dest_pos++, name); | 5973 names->set(dest_pos++, name); |
| 5975 } | 5974 } |
| 5976 ASSERT_EQ(0, hidden_strings); | 5975 ASSERT_EQ(0, hidden_strings); |
| 5977 } | 5976 } |
| 5978 | 5977 |
| 5979 return *isolate->factory()->NewJSArrayWithElements(names); | 5978 return *isolate->factory()->NewJSArrayWithElements(names); |
| 5980 } | 5979 } |
| 5981 | 5980 |
| 5982 | 5981 |
| 5983 // Return the names of the local indexed properties. | 5982 // Return the names of the own indexed properties. |
| 5984 // args[0]: object | 5983 // args[0]: object |
| 5985 RUNTIME_FUNCTION(Runtime_GetLocalElementNames) { | 5984 RUNTIME_FUNCTION(Runtime_GetOwnElementNames) { |
| 5986 HandleScope scope(isolate); | 5985 HandleScope scope(isolate); |
| 5987 ASSERT(args.length() == 1); | 5986 ASSERT(args.length() == 1); |
| 5988 if (!args[0]->IsJSObject()) { | 5987 if (!args[0]->IsJSObject()) { |
| 5989 return isolate->heap()->undefined_value(); | 5988 return isolate->heap()->undefined_value(); |
| 5990 } | 5989 } |
| 5991 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 5990 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
| 5992 | 5991 |
| 5993 int n = obj->NumberOfLocalElements(static_cast<PropertyAttributes>(NONE)); | 5992 int n = obj->NumberOfOwnElements(static_cast<PropertyAttributes>(NONE)); |
| 5994 Handle<FixedArray> names = isolate->factory()->NewFixedArray(n); | 5993 Handle<FixedArray> names = isolate->factory()->NewFixedArray(n); |
| 5995 obj->GetLocalElementKeys(*names, static_cast<PropertyAttributes>(NONE)); | 5994 obj->GetOwnElementKeys(*names, static_cast<PropertyAttributes>(NONE)); |
| 5996 return *isolate->factory()->NewJSArrayWithElements(names); | 5995 return *isolate->factory()->NewJSArrayWithElements(names); |
| 5997 } | 5996 } |
| 5998 | 5997 |
| 5999 | 5998 |
| 6000 // Return information on whether an object has a named or indexed interceptor. | 5999 // Return information on whether an object has a named or indexed interceptor. |
| 6001 // args[0]: object | 6000 // args[0]: object |
| 6002 RUNTIME_FUNCTION(Runtime_GetInterceptorInfo) { | 6001 RUNTIME_FUNCTION(Runtime_GetInterceptorInfo) { |
| 6003 HandleScope scope(isolate); | 6002 HandleScope scope(isolate); |
| 6004 ASSERT(args.length() == 1); | 6003 ASSERT(args.length() == 1); |
| 6005 if (!args[0]->IsJSObject()) { | 6004 if (!args[0]->IsJSObject()) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6042 if (obj->HasIndexedInterceptor()) { | 6041 if (obj->HasIndexedInterceptor()) { |
| 6043 Handle<JSObject> result; | 6042 Handle<JSObject> result; |
| 6044 if (JSObject::GetKeysForIndexedInterceptor(obj, obj).ToHandle(&result)) { | 6043 if (JSObject::GetKeysForIndexedInterceptor(obj, obj).ToHandle(&result)) { |
| 6045 return *result; | 6044 return *result; |
| 6046 } | 6045 } |
| 6047 } | 6046 } |
| 6048 return isolate->heap()->undefined_value(); | 6047 return isolate->heap()->undefined_value(); |
| 6049 } | 6048 } |
| 6050 | 6049 |
| 6051 | 6050 |
| 6052 RUNTIME_FUNCTION(Runtime_LocalKeys) { | 6051 RUNTIME_FUNCTION(Runtime_OwnKeys) { |
| 6053 HandleScope scope(isolate); | 6052 HandleScope scope(isolate); |
| 6054 ASSERT(args.length() == 1); | 6053 ASSERT(args.length() == 1); |
| 6055 CONVERT_ARG_CHECKED(JSObject, raw_object, 0); | 6054 CONVERT_ARG_CHECKED(JSObject, raw_object, 0); |
| 6056 Handle<JSObject> object(raw_object); | 6055 Handle<JSObject> object(raw_object); |
| 6057 | 6056 |
| 6058 if (object->IsJSGlobalProxy()) { | 6057 if (object->IsJSGlobalProxy()) { |
| 6059 // Do access checks before going to the global object. | 6058 // Do access checks before going to the global object. |
| 6060 if (object->IsAccessCheckNeeded() && | 6059 if (object->IsAccessCheckNeeded() && |
| 6061 !isolate->MayNamedAccess( | 6060 !isolate->MayNamedAccess( |
| 6062 object, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) { | 6061 object, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) { |
| 6063 isolate->ReportFailedAccessCheck(object, v8::ACCESS_KEYS); | 6062 isolate->ReportFailedAccessCheck(object, v8::ACCESS_KEYS); |
| 6064 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 6063 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
| 6065 return *isolate->factory()->NewJSArray(0); | 6064 return *isolate->factory()->NewJSArray(0); |
| 6066 } | 6065 } |
| 6067 | 6066 |
| 6068 Handle<Object> proto(object->GetPrototype(), isolate); | 6067 Handle<Object> proto(object->GetPrototype(), isolate); |
| 6069 // If proxy is detached we simply return an empty array. | 6068 // If proxy is detached we simply return an empty array. |
| 6070 if (proto->IsNull()) return *isolate->factory()->NewJSArray(0); | 6069 if (proto->IsNull()) return *isolate->factory()->NewJSArray(0); |
| 6071 object = Handle<JSObject>::cast(proto); | 6070 object = Handle<JSObject>::cast(proto); |
| 6072 } | 6071 } |
| 6073 | 6072 |
| 6074 Handle<FixedArray> contents; | 6073 Handle<FixedArray> contents; |
| 6075 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6074 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 6076 isolate, contents, | 6075 isolate, contents, |
| 6077 JSReceiver::GetKeys(object, JSReceiver::LOCAL_ONLY)); | 6076 JSReceiver::GetKeys(object, JSReceiver::OWN_ONLY)); |
| 6078 | 6077 |
| 6079 // Some fast paths through GetKeysInFixedArrayFor reuse a cached | 6078 // Some fast paths through GetKeysInFixedArrayFor reuse a cached |
| 6080 // property array and since the result is mutable we have to create | 6079 // property array and since the result is mutable we have to create |
| 6081 // a fresh clone on each invocation. | 6080 // a fresh clone on each invocation. |
| 6082 int length = contents->length(); | 6081 int length = contents->length(); |
| 6083 Handle<FixedArray> copy = isolate->factory()->NewFixedArray(length); | 6082 Handle<FixedArray> copy = isolate->factory()->NewFixedArray(length); |
| 6084 for (int i = 0; i < length; i++) { | 6083 for (int i = 0; i < length; i++) { |
| 6085 Object* entry = contents->get(i); | 6084 Object* entry = contents->get(i); |
| 6086 if (entry->IsString()) { | 6085 if (entry->IsString()) { |
| 6087 copy->set(i, entry); | 6086 copy->set(i, entry); |
| (...skipping 3395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9483 "not_defined", HandleVector(&name, 1)); | 9482 "not_defined", HandleVector(&name, 1)); |
| 9484 return isolate->Throw(*error); | 9483 return isolate->Throw(*error); |
| 9485 } | 9484 } |
| 9486 // In sloppy mode, the property is added to the global object. | 9485 // In sloppy mode, the property is added to the global object. |
| 9487 attributes = NONE; | 9486 attributes = NONE; |
| 9488 object = Handle<JSReceiver>(isolate->context()->global_object()); | 9487 object = Handle<JSReceiver>(isolate->context()->global_object()); |
| 9489 } | 9488 } |
| 9490 | 9489 |
| 9491 // Set the property if it's not read only or doesn't yet exist. | 9490 // Set the property if it's not read only or doesn't yet exist. |
| 9492 if ((attributes & READ_ONLY) == 0 || | 9491 if ((attributes & READ_ONLY) == 0 || |
| 9493 (JSReceiver::GetLocalPropertyAttribute(object, name) == ABSENT)) { | 9492 (JSReceiver::GetOwnPropertyAttribute(object, name) == ABSENT)) { |
| 9494 RETURN_FAILURE_ON_EXCEPTION( | 9493 RETURN_FAILURE_ON_EXCEPTION( |
| 9495 isolate, | 9494 isolate, |
| 9496 JSReceiver::SetProperty(object, name, value, NONE, strict_mode)); | 9495 JSReceiver::SetProperty(object, name, value, NONE, strict_mode)); |
| 9497 } else if (strict_mode == STRICT && (attributes & READ_ONLY) != 0) { | 9496 } else if (strict_mode == STRICT && (attributes & READ_ONLY) != 0) { |
| 9498 // Setting read only property in strict mode. | 9497 // Setting read only property in strict mode. |
| 9499 Handle<Object> error = | 9498 Handle<Object> error = |
| 9500 isolate->factory()->NewTypeError( | 9499 isolate->factory()->NewTypeError( |
| 9501 "strict_cannot_assign", HandleVector(&name, 1)); | 9500 "strict_cannot_assign", HandleVector(&name, 1)); |
| 9502 return isolate->Throw(*error); | 9501 return isolate->Throw(*error); |
| 9503 } | 9502 } |
| (...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10723 for (Handle<Object> p = array; | 10722 for (Handle<Object> p = array; |
| 10724 !p->IsNull(); | 10723 !p->IsNull(); |
| 10725 p = Handle<Object>(p->GetPrototype(isolate), isolate)) { | 10724 p = Handle<Object>(p->GetPrototype(isolate), isolate)) { |
| 10726 if (p->IsJSProxy() || JSObject::cast(*p)->HasIndexedInterceptor()) { | 10725 if (p->IsJSProxy() || JSObject::cast(*p)->HasIndexedInterceptor()) { |
| 10727 // Bail out if we find a proxy or interceptor, likely not worth | 10726 // Bail out if we find a proxy or interceptor, likely not worth |
| 10728 // collecting keys in that case. | 10727 // collecting keys in that case. |
| 10729 return *isolate->factory()->NewNumberFromUint(length); | 10728 return *isolate->factory()->NewNumberFromUint(length); |
| 10730 } | 10729 } |
| 10731 Handle<JSObject> current = Handle<JSObject>::cast(p); | 10730 Handle<JSObject> current = Handle<JSObject>::cast(p); |
| 10732 Handle<FixedArray> current_keys = | 10731 Handle<FixedArray> current_keys = |
| 10733 isolate->factory()->NewFixedArray( | 10732 isolate->factory()->NewFixedArray(current->NumberOfOwnElements(NONE)); |
| 10734 current->NumberOfLocalElements(NONE)); | 10733 current->GetOwnElementKeys(*current_keys, NONE); |
| 10735 current->GetLocalElementKeys(*current_keys, NONE); | |
| 10736 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 10734 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 10737 isolate, keys, FixedArray::UnionOfKeys(keys, current_keys)); | 10735 isolate, keys, FixedArray::UnionOfKeys(keys, current_keys)); |
| 10738 } | 10736 } |
| 10739 // Erase any keys >= length. | 10737 // Erase any keys >= length. |
| 10740 // TODO(adamk): Remove this step when the contract of %GetArrayKeys | 10738 // TODO(adamk): Remove this step when the contract of %GetArrayKeys |
| 10741 // is changed to let this happen on the JS side. | 10739 // is changed to let this happen on the JS side. |
| 10742 for (int i = 0; i < keys->length(); i++) { | 10740 for (int i = 0; i < keys->length(); i++) { |
| 10743 if (NumberToUint32(keys->get(i)) >= length) keys->set_undefined(i); | 10741 if (NumberToUint32(keys->get(i)) >= length) keys->set_undefined(i); |
| 10744 } | 10742 } |
| 10745 return *isolate->factory()->NewJSArrayWithElements(keys); | 10743 return *isolate->factory()->NewJSArrayWithElements(keys); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10908 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 10906 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 10909 isolate, element_or_char, | 10907 isolate, element_or_char, |
| 10910 Runtime::GetElementOrCharAt(isolate, obj, index)); | 10908 Runtime::GetElementOrCharAt(isolate, obj, index)); |
| 10911 details->set(0, *element_or_char); | 10909 details->set(0, *element_or_char); |
| 10912 details->set( | 10910 details->set( |
| 10913 1, PropertyDetails(NONE, NORMAL, Representation::None()).AsSmi()); | 10911 1, PropertyDetails(NONE, NORMAL, Representation::None()).AsSmi()); |
| 10914 return *isolate->factory()->NewJSArrayWithElements(details); | 10912 return *isolate->factory()->NewJSArrayWithElements(details); |
| 10915 } | 10913 } |
| 10916 | 10914 |
| 10917 // Find the number of objects making up this. | 10915 // Find the number of objects making up this. |
| 10918 int length = LocalPrototypeChainLength(*obj); | 10916 int length = OwnPrototypeChainLength(*obj); |
| 10919 | 10917 |
| 10920 // Try local lookup on each of the objects. | 10918 // Try own lookup on each of the objects. |
| 10921 Handle<JSObject> jsproto = obj; | 10919 Handle<JSObject> jsproto = obj; |
| 10922 for (int i = 0; i < length; i++) { | 10920 for (int i = 0; i < length; i++) { |
| 10923 LookupResult result(isolate); | 10921 LookupResult result(isolate); |
| 10924 jsproto->LocalLookup(name, &result); | 10922 jsproto->LookupOwn(name, &result); |
| 10925 if (result.IsFound()) { | 10923 if (result.IsFound()) { |
| 10926 // LookupResult is not GC safe as it holds raw object pointers. | 10924 // LookupResult is not GC safe as it holds raw object pointers. |
| 10927 // GC can happen later in this code so put the required fields into | 10925 // GC can happen later in this code so put the required fields into |
| 10928 // local variables using handles when required for later use. | 10926 // local variables using handles when required for later use. |
| 10929 Handle<Object> result_callback_obj; | 10927 Handle<Object> result_callback_obj; |
| 10930 if (result.IsPropertyCallbacks()) { | 10928 if (result.IsPropertyCallbacks()) { |
| 10931 result_callback_obj = Handle<Object>(result.GetCallbackObject(), | 10929 result_callback_obj = Handle<Object>(result.GetCallbackObject(), |
| 10932 isolate); | 10930 isolate); |
| 10933 } | 10931 } |
| 10934 | 10932 |
| (...skipping 1914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12849 | 12847 |
| 12850 // Helper function to find or create the arguments object for | 12848 // Helper function to find or create the arguments object for |
| 12851 // Runtime_DebugEvaluate. | 12849 // Runtime_DebugEvaluate. |
| 12852 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeArgumentsObject( | 12850 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeArgumentsObject( |
| 12853 Isolate* isolate, | 12851 Isolate* isolate, |
| 12854 Handle<JSObject> target, | 12852 Handle<JSObject> target, |
| 12855 Handle<JSFunction> function) { | 12853 Handle<JSFunction> function) { |
| 12856 // Do not materialize the arguments object for eval or top-level code. | 12854 // Do not materialize the arguments object for eval or top-level code. |
| 12857 // Skip if "arguments" is already taken. | 12855 // Skip if "arguments" is already taken. |
| 12858 if (!function->shared()->is_function() || | 12856 if (!function->shared()->is_function() || |
| 12859 JSReceiver::HasLocalProperty(target, | 12857 JSReceiver::HasOwnProperty( |
| 12860 isolate->factory()->arguments_string())) { | 12858 target, isolate->factory()->arguments_string())) { |
| 12861 return target; | 12859 return target; |
| 12862 } | 12860 } |
| 12863 | 12861 |
| 12864 // FunctionGetArguments can't throw an exception. | 12862 // FunctionGetArguments can't throw an exception. |
| 12865 Handle<JSObject> arguments = Handle<JSObject>::cast( | 12863 Handle<JSObject> arguments = Handle<JSObject>::cast( |
| 12866 Accessors::FunctionGetArguments(function)); | 12864 Accessors::FunctionGetArguments(function)); |
| 12867 Handle<String> arguments_str = isolate->factory()->arguments_string(); | 12865 Handle<String> arguments_str = isolate->factory()->arguments_string(); |
| 12868 RETURN_ON_EXCEPTION( | 12866 RETURN_ON_EXCEPTION( |
| 12869 isolate, | 12867 isolate, |
| 12870 Runtime::SetObjectProperty( | 12868 Runtime::SetObjectProperty( |
| (...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13785 | 13783 |
| 13786 error = U_ZERO_ERROR; | 13784 error = U_ZERO_ERROR; |
| 13787 // No need to force strict BCP47 rules. | 13785 // No need to force strict BCP47 rules. |
| 13788 uloc_toLanguageTag(icu_name, result, ULOC_FULLNAME_CAPACITY, FALSE, &error); | 13786 uloc_toLanguageTag(icu_name, result, ULOC_FULLNAME_CAPACITY, FALSE, &error); |
| 13789 if (U_FAILURE(error)) { | 13787 if (U_FAILURE(error)) { |
| 13790 // This shouldn't happen, but lets not break the user. | 13788 // This shouldn't happen, but lets not break the user. |
| 13791 continue; | 13789 continue; |
| 13792 } | 13790 } |
| 13793 | 13791 |
| 13794 RETURN_FAILURE_ON_EXCEPTION(isolate, | 13792 RETURN_FAILURE_ON_EXCEPTION(isolate, |
| 13795 JSObject::SetLocalPropertyIgnoreAttributes( | 13793 JSObject::SetOwnPropertyIgnoreAttributes( |
| 13796 locales, | 13794 locales, |
| 13797 factory->NewStringFromAsciiChecked(result), | 13795 factory->NewStringFromAsciiChecked(result), |
| 13798 factory->NewNumber(i), | 13796 factory->NewNumber(i), |
| 13799 NONE)); | 13797 NONE)); |
| 13800 } | 13798 } |
| 13801 | 13799 |
| 13802 return *locales; | 13800 return *locales; |
| 13803 } | 13801 } |
| 13804 | 13802 |
| 13805 | 13803 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13890 char base_locale[ULOC_FULLNAME_CAPACITY]; | 13888 char base_locale[ULOC_FULLNAME_CAPACITY]; |
| 13891 uloc_toLanguageTag( | 13889 uloc_toLanguageTag( |
| 13892 icu_base_locale, base_locale, ULOC_FULLNAME_CAPACITY, FALSE, &error); | 13890 icu_base_locale, base_locale, ULOC_FULLNAME_CAPACITY, FALSE, &error); |
| 13893 | 13891 |
| 13894 if (U_FAILURE(error)) { | 13892 if (U_FAILURE(error)) { |
| 13895 return isolate->Throw(*factory->illegal_argument_string()); | 13893 return isolate->Throw(*factory->illegal_argument_string()); |
| 13896 } | 13894 } |
| 13897 | 13895 |
| 13898 Handle<JSObject> result = factory->NewJSObject(isolate->object_function()); | 13896 Handle<JSObject> result = factory->NewJSObject(isolate->object_function()); |
| 13899 RETURN_FAILURE_ON_EXCEPTION(isolate, | 13897 RETURN_FAILURE_ON_EXCEPTION(isolate, |
| 13900 JSObject::SetLocalPropertyIgnoreAttributes( | 13898 JSObject::SetOwnPropertyIgnoreAttributes( |
| 13901 result, | 13899 result, |
| 13902 maximized, | 13900 maximized, |
| 13903 factory->NewStringFromAsciiChecked(base_max_locale), | 13901 factory->NewStringFromAsciiChecked(base_max_locale), |
| 13904 NONE)); | 13902 NONE)); |
| 13905 RETURN_FAILURE_ON_EXCEPTION(isolate, | 13903 RETURN_FAILURE_ON_EXCEPTION(isolate, |
| 13906 JSObject::SetLocalPropertyIgnoreAttributes( | 13904 JSObject::SetOwnPropertyIgnoreAttributes( |
| 13907 result, | 13905 result, |
| 13908 base, | 13906 base, |
| 13909 factory->NewStringFromAsciiChecked(base_locale), | 13907 factory->NewStringFromAsciiChecked(base_locale), |
| 13910 NONE)); | 13908 NONE)); |
| 13911 output->set(i, *result); | 13909 output->set(i, *result); |
| 13912 } | 13910 } |
| 13913 | 13911 |
| 13914 Handle<JSArray> result = factory->NewJSArrayWithElements(output); | 13912 Handle<JSArray> result = factory->NewJSArrayWithElements(output); |
| 13915 result->set_length(Smi::FromInt(length)); | 13913 result->set_length(Smi::FromInt(length)); |
| 13916 return *result; | 13914 return *result; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14018 | 14016 |
| 14019 // Set date time formatter as internal field of the resulting JS object. | 14017 // Set date time formatter as internal field of the resulting JS object. |
| 14020 icu::SimpleDateFormat* date_format = DateFormat::InitializeDateTimeFormat( | 14018 icu::SimpleDateFormat* date_format = DateFormat::InitializeDateTimeFormat( |
| 14021 isolate, locale, options, resolved); | 14019 isolate, locale, options, resolved); |
| 14022 | 14020 |
| 14023 if (!date_format) return isolate->ThrowIllegalOperation(); | 14021 if (!date_format) return isolate->ThrowIllegalOperation(); |
| 14024 | 14022 |
| 14025 local_object->SetInternalField(0, reinterpret_cast<Smi*>(date_format)); | 14023 local_object->SetInternalField(0, reinterpret_cast<Smi*>(date_format)); |
| 14026 | 14024 |
| 14027 RETURN_FAILURE_ON_EXCEPTION(isolate, | 14025 RETURN_FAILURE_ON_EXCEPTION(isolate, |
| 14028 JSObject::SetLocalPropertyIgnoreAttributes( | 14026 JSObject::SetOwnPropertyIgnoreAttributes( |
| 14029 local_object, | 14027 local_object, |
| 14030 isolate->factory()->NewStringFromStaticAscii("dateFormat"), | 14028 isolate->factory()->NewStringFromStaticAscii("dateFormat"), |
| 14031 isolate->factory()->NewStringFromStaticAscii("valid"), | 14029 isolate->factory()->NewStringFromStaticAscii("valid"), |
| 14032 NONE)); | 14030 NONE)); |
| 14033 | 14031 |
| 14034 // Make object handle weak so we can delete the data format once GC kicks in. | 14032 // Make object handle weak so we can delete the data format once GC kicks in. |
| 14035 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); | 14033 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); |
| 14036 GlobalHandles::MakeWeak(wrapper.location(), | 14034 GlobalHandles::MakeWeak(wrapper.location(), |
| 14037 reinterpret_cast<void*>(wrapper.location()), | 14035 reinterpret_cast<void*>(wrapper.location()), |
| 14038 DateFormat::DeleteDateFormat); | 14036 DateFormat::DeleteDateFormat); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14117 | 14115 |
| 14118 // Set number formatter as internal field of the resulting JS object. | 14116 // Set number formatter as internal field of the resulting JS object. |
| 14119 icu::DecimalFormat* number_format = NumberFormat::InitializeNumberFormat( | 14117 icu::DecimalFormat* number_format = NumberFormat::InitializeNumberFormat( |
| 14120 isolate, locale, options, resolved); | 14118 isolate, locale, options, resolved); |
| 14121 | 14119 |
| 14122 if (!number_format) return isolate->ThrowIllegalOperation(); | 14120 if (!number_format) return isolate->ThrowIllegalOperation(); |
| 14123 | 14121 |
| 14124 local_object->SetInternalField(0, reinterpret_cast<Smi*>(number_format)); | 14122 local_object->SetInternalField(0, reinterpret_cast<Smi*>(number_format)); |
| 14125 | 14123 |
| 14126 RETURN_FAILURE_ON_EXCEPTION(isolate, | 14124 RETURN_FAILURE_ON_EXCEPTION(isolate, |
| 14127 JSObject::SetLocalPropertyIgnoreAttributes( | 14125 JSObject::SetOwnPropertyIgnoreAttributes( |
| 14128 local_object, | 14126 local_object, |
| 14129 isolate->factory()->NewStringFromStaticAscii("numberFormat"), | 14127 isolate->factory()->NewStringFromStaticAscii("numberFormat"), |
| 14130 isolate->factory()->NewStringFromStaticAscii("valid"), | 14128 isolate->factory()->NewStringFromStaticAscii("valid"), |
| 14131 NONE)); | 14129 NONE)); |
| 14132 | 14130 |
| 14133 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); | 14131 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); |
| 14134 GlobalHandles::MakeWeak(wrapper.location(), | 14132 GlobalHandles::MakeWeak(wrapper.location(), |
| 14135 reinterpret_cast<void*>(wrapper.location()), | 14133 reinterpret_cast<void*>(wrapper.location()), |
| 14136 NumberFormat::DeleteNumberFormat); | 14134 NumberFormat::DeleteNumberFormat); |
| 14137 return *local_object; | 14135 return *local_object; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14225 | 14223 |
| 14226 // Set collator as internal field of the resulting JS object. | 14224 // Set collator as internal field of the resulting JS object. |
| 14227 icu::Collator* collator = Collator::InitializeCollator( | 14225 icu::Collator* collator = Collator::InitializeCollator( |
| 14228 isolate, locale, options, resolved); | 14226 isolate, locale, options, resolved); |
| 14229 | 14227 |
| 14230 if (!collator) return isolate->ThrowIllegalOperation(); | 14228 if (!collator) return isolate->ThrowIllegalOperation(); |
| 14231 | 14229 |
| 14232 local_object->SetInternalField(0, reinterpret_cast<Smi*>(collator)); | 14230 local_object->SetInternalField(0, reinterpret_cast<Smi*>(collator)); |
| 14233 | 14231 |
| 14234 RETURN_FAILURE_ON_EXCEPTION(isolate, | 14232 RETURN_FAILURE_ON_EXCEPTION(isolate, |
| 14235 JSObject::SetLocalPropertyIgnoreAttributes( | 14233 JSObject::SetOwnPropertyIgnoreAttributes( |
| 14236 local_object, | 14234 local_object, |
| 14237 isolate->factory()->NewStringFromStaticAscii("collator"), | 14235 isolate->factory()->NewStringFromStaticAscii("collator"), |
| 14238 isolate->factory()->NewStringFromStaticAscii("valid"), | 14236 isolate->factory()->NewStringFromStaticAscii("valid"), |
| 14239 NONE)); | 14237 NONE)); |
| 14240 | 14238 |
| 14241 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); | 14239 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); |
| 14242 GlobalHandles::MakeWeak(wrapper.location(), | 14240 GlobalHandles::MakeWeak(wrapper.location(), |
| 14243 reinterpret_cast<void*>(wrapper.location()), | 14241 reinterpret_cast<void*>(wrapper.location()), |
| 14244 Collator::DeleteCollator); | 14242 Collator::DeleteCollator); |
| 14245 return *local_object; | 14243 return *local_object; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14331 icu::BreakIterator* break_iterator = BreakIterator::InitializeBreakIterator( | 14329 icu::BreakIterator* break_iterator = BreakIterator::InitializeBreakIterator( |
| 14332 isolate, locale, options, resolved); | 14330 isolate, locale, options, resolved); |
| 14333 | 14331 |
| 14334 if (!break_iterator) return isolate->ThrowIllegalOperation(); | 14332 if (!break_iterator) return isolate->ThrowIllegalOperation(); |
| 14335 | 14333 |
| 14336 local_object->SetInternalField(0, reinterpret_cast<Smi*>(break_iterator)); | 14334 local_object->SetInternalField(0, reinterpret_cast<Smi*>(break_iterator)); |
| 14337 // Make sure that the pointer to adopted text is NULL. | 14335 // Make sure that the pointer to adopted text is NULL. |
| 14338 local_object->SetInternalField(1, reinterpret_cast<Smi*>(NULL)); | 14336 local_object->SetInternalField(1, reinterpret_cast<Smi*>(NULL)); |
| 14339 | 14337 |
| 14340 RETURN_FAILURE_ON_EXCEPTION(isolate, | 14338 RETURN_FAILURE_ON_EXCEPTION(isolate, |
| 14341 JSObject::SetLocalPropertyIgnoreAttributes( | 14339 JSObject::SetOwnPropertyIgnoreAttributes( |
| 14342 local_object, | 14340 local_object, |
| 14343 isolate->factory()->NewStringFromStaticAscii("breakIterator"), | 14341 isolate->factory()->NewStringFromStaticAscii("breakIterator"), |
| 14344 isolate->factory()->NewStringFromStaticAscii("valid"), | 14342 isolate->factory()->NewStringFromStaticAscii("valid"), |
| 14345 NONE)); | 14343 NONE)); |
| 14346 | 14344 |
| 14347 // Make object handle weak so we can delete the break iterator once GC kicks | 14345 // Make object handle weak so we can delete the break iterator once GC kicks |
| 14348 // in. | 14346 // in. |
| 14349 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); | 14347 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); |
| 14350 GlobalHandles::MakeWeak(wrapper.location(), | 14348 GlobalHandles::MakeWeak(wrapper.location(), |
| 14351 reinterpret_cast<void*>(wrapper.location()), | 14349 reinterpret_cast<void*>(wrapper.location()), |
| (...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15223 } | 15221 } |
| 15224 return NULL; | 15222 return NULL; |
| 15225 } | 15223 } |
| 15226 | 15224 |
| 15227 | 15225 |
| 15228 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 15226 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
| 15229 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 15227 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
| 15230 } | 15228 } |
| 15231 | 15229 |
| 15232 } } // namespace v8::internal | 15230 } } // namespace v8::internal |
| OLD | NEW |