Skip to content

Commit

Permalink
issue #227 - monomorphic fibers frames
Browse files Browse the repository at this point in the history
  • Loading branch information
bjouhier committed Aug 10, 2014
1 parent 4e1deb7 commit d7c9c6b
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions lib/fibers/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,19 @@ this.globals = globals;
* ...
* }, 1);
*/
function Frame(fn, file, line) {
this.prev = globals.frame;
this.name = fn.name;
this.file = file;
this.line = line;
// initialize streamline-flamegraph fields to make it monomorphic
this.recurse = 0;
this.yielded = 0;
this.id = 0;
}

function pushFrame(fn, file, line) {
var frame = globals.frame = {
prev: globals.frame,
name: fn.name,
file: file,
line: line,
}
var frame = globals.frame = new Frame(fn, file, line);
globals.emitter.emit('enter');
return frame;
}
Expand Down Expand Up @@ -161,18 +167,21 @@ function invoke(that, fn, args, options) {
globals.frame = frame;
if (globals.yielded) emitter.emit('resume');
globals.yielded = false;
//emitter.emit('enter');
}
try {
try {
if (e) {
fiber.throwInto(e);
} else {
fiber.run(v);
}
} finally {
globals.frame = oldFrame;
}
} else {
if (e) {
fiber.throwInto(e);
} else {
fiber.run(v);
}
} finally {
if (emitter) {
globals.frame = oldFrame;
}
}
}
}
};
Expand Down

0 comments on commit d7c9c6b

Please sign in to comment.