| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 2338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2349 ASSERT(!scratch.is_valid()); | 2349 ASSERT(!scratch.is_valid()); |
| 2350 #ifdef DEBUG | 2350 #ifdef DEBUG |
| 2351 // Assert that result actually contains top on entry. | 2351 // Assert that result actually contains top on entry. |
| 2352 movq(kScratchRegister, new_space_allocation_top); | 2352 movq(kScratchRegister, new_space_allocation_top); |
| 2353 cmpq(result, Operand(kScratchRegister, 0)); | 2353 cmpq(result, Operand(kScratchRegister, 0)); |
| 2354 Check(equal, "Unexpected allocation top"); | 2354 Check(equal, "Unexpected allocation top"); |
| 2355 #endif | 2355 #endif |
| 2356 return; | 2356 return; |
| 2357 } | 2357 } |
| 2358 | 2358 |
| 2359 // Move address of new object to result. Use scratch register if available. | 2359 // Move address of new object to result. Use scratch register if available, |
| 2360 if (!scratch.is_valid()) { | 2360 // and keep address in scratch until call to UpdateAllocationTopHelper. |
| 2361 if (result.is(rax)) { | 2361 if (scratch.is_valid()) { |
| 2362 load_rax(new_space_allocation_top); | |
| 2363 } else { | |
| 2364 movq(kScratchRegister, new_space_allocation_top); | |
| 2365 movq(result, Operand(kScratchRegister, 0)); | |
| 2366 } | |
| 2367 } else { | |
| 2368 ASSERT(!scratch.is(result_end)); | 2362 ASSERT(!scratch.is(result_end)); |
| 2369 movq(scratch, new_space_allocation_top); | 2363 movq(scratch, new_space_allocation_top); |
| 2370 movq(result, Operand(scratch, 0)); | 2364 movq(result, Operand(scratch, 0)); |
| 2365 } else if (result.is(rax)) { |
| 2366 load_rax(new_space_allocation_top); |
| 2367 } else { |
| 2368 movq(kScratchRegister, new_space_allocation_top); |
| 2369 movq(result, Operand(kScratchRegister, 0)); |
| 2371 } | 2370 } |
| 2372 } | 2371 } |
| 2373 | 2372 |
| 2374 | 2373 |
| 2375 void MacroAssembler::UpdateAllocationTopHelper(Register result_end, | 2374 void MacroAssembler::UpdateAllocationTopHelper(Register result_end, |
| 2376 Register scratch) { | 2375 Register scratch) { |
| 2377 if (FLAG_debug_code) { | 2376 if (FLAG_debug_code) { |
| 2378 testq(result_end, Immediate(kObjectAlignmentMask)); | 2377 testq(result_end, Immediate(kObjectAlignmentMask)); |
| 2379 Check(zero, "Unaligned allocation in new space"); | 2378 Check(zero, "Unaligned allocation in new space"); |
| 2380 } | 2379 } |
| 2381 | 2380 |
| 2382 ExternalReference new_space_allocation_top = | 2381 ExternalReference new_space_allocation_top = |
| 2383 ExternalReference::new_space_allocation_top_address(); | 2382 ExternalReference::new_space_allocation_top_address(); |
| 2384 | 2383 |
| 2385 // Update new top. | 2384 // Update new top. |
| 2386 if (result_end.is(rax)) { | 2385 if (result_end.is(rax)) { |
| 2387 // rax can be stored directly to a memory location. | 2386 // rax can be stored directly to a memory location. |
| 2388 store_rax(new_space_allocation_top); | 2387 store_rax(new_space_allocation_top); |
| 2389 } else { | 2388 } else { |
| 2390 // Register required - use scratch provided if available. | 2389 // Register required - use scratch provided if available. |
| 2391 if (!scratch.is_valid()) { | 2390 if (scratch.is_valid()) { |
| 2391 movq(Operand(scratch, 0), result_end); |
| 2392 } else { |
| 2392 movq(kScratchRegister, new_space_allocation_top); | 2393 movq(kScratchRegister, new_space_allocation_top); |
| 2393 movq(Operand(kScratchRegister, 0), result_end); | 2394 movq(Operand(kScratchRegister, 0), result_end); |
| 2394 } else { | |
| 2395 movq(Operand(scratch, 0), result_end); | |
| 2396 } | 2395 } |
| 2397 } | 2396 } |
| 2398 } | 2397 } |
| 2399 | 2398 |
| 2400 | 2399 |
| 2401 void MacroAssembler::AllocateInNewSpace(int object_size, | 2400 void MacroAssembler::AllocateInNewSpace(int object_size, |
| 2402 Register result, | 2401 Register result, |
| 2403 Register result_end, | 2402 Register result_end, |
| 2404 Register scratch, | 2403 Register scratch, |
| 2405 Label* gc_required, | 2404 Label* gc_required, |
| 2406 AllocationFlags flags) { | 2405 AllocationFlags flags) { |
| 2407 ASSERT(!result.is(result_end)); | 2406 ASSERT(!result.is(result_end)); |
| 2408 | 2407 |
| 2409 // Load address of new object into result. | 2408 // Load address of new object into result. |
| 2410 LoadAllocationTopHelper(result, result_end, scratch, flags); | 2409 LoadAllocationTopHelper(result, result_end, scratch, flags); |
| 2411 | 2410 |
| 2412 // Calculate new top and bail out if new space is exhausted. | 2411 // Calculate new top and bail out if new space is exhausted. |
| 2413 ExternalReference new_space_allocation_limit = | 2412 ExternalReference new_space_allocation_limit = |
| 2414 ExternalReference::new_space_allocation_limit_address(); | 2413 ExternalReference::new_space_allocation_limit_address(); |
| 2415 | 2414 |
| 2416 Register top_reg = result_end.is_valid() ? result_end : result; | 2415 Register top_reg = result_end.is_valid() ? result_end : result; |
| 2417 | 2416 |
| 2418 lea(top_reg, Operand(result, object_size)); | 2417 if (top_reg.is(result)) { |
| 2418 addq(top_reg, Immediate(object_size)); |
| 2419 } else { |
| 2420 lea(top_reg, Operand(result, object_size)); |
| 2421 } |
| 2419 movq(kScratchRegister, new_space_allocation_limit); | 2422 movq(kScratchRegister, new_space_allocation_limit); |
| 2420 cmpq(top_reg, Operand(kScratchRegister, 0)); | 2423 cmpq(top_reg, Operand(kScratchRegister, 0)); |
| 2421 j(above, gc_required); | 2424 j(above, gc_required); |
| 2422 | 2425 |
| 2423 // Update allocation top. | 2426 // Update allocation top. |
| 2424 UpdateAllocationTopHelper(top_reg, scratch); | 2427 UpdateAllocationTopHelper(top_reg, scratch); |
| 2425 | 2428 |
| 2426 if (top_reg.is(result)) { | 2429 if (top_reg.is(result)) { |
| 2427 if ((flags & TAG_OBJECT) != 0) { | 2430 if ((flags & TAG_OBJECT) != 0) { |
| 2428 subq(result, Immediate(object_size - kHeapObjectTag)); | 2431 subq(result, Immediate(object_size - kHeapObjectTag)); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2712 CodePatcher::~CodePatcher() { | 2715 CodePatcher::~CodePatcher() { |
| 2713 // Indicate that code has changed. | 2716 // Indicate that code has changed. |
| 2714 CPU::FlushICache(address_, size_); | 2717 CPU::FlushICache(address_, size_); |
| 2715 | 2718 |
| 2716 // Check that the code was patched as expected. | 2719 // Check that the code was patched as expected. |
| 2717 ASSERT(masm_.pc_ == address_ + size_); | 2720 ASSERT(masm_.pc_ == address_ + size_); |
| 2718 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 2721 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
| 2719 } | 2722 } |
| 2720 | 2723 |
| 2721 } } // namespace v8::internal | 2724 } } // namespace v8::internal |
| OLD | NEW |