| 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 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
| 8 #include "src/base/platform/platform.h" | 8 #include "src/base/platform/platform.h" |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 }; | 642 }; |
| 643 | 643 |
| 644 | 644 |
| 645 void WriteHeader(Writer* w) { | 645 void WriteHeader(Writer* w) { |
| 646 DCHECK(w->position() == 0); | 646 DCHECK(w->position() == 0); |
| 647 Writer::Slot<ELFHeader> header = w->CreateSlotHere<ELFHeader>(); | 647 Writer::Slot<ELFHeader> header = w->CreateSlotHere<ELFHeader>(); |
| 648 #if (V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X87 || \ | 648 #if (V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X87 || \ |
| 649 (V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_32_BIT)) | 649 (V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_32_BIT)) |
| 650 const uint8_t ident[16] = | 650 const uint8_t ident[16] = |
| 651 { 0x7f, 'E', 'L', 'F', 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | 651 { 0x7f, 'E', 'L', 'F', 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
| 652 #elif V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_64_BIT | 652 #elif(V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_64_BIT) || \ |
| 653 (V8_TARGET_ARCH_PPC64 && V8_TARGET_LITTLE_ENDIAN) |
| 653 const uint8_t ident[16] = | 654 const uint8_t ident[16] = |
| 654 { 0x7f, 'E', 'L', 'F', 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | 655 { 0x7f, 'E', 'L', 'F', 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
| 656 #elif V8_TARGET_ARCH_PPC64 && V8_TARGET_BIG_ENDIAN && V8_OS_LINUX |
| 657 const uint8_t ident[16] = {0x7f, 'E', 'L', 'F', 2, 2, 1, 0, |
| 658 0, 0, 0, 0, 0, 0, 0, 0}; |
| 655 #else | 659 #else |
| 656 #error Unsupported target architecture. | 660 #error Unsupported target architecture. |
| 657 #endif | 661 #endif |
| 658 memcpy(header->ident, ident, 16); | 662 memcpy(header->ident, ident, 16); |
| 659 header->type = 1; | 663 header->type = 1; |
| 660 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87 | 664 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87 |
| 661 header->machine = 3; | 665 header->machine = 3; |
| 662 #elif V8_TARGET_ARCH_X64 | 666 #elif V8_TARGET_ARCH_X64 |
| 663 // Processor identification value for x64 is 62 as defined in | 667 // Processor identification value for x64 is 62 as defined in |
| 664 // System V ABI, AMD64 Supplement | 668 // System V ABI, AMD64 Supplement |
| 665 // http://www.x86-64.org/documentation/abi.pdf | 669 // http://www.x86-64.org/documentation/abi.pdf |
| 666 header->machine = 62; | 670 header->machine = 62; |
| 667 #elif V8_TARGET_ARCH_ARM | 671 #elif V8_TARGET_ARCH_ARM |
| 668 // Set to EM_ARM, defined as 40, in "ARM ELF File Format" at | 672 // Set to EM_ARM, defined as 40, in "ARM ELF File Format" at |
| 669 // infocenter.arm.com/help/topic/com.arm.doc.dui0101a/DUI0101A_Elf.pdf | 673 // infocenter.arm.com/help/topic/com.arm.doc.dui0101a/DUI0101A_Elf.pdf |
| 670 header->machine = 40; | 674 header->machine = 40; |
| 675 #elif V8_TARGET_ARCH_PPC64 && V8_OS_LINUX |
| 676 // Set to EM_PPC64, defined as 21, in Power ABI, |
| 677 // Join the next 4 lines, omitting the spaces and double-slashes. |
| 678 // https://www-03.ibm.com/technologyconnect/tgcm/TGCMFileServlet.wss/ |
| 679 // ABI64BitOpenPOWERv1.1_16July2015_pub.pdf? |
| 680 // id=B81AEC1A37F5DAF185257C3E004E8845&linkid=1n0000&c_t= |
| 681 // c9xw7v5dzsj7gt1ifgf4cjbcnskqptmr |
| 682 header->machine = 21; |
| 671 #else | 683 #else |
| 672 #error Unsupported target architecture. | 684 #error Unsupported target architecture. |
| 673 #endif | 685 #endif |
| 674 header->version = 1; | 686 header->version = 1; |
| 675 header->entry = 0; | 687 header->entry = 0; |
| 676 header->pht_offset = 0; | 688 header->pht_offset = 0; |
| 677 header->sht_offset = sizeof(ELFHeader); // Section table follows header. | 689 header->sht_offset = sizeof(ELFHeader); // Section table follows header. |
| 678 header->flags = 0; | 690 header->flags = 0; |
| 679 header->header_size = sizeof(ELFHeader); | 691 header->header_size = sizeof(ELFHeader); |
| 680 header->pht_entry_size = 0; | 692 header->pht_entry_size = 0; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 section(section) { | 788 section(section) { |
| 777 } | 789 } |
| 778 | 790 |
| 779 uint32_t name; | 791 uint32_t name; |
| 780 uintptr_t value; | 792 uintptr_t value; |
| 781 uintptr_t size; | 793 uintptr_t size; |
| 782 uint8_t info; | 794 uint8_t info; |
| 783 uint8_t other; | 795 uint8_t other; |
| 784 uint16_t section; | 796 uint16_t section; |
| 785 }; | 797 }; |
| 786 #elif V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_64_BIT | 798 #elif(V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_64_BIT) || \ |
| 799 (V8_TARGET_ARCH_PPC64 && V8_OS_LINUX) |
| 787 struct SerializedLayout { | 800 struct SerializedLayout { |
| 788 SerializedLayout(uint32_t name, | 801 SerializedLayout(uint32_t name, |
| 789 uintptr_t value, | 802 uintptr_t value, |
| 790 uintptr_t size, | 803 uintptr_t size, |
| 791 Binding binding, | 804 Binding binding, |
| 792 Type type, | 805 Type type, |
| 793 uint16_t section) | 806 uint16_t section) |
| 794 : name(name), | 807 : name(name), |
| 795 info((binding << 4) | type), | 808 info((binding << 4) | type), |
| 796 other(0), | 809 other(0), |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 // DWARF2 standard | 1067 // DWARF2 standard |
| 1055 enum DWARF2LocationOp { | 1068 enum DWARF2LocationOp { |
| 1056 DW_OP_reg0 = 0x50, | 1069 DW_OP_reg0 = 0x50, |
| 1057 DW_OP_reg1 = 0x51, | 1070 DW_OP_reg1 = 0x51, |
| 1058 DW_OP_reg2 = 0x52, | 1071 DW_OP_reg2 = 0x52, |
| 1059 DW_OP_reg3 = 0x53, | 1072 DW_OP_reg3 = 0x53, |
| 1060 DW_OP_reg4 = 0x54, | 1073 DW_OP_reg4 = 0x54, |
| 1061 DW_OP_reg5 = 0x55, | 1074 DW_OP_reg5 = 0x55, |
| 1062 DW_OP_reg6 = 0x56, | 1075 DW_OP_reg6 = 0x56, |
| 1063 DW_OP_reg7 = 0x57, | 1076 DW_OP_reg7 = 0x57, |
| 1077 DW_OP_reg8 = 0x58, |
| 1078 DW_OP_reg9 = 0x59, |
| 1079 DW_OP_reg10 = 0x5a, |
| 1080 DW_OP_reg11 = 0x5b, |
| 1081 DW_OP_reg12 = 0x5c, |
| 1082 DW_OP_reg13 = 0x5d, |
| 1083 DW_OP_reg14 = 0x5e, |
| 1084 DW_OP_reg15 = 0x5f, |
| 1085 DW_OP_reg16 = 0x60, |
| 1086 DW_OP_reg17 = 0x61, |
| 1087 DW_OP_reg18 = 0x62, |
| 1088 DW_OP_reg19 = 0x63, |
| 1089 DW_OP_reg20 = 0x64, |
| 1090 DW_OP_reg21 = 0x65, |
| 1091 DW_OP_reg22 = 0x66, |
| 1092 DW_OP_reg23 = 0x67, |
| 1093 DW_OP_reg24 = 0x68, |
| 1094 DW_OP_reg25 = 0x69, |
| 1095 DW_OP_reg26 = 0x6a, |
| 1096 DW_OP_reg27 = 0x6b, |
| 1097 DW_OP_reg28 = 0x6c, |
| 1098 DW_OP_reg29 = 0x6d, |
| 1099 DW_OP_reg30 = 0x6e, |
| 1100 DW_OP_reg31 = 0x6f, |
| 1064 DW_OP_fbreg = 0x91 // 1 param: SLEB128 offset | 1101 DW_OP_fbreg = 0x91 // 1 param: SLEB128 offset |
| 1065 }; | 1102 }; |
| 1066 | 1103 |
| 1067 enum DWARF2Encoding { | 1104 enum DWARF2Encoding { |
| 1068 DW_ATE_ADDRESS = 0x1, | 1105 DW_ATE_ADDRESS = 0x1, |
| 1069 DW_ATE_SIGNED = 0x5 | 1106 DW_ATE_SIGNED = 0x5 |
| 1070 }; | 1107 }; |
| 1071 | 1108 |
| 1072 bool WriteBodyInternal(Writer* w) { | 1109 bool WriteBodyInternal(Writer* w) { |
| 1073 uintptr_t cu_start = w->position(); | 1110 uintptr_t cu_start = w->position(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1099 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87 | 1136 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87 |
| 1100 w->Write<uint8_t>(DW_OP_reg5); // The frame pointer's here on ia32 | 1137 w->Write<uint8_t>(DW_OP_reg5); // The frame pointer's here on ia32 |
| 1101 #elif V8_TARGET_ARCH_X64 | 1138 #elif V8_TARGET_ARCH_X64 |
| 1102 w->Write<uint8_t>(DW_OP_reg6); // and here on x64. | 1139 w->Write<uint8_t>(DW_OP_reg6); // and here on x64. |
| 1103 #elif V8_TARGET_ARCH_ARM | 1140 #elif V8_TARGET_ARCH_ARM |
| 1104 UNIMPLEMENTED(); | 1141 UNIMPLEMENTED(); |
| 1105 #elif V8_TARGET_ARCH_MIPS | 1142 #elif V8_TARGET_ARCH_MIPS |
| 1106 UNIMPLEMENTED(); | 1143 UNIMPLEMENTED(); |
| 1107 #elif V8_TARGET_ARCH_MIPS64 | 1144 #elif V8_TARGET_ARCH_MIPS64 |
| 1108 UNIMPLEMENTED(); | 1145 UNIMPLEMENTED(); |
| 1146 #elif V8_TARGET_ARCH_PPC64 && V8_OS_LINUX |
| 1147 w->Write<uint8_t>(DW_OP_reg31); // The frame pointer is here on PPC64. |
| 1109 #else | 1148 #else |
| 1110 #error Unsupported target architecture. | 1149 #error Unsupported target architecture. |
| 1111 #endif | 1150 #endif |
| 1112 fb_block_size.set(static_cast<uint32_t>(w->position() - fb_block_start)); | 1151 fb_block_size.set(static_cast<uint32_t>(w->position() - fb_block_start)); |
| 1113 | 1152 |
| 1114 int params = scope->ParameterCount(); | 1153 int params = scope->ParameterCount(); |
| 1115 int slots = scope->StackLocalCount(); | 1154 int slots = scope->StackLocalCount(); |
| 1116 int context_slots = scope->ContextLocalCount(); | 1155 int context_slots = scope->ContextLocalCount(); |
| 1117 // The real slot ID is internal_slots + context_slot_id. | 1156 // The real slot ID is internal_slots + context_slot_id. |
| 1118 int internal_slots = Context::MIN_CONTEXT_SLOTS; | 1157 int internal_slots = Context::MIN_CONTEXT_SLOTS; |
| (...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2157 LineInfo* line_info = reinterpret_cast<LineInfo*>(event->user_data); | 2196 LineInfo* line_info = reinterpret_cast<LineInfo*>(event->user_data); |
| 2158 PutLineInfo(reinterpret_cast<Address>(event->code_start), line_info); | 2197 PutLineInfo(reinterpret_cast<Address>(event->code_start), line_info); |
| 2159 break; | 2198 break; |
| 2160 } | 2199 } |
| 2161 } | 2200 } |
| 2162 } | 2201 } |
| 2163 #endif | 2202 #endif |
| 2164 } // namespace GDBJITInterface | 2203 } // namespace GDBJITInterface |
| 2165 } // namespace internal | 2204 } // namespace internal |
| 2166 } // namespace v8 | 2205 } // namespace v8 |
| OLD | NEW |