Commit graph

36 commits

Author SHA1 Message Date
HyukWoo Park
05678d6449 Update parsing of async feature
* add empty async related Nodes
* await and async are handled as a normal identifier
* add const keyword for passed NodeList reference in Node constructor

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-11-06 18:16:31 +09:00
Patrick Kim
b9a6f92b27 Optimize script initialization performance (#462)
* Build numeral literal number in token only if needs
* Build string literal for ast only if needs
* Move NumeralData from ASTContext to ASTNode
* Fix compile error on gcc 7+

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-10-14 19:18:39 +09:00
Hyukwoo Park
1e459af46c Fix several modules of Parser (#461)
* small-sized SmallScannerResult replaces origin ScannerResult in parsing process to reduce the memory pressure.
* ScannerResultVector in parseBinaryExpression is replaced by GC-independent SmallScannerResultVector to reduce the memory overhead (both the performance and memory usage)
* ParseFormalParametersResult holds SyntaxNodeVector instead of NodeVector because each parameter Node is re-generated when it is really necessary (parsing of function call) and we only needs the name and type of each parameter during the pre-parsing
* parser/scanner of parameter parsing is added
* clear up some unnecessary codes such as each friend class annotation in Nodes and NodeVectors

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-10-14 16:36:57 +09:00
Patrick Kim
4bb343552e Optimize script initialization performance (#458)
* Store child {ASTFunctionContext, InterpretedCodeBlock} as linked-list
* Reduce size of ScannerResult
* Remove Parser::scopeContexts
* Fix compile error in old system

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-10-14 13:07:28 +09:00
Patrick Kim
03ac100d7f Optmize escargot (#454)
* Don't allocate new StringView on parser if possible
* Store esprima::Context::firstCoverInitializedNameError as pointer. it can reduce copy cost on esprima::*CoverGrammar
* Make Script as reexcutable if possible
* Don't save parsed source codes
  - Remove SourceStringView
  - When create AtomicString from StringView, we should make new string data instead of reference StringView
* Reduce size of StringBufferAccessData
* Fix crash in toString of FunctionObject.

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-10-11 15:32:04 +09:00
Patrick Kim
87ca01b658 Implement indirect export, import (#453)
* Rename ambiguous variables names(src, source, fileName) into src, sourceCode
* Treat 'await' as keyword

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-10-08 18:25:05 +09:00
Hyukwoo Park
6fa563c68e Update minor syntax errors (#436)
* add invalid hexadecimal escape sequence error
* lexical declaration cannot appear in a single-statement context
* ASTContext structures are divided into another file
* pass more test262 TCs

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-09-20 15:47:50 +09:00
Patrick Kim
2cc9e3d63f Pass more test262 testcases (#428)
* Process 0x2028, 0x2029 char on template literal correctly
* Object are created by TaggedTemplateLiteral are should frozen
* When eval `super.foo = 1`, use `this` as receiver
* Implement Function.protoype.caller
* Fix processing '\0' char bug in builtinFileReadHelper
* When eval `yield delegate` repect it's result.

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-09-17 15:27:09 +09:00
Patrick Kim
c7b40195f1 Implement TaggedTempleateExpression correctly (#413)
* Implement {parse, scan}templateLiteral
* Fix bug in raw value parsing in TemplateLiteral

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-09-05 12:44:48 +09:00
Patrick Kim
91ce0c6127 Pass more tests in test262 (#403)
* Test zero started number correctly
* global Date, Number prototypes should have "Object" on [[class]] internal property
* global {*}Error have Error.prototype in [[prototype]] prototype
* Should call iteratorClose function on When get exception on {Map, Set, WeakSet, WeakMap} constructor.
* Math.imul.length is 2
* Some global Object util functions don't require Object as first parameter from ES6.
* Re-implement Promise.{all, race} for using iterator correctly
* Fix template literal token start position bug in Lexer

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-09-02 12:51:17 +09:00
Patrick Kim
35d046e023 Optmize execution speed & Enable clang build test (#381)
* Inline Object::getPrototypeObject function in inline-cache functions(interpreter)
* Use POINTER_VALUE_STRING_TAG_IN_DATA, POINTER_VALUE_SYMBOL_TAG_IN_DATA for finding PointerValue type quickly

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-08-21 15:04:46 +09:00
Patrick Kim
864973236d 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>
2019-08-08 12:20:19 +09:00
Robert Fancsik
3b81c3e572 Optimize/simplify static string initialization (#324)
- Introduce INIT_STATIC_STRING macro to make adding new static string much easier.
 - Introduce AtomicString::initStaticString to append static string to the static string set directly
   without lookup for an already existing name.
 - Add a number list and remove the dtoa function call for the initialization of string numbers.
 - Split the single character initialization to ASCII and Latin1 string part.

Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-07-24 18:16:41 +09:00
Patrick Kim
d1b4ced24c 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>
2019-07-18 15:34:10 +09:00
Hyukwoo Park
151e30e24d Remove redundant GC objects in parsing (#261)
* unnecessary GC object/structure in parser removed
* explicitly represent stack-allocated object

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-05-28 13:53:40 +09:00
Hyukwoo Park
6d7312579e Optimize memory allocation of Lexer based on the stack (#266)
* each ScannerResult is now allocated on the stack if it is really necessary
* reduce the reference count overhead for each ScannerResult
* ALLOC_TOKEN macro is newly added for allocation of each ScannerResult token

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-05-22 14:58:52 +09:00
Patrick Kim
1004220604 Implement ESCARGOT_TREAT_LET_AS_VAR env variable (#248)
This is bad implementation. but it is needed for some special reason

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-05-13 11:57:47 +09:00
Tóth Béla
69ae9be8d2 Reduce Code Smell issues (#221)
Rewamped a little bit of code, reported by SonarCloud for code smell.
Redudant parenthesis, and empty if statement code blocks.

Signed-off-by: Bela Toth tbela@inf.u-szeged.hu
2019-05-08 13:57:15 +09:00
Tóth Béla
31393f2a90 Fix ES6 octal literal parsing (#230)
The code had the place for parsing octal numbers like `0o543` and
`0O543`, but due to an implementation error the code returned with
`Unexpected token ILLEGAL`.

Signed-off-by: Bela Toth tbela@inf.u-szeged.hu
2019-05-07 11:22:08 +09:00
Tóth Béla
47dce1c42b Merge collapsible if statements (#171)
Merged Collapsible if statements reported by SonarCloud.
Also unified some code in Lexer, to follow this ruleset.

https://sonarcloud.io/project/issues?branch=travisMoka&id=Achie72_escargot&resolved=false&rules=cpp%3AS1066&severities=MAJOR

Signed-off-by: Bela Toth tbela@inf.u-szeged.hu
2019-03-28 16:53:51 +09:00
Zoltan Herczeg
beaa26988b Start merging parsing/scanning. (#148)
There is a lot of code duplication for parser and scanner.
Source code duplications can be reduced by templates without sacrificing performance.

Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-03-15 20:07:49 +09:00
Zoltan Herczeg
b5e787f82a Unify reserved word checking. (#139)
Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-03-14 11:58:28 +09:00
Zoltan Herczeg
3ed483090f Simplify error throwing in parser. (#134)
Remove unnecessary functions, simplify interface.

Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-03-11 12:00:06 +09:00
Peter Marki
9f399d4682 Reduce cognitive code complexity of Scanner::ScannerResult::constructStringLiteral() (#111)
https://sonarcloud.io/project/issues?id=pando-project_escargot&issues=AWijtp3UBmaQb3-uIc8f&open=AWijtp3UBmaQb3-uIc8f

Signed-off-by: Peter Marki marpeter@inf.u-szeged.hu
2019-02-28 14:07:09 +09:00
Zoltan Herczeg
6d2b73f818 Simplifiy punctuator parsing and introduce peekChar(). (#106)
Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-02-26 14:28:34 +09:00
Peter Marki
2ad365189d Use initializer lists where possible (#105)
https://sonarcloud.io/organizations/pando-project/rules?open=cpp%3AS3230&rule_key=cpp%3AS3230

Signed-off-by: Peter Marki marpeter@inf.u-szeged.hu
2019-02-26 14:28:05 +09:00
Daniella Barsony
56b7748c67 Reduce code smells (#82)
Signed-off-by: Daniella Barsony bella@inf.u-szeged.hu
2019-02-19 15:48:48 +09:00
Tóth Béla
dab095397d Extract assignment from sub-expressions (#97)
Sonarcloud reported an issue, namely `Assignments should not be made
from within sub-expressions. This affected only the Lexer, and were fixed.

https://sonarcloud.io/project/issues?id=pando-project_escargot&resolved=false&rules=cpp%3AAssignmentInSubExpression&sinceLeakPeriod=true&types=CODE_SMELL

Signed-off-by: Bela Toth tbela@inf.u-szeged.hu
2019-02-15 13:46:20 +09:00
Zoltan Herczeg
29ac4731c9 Move white space and new line checkers into the Lexer. (#81)
Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-02-13 08:19:28 +09:00
Zoltan Herczeg
f09fba8cce Remove OctalToDecimalResult from Lexer. (#80)
Instead use a special value to represent invalid octal values.

Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-02-12 10:12:03 +09:00
Zoltan Herczeg
dc30cd3035 Move ScannerResult into Scanner. (#77)
This way several functions can be moved into the private section.

Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-01-31 18:16:26 +09:00
Zoltan Herczeg
a82b41313b Introduce private section for Lexer. (#74)
Start hiding private helper functions from outside world. Next step
will be hiding private data members.

Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-01-30 14:47:42 +09:00
Zoltan Herczeg
56868385e1 Remove CharOrEmptyResult structure. (#63)
Introduce EmptyCodePoint constant to represent the empty case.
Also hex conversion is simplified.

Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-01-24 14:20:36 +09:00
Zoltan Herczeg
de84be2e9e Remove curlyStack structure. (#59)
Instead of maintaining a structure in memory simply re-scan the
right brace when a template is parsed.

Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-01-22 18:15:17 +09:00
Zoltan Herczeg
57b75326d4 Rework isIdentifierPartSlow. (#56)
The new code uses a binary search instead of a very large if statement.

Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-01-21 12:24:38 +09:00
Zoltan Herczeg
09b45e47b4 Move Lexer (Scanner) out of parser. (#55)
Currently the parser is a very large file and hard to maintain. This patch is
the first which splits it into smaller files.

During the move some style fixes are applied. The identifer start
detection is improved as well.

Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-01-17 15:36:14 +09:00