Chromium Code Reviews| 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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 373 | 373 |
| 374 | 374 |
| 375 void RelocInfoWriter::WriteExtraTaggedPC(uint32_t pc_delta, int extra_tag) { | 375 void RelocInfoWriter::WriteExtraTaggedPC(uint32_t pc_delta, int extra_tag) { |
| 376 // Write two-byte tagged pc-delta, possibly preceded by var. length pc-jump. | 376 // Write two-byte tagged pc-delta, possibly preceded by var. length pc-jump. |
| 377 pc_delta = WriteVariableLengthPCJump(pc_delta); | 377 pc_delta = WriteVariableLengthPCJump(pc_delta); |
| 378 WriteExtraTag(extra_tag, 0); | 378 WriteExtraTag(extra_tag, 0); |
| 379 *--pos_ = pc_delta; | 379 *--pos_ = pc_delta; |
| 380 } | 380 } |
| 381 | 381 |
| 382 | 382 |
| 383 void RelocInfoWriter::WriteInt(int number) { | |
| 384 for (int i = 0; i < kIntSize; i++) { | |
| 385 *--pos_ = static_cast<byte>(number); | |
| 386 // Signed right shift is arithmetic shift. Tested in test-utils.cc. | |
| 387 number = number >> kBitsPerByte; | |
| 388 } | |
| 389 } | |
| 390 | |
| 391 | |
| 383 void RelocInfoWriter::WriteExtraTaggedIntData(int data_delta, int top_tag) { | 392 void RelocInfoWriter::WriteExtraTaggedIntData(int data_delta, int top_tag) { |
| 384 WriteExtraTag(kDataJumpExtraTag, top_tag); | 393 WriteExtraTag(kDataJumpExtraTag, top_tag); |
| 385 for (int i = 0; i < kIntSize; i++) { | 394 WriteInt(data_delta); |
| 386 *--pos_ = static_cast<byte>(data_delta); | |
| 387 // Signed right shift is arithmetic shift. Tested in test-utils.cc. | |
| 388 data_delta = data_delta >> kBitsPerByte; | |
| 389 } | |
| 390 } | 395 } |
| 391 | 396 |
| 392 | 397 |
| 393 void RelocInfoWriter::WriteExtraTaggedPoolData(int data, int pool_type) { | 398 void RelocInfoWriter::WriteExtraTaggedPoolData(int data, int pool_type) { |
| 394 WriteExtraTag(kPoolExtraTag, pool_type); | 399 WriteExtraTag(kPoolExtraTag, pool_type); |
| 395 for (int i = 0; i < kIntSize; i++) { | 400 WriteInt(data); |
| 396 *--pos_ = static_cast<byte>(data); | |
| 397 // Signed right shift is arithmetic shift. Tested in test-utils.cc. | |
| 398 data = data >> kBitsPerByte; | |
| 399 } | |
| 400 } | 401 } |
| 401 | 402 |
| 402 | 403 |
| 403 void RelocInfoWriter::WriteExtraTaggedData(intptr_t data_delta, int top_tag) { | 404 void RelocInfoWriter::WriteExtraTaggedData(intptr_t data_delta, int top_tag) { |
| 404 WriteExtraTag(kDataJumpExtraTag, top_tag); | 405 WriteExtraTag(kDataJumpExtraTag, top_tag); |
| 405 for (int i = 0; i < kIntptrSize; i++) { | 406 for (int i = 0; i < kIntptrSize; i++) { |
| 406 *--pos_ = static_cast<byte>(data_delta); | 407 *--pos_ = static_cast<byte>(data_delta); |
| 407 // Signed right shift is arithmetic shift. Tested in test-utils.cc. | 408 // Signed right shift is arithmetic shift. Tested in test-utils.cc. |
| 408 data_delta = data_delta >> kBitsPerByte; | 409 data_delta = data_delta >> kBitsPerByte; |
| 409 } | 410 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 491 } | 492 } |
| 492 next_position_candidate_flushed_ = false; | 493 next_position_candidate_flushed_ = false; |
| 493 } | 494 } |
| 494 last_position_ = static_cast<int>(rinfo->data()); | 495 last_position_ = static_cast<int>(rinfo->data()); |
| 495 } else if (RelocInfo::IsComment(rmode)) { | 496 } else if (RelocInfo::IsComment(rmode)) { |
| 496 // Comments are normally not generated, so we use the costly encoding. | 497 // Comments are normally not generated, so we use the costly encoding. |
| 497 WriteExtraTaggedPC(pc_delta, kPCJumpExtraTag); | 498 WriteExtraTaggedPC(pc_delta, kPCJumpExtraTag); |
| 498 WriteExtraTaggedData(rinfo->data(), kCommentTag); | 499 WriteExtraTaggedData(rinfo->data(), kCommentTag); |
| 499 DCHECK(begin_pos - pos_ >= RelocInfo::kMinRelocCommentSize); | 500 DCHECK(begin_pos - pos_ >= RelocInfo::kMinRelocCommentSize); |
| 500 } else if (RelocInfo::IsConstPool(rmode) || RelocInfo::IsVeneerPool(rmode)) { | 501 } else if (RelocInfo::IsConstPool(rmode) || RelocInfo::IsVeneerPool(rmode)) { |
| 501 WriteExtraTaggedPC(pc_delta, kPCJumpExtraTag); | 502 WriteExtraTaggedPC(pc_delta, kPCJumpExtraTag); |
| 502 WriteExtraTaggedPoolData(static_cast<int>(rinfo->data()), | 503 WriteExtraTaggedPoolData( |
| 503 RelocInfo::IsConstPool(rmode) ? kConstPoolTag | 504 static_cast<int>(rinfo->data()), |
| 504 : kVeneerPoolTag); | 505 RelocInfo::IsConstPool(rmode) ? kConstPoolTag : kVeneerPoolTag); |
| 505 } else { | 506 } else { |
| 506 DCHECK(rmode > RelocInfo::LAST_COMPACT_ENUM); | 507 DCHECK(rmode > RelocInfo::LAST_COMPACT_ENUM); |
| 507 DCHECK(rmode <= RelocInfo::LAST_STANDARD_NONCOMPACT_ENUM); | 508 DCHECK(rmode <= RelocInfo::LAST_STANDARD_NONCOMPACT_ENUM); |
| 508 STATIC_ASSERT(RelocInfo::LAST_STANDARD_NONCOMPACT_ENUM - | 509 STATIC_ASSERT(RelocInfo::LAST_STANDARD_NONCOMPACT_ENUM - |
| 509 RelocInfo::LAST_COMPACT_ENUM <= | 510 RelocInfo::LAST_COMPACT_ENUM <= |
| 510 kPoolExtraTag); | 511 kPoolExtraTag); |
| 511 int saved_mode = rmode - RelocInfo::LAST_COMPACT_ENUM - 1; | 512 int saved_mode = rmode - RelocInfo::LAST_COMPACT_ENUM - 1; |
| 512 // For all other modes we simply use the mode as the extra tag. | 513 // For all other modes we simply use the mode as the extra tag. |
| 513 // None of these modes need a data component. | 514 // None of these modes need a data component. |
| 514 DCHECK(0 <= saved_mode && saved_mode < kPoolExtraTag); | 515 DCHECK(0 <= saved_mode && saved_mode < kPoolExtraTag); |
| 515 WriteExtraTaggedPC(pc_delta, saved_mode); | 516 WriteExtraTaggedPC(pc_delta, saved_mode); |
| 517 if (RelocInfo::IsDebugBreakSlot(rmode)) { | |
|
ulan
2015/07/07 13:31:31
Let's make it into a method with descriptive name
Yang
2015/07/07 14:39:00
Done.
| |
| 518 WriteInt(reinterpret_cast<int>(rinfo->data())); | |
| 519 } | |
| 516 } | 520 } |
| 517 last_pc_ = rinfo->pc(); | 521 last_pc_ = rinfo->pc(); |
| 518 last_mode_ = rmode; | 522 last_mode_ = rmode; |
| 519 #ifdef DEBUG | 523 #ifdef DEBUG |
| 520 DCHECK(begin_pos - pos_ <= kMaxSize); | 524 DCHECK(begin_pos - pos_ <= kMaxSize); |
| 521 #endif | 525 #endif |
| 522 } | 526 } |
| 523 | 527 |
| 524 | 528 |
| 525 inline int RelocIterator::AdvanceGetTag() { | 529 inline int RelocIterator::AdvanceGetTag() { |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 550 void RelocIterator::AdvanceReadId() { | 554 void RelocIterator::AdvanceReadId() { |
| 551 int x = 0; | 555 int x = 0; |
| 552 for (int i = 0; i < kIntSize; i++) { | 556 for (int i = 0; i < kIntSize; i++) { |
| 553 x |= static_cast<int>(*--pos_) << i * kBitsPerByte; | 557 x |= static_cast<int>(*--pos_) << i * kBitsPerByte; |
| 554 } | 558 } |
| 555 last_id_ += x; | 559 last_id_ += x; |
| 556 rinfo_.data_ = last_id_; | 560 rinfo_.data_ = last_id_; |
| 557 } | 561 } |
| 558 | 562 |
| 559 | 563 |
| 560 void RelocIterator::AdvanceReadPoolData() { | 564 void RelocIterator::AdvanceReadInt() { |
| 561 int x = 0; | 565 int x = 0; |
| 562 for (int i = 0; i < kIntSize; i++) { | 566 for (int i = 0; i < kIntSize; i++) { |
| 563 x |= static_cast<int>(*--pos_) << i * kBitsPerByte; | 567 x |= static_cast<int>(*--pos_) << i * kBitsPerByte; |
| 564 } | 568 } |
| 565 rinfo_.data_ = x; | 569 rinfo_.data_ = x; |
| 566 } | 570 } |
| 567 | 571 |
| 568 | 572 |
| 569 void RelocIterator::AdvanceReadPosition() { | 573 void RelocIterator::AdvanceReadPosition() { |
| 570 int x = 0; | 574 int x = 0; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 705 return; | 709 return; |
| 706 } | 710 } |
| 707 Advance(kIntptrSize); | 711 Advance(kIntptrSize); |
| 708 } | 712 } |
| 709 } else if (extra_tag == kPoolExtraTag) { | 713 } else if (extra_tag == kPoolExtraTag) { |
| 710 int pool_type = GetTopTag(); | 714 int pool_type = GetTopTag(); |
| 711 DCHECK(pool_type == kConstPoolTag || pool_type == kVeneerPoolTag); | 715 DCHECK(pool_type == kConstPoolTag || pool_type == kVeneerPoolTag); |
| 712 RelocInfo::Mode rmode = (pool_type == kConstPoolTag) ? | 716 RelocInfo::Mode rmode = (pool_type == kConstPoolTag) ? |
| 713 RelocInfo::CONST_POOL : RelocInfo::VENEER_POOL; | 717 RelocInfo::CONST_POOL : RelocInfo::VENEER_POOL; |
| 714 if (SetMode(rmode)) { | 718 if (SetMode(rmode)) { |
| 715 AdvanceReadPoolData(); | 719 AdvanceReadInt(); |
|
ulan
2015/07/07 13:31:31
The old name was more discriptive: AdvanceReadPool
Yang
2015/07/07 14:39:00
Done.
| |
| 716 return; | 720 return; |
| 717 } | 721 } |
| 718 Advance(kIntSize); | 722 Advance(kIntSize); |
| 719 } else { | 723 } else { |
| 720 AdvanceReadPC(); | 724 AdvanceReadPC(); |
| 721 int rmode = extra_tag + RelocInfo::LAST_COMPACT_ENUM + 1; | 725 RelocInfo::Mode rmode = static_cast<RelocInfo::Mode>( |
| 722 if (SetMode(static_cast<RelocInfo::Mode>(rmode))) return; | 726 extra_tag + RelocInfo::LAST_COMPACT_ENUM + 1); |
| 727 if (RelocInfo::IsDebugBreakSlot(rmode)) { | |
|
ulan
2015/07/07 13:31:31
Let's extract this into a separate function "Advan
Yang
2015/07/07 14:38:59
Done.
| |
| 728 if (SetMode(rmode)) return AdvanceReadInt(); | |
| 729 Advance(kIntSize); | |
| 730 } | |
| 731 if (SetMode(rmode)) return; | |
| 723 } | 732 } |
| 724 } | 733 } |
| 725 } | 734 } |
| 726 if (code_age_sequence_ != NULL) { | 735 if (code_age_sequence_ != NULL) { |
| 727 byte* old_code_age_sequence = code_age_sequence_; | 736 byte* old_code_age_sequence = code_age_sequence_; |
| 728 code_age_sequence_ = NULL; | 737 code_age_sequence_ = NULL; |
| 729 if (SetMode(RelocInfo::CODE_AGE_SEQUENCE)) { | 738 if (SetMode(RelocInfo::CODE_AGE_SEQUENCE)) { |
| 730 rinfo_.data_ = 0; | 739 rinfo_.data_ = 0; |
| 731 rinfo_.pc_ = old_code_age_sequence; | 740 rinfo_.pc_ = old_code_age_sequence; |
| 732 return; | 741 return; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 876 } else if (IsRuntimeEntry(rmode_) && | 885 } else if (IsRuntimeEntry(rmode_) && |
| 877 isolate->deoptimizer_data() != NULL) { | 886 isolate->deoptimizer_data() != NULL) { |
| 878 // Depotimization bailouts are stored as runtime entries. | 887 // Depotimization bailouts are stored as runtime entries. |
| 879 int id = Deoptimizer::GetDeoptimizationId( | 888 int id = Deoptimizer::GetDeoptimizationId( |
| 880 isolate, target_address(), Deoptimizer::EAGER); | 889 isolate, target_address(), Deoptimizer::EAGER); |
| 881 if (id != Deoptimizer::kNotDeoptimizationEntry) { | 890 if (id != Deoptimizer::kNotDeoptimizationEntry) { |
| 882 os << " (deoptimization bailout " << id << ")"; | 891 os << " (deoptimization bailout " << id << ")"; |
| 883 } | 892 } |
| 884 } else if (IsConstPool(rmode_)) { | 893 } else if (IsConstPool(rmode_)) { |
| 885 os << " (size " << static_cast<int>(data_) << ")"; | 894 os << " (size " << static_cast<int>(data_) << ")"; |
| 895 } else if (IsDebugBreakSlot(rmode_)) { | |
| 896 if (DebugBreakIsCall()) { | |
| 897 os << " (call with " << DebugBreakCallArgumentsCount() << " args)"; | |
| 898 } else { | |
| 899 os << " (slot)"; | |
| 900 } | |
| 886 } | 901 } |
| 887 | 902 |
| 888 os << "\n"; | 903 os << "\n"; |
| 889 } | 904 } |
| 890 #endif // ENABLE_DISASSEMBLER | 905 #endif // ENABLE_DISASSEMBLER |
| 891 | 906 |
| 892 | 907 |
| 893 #ifdef VERIFY_HEAP | 908 #ifdef VERIFY_HEAP |
| 894 void RelocInfo::Verify(Isolate* isolate) { | 909 void RelocInfo::Verify(Isolate* isolate) { |
| 895 switch (rmode_) { | 910 switch (rmode_) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 939 UNREACHABLE(); | 954 UNREACHABLE(); |
| 940 break; | 955 break; |
| 941 case CODE_AGE_SEQUENCE: | 956 case CODE_AGE_SEQUENCE: |
| 942 DCHECK(Code::IsYoungSequence(isolate, pc_) || code_age_stub()->IsCode()); | 957 DCHECK(Code::IsYoungSequence(isolate, pc_) || code_age_stub()->IsCode()); |
| 943 break; | 958 break; |
| 944 } | 959 } |
| 945 } | 960 } |
| 946 #endif // VERIFY_HEAP | 961 #endif // VERIFY_HEAP |
| 947 | 962 |
| 948 | 963 |
| 964 bool RelocInfo::DebugBreakIsCall() { | |
| 965 DCHECK(IsDebugBreakSlot(rmode_)); | |
| 966 return data_ >= kDebugBreakCallArgsOffset; | |
| 967 } | |
| 968 | |
| 969 | |
| 970 int RelocInfo::DebugBreakCallArgumentsCount() { | |
| 971 DCHECK(DebugBreakIsCall()); | |
| 972 return data_ - kDebugBreakCallArgsOffset; | |
| 973 } | |
| 974 | |
| 975 | |
| 949 // ----------------------------------------------------------------------------- | 976 // ----------------------------------------------------------------------------- |
| 950 // Implementation of ExternalReference | 977 // Implementation of ExternalReference |
| 951 | 978 |
| 952 void ExternalReference::SetUp() { | 979 void ExternalReference::SetUp() { |
| 953 double_constants.min_int = kMinInt; | 980 double_constants.min_int = kMinInt; |
| 954 double_constants.one_half = 0.5; | 981 double_constants.one_half = 0.5; |
| 955 double_constants.minus_one_half = -0.5; | 982 double_constants.minus_one_half = -0.5; |
| 956 double_constants.the_hole_nan = bit_cast<double>(kHoleNanInt64); | 983 double_constants.the_hole_nan = bit_cast<double>(kHoleNanInt64); |
| 957 double_constants.negative_infinity = -V8_INFINITY; | 984 double_constants.negative_infinity = -V8_INFINITY; |
| 958 double_constants.uint32_bias = | 985 double_constants.uint32_bias = |
| (...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1862 | 1889 |
| 1863 void Assembler::RecordJSReturn() { | 1890 void Assembler::RecordJSReturn() { |
| 1864 positions_recorder()->WriteRecordedPositions(); | 1891 positions_recorder()->WriteRecordedPositions(); |
| 1865 EnsureSpace ensure_space(this); | 1892 EnsureSpace ensure_space(this); |
| 1866 RecordRelocInfo(RelocInfo::JS_RETURN); | 1893 RecordRelocInfo(RelocInfo::JS_RETURN); |
| 1867 } | 1894 } |
| 1868 | 1895 |
| 1869 | 1896 |
| 1870 void Assembler::RecordDebugBreakSlot() { | 1897 void Assembler::RecordDebugBreakSlot() { |
| 1871 EnsureSpace ensure_space(this); | 1898 EnsureSpace ensure_space(this); |
| 1872 RecordRelocInfo(RelocInfo::DEBUG_BREAK_SLOT); | 1899 intptr_t data = reinterpret_cast<intptr_t>(RelocInfo::kDebugBreakNonCallArgs); |
| 1900 RecordRelocInfo(RelocInfo::DEBUG_BREAK_SLOT, data); | |
| 1873 } | 1901 } |
| 1874 | 1902 |
| 1875 | 1903 |
| 1904 void Assembler::RecordDebugBreakSlotForCall(int argc) { | |
| 1905 EnsureSpace ensure_space(this); | |
| 1906 intptr_t data = | |
| 1907 reinterpret_cast<intptr_t>(argc + RelocInfo::kDebugBreakCallArgsOffset); | |
| 1908 RecordRelocInfo(RelocInfo::DEBUG_BREAK_SLOT, data); | |
| 1909 } | |
| 1910 | |
| 1911 | |
| 1876 void Assembler::DataAlign(int m) { | 1912 void Assembler::DataAlign(int m) { |
| 1877 DCHECK(m >= 2 && base::bits::IsPowerOfTwo32(m)); | 1913 DCHECK(m >= 2 && base::bits::IsPowerOfTwo32(m)); |
| 1878 while ((pc_offset() & (m - 1)) != 0) { | 1914 while ((pc_offset() & (m - 1)) != 0) { |
| 1879 db(0); | 1915 db(0); |
| 1880 } | 1916 } |
| 1881 } | 1917 } |
| 1882 } // namespace internal | 1918 } // namespace internal |
| 1883 } // namespace v8 | 1919 } // namespace v8 |
| OLD | NEW |