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 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1528 MaybeObject* maybe = GetElementsTransitionMap(GetIsolate(), elements_kind); | 1528 MaybeObject* maybe = GetElementsTransitionMap(GetIsolate(), elements_kind); |
1529 Map* map; | 1529 Map* map; |
1530 if (!maybe->To(&map)) return maybe; | 1530 if (!maybe->To(&map)) return maybe; |
1531 set_map(map); | 1531 set_map(map); |
1532 initialize_elements(); | 1532 initialize_elements(); |
1533 | 1533 |
1534 return this; | 1534 return this; |
1535 } | 1535 } |
1536 | 1536 |
1537 | 1537 |
1538 MaybeObject* JSObject::AllocateStorageForMap(Map* map) { | |
1539 ASSERT(this->map()->inobject_properties() == map->inobject_properties()); | |
1540 ElementsKind obj_kind = this->map()->elements_kind(); | |
1541 ElementsKind map_kind = map->elements_kind(); | |
1542 if (map_kind != obj_kind) { | |
1543 ElementsKind to_kind = map_kind; | |
1544 if (IsMoreGeneralElementsKindTransition(map_kind, obj_kind) || | |
1545 IsDictionaryElementsKind(obj_kind)) { | |
1546 to_kind = obj_kind; | |
1547 } | |
1548 MaybeObject* maybe_obj = | |
1549 IsDictionaryElementsKind(to_kind) ? NormalizeElements() | |
1550 : TransitionElementsKind(to_kind); | |
1551 if (maybe_obj->IsFailure()) return maybe_obj; | |
1552 MaybeObject* maybe_map = map->AsElementsKind(to_kind); | |
1553 if (!maybe_map->To(&map)) return maybe_map; | |
1554 } | |
1555 int total_size = | |
1556 map->NumberOfOwnDescriptors() + map->unused_property_fields(); | |
1557 int out_of_object = total_size - map->inobject_properties(); | |
1558 if (out_of_object != properties()->length()) { | |
1559 FixedArray* new_properties; | |
1560 MaybeObject* maybe_properties = properties()->CopySize(out_of_object); | |
1561 if (!maybe_properties->To(&new_properties)) return maybe_properties; | |
1562 set_properties(new_properties); | |
1563 } | |
1564 set_map(map); | |
1565 return this; | |
1566 } | |
1567 | |
1568 | |
1569 MaybeObject* JSObject::TryMigrateInstance() { | 1538 MaybeObject* JSObject::TryMigrateInstance() { |
1570 Map* new_map = map()->CurrentMapForDeprecated(); | 1539 Map* new_map = map()->CurrentMapForDeprecated(); |
1571 if (new_map == NULL) return Smi::FromInt(0); | 1540 if (new_map == NULL) return Smi::FromInt(0); |
1572 Map* original_map = map(); | 1541 Map* original_map = map(); |
1573 MaybeObject* maybe_result = MigrateToMap(new_map); | 1542 MaybeObject* maybe_result = MigrateToMap(new_map); |
1574 JSObject* result; | 1543 JSObject* result; |
1575 if (FLAG_trace_migration && maybe_result->To(&result)) { | 1544 if (FLAG_trace_migration && maybe_result->To(&result)) { |
1576 PrintInstanceMigration(stdout, original_map, result->map()); | 1545 PrintInstanceMigration(stdout, original_map, result->map()); |
1577 } | 1546 } |
1578 return maybe_result; | 1547 return maybe_result; |
(...skipping 4705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6284 #undef WRITE_UINT32_FIELD | 6253 #undef WRITE_UINT32_FIELD |
6285 #undef READ_SHORT_FIELD | 6254 #undef READ_SHORT_FIELD |
6286 #undef WRITE_SHORT_FIELD | 6255 #undef WRITE_SHORT_FIELD |
6287 #undef READ_BYTE_FIELD | 6256 #undef READ_BYTE_FIELD |
6288 #undef WRITE_BYTE_FIELD | 6257 #undef WRITE_BYTE_FIELD |
6289 | 6258 |
6290 | 6259 |
6291 } } // namespace v8::internal | 6260 } } // namespace v8::internal |
6292 | 6261 |
6293 #endif // V8_OBJECTS_INL_H_ | 6262 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |