flat assembler
Message board for the users of flat assembler.
Index
> Windows > JavaScript Interpreter |
How small can a JavaScript Interpreter be? | |||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||
Total Votes : 8 |
Author |
|
rugxulo 28 Jan 2008, 22:03
I dunno how big an asm version would be. Lately, I've been approximating that any equivalent assembly program is about 10x smaller than (unpacked, static) C version (but that's excluding alignment and locales and whatnot).
P.S. Congratulations on your recent SAG award! |
|||
28 Jan 2008, 22:03 |
|
calpol2004 28 Jan 2008, 22:33
By using assembly not only will your interpreter be smaller but a lot faster too. It will probably take longer to build the project in than it would in D though.
I really like the D language but i hate the way they made it, it seems to be a refined cleaned up C++ but all the code bloat and other stuff that get's added has put me right off. Not only will you get all that set-up for heap .etc and all you had in C but you have garbage collector running in the background too. From what i've read, you already have the project done in D? what was the size of it in that language? FASM you will EASILY make 100kb. |
|||
28 Jan 2008, 22:33 |
|
daniel.lewis 29 Jan 2008, 00:09
@work;
As it stands, Walnut 1.0 is the smallest, fastest JavaScript interpreter I have seen out of roughly 14 different engines; with 409kb of source and a 384kb binary. http://dsource.org/projects/walnut/browser/branches/1.1/ Walnut 2.0 would be standing at 240kb completed. It's 209kb at the time of this writing; but the parser was about 90% finished, and the AST interpretation code wasn't written yet. http://dsource.org/projects/walnut/browser/branches/1.9/ I'm thinking to abandon Walnut 2.0 and start work on it in x86 assembler, with notes to ease porting it to x86-64. Planning to call the new one "Almond". |
|||
29 Jan 2008, 00:09 |
|
edfed 29 Jan 2008, 00:24
interpreter <<< 50kb (the program that interpret the javascript)
data base ~ ????kb (the database used by the programm to interpret the javascript) java is really huge. |
|||
29 Jan 2008, 00:24 |
|
f0dder 29 Jan 2008, 00:36
edfed: javascript != java.
daniel.lewis: D is a pretty interesting language, but the compiler optimizations aren't quite up to the level of MSVC or ICC. I know there's a GCC version as well, but while GCC has improved a lot over the years, MSVC and ICC still tends to beat it. You might want to try a C++ implementation and look at MSVC, ICC and GCC results, before going all the way and doing it in assembly. Bound to be less work, and you end up with more portable code - while not 100% trivial, it's still less work to produce x86-32 and x86-64 binaries from a single C++ source than from assembly. PS: be careful about messing with ESP directly, you will need to modify fields in [FS:xx] if you don't want your thread to be auto-terminate. |
|||
29 Jan 2008, 00:36 |
|
daniel.lewis 29 Jan 2008, 01:45
f0dder:
Nah, I've decided on doing it in fasm. My reasons, are because I plan on using: - a flow control device for the lexer that's quite illegible, if possible, in C-like languages (a modified duff's device) - a token stack of bytes which might have 15 more appended to them depending on their value. If it's a '+=', it's unnecessary but objects, arrays, strings, numbers etc will be built during tokenization. Variably sized code points are a bitch in C-like languages. - stack frame style crushing of local variables for Scope, rather than the high level form implied in the spec. Sure I could do it in C, but transparency makes it easier. - debugging and analysis of produced code in IDA free or similar; simply because it kicks butt. - Some code inspired by guys like Agner Fog and Paul Hsieh in places like the Math library. When the examples of good code are in assembler, why use C? - It's what's inside that counts. : ) Regards, Dan _________________ dd 0x90909090 ; problem solved. |
|||
29 Jan 2008, 01:45 |
|
vid 29 Jan 2008, 02:04
Quote: - a flow control device for the lexer that's quite illegible, if possible, in C-like languages (a modified duff's device) you might consider "flex", it should generate better lexer than anything you'd write yourself. Quote:
yep, lot of *(type*)value, etc... and it makes portability a hard fight... Quote: Some code inspired by guys like Agner Fog and Paul Hsieh in places like the Math library. When the examples of good code are in assembler, why use C? math library is good example where asm is best. but personally, i'd stick to something done, like LibTomMath, which has version written in assembly, but also in C, so it has both advantages. |
|||
29 Jan 2008, 02:04 |
|
daniel.lewis 29 Jan 2008, 07:48
I think I'll manage.
_________________ dd 0x90909090 ; problem solved. |
|||
29 Jan 2008, 07:48 |
|
daniel.lewis 05 Feb 2008, 00:02
Update
I have the DLL binding working. I added a few features to the example GUI text editor to get that interface working. The function signatures have been worked out. Each data type uses a different signature, but I plan to use toDouble, toString, toObject etc. as per ECMA spec to coerce types. I've managed to get Math's methods fleshed out using SSE2 with duff's device for handling multiple arguments. The convention for doubles is you pass argc in ECX, and the rest goes in XMM0-7. Still gotta think out how that'll work with the stack. I'm still choking in a few places where I can't think which instructions to use, so I have to fix a few items and I have to figure out the proofs still. My assembler-based lexer/parser now consumes ECMA defined whitespace, comments, Program, BlockStatement, EmptyStatement, ExpressionStatement, PrimaryExpression, StringLiteral and Identifier. Most of it's still not fleshed out and output generation is commented out. ~~ I had trouble getting cmd line and stdio figured out. I noticed there's no license or release and a copyright on the examples so I never read it. I also haven't started on using int 0x03 or debugger related stuff. _________________ dd 0x90909090 ; problem solved. |
|||
05 Feb 2008, 00:02 |
|
TheRaven 24 Apr 2008, 03:18
I thought of doing the same thing!
FASM is cross platform with little differencing, comparitively speaking of course. Assembly does produce cleaner code realizing speed gains as asm exe's grow in size compared to any equivalent in a HLL. Parsers can really benefit from assembly constrained design as they are on the fly JIT/realtime oriented. ECMA spec across the boards to boot. Excellent! FLEX is cool for building compilers, but as far as parsers are concerned I have heard the opposite on Flex. I have also heard that Flex is similar to C which isn't bad but not as good for parser development. Lewis, you are the man! Kick a** man! Any whoo, keep us posted dude as this is awesome, awesome, awesome. _________________ Nothing so sought and avoided more than the truth. I'm not insane, I know the voices in my head aren't real! |
|||
24 Apr 2008, 03:18 |
|
AlexP 24 Apr 2008, 12:50
How about this:
Instead of interpreting the Java language -> Assembly, how about have some sort of a store of commonly used Java prgms already translated, and just run those. Or just use a Jitter like C# |
|||
24 Apr 2008, 12:50 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.