GithubHelp home page GithubHelp logo

What does LJ_TNUMX+2 mean? about raptorjit HOT 3 OPEN

raptorjit avatar raptorjit commented on June 5, 2024
What does LJ_TNUMX+2 mean?

from raptorjit.

Comments (3)

fogfx avatar fogfx commented on June 5, 2024

This appears to be another genlibbc.lua thing; this check is located within the BC_ISTYPE and BC_ISNUM cases. This is checking the contents of those instructions' C operand.

So if we look at the code in that file, we see that operand C is being assigned a value located in name2itype, a table that maps short type names to values. The type name is derived from the name of the CHECK functions in the embedded Lua definitions (eg. CHECK_tab). We see that CHECK_int and CHECK_num would, according to this table, store the values of 14 and 15, respectively, into operand C.

LJ_TNUMX is defined as (~13u), so the result of this expression is 15, which corresponds to the num entry. So it appears this branch corresponds to CHECK_num (which appears to always generate BC_ISNUM instead of BC_ISTYPE like the others). So this looks like BC_ISNUM is sort-of-kind-of like a cut-down tonumber instruction.

from raptorjit.

lukego avatar lukego commented on June 5, 2024

Thanks for the explanation @fogfx. I am reading genlibbc.lua for the first time.

Does the value ~LJ_TNUMX+2 make sense even so? How come +2 specifically?

There is a comment:

/* These coercions need to correspond with lj_meta_istype(). */

but the code in lj_meta_istype() seems to use +1 instead of +2.

from raptorjit.

fogfx avatar fogfx commented on June 5, 2024

but the code in lj_meta_istype() seems to use +1 instead of +2

It does, but you can see that it decrements tp first (the string checking branch is also different because of this). Why it does it that way instead of mirroring the lj_record.c code... who knows.

from raptorjit.

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.