Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
ea09ebd
Extract WASM section model
jtschuster Aug 3, 2026
0c14386
Add typed self-counting WASM sections
jtschuster Aug 3, 2026
8e2a3ef
Rename Emit and Stream, hide ObjectWriter.GetOrCreateSection
jtschuster Aug 5, 2026
b313142
Make WebCilSection not inherit from WasmSection, refactor WasmSections
jtschuster Aug 6, 2026
c4453f2
Add typed self-counting WASM sections
jtschuster Aug 3, 2026
a4e0a82
Rename Emit and Stream, hide ObjectWriter.GetOrCreateSection
jtschuster Aug 5, 2026
48871a1
Make WebCilSection not inherit from WasmSection, refactor WasmSections
jtschuster Aug 6, 2026
c55ebc1
Add SectionIndex to SectionDataEmitter, make WasmSection implement IW…
jtschuster Aug 6, 2026
fc88305
Make sure EntryCount is set before emission in WasmExternalyCountedSe…
jtschuster Aug 6, 2026
8f740c0
Merge branch 'wasm-writer-typed-sections' of https://github.com/dotne…
jtschuster Aug 6, 2026
78c7f21
Merge branch 'main' of https://github.com/dotnet/runtime into wasm-wr…
jtschuster Aug 6, 2026
2bdb817
Undo the rename of methods back to WriteX()
jtschuster Aug 6, 2026
a6dc50b
Rename EncodedSize, don't include exception message
jtschuster Aug 11, 2026
d3266c0
Potential fix for pull request finding
jtschuster Aug 12, 2026
24fccf9
Merge branch 'main' of https://github.com/dotnet/runtime into wasm-wr…
jtschuster Aug 12, 2026
454c5bb
Merge branch 'wasm-writer-typed-sections' of https://github.com/dotne…
jtschuster Aug 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public ObjectNode.ObjectData Encode(ISymbolDefinitionNode symbolDefinitionNode)

Relocation[] relocs = new Relocation[FunctionBody.EncodeRelocationCount()];
FunctionBody.EncodeRelocations(relocs.AsSpan());

return new ObjectNode.ObjectData(encodedThunk, relocs, 1, new ISymbolDefinitionNode[] { symbolDefinitionNode });
#else
return default(ObjectNode.ObjectData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@

namespace ILCompiler.ObjectWriter
{
internal class WasmDataSection : WasmSection
internal class WasmDataSection : IWasmEmittable, IWasmSection
{
private List<WasmDataSegment> _segments;
public List<WasmDataSegment> Segments => _segments;
private int _contentAlign = 1;
public WasmDataSection(List<WasmDataSegment> segments, Utf8String name, int contentAlign = 1)
: base(WasmSectionType.Data, null, name)
{
_segments = segments;
_contentAlign = contentAlign;
}

public override int ContentSize
public WasmSectionType Type => WasmSectionType.Data;

public int ContentSize
{
get
{
Expand All @@ -38,7 +39,9 @@ public override int ContentSize
}
}

public override int EncodeHeader(Span<byte> headerBuffer)
public int HeaderSize => 1 + Relocation.WASM_PADDED_RELOC_SIZE_32;

private int EncodeHeader(Span<byte> headerBuffer)
{
uint encodeLength = Relocation.WASM_PADDED_RELOC_SIZE_32;

Expand All @@ -51,9 +54,12 @@ public override int EncodeHeader(Span<byte> headerBuffer)
return 1 + (int)encodeLength;
}

public override int HeaderSize => 1 + Relocation.WASM_PADDED_RELOC_SIZE_32;
public int EncodeSize()
{
return HeaderSize + ContentSize;
}

public override int Emit(Stream outputFileStream)
public int EmitToStream(Stream outputFileStream)
{
int size = 0;
int headerPosition = (int)outputFileStream.Position;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using ILCompiler.DependencyAnalysis;
Expand All @@ -10,7 +11,7 @@

namespace ILCompiler.ObjectWriter
{
internal enum WasmDataSectionType : byte
internal enum WasmDataSegmentType : byte
{
Active = 0, // (data list(byte) (active offset-expr))
Passive = 1, // (data list(byte) passive)
Expand All @@ -21,11 +22,11 @@ internal class WasmDataSegment
{
// The segments are not sections per se, but they represent data segments within the data section.
Stream _stream;
WasmDataSectionType _type;
WasmDataSegmentType _type;
WasmInstructionGroup _initExpr;
private PaddingHelper _paddingHelper;

public WasmDataSegment(Stream contents, Utf8String name, WasmDataSectionType type, WasmInstructionGroup initExpr)
public WasmDataSegment(Stream contents, Utf8String name, WasmDataSegmentType type, WasmInstructionGroup initExpr)
{
_stream = contents;
_type = type;
Expand All @@ -39,11 +40,11 @@ public int HeaderSize
{
return _type switch
{
WasmDataSectionType.Active =>
WasmDataSegmentType.Active =>
(int)DwarfHelper.SizeOfULEB128((ulong)_type) + // type indicator
_initExpr.EncodeSize() + // init expr encodeSize
Relocation.WASM_PADDED_RELOC_SIZE_32, // encode size of data length
WasmDataSectionType.Passive =>
WasmDataSegmentType.Passive =>
(int)DwarfHelper.SizeOfULEB128((ulong)_type) +
Relocation.WASM_PADDED_RELOC_SIZE_32, // encode size of data length
_ =>
Expand Down Expand Up @@ -80,7 +81,7 @@ public int EncodeHeader(Span<byte> headerBuffer)
{
switch (_type)
{
case WasmDataSectionType.Active:
case WasmDataSegmentType.Active:
{
int len = 0;
len = DwarfHelper.WriteULEB128(headerBuffer, (ulong)_type);
Expand All @@ -90,7 +91,7 @@ public int EncodeHeader(Span<byte> headerBuffer)
len += headerBuffer.Slice(len).Length;
return len;
}
case WasmDataSectionType.Passive:
case WasmDataSegmentType.Passive:
{
int len = 0;
len = DwarfHelper.WriteULEB128(headerBuffer, (ulong)_type);
Expand Down
Loading
Loading