Skip to content

Remove redundant assertion in the method freeTempLocal #2313

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 10, 2022

Conversation

ApsarasX
Copy link
Contributor

@ApsarasX ApsarasX commented Jun 8, 2022

  • I've read the contributing guidelines
  • I've added my name and email to the NOTICE file

I think the last assertion is redundant in the method freeTempLocal.

Neither local nor local.index was modified between the two assertions below.

assemblyscript/src/flow.ts

Lines 376 to 450 in 3ff1003

assert(local.index >= 0);
var parentFunction = this.parentFunction;
var temps: Local[];
assert(local.type != null); // internal error
local.resetTemporaryName();
switch (<u32>local.type.toRef()) {
case <u32>TypeRef.I32: {
let tempI32s = parentFunction.tempI32s;
if (tempI32s) temps = tempI32s;
else parentFunction.tempI32s = temps = [];
break;
}
case <u32>TypeRef.I64: {
let tempI64s = parentFunction.tempI64s;
if (tempI64s) temps = tempI64s;
else parentFunction.tempI64s = temps = [];
break;
}
case <u32>TypeRef.F32: {
let tempF32s = parentFunction.tempF32s;
if (tempF32s) temps = tempF32s;
else parentFunction.tempF32s = temps = [];
break;
}
case <u32>TypeRef.F64: {
let tempF64s = parentFunction.tempF64s;
if (tempF64s) temps = tempF64s;
else parentFunction.tempF64s = temps = [];
break;
}
case <u32>TypeRef.V128: {
let tempV128s = parentFunction.tempV128s;
if (tempV128s) temps = tempV128s;
else parentFunction.tempV128s = temps = [];
break;
}
case <u32>TypeRef.Funcref: {
let tempFuncrefs = parentFunction.tempFuncrefs;
if (tempFuncrefs) temps = tempFuncrefs;
else parentFunction.tempFuncrefs = temps = [];
break;
}
case <u32>TypeRef.Externref: {
let tempExternrefs = parentFunction.tempExternrefs;
if (tempExternrefs) temps = tempExternrefs;
else parentFunction.tempExternrefs = temps = [];
break;
}
case <u32>TypeRef.Anyref: {
let tempAnyrefs = parentFunction.tempAnyrefs;
if (tempAnyrefs) temps = tempAnyrefs;
else parentFunction.tempAnyrefs = temps = [];
break;
}
case <u32>TypeRef.Eqref: {
let tempEqrefs = parentFunction.tempEqrefs;
if (tempEqrefs) temps = tempEqrefs;
else parentFunction.tempEqrefs = temps = [];
break;
}
case <u32>TypeRef.I31ref: {
let tempI31refs = parentFunction.tempI31refs;
if (tempI31refs) temps = tempI31refs;
else parentFunction.tempI31refs = temps = [];
break;
}
case <u32>TypeRef.Dataref: {
let tempDatarefs = parentFunction.tempDatarefs;
if (tempDatarefs) temps = tempDatarefs;
else parentFunction.tempDatarefs = temps = [];
break;
}
default: throw new Error("concrete type expected");
}
assert(local.index >= 0);

@dcodeIO dcodeIO merged commit f0a1043 into AssemblyScript:main Jun 10, 2022
@ApsarasX ApsarasX deleted the remove-redundant-assertion branch June 10, 2022 12:28
@ApsarasX ApsarasX restored the remove-redundant-assertion branch June 10, 2022 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants