| 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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 bool is_result_from_cache = false; | 348 bool is_result_from_cache = false; |
| 349 Handle<Map> map = has_function_literal | 349 Handle<Map> map = has_function_literal |
| 350 ? Handle<Map>(context->object_function()->initial_map()) | 350 ? Handle<Map>(context->object_function()->initial_map()) |
| 351 : ComputeObjectLiteralMap(context, | 351 : ComputeObjectLiteralMap(context, |
| 352 constant_properties, | 352 constant_properties, |
| 353 &is_result_from_cache); | 353 &is_result_from_cache); |
| 354 | 354 |
| 355 Handle<JSObject> boilerplate = isolate->factory()->NewJSObjectFromMap(map); | 355 Handle<JSObject> boilerplate = isolate->factory()->NewJSObjectFromMap(map); |
| 356 | 356 |
| 357 // Normalize the elements of the boilerplate to save space if needed. | 357 // Normalize the elements of the boilerplate to save space if needed. |
| 358 if (!should_have_fast_elements) NormalizeElements(boilerplate); | 358 if (!should_have_fast_elements) JSObject::NormalizeElements(boilerplate); |
| 359 | 359 |
| 360 // Add the constant properties to the boilerplate. | 360 // Add the constant properties to the boilerplate. |
| 361 int length = constant_properties->length(); | 361 int length = constant_properties->length(); |
| 362 bool should_transform = | 362 bool should_transform = |
| 363 !is_result_from_cache && boilerplate->HasFastProperties(); | 363 !is_result_from_cache && boilerplate->HasFastProperties(); |
| 364 if (should_transform || has_function_literal) { | 364 if (should_transform || has_function_literal) { |
| 365 // Normalize the properties of object to avoid n^2 behavior | 365 // Normalize the properties of object to avoid n^2 behavior |
| 366 // when extending the object multiple properties. Indicate the number of | 366 // when extending the object multiple properties. Indicate the number of |
| 367 // properties to be added. | 367 // properties to be added. |
| 368 NormalizeProperties(boilerplate, KEEP_INOBJECT_PROPERTIES, length / 2); | 368 JSObject::NormalizeProperties( |
| 369 boilerplate, KEEP_INOBJECT_PROPERTIES, length / 2); |
| 369 } | 370 } |
| 370 | 371 |
| 371 for (int index = 0; index < length; index +=2) { | 372 for (int index = 0; index < length; index +=2) { |
| 372 Handle<Object> key(constant_properties->get(index+0), isolate); | 373 Handle<Object> key(constant_properties->get(index+0), isolate); |
| 373 Handle<Object> value(constant_properties->get(index+1), isolate); | 374 Handle<Object> value(constant_properties->get(index+1), isolate); |
| 374 if (value->IsFixedArray()) { | 375 if (value->IsFixedArray()) { |
| 375 // The value contains the constant_properties of a | 376 // The value contains the constant_properties of a |
| 376 // simple object or array literal. | 377 // simple object or array literal. |
| 377 Handle<FixedArray> array = Handle<FixedArray>::cast(value); | 378 Handle<FixedArray> array = Handle<FixedArray>::cast(value); |
| 378 value = CreateLiteralBoilerplate(isolate, literals, array); | 379 value = CreateLiteralBoilerplate(isolate, literals, array); |
| 379 if (value.is_null()) return value; | 380 if (value.is_null()) return value; |
| 380 } | 381 } |
| 381 Handle<Object> result; | 382 Handle<Object> result; |
| 382 uint32_t element_index = 0; | 383 uint32_t element_index = 0; |
| 383 if (key->IsSymbol()) { | 384 if (key->IsSymbol()) { |
| 384 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) { | 385 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) { |
| 385 // Array index as string (uint32). | 386 // Array index as string (uint32). |
| 386 result = SetOwnElement(boilerplate, | 387 result = JSObject::SetOwnElement( |
| 387 element_index, | 388 boilerplate, element_index, value, kNonStrictMode); |
| 388 value, | |
| 389 kNonStrictMode); | |
| 390 } else { | 389 } else { |
| 391 Handle<String> name(String::cast(*key)); | 390 Handle<String> name(String::cast(*key)); |
| 392 ASSERT(!name->AsArrayIndex(&element_index)); | 391 ASSERT(!name->AsArrayIndex(&element_index)); |
| 393 result = SetLocalPropertyIgnoreAttributes(boilerplate, name, | 392 result = JSObject::SetLocalPropertyIgnoreAttributes( |
| 394 value, NONE); | 393 boilerplate, name, value, NONE); |
| 395 } | 394 } |
| 396 } else if (key->ToArrayIndex(&element_index)) { | 395 } else if (key->ToArrayIndex(&element_index)) { |
| 397 // Array index (uint32). | 396 // Array index (uint32). |
| 398 result = SetOwnElement(boilerplate, | 397 result = JSObject::SetOwnElement( |
| 399 element_index, | 398 boilerplate, element_index, value, kNonStrictMode); |
| 400 value, | |
| 401 kNonStrictMode); | |
| 402 } else { | 399 } else { |
| 403 // Non-uint32 number. | 400 // Non-uint32 number. |
| 404 ASSERT(key->IsNumber()); | 401 ASSERT(key->IsNumber()); |
| 405 double num = key->Number(); | 402 double num = key->Number(); |
| 406 char arr[100]; | 403 char arr[100]; |
| 407 Vector<char> buffer(arr, ARRAY_SIZE(arr)); | 404 Vector<char> buffer(arr, ARRAY_SIZE(arr)); |
| 408 const char* str = DoubleToCString(num, buffer); | 405 const char* str = DoubleToCString(num, buffer); |
| 409 Handle<String> name = | 406 Handle<String> name = |
| 410 isolate->factory()->NewStringFromAscii(CStrVector(str)); | 407 isolate->factory()->NewStringFromAscii(CStrVector(str)); |
| 411 result = SetLocalPropertyIgnoreAttributes(boilerplate, name, | 408 result = JSObject::SetLocalPropertyIgnoreAttributes( |
| 412 value, NONE); | 409 boilerplate, name, value, NONE); |
| 413 } | 410 } |
| 414 // If setting the property on the boilerplate throws an | 411 // If setting the property on the boilerplate throws an |
| 415 // exception, the exception is converted to an empty handle in | 412 // exception, the exception is converted to an empty handle in |
| 416 // the handle based operations. In that case, we need to | 413 // the handle based operations. In that case, we need to |
| 417 // convert back to an exception. | 414 // convert back to an exception. |
| 418 if (result.is_null()) return result; | 415 if (result.is_null()) return result; |
| 419 } | 416 } |
| 420 | 417 |
| 421 // Transform to fast properties if necessary. For object literals with | 418 // Transform to fast properties if necessary. For object literals with |
| 422 // containing function literals we defer this operation until after all | 419 // containing function literals we defer this operation until after all |
| 423 // computed properties have been assigned so that we can generate | 420 // computed properties have been assigned so that we can generate |
| 424 // constant function properties. | 421 // constant function properties. |
| 425 if (should_transform && !has_function_literal) { | 422 if (should_transform && !has_function_literal) { |
| 426 TransformToFastProperties(boilerplate, | 423 JSObject::TransformToFastProperties( |
| 427 boilerplate->map()->unused_property_fields()); | 424 boilerplate, boilerplate->map()->unused_property_fields()); |
| 428 } | 425 } |
| 429 | 426 |
| 430 return boilerplate; | 427 return boilerplate; |
| 431 } | 428 } |
| 432 | 429 |
| 433 | 430 |
| 434 static const int kSmiOnlyLiteralMinimumLength = 1024; | 431 static const int kSmiOnlyLiteralMinimumLength = 1024; |
| 435 | 432 |
| 436 | 433 |
| 437 // static | 434 // static |
| (...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1328 // handlers such as "function onload() {}". Firefox does call the | 1325 // handlers such as "function onload() {}". Firefox does call the |
| 1329 // onload setter in those case and Safari does not. We follow | 1326 // onload setter in those case and Safari does not. We follow |
| 1330 // Safari for compatibility. | 1327 // Safari for compatibility. |
| 1331 if (value->IsJSFunction()) { | 1328 if (value->IsJSFunction()) { |
| 1332 // Do not change DONT_DELETE to false from true. | 1329 // Do not change DONT_DELETE to false from true. |
| 1333 if (lookup.IsProperty() && (lookup.type() != INTERCEPTOR)) { | 1330 if (lookup.IsProperty() && (lookup.type() != INTERCEPTOR)) { |
| 1334 attr |= lookup.GetAttributes() & DONT_DELETE; | 1331 attr |= lookup.GetAttributes() & DONT_DELETE; |
| 1335 } | 1332 } |
| 1336 PropertyAttributes attributes = static_cast<PropertyAttributes>(attr); | 1333 PropertyAttributes attributes = static_cast<PropertyAttributes>(attr); |
| 1337 | 1334 |
| 1338 RETURN_IF_EMPTY_HANDLE(isolate, | 1335 RETURN_IF_EMPTY_HANDLE( |
| 1339 SetLocalPropertyIgnoreAttributes(global, | 1336 isolate, |
| 1340 name, | 1337 JSObject::SetLocalPropertyIgnoreAttributes(global, name, value, |
| 1341 value, | 1338 attributes)); |
| 1342 attributes)); | |
| 1343 } else { | 1339 } else { |
| 1344 LanguageMode language_mode = DeclareGlobalsLanguageMode::decode(flags); | 1340 LanguageMode language_mode = DeclareGlobalsLanguageMode::decode(flags); |
| 1345 StrictModeFlag strict_mode_flag = (language_mode == CLASSIC_MODE) | 1341 StrictModeFlag strict_mode_flag = (language_mode == CLASSIC_MODE) |
| 1346 ? kNonStrictMode : kStrictMode; | 1342 ? kNonStrictMode : kStrictMode; |
| 1347 RETURN_IF_EMPTY_HANDLE(isolate, | 1343 RETURN_IF_EMPTY_HANDLE( |
| 1348 SetProperty(global, | 1344 isolate, |
| 1349 name, | 1345 JSReceiver::SetProperty(global, name, value, |
| 1350 value, | 1346 static_cast<PropertyAttributes>(attr), |
| 1351 static_cast<PropertyAttributes>(attr), | 1347 strict_mode_flag)); |
| 1352 strict_mode_flag)); | |
| 1353 } | 1348 } |
| 1354 } | 1349 } |
| 1355 | 1350 |
| 1356 ASSERT(!isolate->has_pending_exception()); | 1351 ASSERT(!isolate->has_pending_exception()); |
| 1357 return isolate->heap()->undefined_value(); | 1352 return isolate->heap()->undefined_value(); |
| 1358 } | 1353 } |
| 1359 | 1354 |
| 1360 | 1355 |
| 1361 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareContextSlot) { | 1356 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareContextSlot) { |
| 1362 HandleScope scope(isolate); | 1357 HandleScope scope(isolate); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1396 if (((attributes & READ_ONLY) == 0) || | 1391 if (((attributes & READ_ONLY) == 0) || |
| 1397 context->get(index)->IsTheHole()) { | 1392 context->get(index)->IsTheHole()) { |
| 1398 context->set(index, *initial_value); | 1393 context->set(index, *initial_value); |
| 1399 } | 1394 } |
| 1400 } else { | 1395 } else { |
| 1401 // Slow case: The property is in the context extension object of a | 1396 // Slow case: The property is in the context extension object of a |
| 1402 // function context or the global object of a global context. | 1397 // function context or the global object of a global context. |
| 1403 Handle<JSObject> object = Handle<JSObject>::cast(holder); | 1398 Handle<JSObject> object = Handle<JSObject>::cast(holder); |
| 1404 RETURN_IF_EMPTY_HANDLE( | 1399 RETURN_IF_EMPTY_HANDLE( |
| 1405 isolate, | 1400 isolate, |
| 1406 SetProperty(object, name, initial_value, mode, kNonStrictMode)); | 1401 JSReceiver::SetProperty(object, name, initial_value, mode, |
| 1402 kNonStrictMode)); |
| 1407 } | 1403 } |
| 1408 } | 1404 } |
| 1409 | 1405 |
| 1410 } else { | 1406 } else { |
| 1411 // The property is not in the function context. It needs to be | 1407 // The property is not in the function context. It needs to be |
| 1412 // "declared" in the function context's extension context or as a | 1408 // "declared" in the function context's extension context or as a |
| 1413 // property of the the global object. | 1409 // property of the the global object. |
| 1414 Handle<JSObject> object; | 1410 Handle<JSObject> object; |
| 1415 if (context->has_extension()) { | 1411 if (context->has_extension()) { |
| 1416 object = Handle<JSObject>(JSObject::cast(context->extension())); | 1412 object = Handle<JSObject>(JSObject::cast(context->extension())); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1436 // SetProperty and no setters are invoked for those since they are | 1432 // SetProperty and no setters are invoked for those since they are |
| 1437 // not real JSObjects. | 1433 // not real JSObjects. |
| 1438 if (initial_value->IsTheHole() && | 1434 if (initial_value->IsTheHole() && |
| 1439 !object->IsJSContextExtensionObject()) { | 1435 !object->IsJSContextExtensionObject()) { |
| 1440 LookupResult lookup(isolate); | 1436 LookupResult lookup(isolate); |
| 1441 object->Lookup(*name, &lookup); | 1437 object->Lookup(*name, &lookup); |
| 1442 if (lookup.IsProperty() && (lookup.type() == CALLBACKS)) { | 1438 if (lookup.IsProperty() && (lookup.type() == CALLBACKS)) { |
| 1443 return ThrowRedeclarationError(isolate, "const", name); | 1439 return ThrowRedeclarationError(isolate, "const", name); |
| 1444 } | 1440 } |
| 1445 } | 1441 } |
| 1446 RETURN_IF_EMPTY_HANDLE(isolate, | 1442 RETURN_IF_EMPTY_HANDLE( |
| 1447 SetProperty(object, name, value, mode, | 1443 isolate, |
| 1448 kNonStrictMode)); | 1444 JSReceiver::SetProperty(object, name, value, mode, kNonStrictMode)); |
| 1449 } | 1445 } |
| 1450 | 1446 |
| 1451 return isolate->heap()->undefined_value(); | 1447 return isolate->heap()->undefined_value(); |
| 1452 } | 1448 } |
| 1453 | 1449 |
| 1454 | 1450 |
| 1455 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) { | 1451 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) { |
| 1456 NoHandleAllocation nha; | 1452 NoHandleAllocation nha; |
| 1457 // args[0] == name | 1453 // args[0] == name |
| 1458 // args[1] == language_mode | 1454 // args[1] == language_mode |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1547 if (!lookup.IsReadOnly()) { | 1543 if (!lookup.IsReadOnly()) { |
| 1548 // Restore global object from context (in case of GC) and continue | 1544 // Restore global object from context (in case of GC) and continue |
| 1549 // with setting the value. | 1545 // with setting the value. |
| 1550 HandleScope handle_scope(isolate); | 1546 HandleScope handle_scope(isolate); |
| 1551 Handle<GlobalObject> global(isolate->context()->global()); | 1547 Handle<GlobalObject> global(isolate->context()->global()); |
| 1552 | 1548 |
| 1553 // BUG 1213575: Handle the case where we have to set a read-only | 1549 // BUG 1213575: Handle the case where we have to set a read-only |
| 1554 // property through an interceptor and only do it if it's | 1550 // property through an interceptor and only do it if it's |
| 1555 // uninitialized, e.g. the hole. Nirk... | 1551 // uninitialized, e.g. the hole. Nirk... |
| 1556 // Passing non-strict mode because the property is writable. | 1552 // Passing non-strict mode because the property is writable. |
| 1557 RETURN_IF_EMPTY_HANDLE(isolate, | 1553 RETURN_IF_EMPTY_HANDLE( |
| 1558 SetProperty(global, | 1554 isolate, |
| 1559 name, | 1555 JSReceiver::SetProperty(global, name, value, attributes, |
| 1560 value, | 1556 kNonStrictMode)); |
| 1561 attributes, | |
| 1562 kNonStrictMode)); | |
| 1563 return *value; | 1557 return *value; |
| 1564 } | 1558 } |
| 1565 | 1559 |
| 1566 // Set the value, but only if we're assigning the initial value to a | 1560 // Set the value, but only if we're assigning the initial value to a |
| 1567 // constant. For now, we determine this by checking if the | 1561 // constant. For now, we determine this by checking if the |
| 1568 // current value is the hole. | 1562 // current value is the hole. |
| 1569 // Strict mode handling not needed (const is disallowed in strict mode). | 1563 // Strict mode handling not needed (const is disallowed in strict mode). |
| 1570 PropertyType type = lookup.type(); | 1564 PropertyType type = lookup.type(); |
| 1571 if (type == FIELD) { | 1565 if (type == FIELD) { |
| 1572 FixedArray* properties = global->properties(); | 1566 FixedArray* properties = global->properties(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1622 } | 1616 } |
| 1623 | 1617 |
| 1624 // The property could not be found, we introduce it as a property of the | 1618 // The property could not be found, we introduce it as a property of the |
| 1625 // global object. | 1619 // global object. |
| 1626 if (attributes == ABSENT) { | 1620 if (attributes == ABSENT) { |
| 1627 Handle<JSObject> global = Handle<JSObject>( | 1621 Handle<JSObject> global = Handle<JSObject>( |
| 1628 isolate->context()->global()); | 1622 isolate->context()->global()); |
| 1629 // Strict mode not needed (const disallowed in strict mode). | 1623 // Strict mode not needed (const disallowed in strict mode). |
| 1630 RETURN_IF_EMPTY_HANDLE( | 1624 RETURN_IF_EMPTY_HANDLE( |
| 1631 isolate, | 1625 isolate, |
| 1632 SetProperty(global, name, value, NONE, kNonStrictMode)); | 1626 JSReceiver::SetProperty(global, name, value, NONE, kNonStrictMode)); |
| 1633 return *value; | 1627 return *value; |
| 1634 } | 1628 } |
| 1635 | 1629 |
| 1636 // The property was present in some function's context extension object, | 1630 // The property was present in some function's context extension object, |
| 1637 // as a property on the subject of a with, or as a property of the global | 1631 // as a property on the subject of a with, or as a property of the global |
| 1638 // object. | 1632 // object. |
| 1639 // | 1633 // |
| 1640 // In most situations, eval-introduced consts should still be present in | 1634 // In most situations, eval-introduced consts should still be present in |
| 1641 // the context extension object. However, because declaration and | 1635 // the context extension object. However, because declaration and |
| 1642 // initialization are separate, the property might have been deleted | 1636 // initialization are separate, the property might have been deleted |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1674 // either a field or a dictionary slot. | 1668 // either a field or a dictionary slot. |
| 1675 UNREACHABLE(); | 1669 UNREACHABLE(); |
| 1676 } | 1670 } |
| 1677 } else { | 1671 } else { |
| 1678 // The property was found on some other object. Set it if it is not a | 1672 // The property was found on some other object. Set it if it is not a |
| 1679 // read-only property. | 1673 // read-only property. |
| 1680 if ((attributes & READ_ONLY) == 0) { | 1674 if ((attributes & READ_ONLY) == 0) { |
| 1681 // Strict mode not needed (const disallowed in strict mode). | 1675 // Strict mode not needed (const disallowed in strict mode). |
| 1682 RETURN_IF_EMPTY_HANDLE( | 1676 RETURN_IF_EMPTY_HANDLE( |
| 1683 isolate, | 1677 isolate, |
| 1684 SetProperty(object, name, value, attributes, kNonStrictMode)); | 1678 JSReceiver::SetProperty(object, name, value, attributes, |
| 1679 kNonStrictMode)); |
| 1685 } | 1680 } |
| 1686 } | 1681 } |
| 1687 | 1682 |
| 1688 return *value; | 1683 return *value; |
| 1689 } | 1684 } |
| 1690 | 1685 |
| 1691 | 1686 |
| 1692 RUNTIME_FUNCTION(MaybeObject*, | 1687 RUNTIME_FUNCTION(MaybeObject*, |
| 1693 Runtime_OptimizeObjectForAddingMultipleProperties) { | 1688 Runtime_OptimizeObjectForAddingMultipleProperties) { |
| 1694 HandleScope scope(isolate); | 1689 HandleScope scope(isolate); |
| 1695 ASSERT(args.length() == 2); | 1690 ASSERT(args.length() == 2); |
| 1696 CONVERT_ARG_CHECKED(JSObject, object, 0); | 1691 CONVERT_ARG_CHECKED(JSObject, object, 0); |
| 1697 CONVERT_SMI_ARG_CHECKED(properties, 1); | 1692 CONVERT_SMI_ARG_CHECKED(properties, 1); |
| 1698 if (object->HasFastProperties()) { | 1693 if (object->HasFastProperties()) { |
| 1699 NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties); | 1694 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties); |
| 1700 } | 1695 } |
| 1701 return *object; | 1696 return *object; |
| 1702 } | 1697 } |
| 1703 | 1698 |
| 1704 | 1699 |
| 1705 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpExec) { | 1700 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpExec) { |
| 1706 HandleScope scope(isolate); | 1701 HandleScope scope(isolate); |
| 1707 ASSERT(args.length() == 4); | 1702 ASSERT(args.length() == 4); |
| 1708 CONVERT_ARG_CHECKED(JSRegExp, regexp, 0); | 1703 CONVERT_ARG_CHECKED(JSRegExp, regexp, 0); |
| 1709 CONVERT_ARG_CHECKED(String, subject, 1); | 1704 CONVERT_ARG_CHECKED(String, subject, 1); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1845 Builtins::Name builtin_name) { | 1840 Builtins::Name builtin_name) { |
| 1846 Handle<String> key = isolate->factory()->LookupAsciiSymbol(name); | 1841 Handle<String> key = isolate->factory()->LookupAsciiSymbol(name); |
| 1847 Handle<Code> code(isolate->builtins()->builtin(builtin_name)); | 1842 Handle<Code> code(isolate->builtins()->builtin(builtin_name)); |
| 1848 Handle<JSFunction> optimized = | 1843 Handle<JSFunction> optimized = |
| 1849 isolate->factory()->NewFunction(key, | 1844 isolate->factory()->NewFunction(key, |
| 1850 JS_OBJECT_TYPE, | 1845 JS_OBJECT_TYPE, |
| 1851 JSObject::kHeaderSize, | 1846 JSObject::kHeaderSize, |
| 1852 code, | 1847 code, |
| 1853 false); | 1848 false); |
| 1854 optimized->shared()->DontAdaptArguments(); | 1849 optimized->shared()->DontAdaptArguments(); |
| 1855 SetProperty(holder, key, optimized, NONE, kStrictMode); | 1850 JSReceiver::SetProperty(holder, key, optimized, NONE, kStrictMode); |
| 1856 return optimized; | 1851 return optimized; |
| 1857 } | 1852 } |
| 1858 | 1853 |
| 1859 | 1854 |
| 1860 RUNTIME_FUNCTION(MaybeObject*, Runtime_SpecialArrayFunctions) { | 1855 RUNTIME_FUNCTION(MaybeObject*, Runtime_SpecialArrayFunctions) { |
| 1861 HandleScope scope(isolate); | 1856 HandleScope scope(isolate); |
| 1862 ASSERT(args.length() == 1); | 1857 ASSERT(args.length() == 1); |
| 1863 CONVERT_ARG_CHECKED(JSObject, holder, 0); | 1858 CONVERT_ARG_CHECKED(JSObject, holder, 0); |
| 1864 | 1859 |
| 1865 InstallBuiltin(isolate, holder, "pop", Builtins::kArrayPop); | 1860 InstallBuiltin(isolate, holder, "pop", Builtins::kArrayPop); |
| (...skipping 2193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4059 | 4054 |
| 4060 // Handle [] indexing on String objects | 4055 // Handle [] indexing on String objects |
| 4061 if (object->IsStringObjectWithCharacterAt(index)) { | 4056 if (object->IsStringObjectWithCharacterAt(index)) { |
| 4062 Handle<JSValue> js_value = Handle<JSValue>::cast(object); | 4057 Handle<JSValue> js_value = Handle<JSValue>::cast(object); |
| 4063 Handle<Object> result = | 4058 Handle<Object> result = |
| 4064 GetCharAt(Handle<String>(String::cast(js_value->value())), index); | 4059 GetCharAt(Handle<String>(String::cast(js_value->value())), index); |
| 4065 if (!result->IsUndefined()) return *result; | 4060 if (!result->IsUndefined()) return *result; |
| 4066 } | 4061 } |
| 4067 | 4062 |
| 4068 if (object->IsString() || object->IsNumber() || object->IsBoolean()) { | 4063 if (object->IsString() || object->IsNumber() || object->IsBoolean()) { |
| 4069 Handle<Object> prototype = GetPrototype(object); | 4064 return object->GetPrototype()->GetElement(index); |
| 4070 return prototype->GetElement(index); | |
| 4071 } | 4065 } |
| 4072 | 4066 |
| 4073 return object->GetElement(index); | 4067 return object->GetElement(index); |
| 4074 } | 4068 } |
| 4075 | 4069 |
| 4076 | 4070 |
| 4077 MaybeObject* Runtime::GetObjectProperty(Isolate* isolate, | 4071 MaybeObject* Runtime::GetObjectProperty(Isolate* isolate, |
| 4078 Handle<Object> object, | 4072 Handle<Object> object, |
| 4079 Handle<Object> key) { | 4073 Handle<Object> key) { |
| 4080 HandleScope scope(isolate); | 4074 HandleScope scope(isolate); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4127 | 4121 |
| 4128 | 4122 |
| 4129 MaybeObject* TransitionElements(Handle<Object> object, | 4123 MaybeObject* TransitionElements(Handle<Object> object, |
| 4130 ElementsKind to_kind, | 4124 ElementsKind to_kind, |
| 4131 Isolate* isolate) { | 4125 Isolate* isolate) { |
| 4132 HandleScope scope(isolate); | 4126 HandleScope scope(isolate); |
| 4133 if (!object->IsJSObject()) return isolate->ThrowIllegalOperation(); | 4127 if (!object->IsJSObject()) return isolate->ThrowIllegalOperation(); |
| 4134 ElementsKind from_kind = | 4128 ElementsKind from_kind = |
| 4135 Handle<JSObject>::cast(object)->map()->elements_kind(); | 4129 Handle<JSObject>::cast(object)->map()->elements_kind(); |
| 4136 if (Map::IsValidElementsTransition(from_kind, to_kind)) { | 4130 if (Map::IsValidElementsTransition(from_kind, to_kind)) { |
| 4137 Handle<Object> result = | 4131 Handle<Object> result = JSObject::TransitionElementsKind( |
| 4138 TransitionElementsKind(Handle<JSObject>::cast(object), to_kind); | 4132 Handle<JSObject>::cast(object), to_kind); |
| 4139 if (result.is_null()) return isolate->ThrowIllegalOperation(); | 4133 if (result.is_null()) return isolate->ThrowIllegalOperation(); |
| 4140 return *result; | 4134 return *result; |
| 4141 } | 4135 } |
| 4142 return isolate->ThrowIllegalOperation(); | 4136 return isolate->ThrowIllegalOperation(); |
| 4143 } | 4137 } |
| 4144 | 4138 |
| 4145 | 4139 |
| 4146 // KeyedStringGetProperty is called from KeyedLoadIC::GenerateGeneric. | 4140 // KeyedStringGetProperty is called from KeyedLoadIC::GenerateGeneric. |
| 4147 RUNTIME_FUNCTION(MaybeObject*, Runtime_KeyedGetProperty) { | 4141 RUNTIME_FUNCTION(MaybeObject*, Runtime_KeyedGetProperty) { |
| 4148 NoHandleAllocation ha; | 4142 NoHandleAllocation ha; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4300 // Don't allow element properties to be redefined on objects with external | 4294 // Don't allow element properties to be redefined on objects with external |
| 4301 // array elements. | 4295 // array elements. |
| 4302 if (js_object->HasExternalArrayElements()) { | 4296 if (js_object->HasExternalArrayElements()) { |
| 4303 Handle<Object> args[2] = { js_object, name }; | 4297 Handle<Object> args[2] = { js_object, name }; |
| 4304 Handle<Object> error = | 4298 Handle<Object> error = |
| 4305 isolate->factory()->NewTypeError("redef_external_array_element", | 4299 isolate->factory()->NewTypeError("redef_external_array_element", |
| 4306 HandleVector(args, 2)); | 4300 HandleVector(args, 2)); |
| 4307 return isolate->Throw(*error); | 4301 return isolate->Throw(*error); |
| 4308 } | 4302 } |
| 4309 | 4303 |
| 4310 Handle<NumberDictionary> dictionary = NormalizeElements(js_object); | 4304 Handle<NumberDictionary> dictionary = |
| 4305 JSObject::NormalizeElements(js_object); |
| 4311 // Make sure that we never go back to fast case. | 4306 // Make sure that we never go back to fast case. |
| 4312 dictionary->set_requires_slow_elements(); | 4307 dictionary->set_requires_slow_elements(); |
| 4313 PropertyDetails details = PropertyDetails(attr, NORMAL); | 4308 PropertyDetails details = PropertyDetails(attr, NORMAL); |
| 4314 Handle<NumberDictionary> extended_dictionary = | 4309 Handle<NumberDictionary> extended_dictionary = |
| 4315 NumberDictionarySet(dictionary, index, obj_value, details); | 4310 NumberDictionary::Set(dictionary, index, obj_value, details); |
| 4316 if (*extended_dictionary != *dictionary) { | 4311 if (*extended_dictionary != *dictionary) { |
| 4317 if (js_object->GetElementsKind() == NON_STRICT_ARGUMENTS_ELEMENTS) { | 4312 if (js_object->GetElementsKind() == NON_STRICT_ARGUMENTS_ELEMENTS) { |
| 4318 FixedArray::cast(js_object->elements())->set(1, *extended_dictionary); | 4313 FixedArray::cast(js_object->elements())->set(1, *extended_dictionary); |
| 4319 } else { | 4314 } else { |
| 4320 js_object->set_elements(*extended_dictionary); | 4315 js_object->set_elements(*extended_dictionary); |
| 4321 } | 4316 } |
| 4322 } | 4317 } |
| 4323 return *obj_value; | 4318 return *obj_value; |
| 4324 } | 4319 } |
| 4325 | 4320 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 4355 // correctly in the case where a property is a field and is reset with | 4350 // correctly in the case where a property is a field and is reset with |
| 4356 // new attributes. | 4351 // new attributes. |
| 4357 if (result.IsProperty() && | 4352 if (result.IsProperty() && |
| 4358 (attr != result.GetAttributes() || result.type() == CALLBACKS)) { | 4353 (attr != result.GetAttributes() || result.type() == CALLBACKS)) { |
| 4359 // New attributes - normalize to avoid writing to instance descriptor | 4354 // New attributes - normalize to avoid writing to instance descriptor |
| 4360 if (js_object->IsJSGlobalProxy()) { | 4355 if (js_object->IsJSGlobalProxy()) { |
| 4361 // Since the result is a property, the prototype will exist so | 4356 // Since the result is a property, the prototype will exist so |
| 4362 // we don't have to check for null. | 4357 // we don't have to check for null. |
| 4363 js_object = Handle<JSObject>(JSObject::cast(js_object->GetPrototype())); | 4358 js_object = Handle<JSObject>(JSObject::cast(js_object->GetPrototype())); |
| 4364 } | 4359 } |
| 4365 NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0); | 4360 JSObject::NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0); |
| 4366 // Use IgnoreAttributes version since a readonly property may be | 4361 // Use IgnoreAttributes version since a readonly property may be |
| 4367 // overridden and SetProperty does not allow this. | 4362 // overridden and SetProperty does not allow this. |
| 4368 return js_object->SetLocalPropertyIgnoreAttributes(*name, | 4363 return js_object->SetLocalPropertyIgnoreAttributes(*name, |
| 4369 *obj_value, | 4364 *obj_value, |
| 4370 attr); | 4365 attr); |
| 4371 } | 4366 } |
| 4372 | 4367 |
| 4373 return Runtime::ForceSetObjectProperty(isolate, | 4368 return Runtime::ForceSetObjectProperty(isolate, |
| 4374 js_object, | 4369 js_object, |
| 4375 name, | 4370 name, |
| 4376 obj_value, | 4371 obj_value, |
| 4377 attr); | 4372 attr); |
| 4378 } | 4373 } |
| 4379 | 4374 |
| 4380 | 4375 |
| 4381 // Special case for elements if any of the flags are true. | 4376 // Special case for elements if any of the flags are true. |
| 4382 // If elements are in fast case we always implicitly assume that: | 4377 // If elements are in fast case we always implicitly assume that: |
| 4383 // DONT_DELETE: false, DONT_ENUM: false, READ_ONLY: false. | 4378 // DONT_DELETE: false, DONT_ENUM: false, READ_ONLY: false. |
| 4384 static MaybeObject* NormalizeObjectSetElement(Isolate* isolate, | 4379 static MaybeObject* NormalizeObjectSetElement(Isolate* isolate, |
| 4385 Handle<JSObject> js_object, | 4380 Handle<JSObject> js_object, |
| 4386 uint32_t index, | 4381 uint32_t index, |
| 4387 Handle<Object> value, | 4382 Handle<Object> value, |
| 4388 PropertyAttributes attr) { | 4383 PropertyAttributes attr) { |
| 4389 // Normalize the elements to enable attributes on the property. | 4384 // Normalize the elements to enable attributes on the property. |
| 4390 Handle<NumberDictionary> dictionary = NormalizeElements(js_object); | 4385 Handle<NumberDictionary> dictionary = JSObject::NormalizeElements(js_object); |
| 4391 // Make sure that we never go back to fast case. | 4386 // Make sure that we never go back to fast case. |
| 4392 dictionary->set_requires_slow_elements(); | 4387 dictionary->set_requires_slow_elements(); |
| 4393 PropertyDetails details = PropertyDetails(attr, NORMAL); | 4388 PropertyDetails details = PropertyDetails(attr, NORMAL); |
| 4394 Handle<NumberDictionary> extended_dictionary = | 4389 Handle<NumberDictionary> extended_dictionary = |
| 4395 NumberDictionarySet(dictionary, index, value, details); | 4390 NumberDictionary::Set(dictionary, index, value, details); |
| 4396 if (*extended_dictionary != *dictionary) { | 4391 if (*extended_dictionary != *dictionary) { |
| 4397 js_object->set_elements(*extended_dictionary); | 4392 js_object->set_elements(*extended_dictionary); |
| 4398 } | 4393 } |
| 4399 return *value; | 4394 return *value; |
| 4400 } | 4395 } |
| 4401 | 4396 |
| 4402 | 4397 |
| 4403 MaybeObject* Runtime::SetObjectProperty(Isolate* isolate, | 4398 MaybeObject* Runtime::SetObjectProperty(Isolate* isolate, |
| 4404 Handle<Object> object, | 4399 Handle<Object> object, |
| 4405 Handle<Object> key, | 4400 Handle<Object> key, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4440 // string does nothing with the assignment then we can ignore such | 4435 // string does nothing with the assignment then we can ignore such |
| 4441 // assignments. | 4436 // assignments. |
| 4442 if (js_object->IsStringObjectWithCharacterAt(index)) { | 4437 if (js_object->IsStringObjectWithCharacterAt(index)) { |
| 4443 return *value; | 4438 return *value; |
| 4444 } | 4439 } |
| 4445 | 4440 |
| 4446 if (((attr & (DONT_DELETE | DONT_ENUM | READ_ONLY)) != 0)) { | 4441 if (((attr & (DONT_DELETE | DONT_ENUM | READ_ONLY)) != 0)) { |
| 4447 return NormalizeObjectSetElement(isolate, js_object, index, value, attr); | 4442 return NormalizeObjectSetElement(isolate, js_object, index, value, attr); |
| 4448 } | 4443 } |
| 4449 | 4444 |
| 4450 Handle<Object> result = SetElement(js_object, index, value, strict_mode); | 4445 Handle<Object> result = |
| 4446 JSObject::SetElement(js_object, index, value, strict_mode); |
| 4451 if (result.is_null()) return Failure::Exception(); | 4447 if (result.is_null()) return Failure::Exception(); |
| 4452 return *value; | 4448 return *value; |
| 4453 } | 4449 } |
| 4454 | 4450 |
| 4455 if (key->IsString()) { | 4451 if (key->IsString()) { |
| 4456 Handle<Object> result; | 4452 Handle<Object> result; |
| 4457 if (Handle<String>::cast(key)->AsArrayIndex(&index)) { | 4453 if (Handle<String>::cast(key)->AsArrayIndex(&index)) { |
| 4458 if (((attr & (DONT_DELETE | DONT_ENUM | READ_ONLY)) != 0)) { | 4454 if (((attr & (DONT_DELETE | DONT_ENUM | READ_ONLY)) != 0)) { |
| 4459 return NormalizeObjectSetElement(isolate, | 4455 return NormalizeObjectSetElement(isolate, |
| 4460 js_object, | 4456 js_object, |
| 4461 index, | 4457 index, |
| 4462 value, | 4458 value, |
| 4463 attr); | 4459 attr); |
| 4464 } | 4460 } |
| 4465 result = SetElement(js_object, index, value, strict_mode); | 4461 result = |
| 4462 JSObject::SetElement(js_object, index, value, strict_mode); |
| 4466 } else { | 4463 } else { |
| 4467 Handle<String> key_string = Handle<String>::cast(key); | 4464 Handle<String> key_string = Handle<String>::cast(key); |
| 4468 key_string->TryFlatten(); | 4465 key_string->TryFlatten(); |
| 4469 result = SetProperty(js_object, key_string, value, attr, strict_mode); | 4466 result = JSReceiver::SetProperty( |
| 4467 js_object, key_string, value, attr, strict_mode); |
| 4470 } | 4468 } |
| 4471 if (result.is_null()) return Failure::Exception(); | 4469 if (result.is_null()) return Failure::Exception(); |
| 4472 return *value; | 4470 return *value; |
| 4473 } | 4471 } |
| 4474 | 4472 |
| 4475 // Call-back into JavaScript to convert the key to a string. | 4473 // Call-back into JavaScript to convert the key to a string. |
| 4476 bool has_pending_exception = false; | 4474 bool has_pending_exception = false; |
| 4477 Handle<Object> converted = Execution::ToString(key, &has_pending_exception); | 4475 Handle<Object> converted = Execution::ToString(key, &has_pending_exception); |
| 4478 if (has_pending_exception) return Failure::Exception(); | 4476 if (has_pending_exception) return Failure::Exception(); |
| 4479 Handle<String> name = Handle<String>::cast(converted); | 4477 Handle<String> name = Handle<String>::cast(converted); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4648 Handle<JSArray> boilerplate_object(JSArray::cast(raw_boilerplate_object)); | 4646 Handle<JSArray> boilerplate_object(JSArray::cast(raw_boilerplate_object)); |
| 4649 #if DEBUG | 4647 #if DEBUG |
| 4650 ElementsKind elements_kind = object->GetElementsKind(); | 4648 ElementsKind elements_kind = object->GetElementsKind(); |
| 4651 #endif | 4649 #endif |
| 4652 ASSERT(elements_kind <= FAST_DOUBLE_ELEMENTS); | 4650 ASSERT(elements_kind <= FAST_DOUBLE_ELEMENTS); |
| 4653 // Smis should never trigger transitions. | 4651 // Smis should never trigger transitions. |
| 4654 ASSERT(!value->IsSmi()); | 4652 ASSERT(!value->IsSmi()); |
| 4655 | 4653 |
| 4656 if (value->IsNumber()) { | 4654 if (value->IsNumber()) { |
| 4657 ASSERT(elements_kind == FAST_SMI_ONLY_ELEMENTS); | 4655 ASSERT(elements_kind == FAST_SMI_ONLY_ELEMENTS); |
| 4658 TransitionElementsKind(object, FAST_DOUBLE_ELEMENTS); | 4656 JSObject::TransitionElementsKind(object, FAST_DOUBLE_ELEMENTS); |
| 4659 TransitionElementsKind(boilerplate_object, FAST_DOUBLE_ELEMENTS); | 4657 JSObject::TransitionElementsKind(boilerplate_object, FAST_DOUBLE_ELEMENTS); |
| 4660 ASSERT(object->GetElementsKind() == FAST_DOUBLE_ELEMENTS); | 4658 ASSERT(object->GetElementsKind() == FAST_DOUBLE_ELEMENTS); |
| 4661 FixedDoubleArray* double_array = | 4659 FixedDoubleArray* double_array = |
| 4662 FixedDoubleArray::cast(object->elements()); | 4660 FixedDoubleArray::cast(object->elements()); |
| 4663 HeapNumber* number = HeapNumber::cast(*value); | 4661 HeapNumber* number = HeapNumber::cast(*value); |
| 4664 double_array->set(store_index, number->Number()); | 4662 double_array->set(store_index, number->Number()); |
| 4665 } else { | 4663 } else { |
| 4666 ASSERT(elements_kind == FAST_SMI_ONLY_ELEMENTS || | 4664 ASSERT(elements_kind == FAST_SMI_ONLY_ELEMENTS || |
| 4667 elements_kind == FAST_DOUBLE_ELEMENTS); | 4665 elements_kind == FAST_DOUBLE_ELEMENTS); |
| 4668 TransitionElementsKind(object, FAST_ELEMENTS); | 4666 JSObject::TransitionElementsKind(object, FAST_ELEMENTS); |
| 4669 TransitionElementsKind(boilerplate_object, FAST_ELEMENTS); | 4667 JSObject::TransitionElementsKind(boilerplate_object, FAST_ELEMENTS); |
| 4670 FixedArray* object_array = | 4668 FixedArray* object_array = |
| 4671 FixedArray::cast(object->elements()); | 4669 FixedArray::cast(object->elements()); |
| 4672 object_array->set(store_index, *value); | 4670 object_array->set(store_index, *value); |
| 4673 } | 4671 } |
| 4674 return *object; | 4672 return *object; |
| 4675 } | 4673 } |
| 4676 | 4674 |
| 4677 | 4675 |
| 4678 // Set a local property, even if it is READ_ONLY. If the property does not | 4676 // Set a local property, even if it is READ_ONLY. If the property does not |
| 4679 // exist, it will be added with attributes NONE. | 4677 // exist, it will be added with attributes NONE. |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5137 } | 5135 } |
| 5138 return function; | 5136 return function; |
| 5139 } | 5137 } |
| 5140 | 5138 |
| 5141 // Lookup in the initial Object.prototype object. | 5139 // Lookup in the initial Object.prototype object. |
| 5142 return isolate->initial_object_prototype()->GetProperty(*key); | 5140 return isolate->initial_object_prototype()->GetProperty(*key); |
| 5143 } | 5141 } |
| 5144 | 5142 |
| 5145 | 5143 |
| 5146 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToFastProperties) { | 5144 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToFastProperties) { |
| 5147 HandleScope scope(isolate); | |
| 5148 | |
| 5149 ASSERT(args.length() == 1); | 5145 ASSERT(args.length() == 1); |
| 5150 Handle<Object> object = args.at<Object>(0); | 5146 Object* object = args[0]; |
| 5151 if (object->IsJSObject()) { | 5147 return (object->IsJSObject() && !object->IsGlobalObject()) |
| 5152 Handle<JSObject> js_object = Handle<JSObject>::cast(object); | 5148 ? JSObject::cast(object)->TransformToFastProperties(0) |
| 5153 if (!js_object->HasFastProperties() && !js_object->IsGlobalObject()) { | 5149 : object; |
| 5154 MaybeObject* ok = js_object->TransformToFastProperties(0); | |
| 5155 if (ok->IsRetryAfterGC()) return ok; | |
| 5156 } | |
| 5157 } | |
| 5158 return *object; | |
| 5159 } | 5150 } |
| 5160 | 5151 |
| 5161 | 5152 |
| 5162 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToSlowProperties) { | 5153 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToSlowProperties) { |
| 5163 HandleScope scope(isolate); | |
| 5164 | |
| 5165 ASSERT(args.length() == 1); | 5154 ASSERT(args.length() == 1); |
| 5166 Handle<Object> object = args.at<Object>(0); | 5155 Object* obj = args[0]; |
| 5167 if (object->IsJSObject() && !object->IsJSGlobalProxy()) { | 5156 return (obj->IsJSObject() && !obj->IsJSGlobalProxy()) |
| 5168 Handle<JSObject> js_object = Handle<JSObject>::cast(object); | 5157 ? JSObject::cast(obj)->NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0) |
| 5169 NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0); | 5158 : obj; |
| 5170 } | |
| 5171 return *object; | |
| 5172 } | 5159 } |
| 5173 | 5160 |
| 5174 | 5161 |
| 5175 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToBool) { | 5162 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToBool) { |
| 5176 NoHandleAllocation ha; | 5163 NoHandleAllocation ha; |
| 5177 ASSERT(args.length() == 1); | 5164 ASSERT(args.length() == 1); |
| 5178 | 5165 |
| 5179 return args[0]->ToBoolean(); | 5166 return args[0]->ToBoolean(); |
| 5180 } | 5167 } |
| 5181 | 5168 |
| (...skipping 3944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9126 // In non-strict mode, the property is added to the global object. | 9113 // In non-strict mode, the property is added to the global object. |
| 9127 attributes = NONE; | 9114 attributes = NONE; |
| 9128 object = Handle<JSObject>(isolate->context()->global()); | 9115 object = Handle<JSObject>(isolate->context()->global()); |
| 9129 } | 9116 } |
| 9130 | 9117 |
| 9131 // Set the property if it's not read only or doesn't yet exist. | 9118 // Set the property if it's not read only or doesn't yet exist. |
| 9132 if ((attributes & READ_ONLY) == 0 || | 9119 if ((attributes & READ_ONLY) == 0 || |
| 9133 (object->GetLocalPropertyAttribute(*name) == ABSENT)) { | 9120 (object->GetLocalPropertyAttribute(*name) == ABSENT)) { |
| 9134 RETURN_IF_EMPTY_HANDLE( | 9121 RETURN_IF_EMPTY_HANDLE( |
| 9135 isolate, | 9122 isolate, |
| 9136 SetProperty(object, name, value, NONE, strict_mode)); | 9123 JSReceiver::SetProperty(object, name, value, NONE, strict_mode)); |
| 9137 } else if (strict_mode == kStrictMode && (attributes & READ_ONLY) != 0) { | 9124 } else if (strict_mode == kStrictMode && (attributes & READ_ONLY) != 0) { |
| 9138 // Setting read only property in strict mode. | 9125 // Setting read only property in strict mode. |
| 9139 Handle<Object> error = | 9126 Handle<Object> error = |
| 9140 isolate->factory()->NewTypeError( | 9127 isolate->factory()->NewTypeError( |
| 9141 "strict_cannot_assign", HandleVector(&name, 1)); | 9128 "strict_cannot_assign", HandleVector(&name, 1)); |
| 9142 return isolate->Throw(*error); | 9129 return isolate->Throw(*error); |
| 9143 } | 9130 } |
| 9144 return *value; | 9131 return *value; |
| 9145 } | 9132 } |
| 9146 | 9133 |
| (...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10042 Handle<Object> obj(elements->get(i)); | 10029 Handle<Object> obj(elements->get(i)); |
| 10043 uint32_t length_estimate; | 10030 uint32_t length_estimate; |
| 10044 uint32_t element_estimate; | 10031 uint32_t element_estimate; |
| 10045 if (obj->IsJSArray()) { | 10032 if (obj->IsJSArray()) { |
| 10046 Handle<JSArray> array(Handle<JSArray>::cast(obj)); | 10033 Handle<JSArray> array(Handle<JSArray>::cast(obj)); |
| 10047 // TODO(1810): Find out if it's worthwhile to properly support | 10034 // TODO(1810): Find out if it's worthwhile to properly support |
| 10048 // arbitrary ElementsKinds. For now, pessimistically transition to | 10035 // arbitrary ElementsKinds. For now, pessimistically transition to |
| 10049 // FAST_ELEMENTS. | 10036 // FAST_ELEMENTS. |
| 10050 if (array->HasFastDoubleElements()) { | 10037 if (array->HasFastDoubleElements()) { |
| 10051 array = Handle<JSArray>::cast( | 10038 array = Handle<JSArray>::cast( |
| 10052 TransitionElementsKind(array, FAST_ELEMENTS)); | 10039 JSObject::TransitionElementsKind(array, FAST_ELEMENTS)); |
| 10053 } | 10040 } |
| 10054 length_estimate = | 10041 length_estimate = |
| 10055 static_cast<uint32_t>(array->length()->Number()); | 10042 static_cast<uint32_t>(array->length()->Number()); |
| 10056 element_estimate = | 10043 element_estimate = |
| 10057 EstimateElementCount(array); | 10044 EstimateElementCount(array); |
| 10058 } else { | 10045 } else { |
| 10059 length_estimate = 1; | 10046 length_estimate = 1; |
| 10060 element_estimate = 1; | 10047 element_estimate = 1; |
| 10061 } | 10048 } |
| 10062 // Avoid overflows by capping at kMaxElementCount. | 10049 // Avoid overflows by capping at kMaxElementCount. |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10202 || !key2->ToArrayIndex(&index2)) { | 10189 || !key2->ToArrayIndex(&index2)) { |
| 10203 return isolate->ThrowIllegalOperation(); | 10190 return isolate->ThrowIllegalOperation(); |
| 10204 } | 10191 } |
| 10205 | 10192 |
| 10206 Handle<JSObject> jsobject = Handle<JSObject>::cast(object); | 10193 Handle<JSObject> jsobject = Handle<JSObject>::cast(object); |
| 10207 Handle<Object> tmp1 = Object::GetElement(jsobject, index1); | 10194 Handle<Object> tmp1 = Object::GetElement(jsobject, index1); |
| 10208 RETURN_IF_EMPTY_HANDLE(isolate, tmp1); | 10195 RETURN_IF_EMPTY_HANDLE(isolate, tmp1); |
| 10209 Handle<Object> tmp2 = Object::GetElement(jsobject, index2); | 10196 Handle<Object> tmp2 = Object::GetElement(jsobject, index2); |
| 10210 RETURN_IF_EMPTY_HANDLE(isolate, tmp2); | 10197 RETURN_IF_EMPTY_HANDLE(isolate, tmp2); |
| 10211 | 10198 |
| 10212 RETURN_IF_EMPTY_HANDLE(isolate, | 10199 RETURN_IF_EMPTY_HANDLE( |
| 10213 SetElement(jsobject, index1, tmp2, kStrictMode)); | 10200 isolate, JSObject::SetElement(jsobject, index1, tmp2, kStrictMode)); |
| 10214 RETURN_IF_EMPTY_HANDLE(isolate, | 10201 RETURN_IF_EMPTY_HANDLE( |
| 10215 SetElement(jsobject, index2, tmp1, kStrictMode)); | 10202 isolate, JSObject::SetElement(jsobject, index2, tmp1, kStrictMode)); |
| 10216 | 10203 |
| 10217 return isolate->heap()->undefined_value(); | 10204 return isolate->heap()->undefined_value(); |
| 10218 } | 10205 } |
| 10219 | 10206 |
| 10220 | 10207 |
| 10221 // Returns an array that tells you where in the [0, length) interval an array | 10208 // Returns an array that tells you where in the [0, length) interval an array |
| 10222 // might have elements. Can either return keys (positive integers) or | 10209 // might have elements. Can either return keys (positive integers) or |
| 10223 // intervals (pair of a negative integer (-start-1) followed by a | 10210 // intervals (pair of a negative integer (-start-1) followed by a |
| 10224 // positive (length)) or undefined values. | 10211 // positive (length)) or undefined values. |
| 10225 // Intervals can span over some keys that are not in the object. | 10212 // Intervals can span over some keys that are not in the object. |
| (...skipping 3335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13561 } else { | 13548 } else { |
| 13562 // Handle last resort GC and make sure to allow future allocations | 13549 // Handle last resort GC and make sure to allow future allocations |
| 13563 // to grow the heap without causing GCs (if possible). | 13550 // to grow the heap without causing GCs (if possible). |
| 13564 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13551 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13565 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 13552 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
| 13566 } | 13553 } |
| 13567 } | 13554 } |
| 13568 | 13555 |
| 13569 | 13556 |
| 13570 } } // namespace v8::internal | 13557 } } // namespace v8::internal |
| OLD | NEW |