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

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

Issue 183803022: 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: 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/x64/assembler-x64.h ('k') | src/x64/frames-x64.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 void Assembler::emit_optional_rex_32(Register rm_reg) { 198 void Assembler::emit_optional_rex_32(Register rm_reg) {
199 if (rm_reg.high_bit()) emit(0x41); 199 if (rm_reg.high_bit()) emit(0x41);
200 } 200 }
201 201
202 202
203 void Assembler::emit_optional_rex_32(const Operand& op) { 203 void Assembler::emit_optional_rex_32(const Operand& op) {
204 if (op.rex_ != 0) emit(0x40 | op.rex_); 204 if (op.rex_ != 0) emit(0x40 | op.rex_);
205 } 205 }
206 206
207 207
208 Address Assembler::target_address_at(Address pc) { 208 Address Assembler::target_address_at(Address pc,
209 ConstantPoolArray* constant_pool) {
209 return Memory::int32_at(pc) + pc + 4; 210 return Memory::int32_at(pc) + pc + 4;
210 } 211 }
211 212
212 213
213 void Assembler::set_target_address_at(Address pc, Address target) { 214 void Assembler::set_target_address_at(Address pc,
215 ConstantPoolArray* constant_pool,
216 Address target) {
214 Memory::int32_at(pc) = static_cast<int32_t>(target - pc - 4); 217 Memory::int32_at(pc) = static_cast<int32_t>(target - pc - 4);
215 CPU::FlushICache(pc, sizeof(int32_t)); 218 CPU::FlushICache(pc, sizeof(int32_t));
216 } 219 }
217 220
218 221
219 Address Assembler::target_address_from_return_address(Address pc) { 222 Address Assembler::target_address_from_return_address(Address pc) {
220 return pc - kCallTargetAddressOffset; 223 return pc - kCallTargetAddressOffset;
221 } 224 }
222 225
223 226
(...skipping 24 matching lines...) Expand all
248 int32_t* p = reinterpret_cast<int32_t*>(pc_ + 1); 251 int32_t* p = reinterpret_cast<int32_t*>(pc_ + 1);
249 *p -= static_cast<int32_t>(delta); // Relocate entry. 252 *p -= static_cast<int32_t>(delta); // Relocate entry.
250 CPU::FlushICache(p, sizeof(uint32_t)); 253 CPU::FlushICache(p, sizeof(uint32_t));
251 } 254 }
252 } 255 }
253 } 256 }
254 257
255 258
256 Address RelocInfo::target_address() { 259 Address RelocInfo::target_address() {
257 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); 260 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_));
258 return Assembler::target_address_at(pc_); 261 return Assembler::target_address_at(pc_, host_);
259 } 262 }
260 263
261 264
262 Address RelocInfo::target_address_address() { 265 Address RelocInfo::target_address_address() {
263 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) 266 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)
264 || rmode_ == EMBEDDED_OBJECT 267 || rmode_ == EMBEDDED_OBJECT
265 || rmode_ == EXTERNAL_REFERENCE); 268 || rmode_ == EXTERNAL_REFERENCE);
266 return reinterpret_cast<Address>(pc_); 269 return reinterpret_cast<Address>(pc_);
267 } 270 }
268 271
269 272
270 int RelocInfo::target_address_size() { 273 int RelocInfo::target_address_size() {
271 if (IsCodedSpecially()) { 274 if (IsCodedSpecially()) {
272 return Assembler::kSpecialTargetSize; 275 return Assembler::kSpecialTargetSize;
273 } else { 276 } else {
274 return kPointerSize; 277 return kPointerSize;
275 } 278 }
276 } 279 }
277 280
278 281
279 void RelocInfo::set_target_address(Address target, WriteBarrierMode mode) { 282 void RelocInfo::set_target_address(Address target, WriteBarrierMode mode) {
280 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); 283 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_));
281 Assembler::set_target_address_at(pc_, target); 284 Assembler::set_target_address_at(pc_, host_, target);
282 if (mode == UPDATE_WRITE_BARRIER && host() != NULL && IsCodeTarget(rmode_)) { 285 if (mode == UPDATE_WRITE_BARRIER && host() != NULL && IsCodeTarget(rmode_)) {
283 Object* target_code = Code::GetCodeFromTargetAddress(target); 286 Object* target_code = Code::GetCodeFromTargetAddress(target);
284 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( 287 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode(
285 host(), this, HeapObject::cast(target_code)); 288 host(), this, HeapObject::cast(target_code));
286 } 289 }
287 } 290 }
288 291
289 292
290 Object* RelocInfo::target_object() { 293 Object* RelocInfo::target_object() {
291 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); 294 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 host(), NULL, cell); 365 host(), NULL, cell);
363 } 366 }
364 } 367 }
365 368
366 369
367 void RelocInfo::WipeOut() { 370 void RelocInfo::WipeOut() {
368 if (IsEmbeddedObject(rmode_) || IsExternalReference(rmode_)) { 371 if (IsEmbeddedObject(rmode_) || IsExternalReference(rmode_)) {
369 Memory::Address_at(pc_) = NULL; 372 Memory::Address_at(pc_) = NULL;
370 } else if (IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)) { 373 } else if (IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)) {
371 // Effectively write zero into the relocation. 374 // Effectively write zero into the relocation.
372 Assembler::set_target_address_at(pc_, pc_ + sizeof(int32_t)); 375 Assembler::set_target_address_at(pc_, host_, pc_ + sizeof(int32_t));
373 } else { 376 } else {
374 UNREACHABLE(); 377 UNREACHABLE();
375 } 378 }
376 } 379 }
377 380
378 381
379 bool RelocInfo::IsPatchedReturnSequence() { 382 bool RelocInfo::IsPatchedReturnSequence() {
380 // The recognized call sequence is: 383 // The recognized call sequence is:
381 // movq(kScratchRegister, address); call(kScratchRegister); 384 // movq(kScratchRegister, address); call(kScratchRegister);
382 // It only needs to be distinguished from a return sequence 385 // It only needs to be distinguished from a return sequence
(...skipping 18 matching lines...) Expand all
401 ASSERT(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); 404 ASSERT(rmode_ == RelocInfo::CODE_AGE_SEQUENCE);
402 ASSERT(*pc_ == kCallOpcode); 405 ASSERT(*pc_ == kCallOpcode);
403 return origin->code_target_object_handle_at(pc_ + 1); 406 return origin->code_target_object_handle_at(pc_ + 1);
404 } 407 }
405 408
406 409
407 Code* RelocInfo::code_age_stub() { 410 Code* RelocInfo::code_age_stub() {
408 ASSERT(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); 411 ASSERT(rmode_ == RelocInfo::CODE_AGE_SEQUENCE);
409 ASSERT(*pc_ == kCallOpcode); 412 ASSERT(*pc_ == kCallOpcode);
410 return Code::GetCodeFromTargetAddress( 413 return Code::GetCodeFromTargetAddress(
411 Assembler::target_address_at(pc_ + 1)); 414 Assembler::target_address_at(pc_ + 1, host_));
412 } 415 }
413 416
414 417
415 void RelocInfo::set_code_age_stub(Code* stub) { 418 void RelocInfo::set_code_age_stub(Code* stub) {
416 ASSERT(*pc_ == kCallOpcode); 419 ASSERT(*pc_ == kCallOpcode);
417 ASSERT(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); 420 ASSERT(rmode_ == RelocInfo::CODE_AGE_SEQUENCE);
418 Assembler::set_target_address_at(pc_ + 1, stub->instruction_start()); 421 Assembler::set_target_address_at(pc_ + 1, host_, stub->instruction_start());
419 } 422 }
420 423
421 424
422 Address RelocInfo::call_address() { 425 Address RelocInfo::call_address() {
423 ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || 426 ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) ||
424 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); 427 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()));
425 return Memory::Address_at( 428 return Memory::Address_at(
426 pc_ + Assembler::kRealPatchReturnSequenceAddressOffset); 429 pc_ + Assembler::kRealPatchReturnSequenceAddressOffset);
427 } 430 }
428 431
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 ASSERT(len_ == 1 || len_ == 2); 554 ASSERT(len_ == 1 || len_ == 2);
552 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]); 555 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]);
553 *p = disp; 556 *p = disp;
554 len_ += sizeof(int32_t); 557 len_ += sizeof(int32_t);
555 } 558 }
556 559
557 560
558 } } // namespace v8::internal 561 } } // namespace v8::internal
559 562
560 #endif // V8_X64_ASSEMBLER_X64_INL_H_ 563 #endif // V8_X64_ASSEMBLER_X64_INL_H_
OLDNEW
« no previous file with comments | « src/x64/assembler-x64.h ('k') | src/x64/frames-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698