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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 void RelocInfoWriter::WriteExtraTaggedData(intptr_t data_delta, int top_tag) { | 408 void RelocInfoWriter::WriteExtraTaggedData(intptr_t data_delta, int top_tag) { |
409 WriteExtraTag(kDataJumpExtraTag, top_tag); | 409 WriteExtraTag(kDataJumpExtraTag, top_tag); |
410 for (int i = 0; i < kIntptrSize; i++) { | 410 for (int i = 0; i < kIntptrSize; i++) { |
411 *--pos_ = static_cast<byte>(data_delta); | 411 *--pos_ = static_cast<byte>(data_delta); |
412 // Signed right shift is arithmetic shift. Tested in test-utils.cc. | 412 // Signed right shift is arithmetic shift. Tested in test-utils.cc. |
413 data_delta = data_delta >> kBitsPerByte; | 413 data_delta = data_delta >> kBitsPerByte; |
414 } | 414 } |
415 } | 415 } |
416 | 416 |
417 | 417 |
| 418 void RelocInfoWriter::WritePosition(int pc_delta, int pos_delta, |
| 419 RelocInfo::Mode rmode) { |
| 420 int pos_type_tag = (rmode == RelocInfo::POSITION) ? kNonstatementPositionTag |
| 421 : kStatementPositionTag; |
| 422 // Check if delta is small enough to fit in a tagged byte. |
| 423 if (is_intn(pos_delta, kSmallDataBits)) { |
| 424 WriteTaggedPC(pc_delta, kLocatableTag); |
| 425 WriteTaggedData(pos_delta, pos_type_tag); |
| 426 } else { |
| 427 // Otherwise, use costly encoding. |
| 428 WriteExtraTaggedPC(pc_delta, kPCJumpExtraTag); |
| 429 WriteExtraTaggedIntData(pos_delta, pos_type_tag); |
| 430 } |
| 431 } |
| 432 |
| 433 |
| 434 void RelocInfoWriter::FlushPosition() { |
| 435 if (!next_position_candidate_flushed_) { |
| 436 WritePosition(next_position_candidate_pc_delta_, |
| 437 next_position_candidate_pos_delta_, RelocInfo::POSITION); |
| 438 next_position_candidate_pos_delta_ = 0; |
| 439 next_position_candidate_pc_delta_ = 0; |
| 440 next_position_candidate_flushed_ = true; |
| 441 } |
| 442 } |
| 443 |
| 444 |
418 void RelocInfoWriter::Write(const RelocInfo* rinfo) { | 445 void RelocInfoWriter::Write(const RelocInfo* rinfo) { |
| 446 RelocInfo::Mode rmode = rinfo->rmode(); |
| 447 if (rmode != RelocInfo::POSITION) { |
| 448 FlushPosition(); |
| 449 } |
419 #ifdef DEBUG | 450 #ifdef DEBUG |
420 byte* begin_pos = pos_; | 451 byte* begin_pos = pos_; |
421 #endif | 452 #endif |
422 DCHECK(rinfo->rmode() < RelocInfo::NUMBER_OF_MODES); | 453 DCHECK(rinfo->rmode() < RelocInfo::NUMBER_OF_MODES); |
423 DCHECK(rinfo->pc() - last_pc_ >= 0); | 454 DCHECK(rinfo->pc() - last_pc_ >= 0); |
424 DCHECK(RelocInfo::LAST_STANDARD_NONCOMPACT_ENUM - RelocInfo::LAST_COMPACT_ENUM | 455 DCHECK(RelocInfo::LAST_STANDARD_NONCOMPACT_ENUM - RelocInfo::LAST_COMPACT_ENUM |
425 <= kMaxStandardNonCompactModes); | 456 <= kMaxStandardNonCompactModes); |
426 // Use unsigned delta-encoding for pc. | 457 // Use unsigned delta-encoding for pc. |
427 uint32_t pc_delta = static_cast<uint32_t>(rinfo->pc() - last_pc_); | 458 uint32_t pc_delta = static_cast<uint32_t>(rinfo->pc() - last_pc_); |
428 RelocInfo::Mode rmode = rinfo->rmode(); | |
429 | 459 |
430 // The two most common modes are given small tags, and usually fit in a byte. | 460 // The two most common modes are given small tags, and usually fit in a byte. |
431 if (rmode == RelocInfo::EMBEDDED_OBJECT) { | 461 if (rmode == RelocInfo::EMBEDDED_OBJECT) { |
432 WriteTaggedPC(pc_delta, kEmbeddedObjectTag); | 462 WriteTaggedPC(pc_delta, kEmbeddedObjectTag); |
433 } else if (rmode == RelocInfo::CODE_TARGET) { | 463 } else if (rmode == RelocInfo::CODE_TARGET) { |
434 WriteTaggedPC(pc_delta, kCodeTargetTag); | 464 WriteTaggedPC(pc_delta, kCodeTargetTag); |
435 DCHECK(begin_pos - pos_ <= RelocInfo::kMaxCallSize); | 465 DCHECK(begin_pos - pos_ <= RelocInfo::kMaxCallSize); |
436 } else if (rmode == RelocInfo::CODE_TARGET_WITH_ID) { | 466 } else if (rmode == RelocInfo::CODE_TARGET_WITH_ID) { |
437 // Use signed delta-encoding for id. | 467 // Use signed delta-encoding for id. |
438 DCHECK(static_cast<int>(rinfo->data()) == rinfo->data()); | 468 DCHECK(static_cast<int>(rinfo->data()) == rinfo->data()); |
439 int id_delta = static_cast<int>(rinfo->data()) - last_id_; | 469 int id_delta = static_cast<int>(rinfo->data()) - last_id_; |
440 // Check if delta is small enough to fit in a tagged byte. | 470 // Check if delta is small enough to fit in a tagged byte. |
441 if (is_intn(id_delta, kSmallDataBits)) { | 471 if (is_intn(id_delta, kSmallDataBits)) { |
442 WriteTaggedPC(pc_delta, kLocatableTag); | 472 WriteTaggedPC(pc_delta, kLocatableTag); |
443 WriteTaggedData(id_delta, kCodeWithIdTag); | 473 WriteTaggedData(id_delta, kCodeWithIdTag); |
444 } else { | 474 } else { |
445 // Otherwise, use costly encoding. | 475 // Otherwise, use costly encoding. |
446 WriteExtraTaggedPC(pc_delta, kPCJumpExtraTag); | 476 WriteExtraTaggedPC(pc_delta, kPCJumpExtraTag); |
447 WriteExtraTaggedIntData(id_delta, kCodeWithIdTag); | 477 WriteExtraTaggedIntData(id_delta, kCodeWithIdTag); |
448 } | 478 } |
449 last_id_ = static_cast<int>(rinfo->data()); | 479 last_id_ = static_cast<int>(rinfo->data()); |
450 } else if (rmode == RelocInfo::DEOPT_REASON) { | 480 } else if (rmode == RelocInfo::DEOPT_REASON) { |
451 DCHECK(rinfo->data() < (1 << kSmallDataBits)); | 481 DCHECK(rinfo->data() < (1 << kSmallDataBits)); |
452 WriteTaggedPC(pc_delta, kLocatableTag); | 482 WriteTaggedPC(pc_delta, kLocatableTag); |
453 WriteTaggedData(rinfo->data(), kDeoptReasonTag); | 483 WriteTaggedData(rinfo->data(), kDeoptReasonTag); |
454 } else if (RelocInfo::IsPosition(rmode)) { | 484 } else if (RelocInfo::IsPosition(rmode)) { |
455 // Use signed delta-encoding for position. | 485 // Use signed delta-encoding for position. |
456 DCHECK(static_cast<int>(rinfo->data()) == rinfo->data()); | 486 DCHECK(static_cast<int>(rinfo->data()) == rinfo->data()); |
457 int pos_delta = static_cast<int>(rinfo->data()) - last_position_; | 487 int pos_delta = static_cast<int>(rinfo->data()) - last_position_; |
458 int pos_type_tag = (rmode == RelocInfo::POSITION) ? kNonstatementPositionTag | 488 if (rmode == RelocInfo::STATEMENT_POSITION) { |
459 : kStatementPositionTag; | 489 WritePosition(pc_delta, pos_delta, rmode); |
460 // Check if delta is small enough to fit in a tagged byte. | |
461 if (is_intn(pos_delta, kSmallDataBits)) { | |
462 WriteTaggedPC(pc_delta, kLocatableTag); | |
463 WriteTaggedData(pos_delta, pos_type_tag); | |
464 } else { | 490 } else { |
465 // Otherwise, use costly encoding. | 491 DCHECK(rmode == RelocInfo::POSITION); |
466 WriteExtraTaggedPC(pc_delta, kPCJumpExtraTag); | 492 if (pc_delta != 0 || last_mode_ != RelocInfo::POSITION) { |
467 WriteExtraTaggedIntData(pos_delta, pos_type_tag); | 493 FlushPosition(); |
| 494 next_position_candidate_pc_delta_ = pc_delta; |
| 495 next_position_candidate_pos_delta_ = pos_delta; |
| 496 } else { |
| 497 next_position_candidate_pos_delta_ += pos_delta; |
| 498 } |
| 499 next_position_candidate_flushed_ = false; |
468 } | 500 } |
469 last_position_ = static_cast<int>(rinfo->data()); | 501 last_position_ = static_cast<int>(rinfo->data()); |
470 } else if (RelocInfo::IsComment(rmode)) { | 502 } else if (RelocInfo::IsComment(rmode)) { |
471 // Comments are normally not generated, so we use the costly encoding. | 503 // Comments are normally not generated, so we use the costly encoding. |
472 WriteExtraTaggedPC(pc_delta, kPCJumpExtraTag); | 504 WriteExtraTaggedPC(pc_delta, kPCJumpExtraTag); |
473 WriteExtraTaggedData(rinfo->data(), kCommentTag); | 505 WriteExtraTaggedData(rinfo->data(), kCommentTag); |
474 DCHECK(begin_pos - pos_ >= RelocInfo::kMinRelocCommentSize); | 506 DCHECK(begin_pos - pos_ >= RelocInfo::kMinRelocCommentSize); |
475 } else if (RelocInfo::IsConstPool(rmode) || RelocInfo::IsVeneerPool(rmode)) { | 507 } else if (RelocInfo::IsConstPool(rmode) || RelocInfo::IsVeneerPool(rmode)) { |
476 WriteExtraTaggedPC(pc_delta, kPCJumpExtraTag); | 508 WriteExtraTaggedPC(pc_delta, kPCJumpExtraTag); |
477 WriteExtraTaggedPoolData(static_cast<int>(rinfo->data()), | 509 WriteExtraTaggedPoolData(static_cast<int>(rinfo->data()), |
478 RelocInfo::IsConstPool(rmode) ? kConstPoolTag | 510 RelocInfo::IsConstPool(rmode) ? kConstPoolTag |
479 : kVeneerPoolTag); | 511 : kVeneerPoolTag); |
480 } else { | 512 } else { |
481 DCHECK(rmode > RelocInfo::LAST_COMPACT_ENUM); | 513 DCHECK(rmode > RelocInfo::LAST_COMPACT_ENUM); |
482 int saved_mode = rmode - RelocInfo::LAST_COMPACT_ENUM; | 514 int saved_mode = rmode - RelocInfo::LAST_COMPACT_ENUM; |
483 // For all other modes we simply use the mode as the extra tag. | 515 // For all other modes we simply use the mode as the extra tag. |
484 // None of these modes need a data component. | 516 // None of these modes need a data component. |
485 DCHECK(saved_mode < kPoolExtraTag); | 517 DCHECK(saved_mode < kPoolExtraTag); |
486 WriteExtraTaggedPC(pc_delta, saved_mode); | 518 WriteExtraTaggedPC(pc_delta, saved_mode); |
487 } | 519 } |
488 last_pc_ = rinfo->pc(); | 520 last_pc_ = rinfo->pc(); |
| 521 last_mode_ = rmode; |
489 #ifdef DEBUG | 522 #ifdef DEBUG |
490 DCHECK(begin_pos - pos_ <= kMaxSize); | 523 DCHECK(begin_pos - pos_ <= kMaxSize); |
491 #endif | 524 #endif |
492 } | 525 } |
493 | 526 |
494 | 527 |
495 inline int RelocIterator::AdvanceGetTag() { | 528 inline int RelocIterator::AdvanceGetTag() { |
496 return *--pos_ & kTagMask; | 529 return *--pos_ & kTagMask; |
497 } | 530 } |
498 | 531 |
(...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1613 assembler_->RecordRelocInfo(RelocInfo::POSITION, state_.current_position); | 1646 assembler_->RecordRelocInfo(RelocInfo::POSITION, state_.current_position); |
1614 state_.written_position = state_.current_position; | 1647 state_.written_position = state_.current_position; |
1615 written = true; | 1648 written = true; |
1616 } | 1649 } |
1617 | 1650 |
1618 // Return whether something was written. | 1651 // Return whether something was written. |
1619 return written; | 1652 return written; |
1620 } | 1653 } |
1621 | 1654 |
1622 } } // namespace v8::internal | 1655 } } // namespace v8::internal |
OLD | NEW |