Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^7: Run Perl 5 in the Browser!

by ikegami (Patriarch)
on Aug 23, 2018 at 01:45 UTC ( [id://1220889]=note: print w/replies, xml ) Need Help??


in reply to Re^6: Run Perl 5 in the Browser!
in thread Run Perl 5 in the Browser!

I think the fundamental problem is that Perl has too many hooks (operation overloading, constant overloading, variable type overloading, custom opcodes, etc) that prevent optimizations without changing the language. We can't even guarantee that 2 returns a number (e.g. when using use bigint;), so we're stuck with fat opcodes that must be able to accept any kind of value.

Replies are listed 'Best First'.
Re^8: Run Perl 5 in the Browser!
by chromatic (Archbishop) on Aug 23, 2018 at 17:59 UTC

    Yeah, given that observing a variable at the Perl level could cause SV upgrades within an opcode, maybe it's better to say the challenges are:

    • Polymorphic data structures at the C level; with
    • SV upgrades in opcodes; leading to
    • Large opcode function sizes

    We're not talking about JITting a five line Smalltalk method that's monomorphic across 80% of calls here. It would surprise me if the average opcode didn't expand to a size larger—and quite a few basic blocks more‐than LLVM wants to try to JIT.

      Nah, implicit type conversions is something JIT compilers can handle.

Re^8: Run Perl 5 in the Browser!
by LanX (Saint) on Aug 23, 2018 at 04:26 UTC
    JIT is about optimizing the main cases and observing the edge cases.

    You don't need guarantees because you just fall back to the generic solution if the input variables become unusual.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

      It's the checking that makes it slow right now, so I'm not sure how what you said helps.

        What I suggested is very similar to memoization.

        Only you don't cache the result of a function based on passed values.

        You cache the optimized code based on passed types *

        see https://en.m.wikipedia.org/wiki/Just-in-time_compilation

        Hence the "slow" checking only happens at call time.

        (of course you'll need kind of type of inference deduce implied types inside a sub)

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

        *) and global states like bigint

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1220889]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2024-04-19 13:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found