Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Supported types #14

Open
rybakit opened this issue Nov 12, 2014 · 1 comment
Open

Supported types #14

rybakit opened this issue Nov 12, 2014 · 1 comment

Comments

@rybakit
Copy link

rybakit commented Nov 12, 2014

I tried to modify 01-simple-usage.php to use string instead of int like this:

/**
 * @param string $n The parameter
 *
 * @return string The parameter, returned
 */
function test($n)
{
    return $n;
}

$func = Jit::jitfu('test');
benchmark($func, "ReckiCT");

function benchmark(callable $func, $label)
{
    $start = microtime(true);
    for ($i = 0; $i < 1000000; $i++) {
        $func('x');
    }
    $end = microtime(true);
    printf("%s completed in %01.4F seconds\n", $label, $end - $start);
}

And got a fatal error:

PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 947180166 bytes) in ...

Then I tried array type:

/**
 * @param array $n The parameter
 *
 * @return array $n
 */
function test($n)
{
    return [$n];
}

...

function benchmark(callable $func, $label)
{
    ...
    $func([]);
    ....
}

And got:

Fatal error: Uncaught exception 'LogicException' with message 'Found node without parser rule: Expr_Array' ...

So I wonder which types are supported?

@ircmaxell
Copy link
Contributor

Arrays and strings are only sort-of supported. The exact level of support is extremely limited and shouldn't be relied upon (will change over time).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants