Date: Mon, 25 Aug 2014 10:22:13 -0700 From: <dteske@FreeBSD.org> To: "'Jordan Hubbard'" <jkh@ixsystems.com>, <dteske@FreeBSD.org> Cc: freebsd-hackers@freebsd.org, 'Pedro Giffuni' <pfg@freebsd.org>, "'Wojciech A. Koszek'" <wkoszek@freebsd.org>, 'Pedro Arthur' <bygrandao@gmail.com> Subject: RE: Lua in the bootloader Message-ID: <17e701cfc089$1d0e1b30$572a5190$@FreeBSD.org> In-Reply-To: <5FE57E4E-A627-4ABA-AB73-F0D60A3602D5@ixsystems.com> References: <3D62F4F4-ECCF-4622-BB57-D028160F3451@freebsd.org> <157901cfbe83$6cbf18d0$463d4a70$@FreeBSD.org> <A87AA9EB-373F-400E-986E-4D9017EB2375@freebsd.org> <16e101cfbfee$42b3b930$c81b2b90$@FreeBSD.org> <5FE57E4E-A627-4ABA-AB73-F0D60A3602D5@ixsystems.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> -----Original Message----- > From: Jordan Hubbard [mailto:jkh@ixsystems.com] > Sent: Sunday, August 24, 2014 4:43 PM > To: <dteske@FreeBSD.org> > Cc: <freebsd-hackers@freebsd.org>; Wojciech A. Koszek; Pedro Giffuni; > Pedro Arthur > Subject: Re: Lua in the bootloader > > > > limitations that I battle in Forth are significant enough > > that I'd like to see if Lua can break said chains (such as > > "dictionary full" errors causing BTX halt -- induced simply > > by adding "too many functions" in Forth). > > I'm not one to stand in the way of progress either, but just to make sure we > are not foolishly conflating "language" with "environment" here: You do all > realize that ficl can have any sized dictionary you want, right? Correct. I've also not yet tried my hand at "dictionary partitioning". You're right that there are things I can do to reduce the dictionary, but I think that where Forth fails us is that Lua already brings a lot of what we need versus in Forth I've had to invent a lot of what I need. For example, simply checking a "string" if it contains another "string" (space or comma-separated) means that I have to create a new function (see below): Plucked from: http://svnweb.freebsd.org/base/head/sys/boot/forth/support.4th?view=markup 205 : contains? ( addr1 len1 addr2 len2 -- 0 | -1 ) 206 2 pick 0= if 2drop 2drop true exit then 207 dup 0= if 2drop 2drop false exit then 208 begin 209 begin 210 swap dup c@ dup 32 = over 9 = or over 10 = or 211 over 13 = or over 44 = or swap drop 212 while 1+ swap 1- repeat 213 swap 2 pick 1- over < 214 while 215 2over 2over drop over compare-insensitive 0= if 216 2 pick over = if 2drop 2drop true exit then 217 2 pick tuck - -rot + swap over c@ dup 32 = 218 over 9 = or over 10 = or over 13 = or over 44 = or 219 swap drop if 2drop 2drop true exit then 220 then begin 221 swap dup c@ dup 32 = over 9 = or over 10 = or 222 over 13 = or over 44 = or swap drop 223 if false else true then 2 pick 0> and 224 while 1+ swap 1- repeat 225 swap 226 repeat 227 2drop 2drop false 228 ; This function takes up space in the dictionary. > Presumably, > it's kept small due to the limitations of the boot loader environment, and Lua > is not going to magically transcend those limitations. To understand why Lua can do better, execute "words" in the Forth loader environment to see the caliber of items taking up space in the dictionary. The idea here is that Lua can provide us with a higher caliber of functionality within the same footprint. > Writing lots of boot > code in Lua will require memory, perhaps even MORE memory since, say > what you like about Forth, it's hard to get more concise or compact than a > Forth dictionary of compiled CFA's. That's why we picked it for the role in the > first place. > Lua can indeed take less memory. Forth has a dynamic dictionary that can be used to hold multiple definitions. The Code Field Address (CFA) does not have to associated with a unique element, and in this implementation you can use the "forget" word in Forth to access old CFA's (using "[']" to get at the eXecution Token, or XT, for the current definition). While Lua allows you to redefine functions [1] the unique identifier maps uniquely to the current definition (old definitions do not pollute the map). [1] http://www.lua.org/pil/6.1.html That is not to say that you cannot have a function in Lua that calls an old copy, but you have to reference the old definition in the redefinition. This is unlike Forth wherein the XT is stored _and_ the dictionary retains CFA mappings. > So anyway, first try expanding the size of the dictionary. If that can't be done, > now you know your "ceiling" for Lua. Can you stay below it, not just now but > longer term? Those are the questions you need to answer. > I know that I can increase the size of the dictionary, and it will work on my machine, but I'm too worried about the machines of yester-year to actually bump the dictionary size. -- Devin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?17e701cfc089$1d0e1b30$572a5190$>