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 13 matching lines...) Expand all Loading... |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #ifdef ENABLE_GDB_JIT_INTERFACE | 28 #ifdef ENABLE_GDB_JIT_INTERFACE |
29 #include "v8.h" | 29 #include "v8.h" |
30 #include "gdb-jit.h" | 30 #include "gdb-jit.h" |
31 | 31 |
32 #include "bootstrapper.h" | 32 #include "bootstrapper.h" |
33 #include "compiler.h" | 33 #include "compiler.h" |
| 34 #include "frames.h" |
| 35 #include "frames-inl.h" |
34 #include "global-handles.h" | 36 #include "global-handles.h" |
35 #include "messages.h" | 37 #include "messages.h" |
| 38 #include "natives.h" |
36 #include "platform.h" | 39 #include "platform.h" |
37 #include "natives.h" | 40 #include "scopes.h" |
38 #include "scopeinfo.h" | |
39 | 41 |
40 namespace v8 { | 42 namespace v8 { |
41 namespace internal { | 43 namespace internal { |
42 | 44 |
43 #ifdef __APPLE__ | 45 #ifdef __APPLE__ |
44 #define __MACH_O | 46 #define __MACH_O |
45 class MachO; | 47 class MachO; |
46 class MachOSection; | 48 class MachOSection; |
47 typedef MachO DebugObject; | 49 typedef MachO DebugObject; |
48 typedef MachOSection DebugSection; | 50 typedef MachOSection DebugSection; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 189 |
188 class StringTable; | 190 class StringTable; |
189 | 191 |
190 template<typename THeader> | 192 template<typename THeader> |
191 class DebugSectionBase : public ZoneObject { | 193 class DebugSectionBase : public ZoneObject { |
192 public: | 194 public: |
193 virtual ~DebugSectionBase() { } | 195 virtual ~DebugSectionBase() { } |
194 | 196 |
195 virtual void WriteBody(Writer::Slot<THeader> header, Writer* writer) { | 197 virtual void WriteBody(Writer::Slot<THeader> header, Writer* writer) { |
196 uintptr_t start = writer->position(); | 198 uintptr_t start = writer->position(); |
197 if (WriteBody(writer)) { | 199 if (WriteBodyInternal(writer)) { |
198 uintptr_t end = writer->position(); | 200 uintptr_t end = writer->position(); |
199 header->offset = start; | 201 header->offset = start; |
200 #if defined(__MACH_O) | 202 #if defined(__MACH_O) |
201 header->addr = 0; | 203 header->addr = 0; |
202 #endif | 204 #endif |
203 header->size = end - start; | 205 header->size = end - start; |
204 } | 206 } |
205 } | 207 } |
206 | 208 |
207 virtual bool WriteBody(Writer* writer) { | 209 virtual bool WriteBodyInternal(Writer* writer) { |
208 return false; | 210 return false; |
209 } | 211 } |
210 | 212 |
211 typedef THeader Header; | 213 typedef THeader Header; |
212 }; | 214 }; |
213 | 215 |
214 | 216 |
215 struct MachOSectionHeader { | 217 struct MachOSectionHeader { |
216 char sectname[16]; | 218 char sectname[16]; |
217 char segname[16]; | 219 char segname[16]; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 | 335 |
334 ELFSection(const char* name, Type type, uintptr_t align) | 336 ELFSection(const char* name, Type type, uintptr_t align) |
335 : name_(name), type_(type), align_(align) { } | 337 : name_(name), type_(type), align_(align) { } |
336 | 338 |
337 virtual ~ELFSection() { } | 339 virtual ~ELFSection() { } |
338 | 340 |
339 void PopulateHeader(Writer::Slot<Header> header, StringTable* strtab); | 341 void PopulateHeader(Writer::Slot<Header> header, StringTable* strtab); |
340 | 342 |
341 virtual void WriteBody(Writer::Slot<Header> header, Writer* w) { | 343 virtual void WriteBody(Writer::Slot<Header> header, Writer* w) { |
342 uintptr_t start = w->position(); | 344 uintptr_t start = w->position(); |
343 if (WriteBody(w)) { | 345 if (WriteBodyInternal(w)) { |
344 uintptr_t end = w->position(); | 346 uintptr_t end = w->position(); |
345 header->offset = start; | 347 header->offset = start; |
346 header->size = end - start; | 348 header->size = end - start; |
347 } | 349 } |
348 } | 350 } |
349 | 351 |
350 virtual bool WriteBody(Writer* w) { | 352 virtual bool WriteBodyInternal(Writer* w) { |
351 return false; | 353 return false; |
352 } | 354 } |
353 | 355 |
354 uint16_t index() const { return index_; } | 356 uint16_t index() const { return index_; } |
355 void set_index(uint16_t index) { index_ = index; } | 357 void set_index(uint16_t index) { index_ = index; } |
356 | 358 |
357 protected: | 359 protected: |
358 virtual void PopulateHeader(Writer::Slot<Header> header) { | 360 virtual void PopulateHeader(Writer::Slot<Header> header) { |
359 header->flags = 0; | 361 header->flags = 0; |
360 header->address = 0; | 362 header->address = 0; |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 | 622 |
621 | 623 |
622 ZoneList<MachOSection*> sections_; | 624 ZoneList<MachOSection*> sections_; |
623 }; | 625 }; |
624 #endif // defined(__MACH_O) | 626 #endif // defined(__MACH_O) |
625 | 627 |
626 | 628 |
627 #if defined(__ELF) | 629 #if defined(__ELF) |
628 class ELF BASE_EMBEDDED { | 630 class ELF BASE_EMBEDDED { |
629 public: | 631 public: |
630 ELF() : sections_(6) { | 632 ELF(Zone* zone) : sections_(6, zone) { |
631 sections_.Add(new ELFSection("", ELFSection::TYPE_NULL, 0)); | 633 sections_.Add(new(zone) ELFSection("", ELFSection::TYPE_NULL, 0), zone); |
632 sections_.Add(new StringTable(".shstrtab")); | 634 sections_.Add(new(zone) StringTable(".shstrtab"), zone); |
633 } | 635 } |
634 | 636 |
635 void Write(Writer* w) { | 637 void Write(Writer* w) { |
636 WriteHeader(w); | 638 WriteHeader(w); |
637 WriteSectionTable(w); | 639 WriteSectionTable(w); |
638 WriteSections(w); | 640 WriteSections(w); |
639 } | 641 } |
640 | 642 |
641 ELFSection* SectionAt(uint32_t index) { | 643 ELFSection* SectionAt(uint32_t index) { |
642 return sections_[index]; | 644 return sections_[index]; |
643 } | 645 } |
644 | 646 |
645 uint32_t AddSection(ELFSection* section) { | 647 uint32_t AddSection(ELFSection* section, Zone* zone) { |
646 sections_.Add(section); | 648 sections_.Add(section, zone); |
647 section->set_index(sections_.length() - 1); | 649 section->set_index(sections_.length() - 1); |
648 return sections_.length() - 1; | 650 return sections_.length() - 1; |
649 } | 651 } |
650 | 652 |
651 private: | 653 private: |
652 struct ELFHeader { | 654 struct ELFHeader { |
653 uint8_t ident[16]; | 655 uint8_t ident[16]; |
654 uint16_t type; | 656 uint16_t type; |
655 uint16_t machine; | 657 uint16_t machine; |
656 uint32_t version; | 658 uint32_t version; |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 uintptr_t value; | 847 uintptr_t value; |
846 uintptr_t size; | 848 uintptr_t size; |
847 uint8_t info; | 849 uint8_t info; |
848 uint8_t other; | 850 uint8_t other; |
849 uint16_t section; | 851 uint16_t section; |
850 }; | 852 }; |
851 | 853 |
852 | 854 |
853 class ELFSymbolTable : public ELFSection { | 855 class ELFSymbolTable : public ELFSection { |
854 public: | 856 public: |
855 explicit ELFSymbolTable(const char* name) | 857 ELFSymbolTable(const char* name, Zone* zone) |
856 : ELFSection(name, TYPE_SYMTAB, sizeof(uintptr_t)), | 858 : ELFSection(name, TYPE_SYMTAB, sizeof(uintptr_t)), |
857 locals_(1), | 859 locals_(1, zone), |
858 globals_(1) { | 860 globals_(1, zone) { |
859 } | 861 } |
860 | 862 |
861 virtual void WriteBody(Writer::Slot<Header> header, Writer* w) { | 863 virtual void WriteBody(Writer::Slot<Header> header, Writer* w) { |
862 w->Align(header->alignment); | 864 w->Align(header->alignment); |
863 int total_symbols = locals_.length() + globals_.length() + 1; | 865 int total_symbols = locals_.length() + globals_.length() + 1; |
864 header->offset = w->position(); | 866 header->offset = w->position(); |
865 | 867 |
866 Writer::Slot<ELFSymbol::SerializedLayout> symbols = | 868 Writer::Slot<ELFSymbol::SerializedLayout> symbols = |
867 w->CreateSlotsHere<ELFSymbol::SerializedLayout>(total_symbols); | 869 w->CreateSlotsHere<ELFSymbol::SerializedLayout>(total_symbols); |
868 | 870 |
869 header->size = w->position() - header->offset; | 871 header->size = w->position() - header->offset; |
870 | 872 |
871 // String table for this symbol table should follow it in the section table. | 873 // String table for this symbol table should follow it in the section table. |
872 StringTable* strtab = | 874 StringTable* strtab = |
873 static_cast<StringTable*>(w->debug_object()->SectionAt(index() + 1)); | 875 static_cast<StringTable*>(w->debug_object()->SectionAt(index() + 1)); |
874 strtab->AttachWriter(w); | 876 strtab->AttachWriter(w); |
875 symbols.at(0).set(ELFSymbol::SerializedLayout(0, | 877 symbols.at(0).set(ELFSymbol::SerializedLayout(0, |
876 0, | 878 0, |
877 0, | 879 0, |
878 ELFSymbol::BIND_LOCAL, | 880 ELFSymbol::BIND_LOCAL, |
879 ELFSymbol::TYPE_NOTYPE, | 881 ELFSymbol::TYPE_NOTYPE, |
880 0)); | 882 0)); |
881 WriteSymbolsList(&locals_, symbols.at(1), strtab); | 883 WriteSymbolsList(&locals_, symbols.at(1), strtab); |
882 WriteSymbolsList(&globals_, symbols.at(locals_.length() + 1), strtab); | 884 WriteSymbolsList(&globals_, symbols.at(locals_.length() + 1), strtab); |
883 strtab->DetachWriter(); | 885 strtab->DetachWriter(); |
884 } | 886 } |
885 | 887 |
886 void Add(const ELFSymbol& symbol) { | 888 void Add(const ELFSymbol& symbol, Zone* zone) { |
887 if (symbol.binding() == ELFSymbol::BIND_LOCAL) { | 889 if (symbol.binding() == ELFSymbol::BIND_LOCAL) { |
888 locals_.Add(symbol); | 890 locals_.Add(symbol, zone); |
889 } else { | 891 } else { |
890 globals_.Add(symbol); | 892 globals_.Add(symbol, zone); |
891 } | 893 } |
892 } | 894 } |
893 | 895 |
894 protected: | 896 protected: |
895 virtual void PopulateHeader(Writer::Slot<Header> header) { | 897 virtual void PopulateHeader(Writer::Slot<Header> header) { |
896 ELFSection::PopulateHeader(header); | 898 ELFSection::PopulateHeader(header); |
897 // We are assuming that string table will follow symbol table. | 899 // We are assuming that string table will follow symbol table. |
898 header->link = index() + 1; | 900 header->link = index() + 1; |
899 header->info = locals_.length() + 1; | 901 header->info = locals_.length() + 1; |
900 header->entry_size = sizeof(ELFSymbol::SerializedLayout); | 902 header->entry_size = sizeof(ELFSymbol::SerializedLayout); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 CompilationInfo* info_; | 1014 CompilationInfo* info_; |
1013 #ifdef V8_TARGET_ARCH_X64 | 1015 #ifdef V8_TARGET_ARCH_X64 |
1014 uintptr_t stack_state_start_addresses_[STACK_STATE_MAX]; | 1016 uintptr_t stack_state_start_addresses_[STACK_STATE_MAX]; |
1015 #endif | 1017 #endif |
1016 }; | 1018 }; |
1017 | 1019 |
1018 #if defined(__ELF) | 1020 #if defined(__ELF) |
1019 static void CreateSymbolsTable(CodeDescription* desc, | 1021 static void CreateSymbolsTable(CodeDescription* desc, |
1020 ELF* elf, | 1022 ELF* elf, |
1021 int text_section_index) { | 1023 int text_section_index) { |
1022 ELFSymbolTable* symtab = new ELFSymbolTable(".symtab"); | 1024 Zone* zone = desc->info()->zone(); |
1023 StringTable* strtab = new StringTable(".strtab"); | 1025 ELFSymbolTable* symtab = new(zone) ELFSymbolTable(".symtab", zone); |
| 1026 StringTable* strtab = new(zone) StringTable(".strtab"); |
1024 | 1027 |
1025 // Symbol table should be followed by the linked string table. | 1028 // Symbol table should be followed by the linked string table. |
1026 elf->AddSection(symtab); | 1029 elf->AddSection(symtab, zone); |
1027 elf->AddSection(strtab); | 1030 elf->AddSection(strtab, zone); |
1028 | 1031 |
1029 symtab->Add(ELFSymbol("V8 Code", | 1032 symtab->Add(ELFSymbol("V8 Code", |
1030 0, | 1033 0, |
1031 0, | 1034 0, |
1032 ELFSymbol::BIND_LOCAL, | 1035 ELFSymbol::BIND_LOCAL, |
1033 ELFSymbol::TYPE_FILE, | 1036 ELFSymbol::TYPE_FILE, |
1034 ELFSection::INDEX_ABSOLUTE)); | 1037 ELFSection::INDEX_ABSOLUTE), |
| 1038 zone); |
1035 | 1039 |
1036 symtab->Add(ELFSymbol(desc->name(), | 1040 symtab->Add(ELFSymbol(desc->name(), |
1037 0, | 1041 0, |
1038 desc->CodeSize(), | 1042 desc->CodeSize(), |
1039 ELFSymbol::BIND_GLOBAL, | 1043 ELFSymbol::BIND_GLOBAL, |
1040 ELFSymbol::TYPE_FUNC, | 1044 ELFSymbol::TYPE_FUNC, |
1041 text_section_index)); | 1045 text_section_index), |
| 1046 zone); |
1042 } | 1047 } |
1043 #endif // defined(__ELF) | 1048 #endif // defined(__ELF) |
1044 | 1049 |
1045 | 1050 |
1046 class DebugInfoSection : public DebugSection { | 1051 class DebugInfoSection : public DebugSection { |
1047 public: | 1052 public: |
1048 explicit DebugInfoSection(CodeDescription* desc) | 1053 explicit DebugInfoSection(CodeDescription* desc) |
1049 #if defined(__ELF) | 1054 #if defined(__ELF) |
1050 : ELFSection(".debug_info", TYPE_PROGBITS, 1), | 1055 : ELFSection(".debug_info", TYPE_PROGBITS, 1), |
1051 #else | 1056 #else |
(...skipping 15 matching lines...) Expand all Loading... |
1067 DW_OP_reg6 = 0x56, | 1072 DW_OP_reg6 = 0x56, |
1068 DW_OP_reg7 = 0x57, | 1073 DW_OP_reg7 = 0x57, |
1069 DW_OP_fbreg = 0x91 // 1 param: SLEB128 offset | 1074 DW_OP_fbreg = 0x91 // 1 param: SLEB128 offset |
1070 }; | 1075 }; |
1071 | 1076 |
1072 enum DWARF2Encoding { | 1077 enum DWARF2Encoding { |
1073 DW_ATE_ADDRESS = 0x1, | 1078 DW_ATE_ADDRESS = 0x1, |
1074 DW_ATE_SIGNED = 0x5 | 1079 DW_ATE_SIGNED = 0x5 |
1075 }; | 1080 }; |
1076 | 1081 |
1077 bool WriteBody(Writer* w) { | 1082 bool WriteBodyInternal(Writer* w) { |
1078 uintptr_t cu_start = w->position(); | 1083 uintptr_t cu_start = w->position(); |
1079 Writer::Slot<uint32_t> size = w->CreateSlotHere<uint32_t>(); | 1084 Writer::Slot<uint32_t> size = w->CreateSlotHere<uint32_t>(); |
1080 uintptr_t start = w->position(); | 1085 uintptr_t start = w->position(); |
1081 w->Write<uint16_t>(2); // DWARF version. | 1086 w->Write<uint16_t>(2); // DWARF version. |
1082 w->Write<uint32_t>(0); // Abbreviation table offset. | 1087 w->Write<uint32_t>(0); // Abbreviation table offset. |
1083 w->Write<uint8_t>(sizeof(intptr_t)); | 1088 w->Write<uint8_t>(sizeof(intptr_t)); |
1084 | 1089 |
1085 w->WriteULEB128(1); // Abbreviation code. | 1090 w->WriteULEB128(1); // Abbreviation code. |
1086 w->WriteString(*desc_->GetFilename()); | 1091 w->WriteString(*desc_->GetFilename()); |
1087 w->Write<intptr_t>(desc_->CodeStart()); | 1092 w->Write<intptr_t>(desc_->CodeStart()); |
1088 w->Write<intptr_t>(desc_->CodeStart() + desc_->CodeSize()); | 1093 w->Write<intptr_t>(desc_->CodeStart() + desc_->CodeSize()); |
1089 w->Write<uint32_t>(0); | 1094 w->Write<uint32_t>(0); |
1090 | 1095 |
1091 uint32_t ty_offset = static_cast<uint32_t>(w->position() - cu_start); | 1096 uint32_t ty_offset = static_cast<uint32_t>(w->position() - cu_start); |
1092 w->WriteULEB128(3); | 1097 w->WriteULEB128(3); |
1093 w->Write<uint8_t>(kPointerSize); | 1098 w->Write<uint8_t>(kPointerSize); |
1094 w->WriteString("v8value"); | 1099 w->WriteString("v8value"); |
1095 | 1100 |
1096 if (desc_->IsInfoAvailable()) { | 1101 if (desc_->IsInfoAvailable()) { |
1097 CompilationInfo* info = desc_->info(); | 1102 Scope* scope = desc_->info()->scope(); |
1098 ScopeInfo<FreeStoreAllocationPolicy> scope_info(info->scope()); | |
1099 w->WriteULEB128(2); | 1103 w->WriteULEB128(2); |
1100 w->WriteString(desc_->name()); | 1104 w->WriteString(desc_->name()); |
1101 w->Write<intptr_t>(desc_->CodeStart()); | 1105 w->Write<intptr_t>(desc_->CodeStart()); |
1102 w->Write<intptr_t>(desc_->CodeStart() + desc_->CodeSize()); | 1106 w->Write<intptr_t>(desc_->CodeStart() + desc_->CodeSize()); |
1103 Writer::Slot<uint32_t> fb_block_size = w->CreateSlotHere<uint32_t>(); | 1107 Writer::Slot<uint32_t> fb_block_size = w->CreateSlotHere<uint32_t>(); |
1104 uintptr_t fb_block_start = w->position(); | 1108 uintptr_t fb_block_start = w->position(); |
1105 #if defined(V8_TARGET_ARCH_IA32) | 1109 #if defined(V8_TARGET_ARCH_IA32) |
1106 w->Write<uint8_t>(DW_OP_reg5); // The frame pointer's here on ia32 | 1110 w->Write<uint8_t>(DW_OP_reg5); // The frame pointer's here on ia32 |
1107 #elif defined(V8_TARGET_ARCH_X64) | 1111 #elif defined(V8_TARGET_ARCH_X64) |
1108 w->Write<uint8_t>(DW_OP_reg6); // and here on x64. | 1112 w->Write<uint8_t>(DW_OP_reg6); // and here on x64. |
1109 #else | 1113 #else |
1110 #error Unsupported target architecture. | 1114 #error Unsupported target architecture. |
1111 #endif | 1115 #endif |
1112 fb_block_size.set(static_cast<uint32_t>(w->position() - fb_block_start)); | 1116 fb_block_size.set(static_cast<uint32_t>(w->position() - fb_block_start)); |
1113 | 1117 |
1114 int params = scope_info.number_of_parameters(); | 1118 int params = scope->num_parameters(); |
1115 int slots = scope_info.number_of_stack_slots(); | 1119 int slots = scope->num_stack_slots(); |
1116 int context_slots = scope_info.number_of_context_slots(); | 1120 int context_slots = scope->ContextLocalCount(); |
1117 // The real slot ID is internal_slots + context_slot_id. | 1121 // The real slot ID is internal_slots + context_slot_id. |
1118 int internal_slots = Context::MIN_CONTEXT_SLOTS; | 1122 int internal_slots = Context::MIN_CONTEXT_SLOTS; |
1119 int locals = scope_info.LocalCount(); | 1123 int locals = scope->StackLocalCount(); |
1120 int current_abbreviation = 4; | 1124 int current_abbreviation = 4; |
1121 | 1125 |
1122 for (int param = 0; param < params; ++param) { | 1126 for (int param = 0; param < params; ++param) { |
1123 w->WriteULEB128(current_abbreviation++); | 1127 w->WriteULEB128(current_abbreviation++); |
1124 w->WriteString( | 1128 w->WriteString( |
1125 *scope_info.ParameterName(param)->ToCString(DISALLOW_NULLS)); | 1129 *scope->parameter(param)->name()->ToCString(DISALLOW_NULLS)); |
1126 w->Write<uint32_t>(ty_offset); | 1130 w->Write<uint32_t>(ty_offset); |
1127 Writer::Slot<uint32_t> block_size = w->CreateSlotHere<uint32_t>(); | 1131 Writer::Slot<uint32_t> block_size = w->CreateSlotHere<uint32_t>(); |
1128 uintptr_t block_start = w->position(); | 1132 uintptr_t block_start = w->position(); |
1129 w->Write<uint8_t>(DW_OP_fbreg); | 1133 w->Write<uint8_t>(DW_OP_fbreg); |
1130 w->WriteSLEB128( | 1134 w->WriteSLEB128( |
1131 JavaScriptFrameConstants::kLastParameterOffset + | 1135 JavaScriptFrameConstants::kLastParameterOffset + |
1132 kPointerSize * (params - param - 1)); | 1136 kPointerSize * (params - param - 1)); |
1133 block_size.set(static_cast<uint32_t>(w->position() - block_start)); | 1137 block_size.set(static_cast<uint32_t>(w->position() - block_start)); |
1134 } | 1138 } |
1135 | 1139 |
1136 EmbeddedVector<char, 256> buffer; | 1140 EmbeddedVector<char, 256> buffer; |
1137 StringBuilder builder(buffer.start(), buffer.length()); | 1141 StringBuilder builder(buffer.start(), buffer.length()); |
1138 | 1142 |
1139 for (int slot = 0; slot < slots; ++slot) { | 1143 for (int slot = 0; slot < slots; ++slot) { |
1140 w->WriteULEB128(current_abbreviation++); | 1144 w->WriteULEB128(current_abbreviation++); |
1141 builder.Reset(); | 1145 builder.Reset(); |
1142 builder.AddFormatted("slot%d", slot); | 1146 builder.AddFormatted("slot%d", slot); |
1143 w->WriteString(builder.Finalize()); | 1147 w->WriteString(builder.Finalize()); |
1144 } | 1148 } |
1145 | 1149 |
1146 // See contexts.h for more information. | 1150 // See contexts.h for more information. |
1147 ASSERT(Context::MIN_CONTEXT_SLOTS == 4); | 1151 ASSERT(Context::MIN_CONTEXT_SLOTS == 4); |
1148 ASSERT(Context::CLOSURE_INDEX == 0); | 1152 ASSERT(Context::CLOSURE_INDEX == 0); |
1149 ASSERT(Context::PREVIOUS_INDEX == 1); | 1153 ASSERT(Context::PREVIOUS_INDEX == 1); |
1150 ASSERT(Context::EXTENSION_INDEX == 2); | 1154 ASSERT(Context::EXTENSION_INDEX == 2); |
1151 ASSERT(Context::GLOBAL_INDEX == 3); | 1155 ASSERT(Context::GLOBAL_OBJECT_INDEX == 3); |
1152 w->WriteULEB128(current_abbreviation++); | 1156 w->WriteULEB128(current_abbreviation++); |
1153 w->WriteString(".closure"); | 1157 w->WriteString(".closure"); |
1154 w->WriteULEB128(current_abbreviation++); | 1158 w->WriteULEB128(current_abbreviation++); |
1155 w->WriteString(".previous"); | 1159 w->WriteString(".previous"); |
1156 w->WriteULEB128(current_abbreviation++); | 1160 w->WriteULEB128(current_abbreviation++); |
1157 w->WriteString(".extension"); | 1161 w->WriteString(".extension"); |
1158 w->WriteULEB128(current_abbreviation++); | 1162 w->WriteULEB128(current_abbreviation++); |
1159 w->WriteString(".global"); | 1163 w->WriteString(".global"); |
1160 | 1164 |
1161 for (int context_slot = 0; | 1165 for (int context_slot = 0; |
1162 context_slot < context_slots; | 1166 context_slot < context_slots; |
1163 ++context_slot) { | 1167 ++context_slot) { |
1164 w->WriteULEB128(current_abbreviation++); | 1168 w->WriteULEB128(current_abbreviation++); |
1165 builder.Reset(); | 1169 builder.Reset(); |
1166 builder.AddFormatted("context_slot%d", context_slot + internal_slots); | 1170 builder.AddFormatted("context_slot%d", context_slot + internal_slots); |
1167 w->WriteString(builder.Finalize()); | 1171 w->WriteString(builder.Finalize()); |
1168 } | 1172 } |
1169 | 1173 |
| 1174 ZoneList<Variable*> stack_locals(locals, scope->zone()); |
| 1175 ZoneList<Variable*> context_locals(context_slots, scope->zone()); |
| 1176 scope->CollectStackAndContextLocals(&stack_locals, &context_locals); |
1170 for (int local = 0; local < locals; ++local) { | 1177 for (int local = 0; local < locals; ++local) { |
1171 w->WriteULEB128(current_abbreviation++); | 1178 w->WriteULEB128(current_abbreviation++); |
1172 w->WriteString( | 1179 w->WriteString( |
1173 *scope_info.LocalName(local)->ToCString(DISALLOW_NULLS)); | 1180 *stack_locals[local]->name()->ToCString(DISALLOW_NULLS)); |
1174 w->Write<uint32_t>(ty_offset); | 1181 w->Write<uint32_t>(ty_offset); |
1175 Writer::Slot<uint32_t> block_size = w->CreateSlotHere<uint32_t>(); | 1182 Writer::Slot<uint32_t> block_size = w->CreateSlotHere<uint32_t>(); |
1176 uintptr_t block_start = w->position(); | 1183 uintptr_t block_start = w->position(); |
1177 w->Write<uint8_t>(DW_OP_fbreg); | 1184 w->Write<uint8_t>(DW_OP_fbreg); |
1178 w->WriteSLEB128( | 1185 w->WriteSLEB128( |
1179 JavaScriptFrameConstants::kLocal0Offset - | 1186 JavaScriptFrameConstants::kLocal0Offset - |
1180 kPointerSize * local); | 1187 kPointerSize * local); |
1181 block_size.set(static_cast<uint32_t>(w->position() - block_start)); | 1188 block_size.set(static_cast<uint32_t>(w->position() - block_start)); |
1182 } | 1189 } |
1183 | 1190 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1280 if (has_value) { | 1287 if (has_value) { |
1281 w->WriteULEB128(DW_AT_TYPE); | 1288 w->WriteULEB128(DW_AT_TYPE); |
1282 w->WriteULEB128(DW_FORM_REF4); | 1289 w->WriteULEB128(DW_FORM_REF4); |
1283 w->WriteULEB128(DW_AT_LOCATION); | 1290 w->WriteULEB128(DW_AT_LOCATION); |
1284 w->WriteULEB128(DW_FORM_BLOCK4); | 1291 w->WriteULEB128(DW_FORM_BLOCK4); |
1285 } | 1292 } |
1286 w->WriteULEB128(0); | 1293 w->WriteULEB128(0); |
1287 w->WriteULEB128(0); | 1294 w->WriteULEB128(0); |
1288 } | 1295 } |
1289 | 1296 |
1290 bool WriteBody(Writer* w) { | 1297 bool WriteBodyInternal(Writer* w) { |
1291 int current_abbreviation = 1; | 1298 int current_abbreviation = 1; |
1292 bool extra_info = desc_->IsInfoAvailable(); | 1299 bool extra_info = desc_->IsInfoAvailable(); |
1293 ASSERT(desc_->IsLineInfoAvailable()); | 1300 ASSERT(desc_->IsLineInfoAvailable()); |
1294 w->WriteULEB128(current_abbreviation++); | 1301 w->WriteULEB128(current_abbreviation++); |
1295 w->WriteULEB128(DW_TAG_COMPILE_UNIT); | 1302 w->WriteULEB128(DW_TAG_COMPILE_UNIT); |
1296 w->Write<uint8_t>(extra_info ? DW_CHILDREN_YES : DW_CHILDREN_NO); | 1303 w->Write<uint8_t>(extra_info ? DW_CHILDREN_YES : DW_CHILDREN_NO); |
1297 w->WriteULEB128(DW_AT_NAME); | 1304 w->WriteULEB128(DW_AT_NAME); |
1298 w->WriteULEB128(DW_FORM_STRING); | 1305 w->WriteULEB128(DW_FORM_STRING); |
1299 w->WriteULEB128(DW_AT_LOW_PC); | 1306 w->WriteULEB128(DW_AT_LOW_PC); |
1300 w->WriteULEB128(DW_FORM_ADDR); | 1307 w->WriteULEB128(DW_FORM_ADDR); |
1301 w->WriteULEB128(DW_AT_HIGH_PC); | 1308 w->WriteULEB128(DW_AT_HIGH_PC); |
1302 w->WriteULEB128(DW_FORM_ADDR); | 1309 w->WriteULEB128(DW_FORM_ADDR); |
1303 w->WriteULEB128(DW_AT_STMT_LIST); | 1310 w->WriteULEB128(DW_AT_STMT_LIST); |
1304 w->WriteULEB128(DW_FORM_DATA4); | 1311 w->WriteULEB128(DW_FORM_DATA4); |
1305 w->WriteULEB128(0); | 1312 w->WriteULEB128(0); |
1306 w->WriteULEB128(0); | 1313 w->WriteULEB128(0); |
1307 | 1314 |
1308 if (extra_info) { | 1315 if (extra_info) { |
1309 CompilationInfo* info = desc_->info(); | 1316 Scope* scope = desc_->info()->scope(); |
1310 ScopeInfo<FreeStoreAllocationPolicy> scope_info(info->scope()); | 1317 int params = scope->num_parameters(); |
1311 int params = scope_info.number_of_parameters(); | 1318 int slots = scope->num_stack_slots(); |
1312 int slots = scope_info.number_of_stack_slots(); | 1319 int context_slots = scope->ContextLocalCount(); |
1313 int context_slots = scope_info.number_of_context_slots(); | |
1314 // The real slot ID is internal_slots + context_slot_id. | 1320 // The real slot ID is internal_slots + context_slot_id. |
1315 int internal_slots = Context::MIN_CONTEXT_SLOTS; | 1321 int internal_slots = Context::MIN_CONTEXT_SLOTS; |
1316 int locals = scope_info.LocalCount(); | 1322 int locals = scope->StackLocalCount(); |
1317 int total_children = | 1323 int total_children = |
1318 params + slots + context_slots + internal_slots + locals + 2; | 1324 params + slots + context_slots + internal_slots + locals + 2; |
1319 | 1325 |
1320 // The extra duplication below seems to be necessary to keep | 1326 // The extra duplication below seems to be necessary to keep |
1321 // gdb from getting upset on OSX. | 1327 // gdb from getting upset on OSX. |
1322 w->WriteULEB128(current_abbreviation++); // Abbreviation code. | 1328 w->WriteULEB128(current_abbreviation++); // Abbreviation code. |
1323 w->WriteULEB128(DW_TAG_SUBPROGRAM); | 1329 w->WriteULEB128(DW_TAG_SUBPROGRAM); |
1324 w->Write<uint8_t>( | 1330 w->Write<uint8_t>( |
1325 total_children != 0 ? DW_CHILDREN_YES : DW_CHILDREN_NO); | 1331 total_children != 0 ? DW_CHILDREN_YES : DW_CHILDREN_NO); |
1326 w->WriteULEB128(DW_AT_NAME); | 1332 w->WriteULEB128(DW_AT_NAME); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1411 DW_LNS_NEGATE_STMT = 6 | 1417 DW_LNS_NEGATE_STMT = 6 |
1412 }; | 1418 }; |
1413 | 1419 |
1414 // DWARF2 standard, figure 35. | 1420 // DWARF2 standard, figure 35. |
1415 enum DWARF2ExtendedOpcode { | 1421 enum DWARF2ExtendedOpcode { |
1416 DW_LNE_END_SEQUENCE = 1, | 1422 DW_LNE_END_SEQUENCE = 1, |
1417 DW_LNE_SET_ADDRESS = 2, | 1423 DW_LNE_SET_ADDRESS = 2, |
1418 DW_LNE_DEFINE_FILE = 3 | 1424 DW_LNE_DEFINE_FILE = 3 |
1419 }; | 1425 }; |
1420 | 1426 |
1421 bool WriteBody(Writer* w) { | 1427 bool WriteBodyInternal(Writer* w) { |
1422 // Write prologue. | 1428 // Write prologue. |
1423 Writer::Slot<uint32_t> total_length = w->CreateSlotHere<uint32_t>(); | 1429 Writer::Slot<uint32_t> total_length = w->CreateSlotHere<uint32_t>(); |
1424 uintptr_t start = w->position(); | 1430 uintptr_t start = w->position(); |
1425 | 1431 |
1426 // Used for special opcodes | 1432 // Used for special opcodes |
1427 const int8_t line_base = 1; | 1433 const int8_t line_base = 1; |
1428 const uint8_t line_range = 7; | 1434 const uint8_t line_range = 7; |
1429 const int8_t max_line_incr = (line_base + line_range - 1); | 1435 const int8_t max_line_incr = (line_base + line_range - 1); |
1430 const uint8_t opcode_base = DW_LNS_NEGATE_STMT + 1; | 1436 const uint8_t opcode_base = DW_LNS_NEGATE_STMT + 1; |
1431 | 1437 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1551 | 1557 |
1552 CodeDescription* desc_; | 1558 CodeDescription* desc_; |
1553 }; | 1559 }; |
1554 | 1560 |
1555 | 1561 |
1556 #ifdef V8_TARGET_ARCH_X64 | 1562 #ifdef V8_TARGET_ARCH_X64 |
1557 | 1563 |
1558 class UnwindInfoSection : public DebugSection { | 1564 class UnwindInfoSection : public DebugSection { |
1559 public: | 1565 public: |
1560 explicit UnwindInfoSection(CodeDescription* desc); | 1566 explicit UnwindInfoSection(CodeDescription* desc); |
1561 virtual bool WriteBody(Writer* w); | 1567 virtual bool WriteBodyInternal(Writer* w); |
1562 | 1568 |
1563 int WriteCIE(Writer* w); | 1569 int WriteCIE(Writer* w); |
1564 void WriteFDE(Writer* w, int); | 1570 void WriteFDE(Writer* w, int); |
1565 | 1571 |
1566 void WriteFDEStateOnEntry(Writer* w); | 1572 void WriteFDEStateOnEntry(Writer* w); |
1567 void WriteFDEStateAfterRBPPush(Writer* w); | 1573 void WriteFDEStateAfterRBPPush(Writer* w); |
1568 void WriteFDEStateAfterRBPSet(Writer* w); | 1574 void WriteFDEStateAfterRBPSet(Writer* w); |
1569 void WriteFDEStateAfterRBPPop(Writer* w); | 1575 void WriteFDEStateAfterRBPPop(Writer* w); |
1570 | 1576 |
1571 void WriteLength(Writer* w, | 1577 void WriteLength(Writer* w, |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1763 w->Write<uint8_t>(DW_CFA_OFFSET_EXTENDED); | 1769 w->Write<uint8_t>(DW_CFA_OFFSET_EXTENDED); |
1764 w->WriteULEB128(AMD64_RBP); | 1770 w->WriteULEB128(AMD64_RBP); |
1765 w->WriteSLEB128(StandardFrameConstants::kCallerFPOffset); | 1771 w->WriteSLEB128(StandardFrameConstants::kCallerFPOffset); |
1766 | 1772 |
1767 // Last location described by this entry. | 1773 // Last location described by this entry. |
1768 w->Write<uint8_t>(DW_CFA_SET_LOC); | 1774 w->Write<uint8_t>(DW_CFA_SET_LOC); |
1769 w->Write<uint64_t>(desc_->CodeEnd()); | 1775 w->Write<uint64_t>(desc_->CodeEnd()); |
1770 } | 1776 } |
1771 | 1777 |
1772 | 1778 |
1773 bool UnwindInfoSection::WriteBody(Writer* w) { | 1779 bool UnwindInfoSection::WriteBodyInternal(Writer* w) { |
1774 uint32_t cie_position = WriteCIE(w); | 1780 uint32_t cie_position = WriteCIE(w); |
1775 WriteFDE(w, cie_position); | 1781 WriteFDE(w, cie_position); |
1776 return true; | 1782 return true; |
1777 } | 1783 } |
1778 | 1784 |
1779 | 1785 |
1780 #endif // V8_TARGET_ARCH_X64 | 1786 #endif // V8_TARGET_ARCH_X64 |
1781 | 1787 |
1782 static void CreateDWARFSections(CodeDescription* desc, DebugObject* obj) { | 1788 static void CreateDWARFSections(CodeDescription* desc, DebugObject* obj) { |
| 1789 Zone* zone = desc->info()->zone(); |
1783 if (desc->IsLineInfoAvailable()) { | 1790 if (desc->IsLineInfoAvailable()) { |
1784 obj->AddSection(new DebugInfoSection(desc)); | 1791 obj->AddSection(new(zone) DebugInfoSection(desc), zone); |
1785 obj->AddSection(new DebugAbbrevSection(desc)); | 1792 obj->AddSection(new(zone) DebugAbbrevSection(desc), zone); |
1786 obj->AddSection(new DebugLineSection(desc)); | 1793 obj->AddSection(new(zone) DebugLineSection(desc), zone); |
1787 } | 1794 } |
1788 #ifdef V8_TARGET_ARCH_X64 | 1795 #ifdef V8_TARGET_ARCH_X64 |
1789 obj->AddSection(new UnwindInfoSection(desc)); | 1796 obj->AddSection(new(zone) UnwindInfoSection(desc), zone); |
1790 #endif | 1797 #endif |
1791 } | 1798 } |
1792 | 1799 |
1793 | 1800 |
1794 // ------------------------------------------------------------------- | 1801 // ------------------------------------------------------------------- |
1795 // Binary GDB JIT Interface as described in | 1802 // Binary GDB JIT Interface as described in |
1796 // http://sourceware.org/gdb/onlinedocs/gdb/Declarations.html | 1803 // http://sourceware.org/gdb/onlinedocs/gdb/Declarations.html |
1797 extern "C" { | 1804 extern "C" { |
1798 typedef enum { | 1805 typedef enum { |
1799 JIT_NOACTION = 0, | 1806 JIT_NOACTION = 0, |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1898 entry->next_->prev_ = entry->prev_; | 1905 entry->next_->prev_ = entry->prev_; |
1899 } | 1906 } |
1900 | 1907 |
1901 __jit_debug_descriptor.relevant_entry_ = entry; | 1908 __jit_debug_descriptor.relevant_entry_ = entry; |
1902 __jit_debug_descriptor.action_flag_ = JIT_UNREGISTER_FN; | 1909 __jit_debug_descriptor.action_flag_ = JIT_UNREGISTER_FN; |
1903 __jit_debug_register_code(); | 1910 __jit_debug_register_code(); |
1904 } | 1911 } |
1905 | 1912 |
1906 | 1913 |
1907 static JITCodeEntry* CreateELFObject(CodeDescription* desc) { | 1914 static JITCodeEntry* CreateELFObject(CodeDescription* desc) { |
1908 ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT); | 1915 Zone* zone = desc->info()->zone(); |
| 1916 ZoneScope zone_scope(zone, DELETE_ON_EXIT); |
1909 #ifdef __MACH_O | 1917 #ifdef __MACH_O |
1910 MachO mach_o; | 1918 MachO mach_o; |
1911 Writer w(&mach_o); | 1919 Writer w(&mach_o); |
1912 | 1920 |
1913 mach_o.AddSection(new MachOTextSection(kCodeAlignment, | 1921 mach_o.AddSection(new MachOTextSection(kCodeAlignment, |
1914 desc->CodeStart(), | 1922 desc->CodeStart(), |
1915 desc->CodeSize())); | 1923 desc->CodeSize())); |
1916 | 1924 |
1917 CreateDWARFSections(desc, &mach_o); | 1925 CreateDWARFSections(desc, &mach_o); |
1918 | 1926 |
1919 mach_o.Write(&w, desc->CodeStart(), desc->CodeSize()); | 1927 mach_o.Write(&w, desc->CodeStart(), desc->CodeSize()); |
1920 #else | 1928 #else |
1921 ELF elf; | 1929 ELF elf(zone); |
1922 Writer w(&elf); | 1930 Writer w(&elf); |
1923 | 1931 |
1924 int text_section_index = elf.AddSection( | 1932 int text_section_index = elf.AddSection( |
1925 new FullHeaderELFSection(".text", | 1933 new(zone) FullHeaderELFSection( |
1926 ELFSection::TYPE_NOBITS, | 1934 ".text", |
1927 kCodeAlignment, | 1935 ELFSection::TYPE_NOBITS, |
1928 desc->CodeStart(), | 1936 kCodeAlignment, |
1929 0, | 1937 desc->CodeStart(), |
1930 desc->CodeSize(), | 1938 0, |
1931 ELFSection::FLAG_ALLOC | ELFSection::FLAG_EXEC)); | 1939 desc->CodeSize(), |
| 1940 ELFSection::FLAG_ALLOC | ELFSection::FLAG_EXEC), |
| 1941 zone); |
1932 | 1942 |
1933 CreateSymbolsTable(desc, &elf, text_section_index); | 1943 CreateSymbolsTable(desc, &elf, text_section_index); |
1934 | 1944 |
1935 CreateDWARFSections(desc, &elf); | 1945 CreateDWARFSections(desc, &elf); |
1936 | 1946 |
1937 elf.Write(&w); | 1947 elf.Write(&w); |
1938 #endif | 1948 #endif |
1939 | 1949 |
1940 return CreateCodeEntry(w.buffer(), w.position()); | 1950 return CreateCodeEntry(w.buffer(), w.position()); |
1941 } | 1951 } |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2150 ScopedLock lock(mutex.Pointer()); | 2160 ScopedLock lock(mutex.Pointer()); |
2151 ASSERT(!IsLineInfoTagged(line_info)); | 2161 ASSERT(!IsLineInfoTagged(line_info)); |
2152 HashMap::Entry* e = GetEntries()->Lookup(code, HashForCodeObject(code), true); | 2162 HashMap::Entry* e = GetEntries()->Lookup(code, HashForCodeObject(code), true); |
2153 ASSERT(e->value == NULL); | 2163 ASSERT(e->value == NULL); |
2154 e->value = TagLineInfo(line_info); | 2164 e->value = TagLineInfo(line_info); |
2155 } | 2165 } |
2156 | 2166 |
2157 | 2167 |
2158 } } // namespace v8::internal | 2168 } } // namespace v8::internal |
2159 #endif | 2169 #endif |
OLD | NEW |