OLD | NEW |
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 4179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4190 int obj_size = Code::SizeFor(body_size); | 4190 int obj_size = Code::SizeFor(body_size); |
4191 ASSERT(IsAligned(static_cast<intptr_t>(obj_size), kCodeAlignment)); | 4191 ASSERT(IsAligned(static_cast<intptr_t>(obj_size), kCodeAlignment)); |
4192 MaybeObject* maybe_result; | 4192 MaybeObject* maybe_result; |
4193 // Large code objects and code objects which should stay at a fixed address | 4193 // Large code objects and code objects which should stay at a fixed address |
4194 // are allocated in large object space. | 4194 // are allocated in large object space. |
4195 HeapObject* result; | 4195 HeapObject* result; |
4196 bool force_lo_space = obj_size > code_space()->AreaSize(); | 4196 bool force_lo_space = obj_size > code_space()->AreaSize(); |
4197 if (force_lo_space) { | 4197 if (force_lo_space) { |
4198 maybe_result = lo_space_->AllocateRaw(obj_size, EXECUTABLE); | 4198 maybe_result = lo_space_->AllocateRaw(obj_size, EXECUTABLE); |
4199 } else { | 4199 } else { |
4200 maybe_result = code_space_->AllocateRaw(obj_size); | 4200 maybe_result = AllocateRaw(obj_size, CODE_SPACE, CODE_SPACE); |
4201 } | 4201 } |
4202 if (!maybe_result->To<HeapObject>(&result)) return maybe_result; | 4202 if (!maybe_result->To<HeapObject>(&result)) return maybe_result; |
4203 | 4203 |
4204 if (immovable && !force_lo_space && | 4204 if (immovable && !force_lo_space && |
4205 // Objects on the first page of each space are never moved. | 4205 // Objects on the first page of each space are never moved. |
4206 !code_space_->FirstPage()->Contains(result->address())) { | 4206 !code_space_->FirstPage()->Contains(result->address())) { |
4207 // Discard the first code allocation, which was on a page where it could be | 4207 // Discard the first code allocation, which was on a page where it could be |
4208 // moved. | 4208 // moved. |
4209 CreateFillerObjectAt(result->address(), obj_size); | 4209 CreateFillerObjectAt(result->address(), obj_size); |
4210 maybe_result = lo_space_->AllocateRaw(obj_size, EXECUTABLE); | 4210 maybe_result = lo_space_->AllocateRaw(obj_size, EXECUTABLE); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4261 } | 4261 } |
4262 | 4262 |
4263 | 4263 |
4264 MaybeObject* Heap::CopyCode(Code* code) { | 4264 MaybeObject* Heap::CopyCode(Code* code) { |
4265 // Allocate an object the same size as the code object. | 4265 // Allocate an object the same size as the code object. |
4266 int obj_size = code->Size(); | 4266 int obj_size = code->Size(); |
4267 MaybeObject* maybe_result; | 4267 MaybeObject* maybe_result; |
4268 if (obj_size > code_space()->AreaSize()) { | 4268 if (obj_size > code_space()->AreaSize()) { |
4269 maybe_result = lo_space_->AllocateRaw(obj_size, EXECUTABLE); | 4269 maybe_result = lo_space_->AllocateRaw(obj_size, EXECUTABLE); |
4270 } else { | 4270 } else { |
4271 maybe_result = code_space_->AllocateRaw(obj_size); | 4271 maybe_result = AllocateRaw(obj_size, CODE_SPACE, CODE_SPACE); |
4272 } | 4272 } |
4273 | 4273 |
4274 Object* result; | 4274 Object* result; |
4275 if (!maybe_result->ToObject(&result)) return maybe_result; | 4275 if (!maybe_result->ToObject(&result)) return maybe_result; |
4276 | 4276 |
4277 // Copy code object. | 4277 // Copy code object. |
4278 Address old_addr = code->address(); | 4278 Address old_addr = code->address(); |
4279 Address new_addr = reinterpret_cast<HeapObject*>(result)->address(); | 4279 Address new_addr = reinterpret_cast<HeapObject*>(result)->address(); |
4280 CopyBlock(new_addr, old_addr, obj_size); | 4280 CopyBlock(new_addr, old_addr, obj_size); |
4281 // Relocate the copy. | 4281 // Relocate the copy. |
(...skipping 22 matching lines...) Expand all Loading... |
4304 | 4304 |
4305 Address old_addr = code->address(); | 4305 Address old_addr = code->address(); |
4306 | 4306 |
4307 size_t relocation_offset = | 4307 size_t relocation_offset = |
4308 static_cast<size_t>(code->instruction_end() - old_addr); | 4308 static_cast<size_t>(code->instruction_end() - old_addr); |
4309 | 4309 |
4310 MaybeObject* maybe_result; | 4310 MaybeObject* maybe_result; |
4311 if (new_obj_size > code_space()->AreaSize()) { | 4311 if (new_obj_size > code_space()->AreaSize()) { |
4312 maybe_result = lo_space_->AllocateRaw(new_obj_size, EXECUTABLE); | 4312 maybe_result = lo_space_->AllocateRaw(new_obj_size, EXECUTABLE); |
4313 } else { | 4313 } else { |
4314 maybe_result = code_space_->AllocateRaw(new_obj_size); | 4314 maybe_result = AllocateRaw(new_obj_size, CODE_SPACE, CODE_SPACE); |
4315 } | 4315 } |
4316 | 4316 |
4317 Object* result; | 4317 Object* result; |
4318 if (!maybe_result->ToObject(&result)) return maybe_result; | 4318 if (!maybe_result->ToObject(&result)) return maybe_result; |
4319 | 4319 |
4320 // Copy code object. | 4320 // Copy code object. |
4321 Address new_addr = reinterpret_cast<HeapObject*>(result)->address(); | 4321 Address new_addr = reinterpret_cast<HeapObject*>(result)->address(); |
4322 | 4322 |
4323 // Copy header and instructions. | 4323 // Copy header and instructions. |
4324 CopyBytes(new_addr, old_addr, relocation_offset); | 4324 CopyBytes(new_addr, old_addr, relocation_offset); |
(...skipping 3588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7913 if (FLAG_concurrent_recompilation) { | 7913 if (FLAG_concurrent_recompilation) { |
7914 heap_->relocation_mutex_->Lock(); | 7914 heap_->relocation_mutex_->Lock(); |
7915 #ifdef DEBUG | 7915 #ifdef DEBUG |
7916 heap_->relocation_mutex_locked_by_optimizer_thread_ = | 7916 heap_->relocation_mutex_locked_by_optimizer_thread_ = |
7917 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); | 7917 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); |
7918 #endif // DEBUG | 7918 #endif // DEBUG |
7919 } | 7919 } |
7920 } | 7920 } |
7921 | 7921 |
7922 } } // namespace v8::internal | 7922 } } // namespace v8::internal |
OLD | NEW |