authorgravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2023-06-23 11:54:06-04:00
committergravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2023-07-20 22:58:13-04:00
loga47212c72e9d156e06cb278ac681e51e11e140b7
tree189aab57b5b54081fb7d86a6a3d47dbe29707850
parentadbc5bbdb317847d1446395d24cd92c0ffc7fc49

- rebase and update to lastest master


3 files changed, 36 insertions(+), 38 deletions(-)

lib/std/debug.zig+13-15
...@@ -988,7 +988,7 @@ pub fn readElfDebugInfo(...@@ -988,7 +988,7 @@ pub fn readElfDebugInfo(
988 if (mem.eql(u8, name, ".gnu_debuglink")) {988 if (mem.eql(u8, name, ".gnu_debuglink")) {
989 const gnu_debuglink = try chopSlice(mapped_mem, shdr.sh_offset, shdr.sh_size);989 const gnu_debuglink = try chopSlice(mapped_mem, shdr.sh_offset, shdr.sh_size);
990 const debug_filename = mem.sliceTo(@ptrCast([*:0]const u8, gnu_debuglink.ptr), 0);990 const debug_filename = mem.sliceTo(@ptrCast([*:0]const u8, gnu_debuglink.ptr), 0);
991 const crc_offset = mem.alignForward(@ptrToInt(&debug_filename[debug_filename.len]) + 1, 4) - @ptrToInt(gnu_debuglink.ptr);991 const crc_offset = mem.alignForward(usize, @intFromPtr(&debug_filename[debug_filename.len]) + 1, 4) - @intFromPtr(gnu_debuglink.ptr);
992 const crc_bytes = gnu_debuglink[crc_offset .. crc_offset + 4];992 const crc_bytes = gnu_debuglink[crc_offset .. crc_offset + 4];
993 separate_debug_crc = mem.readIntSliceNative(u32, crc_bytes);993 separate_debug_crc = mem.readIntSliceNative(u32, crc_bytes);
994 separate_debug_filename = debug_filename;994 separate_debug_filename = debug_filename;
...@@ -1007,11 +1007,9 @@ pub fn readElfDebugInfo(...@@ -1007,11 +1007,9 @@ pub fn readElfDebugInfo(
1007 var section_stream = io.fixedBufferStream(section_bytes);1007 var section_stream = io.fixedBufferStream(section_bytes);
1008 var section_reader = section_stream.reader();1008 var section_reader = section_stream.reader();
1009 const chdr = section_reader.readStruct(elf.Chdr) catch continue;1009 const chdr = section_reader.readStruct(elf.Chdr) catch continue;
1010
1011 // TODO: Support ZSTD
1012 if (chdr.ch_type != .ZLIB) continue;1010 if (chdr.ch_type != .ZLIB) continue;
10131011
1014 var zlib_stream = std.compress.zlib.zlibStream(allocator, section_stream.reader()) catch continue;1012 var zlib_stream = std.compress.zlib.decompressStream(allocator, section_stream.reader()) catch continue;
1015 defer zlib_stream.deinit();1013 defer zlib_stream.deinit();
10161014
1017 var decompressed_section = try allocator.alloc(u8, chdr.ch_size);1015 var decompressed_section = try allocator.alloc(u8, chdr.ch_size);
...@@ -1031,10 +1029,10 @@ pub fn readElfDebugInfo(...@@ -1031,10 +1029,10 @@ pub fn readElfDebugInfo(
1031 }1029 }
10321030
1033 const missing_debug_info =1031 const missing_debug_info =
1034 sections[@enumToInt(DW.DwarfSection.debug_info)] == null or1032 sections[@intFromEnum(DW.DwarfSection.debug_info)] == null or
1035 sections[@enumToInt(DW.DwarfSection.debug_abbrev)] == null or1033 sections[@intFromEnum(DW.DwarfSection.debug_abbrev)] == null or
1036 sections[@enumToInt(DW.DwarfSection.debug_str)] == null or1034 sections[@intFromEnum(DW.DwarfSection.debug_str)] == null or
1037 sections[@enumToInt(DW.DwarfSection.debug_line)] == null;1035 sections[@intFromEnum(DW.DwarfSection.debug_line)] == null;
10381036
1039 // Attempt to load debug info from an external file1037 // Attempt to load debug info from an external file
1040 // See: https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html1038 // See: https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html
...@@ -1537,7 +1535,7 @@ pub const DebugInfo = struct {...@@ -1537,7 +1535,7 @@ pub const DebugInfo = struct {
1537 switch (phdr.p_type) {1535 switch (phdr.p_type) {
1538 elf.PT_NOTE => {1536 elf.PT_NOTE => {
1539 // Look for .note.gnu.build-id1537 // Look for .note.gnu.build-id
1540 const note_bytes = @intToPtr([*]const u8, info.dlpi_addr + phdr.p_vaddr)[0..phdr.p_memsz];1538 const note_bytes = @ptrFromInt([*]const u8, info.dlpi_addr + phdr.p_vaddr)[0..phdr.p_memsz];
1541 const name_size = mem.readIntSliceNative(u32, note_bytes[0..4]);1539 const name_size = mem.readIntSliceNative(u32, note_bytes[0..4]);
1542 if (name_size != 4) continue;1540 if (name_size != 4) continue;
1543 const desc_size = mem.readIntSliceNative(u32, note_bytes[4..8]);1541 const desc_size = mem.readIntSliceNative(u32, note_bytes[4..8]);
...@@ -1547,7 +1545,7 @@ pub const DebugInfo = struct {...@@ -1547,7 +1545,7 @@ pub const DebugInfo = struct {
1547 context.build_id = note_bytes[16..][0..desc_size];1545 context.build_id = note_bytes[16..][0..desc_size];
1548 },1546 },
1549 elf.PT_GNU_EH_FRAME => {1547 elf.PT_GNU_EH_FRAME => {
1550 context.gnu_eh_frame = @intToPtr([*]const u8, info.dlpi_addr + phdr.p_vaddr)[0..phdr.p_memsz];1548 context.gnu_eh_frame = @ptrFromInt([*]const u8, info.dlpi_addr + phdr.p_vaddr)[0..phdr.p_memsz];
1551 },1549 },
1552 else => {},1550 else => {},
1553 }1551 }
...@@ -1575,7 +1573,7 @@ pub const DebugInfo = struct {...@@ -1575,7 +1573,7 @@ pub const DebugInfo = struct {
1575 // are encoded relative to its base address, so we must use the1573 // are encoded relative to its base address, so we must use the
1576 // version that is already memory mapped, and not the one that1574 // version that is already memory mapped, and not the one that
1577 // will be mapped separately from the ELF file.1575 // will be mapped separately from the ELF file.
1578 sections[@enumToInt(DW.DwarfSection.eh_frame_hdr)] = .{1576 sections[@intFromEnum(DW.DwarfSection.eh_frame_hdr)] = .{
1579 .data = eh_frame_hdr,1577 .data = eh_frame_hdr,
1580 .owned = false,1578 .owned = false,
1581 };1579 };
...@@ -1689,10 +1687,10 @@ pub const ModuleDebugInfo = switch (native_os) {...@@ -1689,10 +1687,10 @@ pub const ModuleDebugInfo = switch (native_os) {
1689 }1687 }
16901688
1691 const missing_debug_info =1689 const missing_debug_info =
1692 sections[@enumToInt(DW.DwarfSection.debug_info)] == null or1690 sections[@intFromEnum(DW.DwarfSection.debug_info)] == null or
1693 sections[@enumToInt(DW.DwarfSection.debug_abbrev)] == null or1691 sections[@intFromEnum(DW.DwarfSection.debug_abbrev)] == null or
1694 sections[@enumToInt(DW.DwarfSection.debug_str)] == null or1692 sections[@intFromEnum(DW.DwarfSection.debug_str)] == null or
1695 sections[@enumToInt(DW.DwarfSection.debug_line)] == null;1693 sections[@intFromEnum(DW.DwarfSection.debug_line)] == null;
1696 if (missing_debug_info) return error.MissingDebugInfo;1694 if (missing_debug_info) return error.MissingDebugInfo;
16971695
1698 var di = DW.DwarfInfo{1696 var di = DW.DwarfInfo{
lib/std/dwarf.zig+16-16
...@@ -691,7 +691,7 @@ pub const DwarfInfo = struct {...@@ -691,7 +691,7 @@ pub const DwarfInfo = struct {
691 is_macho: bool,691 is_macho: bool,
692692
693 pub fn section(di: DwarfInfo, dwarf_section: DwarfSection) ?[]const u8 {693 pub fn section(di: DwarfInfo, dwarf_section: DwarfSection) ?[]const u8 {
694 return if (di.sections[@enumToInt(dwarf_section)]) |s| s.data else null;694 return if (di.sections[@intFromEnum(dwarf_section)]) |s| s.data else null;
695 }695 }
696696
697 pub fn deinit(di: *DwarfInfo, allocator: mem.Allocator) void {697 pub fn deinit(di: *DwarfInfo, allocator: mem.Allocator) void {
...@@ -1506,12 +1506,12 @@ pub const DwarfInfo = struct {...@@ -1506,12 +1506,12 @@ pub const DwarfInfo = struct {
1506 if (table_enc == EH.PE.omit) break :blk;1506 if (table_enc == EH.PE.omit) break :blk;
15071507
1508 const eh_frame_ptr = std.math.cast(usize, try readEhPointer(reader, eh_frame_ptr_enc, @sizeOf(usize), .{1508 const eh_frame_ptr = std.math.cast(usize, try readEhPointer(reader, eh_frame_ptr_enc, @sizeOf(usize), .{
1509 .pc_rel_base = @ptrToInt(&eh_frame_hdr[stream.pos]),1509 .pc_rel_base = @intFromPtr(&eh_frame_hdr[stream.pos]),
1510 .follow_indirect = true,1510 .follow_indirect = true,
1511 }, builtin.cpu.arch.endian()) orelse return badDwarf()) orelse return badDwarf();1511 }, builtin.cpu.arch.endian()) orelse return badDwarf()) orelse return badDwarf();
15121512
1513 const fde_count = std.math.cast(usize, try readEhPointer(reader, fde_count_enc, @sizeOf(usize), .{1513 const fde_count = std.math.cast(usize, try readEhPointer(reader, fde_count_enc, @sizeOf(usize), .{
1514 .pc_rel_base = @ptrToInt(&eh_frame_hdr[stream.pos]),1514 .pc_rel_base = @intFromPtr(&eh_frame_hdr[stream.pos]),
1515 .follow_indirect = true,1515 .follow_indirect = true,
1516 }, builtin.cpu.arch.endian()) orelse return badDwarf()) orelse return badDwarf();1516 }, builtin.cpu.arch.endian()) orelse return badDwarf()) orelse return badDwarf();
15171517
...@@ -1538,7 +1538,7 @@ pub const DwarfInfo = struct {...@@ -1538,7 +1538,7 @@ pub const DwarfInfo = struct {
1538 .cie => {1538 .cie => {
1539 const cie = try CommonInformationEntry.parse(1539 const cie = try CommonInformationEntry.parse(
1540 entry_header.entry_bytes,1540 entry_header.entry_bytes,
1541 -@intCast(isize, @ptrToInt(binary_mem.ptr)),1541 -@intCast(isize, @intFromPtr(binary_mem.ptr)),
1542 //@ptrToInt(eh_frame.ptr),1542 //@ptrToInt(eh_frame.ptr),
1543 //@ptrToInt(eh_frame.ptr) - @ptrToInt(binary_mem.ptr),1543 //@ptrToInt(eh_frame.ptr) - @ptrToInt(binary_mem.ptr),
1544 true,1544 true,
...@@ -1552,7 +1552,7 @@ pub const DwarfInfo = struct {...@@ -1552,7 +1552,7 @@ pub const DwarfInfo = struct {
1552 const cie = di.cie_map.get(cie_offset) orelse return badDwarf();1552 const cie = di.cie_map.get(cie_offset) orelse return badDwarf();
1553 const fde = try FrameDescriptionEntry.parse(1553 const fde = try FrameDescriptionEntry.parse(
1554 entry_header.entry_bytes,1554 entry_header.entry_bytes,
1555 -@intCast(isize, @ptrToInt(binary_mem.ptr)),1555 -@intCast(isize, @intFromPtr(binary_mem.ptr)),
1556 //@ptrToInt(eh_frame.ptr),1556 //@ptrToInt(eh_frame.ptr),
1557 //@ptrToInt(eh_frame.ptr) - @ptrToInt(binary_mem.ptr),1557 //@ptrToInt(eh_frame.ptr) - @ptrToInt(binary_mem.ptr),
1558 true,1558 true,
...@@ -1594,7 +1594,7 @@ pub const DwarfInfo = struct {...@@ -1594,7 +1594,7 @@ pub const DwarfInfo = struct {
15941594
1595 if (di.eh_frame_hdr) |header| {1595 if (di.eh_frame_hdr) |header| {
1596 mapped_pc = context.pc;1596 mapped_pc = context.pc;
1597 try header.findEntry(context.isValidMemory, @ptrToInt(di.section(.eh_frame_hdr).?.ptr), mapped_pc, &cie, &fde);1597 try header.findEntry(context.isValidMemory, @intFromPtr(di.section(.eh_frame_hdr).?.ptr), mapped_pc, &cie, &fde);
1598 } else {1598 } else {
1599 mapped_pc = context.pc - module_base_address;1599 mapped_pc = context.pc - module_base_address;
1600 const index = std.sort.binarySearch(FrameDescriptionEntry, mapped_pc, di.fde_list.items, {}, struct {1600 const index = std.sort.binarySearch(FrameDescriptionEntry, mapped_pc, di.fde_list.items, {}, struct {
...@@ -1790,7 +1790,7 @@ fn readEhPointer(reader: anytype, enc: u8, addr_size_bytes: u8, ctx: EhPointerCo...@@ -1790,7 +1790,7 @@ fn readEhPointer(reader: anytype, enc: u8, addr_size_bytes: u8, ctx: EhPointerCo
17901790
1791 const native_ptr = math.cast(usize, ptr) orelse return error.PointerOverflow;1791 const native_ptr = math.cast(usize, ptr) orelse return error.PointerOverflow;
1792 return switch (addr_size_bytes) {1792 return switch (addr_size_bytes) {
1793 2, 4, 8 => return @intToPtr(*const usize, native_ptr).*,1793 2, 4, 8 => return @ptrFromInt(*const usize, native_ptr).*,
1794 else => return error.UnsupportedAddrSize,1794 else => return error.UnsupportedAddrSize,
1795 };1795 };
1796 } else {1796 } else {
...@@ -1842,7 +1842,7 @@ pub const ExceptionFrameHeader = struct {...@@ -1842,7 +1842,7 @@ pub const ExceptionFrameHeader = struct {
18421842
1843 try stream.seekTo(mid * entry_size);1843 try stream.seekTo(mid * entry_size);
1844 const pc_begin = try readEhPointer(reader, self.table_enc, @sizeOf(usize), .{1844 const pc_begin = try readEhPointer(reader, self.table_enc, @sizeOf(usize), .{
1845 .pc_rel_base = @ptrToInt(&self.entries[stream.pos]),1845 .pc_rel_base = @intFromPtr(&self.entries[stream.pos]),
1846 .follow_indirect = true,1846 .follow_indirect = true,
1847 .data_rel_base = eh_frame_hdr_ptr,1847 .data_rel_base = eh_frame_hdr_ptr,
1848 }, builtin.cpu.arch.endian()) orelse return badDwarf();1848 }, builtin.cpu.arch.endian()) orelse return badDwarf();
...@@ -1857,13 +1857,13 @@ pub const ExceptionFrameHeader = struct {...@@ -1857,13 +1857,13 @@ pub const ExceptionFrameHeader = struct {
18571857
1858 // Read past pc_begin1858 // Read past pc_begin
1859 _ = try readEhPointer(reader, self.table_enc, @sizeOf(usize), .{1859 _ = try readEhPointer(reader, self.table_enc, @sizeOf(usize), .{
1860 .pc_rel_base = @ptrToInt(&self.entries[stream.pos]),1860 .pc_rel_base = @intFromPtr(&self.entries[stream.pos]),
1861 .follow_indirect = true,1861 .follow_indirect = true,
1862 .data_rel_base = eh_frame_hdr_ptr,1862 .data_rel_base = eh_frame_hdr_ptr,
1863 }, builtin.cpu.arch.endian()) orelse return badDwarf();1863 }, builtin.cpu.arch.endian()) orelse return badDwarf();
18641864
1865 const fde_ptr = math.cast(usize, try readEhPointer(reader, self.table_enc, @sizeOf(usize), .{1865 const fde_ptr = math.cast(usize, try readEhPointer(reader, self.table_enc, @sizeOf(usize), .{
1866 .pc_rel_base = @ptrToInt(&self.entries[stream.pos]),1866 .pc_rel_base = @intFromPtr(&self.entries[stream.pos]),
1867 .follow_indirect = true,1867 .follow_indirect = true,
1868 .data_rel_base = eh_frame_hdr_ptr,1868 .data_rel_base = eh_frame_hdr_ptr,
1869 }, builtin.cpu.arch.endian()) orelse return badDwarf()) orelse return badDwarf();1869 }, builtin.cpu.arch.endian()) orelse return badDwarf()) orelse return badDwarf();
...@@ -1872,20 +1872,20 @@ pub const ExceptionFrameHeader = struct {...@@ -1872,20 +1872,20 @@ pub const ExceptionFrameHeader = struct {
18721872
1873 // The length of the .eh_frame section is unknown at this point, since .eh_frame_hdr only provides the start1873 // The length of the .eh_frame section is unknown at this point, since .eh_frame_hdr only provides the start
1874 if (!isValidMemory(fde_ptr) or fde_ptr < self.eh_frame_ptr) return badDwarf();1874 if (!isValidMemory(fde_ptr) or fde_ptr < self.eh_frame_ptr) return badDwarf();
1875 const eh_frame = @intToPtr([*]const u8, self.eh_frame_ptr)[0..math.maxInt(usize)];1875 const eh_frame = @ptrFromInt([*]const u8, self.eh_frame_ptr)[0..math.maxInt(usize)];
1876 const fde_offset = fde_ptr - self.eh_frame_ptr;1876 const fde_offset = fde_ptr - self.eh_frame_ptr;
18771877
1878 var eh_frame_stream = io.fixedBufferStream(eh_frame);1878 var eh_frame_stream = io.fixedBufferStream(eh_frame);
1879 try eh_frame_stream.seekTo(fde_offset);1879 try eh_frame_stream.seekTo(fde_offset);
18801880
1881 const fde_entry_header = try EntryHeader.read(&eh_frame_stream, builtin.cpu.arch.endian());1881 const fde_entry_header = try EntryHeader.read(&eh_frame_stream, builtin.cpu.arch.endian());
1882 if (!isValidMemory(@ptrToInt(&fde_entry_header.entry_bytes[fde_entry_header.entry_bytes.len - 1]))) return badDwarf();1882 if (!isValidMemory(@intFromPtr(&fde_entry_header.entry_bytes[fde_entry_header.entry_bytes.len - 1]))) return badDwarf();
1883 if (fde_entry_header.type != .fde) return badDwarf();1883 if (fde_entry_header.type != .fde) return badDwarf();
18841884
1885 const cie_offset = fde_entry_header.type.fde;1885 const cie_offset = fde_entry_header.type.fde;
1886 try eh_frame_stream.seekTo(cie_offset);1886 try eh_frame_stream.seekTo(cie_offset);
1887 const cie_entry_header = try EntryHeader.read(&eh_frame_stream, builtin.cpu.arch.endian());1887 const cie_entry_header = try EntryHeader.read(&eh_frame_stream, builtin.cpu.arch.endian());
1888 if (!isValidMemory(@ptrToInt(&cie_entry_header.entry_bytes[cie_entry_header.entry_bytes.len - 1]))) return badDwarf();1888 if (!isValidMemory(@intFromPtr(&cie_entry_header.entry_bytes[cie_entry_header.entry_bytes.len - 1]))) return badDwarf();
1889 if (cie_entry_header.type != .cie) return badDwarf();1889 if (cie_entry_header.type != .cie) return badDwarf();
18901890
1891 cie.* = try CommonInformationEntry.parse(1891 cie.* = try CommonInformationEntry.parse(
...@@ -2083,7 +2083,7 @@ pub const CommonInformationEntry = struct {...@@ -2083,7 +2083,7 @@ pub const CommonInformationEntry = struct {
2083 personality_enc.?,2083 personality_enc.?,
2084 addr_size_bytes,2084 addr_size_bytes,
2085 .{2085 .{
2086 .pc_rel_base = try pcRelBase(@ptrToInt(&cie_bytes[stream.pos]), pc_rel_offset),2086 .pc_rel_base = try pcRelBase(@intFromPtr(&cie_bytes[stream.pos]), pc_rel_offset),
2087 .follow_indirect = is_runtime,2087 .follow_indirect = is_runtime,
2088 },2088 },
2089 endian,2089 endian,
...@@ -2161,7 +2161,7 @@ pub const FrameDescriptionEntry = struct {...@@ -2161,7 +2161,7 @@ pub const FrameDescriptionEntry = struct {
2161 cie.fde_pointer_enc,2161 cie.fde_pointer_enc,
2162 addr_size_bytes,2162 addr_size_bytes,
2163 .{2163 .{
2164 .pc_rel_base = try pcRelBase(@ptrToInt(&fde_bytes[stream.pos]), pc_rel_offset),2164 .pc_rel_base = try pcRelBase(@intFromPtr(&fde_bytes[stream.pos]), pc_rel_offset),
2165 .follow_indirect = is_runtime,2165 .follow_indirect = is_runtime,
2166 },2166 },
2167 endian,2167 endian,
...@@ -2190,7 +2190,7 @@ pub const FrameDescriptionEntry = struct {...@@ -2190,7 +2190,7 @@ pub const FrameDescriptionEntry = struct {
2190 cie.lsda_pointer_enc,2190 cie.lsda_pointer_enc,
2191 addr_size_bytes,2191 addr_size_bytes,
2192 .{2192 .{
2193 .pc_rel_base = try pcRelBase(@ptrToInt(&fde_bytes[stream.pos]), pc_rel_offset),2193 .pc_rel_base = try pcRelBase(@intFromPtr(&fde_bytes[stream.pos]), pc_rel_offset),
2194 .follow_indirect = is_runtime,2194 .follow_indirect = is_runtime,
2195 },2195 },
2196 endian,2196 endian,
lib/std/dwarf/call_frame.zig+7-7
...@@ -38,12 +38,12 @@ const Opcode = enum(u8) {...@@ -38,12 +38,12 @@ const Opcode = enum(u8) {
38 val_expression = 0x16,38 val_expression = 0x16,
3939
40 // These opcodes encode an operand in the lower 6 bits of the opcode itself40 // These opcodes encode an operand in the lower 6 bits of the opcode itself
41 pub const lo_inline = @enumToInt(Opcode.advance_loc);41 pub const lo_inline = @intFromEnum(Opcode.advance_loc);
42 pub const hi_inline = @enumToInt(Opcode.restore) | 0b111111;42 pub const hi_inline = @intFromEnum(Opcode.restore) | 0b111111;
4343
44 // These opcodes are trailed by zero or more operands44 // These opcodes are trailed by zero or more operands
45 pub const lo_reserved = @enumToInt(Opcode.nop);45 pub const lo_reserved = @intFromEnum(Opcode.nop);
46 pub const hi_reserved = @enumToInt(Opcode.val_expression);46 pub const hi_reserved = @intFromEnum(Opcode.val_expression);
4747
48 // Vendor-specific opcodes48 // Vendor-specific opcodes
49 pub const lo_user = 0x1c;49 pub const lo_user = 0x1c;
...@@ -206,13 +206,13 @@ pub const Instruction = union(Opcode) {...@@ -206,13 +206,13 @@ pub const Instruction = union(Opcode) {
206 ) !Instruction {206 ) !Instruction {
207 return switch (try stream.reader().readByte()) {207 return switch (try stream.reader().readByte()) {
208 inline Opcode.lo_inline...Opcode.hi_inline => |opcode| blk: {208 inline Opcode.lo_inline...Opcode.hi_inline => |opcode| blk: {
209 const e = @intToEnum(Opcode, opcode & 0b11000000);209 const e = @enumFromInt(Opcode, opcode & 0b11000000);
210 var result = @unionInit(Instruction, @tagName(e), undefined);210 var result = @unionInit(Instruction, @tagName(e), undefined);
211 try result.readOperands(stream, @intCast(u6, opcode & 0b111111), addr_size_bytes, endian);211 try result.readOperands(stream, @intCast(u6, opcode & 0b111111), addr_size_bytes, endian);
212 break :blk result;212 break :blk result;
213 },213 },
214 inline Opcode.lo_reserved...Opcode.hi_reserved => |opcode| blk: {214 inline Opcode.lo_reserved...Opcode.hi_reserved => |opcode| blk: {
215 const e = @intToEnum(Opcode, opcode);215 const e = @enumFromInt(Opcode, opcode);
216 var result = @unionInit(Instruction, @tagName(e), undefined);216 var result = @unionInit(Instruction, @tagName(e), undefined);
217 try result.readOperands(stream, null, addr_size_bytes, endian);217 try result.readOperands(stream, null, addr_size_bytes, endian);
218 break :blk result;218 break :blk result;
...@@ -304,7 +304,7 @@ pub const VirtualMachine = struct {...@@ -304,7 +304,7 @@ pub const VirtualMachine = struct {
304 .same_value => {},304 .same_value => {},
305 .offset => |offset| {305 .offset => |offset| {
306 if (context.cfa) |cfa| {306 if (context.cfa) |cfa| {
307 const ptr = @intToPtr(*const usize, try applyOffset(cfa, offset));307 const ptr = @ptrFromInt(*const usize, try applyOffset(cfa, offset));
308308
309 // TODO: context.isValidMemory(ptr)309 // TODO: context.isValidMemory(ptr)
310 mem.writeIntSliceNative(usize, out, ptr.*);310 mem.writeIntSliceNative(usize, out, ptr.*);