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 | |
392 void RelocInfoWriter::WriteDebugBreakSlotData(int data) { WriteInt(data); } | |
393 | |
394 | |
383 void RelocInfoWriter::WriteExtraTaggedIntData(int data_delta, int top_tag) { | 395 void RelocInfoWriter::WriteExtraTaggedIntData(int data_delta, int top_tag) { |
384 WriteExtraTag(kDataJumpExtraTag, top_tag); | 396 WriteExtraTag(kDataJumpExtraTag, top_tag); |
385 for (int i = 0; i < kIntSize; i++) { | 397 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 } | 398 } |
391 | 399 |
392 | 400 |
393 void RelocInfoWriter::WriteExtraTaggedPoolData(int data, int pool_type) { | 401 void RelocInfoWriter::WriteExtraTaggedPoolData(int data, int pool_type) { |
394 WriteExtraTag(kPoolExtraTag, pool_type); | 402 WriteExtraTag(kPoolExtraTag, pool_type); |
395 for (int i = 0; i < kIntSize; i++) { | 403 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 } | 404 } |
401 | 405 |
402 | 406 |
403 void RelocInfoWriter::WriteExtraTaggedData(intptr_t data_delta, int top_tag) { | 407 void RelocInfoWriter::WriteExtraTaggedData(intptr_t data_delta, int top_tag) { |
404 WriteExtraTag(kDataJumpExtraTag, top_tag); | 408 WriteExtraTag(kDataJumpExtraTag, top_tag); |
405 for (int i = 0; i < kIntptrSize; i++) { | 409 for (int i = 0; i < kIntptrSize; i++) { |
406 *--pos_ = static_cast<byte>(data_delta); | 410 *--pos_ = static_cast<byte>(data_delta); |
407 // Signed right shift is arithmetic shift. Tested in test-utils.cc. | 411 // Signed right shift is arithmetic shift. Tested in test-utils.cc. |
408 data_delta = data_delta >> kBitsPerByte; | 412 data_delta = data_delta >> kBitsPerByte; |
409 } | 413 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
491 } | 495 } |
492 next_position_candidate_flushed_ = false; | 496 next_position_candidate_flushed_ = false; |
493 } | 497 } |
494 last_position_ = static_cast<int>(rinfo->data()); | 498 last_position_ = static_cast<int>(rinfo->data()); |
495 } else if (RelocInfo::IsComment(rmode)) { | 499 } else if (RelocInfo::IsComment(rmode)) { |
496 // Comments are normally not generated, so we use the costly encoding. | 500 // Comments are normally not generated, so we use the costly encoding. |
497 WriteExtraTaggedPC(pc_delta, kPCJumpExtraTag); | 501 WriteExtraTaggedPC(pc_delta, kPCJumpExtraTag); |
498 WriteExtraTaggedData(rinfo->data(), kCommentTag); | 502 WriteExtraTaggedData(rinfo->data(), kCommentTag); |
499 DCHECK(begin_pos - pos_ >= RelocInfo::kMinRelocCommentSize); | 503 DCHECK(begin_pos - pos_ >= RelocInfo::kMinRelocCommentSize); |
500 } else if (RelocInfo::IsConstPool(rmode) || RelocInfo::IsVeneerPool(rmode)) { | 504 } else if (RelocInfo::IsConstPool(rmode) || RelocInfo::IsVeneerPool(rmode)) { |
501 WriteExtraTaggedPC(pc_delta, kPCJumpExtraTag); | 505 WriteExtraTaggedPC(pc_delta, kPCJumpExtraTag); |
502 WriteExtraTaggedPoolData(static_cast<int>(rinfo->data()), | 506 WriteExtraTaggedPoolData( |
503 RelocInfo::IsConstPool(rmode) ? kConstPoolTag | 507 static_cast<int>(rinfo->data()), |
504 : kVeneerPoolTag); | 508 RelocInfo::IsConstPool(rmode) ? kConstPoolTag : kVeneerPoolTag); |
505 } else { | 509 } else { |
506 DCHECK(rmode > RelocInfo::LAST_COMPACT_ENUM); | 510 DCHECK(rmode > RelocInfo::LAST_COMPACT_ENUM); |
507 DCHECK(rmode <= RelocInfo::LAST_STANDARD_NONCOMPACT_ENUM); | 511 DCHECK(rmode <= RelocInfo::LAST_STANDARD_NONCOMPACT_ENUM); |
508 STATIC_ASSERT(RelocInfo::LAST_STANDARD_NONCOMPACT_ENUM - | 512 STATIC_ASSERT(RelocInfo::LAST_STANDARD_NONCOMPACT_ENUM - |
509 RelocInfo::LAST_COMPACT_ENUM <= | 513 RelocInfo::LAST_COMPACT_ENUM <= |
510 kPoolExtraTag); | 514 kPoolExtraTag); |
511 int saved_mode = rmode - RelocInfo::LAST_COMPACT_ENUM - 1; | 515 int saved_mode = rmode - RelocInfo::LAST_COMPACT_ENUM - 1; |
512 // For all other modes we simply use the mode as the extra tag. | 516 // For all other modes we simply use the mode as the extra tag. |
513 // None of these modes need a data component. | 517 // None of these modes need a data component. |
514 DCHECK(0 <= saved_mode && saved_mode < kPoolExtraTag); | 518 DCHECK(0 <= saved_mode && saved_mode < kPoolExtraTag); |
515 WriteExtraTaggedPC(pc_delta, saved_mode); | 519 WriteExtraTaggedPC(pc_delta, saved_mode); |
520 if (RelocInfo::IsDebugBreakSlot(rmode)) { | |
521 WriteDebugBreakSlotData(static_cast<int>(rinfo->data())); | |
522 } | |
516 } | 523 } |
517 last_pc_ = rinfo->pc(); | 524 last_pc_ = rinfo->pc(); |
518 last_mode_ = rmode; | 525 last_mode_ = rmode; |
519 #ifdef DEBUG | 526 #ifdef DEBUG |
520 DCHECK(begin_pos - pos_ <= kMaxSize); | 527 DCHECK(begin_pos - pos_ <= kMaxSize); |
521 #endif | 528 #endif |
522 } | 529 } |
523 | 530 |
524 | 531 |
525 inline int RelocIterator::AdvanceGetTag() { | 532 inline int RelocIterator::AdvanceGetTag() { |
(...skipping 24 matching lines...) Expand all Loading... | |
550 void RelocIterator::AdvanceReadId() { | 557 void RelocIterator::AdvanceReadId() { |
551 int x = 0; | 558 int x = 0; |
552 for (int i = 0; i < kIntSize; i++) { | 559 for (int i = 0; i < kIntSize; i++) { |
553 x |= static_cast<int>(*--pos_) << i * kBitsPerByte; | 560 x |= static_cast<int>(*--pos_) << i * kBitsPerByte; |
554 } | 561 } |
555 last_id_ += x; | 562 last_id_ += x; |
556 rinfo_.data_ = last_id_; | 563 rinfo_.data_ = last_id_; |
557 } | 564 } |
558 | 565 |
559 | 566 |
560 void RelocIterator::AdvanceReadPoolData() { | 567 void RelocIterator::AdvanceReadInt() { |
561 int x = 0; | 568 int x = 0; |
562 for (int i = 0; i < kIntSize; i++) { | 569 for (int i = 0; i < kIntSize; i++) { |
563 x |= static_cast<int>(*--pos_) << i * kBitsPerByte; | 570 x |= static_cast<int>(*--pos_) << i * kBitsPerByte; |
564 } | 571 } |
565 rinfo_.data_ = x; | 572 rinfo_.data_ = x; |
566 } | 573 } |
567 | 574 |
568 | 575 |
576 void RelocIterator::AdvanceReadPoolData() { AdvanceReadInt(); } | |
577 | |
578 | |
579 void RelocIterator::AdvanceReadDebugBreakSlotData() { AdvanceReadInt(); } | |
580 | |
581 | |
569 void RelocIterator::AdvanceReadPosition() { | 582 void RelocIterator::AdvanceReadPosition() { |
570 int x = 0; | 583 int x = 0; |
571 for (int i = 0; i < kIntSize; i++) { | 584 for (int i = 0; i < kIntSize; i++) { |
572 x |= static_cast<int>(*--pos_) << i * kBitsPerByte; | 585 x |= static_cast<int>(*--pos_) << i * kBitsPerByte; |
573 } | 586 } |
574 last_position_ += x; | 587 last_position_ += x; |
575 rinfo_.data_ = last_position_; | 588 rinfo_.data_ = last_position_; |
576 } | 589 } |
577 | 590 |
578 | 591 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
711 DCHECK(pool_type == kConstPoolTag || pool_type == kVeneerPoolTag); | 724 DCHECK(pool_type == kConstPoolTag || pool_type == kVeneerPoolTag); |
712 RelocInfo::Mode rmode = (pool_type == kConstPoolTag) ? | 725 RelocInfo::Mode rmode = (pool_type == kConstPoolTag) ? |
713 RelocInfo::CONST_POOL : RelocInfo::VENEER_POOL; | 726 RelocInfo::CONST_POOL : RelocInfo::VENEER_POOL; |
714 if (SetMode(rmode)) { | 727 if (SetMode(rmode)) { |
715 AdvanceReadPoolData(); | 728 AdvanceReadPoolData(); |
716 return; | 729 return; |
717 } | 730 } |
718 Advance(kIntSize); | 731 Advance(kIntSize); |
719 } else { | 732 } else { |
720 AdvanceReadPC(); | 733 AdvanceReadPC(); |
721 int rmode = extra_tag + RelocInfo::LAST_COMPACT_ENUM + 1; | 734 RelocInfo::Mode rmode = static_cast<RelocInfo::Mode>( |
722 if (SetMode(static_cast<RelocInfo::Mode>(rmode))) return; | 735 extra_tag + RelocInfo::LAST_COMPACT_ENUM + 1); |
736 if (RelocInfo::IsDebugBreakSlot(rmode)) { | |
737 if (SetMode(rmode)) return AdvanceReadDebugBreakSlotData(); | |
ulan
2015/07/08 11:53:33
Did you mean
if (SetMode(rmode)) return;
AdvanceR
Yang
2015/07/09 09:38:47
actually no. if SetMode returns true, we want to r
| |
738 Advance(kIntSize); | |
739 } | |
740 if (SetMode(rmode)) return; | |
723 } | 741 } |
724 } | 742 } |
725 } | 743 } |
726 if (code_age_sequence_ != NULL) { | 744 if (code_age_sequence_ != NULL) { |
727 byte* old_code_age_sequence = code_age_sequence_; | 745 byte* old_code_age_sequence = code_age_sequence_; |
728 code_age_sequence_ = NULL; | 746 code_age_sequence_ = NULL; |
729 if (SetMode(RelocInfo::CODE_AGE_SEQUENCE)) { | 747 if (SetMode(RelocInfo::CODE_AGE_SEQUENCE)) { |
730 rinfo_.data_ = 0; | 748 rinfo_.data_ = 0; |
731 rinfo_.pc_ = old_code_age_sequence; | 749 rinfo_.pc_ = old_code_age_sequence; |
732 return; | 750 return; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
876 } else if (IsRuntimeEntry(rmode_) && | 894 } else if (IsRuntimeEntry(rmode_) && |
877 isolate->deoptimizer_data() != NULL) { | 895 isolate->deoptimizer_data() != NULL) { |
878 // Depotimization bailouts are stored as runtime entries. | 896 // Depotimization bailouts are stored as runtime entries. |
879 int id = Deoptimizer::GetDeoptimizationId( | 897 int id = Deoptimizer::GetDeoptimizationId( |
880 isolate, target_address(), Deoptimizer::EAGER); | 898 isolate, target_address(), Deoptimizer::EAGER); |
881 if (id != Deoptimizer::kNotDeoptimizationEntry) { | 899 if (id != Deoptimizer::kNotDeoptimizationEntry) { |
882 os << " (deoptimization bailout " << id << ")"; | 900 os << " (deoptimization bailout " << id << ")"; |
883 } | 901 } |
884 } else if (IsConstPool(rmode_)) { | 902 } else if (IsConstPool(rmode_)) { |
885 os << " (size " << static_cast<int>(data_) << ")"; | 903 os << " (size " << static_cast<int>(data_) << ")"; |
904 } else if (IsDebugBreakSlot(rmode_)) { | |
905 if (DebugBreakIsCall(data_)) { | |
906 os << " (call with " << DebugBreakCallArgumentsCount(data_) << " args)"; | |
907 } else if (DebugBreakIsConstructCall(data_)) { | |
908 os << " (construct call)"; | |
909 } else { | |
910 os << " (slot)"; | |
911 } | |
886 } | 912 } |
887 | 913 |
888 os << "\n"; | 914 os << "\n"; |
889 } | 915 } |
890 #endif // ENABLE_DISASSEMBLER | 916 #endif // ENABLE_DISASSEMBLER |
891 | 917 |
892 | 918 |
893 #ifdef VERIFY_HEAP | 919 #ifdef VERIFY_HEAP |
894 void RelocInfo::Verify(Isolate* isolate) { | 920 void RelocInfo::Verify(Isolate* isolate) { |
895 switch (rmode_) { | 921 switch (rmode_) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
939 UNREACHABLE(); | 965 UNREACHABLE(); |
940 break; | 966 break; |
941 case CODE_AGE_SEQUENCE: | 967 case CODE_AGE_SEQUENCE: |
942 DCHECK(Code::IsYoungSequence(isolate, pc_) || code_age_stub()->IsCode()); | 968 DCHECK(Code::IsYoungSequence(isolate, pc_) || code_age_stub()->IsCode()); |
943 break; | 969 break; |
944 } | 970 } |
945 } | 971 } |
946 #endif // VERIFY_HEAP | 972 #endif // VERIFY_HEAP |
947 | 973 |
948 | 974 |
975 bool RelocInfo::DebugBreakIsConstructCall(intptr_t data) { | |
976 return data == static_cast<intptr_t>(kDebugBreakConstructCallSentinel); | |
977 } | |
978 | |
979 | |
980 bool RelocInfo::DebugBreakIsCall(intptr_t data) { return data >= 0; } | |
981 | |
982 | |
983 int RelocInfo::DebugBreakCallArgumentsCount(intptr_t data) { | |
984 DCHECK(DebugBreakIsCall(data)); | |
985 return static_cast<int>(data); | |
986 } | |
987 | |
988 | |
949 // ----------------------------------------------------------------------------- | 989 // ----------------------------------------------------------------------------- |
950 // Implementation of ExternalReference | 990 // Implementation of ExternalReference |
951 | 991 |
952 void ExternalReference::SetUp() { | 992 void ExternalReference::SetUp() { |
953 double_constants.min_int = kMinInt; | 993 double_constants.min_int = kMinInt; |
954 double_constants.one_half = 0.5; | 994 double_constants.one_half = 0.5; |
955 double_constants.minus_one_half = -0.5; | 995 double_constants.minus_one_half = -0.5; |
956 double_constants.the_hole_nan = bit_cast<double>(kHoleNanInt64); | 996 double_constants.the_hole_nan = bit_cast<double>(kHoleNanInt64); |
957 double_constants.negative_infinity = -V8_INFINITY; | 997 double_constants.negative_infinity = -V8_INFINITY; |
958 double_constants.uint32_bias = | 998 double_constants.uint32_bias = |
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1862 | 1902 |
1863 void Assembler::RecordJSReturn() { | 1903 void Assembler::RecordJSReturn() { |
1864 positions_recorder()->WriteRecordedPositions(); | 1904 positions_recorder()->WriteRecordedPositions(); |
1865 EnsureSpace ensure_space(this); | 1905 EnsureSpace ensure_space(this); |
1866 RecordRelocInfo(RelocInfo::JS_RETURN); | 1906 RecordRelocInfo(RelocInfo::JS_RETURN); |
1867 } | 1907 } |
1868 | 1908 |
1869 | 1909 |
1870 void Assembler::RecordDebugBreakSlot() { | 1910 void Assembler::RecordDebugBreakSlot() { |
1871 EnsureSpace ensure_space(this); | 1911 EnsureSpace ensure_space(this); |
1872 RecordRelocInfo(RelocInfo::DEBUG_BREAK_SLOT); | 1912 intptr_t data = static_cast<intptr_t>(RelocInfo::kDebugBreakNonCallSentinel); |
1913 RecordRelocInfo(RelocInfo::DEBUG_BREAK_SLOT, data); | |
1873 } | 1914 } |
1874 | 1915 |
1875 | 1916 |
1917 void Assembler::RecordDebugBreakSlotForCall(int argc) { | |
1918 EnsureSpace ensure_space(this); | |
1919 intptr_t data = static_cast<intptr_t>(argc); | |
1920 RecordRelocInfo(RelocInfo::DEBUG_BREAK_SLOT, data); | |
1921 } | |
1922 | |
1923 | |
1924 void Assembler::RecordDebugBreakSlotForConstructCall() { | |
1925 EnsureSpace ensure_space(this); | |
1926 intptr_t data = | |
1927 static_cast<intptr_t>(RelocInfo::kDebugBreakConstructCallSentinel); | |
1928 RecordRelocInfo(RelocInfo::DEBUG_BREAK_SLOT, data); | |
1929 } | |
1930 | |
1931 | |
1876 void Assembler::DataAlign(int m) { | 1932 void Assembler::DataAlign(int m) { |
1877 DCHECK(m >= 2 && base::bits::IsPowerOfTwo32(m)); | 1933 DCHECK(m >= 2 && base::bits::IsPowerOfTwo32(m)); |
1878 while ((pc_offset() & (m - 1)) != 0) { | 1934 while ((pc_offset() & (m - 1)) != 0) { |
1879 db(0); | 1935 db(0); |
1880 } | 1936 } |
1881 } | 1937 } |
1882 } // namespace internal | 1938 } // namespace internal |
1883 } // namespace v8 | 1939 } // namespace v8 |
OLD | NEW |