I have started to bootstrap Tachyon with js2scm to find which library functions are required. In the process I have had to resolve a few issues with the Tachyon sources.
In particular the js2scm compiler does not support LabelledStatements yet (i.e. <label> : <statement>) and this is used in a few places to control loop exit. I have rewritten such uses when it was easy, but there remains one use in ir/optpatterns.js that I don't dare modify because the control flow and invariants are not obvious. Maxime: could you take a look and rewrite it without "continue <label>;" statements?
I've also discovered that the following global variables are referenced but they are not used anywhere. Please fix this!
newdest reg rhsValAssg signExtend u2 upperAddr
Also, I have encountered this style of code:
if (Error.captureStackTrace)
to test for the existence of a particular feature (V8 specific?). Please use this instead:
if (Error.captureStackTrace !== undefined)
which will make implementing "if" easier. In other words, make sure the test of an if yields a boolean.
Marc
Afficher les réponses par date
I have started to bootstrap Tachyon with js2scm to find which library functions are required. In the process I have had to resolve a few issues with the Tachyon sources.
I thought your goal was to use the parser to find the missing library functions we need to implement. Are you telling us that your goal is to fully compile Tachyon to scheme? Not to be grumpy, but I wish that time was spent elsewhere. The parser still isn't fully fixed, as far as I know. There was a long list of fixes you had me e-mail you twice (or was it 3 times?) a little while ago.
Also, the modifications you've made in the assembler seem to be causing "make run" to segfault on my machine. What are those "redundant x86 instructions" you removed?
I've also discovered that the following global variables are referenced but they are not used anywhere. Please fix this!
I fixed the ones I was able to locate.
Also, I have encountered this style of code: if (Error.captureStackTrace) to test for the existence of a particular feature (V8 specific?). Please use this instead: if (Error.captureStackTrace !== undefined) which will make implementing "if" easier. In other words, make sure the test of an if yields a boolean.
Seriously? This should be trivial to implement in any interpreter. It's also used in lots of places in our code, and it's convenient.
- Maxime
On 2010-12-14, at 3:37 PM, chevalma@iro.umontreal.ca wrote:
I have started to bootstrap Tachyon with js2scm to find which library functions are required. In the process I have had to resolve a few issues with the Tachyon sources.
I thought your goal was to use the parser to find the missing library functions we need to implement. Are you telling us that your goal is to fully compile Tachyon to scheme?
Just enough to run Tachyon and generate some code (no run-time execution of the generated code). This is to find all the runtime functions and features that are used by Tachyon. The code has to be run because JavaScript is a dynamic language (i.e. you can't tell statically what is required, so just parsing Tachyon is not enough).
Not to be grumpy, but I wish that time was spent elsewhere. The parser still isn't fully fixed, as far as I know. There was a long list of fixes you had me e-mail you twice (or was it 3 times?) a little while ago.
The parser is not on the critical path to the bootstrap of Tachyon.
Also, the modifications you've made in the assembler seem to be causing "make run" to segfault on my machine.
I introduced a bug for a few minutes but it should be gone now.
What are those "redundant x86 instructions" you removed?
cmove is just another name for cmovz, so there is no reason to have both (it just bloats the compiler for no good reason). There are other redundant conditional move instructions.
I've also discovered that the following global variables are referenced but they are not used anywhere. Please fix this!
I fixed the ones I was able to locate.
Also, I have encountered this style of code: if (Error.captureStackTrace) to test for the existence of a particular feature (V8 specific?). Please use this instead: if (Error.captureStackTrace !== undefined) which will make implementing "if" easier. In other words, make sure the test of an if yields a boolean.
Seriously?
Let me be clear... from now on if I'm being sarcastic in my email I will add a smiley at the end of the sentence.
I really don't appreciate your derogatory tone. So please try to keep things civil.
This should be trivial to implement in any interpreter.
It is not easy when the target language does not have "goto". Remember that at the start of the project we agreed to not use advanced features of JavaScript so that the bootstrap process would be simplified. Labelled statements are neither required, nor particularly good style (I rewrote the current uses of it except for one, with no loss of readability, in fact I would say the code is easier to understand now).
It's also used in lots of places in our code, and it's convenient.
The compiler should not rely on this misfeature of JavaScript. In JavaScript, several objects count as false:
false, 0, null, undefined, ""
so the implementation of
if (x) ...
must in general test if x is one of the false values. It is sufficiently complex that you don't want to generate the tests inline, so an out-of-line function must be called, which is slow. On the other hand, the test
if (x !== undefined) ...
only has to check for a single value. Less machine code is required, the performance is better, and the intent of the programmer is clear (and thus the code is easier to maintain and debug).
Marc
This should be trivial to implement in any interpreter.
It is not easy when the target language does not have "goto".
I wasn't talking about labels. I was talking about if (varName).
so the implementation of
if (x) ...
must in general test if x is one of the false values. It is sufficiently complex that you don't want to generate the tests inline, so an out-of-line function must be called, which is slow.
A very marginal slowdown shouldn't be important for what you're trying to achieve with js2scm. It's more convenient for you to implement this function than for me to try and find all the instances of if (x) and make my code more verbose.
- Maxime
On 2010-12-14, at 5:04 PM, chevalma@iro.umontreal.ca wrote:
This should be trivial to implement in any interpreter.
It is not easy when the target language does not have "goto".
I wasn't talking about labels. I was talking about if (varName).
so the implementation of
if (x) ...
must in general test if x is one of the false values. It is sufficiently complex that you don't want to generate the tests inline, so an out-of-line function must be called, which is slow.
A very marginal slowdown shouldn't be important for what you're trying to achieve with js2scm. It's more convenient for you to implement this function than for me to try and find all the instances of if (x) and make my code more verbose.
I wasn't talking about js2scm's performance. That is not an issue at this point. I'm talking about coding style for Tachyon's source code. The problem is that the idiom
function f(x) { if (!x) x = ...;
is bad style. It doesn't convey the intent of the programmer, which is to test wether parameter x was supplied in the call to f. It is broken because it does not distinguish
f(); f(false); f(0); f(null); f("");
To properly distinguish them you need
function f(x) { if (x === undefined) x = ...;
That matches the intent much better (it is not perfect because it doesn't distinguish f() from f(undefined) but that is minor).
In addition there is a performance hit for the if (!x) ... style in code space and code speed, and this is relevant for when Tachyon will be bootstrapped with Tachyon.
So no matter which way you look at it there is no advantage to the if (!x) ... style.
Marc
More bugs and bad style comments...
1) Don't forget to add a "var" declaration at top-level when defining a global variable. So instead of:
PLATFORM_PTR_SIZE = 4; ArithInstr = function () ...
write
var PLATFORM_PTR_SIZE = 4; var ArithInstr = function () ...
2) Don't use "delete" gratuitously. In ir/instructions.js some properties were deleted that were added just a few lines before.
3) The PLATFORM_PTR_SIZE global variable is a bad idea. Once we have Tachyon running on a 32 bit machine, how will we bootstrap on a 64 bit machine? We can't assign 8 to PLATFORM_PTR_SIZE because that will break the VM itself. It must be possible to generate 64 bit code on 32 bit x86, just like it should be possible to generate ARM code on x86. The compiler should be parameterized by a "target" object indicating the specifics of the target processor.
Marc
On 2010-12-14, at 1:58 PM, Marc Feeley wrote:
I have started to bootstrap Tachyon with js2scm to find which library functions are required. In the process I have had to resolve a few issues with the Tachyon sources.
In particular the js2scm compiler does not support LabelledStatements yet (i.e. <label> : <statement>) and this is used in a few places to control loop exit. I have rewritten such uses when it was easy, but there remains one use in ir/optpatterns.js that I don't dare modify because the control flow and invariants are not obvious. Maxime: could you take a look and rewrite it without "continue <label>;" statements?
I've also discovered that the following global variables are referenced but they are not used anywhere. Please fix this!
newdest reg rhsValAssg signExtend u2 upperAddr
Also, I have encountered this style of code:
if (Error.captureStackTrace)
to test for the existence of a particular feature (V8 specific?). Please use this instead:
if (Error.captureStackTrace !== undefined)
which will make implementing "if" easier. In other words, make sure the test of an if yields a boolean.
Marc
Marc, how do I test if unused global variables remain?
I fixed upperAddr but I could not find any instance for reg, the others were modified by Maxime in recent commits so I guess that should be ok now.
Erick
Le 10-12-14 13:58 , Marc Feeley a écrit :
I've also discovered that the following global variables are referenced but they are not used anywhere. Please fix this!
newdest reg rhsValAssg signExtend u2 upperAddr
Tachyon-list mailing list Tachyon-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/tachyon-list