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

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: Addresss comments Created 6 years, 9 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 unified diff | Download patch | 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 4029 matching lines...) Expand 10 before | Expand all | Expand 10 after
4040 return elements; 4040 return elements;
4041 } 4041 }
4042 4042
4043 4043
4044 MaybeObject* Heap::CreateCode(const CodeDesc& desc, 4044 MaybeObject* Heap::CreateCode(const CodeDesc& desc,
4045 Code::Flags flags, 4045 Code::Flags flags,
4046 Handle<Object> self_reference, 4046 Handle<Object> self_reference,
4047 bool immovable, 4047 bool immovable,
4048 bool crankshafted, 4048 bool crankshafted,
4049 int prologue_offset) { 4049 int prologue_offset) {
4050 // Allocate ByteArray before the Code object, so that we do not risk 4050 // Allocate ByteArray and ConstantPoolArray before the Code object, so that we
4051 // leaving uninitialized Code object (and breaking the heap). 4051 // do not risk leaving uninitialized Code object (and breaking the heap).
4052 ByteArray* reloc_info; 4052 ByteArray* reloc_info;
4053 MaybeObject* maybe_reloc_info = AllocateByteArray(desc.reloc_size, TENURED); 4053 MaybeObject* maybe_reloc_info = AllocateByteArray(desc.reloc_size, TENURED);
4054 if (!maybe_reloc_info->To(&reloc_info)) return maybe_reloc_info; 4054 if (!maybe_reloc_info->To(&reloc_info)) return maybe_reloc_info;
4055 4055
4056 ConstantPoolArray* constant_pool;
4057 if (!FLAG_enable_ool_constant_pool || desc.has_empty_constant_pool()) {
4058 constant_pool = empty_constant_pool_array();
4059 } else {
4060 MaybeObject* maybe_constant_pool = AllocateConstantPoolArray(
4061 desc.constant_pool_64bit_count,
4062 desc.constant_pool_code_ptr_count,
4063 desc.constant_pool_heap_ptr_count,
4064 desc.constant_pool_32bit_count);
4065 if (!maybe_constant_pool->To(&constant_pool)) return maybe_constant_pool;
4066 }
4067
4056 // Compute size. 4068 // Compute size.
4057 int body_size = RoundUp(desc.instr_size, kObjectAlignment); 4069 int body_size = RoundUp(desc.instr_size, kObjectAlignment);
4058 int obj_size = Code::SizeFor(body_size); 4070 int obj_size = Code::SizeFor(body_size);
4059 ASSERT(IsAligned(static_cast<intptr_t>(obj_size), kCodeAlignment)); 4071 ASSERT(IsAligned(static_cast<intptr_t>(obj_size), kCodeAlignment));
4060 MaybeObject* maybe_result; 4072 MaybeObject* maybe_result;
4061 // Large code objects and code objects which should stay at a fixed address 4073 // Large code objects and code objects which should stay at a fixed address
4062 // are allocated in large object space. 4074 // are allocated in large object space.
4063 HeapObject* result; 4075 HeapObject* result;
4064 bool force_lo_space = obj_size > code_space()->AreaSize(); 4076 bool force_lo_space = obj_size > code_space()->AreaSize();
4065 if (force_lo_space) { 4077 if (force_lo_space) {
(...skipping 26 matching lines...) Expand all
4092 code->set_is_crankshafted(crankshafted); 4104 code->set_is_crankshafted(crankshafted);
4093 code->set_deoptimization_data(empty_fixed_array(), SKIP_WRITE_BARRIER); 4105 code->set_deoptimization_data(empty_fixed_array(), SKIP_WRITE_BARRIER);
4094 code->set_raw_type_feedback_info(undefined_value()); 4106 code->set_raw_type_feedback_info(undefined_value());
4095 code->set_handler_table(empty_fixed_array(), SKIP_WRITE_BARRIER); 4107 code->set_handler_table(empty_fixed_array(), SKIP_WRITE_BARRIER);
4096 code->set_gc_metadata(Smi::FromInt(0)); 4108 code->set_gc_metadata(Smi::FromInt(0));
4097 code->set_ic_age(global_ic_age_); 4109 code->set_ic_age(global_ic_age_);
4098 code->set_prologue_offset(prologue_offset); 4110 code->set_prologue_offset(prologue_offset);
4099 if (code->kind() == Code::OPTIMIZED_FUNCTION) { 4111 if (code->kind() == Code::OPTIMIZED_FUNCTION) {
4100 code->set_marked_for_deoptimization(false); 4112 code->set_marked_for_deoptimization(false);
4101 } 4113 }
4102 code->set_constant_pool(empty_constant_pool_array()); 4114
4115 if (FLAG_enable_ool_constant_pool) {
4116 desc.origin->PopulateConstantPool(constant_pool);
4117 }
4118 code->set_constant_pool(constant_pool);
4103 4119
4104 #ifdef ENABLE_DEBUGGER_SUPPORT 4120 #ifdef ENABLE_DEBUGGER_SUPPORT
4105 if (code->kind() == Code::FUNCTION) { 4121 if (code->kind() == Code::FUNCTION) {
4106 code->set_has_debug_break_slots( 4122 code->set_has_debug_break_slots(
4107 isolate_->debugger()->IsDebuggerActive()); 4123 isolate_->debugger()->IsDebuggerActive());
4108 } 4124 }
4109 #endif 4125 #endif
4110 4126
4111 // Allow self references to created code object by patching the handle to 4127 // Allow self references to created code object by patching the handle to
4112 // point to the newly allocated Code object. 4128 // point to the newly allocated Code object.
(...skipping 26 matching lines...) Expand all
4139 maybe_result = AllocateRaw(obj_size, CODE_SPACE, CODE_SPACE); 4155 maybe_result = AllocateRaw(obj_size, CODE_SPACE, CODE_SPACE);
4140 } 4156 }
4141 4157
4142 Object* result; 4158 Object* result;
4143 if (!maybe_result->ToObject(&result)) return maybe_result; 4159 if (!maybe_result->ToObject(&result)) return maybe_result;
4144 4160
4145 // Copy code object. 4161 // Copy code object.
4146 Address old_addr = code->address(); 4162 Address old_addr = code->address();
4147 Address new_addr = reinterpret_cast<HeapObject*>(result)->address(); 4163 Address new_addr = reinterpret_cast<HeapObject*>(result)->address();
4148 CopyBlock(new_addr, old_addr, obj_size); 4164 CopyBlock(new_addr, old_addr, obj_size);
4165 Code* new_code = Code::cast(result);
4166
4167 if (FLAG_enable_ool_constant_pool &&
4168 code->constant_pool() != empty_constant_pool_array()) {
4169 // Copy the constant pool too, since edits to the copied code may modify
4170 // the constant pool.
4171 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.
4172 Object* constant_pool_copy;
4173 if (!maybe_result->ToObject(&constant_pool_copy)) return maybe_result;
4174 new_code->set_constant_pool(constant_pool_copy);
4175 }
4176
4149 // Relocate the copy. 4177 // Relocate the copy.
4150 Code* new_code = Code::cast(result);
4151 ASSERT(!isolate_->code_range()->exists() || 4178 ASSERT(!isolate_->code_range()->exists() ||
4152 isolate_->code_range()->contains(code->address())); 4179 isolate_->code_range()->contains(code->address()));
4153 new_code->Relocate(new_addr - old_addr); 4180 new_code->Relocate(new_addr - old_addr);
4154 return new_code; 4181 return new_code;
4155 } 4182 }
4156 4183
4157 4184
4158 MaybeObject* Heap::CopyCode(Code* code, Vector<byte> reloc_info) { 4185 MaybeObject* Heap::CopyCode(Code* code, Vector<byte> reloc_info) {
4159 // Allocate ByteArray before the Code object, so that we do not risk 4186 // Allocate ByteArray before the Code object, so that we do not risk
4160 // leaving uninitialized Code object (and breaking the heap). 4187 // leaving uninitialized Code object (and breaking the heap).
(...skipping 26 matching lines...) Expand all
4187 4214
4188 // Copy code object. 4215 // Copy code object.
4189 Address new_addr = reinterpret_cast<HeapObject*>(result)->address(); 4216 Address new_addr = reinterpret_cast<HeapObject*>(result)->address();
4190 4217
4191 // Copy header and instructions. 4218 // Copy header and instructions.
4192 CopyBytes(new_addr, old_addr, relocation_offset); 4219 CopyBytes(new_addr, old_addr, relocation_offset);
4193 4220
4194 Code* new_code = Code::cast(result); 4221 Code* new_code = Code::cast(result);
4195 new_code->set_relocation_info(ByteArray::cast(reloc_info_array)); 4222 new_code->set_relocation_info(ByteArray::cast(reloc_info_array));
4196 4223
4224 if (FLAG_enable_ool_constant_pool) {
4225 // Copy the constant pool too, since edits to the copied code may modify
4226 // the constant pool.
4227 maybe_result = CopyConstantPoolArray(code->constant_pool());
4228 Object* constant_pool_copy;
ulan 2014/03/18 12:27:51 The same as above.
rmcilroy 2014/03/18 15:14:35 Done.
4229 if (!maybe_result->ToObject(&constant_pool_copy)) return maybe_result;
4230 new_code->set_constant_pool(constant_pool_copy);
4231 }
4232
4197 // Copy patched rinfo. 4233 // Copy patched rinfo.
4198 CopyBytes(new_code->relocation_start(), 4234 CopyBytes(new_code->relocation_start(),
4199 reloc_info.start(), 4235 reloc_info.start(),
4200 static_cast<size_t>(reloc_info.length())); 4236 static_cast<size_t>(reloc_info.length()));
4201 4237
4202 // Relocate the copy. 4238 // Relocate the copy.
4203 ASSERT(!isolate_->code_range()->exists() || 4239 ASSERT(!isolate_->code_range()->exists() ||
4204 isolate_->code_range()->contains(code->address())); 4240 isolate_->code_range()->contains(code->address()));
4205 new_code->Relocate(new_addr - old_addr); 4241 new_code->Relocate(new_addr - old_addr);
4206 4242
(...skipping 3541 matching lines...) Expand 10 before | Expand all | Expand 10 after
7748 static_cast<int>(object_sizes_last_time_[index])); 7784 static_cast<int>(object_sizes_last_time_[index]));
7749 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 7785 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
7750 #undef ADJUST_LAST_TIME_OBJECT_COUNT 7786 #undef ADJUST_LAST_TIME_OBJECT_COUNT
7751 7787
7752 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 7788 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
7753 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 7789 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
7754 ClearObjectStats(); 7790 ClearObjectStats();
7755 } 7791 }
7756 7792
7757 } } // namespace v8::internal 7793 } } // namespace v8::internal
OLDNEW
« src/arm/builtins-arm.cc ('K') | « src/assembler.h ('k') | src/ia32/assembler-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698