Michael Pliskin | 9 Feb 2009 18:44
Favicon

How to get PID of the current process

Hi all,

 

Is there any way in haXe/neko to get PID of the current process? I found some ways to get PID of the child processes, but what about the current one?

 

Kind regards,

  Michael Pliskin

--

-- 
Neko : One VM to run them all
(http://nekovm.org)
Justin Collins | 20 Feb 2009 06:12
Favicon
Gravatar

$varargs and recursion

After a considerable amount of fussing around, I figured out that tail 
recursion with a function produced with $varargs will not have the tail 
recursion optimized, at least not how I expected.

Example that loops forever:

test = function() {
        test();
}

test();

Example that results in stack overflow:

test_var = $varargs(function(args) {
        test_var();
});

test_var();

The same occurs with the following two examples, which are probably 
closer to my original issue.

Loops forever:

test = function() {
        test_var(test);
}

test_var = function(arg) {
        arg();
};

test();

Stack overflow:

test = function() {
        test_var(test);
}

test_var = $varargs(function(args) {
        args[0]();
});

test();

----------------------------------------

Is there any way to have this work?

Thanks,
Justin

--

-- 
Neko : One VM to run them all
(http://nekovm.org)

Justin Collins | 20 Feb 2009 06:47
Favicon
Gravatar

Linking modules

Hi,

I have a module which loads another module. I would like to link these 
so that they are a single file. nekoc -link seems to support this, even 
finding the external module automatically. But I keep getting an error:

nekoc -link try.n test
test
internal
Called from neko/Main.nml line 136
Called from neko/Linker.nml line 176
Called from core/Array.nml line 112
Called from neko/Bytecode.nml line 321
Called from core/Core.nml line 172
Called from core/Core.nml line 205
Called from core/Core.nml line 197
Exception : Invalid_argument(Array.get)

I am not sure what I am doing wrong here.

Thanks,
Justin

--

-- 
Neko : One VM to run them all
(http://nekovm.org)

Nicolas Cannasse | 20 Feb 2009 11:07
Favicon
Gravatar

Re: How to get PID of the current process

Michael Pliskin a écrit :
> Hi all,
> 
>  
> 
> Is there any way in haXe/neko to get PID of the current process? I found 
> some ways to get PID of the child processes, but what about the current one?

I think this is not available right now.

Best,
Nicolas

--

-- 
Neko : One VM to run them all
(http://nekovm.org)

Michael Pliskin | 20 Feb 2009 11:18
Favicon

RE: How to get PID of the current process

Hi Nicolas,

  Ok any API to extend? I can try to write some C code..

Mike


-----Original Message-----
From: neko-bounces <at> lists.motion-twin.com [mailto:neko-bounces <at> lists.motion-twin.com] On Behalf
Of Nicolas Cannasse
Sent: Friday, February 20, 2009 1:07 PM
To: Neko intermediate language mailing list
Subject: Re: [Neko] How to get PID of the current process

Michael Pliskin a écrit :
> Hi all,
> 
>  
> 
> Is there any way in haXe/neko to get PID of the current process? I found 
> some ways to get PID of the child processes, but what about the current one?

I think this is not available right now.

Best,
Nicolas

-- 
Neko : One VM to run them all
(http://nekovm.org)

--

-- 
Neko : One VM to run them all
(http://nekovm.org)
Nicolas Cannasse | 20 Feb 2009 11:20
Favicon
Gravatar

Re: $varargs and recursion

Justin Collins a écrit :
> After a considerable amount of fussing around, I figured out that tail 
> recursion with a function produced with $varargs will not have the tail 
> recursion optimized, at least not how I expected.
[...]
> 
> Is there any way to have this work?

This is not possible right now : the main reason is that $varargs go 
through a C function which then callback the original neko function. And 
calls VM->C->VM cannot be tail recursive.

Best,
Nicolas

--

-- 
Neko : One VM to run them all
(http://nekovm.org)

Nicolas Cannasse | 20 Feb 2009 11:23
Favicon
Gravatar

Re: How to get PID of the current process

Michael Pliskin a écrit :
> Hi Nicolas,
> 
>   Ok any API to extend? I can try to write some C code..
> 
> Mike

We could add something like

process_current_pid()

in libs/std/process.c

Full testing on Linux+Windows is required before submission ;)

Best,
Nicolas

--

-- 
Neko : One VM to run them all
(http://nekovm.org)

Nicolas Cannasse | 20 Feb 2009 11:27
Favicon
Gravatar

Re: Linking modules

Justin Collins a écrit :
> Hi,
> 
> I have a module which loads another module. I would like to link these 
> so that they are a single file. nekoc -link seems to support this, even 
> finding the external module automatically. But I keep getting an error:
> 
> nekoc -link try.n test
> test
> internal
> Called from neko/Main.nml line 136
> Called from neko/Linker.nml line 176
> Called from core/Array.nml line 112
> Called from neko/Bytecode.nml line 321
> Called from core/Core.nml line 172
> Called from core/Core.nml line 205
> Called from core/Core.nml line 197
> Exception : Invalid_argument(Array.get)
> 
> 
> I am not sure what I am doing wrong here.

Right now, modules linking is quite restricted.

I'm not sure in which limitation you're hitting but it seems like the 
bytecode produced by the linker is not valid (a jump operation is not 
correct)

If you want to contribute, you can have a look at the sources in 
neko/src/neko/Linker.nml , it's written in NekoML which is similar to 
OCaml but with a more friendly syntax ;)

Best,
Nicolas

--

-- 
Neko : One VM to run them all
(http://nekovm.org)

Justin Collins | 20 Feb 2009 11:40
Favicon
Gravatar

Re: Linking modules

Nicolas Cannasse wrote:
> Justin Collins a écrit :
>> Hi,
>>
>> I have a module which loads another module. I would like to link 
>> these so that they are a single file. nekoc -link seems to support 
>> this, even finding the external module automatically. But I keep 
>> getting an error:
>>
>> nekoc -link try.n test
>> test
>> internal
>> Called from neko/Main.nml line 136
>> Called from neko/Linker.nml line 176
>> Called from core/Array.nml line 112
>> Called from neko/Bytecode.nml line 321
>> Called from core/Core.nml line 172
>> Called from core/Core.nml line 205
>> Called from core/Core.nml line 197
>> Exception : Invalid_argument(Array.get)
>>
>>
>> I am not sure what I am doing wrong here.
>
> Right now, modules linking is quite restricted.
>
> I'm not sure in which limitation you're hitting but it seems like the 
> bytecode produced by the linker is not valid (a jump operation is not 
> correct)
>
> If you want to contribute, you can have a look at the sources in 
> neko/src/neko/Linker.nml , it's written in NekoML which is similar to 
> OCaml but with a more friendly syntax ;)
>
> Best,
> Nicolas
>

Okay, at least it's not my fault.
I will see what I can do, however little that may be :)

Thanks,
Justin

--

-- 
Neko : One VM to run them all
(http://nekovm.org)

Michael Pliskin | 20 Feb 2009 23:53
Favicon

RE: How to get PID of the current process

Hi Nicolas,

Well I've made the patch and it compiles on both Linux and Windows and I've tried it on Windows and it worked. I
wanted to try on Linux but my Fedora 4 complained when building the latest neko. Did you add something
recently to PCRE lib?

Compiling regexp...
gcc -O3 -fPIC -pthread  -c -I../../vm -I/usr/include regexp.c
regexp.c: In function 'regexp_main':
regexp.c:284: error: 'PCRE_EXTRA_MATCH_LIMIT_RECURSION' undeclared (first use in this function)
regexp.c:284: error: (Each undeclared identifier is reported only once
regexp.c:284: error: for each function it appears in.)
regexp.c:285: error: 'pcre_extra' has no member named 'match_limit_recursion'
Called from tools/install.neko line 397
Called from tools/install.neko line 358
Called from tools/install.neko line 195
Uncaught exception - Error 256 : aborted
make: *** [libs] Error 1

Mike


-----Original Message-----
From: neko-bounces <at> lists.motion-twin.com [mailto:neko-bounces <at> lists.motion-twin.com] On Behalf
Of Nicolas Cannasse
Sent: Friday, February 20, 2009 1:24 PM
To: Neko intermediate language mailing list
Subject: Re: [Neko] How to get PID of the current process

Michael Pliskin a écrit :
> Hi Nicolas,
> 
>   Ok any API to extend? I can try to write some C code..
> 
> Mike

We could add something like

process_current_pid()

in libs/std/process.c

Full testing on Linux+Windows is required before submission ;)

Best,
Nicolas

-- 
Neko : One VM to run them all
(http://nekovm.org)

Attachment (process.c.patch): application/octet-stream, 831 bytes
--

-- 
Neko : One VM to run them all
(http://nekovm.org)

Gmane