Commit graph

191 commits

Author SHA1 Message Date
Seonghyun Kim
e7221f4211 Fix labeled continue targeting a for-of loop (Issue #1577 Crash #1)
`L: for (const v of [...]) { continue L; }` aborted with
Assertion `!v.isEmpty()' failed, and `continue OUTER` from a nested
loop silently terminated the script.

A `continue <label>` whose label targets a for-of loop was left to be
resolved by LabelledStatementNode after the loop body, by which point
the for-of iterator-cleanup try block had registered the jump as a
complex case. It was then morphed into a JumpComplexCase that unwound
the try block, wrongly closing the iterator and leaving an empty Value
in the result register.

A previous per-loop attempt (8fd141b2) was reverted (60b1202a) because
a single m_currentLoopLabel leaked into nested loops and broke test262.

Track all labels directly targeting a loop (m_currentLoopLabels), clear
the list when entering each loop body so nested loops never inherit it,
and let for-of/for-in resolve continues for its own labels to
continuePosition (a plain jump, identical to an unlabeled continue)
before the try block is registered as a complex case.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-06-17 10:06:57 +09:00
Seonghyun Kim
0a2fcaaf5e Add missing m_currentLoopLabel field and fix Crashes #1-2
- Add m_currentLoopLabel to ByteCodeGenerateContext for tracking labeled loop labels (Issue #1571)
- Fix Crash #1: Add bounds checking in inline cache proto traverse with std::min clamping
- Fix Crash #2: Check hasBinding before initializeBinding to prevent assertion on unreachable code paths

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-06-16 15:35:01 +09:00
Seonghyun Kim
95036c339e Evaluate destructuring correctly
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2026-01-07 12:20:48 +09:00
Seonghyun Kim
fff09af8c3 Implement basic of await using statement
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2025-08-21 17:22:15 +09:00
Seonghyun Kim
954b5bc77f Implement basic of using variable
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2025-08-21 17:22:15 +09:00
Seonghyun Kim
795aa354f1 Fix print error on ByteCodeGenerator
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2025-06-02 12:45:48 +09:00
HyukWoo Park
a57df7576b Fix memory leaks in Debugger
* shared structure `BreakpointLocationsInfo` between debuggger and ByteCodeBlock can cause memory leaks
* correctly delete each `BreakpointLocationsInfo`

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2025-01-17 10:44:49 +09:00
Seonghyun Kim
7365c2ae4b Fix crash when got stack overflow error while computing bytecode position
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2024-09-24 10:18:56 +09:00
HyukWoo Park
f039511557 Fix calculation of outer limit of complex jump correctly
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2024-05-02 10:17:14 +09:00
HyukWoo Park
01c132434c Fix missing parameters in collectByteCodeLOCData
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2024-03-20 14:57:06 +09:00
HyukWoo Park
023b7ea014 Implement general tail call optimization
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2024-02-20 17:16:10 +09:00
HyukWoo Park
c4ab1cf57d Merge tail call bytecodes
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2024-02-05 14:19:01 +09:00
Seonghyun Kim
2b6e3fcc7d Update object creation code from script
* Use ObjectCreatePrepare code everytime
* Implement simple inline-cache object structure in ObjectCreatePrepare

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2024-02-01 10:49:00 +09:00
Seonghyun Kim
bd95de3c46 Implement more things for CreateObjectPrepare operation
* It should support methods and spread element

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2024-01-18 16:40:37 +09:00
Seonghyun Kim
ded2d1145e Introduce new way of create object in script
* Prepare the property and key list before object creation
* The new way reduce size of object structure with transition

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2024-01-18 16:40:37 +09:00
Seonghyun Kim
b0543cfe9c Use realloc for ByteCodeGeneration
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2023-12-28 09:31:13 +09:00
Seonghyun Kim
5d59757208 Optimize JSON.parse with large input
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2023-12-07 16:36:24 +09:00
Seonghyun Kim
195039d901 Revise computing and using stack limit
* Compute stack limit correctly through pthread API or Windows internal API
* Store stack limit in TLS(or global) not a VMInstance or ExecutionState

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2023-11-20 13:31:17 +09:00
Seonghyun Kim
48150217a8 Divide ExectuionState to ExecutionState and ExtendedExecutionState(with rareData)
* This path reduce gc_malloc count for try-catch, with, generator, async function

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2023-11-20 13:31:17 +09:00
HyukWoo Park
4581040747 Implement TCO for try-catch-finally block
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2023-11-08 15:16:42 +09:00
HyukWoo Park
e84107d418 Remove unused parameters in ByteCode macro
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2023-05-31 12:49:24 +09:00
HyukWoo Park
1fbf4872c7 Add a build option of tail call optimization
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2023-05-08 17:05:02 +09:00
HyukWoo Park
283873a291 Implement basic tail call optimization for normal function
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2023-05-03 11:18:25 +09:00
HyukWoo Park
0e0b759817 Include breakpoint bytecodes only for debugger mode
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2023-05-03 11:18:25 +09:00
HyukWoo Park
02e9b999e9 Fix error in optional chaining
* should trigger an exception when callee or target object is indeed undefined in optional chaining

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2023-04-28 12:14:30 +09:00
HyukWoo Park
c35bd083b5 Remove unused member in ByteCodeGenerateContext
* remove m_openedNonBlockEnvCount

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2023-04-17 09:16:01 +09:00
HyukWoo Park
c8cc70d83e Update Stack Overflow checker and disabler
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2023-04-17 09:16:01 +09:00
HyukWoo Park
53289897e8 Add AssignmentExpressionNode interface
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2023-04-03 11:22:51 +09:00
HyukWoo Park
bf3f885519 Remove cycle dependency from interpreter to parser
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2023-04-03 11:22:51 +09:00
Seonghyun Kim
a6ec162bd8 Fix bugs
* if there is too big expression, bytecode generation can be failed
* fix some errors on 64-bit platform through using int

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2023-03-30 13:10:13 +09:00
HyukWoo Park
9f93022d78 Unlink circular dependency between runtime and parser source codes
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2023-03-28 16:17:00 +09:00
HyukWoo Park
4c5a226df4 Fix a bug in virtual stack access
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2023-01-17 13:03:18 +09:00
HyukWoo Park
81bcf2ed13 Enable threaded interpreter for arm64 architecture
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2023-01-05 10:44:31 +09:00
HyukWoo Park
79c3b4c73f Fix a bug in explicitly declared funtion name with exception case
* remove a redundant bytecode addition in node line info calculation

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2022-07-15 15:31:37 +09:00
HyukWoo Park
f23646ca1b Fix debugger to match with the updated vscode extension
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2022-06-24 11:09:13 +09:00
Zoltan Herczeg
ae893f84c6 Support eval code debugging
Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2022-05-27 14:57:08 +09:00
Seonghyun Kim
25771515ff Merge Equals, NotEquals binary opcodes into one opcode
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2022-05-27 09:54:04 +09:00
HyukWoo Park
ebd5a42641 Fix backtrace info within eval code
* collect backtrace info including eval codes

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2022-05-20 08:44:14 +09:00
HyukWoo Park
9f901623dd Enable first breakpoint for Script created by initializeFunctionScript
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2022-04-18 17:19:19 +09:00
HyukWoo Park
02aac43bcf Minor fix for debugger
* debugger always stops at the start of new Script execution
* BreakpointLocationsInfo is added to debugger when Escargot generates bytecode for execution only

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2022-04-18 17:19:19 +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
HyukWoo Park
d0716850af Rename required register numbers for ByteCodeBlock
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2022-04-06 09:55:14 +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
Seonghyun Kim
c9f14d2a87 Implement ScriptSimpleFunctionObject for enhance function call performance
many general function can use ScriptSimpleFunctionObject.
It has simple call operation

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2022-03-23 10:53:36 +09:00
Seonghyun Kim
400507c0f3 Treat parsingEnabled flag in Debugger correctly
* turn on parserEnable flag in ScriptParser only
* Always store breakpointLocations in debugger(debugger can be turn on later)

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
2021-12-29 15:58:08 +09:00
Zoltan Herczeg
a481cd6dd8 Start creating a debugger API
- The debugger callbacks are implemented as class
- Using std::vector for storing data

Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-12-10 16:46:22 +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
Zoltan Herczeg
56157aaa74 Simplify the parsing API of the debugger.
Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-11-26 14:00:03 +09:00
Zoltan Herczeg
e3b1a9f5e6 Introduce abstract base class for debugger
Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-11-23 10:52:17 +09:00