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

Unified Diff: src/heap.cc

Issue 304143002: Add support for extended constant pool arrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Sync Created 6 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.h ('k') | src/mark-compact.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index fce6bf88c629ddbcf4ed2388e5c3eb55d048ed4a..7c1d61a0c4791c3ce5f921433cfa3ca0c6b11b25 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -1808,7 +1808,9 @@ Address Heap::DoScavenge(ObjectVisitor* scavenge_visitor,
STATIC_ASSERT((FixedDoubleArray::kHeaderSize &
kDoubleAlignmentMask) == 0); // NOLINT
-STATIC_ASSERT((ConstantPoolArray::kHeaderSize &
+STATIC_ASSERT((ConstantPoolArray::kFirstEntryOffset &
+ kDoubleAlignmentMask) == 0); // NOLINT
+STATIC_ASSERT((ConstantPoolArray::kExtendedFirstOffset &
kDoubleAlignmentMask) == 0); // NOLINT
@@ -4046,23 +4048,26 @@ AllocationResult Heap::CopyFixedDoubleArrayWithMap(FixedDoubleArray* src,
AllocationResult Heap::CopyConstantPoolArrayWithMap(ConstantPoolArray* src,
Map* map) {
- int int64_entries = src->count_of_int64_entries();
- int code_ptr_entries = src->count_of_code_ptr_entries();
- int heap_ptr_entries = src->count_of_heap_ptr_entries();
- int int32_entries = src->count_of_int32_entries();
HeapObject* obj;
- { AllocationResult allocation =
- AllocateConstantPoolArray(int64_entries, code_ptr_entries,
- heap_ptr_entries, int32_entries);
+ 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);
- int size = ConstantPoolArray::SizeFor(
- int64_entries, code_ptr_entries, heap_ptr_entries, int32_entries);
CopyBlock(
- obj->address() + ConstantPoolArray::kLengthOffset,
- src->address() + ConstantPoolArray::kLengthOffset,
- size - ConstantPoolArray::kLengthOffset);
+ obj->address() + ConstantPoolArray::kFirstEntryOffset,
+ src->address() + ConstantPoolArray::kFirstEntryOffset,
+ src->size() - ConstantPoolArray::kFirstEntryOffset);
return obj;
}
@@ -4154,22 +4159,10 @@ AllocationResult Heap::AllocateRawFixedDoubleArray(int length,
}
-AllocationResult Heap::AllocateConstantPoolArray(int number_of_int64_entries,
- int number_of_code_ptr_entries,
- int number_of_heap_ptr_entries,
- int number_of_int32_entries) {
- CHECK(number_of_int64_entries >= 0 &&
- number_of_int64_entries <= ConstantPoolArray::kMaxEntriesPerType &&
- number_of_code_ptr_entries >= 0 &&
- number_of_code_ptr_entries <= ConstantPoolArray::kMaxEntriesPerType &&
- number_of_heap_ptr_entries >= 0 &&
- number_of_heap_ptr_entries <= ConstantPoolArray::kMaxEntriesPerType &&
- number_of_int32_entries >= 0 &&
- number_of_int32_entries <= ConstantPoolArray::kMaxEntriesPerType);
- int size = ConstantPoolArray::SizeFor(number_of_int64_entries,
- number_of_code_ptr_entries,
- number_of_heap_ptr_entries,
- number_of_int32_entries);
+AllocationResult Heap::AllocateConstantPoolArray(
+ const ConstantPoolArray::NumberOfEntries& small) {
+ CHECK(small.are_in_range(0, ConstantPoolArray::kMaxSmallEntriesPerType));
+ int size = ConstantPoolArray::SizeFor(small);
#ifndef V8_HOST_ARCH_64_BIT
size += kPointerSize;
#endif
@@ -4183,39 +4176,47 @@ AllocationResult Heap::AllocateConstantPoolArray(int number_of_int64_entries,
object->set_map_no_write_barrier(constant_pool_array_map());
ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object);
- constant_pool->Init(number_of_int64_entries,
- number_of_code_ptr_entries,
- number_of_heap_ptr_entries,
- number_of_int32_entries);
- if (number_of_code_ptr_entries > 0) {
- int offset =
- constant_pool->OffsetOfElementAt(constant_pool->first_code_ptr_index());
- MemsetPointer(
- reinterpret_cast<Address*>(HeapObject::RawField(constant_pool, offset)),
- isolate()->builtins()->builtin(Builtins::kIllegal)->entry(),
- number_of_code_ptr_entries);
- }
- if (number_of_heap_ptr_entries > 0) {
- int offset =
- constant_pool->OffsetOfElementAt(constant_pool->first_heap_ptr_index());
- MemsetPointer(
- HeapObject::RawField(constant_pool, offset),
- undefined_value(),
- number_of_heap_ptr_entries);
+ 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);
+#ifndef V8_HOST_ARCH_64_BIT
+ size += kPointerSize;
+#endif
+ AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, TENURED);
+
+ HeapObject* object;
+ { AllocationResult allocation = AllocateRaw(size, space, OLD_POINTER_SPACE);
+ if (!allocation.To(&object)) return allocation;
}
+ object = EnsureDoubleAligned(this, object, size);
+ 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() {
- int size = ConstantPoolArray::SizeFor(0, 0, 0, 0);
+ ConstantPoolArray::NumberOfEntries small(0, 0, 0, 0);
+ int size = ConstantPoolArray::SizeFor(small);
HeapObject* result;
{ AllocationResult allocation =
AllocateRaw(size, OLD_DATA_SPACE, OLD_DATA_SPACE);
if (!allocation.To(&result)) return allocation;
}
result->set_map_no_write_barrier(constant_pool_array_map());
- ConstantPoolArray::cast(result)->Init(0, 0, 0, 0);
+ ConstantPoolArray::cast(result)->Init(small);
return result;
}
« no previous file with comments | « src/heap.h ('k') | src/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698