Skip to content

Commit

Permalink
$262: Create a new host api for invoking garbage collector. Closes gh-83
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Jun 21, 2019
1 parent bc8cb21 commit 8a88e33
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 4 deletions.
2 changes: 2 additions & 0 deletions lib/agents/d8.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class D8Agent extends ConsoleAgent {
this.args.shift();
}

this.args.push('--expose-gc');

return super.evalScript(code, options);
}

Expand Down
2 changes: 2 additions & 0 deletions lib/agents/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class NodeAgent extends ConsoleAgent {
this.args.shift();
}

this.args.push('--expose-gc');

return super.evalScript(code, options);
}

Expand Down
3 changes: 3 additions & 0 deletions runtimes/chakra.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
var $ = {
global: Function('return this')(),
gc() {
throw new Test262Error('GC not yet supported.');
},
createRealm(options) {
options = options || {};
options.globals = options.globals || {};
Expand Down
3 changes: 3 additions & 0 deletions runtimes/d8.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
var $ = {
global: Function('return this')(),
gc() {
return gc();
},
createRealm(options) {
options = options || {};
options.globals = options.globals || {};
Expand Down
5 changes: 4 additions & 1 deletion runtimes/engine262.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
/* Using this["\x24"]; prevents overwrite by ConsoleAgent */
var engine262 = this["\x24"];
var $ = {
global: engine262.global,
realm: null,
global: engine262.global,
gc() {
throw new Test262Error('GC not yet supported.');
},
createRealm(options) {
options = options || {};
options.globals = options.globals || {};
Expand Down
3 changes: 3 additions & 0 deletions runtimes/jsc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ $262.getGlobal = function(name) {
$262.setGlobal = function(name, value) {
this.global[name] = value;
};
$262.gc = function() {
return gc();
};
3 changes: 3 additions & 0 deletions runtimes/nashorn.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
var $ = {
global: Function('return this')(),
gc() {
throw new Test262Error('GC not yet supported.');
},
createRealm: function(options) {
options = options || {};
options.globals = options.globals || {};
Expand Down
13 changes: 10 additions & 3 deletions runtimes/node.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
function print(...args) {
console.log(...args);
}
var vm = require('vm');
var $ = {
global: Function('return this')(),
gc() {
return gc();
},
createRealm(options) {
options = options || {};
options.globals = options.globals || {};

context = {
console: console,
require: require
console,
require,
print,
};

for(var glob in options.globals) {
Expand Down Expand Up @@ -49,4 +56,4 @@ var $ = {
source: $SOURCE
};

function print() { console.log.apply(console, arguments); }

3 changes: 3 additions & 0 deletions runtimes/sm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
var $ = {
global: Function('return this')(),
gc() {
return gc();
},
createRealm(options) {
options = options || {};
options.globals = options.globals || {};
Expand Down
3 changes: 3 additions & 0 deletions runtimes/xs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
var $ = {
global,
gc() {
throw new Test262Error('GC not yet supported.');
},
createRealm(options) {
options = options || {};
options.globals = options.globals || {};
Expand Down

0 comments on commit 8a88e33

Please sign in to comment.