Commit graph

194 commits

Author SHA1 Message Date
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
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
Hyukwoo Park
474b917ecb Fix some bugs in Patterns (#412)
* add check code for ObjectPattern without AssignmentPropertyList
* handle the case when value of PropertyNode is a MemberExpression
* add generateStoreByteCode module for SpreadElement
* pass related TCs in test262

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-09-05 12:44:09 +09:00
Patrick Kim
4432709661 Revise RegExp module (#411)
* Update yarr (webkitgtk-2.18.5) & import into repo
* Implement new RegExp ES6 error when unicode flag is on
* Fix ignorecase bug on RegExp

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-09-04 14:12:01 +09:00
Hyukwoo Park
c829029eae Fix a bug of variable declarations within patterns (#408)
* declarations of block scoped variables are correctly handled
* const variable check is added to GlobalEnvironmentRecord::setMutableBindingByBindingSlot

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-09-03 17:14:20 +09:00
Hyukwoo Park
46c6ffa8a2 Fix Patterns (#400)
* simplify bytecode generation of ArrayPatternNode and ObjectPatternNode by implementing generateStoreByteCode method
* fix bugs related to variable declarations by patterns
* remove unnecessary members in pattern

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-09-02 16:05:01 +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
881a44e0fb Fixup generator (#393)
* We can use try-catch with yield together now.
* Implement return, throw function in GeneratorObject correctly
* yield expression parsing in esprima 3.1.1 is wrong. so I get right version of yield parsing from newer version of esprima

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-08-28 13:57:32 +09:00
Hyukwoo Park
cc3f7deb8c Remove redundant parameter modules (#390)
* CodeBlock has essential parameter name list only
* toString builtin function is fixed to use the entire source instead of body source
* some TCs are fixed upto the spec

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-08-27 10:40:30 +09:00
Hyukwoo Park
4a61f0f9b7 Implement lazy parameter initialization (#388)
* each parameter is initialized by bytecode execution
* patterns in parameter list are no longer allocated in the heap in default

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-08-23 19:21:14 +09:00
Patrick Kim
66bd235740 Remove c++ try-catch statement in interpreter function. (#387)
* separate ByteCodeGenerator::m_tryStatementCount into multiple items for implementing es6 generator

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-08-23 16:55:34 +09:00
Boram Bae
90240a18f8 Set the function name Implicitly (#386)
* Pass more test262 tests

Signed-off-by: Boram Bae <boram21.bae@samsung.com>
2019-08-23 16:55:10 +09:00
Patrick Kim
e3a8fba176 Migrate to new bdwgc 8.0 GCutil & use cmake on building gc (#385)
Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-08-21 18:14:36 +09:00
Hyukwoo Park
c51ba1bf0e Fix several modules in parser (#384)
* check duplicated parameter names at once
* temporal nodes are allocated on stack
* remove unnecessary structs and flags
* sync parsing part of default parameter to that of esprima code

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-08-21 15:16:05 +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
Zoltan Herczeg
9ff6ee34c5 Don't add empty function expression names to scopes. (#373)
Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-08-19 11:20:20 +09:00
Patrick Kim
8855166418 Enhance develoment productivity (#366)
* Add ESCARGOT_ASAN options for debug
* Throw statement should have correct line:column number
* Fix bug in sunspider-js in test driver. if we want to run sunspider test cases at once, excution order is important because some test ruins GlobalObject

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-08-14 11:10:21 +09:00
Hyukwoo Park
c28a8f6858 Skip the parsing of arrow function body in scan mode (#362)
* arrow function body is skipped in scan mode to match parseSingleFunctionChildIndex consistently with normal function body block
* extract parameter names right after pushing a scope context

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-08-13 17:00:38 +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
Robert Fancsik
2113ddd673 Fix arrow function bugs related to lazy instantiation (#353)
Fixed a bug when an arrow function with block braces is inside an arrow function without braces handled incorrently during an outer function lazy instantiation.
The inner arrow function treated the most outer simple function as its parent instead of the outer arrow function due to the invalid use of config.parseSingleFunction.
Also the 0 parseFunctionIndex must be valid for arrow functions as well during the lazy instantiation.

This patch fixes #343.

Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-08-08 09:53:39 +09:00
Boram Bae
de65761ac7 Implement GeneratorFunction constructor (#350)
* Fix some bugs
* Pass more test262 tests

Signed-off-by: Boram Bae <boram21.bae@samsung.com>
2019-08-06 22:12:49 +09:00
Hyukwoo Park
49266b6c9f Create rest parameter through bytecode interpretation (#348)
* CreateRestElement bytecode is newly added for generating a rest parameter
* RestElementNode is added to handle patterns in rest parameter later
* rest parameter is created at the first part of the function body execution

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-08-06 13:38:25 +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
Zoltan Herczeg
8708e4202c Only loops with label can be target of continue statement with label. (#345)
Note: a loop can have multiple labels.

Fixes #330.

Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-08-02 14:45:55 +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
Hyukwoo Park
f94e8fcd11 Fix ScanExpressionResult in parser to store AtomicString info (#326)
* ScanExpresionResult stores additional AtomicString info to sync with esprima code more intuitively
* scanner for groupExpression module is updated

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-07-25 20:19:40 +09:00
Hyukwoo Park
34867f39fe Enable rest element for arrow function (#322)
* Parser::groupExpression is fixed according to the esprima code
* passed two v8 TCs

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-07-24 10:11:29 +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
Robert Fancsik
ef59096112 Implement the lexical scoping (#285)
This patch introduces the let and const keyword and all the related lexical scoping rules.

Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-07-05 13:38:11 +09:00
Patrick Kim
c0c83ad0d6 Prepare for implementing es2015 specs (#304)
* Remove ES2015, PROMISE, PROXY, TYPEDARRAY defines
* Change test262 from 5.1 to 2015

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2019-07-04 15:18:23 +09:00
Hyukwoo Park
6577d2dac9 Merge parsing and bytecode generation process (#297)
* in most cases, parsing and bytecode generation process runs sequentially
* parsing error throws SyntaxError exception inside sandbox and this exception will be catched by the sandbox
* clear up some complicated code

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-07-04 15:17:27 +09:00
Hyukwoo Park
2b145ef54c
Update coding style guide (#296)
* reformat all single logical expression based on the new rule

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2019-07-03 15:42:41 +09:00
Robert Fancsik
9166b2de38 Implement the generator functions (#270)
Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-06-10 11:55:14 +09:00