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 1680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1691 if (maybe_transitioned_map->IsMap()) { | 1691 if (maybe_transitioned_map->IsMap()) { |
1692 return Map::cast(maybe_transitioned_map); | 1692 return Map::cast(maybe_transitioned_map); |
1693 } | 1693 } |
1694 } | 1694 } |
1695 } | 1695 } |
1696 | 1696 |
1697 return GetElementsTransitionMapSlow(to_kind); | 1697 return GetElementsTransitionMapSlow(to_kind); |
1698 } | 1698 } |
1699 | 1699 |
1700 | 1700 |
1701 void JSObject::set_map_and_elements(Map* new_map, | 1701 void JSObject::SetMapAndElements(Handle<JSObject> object, |
1702 FixedArrayBase* value, | 1702 Handle<Map> new_map, |
1703 WriteBarrierMode mode) { | 1703 Handle<FixedArrayBase> value) { |
1704 ASSERT(value->HasValidElements()); | 1704 JSObject::MigrateToMap(object, new_map); |
1705 if (new_map != NULL) { | 1705 ASSERT((object->map()->has_fast_smi_or_object_elements() || |
1706 if (mode == UPDATE_WRITE_BARRIER) { | 1706 (*value == object->GetHeap()->empty_fixed_array())) == |
1707 set_map(new_map); | 1707 (value->map() == object->GetHeap()->fixed_array_map() || |
1708 } else { | 1708 value->map() == object->GetHeap()->fixed_cow_array_map())); |
1709 ASSERT(mode == SKIP_WRITE_BARRIER); | 1709 ASSERT((*value == object->GetHeap()->empty_fixed_array()) || |
1710 set_map_no_write_barrier(new_map); | 1710 (object->map()->has_fast_double_elements() == |
1711 } | 1711 value->IsFixedDoubleArray())); |
1712 } | 1712 JSObject* obj = *object; |
1713 ASSERT((map()->has_fast_smi_or_object_elements() || | 1713 FixedArrayBase* val = *value; |
1714 (value == GetHeap()->empty_fixed_array())) == | 1714 WRITE_FIELD(obj, kElementsOffset, val); |
1715 (value->map() == GetHeap()->fixed_array_map() || | 1715 WRITE_BARRIER(obj->GetHeap(), obj, kElementsOffset, val); |
Igor Sheludko
2014/03/31 12:35:46
What about calling object->set_elements(*value); h
Toon Verwaest
2014/03/31 12:37:51
That makes more sense indeed :)
On 2014/03/31 12:
| |
1716 value->map() == GetHeap()->fixed_cow_array_map())); | 1716 } |
1717 ASSERT((value == GetHeap()->empty_fixed_array()) || | 1717 |
1718 (map()->has_fast_double_elements() == value->IsFixedDoubleArray())); | 1718 |
1719 void JSObject::set_elements(FixedArrayBase* value, WriteBarrierMode mode) { | |
1719 WRITE_FIELD(this, kElementsOffset, value); | 1720 WRITE_FIELD(this, kElementsOffset, value); |
1720 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kElementsOffset, value, mode); | 1721 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kElementsOffset, value, mode); |
1721 } | 1722 } |
1722 | 1723 |
1723 | 1724 |
1724 void JSObject::set_elements(FixedArrayBase* value, WriteBarrierMode mode) { | |
1725 set_map_and_elements(NULL, value, mode); | |
1726 } | |
1727 | |
1728 | |
1729 void JSObject::initialize_properties() { | 1725 void JSObject::initialize_properties() { |
1730 ASSERT(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array())); | 1726 ASSERT(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array())); |
1731 WRITE_FIELD(this, kPropertiesOffset, GetHeap()->empty_fixed_array()); | 1727 WRITE_FIELD(this, kPropertiesOffset, GetHeap()->empty_fixed_array()); |
1732 } | 1728 } |
1733 | 1729 |
1734 | 1730 |
1735 void JSObject::initialize_elements() { | 1731 void JSObject::initialize_elements() { |
1736 if (map()->has_fast_smi_or_object_elements() || | 1732 if (map()->has_fast_smi_or_object_elements() || |
1737 map()->has_fast_double_elements()) { | 1733 map()->has_fast_double_elements()) { |
1738 ASSERT(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array())); | 1734 ASSERT(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array())); |
(...skipping 5154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6893 #undef READ_UINT32_FIELD | 6889 #undef READ_UINT32_FIELD |
6894 #undef WRITE_UINT32_FIELD | 6890 #undef WRITE_UINT32_FIELD |
6895 #undef READ_SHORT_FIELD | 6891 #undef READ_SHORT_FIELD |
6896 #undef WRITE_SHORT_FIELD | 6892 #undef WRITE_SHORT_FIELD |
6897 #undef READ_BYTE_FIELD | 6893 #undef READ_BYTE_FIELD |
6898 #undef WRITE_BYTE_FIELD | 6894 #undef WRITE_BYTE_FIELD |
6899 | 6895 |
6900 } } // namespace v8::internal | 6896 } } // namespace v8::internal |
6901 | 6897 |
6902 #endif // V8_OBJECTS_INL_H_ | 6898 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |