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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 void PromotionQueue::insert(HeapObject* target, int size) { | 42 void PromotionQueue::insert(HeapObject* target, int size) { |
43 if (emergency_stack_ != NULL) { | 43 if (emergency_stack_ != NULL) { |
44 emergency_stack_->Add(Entry(target, size)); | 44 emergency_stack_->Add(Entry(target, size)); |
45 return; | 45 return; |
46 } | 46 } |
47 | 47 |
48 if (NewSpacePage::IsAtStart(reinterpret_cast<Address>(rear_))) { | 48 if (NewSpacePage::IsAtStart(reinterpret_cast<Address>(rear_))) { |
49 NewSpacePage* rear_page = | 49 NewSpacePage* rear_page = |
50 NewSpacePage::FromAddress(reinterpret_cast<Address>(rear_)); | 50 NewSpacePage::FromAddress(reinterpret_cast<Address>(rear_)); |
51 ASSERT(!rear_page->prev_page()->is_anchor()); | 51 ASSERT(!rear_page->prev_page()->is_anchor()); |
52 rear_ = reinterpret_cast<intptr_t*>(rear_page->prev_page()->body_limit()); | 52 rear_ = reinterpret_cast<intptr_t*>(rear_page->prev_page()->area_end()); |
53 ActivateGuardIfOnTheSamePage(); | 53 ActivateGuardIfOnTheSamePage(); |
54 } | 54 } |
55 | 55 |
56 if (guard_) { | 56 if (guard_) { |
57 ASSERT(GetHeadPage() == | 57 ASSERT(GetHeadPage() == |
58 Page::FromAllocationTop(reinterpret_cast<Address>(limit_))); | 58 Page::FromAllocationTop(reinterpret_cast<Address>(limit_))); |
59 | 59 |
60 if ((rear_ - 2) < limit_) { | 60 if ((rear_ - 2) < limit_) { |
61 RelocateQueueHead(); | 61 RelocateQueueHead(); |
62 emergency_stack_->Add(Entry(target, size)); | 62 emergency_stack_->Add(Entry(target, size)); |
(...skipping 11 matching lines...) Expand all Loading... |
74 } | 74 } |
75 | 75 |
76 | 76 |
77 void PromotionQueue::ActivateGuardIfOnTheSamePage() { | 77 void PromotionQueue::ActivateGuardIfOnTheSamePage() { |
78 guard_ = guard_ || | 78 guard_ = guard_ || |
79 heap_->new_space()->active_space()->current_page()->address() == | 79 heap_->new_space()->active_space()->current_page()->address() == |
80 GetHeadPage()->address(); | 80 GetHeadPage()->address(); |
81 } | 81 } |
82 | 82 |
83 | 83 |
84 int Heap::MaxObjectSizeInPagedSpace() { | |
85 return Page::kMaxHeapObjectSize; | |
86 } | |
87 | |
88 | |
89 MaybeObject* Heap::AllocateStringFromUtf8(Vector<const char> str, | 84 MaybeObject* Heap::AllocateStringFromUtf8(Vector<const char> str, |
90 PretenureFlag pretenure) { | 85 PretenureFlag pretenure) { |
91 // Check for ASCII first since this is the common case. | 86 // Check for ASCII first since this is the common case. |
92 if (String::IsAscii(str.start(), str.length())) { | 87 if (String::IsAscii(str.start(), str.length())) { |
93 // If the string is ASCII, we do not need to convert the characters | 88 // If the string is ASCII, we do not need to convert the characters |
94 // since UTF8 is backwards compatible with ASCII. | 89 // since UTF8 is backwards compatible with ASCII. |
95 return AllocateStringFromAscii(str, pretenure); | 90 return AllocateStringFromAscii(str, pretenure); |
96 } | 91 } |
97 // Non-ASCII and we need to decode. | 92 // Non-ASCII and we need to decode. |
98 return AllocateStringFromUtf8Slow(str, pretenure); | 93 return AllocateStringFromUtf8Slow(str, pretenure); |
(...skipping 13 matching lines...) Expand all Loading... |
112 uint32_t hash_field) { | 107 uint32_t hash_field) { |
113 if (str.length() > SeqAsciiString::kMaxLength) { | 108 if (str.length() > SeqAsciiString::kMaxLength) { |
114 return Failure::OutOfMemoryException(); | 109 return Failure::OutOfMemoryException(); |
115 } | 110 } |
116 // Compute map and object size. | 111 // Compute map and object size. |
117 Map* map = ascii_symbol_map(); | 112 Map* map = ascii_symbol_map(); |
118 int size = SeqAsciiString::SizeFor(str.length()); | 113 int size = SeqAsciiString::SizeFor(str.length()); |
119 | 114 |
120 // Allocate string. | 115 // Allocate string. |
121 Object* result; | 116 Object* result; |
122 { MaybeObject* maybe_result = (size > MaxObjectSizeInPagedSpace()) | 117 { MaybeObject* maybe_result = (size > Page::kMaxNonCodeHeapObjectSize) |
123 ? lo_space_->AllocateRaw(size, NOT_EXECUTABLE) | 118 ? lo_space_->AllocateRaw(size, NOT_EXECUTABLE) |
124 : old_data_space_->AllocateRaw(size); | 119 : old_data_space_->AllocateRaw(size); |
125 if (!maybe_result->ToObject(&result)) return maybe_result; | 120 if (!maybe_result->ToObject(&result)) return maybe_result; |
126 } | 121 } |
127 | 122 |
128 // String maps are all immortal immovable objects. | 123 // String maps are all immortal immovable objects. |
129 reinterpret_cast<HeapObject*>(result)->set_map_no_write_barrier(map); | 124 reinterpret_cast<HeapObject*>(result)->set_map_no_write_barrier(map); |
130 // Set length and hash fields of the allocated string. | 125 // Set length and hash fields of the allocated string. |
131 String* answer = String::cast(result); | 126 String* answer = String::cast(result); |
132 answer->set_length(str.length()); | 127 answer->set_length(str.length()); |
(...skipping 13 matching lines...) Expand all Loading... |
146 uint32_t hash_field) { | 141 uint32_t hash_field) { |
147 if (str.length() > SeqTwoByteString::kMaxLength) { | 142 if (str.length() > SeqTwoByteString::kMaxLength) { |
148 return Failure::OutOfMemoryException(); | 143 return Failure::OutOfMemoryException(); |
149 } | 144 } |
150 // Compute map and object size. | 145 // Compute map and object size. |
151 Map* map = symbol_map(); | 146 Map* map = symbol_map(); |
152 int size = SeqTwoByteString::SizeFor(str.length()); | 147 int size = SeqTwoByteString::SizeFor(str.length()); |
153 | 148 |
154 // Allocate string. | 149 // Allocate string. |
155 Object* result; | 150 Object* result; |
156 { MaybeObject* maybe_result = (size > MaxObjectSizeInPagedSpace()) | 151 { MaybeObject* maybe_result = (size > Page::kMaxNonCodeHeapObjectSize) |
157 ? lo_space_->AllocateRaw(size, NOT_EXECUTABLE) | 152 ? lo_space_->AllocateRaw(size, NOT_EXECUTABLE) |
158 : old_data_space_->AllocateRaw(size); | 153 : old_data_space_->AllocateRaw(size); |
159 if (!maybe_result->ToObject(&result)) return maybe_result; | 154 if (!maybe_result->ToObject(&result)) return maybe_result; |
160 } | 155 } |
161 | 156 |
162 reinterpret_cast<HeapObject*>(result)->set_map(map); | 157 reinterpret_cast<HeapObject*>(result)->set_map(map); |
163 // Set length and hash fields of the allocated string. | 158 // Set length and hash fields of the allocated string. |
164 String* answer = String::cast(result); | 159 String* answer = String::cast(result); |
165 answer->set_length(str.length()); | 160 answer->set_length(str.length()); |
166 answer->set_hash_field(hash_field); | 161 answer->set_hash_field(hash_field); |
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 AssertNoAllocation::~AssertNoAllocation() { } | 782 AssertNoAllocation::~AssertNoAllocation() { } |
788 DisableAssertNoAllocation::DisableAssertNoAllocation() { } | 783 DisableAssertNoAllocation::DisableAssertNoAllocation() { } |
789 DisableAssertNoAllocation::~DisableAssertNoAllocation() { } | 784 DisableAssertNoAllocation::~DisableAssertNoAllocation() { } |
790 | 785 |
791 #endif | 786 #endif |
792 | 787 |
793 | 788 |
794 } } // namespace v8::internal | 789 } } // namespace v8::internal |
795 | 790 |
796 #endif // V8_HEAP_INL_H_ | 791 #endif // V8_HEAP_INL_H_ |
OLD | NEW |