continuing to fight compatiblity issues

This commit is contained in:
Danny Yoo 2011-09-15 14:00:33 -04:00
parent 67341e3301
commit f2cc5b421f
5 changed files with 89 additions and 89 deletions

View File

@ -66,7 +66,7 @@ for (param in params) {
} }
EOF EOF
op) op)
(fprintf op "M.trampoline(~a); })" (fprintf op "M.trampoline(~a, true); })"
(assemble-label (make-Label (BasicBlock-name (first basic-blocks)))))) (assemble-label (make-Label (BasicBlock-name (first basic-blocks))))))

View File

@ -236,7 +236,8 @@ M.modules[~s] =
;; load in modules. ;; load in modules.
(define (package source-code (define (package source-code
#:should-follow-children? should-follow? #:should-follow-children? should-follow?
#:output-port op) #:output-port op
#:next-file-path (next-file-path (lambda () (error 'package))))
(define resources (set)) (define resources (set))
@ -257,22 +258,28 @@ M.modules[~s] =
;; Record the use of resources on source module visitation... ;; Record the use of resources on source module visitation...
(set! resources (set-union resources (list->set (source-resources src)))) (set! resources (set-union resources (list->set (source-resources src))))
(fprintf op "\n// ** Visiting ~a\n" (source-name src)) (fprintf op "\n// ** Visiting ~a\n" (source-name src))
(define start-time (current-inexact-milliseconds)) (define start-time (current-inexact-milliseconds))
(cond (cond
[(UninterpretedSource? src) [(UninterpretedSource? src)
(fprintf op "~a" (UninterpretedSource-datum src))] (fprintf op "(function(M) { ~a }(plt.runtime.currentMachine));" (UninterpretedSource-datum src))]
[else [else
(fprintf op "(") (fprintf op "(")
(assemble/write-invoke stmts op) (assemble/write-invoke stmts op)
(fprintf op ")(M, (fprintf op ")(plt.runtime.currentMachine,
function() { function() {
if (window.console && window.console.log) { if (window.console && window.console.log) {
window.console.log('loaded ' + ~s); window.console.log('loaded ' + ~s);
} }
}, },
FAIL, function(err) {
PARAMS);" if (window.console && window.console.log) {
window.console.log('error: unable to load ' + ~s);
}
},
{});"
(format "~a" (source-name src))
(format "~a" (source-name src))) (format "~a" (source-name src)))
(define stop-time (current-inexact-milliseconds)) (define stop-time (current-inexact-milliseconds))
(fprintf (current-timing-port) " assembly: ~s milliseconds\n" (- stop-time start-time)) (fprintf (current-timing-port) " assembly: ~s milliseconds\n" (- stop-time start-time))
@ -284,7 +291,7 @@ M.modules[~s] =
(define (on-last-src) (define (on-last-src)
(fprintf op "plt.runtime.setReadyTrue(); SUCCESS();")) (void))
@ -303,13 +310,8 @@ M.modules[~s] =
;; last ;; last
on-last-src)) on-last-src))
(fprintf op "var invoke = (function(M, SUCCESS, FAIL, PARAMS) {")
(fprintf op " plt.runtime.ready(function() {")
(fprintf op " plt.runtime.setReadyFalse();")
(make (list (make-MainModuleSource source-code)) (make (list (make-MainModuleSource source-code))
packaging-configuration) packaging-configuration)
(fprintf op " });");
(fprintf op "});\n")
(for ([r resources]) (for ([r resources])
((current-on-resource) r))) ((current-on-resource) r)))
@ -322,7 +324,8 @@ M.modules[~s] =
(display *header* op) (display *header* op)
(display (quote-cdata (display (quote-cdata
(string-append (get-runtime) (string-append (get-runtime)
(get-inert-code source-code) (get-inert-code source-code
(lambda () (error 'package-standalone-xhtml)))
invoke-main-module-code)) op) invoke-main-module-code)) op)
(display *footer* op)) (display *footer* op))
@ -431,12 +434,13 @@ EOF
invoke-main-module-code)) invoke-main-module-code))
;; get-inert-code: source -> string ;; get-inert-code: source (-> path) -> string
(define (get-inert-code source-code) (define (get-inert-code source-code next-file-path)
(let ([buffer (open-output-string)]) (let ([buffer (open-output-string)])
(package source-code (package source-code
#:should-follow-children? (lambda (src) #t) #:should-follow-children? (lambda (src) #t)
#:output-port buffer) #:output-port buffer
#:next-file-path next-file-path)
(compress (compress
(get-output-string buffer)))) (get-output-string buffer))))
@ -465,66 +469,56 @@ EOF
#<<EOF #<<EOF
var invokeMainModule = function() { var invokeMainModule = function() {
var M = plt.runtime.currentMachine; var M = plt.runtime.currentMachine;
invoke(M, var startTime = new Date().valueOf();
function() { plt.runtime.invokeMains(
var startTime = new Date().valueOf(); M,
plt.runtime.invokeMains( function() {
M, // On main module invokation success:
function() { var stopTime = new Date().valueOf();
// On main module invokation success: if (window.console && window.console.log) {
var stopTime = new Date().valueOf(); window.console.log('evaluation took ' + (stopTime - startTime) + ' milliseconds');
if (window.console && window.console.log) { }
window.console.log('evaluation took ' + (stopTime - startTime) + ' milliseconds'); },
} function(M, e) {
}, var contMarkSet, context, i, appName;
function(M, e) { // On main module invokation failure
var contMarkSet, context, i, appName; if (window.console && window.console.log) {
// On main module invokation failure window.console.log(e.stack || e);
if (window.console && window.console.log) { }
window.console.log(e.stack || e);
} M.params.currentErrorDisplayer(
M, $(plt.baselib.format.toDomNode(e.stack || e)).css('color', 'red'));
M.params.currentErrorDisplayer(
M, $(plt.baselib.format.toDomNode(e.stack || e)).css('color', 'red'));
if (e.hasOwnProperty('racketError') && if (e.hasOwnProperty('racketError') &&
plt.baselib.exceptions.isExn(e.racketError)) { plt.baselib.exceptions.isExn(e.racketError)) {
contMarkSet = plt.baselib.exceptions.exnContMarks(e.racketError); contMarkSet = plt.baselib.exceptions.exnContMarks(e.racketError);
if (contMarkSet) { if (contMarkSet) {
context = contMarkSet.getContext(M); context = contMarkSet.getContext(M);
for (i = 0; i < context.length; i++) { for (i = 0; i < context.length; i++) {
if (plt.runtime.isVector(context[i])) { if (plt.runtime.isVector(context[i])) {
M.params.currentErrorDisplayer( M.params.currentErrorDisplayer(
M, M,
$('<div/>').text(' at ' + context[i].elts[0] + $('<div/>').text(' at ' + context[i].elts[0] +
', line ' + context[i].elts[2] + ', line ' + context[i].elts[2] +
', column ' + context[i].elts[3]) ', column ' + context[i].elts[3])
.addClass('stacktrace') .addClass('stacktrace')
.css('margin-left', '10px') .css('margin-left', '10px')
.css('whitespace', 'pre') .css('whitespace', 'pre')
.css('color', 'red')); .css('color', 'red'));
} else if (plt.runtime.isProcedure(context[i])) { } else if (plt.runtime.isProcedure(context[i])) {
M.params.currentErrorDisplayer( M.params.currentErrorDisplayer(
M, M,
$('<div/>').text(' in ' + context[i].displayName) $('<div/>').text(' in ' + context[i].displayName)
.addClass('stacktrace') .addClass('stacktrace')
.css('margin-left', '10px') .css('margin-left', '10px')
.css('whitespace', 'pre') .css('whitespace', 'pre')
.css('color', 'red')); .css('color', 'red'));
} }
} }
} }
} }
})}, });
function() {
// On module loading failure
if (window.console && window.console.log) {
window.console.log(e.stack || e);
}
},
{});
}; };
$(document).ready(invokeMainModule); $(document).ready(invokeMainModule);
EOF EOF
) )

View File

@ -694,7 +694,7 @@
'substring', 'substring',
makeList(2, 3), makeList(2, 3),
function(M) { function(M) {
var str = String(checkString(M, 'substring', 0)); var str = checkString(M, 'substring', 0).toString();
var start = baselib.numbers.toFixnum(checkNatural(M, 'substring', 1)); var start = baselib.numbers.toFixnum(checkNatural(M, 'substring', 1));
var end = str.length; var end = str.length;
if (M.a === 3) { if (M.a === 3) {
@ -1722,8 +1722,8 @@
var i; var i;
if (M.a === 1) { if (M.a === 1) {
var sym = checkSymbol(M, 'error', 1); var sym = checkSymbol(M, 'error', 1);
raise(M, baselib.exceptions.makeExnFail(String(sym), raise(M, baselib.exceptions.makeExnFail(sym.toString(),
M.captureContinuationMarks())); M.captureContinuationMarks()));
} }
if (isString(M.e[M.e.length - 1])) { if (isString(M.e[M.e.length - 1])) {
@ -1731,7 +1731,7 @@
for (i = 1; i < M.a; i++) { for (i = 1; i < M.a; i++) {
vs.push(baselib.format.format("~e", [M.e[M.e.length - 1 - i]])); vs.push(baselib.format.format("~e", [M.e[M.e.length - 1 - i]]));
} }
raise(M, baselib.exceptions.makeExnFail(String(M.e[M.e.length - 1]) + raise(M, baselib.exceptions.makeExnFail(M.e[M.e.length - 1].toString() +
": " + ": " +
vs.join(' '), vs.join(' '),
M.captureContinuationMarks())); M.captureContinuationMarks()));
@ -1744,7 +1744,7 @@
args.push(M.e[M.e.length - 1 - i]); args.push(M.e[M.e.length - 1 - i]);
} }
raise(M, baselib.exceptions.makeExnFail( raise(M, baselib.exceptions.makeExnFail(
baselib.format.format('~s: ' + String(fmtString), baselib.format.format('~s: ' + fmtString.toString(),
args), args),
M.captureContinuationMarks())); M.captureContinuationMarks()));
} }
@ -1850,7 +1850,7 @@
var predicateValue = var predicateValue =
makePrimitiveProcedure( makePrimitiveProcedure(
String(name) + "?", name.toString() + "?",
1, 1,
function (M) { function (M) {
return structType.predicate(M.e[M.e.length - 1]); return structType.predicate(M.e[M.e.length - 1]);
@ -1858,7 +1858,7 @@
var accessorValue = var accessorValue =
makePrimitiveProcedure( makePrimitiveProcedure(
String(name) + "-accessor", name.toString() + "-accessor",
2, 2,
function (M) { function (M) {
return structType.accessor( return structType.accessor(
@ -1869,7 +1869,7 @@
var mutatorValue = var mutatorValue =
makePrimitiveProcedure( makePrimitiveProcedure(
String(name) + "-mutator", name.toString() + "-mutator",
3, 3,
function (M) { function (M) {
return structType.mutator( return structType.mutator(
@ -1913,7 +1913,7 @@
var index = M.e[M.e.length - 2]; var index = M.e[M.e.length - 2];
var name; var name;
if (M.a === 3) { if (M.a === 3) {
name = String(M.e[M.e.length - 3]); name = M.e[M.e.length - 3].toString();
} else { } else {
name = 'field' + index; name = 'field' + index;
} }
@ -1940,7 +1940,7 @@
var index = M.e[M.e.length - 2]; var index = M.e[M.e.length - 2];
var name; var name;
if (M.a === 3) { if (M.a === 3) {
name = String(M.e[M.e.length - 3]); name = M.e[M.e.length - 3].toString();
} else { } else {
name = 'field' + index; name = 'field' + index;
} }

View File

@ -443,7 +443,7 @@
}; };
Machine.prototype.trampoline = function(initialJump) { Machine.prototype.trampoline = function(initialJump, noJumpingOff) {
var thunk = initialJump; var thunk = initialJump;
var startTime = (new Date()).valueOf(); var startTime = (new Date()).valueOf();
this.cbt = STACK_LIMIT_ESTIMATE; this.cbt = STACK_LIMIT_ESTIMATE;
@ -480,6 +480,13 @@
thunk = e; thunk = e;
this.cbt = STACK_LIMIT_ESTIMATE; this.cbt = STACK_LIMIT_ESTIMATE;
// If we're running an a model that prohibits
// jumping off the trampoline, continue.
if (noJumpingOff) {
continue;
}
if (this.params.numBouncesBeforeYield-- < 0) { if (this.params.numBouncesBeforeYield-- < 0) {
recomputeMaxNumBouncesBeforeYield( recomputeMaxNumBouncesBeforeYield(
this, this,
@ -506,9 +513,7 @@
} }
this.running = false; this.running = false;
var that = this; var that = this;
setTimeout( this.params.currentSuccessHandler(this);
function() { that.params.currentSuccessHandler(that); },
0);
return; return;
}; };

View File

@ -141,7 +141,8 @@
(call-with-output-file* output-js-filename (call-with-output-file* output-js-filename
(lambda (op) (lambda (op)
(display (get-runtime) op) (display (get-runtime) op)
(display (get-inert-code (make-ModuleSource (build-path f))) (display (get-inert-code (make-ModuleSource (build-path f))
make-output-js-filename)
op)) op))
#:exists 'replace) #:exists 'replace)