Skip to content

[NativeAOT-LLVM] Remove the workaround for CalendarData.EnumCalendarInfo #2095

Closed

Description

The functions need real implementations. Opening an issue for tracking purposes.

Code references:

// TODO-LLVM: look for a WASI random function; investigate ICU and EnumCalendarInfo
public static MethodIL ReplaceStubbedWasmMethods(MethodDesc method, MethodIL methodIL)
{
// stubs for Unix calls which are not available to this target yet
if ((method.OwningType as EcmaType)?.Name == "Interop" && method.Name == "GetRandomBytes")
{
// this would normally fill the buffer parameter, but we'll just leave the buffer as is and that will be our "random" data for now
return new ILStubMethodIL(method, new byte[] { (byte)ILOpcode.ret }, Array.Empty<LocalVariableDefinition>(), null);
}
if ((method.OwningType as EcmaType)?.Name == "CalendarData" && method.Name == "EnumCalendarInfo")
{
// just return false
return new ILStubMethodIL(method, new byte[] { (byte)ILOpcode.ldc_i4_0, (byte)ILOpcode.ret }, Array.Empty<LocalVariableDefinition>(), null);
}
return methodIL;
}

// mono does this via Javascript (pal_random.js), but prefer not to introduce that dependency as it limits the ability to run out of the browser.
// Copy the temporary workaround from the IL->LLVM generator for now.
if (!strcmp(mangledName, "S_P_CoreLib_Interop__GetRandomBytes"))
{
// this would normally fill the buffer parameter, but we'll just leave the buffer as is and that will be our "random" data for now
llvm::BasicBlock* llvmBlock = llvm::BasicBlock::Create(_llvmContext, "", _function);
_builder.SetInsertPoint(llvmBlock);
_builder.CreateRetVoid();
return;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    area-NativeAOT-LLVMLLVM generation for Native AOT compilation (including Web Assembly)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions