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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 { |
502 public: | 502 public: |
503 MachO() : sections_(6) { } | 503 explicit MachO(Zone* zone) : zone_(zone), sections_(6, zone) { } |
504 | 504 |
505 uint32_t AddSection(MachOSection* section) { | 505 uint32_t AddSection(MachOSection* section) { |
506 sections_.Add(section); | 506 sections_.Add(section, zone_); |
507 return sections_.length() - 1; | 507 return sections_.length() - 1; |
508 } | 508 } |
509 | 509 |
510 void Write(Writer* w, uintptr_t code_start, uintptr_t code_size) { | 510 void Write(Writer* w, uintptr_t code_start, uintptr_t code_size) { |
511 Writer::Slot<MachOHeader> header = WriteHeader(w); | 511 Writer::Slot<MachOHeader> header = WriteHeader(w); |
512 uintptr_t load_command_start = w->position(); | 512 uintptr_t load_command_start = w->position(); |
513 Writer::Slot<MachOSegmentCommand> cmd = WriteSegmentCommand(w, | 513 Writer::Slot<MachOSegmentCommand> cmd = WriteSegmentCommand(w, |
514 code_start, | 514 code_start, |
515 code_size); | 515 code_size); |
516 WriteSections(w, cmd, header, load_command_start); | 516 WriteSections(w, cmd, header, load_command_start); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 w->CreateSlotsHere<MachOSection::Header>(sections_.length()); | 613 w->CreateSlotsHere<MachOSection::Header>(sections_.length()); |
614 cmd->fileoff = w->position(); | 614 cmd->fileoff = w->position(); |
615 header->sizeofcmds = w->position() - load_command_start; | 615 header->sizeofcmds = w->position() - load_command_start; |
616 for (int section = 0; section < sections_.length(); ++section) { | 616 for (int section = 0; section < sections_.length(); ++section) { |
617 sections_[section]->PopulateHeader(headers.at(section)); | 617 sections_[section]->PopulateHeader(headers.at(section)); |
618 sections_[section]->WriteBody(headers.at(section), w); | 618 sections_[section]->WriteBody(headers.at(section), w); |
619 } | 619 } |
620 cmd->filesize = w->position() - (uintptr_t)cmd->fileoff; | 620 cmd->filesize = w->position() - (uintptr_t)cmd->fileoff; |
621 } | 621 } |
622 | 622 |
623 | 623 Zone* zone_; |
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 explicit ELF(Zone* zone) : sections_(6, zone) { | 632 explicit 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); |
(...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1786 return true; | 1786 return true; |
1787 } | 1787 } |
1788 | 1788 |
1789 | 1789 |
1790 #endif // V8_TARGET_ARCH_X64 | 1790 #endif // V8_TARGET_ARCH_X64 |
1791 | 1791 |
1792 static void CreateDWARFSections(CodeDescription* desc, | 1792 static void CreateDWARFSections(CodeDescription* desc, |
1793 Zone* zone, | 1793 Zone* zone, |
1794 DebugObject* obj) { | 1794 DebugObject* obj) { |
1795 if (desc->IsLineInfoAvailable()) { | 1795 if (desc->IsLineInfoAvailable()) { |
1796 obj->AddSection(new(zone) DebugInfoSection(desc), zone); | 1796 obj->AddSection(new(zone) DebugInfoSection(desc)); |
1797 obj->AddSection(new(zone) DebugAbbrevSection(desc), zone); | 1797 obj->AddSection(new(zone) DebugAbbrevSection(desc)); |
1798 obj->AddSection(new(zone) DebugLineSection(desc), zone); | 1798 obj->AddSection(new(zone) DebugLineSection(desc)); |
1799 } | 1799 } |
1800 #ifdef V8_TARGET_ARCH_X64 | 1800 #ifdef V8_TARGET_ARCH_X64 |
1801 obj->AddSection(new(zone) UnwindInfoSection(desc), zone); | 1801 obj->AddSection(new(zone) UnwindInfoSection(desc), zone); |
1802 #endif | 1802 #endif |
1803 } | 1803 } |
1804 | 1804 |
1805 | 1805 |
1806 // ------------------------------------------------------------------- | 1806 // ------------------------------------------------------------------- |
1807 // Binary GDB JIT Interface as described in | 1807 // Binary GDB JIT Interface as described in |
1808 // http://sourceware.org/gdb/onlinedocs/gdb/Declarations.html | 1808 // http://sourceware.org/gdb/onlinedocs/gdb/Declarations.html |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1912 | 1912 |
1913 __jit_debug_descriptor.relevant_entry_ = entry; | 1913 __jit_debug_descriptor.relevant_entry_ = entry; |
1914 __jit_debug_descriptor.action_flag_ = JIT_UNREGISTER_FN; | 1914 __jit_debug_descriptor.action_flag_ = JIT_UNREGISTER_FN; |
1915 __jit_debug_register_code(); | 1915 __jit_debug_register_code(); |
1916 } | 1916 } |
1917 | 1917 |
1918 | 1918 |
1919 static JITCodeEntry* CreateELFObject(CodeDescription* desc, Zone* zone) { | 1919 static JITCodeEntry* CreateELFObject(CodeDescription* desc, Zone* zone) { |
1920 ZoneScope zone_scope(zone, DELETE_ON_EXIT); | 1920 ZoneScope zone_scope(zone, DELETE_ON_EXIT); |
1921 #ifdef __MACH_O | 1921 #ifdef __MACH_O |
1922 MachO mach_o; | 1922 MachO mach_o(zone); |
1923 Writer w(&mach_o); | 1923 Writer w(&mach_o); |
1924 | 1924 |
1925 mach_o.AddSection(new MachOTextSection(kCodeAlignment, | 1925 mach_o.AddSection(new(zone) MachOTextSection(kCodeAlignment, |
1926 desc->CodeStart(), | 1926 desc->CodeStart(), |
1927 desc->CodeSize())); | 1927 desc->CodeSize())); |
1928 | 1928 |
1929 CreateDWARFSections(desc, &mach_o); | 1929 CreateDWARFSections(desc, zone, &mach_o); |
1930 | 1930 |
1931 mach_o.Write(&w, desc->CodeStart(), desc->CodeSize()); | 1931 mach_o.Write(&w, desc->CodeStart(), desc->CodeSize()); |
1932 #else | 1932 #else |
1933 ELF elf(zone); | 1933 ELF elf(zone); |
1934 Writer w(&elf); | 1934 Writer w(&elf); |
1935 | 1935 |
1936 int text_section_index = elf.AddSection( | 1936 int text_section_index = elf.AddSection( |
1937 new(zone) FullHeaderELFSection( | 1937 new(zone) FullHeaderELFSection( |
1938 ".text", | 1938 ".text", |
1939 ELFSection::TYPE_NOBITS, | 1939 ELFSection::TYPE_NOBITS, |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2055 | 2055 |
2056 | 2056 |
2057 void GDBJITInterface::AddCode(const char* name, | 2057 void GDBJITInterface::AddCode(const char* name, |
2058 Code* code, | 2058 Code* code, |
2059 GDBJITInterface::CodeTag tag, | 2059 GDBJITInterface::CodeTag tag, |
2060 Script* script, | 2060 Script* script, |
2061 CompilationInfo* info) { | 2061 CompilationInfo* info) { |
2062 if (!FLAG_gdbjit) return; | 2062 if (!FLAG_gdbjit) return; |
2063 | 2063 |
2064 ScopedLock lock(mutex.Pointer()); | 2064 ScopedLock lock(mutex.Pointer()); |
2065 AssertNoAllocation no_gc; | 2065 DisallowHeapAllocation no_gc; |
2066 | 2066 |
2067 HashMap::Entry* e = GetEntries()->Lookup(code, HashForCodeObject(code), true); | 2067 HashMap::Entry* e = GetEntries()->Lookup(code, HashForCodeObject(code), true); |
2068 if (e->value != NULL && !IsLineInfoTagged(e->value)) return; | 2068 if (e->value != NULL && !IsLineInfoTagged(e->value)) return; |
2069 | 2069 |
2070 GDBJITLineInfo* lineinfo = UntagLineInfo(e->value); | 2070 GDBJITLineInfo* lineinfo = UntagLineInfo(e->value); |
2071 CodeDescription code_desc(name, | 2071 CodeDescription code_desc(name, |
2072 code, | 2072 code, |
2073 script != NULL ? Handle<Script>(script) | 2073 script != NULL ? Handle<Script>(script) |
2074 : Handle<Script>(), | 2074 : Handle<Script>(), |
2075 lineinfo, | 2075 lineinfo, |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2170 ScopedLock lock(mutex.Pointer()); | 2170 ScopedLock lock(mutex.Pointer()); |
2171 ASSERT(!IsLineInfoTagged(line_info)); | 2171 ASSERT(!IsLineInfoTagged(line_info)); |
2172 HashMap::Entry* e = GetEntries()->Lookup(code, HashForCodeObject(code), true); | 2172 HashMap::Entry* e = GetEntries()->Lookup(code, HashForCodeObject(code), true); |
2173 ASSERT(e->value == NULL); | 2173 ASSERT(e->value == NULL); |
2174 e->value = TagLineInfo(line_info); | 2174 e->value = TagLineInfo(line_info); |
2175 } | 2175 } |
2176 | 2176 |
2177 | 2177 |
2178 } } // namespace v8::internal | 2178 } } // namespace v8::internal |
2179 #endif | 2179 #endif |
OLD | NEW |