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

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

Issue 191233003: Add out-of-line constant pool support to Arm. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix other Arches. Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/arm/assembler-arm.cc ('k') | src/arm/builtins-arm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 Address RelocInfo::target_address() { 102 Address RelocInfo::target_address() {
103 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); 103 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_));
104 return Assembler::target_address_at(pc_, host_); 104 return Assembler::target_address_at(pc_, host_);
105 } 105 }
106 106
107 107
108 Address RelocInfo::target_address_address() { 108 Address RelocInfo::target_address_address() {
109 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) 109 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)
110 || rmode_ == EMBEDDED_OBJECT 110 || rmode_ == EMBEDDED_OBJECT
111 || rmode_ == EXTERNAL_REFERENCE); 111 || rmode_ == EXTERNAL_REFERENCE);
112 return Assembler::target_pointer_address_at(pc_); 112 if (FLAG_enable_ool_constant_pool ||
113 Assembler::IsMovW(Memory::int32_at(pc_))) {
114 // We return the PC for ool constant pool since this function is used by the
115 // serializerer and expects the address to reside within the code object.
116 return reinterpret_cast<Address>(pc_);
117 } else {
118 ASSERT(Assembler::IsLdrPcImmediateOffset(Memory::int32_at(pc_)));
119 return Assembler::target_pointer_address_at(pc_);
120 }
113 } 121 }
114 122
115 123
116 Address RelocInfo::constant_pool_entry_address() { 124 Address RelocInfo::constant_pool_entry_address() {
117 ASSERT(IsInConstantPool()); 125 ASSERT(IsInConstantPool());
118 ASSERT(Assembler::IsLdrPcImmediateOffset(Memory::int32_at(pc_))); 126 if (FLAG_enable_ool_constant_pool) {
119 return Assembler::target_pointer_address_at(pc_); 127 ASSERT(Assembler::IsLdrPpImmediateOffset(Memory::int32_at(pc_)));
128 return Assembler::target_constant_pool_address_at(pc_,
129 host_->constant_pool());
130 } else {
131 ASSERT(Assembler::IsLdrPcImmediateOffset(Memory::int32_at(pc_)));
132 return Assembler::target_pointer_address_at(pc_);
133 }
120 } 134 }
121 135
122 136
123 int RelocInfo::target_address_size() { 137 int RelocInfo::target_address_size() {
124 return kPointerSize; 138 return kPointerSize;
125 } 139 }
126 140
127 141
128 void RelocInfo::set_target_address(Address target, WriteBarrierMode mode) { 142 void RelocInfo::set_target_address(Address target, WriteBarrierMode mode) {
129 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); 143 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_));
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 pc_ += kInstrSize; 417 pc_ += kInstrSize;
404 } 418 }
405 419
406 420
407 Address Assembler::target_pointer_address_at(Address pc) { 421 Address Assembler::target_pointer_address_at(Address pc) {
408 Instr instr = Memory::int32_at(pc); 422 Instr instr = Memory::int32_at(pc);
409 return pc + GetLdrRegisterImmediateOffset(instr) + kPcLoadDelta; 423 return pc + GetLdrRegisterImmediateOffset(instr) + kPcLoadDelta;
410 } 424 }
411 425
412 426
427 Address Assembler::target_constant_pool_address_at(
428 Address pc, ConstantPoolArray* constant_pool) {
429 ASSERT(constant_pool != NULL);
430 ASSERT(IsLdrPpImmediateOffset(Memory::int32_at(pc)));
431 Instr instr = Memory::int32_at(pc);
432 return reinterpret_cast<Address>(constant_pool) +
433 GetLdrRegisterImmediateOffset(instr);
434 }
435
436
413 Address Assembler::target_address_at(Address pc, 437 Address Assembler::target_address_at(Address pc,
414 ConstantPoolArray* constant_pool) { 438 ConstantPoolArray* constant_pool) {
415 if (IsMovW(Memory::int32_at(pc))) { 439 if (IsMovW(Memory::int32_at(pc))) {
416 ASSERT(IsMovT(Memory::int32_at(pc + kInstrSize))); 440 ASSERT(IsMovT(Memory::int32_at(pc + kInstrSize)));
417 Instruction* instr = Instruction::At(pc); 441 Instruction* instr = Instruction::At(pc);
418 Instruction* next_instr = Instruction::At(pc + kInstrSize); 442 Instruction* next_instr = Instruction::At(pc + kInstrSize);
419 return reinterpret_cast<Address>( 443 return reinterpret_cast<Address>(
420 (next_instr->ImmedMovwMovtValue() << 16) | 444 (next_instr->ImmedMovwMovtValue() << 16) |
421 instr->ImmedMovwMovtValue()); 445 instr->ImmedMovwMovtValue());
446 } else if (FLAG_enable_ool_constant_pool) {
447 ASSERT(IsLdrPpImmediateOffset(Memory::int32_at(pc)));
448 return Memory::Address_at(
449 target_constant_pool_address_at(pc, constant_pool));
450 } else {
451 ASSERT(IsLdrPcImmediateOffset(Memory::int32_at(pc)));
452 return Memory::Address_at(target_pointer_address_at(pc));
422 } 453 }
423 ASSERT(IsLdrPcImmediateOffset(Memory::int32_at(pc)));
424 return Memory::Address_at(target_pointer_address_at(pc));
425 } 454 }
426 455
427 456
428 Address Assembler::target_address_from_return_address(Address pc) { 457 Address Assembler::target_address_from_return_address(Address pc) {
429 // Returns the address of the call target from the return address that will 458 // Returns the address of the call target from the return address that will
430 // be returned to after a call. 459 // be returned to after a call.
431 // Call sequence on V7 or later is : 460 // Call sequence on V7 or later is :
432 // movw ip, #... @ call address low 16 461 // movw ip, #... @ call address low 16
433 // movt ip, #... @ call address high 16 462 // movt ip, #... @ call address high 16
434 // blx ip 463 // blx ip
435 // @ return address 464 // @ return address
436 // Or pre-V7 or cases that need frequent patching: 465 // Or pre-V7 or cases that need frequent patching:
437 // ldr ip, [pc, #...] @ call address 466 // ldr ip, [pc, #...] @ call address
438 // blx ip 467 // blx ip
439 // @ return address 468 // @ return address
440 Address candidate = pc - 2 * Assembler::kInstrSize; 469 Address candidate = pc - 2 * Assembler::kInstrSize;
441 Instr candidate_instr(Memory::int32_at(candidate)); 470 Instr candidate_instr(Memory::int32_at(candidate));
442 if (IsLdrPcImmediateOffset(candidate_instr)) { 471 if (IsLdrPcImmediateOffset(candidate_instr) |
472 IsLdrPpImmediateOffset(candidate_instr)) {
443 return candidate; 473 return candidate;
444 } 474 }
445 candidate = pc - 3 * Assembler::kInstrSize; 475 candidate = pc - 3 * Assembler::kInstrSize;
446 ASSERT(IsMovW(Memory::int32_at(candidate)) && 476 ASSERT(IsMovW(Memory::int32_at(candidate)) &&
447 IsMovT(Memory::int32_at(candidate + kInstrSize))); 477 IsMovT(Memory::int32_at(candidate + kInstrSize)));
448 return candidate; 478 return candidate;
449 } 479 }
450 480
451 481
452 Address Assembler::return_address_from_call_start(Address pc) { 482 Address Assembler::return_address_from_call_start(Address pc) {
453 if (IsLdrPcImmediateOffset(Memory::int32_at(pc))) { 483 if (IsLdrPcImmediateOffset(Memory::int32_at(pc)) |
484 IsLdrPpImmediateOffset(Memory::int32_at(pc))) {
454 return pc + kInstrSize * 2; 485 return pc + kInstrSize * 2;
455 } else { 486 } else {
456 ASSERT(IsMovW(Memory::int32_at(pc))); 487 ASSERT(IsMovW(Memory::int32_at(pc)));
457 ASSERT(IsMovT(Memory::int32_at(pc + kInstrSize))); 488 ASSERT(IsMovT(Memory::int32_at(pc + kInstrSize)));
458 return pc + kInstrSize * 3; 489 return pc + kInstrSize * 3;
459 } 490 }
460 } 491 }
461 492
462 493
463 void Assembler::deserialization_set_special_target_at( 494 void Assembler::deserialization_set_special_target_at(
464 Address constant_pool_entry, Code* code, Address target) { 495 Address constant_pool_entry, Code* code, Address target) {
465 Memory::Address_at(constant_pool_entry) = target; 496 if (FLAG_enable_ool_constant_pool) {
497 set_target_address_at(constant_pool_entry, code, target);
498 } else {
499 Memory::Address_at(constant_pool_entry) = target;
500 }
466 } 501 }
467 502
468 503
469 static Instr EncodeMovwImmediate(uint32_t immediate) { 504 static Instr EncodeMovwImmediate(uint32_t immediate) {
470 ASSERT(immediate < 0x10000); 505 ASSERT(immediate < 0x10000);
471 return ((immediate & 0xf000) << 4) | (immediate & 0xfff); 506 return ((immediate & 0xf000) << 4) | (immediate & 0xfff);
472 } 507 }
473 508
474 509
475 void Assembler::set_target_address_at(Address pc, 510 void Assembler::set_target_address_at(Address pc,
476 ConstantPoolArray* constant_pool, 511 ConstantPoolArray* constant_pool,
477 Address target) { 512 Address target) {
478 if (IsMovW(Memory::int32_at(pc))) { 513 if (IsMovW(Memory::int32_at(pc))) {
479 ASSERT(IsMovT(Memory::int32_at(pc + kInstrSize))); 514 ASSERT(IsMovT(Memory::int32_at(pc + kInstrSize)));
480 uint32_t* instr_ptr = reinterpret_cast<uint32_t*>(pc); 515 uint32_t* instr_ptr = reinterpret_cast<uint32_t*>(pc);
481 uint32_t immediate = reinterpret_cast<uint32_t>(target); 516 uint32_t immediate = reinterpret_cast<uint32_t>(target);
482 uint32_t intermediate = instr_ptr[0]; 517 uint32_t intermediate = instr_ptr[0];
483 intermediate &= ~EncodeMovwImmediate(0xFFFF); 518 intermediate &= ~EncodeMovwImmediate(0xFFFF);
484 intermediate |= EncodeMovwImmediate(immediate & 0xFFFF); 519 intermediate |= EncodeMovwImmediate(immediate & 0xFFFF);
485 instr_ptr[0] = intermediate; 520 instr_ptr[0] = intermediate;
486 intermediate = instr_ptr[1]; 521 intermediate = instr_ptr[1];
487 intermediate &= ~EncodeMovwImmediate(0xFFFF); 522 intermediate &= ~EncodeMovwImmediate(0xFFFF);
488 intermediate |= EncodeMovwImmediate(immediate >> 16); 523 intermediate |= EncodeMovwImmediate(immediate >> 16);
489 instr_ptr[1] = intermediate; 524 instr_ptr[1] = intermediate;
490 ASSERT(IsMovW(Memory::int32_at(pc))); 525 ASSERT(IsMovW(Memory::int32_at(pc)));
491 ASSERT(IsMovT(Memory::int32_at(pc + kInstrSize))); 526 ASSERT(IsMovT(Memory::int32_at(pc + kInstrSize)));
492 CPU::FlushICache(pc, 2 * kInstrSize); 527 CPU::FlushICache(pc, 2 * kInstrSize);
528 } else if (FLAG_enable_ool_constant_pool) {
529 ASSERT(IsLdrPpImmediateOffset(Memory::int32_at(pc)));
530 Memory::Address_at(
531 target_constant_pool_address_at(pc, constant_pool)) = target;
493 } else { 532 } else {
494 ASSERT(IsLdrPcImmediateOffset(Memory::int32_at(pc))); 533 ASSERT(IsLdrPcImmediateOffset(Memory::int32_at(pc)));
495 Memory::Address_at(target_pointer_address_at(pc)) = target; 534 Memory::Address_at(target_pointer_address_at(pc)) = target;
496 // Intuitively, we would think it is necessary to always flush the 535 // Intuitively, we would think it is necessary to always flush the
497 // instruction cache after patching a target address in the code as follows: 536 // instruction cache after patching a target address in the code as follows:
498 // CPU::FlushICache(pc, sizeof(target)); 537 // CPU::FlushICache(pc, sizeof(target));
499 // However, on ARM, no instruction is actually patched in the case 538 // However, on ARM, no instruction is actually patched in the case
500 // of embedded constants of the form: 539 // of embedded constants of the form:
501 // ldr ip, [pc, #...] 540 // ldr ip, [pc, #...]
502 // since the instruction accessing this address in the constant pool remains 541 // since the instruction accessing this address in the constant pool remains
503 // unchanged. 542 // unchanged.
504 } 543 }
505 } 544 }
506 545
507 546
508 } } // namespace v8::internal 547 } } // namespace v8::internal
509 548
510 #endif // V8_ARM_ASSEMBLER_ARM_INL_H_ 549 #endif // V8_ARM_ASSEMBLER_ARM_INL_H_
OLDNEW
« no previous file with comments | « src/arm/assembler-arm.cc ('k') | src/arm/builtins-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698