src/cpu/mips/vm/macroAssembler_mips.cpp

changeset 8862
fd13a567f179
parent 8019
3fb3ceb7398f
child 8865
ffcdff41a92f
equal deleted inserted replaced
8861:2a33b32dd03c 8862:fd13a567f179
93 } 93 }
94 94
95 95
96 void MacroAssembler::pd_patch_instruction(address branch, address target) { 96 void MacroAssembler::pd_patch_instruction(address branch, address target) {
97 jint& stub_inst = *(jint*) branch; 97 jint& stub_inst = *(jint*) branch;
98 jint *pc = (jint *)branch;
98 99
99 /* * 100 /* *
100 move(AT, RA); // dadd 101 move(AT, RA); // dadd
101 emit_long(insn_ORRI(regimm_op, 0, bgezal_op, 1)); 102 emit_long(insn_ORRI(regimm_op, 0, bgezal_op, 1));
102 nop(); 103 nop();
104 ori(T9, 0); 105 ori(T9, 0);
105 daddu(T9, T9, RA); 106 daddu(T9, T9, RA);
106 move(RA, AT); 107 move(RA, AT);
107 jr(T9); 108 jr(T9);
108 */ 109 */
109 if(special(stub_inst) == dadd_op) { 110 if((opcode(stub_inst) == special_op) && (special(stub_inst) == dadd_op)) {
110 jint *pc = (jint *)branch;
111 111
112 assert(opcode(pc[3]) == lui_op 112 assert(opcode(pc[3]) == lui_op
113 && opcode(pc[4]) == ori_op 113 && opcode(pc[4]) == ori_op
114 && special(pc[5]) == daddu_op, "Not a branch label patch"); 114 && special(pc[5]) == daddu_op, "Not a branch label patch");
115 if(!(opcode(pc[3]) == lui_op 115 if(!(opcode(pc[3]) == lui_op
133 __ nop(); 133 __ nop();
134 __ nop(); 134 __ nop();
135 __ nop(); 135 __ nop();
136 } 136 }
137 return; 137 return;
138 } else if (special(pc[4]) == jr_op
139 && opcode(pc[4]) == special_op
140 && (((opcode(pc[0]) == lui_op) || opcode(pc[0]) == daddiu_op) || (opcode(pc[0]) == ori_op))) {
141
142 CodeBuffer cb(branch, 4 * 4);
143 MacroAssembler masm(&cb);
144 masm.patchable_set48(T9, (long)(target));
145 return;
138 } 146 }
139 147
140 #ifndef PRODUCT 148 #ifndef PRODUCT
141 if (!is_simm16((target - branch - 4) >> 2)) { 149 if (!is_simm16((target - branch - 4) >> 2)) {
142 tty->print_cr("Illegal patching: target=0x%lx", target); 150 tty->print_cr("Illegal patching: target=0x%lx", target);
328 delayed()->nop(); 336 delayed()->nop();
329 337
330 bind(not_jump); 338 bind(not_jump);
331 has_delay_slot(); 339 has_delay_slot();
332 } 340 }
341 }
342
343 void MacroAssembler::beq_long(Register rs, Register rt, Label& L) {
344 Label not_taken;
345
346 bne(rs, rt, not_taken);
347 nop();
348
349 jmp_far(L);
350
351 bind(not_taken);
352 }
353
354 void MacroAssembler::bne_long(Register rs, Register rt, Label& L) {
355 Label not_taken;
356
357 beq(rs, rt, not_taken);
358 nop();
359
360 jmp_far(L);
361
362 bind(not_taken);
363 }
364
365 void MacroAssembler::bc1t_long(Label& L) {
366 Label not_taken;
367
368 bc1f(not_taken);
369 nop();
370
371 jmp_far(L);
372
373 bind(not_taken);
374 }
375
376 void MacroAssembler::bc1f_long(Label& L) {
377 Label not_taken;
378
379 bc1t(not_taken);
380 nop();
381
382 jmp_far(L);
383
384 bind(not_taken);
333 } 385 }
334 386
335 void MacroAssembler::b_far(Label& L) { 387 void MacroAssembler::b_far(Label& L) {
336 if (L.is_bound()) { 388 if (L.is_bound()) {
337 b_far(target(L)); 389 b_far(target(L));
743 patchable_set48(T9, (long)entry); 795 patchable_set48(T9, (long)entry);
744 jr(T9); 796 jr(T9);
745 } 797 }
746 break; 798 break;
747 } 799 }
800 }
801
802 void MacroAssembler::jmp_far(Label& L) {
803 if (L.is_bound()) {
804 address entry = target(L);
805 assert(entry != NULL, "jmp most probably wrong");
806 InstructionMark im(this);
807
808 relocate(relocInfo::internal_word_type);
809 patchable_set48(T9, (long)entry);
810 } else {
811 InstructionMark im(this);
812 L.add_patch_at(code(), locator());
813
814 relocate(relocInfo::internal_word_type);
815 patchable_set48(T9, (long)pc());
816 }
817
818 jr(T9);
819 nop();
748 } 820 }
749 821
750 void MacroAssembler::call(address entry) { 822 void MacroAssembler::call(address entry) {
751 // c/c++ code assume T9 is entry point, so we just always move entry to t9 823 // c/c++ code assume T9 is entry point, so we just always move entry to t9
752 // maybe there is some more graceful method to handle this. FIXME 824 // maybe there is some more graceful method to handle this. FIXME

mercurial