| Index: src/heap.cc
|
| diff --git a/src/heap.cc b/src/heap.cc
|
| index 4cb1adcbc0f1ca083ceb349e4966aadf4ef2af02..78052b91018999a7e2cce31b407632e2ce0219ee 100644
|
| --- a/src/heap.cc
|
| +++ b/src/heap.cc
|
| @@ -4010,12 +4010,24 @@ MaybeObject* Heap::CreateCode(const CodeDesc& desc,
|
| bool immovable,
|
| bool crankshafted,
|
| int prologue_offset) {
|
| - // 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;
|
| MaybeObject* maybe_reloc_info = AllocateByteArray(desc.reloc_size, TENURED);
|
| if (!maybe_reloc_info->To(&reloc_info)) return maybe_reloc_info;
|
|
|
| + ConstantPoolArray* constant_pool;
|
| + if (!FLAG_enable_ool_constant_pool || desc.has_empty_constant_pool()) {
|
| + constant_pool = empty_constant_pool_array();
|
| + } else {
|
| + MaybeObject* maybe_constant_pool = AllocateConstantPoolArray(
|
| + desc.constant_pool_64bit_count,
|
| + desc.constant_pool_code_ptr_count,
|
| + desc.constant_pool_heap_ptr_count,
|
| + desc.constant_pool_32bit_count);
|
| + if (!maybe_constant_pool->To(&constant_pool)) return maybe_constant_pool;
|
| + }
|
| +
|
| // Compute size.
|
| int body_size = RoundUp(desc.instr_size, kObjectAlignment);
|
| int obj_size = Code::SizeFor(body_size);
|
| @@ -4062,7 +4074,11 @@ MaybeObject* Heap::CreateCode(const CodeDesc& desc,
|
| if (code->kind() == Code::OPTIMIZED_FUNCTION) {
|
| code->set_marked_for_deoptimization(false);
|
| }
|
| - code->set_constant_pool(empty_constant_pool_array());
|
| +
|
| + if (FLAG_enable_ool_constant_pool) {
|
| + desc.origin->PopulateConstantPool(constant_pool);
|
| + }
|
| + code->set_constant_pool(constant_pool);
|
|
|
| #ifdef ENABLE_DEBUGGER_SUPPORT
|
| if (code->kind() == Code::FUNCTION) {
|
| @@ -4109,8 +4125,19 @@ MaybeObject* Heap::CopyCode(Code* code) {
|
| Address old_addr = code->address();
|
| Address new_addr = reinterpret_cast<HeapObject*>(result)->address();
|
| CopyBlock(new_addr, old_addr, obj_size);
|
| - // Relocate the copy.
|
| Code* new_code = Code::cast(result);
|
| +
|
| + if (FLAG_enable_ool_constant_pool &&
|
| + code->constant_pool() != empty_constant_pool_array()) {
|
| + // Copy the constant pool too, since edits to the copied code may modify
|
| + // the constant pool.
|
| + maybe_result = CopyConstantPoolArray(code->constant_pool());
|
| + Object* constant_pool_copy;
|
| + if (!maybe_result->ToObject(&constant_pool_copy)) return maybe_result;
|
| + new_code->set_constant_pool(constant_pool_copy);
|
| + }
|
| +
|
| + // Relocate the copy.
|
| ASSERT(!isolate_->code_range()->exists() ||
|
| isolate_->code_range()->contains(code->address()));
|
| new_code->Relocate(new_addr - old_addr);
|
| @@ -4157,6 +4184,15 @@ MaybeObject* Heap::CopyCode(Code* code, Vector<byte> reloc_info) {
|
| Code* new_code = Code::cast(result);
|
| new_code->set_relocation_info(ByteArray::cast(reloc_info_array));
|
|
|
| + if (FLAG_enable_ool_constant_pool) {
|
| + // Copy the constant pool too, since edits to the copied code may modify
|
| + // the constant pool.
|
| + maybe_result = CopyConstantPoolArray(code->constant_pool());
|
| + Object* constant_pool_copy;
|
| + if (!maybe_result->ToObject(&constant_pool_copy)) return maybe_result;
|
| + new_code->set_constant_pool(constant_pool_copy);
|
| + }
|
| +
|
| // Copy patched rinfo.
|
| CopyBytes(new_code->relocation_start(),
|
| reloc_info.start(),
|
|
|