Skip to content

Commit

Permalink
Temporarily disable the 'banalyze' phase
Browse files Browse the repository at this point in the history
  • Loading branch information
cscott committed Dec 7, 2022
1 parent f9f4c16 commit 27a3e5f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
15 changes: 14 additions & 1 deletion banalyze.js
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,9 @@ define(["text!banalyze.js", "bytecode-table", "literal-map"], function make_bana
});
};


var optimize = {
// compute liveness?
};

var banalyze = function(bc, func_id, literalMap) {
var bcFunc = bc.functions[func_id];
Expand Down Expand Up @@ -1023,6 +1025,17 @@ define(["text!banalyze.js", "bytecode-table", "literal-map"], function make_bana
// and we don't actually need the get_slot_direct/get_slot distinction
// because it is implicit in the valueNum used
state.prettyPrint();

// XXX what's needed now is to emit this computed type information
// in a manner which is easily usable for code generation; including
// allowing common subexpressions and dead assignments to be recognized
// (and thus not generated). For code gen we're basically going to
// reexecute the byte code but push expression fragments on the stack,
// so that `biadd` (for example) pops expression `a` and expression `b`
// off the stack and pushes `mt(a).add(a, b)` onto the stack, or
// something like that. We have to dump entries onto the stack
// into temp variables when the stack is re-ordered or we need
// side-effects to occur in a certain order.
};
banalyze.__module_name__ = "banalyze";
banalyze.__module_init__ = make_banalyze;
Expand Down
15 changes: 9 additions & 6 deletions write-lua-bytecode.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//
// Run it under `node` with the CLI in `bin/write-lua-bytecode.js`
define(['./parse', './bcompile', './banalyze', './bytecode-table', './top-level', './str-escape', './literal-map', './tests', './stdlib', './extensions'], function(parse, bcompile, banalyze, bytecode_table, top_level, str_escape, LiteralMap, tests, stdlib) {
banalyze = null; // Disable banalyze for now.
var fake_require =
"var __modules__ = {};\n"+
"define = function _define(name, deps, init_func) {\n"+
Expand All @@ -14,10 +15,12 @@ define(['./parse', './bcompile', './banalyze', './bytecode-table', './top-level'
source = source || '{ return 1+2; }';
var tree = parse(source, TOP_LEVEL);
var bc = bcompile(tree, true/*don't desugar frame get*/);
var literalMap = LiteralMap.New(bc.literals);
bc.functions.forEach(function(f, i) {
banalyze(bc, f.id, literalMap);
});
if (banalyze) {
var literalMap = LiteralMap.New(bc.literals);
bc.functions.forEach(function(f, i) {
banalyze(bc, f.id, literalMap);
});
}
var result = as_object ? bc : bc.encode();
return result;
};
Expand Down Expand Up @@ -46,7 +49,7 @@ define(['./parse', './bcompile', './banalyze', './bytecode-table', './top-level'
tests.lookup("bytecode-table")+"\n"+
tests.lookup("literal-map")+"\n"+
tests.lookup("bcompile")+"\n"+
tests.lookup("banalyze")+"\n"+
(banalyze ? (tests.lookup("banalyze")+"\n") : "") +
top_level_source+"\n"+
cfs_source + '\n' +
/*
Expand All @@ -70,7 +73,7 @@ define(['./parse', './bcompile', './banalyze', './bytecode-table', './top-level'
"}\n" +
"return two; }; return fib(10); }";
*/
console.log(source);
// console.log(source);

var compile_from_source = make_compile_from_source(parse, bcompile, banalyze, LiteralMap, top_level);
var bc = compile_from_source(source, true/*as object*/);
Expand Down

0 comments on commit 27a3e5f

Please sign in to comment.