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 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1507 if (!maybe->To(&map)) return maybe; | 1507 if (!maybe->To(&map)) return maybe; |
1508 set_map(map); | 1508 set_map(map); |
1509 initialize_elements(); | 1509 initialize_elements(); |
1510 | 1510 |
1511 return this; | 1511 return this; |
1512 } | 1512 } |
1513 | 1513 |
1514 | 1514 |
1515 MaybeObject* JSObject::TransitionToMap(Map* map) { | 1515 MaybeObject* JSObject::TransitionToMap(Map* map) { |
1516 ASSERT(this->map()->inobject_properties() == map->inobject_properties()); | 1516 ASSERT(this->map()->inobject_properties() == map->inobject_properties()); |
1517 ElementsKind expected_kind = this->map()->elements_kind(); | 1517 ElementsKind obj_kind = this->map()->elements_kind(); |
1518 if (map->elements_kind() != expected_kind) { | 1518 ElementsKind map_kind = map->elements_kind(); |
1519 MaybeObject* maybe_map = map->AsElementsKind(expected_kind); | 1519 if (map_kind != obj_kind) { |
| 1520 ElementsKind to_kind = map_kind; |
| 1521 if (IsMoreGeneralElementsKindTransition(map_kind, obj_kind) || |
| 1522 IsDictionaryElementsKind(obj_kind)) { |
| 1523 to_kind = obj_kind; |
| 1524 } |
| 1525 MaybeObject* maybe_obj = |
| 1526 IsDictionaryElementsKind(to_kind) ? NormalizeElements() |
| 1527 : TransitionElementsKind(to_kind); |
| 1528 if (maybe_obj->IsFailure()) return maybe_obj; |
| 1529 MaybeObject* maybe_map = map->AsElementsKind(to_kind); |
1520 if (!maybe_map->To(&map)) return maybe_map; | 1530 if (!maybe_map->To(&map)) return maybe_map; |
1521 } | 1531 } |
1522 int total_size = | 1532 int total_size = |
1523 map->NumberOfOwnDescriptors() + map->unused_property_fields(); | 1533 map->NumberOfOwnDescriptors() + map->unused_property_fields(); |
1524 int out_of_object = total_size - map->inobject_properties(); | 1534 int out_of_object = total_size - map->inobject_properties(); |
1525 if (out_of_object != properties()->length()) { | 1535 if (out_of_object != properties()->length()) { |
1526 FixedArray* new_properties; | 1536 FixedArray* new_properties; |
1527 MaybeObject* maybe_properties = properties()->CopySize(out_of_object); | 1537 MaybeObject* maybe_properties = properties()->CopySize(out_of_object); |
1528 if (!maybe_properties->To(&new_properties)) return maybe_properties; | 1538 if (!maybe_properties->To(&new_properties)) return maybe_properties; |
1529 set_properties(new_properties); | 1539 set_properties(new_properties); |
(...skipping 4691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6221 #undef WRITE_UINT32_FIELD | 6231 #undef WRITE_UINT32_FIELD |
6222 #undef READ_SHORT_FIELD | 6232 #undef READ_SHORT_FIELD |
6223 #undef WRITE_SHORT_FIELD | 6233 #undef WRITE_SHORT_FIELD |
6224 #undef READ_BYTE_FIELD | 6234 #undef READ_BYTE_FIELD |
6225 #undef WRITE_BYTE_FIELD | 6235 #undef WRITE_BYTE_FIELD |
6226 | 6236 |
6227 | 6237 |
6228 } } // namespace v8::internal | 6238 } } // namespace v8::internal |
6229 | 6239 |
6230 #endif // V8_OBJECTS_INL_H_ | 6240 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |