Refactoring source code (#356)

* Remove some unused function, variables
* Remove LexicalEnvironment from NativeFunctionObject
* Don't save stack-allocated LexicalEnvironment on ScriptFunctionObject. it may cause memory leak from stack
* Don't store newTarget, ThisBinded value on FunctionEnvironmentRecord if possible(we don't need these values except class functions)

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
This commit is contained in:
Patrick Kim 2019-08-08 12:20:19 +09:00 committed by Boram Bae
commit 864973236d
28 changed files with 496 additions and 405 deletions

View file

@ -122,10 +122,6 @@ Value NativeFunctionObject::processNativeFunctionCall(ExecutionState& state, con
CallNativeFunctionData* code = m_codeBlock->nativeFunctionData();
// TODO don't make LexicalEnvironment if possiable
FunctionEnvironmentRecordSimple record(this, 0, nullptr);
LexicalEnvironment env(&record, nullptr);
size_t len = m_codeBlock->parameterCount();
if (argc < len) {
Value* newArgv = (Value*)alloca(sizeof(Value) * len);
@ -139,7 +135,7 @@ Value NativeFunctionObject::processNativeFunctionCall(ExecutionState& state, con
}
Value receiver = receiverSrc;
ExecutionState newState(ctx, &state, &env, isStrict, &receiver);
ExecutionState newState(ctx, &state, nullptr, this, isStrict);
if (!isConstruct) {
// prepare receiver
@ -179,7 +175,7 @@ Value NativeFunctionObject::processNativeFunctionCall(ExecutionState& state, con
}
return result;
} catch (const Value& v) {
ByteCodeInterpreter::processException(newState, v, SIZE_MAX);
ByteCodeInterpreter::processException(newState, v, m_codeBlock, SIZE_MAX);
return Value();
}
}