GithubHelp home page GithubHelp logo

Comments (11)

mterwoord avatar mterwoord commented on July 18, 2024

Sorry for the late response...

Would you be willing to help us fix this?
It's a bug in our IL interpreter..

from cosmos.

 avatar commented on July 18, 2024

I've also run into several "not implanted" IL errors. I'm assuming this has something to do with the recent Z-machine implantation.

from cosmos.

mterwoord avatar mterwoord commented on July 18, 2024

Which Z-machine implementation?

The bug is in our IL interpreter, and isn't too hard to fix. We could guide you through the process....

from cosmos.

cuuupid avatar cuuupid commented on July 18, 2024

That'd be great! Fair warning, I'm a bit lost on "IL interpreter". Is that
what interprets methods + etc into machine language?

from cosmos.

 avatar commented on July 18, 2024

Oh, I thought it had something to do with it. Never mind!

from cosmos.

mterwoord avatar mterwoord commented on July 18, 2024

@phsah123 IL looks for example like this:
IL_0001: ldc.i4.3 (Loads a constant int32 value of 4 on to the stack)
IL_0002: ldc.i4.2
IL_0003: add

offset 3 ha no way of knowing (without looking back) what types it has to add (it could be 2 bytes, but also 2 decimals). The il interpreter "interprets" the previous instructions (and branches etc are also handled) to see what operand types the compiler needs to use..

The situation for stobj is not yet implemented.

from cosmos.

PathogenDavid avatar PathogenDavid commented on July 18, 2024

So I decided to take a stab at this problem since I've been meaning to check out Cosmos in detail for some time and had some free time today.

Fixing Stobj for GetNumberOfStackPops and GetNumberOfStackPushes was simple enough. However, after I fixed those two things I got an issue of a missing plug for RuntimeTypeHandle::CreateInstanceForAnotherGenericParameter.

This method is called from EqualityComparer.CreateComparer when a System.Collections.Generic.Dictionary is constructed.

Of course, it might seem confusing that there is a Dictionary getting created considering pshah123's code doesn't use the Dictionary class. Well, apparently after you go over 6 cases in a switch statement on a string, the C# compiler changes it into a Dictionary lookup instead.

Anyway, I tracked down CreateInstanceForAnotherGenericParameter's implementation in CoreCLR to CreateInstanceForGenericType, and it is a bit of a doozy.

I'm pretty sure the whole thing boils down to allocating and constructing a GenericEqualityComparer (in our case), but it isn't immediately obvious to me how to best do the same thing in Cosmos. I wanted to post in here and see if anyone wanted to point me in the right direction before I dive down this rabbit hole.

from cosmos.

PathogenDavid avatar PathogenDavid commented on July 18, 2024

And on a semi-related note: Is there a way to get changes I've made to Cosmos into my installed user kit without restarting Visual Studio every time? Whenever I make a change to IL2CPU, I end up closing all my instances of Visual Studio and running install.bat again. Not sure if I missed something in the documentation or the workflow there is just a bit tedious right now.

from cosmos.

mterwoord avatar mterwoord commented on July 18, 2024

@PathogenDavid Good work. Can you send a pull request for the GetNumberOfStackPops and GetNumberOfStackPushes changes?

Most likely the CreateCompiler code uses reflection to do its magic, which won't work for sure on cosmos.
Maybe we could make special cases in EqualityComparer.CreateComparer for the main types (String, numeric types, etc)

@PathogenDavid Would you be interested in helping us out? We could really use some lower-level people. We have some humps in the compiler currently and once we're past those, we could really move forward again...

from cosmos.

PathogenDavid avatar PathogenDavid commented on July 18, 2024

@mterwoord
Sure, do know though that I have no idea if stobj is working since I couldn't compile+run the code without the plug. The pull request is #77.

That is what I was thinking as well. It wouldn't be as ideal, but it certainly works. I'll give it a try sometime this week and report back.

I'm definitely interested in helping out, but I can't really promise any consistent effort on my part for the time being. My free time is a bit sporadic these days.

from cosmos.

mterwoord avatar mterwoord commented on July 18, 2024

@PathogenDavid If you're interested in helping, please add me on skype (same handle), and I'll get you going. At first, we could use help on getting the PR's reviewed...

from cosmos.

Related Issues (20)

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.