Revise BigInt not to hold VMInstance pointer

* bf_context_t is now defined as a global variable and maintained during the runtime
* VMInstance::finalize is invoked at the end of program to guarantee the life time of bf_context_t

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
This commit is contained in:
HyukWoo Park 2021-03-09 12:39:36 +09:00 committed by Boram Bae
commit 2b775dc2f5
15 changed files with 148 additions and 129 deletions

View file

@ -1915,7 +1915,7 @@ ALWAYS_INLINE bool abstractLeftIsLessThanRightNumeric(ExecutionState& state, con
// If Type(px) is BigInt and Type(py) is String, then
if (UNLIKELY(lvalIsBigInt && rvalIsString)) {
// Let ny be StringToBigInt(py).
BigIntData ny(state.context()->vmInstance(), rval.asString());
BigIntData ny(rval.asString());
// If ny is NaN, return undefined.
if (ny.isNaN()) {
return false;
@ -1927,7 +1927,7 @@ ALWAYS_INLINE bool abstractLeftIsLessThanRightNumeric(ExecutionState& state, con
// If Type(px) is String and Type(py) is BigInt, then
if (UNLIKELY(lvalIsString && rvalIsBigInt)) {
// Let nx be StringToBigInt(px).
BigIntData nx(state.context()->vmInstance(), lval.asString());
BigIntData nx(lval.asString());
// If nx is NaN, return undefined.
if (nx.isNaN()) {
return false;
@ -1952,11 +1952,11 @@ ALWAYS_INLINE bool abstractLeftIsLessThanRightNumeric(ExecutionState& state, con
if (UNLIKELY(ny.second)) {
return compBigIntBigInt(nx.first.asBigInt(), ny.first.asBigInt());
} else {
return compBigIntBigIntData(nx.first.asBigInt(), BigIntData(state.context()->vmInstance(), ny.first.asNumber()));
return compBigIntBigIntData(nx.first.asBigInt(), BigIntData(ny.first.asNumber()));
}
} else {
if (UNLIKELY(ny.second)) {
return compBigIntDataBigInt(BigIntData(state.context()->vmInstance(), nx.first.asNumber()), ny.first.asBigInt());
return compBigIntDataBigInt(BigIntData(nx.first.asNumber()), ny.first.asBigInt());
} else {
return compDoubleDouble(nx.first.asNumber(), ny.first.asNumber());
}