Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fully deoptimize first level path when deoptimizing nested parameter paths #5153

Merged
merged 1 commit into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion src/ast/variables/ParameterVariable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default class ParameterVariable extends LocalVariable {
for (const entity of this.entitiesToBeDeoptimized) {
// We do not need a recursion tracker here as we already track whether
// this field is deoptimized
entity.deoptimizePath(path);
entity.deoptimizePath([key]);
}
if (key === UnknownKey) {
// save some memory
Expand Down
8 changes: 8 additions & 0 deletions test/function/samples/track-mutated-in-callback/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = defineTest({
description: 'tracks mutations of variables in callbacks passed to globals',
context: {
globalFunction(callback) {
callback(true);
}
}
});
10 changes: 10 additions & 0 deletions test/function/samples/track-mutated-in-callback/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const createCallback = box => newValue => {
box[0] = newValue;
return box[0];
};

const box = [null];
const callback = createCallback(box);
globalFunction(callback);

assert.ok(box[0] ? true : false);