Chromium Code Reviews| Index: src/heap.cc |
| diff --git a/src/heap.cc b/src/heap.cc |
| index 66b527456e6ec53b1f149b378576a08b59b614a9..2198bd5957ea57a1c9d948c1a523c0f5d1e4307e 100644 |
| --- a/src/heap.cc |
| +++ b/src/heap.cc |
| @@ -4047,12 +4047,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); |
| @@ -4099,7 +4111,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) { |
| @@ -4146,8 +4162,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()); |
|
ulan
2014/03/18 12:27:51
Since const pool is smaller then code, it is proba
rmcilroy
2014/03/18 15:14:35
Done.
|
| + 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); |
| @@ -4194,6 +4221,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; |
|
ulan
2014/03/18 12:27:51
The same as above.
rmcilroy
2014/03/18 15:14:35
Done.
|
| + 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(), |