Lines Matching refs:w
77 Slot(Writer* w, uintptr_t offset) : w_(w), offset_(offset) { } in Slot() argument
341 virtual void WriteBody(Writer::Slot<Header> header, Writer* w) { in WriteBody() argument
342 uintptr_t start = w->position(); in WriteBody()
343 if (WriteBody(w)) { in WriteBody()
344 uintptr_t end = w->position(); in WriteBody()
350 virtual bool WriteBody(Writer* w) { in WriteBody() argument
453 void AttachWriter(Writer* w) { in AttachWriter() argument
454 writer_ = w; in AttachWriter()
465 virtual void WriteBody(Writer::Slot<Header> header, Writer* w) { in WriteBody() argument
508 void Write(Writer* w, uintptr_t code_start, uintptr_t code_size) { in Write() argument
509 Writer::Slot<MachOHeader> header = WriteHeader(w); in Write()
510 uintptr_t load_command_start = w->position(); in Write()
511 Writer::Slot<MachOSegmentCommand> cmd = WriteSegmentCommand(w, in Write()
514 WriteSections(w, cmd, header, load_command_start); in Write()
558 Writer::Slot<MachOHeader> WriteHeader(Writer* w) { in WriteHeader() argument
559 ASSERT(w->position() == 0); in WriteHeader()
560 Writer::Slot<MachOHeader> header = w->CreateSlotHere<MachOHeader>(); in WriteHeader()
581 Writer::Slot<MachOSegmentCommand> WriteSegmentCommand(Writer* w, in WriteSegmentCommand() argument
585 w->CreateSlotHere<MachOSegmentCommand>(); in WriteSegmentCommand()
606 void WriteSections(Writer* w, in WriteSections() argument
611 w->CreateSlotsHere<MachOSection::Header>(sections_.length()); in WriteSections()
612 cmd->fileoff = w->position(); in WriteSections()
613 header->sizeofcmds = w->position() - load_command_start; in WriteSections()
616 sections_[section]->WriteBody(headers.at(section), w); in WriteSections()
618 cmd->filesize = w->position() - (uintptr_t)cmd->fileoff; in WriteSections()
635 void Write(Writer* w) { in Write() argument
636 WriteHeader(w); in Write()
637 WriteSectionTable(w); in Write()
638 WriteSections(w); in Write()
670 void WriteHeader(Writer* w) { in WriteHeader() argument
671 ASSERT(w->position() == 0); in WriteHeader()
672 Writer::Slot<ELFHeader> header = w->CreateSlotHere<ELFHeader>(); in WriteHeader()
711 void WriteSectionTable(Writer* w) { in WriteSectionTable() argument
713 ASSERT(w->position() == sizeof(ELFHeader)); in WriteSectionTable()
716 w->CreateSlotsHere<ELFSection::Header>(sections_.length()); in WriteSectionTable()
720 strtab->AttachWriter(w); in WriteSectionTable()
733 void WriteSections(Writer* w) { in WriteSections() argument
735 w->SlotAt<ELFSection::Header>(sizeof(ELFHeader)); in WriteSections()
740 sections_[i]->WriteBody(headers.at(i), w); in WriteSections()
861 virtual void WriteBody(Writer::Slot<Header> header, Writer* w) { in WriteBody() argument
862 w->Align(header->alignment); in WriteBody()
864 header->offset = w->position(); in WriteBody()
867 w->CreateSlotsHere<ELFSymbol::SerializedLayout>(total_symbols); in WriteBody()
869 header->size = w->position() - header->offset; in WriteBody()
873 static_cast<StringTable*>(w->debug_object()->SectionAt(index() + 1)); in WriteBody()
874 strtab->AttachWriter(w); in WriteBody()
1077 bool WriteBody(Writer* w) { in WriteBody() argument
1078 uintptr_t cu_start = w->position(); in WriteBody()
1079 Writer::Slot<uint32_t> size = w->CreateSlotHere<uint32_t>(); in WriteBody()
1080 uintptr_t start = w->position(); in WriteBody()
1081 w->Write<uint16_t>(2); // DWARF version. in WriteBody()
1082 w->Write<uint32_t>(0); // Abbreviation table offset. in WriteBody()
1083 w->Write<uint8_t>(sizeof(intptr_t)); in WriteBody()
1085 w->WriteULEB128(1); // Abbreviation code. in WriteBody()
1086 w->WriteString(*desc_->GetFilename()); in WriteBody()
1087 w->Write<intptr_t>(desc_->CodeStart()); in WriteBody()
1088 w->Write<intptr_t>(desc_->CodeStart() + desc_->CodeSize()); in WriteBody()
1089 w->Write<uint32_t>(0); in WriteBody()
1091 uint32_t ty_offset = static_cast<uint32_t>(w->position() - cu_start); in WriteBody()
1092 w->WriteULEB128(3); in WriteBody()
1093 w->Write<uint8_t>(kPointerSize); in WriteBody()
1094 w->WriteString("v8value"); in WriteBody()
1099 w->WriteULEB128(2); in WriteBody()
1100 w->WriteString(desc_->name()); in WriteBody()
1101 w->Write<intptr_t>(desc_->CodeStart()); in WriteBody()
1102 w->Write<intptr_t>(desc_->CodeStart() + desc_->CodeSize()); in WriteBody()
1103 Writer::Slot<uint32_t> fb_block_size = w->CreateSlotHere<uint32_t>(); in WriteBody()
1104 uintptr_t fb_block_start = w->position(); in WriteBody()
1106 w->Write<uint8_t>(DW_OP_reg5); // The frame pointer's here on ia32 in WriteBody()
1108 w->Write<uint8_t>(DW_OP_reg6); // and here on x64. in WriteBody()
1112 fb_block_size.set(static_cast<uint32_t>(w->position() - fb_block_start)); in WriteBody()
1123 w->WriteULEB128(current_abbreviation++); in WriteBody()
1124 w->WriteString( in WriteBody()
1126 w->Write<uint32_t>(ty_offset); in WriteBody()
1127 Writer::Slot<uint32_t> block_size = w->CreateSlotHere<uint32_t>(); in WriteBody()
1128 uintptr_t block_start = w->position(); in WriteBody()
1129 w->Write<uint8_t>(DW_OP_fbreg); in WriteBody()
1130 w->WriteSLEB128( in WriteBody()
1133 block_size.set(static_cast<uint32_t>(w->position() - block_start)); in WriteBody()
1140 w->WriteULEB128(current_abbreviation++); in WriteBody()
1143 w->WriteString(builder.Finalize()); in WriteBody()
1152 w->WriteULEB128(current_abbreviation++); in WriteBody()
1153 w->WriteString(".closure"); in WriteBody()
1154 w->WriteULEB128(current_abbreviation++); in WriteBody()
1155 w->WriteString(".previous"); in WriteBody()
1156 w->WriteULEB128(current_abbreviation++); in WriteBody()
1157 w->WriteString(".extension"); in WriteBody()
1158 w->WriteULEB128(current_abbreviation++); in WriteBody()
1159 w->WriteString(".global"); in WriteBody()
1164 w->WriteULEB128(current_abbreviation++); in WriteBody()
1167 w->WriteString(builder.Finalize()); in WriteBody()
1171 w->WriteULEB128(current_abbreviation++); in WriteBody()
1172 w->WriteString( in WriteBody()
1174 w->Write<uint32_t>(ty_offset); in WriteBody()
1175 Writer::Slot<uint32_t> block_size = w->CreateSlotHere<uint32_t>(); in WriteBody()
1176 uintptr_t block_start = w->position(); in WriteBody()
1177 w->Write<uint8_t>(DW_OP_fbreg); in WriteBody()
1178 w->WriteSLEB128( in WriteBody()
1181 block_size.set(static_cast<uint32_t>(w->position() - block_start)); in WriteBody()
1185 w->WriteULEB128(current_abbreviation++); in WriteBody()
1186 w->WriteString("__function"); in WriteBody()
1187 w->Write<uint32_t>(ty_offset); in WriteBody()
1188 Writer::Slot<uint32_t> block_size = w->CreateSlotHere<uint32_t>(); in WriteBody()
1189 uintptr_t block_start = w->position(); in WriteBody()
1190 w->Write<uint8_t>(DW_OP_fbreg); in WriteBody()
1191 w->WriteSLEB128(JavaScriptFrameConstants::kFunctionOffset); in WriteBody()
1192 block_size.set(static_cast<uint32_t>(w->position() - block_start)); in WriteBody()
1196 w->WriteULEB128(current_abbreviation++); in WriteBody()
1197 w->WriteString("__context"); in WriteBody()
1198 w->Write<uint32_t>(ty_offset); in WriteBody()
1199 Writer::Slot<uint32_t> block_size = w->CreateSlotHere<uint32_t>(); in WriteBody()
1200 uintptr_t block_start = w->position(); in WriteBody()
1201 w->Write<uint8_t>(DW_OP_fbreg); in WriteBody()
1202 w->WriteSLEB128(StandardFrameConstants::kContextOffset); in WriteBody()
1203 block_size.set(static_cast<uint32_t>(w->position() - block_start)); in WriteBody()
1207 size.set(static_cast<uint32_t>(w->position() - start)); in WriteBody()
1271 void WriteVariableAbbreviation(Writer* w, in WriteVariableAbbreviation() argument
1275 w->WriteULEB128(abbreviation_code); in WriteVariableAbbreviation()
1276 w->WriteULEB128(is_parameter ? DW_TAG_FORMAL_PARAMETER : DW_TAG_VARIABLE); in WriteVariableAbbreviation()
1277 w->Write<uint8_t>(DW_CHILDREN_NO); in WriteVariableAbbreviation()
1278 w->WriteULEB128(DW_AT_NAME); in WriteVariableAbbreviation()
1279 w->WriteULEB128(DW_FORM_STRING); in WriteVariableAbbreviation()
1281 w->WriteULEB128(DW_AT_TYPE); in WriteVariableAbbreviation()
1282 w->WriteULEB128(DW_FORM_REF4); in WriteVariableAbbreviation()
1283 w->WriteULEB128(DW_AT_LOCATION); in WriteVariableAbbreviation()
1284 w->WriteULEB128(DW_FORM_BLOCK4); in WriteVariableAbbreviation()
1286 w->WriteULEB128(0); in WriteVariableAbbreviation()
1287 w->WriteULEB128(0); in WriteVariableAbbreviation()
1290 bool WriteBody(Writer* w) { in WriteBody() argument
1294 w->WriteULEB128(current_abbreviation++); in WriteBody()
1295 w->WriteULEB128(DW_TAG_COMPILE_UNIT); in WriteBody()
1296 w->Write<uint8_t>(extra_info ? DW_CHILDREN_YES : DW_CHILDREN_NO); in WriteBody()
1297 w->WriteULEB128(DW_AT_NAME); in WriteBody()
1298 w->WriteULEB128(DW_FORM_STRING); in WriteBody()
1299 w->WriteULEB128(DW_AT_LOW_PC); in WriteBody()
1300 w->WriteULEB128(DW_FORM_ADDR); in WriteBody()
1301 w->WriteULEB128(DW_AT_HIGH_PC); in WriteBody()
1302 w->WriteULEB128(DW_FORM_ADDR); in WriteBody()
1303 w->WriteULEB128(DW_AT_STMT_LIST); in WriteBody()
1304 w->WriteULEB128(DW_FORM_DATA4); in WriteBody()
1305 w->WriteULEB128(0); in WriteBody()
1306 w->WriteULEB128(0); in WriteBody()
1322 w->WriteULEB128(current_abbreviation++); // Abbreviation code. in WriteBody()
1323 w->WriteULEB128(DW_TAG_SUBPROGRAM); in WriteBody()
1324 w->Write<uint8_t>( in WriteBody()
1326 w->WriteULEB128(DW_AT_NAME); in WriteBody()
1327 w->WriteULEB128(DW_FORM_STRING); in WriteBody()
1328 w->WriteULEB128(DW_AT_LOW_PC); in WriteBody()
1329 w->WriteULEB128(DW_FORM_ADDR); in WriteBody()
1330 w->WriteULEB128(DW_AT_HIGH_PC); in WriteBody()
1331 w->WriteULEB128(DW_FORM_ADDR); in WriteBody()
1332 w->WriteULEB128(DW_AT_FRAME_BASE); in WriteBody()
1333 w->WriteULEB128(DW_FORM_BLOCK4); in WriteBody()
1334 w->WriteULEB128(0); in WriteBody()
1335 w->WriteULEB128(0); in WriteBody()
1337 w->WriteULEB128(current_abbreviation++); in WriteBody()
1338 w->WriteULEB128(DW_TAG_STRUCTURE_TYPE); in WriteBody()
1339 w->Write<uint8_t>(DW_CHILDREN_NO); in WriteBody()
1340 w->WriteULEB128(DW_AT_BYTE_SIZE); in WriteBody()
1341 w->WriteULEB128(DW_FORM_DATA1); in WriteBody()
1342 w->WriteULEB128(DW_AT_NAME); in WriteBody()
1343 w->WriteULEB128(DW_FORM_STRING); in WriteBody()
1344 w->WriteULEB128(0); in WriteBody()
1345 w->WriteULEB128(0); in WriteBody()
1348 WriteVariableAbbreviation(w, current_abbreviation++, true, true); in WriteBody()
1352 WriteVariableAbbreviation(w, current_abbreviation++, false, false); in WriteBody()
1358 WriteVariableAbbreviation(w, current_abbreviation++, false, false); in WriteBody()
1364 WriteVariableAbbreviation(w, current_abbreviation++, false, false); in WriteBody()
1368 WriteVariableAbbreviation(w, current_abbreviation++, true, false); in WriteBody()
1372 WriteVariableAbbreviation(w, current_abbreviation++, true, false); in WriteBody()
1375 WriteVariableAbbreviation(w, current_abbreviation++, true, false); in WriteBody()
1378 w->WriteULEB128(0); // Terminate the sibling list. in WriteBody()
1382 w->WriteULEB128(0); // Terminate the table. in WriteBody()
1421 bool WriteBody(Writer* w) { in WriteBody() argument
1423 Writer::Slot<uint32_t> total_length = w->CreateSlotHere<uint32_t>(); in WriteBody()
1424 uintptr_t start = w->position(); in WriteBody()
1432 w->Write<uint16_t>(2); // Field version. in WriteBody()
1433 Writer::Slot<uint32_t> prologue_length = w->CreateSlotHere<uint32_t>(); in WriteBody()
1434 uintptr_t prologue_start = w->position(); in WriteBody()
1435 w->Write<uint8_t>(1); // Field minimum_instruction_length. in WriteBody()
1436 w->Write<uint8_t>(1); // Field default_is_stmt. in WriteBody()
1437 w->Write<int8_t>(line_base); // Field line_base. in WriteBody()
1438 w->Write<uint8_t>(line_range); // Field line_range. in WriteBody()
1439 w->Write<uint8_t>(opcode_base); // Field opcode_base. in WriteBody()
1440 w->Write<uint8_t>(0); // DW_LNS_COPY operands count. in WriteBody()
1441 w->Write<uint8_t>(1); // DW_LNS_ADVANCE_PC operands count. in WriteBody()
1442 w->Write<uint8_t>(1); // DW_LNS_ADVANCE_LINE operands count. in WriteBody()
1443 w->Write<uint8_t>(1); // DW_LNS_SET_FILE operands count. in WriteBody()
1444 w->Write<uint8_t>(1); // DW_LNS_SET_COLUMN operands count. in WriteBody()
1445 w->Write<uint8_t>(0); // DW_LNS_NEGATE_STMT operands count. in WriteBody()
1446 w->Write<uint8_t>(0); // Empty include_directories sequence. in WriteBody()
1447 w->WriteString(*desc_->GetFilename()); // File name. in WriteBody()
1448 w->WriteULEB128(0); // Current directory. in WriteBody()
1449 w->WriteULEB128(0); // Unknown modification time. in WriteBody()
1450 w->WriteULEB128(0); // Unknown file size. in WriteBody()
1451 w->Write<uint8_t>(0); in WriteBody()
1452 prologue_length.set(static_cast<uint32_t>(w->position() - prologue_start)); in WriteBody()
1454 WriteExtendedOpcode(w, DW_LNE_SET_ADDRESS, sizeof(intptr_t)); in WriteBody()
1455 w->Write<intptr_t>(desc_->CodeStart()); in WriteBody()
1456 w->Write<uint8_t>(DW_LNS_COPY); in WriteBody()
1483 w->Write<uint8_t>(DW_LNS_NEGATE_STMT); in WriteBody()
1486 w->Write<uint8_t>(DW_LNS_NEGATE_STMT); in WriteBody()
1507 w->Write<uint8_t>(special_opcode); in WriteBody()
1509 w->Write<uint8_t>(DW_LNS_ADVANCE_PC); in WriteBody()
1510 w->WriteSLEB128(pc_diff); in WriteBody()
1511 w->Write<uint8_t>(DW_LNS_ADVANCE_LINE); in WriteBody()
1512 w->WriteSLEB128(line_diff); in WriteBody()
1513 w->Write<uint8_t>(DW_LNS_COPY); in WriteBody()
1522 w->Write<uint8_t>(DW_LNS_ADVANCE_PC); in WriteBody()
1523 w->WriteSLEB128(desc_->CodeSize() - pc); in WriteBody()
1524 WriteExtendedOpcode(w, DW_LNE_END_SEQUENCE, 0); in WriteBody()
1525 total_length.set(static_cast<uint32_t>(w->position() - start)); in WriteBody()
1530 void WriteExtendedOpcode(Writer* w, in WriteExtendedOpcode() argument
1533 w->Write<uint8_t>(0); in WriteExtendedOpcode()
1534 w->WriteULEB128(operands_size + 1); in WriteExtendedOpcode()
1535 w->Write<uint8_t>(op); in WriteExtendedOpcode()
1561 virtual bool WriteBody(Writer* w);
1563 int WriteCIE(Writer* w);
1564 void WriteFDE(Writer* w, int);
1566 void WriteFDEStateOnEntry(Writer* w);
1567 void WriteFDEStateAfterRBPPush(Writer* w);
1568 void WriteFDEStateAfterRBPSet(Writer* w);
1569 void WriteFDEStateAfterRBPPop(Writer* w);
1571 void WriteLength(Writer* w,
1627 void UnwindInfoSection::WriteLength(Writer* w, in WriteLength() argument
1630 uint32_t align = (w->position() - initial_position) % kPointerSize; in WriteLength()
1634 w->Write<uint8_t>(DW_CFA_NOP); in WriteLength()
1638 ASSERT((w->position() - initial_position) % kPointerSize == 0); in WriteLength()
1639 length_slot->set(w->position() - initial_position); in WriteLength()
1652 int UnwindInfoSection::WriteCIE(Writer* w) { in WriteCIE() argument
1653 Writer::Slot<uint32_t> cie_length_slot = w->CreateSlotHere<uint32_t>(); in WriteCIE()
1654 uint32_t cie_position = w->position(); in WriteCIE()
1659 w->Write<uint32_t>(CIE_ID); in WriteCIE()
1660 w->Write<uint8_t>(CIE_VERSION); in WriteCIE()
1661 w->Write<uint8_t>(0); // Null augmentation string. in WriteCIE()
1662 w->WriteSLEB128(CODE_ALIGN_FACTOR); in WriteCIE()
1663 w->WriteSLEB128(DATA_ALIGN_FACTOR); in WriteCIE()
1664 w->Write<uint8_t>(RETURN_ADDRESS_REGISTER); in WriteCIE()
1666 WriteLength(w, &cie_length_slot, cie_position); in WriteCIE()
1672 void UnwindInfoSection::WriteFDE(Writer* w, int cie_position) { in WriteFDE() argument
1674 Writer::Slot<uint32_t> fde_length_slot = w->CreateSlotHere<uint32_t>(); in WriteFDE()
1675 int fde_position = w->position(); in WriteFDE()
1676 w->Write<int32_t>(fde_position - cie_position + 4); in WriteFDE()
1678 w->Write<uintptr_t>(desc_->CodeStart()); in WriteFDE()
1679 w->Write<uintptr_t>(desc_->CodeSize()); in WriteFDE()
1681 WriteFDEStateOnEntry(w); in WriteFDE()
1682 WriteFDEStateAfterRBPPush(w); in WriteFDE()
1683 WriteFDEStateAfterRBPSet(w); in WriteFDE()
1684 WriteFDEStateAfterRBPPop(w); in WriteFDE()
1686 WriteLength(w, &fde_length_slot, fde_position); in WriteFDE()
1690 void UnwindInfoSection::WriteFDEStateOnEntry(Writer* w) { in WriteFDEStateOnEntry() argument
1696 w->Write<uint8_t>(DW_CFA_DEF_CFA_SF); in WriteFDEStateOnEntry()
1697 w->WriteULEB128(AMD64_RSP); in WriteFDEStateOnEntry()
1698 w->WriteSLEB128(-kPointerSize); in WriteFDEStateOnEntry()
1702 w->Write<uint8_t>(DW_CFA_OFFSET_EXTENDED); in WriteFDEStateOnEntry()
1703 w->WriteULEB128(AMD64_RA); in WriteFDEStateOnEntry()
1704 w->WriteSLEB128(StandardFrameConstants::kCallerPCOffset); in WriteFDEStateOnEntry()
1707 w->Write<uint8_t>(DW_CFA_SAME_VALUE); in WriteFDEStateOnEntry()
1708 w->WriteULEB128(AMD64_RBP); in WriteFDEStateOnEntry()
1711 w->Write<uint8_t>(DW_CFA_SET_LOC); in WriteFDEStateOnEntry()
1712 w->Write<uint64_t>( in WriteFDEStateOnEntry()
1717 void UnwindInfoSection::WriteFDEStateAfterRBPPush(Writer* w) { in WriteFDEStateAfterRBPPush() argument
1722 w->Write<uint8_t>(DW_CFA_DEF_CFA_OFFSET); in WriteFDEStateAfterRBPPush()
1723 w->WriteULEB128(0); in WriteFDEStateAfterRBPPush()
1727 w->Write<uint8_t>(DW_CFA_OFFSET_EXTENDED); in WriteFDEStateAfterRBPPush()
1728 w->WriteULEB128(AMD64_RBP); in WriteFDEStateAfterRBPPush()
1729 w->WriteSLEB128(StandardFrameConstants::kCallerFPOffset); in WriteFDEStateAfterRBPPush()
1732 w->Write<uint8_t>(DW_CFA_SET_LOC); in WriteFDEStateAfterRBPPush()
1733 w->Write<uint64_t>( in WriteFDEStateAfterRBPPush()
1738 void UnwindInfoSection::WriteFDEStateAfterRBPSet(Writer* w) { in WriteFDEStateAfterRBPSet() argument
1742 w->Write<uint8_t>(DW_CFA_DEF_CFA); in WriteFDEStateAfterRBPSet()
1743 w->WriteULEB128(AMD64_RBP); in WriteFDEStateAfterRBPSet()
1744 w->WriteULEB128(0); in WriteFDEStateAfterRBPSet()
1747 w->Write<uint8_t>(DW_CFA_SET_LOC); in WriteFDEStateAfterRBPSet()
1748 w->Write<uint64_t>( in WriteFDEStateAfterRBPSet()
1753 void UnwindInfoSection::WriteFDEStateAfterRBPPop(Writer* w) { in WriteFDEStateAfterRBPPop() argument
1758 w->Write<uint8_t>(DW_CFA_DEF_CFA_SF); in WriteFDEStateAfterRBPPop()
1759 w->WriteULEB128(AMD64_RSP); in WriteFDEStateAfterRBPPop()
1760 w->WriteSLEB128(-kPointerSize); in WriteFDEStateAfterRBPPop()
1763 w->Write<uint8_t>(DW_CFA_OFFSET_EXTENDED); in WriteFDEStateAfterRBPPop()
1764 w->WriteULEB128(AMD64_RBP); in WriteFDEStateAfterRBPPop()
1765 w->WriteSLEB128(StandardFrameConstants::kCallerFPOffset); in WriteFDEStateAfterRBPPop()
1768 w->Write<uint8_t>(DW_CFA_SET_LOC); in WriteFDEStateAfterRBPPop()
1769 w->Write<uint64_t>(desc_->CodeEnd()); in WriteFDEStateAfterRBPPop()
1773 bool UnwindInfoSection::WriteBody(Writer* w) { in WriteBody() argument
1774 uint32_t cie_position = WriteCIE(w); in WriteBody()
1775 WriteFDE(w, cie_position); in WriteBody()
1911 Writer w(&mach_o); in CreateELFObject() local
1919 mach_o.Write(&w, desc->CodeStart(), desc->CodeSize()); in CreateELFObject()
1922 Writer w(&elf); in CreateELFObject() local
1937 elf.Write(&w); in CreateELFObject()
1940 return CreateCodeEntry(w.buffer(), w.position()); in CreateELFObject()