| 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 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1532 // Normalize the object if the name is an actual string (not the | 1532 // Normalize the object if the name is an actual string (not the |
| 1533 // hidden symbols) and is not a real identifier. | 1533 // hidden symbols) and is not a real identifier. |
| 1534 // Normalize the object if it will have too many fast properties. | 1534 // Normalize the object if it will have too many fast properties. |
| 1535 Isolate* isolate = GetHeap()->isolate(); | 1535 Isolate* isolate = GetHeap()->isolate(); |
| 1536 StringInputBuffer buffer(name); | 1536 StringInputBuffer buffer(name); |
| 1537 if ((!IsIdentifier(isolate->unicode_cache(), &buffer) | 1537 if ((!IsIdentifier(isolate->unicode_cache(), &buffer) |
| 1538 && name != isolate->heap()->hidden_symbol()) || | 1538 && name != isolate->heap()->hidden_symbol()) || |
| 1539 (map()->unused_property_fields() == 0 && | 1539 (map()->unused_property_fields() == 0 && |
| 1540 TooManyFastProperties(properties()->length(), store_mode))) { | 1540 TooManyFastProperties(properties()->length(), store_mode))) { |
| 1541 Object* obj; | 1541 Object* obj; |
| 1542 { MaybeObject* maybe_obj = | 1542 MaybeObject* maybe_obj = |
| 1543 NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); | 1543 NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); |
| 1544 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 1544 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 1545 } | 1545 |
| 1546 return AddSlowProperty(name, value, attributes); | 1546 return AddSlowProperty(name, value, attributes); |
| 1547 } | 1547 } |
| 1548 | 1548 |
| 1549 DescriptorArray* old_descriptors = map()->instance_descriptors(); | 1549 DescriptorArray* old_descriptors = map()->instance_descriptors(); |
| 1550 // Compute the new index for new field. | 1550 // Compute the new index for new field. |
| 1551 int index = map()->NextFreePropertyIndex(); | 1551 int index = map()->NextFreePropertyIndex(); |
| 1552 | 1552 |
| 1553 // Allocate new instance descriptors with (name, index) added | 1553 // Allocate new instance descriptors with (name, index) added |
| 1554 FieldDescriptor new_field(name, index, attributes, 0); | 1554 FieldDescriptor new_field(name, index, attributes, 0); |
| 1555 |
| 1555 DescriptorArray* new_descriptors; | 1556 DescriptorArray* new_descriptors; |
| 1556 { MaybeObject* maybe_new_descriptors = old_descriptors->CopyAdd(&new_field); | 1557 MaybeObject* maybe_new_descriptors = old_descriptors->CopyAdd(&new_field); |
| 1557 if (!maybe_new_descriptors->To(&new_descriptors)) { | 1558 if (!maybe_new_descriptors->To(&new_descriptors)) { |
| 1558 return maybe_new_descriptors; | 1559 return maybe_new_descriptors; |
| 1559 } | |
| 1560 } | 1560 } |
| 1561 | 1561 |
| 1562 // Only allow map transition if the object isn't the global object. | 1562 // Only allow map transition if the object isn't the global object. |
| 1563 bool allow_map_transition = | 1563 bool allow_map_transition = isolate->empty_object_map() != map(); |
| 1564 (isolate->context()->global_context()->object_function()->map() != map()); | |
| 1565 | 1564 |
| 1566 ASSERT(index < map()->inobject_properties() || | 1565 ASSERT(index < map()->inobject_properties() || |
| 1567 (index - map()->inobject_properties()) < properties()->length() || | 1566 (index - map()->inobject_properties()) < properties()->length() || |
| 1568 map()->unused_property_fields() == 0); | 1567 map()->unused_property_fields() == 0); |
| 1569 | 1568 |
| 1570 // Allocate a new map for the object. | 1569 // Allocate a new map for the object. |
| 1571 Map* new_map; | 1570 Map* new_map; |
| 1572 { MaybeObject* maybe_r = map()->CopyReplaceDescriptors(new_descriptors); | 1571 MaybeObject* maybe_r = map()->CopyReplaceDescriptors(new_descriptors); |
| 1573 if (!maybe_r->To(&new_map)) return maybe_r; | 1572 if (!maybe_r->To(&new_map)) return maybe_r; |
| 1574 } | |
| 1575 | 1573 |
| 1576 TransitionArray* new_transitions = NULL; | 1574 TransitionArray* new_transitions = NULL; |
| 1577 if (allow_map_transition) { | 1575 if (allow_map_transition) { |
| 1578 MaybeObject* maybe_new_transitions = map()->AddTransition(name, new_map); | 1576 MaybeObject* maybe_transitions = map()->AddTransition(name, new_map); |
| 1579 if (!maybe_new_transitions->To(&new_transitions)) { | 1577 if (!maybe_transitions->To(&new_transitions)) return maybe_transitions; |
| 1580 return maybe_new_transitions; | |
| 1581 } | |
| 1582 } | 1578 } |
| 1583 | 1579 |
| 1584 if (map()->unused_property_fields() == 0) { | 1580 if (map()->unused_property_fields() == 0) { |
| 1585 // Make room for the new value | 1581 // Make room for the new value |
| 1586 FixedArray* values; | 1582 FixedArray* values; |
| 1587 { MaybeObject* maybe_values = | 1583 MaybeObject* maybe_values = |
| 1588 properties()->CopySize(properties()->length() + kFieldsAdded); | 1584 properties()->CopySize(properties()->length() + kFieldsAdded); |
| 1589 if (!maybe_values->To(&values)) return maybe_values; | 1585 if (!maybe_values->To(&values)) return maybe_values; |
| 1590 } | 1586 |
| 1591 set_properties(values); | 1587 set_properties(values); |
| 1592 new_map->set_unused_property_fields(kFieldsAdded - 1); | 1588 new_map->set_unused_property_fields(kFieldsAdded - 1); |
| 1593 } else { | 1589 } else { |
| 1594 new_map->set_unused_property_fields(map()->unused_property_fields() - 1); | 1590 new_map->set_unused_property_fields(map()->unused_property_fields() - 1); |
| 1595 } | 1591 } |
| 1596 | 1592 |
| 1597 // Apply all changes at once, so they are atomic. | 1593 // Apply all changes at once, so they are atomic. |
| 1598 if (allow_map_transition) { | 1594 if (allow_map_transition) { |
| 1599 MaybeObject* transition_added = map()->set_transitions(new_transitions); | 1595 MaybeObject* transition_added = map()->set_transitions(new_transitions); |
| 1600 if (transition_added->IsFailure()) return transition_added; | 1596 if (transition_added->IsFailure()) return transition_added; |
| 1601 } | 1597 } |
| 1602 | 1598 |
| 1603 new_map->SetBackPointer(map()); | 1599 new_map->SetBackPointer(map()); |
| 1604 set_map(new_map); | 1600 set_map(new_map); |
| 1605 return FastPropertyAtPut(index, value); | 1601 return FastPropertyAtPut(index, value); |
| 1606 } | 1602 } |
| 1607 | 1603 |
| 1608 | 1604 |
| 1609 MaybeObject* JSObject::AddConstantFunctionProperty( | 1605 MaybeObject* JSObject::AddConstantFunctionProperty( |
| 1610 String* name, | 1606 String* name, |
| 1611 JSFunction* function, | 1607 JSFunction* function, |
| 1612 PropertyAttributes attributes) { | 1608 PropertyAttributes attributes) { |
| 1613 // Allocate new instance descriptors with (name, function) added | 1609 // Allocate new instance descriptors with (name, function) added |
| 1614 ConstantFunctionDescriptor d(name, function, attributes, 0); | 1610 ConstantFunctionDescriptor d(name, function, attributes, 0); |
| 1611 |
| 1615 DescriptorArray* new_descriptors; | 1612 DescriptorArray* new_descriptors; |
| 1616 { MaybeObject* maybe_new_descriptors = | 1613 MaybeObject* maybe_new_descriptors = |
| 1617 map()->instance_descriptors()->CopyAdd(&d); | 1614 map()->instance_descriptors()->CopyAdd(&d); |
| 1618 if (!maybe_new_descriptors->To(&new_descriptors)) { | 1615 if (!maybe_new_descriptors->To(&new_descriptors)) { |
| 1619 return maybe_new_descriptors; | 1616 return maybe_new_descriptors; |
| 1620 } | |
| 1621 } | 1617 } |
| 1622 | 1618 |
| 1623 // Allocate a new map for the object. | 1619 // Allocate a new map for the object. |
| 1624 Map* new_map; | 1620 Map* new_map; |
| 1625 { MaybeObject* maybe_new_map = map()->CopyReplaceDescriptors(new_descriptors); | 1621 MaybeObject* maybe_new_map = map()->CopyReplaceDescriptors(new_descriptors); |
| 1626 if (!maybe_new_map->To(&new_map)) return maybe_new_map; | 1622 if (!maybe_new_map->To(&new_map)) return maybe_new_map; |
| 1627 } | |
| 1628 | 1623 |
| 1629 Map* old_map = map(); | 1624 Map* old_map = map(); |
| 1630 set_map(new_map); | |
| 1631 | 1625 |
| 1632 // If the old map is the global object map (from new Object()), | |
| 1633 // then transitions are not added to it, so we are done. | |
| 1634 Heap* heap = GetHeap(); | 1626 Heap* heap = GetHeap(); |
| 1635 if (old_map == heap->isolate()->context()->global_context()-> | 1627 // Do not add transitions to the empty object map (map of "new Object()"), nor |
| 1636 object_function()->map()) { | 1628 // to global objects. |
| 1629 if (old_map == heap->isolate()->empty_object_map() || IsGlobalObject()) { |
| 1630 set_map(new_map); |
| 1637 return function; | 1631 return function; |
| 1638 } | 1632 } |
| 1639 | 1633 |
| 1640 // Do not add constant transitions to global objects | 1634 // Don't add transitions to special properties with non-trivial attributes. |
| 1641 if (IsGlobalObject()) { | 1635 // TODO(verwaest): Once we support attribute changes, these transitions should |
| 1636 // be kept as well. |
| 1637 if (attributes != NONE) { |
| 1638 set_map(new_map); |
| 1642 return function; | 1639 return function; |
| 1643 } | 1640 } |
| 1644 | 1641 |
| 1645 // Add a constant transition to the old map, so future assignments to this | 1642 // Add a constant transition to the old map, so future assignments to this |
| 1646 // property on other objects of the same type will create a normal field, not | 1643 // property on other objects of the same type will create a normal field, not |
| 1647 // a constant function. Don't do this for special properties, with non-trival | 1644 // a constant function. |
| 1648 // attributes. | 1645 TransitionArray* transitions; |
| 1649 if (attributes != NONE) { | 1646 MaybeObject* maybe_transitions = old_map->AddTransition(name, new_map); |
| 1650 return function; | 1647 if (!maybe_transitions->To(&transitions)) return maybe_transitions; |
| 1651 } | |
| 1652 | 1648 |
| 1653 TransitionArray* new_transitions; | 1649 MaybeObject* transition_added = old_map->set_transitions(transitions); |
| 1654 { MaybeObject* maybe_new_transitions = | 1650 if (transition_added->IsFailure()) return transition_added; |
| 1655 old_map->AddTransition(name, new_map); | |
| 1656 if (!maybe_new_transitions->To(&new_transitions)) { | |
| 1657 // We have accomplished the main goal, so return success. | |
| 1658 return function; | |
| 1659 } | |
| 1660 } | |
| 1661 | 1651 |
| 1662 { MaybeObject* transition_added = old_map->set_transitions(new_transitions); | 1652 set_map(new_map); |
| 1663 // We have accomplished the main goal, so return success. | |
| 1664 if (transition_added->IsFailure()) { | |
| 1665 return function; | |
| 1666 } | |
| 1667 } | |
| 1668 | |
| 1669 new_map->SetBackPointer(old_map); | 1653 new_map->SetBackPointer(old_map); |
| 1670 return function; | 1654 return function; |
| 1671 } | 1655 } |
| 1672 | 1656 |
| 1673 | 1657 |
| 1674 // Add property in slow mode | 1658 // Add property in slow mode |
| 1675 MaybeObject* JSObject::AddSlowProperty(String* name, | 1659 MaybeObject* JSObject::AddSlowProperty(String* name, |
| 1676 Object* value, | 1660 Object* value, |
| 1677 PropertyAttributes attributes) { | 1661 PropertyAttributes attributes) { |
| 1678 ASSERT(!HasFastProperties()); | 1662 ASSERT(!HasFastProperties()); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1793 PropertyDetails new_details(attributes, NORMAL, new_enumeration_index); | 1777 PropertyDetails new_details(attributes, NORMAL, new_enumeration_index); |
| 1794 return SetNormalizedProperty(name, value, new_details); | 1778 return SetNormalizedProperty(name, value, new_details); |
| 1795 } | 1779 } |
| 1796 | 1780 |
| 1797 | 1781 |
| 1798 MaybeObject* JSObject::ConvertDescriptorToFieldAndMapTransition( | 1782 MaybeObject* JSObject::ConvertDescriptorToFieldAndMapTransition( |
| 1799 String* name, | 1783 String* name, |
| 1800 Object* new_value, | 1784 Object* new_value, |
| 1801 PropertyAttributes attributes) { | 1785 PropertyAttributes attributes) { |
| 1802 Map* old_map = map(); | 1786 Map* old_map = map(); |
| 1787 FixedArray* old_properties = properties(); |
| 1803 Object* result; | 1788 Object* result; |
| 1804 | 1789 |
| 1805 { MaybeObject* maybe_result = | 1790 MaybeObject* maybe_result = |
| 1806 ConvertDescriptorToField(name, new_value, attributes); | 1791 ConvertDescriptorToField(name, new_value, attributes); |
| 1807 if (!maybe_result->To(&result)) return maybe_result; | 1792 if (!maybe_result->To(&result)) return maybe_result; |
| 1793 |
| 1794 if (!HasFastProperties()) return result; |
| 1795 |
| 1796 // This method should only be used to convert existing transitions. Objects |
| 1797 // with the map of "new Object()" cannot have transitions in the first place. |
| 1798 ASSERT(map() != GetIsolate()->empty_object_map()); |
| 1799 |
| 1800 TransitionArray* new_transitions; |
| 1801 MaybeObject* maybe_new_transitions = old_map->AddTransition(name, map()); |
| 1802 if (!maybe_new_transitions->To(&new_transitions)) { |
| 1803 // Undo changes and return failure. |
| 1804 set_map(old_map); |
| 1805 set_properties(old_properties); |
| 1806 return maybe_new_transitions; |
| 1808 } | 1807 } |
| 1809 | 1808 |
| 1810 // If we get to this point we have succeeded - do not return failure | 1809 MaybeObject* transition_added = old_map->set_transitions(new_transitions); |
| 1811 // after this point. Later stuff is optional. | 1810 if (transition_added->IsFailure()) { |
| 1812 if (!HasFastProperties()) { | 1811 // Undo changes and return failure. |
| 1813 return result; | 1812 set_map(old_map); |
| 1813 set_properties(old_properties); |
| 1814 return transition_added; |
| 1814 } | 1815 } |
| 1815 | 1816 |
| 1816 // Do not add transitions to the map of "new Object()". | 1817 map()->SetBackPointer(old_map); |
| 1817 if (map() == GetIsolate()->context()->global_context()-> | |
| 1818 object_function()->map()) { | |
| 1819 return result; | |
| 1820 } | |
| 1821 | |
| 1822 TransitionArray* new_transitions; | |
| 1823 { MaybeObject* maybe_new_transitions = old_map->AddTransition(name, map()); | |
| 1824 if (!maybe_new_transitions->To(&new_transitions)) { | |
| 1825 // We have accomplished the main goal, so return success. | |
| 1826 return result; | |
| 1827 } | |
| 1828 } | |
| 1829 | |
| 1830 { MaybeObject* transition_added = old_map->set_transitions(new_transitions); | |
| 1831 // Return success if failure since we accomplished the main goal. Otherwise | |
| 1832 // also set backpointer. | |
| 1833 if (!transition_added->IsFailure()) { | |
| 1834 map()->SetBackPointer(old_map); | |
| 1835 } | |
| 1836 } | |
| 1837 | |
| 1838 return result; | 1818 return result; |
| 1839 } | 1819 } |
| 1840 | 1820 |
| 1841 | 1821 |
| 1842 MaybeObject* JSObject::ConvertDescriptorToField(String* name, | 1822 MaybeObject* JSObject::ConvertDescriptorToField(String* name, |
| 1843 Object* new_value, | 1823 Object* new_value, |
| 1844 PropertyAttributes attributes) { | 1824 PropertyAttributes attributes) { |
| 1845 if (map()->unused_property_fields() == 0 && | 1825 if (map()->unused_property_fields() == 0 && |
| 1846 TooManyFastProperties(properties()->length(), MAY_BE_STORE_FROM_KEYED)) { | 1826 TooManyFastProperties(properties()->length(), MAY_BE_STORE_FROM_KEYED)) { |
| 1847 Object* obj; | 1827 Object* obj; |
| 1848 { MaybeObject* maybe_obj = | 1828 MaybeObject* maybe_obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); |
| 1849 NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); | 1829 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 1850 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | |
| 1851 } | |
| 1852 return ReplaceSlowProperty(name, new_value, attributes); | 1830 return ReplaceSlowProperty(name, new_value, attributes); |
| 1853 } | 1831 } |
| 1854 | 1832 |
| 1855 int index = map()->NextFreePropertyIndex(); | 1833 int index = map()->NextFreePropertyIndex(); |
| 1856 FieldDescriptor new_field(name, index, attributes, 0); | 1834 FieldDescriptor new_field(name, index, attributes, 0); |
| 1835 |
| 1857 // Make a new DescriptorArray replacing an entry with FieldDescriptor. | 1836 // Make a new DescriptorArray replacing an entry with FieldDescriptor. |
| 1858 DescriptorArray* new_descriptors; | 1837 DescriptorArray* new_descriptors; |
| 1859 { MaybeObject* maybe_descriptors = | 1838 MaybeObject* maybe_descriptors = |
| 1860 map()->instance_descriptors()->CopyInsert(&new_field); | 1839 map()->instance_descriptors()->CopyInsert(&new_field); |
| 1861 if (!maybe_descriptors->To(&new_descriptors)) return maybe_descriptors; | 1840 if (!maybe_descriptors->To(&new_descriptors)) return maybe_descriptors; |
| 1862 } | |
| 1863 | 1841 |
| 1864 // Make a new map for the object. | 1842 // Make a new map for the object. |
| 1865 Map* new_map; | 1843 Map* new_map; |
| 1866 { MaybeObject* maybe_new_map = map()->CopyReplaceDescriptors(new_descriptors); | 1844 MaybeObject* maybe_new_map = map()->CopyReplaceDescriptors(new_descriptors); |
| 1867 if (!maybe_new_map->To(&new_map)) return maybe_new_map; | 1845 if (!maybe_new_map->To(&new_map)) return maybe_new_map; |
| 1868 } | |
| 1869 | 1846 |
| 1870 // Make new properties array if necessary. | 1847 // Make new properties array if necessary. |
| 1871 FixedArray* new_properties = 0; // Will always be NULL or a valid pointer. | 1848 FixedArray* new_properties = NULL; |
| 1872 int new_unused_property_fields = map()->unused_property_fields() - 1; | 1849 int new_unused_property_fields = map()->unused_property_fields() - 1; |
| 1873 if (map()->unused_property_fields() == 0) { | 1850 if (map()->unused_property_fields() == 0) { |
| 1874 new_unused_property_fields = kFieldsAdded - 1; | 1851 new_unused_property_fields = kFieldsAdded - 1; |
| 1875 Object* new_properties_object; | 1852 MaybeObject* maybe_new_properties = |
| 1876 { MaybeObject* maybe_new_properties_object = | 1853 properties()->CopySize(properties()->length() + kFieldsAdded); |
| 1877 properties()->CopySize(properties()->length() + kFieldsAdded); | 1854 if (!maybe_new_properties->To(&new_properties)) return maybe_new_properties; |
| 1878 if (!maybe_new_properties_object->ToObject(&new_properties_object)) { | |
| 1879 return maybe_new_properties_object; | |
| 1880 } | |
| 1881 } | |
| 1882 new_properties = FixedArray::cast(new_properties_object); | |
| 1883 } | 1855 } |
| 1884 | 1856 |
| 1885 // Update pointers to commit changes. | 1857 // Update pointers to commit changes. |
| 1886 // Object points to the new map. | 1858 // Object points to the new map. |
| 1887 new_map->set_unused_property_fields(new_unused_property_fields); | 1859 new_map->set_unused_property_fields(new_unused_property_fields); |
| 1888 set_map(new_map); | 1860 set_map(new_map); |
| 1889 if (new_properties) { | 1861 if (new_properties != NULL) { |
| 1890 set_properties(FixedArray::cast(new_properties)); | 1862 set_properties(new_properties); |
| 1891 } | 1863 } |
| 1892 return FastPropertyAtPut(index, new_value); | 1864 return FastPropertyAtPut(index, new_value); |
| 1893 } | 1865 } |
| 1894 | 1866 |
| 1895 | 1867 |
| 1896 | 1868 |
| 1897 MaybeObject* JSObject::SetPropertyWithInterceptor( | 1869 MaybeObject* JSObject::SetPropertyWithInterceptor( |
| 1898 String* name, | 1870 String* name, |
| 1899 Object* value, | 1871 Object* value, |
| 1900 PropertyAttributes attributes, | 1872 PropertyAttributes attributes, |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2342 | 2314 |
| 2343 | 2315 |
| 2344 MaybeObject* JSObject::GetElementsTransitionMapSlow(ElementsKind to_kind) { | 2316 MaybeObject* JSObject::GetElementsTransitionMapSlow(ElementsKind to_kind) { |
| 2345 Map* start_map = map(); | 2317 Map* start_map = map(); |
| 2346 ElementsKind from_kind = start_map->elements_kind(); | 2318 ElementsKind from_kind = start_map->elements_kind(); |
| 2347 | 2319 |
| 2348 if (from_kind == to_kind) { | 2320 if (from_kind == to_kind) { |
| 2349 return start_map; | 2321 return start_map; |
| 2350 } | 2322 } |
| 2351 | 2323 |
| 2352 Context* global_context = GetIsolate()->context()->global_context(); | |
| 2353 bool allow_store_transition = | 2324 bool allow_store_transition = |
| 2354 // Only remember the map transition if the object's map is NOT equal to | 2325 // Only remember the map transition if the object's map is NOT equal to |
| 2355 // the global object_function's map and there is not an already existing | 2326 // the global object_function's map and there is not an already existing |
| 2356 // non-matching element transition. | 2327 // non-matching element transition. |
| 2357 (global_context->object_function()->map() != map()) && | 2328 (GetIsolate()->empty_object_map() != map()) && |
| 2358 !start_map->IsUndefined() && !start_map->is_shared() && | 2329 !start_map->IsUndefined() && !start_map->is_shared() && |
| 2359 IsFastElementsKind(from_kind); | 2330 IsFastElementsKind(from_kind); |
| 2360 | 2331 |
| 2361 // Only store fast element maps in ascending generality. | 2332 // Only store fast element maps in ascending generality. |
| 2362 if (IsFastElementsKind(to_kind)) { | 2333 if (IsFastElementsKind(to_kind)) { |
| 2363 allow_store_transition &= | 2334 allow_store_transition &= |
| 2364 IsTransitionableFastElementsKind(from_kind) && | 2335 IsTransitionableFastElementsKind(from_kind) && |
| 2365 IsMoreGeneralElementsKindTransition(from_kind, to_kind); | 2336 IsMoreGeneralElementsKindTransition(from_kind, to_kind); |
| 2366 } | 2337 } |
| 2367 | 2338 |
| (...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3364 } | 3335 } |
| 3365 } | 3336 } |
| 3366 | 3337 |
| 3367 Heap* current_heap = GetHeap(); | 3338 Heap* current_heap = GetHeap(); |
| 3368 | 3339 |
| 3369 // Copy the next enumeration index from instance descriptor. | 3340 // Copy the next enumeration index from instance descriptor. |
| 3370 int index = map_of_this->instance_descriptors()->NextEnumerationIndex(); | 3341 int index = map_of_this->instance_descriptors()->NextEnumerationIndex(); |
| 3371 dictionary->SetNextEnumerationIndex(index); | 3342 dictionary->SetNextEnumerationIndex(index); |
| 3372 | 3343 |
| 3373 Map* new_map; | 3344 Map* new_map; |
| 3374 { MaybeObject* maybe_map = | 3345 MaybeObject* maybe_map = |
| 3375 current_heap->isolate()->context()->global_context()-> | 3346 current_heap->isolate()->context()->global_context()-> |
| 3376 normalized_map_cache()->Get(this, mode); | 3347 normalized_map_cache()->Get(this, mode); |
| 3377 if (!maybe_map->To(&new_map)) return maybe_map; | 3348 if (!maybe_map->To(&new_map)) return maybe_map; |
| 3378 } | |
| 3379 | 3349 |
| 3380 // We have now successfully allocated all the necessary objects. | 3350 // We have now successfully allocated all the necessary objects. |
| 3381 // Changes can now be made with the guarantee that all of them take effect. | 3351 // Changes can now be made with the guarantee that all of them take effect. |
| 3382 | 3352 |
| 3383 // Resize the object in the heap if necessary. | 3353 // Resize the object in the heap if necessary. |
| 3384 int new_instance_size = new_map->instance_size(); | 3354 int new_instance_size = new_map->instance_size(); |
| 3385 int instance_size_delta = map_of_this->instance_size() - new_instance_size; | 3355 int instance_size_delta = map_of_this->instance_size() - new_instance_size; |
| 3386 ASSERT(instance_size_delta >= 0); | 3356 ASSERT(instance_size_delta >= 0); |
| 3387 current_heap->CreateFillerObjectAt(this->address() + new_instance_size, | 3357 current_heap->CreateFillerObjectAt(this->address() + new_instance_size, |
| 3388 instance_size_delta); | 3358 instance_size_delta); |
| (...skipping 9908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13297 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13267 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
| 13298 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13268 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
| 13299 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13269 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
| 13300 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13270 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
| 13301 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13271 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
| 13302 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13272 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
| 13303 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13273 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
| 13304 } | 13274 } |
| 13305 | 13275 |
| 13306 } } // namespace v8::internal | 13276 } } // namespace v8::internal |
| OLD | NEW |