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

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

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