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

Unified Diff: src/heap/heap.cc

Issue 1155703006: Revert of Embedded constant pools. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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/heap-inl.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 47fef8c5a2edbb296612a38e08afe7afea7a9e94..ff9cc5b46b4cf1be4cb8eb636021ef1b00922d64 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -1976,6 +1976,10 @@
STATIC_ASSERT((FixedDoubleArray::kHeaderSize & kDoubleAlignmentMask) ==
0); // NOLINT
+STATIC_ASSERT((ConstantPoolArray::kFirstEntryOffset & kDoubleAlignmentMask) ==
+ 0); // NOLINT
+STATIC_ASSERT((ConstantPoolArray::kExtendedFirstOffset &
+ kDoubleAlignmentMask) == 0); // NOLINT
STATIC_ASSERT((FixedTypedArrayBase::kDataOffset & kDoubleAlignmentMask) ==
0); // NOLINT
#ifdef V8_HOST_ARCH_32_BIT
@@ -2609,6 +2613,8 @@
ALLOCATE_PARTIAL_MAP(FIXED_ARRAY_TYPE, kVariableSizeSentinel, fixed_array);
ALLOCATE_PARTIAL_MAP(ODDBALL_TYPE, Oddball::kSize, undefined);
ALLOCATE_PARTIAL_MAP(ODDBALL_TYPE, Oddball::kSize, null);
+ ALLOCATE_PARTIAL_MAP(CONSTANT_POOL_ARRAY_TYPE, kVariableSizeSentinel,
+ constant_pool_array);
#undef ALLOCATE_PARTIAL_MAP
}
@@ -2644,6 +2650,13 @@
if (!allocation.To(&obj)) return false;
}
set_empty_descriptor_array(DescriptorArray::cast(obj));
+
+ // Allocate the constant pool array.
+ {
+ AllocationResult allocation = AllocateEmptyConstantPoolArray();
+ if (!allocation.To(&obj)) return false;
+ }
+ set_empty_constant_pool_array(ConstantPoolArray::cast(obj));
// Fix the instance_descriptors for the existing maps.
meta_map()->set_code_cache(empty_fixed_array());
@@ -2681,6 +2694,16 @@
null_map()->set_layout_descriptor(LayoutDescriptor::FastPointerLayout());
}
+ constant_pool_array_map()->set_code_cache(empty_fixed_array());
+ constant_pool_array_map()->set_dependent_code(
+ DependentCode::cast(empty_fixed_array()));
+ constant_pool_array_map()->set_raw_transitions(Smi::FromInt(0));
+ constant_pool_array_map()->set_instance_descriptors(empty_descriptor_array());
+ if (FLAG_unbox_double_fields) {
+ constant_pool_array_map()->set_layout_descriptor(
+ LayoutDescriptor::FastPointerLayout());
+ }
+
// Fix prototype object for existing maps.
meta_map()->set_prototype(null_value());
meta_map()->set_constructor_or_backpointer(null_value());
@@ -2693,6 +2716,9 @@
null_map()->set_prototype(null_value());
null_map()->set_constructor_or_backpointer(null_value());
+
+ constant_pool_array_map()->set_prototype(null_value());
+ constant_pool_array_map()->set_constructor_or_backpointer(null_value());
{ // Map allocation
#define ALLOCATE_MAP(instance_type, size, field_name) \
@@ -3764,6 +3790,16 @@
AllocationResult Heap::CopyCode(Code* code) {
AllocationResult allocation;
+ HeapObject* new_constant_pool;
+ if (FLAG_enable_ool_constant_pool &&
+ code->constant_pool() != empty_constant_pool_array()) {
+ // Copy the constant pool, since edits to the copied code may modify
+ // the constant pool.
+ allocation = CopyConstantPoolArray(code->constant_pool());
+ if (!allocation.To(&new_constant_pool)) return allocation;
+ } else {
+ new_constant_pool = empty_constant_pool_array();
+ }
HeapObject* result = NULL;
// Allocate an object the same size as the code object.
@@ -3776,6 +3812,9 @@
Address new_addr = result->address();
CopyBlock(new_addr, old_addr, obj_size);
Code* new_code = Code::cast(result);
+
+ // Update the constant pool.
+ new_code->set_constant_pool(new_constant_pool);
// Relocate the copy.
DCHECK(IsAligned(bit_cast<intptr_t>(new_code->address()), kCodeAlignment));
@@ -3787,14 +3826,24 @@
AllocationResult Heap::CopyCode(Code* code, Vector<byte> reloc_info) {
- // Allocate ByteArray before the Code object, so that we do not risk
- // leaving uninitialized Code object (and breaking the heap).
+ // Allocate ByteArray and ConstantPoolArray before the Code object, so that we
+ // do not risk leaving uninitialized Code object (and breaking the heap).
ByteArray* reloc_info_array;
{
AllocationResult allocation =
AllocateByteArray(reloc_info.length(), TENURED);
if (!allocation.To(&reloc_info_array)) return allocation;
}
+ HeapObject* new_constant_pool;
+ if (FLAG_enable_ool_constant_pool &&
+ code->constant_pool() != empty_constant_pool_array()) {
+ // Copy the constant pool, since edits to the copied code may modify
+ // the constant pool.
+ AllocationResult allocation = CopyConstantPoolArray(code->constant_pool());
+ if (!allocation.To(&new_constant_pool)) return allocation;
+ } else {
+ new_constant_pool = empty_constant_pool_array();
+ }
int new_body_size = RoundUp(code->instruction_size(), kObjectAlignment);
@@ -3818,6 +3867,9 @@
Code* new_code = Code::cast(result);
new_code->set_relocation_info(reloc_info_array);
+
+ // Update constant pool.
+ new_code->set_constant_pool(new_constant_pool);
// Copy patched rinfo.
CopyBytes(new_code->relocation_start(), reloc_info.start(),
@@ -4311,6 +4363,31 @@
}
+AllocationResult Heap::CopyConstantPoolArrayWithMap(ConstantPoolArray* src,
+ Map* map) {
+ HeapObject* obj;
+ if (src->is_extended_layout()) {
+ ConstantPoolArray::NumberOfEntries small(src,
+ ConstantPoolArray::SMALL_SECTION);
+ ConstantPoolArray::NumberOfEntries extended(
+ src, ConstantPoolArray::EXTENDED_SECTION);
+ AllocationResult allocation =
+ AllocateExtendedConstantPoolArray(small, extended);
+ if (!allocation.To(&obj)) return allocation;
+ } else {
+ ConstantPoolArray::NumberOfEntries small(src,
+ ConstantPoolArray::SMALL_SECTION);
+ AllocationResult allocation = AllocateConstantPoolArray(small);
+ if (!allocation.To(&obj)) return allocation;
+ }
+ obj->set_map_no_write_barrier(map);
+ CopyBlock(obj->address() + ConstantPoolArray::kFirstEntryOffset,
+ src->address() + ConstantPoolArray::kFirstEntryOffset,
+ src->size() - ConstantPoolArray::kFirstEntryOffset);
+ return obj;
+}
+
+
AllocationResult Heap::AllocateRawFixedArray(int length,
PretenureFlag pretenure) {
if (length < 0 || length > FixedArray::kMaxLength) {
@@ -4396,6 +4473,64 @@
}
return object;
+}
+
+
+AllocationResult Heap::AllocateConstantPoolArray(
+ const ConstantPoolArray::NumberOfEntries& small) {
+ CHECK(small.are_in_range(0, ConstantPoolArray::kMaxSmallEntriesPerType));
+ int size = ConstantPoolArray::SizeFor(small);
+ AllocationSpace space = SelectSpace(size, TENURED);
+
+ HeapObject* object = nullptr;
+ {
+ AllocationResult allocation =
+ AllocateRaw(size, space, OLD_SPACE, kDoubleAligned);
+ if (!allocation.To(&object)) return allocation;
+ }
+ object->set_map_no_write_barrier(constant_pool_array_map());
+
+ ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object);
+ constant_pool->Init(small);
+ constant_pool->ClearPtrEntries(isolate());
+ return constant_pool;
+}
+
+
+AllocationResult Heap::AllocateExtendedConstantPoolArray(
+ const ConstantPoolArray::NumberOfEntries& small,
+ const ConstantPoolArray::NumberOfEntries& extended) {
+ CHECK(small.are_in_range(0, ConstantPoolArray::kMaxSmallEntriesPerType));
+ CHECK(extended.are_in_range(0, kMaxInt));
+ int size = ConstantPoolArray::SizeForExtended(small, extended);
+ AllocationSpace space = SelectSpace(size, TENURED);
+
+ HeapObject* object;
+ {
+ AllocationResult allocation =
+ AllocateRaw(size, space, OLD_SPACE, kDoubleAligned);
+ if (!allocation.To(&object)) return allocation;
+ }
+ object->set_map_no_write_barrier(constant_pool_array_map());
+
+ ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object);
+ constant_pool->InitExtended(small, extended);
+ constant_pool->ClearPtrEntries(isolate());
+ return constant_pool;
+}
+
+
+AllocationResult Heap::AllocateEmptyConstantPoolArray() {
+ ConstantPoolArray::NumberOfEntries small(0, 0, 0, 0);
+ int size = ConstantPoolArray::SizeFor(small);
+ HeapObject* result = NULL;
+ {
+ AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE);
+ if (!allocation.To(&result)) return allocation;
+ }
+ result->set_map_no_write_barrier(constant_pool_array_map());
+ ConstantPoolArray::cast(result)->Init(small);
+ return result;
}
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/heap-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698