Home  
Login
Username:

Password:

Remember me



Lost Password?

Register now!
Sections
Who's Online
76 user(s) are online (66 user(s) are browsing Forums)

Members: 1
Guests: 75

Severin, more...
Support us!
Recent OS4 Files
OS4Depot.net



(1) 2 »


WIP port of Ruby-1.9.3-p327 for AmigaOS 4.x
Just can't stay away
Joined:
2006/11/30 11:30
From Finland
Posts: 1526
I'm working on a port of ruby-1.9.3-p327 to AmigaOS 4 and as part of this I am working on the system dependent thread implementation code.

What has me confused currently is the implementation of the native_thread_init_stack() function which apparently allocates a region of the thread stack for some kind of virtual machine.

This is what the win32 version of the function looks like:
static void
native_thread_init_stack
(rb_thread_t *th)
{
    
MEMORY_BASIC_INFORMATION mi;
    
char *base, *end;
    
DWORD sizespace;

    
CHECK_ERR(VirtualQuery(&mi, &misizeof(mi)));
    
base mi.AllocationBase;
    
end mi.BaseAddress;
    
end += mi.RegionSize;
    
size end base;
    
space size 5;
    if (
space 1024*1024space 1024*1024;
    
th->machine_stack_start = (VALUE *)end 1;
    
th->machine_stack_maxsize size space;
}


To me it looks like it's allocating from the upper end of the stack for this and leaves space on the lower end, but shouldn't this be the opposite as FWICT from googling Windows should have a decreasing stack same as AmigaOS?

Also looking at the pthreads version only makes things more confusing as it seems to use the entire stack region leaving no space at all for the thread to use for auto variables?


Edited by salass00 on 2012/12/17 21:47:34
   Report Go to top

Re: Ruby native_thread_init_stack() implementation
Just can't stay away
Joined:
2006/11/30 11:30
From Finland
Posts: 1526
I think the 1MB region at the lower end that the win32 implementation leaves unused is the 1MB that Windows uses as a guard area so I will use this code for now which should be equivalent to the pthread version:

static void native_thread_init_stack(rb_thread_t *th)
{
    
struct Task *me IExec->FindTask(NULL);
    
th->machine_stack_start me->tc_SPUpper;
    
th->machine_stack_maxsize = (char *)me->tc_SPUpper - (char *)me->tc_SPLower;
}


Edited by salass00 on 2012/12/16 12:36:41
   Report Go to top

Re: Ruby native_thread_init_stack() implementation
Not too shy to talk
Joined:
2007/3/30 17:39
Posts: 252
I have to say that the description of the MEMORY_BASIC_INFORMATION structure is not clear to me ...

With what you propose in the second comment, is there no risk for a thread to overwrite the stack top of the process ?

Anyway, that's very nice to see that you are working on this port. I am interested in Ruby (and ported the existing version on OS4, but quite limited).

   Report Go to top

Re: Ruby native_thread_init_stack() implementation
Just can't stay away
Joined:
2006/11/30 11:30
From Finland
Posts: 1526
After a lot of work I now have a fully compiled and more or less working ruby command with extensions as shared object files.

I have tested it with some simple ruby scripts and it appears to be working correctly FWICT.

Ruby gems is disabled at configure for now and not working.

   Report Go to top

Re: Ruby native_thread_init_stack() implementation
Amigans Defender
Joined:
2006/11/26 23:16
Posts: 983
Quote:
What has me confused currently is the implementation of the native_thread_init_stack() function which apparently allocates a region of the thread stack for some kind of virtual machine.

I have no idea what they are up to but you might want to ping the developer list for help.

_________________
Be authentic. Get AmigaOS.
Amiga Users of Calgary (AMUC)
   Report Go to top

Re: Ruby native_thread_init_stack() implementation
Amigans Defender
Joined:
2006/11/26 23:16
Posts: 983
Quote:
I have tested it with some simple ruby scripts and it appears to be working correctly FWICT.

When I was working with Python one of my goals was to get as much of the test suite working as possible. I imagine Ruby comes with an extensive test suite as well.

_________________
Be authentic. Get AmigaOS.
Amiga Users of Calgary (AMUC)
   Report Go to top

Re: Ruby native_thread_init_stack() implementation
Just can't stay away
Joined:
2006/11/30 11:30
From Finland
Posts: 1526
@ssolie

I think native_thread_init_stack() is probably supposed to report the full stack and then ruby itself decides how much of this is it wants to use. I can't see how it would work otherwise.

It has some pretty long and complicated code for detecting and handling growing and decreasing stack pointers. TBH I'm not sure why they didn't just allocate an area from the free store using malloc(). Would have been a lot easier and safer.

What I'm now working on is getting gems working. Ruby gems is a package management system for Ruby extensions, a bit like apt-get but for Ruby only and the packages are called gems.

First in order to be able to run the gem script (Ruby gems is itself written in ruby) I had to fix a couple of issues:
1. A path issue with dlopen() (apparently it doesn't like unix-style paths even when linking with -lunix)
2. An unresolved runtime reference in encdb.so (it was referencing a function in the main ruby exe so I had to add -Wl,--export-dynamic to LDFLAGS for the ruby exe)

   Report Go to top

Re: WIP port of Ruby-1.9.3-p327 for AmigaOS 4.x
Just can't stay away
Joined:
2006/11/26 16:47
Posts: 1420
You rock Salass00! \o/

   Report Go to top

Re: WIP port of Ruby-1.9.3-p327 for AmigaOS 4.x
Just can't stay away
Joined:
2006/11/26 16:47
Posts: 1420
It would be fun if you ported ruby/sdl too! :)
http://www.kmc.gr.jp/~ohai/rubysdl.en.html

   Report Go to top

Re: Ruby native_thread_init_stack() implementation
Amigans Defender
Joined:
2006/11/26 23:16
Posts: 983
Quote:

1. A path issue with dlopen() (apparently it doesn't like unix-style paths even when linking with -lunix)

dlopen() is just a wrapper for IElf->DLOpen() so perhaps it doesn't have the usual path conversion code in dlopen() yet?

Luckily, you can go look now for yourself.

Quote:
2. An unresolved runtime reference in encdb.so (it was referencing a function in the main ruby exe so I had to add -Wl,--export-dynamic to LDFLAGS for the ruby exe)

Yes, that will happen from time to time. The same problems occur with REBOL and Python.

With REBOL and Python we use real Amiga paths and don't try to fake things. It tends to be a lot more work to convert everything but the end result is nicer.

_________________
Be authentic. Get AmigaOS.
Amiga Users of Calgary (AMUC)
   Report Go to top

Re: Ruby native_thread_init_stack() implementation
Just can't stay away
Joined:
2006/11/30 11:30
From Finland
Posts: 1526
After a lot of debugging and some more minor fixes ruby gems can now connect to and download gems from the gem server.

   Report Go to top

Re: WIP port of Ruby-1.9.3-p327 for AmigaOS 4.x
Just can't stay away
Joined:
2006/11/26 16:47
Posts: 1420
\o/

   Report Go to top

Re: WIP port of Ruby-1.9.3-p327 for AmigaOS 4.x
Home away from home
Joined:
2007/9/11 11:31
From Russia
Posts: 4193
Quote:

You rock Salass00! \o/


He is for sure. Now .. when he will write new workbench replacement for os4 ?:)

_________________
Join us to improve dopus5!
zerohero's mirror of os4/os3 crosscompiler suites
   Report Go to top

Re: WIP port of Ruby-1.9.3-p327 for AmigaOS 4.x
Home away from home
Joined:
2006/12/2 3:55
From Italy, Perugia
Posts: 2975
@all

To see how salass is awesome for this community just look to his software's list

http://www.a500.org/

   Report Go to top

Re: WIP port of Ruby-1.9.3-p327 for AmigaOS 4.x
Amigans Defender
Joined:
2006/12/2 13:27
From Taranto, Italy
Posts: 914
Ok Fredrik.. now come back to work on that other thing!!!

_________________
i'm really tired...
   Report Go to top

Re: WIP port of Ruby-1.9.3-p327 for AmigaOS 4.x
Just can't stay away
Joined:
2006/11/30 11:30
From Finland
Posts: 1526
@afxgroup

I did some work on the other thing this morning (assuming you mean what I think you mean ). Unfortunately it's still not doing anything useful. Much documentation reading and debugging ahead there.

Regarding ruby I just managed today to create and install a native gem (libxml-ruby to be precise). At the moment it required me to edit the extconf.rb script a little in order for it to work 100% correctly but hopefully I should be able to make it work without too much such changes in the future.

   Report Go to top

Re: WIP port of Ruby-1.9.3-p327 for AmigaOS 4.x
Amigans Defender
Joined:
2006/12/2 13:27
From Taranto, Italy
Posts: 914
yes.. i mean what you understand... if you need help you only have to ask.. not to me but you know

_________________
i'm really tired...
   Report Go to top

Re: WIP port of Ruby-1.9.3-p327 for AmigaOS 4.x
Just can't stay away
Joined:
2006/11/30 11:30
From Finland
Posts: 1526
@spotUP

Quote:

It would be fun if you ported ruby/sdl too! :)
http://www.kmc.gr.jp/~ohai/rubysdl.en.html


Resized Image
Resized Image
Resized Image


Edited by salass00 on 2012/12/21 14:18:29
Edited by salass00 on 2012/12/21 15:10:38
   Report Go to top

Re: WIP port of Ruby-1.9.3-p327 for AmigaOS 4.x
Home away from home
Joined:
2006/11/26 21:45
From A haunted Castle somewhere in the Bavarian Mountains
Posts: 2878
@salass00



/we are not worthy mode

Resized ImageResized Image

/we are not worthy mode off



@orgin

We need a "We are not worthy" smiley

_________________
If slaughterhouses had glass walls, everyone would be a vegetarian. ~ Sir Paul McCartney
-
Did everything just taste purple for a second? ~ Philip J. Fry
-
Ain't got no cash, ain't got no style, ladies vomit when I smile. ~ Dr. John Zoidberg
   Report Go to top

Re: WIP port of Ruby-1.9.3-p327 for AmigaOS 4.x
Just can't stay away
Joined:
2006/11/30 11:30
From Finland
Posts: 1526
The Ruby Documentation (RDoc) system will be enabled and working in the next release of Ruby for AmigaOS 4.x.

Obtaining documentation on Array.sort using ri:
Quote:

10.OS4.1:System/Ruby/bin> ruby ri Array.sort
= Array.sort

(from ruby core)
------------------------------------------------------------------------------
ary.sort -> new_ary
ary.sort {| a,b | block } -> new_ary


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

Returns a new array created by sorting self. Comparisons for the sort will be
done using the <=> operator or using an optional code block. The block
implements a comparison between a and b, returning -1, 0, or +1. See also
Enumerable#sort_by.

a = [ "d", "a", "e", "c", "b" ]
a.sort #=> ["a", "b", "c", "d", "e"]
a.sort {|x,y| y <=> x } #=> ["e", "d", "c", "b", "a"]


10.OS4.1:System/Ruby/bin>


I had to disable it during configure before because the ruby version on my cross-compilation system was too old (1.8.?) but I've updated it to 1.9.3 now so that I can leave it enabled.

   Report Go to top


(1) 2 »



[Advanced Search]


Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project