OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifdef ENABLE_GDB_JIT_INTERFACE | 5 #ifdef ENABLE_GDB_JIT_INTERFACE |
6 #include "v8.h" | 6 #include "v8.h" |
7 #include "gdb-jit.h" | 7 #include "gdb-jit.h" |
8 | 8 |
9 #include "bootstrapper.h" | 9 #include "bootstrapper.h" |
10 #include "compiler.h" | 10 #include "compiler.h" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 return false; | 187 return false; |
188 } | 188 } |
189 | 189 |
190 typedef THeader Header; | 190 typedef THeader Header; |
191 }; | 191 }; |
192 | 192 |
193 | 193 |
194 struct MachOSectionHeader { | 194 struct MachOSectionHeader { |
195 char sectname[16]; | 195 char sectname[16]; |
196 char segname[16]; | 196 char segname[16]; |
197 #if V8_TARGET_ARCH_IA32 | 197 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87 |
198 uint32_t addr; | 198 uint32_t addr; |
199 uint32_t size; | 199 uint32_t size; |
200 #else | 200 #else |
201 uint64_t addr; | 201 uint64_t addr; |
202 uint64_t size; | 202 uint64_t size; |
203 #endif | 203 #endif |
204 uint32_t offset; | 204 uint32_t offset; |
205 uint32_t align; | 205 uint32_t align; |
206 uint32_t reloff; | 206 uint32_t reloff; |
207 uint32_t nreloc; | 207 uint32_t nreloc; |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 uint32_t flags; | 504 uint32_t flags; |
505 #if V8_TARGET_ARCH_X64 | 505 #if V8_TARGET_ARCH_X64 |
506 uint32_t reserved; | 506 uint32_t reserved; |
507 #endif | 507 #endif |
508 }; | 508 }; |
509 | 509 |
510 struct MachOSegmentCommand { | 510 struct MachOSegmentCommand { |
511 uint32_t cmd; | 511 uint32_t cmd; |
512 uint32_t cmdsize; | 512 uint32_t cmdsize; |
513 char segname[16]; | 513 char segname[16]; |
514 #if V8_TARGET_ARCH_IA32 | 514 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87 |
515 uint32_t vmaddr; | 515 uint32_t vmaddr; |
516 uint32_t vmsize; | 516 uint32_t vmsize; |
517 uint32_t fileoff; | 517 uint32_t fileoff; |
518 uint32_t filesize; | 518 uint32_t filesize; |
519 #else | 519 #else |
520 uint64_t vmaddr; | 520 uint64_t vmaddr; |
521 uint64_t vmsize; | 521 uint64_t vmsize; |
522 uint64_t fileoff; | 522 uint64_t fileoff; |
523 uint64_t filesize; | 523 uint64_t filesize; |
524 #endif | 524 #endif |
525 uint32_t maxprot; | 525 uint32_t maxprot; |
526 uint32_t initprot; | 526 uint32_t initprot; |
527 uint32_t nsects; | 527 uint32_t nsects; |
528 uint32_t flags; | 528 uint32_t flags; |
529 }; | 529 }; |
530 | 530 |
531 enum MachOLoadCommandCmd { | 531 enum MachOLoadCommandCmd { |
532 LC_SEGMENT_32 = 0x00000001u, | 532 LC_SEGMENT_32 = 0x00000001u, |
533 LC_SEGMENT_64 = 0x00000019u | 533 LC_SEGMENT_64 = 0x00000019u |
534 }; | 534 }; |
535 | 535 |
536 | 536 |
537 Writer::Slot<MachOHeader> WriteHeader(Writer* w) { | 537 Writer::Slot<MachOHeader> WriteHeader(Writer* w) { |
538 ASSERT(w->position() == 0); | 538 ASSERT(w->position() == 0); |
539 Writer::Slot<MachOHeader> header = w->CreateSlotHere<MachOHeader>(); | 539 Writer::Slot<MachOHeader> header = w->CreateSlotHere<MachOHeader>(); |
540 #if V8_TARGET_ARCH_IA32 | 540 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87 |
541 header->magic = 0xFEEDFACEu; | 541 header->magic = 0xFEEDFACEu; |
542 header->cputype = 7; // i386 | 542 header->cputype = 7; // i386 |
543 header->cpusubtype = 3; // CPU_SUBTYPE_I386_ALL | 543 header->cpusubtype = 3; // CPU_SUBTYPE_I386_ALL |
544 #elif V8_TARGET_ARCH_X64 | 544 #elif V8_TARGET_ARCH_X64 |
545 header->magic = 0xFEEDFACFu; | 545 header->magic = 0xFEEDFACFu; |
546 header->cputype = 7 | 0x01000000; // i386 | 64-bit ABI | 546 header->cputype = 7 | 0x01000000; // i386 | 64-bit ABI |
547 header->cpusubtype = 3; // CPU_SUBTYPE_I386_ALL | 547 header->cpusubtype = 3; // CPU_SUBTYPE_I386_ALL |
548 header->reserved = 0; | 548 header->reserved = 0; |
549 #else | 549 #else |
550 #error Unsupported target architecture. | 550 #error Unsupported target architecture. |
551 #endif | 551 #endif |
552 header->filetype = 0x1; // MH_OBJECT | 552 header->filetype = 0x1; // MH_OBJECT |
553 header->ncmds = 1; | 553 header->ncmds = 1; |
554 header->sizeofcmds = 0; | 554 header->sizeofcmds = 0; |
555 header->flags = 0; | 555 header->flags = 0; |
556 return header; | 556 return header; |
557 } | 557 } |
558 | 558 |
559 | 559 |
560 Writer::Slot<MachOSegmentCommand> WriteSegmentCommand(Writer* w, | 560 Writer::Slot<MachOSegmentCommand> WriteSegmentCommand(Writer* w, |
561 uintptr_t code_start, | 561 uintptr_t code_start, |
562 uintptr_t code_size) { | 562 uintptr_t code_size) { |
563 Writer::Slot<MachOSegmentCommand> cmd = | 563 Writer::Slot<MachOSegmentCommand> cmd = |
564 w->CreateSlotHere<MachOSegmentCommand>(); | 564 w->CreateSlotHere<MachOSegmentCommand>(); |
565 #if V8_TARGET_ARCH_IA32 | 565 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87 |
566 cmd->cmd = LC_SEGMENT_32; | 566 cmd->cmd = LC_SEGMENT_32; |
567 #else | 567 #else |
568 cmd->cmd = LC_SEGMENT_64; | 568 cmd->cmd = LC_SEGMENT_64; |
569 #endif | 569 #endif |
570 cmd->vmaddr = code_start; | 570 cmd->vmaddr = code_start; |
571 cmd->vmsize = code_size; | 571 cmd->vmsize = code_size; |
572 cmd->fileoff = 0; | 572 cmd->fileoff = 0; |
573 cmd->filesize = 0; | 573 cmd->filesize = 0; |
574 cmd->maxprot = 7; | 574 cmd->maxprot = 7; |
575 cmd->initprot = 7; | 575 cmd->initprot = 7; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 uint16_t pht_entry_num; | 642 uint16_t pht_entry_num; |
643 uint16_t sht_entry_size; | 643 uint16_t sht_entry_size; |
644 uint16_t sht_entry_num; | 644 uint16_t sht_entry_num; |
645 uint16_t sht_strtab_index; | 645 uint16_t sht_strtab_index; |
646 }; | 646 }; |
647 | 647 |
648 | 648 |
649 void WriteHeader(Writer* w) { | 649 void WriteHeader(Writer* w) { |
650 ASSERT(w->position() == 0); | 650 ASSERT(w->position() == 0); |
651 Writer::Slot<ELFHeader> header = w->CreateSlotHere<ELFHeader>(); | 651 Writer::Slot<ELFHeader> header = w->CreateSlotHere<ELFHeader>(); |
652 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_ARM | 652 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X87 |
653 const uint8_t ident[16] = | 653 const uint8_t ident[16] = |
654 { 0x7f, 'E', 'L', 'F', 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | 654 { 0x7f, 'E', 'L', 'F', 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
655 #elif V8_TARGET_ARCH_X64 | 655 #elif V8_TARGET_ARCH_X64 |
656 const uint8_t ident[16] = | 656 const uint8_t ident[16] = |
657 { 0x7f, 'E', 'L', 'F', 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | 657 { 0x7f, 'E', 'L', 'F', 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
658 #else | 658 #else |
659 #error Unsupported target architecture. | 659 #error Unsupported target architecture. |
660 #endif | 660 #endif |
661 OS::MemCopy(header->ident, ident, 16); | 661 OS::MemCopy(header->ident, ident, 16); |
662 header->type = 1; | 662 header->type = 1; |
663 #if V8_TARGET_ARCH_IA32 | 663 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87 |
664 header->machine = 3; | 664 header->machine = 3; |
665 #elif V8_TARGET_ARCH_X64 | 665 #elif V8_TARGET_ARCH_X64 |
666 // Processor identification value for x64 is 62 as defined in | 666 // Processor identification value for x64 is 62 as defined in |
667 // System V ABI, AMD64 Supplement | 667 // System V ABI, AMD64 Supplement |
668 // http://www.x86-64.org/documentation/abi.pdf | 668 // http://www.x86-64.org/documentation/abi.pdf |
669 header->machine = 62; | 669 header->machine = 62; |
670 #elif V8_TARGET_ARCH_ARM | 670 #elif V8_TARGET_ARCH_ARM |
671 // Set to EM_ARM, defined as 40, in "ARM ELF File Format" at | 671 // Set to EM_ARM, defined as 40, in "ARM ELF File Format" at |
672 // infocenter.arm.com/help/topic/com.arm.doc.dui0101a/DUI0101A_Elf.pdf | 672 // infocenter.arm.com/help/topic/com.arm.doc.dui0101a/DUI0101A_Elf.pdf |
673 header->machine = 40; | 673 header->machine = 40; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 value(value), | 755 value(value), |
756 size(size), | 756 size(size), |
757 info((binding << 4) | type), | 757 info((binding << 4) | type), |
758 other(0), | 758 other(0), |
759 section(section) { | 759 section(section) { |
760 } | 760 } |
761 | 761 |
762 Binding binding() const { | 762 Binding binding() const { |
763 return static_cast<Binding>(info >> 4); | 763 return static_cast<Binding>(info >> 4); |
764 } | 764 } |
765 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_ARM | 765 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X87 |
766 struct SerializedLayout { | 766 struct SerializedLayout { |
767 SerializedLayout(uint32_t name, | 767 SerializedLayout(uint32_t name, |
768 uintptr_t value, | 768 uintptr_t value, |
769 uintptr_t size, | 769 uintptr_t size, |
770 Binding binding, | 770 Binding binding, |
771 Type type, | 771 Type type, |
772 uint16_t section) | 772 uint16_t section) |
773 : name(name), | 773 : name(name), |
774 value(value), | 774 value(value), |
775 size(size), | 775 size(size), |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1077 w->WriteString("v8value"); | 1077 w->WriteString("v8value"); |
1078 | 1078 |
1079 if (desc_->IsInfoAvailable()) { | 1079 if (desc_->IsInfoAvailable()) { |
1080 Scope* scope = desc_->info()->scope(); | 1080 Scope* scope = desc_->info()->scope(); |
1081 w->WriteULEB128(2); | 1081 w->WriteULEB128(2); |
1082 w->WriteString(desc_->name()); | 1082 w->WriteString(desc_->name()); |
1083 w->Write<intptr_t>(desc_->CodeStart()); | 1083 w->Write<intptr_t>(desc_->CodeStart()); |
1084 w->Write<intptr_t>(desc_->CodeStart() + desc_->CodeSize()); | 1084 w->Write<intptr_t>(desc_->CodeStart() + desc_->CodeSize()); |
1085 Writer::Slot<uint32_t> fb_block_size = w->CreateSlotHere<uint32_t>(); | 1085 Writer::Slot<uint32_t> fb_block_size = w->CreateSlotHere<uint32_t>(); |
1086 uintptr_t fb_block_start = w->position(); | 1086 uintptr_t fb_block_start = w->position(); |
1087 #if V8_TARGET_ARCH_IA32 | 1087 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87 |
1088 w->Write<uint8_t>(DW_OP_reg5); // The frame pointer's here on ia32 | 1088 w->Write<uint8_t>(DW_OP_reg5); // The frame pointer's here on ia32 |
1089 #elif V8_TARGET_ARCH_X64 | 1089 #elif V8_TARGET_ARCH_X64 |
1090 w->Write<uint8_t>(DW_OP_reg6); // and here on x64. | 1090 w->Write<uint8_t>(DW_OP_reg6); // and here on x64. |
1091 #elif V8_TARGET_ARCH_ARM | 1091 #elif V8_TARGET_ARCH_ARM |
1092 UNIMPLEMENTED(); | 1092 UNIMPLEMENTED(); |
1093 #elif V8_TARGET_ARCH_MIPS | 1093 #elif V8_TARGET_ARCH_MIPS |
1094 UNIMPLEMENTED(); | 1094 UNIMPLEMENTED(); |
1095 #else | 1095 #else |
1096 #error Unsupported target architecture. | 1096 #error Unsupported target architecture. |
1097 #endif | 1097 #endif |
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2167 LockGuard<Mutex> lock_guard(mutex.Pointer()); | 2167 LockGuard<Mutex> lock_guard(mutex.Pointer()); |
2168 ASSERT(!IsLineInfoTagged(line_info)); | 2168 ASSERT(!IsLineInfoTagged(line_info)); |
2169 HashMap::Entry* e = GetEntries()->Lookup(code, HashForCodeObject(code), true); | 2169 HashMap::Entry* e = GetEntries()->Lookup(code, HashForCodeObject(code), true); |
2170 ASSERT(e->value == NULL); | 2170 ASSERT(e->value == NULL); |
2171 e->value = TagLineInfo(line_info); | 2171 e->value = TagLineInfo(line_info); |
2172 } | 2172 } |
2173 | 2173 |
2174 | 2174 |
2175 } } // namespace v8::internal | 2175 } } // namespace v8::internal |
2176 #endif | 2176 #endif |
OLD | NEW |