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

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: Use BytecodeArray in bytecode emission path in interpreter. 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 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);

Powered by Google App Engine
This is Rietveld 408576698