Chromium Code Reviews

Side by Side Diff: src/heap.cc

Issue 191233003: Add out-of-line constant pool support to Arm. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 3992 matching lines...)
4003 return elements; 4003 return elements;
4004 } 4004 }
4005 4005
4006 4006
4007 MaybeObject* Heap::CreateCode(const CodeDesc& desc, 4007 MaybeObject* Heap::CreateCode(const CodeDesc& desc,
4008 Code::Flags flags, 4008 Code::Flags flags,
4009 Handle<Object> self_reference, 4009 Handle<Object> self_reference,
4010 bool immovable, 4010 bool immovable,
4011 bool crankshafted, 4011 bool crankshafted,
4012 int prologue_offset) { 4012 int prologue_offset) {
4013 // Allocate ByteArray before the Code object, so that we do not risk 4013 // Allocate ByteArray and ConstantPoolArray before the Code object, so that we
4014 // leaving uninitialized Code object (and breaking the heap). 4014 // do not risk leaving uninitialized Code object (and breaking the heap).
4015 ByteArray* reloc_info; 4015 ByteArray* reloc_info;
4016 MaybeObject* maybe_reloc_info = AllocateByteArray(desc.reloc_size, TENURED); 4016 MaybeObject* maybe_reloc_info = AllocateByteArray(desc.reloc_size, TENURED);
4017 if (!maybe_reloc_info->To(&reloc_info)) return maybe_reloc_info; 4017 if (!maybe_reloc_info->To(&reloc_info)) return maybe_reloc_info;
4018 4018
4019 ConstantPoolArray* constant_pool;
4020 if (!FLAG_enable_ool_constant_pool || desc.has_empty_constant_pool()) {
4021 constant_pool = empty_constant_pool_array();
4022 } else {
4023 MaybeObject* maybe_constant_pool = AllocateConstantPoolArray(
4024 desc.constant_pool_64bit_count,
4025 desc.constant_pool_code_ptr_count,
4026 desc.constant_pool_heap_ptr_count,
4027 desc.constant_pool_32bit_count);
4028 if (!maybe_constant_pool->To(&constant_pool)) return maybe_constant_pool;
4029 }
4030
4019 // Compute size. 4031 // Compute size.
4020 int body_size = RoundUp(desc.instr_size, kObjectAlignment); 4032 int body_size = RoundUp(desc.instr_size, kObjectAlignment);
4021 int obj_size = Code::SizeFor(body_size); 4033 int obj_size = Code::SizeFor(body_size);
4022 ASSERT(IsAligned(static_cast<intptr_t>(obj_size), kCodeAlignment)); 4034 ASSERT(IsAligned(static_cast<intptr_t>(obj_size), kCodeAlignment));
4023 MaybeObject* maybe_result; 4035 MaybeObject* maybe_result;
4024 // Large code objects and code objects which should stay at a fixed address 4036 // Large code objects and code objects which should stay at a fixed address
4025 // are allocated in large object space. 4037 // are allocated in large object space.
4026 HeapObject* result; 4038 HeapObject* result;
4027 bool force_lo_space = obj_size > code_space()->AreaSize(); 4039 bool force_lo_space = obj_size > code_space()->AreaSize();
4028 if (force_lo_space) { 4040 if (force_lo_space) {
(...skipping 26 matching lines...)
4055 code->set_is_crankshafted(crankshafted); 4067 code->set_is_crankshafted(crankshafted);
4056 code->set_deoptimization_data(empty_fixed_array(), SKIP_WRITE_BARRIER); 4068 code->set_deoptimization_data(empty_fixed_array(), SKIP_WRITE_BARRIER);
4057 code->set_raw_type_feedback_info(undefined_value()); 4069 code->set_raw_type_feedback_info(undefined_value());
4058 code->set_handler_table(empty_fixed_array(), SKIP_WRITE_BARRIER); 4070 code->set_handler_table(empty_fixed_array(), SKIP_WRITE_BARRIER);
4059 code->set_gc_metadata(Smi::FromInt(0)); 4071 code->set_gc_metadata(Smi::FromInt(0));
4060 code->set_ic_age(global_ic_age_); 4072 code->set_ic_age(global_ic_age_);
4061 code->set_prologue_offset(prologue_offset); 4073 code->set_prologue_offset(prologue_offset);
4062 if (code->kind() == Code::OPTIMIZED_FUNCTION) { 4074 if (code->kind() == Code::OPTIMIZED_FUNCTION) {
4063 code->set_marked_for_deoptimization(false); 4075 code->set_marked_for_deoptimization(false);
4064 } 4076 }
4065 code->set_constant_pool(empty_constant_pool_array()); 4077
4078 if (FLAG_enable_ool_constant_pool) {
4079 desc.origin->PopulateConstantPool(constant_pool);
4080 }
4081 code->set_constant_pool(constant_pool);
4066 4082
4067 #ifdef ENABLE_DEBUGGER_SUPPORT 4083 #ifdef ENABLE_DEBUGGER_SUPPORT
4068 if (code->kind() == Code::FUNCTION) { 4084 if (code->kind() == Code::FUNCTION) {
4069 code->set_has_debug_break_slots( 4085 code->set_has_debug_break_slots(
4070 isolate_->debugger()->IsDebuggerActive()); 4086 isolate_->debugger()->IsDebuggerActive());
4071 } 4087 }
4072 #endif 4088 #endif
4073 4089
4074 // Allow self references to created code object by patching the handle to 4090 // Allow self references to created code object by patching the handle to
4075 // point to the newly allocated Code object. 4091 // point to the newly allocated Code object.
(...skipping 26 matching lines...)
4102 maybe_result = AllocateRaw(obj_size, CODE_SPACE, CODE_SPACE); 4118 maybe_result = AllocateRaw(obj_size, CODE_SPACE, CODE_SPACE);
4103 } 4119 }
4104 4120
4105 Object* result; 4121 Object* result;
4106 if (!maybe_result->ToObject(&result)) return maybe_result; 4122 if (!maybe_result->ToObject(&result)) return maybe_result;
4107 4123
4108 // Copy code object. 4124 // Copy code object.
4109 Address old_addr = code->address(); 4125 Address old_addr = code->address();
4110 Address new_addr = reinterpret_cast<HeapObject*>(result)->address(); 4126 Address new_addr = reinterpret_cast<HeapObject*>(result)->address();
4111 CopyBlock(new_addr, old_addr, obj_size); 4127 CopyBlock(new_addr, old_addr, obj_size);
4128 Code* new_code = Code::cast(result);
4129
4130 if (FLAG_enable_ool_constant_pool &&
4131 code->constant_pool() != empty_constant_pool_array()) {
4132 // Copy the constant pool too, since edits to the copied code may modify
4133 // the constant pool.
4134 maybe_result = CopyConstantPoolArray(code->constant_pool());
4135 Object* constant_pool_copy;
4136 if (!maybe_result->ToObject(&constant_pool_copy)) return maybe_result;
4137 new_code->set_constant_pool(constant_pool_copy);
4138 }
4139
4112 // Relocate the copy. 4140 // Relocate the copy.
4113 Code* new_code = Code::cast(result);
4114 ASSERT(!isolate_->code_range()->exists() || 4141 ASSERT(!isolate_->code_range()->exists() ||
4115 isolate_->code_range()->contains(code->address())); 4142 isolate_->code_range()->contains(code->address()));
4116 new_code->Relocate(new_addr - old_addr); 4143 new_code->Relocate(new_addr - old_addr);
4117 return new_code; 4144 return new_code;
4118 } 4145 }
4119 4146
4120 4147
4121 MaybeObject* Heap::CopyCode(Code* code, Vector<byte> reloc_info) { 4148 MaybeObject* Heap::CopyCode(Code* code, Vector<byte> reloc_info) {
4122 // Allocate ByteArray before the Code object, so that we do not risk 4149 // Allocate ByteArray before the Code object, so that we do not risk
4123 // leaving uninitialized Code object (and breaking the heap). 4150 // leaving uninitialized Code object (and breaking the heap).
(...skipping 26 matching lines...)
4150 4177
4151 // Copy code object. 4178 // Copy code object.
4152 Address new_addr = reinterpret_cast<HeapObject*>(result)->address(); 4179 Address new_addr = reinterpret_cast<HeapObject*>(result)->address();
4153 4180
4154 // Copy header and instructions. 4181 // Copy header and instructions.
4155 CopyBytes(new_addr, old_addr, relocation_offset); 4182 CopyBytes(new_addr, old_addr, relocation_offset);
4156 4183
4157 Code* new_code = Code::cast(result); 4184 Code* new_code = Code::cast(result);
4158 new_code->set_relocation_info(ByteArray::cast(reloc_info_array)); 4185 new_code->set_relocation_info(ByteArray::cast(reloc_info_array));
4159 4186
4187 if (FLAG_enable_ool_constant_pool) {
4188 // Copy the constant pool too, since edits to the copied code may modify
4189 // the constant pool.
4190 maybe_result = CopyConstantPoolArray(code->constant_pool());
4191 Object* constant_pool_copy;
4192 if (!maybe_result->ToObject(&constant_pool_copy)) return maybe_result;
4193 new_code->set_constant_pool(constant_pool_copy);
4194 }
4195
4160 // Copy patched rinfo. 4196 // Copy patched rinfo.
4161 CopyBytes(new_code->relocation_start(), 4197 CopyBytes(new_code->relocation_start(),
4162 reloc_info.start(), 4198 reloc_info.start(),
4163 static_cast<size_t>(reloc_info.length())); 4199 static_cast<size_t>(reloc_info.length()));
4164 4200
4165 // Relocate the copy. 4201 // Relocate the copy.
4166 ASSERT(!isolate_->code_range()->exists() || 4202 ASSERT(!isolate_->code_range()->exists() ||
4167 isolate_->code_range()->contains(code->address())); 4203 isolate_->code_range()->contains(code->address()));
4168 new_code->Relocate(new_addr - old_addr); 4204 new_code->Relocate(new_addr - old_addr);
4169 4205
(...skipping 3579 matching lines...)
7749 static_cast<int>(object_sizes_last_time_[index])); 7785 static_cast<int>(object_sizes_last_time_[index]));
7750 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 7786 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
7751 #undef ADJUST_LAST_TIME_OBJECT_COUNT 7787 #undef ADJUST_LAST_TIME_OBJECT_COUNT
7752 7788
7753 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 7789 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
7754 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 7790 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
7755 ClearObjectStats(); 7791 ClearObjectStats();
7756 } 7792 }
7757 7793
7758 } } // namespace v8::internal 7794 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine