| OLD | NEW |
| 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 // | 272 // |
| 273 // 01: code_target: [6-bit pc delta] 01 | 273 // 01: code_target: [6-bit pc delta] 01 |
| 274 // | 274 // |
| 275 // 10: short_data_record: [6-bit pc delta] 10 followed by | 275 // 10: short_data_record: [6-bit pc delta] 10 followed by |
| 276 // [6-bit data delta] [2-bit data type tag] | 276 // [6-bit data delta] [2-bit data type tag] |
| 277 // | 277 // |
| 278 // 11: long_record [6 bit reloc mode] 11 | 278 // 11: long_record [6 bit reloc mode] 11 |
| 279 // followed by pc delta | 279 // followed by pc delta |
| 280 // followed by optional data depending on type. | 280 // followed by optional data depending on type. |
| 281 // | 281 // |
| 282 // 2-bit data type tags, used in short_data_record and data_jump long_record: | 282 // 1-bit data type tags, used in short_data_record and data_jump long_record: |
| 283 // code_target_with_id: 00 | 283 // code_target_with_id: 0 |
| 284 // position: 01 | 284 // deopt_reason: 1 |
| 285 // statement_position: 10 | |
| 286 // deopt_reason: 11 | |
| 287 // | 285 // |
| 288 // If a pc delta exceeds 6 bits, it is split into a remainder that fits into | 286 // If a pc delta exceeds 6 bits, it is split into a remainder that fits into |
| 289 // 6 bits and a part that does not. The latter is encoded as a long record | 287 // 6 bits and a part that does not. The latter is encoded as a long record |
| 290 // with PC_JUMP as pseudo reloc info mode. The former is encoded as part of | 288 // with PC_JUMP as pseudo reloc info mode. The former is encoded as part of |
| 291 // the following record in the usual way. The long pc jump record has variable | 289 // the following record in the usual way. The long pc jump record has variable |
| 292 // length: | 290 // length: |
| 293 // pc-jump: [PC_JUMP] 11 | 291 // pc-jump: [PC_JUMP] 11 |
| 294 // [7 bits data] 0 | 292 // [7 bits data] 0 |
| 295 // ... | 293 // ... |
| 296 // [7 bits data] 1 | 294 // [7 bits data] 1 |
| 297 // (Bits 6..31 of pc delta, with leading zeroes | 295 // (Bits 6..31 of pc delta, with leading zeroes |
| 298 // dropped, and last non-zero chunk tagged with 1.) | 296 // dropped, and last non-zero chunk tagged with 1.) |
| 299 | 297 |
| 300 const int kTagBits = 2; | 298 const int kTagBits = 2; |
| 301 const int kTagMask = (1 << kTagBits) - 1; | 299 const int kTagMask = (1 << kTagBits) - 1; |
| 302 const int kLongTagBits = 6; | 300 const int kLongTagBits = 6; |
| 303 const int kShortDataTypeTagBits = 2; | 301 const int kShortDataTypeTagBits = 1; |
| 304 const int kShortDataBits = kBitsPerByte - kShortDataTypeTagBits; | 302 const int kShortDataBits = kBitsPerByte - kShortDataTypeTagBits; |
| 305 | 303 |
| 306 const int kEmbeddedObjectTag = 0; | 304 const int kEmbeddedObjectTag = 0; |
| 307 const int kCodeTargetTag = 1; | 305 const int kCodeTargetTag = 1; |
| 308 const int kLocatableTag = 2; | 306 const int kLocatableTag = 2; |
| 309 const int kDefaultTag = 3; | 307 const int kDefaultTag = 3; |
| 310 | 308 |
| 311 const int kSmallPCDeltaBits = kBitsPerByte - kTagBits; | 309 const int kSmallPCDeltaBits = kBitsPerByte - kTagBits; |
| 312 const int kSmallPCDeltaMask = (1 << kSmallPCDeltaBits) - 1; | 310 const int kSmallPCDeltaMask = (1 << kSmallPCDeltaBits) - 1; |
| 313 const int RelocInfo::kMaxSmallPCDelta = kSmallPCDeltaMask; | 311 const int RelocInfo::kMaxSmallPCDelta = kSmallPCDeltaMask; |
| 314 | 312 |
| 315 const int kChunkBits = 7; | 313 const int kChunkBits = 7; |
| 316 const int kChunkMask = (1 << kChunkBits) - 1; | 314 const int kChunkMask = (1 << kChunkBits) - 1; |
| 317 const int kLastChunkTagBits = 1; | 315 const int kLastChunkTagBits = 1; |
| 318 const int kLastChunkTagMask = 1; | 316 const int kLastChunkTagMask = 1; |
| 319 const int kLastChunkTag = 1; | 317 const int kLastChunkTag = 1; |
| 320 | 318 |
| 321 const int kCodeWithIdTag = 0; | 319 const int kCodeWithIdTag = 0; |
| 322 const int kNonstatementPositionTag = 1; | 320 const int kDeoptReasonTag = 1; |
| 323 const int kStatementPositionTag = 2; | |
| 324 const int kDeoptReasonTag = 3; | |
| 325 | 321 |
| 326 void RelocInfo::update_wasm_memory_reference( | 322 void RelocInfo::update_wasm_memory_reference( |
| 327 Address old_base, Address new_base, uint32_t old_size, uint32_t new_size, | 323 Address old_base, Address new_base, uint32_t old_size, uint32_t new_size, |
| 328 ICacheFlushMode icache_flush_mode) { | 324 ICacheFlushMode icache_flush_mode) { |
| 329 DCHECK(IsWasmMemoryReference(rmode_) || IsWasmMemorySizeReference(rmode_)); | 325 DCHECK(IsWasmMemoryReference(rmode_) || IsWasmMemorySizeReference(rmode_)); |
| 330 if (IsWasmMemoryReference(rmode_)) { | 326 if (IsWasmMemoryReference(rmode_)) { |
| 331 Address updated_reference; | 327 Address updated_reference; |
| 332 DCHECK(old_size == 0 || Memory::IsAddressInRange( | 328 DCHECK(old_size == 0 || Memory::IsAddressInRange( |
| 333 old_base, wasm_memory_reference(), old_size)); | 329 old_base, wasm_memory_reference(), old_size)); |
| 334 updated_reference = new_base + (wasm_memory_reference() - old_base); | 330 updated_reference = new_base + (wasm_memory_reference() - old_base); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 | 420 |
| 425 void RelocInfoWriter::WriteData(intptr_t data_delta) { | 421 void RelocInfoWriter::WriteData(intptr_t data_delta) { |
| 426 for (int i = 0; i < kIntptrSize; i++) { | 422 for (int i = 0; i < kIntptrSize; i++) { |
| 427 *--pos_ = static_cast<byte>(data_delta); | 423 *--pos_ = static_cast<byte>(data_delta); |
| 428 // Signed right shift is arithmetic shift. Tested in test-utils.cc. | 424 // Signed right shift is arithmetic shift. Tested in test-utils.cc. |
| 429 data_delta = data_delta >> kBitsPerByte; | 425 data_delta = data_delta >> kBitsPerByte; |
| 430 } | 426 } |
| 431 } | 427 } |
| 432 | 428 |
| 433 | 429 |
| 434 void RelocInfoWriter::WritePosition(int pc_delta, int pos_delta, | |
| 435 RelocInfo::Mode rmode) { | |
| 436 int pos_type_tag = (rmode == RelocInfo::POSITION) ? kNonstatementPositionTag | |
| 437 : kStatementPositionTag; | |
| 438 // Check if delta is small enough to fit in a tagged byte. | |
| 439 if (is_intn(pos_delta, kShortDataBits)) { | |
| 440 WriteShortTaggedPC(pc_delta, kLocatableTag); | |
| 441 WriteShortTaggedData(pos_delta, pos_type_tag); | |
| 442 } else { | |
| 443 // Otherwise, use costly encoding. | |
| 444 WriteModeAndPC(pc_delta, rmode); | |
| 445 WriteIntData(pos_delta); | |
| 446 } | |
| 447 } | |
| 448 | |
| 449 | |
| 450 void RelocInfoWriter::FlushPosition() { | |
| 451 if (!next_position_candidate_flushed_) { | |
| 452 WritePosition(next_position_candidate_pc_delta_, | |
| 453 next_position_candidate_pos_delta_, RelocInfo::POSITION); | |
| 454 next_position_candidate_pos_delta_ = 0; | |
| 455 next_position_candidate_pc_delta_ = 0; | |
| 456 next_position_candidate_flushed_ = true; | |
| 457 } | |
| 458 } | |
| 459 | |
| 460 | |
| 461 void RelocInfoWriter::Write(const RelocInfo* rinfo) { | 430 void RelocInfoWriter::Write(const RelocInfo* rinfo) { |
| 462 RelocInfo::Mode rmode = rinfo->rmode(); | 431 RelocInfo::Mode rmode = rinfo->rmode(); |
| 463 if (rmode != RelocInfo::POSITION) { | |
| 464 FlushPosition(); | |
| 465 } | |
| 466 #ifdef DEBUG | 432 #ifdef DEBUG |
| 467 byte* begin_pos = pos_; | 433 byte* begin_pos = pos_; |
| 468 #endif | 434 #endif |
| 469 DCHECK(rinfo->rmode() < RelocInfo::NUMBER_OF_MODES); | 435 DCHECK(rinfo->rmode() < RelocInfo::NUMBER_OF_MODES); |
| 470 DCHECK(rinfo->pc() - last_pc_ >= 0); | 436 DCHECK(rinfo->pc() - last_pc_ >= 0); |
| 471 // Use unsigned delta-encoding for pc. | 437 // Use unsigned delta-encoding for pc. |
| 472 uint32_t pc_delta = static_cast<uint32_t>(rinfo->pc() - last_pc_); | 438 uint32_t pc_delta = static_cast<uint32_t>(rinfo->pc() - last_pc_); |
| 473 | 439 |
| 474 // The two most common modes are given small tags, and usually fit in a byte. | 440 // The two most common modes are given small tags, and usually fit in a byte. |
| 475 if (rmode == RelocInfo::EMBEDDED_OBJECT) { | 441 if (rmode == RelocInfo::EMBEDDED_OBJECT) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 488 } else { | 454 } else { |
| 489 // Otherwise, use costly encoding. | 455 // Otherwise, use costly encoding. |
| 490 WriteModeAndPC(pc_delta, rmode); | 456 WriteModeAndPC(pc_delta, rmode); |
| 491 WriteIntData(id_delta); | 457 WriteIntData(id_delta); |
| 492 } | 458 } |
| 493 last_id_ = static_cast<int>(rinfo->data()); | 459 last_id_ = static_cast<int>(rinfo->data()); |
| 494 } else if (rmode == RelocInfo::DEOPT_REASON) { | 460 } else if (rmode == RelocInfo::DEOPT_REASON) { |
| 495 DCHECK(rinfo->data() < (1 << kShortDataBits)); | 461 DCHECK(rinfo->data() < (1 << kShortDataBits)); |
| 496 WriteShortTaggedPC(pc_delta, kLocatableTag); | 462 WriteShortTaggedPC(pc_delta, kLocatableTag); |
| 497 WriteShortTaggedData(rinfo->data(), kDeoptReasonTag); | 463 WriteShortTaggedData(rinfo->data(), kDeoptReasonTag); |
| 498 } else if (RelocInfo::IsPosition(rmode)) { | |
| 499 // Use signed delta-encoding for position. | |
| 500 DCHECK_EQ(static_cast<int>(rinfo->data()), rinfo->data()); | |
| 501 int pos_delta = static_cast<int>(rinfo->data()) - last_position_; | |
| 502 if (rmode == RelocInfo::STATEMENT_POSITION) { | |
| 503 WritePosition(pc_delta, pos_delta, rmode); | |
| 504 } else { | |
| 505 DCHECK_EQ(rmode, RelocInfo::POSITION); | |
| 506 if (pc_delta != 0 || last_mode_ != RelocInfo::POSITION) { | |
| 507 FlushPosition(); | |
| 508 next_position_candidate_pc_delta_ = pc_delta; | |
| 509 next_position_candidate_pos_delta_ = pos_delta; | |
| 510 } else { | |
| 511 next_position_candidate_pos_delta_ += pos_delta; | |
| 512 } | |
| 513 next_position_candidate_flushed_ = false; | |
| 514 } | |
| 515 last_position_ = static_cast<int>(rinfo->data()); | |
| 516 } else { | 464 } else { |
| 517 WriteModeAndPC(pc_delta, rmode); | 465 WriteModeAndPC(pc_delta, rmode); |
| 518 if (RelocInfo::IsComment(rmode)) { | 466 if (RelocInfo::IsComment(rmode)) { |
| 519 WriteData(rinfo->data()); | 467 WriteData(rinfo->data()); |
| 520 } else if (RelocInfo::IsConstPool(rmode) || | 468 } else if (RelocInfo::IsConstPool(rmode) || |
| 521 RelocInfo::IsVeneerPool(rmode) || | 469 RelocInfo::IsVeneerPool(rmode) || RelocInfo::IsDeoptId(rmode) || |
| 522 RelocInfo::IsDeoptId(rmode)) { | 470 RelocInfo::IsDeoptPosition(rmode)) { |
| 523 WriteIntData(static_cast<int>(rinfo->data())); | 471 WriteIntData(static_cast<int>(rinfo->data())); |
| 524 } | 472 } |
| 525 } | 473 } |
| 526 last_pc_ = rinfo->pc(); | 474 last_pc_ = rinfo->pc(); |
| 527 last_mode_ = rmode; | 475 last_mode_ = rmode; |
| 528 #ifdef DEBUG | 476 #ifdef DEBUG |
| 529 DCHECK(begin_pos - pos_ <= kMaxSize); | 477 DCHECK(begin_pos - pos_ <= kMaxSize); |
| 530 #endif | 478 #endif |
| 531 } | 479 } |
| 532 | 480 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 | 512 |
| 565 void RelocIterator::AdvanceReadInt() { | 513 void RelocIterator::AdvanceReadInt() { |
| 566 int x = 0; | 514 int x = 0; |
| 567 for (int i = 0; i < kIntSize; i++) { | 515 for (int i = 0; i < kIntSize; i++) { |
| 568 x |= static_cast<int>(*--pos_) << i * kBitsPerByte; | 516 x |= static_cast<int>(*--pos_) << i * kBitsPerByte; |
| 569 } | 517 } |
| 570 rinfo_.data_ = x; | 518 rinfo_.data_ = x; |
| 571 } | 519 } |
| 572 | 520 |
| 573 | 521 |
| 574 void RelocIterator::AdvanceReadPosition() { | |
| 575 int x = 0; | |
| 576 for (int i = 0; i < kIntSize; i++) { | |
| 577 x |= static_cast<int>(*--pos_) << i * kBitsPerByte; | |
| 578 } | |
| 579 last_position_ += x; | |
| 580 rinfo_.data_ = last_position_; | |
| 581 } | |
| 582 | |
| 583 | |
| 584 void RelocIterator::AdvanceReadData() { | 522 void RelocIterator::AdvanceReadData() { |
| 585 intptr_t x = 0; | 523 intptr_t x = 0; |
| 586 for (int i = 0; i < kIntptrSize; i++) { | 524 for (int i = 0; i < kIntptrSize; i++) { |
| 587 x |= static_cast<intptr_t>(*--pos_) << i * kBitsPerByte; | 525 x |= static_cast<intptr_t>(*--pos_) << i * kBitsPerByte; |
| 588 } | 526 } |
| 589 rinfo_.data_ = x; | 527 rinfo_.data_ = x; |
| 590 } | 528 } |
| 591 | 529 |
| 592 | 530 |
| 593 void RelocIterator::AdvanceReadLongPCJump() { | 531 void RelocIterator::AdvanceReadLongPCJump() { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 612 | 550 |
| 613 | 551 |
| 614 inline void RelocIterator::ReadShortTaggedId() { | 552 inline void RelocIterator::ReadShortTaggedId() { |
| 615 int8_t signed_b = *pos_; | 553 int8_t signed_b = *pos_; |
| 616 // Signed right shift is arithmetic shift. Tested in test-utils.cc. | 554 // Signed right shift is arithmetic shift. Tested in test-utils.cc. |
| 617 last_id_ += signed_b >> kShortDataTypeTagBits; | 555 last_id_ += signed_b >> kShortDataTypeTagBits; |
| 618 rinfo_.data_ = last_id_; | 556 rinfo_.data_ = last_id_; |
| 619 } | 557 } |
| 620 | 558 |
| 621 | 559 |
| 622 inline void RelocIterator::ReadShortTaggedPosition() { | |
| 623 int8_t signed_b = *pos_; | |
| 624 // Signed right shift is arithmetic shift. Tested in test-utils.cc. | |
| 625 last_position_ += signed_b >> kShortDataTypeTagBits; | |
| 626 rinfo_.data_ = last_position_; | |
| 627 } | |
| 628 | |
| 629 | |
| 630 inline void RelocIterator::ReadShortTaggedData() { | 560 inline void RelocIterator::ReadShortTaggedData() { |
| 631 uint8_t unsigned_b = *pos_; | 561 uint8_t unsigned_b = *pos_; |
| 632 rinfo_.data_ = unsigned_b >> kTagBits; | 562 rinfo_.data_ = unsigned_b >> kShortDataTypeTagBits; |
| 633 } | 563 } |
| 634 | 564 |
| 635 | 565 |
| 636 static inline RelocInfo::Mode GetPositionModeFromTag(int tag) { | |
| 637 DCHECK(tag == kNonstatementPositionTag || | |
| 638 tag == kStatementPositionTag); | |
| 639 return (tag == kNonstatementPositionTag) ? | |
| 640 RelocInfo::POSITION : | |
| 641 RelocInfo::STATEMENT_POSITION; | |
| 642 } | |
| 643 | |
| 644 | |
| 645 void RelocIterator::next() { | 566 void RelocIterator::next() { |
| 646 DCHECK(!done()); | 567 DCHECK(!done()); |
| 647 // Basically, do the opposite of RelocInfoWriter::Write. | 568 // Basically, do the opposite of RelocInfoWriter::Write. |
| 648 // Reading of data is as far as possible avoided for unwanted modes, | 569 // Reading of data is as far as possible avoided for unwanted modes, |
| 649 // but we must always update the pc. | 570 // but we must always update the pc. |
| 650 // | 571 // |
| 651 // We exit this loop by returning when we find a mode we want. | 572 // We exit this loop by returning when we find a mode we want. |
| 652 while (pos_ > end_) { | 573 while (pos_ > end_) { |
| 653 int tag = AdvanceGetTag(); | 574 int tag = AdvanceGetTag(); |
| 654 if (tag == kEmbeddedObjectTag) { | 575 if (tag == kEmbeddedObjectTag) { |
| 655 ReadShortTaggedPC(); | 576 ReadShortTaggedPC(); |
| 656 if (SetMode(RelocInfo::EMBEDDED_OBJECT)) return; | 577 if (SetMode(RelocInfo::EMBEDDED_OBJECT)) return; |
| 657 } else if (tag == kCodeTargetTag) { | 578 } else if (tag == kCodeTargetTag) { |
| 658 ReadShortTaggedPC(); | 579 ReadShortTaggedPC(); |
| 659 if (SetMode(RelocInfo::CODE_TARGET)) return; | 580 if (SetMode(RelocInfo::CODE_TARGET)) return; |
| 660 } else if (tag == kLocatableTag) { | 581 } else if (tag == kLocatableTag) { |
| 661 ReadShortTaggedPC(); | 582 ReadShortTaggedPC(); |
| 662 Advance(); | 583 Advance(); |
| 663 int data_type_tag = GetShortDataTypeTag(); | 584 int data_type_tag = GetShortDataTypeTag(); |
| 664 if (data_type_tag == kCodeWithIdTag) { | 585 if (data_type_tag == kCodeWithIdTag) { |
| 665 if (SetMode(RelocInfo::CODE_TARGET_WITH_ID)) { | 586 if (SetMode(RelocInfo::CODE_TARGET_WITH_ID)) { |
| 666 ReadShortTaggedId(); | 587 ReadShortTaggedId(); |
| 667 return; | 588 return; |
| 668 } | 589 } |
| 669 } else if (data_type_tag == kDeoptReasonTag) { | 590 } else { |
| 591 DCHECK(data_type_tag == kDeoptReasonTag); |
| 670 if (SetMode(RelocInfo::DEOPT_REASON)) { | 592 if (SetMode(RelocInfo::DEOPT_REASON)) { |
| 671 ReadShortTaggedData(); | 593 ReadShortTaggedData(); |
| 672 return; | 594 return; |
| 673 } | 595 } |
| 674 } else { | |
| 675 DCHECK(data_type_tag == kNonstatementPositionTag || | |
| 676 data_type_tag == kStatementPositionTag); | |
| 677 if (mode_mask_ & RelocInfo::kPositionMask) { | |
| 678 // Always update the position if we are interested in either | |
| 679 // statement positions or non-statement positions. | |
| 680 ReadShortTaggedPosition(); | |
| 681 if (SetMode(GetPositionModeFromTag(data_type_tag))) return; | |
| 682 } | |
| 683 } | 596 } |
| 684 } else { | 597 } else { |
| 685 DCHECK(tag == kDefaultTag); | 598 DCHECK(tag == kDefaultTag); |
| 686 RelocInfo::Mode rmode = GetMode(); | 599 RelocInfo::Mode rmode = GetMode(); |
| 687 if (rmode == RelocInfo::PC_JUMP) { | 600 if (rmode == RelocInfo::PC_JUMP) { |
| 688 AdvanceReadLongPCJump(); | 601 AdvanceReadLongPCJump(); |
| 689 } else { | 602 } else { |
| 690 AdvanceReadPC(); | 603 AdvanceReadPC(); |
| 691 if (rmode == RelocInfo::CODE_TARGET_WITH_ID) { | 604 if (rmode == RelocInfo::CODE_TARGET_WITH_ID) { |
| 692 if (SetMode(rmode)) { | 605 if (SetMode(rmode)) { |
| 693 AdvanceReadId(); | 606 AdvanceReadId(); |
| 694 return; | 607 return; |
| 695 } | 608 } |
| 696 Advance(kIntSize); | 609 Advance(kIntSize); |
| 697 } else if (RelocInfo::IsComment(rmode)) { | 610 } else if (RelocInfo::IsComment(rmode)) { |
| 698 if (SetMode(rmode)) { | 611 if (SetMode(rmode)) { |
| 699 AdvanceReadData(); | 612 AdvanceReadData(); |
| 700 return; | 613 return; |
| 701 } | 614 } |
| 702 Advance(kIntptrSize); | 615 Advance(kIntptrSize); |
| 703 } else if (RelocInfo::IsPosition(rmode)) { | |
| 704 if (mode_mask_ & RelocInfo::kPositionMask) { | |
| 705 // Always update the position if we are interested in either | |
| 706 // statement positions or non-statement positions. | |
| 707 AdvanceReadPosition(); | |
| 708 if (SetMode(rmode)) return; | |
| 709 } else { | |
| 710 Advance(kIntSize); | |
| 711 } | |
| 712 } else if (RelocInfo::IsConstPool(rmode) || | 616 } else if (RelocInfo::IsConstPool(rmode) || |
| 713 RelocInfo::IsVeneerPool(rmode) || | 617 RelocInfo::IsVeneerPool(rmode) || |
| 714 RelocInfo::IsDeoptId(rmode)) { | 618 RelocInfo::IsDeoptId(rmode) || |
| 619 RelocInfo::IsDeoptPosition(rmode)) { |
| 715 if (SetMode(rmode)) { | 620 if (SetMode(rmode)) { |
| 716 AdvanceReadInt(); | 621 AdvanceReadInt(); |
| 717 return; | 622 return; |
| 718 } | 623 } |
| 719 Advance(kIntSize); | 624 Advance(kIntSize); |
| 720 } else if (SetMode(static_cast<RelocInfo::Mode>(rmode))) { | 625 } else if (SetMode(static_cast<RelocInfo::Mode>(rmode))) { |
| 721 return; | 626 return; |
| 722 } | 627 } |
| 723 } | 628 } |
| 724 } | 629 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 740 : rinfo_(code->map()->GetIsolate()) { | 645 : rinfo_(code->map()->GetIsolate()) { |
| 741 rinfo_.host_ = code; | 646 rinfo_.host_ = code; |
| 742 rinfo_.pc_ = code->instruction_start(); | 647 rinfo_.pc_ = code->instruction_start(); |
| 743 rinfo_.data_ = 0; | 648 rinfo_.data_ = 0; |
| 744 // Relocation info is read backwards. | 649 // Relocation info is read backwards. |
| 745 pos_ = code->relocation_start() + code->relocation_size(); | 650 pos_ = code->relocation_start() + code->relocation_size(); |
| 746 end_ = code->relocation_start(); | 651 end_ = code->relocation_start(); |
| 747 done_ = false; | 652 done_ = false; |
| 748 mode_mask_ = mode_mask; | 653 mode_mask_ = mode_mask; |
| 749 last_id_ = 0; | 654 last_id_ = 0; |
| 750 last_position_ = 0; | |
| 751 byte* sequence = code->FindCodeAgeSequence(); | 655 byte* sequence = code->FindCodeAgeSequence(); |
| 752 // We get the isolate from the map, because at serialization time | 656 // We get the isolate from the map, because at serialization time |
| 753 // the code pointer has been cloned and isn't really in heap space. | 657 // the code pointer has been cloned and isn't really in heap space. |
| 754 Isolate* isolate = code->map()->GetIsolate(); | 658 Isolate* isolate = code->map()->GetIsolate(); |
| 755 if (sequence != NULL && !Code::IsYoungSequence(isolate, sequence)) { | 659 if (sequence != NULL && !Code::IsYoungSequence(isolate, sequence)) { |
| 756 code_age_sequence_ = sequence; | 660 code_age_sequence_ = sequence; |
| 757 } else { | 661 } else { |
| 758 code_age_sequence_ = NULL; | 662 code_age_sequence_ = NULL; |
| 759 } | 663 } |
| 760 if (mode_mask_ == 0) pos_ = end_; | 664 if (mode_mask_ == 0) pos_ = end_; |
| 761 next(); | 665 next(); |
| 762 } | 666 } |
| 763 | 667 |
| 764 | 668 |
| 765 RelocIterator::RelocIterator(const CodeDesc& desc, int mode_mask) | 669 RelocIterator::RelocIterator(const CodeDesc& desc, int mode_mask) |
| 766 : rinfo_(desc.origin->isolate()) { | 670 : rinfo_(desc.origin->isolate()) { |
| 767 rinfo_.pc_ = desc.buffer; | 671 rinfo_.pc_ = desc.buffer; |
| 768 rinfo_.data_ = 0; | 672 rinfo_.data_ = 0; |
| 769 // Relocation info is read backwards. | 673 // Relocation info is read backwards. |
| 770 pos_ = desc.buffer + desc.buffer_size; | 674 pos_ = desc.buffer + desc.buffer_size; |
| 771 end_ = pos_ - desc.reloc_size; | 675 end_ = pos_ - desc.reloc_size; |
| 772 done_ = false; | 676 done_ = false; |
| 773 mode_mask_ = mode_mask; | 677 mode_mask_ = mode_mask; |
| 774 last_id_ = 0; | 678 last_id_ = 0; |
| 775 last_position_ = 0; | |
| 776 code_age_sequence_ = NULL; | 679 code_age_sequence_ = NULL; |
| 777 if (mode_mask_ == 0) pos_ = end_; | 680 if (mode_mask_ == 0) pos_ = end_; |
| 778 next(); | 681 next(); |
| 779 } | 682 } |
| 780 | 683 |
| 781 | 684 |
| 782 // ----------------------------------------------------------------------------- | 685 // ----------------------------------------------------------------------------- |
| 783 // Implementation of RelocInfo | 686 // Implementation of RelocInfo |
| 784 | 687 |
| 785 bool RelocInfo::IsPatchedDebugBreakSlotSequence() { | 688 bool RelocInfo::IsPatchedDebugBreakSlotSequence() { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 815 case CODE_TARGET: | 718 case CODE_TARGET: |
| 816 return "code target"; | 719 return "code target"; |
| 817 case CODE_TARGET_WITH_ID: | 720 case CODE_TARGET_WITH_ID: |
| 818 return "code target with id"; | 721 return "code target with id"; |
| 819 case CELL: | 722 case CELL: |
| 820 return "property cell"; | 723 return "property cell"; |
| 821 case RUNTIME_ENTRY: | 724 case RUNTIME_ENTRY: |
| 822 return "runtime entry"; | 725 return "runtime entry"; |
| 823 case COMMENT: | 726 case COMMENT: |
| 824 return "comment"; | 727 return "comment"; |
| 825 case POSITION: | |
| 826 return "position"; | |
| 827 case STATEMENT_POSITION: | |
| 828 return "statement position"; | |
| 829 case EXTERNAL_REFERENCE: | 728 case EXTERNAL_REFERENCE: |
| 830 return "external reference"; | 729 return "external reference"; |
| 831 case INTERNAL_REFERENCE: | 730 case INTERNAL_REFERENCE: |
| 832 return "internal reference"; | 731 return "internal reference"; |
| 833 case INTERNAL_REFERENCE_ENCODED: | 732 case INTERNAL_REFERENCE_ENCODED: |
| 834 return "encoded internal reference"; | 733 return "encoded internal reference"; |
| 734 case DEOPT_POSITION: |
| 735 return "deopt position"; |
| 835 case DEOPT_REASON: | 736 case DEOPT_REASON: |
| 836 return "deopt reason"; | 737 return "deopt reason"; |
| 837 case DEOPT_ID: | 738 case DEOPT_ID: |
| 838 return "deopt index"; | 739 return "deopt index"; |
| 839 case CONST_POOL: | 740 case CONST_POOL: |
| 840 return "constant pool"; | 741 return "constant pool"; |
| 841 case VENEER_POOL: | 742 case VENEER_POOL: |
| 842 return "veneer pool"; | 743 return "veneer pool"; |
| 843 case DEBUG_BREAK_SLOT_AT_POSITION: | 744 case DEBUG_BREAK_SLOT_AT_POSITION: |
| 844 return "debug break slot at position"; | 745 return "debug break slot at position"; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 864 return "number_of_modes"; | 765 return "number_of_modes"; |
| 865 } | 766 } |
| 866 return "unknown relocation type"; | 767 return "unknown relocation type"; |
| 867 } | 768 } |
| 868 | 769 |
| 869 | 770 |
| 870 void RelocInfo::Print(Isolate* isolate, std::ostream& os) { // NOLINT | 771 void RelocInfo::Print(Isolate* isolate, std::ostream& os) { // NOLINT |
| 871 os << static_cast<const void*>(pc_) << " " << RelocModeName(rmode_); | 772 os << static_cast<const void*>(pc_) << " " << RelocModeName(rmode_); |
| 872 if (IsComment(rmode_)) { | 773 if (IsComment(rmode_)) { |
| 873 os << " (" << reinterpret_cast<char*>(data_) << ")"; | 774 os << " (" << reinterpret_cast<char*>(data_) << ")"; |
| 775 } else if (rmode_ == DEOPT_POSITION) { |
| 776 os << " (" << data() << ")"; |
| 874 } else if (rmode_ == DEOPT_REASON) { | 777 } else if (rmode_ == DEOPT_REASON) { |
| 875 os << " (" << Deoptimizer::GetDeoptReason( | 778 os << " (" << Deoptimizer::GetDeoptReason( |
| 876 static_cast<Deoptimizer::DeoptReason>(data_)) << ")"; | 779 static_cast<Deoptimizer::DeoptReason>(data_)) << ")"; |
| 877 } else if (rmode_ == EMBEDDED_OBJECT) { | 780 } else if (rmode_ == EMBEDDED_OBJECT) { |
| 878 os << " (" << Brief(target_object()) << ")"; | 781 os << " (" << Brief(target_object()) << ")"; |
| 879 } else if (rmode_ == EXTERNAL_REFERENCE) { | 782 } else if (rmode_ == EXTERNAL_REFERENCE) { |
| 880 ExternalReferenceEncoder ref_encoder(isolate); | 783 ExternalReferenceEncoder ref_encoder(isolate); |
| 881 os << " (" | 784 os << " (" |
| 882 << ref_encoder.NameOfAddress(isolate, target_external_reference()) | 785 << ref_encoder.NameOfAddress(isolate, target_external_reference()) |
| 883 << ") (" << static_cast<const void*>(target_external_reference()) | 786 << ") (" << static_cast<const void*>(target_external_reference()) |
| 884 << ")"; | 787 << ")"; |
| 885 } else if (IsCodeTarget(rmode_)) { | 788 } else if (IsCodeTarget(rmode_)) { |
| 886 Code* code = Code::GetCodeFromTargetAddress(target_address()); | 789 Code* code = Code::GetCodeFromTargetAddress(target_address()); |
| 887 os << " (" << Code::Kind2String(code->kind()) << ") (" | 790 os << " (" << Code::Kind2String(code->kind()) << ") (" |
| 888 << static_cast<const void*>(target_address()) << ")"; | 791 << static_cast<const void*>(target_address()) << ")"; |
| 889 if (rmode_ == CODE_TARGET_WITH_ID) { | 792 if (rmode_ == CODE_TARGET_WITH_ID) { |
| 890 os << " (id=" << static_cast<int>(data_) << ")"; | 793 os << " (id=" << static_cast<int>(data_) << ")"; |
| 891 } | 794 } |
| 892 } else if (IsPosition(rmode_)) { | |
| 893 os << " (" << data() << ")"; | |
| 894 } else if (IsRuntimeEntry(rmode_) && | 795 } else if (IsRuntimeEntry(rmode_) && |
| 895 isolate->deoptimizer_data() != NULL) { | 796 isolate->deoptimizer_data() != NULL) { |
| 896 // Depotimization bailouts are stored as runtime entries. | 797 // Depotimization bailouts are stored as runtime entries. |
| 897 int id = Deoptimizer::GetDeoptimizationId( | 798 int id = Deoptimizer::GetDeoptimizationId( |
| 898 isolate, target_address(), Deoptimizer::EAGER); | 799 isolate, target_address(), Deoptimizer::EAGER); |
| 899 if (id != Deoptimizer::kNotDeoptimizationEntry) { | 800 if (id != Deoptimizer::kNotDeoptimizationEntry) { |
| 900 os << " (deoptimization bailout " << id << ")"; | 801 os << " (deoptimization bailout " << id << ")"; |
| 901 } | 802 } |
| 902 } else if (IsConstPool(rmode_)) { | 803 } else if (IsConstPool(rmode_)) { |
| 903 os << " (size " << static_cast<int>(data_) << ")"; | 804 os << " (size " << static_cast<int>(data_) << ")"; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 934 case INTERNAL_REFERENCE_ENCODED: { | 835 case INTERNAL_REFERENCE_ENCODED: { |
| 935 Address target = target_internal_reference(); | 836 Address target = target_internal_reference(); |
| 936 Address pc = target_internal_reference_address(); | 837 Address pc = target_internal_reference_address(); |
| 937 Code* code = Code::cast(isolate->FindCodeObject(pc)); | 838 Code* code = Code::cast(isolate->FindCodeObject(pc)); |
| 938 CHECK(target >= code->instruction_start()); | 839 CHECK(target >= code->instruction_start()); |
| 939 CHECK(target <= code->instruction_end()); | 840 CHECK(target <= code->instruction_end()); |
| 940 break; | 841 break; |
| 941 } | 842 } |
| 942 case RUNTIME_ENTRY: | 843 case RUNTIME_ENTRY: |
| 943 case COMMENT: | 844 case COMMENT: |
| 944 case POSITION: | |
| 945 case STATEMENT_POSITION: | |
| 946 case EXTERNAL_REFERENCE: | 845 case EXTERNAL_REFERENCE: |
| 846 case DEOPT_POSITION: |
| 947 case DEOPT_REASON: | 847 case DEOPT_REASON: |
| 948 case DEOPT_ID: | 848 case DEOPT_ID: |
| 949 case CONST_POOL: | 849 case CONST_POOL: |
| 950 case VENEER_POOL: | 850 case VENEER_POOL: |
| 951 case DEBUG_BREAK_SLOT_AT_POSITION: | 851 case DEBUG_BREAK_SLOT_AT_POSITION: |
| 952 case DEBUG_BREAK_SLOT_AT_RETURN: | 852 case DEBUG_BREAK_SLOT_AT_RETURN: |
| 953 case DEBUG_BREAK_SLOT_AT_CALL: | 853 case DEBUG_BREAK_SLOT_AT_CALL: |
| 954 case DEBUG_BREAK_SLOT_AT_TAIL_CALL: | 854 case DEBUG_BREAK_SLOT_AT_TAIL_CALL: |
| 955 case GENERATOR_CONTINUATION: | 855 case GENERATOR_CONTINUATION: |
| 956 case WASM_MEMORY_REFERENCE: | 856 case WASM_MEMORY_REFERENCE: |
| (...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1726 } | 1626 } |
| 1727 | 1627 |
| 1728 | 1628 |
| 1729 std::ostream& operator<<(std::ostream& os, ExternalReference reference) { | 1629 std::ostream& operator<<(std::ostream& os, ExternalReference reference) { |
| 1730 os << static_cast<const void*>(reference.address()); | 1630 os << static_cast<const void*>(reference.address()); |
| 1731 const Runtime::Function* fn = Runtime::FunctionForEntry(reference.address()); | 1631 const Runtime::Function* fn = Runtime::FunctionForEntry(reference.address()); |
| 1732 if (fn) os << "<" << fn->name << ".entry>"; | 1632 if (fn) os << "<" << fn->name << ".entry>"; |
| 1733 return os; | 1633 return os; |
| 1734 } | 1634 } |
| 1735 | 1635 |
| 1736 void AssemblerPositionsRecorder::RecordPosition(int pos) { | |
| 1737 DCHECK(pos != RelocInfo::kNoPosition); | |
| 1738 DCHECK(pos >= 0); | |
| 1739 current_position_ = pos; | |
| 1740 LOG_CODE_EVENT(assembler_->isolate(), | |
| 1741 CodeLinePosInfoAddPositionEvent(jit_handler_data_, | |
| 1742 assembler_->pc_offset(), | |
| 1743 pos)); | |
| 1744 WriteRecordedPositions(); | |
| 1745 } | |
| 1746 | |
| 1747 void AssemblerPositionsRecorder::RecordStatementPosition(int pos) { | |
| 1748 DCHECK(pos != RelocInfo::kNoPosition); | |
| 1749 DCHECK(pos >= 0); | |
| 1750 current_statement_position_ = pos; | |
| 1751 LOG_CODE_EVENT(assembler_->isolate(), | |
| 1752 CodeLinePosInfoAddStatementPositionEvent( | |
| 1753 jit_handler_data_, | |
| 1754 assembler_->pc_offset(), | |
| 1755 pos)); | |
| 1756 RecordPosition(pos); | |
| 1757 } | |
| 1758 | |
| 1759 void AssemblerPositionsRecorder::WriteRecordedPositions() { | |
| 1760 // Write the statement position if it is different from what was written last | |
| 1761 // time. | |
| 1762 if (current_statement_position_ != written_statement_position_) { | |
| 1763 EnsureSpace ensure_space(assembler_); | |
| 1764 assembler_->RecordRelocInfo(RelocInfo::STATEMENT_POSITION, | |
| 1765 current_statement_position_); | |
| 1766 written_position_ = current_statement_position_; | |
| 1767 written_statement_position_ = current_statement_position_; | |
| 1768 } | |
| 1769 | |
| 1770 // Write the position if it is different from what was written last time and | |
| 1771 // also different from the statement position that was just written. | |
| 1772 if (current_position_ != written_position_) { | |
| 1773 EnsureSpace ensure_space(assembler_); | |
| 1774 assembler_->RecordRelocInfo(RelocInfo::POSITION, current_position_); | |
| 1775 written_position_ = current_position_; | |
| 1776 } | |
| 1777 } | |
| 1778 | |
| 1779 | 1636 |
| 1780 ConstantPoolBuilder::ConstantPoolBuilder(int ptr_reach_bits, | 1637 ConstantPoolBuilder::ConstantPoolBuilder(int ptr_reach_bits, |
| 1781 int double_reach_bits) { | 1638 int double_reach_bits) { |
| 1782 info_[ConstantPoolEntry::INTPTR].entries.reserve(64); | 1639 info_[ConstantPoolEntry::INTPTR].entries.reserve(64); |
| 1783 info_[ConstantPoolEntry::INTPTR].regular_reach_bits = ptr_reach_bits; | 1640 info_[ConstantPoolEntry::INTPTR].regular_reach_bits = ptr_reach_bits; |
| 1784 info_[ConstantPoolEntry::DOUBLE].regular_reach_bits = double_reach_bits; | 1641 info_[ConstantPoolEntry::DOUBLE].regular_reach_bits = double_reach_bits; |
| 1785 } | 1642 } |
| 1786 | 1643 |
| 1787 | 1644 |
| 1788 ConstantPoolEntry::Access ConstantPoolBuilder::NextAccess( | 1645 ConstantPoolEntry::Access ConstantPoolBuilder::NextAccess( |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1977 | 1834 |
| 1978 return !empty ? emitted_label_.pos() : 0; | 1835 return !empty ? emitted_label_.pos() : 0; |
| 1979 } | 1836 } |
| 1980 | 1837 |
| 1981 | 1838 |
| 1982 // Platform specific but identical code for all the platforms. | 1839 // Platform specific but identical code for all the platforms. |
| 1983 | 1840 |
| 1984 void Assembler::RecordDeoptReason(const int reason, int raw_position, int id) { | 1841 void Assembler::RecordDeoptReason(const int reason, int raw_position, int id) { |
| 1985 if (FLAG_trace_deopt || isolate()->is_profiling()) { | 1842 if (FLAG_trace_deopt || isolate()->is_profiling()) { |
| 1986 EnsureSpace ensure_space(this); | 1843 EnsureSpace ensure_space(this); |
| 1987 RecordRelocInfo(RelocInfo::POSITION, raw_position); | 1844 RecordRelocInfo(RelocInfo::DEOPT_POSITION, raw_position); |
| 1988 RecordRelocInfo(RelocInfo::DEOPT_REASON, reason); | 1845 RecordRelocInfo(RelocInfo::DEOPT_REASON, reason); |
| 1989 RecordRelocInfo(RelocInfo::DEOPT_ID, id); | 1846 RecordRelocInfo(RelocInfo::DEOPT_ID, id); |
| 1990 } | 1847 } |
| 1991 } | 1848 } |
| 1992 | 1849 |
| 1993 | 1850 |
| 1994 void Assembler::RecordComment(const char* msg) { | 1851 void Assembler::RecordComment(const char* msg) { |
| 1995 if (FLAG_code_comments) { | 1852 if (FLAG_code_comments) { |
| 1996 EnsureSpace ensure_space(this); | 1853 EnsureSpace ensure_space(this); |
| 1997 RecordRelocInfo(RelocInfo::COMMENT, reinterpret_cast<intptr_t>(msg)); | 1854 RecordRelocInfo(RelocInfo::COMMENT, reinterpret_cast<intptr_t>(msg)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2013 | 1870 |
| 2014 | 1871 |
| 2015 void Assembler::DataAlign(int m) { | 1872 void Assembler::DataAlign(int m) { |
| 2016 DCHECK(m >= 2 && base::bits::IsPowerOfTwo32(m)); | 1873 DCHECK(m >= 2 && base::bits::IsPowerOfTwo32(m)); |
| 2017 while ((pc_offset() & (m - 1)) != 0) { | 1874 while ((pc_offset() & (m - 1)) != 0) { |
| 2018 db(0); | 1875 db(0); |
| 2019 } | 1876 } |
| 2020 } | 1877 } |
| 2021 } // namespace internal | 1878 } // namespace internal |
| 2022 } // namespace v8 | 1879 } // namespace v8 |
| OLD | NEW |