Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 numberDiff line numberDiff line change
Expand Up@@ -1732,16 +1732,8 @@ private void ForceSigWalk()
int floatRegOfsInBytes = argOffset - _transitionBlock.OffsetOfFloatArgumentRegisters;
Debug.Assert((floatRegOfsInBytes % _transitionBlock.FloatRegisterSize) == 0);
pLoc.m_idxFloatReg = floatRegOfsInBytes / _transitionBlock.FloatRegisterSize;
pLoc.m_cFloatReg = 1;

if (!_argTypeHandle.IsNull() && _argTypeHandle.IsHomogeneousAggregate())
{
int haElementSize = _argTypeHandle.GetHomogeneousAggregateElementSize();
pLoc.m_cFloatReg = GetArgSize() / haElementSize;
}
else
{
pLoc.m_cFloatReg = 1;
}
return pLoc;
}

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ protected override void EmitCode(NodeFactory factory, ref LoongArch64Emitter ins

if (!relocsOnly)
{
// movz T0=R12, #index
// ori T0=R12, R0, #index
int index = _containingImportSection.IndexFromBeginningOfArray;
instructionEncoder.EmitMOV(Register.R12, checked((ushort)index));
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -651,8 +651,8 @@ private class LoongArch64TransitionBlock : TransitionBlock
public override int NumCalleeSavedRegisters => 12;
// Callee-saves, argument registers
public override int SizeOfTransitionBlock => SizeOfCalleeSavedRegisters + SizeOfArgumentRegisters;
public override int OffsetOfArgumentRegisters => SizeOfCalleeSavedRegisters;
public override int OffsetOfFirstGCRefMapSlot => OffsetOfArgumentRegisters;
public override int OffsetOfFirstGCRefMapSlot => SizeOfCalleeSavedRegisters;
public override int OffsetOfArgumentRegisters => OffsetOfFirstGCRefMapSlot;

// F0..F7
public override int OffsetOfFloatArgumentRegisters => 8 * sizeof(double);
Expand All@@ -671,19 +671,11 @@ public override bool IsArgPassedByRef(TypeHandle th)
}
else
{
int numIntroducedFields = 0;
foreach (FieldDesc field in th.GetRuntimeTypeHandle().GetFields())
{
if (!field.IsStatic)
{
numIntroducedFields++;
}
}
return ((numIntroducedFields == 0) || (numIntroducedFields > 2));
return false;
}
}

public sealed override int GetRetBuffArgOffset(bool hasThis) => OffsetOfArgumentRegisters;
public sealed override int GetRetBuffArgOffset(bool hasThis) => OffsetOfFirstGCRefMapSlot + (hasThis ? 8 : 0);

public override int StackElemSize(int parmSize, bool isValueType = false, bool isFloatHfa = false)
{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -259,6 +259,14 @@ public override string ToString()

sb.AppendLine($" Has Tailcalls: {_wantsReportOnlyLeaf}");
}
else if (_machine == Machine.LoongArch64)
{
if (StackBaseRegister != 0xffffffff)
{
sb.AppendLine($" StackBaseRegister: {(LoongArch64.Registers)StackBaseRegister}");
}
sb.AppendLine($" Has Tailcalls: {_wantsReportOnlyLeaf}");
}

sb.AppendLine($" Size of parameter area: 0x{SizeOfStackOutgoingAndScratchArea:X}");
if (SizeOfEditAndContinuePreservedArea != 0xffffffff)
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -68,6 +68,9 @@ private static string GetRegisterName(int registerNumber, Machine machine)
case Machine.Arm64:
return ((Arm64.Registers)registerNumber).ToString();

case Machine.LoongArch64:
return ((LoongArch64.Registers)registerNumber).ToString();

default:
throw new NotImplementedException(machine.ToString());
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -65,6 +65,10 @@ public string GetSlotState(GcSlotTable slotTable, Machine machine)
regType = typeof(Amd64.Registers);
break;

case Machine.LoongArch64:
regType = typeof(LoongArch64.Registers);
break;

default:
throw new NotImplementedException();
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,6 +72,8 @@ public static string GetPlatformSpecificRegister(Machine machine, int regnum)
return ((Arm.Registers)regnum).ToString();
case Machine.Arm64:
return ((Arm64.Registers)regnum).ToString();
case Machine.LoongArch64:
return ((LoongArch64.Registers)regnum).ToString();
default:
throw new NotImplementedException($"No implementation for machine type {machine}.");
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -149,6 +149,11 @@ internal GcInfoTypes(Machine machine)
NUM_UNTRACKED_SLOTS_ENCBASE = 5;
REGISTER_DELTA_ENCBASE = 3;
break;
case Machine.LoongArch64:
SIZE_OF_RETURN_KIND_FAT = 4;
STACK_BASE_REGISTER_ENCBASE = 2;
NUM_REGISTERS_ENCBASE = 3;
break;
}
}

Expand All@@ -159,6 +164,7 @@ internal int DenormalizeCodeLength(int x)
case Machine.ArmThumb2:
return (x << 1);
case Machine.Arm64:
case Machine.LoongArch64:
return (x << 2);
}
return x;
Expand All@@ -173,6 +179,7 @@ internal int DenormalizeStackSlot(int x)
case Machine.ArmThumb2:
return (x << 2);
case Machine.Arm64:
case Machine.LoongArch64:
return (x << 3);
}
return x;
Expand All@@ -188,6 +195,8 @@ internal uint DenormalizeStackBaseRegister(uint x)
return ((x ^ 7) + 4);
case Machine.Arm64:
return (x ^ 29);
case Machine.LoongArch64:
return ((x ^ 22) & 0x3);
}
return x;
}
Expand All@@ -201,6 +210,7 @@ internal uint DenormalizeSizeOfStackArea(uint x)
case Machine.ArmThumb2:
return (x << 2);
case Machine.Arm64:
case Machine.LoongArch64:
return (x << 3);
}
return x;
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.Text;

namespace ILCompiler.Reflection.ReadyToRun.LoongArch64
{
public enum Registers
{
R0,
Ra,
Tp,
Sp,
A0,
A1,
A2,
A3,
A4,
A5,
A6,
A7,
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
X0,
Fp,
S0,
S1,
S2,
S3,
S4,
S5,
S6,
S7,
S8
}
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Text;

namespace ILCompiler.Reflection.ReadyToRun.LoongArch64
{
public class Epilog
{
public int Index { get; set; }

public uint EpilogStartOffset { get; set; }
public uint Res { get; set; }
public uint Condition { get; set; }
public uint EpilogStartIndex { get; set; }
public uint EpilogStartOffsetFromMainFunctionBegin { get; set; }

public Epilog() { }

public Epilog(int index, int dw, uint startOffset)
{
Index = index;

EpilogStartOffset = UnwindInfo.ExtractBits(dw, 0, 18);
Res = UnwindInfo.ExtractBits(dw, 18, 4);
Condition = UnwindInfo.ExtractBits(dw, 20, 4);
EpilogStartIndex = UnwindInfo.ExtractBits(dw, 22, 10);

// Note that epilogStartOffset for a funclet is the offset from the beginning
// of the current funclet, not the offset from the beginning of the main function.
// To help find it when looking through JitDump output, also show the offset from
// the beginning of the main function.
EpilogStartOffsetFromMainFunctionBegin = EpilogStartOffset * 4 + startOffset;
}

public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine($" Epilog Start Offset: 0x{EpilogStartOffset:X5} Actual offset = 0x{EpilogStartOffset * 4:X5} Offset from main function begin = 0x{EpilogStartOffsetFromMainFunctionBegin:X6}");
sb.AppendLine($" Condition: {Condition} (0x{Condition:X})" + ((Condition == 0xE) ? " (always)" : ""));
sb.Append($" Epilog Start Index: {EpilogStartIndex} (0x{EpilogStartIndex:X})");
return sb.ToString();
}
}

public class UnwindCode
{
public int Index { get; set; }

public UnwindCode() { }

public UnwindCode(int index)
{
Index = index;

}
}

/// <summary>
/// based on <a href="https://github.com/dotnet/runtime/src/coreclr/jit/unwindloongarch64.cpp">src/jit/unwindloongarch64.cpp</a> DumpUnwindInfo
/// </summary>
public class UnwindInfo : BaseUnwindInfo
{
public uint CodeWords { get; set; }
public uint EpilogCount { get; set; }
public uint EBit { get; set; }
public uint XBit { get; set; }
public uint Vers { get; set; }
public uint FunctionLength { get; set; }

public uint ExtendedCodeWords { get; set; }
public uint ExtendedEpilogCount { get; set; }

public Epilog[] Epilogs { get; set; }

public UnwindInfo() { }

public UnwindInfo(byte[] image, int offset)
{
uint startOffset = (uint)offset;

int dw = NativeReader.ReadInt32(image, ref offset);
CodeWords = ExtractBits(dw, 27, 5);
EpilogCount = ExtractBits(dw, 22, 5);
EBit = ExtractBits(dw, 21, 1);
XBit = ExtractBits(dw, 20, 1);
Vers = ExtractBits(dw, 18, 2);
FunctionLength = ExtractBits(dw, 0, 18) * 4;

if (CodeWords == 0 && EpilogCount == 0)
{
// We have an extension word specifying a larger number of Code Words or Epilog Counts
// than can be specified in the header word.
dw = NativeReader.ReadInt32(image, ref offset);
ExtendedCodeWords = ExtractBits(dw, 16, 8);
ExtendedEpilogCount = ExtractBits(dw, 0, 16);
}

bool[] epilogStartAt = new bool[1024]; // One byte per possible epilog start index; initialized to false

if (EBit == 0)
{
Epilogs = new Epilog[EpilogCount];
if (EpilogCount != 0)
{
for (int scope = 0; scope < EpilogCount; scope++)
{
dw = NativeReader.ReadInt32(image, ref offset);
Epilogs[scope] = new Epilog(scope, dw, startOffset);
epilogStartAt[Epilogs[scope].EpilogStartIndex] = true; // an epilog starts at this offset in the unwind codes
}
}
}
else
{
Epilogs = new Epilog[0];
epilogStartAt[EpilogCount] = true; // the one and only epilog starts its unwind codes at this offset
}



Size = offset - (int)startOffset + (int)CodeWords * 4;
int alignmentPad = ((Size + sizeof(int) - 1) & ~(sizeof(int) - 1)) - Size;
Size += (alignmentPad + sizeof(uint));
}

public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine($" CodeWords: {CodeWords}");
sb.AppendLine($" EpilogCount: {EpilogCount}");
sb.AppendLine($" EBit: {EBit}");
sb.AppendLine($" XBit: {XBit}");
sb.AppendLine($" Vers: {Vers}");
sb.AppendLine($" FunctionLength: {FunctionLength}");
if (CodeWords == 0 && EpilogCount == 0)
{
sb.AppendLine(" ---- Extension word ----");
sb.AppendLine($" Extended Code Words: {CodeWords}");
sb.AppendLine($" Extended Epilog Count: {EpilogCount}");
}
if (EpilogCount == 0)
{
sb.AppendLine(" No epilogs");
}
else
{
for (int i = 0; i < Epilogs.Length; i++)
{
sb.AppendLine(" -------------------------");
sb.AppendLine(Epilogs[i].ToString());
sb.AppendLine(" -------------------------");
}
}
return sb.ToString();
}

internal static uint ExtractBits(int dw, int start, int length)
{
return (uint)((dw >> start) & ((1 << length) - 1));
}
}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -225,6 +225,10 @@ private int GetSize()
{
return (int)arm64Info.FunctionLength;
}
else if (UnwindInfo is LoongArch64.UnwindInfo loongarch64Info)
{
return (int)loongarch64Info.FunctionLength;
}
else if (Method.GcInfo != null)
{
return Method.GcInfo.CodeLength;
Expand DownExpand Up@@ -488,7 +492,7 @@ private void EnsureInitialized()
}
else
{
// Armand Arm64 use the same GcInfo format as Amd64
// Arm, Arm64 and LoongArch64 use the same GcInfo format as Amd64
_gcInfo = new Amd64.GcInfo(_readyToRunReader.Image, gcInfoOffset, _readyToRunReader.Machine, _readyToRunReader.ReadyToRunHeader.MajorVersion);
}
}
Expand DownExpand Up@@ -604,6 +608,10 @@ private void ParseRuntimeFunctions(bool partial)
{
unwindInfo = new Arm64.UnwindInfo(_readyToRunReader.Image, unwindOffset);
}
else if (_readyToRunReader.Machine == Machine.LoongArch64)
{
unwindInfo = new LoongArch64.UnwindInfo(_readyToRunReader.Image, unwindOffset);
}

if (i == 0 && unwindInfo != null)
{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -1415,6 +1415,7 @@ private void EnsureImportSections()

case Machine.Amd64:
case Machine.Arm64:
case Machine.LoongArch64:
entrySize = 8;
break;

Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 numberDiff line numberDiff line change
Expand Up@@ -1732,16 +1732,8 @@ private void ForceSigWalk()
int floatRegOfsInBytes = argOffset - _transitionBlock.OffsetOfFloatArgumentRegisters;
Debug.Assert((floatRegOfsInBytes % _transitionBlock.FloatRegisterSize) == 0);
pLoc.m_idxFloatReg = floatRegOfsInBytes / _transitionBlock.FloatRegisterSize;
pLoc.m_cFloatReg = 1;

if (!_argTypeHandle.IsNull() && _argTypeHandle.IsHomogeneousAggregate())
{
int haElementSize = _argTypeHandle.GetHomogeneousAggregateElementSize();
pLoc.m_cFloatReg = GetArgSize() / haElementSize;
}
else
{
pLoc.m_cFloatReg = 1;
}
return pLoc;
}

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ protected override void EmitCode(NodeFactory factory, ref LoongArch64Emitter ins

if (!relocsOnly)
{
// movz T0=R12, #index
// ori T0=R12, R0, #index
int index = _containingImportSection.IndexFromBeginningOfArray;
instructionEncoder.EmitMOV(Register.R12, checked((ushort)index));
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -651,8 +651,8 @@ private class LoongArch64TransitionBlock : TransitionBlock
public override int NumCalleeSavedRegisters => 12;
// Callee-saves, argument registers
public override int SizeOfTransitionBlock => SizeOfCalleeSavedRegisters + SizeOfArgumentRegisters;
public override int OffsetOfArgumentRegisters => SizeOfCalleeSavedRegisters;
public override int OffsetOfFirstGCRefMapSlot => OffsetOfArgumentRegisters;
public override int OffsetOfFirstGCRefMapSlot => SizeOfCalleeSavedRegisters;
public override int OffsetOfArgumentRegisters => OffsetOfFirstGCRefMapSlot;

// F0..F7
public override int OffsetOfFloatArgumentRegisters => 8 * sizeof(double);
Expand All@@ -671,19 +671,11 @@ public override bool IsArgPassedByRef(TypeHandle th)
}
else
{
int numIntroducedFields = 0;
foreach (FieldDesc field in th.GetRuntimeTypeHandle().GetFields())
{
if (!field.IsStatic)
{
numIntroducedFields++;
}
}
return ((numIntroducedFields == 0) || (numIntroducedFields > 2));
return false;
}
}

public sealed override int GetRetBuffArgOffset(bool hasThis) => OffsetOfArgumentRegisters;
public sealed override int GetRetBuffArgOffset(bool hasThis) => OffsetOfFirstGCRefMapSlot + (hasThis ? 8 : 0);

public override int StackElemSize(int parmSize, bool isValueType = false, bool isFloatHfa = false)
{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -259,6 +259,14 @@ public override string ToString()

sb.AppendLine($" Has Tailcalls: {_wantsReportOnlyLeaf}");
}
else if (_machine == Machine.LoongArch64)
{
if (StackBaseRegister != 0xffffffff)
{
sb.AppendLine($" StackBaseRegister: {(LoongArch64.Registers)StackBaseRegister}");
}
sb.AppendLine($" Has Tailcalls: {_wantsReportOnlyLeaf}");
}

sb.AppendLine($" Size of parameter area: 0x{SizeOfStackOutgoingAndScratchArea:X}");
if (SizeOfEditAndContinuePreservedArea != 0xffffffff)
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -68,6 +68,9 @@ private static string GetRegisterName(int registerNumber, Machine machine)
case Machine.Arm64:
return ((Arm64.Registers)registerNumber).ToString();

case Machine.LoongArch64:
return ((LoongArch64.Registers)registerNumber).ToString();

default:
throw new NotImplementedException(machine.ToString());
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -65,6 +65,10 @@ public string GetSlotState(GcSlotTable slotTable, Machine machine)
regType = typeof(Amd64.Registers);
break;

case Machine.LoongArch64:
regType = typeof(LoongArch64.Registers);
break;

default:
throw new NotImplementedException();
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,6 +72,8 @@ public static string GetPlatformSpecificRegister(Machine machine, int regnum)
return ((Arm.Registers)regnum).ToString();
case Machine.Arm64:
return ((Arm64.Registers)regnum).ToString();
case Machine.LoongArch64:
return ((LoongArch64.Registers)regnum).ToString();
default:
throw new NotImplementedException($"No implementation for machine type {machine}.");
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -149,6 +149,11 @@ internal GcInfoTypes(Machine machine)
NUM_UNTRACKED_SLOTS_ENCBASE = 5;
REGISTER_DELTA_ENCBASE = 3;
break;
case Machine.LoongArch64:
SIZE_OF_RETURN_KIND_FAT = 4;
STACK_BASE_REGISTER_ENCBASE = 2;
NUM_REGISTERS_ENCBASE = 3;
break;
}
}

Expand All@@ -159,6 +164,7 @@ internal int DenormalizeCodeLength(int x)
case Machine.ArmThumb2:
return (x << 1);
case Machine.Arm64:
case Machine.LoongArch64:
return (x << 2);
}
return x;
Expand All@@ -173,6 +179,7 @@ internal int DenormalizeStackSlot(int x)
case Machine.ArmThumb2:
return (x << 2);
case Machine.Arm64:
case Machine.LoongArch64:
return (x << 3);
}
return x;
Expand All@@ -188,6 +195,8 @@ internal uint DenormalizeStackBaseRegister(uint x)
return ((x ^ 7) + 4);
case Machine.Arm64:
return (x ^ 29);
case Machine.LoongArch64:
return ((x ^ 22) & 0x3);
}
return x;
}
Expand All@@ -201,6 +210,7 @@ internal uint DenormalizeSizeOfStackArea(uint x)
case Machine.ArmThumb2:
return (x << 2);
case Machine.Arm64:
case Machine.LoongArch64:
return (x << 3);
}
return x;
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.Text;

namespace ILCompiler.Reflection.ReadyToRun.LoongArch64
{
public enum Registers
{
R0,
Ra,
Tp,
Sp,
A0,
A1,
A2,
A3,
A4,
A5,
A6,
A7,
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
X0,
Fp,
S0,
S1,
S2,
S3,
S4,
S5,
S6,
S7,
S8
}
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Text;

namespace ILCompiler.Reflection.ReadyToRun.LoongArch64
{
public class Epilog
{
public int Index { get; set; }

public uint EpilogStartOffset { get; set; }
public uint Res { get; set; }
public uint Condition { get; set; }
public uint EpilogStartIndex { get; set; }
public uint EpilogStartOffsetFromMainFunctionBegin { get; set; }

public Epilog() { }

public Epilog(int index, int dw, uint startOffset)
{
Index = index;

EpilogStartOffset = UnwindInfo.ExtractBits(dw, 0, 18);
Res = UnwindInfo.ExtractBits(dw, 18, 4);
Condition = UnwindInfo.ExtractBits(dw, 20, 4);
EpilogStartIndex = UnwindInfo.ExtractBits(dw, 22, 10);

// Note that epilogStartOffset for a funclet is the offset from the beginning
// of the current funclet, not the offset from the beginning of the main function.
// To help find it when looking through JitDump output, also show the offset from
// the beginning of the main function.
EpilogStartOffsetFromMainFunctionBegin = EpilogStartOffset * 4 + startOffset;
}

public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine($" Epilog Start Offset: 0x{EpilogStartOffset:X5} Actual offset = 0x{EpilogStartOffset * 4:X5} Offset from main function begin = 0x{EpilogStartOffsetFromMainFunctionBegin:X6}");
sb.AppendLine($" Condition: {Condition} (0x{Condition:X})" + ((Condition == 0xE) ? " (always)" : ""));
sb.Append($" Epilog Start Index: {EpilogStartIndex} (0x{EpilogStartIndex:X})");
return sb.ToString();
}
}

public class UnwindCode
{
public int Index { get; set; }

public UnwindCode() { }

public UnwindCode(int index)
{
Index = index;

}
}

/// <summary>
/// based on <a href="https://github.com/dotnet/runtime/src/coreclr/jit/unwindloongarch64.cpp">src/jit/unwindloongarch64.cpp</a> DumpUnwindInfo
/// </summary>
public class UnwindInfo : BaseUnwindInfo
{
public uint CodeWords { get; set; }
public uint EpilogCount { get; set; }
public uint EBit { get; set; }
public uint XBit { get; set; }
public uint Vers { get; set; }
public uint FunctionLength { get; set; }

public uint ExtendedCodeWords { get; set; }
public uint ExtendedEpilogCount { get; set; }

public Epilog[] Epilogs { get; set; }

public UnwindInfo() { }

public UnwindInfo(byte[] image, int offset)
{
uint startOffset = (uint)offset;

int dw = NativeReader.ReadInt32(image, ref offset);
CodeWords = ExtractBits(dw, 27, 5);
EpilogCount = ExtractBits(dw, 22, 5);
EBit = ExtractBits(dw, 21, 1);
XBit = ExtractBits(dw, 20, 1);
Vers = ExtractBits(dw, 18, 2);
FunctionLength = ExtractBits(dw, 0, 18) * 4;

if (CodeWords == 0 && EpilogCount == 0)
{
// We have an extension word specifying a larger number of Code Words or Epilog Counts
// than can be specified in the header word.
dw = NativeReader.ReadInt32(image, ref offset);
ExtendedCodeWords = ExtractBits(dw, 16, 8);
ExtendedEpilogCount = ExtractBits(dw, 0, 16);
}

bool[] epilogStartAt = new bool[1024]; // One byte per possible epilog start index; initialized to false

if (EBit == 0)
{
Epilogs = new Epilog[EpilogCount];
if (EpilogCount != 0)
{
for (int scope = 0; scope < EpilogCount; scope++)
{
dw = NativeReader.ReadInt32(image, ref offset);
Epilogs[scope] = new Epilog(scope, dw, startOffset);
epilogStartAt[Epilogs[scope].EpilogStartIndex] = true; // an epilog starts at this offset in the unwind codes
}
}
}
else
{
Epilogs = new Epilog[0];
epilogStartAt[EpilogCount] = true; // the one and only epilog starts its unwind codes at this offset
}



Size = offset - (int)startOffset + (int)CodeWords * 4;
int alignmentPad = ((Size + sizeof(int) - 1) & ~(sizeof(int) - 1)) - Size;
Size += (alignmentPad + sizeof(uint));
}

public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine($" CodeWords: {CodeWords}");
sb.AppendLine($" EpilogCount: {EpilogCount}");
sb.AppendLine($" EBit: {EBit}");
sb.AppendLine($" XBit: {XBit}");
sb.AppendLine($" Vers: {Vers}");
sb.AppendLine($" FunctionLength: {FunctionLength}");
if (CodeWords == 0 && EpilogCount == 0)
{
sb.AppendLine(" ---- Extension word ----");
sb.AppendLine($" Extended Code Words: {CodeWords}");
sb.AppendLine($" Extended Epilog Count: {EpilogCount}");
}
if (EpilogCount == 0)
{
sb.AppendLine(" No epilogs");
}
else
{
for (int i = 0; i < Epilogs.Length; i++)
{
sb.AppendLine(" -------------------------");
sb.AppendLine(Epilogs[i].ToString());
sb.AppendLine(" -------------------------");
}
}
return sb.ToString();
}

internal static uint ExtractBits(int dw, int start, int length)
{
return (uint)((dw >> start) & ((1 << length) - 1));
}
}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -225,6 +225,10 @@ private int GetSize()
{
return (int)arm64Info.FunctionLength;
}
else if (UnwindInfo is LoongArch64.UnwindInfo loongarch64Info)
{
return (int)loongarch64Info.FunctionLength;
}
else if (Method.GcInfo != null)
{
return Method.GcInfo.CodeLength;
Expand DownExpand Up@@ -488,7 +492,7 @@ private void EnsureInitialized()
}
else
{
// Armand Arm64 use the same GcInfo format as Amd64
// Arm, Arm64 and LoongArch64 use the same GcInfo format as Amd64
_gcInfo = new Amd64.GcInfo(_readyToRunReader.Image, gcInfoOffset, _readyToRunReader.Machine, _readyToRunReader.ReadyToRunHeader.MajorVersion);
}
}
Expand DownExpand Up@@ -604,6 +608,10 @@ private void ParseRuntimeFunctions(bool partial)
{
unwindInfo = new Arm64.UnwindInfo(_readyToRunReader.Image, unwindOffset);
}
else if (_readyToRunReader.Machine == Machine.LoongArch64)
{
unwindInfo = new LoongArch64.UnwindInfo(_readyToRunReader.Image, unwindOffset);
}

if (i == 0 && unwindInfo != null)
{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -1415,6 +1415,7 @@ private void EnsureImportSections()

case Machine.Amd64:
case Machine.Arm64:
case Machine.LoongArch64:
entrySize = 8;
break;

Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 numberDiff line numberDiff line change
Expand Up@@ -1732,16 +1732,8 @@ private void ForceSigWalk()
int floatRegOfsInBytes = argOffset - _transitionBlock.OffsetOfFloatArgumentRegisters;
Debug.Assert((floatRegOfsInBytes % _transitionBlock.FloatRegisterSize) == 0);
pLoc.m_idxFloatReg = floatRegOfsInBytes / _transitionBlock.FloatRegisterSize;
pLoc.m_cFloatReg = 1;

if (!_argTypeHandle.IsNull() && _argTypeHandle.IsHomogeneousAggregate())
{
int haElementSize = _argTypeHandle.GetHomogeneousAggregateElementSize();
pLoc.m_cFloatReg = GetArgSize() / haElementSize;
}
else
{
pLoc.m_cFloatReg = 1;
}
return pLoc;
}

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ protected override void EmitCode(NodeFactory factory, ref LoongArch64Emitter ins

if (!relocsOnly)
{
// movz T0=R12, #index
// ori T0=R12, R0, #index
int index = _containingImportSection.IndexFromBeginningOfArray;
instructionEncoder.EmitMOV(Register.R12, checked((ushort)index));
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -651,8 +651,8 @@ private class LoongArch64TransitionBlock : TransitionBlock
public override int NumCalleeSavedRegisters => 12;
// Callee-saves, argument registers
public override int SizeOfTransitionBlock => SizeOfCalleeSavedRegisters + SizeOfArgumentRegisters;
public override int OffsetOfArgumentRegisters => SizeOfCalleeSavedRegisters;
public override int OffsetOfFirstGCRefMapSlot => OffsetOfArgumentRegisters;
public override int OffsetOfFirstGCRefMapSlot => SizeOfCalleeSavedRegisters;
public override int OffsetOfArgumentRegisters => OffsetOfFirstGCRefMapSlot;

// F0..F7
public override int OffsetOfFloatArgumentRegisters => 8 * sizeof(double);
Expand All@@ -671,19 +671,11 @@ public override bool IsArgPassedByRef(TypeHandle th)
}
else
{
int numIntroducedFields = 0;
foreach (FieldDesc field in th.GetRuntimeTypeHandle().GetFields())
{
if (!field.IsStatic)
{
numIntroducedFields++;
}
}
return ((numIntroducedFields == 0) || (numIntroducedFields > 2));
return false;
}
}

public sealed override int GetRetBuffArgOffset(bool hasThis) => OffsetOfArgumentRegisters;
public sealed override int GetRetBuffArgOffset(bool hasThis) => OffsetOfFirstGCRefMapSlot + (hasThis ? 8 : 0);

public override int StackElemSize(int parmSize, bool isValueType = false, bool isFloatHfa = false)
{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -259,6 +259,14 @@ public override string ToString()

sb.AppendLine($" Has Tailcalls: {_wantsReportOnlyLeaf}");
}
else if (_machine == Machine.LoongArch64)
{
if (StackBaseRegister != 0xffffffff)
{
sb.AppendLine($" StackBaseRegister: {(LoongArch64.Registers)StackBaseRegister}");
}
sb.AppendLine($" Has Tailcalls: {_wantsReportOnlyLeaf}");
}

sb.AppendLine($" Size of parameter area: 0x{SizeOfStackOutgoingAndScratchArea:X}");
if (SizeOfEditAndContinuePreservedArea != 0xffffffff)
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -68,6 +68,9 @@ private static string GetRegisterName(int registerNumber, Machine machine)
case Machine.Arm64:
return ((Arm64.Registers)registerNumber).ToString();

case Machine.LoongArch64:
return ((LoongArch64.Registers)registerNumber).ToString();

default:
throw new NotImplementedException(machine.ToString());
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -65,6 +65,10 @@ public string GetSlotState(GcSlotTable slotTable, Machine machine)
regType = typeof(Amd64.Registers);
break;

case Machine.LoongArch64:
regType = typeof(LoongArch64.Registers);
break;

default:
throw new NotImplementedException();
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,6 +72,8 @@ public static string GetPlatformSpecificRegister(Machine machine, int regnum)
return ((Arm.Registers)regnum).ToString();
case Machine.Arm64:
return ((Arm64.Registers)regnum).ToString();
case Machine.LoongArch64:
return ((LoongArch64.Registers)regnum).ToString();
default:
throw new NotImplementedException($"No implementation for machine type {machine}.");
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -149,6 +149,11 @@ internal GcInfoTypes(Machine machine)
NUM_UNTRACKED_SLOTS_ENCBASE = 5;
REGISTER_DELTA_ENCBASE = 3;
break;
case Machine.LoongArch64:
SIZE_OF_RETURN_KIND_FAT = 4;
STACK_BASE_REGISTER_ENCBASE = 2;
NUM_REGISTERS_ENCBASE = 3;
break;
}
}

Expand All@@ -159,6 +164,7 @@ internal int DenormalizeCodeLength(int x)
case Machine.ArmThumb2:
return (x << 1);
case Machine.Arm64:
case Machine.LoongArch64:
return (x << 2);
}
return x;
Expand All@@ -173,6 +179,7 @@ internal int DenormalizeStackSlot(int x)
case Machine.ArmThumb2:
return (x << 2);
case Machine.Arm64:
case Machine.LoongArch64:
return (x << 3);
}
return x;
Expand All@@ -188,6 +195,8 @@ internal uint DenormalizeStackBaseRegister(uint x)
return ((x ^ 7) + 4);
case Machine.Arm64:
return (x ^ 29);
case Machine.LoongArch64:
return ((x ^ 22) & 0x3);
}
return x;
}
Expand All@@ -201,6 +210,7 @@ internal uint DenormalizeSizeOfStackArea(uint x)
case Machine.ArmThumb2:
return (x << 2);
case Machine.Arm64:
case Machine.LoongArch64:
return (x << 3);
}
return x;
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.Text;

namespace ILCompiler.Reflection.ReadyToRun.LoongArch64
{
public enum Registers
{
R0,
Ra,
Tp,
Sp,
A0,
A1,
A2,
A3,
A4,
A5,
A6,
A7,
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
X0,
Fp,
S0,
S1,
S2,
S3,
S4,
S5,
S6,
S7,
S8
}
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Text;

namespace ILCompiler.Reflection.ReadyToRun.LoongArch64
{
public class Epilog
{
public int Index { get; set; }

public uint EpilogStartOffset { get; set; }
public uint Res { get; set; }
public uint Condition { get; set; }
public uint EpilogStartIndex { get; set; }
public uint EpilogStartOffsetFromMainFunctionBegin { get; set; }

public Epilog() { }

public Epilog(int index, int dw, uint startOffset)
{
Index = index;

EpilogStartOffset = UnwindInfo.ExtractBits(dw, 0, 18);
Res = UnwindInfo.ExtractBits(dw, 18, 4);
Condition = UnwindInfo.ExtractBits(dw, 20, 4);
EpilogStartIndex = UnwindInfo.ExtractBits(dw, 22, 10);

// Note that epilogStartOffset for a funclet is the offset from the beginning
// of the current funclet, not the offset from the beginning of the main function.
// To help find it when looking through JitDump output, also show the offset from
// the beginning of the main function.
EpilogStartOffsetFromMainFunctionBegin = EpilogStartOffset * 4 + startOffset;
}

public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine($" Epilog Start Offset: 0x{EpilogStartOffset:X5} Actual offset = 0x{EpilogStartOffset * 4:X5} Offset from main function begin = 0x{EpilogStartOffsetFromMainFunctionBegin:X6}");
sb.AppendLine($" Condition: {Condition} (0x{Condition:X})" + ((Condition == 0xE) ? " (always)" : ""));
sb.Append($" Epilog Start Index: {EpilogStartIndex} (0x{EpilogStartIndex:X})");
return sb.ToString();
}
}

public class UnwindCode
{
public int Index { get; set; }

public UnwindCode() { }

public UnwindCode(int index)
{
Index = index;

}
}

/// <summary>
/// based on <a href="https://github.com/dotnet/runtime/src/coreclr/jit/unwindloongarch64.cpp">src/jit/unwindloongarch64.cpp</a> DumpUnwindInfo
/// </summary>
public class UnwindInfo : BaseUnwindInfo
{
public uint CodeWords { get; set; }
public uint EpilogCount { get; set; }
public uint EBit { get; set; }
public uint XBit { get; set; }
public uint Vers { get; set; }
public uint FunctionLength { get; set; }

public uint ExtendedCodeWords { get; set; }
public uint ExtendedEpilogCount { get; set; }

public Epilog[] Epilogs { get; set; }

public UnwindInfo() { }

public UnwindInfo(byte[] image, int offset)
{
uint startOffset = (uint)offset;

int dw = NativeReader.ReadInt32(image, ref offset);
CodeWords = ExtractBits(dw, 27, 5);
EpilogCount = ExtractBits(dw, 22, 5);
EBit = ExtractBits(dw, 21, 1);
XBit = ExtractBits(dw, 20, 1);
Vers = ExtractBits(dw, 18, 2);
FunctionLength = ExtractBits(dw, 0, 18) * 4;

if (CodeWords == 0 && EpilogCount == 0)
{
// We have an extension word specifying a larger number of Code Words or Epilog Counts
// than can be specified in the header word.
dw = NativeReader.ReadInt32(image, ref offset);
ExtendedCodeWords = ExtractBits(dw, 16, 8);
ExtendedEpilogCount = ExtractBits(dw, 0, 16);
}

bool[] epilogStartAt = new bool[1024]; // One byte per possible epilog start index; initialized to false

if (EBit == 0)
{
Epilogs = new Epilog[EpilogCount];
if (EpilogCount != 0)
{
for (int scope = 0; scope < EpilogCount; scope++)
{
dw = NativeReader.ReadInt32(image, ref offset);
Epilogs[scope] = new Epilog(scope, dw, startOffset);
epilogStartAt[Epilogs[scope].EpilogStartIndex] = true; // an epilog starts at this offset in the unwind codes
}
}
}
else
{
Epilogs = new Epilog[0];
epilogStartAt[EpilogCount] = true; // the one and only epilog starts its unwind codes at this offset
}



Size = offset - (int)startOffset + (int)CodeWords * 4;
int alignmentPad = ((Size + sizeof(int) - 1) & ~(sizeof(int) - 1)) - Size;
Size += (alignmentPad + sizeof(uint));
}

public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine($" CodeWords: {CodeWords}");
sb.AppendLine($" EpilogCount: {EpilogCount}");
sb.AppendLine($" EBit: {EBit}");
sb.AppendLine($" XBit: {XBit}");
sb.AppendLine($" Vers: {Vers}");
sb.AppendLine($" FunctionLength: {FunctionLength}");
if (CodeWords == 0 && EpilogCount == 0)
{
sb.AppendLine(" ---- Extension word ----");
sb.AppendLine($" Extended Code Words: {CodeWords}");
sb.AppendLine($" Extended Epilog Count: {EpilogCount}");
}
if (EpilogCount == 0)
{
sb.AppendLine(" No epilogs");
}
else
{
for (int i = 0; i < Epilogs.Length; i++)
{
sb.AppendLine(" -------------------------");
sb.AppendLine(Epilogs[i].ToString());
sb.AppendLine(" -------------------------");
}
}
return sb.ToString();
}

internal static uint ExtractBits(int dw, int start, int length)
{
return (uint)((dw >> start) & ((1 << length) - 1));
}
}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -225,6 +225,10 @@ private int GetSize()
{
return (int)arm64Info.FunctionLength;
}
else if (UnwindInfo is LoongArch64.UnwindInfo loongarch64Info)
{
return (int)loongarch64Info.FunctionLength;
}
else if (Method.GcInfo != null)
{
return Method.GcInfo.CodeLength;
Expand DownExpand Up@@ -488,7 +492,7 @@ private void EnsureInitialized()
}
else
{
// Armand Arm64 use the same GcInfo format as Amd64
// Arm, Arm64 and LoongArch64 use the same GcInfo format as Amd64
_gcInfo = new Amd64.GcInfo(_readyToRunReader.Image, gcInfoOffset, _readyToRunReader.Machine, _readyToRunReader.ReadyToRunHeader.MajorVersion);
}
}
Expand DownExpand Up@@ -604,6 +608,10 @@ private void ParseRuntimeFunctions(bool partial)
{
unwindInfo = new Arm64.UnwindInfo(_readyToRunReader.Image, unwindOffset);
}
else if (_readyToRunReader.Machine == Machine.LoongArch64)
{
unwindInfo = new LoongArch64.UnwindInfo(_readyToRunReader.Image, unwindOffset);
}

if (i == 0 && unwindInfo != null)
{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -1415,6 +1415,7 @@ private void EnsureImportSections()

case Machine.Amd64:
case Machine.Arm64:
case Machine.LoongArch64:
entrySize = 8;
break;

Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 numberDiff line numberDiff line change
Expand Up@@ -1732,16 +1732,8 @@ private void ForceSigWalk()
int floatRegOfsInBytes = argOffset - _transitionBlock.OffsetOfFloatArgumentRegisters;
Debug.Assert((floatRegOfsInBytes % _transitionBlock.FloatRegisterSize) == 0);
pLoc.m_idxFloatReg = floatRegOfsInBytes / _transitionBlock.FloatRegisterSize;
pLoc.m_cFloatReg = 1;

if (!_argTypeHandle.IsNull() && _argTypeHandle.IsHomogeneousAggregate())
{
int haElementSize = _argTypeHandle.GetHomogeneousAggregateElementSize();
pLoc.m_cFloatReg = GetArgSize() / haElementSize;
}
else
{
pLoc.m_cFloatReg = 1;
}
return pLoc;
}

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ protected override void EmitCode(NodeFactory factory, ref LoongArch64Emitter ins

if (!relocsOnly)
{
// movz T0=R12, #index
// ori T0=R12, R0, #index
int index = _containingImportSection.IndexFromBeginningOfArray;
instructionEncoder.EmitMOV(Register.R12, checked((ushort)index));
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -651,8 +651,8 @@ private class LoongArch64TransitionBlock : TransitionBlock
public override int NumCalleeSavedRegisters => 12;
// Callee-saves, argument registers
public override int SizeOfTransitionBlock => SizeOfCalleeSavedRegisters + SizeOfArgumentRegisters;
public override int OffsetOfArgumentRegisters => SizeOfCalleeSavedRegisters;
public override int OffsetOfFirstGCRefMapSlot => OffsetOfArgumentRegisters;
public override int OffsetOfFirstGCRefMapSlot => SizeOfCalleeSavedRegisters;
public override int OffsetOfArgumentRegisters => OffsetOfFirstGCRefMapSlot;

// F0..F7
public override int OffsetOfFloatArgumentRegisters => 8 * sizeof(double);
Expand All@@ -671,19 +671,11 @@ public override bool IsArgPassedByRef(TypeHandle th)
}
else
{
int numIntroducedFields = 0;
foreach (FieldDesc field in th.GetRuntimeTypeHandle().GetFields())
{
if (!field.IsStatic)
{
numIntroducedFields++;
}
}
return ((numIntroducedFields == 0) || (numIntroducedFields > 2));
return false;
}
}

public sealed override int GetRetBuffArgOffset(bool hasThis) => OffsetOfArgumentRegisters;
public sealed override int GetRetBuffArgOffset(bool hasThis) => OffsetOfFirstGCRefMapSlot + (hasThis ? 8 : 0);

public override int StackElemSize(int parmSize, bool isValueType = false, bool isFloatHfa = false)
{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -259,6 +259,14 @@ public override string ToString()

sb.AppendLine($" Has Tailcalls: {_wantsReportOnlyLeaf}");
}
else if (_machine == Machine.LoongArch64)
{
if (StackBaseRegister != 0xffffffff)
{
sb.AppendLine($" StackBaseRegister: {(LoongArch64.Registers)StackBaseRegister}");
}
sb.AppendLine($" Has Tailcalls: {_wantsReportOnlyLeaf}");
}

sb.AppendLine($" Size of parameter area: 0x{SizeOfStackOutgoingAndScratchArea:X}");
if (SizeOfEditAndContinuePreservedArea != 0xffffffff)
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -68,6 +68,9 @@ private static string GetRegisterName(int registerNumber, Machine machine)
case Machine.Arm64:
return ((Arm64.Registers)registerNumber).ToString();

case Machine.LoongArch64:
return ((LoongArch64.Registers)registerNumber).ToString();

default:
throw new NotImplementedException(machine.ToString());
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -65,6 +65,10 @@ public string GetSlotState(GcSlotTable slotTable, Machine machine)
regType = typeof(Amd64.Registers);
break;

case Machine.LoongArch64:
regType = typeof(LoongArch64.Registers);
break;

default:
throw new NotImplementedException();
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,6 +72,8 @@ public static string GetPlatformSpecificRegister(Machine machine, int regnum)
return ((Arm.Registers)regnum).ToString();
case Machine.Arm64:
return ((Arm64.Registers)regnum).ToString();
case Machine.LoongArch64:
return ((LoongArch64.Registers)regnum).ToString();
default:
throw new NotImplementedException($"No implementation for machine type {machine}.");
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -149,6 +149,11 @@ internal GcInfoTypes(Machine machine)
NUM_UNTRACKED_SLOTS_ENCBASE = 5;
REGISTER_DELTA_ENCBASE = 3;
break;
case Machine.LoongArch64:
SIZE_OF_RETURN_KIND_FAT = 4;
STACK_BASE_REGISTER_ENCBASE = 2;
NUM_REGISTERS_ENCBASE = 3;
break;
}
}

Expand All@@ -159,6 +164,7 @@ internal int DenormalizeCodeLength(int x)
case Machine.ArmThumb2:
return (x << 1);
case Machine.Arm64:
case Machine.LoongArch64:
return (x << 2);
}
return x;
Expand All@@ -173,6 +179,7 @@ internal int DenormalizeStackSlot(int x)
case Machine.ArmThumb2:
return (x << 2);
case Machine.Arm64:
case Machine.LoongArch64:
return (x << 3);
}
return x;
Expand All@@ -188,6 +195,8 @@ internal uint DenormalizeStackBaseRegister(uint x)
return ((x ^ 7) + 4);
case Machine.Arm64:
return (x ^ 29);
case Machine.LoongArch64:
return ((x ^ 22) & 0x3);
}
return x;
}
Expand All@@ -201,6 +210,7 @@ internal uint DenormalizeSizeOfStackArea(uint x)
case Machine.ArmThumb2:
return (x << 2);
case Machine.Arm64:
case Machine.LoongArch64:
return (x << 3);
}
return x;
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.Text;

namespace ILCompiler.Reflection.ReadyToRun.LoongArch64
{
public enum Registers
{
R0,
Ra,
Tp,
Sp,
A0,
A1,
A2,
A3,
A4,
A5,
A6,
A7,
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
X0,
Fp,
S0,
S1,
S2,
S3,
S4,
S5,
S6,
S7,
S8
}
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Text;

namespace ILCompiler.Reflection.ReadyToRun.LoongArch64
{
public class Epilog
{
public int Index { get; set; }

public uint EpilogStartOffset { get; set; }
public uint Res { get; set; }
public uint Condition { get; set; }
public uint EpilogStartIndex { get; set; }
public uint EpilogStartOffsetFromMainFunctionBegin { get; set; }

public Epilog() { }

public Epilog(int index, int dw, uint startOffset)
{
Index = index;

EpilogStartOffset = UnwindInfo.ExtractBits(dw, 0, 18);
Res = UnwindInfo.ExtractBits(dw, 18, 4);
Condition = UnwindInfo.ExtractBits(dw, 20, 4);
EpilogStartIndex = UnwindInfo.ExtractBits(dw, 22, 10);

// Note that epilogStartOffset for a funclet is the offset from the beginning
// of the current funclet, not the offset from the beginning of the main function.
// To help find it when looking through JitDump output, also show the offset from
// the beginning of the main function.
EpilogStartOffsetFromMainFunctionBegin = EpilogStartOffset * 4 + startOffset;
}

public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine($" Epilog Start Offset: 0x{EpilogStartOffset:X5} Actual offset = 0x{EpilogStartOffset * 4:X5} Offset from main function begin = 0x{EpilogStartOffsetFromMainFunctionBegin:X6}");
sb.AppendLine($" Condition: {Condition} (0x{Condition:X})" + ((Condition == 0xE) ? " (always)" : ""));
sb.Append($" Epilog Start Index: {EpilogStartIndex} (0x{EpilogStartIndex:X})");
return sb.ToString();
}
}

public class UnwindCode
{
public int Index { get; set; }

public UnwindCode() { }

public UnwindCode(int index)
{
Index = index;

}
}

/// <summary>
/// based on <a href="https://github.com/dotnet/runtime/src/coreclr/jit/unwindloongarch64.cpp">src/jit/unwindloongarch64.cpp</a> DumpUnwindInfo
/// </summary>
public class UnwindInfo : BaseUnwindInfo
{
public uint CodeWords { get; set; }
public uint EpilogCount { get; set; }
public uint EBit { get; set; }
public uint XBit { get; set; }
public uint Vers { get; set; }
public uint FunctionLength { get; set; }

public uint ExtendedCodeWords { get; set; }
public uint ExtendedEpilogCount { get; set; }

public Epilog[] Epilogs { get; set; }

public UnwindInfo() { }

public UnwindInfo(byte[] image, int offset)
{
uint startOffset = (uint)offset;

int dw = NativeReader.ReadInt32(image, ref offset);
CodeWords = ExtractBits(dw, 27, 5);
EpilogCount = ExtractBits(dw, 22, 5);
EBit = ExtractBits(dw, 21, 1);
XBit = ExtractBits(dw, 20, 1);
Vers = ExtractBits(dw, 18, 2);
FunctionLength = ExtractBits(dw, 0, 18) * 4;

if (CodeWords == 0 && EpilogCount == 0)
{
// We have an extension word specifying a larger number of Code Words or Epilog Counts
// than can be specified in the header word.
dw = NativeReader.ReadInt32(image, ref offset);
ExtendedCodeWords = ExtractBits(dw, 16, 8);
ExtendedEpilogCount = ExtractBits(dw, 0, 16);
}

bool[] epilogStartAt = new bool[1024]; // One byte per possible epilog start index; initialized to false

if (EBit == 0)
{
Epilogs = new Epilog[EpilogCount];
if (EpilogCount != 0)
{
for (int scope = 0; scope < EpilogCount; scope++)
{
dw = NativeReader.ReadInt32(image, ref offset);
Epilogs[scope] = new Epilog(scope, dw, startOffset);
epilogStartAt[Epilogs[scope].EpilogStartIndex] = true; // an epilog starts at this offset in the unwind codes
}
}
}
else
{
Epilogs = new Epilog[0];
epilogStartAt[EpilogCount] = true; // the one and only epilog starts its unwind codes at this offset
}



Size = offset - (int)startOffset + (int)CodeWords * 4;
int alignmentPad = ((Size + sizeof(int) - 1) & ~(sizeof(int) - 1)) - Size;
Size += (alignmentPad + sizeof(uint));
}

public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine($" CodeWords: {CodeWords}");
sb.AppendLine($" EpilogCount: {EpilogCount}");
sb.AppendLine($" EBit: {EBit}");
sb.AppendLine($" XBit: {XBit}");
sb.AppendLine($" Vers: {Vers}");
sb.AppendLine($" FunctionLength: {FunctionLength}");
if (CodeWords == 0 && EpilogCount == 0)
{
sb.AppendLine(" ---- Extension word ----");
sb.AppendLine($" Extended Code Words: {CodeWords}");
sb.AppendLine($" Extended Epilog Count: {EpilogCount}");
}
if (EpilogCount == 0)
{
sb.AppendLine(" No epilogs");
}
else
{
for (int i = 0; i < Epilogs.Length; i++)
{
sb.AppendLine(" -------------------------");
sb.AppendLine(Epilogs[i].ToString());
sb.AppendLine(" -------------------------");
}
}
return sb.ToString();
}

internal static uint ExtractBits(int dw, int start, int length)
{
return (uint)((dw >> start) & ((1 << length) - 1));
}
}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -225,6 +225,10 @@ private int GetSize()
{
return (int)arm64Info.FunctionLength;
}
else if (UnwindInfo is LoongArch64.UnwindInfo loongarch64Info)
{
return (int)loongarch64Info.FunctionLength;
}
else if (Method.GcInfo != null)
{
return Method.GcInfo.CodeLength;
Expand DownExpand Up@@ -488,7 +492,7 @@ private void EnsureInitialized()
}
else
{
// Armand Arm64 use the same GcInfo format as Amd64
// Arm, Arm64 and LoongArch64 use the same GcInfo format as Amd64
_gcInfo = new Amd64.GcInfo(_readyToRunReader.Image, gcInfoOffset, _readyToRunReader.Machine, _readyToRunReader.ReadyToRunHeader.MajorVersion);
}
}
Expand DownExpand Up@@ -604,6 +608,10 @@ private void ParseRuntimeFunctions(bool partial)
{
unwindInfo = new Arm64.UnwindInfo(_readyToRunReader.Image, unwindOffset);
}
else if (_readyToRunReader.Machine == Machine.LoongArch64)
{
unwindInfo = new LoongArch64.UnwindInfo(_readyToRunReader.Image, unwindOffset);
}

if (i == 0 && unwindInfo != null)
{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -1415,6 +1415,7 @@ private void EnsureImportSections()

case Machine.Amd64:
case Machine.Arm64:
case Machine.LoongArch64:
entrySize = 8;
break;

Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 numberDiff line numberDiff line change
Expand Up@@ -1732,16 +1732,8 @@ private void ForceSigWalk()
int floatRegOfsInBytes = argOffset - _transitionBlock.OffsetOfFloatArgumentRegisters;
Debug.Assert((floatRegOfsInBytes % _transitionBlock.FloatRegisterSize) == 0);
pLoc.m_idxFloatReg = floatRegOfsInBytes / _transitionBlock.FloatRegisterSize;
pLoc.m_cFloatReg = 1;

if (!_argTypeHandle.IsNull() && _argTypeHandle.IsHomogeneousAggregate())
{
int haElementSize = _argTypeHandle.GetHomogeneousAggregateElementSize();
pLoc.m_cFloatReg = GetArgSize() / haElementSize;
}
else
{
pLoc.m_cFloatReg = 1;
}
return pLoc;
}

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ protected override void EmitCode(NodeFactory factory, ref LoongArch64Emitter ins

if (!relocsOnly)
{
// movz T0=R12, #index
// ori T0=R12, R0, #index
int index = _containingImportSection.IndexFromBeginningOfArray;
instructionEncoder.EmitMOV(Register.R12, checked((ushort)index));
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -651,8 +651,8 @@ private class LoongArch64TransitionBlock : TransitionBlock
public override int NumCalleeSavedRegisters => 12;
// Callee-saves, argument registers
public override int SizeOfTransitionBlock => SizeOfCalleeSavedRegisters + SizeOfArgumentRegisters;
public override int OffsetOfArgumentRegisters => SizeOfCalleeSavedRegisters;
public override int OffsetOfFirstGCRefMapSlot => OffsetOfArgumentRegisters;
public override int OffsetOfFirstGCRefMapSlot => SizeOfCalleeSavedRegisters;
public override int OffsetOfArgumentRegisters => OffsetOfFirstGCRefMapSlot;

// F0..F7
public override int OffsetOfFloatArgumentRegisters => 8 * sizeof(double);
Expand All@@ -671,19 +671,11 @@ public override bool IsArgPassedByRef(TypeHandle th)
}
else
{
int numIntroducedFields = 0;
foreach (FieldDesc field in th.GetRuntimeTypeHandle().GetFields())
{
if (!field.IsStatic)
{
numIntroducedFields++;
}
}
return ((numIntroducedFields == 0) || (numIntroducedFields > 2));
return false;
}
}

public sealed override int GetRetBuffArgOffset(bool hasThis) => OffsetOfArgumentRegisters;
public sealed override int GetRetBuffArgOffset(bool hasThis) => OffsetOfFirstGCRefMapSlot + (hasThis ? 8 : 0);

public override int StackElemSize(int parmSize, bool isValueType = false, bool isFloatHfa = false)
{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -259,6 +259,14 @@ public override string ToString()

sb.AppendLine($" Has Tailcalls: {_wantsReportOnlyLeaf}");
}
else if (_machine == Machine.LoongArch64)
{
if (StackBaseRegister != 0xffffffff)
{
sb.AppendLine($" StackBaseRegister: {(LoongArch64.Registers)StackBaseRegister}");
}
sb.AppendLine($" Has Tailcalls: {_wantsReportOnlyLeaf}");
}

sb.AppendLine($" Size of parameter area: 0x{SizeOfStackOutgoingAndScratchArea:X}");
if (SizeOfEditAndContinuePreservedArea != 0xffffffff)
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -68,6 +68,9 @@ private static string GetRegisterName(int registerNumber, Machine machine)
case Machine.Arm64:
return ((Arm64.Registers)registerNumber).ToString();

case Machine.LoongArch64:
return ((LoongArch64.Registers)registerNumber).ToString();

default:
throw new NotImplementedException(machine.ToString());
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -65,6 +65,10 @@ public string GetSlotState(GcSlotTable slotTable, Machine machine)
regType = typeof(Amd64.Registers);
break;

case Machine.LoongArch64:
regType = typeof(LoongArch64.Registers);
break;

default:
throw new NotImplementedException();
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,6 +72,8 @@ public static string GetPlatformSpecificRegister(Machine machine, int regnum)
return ((Arm.Registers)regnum).ToString();
case Machine.Arm64:
return ((Arm64.Registers)regnum).ToString();
case Machine.LoongArch64:
return ((LoongArch64.Registers)regnum).ToString();
default:
throw new NotImplementedException($"No implementation for machine type {machine}.");
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -149,6 +149,11 @@ internal GcInfoTypes(Machine machine)
NUM_UNTRACKED_SLOTS_ENCBASE = 5;
REGISTER_DELTA_ENCBASE = 3;
break;
case Machine.LoongArch64:
SIZE_OF_RETURN_KIND_FAT = 4;
STACK_BASE_REGISTER_ENCBASE = 2;
NUM_REGISTERS_ENCBASE = 3;
break;
}
}

Expand All@@ -159,6 +164,7 @@ internal int DenormalizeCodeLength(int x)
case Machine.ArmThumb2:
return (x << 1);
case Machine.Arm64:
case Machine.LoongArch64:
return (x << 2);
}
return x;
Expand All@@ -173,6 +179,7 @@ internal int DenormalizeStackSlot(int x)
case Machine.ArmThumb2:
return (x << 2);
case Machine.Arm64:
case Machine.LoongArch64:
return (x << 3);
}
return x;
Expand All@@ -188,6 +195,8 @@ internal uint DenormalizeStackBaseRegister(uint x)
return ((x ^ 7) + 4);
case Machine.Arm64:
return (x ^ 29);
case Machine.LoongArch64:
return ((x ^ 22) & 0x3);
}
return x;
}
Expand All@@ -201,6 +210,7 @@ internal uint DenormalizeSizeOfStackArea(uint x)
case Machine.ArmThumb2:
return (x << 2);
case Machine.Arm64:
case Machine.LoongArch64:
return (x << 3);
}
return x;
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.Text;

namespace ILCompiler.Reflection.ReadyToRun.LoongArch64
{
public enum Registers
{
R0,
Ra,
Tp,
Sp,
A0,
A1,
A2,
A3,
A4,
A5,
A6,
A7,
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
X0,
Fp,
S0,
S1,
S2,
S3,
S4,
S5,
S6,
S7,
S8
}
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Text;

namespace ILCompiler.Reflection.ReadyToRun.LoongArch64
{
public class Epilog
{
public int Index { get; set; }

public uint EpilogStartOffset { get; set; }
public uint Res { get; set; }
public uint Condition { get; set; }
public uint EpilogStartIndex { get; set; }
public uint EpilogStartOffsetFromMainFunctionBegin { get; set; }

public Epilog() { }

public Epilog(int index, int dw, uint startOffset)
{
Index = index;

EpilogStartOffset = UnwindInfo.ExtractBits(dw, 0, 18);
Res = UnwindInfo.ExtractBits(dw, 18, 4);
Condition = UnwindInfo.ExtractBits(dw, 20, 4);
EpilogStartIndex = UnwindInfo.ExtractBits(dw, 22, 10);

// Note that epilogStartOffset for a funclet is the offset from the beginning
// of the current funclet, not the offset from the beginning of the main function.
// To help find it when looking through JitDump output, also show the offset from
// the beginning of the main function.
EpilogStartOffsetFromMainFunctionBegin = EpilogStartOffset * 4 + startOffset;
}

public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine($" Epilog Start Offset: 0x{EpilogStartOffset:X5} Actual offset = 0x{EpilogStartOffset * 4:X5} Offset from main function begin = 0x{EpilogStartOffsetFromMainFunctionBegin:X6}");
sb.AppendLine($" Condition: {Condition} (0x{Condition:X})" + ((Condition == 0xE) ? " (always)" : ""));
sb.Append($" Epilog Start Index: {EpilogStartIndex} (0x{EpilogStartIndex:X})");
return sb.ToString();
}
}

public class UnwindCode
{
public int Index { get; set; }

public UnwindCode() { }

public UnwindCode(int index)
{
Index = index;

}
}

/// <summary>
/// based on <a href="https://github.com/dotnet/runtime/src/coreclr/jit/unwindloongarch64.cpp">src/jit/unwindloongarch64.cpp</a> DumpUnwindInfo
/// </summary>
public class UnwindInfo : BaseUnwindInfo
{
public uint CodeWords { get; set; }
public uint EpilogCount { get; set; }
public uint EBit { get; set; }
public uint XBit { get; set; }
public uint Vers { get; set; }
public uint FunctionLength { get; set; }

public uint ExtendedCodeWords { get; set; }
public uint ExtendedEpilogCount { get; set; }

public Epilog[] Epilogs { get; set; }

public UnwindInfo() { }

public UnwindInfo(byte[] image, int offset)
{
uint startOffset = (uint)offset;

int dw = NativeReader.ReadInt32(image, ref offset);
CodeWords = ExtractBits(dw, 27, 5);
EpilogCount = ExtractBits(dw, 22, 5);
EBit = ExtractBits(dw, 21, 1);
XBit = ExtractBits(dw, 20, 1);
Vers = ExtractBits(dw, 18, 2);
FunctionLength = ExtractBits(dw, 0, 18) * 4;

if (CodeWords == 0 && EpilogCount == 0)
{
// We have an extension word specifying a larger number of Code Words or Epilog Counts
// than can be specified in the header word.
dw = NativeReader.ReadInt32(image, ref offset);
ExtendedCodeWords = ExtractBits(dw, 16, 8);
ExtendedEpilogCount = ExtractBits(dw, 0, 16);
}

bool[] epilogStartAt = new bool[1024]; // One byte per possible epilog start index; initialized to false

if (EBit == 0)
{
Epilogs = new Epilog[EpilogCount];
if (EpilogCount != 0)
{
for (int scope = 0; scope < EpilogCount; scope++)
{
dw = NativeReader.ReadInt32(image, ref offset);
Epilogs[scope] = new Epilog(scope, dw, startOffset);
epilogStartAt[Epilogs[scope].EpilogStartIndex] = true; // an epilog starts at this offset in the unwind codes
}
}
}
else
{
Epilogs = new Epilog[0];
epilogStartAt[EpilogCount] = true; // the one and only epilog starts its unwind codes at this offset
}



Size = offset - (int)startOffset + (int)CodeWords * 4;
int alignmentPad = ((Size + sizeof(int) - 1) & ~(sizeof(int) - 1)) - Size;
Size += (alignmentPad + sizeof(uint));
}

public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine($" CodeWords: {CodeWords}");
sb.AppendLine($" EpilogCount: {EpilogCount}");
sb.AppendLine($" EBit: {EBit}");
sb.AppendLine($" XBit: {XBit}");
sb.AppendLine($" Vers: {Vers}");
sb.AppendLine($" FunctionLength: {FunctionLength}");
if (CodeWords == 0 && EpilogCount == 0)
{
sb.AppendLine(" ---- Extension word ----");
sb.AppendLine($" Extended Code Words: {CodeWords}");
sb.AppendLine($" Extended Epilog Count: {EpilogCount}");
}
if (EpilogCount == 0)
{
sb.AppendLine(" No epilogs");
}
else
{
for (int i = 0; i < Epilogs.Length; i++)
{
sb.AppendLine(" -------------------------");
sb.AppendLine(Epilogs[i].ToString());
sb.AppendLine(" -------------------------");
}
}
return sb.ToString();
}

internal static uint ExtractBits(int dw, int start, int length)
{
return (uint)((dw >> start) & ((1 << length) - 1));
}
}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -225,6 +225,10 @@ private int GetSize()
{
return (int)arm64Info.FunctionLength;
}
else if (UnwindInfo is LoongArch64.UnwindInfo loongarch64Info)
{
return (int)loongarch64Info.FunctionLength;
}
else if (Method.GcInfo != null)
{
return Method.GcInfo.CodeLength;
Expand DownExpand Up@@ -488,7 +492,7 @@ private void EnsureInitialized()
}
else
{
// Armand Arm64 use the same GcInfo format as Amd64
// Arm, Arm64 and LoongArch64 use the same GcInfo format as Amd64
_gcInfo = new Amd64.GcInfo(_readyToRunReader.Image, gcInfoOffset, _readyToRunReader.Machine, _readyToRunReader.ReadyToRunHeader.MajorVersion);
}
}
Expand DownExpand Up@@ -604,6 +608,10 @@ private void ParseRuntimeFunctions(bool partial)
{
unwindInfo = new Arm64.UnwindInfo(_readyToRunReader.Image, unwindOffset);
}
else if (_readyToRunReader.Machine == Machine.LoongArch64)
{
unwindInfo = new LoongArch64.UnwindInfo(_readyToRunReader.Image, unwindOffset);
}

if (i == 0 && unwindInfo != null)
{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -1415,6 +1415,7 @@ private void EnsureImportSections()

case Machine.Amd64:
case Machine.Arm64:
case Machine.LoongArch64:
entrySize = 8;
break;

Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 numberDiff line numberDiff line change
Expand Up@@ -1732,16 +1732,8 @@ private void ForceSigWalk()
int floatRegOfsInBytes = argOffset - _transitionBlock.OffsetOfFloatArgumentRegisters;
Debug.Assert((floatRegOfsInBytes % _transitionBlock.FloatRegisterSize) == 0);
pLoc.m_idxFloatReg = floatRegOfsInBytes / _transitionBlock.FloatRegisterSize;
pLoc.m_cFloatReg = 1;

if (!_argTypeHandle.IsNull() && _argTypeHandle.IsHomogeneousAggregate())
{
int haElementSize = _argTypeHandle.GetHomogeneousAggregateElementSize();
pLoc.m_cFloatReg = GetArgSize() / haElementSize;
}
else
{
pLoc.m_cFloatReg = 1;
}
return pLoc;
}

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ protected override void EmitCode(NodeFactory factory, ref LoongArch64Emitter ins

if (!relocsOnly)
{
// movz T0=R12, #index
// ori T0=R12, R0, #index
int index = _containingImportSection.IndexFromBeginningOfArray;
instructionEncoder.EmitMOV(Register.R12, checked((ushort)index));
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -651,8 +651,8 @@ private class LoongArch64TransitionBlock : TransitionBlock
public override int NumCalleeSavedRegisters => 12;
// Callee-saves, argument registers
public override int SizeOfTransitionBlock => SizeOfCalleeSavedRegisters + SizeOfArgumentRegisters;
public override int OffsetOfArgumentRegisters => SizeOfCalleeSavedRegisters;
public override int OffsetOfFirstGCRefMapSlot => OffsetOfArgumentRegisters;
public override int OffsetOfFirstGCRefMapSlot => SizeOfCalleeSavedRegisters;
public override int OffsetOfArgumentRegisters => OffsetOfFirstGCRefMapSlot;

// F0..F7
public override int OffsetOfFloatArgumentRegisters => 8 * sizeof(double);
Expand All@@ -671,19 +671,11 @@ public override bool IsArgPassedByRef(TypeHandle th)
}
else
{
int numIntroducedFields = 0;
foreach (FieldDesc field in th.GetRuntimeTypeHandle().GetFields())
{
if (!field.IsStatic)
{
numIntroducedFields++;
}
}
return ((numIntroducedFields == 0) || (numIntroducedFields > 2));
return false;
}
}

public sealed override int GetRetBuffArgOffset(bool hasThis) => OffsetOfArgumentRegisters;
public sealed override int GetRetBuffArgOffset(bool hasThis) => OffsetOfFirstGCRefMapSlot + (hasThis ? 8 : 0);

public override int StackElemSize(int parmSize, bool isValueType = false, bool isFloatHfa = false)
{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -259,6 +259,14 @@ public override string ToString()

sb.AppendLine($" Has Tailcalls: {_wantsReportOnlyLeaf}");
}
else if (_machine == Machine.LoongArch64)
{
if (StackBaseRegister != 0xffffffff)
{
sb.AppendLine($" StackBaseRegister: {(LoongArch64.Registers)StackBaseRegister}");
}
sb.AppendLine($" Has Tailcalls: {_wantsReportOnlyLeaf}");
}

sb.AppendLine($" Size of parameter area: 0x{SizeOfStackOutgoingAndScratchArea:X}");
if (SizeOfEditAndContinuePreservedArea != 0xffffffff)
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -68,6 +68,9 @@ private static string GetRegisterName(int registerNumber, Machine machine)
case Machine.Arm64:
return ((Arm64.Registers)registerNumber).ToString();

case Machine.LoongArch64:
return ((LoongArch64.Registers)registerNumber).ToString();

default:
throw new NotImplementedException(machine.ToString());
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -65,6 +65,10 @@ public string GetSlotState(GcSlotTable slotTable, Machine machine)
regType = typeof(Amd64.Registers);
break;

case Machine.LoongArch64:
regType = typeof(LoongArch64.Registers);
break;

default:
throw new NotImplementedException();
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,6 +72,8 @@ public static string GetPlatformSpecificRegister(Machine machine, int regnum)
return ((Arm.Registers)regnum).ToString();
case Machine.Arm64:
return ((Arm64.Registers)regnum).ToString();
case Machine.LoongArch64:
return ((LoongArch64.Registers)regnum).ToString();
default:
throw new NotImplementedException($"No implementation for machine type {machine}.");
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -149,6 +149,11 @@ internal GcInfoTypes(Machine machine)
NUM_UNTRACKED_SLOTS_ENCBASE = 5;
REGISTER_DELTA_ENCBASE = 3;
break;
case Machine.LoongArch64:
SIZE_OF_RETURN_KIND_FAT = 4;
STACK_BASE_REGISTER_ENCBASE = 2;
NUM_REGISTERS_ENCBASE = 3;
break;
}
}

Expand All@@ -159,6 +164,7 @@ internal int DenormalizeCodeLength(int x)
case Machine.ArmThumb2:
return (x << 1);
case Machine.Arm64:
case Machine.LoongArch64:
return (x << 2);
}
return x;
Expand All@@ -173,6 +179,7 @@ internal int DenormalizeStackSlot(int x)
case Machine.ArmThumb2:
return (x << 2);
case Machine.Arm64:
case Machine.LoongArch64:
return (x << 3);
}
return x;
Expand All@@ -188,6 +195,8 @@ internal uint DenormalizeStackBaseRegister(uint x)
return ((x ^ 7) + 4);
case Machine.Arm64:
return (x ^ 29);
case Machine.LoongArch64:
return ((x ^ 22) & 0x3);
}
return x;
}
Expand All@@ -201,6 +210,7 @@ internal uint DenormalizeSizeOfStackArea(uint x)
case Machine.ArmThumb2:
return (x << 2);
case Machine.Arm64:
case Machine.LoongArch64:
return (x << 3);
}
return x;
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.Text;

namespace ILCompiler.Reflection.ReadyToRun.LoongArch64
{
public enum Registers
{
R0,
Ra,
Tp,
Sp,
A0,
A1,
A2,
A3,
A4,
A5,
A6,
A7,
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
X0,
Fp,
S0,
S1,
S2,
S3,
S4,
S5,
S6,
S7,
S8
}
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Text;

namespace ILCompiler.Reflection.ReadyToRun.LoongArch64
{
public class Epilog
{
public int Index { get; set; }

public uint EpilogStartOffset { get; set; }
public uint Res { get; set; }
public uint Condition { get; set; }
public uint EpilogStartIndex { get; set; }
public uint EpilogStartOffsetFromMainFunctionBegin { get; set; }

public Epilog() { }

public Epilog(int index, int dw, uint startOffset)
{
Index = index;

EpilogStartOffset = UnwindInfo.ExtractBits(dw, 0, 18);
Res = UnwindInfo.ExtractBits(dw, 18, 4);
Condition = UnwindInfo.ExtractBits(dw, 20, 4);
EpilogStartIndex = UnwindInfo.ExtractBits(dw, 22, 10);

// Note that epilogStartOffset for a funclet is the offset from the beginning
// of the current funclet, not the offset from the beginning of the main function.
// To help find it when looking through JitDump output, also show the offset from
// the beginning of the main function.
EpilogStartOffsetFromMainFunctionBegin = EpilogStartOffset * 4 + startOffset;
}

public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine($" Epilog Start Offset: 0x{EpilogStartOffset:X5} Actual offset = 0x{EpilogStartOffset * 4:X5} Offset from main function begin = 0x{EpilogStartOffsetFromMainFunctionBegin:X6}");
sb.AppendLine($" Condition: {Condition} (0x{Condition:X})" + ((Condition == 0xE) ? " (always)" : ""));
sb.Append($" Epilog Start Index: {EpilogStartIndex} (0x{EpilogStartIndex:X})");
return sb.ToString();
}
}

public class UnwindCode
{
public int Index { get; set; }

public UnwindCode() { }

public UnwindCode(int index)
{
Index = index;

}
}

/// <summary>
/// based on <a href="https://github.com/dotnet/runtime/src/coreclr/jit/unwindloongarch64.cpp">src/jit/unwindloongarch64.cpp</a> DumpUnwindInfo
/// </summary>
public class UnwindInfo : BaseUnwindInfo
{
public uint CodeWords { get; set; }
public uint EpilogCount { get; set; }
public uint EBit { get; set; }
public uint XBit { get; set; }
public uint Vers { get; set; }
public uint FunctionLength { get; set; }

public uint ExtendedCodeWords { get; set; }
public uint ExtendedEpilogCount { get; set; }

public Epilog[] Epilogs { get; set; }

public UnwindInfo() { }

public UnwindInfo(byte[] image, int offset)
{
uint startOffset = (uint)offset;

int dw = NativeReader.ReadInt32(image, ref offset);
CodeWords = ExtractBits(dw, 27, 5);
EpilogCount = ExtractBits(dw, 22, 5);
EBit = ExtractBits(dw, 21, 1);
XBit = ExtractBits(dw, 20, 1);
Vers = ExtractBits(dw, 18, 2);
FunctionLength = ExtractBits(dw, 0, 18) * 4;

if (CodeWords == 0 && EpilogCount == 0)
{
// We have an extension word specifying a larger number of Code Words or Epilog Counts
// than can be specified in the header word.
dw = NativeReader.ReadInt32(image, ref offset);
ExtendedCodeWords = ExtractBits(dw, 16, 8);
ExtendedEpilogCount = ExtractBits(dw, 0, 16);
}

bool[] epilogStartAt = new bool[1024]; // One byte per possible epilog start index; initialized to false

if (EBit == 0)
{
Epilogs = new Epilog[EpilogCount];
if (EpilogCount != 0)
{
for (int scope = 0; scope < EpilogCount; scope++)
{
dw = NativeReader.ReadInt32(image, ref offset);
Epilogs[scope] = new Epilog(scope, dw, startOffset);
epilogStartAt[Epilogs[scope].EpilogStartIndex] = true; // an epilog starts at this offset in the unwind codes
}
}
}
else
{
Epilogs = new Epilog[0];
epilogStartAt[EpilogCount] = true; // the one and only epilog starts its unwind codes at this offset
}



Size = offset - (int)startOffset + (int)CodeWords * 4;
int alignmentPad = ((Size + sizeof(int) - 1) & ~(sizeof(int) - 1)) - Size;
Size += (alignmentPad + sizeof(uint));
}

public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine($" CodeWords: {CodeWords}");
sb.AppendLine($" EpilogCount: {EpilogCount}");
sb.AppendLine($" EBit: {EBit}");
sb.AppendLine($" XBit: {XBit}");
sb.AppendLine($" Vers: {Vers}");
sb.AppendLine($" FunctionLength: {FunctionLength}");
if (CodeWords == 0 && EpilogCount == 0)
{
sb.AppendLine(" ---- Extension word ----");
sb.AppendLine($" Extended Code Words: {CodeWords}");
sb.AppendLine($" Extended Epilog Count: {EpilogCount}");
}
if (EpilogCount == 0)
{
sb.AppendLine(" No epilogs");
}
else
{
for (int i = 0; i < Epilogs.Length; i++)
{
sb.AppendLine(" -------------------------");
sb.AppendLine(Epilogs[i].ToString());
sb.AppendLine(" -------------------------");
}
}
return sb.ToString();
}

internal static uint ExtractBits(int dw, int start, int length)
{
return (uint)((dw >> start) & ((1 << length) - 1));
}
}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -225,6 +225,10 @@ private int GetSize()
{
return (int)arm64Info.FunctionLength;
}
else if (UnwindInfo is LoongArch64.UnwindInfo loongarch64Info)
{
return (int)loongarch64Info.FunctionLength;
}
else if (Method.GcInfo != null)
{
return Method.GcInfo.CodeLength;
Expand DownExpand Up@@ -488,7 +492,7 @@ private void EnsureInitialized()
}
else
{
// Armand Arm64 use the same GcInfo format as Amd64
// Arm, Arm64 and LoongArch64 use the same GcInfo format as Amd64
_gcInfo = new Amd64.GcInfo(_readyToRunReader.Image, gcInfoOffset, _readyToRunReader.Machine, _readyToRunReader.ReadyToRunHeader.MajorVersion);
}
}
Expand DownExpand Up@@ -604,6 +608,10 @@ private void ParseRuntimeFunctions(bool partial)
{
unwindInfo = new Arm64.UnwindInfo(_readyToRunReader.Image, unwindOffset);
}
else if (_readyToRunReader.Machine == Machine.LoongArch64)
{
unwindInfo = new LoongArch64.UnwindInfo(_readyToRunReader.Image, unwindOffset);
}

if (i == 0 && unwindInfo != null)
{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -1415,6 +1415,7 @@ private void EnsureImportSections()

case Machine.Amd64:
case Machine.Arm64:
case Machine.LoongArch64:
entrySize = 8;
break;

Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 numberDiff line numberDiff line change
Expand Up@@ -1732,16 +1732,8 @@ private void ForceSigWalk()
int floatRegOfsInBytes = argOffset - _transitionBlock.OffsetOfFloatArgumentRegisters;
Debug.Assert((floatRegOfsInBytes % _transitionBlock.FloatRegisterSize) == 0);
pLoc.m_idxFloatReg = floatRegOfsInBytes / _transitionBlock.FloatRegisterSize;
pLoc.m_cFloatReg = 1;

if (!_argTypeHandle.IsNull() && _argTypeHandle.IsHomogeneousAggregate())
{
int haElementSize = _argTypeHandle.GetHomogeneousAggregateElementSize();
pLoc.m_cFloatReg = GetArgSize() / haElementSize;
}
else
{
pLoc.m_cFloatReg = 1;
}
return pLoc;
}

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ protected override void EmitCode(NodeFactory factory, ref LoongArch64Emitter ins

if (!relocsOnly)
{
// movz T0=R12, #index
// ori T0=R12, R0, #index
int index = _containingImportSection.IndexFromBeginningOfArray;
instructionEncoder.EmitMOV(Register.R12, checked((ushort)index));
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -651,8 +651,8 @@ private class LoongArch64TransitionBlock : TransitionBlock
public override int NumCalleeSavedRegisters => 12;
// Callee-saves, argument registers
public override int SizeOfTransitionBlock => SizeOfCalleeSavedRegisters + SizeOfArgumentRegisters;
public override int OffsetOfArgumentRegisters => SizeOfCalleeSavedRegisters;
public override int OffsetOfFirstGCRefMapSlot => OffsetOfArgumentRegisters;
public override int OffsetOfFirstGCRefMapSlot => SizeOfCalleeSavedRegisters;
public override int OffsetOfArgumentRegisters => OffsetOfFirstGCRefMapSlot;

// F0..F7
public override int OffsetOfFloatArgumentRegisters => 8 * sizeof(double);
Expand All@@ -671,19 +671,11 @@ public override bool IsArgPassedByRef(TypeHandle th)
}
else
{
int numIntroducedFields = 0;
foreach (FieldDesc field in th.GetRuntimeTypeHandle().GetFields())
{
if (!field.IsStatic)
{
numIntroducedFields++;
}
}
return ((numIntroducedFields == 0) || (numIntroducedFields > 2));
return false;
}
}

public sealed override int GetRetBuffArgOffset(bool hasThis) => OffsetOfArgumentRegisters;
public sealed override int GetRetBuffArgOffset(bool hasThis) => OffsetOfFirstGCRefMapSlot + (hasThis ? 8 : 0);

public override int StackElemSize(int parmSize, bool isValueType = false, bool isFloatHfa = false)
{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -259,6 +259,14 @@ public override string ToString()

sb.AppendLine($" Has Tailcalls: {_wantsReportOnlyLeaf}");
}
else if (_machine == Machine.LoongArch64)
{
if (StackBaseRegister != 0xffffffff)
{
sb.AppendLine($" StackBaseRegister: {(LoongArch64.Registers)StackBaseRegister}");
}
sb.AppendLine($" Has Tailcalls: {_wantsReportOnlyLeaf}");
}

sb.AppendLine($" Size of parameter area: 0x{SizeOfStackOutgoingAndScratchArea:X}");
if (SizeOfEditAndContinuePreservedArea != 0xffffffff)
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -68,6 +68,9 @@ private static string GetRegisterName(int registerNumber, Machine machine)
case Machine.Arm64:
return ((Arm64.Registers)registerNumber).ToString();

case Machine.LoongArch64:
return ((LoongArch64.Registers)registerNumber).ToString();

default:
throw new NotImplementedException(machine.ToString());
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -65,6 +65,10 @@ public string GetSlotState(GcSlotTable slotTable, Machine machine)
regType = typeof(Amd64.Registers);
break;

case Machine.LoongArch64:
regType = typeof(LoongArch64.Registers);
break;

default:
throw new NotImplementedException();
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,6 +72,8 @@ public static string GetPlatformSpecificRegister(Machine machine, int regnum)
return ((Arm.Registers)regnum).ToString();
case Machine.Arm64:
return ((Arm64.Registers)regnum).ToString();
case Machine.LoongArch64:
return ((LoongArch64.Registers)regnum).ToString();
default:
throw new NotImplementedException($"No implementation for machine type {machine}.");
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -149,6 +149,11 @@ internal GcInfoTypes(Machine machine)
NUM_UNTRACKED_SLOTS_ENCBASE = 5;
REGISTER_DELTA_ENCBASE = 3;
break;
case Machine.LoongArch64:
SIZE_OF_RETURN_KIND_FAT = 4;
STACK_BASE_REGISTER_ENCBASE = 2;
NUM_REGISTERS_ENCBASE = 3;
break;
}
}

Expand All@@ -159,6 +164,7 @@ internal int DenormalizeCodeLength(int x)
case Machine.ArmThumb2:
return (x << 1);
case Machine.Arm64:
case Machine.LoongArch64:
return (x << 2);
}
return x;
Expand All@@ -173,6 +179,7 @@ internal int DenormalizeStackSlot(int x)
case Machine.ArmThumb2:
return (x << 2);
case Machine.Arm64:
case Machine.LoongArch64:
return (x << 3);
}
return x;
Expand All@@ -188,6 +195,8 @@ internal uint DenormalizeStackBaseRegister(uint x)
return ((x ^ 7) + 4);
case Machine.Arm64:
return (x ^ 29);
case Machine.LoongArch64:
return ((x ^ 22) & 0x3);
}
return x;
}
Expand All@@ -201,6 +210,7 @@ internal uint DenormalizeSizeOfStackArea(uint x)
case Machine.ArmThumb2:
return (x << 2);
case Machine.Arm64:
case Machine.LoongArch64:
return (x << 3);
}
return x;
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.Text;

namespace ILCompiler.Reflection.ReadyToRun.LoongArch64
{
public enum Registers
{
R0,
Ra,
Tp,
Sp,
A0,
A1,
A2,
A3,
A4,
A5,
A6,
A7,
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
X0,
Fp,
S0,
S1,
S2,
S3,
S4,
S5,
S6,
S7,
S8
}
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Text;

namespace ILCompiler.Reflection.ReadyToRun.LoongArch64
{
public class Epilog
{
public int Index { get; set; }

public uint EpilogStartOffset { get; set; }
public uint Res { get; set; }
public uint Condition { get; set; }
public uint EpilogStartIndex { get; set; }
public uint EpilogStartOffsetFromMainFunctionBegin { get; set; }

public Epilog() { }

public Epilog(int index, int dw, uint startOffset)
{
Index = index;

EpilogStartOffset = UnwindInfo.ExtractBits(dw, 0, 18);
Res = UnwindInfo.ExtractBits(dw, 18, 4);
Condition = UnwindInfo.ExtractBits(dw, 20, 4);
EpilogStartIndex = UnwindInfo.ExtractBits(dw, 22, 10);

// Note that epilogStartOffset for a funclet is the offset from the beginning
// of the current funclet, not the offset from the beginning of the main function.
// To help find it when looking through JitDump output, also show the offset from
// the beginning of the main function.
EpilogStartOffsetFromMainFunctionBegin = EpilogStartOffset * 4 + startOffset;
}

public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine($" Epilog Start Offset: 0x{EpilogStartOffset:X5} Actual offset = 0x{EpilogStartOffset * 4:X5} Offset from main function begin = 0x{EpilogStartOffsetFromMainFunctionBegin:X6}");
sb.AppendLine($" Condition: {Condition} (0x{Condition:X})" + ((Condition == 0xE) ? " (always)" : ""));
sb.Append($" Epilog Start Index: {EpilogStartIndex} (0x{EpilogStartIndex:X})");
return sb.ToString();
}
}

public class UnwindCode
{
public int Index { get; set; }

public UnwindCode() { }

public UnwindCode(int index)
{
Index = index;

}
}

/// <summary>
/// based on <a href="https://github.com/dotnet/runtime/src/coreclr/jit/unwindloongarch64.cpp">src/jit/unwindloongarch64.cpp</a> DumpUnwindInfo
/// </summary>
public class UnwindInfo : BaseUnwindInfo
{
public uint CodeWords { get; set; }
public uint EpilogCount { get; set; }
public uint EBit { get; set; }
public uint XBit { get; set; }
public uint Vers { get; set; }
public uint FunctionLength { get; set; }

public uint ExtendedCodeWords { get; set; }
public uint ExtendedEpilogCount { get; set; }

public Epilog[] Epilogs { get; set; }

public UnwindInfo() { }

public UnwindInfo(byte[] image, int offset)
{
uint startOffset = (uint)offset;

int dw = NativeReader.ReadInt32(image, ref offset);
CodeWords = ExtractBits(dw, 27, 5);
EpilogCount = ExtractBits(dw, 22, 5);
EBit = ExtractBits(dw, 21, 1);
XBit = ExtractBits(dw, 20, 1);
Vers = ExtractBits(dw, 18, 2);
FunctionLength = ExtractBits(dw, 0, 18) * 4;

if (CodeWords == 0 && EpilogCount == 0)
{
// We have an extension word specifying a larger number of Code Words or Epilog Counts
// than can be specified in the header word.
dw = NativeReader.ReadInt32(image, ref offset);
ExtendedCodeWords = ExtractBits(dw, 16, 8);
ExtendedEpilogCount = ExtractBits(dw, 0, 16);
}

bool[] epilogStartAt = new bool[1024]; // One byte per possible epilog start index; initialized to false

if (EBit == 0)
{
Epilogs = new Epilog[EpilogCount];
if (EpilogCount != 0)
{
for (int scope = 0; scope < EpilogCount; scope++)
{
dw = NativeReader.ReadInt32(image, ref offset);
Epilogs[scope] = new Epilog(scope, dw, startOffset);
epilogStartAt[Epilogs[scope].EpilogStartIndex] = true; // an epilog starts at this offset in the unwind codes
}
}
}
else
{
Epilogs = new Epilog[0];
epilogStartAt[EpilogCount] = true; // the one and only epilog starts its unwind codes at this offset
}



Size = offset - (int)startOffset + (int)CodeWords * 4;
int alignmentPad = ((Size + sizeof(int) - 1) & ~(sizeof(int) - 1)) - Size;
Size += (alignmentPad + sizeof(uint));
}

public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine($" CodeWords: {CodeWords}");
sb.AppendLine($" EpilogCount: {EpilogCount}");
sb.AppendLine($" EBit: {EBit}");
sb.AppendLine($" XBit: {XBit}");
sb.AppendLine($" Vers: {Vers}");
sb.AppendLine($" FunctionLength: {FunctionLength}");
if (CodeWords == 0 && EpilogCount == 0)
{
sb.AppendLine(" ---- Extension word ----");
sb.AppendLine($" Extended Code Words: {CodeWords}");
sb.AppendLine($" Extended Epilog Count: {EpilogCount}");
}
if (EpilogCount == 0)
{
sb.AppendLine(" No epilogs");
}
else
{
for (int i = 0; i < Epilogs.Length; i++)
{
sb.AppendLine(" -------------------------");
sb.AppendLine(Epilogs[i].ToString());
sb.AppendLine(" -------------------------");
}
}
return sb.ToString();
}

internal static uint ExtractBits(int dw, int start, int length)
{
return (uint)((dw >> start) & ((1 << length) - 1));
}
}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -225,6 +225,10 @@ private int GetSize()
{
return (int)arm64Info.FunctionLength;
}
else if (UnwindInfo is LoongArch64.UnwindInfo loongarch64Info)
{
return (int)loongarch64Info.FunctionLength;
}
else if (Method.GcInfo != null)
{
return Method.GcInfo.CodeLength;
Expand DownExpand Up@@ -488,7 +492,7 @@ private void EnsureInitialized()
}
else
{
// Armand Arm64 use the same GcInfo format as Amd64
// Arm, Arm64 and LoongArch64 use the same GcInfo format as Amd64
_gcInfo = new Amd64.GcInfo(_readyToRunReader.Image, gcInfoOffset, _readyToRunReader.Machine, _readyToRunReader.ReadyToRunHeader.MajorVersion);
}
}
Expand DownExpand Up@@ -604,6 +608,10 @@ private void ParseRuntimeFunctions(bool partial)
{
unwindInfo = new Arm64.UnwindInfo(_readyToRunReader.Image, unwindOffset);
}
else if (_readyToRunReader.Machine == Machine.LoongArch64)
{
unwindInfo = new LoongArch64.UnwindInfo(_readyToRunReader.Image, unwindOffset);
}

if (i == 0 && unwindInfo != null)
{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -1415,6 +1415,7 @@ private void EnsureImportSections()

case Machine.Amd64:
case Machine.Arm64:
case Machine.LoongArch64:
entrySize = 8;
break;

Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 numberDiff line numberDiff line change
Expand Up@@ -1732,16 +1732,8 @@ private void ForceSigWalk()
int floatRegOfsInBytes = argOffset - _transitionBlock.OffsetOfFloatArgumentRegisters;
Debug.Assert((floatRegOfsInBytes % _transitionBlock.FloatRegisterSize) == 0);
pLoc.m_idxFloatReg = floatRegOfsInBytes / _transitionBlock.FloatRegisterSize;
pLoc.m_cFloatReg = 1;

if (!_argTypeHandle.IsNull() && _argTypeHandle.IsHomogeneousAggregate())
{
int haElementSize = _argTypeHandle.GetHomogeneousAggregateElementSize();
pLoc.m_cFloatReg = GetArgSize() / haElementSize;
}
else
{
pLoc.m_cFloatReg = 1;
}
return pLoc;
}

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ protected override void EmitCode(NodeFactory factory, ref LoongArch64Emitter ins

if (!relocsOnly)
{
// movz T0=R12, #index
// ori T0=R12, R0, #index
int index = _containingImportSection.IndexFromBeginningOfArray;
instructionEncoder.EmitMOV(Register.R12, checked((ushort)index));
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -651,8 +651,8 @@ private class LoongArch64TransitionBlock : TransitionBlock
public override int NumCalleeSavedRegisters => 12;
// Callee-saves, argument registers
public override int SizeOfTransitionBlock => SizeOfCalleeSavedRegisters + SizeOfArgumentRegisters;
public override int OffsetOfArgumentRegisters => SizeOfCalleeSavedRegisters;
public override int OffsetOfFirstGCRefMapSlot => OffsetOfArgumentRegisters;
public override int OffsetOfFirstGCRefMapSlot => SizeOfCalleeSavedRegisters;
public override int OffsetOfArgumentRegisters => OffsetOfFirstGCRefMapSlot;

// F0..F7
public override int OffsetOfFloatArgumentRegisters => 8 * sizeof(double);
Expand All@@ -671,19 +671,11 @@ public override bool IsArgPassedByRef(TypeHandle th)
}
else
{
int numIntroducedFields = 0;
foreach (FieldDesc field in th.GetRuntimeTypeHandle().GetFields())
{
if (!field.IsStatic)
{
numIntroducedFields++;
}
}
return ((numIntroducedFields == 0) || (numIntroducedFields > 2));
return false;
}
}

public sealed override int GetRetBuffArgOffset(bool hasThis) => OffsetOfArgumentRegisters;
public sealed override int GetRetBuffArgOffset(bool hasThis) => OffsetOfFirstGCRefMapSlot + (hasThis ? 8 : 0);

public override int StackElemSize(int parmSize, bool isValueType = false, bool isFloatHfa = false)
{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -259,6 +259,14 @@ public override string ToString()

sb.AppendLine($" Has Tailcalls: {_wantsReportOnlyLeaf}");
}
else if (_machine == Machine.LoongArch64)
{
if (StackBaseRegister != 0xffffffff)
{
sb.AppendLine($" StackBaseRegister: {(LoongArch64.Registers)StackBaseRegister}");
}
sb.AppendLine($" Has Tailcalls: {_wantsReportOnlyLeaf}");
}

sb.AppendLine($" Size of parameter area: 0x{SizeOfStackOutgoingAndScratchArea:X}");
if (SizeOfEditAndContinuePreservedArea != 0xffffffff)
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -68,6 +68,9 @@ private static string GetRegisterName(int registerNumber, Machine machine)
case Machine.Arm64:
return ((Arm64.Registers)registerNumber).ToString();

case Machine.LoongArch64:
return ((LoongArch64.Registers)registerNumber).ToString();

default:
throw new NotImplementedException(machine.ToString());
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -65,6 +65,10 @@ public string GetSlotState(GcSlotTable slotTable, Machine machine)
regType = typeof(Amd64.Registers);
break;

case Machine.LoongArch64:
regType = typeof(LoongArch64.Registers);
break;

default:
throw new NotImplementedException();
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,6 +72,8 @@ public static string GetPlatformSpecificRegister(Machine machine, int regnum)
return ((Arm.Registers)regnum).ToString();
case Machine.Arm64:
return ((Arm64.Registers)regnum).ToString();
case Machine.LoongArch64:
return ((LoongArch64.Registers)regnum).ToString();
default:
throw new NotImplementedException($"No implementation for machine type {machine}.");
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -149,6 +149,11 @@ internal GcInfoTypes(Machine machine)
NUM_UNTRACKED_SLOTS_ENCBASE = 5;
REGISTER_DELTA_ENCBASE = 3;
break;
case Machine.LoongArch64:
SIZE_OF_RETURN_KIND_FAT = 4;
STACK_BASE_REGISTER_ENCBASE = 2;
NUM_REGISTERS_ENCBASE = 3;
break;
}
}

Expand All@@ -159,6 +164,7 @@ internal int DenormalizeCodeLength(int x)
case Machine.ArmThumb2:
return (x << 1);
case Machine.Arm64:
case Machine.LoongArch64:
return (x << 2);
}
return x;
Expand All@@ -173,6 +179,7 @@ internal int DenormalizeStackSlot(int x)
case Machine.ArmThumb2:
return (x << 2);
case Machine.Arm64:
case Machine.LoongArch64:
return (x << 3);
}
return x;
Expand All@@ -188,6 +195,8 @@ internal uint DenormalizeStackBaseRegister(uint x)
return ((x ^ 7) + 4);
case Machine.Arm64:
return (x ^ 29);
case Machine.LoongArch64:
return ((x ^ 22) & 0x3);
}
return x;
}
Expand All@@ -201,6 +210,7 @@ internal uint DenormalizeSizeOfStackArea(uint x)
case Machine.ArmThumb2:
return (x << 2);
case Machine.Arm64:
case Machine.LoongArch64:
return (x << 3);
}
return x;
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.Text;

namespace ILCompiler.Reflection.ReadyToRun.LoongArch64
{
public enum Registers
{
R0,
Ra,
Tp,
Sp,
A0,
A1,
A2,
A3,
A4,
A5,
A6,
A7,
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
X0,
Fp,
S0,
S1,
S2,
S3,
S4,
S5,
S6,
S7,
S8
}
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Text;

namespace ILCompiler.Reflection.ReadyToRun.LoongArch64
{
public class Epilog
{
public int Index { get; set; }

public uint EpilogStartOffset { get; set; }
public uint Res { get; set; }
public uint Condition { get; set; }
public uint EpilogStartIndex { get; set; }
public uint EpilogStartOffsetFromMainFunctionBegin { get; set; }

public Epilog() { }

public Epilog(int index, int dw, uint startOffset)
{
Index = index;

EpilogStartOffset = UnwindInfo.ExtractBits(dw, 0, 18);
Res = UnwindInfo.ExtractBits(dw, 18, 4);
Condition = UnwindInfo.ExtractBits(dw, 20, 4);
EpilogStartIndex = UnwindInfo.ExtractBits(dw, 22, 10);

// Note that epilogStartOffset for a funclet is the offset from the beginning
// of the current funclet, not the offset from the beginning of the main function.
// To help find it when looking through JitDump output, also show the offset from
// the beginning of the main function.
EpilogStartOffsetFromMainFunctionBegin = EpilogStartOffset * 4 + startOffset;
}

public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine($" Epilog Start Offset: 0x{EpilogStartOffset:X5} Actual offset = 0x{EpilogStartOffset * 4:X5} Offset from main function begin = 0x{EpilogStartOffsetFromMainFunctionBegin:X6}");
sb.AppendLine($" Condition: {Condition} (0x{Condition:X})" + ((Condition == 0xE) ? " (always)" : ""));
sb.Append($" Epilog Start Index: {EpilogStartIndex} (0x{EpilogStartIndex:X})");
return sb.ToString();
}
}

public class UnwindCode
{
public int Index { get; set; }

public UnwindCode() { }

public UnwindCode(int index)
{
Index = index;

}
}

/// <summary>
/// based on <a href="https://github.com/dotnet/runtime/src/coreclr/jit/unwindloongarch64.cpp">src/jit/unwindloongarch64.cpp</a> DumpUnwindInfo
/// </summary>
public class UnwindInfo : BaseUnwindInfo
{
public uint CodeWords { get; set; }
public uint EpilogCount { get; set; }
public uint EBit { get; set; }
public uint XBit { get; set; }
public uint Vers { get; set; }
public uint FunctionLength { get; set; }

public uint ExtendedCodeWords { get; set; }
public uint ExtendedEpilogCount { get; set; }

public Epilog[] Epilogs { get; set; }

public UnwindInfo() { }

public UnwindInfo(byte[] image, int offset)
{
uint startOffset = (uint)offset;

int dw = NativeReader.ReadInt32(image, ref offset);
CodeWords = ExtractBits(dw, 27, 5);
EpilogCount = ExtractBits(dw, 22, 5);
EBit = ExtractBits(dw, 21, 1);
XBit = ExtractBits(dw, 20, 1);
Vers = ExtractBits(dw, 18, 2);
FunctionLength = ExtractBits(dw, 0, 18) * 4;

if (CodeWords == 0 && EpilogCount == 0)
{
// We have an extension word specifying a larger number of Code Words or Epilog Counts
// than can be specified in the header word.
dw = NativeReader.ReadInt32(image, ref offset);
ExtendedCodeWords = ExtractBits(dw, 16, 8);
ExtendedEpilogCount = ExtractBits(dw, 0, 16);
}

bool[] epilogStartAt = new bool[1024]; // One byte per possible epilog start index; initialized to false

if (EBit == 0)
{
Epilogs = new Epilog[EpilogCount];
if (EpilogCount != 0)
{
for (int scope = 0; scope < EpilogCount; scope++)
{
dw = NativeReader.ReadInt32(image, ref offset);
Epilogs[scope] = new Epilog(scope, dw, startOffset);
epilogStartAt[Epilogs[scope].EpilogStartIndex] = true; // an epilog starts at this offset in the unwind codes
}
}
}
else
{
Epilogs = new Epilog[0];
epilogStartAt[EpilogCount] = true; // the one and only epilog starts its unwind codes at this offset
}



Size = offset - (int)startOffset + (int)CodeWords * 4;
int alignmentPad = ((Size + sizeof(int) - 1) & ~(sizeof(int) - 1)) - Size;
Size += (alignmentPad + sizeof(uint));
}

public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine($" CodeWords: {CodeWords}");
sb.AppendLine($" EpilogCount: {EpilogCount}");
sb.AppendLine($" EBit: {EBit}");
sb.AppendLine($" XBit: {XBit}");
sb.AppendLine($" Vers: {Vers}");
sb.AppendLine($" FunctionLength: {FunctionLength}");
if (CodeWords == 0 && EpilogCount == 0)
{
sb.AppendLine(" ---- Extension word ----");
sb.AppendLine($" Extended Code Words: {CodeWords}");
sb.AppendLine($" Extended Epilog Count: {EpilogCount}");
}
if (EpilogCount == 0)
{
sb.AppendLine(" No epilogs");
}
else
{
for (int i = 0; i < Epilogs.Length; i++)
{
sb.AppendLine(" -------------------------");
sb.AppendLine(Epilogs[i].ToString());
sb.AppendLine(" -------------------------");
}
}
return sb.ToString();
}

internal static uint ExtractBits(int dw, int start, int length)
{
return (uint)((dw >> start) & ((1 << length) - 1));
}
}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -225,6 +225,10 @@ private int GetSize()
{
return (int)arm64Info.FunctionLength;
}
else if (UnwindInfo is LoongArch64.UnwindInfo loongarch64Info)
{
return (int)loongarch64Info.FunctionLength;
}
else if (Method.GcInfo != null)
{
return Method.GcInfo.CodeLength;
Expand DownExpand Up@@ -488,7 +492,7 @@ private void EnsureInitialized()
}
else
{
// Armand Arm64 use the same GcInfo format as Amd64
// Arm, Arm64 and LoongArch64 use the same GcInfo format as Amd64
_gcInfo = new Amd64.GcInfo(_readyToRunReader.Image, gcInfoOffset, _readyToRunReader.Machine, _readyToRunReader.ReadyToRunHeader.MajorVersion);
}
}
Expand DownExpand Up@@ -604,6 +608,10 @@ private void ParseRuntimeFunctions(bool partial)
{
unwindInfo = new Arm64.UnwindInfo(_readyToRunReader.Image, unwindOffset);
}
else if (_readyToRunReader.Machine == Machine.LoongArch64)
{
unwindInfo = new LoongArch64.UnwindInfo(_readyToRunReader.Image, unwindOffset);
}

if (i == 0 && unwindInfo != null)
{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -1415,6 +1415,7 @@ private void EnsureImportSections()

case Machine.Amd64:
case Machine.Arm64:
case Machine.LoongArch64:
entrySize = 8;
break;

Expand Down
Loading