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 5317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5328 reinterpret_cast<FixedArray*>(result)->set_length(0); | 5328 reinterpret_cast<FixedArray*>(result)->set_length(0); |
5329 return result; | 5329 return result; |
5330 } | 5330 } |
5331 | 5331 |
5332 | 5332 |
5333 MaybeObject* Heap::AllocateEmptyExternalArray(ExternalArrayType array_type) { | 5333 MaybeObject* Heap::AllocateEmptyExternalArray(ExternalArrayType array_type) { |
5334 return AllocateExternalArray(0, array_type, NULL, TENURED); | 5334 return AllocateExternalArray(0, array_type, NULL, TENURED); |
5335 } | 5335 } |
5336 | 5336 |
5337 | 5337 |
5338 MaybeObject* Heap::AllocateRawFixedArray(int length) { | |
5339 if (length < 0 || length > FixedArray::kMaxLength) { | |
5340 return Failure::OutOfMemoryException(0xd); | |
5341 } | |
5342 ASSERT(length > 0); | |
5343 // Use the general function if we're forced to always allocate. | |
5344 if (always_allocate()) return AllocateFixedArray(length, TENURED); | |
5345 // Allocate the raw data for a fixed array. | |
5346 int size = FixedArray::SizeFor(length); | |
5347 return size <= Page::kMaxNonCodeHeapObjectSize | |
5348 ? new_space_.AllocateRaw(size) | |
5349 : lo_space_->AllocateRaw(size, NOT_EXECUTABLE); | |
5350 } | |
5351 | |
5352 | |
5353 MaybeObject* Heap::CopyFixedArrayWithMap(FixedArray* src, Map* map) { | 5338 MaybeObject* Heap::CopyFixedArrayWithMap(FixedArray* src, Map* map) { |
5354 int len = src->length(); | 5339 int len = src->length(); |
5355 Object* obj; | 5340 Object* obj; |
5356 { MaybeObject* maybe_obj = AllocateRawFixedArray(len); | 5341 { MaybeObject* maybe_obj = AllocateRawFixedArray(len, NOT_TENURED); |
5357 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 5342 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
5358 } | 5343 } |
5359 if (InNewSpace(obj)) { | 5344 if (InNewSpace(obj)) { |
5360 HeapObject* dst = HeapObject::cast(obj); | 5345 HeapObject* dst = HeapObject::cast(obj); |
5361 dst->set_map_no_write_barrier(map); | 5346 dst->set_map_no_write_barrier(map); |
5362 CopyBlock(dst->address() + kPointerSize, | 5347 CopyBlock(dst->address() + kPointerSize, |
5363 src->address() + kPointerSize, | 5348 src->address() + kPointerSize, |
5364 FixedArray::SizeFor(len) - kPointerSize); | 5349 FixedArray::SizeFor(len) - kPointerSize); |
5365 return obj; | 5350 return obj; |
5366 } | 5351 } |
(...skipping 30 matching lines...) Expand all Loading... |
5397 if (length < 0 || length > FixedArray::kMaxLength) { | 5382 if (length < 0 || length > FixedArray::kMaxLength) { |
5398 return Failure::OutOfMemoryException(0xe); | 5383 return Failure::OutOfMemoryException(0xe); |
5399 } | 5384 } |
5400 int size = FixedArray::SizeFor(length); | 5385 int size = FixedArray::SizeFor(length); |
5401 AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, pretenure); | 5386 AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, pretenure); |
5402 | 5387 |
5403 return AllocateRaw(size, space, OLD_POINTER_SPACE); | 5388 return AllocateRaw(size, space, OLD_POINTER_SPACE); |
5404 } | 5389 } |
5405 | 5390 |
5406 | 5391 |
5407 MUST_USE_RESULT static MaybeObject* AllocateFixedArrayWithFiller( | 5392 MaybeObject* Heap::AllocateFixedArrayWithFiller(int length, |
5408 Heap* heap, | 5393 PretenureFlag pretenure, |
5409 int length, | 5394 Object* filler) { |
5410 PretenureFlag pretenure, | |
5411 Object* filler) { | |
5412 ASSERT(length >= 0); | 5395 ASSERT(length >= 0); |
5413 ASSERT(heap->empty_fixed_array()->IsFixedArray()); | 5396 ASSERT(empty_fixed_array()->IsFixedArray()); |
5414 if (length == 0) return heap->empty_fixed_array(); | 5397 if (length == 0) return empty_fixed_array(); |
5415 | 5398 |
5416 ASSERT(!heap->InNewSpace(filler)); | 5399 ASSERT(!InNewSpace(filler)); |
5417 Object* result; | 5400 Object* result; |
5418 { MaybeObject* maybe_result = heap->AllocateRawFixedArray(length, pretenure); | 5401 { MaybeObject* maybe_result = AllocateRawFixedArray(length, pretenure); |
5419 if (!maybe_result->ToObject(&result)) return maybe_result; | 5402 if (!maybe_result->ToObject(&result)) return maybe_result; |
5420 } | 5403 } |
5421 | 5404 |
5422 HeapObject::cast(result)->set_map_no_write_barrier(heap->fixed_array_map()); | 5405 HeapObject::cast(result)->set_map_no_write_barrier(fixed_array_map()); |
5423 FixedArray* array = FixedArray::cast(result); | 5406 FixedArray* array = FixedArray::cast(result); |
5424 array->set_length(length); | 5407 array->set_length(length); |
5425 MemsetPointer(array->data_start(), filler, length); | 5408 MemsetPointer(array->data_start(), filler, length); |
5426 return array; | 5409 return array; |
5427 } | 5410 } |
5428 | 5411 |
5429 | 5412 |
5430 MaybeObject* Heap::AllocateFixedArray(int length, PretenureFlag pretenure) { | 5413 MaybeObject* Heap::AllocateFixedArray(int length, PretenureFlag pretenure) { |
5431 return AllocateFixedArrayWithFiller(this, | 5414 return AllocateFixedArrayWithFiller(length, pretenure, undefined_value()); |
5432 length, | |
5433 pretenure, | |
5434 undefined_value()); | |
5435 } | 5415 } |
5436 | 5416 |
5437 | 5417 |
5438 MaybeObject* Heap::AllocateFixedArrayWithHoles(int length, | 5418 MaybeObject* Heap::AllocateFixedArrayWithHoles(int length, |
5439 PretenureFlag pretenure) { | 5419 PretenureFlag pretenure) { |
5440 return AllocateFixedArrayWithFiller(this, | 5420 return AllocateFixedArrayWithFiller(length, pretenure, the_hole_value()); |
5441 length, | |
5442 pretenure, | |
5443 the_hole_value()); | |
5444 } | 5421 } |
5445 | 5422 |
5446 | 5423 |
5447 MaybeObject* Heap::AllocateUninitializedFixedArray(int length) { | 5424 MaybeObject* Heap::AllocateUninitializedFixedArray(int length) { |
5448 if (length == 0) return empty_fixed_array(); | 5425 if (length == 0) return empty_fixed_array(); |
5449 | 5426 |
5450 Object* obj; | 5427 Object* obj; |
5451 { MaybeObject* maybe_obj = AllocateRawFixedArray(length); | 5428 { MaybeObject* maybe_obj = AllocateRawFixedArray(length, NOT_TENURED); |
5452 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 5429 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
5453 } | 5430 } |
5454 | 5431 |
5455 reinterpret_cast<FixedArray*>(obj)->set_map_no_write_barrier( | 5432 reinterpret_cast<FixedArray*>(obj)->set_map_no_write_barrier( |
5456 fixed_array_map()); | 5433 fixed_array_map()); |
5457 FixedArray::cast(obj)->set_length(length); | 5434 FixedArray::cast(obj)->set_length(length); |
5458 return obj; | 5435 return obj; |
5459 } | 5436 } |
5460 | 5437 |
5461 | 5438 |
(...skipping 2433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7895 if (FLAG_concurrent_recompilation) { | 7872 if (FLAG_concurrent_recompilation) { |
7896 heap_->relocation_mutex_->Lock(); | 7873 heap_->relocation_mutex_->Lock(); |
7897 #ifdef DEBUG | 7874 #ifdef DEBUG |
7898 heap_->relocation_mutex_locked_by_optimizer_thread_ = | 7875 heap_->relocation_mutex_locked_by_optimizer_thread_ = |
7899 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); | 7876 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); |
7900 #endif // DEBUG | 7877 #endif // DEBUG |
7901 } | 7878 } |
7902 } | 7879 } |
7903 | 7880 |
7904 } } // namespace v8::internal | 7881 } } // namespace v8::internal |
OLD | NEW |