Commit graph

136 commits

Author SHA1 Message Date
Zoltan Herczeg
1a5414a0ba Support class static initializers
Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2022-08-22 15:21:50 +09:00
HyukWoo Park
a25c6fa5e8 Add a specific API to create a Script by wrapping the source code with an anonymous function
* `initializeFunctionScript` API is added
* unlike dynamically created function, `initializeFunctionScript` supports debugger
* origin line offset is added for correct source code calculation in debugger

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2022-04-14 10:57:47 +09:00
Seonghyun Kim
ebf4756480 Binding function object in interpreter and compute required stack size early
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2022-03-28 14:39:52 +09:00
HyukWoo Park
1b38eeca32 Update Debugger to selectively generate debugging byte codes
* we can choose JS source code for debugging target
* selectively generating debugging byte code (breakpoint)
* add debugger init option (--skip=) to exclude certain source code from debugging
* rename debugger functions
* explicitly present the python version for debugger tool

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2022-03-25 17:41:23 +09:00
HyukWoo Park
bd35e41168 Add setName API of FunctionObject
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2022-01-13 13:24:09 +09:00
HyukWoo Park
e2758f5a2c Add createFunction API with source name parameter
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2022-01-03 11:28:48 +09:00
HyukWoo Park
8c51b7c9a6 Fix bugs in debugger
* fix debugger to add breakpoint at the first line
* fix debugger not to insert any breakpoint when compiling dynamic code
* add some assertion code to detect undesirable cases

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2021-12-03 11:57:22 +09:00
Seonghyun Kim
8986e222f4 Fix compile error on gcc version 5
gcc version 5 cannot decide how many bits are require for enum well
if there is enum has type. it generates warning but we don't need to set type into enum for gcc 5

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2021-10-29 12:38:57 +09:00
SeongHyun Kim
c1a5a53bb7 Mark enum as unsigned
we need to mark enum as unsigned.
because processing enum in msvc is little different

ex) enum Type { A, B }
struct Foo { Type type: 1; }
Foo f; f.type = 1;
if (f.type == Type::B) { puts("failed in msvc."); }

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2021-10-28 12:21:12 +09:00
HyukWoo Park
aef7ba0c98 Update GC event callback registration
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2021-10-07 08:39:04 +09:00
Zoltan Herczeg
ff4d4d593d Add debugger test cases for class fields
Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-08-24 15:26:23 +09:00
Seonghyun Kim
050812963e Implement one of nesting class private rule
- We need to check object value is homeobject if there is same private name on parent class

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2021-07-01 16:36:39 +09:00
Seonghyun Kim
b791bd9850 Disallow using arguments variable in class field when using eval function
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2021-02-02 10:21:45 +09:00
Seonghyun Kim
dac08ab369 Implement runtime things of class field
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2021-01-21 18:22:20 +09:00
Seonghyun Kim
f0c64aa74a Implement super keyword in class static field init
* Implement Open, Close env Bytecode for this

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2021-01-13 17:06:44 +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
c73a012d77 Fix uninitialized member variables found by cppcheck
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2020-10-12 14:12:27 +09:00
Seonghyun Kim
4e9349b999 Implement ReloadableString
* turn off ALWAYS_INLINE in small config
* turn off hidden class transition table in small config

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2020-08-13 14:07:37 +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
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
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
586082c1d7 Fix NativeCodeBlock to directly store the native function point
* remove CallNativeFunctionData
* FunctionTemplate and native APIs allocate ExtendedNativeFunctionObject in itself

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2020-07-16 12:51:00 +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
Seonghyun Kim
4f3774be0c Implement tagged-template cache on CodeBlock according to GetTemplateObject(templateLiteral) on spec
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2020-05-27 17:09:09 +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
Seonghyun Kim
323c2dca20 Each function parameter should have own declarative environment.
but I don't want to add extra bytecodes for this.
and It is only needed when there is direct eval operation.
so I wrap each parameter block with small arrow function.

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2020-05-18 15:18:10 +09:00
Seonghyun Kim
1bd124fc1b Revise function call & Realm
* Revise Object::getPrototypeFromConstructor. we should get prototype from context of consturctor
* We should pass Optional<Object*> instead of Value with newTarget.
* Give correct prototype value for function prototypes and functions
* Implement %ThrowTypeError% correctly

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2020-04-02 17:06:53 +09:00
Seonghyun Kim
4670a4097f Implement additional ECMAScript Features for Web Browsers
* Implement rules of Global Function declaration

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2020-03-18 16:57:42 +09:00
HyukWoo Park
e32b181f4f Add NewTarget parameter to builtin functions
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2020-03-16 16:52:44 +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
a555ac52f6 Initial implementation of the Escargot Debugger. 2020-03-05 10:36:55 +09:00
HyukWoo Park
e2029096f1 Fix minor defects
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2020-02-07 16:09:23 +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
HyukWoo Park
3c6032f8c9 Fix bugs in function parameter
* fix function length to represent the number of consecutive identifiers from the start of parameter list
* collect parameter names including the target names of patterns and rest element
* separate function length and parameter count
* simplify the process of parameter collecting and rename parameter related functions more intuitively

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
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
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
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
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
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
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
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
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
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