Update lexcial environment. (#313)

- Store lexcial block informantion in InterpretedCodeBlock.
- If lexcial block has no lexcial variables, we should collapse the block.
- If there is no heap-allocated variables in lexcial environment, we can skip allocation of the environment.
- Implement Indexed storage for lexcial environment.
- Allocate lexcial variables in function stack storage if possible.

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
This commit is contained in:
Patrick Kim 2019-07-18 15:34:10 +09:00 committed by Hyukwoo Park
commit d1b4ced24c
53 changed files with 1867 additions and 881 deletions

View file

@ -98,7 +98,7 @@ Value Script::executeLocal(ExecutionState& state, Value thisValue, InterpretedCo
record = state.lexicalEnvironment()->record();
}
const CodeBlock::IdentifierInfoVector& vec = m_topCodeBlock->identifierInfos();
const InterpretedCodeBlock::IdentifierInfoVector& vec = m_topCodeBlock->identifierInfos();
size_t len = vec.size();
EnvironmentRecord* recordToAddVariable = record;
LexicalEnvironment* e = state.lexicalEnvironment();
@ -115,12 +115,13 @@ Value Script::executeLocal(ExecutionState& state, Value thisValue, InterpretedCo
ExecutionState newState(&state, newEnvironment, m_topCodeBlock->isStrict());
size_t stackStorageSize = m_topCodeBlock->identifierOnStackCount();
size_t stackStorageSize = m_topCodeBlock->totalStackAllocatedVariableSize();
size_t identifierOnStackCount = m_topCodeBlock->identifierOnStackCount();
size_t literalStorageSize = m_topCodeBlock->byteCodeBlock()->m_numeralLiteralData.size();
Value* registerFile = ALLOCA((m_topCodeBlock->byteCodeBlock()->m_requiredRegisterFileSizeInValueSize + stackStorageSize + literalStorageSize) * sizeof(Value), Value, state);
registerFile[0] = Value();
Value* stackStorage = registerFile + m_topCodeBlock->byteCodeBlock()->m_requiredRegisterFileSizeInValueSize;
for (size_t i = 0; i < stackStorageSize; i++) {
for (size_t i = 0; i < identifierOnStackCount; i++) {
stackStorage[i] = Value();
}
Value* literalStorage = stackStorage + stackStorageSize;