OLD | NEW |
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
2 // All Rights Reserved. | 2 // All Rights Reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions | 5 // modification, are permitted provided that the following conditions |
6 // are met: | 6 // are met: |
7 // | 7 // |
8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
10 // | 10 // |
(...skipping 2417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2428 | 2428 |
2429 | 2429 |
2430 void Assembler::RecordComment(const char* msg) { | 2430 void Assembler::RecordComment(const char* msg) { |
2431 if (FLAG_code_comments) { | 2431 if (FLAG_code_comments) { |
2432 CheckBuffer(); | 2432 CheckBuffer(); |
2433 RecordRelocInfo(RelocInfo::COMMENT, reinterpret_cast<intptr_t>(msg)); | 2433 RecordRelocInfo(RelocInfo::COMMENT, reinterpret_cast<intptr_t>(msg)); |
2434 } | 2434 } |
2435 } | 2435 } |
2436 | 2436 |
2437 | 2437 |
| 2438 void Assembler::RecordConstPool(int size) { |
| 2439 // We only need this for debugger support, to correctly compute offsets in the |
| 2440 // code. |
| 2441 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 2442 RecordRelocInfo(RelocInfo::CONST_POOL, static_cast<intptr_t>(size)); |
| 2443 #endif |
| 2444 } |
| 2445 |
2438 void Assembler::GrowBuffer() { | 2446 void Assembler::GrowBuffer() { |
2439 if (!own_buffer_) FATAL("external code buffer is too small"); | 2447 if (!own_buffer_) FATAL("external code buffer is too small"); |
2440 | 2448 |
2441 // Compute new buffer size. | 2449 // Compute new buffer size. |
2442 CodeDesc desc; // the new buffer | 2450 CodeDesc desc; // the new buffer |
2443 if (buffer_size_ < 4*KB) { | 2451 if (buffer_size_ < 4*KB) { |
2444 desc.buffer_size = 4*KB; | 2452 desc.buffer_size = 4*KB; |
2445 } else if (buffer_size_ < 1*MB) { | 2453 } else if (buffer_size_ < 1*MB) { |
2446 desc.buffer_size = 2*buffer_size_; | 2454 desc.buffer_size = 2*buffer_size_; |
2447 } else { | 2455 } else { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2504 ASSERT(num_pending_reloc_info_ == 0); | 2512 ASSERT(num_pending_reloc_info_ == 0); |
2505 CheckBuffer(); | 2513 CheckBuffer(); |
2506 *reinterpret_cast<uint32_t*>(pc_) = data; | 2514 *reinterpret_cast<uint32_t*>(pc_) = data; |
2507 pc_ += sizeof(uint32_t); | 2515 pc_ += sizeof(uint32_t); |
2508 } | 2516 } |
2509 | 2517 |
2510 | 2518 |
2511 void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { | 2519 void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { |
2512 // We do not try to reuse pool constants. | 2520 // We do not try to reuse pool constants. |
2513 RelocInfo rinfo(pc_, rmode, data, NULL); | 2521 RelocInfo rinfo(pc_, rmode, data, NULL); |
2514 if (rmode >= RelocInfo::JS_RETURN && rmode <= RelocInfo::DEBUG_BREAK_SLOT) { | 2522 if (((rmode >= RelocInfo::JS_RETURN) && |
| 2523 (rmode <= RelocInfo::DEBUG_BREAK_SLOT)) || |
| 2524 (rmode == RelocInfo::CONST_POOL)) { |
2515 // Adjust code for new modes. | 2525 // Adjust code for new modes. |
2516 ASSERT(RelocInfo::IsDebugBreakSlot(rmode) | 2526 ASSERT(RelocInfo::IsDebugBreakSlot(rmode) |
2517 || RelocInfo::IsJSReturn(rmode) | 2527 || RelocInfo::IsJSReturn(rmode) |
2518 || RelocInfo::IsComment(rmode) | 2528 || RelocInfo::IsComment(rmode) |
2519 || RelocInfo::IsPosition(rmode)); | 2529 || RelocInfo::IsPosition(rmode) |
| 2530 || RelocInfo::IsConstPool(rmode)); |
2520 // These modes do not need an entry in the constant pool. | 2531 // These modes do not need an entry in the constant pool. |
2521 } else { | 2532 } else { |
2522 ASSERT(num_pending_reloc_info_ < kMaxNumPendingRelocInfo); | 2533 ASSERT(num_pending_reloc_info_ < kMaxNumPendingRelocInfo); |
2523 if (num_pending_reloc_info_ == 0) { | 2534 if (num_pending_reloc_info_ == 0) { |
2524 first_const_pool_use_ = pc_offset(); | 2535 first_const_pool_use_ = pc_offset(); |
2525 } | 2536 } |
2526 pending_reloc_info_[num_pending_reloc_info_++] = rinfo; | 2537 pending_reloc_info_[num_pending_reloc_info_++] = rinfo; |
2527 // Make sure the constant pool is not emitted in place of the next | 2538 // Make sure the constant pool is not emitted in place of the next |
2528 // instruction for which we just recorded relocation info. | 2539 // instruction for which we just recorded relocation info. |
2529 BlockConstPoolFor(1); | 2540 BlockConstPoolFor(1); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2595 int dist = pc_offset() - first_const_pool_use_; | 2606 int dist = pc_offset() - first_const_pool_use_; |
2596 if (!force_emit && dist < kAvgDistToPool && | 2607 if (!force_emit && dist < kAvgDistToPool && |
2597 (require_jump || (dist < (kMaxDistToPool / 2)))) { | 2608 (require_jump || (dist < (kMaxDistToPool / 2)))) { |
2598 return; | 2609 return; |
2599 } | 2610 } |
2600 | 2611 |
2601 // Check that the code buffer is large enough before emitting the constant | 2612 // Check that the code buffer is large enough before emitting the constant |
2602 // pool (include the jump over the pool and the constant pool marker and | 2613 // pool (include the jump over the pool and the constant pool marker and |
2603 // the gap to the relocation information). | 2614 // the gap to the relocation information). |
2604 int jump_instr = require_jump ? kInstrSize : 0; | 2615 int jump_instr = require_jump ? kInstrSize : 0; |
2605 int needed_space = jump_instr + kInstrSize + | 2616 int size = jump_instr + kInstrSize + num_pending_reloc_info_ * kPointerSize; |
2606 num_pending_reloc_info_ * kInstrSize + kGap; | 2617 int needed_space = size + kGap; |
2607 while (buffer_space() <= needed_space) GrowBuffer(); | 2618 while (buffer_space() <= needed_space) GrowBuffer(); |
2608 | 2619 |
2609 { | 2620 { |
2610 // Block recursive calls to CheckConstPool. | 2621 // Block recursive calls to CheckConstPool. |
2611 BlockConstPoolScope block_const_pool(this); | 2622 BlockConstPoolScope block_const_pool(this); |
| 2623 RecordComment("[ Constant Pool"); |
| 2624 RecordConstPool(size); |
2612 | 2625 |
2613 // Emit jump over constant pool if necessary. | 2626 // Emit jump over constant pool if necessary. |
2614 Label after_pool; | 2627 Label after_pool; |
2615 if (require_jump) { | 2628 if (require_jump) { |
2616 b(&after_pool); | 2629 b(&after_pool); |
2617 } | 2630 } |
2618 | 2631 |
2619 RecordComment("[ Constant Pool"); | |
2620 | |
2621 // Put down constant pool marker "Undefined instruction" as specified by | 2632 // Put down constant pool marker "Undefined instruction" as specified by |
2622 // A5.6 (ARMv7) Instruction set encoding. | 2633 // A5.6 (ARMv7) Instruction set encoding. |
2623 emit(kConstantPoolMarker | num_pending_reloc_info_); | 2634 emit(kConstantPoolMarker | num_pending_reloc_info_); |
2624 | 2635 |
2625 // Emit constant pool entries. | 2636 // Emit constant pool entries. |
2626 for (int i = 0; i < num_pending_reloc_info_; i++) { | 2637 for (int i = 0; i < num_pending_reloc_info_; i++) { |
2627 RelocInfo& rinfo = pending_reloc_info_[i]; | 2638 RelocInfo& rinfo = pending_reloc_info_[i]; |
2628 ASSERT(rinfo.rmode() != RelocInfo::COMMENT && | 2639 ASSERT(rinfo.rmode() != RelocInfo::COMMENT && |
2629 rinfo.rmode() != RelocInfo::POSITION && | 2640 rinfo.rmode() != RelocInfo::POSITION && |
2630 rinfo.rmode() != RelocInfo::STATEMENT_POSITION); | 2641 rinfo.rmode() != RelocInfo::STATEMENT_POSITION && |
| 2642 rinfo.rmode() != RelocInfo::CONST_POOL); |
2631 | 2643 |
2632 Instr instr = instr_at(rinfo.pc()); | 2644 Instr instr = instr_at(rinfo.pc()); |
2633 // Instruction to patch must be 'ldr rd, [pc, #offset]' with offset == 0. | 2645 // Instruction to patch must be 'ldr rd, [pc, #offset]' with offset == 0. |
2634 ASSERT(IsLdrPcImmediateOffset(instr) && | 2646 ASSERT(IsLdrPcImmediateOffset(instr) && |
2635 GetLdrRegisterImmediateOffset(instr) == 0); | 2647 GetLdrRegisterImmediateOffset(instr) == 0); |
2636 | 2648 |
2637 int delta = pc_ - rinfo.pc() - kPcLoadDelta; | 2649 int delta = pc_ - rinfo.pc() - kPcLoadDelta; |
2638 // 0 is the smallest delta: | 2650 // 0 is the smallest delta: |
2639 // ldr rd, [pc, #0] | 2651 // ldr rd, [pc, #0] |
2640 // constant pool marker | 2652 // constant pool marker |
(...skipping 16 matching lines...) Expand all Loading... |
2657 | 2669 |
2658 // Since a constant pool was just emitted, move the check offset forward by | 2670 // Since a constant pool was just emitted, move the check offset forward by |
2659 // the standard interval. | 2671 // the standard interval. |
2660 next_buffer_check_ = pc_offset() + kCheckPoolInterval; | 2672 next_buffer_check_ = pc_offset() + kCheckPoolInterval; |
2661 } | 2673 } |
2662 | 2674 |
2663 | 2675 |
2664 } } // namespace v8::internal | 2676 } } // namespace v8::internal |
2665 | 2677 |
2666 #endif // V8_TARGET_ARCH_ARM | 2678 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |