Skip to content

JIT: If a function/method is built-in, reference it directly #2398

Open
@gfwilliams

Description

@gfwilliams

Right now, JIT creates code on demand, but it looks everything up on the fly.

As an example:

function turnOn() { "jit"
  digitalWrite(LED1,1);
}

roughly translates to:

  • Look up digitalWrite
  • Look up LED1
  • call digitalWrite with LED1 and 1

or.....

function draw() { "jit"
  g.drawLine(0,0,100,100);
}

roughly translates to:

  • Look up g
  • Look up drawLine on g
  • call drawLine with this=g,0,0,100,100

I think it's probably safe to assume that in both cases we could look the relevant thing up at JIT time and if it is built into the interpreter (or it's defined const), we could just use it direct?

edit: sometimes code does overload an old implementation (eg maybe g.drawLine may be patched with a fixed version) but as long as that is done before JIT parses the function we'd be fine

It should translate to a pretty drastic speed improvement.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions