Index: src/heap/heap.cc |
diff --git a/src/heap/heap.cc b/src/heap/heap.cc |
index 4ecb9d70350fbb6523866e7a1cb0a08b40d8832e..7c99bc8a78a5b818bf9bb607a8725ad52624afd7 100644 |
--- a/src/heap/heap.cc |
+++ b/src/heap/heap.cc |
@@ -3001,6 +3001,7 @@ bool Heap::CreateInitialMaps() { |
ALLOCATE_VARSIZE_MAP(FIXED_DOUBLE_ARRAY_TYPE, fixed_double_array) |
ALLOCATE_VARSIZE_MAP(BYTE_ARRAY_TYPE, byte_array) |
+ ALLOCATE_VARSIZE_MAP(BYTECODE_ARRAY_TYPE, bytecode_array) |
ALLOCATE_VARSIZE_MAP(FREE_SPACE_TYPE, free_space) |
#define ALLOCATE_EXTERNAL_ARRAY_MAP(Type, type, TYPE, ctype, size) \ |
@@ -3065,6 +3066,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).To(&bytecode_array)) { |
+ return false; |
+ } |
+ set_empty_bytecode_array(bytecode_array); |
} |
#define ALLOCATE_EMPTY_EXTERNAL_ARRAY(Type, type, TYPE, ctype, size) \ |
@@ -3813,6 +3820,28 @@ AllocationResult Heap::AllocateByteArray(int length, PretenureFlag pretenure) { |
} |
+AllocationResult Heap::AllocateBytecodeArray(int length, |
+ const byte* const raw_bytecodes) { |
+ if (length < 0 || length > BytecodeArray::kMaxLength) { |
+ v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); |
+ } |
+ |
+ int size = BytecodeArray::SizeFor(length); |
+ HeapObject* result; |
+ { |
+ AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE); |
+ if (!allocation.To(&result)) return allocation; |
+ } |
+ |
+ result->set_map_no_write_barrier(bytecode_array_map()); |
+ BytecodeArray* instance = BytecodeArray::cast(result); |
+ instance->set_length(length); |
+ CopyBytes(instance->GetFirstBytecodeAddress(), raw_bytecodes, length); |
+ |
+ return result; |
+} |
+ |
+ |
void Heap::CreateFillerObjectAt(Address addr, int size) { |
if (size == 0) return; |
HeapObject* filler = HeapObject::FromAddress(addr); |