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

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: Fix pedantic build (take2). 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
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/objects-visiting.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/objects-visiting.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698