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->global_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 objects with the global object map, nor to global |
Jakob Kummerow
2012/07/12 14:38:19
for clarity:
"Do not add transitions to empty obje
| |
1636 object_function()->map()) { | 1628 // objects. |
1629 if (old_map == heap->isolate()->global_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-trival attributes. |
Jakob Kummerow
2012/07/12 14:38:19
nit: "trivial", and the comma is unnecessary.
| |
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; |
1808 } | |
1809 | 1793 |
1810 // If we get to this point we have succeeded - do not return failure | 1794 // If we get to this point we have succeeded - do not return failure |
Jakob Kummerow
2012/07/12 14:38:19
Outdated comment. Just remove it.
| |
1811 // after this point. Later stuff is optional. | 1795 // after this point. Later stuff is optional. |
1812 if (!HasFastProperties()) { | 1796 if (!HasFastProperties()) return result; |
1813 return result; | 1797 |
1798 // This method should only be used to convert existing transitions. Objects | |
1799 // with the map of "new Object()" cannot have transitions in the first place. | |
1800 ASSERT(map() != GetIsolate()->global_object_map()); | |
1801 | |
1802 TransitionArray* new_transitions; | |
1803 MaybeObject* maybe_new_transitions = old_map->AddTransition(name, map()); | |
1804 if (!maybe_new_transitions->To(&new_transitions)) { | |
1805 // Undo changes and return failure. | |
1806 set_map(old_map); | |
1807 set_properties(old_properties); | |
1808 return maybe_new_transitions; | |
1814 } | 1809 } |
1815 | 1810 |
1816 // Do not add transitions to the map of "new Object()". | 1811 MaybeObject* transition_added = old_map->set_transitions(new_transitions); |
1817 if (map() == GetIsolate()->context()->global_context()-> | 1812 if (transition_added->IsFailure()) { |
1818 object_function()->map()) { | 1813 // Undo changes and return failure. |
1819 return result; | 1814 set_map(old_map); |
1815 set_properties(old_properties); | |
1816 return transition_added; | |
1820 } | 1817 } |
1821 | 1818 |
1822 TransitionArray* new_transitions; | 1819 map()->SetBackPointer(old_map); |
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; | 1820 return result; |
1839 } | 1821 } |
1840 | 1822 |
1841 | 1823 |
1842 MaybeObject* JSObject::ConvertDescriptorToField(String* name, | 1824 MaybeObject* JSObject::ConvertDescriptorToField(String* name, |
1843 Object* new_value, | 1825 Object* new_value, |
1844 PropertyAttributes attributes) { | 1826 PropertyAttributes attributes) { |
1845 if (map()->unused_property_fields() == 0 && | 1827 if (map()->unused_property_fields() == 0 && |
1846 TooManyFastProperties(properties()->length(), MAY_BE_STORE_FROM_KEYED)) { | 1828 TooManyFastProperties(properties()->length(), MAY_BE_STORE_FROM_KEYED)) { |
1847 Object* obj; | 1829 Object* obj; |
1848 { MaybeObject* maybe_obj = | 1830 MaybeObject* maybe_obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); |
1849 NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); | 1831 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); | 1832 return ReplaceSlowProperty(name, new_value, attributes); |
1853 } | 1833 } |
1854 | 1834 |
1855 int index = map()->NextFreePropertyIndex(); | 1835 int index = map()->NextFreePropertyIndex(); |
1856 FieldDescriptor new_field(name, index, attributes, 0); | 1836 FieldDescriptor new_field(name, index, attributes, 0); |
1837 | |
1857 // Make a new DescriptorArray replacing an entry with FieldDescriptor. | 1838 // Make a new DescriptorArray replacing an entry with FieldDescriptor. |
1858 DescriptorArray* new_descriptors; | 1839 DescriptorArray* new_descriptors; |
1859 { MaybeObject* maybe_descriptors = | 1840 MaybeObject* maybe_descriptors = |
1860 map()->instance_descriptors()->CopyInsert(&new_field); | 1841 map()->instance_descriptors()->CopyInsert(&new_field); |
1861 if (!maybe_descriptors->To(&new_descriptors)) return maybe_descriptors; | 1842 if (!maybe_descriptors->To(&new_descriptors)) return maybe_descriptors; |
1862 } | |
1863 | 1843 |
1864 // Make a new map for the object. | 1844 // Make a new map for the object. |
1865 Map* new_map; | 1845 Map* new_map; |
1866 { MaybeObject* maybe_new_map = map()->CopyReplaceDescriptors(new_descriptors); | 1846 MaybeObject* maybe_new_map = map()->CopyReplaceDescriptors(new_descriptors); |
1867 if (!maybe_new_map->To(&new_map)) return maybe_new_map; | 1847 if (!maybe_new_map->To(&new_map)) return maybe_new_map; |
1868 } | |
1869 | 1848 |
1870 // Make new properties array if necessary. | 1849 // Make new properties array if necessary. |
1871 FixedArray* new_properties = 0; // Will always be NULL or a valid pointer. | 1850 FixedArray* new_properties = NULL; // Will always be NULL or a valid pointer. |
Jakob Kummerow
2012/07/12 14:38:19
You can remove the initialization and the comment
| |
1872 int new_unused_property_fields = map()->unused_property_fields() - 1; | 1851 int new_unused_property_fields = map()->unused_property_fields() - 1; |
1873 if (map()->unused_property_fields() == 0) { | 1852 if (map()->unused_property_fields() == 0) { |
1874 new_unused_property_fields = kFieldsAdded - 1; | 1853 new_unused_property_fields = kFieldsAdded - 1; |
1875 Object* new_properties_object; | 1854 MaybeObject* maybe_new_properties = |
1876 { MaybeObject* maybe_new_properties_object = | 1855 properties()->CopySize(properties()->length() + kFieldsAdded); |
1877 properties()->CopySize(properties()->length() + kFieldsAdded); | 1856 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 } | 1857 } |
1884 | 1858 |
1885 // Update pointers to commit changes. | 1859 // Update pointers to commit changes. |
1886 // Object points to the new map. | 1860 // Object points to the new map. |
1887 new_map->set_unused_property_fields(new_unused_property_fields); | 1861 new_map->set_unused_property_fields(new_unused_property_fields); |
1888 set_map(new_map); | 1862 set_map(new_map); |
1889 if (new_properties) { | 1863 if (new_properties != NULL) { |
1890 set_properties(FixedArray::cast(new_properties)); | 1864 set_properties(new_properties); |
1891 } | 1865 } |
1892 return FastPropertyAtPut(index, new_value); | 1866 return FastPropertyAtPut(index, new_value); |
1893 } | 1867 } |
1894 | 1868 |
1895 | 1869 |
1896 | 1870 |
1897 MaybeObject* JSObject::SetPropertyWithInterceptor( | 1871 MaybeObject* JSObject::SetPropertyWithInterceptor( |
1898 String* name, | 1872 String* name, |
1899 Object* value, | 1873 Object* value, |
1900 PropertyAttributes attributes, | 1874 PropertyAttributes attributes, |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2342 | 2316 |
2343 | 2317 |
2344 MaybeObject* JSObject::GetElementsTransitionMapSlow(ElementsKind to_kind) { | 2318 MaybeObject* JSObject::GetElementsTransitionMapSlow(ElementsKind to_kind) { |
2345 Map* start_map = map(); | 2319 Map* start_map = map(); |
2346 ElementsKind from_kind = start_map->elements_kind(); | 2320 ElementsKind from_kind = start_map->elements_kind(); |
2347 | 2321 |
2348 if (from_kind == to_kind) { | 2322 if (from_kind == to_kind) { |
2349 return start_map; | 2323 return start_map; |
2350 } | 2324 } |
2351 | 2325 |
2352 Context* global_context = GetIsolate()->context()->global_context(); | |
2353 bool allow_store_transition = | 2326 bool allow_store_transition = |
2354 // Only remember the map transition if the object's map is NOT equal to | 2327 // 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 | 2328 // the global object_function's map and there is not an already existing |
2356 // non-matching element transition. | 2329 // non-matching element transition. |
2357 (global_context->object_function()->map() != map()) && | 2330 (GetIsolate()->global_object_map() != map()) && |
2358 !start_map->IsUndefined() && !start_map->is_shared() && | 2331 !start_map->IsUndefined() && !start_map->is_shared() && |
2359 IsFastElementsKind(from_kind); | 2332 IsFastElementsKind(from_kind); |
2360 | 2333 |
2361 // Only store fast element maps in ascending generality. | 2334 // Only store fast element maps in ascending generality. |
2362 if (IsFastElementsKind(to_kind)) { | 2335 if (IsFastElementsKind(to_kind)) { |
2363 allow_store_transition &= | 2336 allow_store_transition &= |
2364 IsTransitionableFastElementsKind(from_kind) && | 2337 IsTransitionableFastElementsKind(from_kind) && |
2365 IsMoreGeneralElementsKindTransition(from_kind, to_kind); | 2338 IsMoreGeneralElementsKindTransition(from_kind, to_kind); |
2366 } | 2339 } |
2367 | 2340 |
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3364 } | 3337 } |
3365 } | 3338 } |
3366 | 3339 |
3367 Heap* current_heap = GetHeap(); | 3340 Heap* current_heap = GetHeap(); |
3368 | 3341 |
3369 // Copy the next enumeration index from instance descriptor. | 3342 // Copy the next enumeration index from instance descriptor. |
3370 int index = map_of_this->instance_descriptors()->NextEnumerationIndex(); | 3343 int index = map_of_this->instance_descriptors()->NextEnumerationIndex(); |
3371 dictionary->SetNextEnumerationIndex(index); | 3344 dictionary->SetNextEnumerationIndex(index); |
3372 | 3345 |
3373 Map* new_map; | 3346 Map* new_map; |
3374 { MaybeObject* maybe_map = | 3347 MaybeObject* maybe_map = |
3375 current_heap->isolate()->context()->global_context()-> | 3348 current_heap->isolate()->context()->global_context()-> |
3376 normalized_map_cache()->Get(this, mode); | 3349 normalized_map_cache()->Get(this, mode); |
3377 if (!maybe_map->To(&new_map)) return maybe_map; | 3350 if (!maybe_map->To(&new_map)) return maybe_map; |
3378 } | |
3379 | 3351 |
3380 // We have now successfully allocated all the necessary objects. | 3352 // We have now successfully allocated all the necessary objects. |
3381 // Changes can now be made with the guarantee that all of them take effect. | 3353 // Changes can now be made with the guarantee that all of them take effect. |
3382 | 3354 |
3383 // Resize the object in the heap if necessary. | 3355 // Resize the object in the heap if necessary. |
3384 int new_instance_size = new_map->instance_size(); | 3356 int new_instance_size = new_map->instance_size(); |
3385 int instance_size_delta = map_of_this->instance_size() - new_instance_size; | 3357 int instance_size_delta = map_of_this->instance_size() - new_instance_size; |
3386 ASSERT(instance_size_delta >= 0); | 3358 ASSERT(instance_size_delta >= 0); |
3387 current_heap->CreateFillerObjectAt(this->address() + new_instance_size, | 3359 current_heap->CreateFillerObjectAt(this->address() + new_instance_size, |
3388 instance_size_delta); | 3360 instance_size_delta); |
(...skipping 9924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13313 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13285 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
13314 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13286 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
13315 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13287 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
13316 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13288 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
13317 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13289 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
13318 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13290 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
13319 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13291 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
13320 } | 13292 } |
13321 | 13293 |
13322 } } // namespace v8::internal | 13294 } } // namespace v8::internal |
OLD | NEW |