GithubHelp home page GithubHelp logo

aromaa / managedclr Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 41 KB

A really, really, really, really basic (and messy) implementation of C# runtime made in C# (For learning purposes)

License: MIT License

C# 100.00%
clr jit csharp codegen il runtime

managedclr's Introduction

Joni Aromaa ๐Ÿ˜ป๐Ÿฑ๐Ÿˆ

Nerd with glasses. A guy who primary writes C# and tries to understand the internals of CoreCLR. Likes the blocky game known as Minecraft โ› and loves building creative, complex and big software with performance in the mind. I may be seen around on all kinds of communities :)

I also like cats, if you didn't figure that out yet..

managedclr's People

Contributors

aromaa avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

managedclr's Issues

Implement all IL instructions

There are few special IL instructions that most likely won't get implemented but keeping them all listed up to track their progress.

Currently implemented instructions are:

  • add
  • add.ovf
  • add.ovf.un
  • and
  • arglist
  • beq
  • beq.s
  • bge
  • bge.s
  • bge.un
  • bge.un.s
  • bgt
  • bgt.s
  • bgt.un
  • bgt.un.s
  • ble
  • ble.s
  • ble.un
  • ble.un.s
  • blt
  • blt.s
  • blt.un
  • blt.un.s
  • bne.un
  • bne.un.s
  • box
  • br
  • br.s
  • break
  • brfalse
  • brfalse.s
  • brinst
  • brinst.s
  • brnull
  • brnull.s
  • brtrue
  • brtrue.s
  • brzero
  • brzero.s
  • call
  • calli
  • callvirt
  • castclass
  • ceq
  • cgt
  • cgt.un
  • ckfinite
  • clt
  • clt.un
  • constrained
  • conv.i
  • conv.i1
  • conv.i2
  • conv.i4
  • conv.i8
  • conv.ovf.i
  • conv.ovf.i.un
  • conv.ovf.i1
  • conv.ovf.i1.un
  • conv.ovf.i2
  • conv.ovf.i2.un
  • conv.ovf.i4
  • conv.ovf.i4.un
  • conv.ovf.i8
  • conv.ovf.i8.un
  • conv.ovf.u
  • conv.ovf.u.un
  • conv.ovf.u1
  • conv.ovf.u1.un
  • conv.ovf.u2
  • conv.ovf.u2.un
  • conv.ovf.u4
  • conv.ovf.u4.un
  • conv.ovf.u8
  • conv.ovf.u8.un
  • conv.r.un
  • conv.r4
  • conv.r8
  • conv.u
  • conv.u1
  • conv.u2
  • conv.u4
  • conv.u8
  • cpblk
  • cpobj
  • div
  • div.un
  • dup
  • endfault
  • endfilter
  • endfinally
  • initblk
  • initobj
    • Basic support for value types
      • Reserve stack space
      • Zero-init
    • Basic support for reference types
  • isinst
  • jmp
  • ldarg
  • ldarg.0
  • ldarg.1
  • ldarg.2
  • ldarg.3
  • ldarg.s
  • ldarga
  • ldarga.s
  • ldc.i4
  • ldc.i4.0
  • ldc.i4.1
  • ldc.i4.2
  • ldc.i4.3
  • ldc.i4.4
  • ldc.i4.5
  • ldc.i4.6
  • ldc.i4.7
  • ldc.i4.8
  • ldc.i4.m1
  • ldc.i4.M1
  • ldc.i4.s
  • ldc.i8
  • ldc.r4
  • ldc.r8
  • ldelem
  • ldelem.i
  • ldelem.i1
  • ldelem.i2
  • ldelem.i4
  • ldelem.i8
  • ldelem.r4
  • ldelem.r8
  • ldelem.ref
  • ldelem.u1
  • ldelem.u2
  • ldelem.u4
  • ldelem.u8
  • ldelema
  • ldfld
    • Value types
    • Reference types
  • ldflda
  • ldftn
  • ldind.i
  • ldind.i1
  • ldind.i2
  • ldind.i4
  • ldind.i8
  • ldind.r4
  • ldind.r8
  • ldind.ref
  • ldind.u1
  • ldind.u2
  • ldind.u4
  • ldind.u8
  • ldlen
  • ldloc
  • ldloc.0
  • ldloc.1
  • ldloc.2
  • ldloc.3
  • ldloc.s
  • ldloca
  • ldloca.s
  • ldnull
  • ldobj
  • ldsfld
  • ldsflda
  • ldstr
  • ldtoken
  • ldvirtftn
  • leave
  • leave.s
  • localloc
  • mkrefany
  • mul
  • mul.ovf
  • mul.ovf.un
  • neg
  • newarr
  • newobj
  • no
  • nop
  • not
  • or
  • pop
  • readonly.
  • refanytype
  • refanyval
  • rem
  • rem.un
  • ret
  • rethrow
  • shl
  • shr
  • shr.un
  • sizeof
  • starg
  • starg.s
  • stelem
  • stelem.i
  • stelem.i1
  • stelem.i2
  • stelem.i4
  • stelem.i8
  • stelem.r4
  • stelem.r8
  • stelem.ref
  • stfld
    • Value types
    • Reference types
  • stind.i
  • stind.i1
  • stind.i2
  • stind.i4
  • stind.i8
  • stind.r4
  • stind.r8
  • stind.ref
  • stloc
  • stloc.0
  • stloc.1
  • stloc.2
  • stloc.3
  • stloc.s
  • stobj
  • stsfld
  • sub
  • sub.ovf
  • sub.ovf.un
  • switch
  • tail.
  • throw
  • unaligned
  • unbox
  • unbox.any
  • volatile.
  • xor

Type loader

The JIT needs to know type layout to be able to generate code for instance objects or structs.

  • Type layout
    • Non-generic
    • Generic
    • Distinct between blittable and non-blittable fields
  • Type methods
    • Non-generic
    • Generic

Support instance objects

In order to support basic instance objects we first need a type system and basic GC.

  • Type loader (Tracked by #3)
  • Basic GC (Tracked by #4)

Basic GC

The goal for the first basic GC is able to ask for allocation space, the other tasks are for more general

  • GC can allocate memory
  • GC knows which objects are reachable
    • GC can track objects fields
    • GC can solve circular dependency
  • GC is able to free memory

Support value types

The value types mostly are only accessed on the stack but we also need to support boxing.

  • Type loader (Tracked by #3)
  • GC can track reference type fields
  • Boxing

Make JIT compile methods only on demand

Currently we are recursively compiling methods as we come across them on IL. This should be pretty straight forward to change by introducing indirection to calls.

Support other platforms

Currently there is only Windows support but I would like to add Linux and macOS support too, these should be fairly simple to do.

  • Windows
  • Linux
    • Ubuntu
  • MacOS

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.