Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Show callstack in browser upon REPL crashes #2021

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scripts/test-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ function runTest(name, code, options: PrepackOptions, args) {
options.invariantLevel = code.includes("// omit invariants") || args.verbose ? 0 : 99;
if (code.includes("// emit concrete model")) options.emitConcreteModel = true;
if (code.includes("// exceeds stack limit")) options.maxStackDepth = 10;
if (code.includes("// heapGraph")) options.heapGraphFormat = "VISJS";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think we need this change anymore.

if (code.includes("// react")) {
options.reactEnabled = true;
options.reactOutput = "jsx";
Expand Down
11 changes: 11 additions & 0 deletions src/serializer/serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,17 @@ export class Serializer {
);

if (this.options.heapGraphFormat) {
if (additionalFunctionValuesAndEffects.size > 0) {
let diagnostic = new CompilerDiagnostic(
"Using __optimize with --heapGraphFilePath flag is not currently supported",
undefined,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't sure what to give these fields since they're not really applicable. Suggestions?

"N/A",
"FatalError"
);
this.realm.handleError(diagnostic);
throw new FatalError("Using __optimize with --heapGraphFilePath flag is not currently supported");
}

const heapRefCounter = new ResidualHeapRefCounter(
this.realm,
this.logger,
Expand Down
10 changes: 8 additions & 2 deletions src/utils/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,15 @@ class ModifiedBindingEntry extends GeneratorEntry {
containingGenerator === this.containingGenerator,
"This entry requires effects to be applied and may not be moved"
);
invariant(this.modifiedBinding.value === this.newValue);
invariant(
this.modifiedBinding.value === this.newValue,
"ModifiedBinding's value has been changed since last visit."
);
let [residualBinding, newValue] = context.visitModifiedBinding(this.modifiedBinding);
invariant(this.residualFunctionBinding === undefined || this.residualFunctionBinding === residualBinding);
invariant(
this.residualFunctionBinding === undefined || this.residualFunctionBinding === residualBinding,
"ResidualFunctionBinding has been changed since last visit."
);
this.residualFunctionBinding = residualBinding;
this.newValue = newValue;
return true;
Expand Down