Optimize ScriptParser more (#70)

* Diet ScannerResult
* Use SourceStringView if possible for reducing memory usage

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
This commit is contained in:
김승현/Tizen Platform Lab(SR)/Engineer/삼성전자 2018-05-04 13:44:02 +09:00 committed by 최영일/Tizen Platform Lab(SR)/Principal Engineer/삼성전자
commit ef57dc3400
13 changed files with 399 additions and 117 deletions

View file

@ -40,12 +40,6 @@ OpcodeTable::OpcodeTable()
ByteCodeInterpreter::interpret(state, &block, 0, nullptr, addr);
}
// ECMA-262 11.3 Line Terminators
ALWAYS_INLINE bool isLineTerminator(char16_t ch)
{
return (ch == 0x0A) || (ch == 0x0D) || (ch == 0x2028) || (ch == 0x2029);
}
void* ByteCodeBlock::operator new(size_t size)
{
static bool typeInited = false;
@ -115,7 +109,7 @@ ExtendedNodeLOC ByteCodeBlock::computeNodeLOC(StringView src, ExtendedNodeLOC so
for (size_t i = 0; i < index && i < srcLength; i++) {
char16_t c = src.charAt(i);
column++;
if (isLineTerminator(c)) {
if (esprima::isLineTerminator(c)) {
// skip \r\n
if (c == 13 && (i + 1 < index) && src.charAt(i + 1) == 10) {
i++;