OLD | NEW |
---|---|
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 TYPE_STRTAB = 3, | 194 TYPE_STRTAB = 3, |
195 TYPE_RELA = 4, | 195 TYPE_RELA = 4, |
196 TYPE_HASH = 5, | 196 TYPE_HASH = 5, |
197 TYPE_DYNAMIC = 6, | 197 TYPE_DYNAMIC = 6, |
198 TYPE_NOTE = 7, | 198 TYPE_NOTE = 7, |
199 TYPE_NOBITS = 8, | 199 TYPE_NOBITS = 8, |
200 TYPE_REL = 9, | 200 TYPE_REL = 9, |
201 TYPE_SHLIB = 10, | 201 TYPE_SHLIB = 10, |
202 TYPE_DYNSYM = 11, | 202 TYPE_DYNSYM = 11, |
203 TYPE_LOPROC = 0x70000000, | 203 TYPE_LOPROC = 0x70000000, |
204 TYPE_X86_64_UNWIND = 0x70000001, | |
204 TYPE_HIPROC = 0x7fffffff, | 205 TYPE_HIPROC = 0x7fffffff, |
205 TYPE_LOUSER = 0x80000000, | 206 TYPE_LOUSER = 0x80000000, |
206 TYPE_HIUSER = 0xffffffff | 207 TYPE_HIUSER = 0xffffffff |
207 }; | 208 }; |
208 | 209 |
209 enum Flags { | 210 enum Flags { |
210 FLAG_WRITE = 1, | 211 FLAG_WRITE = 1, |
211 FLAG_ALLOC = 2, | 212 FLAG_ALLOC = 2, |
212 FLAG_EXEC = 4 | 213 FLAG_EXEC = 4 |
213 }; | 214 }; |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
632 } | 633 } |
633 } | 634 } |
634 | 635 |
635 ZoneList<ELFSymbol> locals_; | 636 ZoneList<ELFSymbol> locals_; |
636 ZoneList<ELFSymbol> globals_; | 637 ZoneList<ELFSymbol> globals_; |
637 }; | 638 }; |
638 | 639 |
639 | 640 |
640 class CodeDescription BASE_EMBEDDED { | 641 class CodeDescription BASE_EMBEDDED { |
641 public: | 642 public: |
643 | |
644 #ifdef V8_TARGET_ARCH_X64 | |
645 enum OffsetType { | |
646 POST_RBP_PUSH, | |
647 POST_RBP_SET, | |
648 POST_RBP_POP, | |
649 OFFSET_TYPE_MAX | |
650 }; | |
651 #endif | |
652 | |
642 CodeDescription(const char* name, | 653 CodeDescription(const char* name, |
643 Code* code, | 654 Code* code, |
644 Handle<Script> script, | 655 Handle<Script> script, |
645 GDBJITLineInfo* lineinfo) | 656 GDBJITLineInfo* lineinfo, |
646 : name_(name), code_(code), script_(script), lineinfo_(lineinfo) | 657 GDBJITInterface::CodeTag tag) |
658 : name_(name), | |
659 code_(code), | |
660 script_(script), | |
661 lineinfo_(lineinfo), | |
662 tag_(tag) | |
647 { } | 663 { } |
648 | 664 |
649 const char* code_name() const { | 665 const char* code_name() const { |
650 return name_; | 666 return name_; |
651 } | 667 } |
652 | 668 |
653 uintptr_t code_size() const { | 669 uintptr_t code_size() const { |
654 return code_->instruction_end() - code_->instruction_start(); | 670 return code_->instruction_end() - code_->instruction_start(); |
655 } | 671 } |
656 | 672 |
673 uintptr_t code_end() const { | |
674 return (uintptr_t)code_->instruction_end(); | |
675 } | |
676 | |
657 uintptr_t code_start() const { | 677 uintptr_t code_start() const { |
658 return (uintptr_t)code_->instruction_start(); | 678 return (uintptr_t)code_->instruction_start(); |
659 } | 679 } |
660 | 680 |
661 bool is_line_info_available() { | 681 bool is_line_info_available() { |
662 return !script_.is_null() && | 682 return !script_.is_null() && |
663 script_->source()->IsString() && | 683 script_->source()->IsString() && |
664 script_->HasValidSource() && | 684 script_->HasValidSource() && |
665 script_->name()->IsString() && | 685 script_->name()->IsString() && |
666 lineinfo_ != NULL; | 686 lineinfo_ != NULL; |
667 } | 687 } |
668 | 688 |
689 #ifdef V8_TARGET_ARCH_X64 | |
690 uintptr_t get_location(OffsetType ofs) const { | |
691 ASSERT(ofs < OFFSET_TYPE_MAX); | |
692 return offsets_[ofs]; | |
693 } | |
694 | |
695 void set_location(OffsetType ofs, uintptr_t value) { | |
696 ASSERT(ofs < OFFSET_TYPE_MAX); | |
697 offsets_[ofs] = value; | |
698 } | |
699 #endif | |
700 | |
669 GDBJITLineInfo* lineinfo() const { return lineinfo_; } | 701 GDBJITLineInfo* lineinfo() const { return lineinfo_; } |
670 | 702 |
671 SmartPointer<char> filename() { | 703 SmartPointer<char> filename() { |
672 return String::cast(script_->name())->ToCString(); | 704 return String::cast(script_->name())->ToCString(); |
673 } | 705 } |
674 | 706 |
675 int GetScriptLineNumber(int pos) { | 707 int GetScriptLineNumber(int pos) { |
676 return GetScriptLineNumberSafe(script_, pos) + 1; | 708 return GetScriptLineNumberSafe(script_, pos) + 1; |
677 } | 709 } |
678 | 710 |
711 GDBJITInterface::CodeTag get_tag() const { | |
Vyacheslav Egorov (Chromium)
2011/02/01 21:00:25
Getters don't have get_ prefix in Google C++ Code
| |
712 return tag_; | |
713 } | |
714 | |
679 private: | 715 private: |
680 const char* name_; | 716 const char* name_; |
681 Code* code_; | 717 Code* code_; |
682 Handle<Script> script_; | 718 Handle<Script> script_; |
683 GDBJITLineInfo* lineinfo_; | 719 GDBJITLineInfo* lineinfo_; |
720 GDBJITInterface::CodeTag tag_; | |
721 #ifdef V8_TARGET_ARCH_X64 | |
722 uintptr_t offsets_[OFFSET_TYPE_MAX]; | |
723 #endif | |
684 }; | 724 }; |
685 | 725 |
686 | 726 |
687 static void CreateSymbolsTable(CodeDescription* desc, | 727 static void CreateSymbolsTable(CodeDescription* desc, |
688 ELF* elf, | 728 ELF* elf, |
689 int text_section_index) { | 729 int text_section_index) { |
690 ELFSymbolTable* symtab = new ELFSymbolTable(".symtab"); | 730 ELFSymbolTable* symtab = new ELFSymbolTable(".symtab"); |
691 StringTable* strtab = new StringTable(".strtab"); | 731 StringTable* strtab = new StringTable(".strtab"); |
692 | 732 |
693 // Symbol table should be followed by the linked string table. | 733 // Symbol table should be followed by the linked string table. |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
893 return +1; | 933 return +1; |
894 } else { | 934 } else { |
895 return -1; | 935 return -1; |
896 } | 936 } |
897 } | 937 } |
898 | 938 |
899 CodeDescription* desc_; | 939 CodeDescription* desc_; |
900 }; | 940 }; |
901 | 941 |
902 | 942 |
943 #ifdef V8_TARGET_ARCH_X64 | |
944 | |
945 | |
946 class UnwindInfoSection : public ELFSection { | |
947 public: | |
948 explicit UnwindInfoSection(CodeDescription *desc); | |
949 virtual bool WriteBody(Writer *w); | |
950 | |
951 int WriteCIE(Writer *w); | |
952 void WriteFDE(Writer *w, int); | |
953 | |
954 void WriteFDEStateOne(Writer *w); | |
955 void WriteFDEStateTwo(Writer *w); | |
956 void WriteFDEStateThree(Writer *w); | |
957 void WriteFDEStateFour(Writer *w); | |
958 | |
959 void WriteLength(Writer *w, Writer::Slot<uint32_t> &, int); | |
960 | |
961 private: | |
962 CodeDescription *desc_; | |
963 | |
964 // DWARF3 Specification, Table 7.23 | |
965 enum CFIInstructions { | |
966 DW_CFA_ADVANCE_LOC = 0X40, | |
967 DW_CFA_OFFSET = 0X80, | |
968 DW_CFA_RESTORE = 0XC0, | |
969 DW_CFA_NOP = 0X00, | |
970 DW_CFA_SET_LOC = 0X01, | |
971 DW_CFA_ADVANCE_LOC1 = 0X02, | |
972 DW_CFA_ADVANCE_LOC2 = 0X03, | |
973 DW_CFA_ADVANCE_LOC4 = 0X04, | |
974 DW_CFA_OFFSET_EXTENDED = 0X05, | |
975 DW_CFA_RESTORE_EXTENDED = 0X06, | |
976 DW_CFA_UNDEFINED = 0X07, | |
977 DW_CFA_SAME_VALUE = 0X08, | |
978 DW_CFA_REGISTER = 0X09, | |
979 DW_CFA_REMEMBER_STATE = 0X0A, | |
980 DW_CFA_RESTORE_STATE = 0X0B, | |
981 DW_CFA_DEF_CFA = 0X0C, | |
982 DW_CFA_DEF_CFA_REGISTER = 0X0D, | |
983 DW_CFA_DEF_CFA_OFFSET = 0X0E, | |
984 | |
985 DW_CFA_DEF_CFA_EXPRESSION = 0X0F, | |
986 DW_CFA_EXPRESSION = 0X10, | |
987 DW_CFA_OFFSET_EXTENDED_SF = 0X11, | |
988 DW_CFA_DEF_CFA_SF = 0X12, | |
989 DW_CFA_DEF_CFA_OFFSET_SF = 0X13, | |
990 DW_CFA_VAL_OFFSET = 0X14, | |
991 DW_CFA_VAL_OFFSET_SF = 0X15, | |
992 DW_CFA_VAL_EXPRESSION = 0X16 | |
993 }; | |
994 | |
995 // System V ABI, AMD64 Supplement, Version 0.99.5, Figure 3.36 | |
996 enum RegisterMapping { | |
997 // Only the relevant ones have been added to reduce clutter. | |
998 AMD64_RBP = 6, | |
999 AMD64_RSP = 7, | |
1000 AMD64_RA = 16 | |
1001 }; | |
1002 | |
1003 enum CFIConstants { | |
1004 CIE_ID = 0, | |
1005 CIE_VERSION = 1, | |
1006 CODE_ALIGN_FACTOR = 1, | |
1007 DATA_ALIGN_FACTOR = 1, | |
1008 RETURN_ADDRESS_REGISTER = AMD64_RA | |
1009 }; | |
1010 }; | |
1011 | |
1012 | |
1013 void UnwindInfoSection::WriteLength(Writer *w, | |
1014 Writer::Slot<uint32_t> &length_slot, | |
1015 int initial_position) { | |
1016 uint32_t align = (w->position() - initial_position) % kPointerSize; | |
1017 | |
1018 if (align != 0) { | |
1019 for (uint32_t i = 0; i < (kPointerSize - align); i++) | |
1020 w->Write<uint8_t>(DW_CFA_NOP); | |
1021 } | |
1022 | |
1023 ASSERT((w->position() - initial_position) % kPointerSize == 0); | |
1024 length_slot.set(w->position() - initial_position); | |
1025 } | |
1026 | |
1027 | |
1028 UnwindInfoSection::UnwindInfoSection(CodeDescription *desc) | |
1029 : ELFSection(".eh_frame", TYPE_X86_64_UNWIND, 1), desc_(desc) | |
1030 { } | |
1031 | |
1032 int UnwindInfoSection::WriteCIE(Writer *w) { | |
1033 Writer::Slot<uint32_t> cie_length_slot = w->CreateSlotHere<uint32_t>(); | |
1034 uint32_t cie_position = w->position(); | |
1035 | |
1036 // Write out the CIE header. Currently no 'common instructions' are | |
1037 // emitted onto the CIE; every FDE has its own set of instructions. | |
1038 | |
1039 w->Write<uint32_t>(CIE_ID); | |
1040 w->Write<uint8_t>(CIE_VERSION); | |
1041 w->Write<uint8_t>(0); // Null augmentation string. | |
1042 w->WriteSLEB128(CODE_ALIGN_FACTOR); | |
1043 w->WriteSLEB128(DATA_ALIGN_FACTOR); | |
1044 w->Write<uint8_t>(RETURN_ADDRESS_REGISTER); | |
1045 | |
1046 WriteLength(w, cie_length_slot, cie_position); | |
1047 | |
1048 return cie_position; | |
1049 } | |
1050 | |
1051 | |
1052 void UnwindInfoSection::WriteFDE(Writer *w, int cie_position) { | |
1053 // The only FDE for this function. The CFA is the current RBP. | |
1054 Writer::Slot<uint32_t> fde_length_slot = w->CreateSlotHere<uint32_t>(); | |
1055 int fde_position = w->position(); | |
1056 w->Write<int32_t>(fde_position - cie_position + 4); | |
1057 | |
1058 w->Write<uintptr_t>(desc_->code_start()); | |
1059 w->Write<uintptr_t>(desc_->code_size()); | |
1060 | |
1061 WriteFDEStateOne(w); | |
Vyacheslav Egorov (Chromium)
2011/02/01 21:00:25
This names are not informative.
| |
1062 WriteFDEStateTwo(w); | |
1063 WriteFDEStateThree(w); | |
1064 WriteFDEStateFour(w); | |
1065 | |
1066 WriteLength(w, fde_length_slot, fde_position); | |
1067 } | |
1068 | |
1069 | |
1070 void UnwindInfoSection::WriteFDEStateOne(Writer *w) { | |
1071 // The first state, just after the control has been transferred to the the | |
1072 // function. | |
1073 | |
1074 // RBP for this function will be the value of RSP after pushing the RBP | |
1075 // for the previous function. The previous RBP has not been pushed yet. | |
1076 w->Write<uint8_t>(DW_CFA_DEF_CFA_SF); | |
1077 w->WriteULEB128(AMD64_RSP); | |
1078 w->WriteSLEB128(-kPointerSize); | |
1079 | |
1080 // The RA is stored at location CFA + kCallerPCOffset. This is an invariant, | |
1081 // and hence omitted from the next states. | |
1082 w->Write<uint8_t>(DW_CFA_OFFSET_EXTENDED); | |
1083 w->WriteULEB128(AMD64_RA); | |
1084 w->WriteSLEB128(StandardFrameConstants::kCallerPCOffset); | |
1085 | |
1086 // The RBP of the previous function is still in RBP. | |
1087 w->Write<uint8_t>(DW_CFA_SAME_VALUE); | |
1088 w->WriteULEB128(AMD64_RBP); | |
1089 | |
1090 // Last location described by this entry. | |
1091 w->Write<uint8_t>(DW_CFA_SET_LOC); | |
1092 w->Write<uint64_t>(desc_->get_location(CodeDescription::POST_RBP_PUSH)); | |
1093 } | |
1094 | |
1095 | |
1096 void UnwindInfoSection::WriteFDEStateTwo(Writer *w) { | |
1097 // The second state, just after RBP has been pushed. | |
1098 | |
1099 // RBP / CFA for this function is now the current RSP, so just set the | |
1100 // offset from the previous rule (from -8) to 0. | |
1101 w->Write<uint8_t>(DW_CFA_DEF_CFA_OFFSET); | |
1102 w->WriteULEB128(0); | |
1103 | |
1104 // The previous RBP is stored at CFA + kCallerFPOffset. This is an invariant | |
1105 // in this and the next state, and hence omitted in the next state. | |
1106 w->Write<uint8_t>(DW_CFA_OFFSET_EXTENDED); | |
1107 w->WriteULEB128(AMD64_RBP); | |
1108 w->WriteSLEB128(StandardFrameConstants::kCallerFPOffset); | |
1109 | |
1110 // Last location described by this entry. | |
1111 w->Write<uint8_t>(DW_CFA_SET_LOC); | |
1112 w->Write<uint64_t>(desc_->get_location(CodeDescription::POST_RBP_SET)); | |
1113 } | |
1114 | |
1115 | |
1116 void UnwindInfoSection::WriteFDEStateThree(Writer *w) { | |
1117 // The third state, after the RBP has been set. | |
1118 | |
1119 // The CFA can now directly be set to RBP. | |
1120 w->Write<uint8_t>(DW_CFA_DEF_CFA); | |
1121 w->WriteULEB128(AMD64_RBP); | |
1122 w->WriteULEB128(0); | |
1123 | |
1124 // Last location described by this entry. | |
1125 w->Write<uint8_t>(DW_CFA_SET_LOC); | |
1126 w->Write<uint64_t>(desc_->get_location(CodeDescription::POST_RBP_POP)); | |
1127 } | |
1128 | |
1129 | |
1130 void UnwindInfoSection::WriteFDEStateFour(Writer *w) { | |
1131 // The fourth (final) state. The RBP has been popped (just before issuing a | |
1132 // return). | |
1133 | |
1134 // The CFA can is now calculated in the same way as in the first state. | |
1135 w->Write<uint8_t>(DW_CFA_DEF_CFA_SF); | |
1136 w->WriteULEB128(AMD64_RSP); | |
1137 w->WriteSLEB128(-kPointerSize); | |
1138 | |
1139 // The RBP | |
1140 w->Write<uint8_t>(DW_CFA_OFFSET_EXTENDED); | |
1141 w->WriteULEB128(AMD64_RBP); | |
1142 w->WriteSLEB128(StandardFrameConstants::kCallerFPOffset); | |
1143 | |
1144 // Last location described by this entry. | |
1145 w->Write<uint8_t>(DW_CFA_SET_LOC); | |
1146 w->Write<uint64_t>(desc_->code_end()); | |
1147 } | |
1148 | |
1149 | |
1150 bool UnwindInfoSection::WriteBody(Writer *w) { | |
1151 uint32_t cie_position = WriteCIE(w); | |
1152 WriteFDE(w, cie_position); | |
1153 return true; | |
1154 } | |
1155 | |
1156 | |
1157 #endif // V8_TARGET_ARCH_X64 | |
1158 | |
1159 | |
903 static void CreateDWARFSections(CodeDescription* desc, ELF* elf) { | 1160 static void CreateDWARFSections(CodeDescription* desc, ELF* elf) { |
904 if (desc->is_line_info_available()) { | 1161 if (desc->is_line_info_available()) { |
905 elf->AddSection(new DebugInfoSection(desc)); | 1162 elf->AddSection(new DebugInfoSection(desc)); |
906 elf->AddSection(new DebugAbbrevSection); | 1163 elf->AddSection(new DebugAbbrevSection); |
907 elf->AddSection(new DebugLineSection(desc)); | 1164 elf->AddSection(new DebugLineSection(desc)); |
908 } | 1165 } |
909 } | 1166 #ifdef V8_TARGET_ARCH_X64 |
910 | 1167 elf->AddSection(new UnwindInfoSection(desc)); |
911 | 1168 #endif |
1169 } | |
1170 | |
1171 | |
912 // ------------------------------------------------------------------- | 1172 // ------------------------------------------------------------------- |
913 // Binary GDB JIT Interface as described in | 1173 // Binary GDB JIT Interface as described in |
914 // http://sourceware.org/gdb/onlinedocs/gdb/Declarations.html | 1174 // http://sourceware.org/gdb/onlinedocs/gdb/Declarations.html |
915 extern "C" { | 1175 extern "C" { |
916 typedef enum { | 1176 typedef enum { |
917 JIT_NOACTION = 0, | 1177 JIT_NOACTION = 0, |
918 JIT_REGISTER_FN, | 1178 JIT_REGISTER_FN, |
919 JIT_UNREGISTER_FN | 1179 JIT_UNREGISTER_FN |
920 } JITAction; | 1180 } JITAction; |
921 | 1181 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1058 void GDBJITInterface::AddCode(Handle<String> name, | 1318 void GDBJITInterface::AddCode(Handle<String> name, |
1059 Handle<Script> script, | 1319 Handle<Script> script, |
1060 Handle<Code> code) { | 1320 Handle<Code> code) { |
1061 if (!FLAG_gdbjit) return; | 1321 if (!FLAG_gdbjit) return; |
1062 | 1322 |
1063 // Force initialization of line_ends array. | 1323 // Force initialization of line_ends array. |
1064 GetScriptLineNumber(script, 0); | 1324 GetScriptLineNumber(script, 0); |
1065 | 1325 |
1066 if (!name.is_null()) { | 1326 if (!name.is_null()) { |
1067 SmartPointer<char> name_cstring = name->ToCString(DISALLOW_NULLS); | 1327 SmartPointer<char> name_cstring = name->ToCString(DISALLOW_NULLS); |
1068 AddCode(*name_cstring, *code, *script); | 1328 AddCode(*name_cstring, *code, GDBJITInterface::FUNCTION, *script); |
1069 } else { | 1329 } else { |
1070 AddCode("", *code, *script); | 1330 AddCode("", *code, GDBJITInterface::FUNCTION, *script); |
1071 } | 1331 } |
1072 } | 1332 } |
1073 | 1333 |
1334 static const int kFramePointerPushOffset = 1; | |
1335 static const int kFramePointerSetOffset = 4; | |
1336 static const int kFramePointerPopOffset = -3; | |
1337 | |
1338 static void AddUnwindInfo(CodeDescription *cd) { | |
1339 #ifdef V8_TARGET_ARCH_X64 | |
1340 if (cd->get_tag() == GDBJITInterface::FUNCTION) { | |
1341 | |
Vyacheslav Egorov (Chromium)
2011/02/01 21:00:25
This does not lint (did you run tools/presubmit.py
| |
1342 { | |
1343 // Sanity check | |
1344 byte *code = reinterpret_cast<byte*>(cd->code_start()); | |
Vyacheslav Egorov (Chromium)
2011/02/01 21:00:25
This will fail to compile in release mode (due to
| |
1345 ASSERT(code[kFramePointerSetOffset] == 0x56); | |
1346 ASSERT(code[kFramePointerSetOffset + 1] == 0x57); | |
1347 ASSERT(code[kFramePointerPushOffset] == 0x48); | |
1348 ASSERT(code[kFramePointerPopOffset] == 0xBE); | |
1349 } | |
1350 | |
1351 cd->set_location(CodeDescription::POST_RBP_PUSH, | |
1352 cd->code_start() + kFramePointerPushOffset); | |
1353 cd->set_location(CodeDescription::POST_RBP_SET, | |
1354 cd->code_start() + kFramePointerSetOffset); | |
1355 cd->set_location(CodeDescription::POST_RBP_POP, | |
1356 cd->code_end() + kFramePointerPopOffset); | |
1357 } else { | |
1358 cd->set_location(CodeDescription::POST_RBP_PUSH, cd->code_start()); | |
1359 cd->set_location(CodeDescription::POST_RBP_SET, cd->code_start()); | |
1360 cd->set_location(CodeDescription::POST_RBP_POP, cd->code_end()); | |
1361 } | |
1362 #endif // V8_TARGET_ARCH_X64 | |
1363 } | |
1364 | |
1074 | 1365 |
1075 void GDBJITInterface::AddCode(const char* name, | 1366 void GDBJITInterface::AddCode(const char* name, |
1076 Code* code, | 1367 Code* code, |
1368 GDBJITInterface::CodeTag tag, | |
1077 Script* script) { | 1369 Script* script) { |
1078 if (!FLAG_gdbjit) return; | 1370 if (!FLAG_gdbjit) return; |
1079 AssertNoAllocation no_gc; | 1371 AssertNoAllocation no_gc; |
1080 | 1372 |
1081 HashMap::Entry* e = entries.Lookup(code, HashForCodeObject(code), true); | 1373 HashMap::Entry* e = entries.Lookup(code, HashForCodeObject(code), true); |
1082 if (e->value != NULL && !IsLineInfoTagged(e->value)) return; | 1374 if (e->value != NULL && !IsLineInfoTagged(e->value)) return; |
1083 | 1375 |
1084 GDBJITLineInfo* lineinfo = UntagLineInfo(e->value); | 1376 GDBJITLineInfo* lineinfo = UntagLineInfo(e->value); |
1085 CodeDescription code_desc(name, | 1377 CodeDescription code_desc(name, |
1086 code, | 1378 code, |
1087 script != NULL ? Handle<Script>(script) | 1379 script != NULL ? Handle<Script>(script) |
1088 : Handle<Script>(), | 1380 : Handle<Script>(), |
1089 lineinfo); | 1381 lineinfo, |
1382 tag); | |
1090 | 1383 |
1091 if (!FLAG_gdbjit_full && !code_desc.is_line_info_available()) { | 1384 if (!FLAG_gdbjit_full && !code_desc.is_line_info_available()) { |
1092 delete lineinfo; | 1385 delete lineinfo; |
1093 entries.Remove(code, HashForCodeObject(code)); | 1386 entries.Remove(code, HashForCodeObject(code)); |
1094 return; | 1387 return; |
1095 } | 1388 } |
1096 | 1389 |
1390 AddUnwindInfo(&code_desc); | |
1097 JITCodeEntry* entry = CreateELFObject(&code_desc); | 1391 JITCodeEntry* entry = CreateELFObject(&code_desc); |
1098 ASSERT(!IsLineInfoTagged(entry)); | 1392 ASSERT(!IsLineInfoTagged(entry)); |
1099 | 1393 |
1100 delete lineinfo; | 1394 delete lineinfo; |
1101 e->value = entry; | 1395 e->value = entry; |
1102 | 1396 |
1103 RegisterCodeEntry(entry); | 1397 RegisterCodeEntry(entry); |
1104 } | 1398 } |
1105 | 1399 |
1106 | 1400 |
1107 void GDBJITInterface::AddCode(GDBJITInterface::CodeTag tag, | 1401 void GDBJITInterface::AddCode(GDBJITInterface::CodeTag tag, |
1108 const char* name, | 1402 const char* name, |
1109 Code* code) { | 1403 Code* code) { |
1110 if (!FLAG_gdbjit) return; | 1404 if (!FLAG_gdbjit) return; |
1111 | 1405 |
1112 EmbeddedVector<char, 256> buffer; | 1406 EmbeddedVector<char, 256> buffer; |
1113 StringBuilder builder(buffer.start(), buffer.length()); | 1407 StringBuilder builder(buffer.start(), buffer.length()); |
1114 | 1408 |
1115 builder.AddString(Tag2String(tag)); | 1409 builder.AddString(Tag2String(tag)); |
1116 if ((name != NULL) && (*name != '\0')) { | 1410 if ((name != NULL) && (*name != '\0')) { |
1117 builder.AddString(": "); | 1411 builder.AddString(": "); |
1118 builder.AddString(name); | 1412 builder.AddString(name); |
1119 } else { | 1413 } else { |
1120 builder.AddFormatted(": code object %p", static_cast<void*>(code)); | 1414 builder.AddFormatted(": code object %p", static_cast<void*>(code)); |
1121 } | 1415 } |
1122 | 1416 |
1123 AddCode(builder.Finalize(), code); | 1417 AddCode(builder.Finalize(), code, tag); |
1124 } | 1418 } |
1125 | 1419 |
1126 | 1420 |
1127 void GDBJITInterface::AddCode(GDBJITInterface::CodeTag tag, | 1421 void GDBJITInterface::AddCode(GDBJITInterface::CodeTag tag, |
1128 String* name, | 1422 String* name, |
1129 Code* code) { | 1423 Code* code) { |
1130 if (!FLAG_gdbjit) return; | 1424 if (!FLAG_gdbjit) return; |
1131 AddCode(tag, name != NULL ? *name->ToCString(DISALLOW_NULLS) : NULL, code); | 1425 AddCode(tag, name != NULL ? *name->ToCString(DISALLOW_NULLS) : NULL, code); |
1132 } | 1426 } |
1133 | 1427 |
(...skipping 27 matching lines...) Expand all Loading... | |
1161 GDBJITLineInfo* line_info) { | 1455 GDBJITLineInfo* line_info) { |
1162 ASSERT(!IsLineInfoTagged(line_info)); | 1456 ASSERT(!IsLineInfoTagged(line_info)); |
1163 HashMap::Entry* e = entries.Lookup(code, HashForCodeObject(code), true); | 1457 HashMap::Entry* e = entries.Lookup(code, HashForCodeObject(code), true); |
1164 ASSERT(e->value == NULL); | 1458 ASSERT(e->value == NULL); |
1165 e->value = TagLineInfo(line_info); | 1459 e->value = TagLineInfo(line_info); |
1166 } | 1460 } |
1167 | 1461 |
1168 | 1462 |
1169 } } // namespace v8::internal | 1463 } } // namespace v8::internal |
1170 #endif | 1464 #endif |
OLD | NEW |