OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 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 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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(isolate, |
1339 SetLocalPropertyIgnoreAttributes(global, | 1336 JSObject::SetLocalPropertyIgnoreAttributes( |
1340 name, | 1337 global, name, value, attributes)); |
1341 value, | |
1342 attributes)); | |
1343 } else { | 1338 } else { |
1344 LanguageMode language_mode = DeclareGlobalsLanguageMode::decode(flags); | 1339 LanguageMode language_mode = DeclareGlobalsLanguageMode::decode(flags); |
1345 StrictModeFlag strict_mode_flag = (language_mode == CLASSIC_MODE) | 1340 StrictModeFlag strict_mode_flag = (language_mode == CLASSIC_MODE) |
1346 ? kNonStrictMode : kStrictMode; | 1341 ? kNonStrictMode : kStrictMode; |
1347 RETURN_IF_EMPTY_HANDLE(isolate, | 1342 RETURN_IF_EMPTY_HANDLE(isolate, |
1348 SetProperty(global, | 1343 JSReceiver::SetProperty( |
1349 name, | 1344 global, |
1350 value, | 1345 name, |
1351 static_cast<PropertyAttributes>(attr), | 1346 value, |
1352 strict_mode_flag)); | 1347 static_cast<PropertyAttributes>(attr), |
1348 strict_mode_flag)); | |
1353 } | 1349 } |
1354 } | 1350 } |
1355 | 1351 |
1356 ASSERT(!isolate->has_pending_exception()); | 1352 ASSERT(!isolate->has_pending_exception()); |
1357 return isolate->heap()->undefined_value(); | 1353 return isolate->heap()->undefined_value(); |
1358 } | 1354 } |
1359 | 1355 |
1360 | 1356 |
1361 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareContextSlot) { | 1357 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareContextSlot) { |
1362 HandleScope scope(isolate); | 1358 HandleScope scope(isolate); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1394 if (index >= 0) { | 1390 if (index >= 0) { |
1395 ASSERT(holder.is_identical_to(context)); | 1391 ASSERT(holder.is_identical_to(context)); |
1396 if (((attributes & READ_ONLY) == 0) || | 1392 if (((attributes & READ_ONLY) == 0) || |
1397 context->get(index)->IsTheHole()) { | 1393 context->get(index)->IsTheHole()) { |
1398 context->set(index, *initial_value); | 1394 context->set(index, *initial_value); |
1399 } | 1395 } |
1400 } else { | 1396 } else { |
1401 // Slow case: The property is in the context extension object of a | 1397 // Slow case: The property is in the context extension object of a |
1402 // function context or the global object of a global context. | 1398 // function context or the global object of a global context. |
1403 Handle<JSObject> object = Handle<JSObject>::cast(holder); | 1399 Handle<JSObject> object = Handle<JSObject>::cast(holder); |
1404 RETURN_IF_EMPTY_HANDLE( | 1400 RETURN_IF_EMPTY_HANDLE( |
Kevin Millikin (Chromium)
2012/01/04 13:00:32
Some other ways to indent this line seem better th
ulan
2012/01/05 11:16:35
Done.
| |
1405 isolate, | 1401 isolate, JSReceiver::SetProperty( |
1406 SetProperty(object, name, initial_value, mode, kNonStrictMode)); | 1402 object, name, initial_value, mode, 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( |
Kevin Millikin (Chromium)
2012/01/04 13:00:32
Same: reindent.
ulan
2012/01/05 11:16:35
Done.
| |
1447 SetProperty(object, name, value, mode, | 1443 isolate, JSReceiver::SetProperty( |
1448 kNonStrictMode)); | 1444 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( |
Kevin Millikin (Chromium)
2012/01/04 13:00:32
Same: reindent.
ulan
2012/01/05 11:16:35
Done.
| |
1558 SetProperty(global, | 1554 isolate, JSReceiver::SetProperty( |
1559 name, | 1555 global, name, value, attributes, kNonStrictMode)); |
1560 value, | |
1561 attributes, | |
1562 kNonStrictMode)); | |
1563 return *value; | 1556 return *value; |
1564 } | 1557 } |
1565 | 1558 |
1566 // Set the value, but only if we're assigning the initial value to a | 1559 // 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 | 1560 // constant. For now, we determine this by checking if the |
1568 // current value is the hole. | 1561 // current value is the hole. |
1569 // Strict mode handling not needed (const is disallowed in strict mode). | 1562 // Strict mode handling not needed (const is disallowed in strict mode). |
1570 PropertyType type = lookup.type(); | 1563 PropertyType type = lookup.type(); |
1571 if (type == FIELD) { | 1564 if (type == FIELD) { |
1572 FixedArray* properties = global->properties(); | 1565 FixedArray* properties = global->properties(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1622 } | 1615 } |
1623 | 1616 |
1624 // The property could not be found, we introduce it as a property of the | 1617 // The property could not be found, we introduce it as a property of the |
1625 // global object. | 1618 // global object. |
1626 if (attributes == ABSENT) { | 1619 if (attributes == ABSENT) { |
1627 Handle<JSObject> global = Handle<JSObject>( | 1620 Handle<JSObject> global = Handle<JSObject>( |
1628 isolate->context()->global()); | 1621 isolate->context()->global()); |
1629 // Strict mode not needed (const disallowed in strict mode). | 1622 // Strict mode not needed (const disallowed in strict mode). |
1630 RETURN_IF_EMPTY_HANDLE( | 1623 RETURN_IF_EMPTY_HANDLE( |
1631 isolate, | 1624 isolate, |
1632 SetProperty(global, name, value, NONE, kNonStrictMode)); | 1625 JSReceiver::SetProperty(global, name, value, NONE, kNonStrictMode)); |
1633 return *value; | 1626 return *value; |
1634 } | 1627 } |
1635 | 1628 |
1636 // The property was present in some function's context extension object, | 1629 // 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 | 1630 // as a property on the subject of a with, or as a property of the global |
1638 // object. | 1631 // object. |
1639 // | 1632 // |
1640 // In most situations, eval-introduced consts should still be present in | 1633 // In most situations, eval-introduced consts should still be present in |
1641 // the context extension object. However, because declaration and | 1634 // the context extension object. However, because declaration and |
1642 // initialization are separate, the property might have been deleted | 1635 // 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. | 1667 // either a field or a dictionary slot. |
1675 UNREACHABLE(); | 1668 UNREACHABLE(); |
1676 } | 1669 } |
1677 } else { | 1670 } else { |
1678 // The property was found on some other object. Set it if it is not a | 1671 // The property was found on some other object. Set it if it is not a |
1679 // read-only property. | 1672 // read-only property. |
1680 if ((attributes & READ_ONLY) == 0) { | 1673 if ((attributes & READ_ONLY) == 0) { |
1681 // Strict mode not needed (const disallowed in strict mode). | 1674 // Strict mode not needed (const disallowed in strict mode). |
1682 RETURN_IF_EMPTY_HANDLE( | 1675 RETURN_IF_EMPTY_HANDLE( |
1683 isolate, | 1676 isolate, |
1684 SetProperty(object, name, value, attributes, kNonStrictMode)); | 1677 JSReceiver::SetProperty( |
1678 object, name, value, attributes, kNonStrictMode)); | |
1685 } | 1679 } |
1686 } | 1680 } |
1687 | 1681 |
1688 return *value; | 1682 return *value; |
1689 } | 1683 } |
1690 | 1684 |
1691 | 1685 |
1692 RUNTIME_FUNCTION(MaybeObject*, | 1686 RUNTIME_FUNCTION(MaybeObject*, |
1693 Runtime_OptimizeObjectForAddingMultipleProperties) { | 1687 Runtime_OptimizeObjectForAddingMultipleProperties) { |
1694 HandleScope scope(isolate); | 1688 HandleScope scope(isolate); |
1695 ASSERT(args.length() == 2); | 1689 ASSERT(args.length() == 2); |
1696 CONVERT_ARG_CHECKED(JSObject, object, 0); | 1690 CONVERT_ARG_CHECKED(JSObject, object, 0); |
1697 CONVERT_SMI_ARG_CHECKED(properties, 1); | 1691 CONVERT_SMI_ARG_CHECKED(properties, 1); |
1698 if (object->HasFastProperties()) { | 1692 if (object->HasFastProperties()) { |
1699 NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties); | 1693 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties); |
1700 } | 1694 } |
1701 return *object; | 1695 return *object; |
1702 } | 1696 } |
1703 | 1697 |
1704 | 1698 |
1705 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpExec) { | 1699 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpExec) { |
1706 HandleScope scope(isolate); | 1700 HandleScope scope(isolate); |
1707 ASSERT(args.length() == 4); | 1701 ASSERT(args.length() == 4); |
1708 CONVERT_ARG_CHECKED(JSRegExp, regexp, 0); | 1702 CONVERT_ARG_CHECKED(JSRegExp, regexp, 0); |
1709 CONVERT_ARG_CHECKED(String, subject, 1); | 1703 CONVERT_ARG_CHECKED(String, subject, 1); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1845 Builtins::Name builtin_name) { | 1839 Builtins::Name builtin_name) { |
1846 Handle<String> key = isolate->factory()->LookupAsciiSymbol(name); | 1840 Handle<String> key = isolate->factory()->LookupAsciiSymbol(name); |
1847 Handle<Code> code(isolate->builtins()->builtin(builtin_name)); | 1841 Handle<Code> code(isolate->builtins()->builtin(builtin_name)); |
1848 Handle<JSFunction> optimized = | 1842 Handle<JSFunction> optimized = |
1849 isolate->factory()->NewFunction(key, | 1843 isolate->factory()->NewFunction(key, |
1850 JS_OBJECT_TYPE, | 1844 JS_OBJECT_TYPE, |
1851 JSObject::kHeaderSize, | 1845 JSObject::kHeaderSize, |
1852 code, | 1846 code, |
1853 false); | 1847 false); |
1854 optimized->shared()->DontAdaptArguments(); | 1848 optimized->shared()->DontAdaptArguments(); |
1855 SetProperty(holder, key, optimized, NONE, kStrictMode); | 1849 JSReceiver::SetProperty(holder, key, optimized, NONE, kStrictMode); |
1856 return optimized; | 1850 return optimized; |
1857 } | 1851 } |
1858 | 1852 |
1859 | 1853 |
1860 RUNTIME_FUNCTION(MaybeObject*, Runtime_SpecialArrayFunctions) { | 1854 RUNTIME_FUNCTION(MaybeObject*, Runtime_SpecialArrayFunctions) { |
1861 HandleScope scope(isolate); | 1855 HandleScope scope(isolate); |
1862 ASSERT(args.length() == 1); | 1856 ASSERT(args.length() == 1); |
1863 CONVERT_ARG_CHECKED(JSObject, holder, 0); | 1857 CONVERT_ARG_CHECKED(JSObject, holder, 0); |
1864 | 1858 |
1865 InstallBuiltin(isolate, holder, "pop", Builtins::kArrayPop); | 1859 InstallBuiltin(isolate, holder, "pop", Builtins::kArrayPop); |
(...skipping 2193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4059 | 4053 |
4060 // Handle [] indexing on String objects | 4054 // Handle [] indexing on String objects |
4061 if (object->IsStringObjectWithCharacterAt(index)) { | 4055 if (object->IsStringObjectWithCharacterAt(index)) { |
4062 Handle<JSValue> js_value = Handle<JSValue>::cast(object); | 4056 Handle<JSValue> js_value = Handle<JSValue>::cast(object); |
4063 Handle<Object> result = | 4057 Handle<Object> result = |
4064 GetCharAt(Handle<String>(String::cast(js_value->value())), index); | 4058 GetCharAt(Handle<String>(String::cast(js_value->value())), index); |
4065 if (!result->IsUndefined()) return *result; | 4059 if (!result->IsUndefined()) return *result; |
4066 } | 4060 } |
4067 | 4061 |
4068 if (object->IsString() || object->IsNumber() || object->IsBoolean()) { | 4062 if (object->IsString() || object->IsNumber() || object->IsBoolean()) { |
4069 Handle<Object> prototype = GetPrototype(object); | 4063 Handle<Object> prototype = Object::GetPrototype(object); |
Kevin Millikin (Chromium)
2012/01/04 13:00:32
Handle<Object> prototype(object->GetPrototype());
ulan
2012/01/05 11:16:35
Done.
| |
4070 return prototype->GetElement(index); | 4064 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) { |
(...skipping 47 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 15 matching lines...) Expand all Loading... | |
4341 // correctly in the case where a property is a field and is reset with | 4336 // correctly in the case where a property is a field and is reset with |
4342 // new attributes. | 4337 // new attributes. |
4343 if (result.IsProperty() && | 4338 if (result.IsProperty() && |
4344 (attr != result.GetAttributes() || result.type() == CALLBACKS)) { | 4339 (attr != result.GetAttributes() || result.type() == CALLBACKS)) { |
4345 // New attributes - normalize to avoid writing to instance descriptor | 4340 // New attributes - normalize to avoid writing to instance descriptor |
4346 if (js_object->IsJSGlobalProxy()) { | 4341 if (js_object->IsJSGlobalProxy()) { |
4347 // Since the result is a property, the prototype will exist so | 4342 // Since the result is a property, the prototype will exist so |
4348 // we don't have to check for null. | 4343 // we don't have to check for null. |
4349 js_object = Handle<JSObject>(JSObject::cast(js_object->GetPrototype())); | 4344 js_object = Handle<JSObject>(JSObject::cast(js_object->GetPrototype())); |
4350 } | 4345 } |
4351 NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0); | 4346 JSObject::NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0); |
4352 // Use IgnoreAttributes version since a readonly property may be | 4347 // Use IgnoreAttributes version since a readonly property may be |
4353 // overridden and SetProperty does not allow this. | 4348 // overridden and SetProperty does not allow this. |
4354 return js_object->SetLocalPropertyIgnoreAttributes(*name, | 4349 return js_object->SetLocalPropertyIgnoreAttributes(*name, |
4355 *obj_value, | 4350 *obj_value, |
4356 attr); | 4351 attr); |
4357 } | 4352 } |
4358 | 4353 |
4359 return Runtime::ForceSetObjectProperty(isolate, | 4354 return Runtime::ForceSetObjectProperty(isolate, |
4360 js_object, | 4355 js_object, |
4361 name, | 4356 name, |
4362 obj_value, | 4357 obj_value, |
4363 attr); | 4358 attr); |
4364 } | 4359 } |
4365 | 4360 |
4366 | 4361 |
4367 // Special case for elements if any of the flags are true. | 4362 // Special case for elements if any of the flags are true. |
4368 // If elements are in fast case we always implicitly assume that: | 4363 // If elements are in fast case we always implicitly assume that: |
4369 // DONT_DELETE: false, DONT_ENUM: false, READ_ONLY: false. | 4364 // DONT_DELETE: false, DONT_ENUM: false, READ_ONLY: false. |
4370 static MaybeObject* NormalizeObjectSetElement(Isolate* isolate, | 4365 static MaybeObject* NormalizeObjectSetElement(Isolate* isolate, |
4371 Handle<JSObject> js_object, | 4366 Handle<JSObject> js_object, |
4372 uint32_t index, | 4367 uint32_t index, |
4373 Handle<Object> value, | 4368 Handle<Object> value, |
4374 PropertyAttributes attr) { | 4369 PropertyAttributes attr) { |
4375 // Normalize the elements to enable attributes on the property. | 4370 // Normalize the elements to enable attributes on the property. |
4376 Handle<NumberDictionary> dictionary = NormalizeElements(js_object); | 4371 Handle<NumberDictionary> dictionary = JSObject::NormalizeElements(js_object); |
4377 // Make sure that we never go back to fast case. | 4372 // Make sure that we never go back to fast case. |
4378 dictionary->set_requires_slow_elements(); | 4373 dictionary->set_requires_slow_elements(); |
4379 PropertyDetails details = PropertyDetails(attr, NORMAL); | 4374 PropertyDetails details = PropertyDetails(attr, NORMAL); |
4380 Handle<NumberDictionary> extended_dictionary = | 4375 Handle<NumberDictionary> extended_dictionary = |
4381 NumberDictionarySet(dictionary, index, value, details); | 4376 NumberDictionary::Set(dictionary, index, value, details); |
4382 if (*extended_dictionary != *dictionary) { | 4377 if (*extended_dictionary != *dictionary) { |
4383 js_object->set_elements(*extended_dictionary); | 4378 js_object->set_elements(*extended_dictionary); |
4384 } | 4379 } |
4385 return *value; | 4380 return *value; |
4386 } | 4381 } |
4387 | 4382 |
4388 | 4383 |
4389 MaybeObject* Runtime::SetObjectProperty(Isolate* isolate, | 4384 MaybeObject* Runtime::SetObjectProperty(Isolate* isolate, |
4390 Handle<Object> object, | 4385 Handle<Object> object, |
4391 Handle<Object> key, | 4386 Handle<Object> key, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4426 // string does nothing with the assignment then we can ignore such | 4421 // string does nothing with the assignment then we can ignore such |
4427 // assignments. | 4422 // assignments. |
4428 if (js_object->IsStringObjectWithCharacterAt(index)) { | 4423 if (js_object->IsStringObjectWithCharacterAt(index)) { |
4429 return *value; | 4424 return *value; |
4430 } | 4425 } |
4431 | 4426 |
4432 if (((attr & (DONT_DELETE | DONT_ENUM | READ_ONLY)) != 0)) { | 4427 if (((attr & (DONT_DELETE | DONT_ENUM | READ_ONLY)) != 0)) { |
4433 return NormalizeObjectSetElement(isolate, js_object, index, value, attr); | 4428 return NormalizeObjectSetElement(isolate, js_object, index, value, attr); |
4434 } | 4429 } |
4435 | 4430 |
4436 Handle<Object> result = SetElement(js_object, index, value, strict_mode); | 4431 Handle<Object> result = |
4432 JSObject::SetElement(js_object, index, value, strict_mode); | |
4437 if (result.is_null()) return Failure::Exception(); | 4433 if (result.is_null()) return Failure::Exception(); |
4438 return *value; | 4434 return *value; |
4439 } | 4435 } |
4440 | 4436 |
4441 if (key->IsString()) { | 4437 if (key->IsString()) { |
4442 Handle<Object> result; | 4438 Handle<Object> result; |
4443 if (Handle<String>::cast(key)->AsArrayIndex(&index)) { | 4439 if (Handle<String>::cast(key)->AsArrayIndex(&index)) { |
4444 if (((attr & (DONT_DELETE | DONT_ENUM | READ_ONLY)) != 0)) { | 4440 if (((attr & (DONT_DELETE | DONT_ENUM | READ_ONLY)) != 0)) { |
4445 return NormalizeObjectSetElement(isolate, | 4441 return NormalizeObjectSetElement(isolate, |
4446 js_object, | 4442 js_object, |
4447 index, | 4443 index, |
4448 value, | 4444 value, |
4449 attr); | 4445 attr); |
4450 } | 4446 } |
4451 result = SetElement(js_object, index, value, strict_mode); | 4447 result = |
4448 JSObject::SetElement(js_object, index, value, strict_mode); | |
4452 } else { | 4449 } else { |
4453 Handle<String> key_string = Handle<String>::cast(key); | 4450 Handle<String> key_string = Handle<String>::cast(key); |
4454 key_string->TryFlatten(); | 4451 key_string->TryFlatten(); |
4455 result = SetProperty(js_object, key_string, value, attr, strict_mode); | 4452 result = JSReceiver::SetProperty( |
4453 js_object, key_string, value, attr, strict_mode); | |
4456 } | 4454 } |
4457 if (result.is_null()) return Failure::Exception(); | 4455 if (result.is_null()) return Failure::Exception(); |
4458 return *value; | 4456 return *value; |
4459 } | 4457 } |
4460 | 4458 |
4461 // Call-back into JavaScript to convert the key to a string. | 4459 // Call-back into JavaScript to convert the key to a string. |
4462 bool has_pending_exception = false; | 4460 bool has_pending_exception = false; |
4463 Handle<Object> converted = Execution::ToString(key, &has_pending_exception); | 4461 Handle<Object> converted = Execution::ToString(key, &has_pending_exception); |
4464 if (has_pending_exception) return Failure::Exception(); | 4462 if (has_pending_exception) return Failure::Exception(); |
4465 Handle<String> name = Handle<String>::cast(converted); | 4463 Handle<String> name = Handle<String>::cast(converted); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4634 Handle<JSArray> boilerplate_object(JSArray::cast(raw_boilerplate_object)); | 4632 Handle<JSArray> boilerplate_object(JSArray::cast(raw_boilerplate_object)); |
4635 #if DEBUG | 4633 #if DEBUG |
4636 ElementsKind elements_kind = object->GetElementsKind(); | 4634 ElementsKind elements_kind = object->GetElementsKind(); |
4637 #endif | 4635 #endif |
4638 ASSERT(elements_kind <= FAST_DOUBLE_ELEMENTS); | 4636 ASSERT(elements_kind <= FAST_DOUBLE_ELEMENTS); |
4639 // Smis should never trigger transitions. | 4637 // Smis should never trigger transitions. |
4640 ASSERT(!value->IsSmi()); | 4638 ASSERT(!value->IsSmi()); |
4641 | 4639 |
4642 if (value->IsNumber()) { | 4640 if (value->IsNumber()) { |
4643 ASSERT(elements_kind == FAST_SMI_ONLY_ELEMENTS); | 4641 ASSERT(elements_kind == FAST_SMI_ONLY_ELEMENTS); |
4644 TransitionElementsKind(object, FAST_DOUBLE_ELEMENTS); | 4642 JSObject::TransitionElementsKind(object, FAST_DOUBLE_ELEMENTS); |
4645 TransitionElementsKind(boilerplate_object, FAST_DOUBLE_ELEMENTS); | 4643 JSObject::TransitionElementsKind(boilerplate_object, FAST_DOUBLE_ELEMENTS); |
4646 ASSERT(object->GetElementsKind() == FAST_DOUBLE_ELEMENTS); | 4644 ASSERT(object->GetElementsKind() == FAST_DOUBLE_ELEMENTS); |
4647 FixedDoubleArray* double_array = | 4645 FixedDoubleArray* double_array = |
4648 FixedDoubleArray::cast(object->elements()); | 4646 FixedDoubleArray::cast(object->elements()); |
4649 HeapNumber* number = HeapNumber::cast(*value); | 4647 HeapNumber* number = HeapNumber::cast(*value); |
4650 double_array->set(store_index, number->Number()); | 4648 double_array->set(store_index, number->Number()); |
4651 } else { | 4649 } else { |
4652 ASSERT(elements_kind == FAST_SMI_ONLY_ELEMENTS || | 4650 ASSERT(elements_kind == FAST_SMI_ONLY_ELEMENTS || |
4653 elements_kind == FAST_DOUBLE_ELEMENTS); | 4651 elements_kind == FAST_DOUBLE_ELEMENTS); |
4654 TransitionElementsKind(object, FAST_ELEMENTS); | 4652 JSObject::TransitionElementsKind(object, FAST_ELEMENTS); |
4655 TransitionElementsKind(boilerplate_object, FAST_ELEMENTS); | 4653 JSObject::TransitionElementsKind(boilerplate_object, FAST_ELEMENTS); |
4656 FixedArray* object_array = | 4654 FixedArray* object_array = |
4657 FixedArray::cast(object->elements()); | 4655 FixedArray::cast(object->elements()); |
4658 object_array->set(store_index, *value); | 4656 object_array->set(store_index, *value); |
4659 } | 4657 } |
4660 return *object; | 4658 return *object; |
4661 } | 4659 } |
4662 | 4660 |
4663 | 4661 |
4664 // Set a local property, even if it is READ_ONLY. If the property does not | 4662 // Set a local property, even if it is READ_ONLY. If the property does not |
4665 // exist, it will be added with attributes NONE. | 4663 // exist, it will be added with attributes NONE. |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5130 | 5128 |
5131 | 5129 |
5132 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToFastProperties) { | 5130 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToFastProperties) { |
5133 HandleScope scope(isolate); | 5131 HandleScope scope(isolate); |
5134 | 5132 |
5135 ASSERT(args.length() == 1); | 5133 ASSERT(args.length() == 1); |
5136 Handle<Object> object = args.at<Object>(0); | 5134 Handle<Object> object = args.at<Object>(0); |
5137 if (object->IsJSObject()) { | 5135 if (object->IsJSObject()) { |
5138 Handle<JSObject> js_object = Handle<JSObject>::cast(object); | 5136 Handle<JSObject> js_object = Handle<JSObject>::cast(object); |
5139 if (!js_object->HasFastProperties() && !js_object->IsGlobalObject()) { | 5137 if (!js_object->HasFastProperties() && !js_object->IsGlobalObject()) { |
5140 MaybeObject* ok = js_object->TransformToFastProperties(0); | 5138 JSObject::TransformToFastProperties(js_object, 0); |
5141 if (ok->IsRetryAfterGC()) return ok; | |
ulan
2012/01/03 11:11:30
Changed it to a handlified function call. Is this
Kevin Millikin (Chromium)
2012/01/04 13:00:32
I think it's OK because TransformToFastProperties
ulan
2012/01/05 11:16:35
Thanks for suggestion, I like it and did the same
| |
5142 } | 5139 } |
5143 } | 5140 } |
5144 return *object; | 5141 return *object; |
5145 } | 5142 } |
5146 | 5143 |
5147 | 5144 |
5148 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToSlowProperties) { | 5145 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToSlowProperties) { |
5149 HandleScope scope(isolate); | 5146 HandleScope scope(isolate); |
5150 | 5147 |
5151 ASSERT(args.length() == 1); | 5148 ASSERT(args.length() == 1); |
5152 Handle<Object> object = args.at<Object>(0); | 5149 Handle<Object> object = args.at<Object>(0); |
5153 if (object->IsJSObject() && !object->IsJSGlobalProxy()) { | 5150 if (object->IsJSObject() && !object->IsJSGlobalProxy()) { |
5154 Handle<JSObject> js_object = Handle<JSObject>::cast(object); | 5151 Handle<JSObject> js_object = Handle<JSObject>::cast(object); |
5155 NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0); | 5152 JSObject::NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0); |
5156 } | 5153 } |
5157 return *object; | 5154 return *object; |
5158 } | 5155 } |
5159 | 5156 |
5160 | 5157 |
5161 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToBool) { | 5158 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToBool) { |
5162 NoHandleAllocation ha; | 5159 NoHandleAllocation ha; |
5163 ASSERT(args.length() == 1); | 5160 ASSERT(args.length() == 1); |
5164 | 5161 |
5165 return args[0]->ToBoolean(); | 5162 return args[0]->ToBoolean(); |
(...skipping 3954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9120 // In non-strict mode, the property is added to the global object. | 9117 // In non-strict mode, the property is added to the global object. |
9121 attributes = NONE; | 9118 attributes = NONE; |
9122 object = Handle<JSObject>(isolate->context()->global()); | 9119 object = Handle<JSObject>(isolate->context()->global()); |
9123 } | 9120 } |
9124 | 9121 |
9125 // Set the property if it's not read only or doesn't yet exist. | 9122 // Set the property if it's not read only or doesn't yet exist. |
9126 if ((attributes & READ_ONLY) == 0 || | 9123 if ((attributes & READ_ONLY) == 0 || |
9127 (object->GetLocalPropertyAttribute(*name) == ABSENT)) { | 9124 (object->GetLocalPropertyAttribute(*name) == ABSENT)) { |
9128 RETURN_IF_EMPTY_HANDLE( | 9125 RETURN_IF_EMPTY_HANDLE( |
9129 isolate, | 9126 isolate, |
9130 SetProperty(object, name, value, NONE, strict_mode)); | 9127 JSReceiver::SetProperty(object, name, value, NONE, strict_mode)); |
9131 } else if (strict_mode == kStrictMode && (attributes & READ_ONLY) != 0) { | 9128 } else if (strict_mode == kStrictMode && (attributes & READ_ONLY) != 0) { |
9132 // Setting read only property in strict mode. | 9129 // Setting read only property in strict mode. |
9133 Handle<Object> error = | 9130 Handle<Object> error = |
9134 isolate->factory()->NewTypeError( | 9131 isolate->factory()->NewTypeError( |
9135 "strict_cannot_assign", HandleVector(&name, 1)); | 9132 "strict_cannot_assign", HandleVector(&name, 1)); |
9136 return isolate->Throw(*error); | 9133 return isolate->Throw(*error); |
9137 } | 9134 } |
9138 return *value; | 9135 return *value; |
9139 } | 9136 } |
9140 | 9137 |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10052 Handle<Object> obj(elements->get(i)); | 10049 Handle<Object> obj(elements->get(i)); |
10053 uint32_t length_estimate; | 10050 uint32_t length_estimate; |
10054 uint32_t element_estimate; | 10051 uint32_t element_estimate; |
10055 if (obj->IsJSArray()) { | 10052 if (obj->IsJSArray()) { |
10056 Handle<JSArray> array(Handle<JSArray>::cast(obj)); | 10053 Handle<JSArray> array(Handle<JSArray>::cast(obj)); |
10057 // TODO(1810): Find out if it's worthwhile to properly support | 10054 // TODO(1810): Find out if it's worthwhile to properly support |
10058 // arbitrary ElementsKinds. For now, pessimistically transition to | 10055 // arbitrary ElementsKinds. For now, pessimistically transition to |
10059 // FAST_ELEMENTS. | 10056 // FAST_ELEMENTS. |
10060 if (array->HasFastDoubleElements()) { | 10057 if (array->HasFastDoubleElements()) { |
10061 array = Handle<JSArray>::cast( | 10058 array = Handle<JSArray>::cast( |
10062 TransitionElementsKind(array, FAST_ELEMENTS)); | 10059 JSObject::TransitionElementsKind(array, FAST_ELEMENTS)); |
10063 } | 10060 } |
10064 length_estimate = | 10061 length_estimate = |
10065 static_cast<uint32_t>(array->length()->Number()); | 10062 static_cast<uint32_t>(array->length()->Number()); |
10066 element_estimate = | 10063 element_estimate = |
10067 EstimateElementCount(array); | 10064 EstimateElementCount(array); |
10068 } else { | 10065 } else { |
10069 length_estimate = 1; | 10066 length_estimate = 1; |
10070 element_estimate = 1; | 10067 element_estimate = 1; |
10071 } | 10068 } |
10072 // Avoid overflows by capping at kMaxElementCount. | 10069 // Avoid overflows by capping at kMaxElementCount. |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10212 || !key2->ToArrayIndex(&index2)) { | 10209 || !key2->ToArrayIndex(&index2)) { |
10213 return isolate->ThrowIllegalOperation(); | 10210 return isolate->ThrowIllegalOperation(); |
10214 } | 10211 } |
10215 | 10212 |
10216 Handle<JSObject> jsobject = Handle<JSObject>::cast(object); | 10213 Handle<JSObject> jsobject = Handle<JSObject>::cast(object); |
10217 Handle<Object> tmp1 = Object::GetElement(jsobject, index1); | 10214 Handle<Object> tmp1 = Object::GetElement(jsobject, index1); |
10218 RETURN_IF_EMPTY_HANDLE(isolate, tmp1); | 10215 RETURN_IF_EMPTY_HANDLE(isolate, tmp1); |
10219 Handle<Object> tmp2 = Object::GetElement(jsobject, index2); | 10216 Handle<Object> tmp2 = Object::GetElement(jsobject, index2); |
10220 RETURN_IF_EMPTY_HANDLE(isolate, tmp2); | 10217 RETURN_IF_EMPTY_HANDLE(isolate, tmp2); |
10221 | 10218 |
10222 RETURN_IF_EMPTY_HANDLE(isolate, | 10219 RETURN_IF_EMPTY_HANDLE( |
10223 SetElement(jsobject, index1, tmp2, kStrictMode)); | 10220 isolate, JSObject::SetElement(jsobject, index1, tmp2, kStrictMode)); |
10224 RETURN_IF_EMPTY_HANDLE(isolate, | 10221 RETURN_IF_EMPTY_HANDLE( |
10225 SetElement(jsobject, index2, tmp1, kStrictMode)); | 10222 isolate, JSObject::SetElement(jsobject, index2, tmp1, kStrictMode)); |
10226 | 10223 |
10227 return isolate->heap()->undefined_value(); | 10224 return isolate->heap()->undefined_value(); |
10228 } | 10225 } |
10229 | 10226 |
10230 | 10227 |
10231 // Returns an array that tells you where in the [0, length) interval an array | 10228 // Returns an array that tells you where in the [0, length) interval an array |
10232 // might have elements. Can either return keys (positive integers) or | 10229 // might have elements. Can either return keys (positive integers) or |
10233 // intervals (pair of a negative integer (-start-1) followed by a | 10230 // intervals (pair of a negative integer (-start-1) followed by a |
10234 // positive (length)) or undefined values. | 10231 // positive (length)) or undefined values. |
10235 // Intervals can span over some keys that are not in the object. | 10232 // 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... | |
13571 } else { | 13568 } else { |
13572 // Handle last resort GC and make sure to allow future allocations | 13569 // Handle last resort GC and make sure to allow future allocations |
13573 // to grow the heap without causing GCs (if possible). | 13570 // to grow the heap without causing GCs (if possible). |
13574 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13571 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13575 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 13572 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
13576 } | 13573 } |
13577 } | 13574 } |
13578 | 13575 |
13579 | 13576 |
13580 } } // namespace v8::internal | 13577 } } // namespace v8::internal |
OLD | NEW |