Commit graph

227 commits

Author SHA1 Message Date
Seonghyun Kim
caa0fbc3fe Implement compress CompressibleStrings on GC reclaim end event
* Compress CompressibleStrings on GC reclaim end event
  - if there is reference about data of CompressibleString on stack, we should give up compressing.
    we don't need to search heap space because I redesigned StringView
    (we should not store string buffer data on heap without owner)
* Redesign StringView
  - Don't save string buffer address as its member. because buffer of CompressibleString can be deleted
  - If we don't save string buffer address on StringView, parser performance may dropped.
    becuase parser access string data a lot.
    so I introduce ParserStringView. it saves buffer address. we should ParserStringView on parser only.
    we can save string buffer address while parsing. because GC is disabled while parsing.

* Enable CompressibleString always
* Implement cache of RegExpOptionStrings
* Implement finding system locale function on RuntimeICUBinder avoiding call uloc_getDefault.

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2020-01-10 17:37:00 +09:00
HyukWoo Park
47bf20782e Check strict mode immediately
* check and convert to strict mode ahead of following tokens
* identifier which has a valid keyword in strict mode is also converted to the complete keyword
* fixes #513

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2020-01-10 11:17:19 +09:00
seonghyun kim
98d4ef6942 Reduce memory usage
* Store array length property in its member variable not value vector
  - This can reduce one of GC_MALLOC call if there is not value in ArrayObject other than fastmode value
* Prevent memory leak from VMInstance, Context
* Change vector capacity reserve strategy

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2019-12-24 14:38:09 +09:00
HyukWoo Park
7c13a84057 Fix valueStringLiteral method in ScannerResult
* remove unnecessary StringView allocation
* simplify parseObjectPropertyKey mothod

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-12-18 13:38:41 +09:00
seonghyun kim
fba9396ec9 Reduce memory usage
* Reduce size of RopeString
* Use fit memory if possible for ArrayObject fastModeData
* Re-implement ByteCode pruning logic
* Re-implement inline-cache for reducing memory usage
* Remove std::vector with gc_allocator. it can cause memory leak

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-12-18 11:11:26 +09:00
HyukWoo Park
963cc4aa07 Handle destructuring in try-catch clause
* fix bugs about object, array destructuring in catch clause
* directly generate bytecode about lexical variable initialization instead of allocating a temporal AssignmentExpressionNode
* RegisterReferenceNode removed because this node is used only during the bytecode generation process

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-12-17 09:37:43 +09:00
seonghyun kim
a126f3dd13 Treat function parameter initialization area as first lexical block
* in parameter initialization area, we cannot access var declared variables

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-12-10 15:43:52 +09:00
seonghyun kim
5dfcfd15bd Fix bugs related with switch statement
* Treat let, const variables in switch statement correctly.
* When Evaluate switch case block, We should set script execution result as undefined.

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-12-09 09:55:36 +09:00
seonghyun kim
53906a6d81 Optimize runtime performance
* Optimize ObjectStructurePropertyDescriptor
* Don't initialize inline storage of VectorWithInlineStorage
* Add Object::setPrototypeForIntrinsicObjectCreation for fast initialize
* Add ArrayObject::ArrayObject(ExecutionState& state, const uint64_t& size) for fast initialize
* Store stack-limit instead of stack-base
* Reduce size of ExecutionState
* Add fast version of Object::ownPropertyKeys for optimize Object.keys
* Add ValueVectorWithInlineStorage
* Remove some compiler warnings

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-12-05 15:04:20 +09:00
HyukWoo Park
b852fa1079 Fix a bug : ignore null or undefined value for spread element in object destructing
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-12-03 19:22:14 +09:00
HyukWoo Park
c328e53927 Implement exponential operation
* update exponential operation and exponentiation-equal assignment
* unnecessary header files are removed in some Node files

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-11-27 09:38:22 +09:00
HyukWoo Park
d918e65ff9 Fix some parsing bugs
* handle implicit function name in parameter list
* handle trailing-comma and also support the trailing-comma rule in setter function
* fix function length not to count parameter-forms other than simple identifier
* disable one wrong TC in v8 (trailing-comma)

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-11-25 10:35:07 +09:00
HyukWoo Park
5b522fbc2d Fix a bug when shorthand object property is used in object destruction
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-11-18 16:05:59 +09:00
HyukWoo Park
01de1210b9 Update rest element in Object pattern
* BindingRestElement bytecode handles Iterator and EnumerateObject both
* MarkEnumerateKey bytecode is added to mark visited properties

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-11-18 15:56:15 +09:00
HyukWoo Park
b0a31717c5 Update spread element in Object initialization
* EnumerateObject is reworked and two derived classes are newly added
* Object spread element is handled through EnumerateObjectWithDestruction
* for-in operation is handled through EnumerateObjectWithIteration

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-11-18 15:56:15 +09:00
HyukWoo Park
e2e34d07db Handle assignment pattern in Object pattern
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-11-18 15:56:15 +09:00
seonghyun kim
42231eba48 Implement basic behavior of async, await.
* Add ExecutionPauser for yield, await
* Add new public API

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-11-15 16:07:03 +09:00
HyukWoo Park
863c99c73f Minor bug fix about duplicated finishIdentifier call in parser
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-11-07 14:38:04 +09:00
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
HyukWoo Park
877539c538 Replace NodeVector by LinkedList
* replace NodeVector by NodeList to completely separate the parsing memory from the GC heap
* each node of NodeList is allocated in AST pool
* NodeList passed as lvalue reference
* remove redundant constructor of each Node

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-11-05 13:04:13 +09:00
Patrick Kim
82f05fdd29 Improve performance (#490)
* Initialize function name binding in interpreter
* If there are so many var variables on function, we should make hash map for finding var fast

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-10-31 16:10:26 +09:00
Boram Bae
f11752b532 Update to support new.target with Class and eval (#489)
* Pass more tests

Signed-off-by: Boram Bae <boram21.bae@samsung.com>
2019-10-31 13:38:49 +09:00
Boram Bae
015836c721 Add a ScriptClassConstructorFunctionObject and Fix some bugs (#483)
* pass more tests

Signed-off-by: Boram Bae <boram21.bae@samsung.com>
2019-10-31 10:19:47 +09:00
Hyukwoo Park
6aa1ede203 Fix bugs about arrow function parsing and toStringWithoutException (#482)
* fix a case that arrow function is located at the first of script
* fix a case that toStringWithoutException is called with no SandBox

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-10-28 17:24:57 +09:00
Patrick Kim
f75945700a Fix various things (#476)
* Fixup canDeclareName in ASTContext
* Add more callstack information on API
* Add onDelete callback on VMInstance
* Add BloomFilter as util
* Use BloomFilter in ASTFunctionContext for find out variable name existence
* Optimize parser using InlineStorageVector

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-10-24 14:29:55 +09:00
Hyukwoo Park
bb7c12cfd5 Optimize parser to skip the scanning of the whole function (#475)
* parsing of function including parameter list and function body is skipped in scanner mode
* m_bodySrc in InterpretedCodeBlock is removed because it is no longer necessary
* some operator overloading in FreeableNode and DestructibleNode is fixed

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-10-23 19:40:26 +09:00
Hyukwoo Park
13343f8417 Optimize memory management in Parsing (#465)
* Revise AST Node allocation through ASTPool

* ASTAllocator is newly added for allocation of AST Nodes
* AST Node is allocated in pool memory and flushed once after bytecode is generated
* All reference counting overhead related to AST Node is removed

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>

* Reduce memory operations in Parsing

* empty vector called SyntaxNodeVector is added for SyntaxChecker
* ASTFunctionScopeContext and ASTBlockScopeContext are allocated in ast pool instead of GC heap
* memory leak(ShellPlatform) in shell is fixed

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-10-21 20:01:17 +09:00
Hyukwoo Park
ba161d7459 Fix case when functions located in parameter list (#468)
* functions in parameter list are scanned instread of skipping it
* fix #236 issue

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-10-17 18:46:03 +09:00
Patrick Kim
ba4631ae02 Fix public API errors & fix bugs (#466)
* When evaluate for-in, we should call [[Enumerate]] function & we shouldn't literate symbols and non-enumerable names.
* In esprima, we need to reset lastUsingName on {open, close}Block

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-10-17 11:20:06 +09:00
Patrick Kim
2b58f8282d Use special vector it has inline storage in esprima::Parser::parseBinaryExpression (#463)
* this special vector reduce malloc/free count on parseBinaryExpression

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-10-15 17:15:52 +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
65ef38b5f7 Revise parser: specify parser/scanner with two ASTBuilders (#447)
* all parser and scanner methods share common parsing codes, but part of creating a new Node is implemented by two ASTBuilders which are passed as argument
* SyntaxChecker only checks any syntax error
* NodeGenerator checks any syntax error and also creates a new Node
* remove unused Node methods and fix some typo in Node
* esprima::Messages is divided into another header file

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-10-08 14:12:19 +09:00
Patrick Kim
eceffac4c4 Implement Direct {Import, Export} (#448)
* Rename ESCARGOT_OUTPUT=bin into shell and make shell_test for testing.
* Remove ESCARGOT_SHELL, -SCARGOT_STANDALONE and Rename ESCARGOT_ENABLE_VENDORTEST into ESCARGOT_ENABLE_TEST.
* Fix bug in PersistentRefHolder
* Add DebuggerStatementNode for preventing parsing error even if we cannot support
* Revise Platform layer for supporting es6 module
* Implmenent class constructor toString

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-10-07 13:11:03 +09:00
Boram Bae
dd78fda084 Update syntax errors related to 'super' (#438)
* Pass more test262 tests

Signed-off-by: Boram Bae <boram21.bae@samsung.com>
2019-09-24 16:23:54 +09:00
Patrick Kim
a19b321a5f Implement for statement per-iteration block correctly (#437)
* we should replace block context before executing update expression in for statement
* merge ObjectDefineGetter, ObjectDefineSetter byte code into one code
* add some missed scan operation in parser

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-09-24 16:15:39 +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
742e6d29e1 Fix bugs & Implement missed ES6 features (#432)
* Reimplement finally block in try-statement.
* Replace `ReturnFunction`, `ReturnFunctionWithValue` bytecode with `End`.
* When for-of loop is exited by exception or break, we need to close iterator
* Don't add Return Statement in ByteCodeGenerator. We should add Return Statement in ScriptParser.
* Fix bug in yield expression.
* Implement add implicit class name on class expression.

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-09-20 14:01:36 +09:00
Hyukwoo Park
a02a2a0d32 Fix several parsing error checks to pass test262 TCs (#431)
* parseFunction is divided into FunctionDeclaration and FunctionExpression to handle the function name differently
* let, yield keywords are enabled in some cases according to the standard

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-09-19 10:38:00 +09:00
Hyukwoo Park
23200a8ca9 Fix syntax error check for destructuring (#429)
* pass more test262 TCs

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-09-18 17:12:06 +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
2173fa4b25 Pass more test262 testcases (#426)
* in ES6, we need to set function name when object literal has function expression on right side
* in ES6, we should not check duplicated property name on object literal
* Refactor Object::hasInstance & Object::getMethod

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-09-16 13:25:56 +09:00
Patrick Kim
c4f82fe5ee When evaluate assigment expression, we should resolve reference on leftside first (#424)
Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-09-11 17:00:19 +09:00
Hyukwoo Park
919b62c40e Fix syntax check of parameters for arrow function (#423)
* add syntax check for single parameter in arrow function
* use of parsePropertyMethod is fixed upto the latest esprima version

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-09-11 10:25:00 +09:00
Hyukwoo Park
d29851c294 Add conversion between ExpressionNode and PatternNode (#419)
* implement reinterpretExpressionAsPattern parsing method for conversion between ExpressionNode and PatternNode
* remove redundant modules in Patterns

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-09-09 10:14:25 +09:00
Patrick Kim
98d3c9c26e Fix class bugs (#418)
* Fixup class parsing error check in esprima
* Class cannot have property named 'prototype'
* When define {getter, setter} in interpreter, property key can be symbol
* Reorder properties on class constructor
* Fixup public API

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-09-09 10:12:47 +09:00
Patrick Kim
f3c433b99d Fixup esprima (#415)
* Implement scanning `class` & add missed calling `parse class` on scanning
* Implement statementListItem function correctly
* Fix class initialization bug

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-09-05 20:44:15 +09:00