OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 Page* page = Page::FromAddress(RoundUp(address(), Page::kPageSize)); | 474 Page* page = Page::FromAddress(RoundUp(address(), Page::kPageSize)); |
475 return page->ObjectAreaStart(); | 475 return page->ObjectAreaStart(); |
476 } | 476 } |
477 | 477 |
478 | 478 |
479 void LargeObjectChunk::Free(Executability executable) { | 479 void LargeObjectChunk::Free(Executability executable) { |
480 MemoryAllocator::FreeRawMemory(address(), size(), executable); | 480 MemoryAllocator::FreeRawMemory(address(), size(), executable); |
481 } | 481 } |
482 | 482 |
483 // ----------------------------------------------------------------------------- | 483 // ----------------------------------------------------------------------------- |
484 // LargeObjectSpace | 484 // NewSpace |
485 | 485 |
486 MaybeObject* NewSpace::AllocateRawInternal(int size_in_bytes, | 486 MaybeObject* NewSpace::AllocateRawInternal(int size_in_bytes, |
487 AllocationInfo* alloc_info) { | 487 AllocationInfo* alloc_info) { |
488 Address new_top = alloc_info->top + size_in_bytes; | 488 Address new_top = alloc_info->top + size_in_bytes; |
489 if (new_top > alloc_info->limit) return Failure::RetryAfterGC(); | 489 if (new_top > alloc_info->limit) return Failure::RetryAfterGC(); |
490 | 490 |
491 Object* obj = HeapObject::FromAddress(alloc_info->top); | 491 Object* obj = HeapObject::FromAddress(alloc_info->top); |
492 alloc_info->top = new_top; | 492 alloc_info->top = new_top; |
493 #ifdef DEBUG | 493 #ifdef DEBUG |
494 SemiSpace* space = | 494 SemiSpace* space = |
495 (alloc_info == &allocation_info_) ? &to_space_ : &from_space_; | 495 (alloc_info == &allocation_info_) ? &to_space_ : &from_space_; |
496 ASSERT(space->low() <= alloc_info->top | 496 ASSERT(space->low() <= alloc_info->top |
497 && alloc_info->top <= space->high() | 497 && alloc_info->top <= space->high() |
498 && alloc_info->limit == space->high()); | 498 && alloc_info->limit == space->high()); |
499 #endif | 499 #endif |
500 return obj; | 500 return obj; |
501 } | 501 } |
502 | 502 |
503 | 503 |
| 504 template <typename StringType> |
| 505 void NewSpace::ShrinkStringAtAllocationBoundary(String* string, int length) { |
| 506 ASSERT(length <= string->length()); |
| 507 ASSERT(string->IsSeqString()); |
| 508 ASSERT(string->address() + StringType::SizeFor(string->length()) == |
| 509 allocation_info_.top); |
| 510 allocation_info_.top = |
| 511 string->address() + StringType::SizeFor(length); |
| 512 string->set_length(length); |
| 513 } |
| 514 |
| 515 |
504 bool FreeListNode::IsFreeListNode(HeapObject* object) { | 516 bool FreeListNode::IsFreeListNode(HeapObject* object) { |
505 return object->map() == Heap::raw_unchecked_byte_array_map() | 517 return object->map() == Heap::raw_unchecked_byte_array_map() |
506 || object->map() == Heap::raw_unchecked_one_pointer_filler_map() | 518 || object->map() == Heap::raw_unchecked_one_pointer_filler_map() |
507 || object->map() == Heap::raw_unchecked_two_pointer_filler_map(); | 519 || object->map() == Heap::raw_unchecked_two_pointer_filler_map(); |
508 } | 520 } |
509 | 521 |
510 } } // namespace v8::internal | 522 } } // namespace v8::internal |
511 | 523 |
512 #endif // V8_SPACES_INL_H_ | 524 #endif // V8_SPACES_INL_H_ |
OLD | NEW |