Index: src/heap/heap.cc |
diff --git a/src/heap/heap.cc b/src/heap/heap.cc |
index 4660a67dd2847e668ca305a780bc8e80a2482488..18e5ecd6642c75b6a56f37c3746421e939a5dc43 100644 |
--- a/src/heap/heap.cc |
+++ b/src/heap/heap.cc |
@@ -3044,6 +3044,12 @@ bool Heap::CreateInitialMaps() { |
ByteArray* byte_array; |
if (!AllocateByteArray(0, TENURED).To(&byte_array)) return false; |
set_empty_byte_array(byte_array); |
+ |
+ BytecodeArray* bytecode_array; |
+ if (!AllocateBytecodeArray(0, nullptr, TENURED).To(&bytecode_array)) { |
+ return false; |
+ } |
+ set_empty_bytecode_array(bytecode_array); |
} |
#define ALLOCATE_EMPTY_EXTERNAL_ARRAY(Type, type, TYPE, ctype, size) \ |
@@ -3786,6 +3792,28 @@ AllocationResult Heap::AllocateByteArray(int length, PretenureFlag pretenure) { |
} |
+AllocationResult Heap::AllocateBytecodeArray(int length, |
+ const byte* const start, |
+ PretenureFlag pretenure) { |
+ if (length < 0 || length > BytecodeArray::kMaxLength) { |
+ v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); |
+ } |
+ int size = BytecodeArray::SizeFor(length); |
+ AllocationSpace space = SelectSpace(size, pretenure); |
+ HeapObject* result; |
+ { |
+ AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); |
+ if (!allocation.To(&result)) return allocation; |
+ } |
+ |
+ BytecodeArray* instance = BytecodeArray::cast(result); |
+ instance->set_length(length); |
+ CopyBytes(instance->GetDataStartAddress(), start, length); |
+ result->set_map_no_write_barrier(byte_array_map()); |
+ return result; |
+} |
+ |
+ |
void Heap::CreateFillerObjectAt(Address addr, int size) { |
if (size == 0) return; |
HeapObject* filler = HeapObject::FromAddress(addr); |