Commit graph

110 commits

Author SHA1 Message Date
Seonghyun Kim
109d199302 Reimplement static field initializer
* wrap initializer expr into virtual arrow function like instance field
* users can access super property in eval

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2021-02-02 10:21:45 +09:00
HyukWoo Park
29c70f7532 Update clang-format version to 6.0
* coding convention fixed following the new clang-format

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2020-12-18 11:13:15 +09:00
HyukWoo Park
f168e4bd7b Remove unused codes found by cppcheck
* remove unused functions
* remove unused variables
* mark necessary but unused variables with UNUSED_VARIABLE

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2020-10-06 13:11:07 +09:00
HyukWoo Park
0e51df514e Handle CodeCache file I/O errors
* first, try to lock cache directory to enable CodeCache
* if file I/O fails, stop caching and remove all cache files
* flush and sync files when writing cache
* add tests to check file error cases

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2020-09-18 13:38:50 +09:00
HyukWoo Park
ae21ea534b Update CodeCache file management
* calculate cache file directory based on $HOME env
* handle all cache list in one file
* use source code's hash value for its cache data file name

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2020-09-16 18:27:30 +09:00
HyukWoo Park
3fe7189d28 Merge caching data into one data file
* CodeCache generates one meta file and data file for each JS file
* enable coverity scan to check CodeCache too

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2020-09-14 11:19:18 +09:00
HyukWoo Park
383069820a Use hash value as its file name for code caching
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2020-08-19 16:54:32 +09:00
HyukWoo Park
f56a557ff5 Reduce memory allocation during bytecode generation
* ByteCodeBlock does not hold location data info anymore
* location data of each bytecode is manually allocated only for stack-tracing or debugger mode
* duplicated String allocation for source code is removed

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2020-08-06 16:23:06 +09:00
HyukWoo Park
11e469c6fa Implement CodeCache for bytecode
* store/load global ByteCodeBlock

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2020-08-03 10:40:17 +09:00
HyukWoo Park
436fac4423 Implement CodeCache for CodeBlock tree
* update read/write modules for CodeCache
* store and load CodeBlock tree

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2020-07-30 10:44:40 +09:00
Ryan Hyun Choi
99b2d0f8ce Check values of getenv() for validity
Signed-off-by: Ryan Choi <ryan.h.choi@gmail.com>
2020-07-27 15:51:18 +09:00
HyukWoo Park
773007bec6 Each InterpretedCodeBlock has its children in a vector
* reduce the whole size of InterpretedCodeBlock instances
* iterate fastly on children

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2020-07-23 15:19:05 +09:00
HyukWoo Park
747803bf81 Add InterpretedCodeBlockWithRareData
* extract infrequently used m_rareData member from InterpretedCodeBlock
* InterpretedCodeBlockWithRareData handles InterpretedCodeBlockRareData inside itself

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2020-07-08 16:56:44 +09:00
HyukWoo Park
2fe9333814 Divide CodeBlock into NativeCodeBlock and InterpretedCodeBlock
* NativeCodeBlock is newly added for NativeFunctionObject
* all interpreter-related info is moved into InterpretedCodeBlock

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2020-07-08 16:56:44 +09:00
HyukWoo Park
cd09ccbb07 Rename ASTContext structure
* rename to ASTScopeContext and ASTBlockContext
* remove redundant ASTScopeContext parameter

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2020-07-06 10:07:56 +09:00
Robert Fancsik
7bb5428cff Fix catch parse error when the debugger is enabled
Signed-off-by: Robert Fancsik <frobert@inf.u-szeged.hu>
2020-06-16 08:55:45 +09:00
Seonghyun Kim
39e10484d7 When parsing TemplateLiteral in TaggedTemplateExpression, we should not throw SyntaxError.
* Set value as undefined when there is SyntaxError
* Fix memory leak related with throwing esprima::Error

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2020-06-01 14:17:29 +09:00
Seonghyun Kim
fe0c65118c * When evaluate super.foo = 1 we should throw TypeError.
when PutValue is failed + isStrict('use strict` or class method).

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2020-05-27 17:09:09 +09:00
bence gabor kis
a88023c9c2 Debugger pending breakpoints
Signed-off-by: bence gabor kis <kisbg@inf.u-szeged.hu>
2020-05-22 11:14:33 +09:00
Seonghyun Kim
355d7244f1 Fix minor issues
* When there is arrow function on class ctor, we should use heap-allocated lex env for class ctor.
  because we need to compute this variable on run-time
* when there is super expression with computed case, we should load this binding first for testing binding

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2020-05-18 15:18:10 +09:00
Seonghyun Kim
1a1078a462 Should treat state of async, * correctly for class method, object method
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2020-03-12 13:31:43 +09:00
MuHong Byun
e2f1c3f47d Fix LGPL License verison typo (2.0 -> 2.1)
Signed-off-by: MuHong Byun <mh.byun@samsung.com>
2020-03-10 11:35:20 +09:00
Zoltan Herczeg
bf3a8c7463 Add support for next and stop operations for the Debugger.
Furthermore the function info is displayed when we stop inside a function.

Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-03-09 16:17:04 +09:00
Zoltan Herczeg
a555ac52f6 Initial implementation of the Escargot Debugger. 2020-03-05 10:36:55 +09:00
HyukWoo Park
eb1bbd0c3f Fix a case in which parameter value is referenced before initialization to throw a reference error
* add ThrowStaticErrorOperation bytecode for each pre-accessed parameter value

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2020-02-03 13:49:44 +09:00
Seonghyun Kim
ae35a576f5 Implement more things according to newer ECMAScript spec
* Fix parser error related with async arrow function
* CodeBlock may have diffrent source code start position data(from `function` keyword)
  - new ECMAScript spec says we should make function source string from `function` keyword
* Apply new spec on builtin Function constructor
* AsyncFunctions must have correct initial properties

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2020-01-22 18:01:52 +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
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
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
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
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
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
Patrick Kim
e820e0b969 Revise public API (#442)
* PointerValueRef should inherit ValueRef
* Implement PersistentRefHolder for easy-rooting
* Remove SandBox interface for public
* Re-implement shell through public API
* Implement Platform for supprot various platform easily
* Add many missed public API methods(Set, Map, Symbol...)
* Add Memory class into public

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-09-30 10:55:27 +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
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
Patrick Kim
b33e7df9a2 Implement MetaProperty(new.target) (#397)
* add some missed public api functions

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-08-29 20:26:20 +09:00
Patrick Kim
3c0a1cfddd Don't use heap allocated lexical environment if possible (#378)
- We should not heap allocated env on...
  * functions uses variable on upper function
  * functions have `typeof` operation
  * functions have unmapped arguments object
- Improve calling function performance by remove accessing vtable once in interpreter(from isCallable, call to just call)

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-08-20 10:41:06 +09:00
Patrick Kim
bffa9402b1 Optimize execution speed (#374)
* Set ALWAYS_INLINE flag for SmallValue <-> Value convertor function
* Implement ScriptGeneratorFunctionObject for remove if-statement in FunctionCall
* Remove calling Object::call in CallFunction, CallFunctionWithReceiver opcode
* if function uses global variable only, we should not use heap env for the function
* Don't use bitfield for ExecutionState::m_inStrictMode because we have only one flag at there.
* Remove useless submodules (test262-master, test262-harness)

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-08-19 11:23:23 +09:00
Patrick Kim
ad0cecbd0d Implement lazy-creation of arguments object. (#361)
* Store ArgumentsObject into Env record with functionObject
* Introduce gc memory leak checker
* Don't save stack pointer in ArgumentsObject

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-08-13 17:00:03 +09:00
Hyukwoo Park
1d143c3871 Expand the parsing scope of function to include parameters (#360)
* we should parse the parameter list together for each function calls to treat argument initializers such as rest, default parameters
* for each function calls, we first parse the parameter list and then, parse the function body sequentially
* also remove and clearup some unnecessary parsing modules

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-08-12 14:02:27 +08: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
Patrick Kim
43f442c560 Revise function call processes (#347)
* Revise [[call]], [[construct]] as described in spec
* Remove m_homeObject in FunctionObject.
* Implement ScriptClass{Constructor, Method}FunctionObject
    this subclass is used for saving [[homeObject]] and implement [[call]], [[consturct]]
* Add more(NewTargetBinder, ReturnValueBinder) into FunctionObjectProcessCallGenerator
* Remove feCounter in ByteCodeGenerationProcess. in ES6, function expression order & evaluation order can differ
* Add CallSuper ByteCode for interpret `super()` in class constructor
* Remove isOngoingSuperCall in ExecutionState
* Remove BuiltinFunctionObject. that was unnecessary

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-08-06 09:58:06 +09:00
Patrick Kim
356a103466 Separate FunctionObject (#344)
There are so many features in FunctionObject. so I separate FunctionObject into multiple classes.
  * Implement FunctionObjectProcessCallGenerator class for generate processCall code for each derived FunctionObject and implement [[call]], [[construct]] separately
  * Implement NativeFunctionObject, BuiltinFunctionObject for process NativeCall separately
  * Implement ScriptArrowFunctionObject for process `this` separately
  * TODO : ScriptClassMethodFunctionObject, ScriptGeneratorFunctionObject.

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-08-01 11:30:40 +09:00
Patrick Kim
2a54ab5e02 Update lexical environment stuffs (#327)
* treat variable in catch() as let
* add lexical environment record data into global environment for saving global permanently
* re-implement variable access bytecode generation
* re-implement class initialize operation
* re-implement global variable access bytecode for support lexcial variables in global
* fix bugs related with per-iteration lexical environment in for-statement

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-07-26 13:16:44 +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