| OLD | NEW |
| 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 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 namespace v8 { | 37 namespace v8 { |
| 38 namespace internal { | 38 namespace internal { |
| 39 | 39 |
| 40 | 40 |
| 41 // ----------------------------------------------------------------------------- | 41 // ----------------------------------------------------------------------------- |
| 42 // Implementation of Assembler | 42 // Implementation of Assembler |
| 43 | 43 |
| 44 | 44 |
| 45 static const byte kCallOpcode = 0xE8; | 45 static const byte kCallOpcode = 0xE8; |
| 46 static const int kNoCodeAgeSequenceLength = 6; |
| 46 | 47 |
| 47 | 48 |
| 48 void Assembler::emitl(uint32_t x) { | 49 void Assembler::emitl(uint32_t x) { |
| 49 Memory::uint32_at(pc_) = x; | 50 Memory::uint32_at(pc_) = x; |
| 50 pc_ += sizeof(uint32_t); | 51 pc_ += sizeof(uint32_t); |
| 51 } | 52 } |
| 52 | 53 |
| 53 | 54 |
| 54 void Assembler::emitp(void* x, RelocInfo::Mode rmode) { | 55 void Assembler::emitp(void* x, RelocInfo::Mode rmode) { |
| 55 uintptr_t value = reinterpret_cast<uintptr_t>(x); | 56 uintptr_t value = reinterpret_cast<uintptr_t>(x); |
| 56 Memory::uintptr_at(pc_) = value; | 57 Memory::uintptr_at(pc_) = value; |
| 57 if (!RelocInfo::IsNone(rmode)) { | 58 if (!RelocInfo::IsNone(rmode)) { |
| 58 RecordRelocInfo(rmode, value); | 59 RecordRelocInfo(rmode, value); |
| 59 } | 60 } |
| 60 pc_ += sizeof(uintptr_t); | 61 pc_ += sizeof(uintptr_t); |
| 61 } | 62 } |
| 62 | 63 |
| 63 | 64 |
| 64 void Assembler::emitq(uint64_t x, RelocInfo::Mode rmode) { | 65 void Assembler::emitq(uint64_t x) { |
| 65 Memory::uint64_at(pc_) = x; | 66 Memory::uint64_at(pc_) = x; |
| 66 if (!RelocInfo::IsNone(rmode)) { | |
| 67 RecordRelocInfo(rmode, x); | |
| 68 } | |
| 69 pc_ += sizeof(uint64_t); | 67 pc_ += sizeof(uint64_t); |
| 70 } | 68 } |
| 71 | 69 |
| 72 | 70 |
| 73 void Assembler::emitw(uint16_t x) { | 71 void Assembler::emitw(uint16_t x) { |
| 74 Memory::uint16_at(pc_) = x; | 72 Memory::uint16_at(pc_) = x; |
| 75 pc_ += sizeof(uint16_t); | 73 pc_ += sizeof(uint16_t); |
| 76 } | 74 } |
| 77 | 75 |
| 78 | 76 |
| 79 void Assembler::emit_code_target(Handle<Code> target, | 77 void Assembler::emit_code_target(Handle<Code> target, |
| 80 RelocInfo::Mode rmode, | 78 RelocInfo::Mode rmode, |
| 81 TypeFeedbackId ast_id) { | 79 TypeFeedbackId ast_id) { |
| 82 ASSERT(RelocInfo::IsCodeTarget(rmode)); | 80 ASSERT(RelocInfo::IsCodeTarget(rmode) || |
| 81 rmode == RelocInfo::CODE_AGE_SEQUENCE); |
| 83 if (rmode == RelocInfo::CODE_TARGET && !ast_id.IsNone()) { | 82 if (rmode == RelocInfo::CODE_TARGET && !ast_id.IsNone()) { |
| 84 RecordRelocInfo(RelocInfo::CODE_TARGET_WITH_ID, ast_id.ToInt()); | 83 RecordRelocInfo(RelocInfo::CODE_TARGET_WITH_ID, ast_id.ToInt()); |
| 85 } else { | 84 } else { |
| 86 RecordRelocInfo(rmode); | 85 RecordRelocInfo(rmode); |
| 87 } | 86 } |
| 88 int current = code_targets_.length(); | 87 int current = code_targets_.length(); |
| 89 if (current > 0 && code_targets_.last().is_identical_to(target)) { | 88 if (current > 0 && code_targets_.last().is_identical_to(target)) { |
| 90 // Optimization if we keep jumping to the same code target. | 89 // Optimization if we keep jumping to the same code target. |
| 91 emitl(current - 1); | 90 emitl(current - 1); |
| 92 } else { | 91 } else { |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 return false; | 384 return false; |
| 386 #endif | 385 #endif |
| 387 } | 386 } |
| 388 | 387 |
| 389 | 388 |
| 390 bool RelocInfo::IsPatchedDebugBreakSlotSequence() { | 389 bool RelocInfo::IsPatchedDebugBreakSlotSequence() { |
| 391 return !Assembler::IsNop(pc()); | 390 return !Assembler::IsNop(pc()); |
| 392 } | 391 } |
| 393 | 392 |
| 394 | 393 |
| 394 Handle<Object> RelocInfo::code_age_stub_handle(Assembler* origin) { |
| 395 ASSERT(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); |
| 396 ASSERT(*pc_ == kCallOpcode); |
| 397 return origin->code_target_object_handle_at(pc_ + 1); |
| 398 } |
| 399 |
| 400 |
| 395 Code* RelocInfo::code_age_stub() { | 401 Code* RelocInfo::code_age_stub() { |
| 396 ASSERT(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); | 402 ASSERT(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); |
| 397 ASSERT(*pc_ == kCallOpcode); | 403 ASSERT(*pc_ == kCallOpcode); |
| 398 return Code::GetCodeFromTargetAddress( | 404 return Code::GetCodeFromTargetAddress( |
| 399 Assembler::target_address_at(pc_ + 1)); | 405 Assembler::target_address_at(pc_ + 1)); |
| 400 } | 406 } |
| 401 | 407 |
| 402 | 408 |
| 403 void RelocInfo::set_code_age_stub(Code* stub) { | 409 void RelocInfo::set_code_age_stub(Code* stub) { |
| 404 ASSERT(*pc_ == kCallOpcode); | 410 ASSERT(*pc_ == kCallOpcode); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 ASSERT(len_ == 1 || len_ == 2); | 545 ASSERT(len_ == 1 || len_ == 2); |
| 540 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]); | 546 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]); |
| 541 *p = disp; | 547 *p = disp; |
| 542 len_ += sizeof(int32_t); | 548 len_ += sizeof(int32_t); |
| 543 } | 549 } |
| 544 | 550 |
| 545 | 551 |
| 546 } } // namespace v8::internal | 552 } } // namespace v8::internal |
| 547 | 553 |
| 548 #endif // V8_X64_ASSEMBLER_X64_INL_H_ | 554 #endif // V8_X64_ASSEMBLER_X64_INL_H_ |
| OLD | NEW |