| 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 2317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2328 void MacroAssembler::LoadAllocationTopHelper(Register result, | 2328 void MacroAssembler::LoadAllocationTopHelper(Register result, |
| 2329 Register result_end, | 2329 Register result_end, |
| 2330 Register scratch, | 2330 Register scratch, |
| 2331 AllocationFlags flags) { | 2331 AllocationFlags flags) { |
| 2332 ExternalReference new_space_allocation_top = | 2332 ExternalReference new_space_allocation_top = |
| 2333 ExternalReference::new_space_allocation_top_address(); | 2333 ExternalReference::new_space_allocation_top_address(); |
| 2334 | 2334 |
| 2335 // Just return if allocation top is already known. | 2335 // Just return if allocation top is already known. |
| 2336 if ((flags & RESULT_CONTAINS_TOP) != 0) { | 2336 if ((flags & RESULT_CONTAINS_TOP) != 0) { |
| 2337 // No use of scratch if allocation top is provided. | 2337 // No use of scratch if allocation top is provided. |
| 2338 ASSERT(scratch.is(no_reg)); | 2338 ASSERT(!scratch.is_valid()); |
| 2339 #ifdef DEBUG | 2339 #ifdef DEBUG |
| 2340 // Assert that result actually contains top on entry. | 2340 // Assert that result actually contains top on entry. |
| 2341 movq(kScratchRegister, new_space_allocation_top); | 2341 movq(kScratchRegister, new_space_allocation_top); |
| 2342 cmpq(result, Operand(kScratchRegister, 0)); | 2342 cmpq(result, Operand(kScratchRegister, 0)); |
| 2343 Check(equal, "Unexpected allocation top"); | 2343 Check(equal, "Unexpected allocation top"); |
| 2344 #endif | 2344 #endif |
| 2345 return; | 2345 return; |
| 2346 } | 2346 } |
| 2347 | 2347 |
| 2348 // Move address of new object to result. Use scratch register if available. | 2348 // Move address of new object to result. Use scratch register if available. |
| 2349 if (scratch.is(no_reg)) { | 2349 if (!scratch.is_valid()) { |
| 2350 movq(kScratchRegister, new_space_allocation_top); | 2350 if (result.is(rax)) { |
| 2351 movq(result, Operand(kScratchRegister, 0)); | 2351 load_rax(new_space_allocation_top); |
| 2352 } else { |
| 2353 movq(kScratchRegister, new_space_allocation_top); |
| 2354 movq(result, Operand(kScratchRegister, 0)); |
| 2355 } |
| 2352 } else { | 2356 } else { |
| 2353 ASSERT(!scratch.is(result_end)); | 2357 ASSERT(!scratch.is(result_end)); |
| 2354 movq(scratch, new_space_allocation_top); | 2358 movq(scratch, new_space_allocation_top); |
| 2355 movq(result, Operand(scratch, 0)); | 2359 movq(result, Operand(scratch, 0)); |
| 2356 } | 2360 } |
| 2357 } | 2361 } |
| 2358 | 2362 |
| 2359 | 2363 |
| 2360 void MacroAssembler::UpdateAllocationTopHelper(Register result_end, | 2364 void MacroAssembler::UpdateAllocationTopHelper(Register result_end, |
| 2361 Register scratch) { | 2365 Register scratch) { |
| 2362 if (FLAG_debug_code) { | 2366 if (FLAG_debug_code) { |
| 2363 testq(result_end, Immediate(kObjectAlignmentMask)); | 2367 testq(result_end, Immediate(kObjectAlignmentMask)); |
| 2364 Check(zero, "Unaligned allocation in new space"); | 2368 Check(zero, "Unaligned allocation in new space"); |
| 2365 } | 2369 } |
| 2366 | 2370 |
| 2367 ExternalReference new_space_allocation_top = | 2371 ExternalReference new_space_allocation_top = |
| 2368 ExternalReference::new_space_allocation_top_address(); | 2372 ExternalReference::new_space_allocation_top_address(); |
| 2369 | 2373 |
| 2370 // Update new top. | 2374 // Update new top. |
| 2371 if (result_end.is(rax)) { | 2375 if (result_end.is(rax)) { |
| 2372 // rax can be stored directly to a memory location. | 2376 // rax can be stored directly to a memory location. |
| 2373 store_rax(new_space_allocation_top); | 2377 store_rax(new_space_allocation_top); |
| 2374 } else { | 2378 } else { |
| 2375 // Register required - use scratch provided if available. | 2379 // Register required - use scratch provided if available. |
| 2376 if (scratch.is(no_reg)) { | 2380 if (!scratch.is_valid()) { |
| 2377 movq(kScratchRegister, new_space_allocation_top); | 2381 movq(kScratchRegister, new_space_allocation_top); |
| 2378 movq(Operand(kScratchRegister, 0), result_end); | 2382 movq(Operand(kScratchRegister, 0), result_end); |
| 2379 } else { | 2383 } else { |
| 2380 movq(Operand(scratch, 0), result_end); | 2384 movq(Operand(scratch, 0), result_end); |
| 2381 } | 2385 } |
| 2382 } | 2386 } |
| 2383 } | 2387 } |
| 2384 | 2388 |
| 2385 | 2389 |
| 2386 void MacroAssembler::AllocateInNewSpace(int object_size, | 2390 void MacroAssembler::AllocateInNewSpace(int object_size, |
| 2387 Register result, | 2391 Register result, |
| 2388 Register result_end, | 2392 Register result_end, |
| 2389 Register scratch, | 2393 Register scratch, |
| 2390 Label* gc_required, | 2394 Label* gc_required, |
| 2391 AllocationFlags flags) { | 2395 AllocationFlags flags) { |
| 2392 ASSERT(!result.is(result_end)); | 2396 ASSERT(!result.is(result_end)); |
| 2393 | 2397 |
| 2394 // Load address of new object into result. | 2398 // Load address of new object into result. |
| 2395 LoadAllocationTopHelper(result, result_end, scratch, flags); | 2399 LoadAllocationTopHelper(result, result_end, scratch, flags); |
| 2396 | 2400 |
| 2397 // Calculate new top and bail out if new space is exhausted. | 2401 // Calculate new top and bail out if new space is exhausted. |
| 2398 ExternalReference new_space_allocation_limit = | 2402 ExternalReference new_space_allocation_limit = |
| 2399 ExternalReference::new_space_allocation_limit_address(); | 2403 ExternalReference::new_space_allocation_limit_address(); |
| 2400 lea(result_end, Operand(result, object_size)); | 2404 |
| 2405 Register top_reg = result_end.is_valid() ? result_end : result; |
| 2406 |
| 2407 lea(top_reg, Operand(result, object_size)); |
| 2401 movq(kScratchRegister, new_space_allocation_limit); | 2408 movq(kScratchRegister, new_space_allocation_limit); |
| 2402 cmpq(result_end, Operand(kScratchRegister, 0)); | 2409 cmpq(top_reg, Operand(kScratchRegister, 0)); |
| 2403 j(above, gc_required); | 2410 j(above, gc_required); |
| 2404 | 2411 |
| 2405 // Update allocation top. | 2412 // Update allocation top. |
| 2406 UpdateAllocationTopHelper(result_end, scratch); | 2413 UpdateAllocationTopHelper(top_reg, scratch); |
| 2407 | 2414 |
| 2408 // Tag the result if requested. | 2415 if (top_reg.is(result)) { |
| 2409 if ((flags & TAG_OBJECT) != 0) { | 2416 if ((flags & TAG_OBJECT) != 0) { |
| 2417 subq(result, Immediate(object_size - kHeapObjectTag)); |
| 2418 } else { |
| 2419 subq(result, Immediate(object_size)); |
| 2420 } |
| 2421 } else if ((flags & TAG_OBJECT) != 0) { |
| 2422 // Tag the result if requested. |
| 2410 addq(result, Immediate(kHeapObjectTag)); | 2423 addq(result, Immediate(kHeapObjectTag)); |
| 2411 } | 2424 } |
| 2412 } | 2425 } |
| 2413 | 2426 |
| 2414 | 2427 |
| 2415 void MacroAssembler::AllocateInNewSpace(int header_size, | 2428 void MacroAssembler::AllocateInNewSpace(int header_size, |
| 2416 ScaleFactor element_size, | 2429 ScaleFactor element_size, |
| 2417 Register element_count, | 2430 Register element_count, |
| 2418 Register result, | 2431 Register result, |
| 2419 Register result_end, | 2432 Register result_end, |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2688 CodePatcher::~CodePatcher() { | 2701 CodePatcher::~CodePatcher() { |
| 2689 // Indicate that code has changed. | 2702 // Indicate that code has changed. |
| 2690 CPU::FlushICache(address_, size_); | 2703 CPU::FlushICache(address_, size_); |
| 2691 | 2704 |
| 2692 // Check that the code was patched as expected. | 2705 // Check that the code was patched as expected. |
| 2693 ASSERT(masm_.pc_ == address_ + size_); | 2706 ASSERT(masm_.pc_ == address_ + size_); |
| 2694 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 2707 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
| 2695 } | 2708 } |
| 2696 | 2709 |
| 2697 } } // namespace v8::internal | 2710 } } // namespace v8::internal |
| OLD | NEW |