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

Side by Side Diff: src/gdb-jit.cc

Issue 12952002: Make GDBJIT interface compile again. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/gdb-jit.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 ASSERT(offset < capacity_ && offset + sizeof(T) <= capacity_); 180 ASSERT(offset < capacity_ && offset + sizeof(T) <= capacity_);
181 return reinterpret_cast<T*>(&buffer_[offset]); 181 return reinterpret_cast<T*>(&buffer_[offset]);
182 } 182 }
183 183
184 DebugObject* debug_object_; 184 DebugObject* debug_object_;
185 uintptr_t position_; 185 uintptr_t position_;
186 uintptr_t capacity_; 186 uintptr_t capacity_;
187 byte* buffer_; 187 byte* buffer_;
188 }; 188 };
189 189
190 class StringTable; 190 class ELFStringTable;
191 191
192 template<typename THeader> 192 template<typename THeader>
193 class DebugSectionBase : public ZoneObject { 193 class DebugSectionBase : public ZoneObject {
194 public: 194 public:
195 virtual ~DebugSectionBase() { } 195 virtual ~DebugSectionBase() { }
196 196
197 virtual void WriteBody(Writer::Slot<THeader> header, Writer* writer) { 197 virtual void WriteBody(Writer::Slot<THeader> header, Writer* writer) {
198 uintptr_t start = writer->position(); 198 uintptr_t start = writer->position();
199 if (WriteBodyInternal(writer)) { 199 if (WriteBodyInternal(writer)) {
200 uintptr_t end = writer->position(); 200 uintptr_t end = writer->position();
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 331
332 enum SpecialIndexes { 332 enum SpecialIndexes {
333 INDEX_ABSOLUTE = 0xfff1 333 INDEX_ABSOLUTE = 0xfff1
334 }; 334 };
335 335
336 ELFSection(const char* name, Type type, uintptr_t align) 336 ELFSection(const char* name, Type type, uintptr_t align)
337 : name_(name), type_(type), align_(align) { } 337 : name_(name), type_(type), align_(align) { }
338 338
339 virtual ~ELFSection() { } 339 virtual ~ELFSection() { }
340 340
341 void PopulateHeader(Writer::Slot<Header> header, StringTable* strtab); 341 void PopulateHeader(Writer::Slot<Header> header, ELFStringTable* strtab);
342 342
343 virtual void WriteBody(Writer::Slot<Header> header, Writer* w) { 343 virtual void WriteBody(Writer::Slot<Header> header, Writer* w) {
344 uintptr_t start = w->position(); 344 uintptr_t start = w->position();
345 if (WriteBodyInternal(w)) { 345 if (WriteBodyInternal(w)) {
346 uintptr_t end = w->position(); 346 uintptr_t end = w->position();
347 header->offset = start; 347 header->offset = start;
348 header->size = end - start; 348 header->size = end - start;
349 } 349 }
350 } 350 }
351 351
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 } 431 }
432 432
433 private: 433 private:
434 uintptr_t addr_; 434 uintptr_t addr_;
435 uintptr_t offset_; 435 uintptr_t offset_;
436 uintptr_t size_; 436 uintptr_t size_;
437 uintptr_t flags_; 437 uintptr_t flags_;
438 }; 438 };
439 439
440 440
441 class StringTable : public ELFSection { 441 class ELFStringTable : public ELFSection {
442 public: 442 public:
443 explicit StringTable(const char* name) 443 explicit ELFStringTable(const char* name)
444 : ELFSection(name, TYPE_STRTAB, 1), writer_(NULL), offset_(0), size_(0) { 444 : ELFSection(name, TYPE_STRTAB, 1), writer_(NULL), offset_(0), size_(0) {
445 } 445 }
446 446
447 uintptr_t Add(const char* str) { 447 uintptr_t Add(const char* str) {
448 if (*str == '\0') return 0; 448 if (*str == '\0') return 0;
449 449
450 uintptr_t offset = size_; 450 uintptr_t offset = size_;
451 WriteString(str); 451 WriteString(str);
452 return offset; 452 return offset;
453 } 453 }
(...skipping 27 matching lines...) Expand all
481 } 481 }
482 482
483 Writer* writer_; 483 Writer* writer_;
484 484
485 uintptr_t offset_; 485 uintptr_t offset_;
486 uintptr_t size_; 486 uintptr_t size_;
487 }; 487 };
488 488
489 489
490 void ELFSection::PopulateHeader(Writer::Slot<ELFSection::Header> header, 490 void ELFSection::PopulateHeader(Writer::Slot<ELFSection::Header> header,
491 StringTable* strtab) { 491 ELFStringTable* strtab) {
492 header->name = strtab->Add(name_); 492 header->name = strtab->Add(name_);
493 header->type = type_; 493 header->type = type_;
494 header->alignment = align_; 494 header->alignment = align_;
495 PopulateHeader(header); 495 PopulateHeader(header);
496 } 496 }
497 #endif // defined(__ELF) 497 #endif // defined(__ELF)
498 498
499 499
500 #if defined(__MACH_O) 500 #if defined(__MACH_O)
501 class MachO BASE_EMBEDDED { 501 class MachO BASE_EMBEDDED {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 ZoneList<MachOSection*> sections_; 624 ZoneList<MachOSection*> sections_;
625 }; 625 };
626 #endif // defined(__MACH_O) 626 #endif // defined(__MACH_O)
627 627
628 628
629 #if defined(__ELF) 629 #if defined(__ELF)
630 class ELF BASE_EMBEDDED { 630 class ELF BASE_EMBEDDED {
631 public: 631 public:
632 ELF(Zone* zone) : sections_(6, zone) { 632 ELF(Zone* zone) : sections_(6, zone) {
633 sections_.Add(new(zone) ELFSection("", ELFSection::TYPE_NULL, 0), zone); 633 sections_.Add(new(zone) ELFSection("", ELFSection::TYPE_NULL, 0), zone);
634 sections_.Add(new(zone) StringTable(".shstrtab"), zone); 634 sections_.Add(new(zone) ELFStringTable(".shstrtab"), zone);
635 } 635 }
636 636
637 void Write(Writer* w) { 637 void Write(Writer* w) {
638 WriteHeader(w); 638 WriteHeader(w);
639 WriteSectionTable(w); 639 WriteSectionTable(w);
640 WriteSections(w); 640 WriteSections(w);
641 } 641 }
642 642
643 ELFSection* SectionAt(uint32_t index) { 643 ELFSection* SectionAt(uint32_t index) {
644 return sections_[index]; 644 return sections_[index];
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 } 711 }
712 712
713 void WriteSectionTable(Writer* w) { 713 void WriteSectionTable(Writer* w) {
714 // Section headers table immediately follows file header. 714 // Section headers table immediately follows file header.
715 ASSERT(w->position() == sizeof(ELFHeader)); 715 ASSERT(w->position() == sizeof(ELFHeader));
716 716
717 Writer::Slot<ELFSection::Header> headers = 717 Writer::Slot<ELFSection::Header> headers =
718 w->CreateSlotsHere<ELFSection::Header>(sections_.length()); 718 w->CreateSlotsHere<ELFSection::Header>(sections_.length());
719 719
720 // String table for section table is the first section. 720 // String table for section table is the first section.
721 StringTable* strtab = static_cast<StringTable*>(SectionAt(1)); 721 ELFStringTable* strtab = static_cast<ELFStringTable*>(SectionAt(1));
722 strtab->AttachWriter(w); 722 strtab->AttachWriter(w);
723 for (int i = 0, length = sections_.length(); 723 for (int i = 0, length = sections_.length();
724 i < length; 724 i < length;
725 i++) { 725 i++) {
726 sections_[i]->PopulateHeader(headers.at(i), strtab); 726 sections_[i]->PopulateHeader(headers.at(i), strtab);
727 } 727 }
728 strtab->DetachWriter(); 728 strtab->DetachWriter();
729 } 729 }
730 730
731 int SectionHeaderPosition(uint32_t section_index) { 731 int SectionHeaderPosition(uint32_t section_index) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 825
826 uint32_t name; 826 uint32_t name;
827 uint8_t info; 827 uint8_t info;
828 uint8_t other; 828 uint8_t other;
829 uint16_t section; 829 uint16_t section;
830 uintptr_t value; 830 uintptr_t value;
831 uintptr_t size; 831 uintptr_t size;
832 }; 832 };
833 #endif 833 #endif
834 834
835 void Write(Writer::Slot<SerializedLayout> s, StringTable* t) { 835 void Write(Writer::Slot<SerializedLayout> s, ELFStringTable* t) {
836 // Convert symbol names from strings to indexes in the string table. 836 // Convert symbol names from strings to indexes in the string table.
837 s->name = t->Add(name); 837 s->name = t->Add(name);
838 s->value = value; 838 s->value = value;
839 s->size = size; 839 s->size = size;
840 s->info = info; 840 s->info = info;
841 s->other = other; 841 s->other = other;
842 s->section = section; 842 s->section = section;
843 } 843 }
844 844
845 private: 845 private:
(...skipping 18 matching lines...) Expand all
864 w->Align(header->alignment); 864 w->Align(header->alignment);
865 int total_symbols = locals_.length() + globals_.length() + 1; 865 int total_symbols = locals_.length() + globals_.length() + 1;
866 header->offset = w->position(); 866 header->offset = w->position();
867 867
868 Writer::Slot<ELFSymbol::SerializedLayout> symbols = 868 Writer::Slot<ELFSymbol::SerializedLayout> symbols =
869 w->CreateSlotsHere<ELFSymbol::SerializedLayout>(total_symbols); 869 w->CreateSlotsHere<ELFSymbol::SerializedLayout>(total_symbols);
870 870
871 header->size = w->position() - header->offset; 871 header->size = w->position() - header->offset;
872 872
873 // 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.
874 StringTable* strtab = 874 ELFStringTable* strtab =
875 static_cast<StringTable*>(w->debug_object()->SectionAt(index() + 1)); 875 static_cast<ELFStringTable*>(w->debug_object()->SectionAt(index() + 1));
876 strtab->AttachWriter(w); 876 strtab->AttachWriter(w);
877 symbols.at(0).set(ELFSymbol::SerializedLayout(0, 877 symbols.at(0).set(ELFSymbol::SerializedLayout(0,
878 0, 878 0,
879 0, 879 0,
880 ELFSymbol::BIND_LOCAL, 880 ELFSymbol::BIND_LOCAL,
881 ELFSymbol::TYPE_NOTYPE, 881 ELFSymbol::TYPE_NOTYPE,
882 0)); 882 0));
883 WriteSymbolsList(&locals_, symbols.at(1), strtab); 883 WriteSymbolsList(&locals_, symbols.at(1), strtab);
884 WriteSymbolsList(&globals_, symbols.at(locals_.length() + 1), strtab); 884 WriteSymbolsList(&globals_, symbols.at(locals_.length() + 1), strtab);
885 strtab->DetachWriter(); 885 strtab->DetachWriter();
(...skipping 12 matching lines...) Expand all
898 ELFSection::PopulateHeader(header); 898 ELFSection::PopulateHeader(header);
899 // We are assuming that string table will follow symbol table. 899 // We are assuming that string table will follow symbol table.
900 header->link = index() + 1; 900 header->link = index() + 1;
901 header->info = locals_.length() + 1; 901 header->info = locals_.length() + 1;
902 header->entry_size = sizeof(ELFSymbol::SerializedLayout); 902 header->entry_size = sizeof(ELFSymbol::SerializedLayout);
903 } 903 }
904 904
905 private: 905 private:
906 void WriteSymbolsList(const ZoneList<ELFSymbol>* src, 906 void WriteSymbolsList(const ZoneList<ELFSymbol>* src,
907 Writer::Slot<ELFSymbol::SerializedLayout> dst, 907 Writer::Slot<ELFSymbol::SerializedLayout> dst,
908 StringTable* strtab) { 908 ELFStringTable* strtab) {
909 for (int i = 0, len = src->length(); 909 for (int i = 0, len = src->length();
910 i < len; 910 i < len;
911 i++) { 911 i++) {
912 src->at(i).Write(dst.at(i), strtab); 912 src->at(i).Write(dst.at(i), strtab);
913 } 913 }
914 } 914 }
915 915
916 ZoneList<ELFSymbol> locals_; 916 ZoneList<ELFSymbol> locals_;
917 ZoneList<ELFSymbol> globals_; 917 ZoneList<ELFSymbol> globals_;
918 }; 918 };
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 uintptr_t stack_state_start_addresses_[STACK_STATE_MAX]; 1016 uintptr_t stack_state_start_addresses_[STACK_STATE_MAX];
1017 #endif 1017 #endif
1018 }; 1018 };
1019 1019
1020 #if defined(__ELF) 1020 #if defined(__ELF)
1021 static void CreateSymbolsTable(CodeDescription* desc, 1021 static void CreateSymbolsTable(CodeDescription* desc,
1022 ELF* elf, 1022 ELF* elf,
1023 int text_section_index) { 1023 int text_section_index) {
1024 Zone* zone = desc->info()->zone(); 1024 Zone* zone = desc->info()->zone();
1025 ELFSymbolTable* symtab = new(zone) ELFSymbolTable(".symtab", zone); 1025 ELFSymbolTable* symtab = new(zone) ELFSymbolTable(".symtab", zone);
1026 StringTable* strtab = new(zone) StringTable(".strtab"); 1026 ELFStringTable* strtab = new(zone) ELFStringTable(".strtab");
1027 1027
1028 // Symbol table should be followed by the linked string table. 1028 // Symbol table should be followed by the linked string table.
1029 elf->AddSection(symtab, zone); 1029 elf->AddSection(symtab, zone);
1030 elf->AddSection(strtab, zone); 1030 elf->AddSection(strtab, zone);
1031 1031
1032 symtab->Add(ELFSymbol("V8 Code", 1032 symtab->Add(ELFSymbol("V8 Code",
1033 0, 1033 0,
1034 0, 1034 0,
1035 ELFSymbol::BIND_LOCAL, 1035 ELFSymbol::BIND_LOCAL,
1036 ELFSymbol::TYPE_FILE, 1036 ELFSymbol::TYPE_FILE,
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after
1989 reinterpret_cast<intptr_t>(ptr) | kLineInfoTag); 1989 reinterpret_cast<intptr_t>(ptr) | kLineInfoTag);
1990 } 1990 }
1991 1991
1992 1992
1993 static GDBJITLineInfo* UntagLineInfo(void* ptr) { 1993 static GDBJITLineInfo* UntagLineInfo(void* ptr) {
1994 return reinterpret_cast<GDBJITLineInfo*>( 1994 return reinterpret_cast<GDBJITLineInfo*>(
1995 reinterpret_cast<intptr_t>(ptr) & ~kLineInfoTag); 1995 reinterpret_cast<intptr_t>(ptr) & ~kLineInfoTag);
1996 } 1996 }
1997 1997
1998 1998
1999 void GDBJITInterface::AddCode(Handle<String> name, 1999 void GDBJITInterface::AddCode(Handle<Name> name,
2000 Handle<Script> script, 2000 Handle<Script> script,
2001 Handle<Code> code, 2001 Handle<Code> code,
2002 CompilationInfo* info) { 2002 CompilationInfo* info) {
2003 if (!FLAG_gdbjit) return; 2003 if (!FLAG_gdbjit) return;
2004 2004
2005 // Force initialization of line_ends array. 2005 // Force initialization of line_ends array.
2006 GetScriptLineNumber(script, 0); 2006 GetScriptLineNumber(script, 0);
2007 2007
2008 if (!name.is_null()) { 2008 if (!name.is_null() && name->IsString()) {
2009 SmartArrayPointer<char> name_cstring = name->ToCString(DISALLOW_NULLS); 2009 SmartArrayPointer<char> name_cstring =
2010 Handle<String>::cast(name)->ToCString(DISALLOW_NULLS);
2010 AddCode(*name_cstring, *code, GDBJITInterface::FUNCTION, *script, info); 2011 AddCode(*name_cstring, *code, GDBJITInterface::FUNCTION, *script, info);
2011 } else { 2012 } else {
2012 AddCode("", *code, GDBJITInterface::FUNCTION, *script, info); 2013 AddCode("", *code, GDBJITInterface::FUNCTION, *script, info);
2013 } 2014 }
2014 } 2015 }
2015 2016
2016 static void AddUnwindInfo(CodeDescription* desc) { 2017 static void AddUnwindInfo(CodeDescription* desc) {
2017 #ifdef V8_TARGET_ARCH_X64 2018 #ifdef V8_TARGET_ARCH_X64
2018 if (desc->tag() == GDBJITInterface::FUNCTION) { 2019 if (desc->tag() == GDBJITInterface::FUNCTION) {
2019 // To avoid propagating unwinding information through 2020 // To avoid propagating unwinding information through
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
2117 builder.AddString(name); 2118 builder.AddString(name);
2118 } else { 2119 } else {
2119 builder.AddFormatted(": code object %p", static_cast<void*>(code)); 2120 builder.AddFormatted(": code object %p", static_cast<void*>(code));
2120 } 2121 }
2121 2122
2122 AddCode(builder.Finalize(), code, tag, NULL, NULL); 2123 AddCode(builder.Finalize(), code, tag, NULL, NULL);
2123 } 2124 }
2124 2125
2125 2126
2126 void GDBJITInterface::AddCode(GDBJITInterface::CodeTag tag, 2127 void GDBJITInterface::AddCode(GDBJITInterface::CodeTag tag,
2127 String* name, 2128 Name* name,
2128 Code* code) { 2129 Code* code) {
2129 if (!FLAG_gdbjit) return; 2130 if (!FLAG_gdbjit) return;
2130 AddCode(tag, name != NULL ? *name->ToCString(DISALLOW_NULLS) : NULL, code); 2131 if (name != NULL && name->IsString()) {
2132 AddCode(tag, *String::cast(name)->ToCString(DISALLOW_NULLS), code);
2133 } else {
2134 AddCode(tag, "", code);
2135 }
2131 } 2136 }
2132 2137
2133 2138
2134 void GDBJITInterface::AddCode(GDBJITInterface::CodeTag tag, Code* code) { 2139 void GDBJITInterface::AddCode(GDBJITInterface::CodeTag tag, Code* code) {
2135 if (!FLAG_gdbjit) return; 2140 if (!FLAG_gdbjit) return;
2136 2141
2137 AddCode(tag, "", code); 2142 AddCode(tag, "", code);
2138 } 2143 }
2139 2144
2140 2145
(...skipping 23 matching lines...) Expand all
2164 ScopedLock lock(mutex.Pointer()); 2169 ScopedLock lock(mutex.Pointer());
2165 ASSERT(!IsLineInfoTagged(line_info)); 2170 ASSERT(!IsLineInfoTagged(line_info));
2166 HashMap::Entry* e = GetEntries()->Lookup(code, HashForCodeObject(code), true); 2171 HashMap::Entry* e = GetEntries()->Lookup(code, HashForCodeObject(code), true);
2167 ASSERT(e->value == NULL); 2172 ASSERT(e->value == NULL);
2168 e->value = TagLineInfo(line_info); 2173 e->value = TagLineInfo(line_info);
2169 } 2174 }
2170 2175
2171 2176
2172 } } // namespace v8::internal 2177 } } // namespace v8::internal
2173 #endif 2178 #endif
OLDNEW
« no previous file with comments | « src/gdb-jit.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698