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

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

Issue 195983002: Reland "Pass a Code object to Assembler::(set_)target_address_at for use by ool constant pool." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix ia32 and x64 bug/ 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/ia32/assembler-ia32.h ('k') | src/ia32/frames-ia32.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 // 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // absolute code pointer inside code object moves with the code object. 78 // absolute code pointer inside code object moves with the code object.
79 int32_t* p = reinterpret_cast<int32_t*>(pc_); 79 int32_t* p = reinterpret_cast<int32_t*>(pc_);
80 *p += delta; // Relocate entry. 80 *p += delta; // Relocate entry.
81 CPU::FlushICache(p, sizeof(uint32_t)); 81 CPU::FlushICache(p, sizeof(uint32_t));
82 } 82 }
83 } 83 }
84 84
85 85
86 Address RelocInfo::target_address() { 86 Address RelocInfo::target_address() {
87 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); 87 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_));
88 return Assembler::target_address_at(pc_); 88 return Assembler::target_address_at(pc_, host_);
89 } 89 }
90 90
91 91
92 Address RelocInfo::target_address_address() { 92 Address RelocInfo::target_address_address() {
93 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) 93 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)
94 || rmode_ == EMBEDDED_OBJECT 94 || rmode_ == EMBEDDED_OBJECT
95 || rmode_ == EXTERNAL_REFERENCE); 95 || rmode_ == EXTERNAL_REFERENCE);
96 return reinterpret_cast<Address>(pc_); 96 return reinterpret_cast<Address>(pc_);
97 } 97 }
98 98
99 99
100 Address RelocInfo::constant_pool_entry_address() { 100 Address RelocInfo::constant_pool_entry_address() {
101 UNREACHABLE(); 101 UNREACHABLE();
102 return NULL; 102 return NULL;
103 } 103 }
104 104
105 105
106 int RelocInfo::target_address_size() { 106 int RelocInfo::target_address_size() {
107 return Assembler::kSpecialTargetSize; 107 return Assembler::kSpecialTargetSize;
108 } 108 }
109 109
110 110
111 void RelocInfo::set_target_address(Address target, WriteBarrierMode mode) { 111 void RelocInfo::set_target_address(Address target, WriteBarrierMode mode) {
112 Assembler::set_target_address_at(pc_, target); 112 Assembler::set_target_address_at(pc_, host_, target);
113 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); 113 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_));
114 if (mode == UPDATE_WRITE_BARRIER && host() != NULL && IsCodeTarget(rmode_)) { 114 if (mode == UPDATE_WRITE_BARRIER && host() != NULL && IsCodeTarget(rmode_)) {
115 Object* target_code = Code::GetCodeFromTargetAddress(target); 115 Object* target_code = Code::GetCodeFromTargetAddress(target);
116 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( 116 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode(
117 host(), this, HeapObject::cast(target_code)); 117 host(), this, HeapObject::cast(target_code));
118 } 118 }
119 } 119 }
120 120
121 121
122 Object* RelocInfo::target_object() { 122 Object* RelocInfo::target_object() {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 ASSERT(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); 195 ASSERT(rmode_ == RelocInfo::CODE_AGE_SEQUENCE);
196 ASSERT(*pc_ == kCallOpcode); 196 ASSERT(*pc_ == kCallOpcode);
197 return Memory::Object_Handle_at(pc_ + 1); 197 return Memory::Object_Handle_at(pc_ + 1);
198 } 198 }
199 199
200 200
201 Code* RelocInfo::code_age_stub() { 201 Code* RelocInfo::code_age_stub() {
202 ASSERT(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); 202 ASSERT(rmode_ == RelocInfo::CODE_AGE_SEQUENCE);
203 ASSERT(*pc_ == kCallOpcode); 203 ASSERT(*pc_ == kCallOpcode);
204 return Code::GetCodeFromTargetAddress( 204 return Code::GetCodeFromTargetAddress(
205 Assembler::target_address_at(pc_ + 1)); 205 Assembler::target_address_at(pc_ + 1, host_));
206 } 206 }
207 207
208 208
209 void RelocInfo::set_code_age_stub(Code* stub) { 209 void RelocInfo::set_code_age_stub(Code* stub) {
210 ASSERT(*pc_ == kCallOpcode); 210 ASSERT(*pc_ == kCallOpcode);
211 ASSERT(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); 211 ASSERT(rmode_ == RelocInfo::CODE_AGE_SEQUENCE);
212 Assembler::set_target_address_at(pc_ + 1, stub->instruction_start()); 212 Assembler::set_target_address_at(pc_ + 1, host_, stub->instruction_start());
213 } 213 }
214 214
215 215
216 Address RelocInfo::call_address() { 216 Address RelocInfo::call_address() {
217 ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || 217 ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) ||
218 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); 218 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()));
219 return Assembler::target_address_at(pc_ + 1); 219 return Assembler::target_address_at(pc_ + 1, host_);
220 } 220 }
221 221
222 222
223 void RelocInfo::set_call_address(Address target) { 223 void RelocInfo::set_call_address(Address target) {
224 ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || 224 ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) ||
225 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); 225 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()));
226 Assembler::set_target_address_at(pc_ + 1, target); 226 Assembler::set_target_address_at(pc_ + 1, host_, target);
227 if (host() != NULL) { 227 if (host() != NULL) {
228 Object* target_code = Code::GetCodeFromTargetAddress(target); 228 Object* target_code = Code::GetCodeFromTargetAddress(target);
229 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( 229 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode(
230 host(), this, HeapObject::cast(target_code)); 230 host(), this, HeapObject::cast(target_code));
231 } 231 }
232 } 232 }
233 233
234 234
235 Object* RelocInfo::call_object() { 235 Object* RelocInfo::call_object() {
236 return *call_object_address(); 236 return *call_object_address();
(...skipping 10 matching lines...) Expand all
247 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); 247 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()));
248 return reinterpret_cast<Object**>(pc_ + 1); 248 return reinterpret_cast<Object**>(pc_ + 1);
249 } 249 }
250 250
251 251
252 void RelocInfo::WipeOut() { 252 void RelocInfo::WipeOut() {
253 if (IsEmbeddedObject(rmode_) || IsExternalReference(rmode_)) { 253 if (IsEmbeddedObject(rmode_) || IsExternalReference(rmode_)) {
254 Memory::Address_at(pc_) = NULL; 254 Memory::Address_at(pc_) = NULL;
255 } else if (IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)) { 255 } else if (IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)) {
256 // Effectively write zero into the relocation. 256 // Effectively write zero into the relocation.
257 Assembler::set_target_address_at(pc_, pc_ + sizeof(int32_t)); 257 Assembler::set_target_address_at(pc_, host_, pc_ + sizeof(int32_t));
258 } else { 258 } else {
259 UNREACHABLE(); 259 UNREACHABLE();
260 } 260 }
261 } 261 }
262 262
263 263
264 bool RelocInfo::IsPatchedReturnSequence() { 264 bool RelocInfo::IsPatchedReturnSequence() {
265 return *pc_ == kCallOpcode; 265 return *pc_ == kCallOpcode;
266 } 266 }
267 267
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 438
439 439
440 void Assembler::emit_w(const Immediate& x) { 440 void Assembler::emit_w(const Immediate& x) {
441 ASSERT(RelocInfo::IsNone(x.rmode_)); 441 ASSERT(RelocInfo::IsNone(x.rmode_));
442 uint16_t value = static_cast<uint16_t>(x.x_); 442 uint16_t value = static_cast<uint16_t>(x.x_);
443 reinterpret_cast<uint16_t*>(pc_)[0] = value; 443 reinterpret_cast<uint16_t*>(pc_)[0] = value;
444 pc_ += sizeof(uint16_t); 444 pc_ += sizeof(uint16_t);
445 } 445 }
446 446
447 447
448 Address Assembler::target_address_at(Address pc) { 448 Address Assembler::target_address_at(Address pc,
449 ConstantPoolArray* constant_pool) {
449 return pc + sizeof(int32_t) + *reinterpret_cast<int32_t*>(pc); 450 return pc + sizeof(int32_t) + *reinterpret_cast<int32_t*>(pc);
450 } 451 }
451 452
452 453
453 void Assembler::set_target_address_at(Address pc, Address target) { 454 void Assembler::set_target_address_at(Address pc,
455 ConstantPoolArray* constant_pool,
456 Address target) {
454 int32_t* p = reinterpret_cast<int32_t*>(pc); 457 int32_t* p = reinterpret_cast<int32_t*>(pc);
455 *p = target - (pc + sizeof(int32_t)); 458 *p = target - (pc + sizeof(int32_t));
456 CPU::FlushICache(p, sizeof(int32_t)); 459 CPU::FlushICache(p, sizeof(int32_t));
457 } 460 }
458 461
459 462
460 Address Assembler::target_address_from_return_address(Address pc) { 463 Address Assembler::target_address_from_return_address(Address pc) {
461 return pc - kCallTargetAddressOffset; 464 return pc - kCallTargetAddressOffset;
462 } 465 }
463 466
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 539
537 Operand::Operand(int32_t disp, RelocInfo::Mode rmode) { 540 Operand::Operand(int32_t disp, RelocInfo::Mode rmode) {
538 // [disp/r] 541 // [disp/r]
539 set_modrm(0, ebp); 542 set_modrm(0, ebp);
540 set_dispr(disp, rmode); 543 set_dispr(disp, rmode);
541 } 544 }
542 545
543 } } // namespace v8::internal 546 } } // namespace v8::internal
544 547
545 #endif // V8_IA32_ASSEMBLER_IA32_INL_H_ 548 #endif // V8_IA32_ASSEMBLER_IA32_INL_H_
OLDNEW
« no previous file with comments | « src/ia32/assembler-ia32.h ('k') | src/ia32/frames-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698