OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 22 matching lines...) Expand all Loading... |
33 #include "list-inl.h" | 33 #include "list-inl.h" |
34 #include "objects.h" | 34 #include "objects.h" |
35 #include "v8-counters.h" | 35 #include "v8-counters.h" |
36 #include "store-buffer.h" | 36 #include "store-buffer.h" |
37 #include "store-buffer-inl.h" | 37 #include "store-buffer-inl.h" |
38 | 38 |
39 namespace v8 { | 39 namespace v8 { |
40 namespace internal { | 40 namespace internal { |
41 | 41 |
42 void PromotionQueue::insert(HeapObject* target, int size) { | 42 void PromotionQueue::insert(HeapObject* target, int size) { |
| 43 if (emergency_stack_ != NULL) { |
| 44 emergency_stack_->Add(Entry(target, size)); |
| 45 return; |
| 46 } |
| 47 |
43 if (NewSpacePage::IsAtStart(reinterpret_cast<Address>(rear_))) { | 48 if (NewSpacePage::IsAtStart(reinterpret_cast<Address>(rear_))) { |
44 NewSpacePage* rear_page = | 49 NewSpacePage* rear_page = |
45 NewSpacePage::FromAddress(reinterpret_cast<Address>(rear_)); | 50 NewSpacePage::FromAddress(reinterpret_cast<Address>(rear_)); |
46 ASSERT(!rear_page->prev_page()->is_anchor()); | 51 ASSERT(!rear_page->prev_page()->is_anchor()); |
47 rear_ = reinterpret_cast<intptr_t*>(rear_page->prev_page()->body_limit()); | 52 rear_ = reinterpret_cast<intptr_t*>(rear_page->prev_page()->body_limit()); |
| 53 ActivateGuardIfOnTheSamePage(); |
48 } | 54 } |
| 55 |
| 56 if (guard_) { |
| 57 ASSERT(GetHeadPage() == |
| 58 Page::FromAllocationTop(reinterpret_cast<Address>(limit_))); |
| 59 |
| 60 if ((rear_ - 2) < limit_) { |
| 61 RelocateQueueHead(); |
| 62 emergency_stack_->Add(Entry(target, size)); |
| 63 return; |
| 64 } |
| 65 } |
| 66 |
49 *(--rear_) = reinterpret_cast<intptr_t>(target); | 67 *(--rear_) = reinterpret_cast<intptr_t>(target); |
50 *(--rear_) = size; | 68 *(--rear_) = size; |
51 // Assert no overflow into live objects. | 69 // Assert no overflow into live objects. |
52 #ifdef DEBUG | 70 #ifdef DEBUG |
53 SemiSpace::AssertValidRange(HEAP->new_space()->top(), | 71 SemiSpace::AssertValidRange(HEAP->new_space()->top(), |
54 reinterpret_cast<Address>(rear_)); | 72 reinterpret_cast<Address>(rear_)); |
55 #endif | 73 #endif |
56 } | 74 } |
57 | 75 |
58 | 76 |
| 77 void PromotionQueue::ActivateGuardIfOnTheSamePage() { |
| 78 guard_ = guard_ || |
| 79 heap_->new_space()->active_space()->current_page()->address() == |
| 80 GetHeadPage()->address(); |
| 81 } |
| 82 |
| 83 |
59 int Heap::MaxObjectSizeInPagedSpace() { | 84 int Heap::MaxObjectSizeInPagedSpace() { |
60 return Page::kMaxHeapObjectSize; | 85 return Page::kMaxHeapObjectSize; |
61 } | 86 } |
62 | 87 |
63 | 88 |
64 MaybeObject* Heap::AllocateStringFromUtf8(Vector<const char> str, | 89 MaybeObject* Heap::AllocateStringFromUtf8(Vector<const char> str, |
65 PretenureFlag pretenure) { | 90 PretenureFlag pretenure) { |
66 // Check for ASCII first since this is the common case. | 91 // Check for ASCII first since this is the common case. |
67 if (String::IsAscii(str.start(), str.length())) { | 92 if (String::IsAscii(str.start(), str.length())) { |
68 // If the string is ASCII, we do not need to convert the characters | 93 // If the string is ASCII, we do not need to convert the characters |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 | 701 |
677 | 702 |
678 Heap* _inline_get_heap_() { | 703 Heap* _inline_get_heap_() { |
679 return HEAP; | 704 return HEAP; |
680 } | 705 } |
681 | 706 |
682 | 707 |
683 } } // namespace v8::internal | 708 } } // namespace v8::internal |
684 | 709 |
685 #endif // V8_HEAP_INL_H_ | 710 #endif // V8_HEAP_INL_H_ |
OLD | NEW |