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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 // Only the latter two contain non-map-word pointers to heap objects. | 411 // Only the latter two contain non-map-word pointers to heap objects. |
412 return ((type & kIsIndirectStringMask) == kIsIndirectStringTag) | 412 return ((type & kIsIndirectStringMask) == kIsIndirectStringTag) |
413 ? OLD_POINTER_SPACE | 413 ? OLD_POINTER_SPACE |
414 : OLD_DATA_SPACE; | 414 : OLD_DATA_SPACE; |
415 } else { | 415 } else { |
416 return (type <= LAST_DATA_TYPE) ? OLD_DATA_SPACE : OLD_POINTER_SPACE; | 416 return (type <= LAST_DATA_TYPE) ? OLD_DATA_SPACE : OLD_POINTER_SPACE; |
417 } | 417 } |
418 } | 418 } |
419 | 419 |
420 | 420 |
421 bool Heap::AllowedToBeMigrated(HeapObject* object, AllocationSpace dst) { | 421 bool Heap::AllowedToBeMigrated(HeapObject* obj, AllocationSpace dst) { |
422 // Object migration is governed by the following rules: | 422 // Object migration is governed by the following rules: |
423 // | 423 // |
424 // 1) Objects in new-space can be migrated to one of the old spaces | 424 // 1) Objects in new-space can be migrated to one of the old spaces |
425 // that matches their target space or they stay in new-space. | 425 // that matches their target space or they stay in new-space. |
426 // 2) Objects in old-space stay in the same space when migrating. | 426 // 2) Objects in old-space stay in the same space when migrating. |
427 // 3) Fillers (two or more words) can migrate due to left-trimming of | 427 // 3) Fillers (two or more words) can migrate due to left-trimming of |
428 // fixed arrays in new-space, old-data-space and old-pointer-space. | 428 // fixed arrays in new-space, old-data-space and old-pointer-space. |
429 // 4) Fillers (one word) can never migrate, they are skipped by | 429 // 4) Fillers (one word) can never migrate, they are skipped by |
430 // incremental marking explicitly to prevent invalid pattern. | 430 // incremental marking explicitly to prevent invalid pattern. |
| 431 // 5) Short external strings can end up in old pointer space when a cons |
| 432 // string in old pointer space is made external (String::MakeExternal). |
431 // | 433 // |
432 // Since this function is used for debugging only, we do not place | 434 // Since this function is used for debugging only, we do not place |
433 // asserts here, but check everything explicitly. | 435 // asserts here, but check everything explicitly. |
434 if (object->map() == one_pointer_filler_map()) return false; | 436 if (obj->map() == one_pointer_filler_map()) return false; |
435 InstanceType type = object->map()->instance_type(); | 437 InstanceType type = obj->map()->instance_type(); |
436 MemoryChunk* chunk = MemoryChunk::FromAddress(object->address()); | 438 MemoryChunk* chunk = MemoryChunk::FromAddress(obj->address()); |
437 AllocationSpace src = chunk->owner()->identity(); | 439 AllocationSpace src = chunk->owner()->identity(); |
438 switch (src) { | 440 switch (src) { |
439 case NEW_SPACE: | 441 case NEW_SPACE: |
440 return dst == src || dst == TargetSpaceId(type); | 442 return dst == src || dst == TargetSpaceId(type); |
441 case OLD_POINTER_SPACE: | 443 case OLD_POINTER_SPACE: |
442 return dst == src && (dst == TargetSpaceId(type) || object->IsFiller()); | 444 return dst == src && |
| 445 (dst == TargetSpaceId(type) || obj->IsFiller() || |
| 446 (obj->IsExternalString() && ExternalString::cast(obj)->is_short())); |
443 case OLD_DATA_SPACE: | 447 case OLD_DATA_SPACE: |
444 return dst == src && dst == TargetSpaceId(type); | 448 return dst == src && dst == TargetSpaceId(type); |
445 case CODE_SPACE: | 449 case CODE_SPACE: |
446 return dst == src && type == CODE_TYPE; | 450 return dst == src && type == CODE_TYPE; |
447 case MAP_SPACE: | 451 case MAP_SPACE: |
448 case CELL_SPACE: | 452 case CELL_SPACE: |
449 case PROPERTY_CELL_SPACE: | 453 case PROPERTY_CELL_SPACE: |
450 case LO_SPACE: | 454 case LO_SPACE: |
451 return false; | 455 return false; |
452 } | 456 } |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 #ifdef DEBUG | 842 #ifdef DEBUG |
839 Isolate* isolate = Isolate::Current(); | 843 Isolate* isolate = Isolate::Current(); |
840 isolate->heap()->disallow_allocation_failure_ = old_state_; | 844 isolate->heap()->disallow_allocation_failure_ = old_state_; |
841 #endif | 845 #endif |
842 } | 846 } |
843 | 847 |
844 | 848 |
845 } } // namespace v8::internal | 849 } } // namespace v8::internal |
846 | 850 |
847 #endif // V8_HEAP_INL_H_ | 851 #endif // V8_HEAP_INL_H_ |
OLD | NEW |