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 126 matching lines...) Loading... |
137 if (str.length() > SeqOneByteString::kMaxLength) { | 137 if (str.length() > SeqOneByteString::kMaxLength) { |
138 return Failure::OutOfMemoryException(0x2); | 138 return Failure::OutOfMemoryException(0x2); |
139 } | 139 } |
140 // Compute map and object size. | 140 // Compute map and object size. |
141 Map* map = ascii_internalized_string_map(); | 141 Map* map = ascii_internalized_string_map(); |
142 int size = SeqOneByteString::SizeFor(str.length()); | 142 int size = SeqOneByteString::SizeFor(str.length()); |
143 | 143 |
144 // Allocate string. | 144 // Allocate string. |
145 Object* result; | 145 Object* result; |
146 { MaybeObject* maybe_result = (size > Page::kMaxNonCodeHeapObjectSize) | 146 { MaybeObject* maybe_result = (size > Page::kMaxNonCodeHeapObjectSize) |
147 ? lo_space_->AllocateRaw(size, NOT_EXECUTABLE) | 147 ? lo_space_->AllocateRaw(size, VirtualMemory::NOT_EXECUTABLE) |
148 : old_data_space_->AllocateRaw(size); | 148 : old_data_space_->AllocateRaw(size); |
149 if (!maybe_result->ToObject(&result)) return maybe_result; | 149 if (!maybe_result->ToObject(&result)) return maybe_result; |
150 } | 150 } |
151 | 151 |
152 // String maps are all immortal immovable objects. | 152 // String maps are all immortal immovable objects. |
153 reinterpret_cast<HeapObject*>(result)->set_map_no_write_barrier(map); | 153 reinterpret_cast<HeapObject*>(result)->set_map_no_write_barrier(map); |
154 // Set length and hash fields of the allocated string. | 154 // Set length and hash fields of the allocated string. |
155 String* answer = String::cast(result); | 155 String* answer = String::cast(result); |
156 answer->set_length(str.length()); | 156 answer->set_length(str.length()); |
157 answer->set_hash_field(hash_field); | 157 answer->set_hash_field(hash_field); |
(...skipping 13 matching lines...) Loading... |
171 if (str.length() > SeqTwoByteString::kMaxLength) { | 171 if (str.length() > SeqTwoByteString::kMaxLength) { |
172 return Failure::OutOfMemoryException(0x3); | 172 return Failure::OutOfMemoryException(0x3); |
173 } | 173 } |
174 // Compute map and object size. | 174 // Compute map and object size. |
175 Map* map = internalized_string_map(); | 175 Map* map = internalized_string_map(); |
176 int size = SeqTwoByteString::SizeFor(str.length()); | 176 int size = SeqTwoByteString::SizeFor(str.length()); |
177 | 177 |
178 // Allocate string. | 178 // Allocate string. |
179 Object* result; | 179 Object* result; |
180 { MaybeObject* maybe_result = (size > Page::kMaxNonCodeHeapObjectSize) | 180 { MaybeObject* maybe_result = (size > Page::kMaxNonCodeHeapObjectSize) |
181 ? lo_space_->AllocateRaw(size, NOT_EXECUTABLE) | 181 ? lo_space_->AllocateRaw(size, VirtualMemory::NOT_EXECUTABLE) |
182 : old_data_space_->AllocateRaw(size); | 182 : old_data_space_->AllocateRaw(size); |
183 if (!maybe_result->ToObject(&result)) return maybe_result; | 183 if (!maybe_result->ToObject(&result)) return maybe_result; |
184 } | 184 } |
185 | 185 |
186 reinterpret_cast<HeapObject*>(result)->set_map(map); | 186 reinterpret_cast<HeapObject*>(result)->set_map(map); |
187 // Set length and hash fields of the allocated string. | 187 // Set length and hash fields of the allocated string. |
188 String* answer = String::cast(result); | 188 String* answer = String::cast(result); |
189 answer->set_length(str.length()); | 189 answer->set_length(str.length()); |
190 answer->set_hash_field(hash_field); | 190 answer->set_hash_field(hash_field); |
191 | 191 |
(...skipping 43 matching lines...) Loading... |
235 } | 235 } |
236 } | 236 } |
237 | 237 |
238 if (OLD_POINTER_SPACE == space) { | 238 if (OLD_POINTER_SPACE == space) { |
239 result = old_pointer_space_->AllocateRaw(size_in_bytes); | 239 result = old_pointer_space_->AllocateRaw(size_in_bytes); |
240 } else if (OLD_DATA_SPACE == space) { | 240 } else if (OLD_DATA_SPACE == space) { |
241 result = old_data_space_->AllocateRaw(size_in_bytes); | 241 result = old_data_space_->AllocateRaw(size_in_bytes); |
242 } else if (CODE_SPACE == space) { | 242 } else if (CODE_SPACE == space) { |
243 result = code_space_->AllocateRaw(size_in_bytes); | 243 result = code_space_->AllocateRaw(size_in_bytes); |
244 } else if (LO_SPACE == space) { | 244 } else if (LO_SPACE == space) { |
245 result = lo_space_->AllocateRaw(size_in_bytes, NOT_EXECUTABLE); | 245 result = lo_space_->AllocateRaw( |
| 246 size_in_bytes, VirtualMemory::NOT_EXECUTABLE); |
246 } else if (CELL_SPACE == space) { | 247 } else if (CELL_SPACE == space) { |
247 result = cell_space_->AllocateRaw(size_in_bytes); | 248 result = cell_space_->AllocateRaw(size_in_bytes); |
248 } else if (PROPERTY_CELL_SPACE == space) { | 249 } else if (PROPERTY_CELL_SPACE == space) { |
249 result = property_cell_space_->AllocateRaw(size_in_bytes); | 250 result = property_cell_space_->AllocateRaw(size_in_bytes); |
250 } else { | 251 } else { |
251 ASSERT(MAP_SPACE == space); | 252 ASSERT(MAP_SPACE == space); |
252 result = map_space_->AllocateRaw(size_in_bytes); | 253 result = map_space_->AllocateRaw(size_in_bytes); |
253 } | 254 } |
254 if (result->IsFailure()) old_gen_exhausted_ = true; | 255 if (result->IsFailure()) old_gen_exhausted_ = true; |
255 return result; | 256 return result; |
(...skipping 625 matching lines...) Loading... |
881 DisallowAllocationFailure::~DisallowAllocationFailure() { | 882 DisallowAllocationFailure::~DisallowAllocationFailure() { |
882 #ifdef DEBUG | 883 #ifdef DEBUG |
883 HEAP->disallow_allocation_failure_ = old_state_; | 884 HEAP->disallow_allocation_failure_ = old_state_; |
884 #endif | 885 #endif |
885 } | 886 } |
886 | 887 |
887 | 888 |
888 } } // namespace v8::internal | 889 } } // namespace v8::internal |
889 | 890 |
890 #endif // V8_HEAP_INL_H_ | 891 #endif // V8_HEAP_INL_H_ |
OLD | NEW |