| 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 are | 5 // modification, are permitted provided that the following conditions are | 
| 6 // met: | 6 // 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 14 matching lines...) Expand all  Loading... | 
| 25 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 25 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 
| 26 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 26 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 
| 27 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 27 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 
| 28 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 28 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 
| 29 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
| 30 | 30 | 
| 31 // The original source code covered by the above license above has been | 31 // The original source code covered by the above license above has been | 
| 32 // modified significantly by Google Inc. | 32 // modified significantly by Google Inc. | 
| 33 // Copyright 2012 the V8 project authors. All rights reserved. | 33 // Copyright 2012 the V8 project authors. All rights reserved. | 
| 34 | 34 | 
| 35 |  | 
| 36 #include "src/v8.h" | 35 #include "src/v8.h" | 
| 37 | 36 | 
| 38 #if V8_TARGET_ARCH_MIPS64 | 37 #if V8_TARGET_ARCH_MIPS64 | 
| 39 | 38 | 
| 40 #include "src/base/cpu.h" | 39 #include "src/base/cpu.h" | 
| 41 #include "src/mips64/assembler-mips64-inl.h" | 40 #include "src/mips64/assembler-mips64-inl.h" | 
| 42 #include "src/serialize.h" | 41 #include "src/serialize.h" | 
| 43 | 42 | 
| 44 namespace v8 { | 43 namespace v8 { | 
| 45 namespace internal { | 44 namespace internal { | 
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 628   DCHECK(IsAddImmediate(instr)); | 627   DCHECK(IsAddImmediate(instr)); | 
| 629   return ((instr & ~kImm16Mask) | (offset & kImm16Mask)); | 628   return ((instr & ~kImm16Mask) | (offset & kImm16Mask)); | 
| 630 } | 629 } | 
| 631 | 630 | 
| 632 | 631 | 
| 633 bool Assembler::IsAndImmediate(Instr instr) { | 632 bool Assembler::IsAndImmediate(Instr instr) { | 
| 634   return GetOpcodeField(instr) == ANDI; | 633   return GetOpcodeField(instr) == ANDI; | 
| 635 } | 634 } | 
| 636 | 635 | 
| 637 | 636 | 
| 638 int64_t Assembler::target_at(int64_t pos, bool is_internal) { | 637 int Assembler::target_at(int pos, bool is_internal) { | 
| 639   if (is_internal) { | 638   if (is_internal) { | 
| 640     int64_t* p = reinterpret_cast<int64_t*>(buffer_ + pos); | 639     int64_t* p = reinterpret_cast<int64_t*>(buffer_ + pos); | 
| 641     int64_t address = *p; | 640     int64_t address = *p; | 
| 642     if (address == kEndOfJumpChain) { | 641     if (address == kEndOfJumpChain) { | 
| 643       return kEndOfChain; | 642       return kEndOfChain; | 
| 644     } else { | 643     } else { | 
| 645       int64_t instr_address = reinterpret_cast<int64_t>(p); | 644       int64_t instr_address = reinterpret_cast<int64_t>(p); | 
| 646       int64_t delta = instr_address - address; | 645       DCHECK(instr_address - address < INT_MAX); | 
|  | 646       int delta = static_cast<int>(instr_address - address); | 
| 647       DCHECK(pos > delta); | 647       DCHECK(pos > delta); | 
| 648       return pos - delta; | 648       return pos - delta; | 
| 649     } | 649     } | 
| 650   } | 650   } | 
| 651   Instr instr = instr_at(pos); | 651   Instr instr = instr_at(pos); | 
| 652   if ((instr & ~kImm16Mask) == 0) { | 652   if ((instr & ~kImm16Mask) == 0) { | 
| 653     // Emitted label constant, not part of a branch. | 653     // Emitted label constant, not part of a branch. | 
| 654     if (instr == 0) { | 654     if (instr == 0) { | 
| 655        return kEndOfChain; | 655        return kEndOfChain; | 
| 656      } else { | 656      } else { | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 682     imm |= static_cast<int64_t>(instr_ori & kImm16Mask) << 32; | 682     imm |= static_cast<int64_t>(instr_ori & kImm16Mask) << 32; | 
| 683     imm |= static_cast<int64_t>(instr_ori2 & kImm16Mask) << 16; | 683     imm |= static_cast<int64_t>(instr_ori2 & kImm16Mask) << 16; | 
| 684     // Sign extend address; | 684     // Sign extend address; | 
| 685     imm >>= 16; | 685     imm >>= 16; | 
| 686 | 686 | 
| 687     if (imm == kEndOfJumpChain) { | 687     if (imm == kEndOfJumpChain) { | 
| 688       // EndOfChain sentinel is returned directly, not relative to pc or pos. | 688       // EndOfChain sentinel is returned directly, not relative to pc or pos. | 
| 689       return kEndOfChain; | 689       return kEndOfChain; | 
| 690     } else { | 690     } else { | 
| 691       uint64_t instr_address = reinterpret_cast<int64_t>(buffer_ + pos); | 691       uint64_t instr_address = reinterpret_cast<int64_t>(buffer_ + pos); | 
| 692       int64_t delta = instr_address - imm; | 692       DCHECK(instr_address - imm < INT_MAX); | 
|  | 693       int delta = static_cast<int>(instr_address - imm); | 
| 693       DCHECK(pos > delta); | 694       DCHECK(pos > delta); | 
| 694       return pos - delta; | 695       return pos - delta; | 
| 695     } | 696     } | 
| 696   } else { | 697   } else { | 
| 697     int32_t imm28 = (instr & static_cast<int32_t>(kImm26Mask)) << 2; | 698     int32_t imm28 = (instr & static_cast<int32_t>(kImm26Mask)) << 2; | 
| 698     if (imm28 == kEndOfJumpChain) { | 699     if (imm28 == kEndOfJumpChain) { | 
| 699       // EndOfChain sentinel is returned directly, not relative to pc or pos. | 700       // EndOfChain sentinel is returned directly, not relative to pc or pos. | 
| 700       return kEndOfChain; | 701       return kEndOfChain; | 
| 701     } else { | 702     } else { | 
| 702       uint64_t instr_address = reinterpret_cast<int64_t>(buffer_ + pos); | 703       uint64_t instr_address = reinterpret_cast<int64_t>(buffer_ + pos); | 
| 703       instr_address &= kImm28Mask; | 704       instr_address &= kImm28Mask; | 
| 704       int64_t delta = instr_address - imm28; | 705       int delta = static_cast<int>(instr_address - imm28); | 
| 705       DCHECK(pos > delta); | 706       DCHECK(pos > delta); | 
| 706       return pos - delta; | 707       return pos - delta; | 
| 707     } | 708     } | 
| 708   } | 709   } | 
| 709 } | 710 } | 
| 710 | 711 | 
| 711 | 712 | 
| 712 void Assembler::target_at_put(int64_t pos, int64_t target_pos, | 713 void Assembler::target_at_put(int pos, int target_pos, bool is_internal) { | 
| 713                               bool is_internal) { |  | 
| 714   if (is_internal) { | 714   if (is_internal) { | 
| 715     uint64_t imm = reinterpret_cast<uint64_t>(buffer_) + target_pos; | 715     uint64_t imm = reinterpret_cast<uint64_t>(buffer_) + target_pos; | 
| 716     *reinterpret_cast<uint64_t*>(buffer_ + pos) = imm; | 716     *reinterpret_cast<uint64_t*>(buffer_ + pos) = imm; | 
| 717     return; | 717     return; | 
| 718   } | 718   } | 
| 719   Instr instr = instr_at(pos); | 719   Instr instr = instr_at(pos); | 
| 720   if ((instr & ~kImm16Mask) == 0) { | 720   if ((instr & ~kImm16Mask) == 0) { | 
| 721     DCHECK(target_pos == kEndOfChain || target_pos >= 0); | 721     DCHECK(target_pos == kEndOfChain || target_pos >= 0); | 
| 722     // Emitted label constant, not part of a branch. | 722     // Emitted label constant, not part of a branch. | 
| 723     // Make label relative to Code* of generated Code object. | 723     // Make label relative to Code* of generated Code object. | 
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 789                    internal_reference_positions_.end()); | 789                    internal_reference_positions_.end()); | 
| 790     } | 790     } | 
| 791   } else { | 791   } else { | 
| 792     PrintF("label in inconsistent state (pos = %d)\n", L->pos_); | 792     PrintF("label in inconsistent state (pos = %d)\n", L->pos_); | 
| 793   } | 793   } | 
| 794 } | 794 } | 
| 795 | 795 | 
| 796 | 796 | 
| 797 void Assembler::bind_to(Label* L, int pos) { | 797 void Assembler::bind_to(Label* L, int pos) { | 
| 798   DCHECK(0 <= pos && pos <= pc_offset());  // Must have valid binding position. | 798   DCHECK(0 <= pos && pos <= pc_offset());  // Must have valid binding position. | 
| 799   int32_t trampoline_pos = kInvalidSlotPos; | 799   int trampoline_pos = kInvalidSlotPos; | 
| 800   bool is_internal = false; | 800   bool is_internal = false; | 
| 801   if (L->is_linked() && !trampoline_emitted_) { | 801   if (L->is_linked() && !trampoline_emitted_) { | 
| 802     unbound_labels_count_--; | 802     unbound_labels_count_--; | 
| 803     next_buffer_check_ += kTrampolineSlotsSize; | 803     next_buffer_check_ += kTrampolineSlotsSize; | 
| 804   } | 804   } | 
| 805 | 805 | 
| 806   while (L->is_linked()) { | 806   while (L->is_linked()) { | 
| 807     int32_t fixup_pos = L->pos(); | 807     int fixup_pos = L->pos(); | 
| 808     int32_t dist = pos - fixup_pos; | 808     int dist = pos - fixup_pos; | 
| 809     is_internal = internal_reference_positions_.find(fixup_pos) != | 809     is_internal = internal_reference_positions_.find(fixup_pos) != | 
| 810                   internal_reference_positions_.end(); | 810                   internal_reference_positions_.end(); | 
| 811     next(L, is_internal);  // Call next before overwriting link with target at | 811     next(L, is_internal);  // Call next before overwriting link with target at | 
| 812                            // fixup_pos. | 812                            // fixup_pos. | 
| 813     Instr instr = instr_at(fixup_pos); | 813     Instr instr = instr_at(fixup_pos); | 
| 814     if (is_internal) { | 814     if (is_internal) { | 
| 815       target_at_put(fixup_pos, pos, is_internal); | 815       target_at_put(fixup_pos, pos, is_internal); | 
| 816     } else if (IsBranch(instr)) { | 816     } else if (IsBranch(instr)) { | 
| 817       if (dist > kMaxBranchOffset) { | 817       if (dist > kMaxBranchOffset) { | 
| 818         if (trampoline_pos == kInvalidSlotPos) { | 818         if (trampoline_pos == kInvalidSlotPos) { | 
| (...skipping 2142 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2961 void Assembler::PopulateConstantPool(ConstantPoolArray* constant_pool) { | 2961 void Assembler::PopulateConstantPool(ConstantPoolArray* constant_pool) { | 
| 2962   // No out-of-line constant pool support. | 2962   // No out-of-line constant pool support. | 
| 2963   DCHECK(!FLAG_enable_ool_constant_pool); | 2963   DCHECK(!FLAG_enable_ool_constant_pool); | 
| 2964   return; | 2964   return; | 
| 2965 } | 2965 } | 
| 2966 | 2966 | 
| 2967 | 2967 | 
| 2968 } }  // namespace v8::internal | 2968 } }  // namespace v8::internal | 
| 2969 | 2969 | 
| 2970 #endif  // V8_TARGET_ARCH_MIPS64 | 2970 #endif  // V8_TARGET_ARCH_MIPS64 | 
| OLD | NEW | 
|---|