Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/mips64/assembler-mips64-inl.h

Issue 1147503002: MIPS64: Improve long branches utilizing code range. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixed typo, addressed stale comment. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/mips64/assembler-mips64.cc ('k') | src/mips64/constants-mips64.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 // Copyright (c) 1994-2006 Sun Microsystems Inc. 2 // Copyright (c) 1994-2006 Sun Microsystems Inc.
3 // All Rights Reserved. 3 // All Rights Reserved.
4 // 4 //
5 // Redistribution and use in source and binary forms, with or without 5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are 6 // modification, are permitted provided that the following conditions are
7 // met: 7 // met:
8 // 8 //
9 // - Redistributions of source code must retain the above copyright notice, 9 // - Redistributions of source code must retain the above copyright notice,
10 // this list of conditions and the following disclaimer. 10 // this list of conditions and the following disclaimer.
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 } 189 }
190 190
191 191
192 Address Assembler::break_address_from_return_address(Address pc) { 192 Address Assembler::break_address_from_return_address(Address pc) {
193 return pc - Assembler::kPatchDebugBreakSlotReturnOffset; 193 return pc - Assembler::kPatchDebugBreakSlotReturnOffset;
194 } 194 }
195 195
196 196
197 void Assembler::set_target_internal_reference_encoded_at(Address pc, 197 void Assembler::set_target_internal_reference_encoded_at(Address pc,
198 Address target) { 198 Address target) {
199 // Encoded internal references are lui/ori load of 48-bit absolute address. 199 // Encoded internal references are j/jal instructions.
200 Instr instr_lui = Assembler::instr_at(pc + 0 * Assembler::kInstrSize); 200 Instr instr = Assembler::instr_at(pc + 0 * Assembler::kInstrSize);
201 Instr instr_ori = Assembler::instr_at(pc + 1 * Assembler::kInstrSize); 201
202 Instr instr_ori2 = Assembler::instr_at(pc + 3 * Assembler::kInstrSize); 202 uint64_t imm28 =
203 DCHECK(Assembler::IsLui(instr_lui)); 203 (reinterpret_cast<uint64_t>(target) & static_cast<uint64_t>(kImm28Mask));
204 DCHECK(Assembler::IsOri(instr_ori)); 204
205 DCHECK(Assembler::IsOri(instr_ori2)); 205 instr &= ~kImm26Mask;
206 instr_lui &= ~kImm16Mask; 206 uint64_t imm26 = imm28 >> 2;
207 instr_ori &= ~kImm16Mask; 207 DCHECK(is_uint26(imm26));
208 instr_ori2 &= ~kImm16Mask; 208
209 int64_t imm = reinterpret_cast<int64_t>(target); 209 instr_at_put(pc, instr | (imm26 & kImm26Mask));
210 DCHECK((imm & 3) == 0);
211 Assembler::instr_at_put(pc + 0 * Assembler::kInstrSize,
212 instr_lui | ((imm >> 32) & kImm16Mask));
213 Assembler::instr_at_put(pc + 1 * Assembler::kInstrSize,
214 instr_ori | ((imm >> 16) & kImm16Mask));
215 Assembler::instr_at_put(pc + 3 * Assembler::kInstrSize,
216 instr_ori | (imm & kImm16Mask));
217 // Currently used only by deserializer, and all code will be flushed 210 // Currently used only by deserializer, and all code will be flushed
218 // after complete deserialization, no need to flush on each reference. 211 // after complete deserialization, no need to flush on each reference.
219 } 212 }
220 213
221 214
222 void Assembler::deserialization_set_target_internal_reference_at( 215 void Assembler::deserialization_set_target_internal_reference_at(
223 Address pc, Address target, RelocInfo::Mode mode) { 216 Address pc, Address target, RelocInfo::Mode mode) {
224 if (mode == RelocInfo::INTERNAL_REFERENCE_ENCODED) { 217 if (mode == RelocInfo::INTERNAL_REFERENCE_ENCODED) {
225 DCHECK(IsLui(instr_at(pc))); 218 DCHECK(IsJ(instr_at(pc)));
226 set_target_internal_reference_encoded_at(pc, target); 219 set_target_internal_reference_encoded_at(pc, target);
227 } else { 220 } else {
228 DCHECK(mode == RelocInfo::INTERNAL_REFERENCE); 221 DCHECK(mode == RelocInfo::INTERNAL_REFERENCE);
229 Memory::Address_at(pc) = target; 222 Memory::Address_at(pc) = target;
230 } 223 }
231 } 224 }
232 225
233 226
234 Object* RelocInfo::target_object() { 227 Object* RelocInfo::target_object() {
235 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); 228 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
(...skipping 27 matching lines...) Expand all
263 Address RelocInfo::target_external_reference() { 256 Address RelocInfo::target_external_reference() {
264 DCHECK(rmode_ == EXTERNAL_REFERENCE); 257 DCHECK(rmode_ == EXTERNAL_REFERENCE);
265 return Assembler::target_address_at(pc_, host_); 258 return Assembler::target_address_at(pc_, host_);
266 } 259 }
267 260
268 261
269 Address RelocInfo::target_internal_reference() { 262 Address RelocInfo::target_internal_reference() {
270 if (rmode_ == INTERNAL_REFERENCE) { 263 if (rmode_ == INTERNAL_REFERENCE) {
271 return Memory::Address_at(pc_); 264 return Memory::Address_at(pc_);
272 } else { 265 } else {
273 // Encoded internal references are lui/ori load of 48-bit absolute address. 266 // Encoded internal references are j/jal instructions.
274 DCHECK(rmode_ == INTERNAL_REFERENCE_ENCODED); 267 DCHECK(rmode_ == INTERNAL_REFERENCE_ENCODED);
275 Instr instr_lui = Assembler::instr_at(pc_ + 0 * Assembler::kInstrSize); 268 Instr instr = Assembler::instr_at(pc_ + 0 * Assembler::kInstrSize);
276 Instr instr_ori = Assembler::instr_at(pc_ + 1 * Assembler::kInstrSize); 269 instr &= kImm26Mask;
277 Instr instr_ori2 = Assembler::instr_at(pc_ + 3 * Assembler::kInstrSize); 270 uint64_t imm28 = instr << 2;
278 DCHECK(Assembler::IsLui(instr_lui)); 271 uint64_t segment =
279 DCHECK(Assembler::IsOri(instr_ori)); 272 (reinterpret_cast<uint64_t>(pc_) & ~static_cast<uint64_t>(kImm28Mask));
280 DCHECK(Assembler::IsOri(instr_ori2)); 273 return reinterpret_cast<Address>(segment | imm28);
281 int64_t imm = (instr_lui & static_cast<int64_t>(kImm16Mask)) << 32;
282 imm |= (instr_ori & static_cast<int64_t>(kImm16Mask)) << 16;
283 imm |= (instr_ori2 & static_cast<int64_t>(kImm16Mask));
284 return reinterpret_cast<Address>(imm);
285 } 274 }
286 } 275 }
287 276
288 277
289 Address RelocInfo::target_internal_reference_address() { 278 Address RelocInfo::target_internal_reference_address() {
290 DCHECK(rmode_ == INTERNAL_REFERENCE || rmode_ == INTERNAL_REFERENCE_ENCODED); 279 DCHECK(rmode_ == INTERNAL_REFERENCE || rmode_ == INTERNAL_REFERENCE_ENCODED);
291 return reinterpret_cast<Address>(pc_); 280 return reinterpret_cast<Address>(pc_);
292 } 281 }
293 282
294 283
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 } 516 }
528 *reinterpret_cast<uint64_t*>(pc_) = x; 517 *reinterpret_cast<uint64_t*>(pc_) = x;
529 pc_ += kInstrSize * 2; 518 pc_ += kInstrSize * 2;
530 CheckTrampolinePoolQuick(); 519 CheckTrampolinePoolQuick();
531 } 520 }
532 521
533 522
534 } } // namespace v8::internal 523 } } // namespace v8::internal
535 524
536 #endif // V8_MIPS_ASSEMBLER_MIPS_INL_H_ 525 #endif // V8_MIPS_ASSEMBLER_MIPS_INL_H_
OLDNEW
« no previous file with comments | « src/mips64/assembler-mips64.cc ('k') | src/mips64/constants-mips64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698