Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Unified Diff: src/heap/heap.cc

Issue 1230753004: [Interpreter] Add BytecodeArray class and add to SharedFunctionInfo. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Avoid outputting junk data in BytecodeArray::Print() and ByteArray::Print(). Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index eef37429aad3a4be453517f52c6efc5402bcd203..e862f0873c0bdc27c8dfd8a271044b55e1ac3816 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -2980,6 +2980,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) \
@@ -3044,6 +3045,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) \
@@ -3789,6 +3796,27 @@ 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;
+ }
+
+ BytecodeArray* instance = BytecodeArray::cast(result);
+ instance->set_length(length);
+ CopyBytes(instance->GetDataStartAddress(), raw_bytecodes, length);
+ result->set_map_no_write_barrier(bytecode_array_map());
+ return result;
+}
+
+
void Heap::CreateFillerObjectAt(Address addr, int size) {
if (size == 0) return;
HeapObject* filler = HeapObject::FromAddress(addr);

Powered by Google App Engine
This is Rietveld 408576698