Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Side by Side Diff: src/assembler.cc

Issue 1222093007: Debugger: use debug break slot to break on call. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebased and addressed comments Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/assembler.h ('k') | src/builtins.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
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)) {
738 AdvanceReadDebugBreakSlotData();
739 return;
740 }
741 Advance(kIntSize);
742 } else if (SetMode(rmode)) {
743 return;
744 }
723 } 745 }
724 } 746 }
725 } 747 }
726 if (code_age_sequence_ != NULL) { 748 if (code_age_sequence_ != NULL) {
727 byte* old_code_age_sequence = code_age_sequence_; 749 byte* old_code_age_sequence = code_age_sequence_;
728 code_age_sequence_ = NULL; 750 code_age_sequence_ = NULL;
729 if (SetMode(RelocInfo::CODE_AGE_SEQUENCE)) { 751 if (SetMode(RelocInfo::CODE_AGE_SEQUENCE)) {
730 rinfo_.data_ = 0; 752 rinfo_.data_ = 0;
731 rinfo_.pc_ = old_code_age_sequence; 753 rinfo_.pc_ = old_code_age_sequence;
732 return; 754 return;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 } else if (IsRuntimeEntry(rmode_) && 898 } else if (IsRuntimeEntry(rmode_) &&
877 isolate->deoptimizer_data() != NULL) { 899 isolate->deoptimizer_data() != NULL) {
878 // Depotimization bailouts are stored as runtime entries. 900 // Depotimization bailouts are stored as runtime entries.
879 int id = Deoptimizer::GetDeoptimizationId( 901 int id = Deoptimizer::GetDeoptimizationId(
880 isolate, target_address(), Deoptimizer::EAGER); 902 isolate, target_address(), Deoptimizer::EAGER);
881 if (id != Deoptimizer::kNotDeoptimizationEntry) { 903 if (id != Deoptimizer::kNotDeoptimizationEntry) {
882 os << " (deoptimization bailout " << id << ")"; 904 os << " (deoptimization bailout " << id << ")";
883 } 905 }
884 } else if (IsConstPool(rmode_)) { 906 } else if (IsConstPool(rmode_)) {
885 os << " (size " << static_cast<int>(data_) << ")"; 907 os << " (size " << static_cast<int>(data_) << ")";
908 } else if (IsDebugBreakSlot(rmode_)) {
909 if (DebugBreakIsCall(data_)) {
910 os << " (call with " << DebugBreakCallArgumentsCount(data_) << " args)";
911 } else if (DebugBreakIsConstructCall(data_)) {
912 os << " (construct call)";
913 } else {
914 os << " (slot)";
915 }
886 } 916 }
887 917
888 os << "\n"; 918 os << "\n";
889 } 919 }
890 #endif // ENABLE_DISASSEMBLER 920 #endif // ENABLE_DISASSEMBLER
891 921
892 922
893 #ifdef VERIFY_HEAP 923 #ifdef VERIFY_HEAP
894 void RelocInfo::Verify(Isolate* isolate) { 924 void RelocInfo::Verify(Isolate* isolate) {
895 switch (rmode_) { 925 switch (rmode_) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 UNREACHABLE(); 969 UNREACHABLE();
940 break; 970 break;
941 case CODE_AGE_SEQUENCE: 971 case CODE_AGE_SEQUENCE:
942 DCHECK(Code::IsYoungSequence(isolate, pc_) || code_age_stub()->IsCode()); 972 DCHECK(Code::IsYoungSequence(isolate, pc_) || code_age_stub()->IsCode());
943 break; 973 break;
944 } 974 }
945 } 975 }
946 #endif // VERIFY_HEAP 976 #endif // VERIFY_HEAP
947 977
948 978
979 bool RelocInfo::DebugBreakIsConstructCall(intptr_t data) {
980 return data == static_cast<intptr_t>(kDebugBreakConstructCallSentinel);
981 }
982
983
984 bool RelocInfo::DebugBreakIsCall(intptr_t data) { return data >= 0; }
985
986
987 int RelocInfo::DebugBreakCallArgumentsCount(intptr_t data) {
988 DCHECK(DebugBreakIsCall(data));
989 return static_cast<int>(data);
990 }
991
992
949 // ----------------------------------------------------------------------------- 993 // -----------------------------------------------------------------------------
950 // Implementation of ExternalReference 994 // Implementation of ExternalReference
951 995
952 void ExternalReference::SetUp() { 996 void ExternalReference::SetUp() {
953 double_constants.min_int = kMinInt; 997 double_constants.min_int = kMinInt;
954 double_constants.one_half = 0.5; 998 double_constants.one_half = 0.5;
955 double_constants.minus_one_half = -0.5; 999 double_constants.minus_one_half = -0.5;
956 double_constants.the_hole_nan = bit_cast<double>(kHoleNanInt64); 1000 double_constants.the_hole_nan = bit_cast<double>(kHoleNanInt64);
957 double_constants.negative_infinity = -V8_INFINITY; 1001 double_constants.negative_infinity = -V8_INFINITY;
958 double_constants.uint32_bias = 1002 double_constants.uint32_bias =
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
1862 1906
1863 void Assembler::RecordJSReturn() { 1907 void Assembler::RecordJSReturn() {
1864 positions_recorder()->WriteRecordedPositions(); 1908 positions_recorder()->WriteRecordedPositions();
1865 EnsureSpace ensure_space(this); 1909 EnsureSpace ensure_space(this);
1866 RecordRelocInfo(RelocInfo::JS_RETURN); 1910 RecordRelocInfo(RelocInfo::JS_RETURN);
1867 } 1911 }
1868 1912
1869 1913
1870 void Assembler::RecordDebugBreakSlot() { 1914 void Assembler::RecordDebugBreakSlot() {
1871 EnsureSpace ensure_space(this); 1915 EnsureSpace ensure_space(this);
1872 RecordRelocInfo(RelocInfo::DEBUG_BREAK_SLOT); 1916 intptr_t data = static_cast<intptr_t>(RelocInfo::kDebugBreakNonCallSentinel);
1917 RecordRelocInfo(RelocInfo::DEBUG_BREAK_SLOT, data);
1873 } 1918 }
1874 1919
1875 1920
1921 void Assembler::RecordDebugBreakSlotForCall(int argc) {
1922 EnsureSpace ensure_space(this);
1923 intptr_t data = static_cast<intptr_t>(argc);
1924 RecordRelocInfo(RelocInfo::DEBUG_BREAK_SLOT, data);
1925 }
1926
1927
1928 void Assembler::RecordDebugBreakSlotForConstructCall() {
1929 EnsureSpace ensure_space(this);
1930 intptr_t data =
1931 static_cast<intptr_t>(RelocInfo::kDebugBreakConstructCallSentinel);
1932 RecordRelocInfo(RelocInfo::DEBUG_BREAK_SLOT, data);
1933 }
1934
1935
1876 void Assembler::DataAlign(int m) { 1936 void Assembler::DataAlign(int m) {
1877 DCHECK(m >= 2 && base::bits::IsPowerOfTwo32(m)); 1937 DCHECK(m >= 2 && base::bits::IsPowerOfTwo32(m));
1878 while ((pc_offset() & (m - 1)) != 0) { 1938 while ((pc_offset() & (m - 1)) != 0) {
1879 db(0); 1939 db(0);
1880 } 1940 }
1881 } 1941 }
1882 } // namespace internal 1942 } // namespace internal
1883 } // namespace v8 1943 } // namespace v8
OLDNEW
« no previous file with comments | « src/assembler.h ('k') | src/builtins.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698