mirror of
https://github.com/facebookarchive/prepack.git
synced 2024-11-09 21:20:06 +03:00
Fix invariant failure in serializer
Summary: For global let bindings, the serializer ignored the CSE value provided by the visitor. This led to an invariant failure when looking up the scope of a value that had been replaced by an equivalent value during CSE analysis in the visitor. Closes https://github.com/facebook/prepack/pull/1149 Differential Revision: D6325186 Pulled By: hermanventer fbshipit-source-id: 421d5bfc3f4e0c9ec7730af6ff3a38d4b926bcae
This commit is contained in:
parent
03750d1b3b
commit
fdc2787c1a
@ -1273,10 +1273,12 @@ export class ResidualHeapSerializer {
|
||||
let value = this.realm.getGlobalLetBinding(boundName);
|
||||
// Check for let binding vs global property
|
||||
if (value) {
|
||||
let id = this.serializeValue(value, true, "let");
|
||||
let rval = residualFunctionBinding.value;
|
||||
invariant(rval !== undefined && value.equals(rval));
|
||||
let id = this.serializeValue(rval, true, "let");
|
||||
// increment ref count one more time as the value has been
|
||||
// referentialized (stored in a variable) by serializeValue
|
||||
this.residualHeapValueIdentifiers.incrementReferenceCount(value);
|
||||
this.residualHeapValueIdentifiers.incrementReferenceCount(rval);
|
||||
residualFunctionBinding.serializedValue = id;
|
||||
} else {
|
||||
residualFunctionBinding.serializedValue = this.preludeGenerator.globalReference(boundName);
|
||||
|
12
test/serializer/abstract/TemporalCSE.js
Normal file
12
test/serializer/abstract/TemporalCSE.js
Normal file
@ -0,0 +1,12 @@
|
||||
this.glob = 123;
|
||||
let b = global.__abstract ? __abstract("boolean", "true"): true;
|
||||
let y;
|
||||
if (b) {
|
||||
y = glob;
|
||||
}
|
||||
let z;
|
||||
if (b) {
|
||||
z = glob;
|
||||
}
|
||||
|
||||
inspect = function () { return y + " " + z; }
|
Loading…
Reference in New Issue
Block a user