rollup 2.75.5 → 2.75.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/bin/rollup +2 -2
- package/dist/es/rollup.browser.js +3 -3
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/rollup.js +618 -724
- package/dist/es/shared/watch.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/rollup.browser.js +3 -3
- package/dist/rollup.browser.js.map +1 -1
- package/dist/rollup.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/mergeOptions.js +2 -2
- package/dist/shared/rollup.js +618 -724
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +1 -1
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v2.75.
|
|
4
|
-
|
|
3
|
+
Rollup.js v2.75.6
|
|
4
|
+
Tue, 07 Jun 2022 14:42:22 GMT - commit 0ab16cc04b7d6dfe5bd14340ba7448085a379e25
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -27,7 +27,7 @@ function _interopNamespaceDefault(e) {
|
|
|
27
27
|
return n;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
var version$1 = "2.75.
|
|
30
|
+
var version$1 = "2.75.6";
|
|
31
31
|
|
|
32
32
|
function ensureArray$1(items) {
|
|
33
33
|
if (Array.isArray(items)) {
|
|
@@ -2228,8 +2228,8 @@ class ExpressionEntity {
|
|
|
2228
2228
|
this.included = false;
|
|
2229
2229
|
}
|
|
2230
2230
|
deoptimizePath(_path) { }
|
|
2231
|
-
|
|
2232
|
-
|
|
2231
|
+
deoptimizeThisOnInteractionAtPath({ thisArg }, _path, _recursionTracker) {
|
|
2232
|
+
thisArg.deoptimizePath(UNKNOWN_PATH);
|
|
2233
2233
|
}
|
|
2234
2234
|
/**
|
|
2235
2235
|
* If possible it returns a stringifyable literal value for this node that can be used
|
|
@@ -2239,16 +2239,10 @@ class ExpressionEntity {
|
|
|
2239
2239
|
getLiteralValueAtPath(_path, _recursionTracker, _origin) {
|
|
2240
2240
|
return UnknownValue;
|
|
2241
2241
|
}
|
|
2242
|
-
getReturnExpressionWhenCalledAtPath(_path,
|
|
2242
|
+
getReturnExpressionWhenCalledAtPath(_path, _interaction, _recursionTracker, _origin) {
|
|
2243
2243
|
return UNKNOWN_EXPRESSION;
|
|
2244
2244
|
}
|
|
2245
|
-
|
|
2246
|
-
return true;
|
|
2247
|
-
}
|
|
2248
|
-
hasEffectsWhenAssignedAtPath(_path, _context) {
|
|
2249
|
-
return true;
|
|
2250
|
-
}
|
|
2251
|
-
hasEffectsWhenCalledAtPath(_path, _callOptions, _context) {
|
|
2245
|
+
hasEffectsOnInteractionAtPath(_path, _interaction, _context) {
|
|
2252
2246
|
return true;
|
|
2253
2247
|
}
|
|
2254
2248
|
include(_context, _includeChildrenRecursively, _options) {
|
|
@@ -2266,6 +2260,30 @@ class ExpressionEntity {
|
|
|
2266
2260
|
const UNKNOWN_EXPRESSION = new (class UnknownExpression extends ExpressionEntity {
|
|
2267
2261
|
})();
|
|
2268
2262
|
|
|
2263
|
+
const INTERACTION_ACCESSED = 0;
|
|
2264
|
+
const INTERACTION_ASSIGNED = 1;
|
|
2265
|
+
const INTERACTION_CALLED = 2;
|
|
2266
|
+
const NODE_INTERACTION_UNKNOWN_ACCESS = {
|
|
2267
|
+
thisArg: null,
|
|
2268
|
+
type: INTERACTION_ACCESSED
|
|
2269
|
+
};
|
|
2270
|
+
const UNKNOWN_ARG = [UNKNOWN_EXPRESSION];
|
|
2271
|
+
const NODE_INTERACTION_UNKNOWN_ASSIGNMENT = {
|
|
2272
|
+
args: UNKNOWN_ARG,
|
|
2273
|
+
thisArg: null,
|
|
2274
|
+
type: INTERACTION_ASSIGNED
|
|
2275
|
+
};
|
|
2276
|
+
const NO_ARGS = [];
|
|
2277
|
+
// While this is technically a call without arguments, we can compare against
|
|
2278
|
+
// this reference in places where precise values or thisArg would make a
|
|
2279
|
+
// difference
|
|
2280
|
+
const NODE_INTERACTION_UNKNOWN_CALL = {
|
|
2281
|
+
args: NO_ARGS,
|
|
2282
|
+
thisArg: null,
|
|
2283
|
+
type: INTERACTION_CALLED,
|
|
2284
|
+
withNew: false
|
|
2285
|
+
};
|
|
2286
|
+
|
|
2269
2287
|
class Variable extends ExpressionEntity {
|
|
2270
2288
|
constructor(name) {
|
|
2271
2289
|
super();
|
|
@@ -2290,8 +2308,8 @@ class Variable extends ExpressionEntity {
|
|
|
2290
2308
|
const name = this.renderName || this.name;
|
|
2291
2309
|
return this.renderBaseName ? `${this.renderBaseName}${getPropertyAccess(name)}` : name;
|
|
2292
2310
|
}
|
|
2293
|
-
|
|
2294
|
-
return path.length > 0;
|
|
2311
|
+
hasEffectsOnInteractionAtPath(path, { type }, _context) {
|
|
2312
|
+
return type !== INTERACTION_ACCESSED || path.length > 0;
|
|
2295
2313
|
}
|
|
2296
2314
|
/**
|
|
2297
2315
|
* Marks this variable as being part of the bundle, which is usually the case when one of
|
|
@@ -2322,8 +2340,8 @@ class ExternalVariable extends Variable {
|
|
|
2322
2340
|
this.module.suggestName(identifier.name);
|
|
2323
2341
|
}
|
|
2324
2342
|
}
|
|
2325
|
-
|
|
2326
|
-
return path.length > (this.isNamespace ? 1 : 0);
|
|
2343
|
+
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
2344
|
+
return type !== INTERACTION_ACCESSED || path.length > (this.isNamespace ? 1 : 0);
|
|
2327
2345
|
}
|
|
2328
2346
|
include() {
|
|
2329
2347
|
if (!this.included) {
|
|
@@ -4710,8 +4728,6 @@ function createHasEffectsContext() {
|
|
|
4710
4728
|
};
|
|
4711
4729
|
}
|
|
4712
4730
|
|
|
4713
|
-
const NO_ARGS = [];
|
|
4714
|
-
|
|
4715
4731
|
function assembleMemberDescriptions(memberDescriptions, inheritedDescriptions = null) {
|
|
4716
4732
|
return Object.create(inheritedDescriptions, memberDescriptions);
|
|
4717
4733
|
}
|
|
@@ -4733,12 +4749,12 @@ const UNKNOWN_LITERAL_BOOLEAN = new (class UnknownBoolean extends ExpressionEnti
|
|
|
4733
4749
|
}
|
|
4734
4750
|
return UNKNOWN_EXPRESSION;
|
|
4735
4751
|
}
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
if (path.length === 1) {
|
|
4741
|
-
return hasMemberEffectWhenCalled(literalBooleanMembers, path[0],
|
|
4752
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
4753
|
+
if (interaction.type === INTERACTION_ACCESSED) {
|
|
4754
|
+
return path.length > 1;
|
|
4755
|
+
}
|
|
4756
|
+
if (interaction.type === INTERACTION_CALLED && path.length === 1) {
|
|
4757
|
+
return hasMemberEffectWhenCalled(literalBooleanMembers, path[0], interaction, context);
|
|
4742
4758
|
}
|
|
4743
4759
|
return true;
|
|
4744
4760
|
}
|
|
@@ -4756,12 +4772,12 @@ const UNKNOWN_LITERAL_NUMBER = new (class UnknownNumber extends ExpressionEntity
|
|
|
4756
4772
|
}
|
|
4757
4773
|
return UNKNOWN_EXPRESSION;
|
|
4758
4774
|
}
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
if (path.length === 1) {
|
|
4764
|
-
return hasMemberEffectWhenCalled(literalNumberMembers, path[0],
|
|
4775
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
4776
|
+
if (interaction.type === INTERACTION_ACCESSED) {
|
|
4777
|
+
return path.length > 1;
|
|
4778
|
+
}
|
|
4779
|
+
if (interaction.type === INTERACTION_CALLED && path.length === 1) {
|
|
4780
|
+
return hasMemberEffectWhenCalled(literalNumberMembers, path[0], interaction, context);
|
|
4765
4781
|
}
|
|
4766
4782
|
return true;
|
|
4767
4783
|
}
|
|
@@ -4779,12 +4795,12 @@ const UNKNOWN_LITERAL_STRING = new (class UnknownString extends ExpressionEntity
|
|
|
4779
4795
|
}
|
|
4780
4796
|
return UNKNOWN_EXPRESSION;
|
|
4781
4797
|
}
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
if (path.length === 1) {
|
|
4787
|
-
return hasMemberEffectWhenCalled(literalStringMembers, path[0],
|
|
4798
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
4799
|
+
if (interaction.type === INTERACTION_ACCESSED) {
|
|
4800
|
+
return path.length > 1;
|
|
4801
|
+
}
|
|
4802
|
+
if (interaction.type === INTERACTION_CALLED && path.length === 1) {
|
|
4803
|
+
return hasMemberEffectWhenCalled(literalStringMembers, path[0], interaction, context);
|
|
4788
4804
|
}
|
|
4789
4805
|
return true;
|
|
4790
4806
|
}
|
|
@@ -4797,17 +4813,13 @@ const returnsString = {
|
|
|
4797
4813
|
};
|
|
4798
4814
|
const stringReplace = {
|
|
4799
4815
|
value: {
|
|
4800
|
-
hasEffectsWhenCalled(
|
|
4801
|
-
const arg1 =
|
|
4802
|
-
return (
|
|
4816
|
+
hasEffectsWhenCalled({ args }, context) {
|
|
4817
|
+
const arg1 = args[1];
|
|
4818
|
+
return (args.length < 2 ||
|
|
4803
4819
|
(typeof arg1.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, {
|
|
4804
4820
|
deoptimizeCache() { }
|
|
4805
4821
|
}) === 'symbol' &&
|
|
4806
|
-
arg1.
|
|
4807
|
-
args: NO_ARGS,
|
|
4808
|
-
thisParam: null,
|
|
4809
|
-
withNew: false
|
|
4810
|
-
}, context)));
|
|
4822
|
+
arg1.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_CALL, context)));
|
|
4811
4823
|
},
|
|
4812
4824
|
returns: UNKNOWN_LITERAL_STRING
|
|
4813
4825
|
}
|
|
@@ -4891,12 +4903,12 @@ function getLiteralMembersForValue(value) {
|
|
|
4891
4903
|
}
|
|
4892
4904
|
return Object.create(null);
|
|
4893
4905
|
}
|
|
4894
|
-
function hasMemberEffectWhenCalled(members, memberName,
|
|
4906
|
+
function hasMemberEffectWhenCalled(members, memberName, interaction, context) {
|
|
4895
4907
|
var _a, _b;
|
|
4896
4908
|
if (typeof memberName !== 'string' || !members[memberName]) {
|
|
4897
4909
|
return true;
|
|
4898
4910
|
}
|
|
4899
|
-
return ((_b = (_a = members[memberName]).hasEffectsWhenCalled) === null || _b === void 0 ? void 0 : _b.call(_a,
|
|
4911
|
+
return ((_b = (_a = members[memberName]).hasEffectsWhenCalled) === null || _b === void 0 ? void 0 : _b.call(_a, interaction, context)) || false;
|
|
4900
4912
|
}
|
|
4901
4913
|
function getMemberReturnExpressionWhenCalled(members, memberName) {
|
|
4902
4914
|
if (typeof memberName !== 'string' || !members[memberName])
|
|
@@ -5335,10 +5347,12 @@ const INCLUDE_PARAMETERS = 'variables';
|
|
|
5335
5347
|
class NodeBase extends ExpressionEntity {
|
|
5336
5348
|
constructor(esTreeNode, parent, parentScope) {
|
|
5337
5349
|
super();
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5350
|
+
/**
|
|
5351
|
+
* Nodes can apply custom deoptimizations once they become part of the
|
|
5352
|
+
* executed code. To do this, they must initialize this as false, implement
|
|
5353
|
+
* applyDeoptimizations and call this from include and hasEffects if they have
|
|
5354
|
+
* custom handlers
|
|
5355
|
+
*/
|
|
5342
5356
|
this.deoptimized = false;
|
|
5343
5357
|
this.esTreeNode = esTreeNode;
|
|
5344
5358
|
this.keys = keys[esTreeNode.type] || getAndCreateKeys(esTreeNode);
|
|
@@ -5394,6 +5408,10 @@ class NodeBase extends ExpressionEntity {
|
|
|
5394
5408
|
}
|
|
5395
5409
|
return false;
|
|
5396
5410
|
}
|
|
5411
|
+
hasEffectsAsAssignmentTarget(context, _checkAccess) {
|
|
5412
|
+
return (this.hasEffects(context) ||
|
|
5413
|
+
this.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.assignmentInteraction, context));
|
|
5414
|
+
}
|
|
5397
5415
|
include(context, includeChildrenRecursively, _options) {
|
|
5398
5416
|
if (!this.deoptimized)
|
|
5399
5417
|
this.applyDeoptimizations();
|
|
@@ -5412,6 +5430,9 @@ class NodeBase extends ExpressionEntity {
|
|
|
5412
5430
|
}
|
|
5413
5431
|
}
|
|
5414
5432
|
}
|
|
5433
|
+
includeAsAssignmentTarget(context, includeChildrenRecursively, _deoptimizeAccess) {
|
|
5434
|
+
this.include(context, includeChildrenRecursively);
|
|
5435
|
+
}
|
|
5415
5436
|
/**
|
|
5416
5437
|
* Override to perform special initialisation steps after the scope is initialised
|
|
5417
5438
|
*/
|
|
@@ -5466,6 +5487,9 @@ class NodeBase extends ExpressionEntity {
|
|
|
5466
5487
|
}
|
|
5467
5488
|
}
|
|
5468
5489
|
}
|
|
5490
|
+
setAssignedValue(value) {
|
|
5491
|
+
this.assignmentInteraction = { args: [value], thisArg: null, type: INTERACTION_ASSIGNED };
|
|
5492
|
+
}
|
|
5469
5493
|
shouldBeIncluded(context) {
|
|
5470
5494
|
return this.included || (!context.brokenFlow && this.hasEffects(createHasEffectsContext()));
|
|
5471
5495
|
}
|
|
@@ -5494,9 +5518,9 @@ class NodeBase extends ExpressionEntity {
|
|
|
5494
5518
|
}
|
|
5495
5519
|
|
|
5496
5520
|
class SpreadElement extends NodeBase {
|
|
5497
|
-
|
|
5521
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
5498
5522
|
if (path.length > 0) {
|
|
5499
|
-
this.argument.
|
|
5523
|
+
this.argument.deoptimizeThisOnInteractionAtPath(interaction, [UnknownKey, ...path], recursionTracker);
|
|
5500
5524
|
}
|
|
5501
5525
|
}
|
|
5502
5526
|
hasEffects(context) {
|
|
@@ -5507,7 +5531,7 @@ class SpreadElement extends NodeBase {
|
|
|
5507
5531
|
return (this.argument.hasEffects(context) ||
|
|
5508
5532
|
(propertyReadSideEffects &&
|
|
5509
5533
|
(propertyReadSideEffects === 'always' ||
|
|
5510
|
-
this.argument.
|
|
5534
|
+
this.argument.hasEffectsOnInteractionAtPath(UNKNOWN_PATH, NODE_INTERACTION_UNKNOWN_ACCESS, context))));
|
|
5511
5535
|
}
|
|
5512
5536
|
applyDeoptimizations() {
|
|
5513
5537
|
this.deoptimized = true;
|
|
@@ -5518,53 +5542,43 @@ class SpreadElement extends NodeBase {
|
|
|
5518
5542
|
}
|
|
5519
5543
|
}
|
|
5520
5544
|
|
|
5521
|
-
const EVENT_ACCESSED = 0;
|
|
5522
|
-
const EVENT_ASSIGNED = 1;
|
|
5523
|
-
const EVENT_CALLED = 2;
|
|
5524
|
-
|
|
5525
5545
|
class Method extends ExpressionEntity {
|
|
5526
5546
|
constructor(description) {
|
|
5527
5547
|
super();
|
|
5528
5548
|
this.description = description;
|
|
5529
5549
|
}
|
|
5530
|
-
|
|
5531
|
-
if (
|
|
5532
|
-
|
|
5550
|
+
deoptimizeThisOnInteractionAtPath({ type, thisArg }, path) {
|
|
5551
|
+
if (type === INTERACTION_CALLED && path.length === 0 && this.description.mutatesSelfAsArray) {
|
|
5552
|
+
thisArg.deoptimizePath(UNKNOWN_INTEGER_PATH);
|
|
5533
5553
|
}
|
|
5534
5554
|
}
|
|
5535
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
5555
|
+
getReturnExpressionWhenCalledAtPath(path, { thisArg }) {
|
|
5536
5556
|
if (path.length > 0) {
|
|
5537
5557
|
return UNKNOWN_EXPRESSION;
|
|
5538
5558
|
}
|
|
5539
5559
|
return (this.description.returnsPrimitive ||
|
|
5540
5560
|
(this.description.returns === 'self'
|
|
5541
|
-
?
|
|
5561
|
+
? thisArg || UNKNOWN_EXPRESSION
|
|
5542
5562
|
: this.description.returns()));
|
|
5543
5563
|
}
|
|
5544
|
-
|
|
5545
|
-
return path.length > 1;
|
|
5546
|
-
}
|
|
5547
|
-
hasEffectsWhenAssignedAtPath(path) {
|
|
5548
|
-
return path.length > 0;
|
|
5549
|
-
}
|
|
5550
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
5564
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5551
5565
|
var _a, _b;
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
((_a = callOptions.thisParam) === null || _a === void 0 ? void 0 : _a.hasEffectsWhenAssignedAtPath(UNKNOWN_INTEGER_PATH, context)))) {
|
|
5566
|
+
const { type } = interaction;
|
|
5567
|
+
if (path.length > (type === INTERACTION_ACCESSED ? 1 : 0)) {
|
|
5555
5568
|
return true;
|
|
5556
5569
|
}
|
|
5557
|
-
if (
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
for (const argIndex of this.description.callsArgs) {
|
|
5561
|
-
if ((_b = callOptions.args[argIndex]) === null || _b === void 0 ? void 0 : _b.hasEffectsWhenCalledAtPath(EMPTY_PATH, {
|
|
5562
|
-
args: NO_ARGS,
|
|
5563
|
-
thisParam: null,
|
|
5564
|
-
withNew: false
|
|
5565
|
-
}, context)) {
|
|
5570
|
+
if (type === INTERACTION_CALLED) {
|
|
5571
|
+
if (this.description.mutatesSelfAsArray === true &&
|
|
5572
|
+
((_a = interaction.thisArg) === null || _a === void 0 ? void 0 : _a.hasEffectsOnInteractionAtPath(UNKNOWN_INTEGER_PATH, NODE_INTERACTION_UNKNOWN_ASSIGNMENT, context))) {
|
|
5566
5573
|
return true;
|
|
5567
5574
|
}
|
|
5575
|
+
if (this.description.callsArgs) {
|
|
5576
|
+
for (const argIndex of this.description.callsArgs) {
|
|
5577
|
+
if ((_b = interaction.args[argIndex]) === null || _b === void 0 ? void 0 : _b.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_CALL, context)) {
|
|
5578
|
+
return true;
|
|
5579
|
+
}
|
|
5580
|
+
}
|
|
5581
|
+
}
|
|
5568
5582
|
}
|
|
5569
5583
|
return false;
|
|
5570
5584
|
}
|
|
@@ -5706,24 +5720,24 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
5706
5720
|
}
|
|
5707
5721
|
(_a = this.prototypeExpression) === null || _a === void 0 ? void 0 : _a.deoptimizePath(path.length === 1 ? [...path, UnknownKey] : path);
|
|
5708
5722
|
}
|
|
5709
|
-
|
|
5723
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
5710
5724
|
var _a;
|
|
5711
5725
|
const [key, ...subPath] = path;
|
|
5712
5726
|
if (this.hasLostTrack ||
|
|
5713
5727
|
// single paths that are deoptimized will not become getters or setters
|
|
5714
|
-
((
|
|
5728
|
+
((interaction.type === INTERACTION_CALLED || path.length > 1) &&
|
|
5715
5729
|
(this.hasUnknownDeoptimizedProperty ||
|
|
5716
5730
|
(typeof key === 'string' && this.deoptimizedPaths[key])))) {
|
|
5717
|
-
|
|
5731
|
+
interaction.thisArg.deoptimizePath(UNKNOWN_PATH);
|
|
5718
5732
|
return;
|
|
5719
5733
|
}
|
|
5720
|
-
const [propertiesForExactMatchByKey, relevantPropertiesByKey, relevantUnmatchableProperties] =
|
|
5734
|
+
const [propertiesForExactMatchByKey, relevantPropertiesByKey, relevantUnmatchableProperties] = interaction.type === INTERACTION_CALLED || path.length > 1
|
|
5721
5735
|
? [
|
|
5722
5736
|
this.propertiesAndGettersByKey,
|
|
5723
5737
|
this.propertiesAndGettersByKey,
|
|
5724
5738
|
this.unmatchablePropertiesAndGetters
|
|
5725
5739
|
]
|
|
5726
|
-
:
|
|
5740
|
+
: interaction.type === INTERACTION_ACCESSED
|
|
5727
5741
|
? [this.propertiesAndGettersByKey, this.gettersByKey, this.unmatchableGetters]
|
|
5728
5742
|
: [this.propertiesAndSettersByKey, this.settersByKey, this.unmatchableSetters];
|
|
5729
5743
|
if (typeof key === 'string') {
|
|
@@ -5731,20 +5745,20 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
5731
5745
|
const properties = relevantPropertiesByKey[key];
|
|
5732
5746
|
if (properties) {
|
|
5733
5747
|
for (const property of properties) {
|
|
5734
|
-
property.
|
|
5748
|
+
property.deoptimizeThisOnInteractionAtPath(interaction, subPath, recursionTracker);
|
|
5735
5749
|
}
|
|
5736
5750
|
}
|
|
5737
5751
|
if (!this.immutable) {
|
|
5738
|
-
this.thisParametersToBeDeoptimized.add(
|
|
5752
|
+
this.thisParametersToBeDeoptimized.add(interaction.thisArg);
|
|
5739
5753
|
}
|
|
5740
5754
|
return;
|
|
5741
5755
|
}
|
|
5742
5756
|
for (const property of relevantUnmatchableProperties) {
|
|
5743
|
-
property.
|
|
5757
|
+
property.deoptimizeThisOnInteractionAtPath(interaction, subPath, recursionTracker);
|
|
5744
5758
|
}
|
|
5745
5759
|
if (INTEGER_REG_EXP.test(key)) {
|
|
5746
5760
|
for (const property of this.unknownIntegerProps) {
|
|
5747
|
-
property.
|
|
5761
|
+
property.deoptimizeThisOnInteractionAtPath(interaction, subPath, recursionTracker);
|
|
5748
5762
|
}
|
|
5749
5763
|
}
|
|
5750
5764
|
}
|
|
@@ -5753,17 +5767,17 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
5753
5767
|
relevantUnmatchableProperties
|
|
5754
5768
|
])) {
|
|
5755
5769
|
for (const property of properties) {
|
|
5756
|
-
property.
|
|
5770
|
+
property.deoptimizeThisOnInteractionAtPath(interaction, subPath, recursionTracker);
|
|
5757
5771
|
}
|
|
5758
5772
|
}
|
|
5759
5773
|
for (const property of this.unknownIntegerProps) {
|
|
5760
|
-
property.
|
|
5774
|
+
property.deoptimizeThisOnInteractionAtPath(interaction, subPath, recursionTracker);
|
|
5761
5775
|
}
|
|
5762
5776
|
}
|
|
5763
5777
|
if (!this.immutable) {
|
|
5764
|
-
this.thisParametersToBeDeoptimized.add(
|
|
5778
|
+
this.thisParametersToBeDeoptimized.add(interaction.thisArg);
|
|
5765
5779
|
}
|
|
5766
|
-
(_a = this.prototypeExpression) === null || _a === void 0 ? void 0 : _a.
|
|
5780
|
+
(_a = this.prototypeExpression) === null || _a === void 0 ? void 0 : _a.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
5767
5781
|
}
|
|
5768
5782
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
5769
5783
|
if (path.length === 0) {
|
|
@@ -5782,79 +5796,29 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
5782
5796
|
}
|
|
5783
5797
|
return UnknownValue;
|
|
5784
5798
|
}
|
|
5785
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
5799
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
5786
5800
|
if (path.length === 0) {
|
|
5787
5801
|
return UNKNOWN_EXPRESSION;
|
|
5788
5802
|
}
|
|
5789
|
-
const key = path
|
|
5803
|
+
const [key, ...subPath] = path;
|
|
5790
5804
|
const expressionAtPath = this.getMemberExpressionAndTrackDeopt(key, origin);
|
|
5791
5805
|
if (expressionAtPath) {
|
|
5792
|
-
return expressionAtPath.getReturnExpressionWhenCalledAtPath(
|
|
5806
|
+
return expressionAtPath.getReturnExpressionWhenCalledAtPath(subPath, interaction, recursionTracker, origin);
|
|
5793
5807
|
}
|
|
5794
5808
|
if (this.prototypeExpression) {
|
|
5795
|
-
return this.prototypeExpression.getReturnExpressionWhenCalledAtPath(path,
|
|
5809
|
+
return this.prototypeExpression.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
5796
5810
|
}
|
|
5797
5811
|
return UNKNOWN_EXPRESSION;
|
|
5798
5812
|
}
|
|
5799
|
-
|
|
5800
|
-
const [key, ...subPath] = path;
|
|
5801
|
-
if (path.length > 1) {
|
|
5802
|
-
if (typeof key !== 'string') {
|
|
5803
|
-
return true;
|
|
5804
|
-
}
|
|
5805
|
-
const expressionAtPath = this.getMemberExpression(key);
|
|
5806
|
-
if (expressionAtPath) {
|
|
5807
|
-
return expressionAtPath.hasEffectsWhenAccessedAtPath(subPath, context);
|
|
5808
|
-
}
|
|
5809
|
-
if (this.prototypeExpression) {
|
|
5810
|
-
return this.prototypeExpression.hasEffectsWhenAccessedAtPath(path, context);
|
|
5811
|
-
}
|
|
5812
|
-
return true;
|
|
5813
|
-
}
|
|
5814
|
-
if (this.hasLostTrack)
|
|
5815
|
-
return true;
|
|
5816
|
-
if (typeof key === 'string') {
|
|
5817
|
-
if (this.propertiesAndGettersByKey[key]) {
|
|
5818
|
-
const getters = this.gettersByKey[key];
|
|
5819
|
-
if (getters) {
|
|
5820
|
-
for (const getter of getters) {
|
|
5821
|
-
if (getter.hasEffectsWhenAccessedAtPath(subPath, context))
|
|
5822
|
-
return true;
|
|
5823
|
-
}
|
|
5824
|
-
}
|
|
5825
|
-
return false;
|
|
5826
|
-
}
|
|
5827
|
-
for (const getter of this.unmatchableGetters) {
|
|
5828
|
-
if (getter.hasEffectsWhenAccessedAtPath(subPath, context)) {
|
|
5829
|
-
return true;
|
|
5830
|
-
}
|
|
5831
|
-
}
|
|
5832
|
-
}
|
|
5833
|
-
else {
|
|
5834
|
-
for (const getters of Object.values(this.gettersByKey).concat([this.unmatchableGetters])) {
|
|
5835
|
-
for (const getter of getters) {
|
|
5836
|
-
if (getter.hasEffectsWhenAccessedAtPath(subPath, context))
|
|
5837
|
-
return true;
|
|
5838
|
-
}
|
|
5839
|
-
}
|
|
5840
|
-
}
|
|
5841
|
-
if (this.prototypeExpression) {
|
|
5842
|
-
return this.prototypeExpression.hasEffectsWhenAccessedAtPath(path, context);
|
|
5843
|
-
}
|
|
5844
|
-
return false;
|
|
5845
|
-
}
|
|
5846
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
5813
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5847
5814
|
const [key, ...subPath] = path;
|
|
5848
|
-
if (
|
|
5849
|
-
if (typeof key !== 'string') {
|
|
5850
|
-
return true;
|
|
5851
|
-
}
|
|
5815
|
+
if (subPath.length || interaction.type === INTERACTION_CALLED) {
|
|
5852
5816
|
const expressionAtPath = this.getMemberExpression(key);
|
|
5853
5817
|
if (expressionAtPath) {
|
|
5854
|
-
return expressionAtPath.
|
|
5818
|
+
return expressionAtPath.hasEffectsOnInteractionAtPath(subPath, interaction, context);
|
|
5855
5819
|
}
|
|
5856
5820
|
if (this.prototypeExpression) {
|
|
5857
|
-
return this.prototypeExpression.
|
|
5821
|
+
return this.prototypeExpression.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
5858
5822
|
}
|
|
5859
5823
|
return true;
|
|
5860
5824
|
}
|
|
@@ -5862,47 +5826,39 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
5862
5826
|
return false;
|
|
5863
5827
|
if (this.hasLostTrack)
|
|
5864
5828
|
return true;
|
|
5829
|
+
const [propertiesAndAccessorsByKey, accessorsByKey, unmatchableAccessors] = interaction.type === INTERACTION_ACCESSED
|
|
5830
|
+
? [this.propertiesAndGettersByKey, this.gettersByKey, this.unmatchableGetters]
|
|
5831
|
+
: [this.propertiesAndSettersByKey, this.settersByKey, this.unmatchableSetters];
|
|
5865
5832
|
if (typeof key === 'string') {
|
|
5866
|
-
if (
|
|
5867
|
-
const
|
|
5868
|
-
if (
|
|
5869
|
-
for (const
|
|
5870
|
-
if (
|
|
5833
|
+
if (propertiesAndAccessorsByKey[key]) {
|
|
5834
|
+
const accessors = accessorsByKey[key];
|
|
5835
|
+
if (accessors) {
|
|
5836
|
+
for (const accessor of accessors) {
|
|
5837
|
+
if (accessor.hasEffectsOnInteractionAtPath(subPath, interaction, context))
|
|
5871
5838
|
return true;
|
|
5872
5839
|
}
|
|
5873
5840
|
}
|
|
5874
5841
|
return false;
|
|
5875
5842
|
}
|
|
5876
|
-
for (const
|
|
5877
|
-
if (
|
|
5843
|
+
for (const accessor of unmatchableAccessors) {
|
|
5844
|
+
if (accessor.hasEffectsOnInteractionAtPath(subPath, interaction, context)) {
|
|
5878
5845
|
return true;
|
|
5879
5846
|
}
|
|
5880
5847
|
}
|
|
5881
5848
|
}
|
|
5882
5849
|
else {
|
|
5883
|
-
for (const
|
|
5884
|
-
for (const
|
|
5885
|
-
if (
|
|
5850
|
+
for (const accessors of Object.values(accessorsByKey).concat([unmatchableAccessors])) {
|
|
5851
|
+
for (const accessor of accessors) {
|
|
5852
|
+
if (accessor.hasEffectsOnInteractionAtPath(subPath, interaction, context))
|
|
5886
5853
|
return true;
|
|
5887
5854
|
}
|
|
5888
5855
|
}
|
|
5889
5856
|
}
|
|
5890
5857
|
if (this.prototypeExpression) {
|
|
5891
|
-
return this.prototypeExpression.
|
|
5858
|
+
return this.prototypeExpression.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
5892
5859
|
}
|
|
5893
5860
|
return false;
|
|
5894
5861
|
}
|
|
5895
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
5896
|
-
const key = path[0];
|
|
5897
|
-
const expressionAtPath = this.getMemberExpression(key);
|
|
5898
|
-
if (expressionAtPath) {
|
|
5899
|
-
return expressionAtPath.hasEffectsWhenCalledAtPath(path.slice(1), callOptions, context);
|
|
5900
|
-
}
|
|
5901
|
-
if (this.prototypeExpression) {
|
|
5902
|
-
return this.prototypeExpression.hasEffectsWhenCalledAtPath(path, callOptions, context);
|
|
5903
|
-
}
|
|
5904
|
-
return true;
|
|
5905
|
-
}
|
|
5906
5862
|
buildPropertyMaps(properties) {
|
|
5907
5863
|
const { allProperties, propertiesAndGettersByKey, propertiesAndSettersByKey, settersByKey, gettersByKey, unknownIntegerProps, unmatchablePropertiesAndGetters, unmatchableGetters, unmatchableSetters } = this;
|
|
5908
5864
|
const unmatchablePropertiesAndSetters = [];
|
|
@@ -6008,9 +5964,9 @@ const isInteger = (prop) => typeof prop === 'string' && /^\d+$/.test(prop);
|
|
|
6008
5964
|
// properties as we do not expect new builtin properties to be numbers, this
|
|
6009
5965
|
// will improve tree-shaking for out-of-bounds array properties
|
|
6010
5966
|
const OBJECT_PROTOTYPE_FALLBACK = new (class ObjectPrototypeFallbackExpression extends ExpressionEntity {
|
|
6011
|
-
|
|
6012
|
-
if (
|
|
6013
|
-
|
|
5967
|
+
deoptimizeThisOnInteractionAtPath({ type, thisArg }, path) {
|
|
5968
|
+
if (type === INTERACTION_CALLED && path.length === 1 && !isInteger(path[0])) {
|
|
5969
|
+
thisArg.deoptimizePath(UNKNOWN_PATH);
|
|
6014
5970
|
}
|
|
6015
5971
|
}
|
|
6016
5972
|
getLiteralValueAtPath(path) {
|
|
@@ -6019,11 +5975,8 @@ const OBJECT_PROTOTYPE_FALLBACK = new (class ObjectPrototypeFallbackExpression e
|
|
|
6019
5975
|
// "undefined"
|
|
6020
5976
|
return path.length === 1 && isInteger(path[0]) ? undefined : UnknownValue;
|
|
6021
5977
|
}
|
|
6022
|
-
|
|
6023
|
-
return path.length > 1;
|
|
6024
|
-
}
|
|
6025
|
-
hasEffectsWhenAssignedAtPath(path) {
|
|
6026
|
-
return path.length > 1;
|
|
5978
|
+
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
5979
|
+
return path.length > 1 || type === INTERACTION_CALLED;
|
|
6027
5980
|
}
|
|
6028
5981
|
})();
|
|
6029
5982
|
const OBJECT_PROTOTYPE = new ObjectEntity({
|
|
@@ -6177,23 +6130,17 @@ class ArrayExpression extends NodeBase {
|
|
|
6177
6130
|
deoptimizePath(path) {
|
|
6178
6131
|
this.getObjectEntity().deoptimizePath(path);
|
|
6179
6132
|
}
|
|
6180
|
-
|
|
6181
|
-
this.getObjectEntity().
|
|
6133
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
6134
|
+
this.getObjectEntity().deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
6182
6135
|
}
|
|
6183
6136
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
6184
6137
|
return this.getObjectEntity().getLiteralValueAtPath(path, recursionTracker, origin);
|
|
6185
6138
|
}
|
|
6186
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
6187
|
-
return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path,
|
|
6139
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
6140
|
+
return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
6188
6141
|
}
|
|
6189
|
-
|
|
6190
|
-
return this.getObjectEntity().
|
|
6191
|
-
}
|
|
6192
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
6193
|
-
return this.getObjectEntity().hasEffectsWhenAssignedAtPath(path, context);
|
|
6194
|
-
}
|
|
6195
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
6196
|
-
return this.getObjectEntity().hasEffectsWhenCalledAtPath(path, callOptions, context);
|
|
6142
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
6143
|
+
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
6197
6144
|
}
|
|
6198
6145
|
applyDeoptimizations() {
|
|
6199
6146
|
this.deoptimized = true;
|
|
@@ -6258,9 +6205,9 @@ class ArrayPattern extends NodeBase {
|
|
|
6258
6205
|
}
|
|
6259
6206
|
}
|
|
6260
6207
|
// Patterns are only checked at the emtpy path at the moment
|
|
6261
|
-
|
|
6208
|
+
hasEffectsOnInteractionAtPath(_path, interaction, context) {
|
|
6262
6209
|
for (const element of this.elements) {
|
|
6263
|
-
if (element === null || element === void 0 ? void 0 : element.
|
|
6210
|
+
if (element === null || element === void 0 ? void 0 : element.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context))
|
|
6264
6211
|
return true;
|
|
6265
6212
|
}
|
|
6266
6213
|
return false;
|
|
@@ -6319,11 +6266,11 @@ class LocalVariable extends Variable {
|
|
|
6319
6266
|
(_b = this.init) === null || _b === void 0 ? void 0 : _b.deoptimizePath(path);
|
|
6320
6267
|
}
|
|
6321
6268
|
}
|
|
6322
|
-
|
|
6269
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
6323
6270
|
if (this.isReassigned || !this.init) {
|
|
6324
|
-
return
|
|
6271
|
+
return interaction.thisArg.deoptimizePath(UNKNOWN_PATH);
|
|
6325
6272
|
}
|
|
6326
|
-
recursionTracker.withTrackedEntityAtPath(path, this.init, () => this.init.
|
|
6273
|
+
recursionTracker.withTrackedEntityAtPath(path, this.init, () => this.init.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker), undefined);
|
|
6327
6274
|
}
|
|
6328
6275
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
6329
6276
|
if (this.isReassigned || !this.init) {
|
|
@@ -6334,39 +6281,40 @@ class LocalVariable extends Variable {
|
|
|
6334
6281
|
return this.init.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
6335
6282
|
}, UnknownValue);
|
|
6336
6283
|
}
|
|
6337
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
6284
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
6338
6285
|
if (this.isReassigned || !this.init) {
|
|
6339
6286
|
return UNKNOWN_EXPRESSION;
|
|
6340
6287
|
}
|
|
6341
6288
|
return recursionTracker.withTrackedEntityAtPath(path, this.init, () => {
|
|
6342
6289
|
this.expressionsToBeDeoptimized.push(origin);
|
|
6343
|
-
return this.init.getReturnExpressionWhenCalledAtPath(path,
|
|
6290
|
+
return this.init.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
6344
6291
|
}, UNKNOWN_EXPRESSION);
|
|
6345
6292
|
}
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6293
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
6294
|
+
switch (interaction.type) {
|
|
6295
|
+
case INTERACTION_ACCESSED:
|
|
6296
|
+
if (this.isReassigned)
|
|
6297
|
+
return true;
|
|
6298
|
+
return (this.init &&
|
|
6299
|
+
!context.accessed.trackEntityAtPathAndGetIfTracked(path, this) &&
|
|
6300
|
+
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
6301
|
+
case INTERACTION_ASSIGNED:
|
|
6302
|
+
if (this.included)
|
|
6303
|
+
return true;
|
|
6304
|
+
if (path.length === 0)
|
|
6305
|
+
return false;
|
|
6306
|
+
if (this.isReassigned)
|
|
6307
|
+
return true;
|
|
6308
|
+
return (this.init &&
|
|
6309
|
+
!context.assigned.trackEntityAtPathAndGetIfTracked(path, this) &&
|
|
6310
|
+
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
6311
|
+
case INTERACTION_CALLED:
|
|
6312
|
+
if (this.isReassigned)
|
|
6313
|
+
return true;
|
|
6314
|
+
return (this.init &&
|
|
6315
|
+
!(interaction.withNew ? context.instantiated : context.called).trackEntityAtPathAndGetIfTracked(path, interaction.args, this) &&
|
|
6316
|
+
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
6317
|
+
}
|
|
6370
6318
|
}
|
|
6371
6319
|
include() {
|
|
6372
6320
|
if (!this.included) {
|
|
@@ -6721,9 +6669,9 @@ const PF = {
|
|
|
6721
6669
|
const MUTATES_ARG_WITHOUT_ACCESSOR = {
|
|
6722
6670
|
__proto__: null,
|
|
6723
6671
|
[ValueProperties]: {
|
|
6724
|
-
hasEffectsWhenCalled(
|
|
6725
|
-
return (!
|
|
6726
|
-
|
|
6672
|
+
hasEffectsWhenCalled({ args }, context) {
|
|
6673
|
+
return (!args.length ||
|
|
6674
|
+
args[0].hasEffectsOnInteractionAtPath(UNKNOWN_NON_ACCESSOR_PATH, NODE_INTERACTION_UNKNOWN_ASSIGNMENT, context));
|
|
6727
6675
|
}
|
|
6728
6676
|
}
|
|
6729
6677
|
};
|
|
@@ -7564,16 +7512,21 @@ class GlobalVariable extends Variable {
|
|
|
7564
7512
|
getLiteralValueAtPath(path, _recursionTracker, _origin) {
|
|
7565
7513
|
return getGlobalAtPath([this.name, ...path]) ? UnknownTruthyValue : UnknownValue;
|
|
7566
7514
|
}
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7515
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
7516
|
+
switch (interaction.type) {
|
|
7517
|
+
case INTERACTION_ACCESSED:
|
|
7518
|
+
if (path.length === 0) {
|
|
7519
|
+
// Technically, "undefined" is a global variable of sorts
|
|
7520
|
+
return this.name !== 'undefined' && !getGlobalAtPath([this.name]);
|
|
7521
|
+
}
|
|
7522
|
+
return !getGlobalAtPath([this.name, ...path].slice(0, -1));
|
|
7523
|
+
case INTERACTION_ASSIGNED:
|
|
7524
|
+
return true;
|
|
7525
|
+
case INTERACTION_CALLED: {
|
|
7526
|
+
const globalAtPath = getGlobalAtPath([this.name, ...path]);
|
|
7527
|
+
return !globalAtPath || globalAtPath.hasEffectsWhenCalled(interaction, context);
|
|
7528
|
+
}
|
|
7571
7529
|
}
|
|
7572
|
-
return !getGlobalAtPath([this.name, ...path].slice(0, -1));
|
|
7573
|
-
}
|
|
7574
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
7575
|
-
const globalAtPath = getGlobalAtPath([this.name, ...path]);
|
|
7576
|
-
return !globalAtPath || globalAtPath.hasEffectsWhenCalled(callOptions, context);
|
|
7577
7530
|
}
|
|
7578
7531
|
}
|
|
7579
7532
|
|
|
@@ -7641,16 +7594,16 @@ class Identifier extends NodeBase {
|
|
|
7641
7594
|
// Identifier as property that might be deoptimized by default
|
|
7642
7595
|
(_a = this.variable) === null || _a === void 0 ? void 0 : _a.deoptimizePath(path);
|
|
7643
7596
|
}
|
|
7644
|
-
|
|
7645
|
-
this.variable.
|
|
7597
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
7598
|
+
this.variable.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
7646
7599
|
}
|
|
7647
7600
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
7648
7601
|
return this.getVariableRespectingTDZ().getLiteralValueAtPath(path, recursionTracker, origin);
|
|
7649
7602
|
}
|
|
7650
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
7651
|
-
return this.getVariableRespectingTDZ().getReturnExpressionWhenCalledAtPath(path,
|
|
7603
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
7604
|
+
return this.getVariableRespectingTDZ().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
7652
7605
|
}
|
|
7653
|
-
hasEffects() {
|
|
7606
|
+
hasEffects(context) {
|
|
7654
7607
|
if (!this.deoptimized)
|
|
7655
7608
|
this.applyDeoptimizations();
|
|
7656
7609
|
if (this.isPossibleTDZ() && this.variable.kind !== 'var') {
|
|
@@ -7658,17 +7611,18 @@ class Identifier extends NodeBase {
|
|
|
7658
7611
|
}
|
|
7659
7612
|
return (this.context.options.treeshake.unknownGlobalSideEffects &&
|
|
7660
7613
|
this.variable instanceof GlobalVariable &&
|
|
7661
|
-
this.variable.
|
|
7662
|
-
}
|
|
7663
|
-
hasEffectsWhenAccessedAtPath(path, context) {
|
|
7664
|
-
return (this.variable !== null &&
|
|
7665
|
-
this.getVariableRespectingTDZ().hasEffectsWhenAccessedAtPath(path, context));
|
|
7614
|
+
this.variable.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_ACCESS, context));
|
|
7666
7615
|
}
|
|
7667
|
-
|
|
7668
|
-
|
|
7669
|
-
|
|
7670
|
-
|
|
7671
|
-
|
|
7616
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
7617
|
+
switch (interaction.type) {
|
|
7618
|
+
case INTERACTION_ACCESSED:
|
|
7619
|
+
return (this.variable !== null &&
|
|
7620
|
+
this.getVariableRespectingTDZ().hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
7621
|
+
case INTERACTION_ASSIGNED:
|
|
7622
|
+
return (path.length > 0 ? this.getVariableRespectingTDZ() : this.variable).hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
7623
|
+
case INTERACTION_CALLED:
|
|
7624
|
+
return this.getVariableRespectingTDZ().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
7625
|
+
}
|
|
7672
7626
|
}
|
|
7673
7627
|
include() {
|
|
7674
7628
|
if (!this.deoptimized)
|
|
@@ -8028,8 +7982,9 @@ class RestElement extends NodeBase {
|
|
|
8028
7982
|
deoptimizePath(path) {
|
|
8029
7983
|
path.length === 0 && this.argument.deoptimizePath(EMPTY_PATH);
|
|
8030
7984
|
}
|
|
8031
|
-
|
|
8032
|
-
return path.length > 0 ||
|
|
7985
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
7986
|
+
return (path.length > 0 ||
|
|
7987
|
+
this.argument.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context));
|
|
8033
7988
|
}
|
|
8034
7989
|
markDeclarationReached() {
|
|
8035
7990
|
this.argument.markDeclarationReached();
|
|
@@ -8057,17 +8012,17 @@ class FunctionBase extends NodeBase {
|
|
|
8057
8012
|
this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH);
|
|
8058
8013
|
}
|
|
8059
8014
|
}
|
|
8060
|
-
|
|
8015
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
8061
8016
|
if (path.length > 0) {
|
|
8062
|
-
this.getObjectEntity().
|
|
8017
|
+
this.getObjectEntity().deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
8063
8018
|
}
|
|
8064
8019
|
}
|
|
8065
8020
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
8066
8021
|
return this.getObjectEntity().getLiteralValueAtPath(path, recursionTracker, origin);
|
|
8067
8022
|
}
|
|
8068
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
8023
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
8069
8024
|
if (path.length > 0) {
|
|
8070
|
-
return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path,
|
|
8025
|
+
return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
8071
8026
|
}
|
|
8072
8027
|
if (this.async) {
|
|
8073
8028
|
if (!this.deoptimizedReturn) {
|
|
@@ -8079,24 +8034,18 @@ class FunctionBase extends NodeBase {
|
|
|
8079
8034
|
}
|
|
8080
8035
|
return this.scope.getReturnExpression();
|
|
8081
8036
|
}
|
|
8082
|
-
|
|
8083
|
-
|
|
8084
|
-
|
|
8085
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
8086
|
-
return this.getObjectEntity().hasEffectsWhenAssignedAtPath(path, context);
|
|
8087
|
-
}
|
|
8088
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
8089
|
-
if (path.length > 0) {
|
|
8090
|
-
return this.getObjectEntity().hasEffectsWhenCalledAtPath(path, callOptions, context);
|
|
8037
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8038
|
+
if (path.length > 0 || interaction.type !== INTERACTION_CALLED) {
|
|
8039
|
+
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
8091
8040
|
}
|
|
8092
8041
|
if (this.async) {
|
|
8093
8042
|
const { propertyReadSideEffects } = this.context.options
|
|
8094
8043
|
.treeshake;
|
|
8095
8044
|
const returnExpression = this.scope.getReturnExpression();
|
|
8096
|
-
if (returnExpression.
|
|
8045
|
+
if (returnExpression.hasEffectsOnInteractionAtPath(['then'], NODE_INTERACTION_UNKNOWN_CALL, context) ||
|
|
8097
8046
|
(propertyReadSideEffects &&
|
|
8098
8047
|
(propertyReadSideEffects === 'always' ||
|
|
8099
|
-
returnExpression.
|
|
8048
|
+
returnExpression.hasEffectsOnInteractionAtPath(['then'], NODE_INTERACTION_UNKNOWN_ACCESS, context)))) {
|
|
8100
8049
|
return true;
|
|
8101
8050
|
}
|
|
8102
8051
|
}
|
|
@@ -8150,20 +8099,22 @@ class ArrowFunctionExpression extends FunctionBase {
|
|
|
8150
8099
|
this.applyDeoptimizations();
|
|
8151
8100
|
return false;
|
|
8152
8101
|
}
|
|
8153
|
-
|
|
8154
|
-
if (super.
|
|
8102
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8103
|
+
if (super.hasEffectsOnInteractionAtPath(path, interaction, context))
|
|
8155
8104
|
return true;
|
|
8156
|
-
|
|
8157
|
-
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
8161
|
-
|
|
8162
|
-
|
|
8163
|
-
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
|
|
8105
|
+
if (interaction.type === INTERACTION_CALLED) {
|
|
8106
|
+
const { ignore, brokenFlow } = context;
|
|
8107
|
+
context.ignore = {
|
|
8108
|
+
breaks: false,
|
|
8109
|
+
continues: false,
|
|
8110
|
+
labels: new Set(),
|
|
8111
|
+
returnYield: true
|
|
8112
|
+
};
|
|
8113
|
+
if (this.body.hasEffects(context))
|
|
8114
|
+
return true;
|
|
8115
|
+
context.ignore = ignore;
|
|
8116
|
+
context.brokenFlow = brokenFlow;
|
|
8117
|
+
}
|
|
8167
8118
|
return false;
|
|
8168
8119
|
}
|
|
8169
8120
|
include(context, includeChildrenRecursively) {
|
|
@@ -8249,11 +8200,12 @@ class ObjectPattern extends NodeBase {
|
|
|
8249
8200
|
}
|
|
8250
8201
|
}
|
|
8251
8202
|
}
|
|
8252
|
-
|
|
8253
|
-
|
|
8254
|
-
|
|
8203
|
+
hasEffectsOnInteractionAtPath(
|
|
8204
|
+
// At the moment, this is only triggered for assignment left-hand sides,
|
|
8205
|
+
// where the path is empty
|
|
8206
|
+
_path, interaction, context) {
|
|
8255
8207
|
for (const property of this.properties) {
|
|
8256
|
-
if (property.
|
|
8208
|
+
if (property.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context))
|
|
8257
8209
|
return true;
|
|
8258
8210
|
}
|
|
8259
8211
|
return false;
|
|
@@ -8267,75 +8219,78 @@ class ObjectPattern extends NodeBase {
|
|
|
8267
8219
|
|
|
8268
8220
|
class AssignmentExpression extends NodeBase {
|
|
8269
8221
|
hasEffects(context) {
|
|
8270
|
-
|
|
8222
|
+
const { deoptimized, left, right } = this;
|
|
8223
|
+
if (!deoptimized)
|
|
8271
8224
|
this.applyDeoptimizations();
|
|
8272
|
-
|
|
8273
|
-
|
|
8274
|
-
|
|
8225
|
+
// MemberExpressions do not access the property before assignments if the
|
|
8226
|
+
// operator is '='.
|
|
8227
|
+
return (right.hasEffects(context) || left.hasEffectsAsAssignmentTarget(context, this.operator !== '='));
|
|
8275
8228
|
}
|
|
8276
|
-
|
|
8277
|
-
return
|
|
8229
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8230
|
+
return this.right.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
8278
8231
|
}
|
|
8279
8232
|
include(context, includeChildrenRecursively) {
|
|
8280
|
-
|
|
8233
|
+
const { deoptimized, left, right, operator } = this;
|
|
8234
|
+
if (!deoptimized)
|
|
8281
8235
|
this.applyDeoptimizations();
|
|
8282
8236
|
this.included = true;
|
|
8283
|
-
let hasEffectsContext;
|
|
8284
8237
|
if (includeChildrenRecursively ||
|
|
8285
|
-
|
|
8286
|
-
|
|
8287
|
-
(
|
|
8288
|
-
|
|
8289
|
-
this.left.hasEffectsWhenAssignedAtPath(EMPTY_PATH, hasEffectsContext))) {
|
|
8290
|
-
this.left.include(context, includeChildrenRecursively);
|
|
8238
|
+
operator !== '=' ||
|
|
8239
|
+
left.included ||
|
|
8240
|
+
left.hasEffectsAsAssignmentTarget(createHasEffectsContext(), false)) {
|
|
8241
|
+
left.includeAsAssignmentTarget(context, includeChildrenRecursively, operator !== '=');
|
|
8291
8242
|
}
|
|
8292
|
-
|
|
8243
|
+
right.include(context, includeChildrenRecursively);
|
|
8244
|
+
}
|
|
8245
|
+
initialise() {
|
|
8246
|
+
this.left.setAssignedValue(this.right);
|
|
8293
8247
|
}
|
|
8294
8248
|
render(code, options, { preventASI, renderedParentType, renderedSurroundingElement } = BLANK) {
|
|
8295
|
-
|
|
8296
|
-
|
|
8297
|
-
|
|
8249
|
+
const { left, right, start, end, parent } = this;
|
|
8250
|
+
if (left.included) {
|
|
8251
|
+
left.render(code, options);
|
|
8252
|
+
right.render(code, options);
|
|
8298
8253
|
}
|
|
8299
8254
|
else {
|
|
8300
|
-
const inclusionStart = findNonWhiteSpace(code.original, findFirstOccurrenceOutsideComment(code.original, '=',
|
|
8301
|
-
code.remove(
|
|
8255
|
+
const inclusionStart = findNonWhiteSpace(code.original, findFirstOccurrenceOutsideComment(code.original, '=', left.end) + 1);
|
|
8256
|
+
code.remove(start, inclusionStart);
|
|
8302
8257
|
if (preventASI) {
|
|
8303
|
-
removeLineBreaks(code, inclusionStart,
|
|
8258
|
+
removeLineBreaks(code, inclusionStart, right.start);
|
|
8304
8259
|
}
|
|
8305
|
-
|
|
8306
|
-
renderedParentType: renderedParentType ||
|
|
8307
|
-
renderedSurroundingElement: renderedSurroundingElement ||
|
|
8260
|
+
right.render(code, options, {
|
|
8261
|
+
renderedParentType: renderedParentType || parent.type,
|
|
8262
|
+
renderedSurroundingElement: renderedSurroundingElement || parent.type
|
|
8308
8263
|
});
|
|
8309
8264
|
}
|
|
8310
8265
|
if (options.format === 'system') {
|
|
8311
|
-
if (
|
|
8312
|
-
const variable =
|
|
8266
|
+
if (left instanceof Identifier) {
|
|
8267
|
+
const variable = left.variable;
|
|
8313
8268
|
const exportNames = options.exportNamesByVariable.get(variable);
|
|
8314
8269
|
if (exportNames) {
|
|
8315
8270
|
if (exportNames.length === 1) {
|
|
8316
|
-
renderSystemExportExpression(variable,
|
|
8271
|
+
renderSystemExportExpression(variable, start, end, code, options);
|
|
8317
8272
|
}
|
|
8318
8273
|
else {
|
|
8319
|
-
renderSystemExportSequenceAfterExpression(variable,
|
|
8274
|
+
renderSystemExportSequenceAfterExpression(variable, start, end, parent.type !== ExpressionStatement$1, code, options);
|
|
8320
8275
|
}
|
|
8321
8276
|
return;
|
|
8322
8277
|
}
|
|
8323
8278
|
}
|
|
8324
8279
|
else {
|
|
8325
8280
|
const systemPatternExports = [];
|
|
8326
|
-
|
|
8281
|
+
left.addExportedVariables(systemPatternExports, options.exportNamesByVariable);
|
|
8327
8282
|
if (systemPatternExports.length > 0) {
|
|
8328
|
-
renderSystemExportFunction(systemPatternExports,
|
|
8283
|
+
renderSystemExportFunction(systemPatternExports, start, end, renderedSurroundingElement === ExpressionStatement$1, code, options);
|
|
8329
8284
|
return;
|
|
8330
8285
|
}
|
|
8331
8286
|
}
|
|
8332
8287
|
}
|
|
8333
|
-
if (
|
|
8334
|
-
|
|
8288
|
+
if (left.included &&
|
|
8289
|
+
left instanceof ObjectPattern &&
|
|
8335
8290
|
(renderedSurroundingElement === ExpressionStatement$1 ||
|
|
8336
8291
|
renderedSurroundingElement === ArrowFunctionExpression$1)) {
|
|
8337
|
-
code.appendRight(
|
|
8338
|
-
code.prependLeft(
|
|
8292
|
+
code.appendRight(start, '(');
|
|
8293
|
+
code.prependLeft(end, ')');
|
|
8339
8294
|
}
|
|
8340
8295
|
}
|
|
8341
8296
|
applyDeoptimizations() {
|
|
@@ -8356,27 +8311,15 @@ class AssignmentPattern extends NodeBase {
|
|
|
8356
8311
|
deoptimizePath(path) {
|
|
8357
8312
|
path.length === 0 && this.left.deoptimizePath(path);
|
|
8358
8313
|
}
|
|
8359
|
-
|
|
8360
|
-
return path.length > 0 || this.left.
|
|
8361
|
-
}
|
|
8362
|
-
include(context, includeChildrenRecursively) {
|
|
8363
|
-
if (!this.deoptimized)
|
|
8364
|
-
this.applyDeoptimizations();
|
|
8365
|
-
this.included = true;
|
|
8366
|
-
this.left.include(context, includeChildrenRecursively);
|
|
8367
|
-
this.right.include(context, includeChildrenRecursively);
|
|
8314
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8315
|
+
return (path.length > 0 || this.left.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context));
|
|
8368
8316
|
}
|
|
8369
8317
|
markDeclarationReached() {
|
|
8370
8318
|
this.left.markDeclarationReached();
|
|
8371
8319
|
}
|
|
8372
8320
|
render(code, options, { isShorthandProperty } = BLANK) {
|
|
8373
8321
|
this.left.render(code, options, { isShorthandProperty });
|
|
8374
|
-
|
|
8375
|
-
this.right.render(code, options);
|
|
8376
|
-
}
|
|
8377
|
-
else {
|
|
8378
|
-
code.remove(this.left.end, this.end);
|
|
8379
|
-
}
|
|
8322
|
+
this.right.render(code, options);
|
|
8380
8323
|
}
|
|
8381
8324
|
applyDeoptimizations() {
|
|
8382
8325
|
this.deoptimized = true;
|
|
@@ -8390,14 +8333,8 @@ class ArgumentsVariable extends LocalVariable {
|
|
|
8390
8333
|
constructor(context) {
|
|
8391
8334
|
super('arguments', null, UNKNOWN_EXPRESSION, context);
|
|
8392
8335
|
}
|
|
8393
|
-
|
|
8394
|
-
return path.length > 1;
|
|
8395
|
-
}
|
|
8396
|
-
hasEffectsWhenAssignedAtPath() {
|
|
8397
|
-
return true;
|
|
8398
|
-
}
|
|
8399
|
-
hasEffectsWhenCalledAtPath() {
|
|
8400
|
-
return true;
|
|
8336
|
+
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
8337
|
+
return type !== INTERACTION_ACCESSED || path.length > 1;
|
|
8401
8338
|
}
|
|
8402
8339
|
}
|
|
8403
8340
|
|
|
@@ -8413,8 +8350,8 @@ class ThisVariable extends LocalVariable {
|
|
|
8413
8350
|
for (const path of this.deoptimizedPaths) {
|
|
8414
8351
|
entity.deoptimizePath(path);
|
|
8415
8352
|
}
|
|
8416
|
-
for (const
|
|
8417
|
-
|
|
8353
|
+
for (const { interaction, path } of this.thisDeoptimizationList) {
|
|
8354
|
+
entity.deoptimizeThisOnInteractionAtPath(interaction, path, SHARED_RECURSION_TRACKER);
|
|
8418
8355
|
}
|
|
8419
8356
|
this.entitiesToBeDeoptimized.add(entity);
|
|
8420
8357
|
}
|
|
@@ -8428,29 +8365,21 @@ class ThisVariable extends LocalVariable {
|
|
|
8428
8365
|
entity.deoptimizePath(path);
|
|
8429
8366
|
}
|
|
8430
8367
|
}
|
|
8431
|
-
|
|
8368
|
+
deoptimizeThisOnInteractionAtPath(interaction, path) {
|
|
8432
8369
|
const thisDeoptimization = {
|
|
8433
|
-
|
|
8434
|
-
path
|
|
8435
|
-
thisParameter
|
|
8370
|
+
interaction,
|
|
8371
|
+
path
|
|
8436
8372
|
};
|
|
8437
|
-
if (!this.thisDeoptimizations.trackEntityAtPathAndGetIfTracked(path,
|
|
8373
|
+
if (!this.thisDeoptimizations.trackEntityAtPathAndGetIfTracked(path, interaction.type, interaction.thisArg)) {
|
|
8438
8374
|
for (const entity of this.entitiesToBeDeoptimized) {
|
|
8439
|
-
|
|
8375
|
+
entity.deoptimizeThisOnInteractionAtPath(interaction, path, SHARED_RECURSION_TRACKER);
|
|
8440
8376
|
}
|
|
8441
8377
|
this.thisDeoptimizationList.push(thisDeoptimization);
|
|
8442
8378
|
}
|
|
8443
8379
|
}
|
|
8444
|
-
|
|
8445
|
-
return (this.getInit(context).
|
|
8446
|
-
super.
|
|
8447
|
-
}
|
|
8448
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
8449
|
-
return (this.getInit(context).hasEffectsWhenAssignedAtPath(path, context) ||
|
|
8450
|
-
super.hasEffectsWhenAssignedAtPath(path, context));
|
|
8451
|
-
}
|
|
8452
|
-
applyThisDeoptimizationEvent(entity, { event, path, thisParameter }) {
|
|
8453
|
-
entity.deoptimizeThisOnEventAtPath(event, path, thisParameter === this ? entity : thisParameter, SHARED_RECURSION_TRACKER);
|
|
8380
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8381
|
+
return (this.getInit(context).hasEffectsOnInteractionAtPath(path, interaction, context) ||
|
|
8382
|
+
super.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
8454
8383
|
}
|
|
8455
8384
|
getInit(context) {
|
|
8456
8385
|
return context.replacedVariableInits.get(this) || UNKNOWN_EXPRESSION;
|
|
@@ -8486,42 +8415,44 @@ class FunctionNode extends FunctionBase {
|
|
|
8486
8415
|
createScope(parentScope) {
|
|
8487
8416
|
this.scope = new FunctionScope(parentScope, this.context);
|
|
8488
8417
|
}
|
|
8489
|
-
|
|
8490
|
-
super.
|
|
8491
|
-
if (
|
|
8492
|
-
this.scope.thisVariable.addEntityToBeDeoptimized(
|
|
8418
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
8419
|
+
super.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
8420
|
+
if (interaction.type === INTERACTION_CALLED && path.length === 0) {
|
|
8421
|
+
this.scope.thisVariable.addEntityToBeDeoptimized(interaction.thisArg);
|
|
8493
8422
|
}
|
|
8494
8423
|
}
|
|
8495
|
-
hasEffects() {
|
|
8424
|
+
hasEffects(context) {
|
|
8496
8425
|
var _a;
|
|
8497
8426
|
if (!this.deoptimized)
|
|
8498
8427
|
this.applyDeoptimizations();
|
|
8499
|
-
return !!((_a = this.id) === null || _a === void 0 ? void 0 : _a.hasEffects());
|
|
8428
|
+
return !!((_a = this.id) === null || _a === void 0 ? void 0 : _a.hasEffects(context));
|
|
8500
8429
|
}
|
|
8501
|
-
|
|
8502
|
-
if (super.
|
|
8430
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8431
|
+
if (super.hasEffectsOnInteractionAtPath(path, interaction, context))
|
|
8503
8432
|
return true;
|
|
8504
|
-
|
|
8505
|
-
|
|
8506
|
-
|
|
8507
|
-
|
|
8508
|
-
|
|
8509
|
-
|
|
8510
|
-
|
|
8511
|
-
|
|
8512
|
-
|
|
8513
|
-
|
|
8514
|
-
|
|
8515
|
-
|
|
8516
|
-
|
|
8517
|
-
|
|
8518
|
-
|
|
8519
|
-
|
|
8520
|
-
|
|
8521
|
-
|
|
8522
|
-
|
|
8433
|
+
if (interaction.type === INTERACTION_CALLED) {
|
|
8434
|
+
const thisInit = context.replacedVariableInits.get(this.scope.thisVariable);
|
|
8435
|
+
context.replacedVariableInits.set(this.scope.thisVariable, interaction.withNew
|
|
8436
|
+
? new ObjectEntity(Object.create(null), OBJECT_PROTOTYPE)
|
|
8437
|
+
: UNKNOWN_EXPRESSION);
|
|
8438
|
+
const { brokenFlow, ignore } = context;
|
|
8439
|
+
context.ignore = {
|
|
8440
|
+
breaks: false,
|
|
8441
|
+
continues: false,
|
|
8442
|
+
labels: new Set(),
|
|
8443
|
+
returnYield: true
|
|
8444
|
+
};
|
|
8445
|
+
if (this.body.hasEffects(context))
|
|
8446
|
+
return true;
|
|
8447
|
+
context.brokenFlow = brokenFlow;
|
|
8448
|
+
if (thisInit) {
|
|
8449
|
+
context.replacedVariableInits.set(this.scope.thisVariable, thisInit);
|
|
8450
|
+
}
|
|
8451
|
+
else {
|
|
8452
|
+
context.replacedVariableInits.delete(this.scope.thisVariable);
|
|
8453
|
+
}
|
|
8454
|
+
context.ignore = ignore;
|
|
8523
8455
|
}
|
|
8524
|
-
context.ignore = ignore;
|
|
8525
8456
|
return false;
|
|
8526
8457
|
}
|
|
8527
8458
|
include(context, includeChildrenRecursively) {
|
|
@@ -8628,8 +8559,8 @@ class BinaryExpression extends NodeBase {
|
|
|
8628
8559
|
return true;
|
|
8629
8560
|
return super.hasEffects(context);
|
|
8630
8561
|
}
|
|
8631
|
-
|
|
8632
|
-
return path.length > 1;
|
|
8562
|
+
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
8563
|
+
return type !== INTERACTION_ACCESSED || path.length > 1;
|
|
8633
8564
|
}
|
|
8634
8565
|
render(code, options, { renderedSurroundingElement } = BLANK) {
|
|
8635
8566
|
this.left.render(code, options, { renderedSurroundingElement });
|
|
@@ -8688,7 +8619,7 @@ function renderCallArguments(code, options, node) {
|
|
|
8688
8619
|
}
|
|
8689
8620
|
|
|
8690
8621
|
class Literal extends NodeBase {
|
|
8691
|
-
|
|
8622
|
+
deoptimizeThisOnInteractionAtPath() { }
|
|
8692
8623
|
getLiteralValueAtPath(path) {
|
|
8693
8624
|
if (path.length > 0 ||
|
|
8694
8625
|
// unknown literals can also be null but do not start with an "n"
|
|
@@ -8705,17 +8636,16 @@ class Literal extends NodeBase {
|
|
|
8705
8636
|
return UNKNOWN_EXPRESSION;
|
|
8706
8637
|
return getMemberReturnExpressionWhenCalled(this.members, path[0]);
|
|
8707
8638
|
}
|
|
8708
|
-
|
|
8709
|
-
|
|
8710
|
-
|
|
8711
|
-
|
|
8712
|
-
|
|
8713
|
-
|
|
8714
|
-
|
|
8715
|
-
|
|
8716
|
-
|
|
8639
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8640
|
+
switch (interaction.type) {
|
|
8641
|
+
case INTERACTION_ACCESSED:
|
|
8642
|
+
return path.length > (this.value === null ? 0 : 1);
|
|
8643
|
+
case INTERACTION_ASSIGNED:
|
|
8644
|
+
return true;
|
|
8645
|
+
case INTERACTION_CALLED:
|
|
8646
|
+
return (path.length !== 1 ||
|
|
8647
|
+
hasMemberEffectWhenCalled(this.members, path[0], interaction, context));
|
|
8717
8648
|
}
|
|
8718
|
-
return true;
|
|
8719
8649
|
}
|
|
8720
8650
|
initialise() {
|
|
8721
8651
|
this.members = getLiteralMembersForValue(this.value);
|
|
@@ -8773,6 +8703,7 @@ class MemberExpression extends NodeBase {
|
|
|
8773
8703
|
constructor() {
|
|
8774
8704
|
super(...arguments);
|
|
8775
8705
|
this.variable = null;
|
|
8706
|
+
this.assignmentDeoptimized = false;
|
|
8776
8707
|
this.bound = false;
|
|
8777
8708
|
this.expressionsToBeDeoptimized = [];
|
|
8778
8709
|
this.replacement = null;
|
|
@@ -8782,7 +8713,7 @@ class MemberExpression extends NodeBase {
|
|
|
8782
8713
|
const path = getPathIfNotComputed(this);
|
|
8783
8714
|
const baseVariable = path && this.scope.findVariable(path[0].key);
|
|
8784
8715
|
if (baseVariable && baseVariable.isNamespace) {
|
|
8785
|
-
const resolvedVariable =
|
|
8716
|
+
const resolvedVariable = resolveNamespaceVariables(baseVariable, path.slice(1), this.context);
|
|
8786
8717
|
if (!resolvedVariable) {
|
|
8787
8718
|
super.bind();
|
|
8788
8719
|
}
|
|
@@ -8823,21 +8754,21 @@ class MemberExpression extends NodeBase {
|
|
|
8823
8754
|
}
|
|
8824
8755
|
}
|
|
8825
8756
|
}
|
|
8826
|
-
|
|
8757
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
8827
8758
|
if (this.variable) {
|
|
8828
|
-
this.variable.
|
|
8759
|
+
this.variable.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
8829
8760
|
}
|
|
8830
8761
|
else if (!this.replacement) {
|
|
8831
8762
|
if (path.length < MAX_PATH_DEPTH) {
|
|
8832
|
-
this.object.
|
|
8763
|
+
this.object.deoptimizeThisOnInteractionAtPath(interaction, [this.getPropertyKey(), ...path], recursionTracker);
|
|
8833
8764
|
}
|
|
8834
8765
|
else {
|
|
8835
|
-
|
|
8766
|
+
interaction.thisArg.deoptimizePath(UNKNOWN_PATH);
|
|
8836
8767
|
}
|
|
8837
8768
|
}
|
|
8838
8769
|
}
|
|
8839
8770
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
8840
|
-
if (this.variable
|
|
8771
|
+
if (this.variable) {
|
|
8841
8772
|
return this.variable.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
8842
8773
|
}
|
|
8843
8774
|
if (this.replacement) {
|
|
@@ -8849,81 +8780,62 @@ class MemberExpression extends NodeBase {
|
|
|
8849
8780
|
}
|
|
8850
8781
|
return UnknownValue;
|
|
8851
8782
|
}
|
|
8852
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
8853
|
-
if (this.variable
|
|
8854
|
-
return this.variable.getReturnExpressionWhenCalledAtPath(path,
|
|
8783
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
8784
|
+
if (this.variable) {
|
|
8785
|
+
return this.variable.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
8855
8786
|
}
|
|
8856
8787
|
if (this.replacement) {
|
|
8857
8788
|
return UNKNOWN_EXPRESSION;
|
|
8858
8789
|
}
|
|
8859
8790
|
this.expressionsToBeDeoptimized.push(origin);
|
|
8860
8791
|
if (path.length < MAX_PATH_DEPTH) {
|
|
8861
|
-
return this.object.getReturnExpressionWhenCalledAtPath([this.getPropertyKey(), ...path],
|
|
8792
|
+
return this.object.getReturnExpressionWhenCalledAtPath([this.getPropertyKey(), ...path], interaction, recursionTracker, origin);
|
|
8862
8793
|
}
|
|
8863
8794
|
return UNKNOWN_EXPRESSION;
|
|
8864
8795
|
}
|
|
8865
8796
|
hasEffects(context) {
|
|
8866
8797
|
if (!this.deoptimized)
|
|
8867
8798
|
this.applyDeoptimizations();
|
|
8868
|
-
const { propertyReadSideEffects } = this.context.options
|
|
8869
|
-
.treeshake;
|
|
8870
8799
|
return (this.property.hasEffects(context) ||
|
|
8871
8800
|
this.object.hasEffects(context) ||
|
|
8872
|
-
|
|
8873
|
-
(!(this.variable ||
|
|
8874
|
-
this.replacement ||
|
|
8875
|
-
(this.parent instanceof AssignmentExpression && this.parent.operator === '=')) &&
|
|
8876
|
-
propertyReadSideEffects &&
|
|
8877
|
-
(propertyReadSideEffects === 'always' ||
|
|
8878
|
-
this.object.hasEffectsWhenAccessedAtPath([this.getPropertyKey()], context))));
|
|
8801
|
+
this.hasAccessEffect(context));
|
|
8879
8802
|
}
|
|
8880
|
-
|
|
8881
|
-
if (this.
|
|
8882
|
-
|
|
8883
|
-
|
|
8884
|
-
|
|
8885
|
-
|
|
8886
|
-
|
|
8887
|
-
|
|
8888
|
-
|
|
8889
|
-
}
|
|
8890
|
-
return true;
|
|
8891
|
-
}
|
|
8892
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
8893
|
-
if (this.variable !== null) {
|
|
8894
|
-
return this.variable.hasEffectsWhenAssignedAtPath(path, context);
|
|
8895
|
-
}
|
|
8896
|
-
if (this.replacement) {
|
|
8897
|
-
return true;
|
|
8898
|
-
}
|
|
8899
|
-
if (path.length < MAX_PATH_DEPTH) {
|
|
8900
|
-
return this.object.hasEffectsWhenAssignedAtPath([this.getPropertyKey(), ...path], context);
|
|
8901
|
-
}
|
|
8902
|
-
return true;
|
|
8803
|
+
hasEffectsAsAssignmentTarget(context, checkAccess) {
|
|
8804
|
+
if (checkAccess && !this.deoptimized)
|
|
8805
|
+
this.applyDeoptimizations();
|
|
8806
|
+
if (!this.assignmentDeoptimized)
|
|
8807
|
+
this.applyAssignmentDeoptimization();
|
|
8808
|
+
return (this.property.hasEffects(context) ||
|
|
8809
|
+
this.object.hasEffects(context) ||
|
|
8810
|
+
(checkAccess && this.hasAccessEffect(context)) ||
|
|
8811
|
+
this.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.assignmentInteraction, context));
|
|
8903
8812
|
}
|
|
8904
|
-
|
|
8905
|
-
if (this.variable
|
|
8906
|
-
return this.variable.
|
|
8813
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8814
|
+
if (this.variable) {
|
|
8815
|
+
return this.variable.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
8907
8816
|
}
|
|
8908
8817
|
if (this.replacement) {
|
|
8909
8818
|
return true;
|
|
8910
8819
|
}
|
|
8911
8820
|
if (path.length < MAX_PATH_DEPTH) {
|
|
8912
|
-
return this.object.
|
|
8821
|
+
return this.object.hasEffectsOnInteractionAtPath([this.getPropertyKey(), ...path], interaction, context);
|
|
8913
8822
|
}
|
|
8914
8823
|
return true;
|
|
8915
8824
|
}
|
|
8916
8825
|
include(context, includeChildrenRecursively) {
|
|
8917
8826
|
if (!this.deoptimized)
|
|
8918
8827
|
this.applyDeoptimizations();
|
|
8919
|
-
|
|
8920
|
-
|
|
8921
|
-
|
|
8922
|
-
|
|
8923
|
-
|
|
8828
|
+
this.includeProperties(context, includeChildrenRecursively);
|
|
8829
|
+
}
|
|
8830
|
+
includeAsAssignmentTarget(context, includeChildrenRecursively, deoptimizeAccess) {
|
|
8831
|
+
if (!this.assignmentDeoptimized)
|
|
8832
|
+
this.applyAssignmentDeoptimization();
|
|
8833
|
+
if (deoptimizeAccess) {
|
|
8834
|
+
this.include(context, includeChildrenRecursively);
|
|
8835
|
+
}
|
|
8836
|
+
else {
|
|
8837
|
+
this.includeProperties(context, includeChildrenRecursively);
|
|
8924
8838
|
}
|
|
8925
|
-
this.object.include(context, includeChildrenRecursively);
|
|
8926
|
-
this.property.include(context, includeChildrenRecursively);
|
|
8927
8839
|
}
|
|
8928
8840
|
includeCallArguments(context, args) {
|
|
8929
8841
|
if (this.variable) {
|
|
@@ -8935,6 +8847,7 @@ class MemberExpression extends NodeBase {
|
|
|
8935
8847
|
}
|
|
8936
8848
|
initialise() {
|
|
8937
8849
|
this.propertyKey = getResolvablePropertyKey(this);
|
|
8850
|
+
this.accessInteraction = { thisArg: this.object, type: INTERACTION_ACCESSED };
|
|
8938
8851
|
}
|
|
8939
8852
|
render(code, options, { renderedParentType, isCalleeOfRenderedParent, renderedSurroundingElement } = BLANK) {
|
|
8940
8853
|
if (this.variable || this.replacement) {
|
|
@@ -8955,6 +8868,13 @@ class MemberExpression extends NodeBase {
|
|
|
8955
8868
|
this.property.render(code, options);
|
|
8956
8869
|
}
|
|
8957
8870
|
}
|
|
8871
|
+
setAssignedValue(value) {
|
|
8872
|
+
this.assignmentInteraction = {
|
|
8873
|
+
args: [value],
|
|
8874
|
+
thisArg: this.object,
|
|
8875
|
+
type: INTERACTION_ASSIGNED
|
|
8876
|
+
};
|
|
8877
|
+
}
|
|
8958
8878
|
applyDeoptimizations() {
|
|
8959
8879
|
this.deoptimized = true;
|
|
8960
8880
|
const { propertyReadSideEffects } = this.context.options
|
|
@@ -8964,13 +8884,21 @@ class MemberExpression extends NodeBase {
|
|
|
8964
8884
|
this.bound &&
|
|
8965
8885
|
propertyReadSideEffects &&
|
|
8966
8886
|
!(this.variable || this.replacement)) {
|
|
8967
|
-
|
|
8968
|
-
|
|
8969
|
-
|
|
8970
|
-
|
|
8971
|
-
|
|
8972
|
-
|
|
8973
|
-
|
|
8887
|
+
const propertyKey = this.getPropertyKey();
|
|
8888
|
+
this.object.deoptimizeThisOnInteractionAtPath(this.accessInteraction, [propertyKey], SHARED_RECURSION_TRACKER);
|
|
8889
|
+
this.context.requestTreeshakingPass();
|
|
8890
|
+
}
|
|
8891
|
+
}
|
|
8892
|
+
applyAssignmentDeoptimization() {
|
|
8893
|
+
this.assignmentDeoptimized = true;
|
|
8894
|
+
const { propertyReadSideEffects } = this.context.options
|
|
8895
|
+
.treeshake;
|
|
8896
|
+
if (
|
|
8897
|
+
// Namespaces are not bound and should not be deoptimized
|
|
8898
|
+
this.bound &&
|
|
8899
|
+
propertyReadSideEffects &&
|
|
8900
|
+
!(this.variable || this.replacement)) {
|
|
8901
|
+
this.object.deoptimizeThisOnInteractionAtPath(this.assignmentInteraction, [this.getPropertyKey()], SHARED_RECURSION_TRACKER);
|
|
8974
8902
|
this.context.requestTreeshakingPass();
|
|
8975
8903
|
}
|
|
8976
8904
|
}
|
|
@@ -8996,28 +8924,46 @@ class MemberExpression extends NodeBase {
|
|
|
8996
8924
|
}
|
|
8997
8925
|
return this.propertyKey;
|
|
8998
8926
|
}
|
|
8999
|
-
|
|
9000
|
-
|
|
9001
|
-
|
|
9002
|
-
|
|
9003
|
-
|
|
9004
|
-
|
|
9005
|
-
|
|
9006
|
-
|
|
9007
|
-
|
|
9008
|
-
|
|
9009
|
-
|
|
9010
|
-
|
|
9011
|
-
|
|
9012
|
-
|
|
9013
|
-
missing: exportName,
|
|
9014
|
-
url: `https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module`
|
|
9015
|
-
}, path[0].pos);
|
|
9016
|
-
return 'undefined';
|
|
8927
|
+
hasAccessEffect(context) {
|
|
8928
|
+
const { propertyReadSideEffects } = this.context.options
|
|
8929
|
+
.treeshake;
|
|
8930
|
+
return (!(this.variable || this.replacement) &&
|
|
8931
|
+
propertyReadSideEffects &&
|
|
8932
|
+
(propertyReadSideEffects === 'always' ||
|
|
8933
|
+
this.object.hasEffectsOnInteractionAtPath([this.getPropertyKey()], this.accessInteraction, context)));
|
|
8934
|
+
}
|
|
8935
|
+
includeProperties(context, includeChildrenRecursively) {
|
|
8936
|
+
if (!this.included) {
|
|
8937
|
+
this.included = true;
|
|
8938
|
+
if (this.variable) {
|
|
8939
|
+
this.context.includeVariableInModule(this.variable);
|
|
8940
|
+
}
|
|
9017
8941
|
}
|
|
9018
|
-
|
|
8942
|
+
this.object.include(context, includeChildrenRecursively);
|
|
8943
|
+
this.property.include(context, includeChildrenRecursively);
|
|
9019
8944
|
}
|
|
9020
8945
|
}
|
|
8946
|
+
function resolveNamespaceVariables(baseVariable, path, astContext) {
|
|
8947
|
+
if (path.length === 0)
|
|
8948
|
+
return baseVariable;
|
|
8949
|
+
if (!baseVariable.isNamespace || baseVariable instanceof ExternalVariable)
|
|
8950
|
+
return null;
|
|
8951
|
+
const exportName = path[0].key;
|
|
8952
|
+
const variable = baseVariable.context.traceExport(exportName);
|
|
8953
|
+
if (!variable) {
|
|
8954
|
+
const fileName = baseVariable.context.fileName;
|
|
8955
|
+
astContext.warn({
|
|
8956
|
+
code: 'MISSING_EXPORT',
|
|
8957
|
+
exporter: relativeId(fileName),
|
|
8958
|
+
importer: relativeId(astContext.fileName),
|
|
8959
|
+
message: `'${exportName}' is not exported by '${relativeId(fileName)}'`,
|
|
8960
|
+
missing: exportName,
|
|
8961
|
+
url: `https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module`
|
|
8962
|
+
}, path[0].pos);
|
|
8963
|
+
return 'undefined';
|
|
8964
|
+
}
|
|
8965
|
+
return resolveNamespaceVariables(variable, path.slice(1), astContext);
|
|
8966
|
+
}
|
|
9021
8967
|
|
|
9022
8968
|
class CallExpressionBase extends NodeBase {
|
|
9023
8969
|
constructor() {
|
|
@@ -9047,15 +8993,15 @@ class CallExpressionBase extends NodeBase {
|
|
|
9047
8993
|
returnExpression.deoptimizePath(path);
|
|
9048
8994
|
}
|
|
9049
8995
|
}
|
|
9050
|
-
|
|
8996
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
9051
8997
|
const returnExpression = this.getReturnExpression(recursionTracker);
|
|
9052
8998
|
if (returnExpression === UNKNOWN_EXPRESSION) {
|
|
9053
|
-
|
|
8999
|
+
interaction.thisArg.deoptimizePath(UNKNOWN_PATH);
|
|
9054
9000
|
}
|
|
9055
9001
|
else {
|
|
9056
9002
|
recursionTracker.withTrackedEntityAtPath(path, returnExpression, () => {
|
|
9057
|
-
this.expressionsToBeDeoptimized.add(
|
|
9058
|
-
returnExpression.
|
|
9003
|
+
this.expressionsToBeDeoptimized.add(interaction.thisArg);
|
|
9004
|
+
returnExpression.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
9059
9005
|
}, undefined);
|
|
9060
9006
|
}
|
|
9061
9007
|
}
|
|
@@ -9069,27 +9015,31 @@ class CallExpressionBase extends NodeBase {
|
|
|
9069
9015
|
return returnExpression.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
9070
9016
|
}, UnknownValue);
|
|
9071
9017
|
}
|
|
9072
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
9018
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
9073
9019
|
const returnExpression = this.getReturnExpression(recursionTracker);
|
|
9074
9020
|
if (this.returnExpression === UNKNOWN_EXPRESSION) {
|
|
9075
9021
|
return UNKNOWN_EXPRESSION;
|
|
9076
9022
|
}
|
|
9077
9023
|
return recursionTracker.withTrackedEntityAtPath(path, returnExpression, () => {
|
|
9078
9024
|
this.deoptimizableDependentExpressions.push(origin);
|
|
9079
|
-
return returnExpression.getReturnExpressionWhenCalledAtPath(path,
|
|
9025
|
+
return returnExpression.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
9080
9026
|
}, UNKNOWN_EXPRESSION);
|
|
9081
9027
|
}
|
|
9082
|
-
|
|
9083
|
-
|
|
9084
|
-
|
|
9085
|
-
|
|
9086
|
-
|
|
9087
|
-
|
|
9088
|
-
|
|
9089
|
-
|
|
9090
|
-
|
|
9091
|
-
|
|
9092
|
-
|
|
9028
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
9029
|
+
const { type } = interaction;
|
|
9030
|
+
if (type === INTERACTION_CALLED) {
|
|
9031
|
+
if ((interaction.withNew
|
|
9032
|
+
? context.instantiated
|
|
9033
|
+
: context.called).trackEntityAtPathAndGetIfTracked(path, interaction.args, this)) {
|
|
9034
|
+
return false;
|
|
9035
|
+
}
|
|
9036
|
+
}
|
|
9037
|
+
else if ((type === INTERACTION_ASSIGNED
|
|
9038
|
+
? context.assigned
|
|
9039
|
+
: context.accessed).trackEntityAtPathAndGetIfTracked(path, this)) {
|
|
9040
|
+
return false;
|
|
9041
|
+
}
|
|
9042
|
+
return this.getReturnExpression().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
9093
9043
|
}
|
|
9094
9044
|
}
|
|
9095
9045
|
|
|
@@ -9112,11 +9062,12 @@ class CallExpression extends CallExpressionBase {
|
|
|
9112
9062
|
}, this.start);
|
|
9113
9063
|
}
|
|
9114
9064
|
}
|
|
9115
|
-
this.
|
|
9065
|
+
this.interaction = {
|
|
9116
9066
|
args: this.arguments,
|
|
9117
|
-
|
|
9067
|
+
thisArg: this.callee instanceof MemberExpression && !this.callee.variable
|
|
9118
9068
|
? this.callee.object
|
|
9119
9069
|
: null,
|
|
9070
|
+
type: INTERACTION_CALLED,
|
|
9120
9071
|
withNew: false
|
|
9121
9072
|
};
|
|
9122
9073
|
}
|
|
@@ -9130,7 +9081,7 @@ class CallExpression extends CallExpressionBase {
|
|
|
9130
9081
|
this.annotations)
|
|
9131
9082
|
return false;
|
|
9132
9083
|
return (this.callee.hasEffects(context) ||
|
|
9133
|
-
this.callee.
|
|
9084
|
+
this.callee.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context));
|
|
9134
9085
|
}
|
|
9135
9086
|
finally {
|
|
9136
9087
|
if (!this.deoptimized)
|
|
@@ -9167,9 +9118,8 @@ class CallExpression extends CallExpressionBase {
|
|
|
9167
9118
|
}
|
|
9168
9119
|
applyDeoptimizations() {
|
|
9169
9120
|
this.deoptimized = true;
|
|
9170
|
-
|
|
9171
|
-
|
|
9172
|
-
this.callee.deoptimizeThisOnEventAtPath(EVENT_CALLED, EMPTY_PATH, thisParam, SHARED_RECURSION_TRACKER);
|
|
9121
|
+
if (this.interaction.thisArg) {
|
|
9122
|
+
this.callee.deoptimizeThisOnInteractionAtPath(this.interaction, EMPTY_PATH, SHARED_RECURSION_TRACKER);
|
|
9173
9123
|
}
|
|
9174
9124
|
for (const argument of this.arguments) {
|
|
9175
9125
|
// This will make sure all properties of parameters behave as "unknown"
|
|
@@ -9180,7 +9130,7 @@ class CallExpression extends CallExpressionBase {
|
|
|
9180
9130
|
getReturnExpression(recursionTracker = SHARED_RECURSION_TRACKER) {
|
|
9181
9131
|
if (this.returnExpression === null) {
|
|
9182
9132
|
this.returnExpression = UNKNOWN_EXPRESSION;
|
|
9183
|
-
return (this.returnExpression = this.callee.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, this.
|
|
9133
|
+
return (this.returnExpression = this.callee.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, this.interaction, recursionTracker, this));
|
|
9184
9134
|
}
|
|
9185
9135
|
return this.returnExpression;
|
|
9186
9136
|
}
|
|
@@ -9258,11 +9208,6 @@ class MethodBase extends NodeBase {
|
|
|
9258
9208
|
constructor() {
|
|
9259
9209
|
super(...arguments);
|
|
9260
9210
|
this.accessedValue = null;
|
|
9261
|
-
this.accessorCallOptions = {
|
|
9262
|
-
args: NO_ARGS,
|
|
9263
|
-
thisParam: null,
|
|
9264
|
-
withNew: false
|
|
9265
|
-
};
|
|
9266
9211
|
}
|
|
9267
9212
|
// As getter properties directly receive their values from fixed function
|
|
9268
9213
|
// expressions, there is no known situation where a getter is deoptimized.
|
|
@@ -9270,45 +9215,60 @@ class MethodBase extends NodeBase {
|
|
|
9270
9215
|
deoptimizePath(path) {
|
|
9271
9216
|
this.getAccessedValue().deoptimizePath(path);
|
|
9272
9217
|
}
|
|
9273
|
-
|
|
9274
|
-
if (
|
|
9275
|
-
return this.value.
|
|
9218
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
9219
|
+
if (interaction.type === INTERACTION_ACCESSED && this.kind === 'get' && path.length === 0) {
|
|
9220
|
+
return this.value.deoptimizeThisOnInteractionAtPath({
|
|
9221
|
+
args: NO_ARGS,
|
|
9222
|
+
thisArg: interaction.thisArg,
|
|
9223
|
+
type: INTERACTION_CALLED,
|
|
9224
|
+
withNew: false
|
|
9225
|
+
}, EMPTY_PATH, recursionTracker);
|
|
9276
9226
|
}
|
|
9277
|
-
if (
|
|
9278
|
-
return this.value.
|
|
9227
|
+
if (interaction.type === INTERACTION_ASSIGNED && this.kind === 'set' && path.length === 0) {
|
|
9228
|
+
return this.value.deoptimizeThisOnInteractionAtPath({
|
|
9229
|
+
args: interaction.args,
|
|
9230
|
+
thisArg: interaction.thisArg,
|
|
9231
|
+
type: INTERACTION_CALLED,
|
|
9232
|
+
withNew: false
|
|
9233
|
+
}, EMPTY_PATH, recursionTracker);
|
|
9279
9234
|
}
|
|
9280
|
-
this.getAccessedValue().
|
|
9235
|
+
this.getAccessedValue().deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
9281
9236
|
}
|
|
9282
9237
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
9283
9238
|
return this.getAccessedValue().getLiteralValueAtPath(path, recursionTracker, origin);
|
|
9284
9239
|
}
|
|
9285
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
9286
|
-
return this.getAccessedValue().getReturnExpressionWhenCalledAtPath(path,
|
|
9240
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
9241
|
+
return this.getAccessedValue().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
9287
9242
|
}
|
|
9288
9243
|
hasEffects(context) {
|
|
9289
9244
|
return this.key.hasEffects(context);
|
|
9290
9245
|
}
|
|
9291
|
-
|
|
9292
|
-
if (this.kind === 'get' && path.length === 0) {
|
|
9293
|
-
return this.value.
|
|
9294
|
-
|
|
9295
|
-
|
|
9296
|
-
|
|
9297
|
-
|
|
9298
|
-
|
|
9299
|
-
|
|
9246
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
9247
|
+
if (this.kind === 'get' && interaction.type === INTERACTION_ACCESSED && path.length === 0) {
|
|
9248
|
+
return this.value.hasEffectsOnInteractionAtPath(EMPTY_PATH, {
|
|
9249
|
+
args: NO_ARGS,
|
|
9250
|
+
thisArg: interaction.thisArg,
|
|
9251
|
+
type: INTERACTION_CALLED,
|
|
9252
|
+
withNew: false
|
|
9253
|
+
}, context);
|
|
9254
|
+
}
|
|
9255
|
+
// setters are only called for empty paths
|
|
9256
|
+
if (this.kind === 'set' && interaction.type === INTERACTION_ASSIGNED) {
|
|
9257
|
+
return this.value.hasEffectsOnInteractionAtPath(EMPTY_PATH, {
|
|
9258
|
+
args: interaction.args,
|
|
9259
|
+
thisArg: interaction.thisArg,
|
|
9260
|
+
type: INTERACTION_CALLED,
|
|
9261
|
+
withNew: false
|
|
9262
|
+
}, context);
|
|
9300
9263
|
}
|
|
9301
|
-
return this.getAccessedValue().
|
|
9302
|
-
}
|
|
9303
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
9304
|
-
return this.getAccessedValue().hasEffectsWhenCalledAtPath(path, callOptions, context);
|
|
9264
|
+
return this.getAccessedValue().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
9305
9265
|
}
|
|
9306
9266
|
applyDeoptimizations() { }
|
|
9307
9267
|
getAccessedValue() {
|
|
9308
9268
|
if (this.accessedValue === null) {
|
|
9309
9269
|
if (this.kind === 'get') {
|
|
9310
9270
|
this.accessedValue = UNKNOWN_EXPRESSION;
|
|
9311
|
-
return (this.accessedValue = this.value.getReturnExpressionWhenCalledAtPath(EMPTY_PATH,
|
|
9271
|
+
return (this.accessedValue = this.value.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_CALL, SHARED_RECURSION_TRACKER, this));
|
|
9312
9272
|
}
|
|
9313
9273
|
else {
|
|
9314
9274
|
return (this.accessedValue = this.value);
|
|
@@ -9331,23 +9291,17 @@ class ObjectMember extends ExpressionEntity {
|
|
|
9331
9291
|
deoptimizePath(path) {
|
|
9332
9292
|
this.object.deoptimizePath([this.key, ...path]);
|
|
9333
9293
|
}
|
|
9334
|
-
|
|
9335
|
-
this.object.
|
|
9294
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
9295
|
+
this.object.deoptimizeThisOnInteractionAtPath(interaction, [this.key, ...path], recursionTracker);
|
|
9336
9296
|
}
|
|
9337
9297
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
9338
9298
|
return this.object.getLiteralValueAtPath([this.key, ...path], recursionTracker, origin);
|
|
9339
9299
|
}
|
|
9340
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
9341
|
-
return this.object.getReturnExpressionWhenCalledAtPath([this.key, ...path],
|
|
9342
|
-
}
|
|
9343
|
-
hasEffectsWhenAccessedAtPath(path, context) {
|
|
9344
|
-
return this.object.hasEffectsWhenAccessedAtPath([this.key, ...path], context);
|
|
9345
|
-
}
|
|
9346
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
9347
|
-
return this.object.hasEffectsWhenAssignedAtPath([this.key, ...path], context);
|
|
9300
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
9301
|
+
return this.object.getReturnExpressionWhenCalledAtPath([this.key, ...path], interaction, recursionTracker, origin);
|
|
9348
9302
|
}
|
|
9349
|
-
|
|
9350
|
-
return this.object.
|
|
9303
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
9304
|
+
return this.object.hasEffectsOnInteractionAtPath([this.key, ...path], interaction, context);
|
|
9351
9305
|
}
|
|
9352
9306
|
}
|
|
9353
9307
|
|
|
@@ -9365,14 +9319,14 @@ class ClassNode extends NodeBase {
|
|
|
9365
9319
|
deoptimizePath(path) {
|
|
9366
9320
|
this.getObjectEntity().deoptimizePath(path);
|
|
9367
9321
|
}
|
|
9368
|
-
|
|
9369
|
-
this.getObjectEntity().
|
|
9322
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
9323
|
+
this.getObjectEntity().deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
9370
9324
|
}
|
|
9371
9325
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
9372
9326
|
return this.getObjectEntity().getLiteralValueAtPath(path, recursionTracker, origin);
|
|
9373
9327
|
}
|
|
9374
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
9375
|
-
return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path,
|
|
9328
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
9329
|
+
return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
9376
9330
|
}
|
|
9377
9331
|
hasEffects(context) {
|
|
9378
9332
|
var _a, _b;
|
|
@@ -9382,23 +9336,17 @@ class ClassNode extends NodeBase {
|
|
|
9382
9336
|
(_b = this.id) === null || _b === void 0 ? void 0 : _b.markDeclarationReached();
|
|
9383
9337
|
return initEffect || super.hasEffects(context);
|
|
9384
9338
|
}
|
|
9385
|
-
|
|
9386
|
-
return this.getObjectEntity().hasEffectsWhenAccessedAtPath(path, context);
|
|
9387
|
-
}
|
|
9388
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
9389
|
-
return this.getObjectEntity().hasEffectsWhenAssignedAtPath(path, context);
|
|
9390
|
-
}
|
|
9391
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
9339
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
9392
9340
|
var _a;
|
|
9393
|
-
if (path.length === 0) {
|
|
9394
|
-
return (!
|
|
9341
|
+
if (interaction.type === INTERACTION_CALLED && path.length === 0) {
|
|
9342
|
+
return (!interaction.withNew ||
|
|
9395
9343
|
(this.classConstructor !== null
|
|
9396
|
-
? this.classConstructor.
|
|
9397
|
-
: (_a = this.superClass) === null || _a === void 0 ? void 0 : _a.
|
|
9344
|
+
? this.classConstructor.hasEffectsOnInteractionAtPath(path, interaction, context)
|
|
9345
|
+
: (_a = this.superClass) === null || _a === void 0 ? void 0 : _a.hasEffectsOnInteractionAtPath(path, interaction, context)) ||
|
|
9398
9346
|
false);
|
|
9399
9347
|
}
|
|
9400
9348
|
else {
|
|
9401
|
-
return this.getObjectEntity().
|
|
9349
|
+
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
9402
9350
|
}
|
|
9403
9351
|
}
|
|
9404
9352
|
include(context, includeChildrenRecursively) {
|
|
@@ -9519,26 +9467,12 @@ class MultiExpression extends ExpressionEntity {
|
|
|
9519
9467
|
expression.deoptimizePath(path);
|
|
9520
9468
|
}
|
|
9521
9469
|
}
|
|
9522
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
9523
|
-
return new MultiExpression(this.expressions.map(expression => expression.getReturnExpressionWhenCalledAtPath(path,
|
|
9524
|
-
}
|
|
9525
|
-
hasEffectsWhenAccessedAtPath(path, context) {
|
|
9526
|
-
for (const expression of this.expressions) {
|
|
9527
|
-
if (expression.hasEffectsWhenAccessedAtPath(path, context))
|
|
9528
|
-
return true;
|
|
9529
|
-
}
|
|
9530
|
-
return false;
|
|
9531
|
-
}
|
|
9532
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
9533
|
-
for (const expression of this.expressions) {
|
|
9534
|
-
if (expression.hasEffectsWhenAssignedAtPath(path, context))
|
|
9535
|
-
return true;
|
|
9536
|
-
}
|
|
9537
|
-
return false;
|
|
9470
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
9471
|
+
return new MultiExpression(this.expressions.map(expression => expression.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)));
|
|
9538
9472
|
}
|
|
9539
|
-
|
|
9473
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
9540
9474
|
for (const expression of this.expressions) {
|
|
9541
|
-
if (expression.
|
|
9475
|
+
if (expression.hasEffectsOnInteractionAtPath(path, interaction, context))
|
|
9542
9476
|
return true;
|
|
9543
9477
|
}
|
|
9544
9478
|
return false;
|
|
@@ -9581,9 +9515,9 @@ class ConditionalExpression extends NodeBase {
|
|
|
9581
9515
|
usedBranch.deoptimizePath(path);
|
|
9582
9516
|
}
|
|
9583
9517
|
}
|
|
9584
|
-
|
|
9585
|
-
this.consequent.
|
|
9586
|
-
this.alternate.
|
|
9518
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
9519
|
+
this.consequent.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
9520
|
+
this.alternate.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
9587
9521
|
}
|
|
9588
9522
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
9589
9523
|
const usedBranch = this.getUsedBranch();
|
|
@@ -9592,15 +9526,15 @@ class ConditionalExpression extends NodeBase {
|
|
|
9592
9526
|
this.expressionsToBeDeoptimized.push(origin);
|
|
9593
9527
|
return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
9594
9528
|
}
|
|
9595
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
9529
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
9596
9530
|
const usedBranch = this.getUsedBranch();
|
|
9597
9531
|
if (!usedBranch)
|
|
9598
9532
|
return new MultiExpression([
|
|
9599
|
-
this.consequent.getReturnExpressionWhenCalledAtPath(path,
|
|
9600
|
-
this.alternate.getReturnExpressionWhenCalledAtPath(path,
|
|
9533
|
+
this.consequent.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin),
|
|
9534
|
+
this.alternate.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)
|
|
9601
9535
|
]);
|
|
9602
9536
|
this.expressionsToBeDeoptimized.push(origin);
|
|
9603
|
-
return usedBranch.getReturnExpressionWhenCalledAtPath(path,
|
|
9537
|
+
return usedBranch.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
9604
9538
|
}
|
|
9605
9539
|
hasEffects(context) {
|
|
9606
9540
|
if (this.test.hasEffects(context))
|
|
@@ -9611,29 +9545,13 @@ class ConditionalExpression extends NodeBase {
|
|
|
9611
9545
|
}
|
|
9612
9546
|
return usedBranch.hasEffects(context);
|
|
9613
9547
|
}
|
|
9614
|
-
|
|
9615
|
-
const usedBranch = this.getUsedBranch();
|
|
9616
|
-
if (!usedBranch) {
|
|
9617
|
-
return (this.consequent.hasEffectsWhenAccessedAtPath(path, context) ||
|
|
9618
|
-
this.alternate.hasEffectsWhenAccessedAtPath(path, context));
|
|
9619
|
-
}
|
|
9620
|
-
return usedBranch.hasEffectsWhenAccessedAtPath(path, context);
|
|
9621
|
-
}
|
|
9622
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
9548
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
9623
9549
|
const usedBranch = this.getUsedBranch();
|
|
9624
9550
|
if (!usedBranch) {
|
|
9625
|
-
return (this.consequent.
|
|
9626
|
-
this.alternate.
|
|
9551
|
+
return (this.consequent.hasEffectsOnInteractionAtPath(path, interaction, context) ||
|
|
9552
|
+
this.alternate.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
9627
9553
|
}
|
|
9628
|
-
return usedBranch.
|
|
9629
|
-
}
|
|
9630
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
9631
|
-
const usedBranch = this.getUsedBranch();
|
|
9632
|
-
if (!usedBranch) {
|
|
9633
|
-
return (this.consequent.hasEffectsWhenCalledAtPath(path, callOptions, context) ||
|
|
9634
|
-
this.alternate.hasEffectsWhenCalledAtPath(path, callOptions, context));
|
|
9635
|
-
}
|
|
9636
|
-
return usedBranch.hasEffectsWhenCalledAtPath(path, callOptions, context);
|
|
9554
|
+
return usedBranch.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
9637
9555
|
}
|
|
9638
9556
|
include(context, includeChildrenRecursively) {
|
|
9639
9557
|
this.included = true;
|
|
@@ -9904,12 +9822,10 @@ class ForInStatement extends NodeBase {
|
|
|
9904
9822
|
this.scope = new BlockScope(parentScope);
|
|
9905
9823
|
}
|
|
9906
9824
|
hasEffects(context) {
|
|
9907
|
-
|
|
9825
|
+
const { deoptimized, left, right } = this;
|
|
9826
|
+
if (!deoptimized)
|
|
9908
9827
|
this.applyDeoptimizations();
|
|
9909
|
-
if ((
|
|
9910
|
-
(this.left.hasEffects(context) ||
|
|
9911
|
-
this.left.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context))) ||
|
|
9912
|
-
(this.right && this.right.hasEffects(context)))
|
|
9828
|
+
if (left.hasEffectsAsAssignmentTarget(context, false) || right.hasEffects(context))
|
|
9913
9829
|
return true;
|
|
9914
9830
|
const { brokenFlow, ignore: { breaks, continues } } = context;
|
|
9915
9831
|
context.ignore.breaks = true;
|
|
@@ -9922,15 +9838,19 @@ class ForInStatement extends NodeBase {
|
|
|
9922
9838
|
return false;
|
|
9923
9839
|
}
|
|
9924
9840
|
include(context, includeChildrenRecursively) {
|
|
9925
|
-
|
|
9841
|
+
const { body, deoptimized, left, right } = this;
|
|
9842
|
+
if (!deoptimized)
|
|
9926
9843
|
this.applyDeoptimizations();
|
|
9927
9844
|
this.included = true;
|
|
9928
|
-
|
|
9929
|
-
|
|
9845
|
+
left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false);
|
|
9846
|
+
right.include(context, includeChildrenRecursively);
|
|
9930
9847
|
const { brokenFlow } = context;
|
|
9931
|
-
|
|
9848
|
+
body.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
9932
9849
|
context.brokenFlow = brokenFlow;
|
|
9933
9850
|
}
|
|
9851
|
+
initialise() {
|
|
9852
|
+
this.left.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
9853
|
+
}
|
|
9934
9854
|
render(code, options) {
|
|
9935
9855
|
this.left.render(code, options, NO_SEMICOLON);
|
|
9936
9856
|
this.right.render(code, options, NO_SEMICOLON);
|
|
@@ -9958,15 +9878,19 @@ class ForOfStatement extends NodeBase {
|
|
|
9958
9878
|
return true;
|
|
9959
9879
|
}
|
|
9960
9880
|
include(context, includeChildrenRecursively) {
|
|
9961
|
-
|
|
9881
|
+
const { body, deoptimized, left, right } = this;
|
|
9882
|
+
if (!deoptimized)
|
|
9962
9883
|
this.applyDeoptimizations();
|
|
9963
9884
|
this.included = true;
|
|
9964
|
-
|
|
9965
|
-
|
|
9885
|
+
left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false);
|
|
9886
|
+
right.include(context, includeChildrenRecursively);
|
|
9966
9887
|
const { brokenFlow } = context;
|
|
9967
|
-
|
|
9888
|
+
body.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
9968
9889
|
context.brokenFlow = brokenFlow;
|
|
9969
9890
|
}
|
|
9891
|
+
initialise() {
|
|
9892
|
+
this.left.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
9893
|
+
}
|
|
9970
9894
|
render(code, options) {
|
|
9971
9895
|
this.left.render(code, options, NO_SEMICOLON);
|
|
9972
9896
|
this.right.render(code, options, NO_SEMICOLON);
|
|
@@ -10673,9 +10597,9 @@ class LogicalExpression extends NodeBase {
|
|
|
10673
10597
|
usedBranch.deoptimizePath(path);
|
|
10674
10598
|
}
|
|
10675
10599
|
}
|
|
10676
|
-
|
|
10677
|
-
this.left.
|
|
10678
|
-
this.right.
|
|
10600
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
10601
|
+
this.left.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
10602
|
+
this.right.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
10679
10603
|
}
|
|
10680
10604
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
10681
10605
|
const usedBranch = this.getUsedBranch();
|
|
@@ -10684,15 +10608,15 @@ class LogicalExpression extends NodeBase {
|
|
|
10684
10608
|
this.expressionsToBeDeoptimized.push(origin);
|
|
10685
10609
|
return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
10686
10610
|
}
|
|
10687
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
10611
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
10688
10612
|
const usedBranch = this.getUsedBranch();
|
|
10689
10613
|
if (!usedBranch)
|
|
10690
10614
|
return new MultiExpression([
|
|
10691
|
-
this.left.getReturnExpressionWhenCalledAtPath(path,
|
|
10692
|
-
this.right.getReturnExpressionWhenCalledAtPath(path,
|
|
10615
|
+
this.left.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin),
|
|
10616
|
+
this.right.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)
|
|
10693
10617
|
]);
|
|
10694
10618
|
this.expressionsToBeDeoptimized.push(origin);
|
|
10695
|
-
return usedBranch.getReturnExpressionWhenCalledAtPath(path,
|
|
10619
|
+
return usedBranch.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
10696
10620
|
}
|
|
10697
10621
|
hasEffects(context) {
|
|
10698
10622
|
if (this.left.hasEffects(context)) {
|
|
@@ -10703,29 +10627,13 @@ class LogicalExpression extends NodeBase {
|
|
|
10703
10627
|
}
|
|
10704
10628
|
return false;
|
|
10705
10629
|
}
|
|
10706
|
-
|
|
10630
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
10707
10631
|
const usedBranch = this.getUsedBranch();
|
|
10708
10632
|
if (!usedBranch) {
|
|
10709
|
-
return (this.left.
|
|
10710
|
-
this.right.
|
|
10633
|
+
return (this.left.hasEffectsOnInteractionAtPath(path, interaction, context) ||
|
|
10634
|
+
this.right.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
10711
10635
|
}
|
|
10712
|
-
return usedBranch.
|
|
10713
|
-
}
|
|
10714
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
10715
|
-
const usedBranch = this.getUsedBranch();
|
|
10716
|
-
if (!usedBranch) {
|
|
10717
|
-
return (this.left.hasEffectsWhenAssignedAtPath(path, context) ||
|
|
10718
|
-
this.right.hasEffectsWhenAssignedAtPath(path, context));
|
|
10719
|
-
}
|
|
10720
|
-
return usedBranch.hasEffectsWhenAssignedAtPath(path, context);
|
|
10721
|
-
}
|
|
10722
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
10723
|
-
const usedBranch = this.getUsedBranch();
|
|
10724
|
-
if (!usedBranch) {
|
|
10725
|
-
return (this.left.hasEffectsWhenCalledAtPath(path, callOptions, context) ||
|
|
10726
|
-
this.right.hasEffectsWhenCalledAtPath(path, callOptions, context));
|
|
10727
|
-
}
|
|
10728
|
-
return usedBranch.hasEffectsWhenCalledAtPath(path, callOptions, context);
|
|
10636
|
+
return usedBranch.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
10729
10637
|
}
|
|
10730
10638
|
include(context, includeChildrenRecursively) {
|
|
10731
10639
|
this.included = true;
|
|
@@ -10815,8 +10723,8 @@ class MetaProperty extends NodeBase {
|
|
|
10815
10723
|
hasEffects() {
|
|
10816
10724
|
return false;
|
|
10817
10725
|
}
|
|
10818
|
-
|
|
10819
|
-
return path.length > 1;
|
|
10726
|
+
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
10727
|
+
return path.length > 1 || type !== INTERACTION_ACCESSED;
|
|
10820
10728
|
}
|
|
10821
10729
|
include() {
|
|
10822
10730
|
if (!this.included) {
|
|
@@ -10964,15 +10872,15 @@ class NewExpression extends NodeBase {
|
|
|
10964
10872
|
this.annotations)
|
|
10965
10873
|
return false;
|
|
10966
10874
|
return (this.callee.hasEffects(context) ||
|
|
10967
|
-
this.callee.
|
|
10875
|
+
this.callee.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context));
|
|
10968
10876
|
}
|
|
10969
10877
|
finally {
|
|
10970
10878
|
if (!this.deoptimized)
|
|
10971
10879
|
this.applyDeoptimizations();
|
|
10972
10880
|
}
|
|
10973
10881
|
}
|
|
10974
|
-
|
|
10975
|
-
return path.length > 0;
|
|
10882
|
+
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
10883
|
+
return path.length > 0 || type !== INTERACTION_ACCESSED;
|
|
10976
10884
|
}
|
|
10977
10885
|
include(context, includeChildrenRecursively) {
|
|
10978
10886
|
if (!this.deoptimized)
|
|
@@ -10987,9 +10895,10 @@ class NewExpression extends NodeBase {
|
|
|
10987
10895
|
this.callee.includeCallArguments(context, this.arguments);
|
|
10988
10896
|
}
|
|
10989
10897
|
initialise() {
|
|
10990
|
-
this.
|
|
10898
|
+
this.interaction = {
|
|
10991
10899
|
args: this.arguments,
|
|
10992
|
-
|
|
10900
|
+
thisArg: null,
|
|
10901
|
+
type: INTERACTION_CALLED,
|
|
10993
10902
|
withNew: true
|
|
10994
10903
|
};
|
|
10995
10904
|
}
|
|
@@ -11018,23 +10927,17 @@ class ObjectExpression extends NodeBase {
|
|
|
11018
10927
|
deoptimizePath(path) {
|
|
11019
10928
|
this.getObjectEntity().deoptimizePath(path);
|
|
11020
10929
|
}
|
|
11021
|
-
|
|
11022
|
-
this.getObjectEntity().
|
|
10930
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
10931
|
+
this.getObjectEntity().deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
11023
10932
|
}
|
|
11024
10933
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
11025
10934
|
return this.getObjectEntity().getLiteralValueAtPath(path, recursionTracker, origin);
|
|
11026
10935
|
}
|
|
11027
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
11028
|
-
return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path,
|
|
11029
|
-
}
|
|
11030
|
-
hasEffectsWhenAccessedAtPath(path, context) {
|
|
11031
|
-
return this.getObjectEntity().hasEffectsWhenAccessedAtPath(path, context);
|
|
11032
|
-
}
|
|
11033
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
11034
|
-
return this.getObjectEntity().hasEffectsWhenAssignedAtPath(path, context);
|
|
10936
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
10937
|
+
return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
11035
10938
|
}
|
|
11036
|
-
|
|
11037
|
-
return this.getObjectEntity().
|
|
10939
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
10940
|
+
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
11038
10941
|
}
|
|
11039
10942
|
render(code, options, { renderedSurroundingElement } = BLANK) {
|
|
11040
10943
|
super.render(code, options);
|
|
@@ -11165,32 +11068,26 @@ class PropertyDefinition extends NodeBase {
|
|
|
11165
11068
|
var _a;
|
|
11166
11069
|
(_a = this.value) === null || _a === void 0 ? void 0 : _a.deoptimizePath(path);
|
|
11167
11070
|
}
|
|
11168
|
-
|
|
11071
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
11169
11072
|
var _a;
|
|
11170
|
-
(_a = this.value) === null || _a === void 0 ? void 0 : _a.
|
|
11073
|
+
(_a = this.value) === null || _a === void 0 ? void 0 : _a.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
11171
11074
|
}
|
|
11172
11075
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
11173
11076
|
return this.value
|
|
11174
11077
|
? this.value.getLiteralValueAtPath(path, recursionTracker, origin)
|
|
11175
11078
|
: UnknownValue;
|
|
11176
11079
|
}
|
|
11177
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
11080
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
11178
11081
|
return this.value
|
|
11179
|
-
? this.value.getReturnExpressionWhenCalledAtPath(path,
|
|
11082
|
+
? this.value.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)
|
|
11180
11083
|
: UNKNOWN_EXPRESSION;
|
|
11181
11084
|
}
|
|
11182
11085
|
hasEffects(context) {
|
|
11183
11086
|
var _a;
|
|
11184
11087
|
return this.key.hasEffects(context) || (this.static && !!((_a = this.value) === null || _a === void 0 ? void 0 : _a.hasEffects(context)));
|
|
11185
11088
|
}
|
|
11186
|
-
|
|
11187
|
-
return !this.value || this.value.
|
|
11188
|
-
}
|
|
11189
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
11190
|
-
return !this.value || this.value.hasEffectsWhenAssignedAtPath(path, context);
|
|
11191
|
-
}
|
|
11192
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
11193
|
-
return !this.value || this.value.hasEffectsWhenCalledAtPath(path, callOptions, context);
|
|
11089
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11090
|
+
return !this.value || this.value.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
11194
11091
|
}
|
|
11195
11092
|
applyDeoptimizations() { }
|
|
11196
11093
|
}
|
|
@@ -11226,8 +11123,8 @@ class SequenceExpression extends NodeBase {
|
|
|
11226
11123
|
deoptimizePath(path) {
|
|
11227
11124
|
this.expressions[this.expressions.length - 1].deoptimizePath(path);
|
|
11228
11125
|
}
|
|
11229
|
-
|
|
11230
|
-
this.expressions[this.expressions.length - 1].
|
|
11126
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
11127
|
+
this.expressions[this.expressions.length - 1].deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
11231
11128
|
}
|
|
11232
11129
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
11233
11130
|
return this.expressions[this.expressions.length - 1].getLiteralValueAtPath(path, recursionTracker, origin);
|
|
@@ -11239,15 +11136,8 @@ class SequenceExpression extends NodeBase {
|
|
|
11239
11136
|
}
|
|
11240
11137
|
return false;
|
|
11241
11138
|
}
|
|
11242
|
-
|
|
11243
|
-
return
|
|
11244
|
-
this.expressions[this.expressions.length - 1].hasEffectsWhenAccessedAtPath(path, context));
|
|
11245
|
-
}
|
|
11246
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
11247
|
-
return this.expressions[this.expressions.length - 1].hasEffectsWhenAssignedAtPath(path, context);
|
|
11248
|
-
}
|
|
11249
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
11250
|
-
return this.expressions[this.expressions.length - 1].hasEffectsWhenCalledAtPath(path, callOptions, context);
|
|
11139
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11140
|
+
return this.expressions[this.expressions.length - 1].hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
11251
11141
|
}
|
|
11252
11142
|
include(context, includeChildrenRecursively) {
|
|
11253
11143
|
this.included = true;
|
|
@@ -11326,8 +11216,8 @@ class Super extends NodeBase {
|
|
|
11326
11216
|
deoptimizePath(path) {
|
|
11327
11217
|
this.variable.deoptimizePath(path);
|
|
11328
11218
|
}
|
|
11329
|
-
|
|
11330
|
-
this.variable.
|
|
11219
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
11220
|
+
this.variable.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
11331
11221
|
}
|
|
11332
11222
|
include() {
|
|
11333
11223
|
if (!this.included) {
|
|
@@ -11467,7 +11357,7 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
11467
11357
|
return true;
|
|
11468
11358
|
}
|
|
11469
11359
|
return (this.tag.hasEffects(context) ||
|
|
11470
|
-
this.tag.
|
|
11360
|
+
this.tag.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context));
|
|
11471
11361
|
}
|
|
11472
11362
|
finally {
|
|
11473
11363
|
if (!this.deoptimized)
|
|
@@ -11485,16 +11375,17 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
11485
11375
|
this.tag.include(context, includeChildrenRecursively);
|
|
11486
11376
|
this.quasi.include(context, includeChildrenRecursively);
|
|
11487
11377
|
}
|
|
11488
|
-
this.tag.includeCallArguments(context, this.
|
|
11378
|
+
this.tag.includeCallArguments(context, this.interaction.args);
|
|
11489
11379
|
const returnExpression = this.getReturnExpression();
|
|
11490
11380
|
if (!returnExpression.included) {
|
|
11491
11381
|
returnExpression.include(context, false);
|
|
11492
11382
|
}
|
|
11493
11383
|
}
|
|
11494
11384
|
initialise() {
|
|
11495
|
-
this.
|
|
11385
|
+
this.interaction = {
|
|
11496
11386
|
args: [UNKNOWN_EXPRESSION, ...this.quasi.expressions],
|
|
11497
|
-
|
|
11387
|
+
thisArg: this.tag instanceof MemberExpression && !this.tag.variable ? this.tag.object : null,
|
|
11388
|
+
type: INTERACTION_CALLED,
|
|
11498
11389
|
withNew: false
|
|
11499
11390
|
};
|
|
11500
11391
|
}
|
|
@@ -11504,9 +11395,8 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
11504
11395
|
}
|
|
11505
11396
|
applyDeoptimizations() {
|
|
11506
11397
|
this.deoptimized = true;
|
|
11507
|
-
|
|
11508
|
-
|
|
11509
|
-
this.tag.deoptimizeThisOnEventAtPath(EVENT_CALLED, EMPTY_PATH, thisParam, SHARED_RECURSION_TRACKER);
|
|
11398
|
+
if (this.interaction.thisArg) {
|
|
11399
|
+
this.tag.deoptimizeThisOnInteractionAtPath(this.interaction, EMPTY_PATH, SHARED_RECURSION_TRACKER);
|
|
11510
11400
|
}
|
|
11511
11401
|
for (const argument of this.quasi.expressions) {
|
|
11512
11402
|
// This will make sure all properties of parameters behave as "unknown"
|
|
@@ -11517,7 +11407,7 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
11517
11407
|
getReturnExpression(recursionTracker = SHARED_RECURSION_TRACKER) {
|
|
11518
11408
|
if (this.returnExpression === null) {
|
|
11519
11409
|
this.returnExpression = UNKNOWN_EXPRESSION;
|
|
11520
|
-
return (this.returnExpression = this.tag.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, this.
|
|
11410
|
+
return (this.returnExpression = this.tag.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, this.interaction, recursionTracker, this));
|
|
11521
11411
|
}
|
|
11522
11412
|
return this.returnExpression;
|
|
11523
11413
|
}
|
|
@@ -11540,7 +11430,7 @@ class TemplateElement extends NodeBase {
|
|
|
11540
11430
|
}
|
|
11541
11431
|
|
|
11542
11432
|
class TemplateLiteral extends NodeBase {
|
|
11543
|
-
|
|
11433
|
+
deoptimizeThisOnInteractionAtPath() { }
|
|
11544
11434
|
getLiteralValueAtPath(path) {
|
|
11545
11435
|
if (path.length > 0 || this.quasis.length !== 1) {
|
|
11546
11436
|
return UnknownValue;
|
|
@@ -11553,12 +11443,12 @@ class TemplateLiteral extends NodeBase {
|
|
|
11553
11443
|
}
|
|
11554
11444
|
return getMemberReturnExpressionWhenCalled(literalStringMembers, path[0]);
|
|
11555
11445
|
}
|
|
11556
|
-
|
|
11557
|
-
|
|
11558
|
-
|
|
11559
|
-
|
|
11560
|
-
if (path.length === 1) {
|
|
11561
|
-
return hasMemberEffectWhenCalled(literalStringMembers, path[0],
|
|
11446
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11447
|
+
if (interaction.type === INTERACTION_ACCESSED) {
|
|
11448
|
+
return path.length > 1;
|
|
11449
|
+
}
|
|
11450
|
+
if (interaction.type === INTERACTION_CALLED && path.length === 1) {
|
|
11451
|
+
return hasMemberEffectWhenCalled(literalStringMembers, path[0], interaction, context);
|
|
11562
11452
|
}
|
|
11563
11453
|
return true;
|
|
11564
11454
|
}
|
|
@@ -11686,16 +11576,15 @@ class ThisExpression extends NodeBase {
|
|
|
11686
11576
|
deoptimizePath(path) {
|
|
11687
11577
|
this.variable.deoptimizePath(path);
|
|
11688
11578
|
}
|
|
11689
|
-
|
|
11690
|
-
this.variable.deoptimizeThisOnEventAtPath(event, path,
|
|
11579
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
11691
11580
|
// We rewrite the parameter so that a ThisVariable can detect self-mutations
|
|
11692
|
-
|
|
11693
|
-
}
|
|
11694
|
-
hasEffectsWhenAccessedAtPath(path, context) {
|
|
11695
|
-
return path.length > 0 && this.variable.hasEffectsWhenAccessedAtPath(path, context);
|
|
11581
|
+
this.variable.deoptimizeThisOnInteractionAtPath(interaction.thisArg === this ? { ...interaction, thisArg: this.variable } : interaction, path, recursionTracker);
|
|
11696
11582
|
}
|
|
11697
|
-
|
|
11698
|
-
|
|
11583
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11584
|
+
if (path.length === 0) {
|
|
11585
|
+
return interaction.type !== INTERACTION_ACCESSED;
|
|
11586
|
+
}
|
|
11587
|
+
return this.variable.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
11699
11588
|
}
|
|
11700
11589
|
include() {
|
|
11701
11590
|
if (!this.included) {
|
|
@@ -11804,13 +11693,10 @@ class UnaryExpression extends NodeBase {
|
|
|
11804
11693
|
return false;
|
|
11805
11694
|
return (this.argument.hasEffects(context) ||
|
|
11806
11695
|
(this.operator === 'delete' &&
|
|
11807
|
-
this.argument.
|
|
11696
|
+
this.argument.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_ASSIGNMENT, context)));
|
|
11808
11697
|
}
|
|
11809
|
-
|
|
11810
|
-
|
|
11811
|
-
return path.length > 0;
|
|
11812
|
-
}
|
|
11813
|
-
return path.length > 1;
|
|
11698
|
+
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
11699
|
+
return type !== INTERACTION_ACCESSED || path.length > (this.operator === 'void' ? 0 : 1);
|
|
11814
11700
|
}
|
|
11815
11701
|
applyDeoptimizations() {
|
|
11816
11702
|
this.deoptimized = true;
|
|
@@ -11834,11 +11720,19 @@ class UpdateExpression extends NodeBase {
|
|
|
11834
11720
|
hasEffects(context) {
|
|
11835
11721
|
if (!this.deoptimized)
|
|
11836
11722
|
this.applyDeoptimizations();
|
|
11837
|
-
return
|
|
11838
|
-
|
|
11723
|
+
return this.argument.hasEffectsAsAssignmentTarget(context, true);
|
|
11724
|
+
}
|
|
11725
|
+
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
11726
|
+
return path.length > 1 || type !== INTERACTION_ACCESSED;
|
|
11839
11727
|
}
|
|
11840
|
-
|
|
11841
|
-
|
|
11728
|
+
include(context, includeChildrenRecursively) {
|
|
11729
|
+
if (!this.deoptimized)
|
|
11730
|
+
this.applyDeoptimizations();
|
|
11731
|
+
this.included = true;
|
|
11732
|
+
this.argument.includeAsAssignmentTarget(context, includeChildrenRecursively, true);
|
|
11733
|
+
}
|
|
11734
|
+
initialise() {
|
|
11735
|
+
this.argument.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
11842
11736
|
}
|
|
11843
11737
|
render(code, options) {
|
|
11844
11738
|
const { exportNamesByVariable, format, snippets: { _ } } = options;
|
|
@@ -11900,7 +11794,7 @@ class VariableDeclaration extends NodeBase {
|
|
|
11900
11794
|
declarator.deoptimizePath(EMPTY_PATH);
|
|
11901
11795
|
}
|
|
11902
11796
|
}
|
|
11903
|
-
|
|
11797
|
+
hasEffectsOnInteractionAtPath() {
|
|
11904
11798
|
return false;
|
|
11905
11799
|
}
|
|
11906
11800
|
include(context, includeChildrenRecursively, { asSingleStatement } = BLANK) {
|