Commit graph

22 commits

Author SHA1 Message Date
Ben Noordhuis
ac4cd17bb5
Track line and column numbers for expressions (#781)
Commit 73cc00e reduced the number of emitted source locations a great
deal but it resulted in at least one observable regression:

    export default async function f() {
         return "abc" + x
    }
    f() // ReferenceError should point to 2:20 but pointed to 1:1

Emit source locations for expressions again. Increases the average
number of source locations by about 15%. Non-scientifically tested
by counting source locations emitted when parsing the test suite
before and after.

No test because we currently cannot easily test stack traces coming
from module imports.

Fixes: https://github.com/quickjs-ng/quickjs/issues/779
2025-01-05 22:20:43 +01:00
Ben Noordhuis
5b609f15af
Optimize derived class construction (#753)
We were emitting gobs of inefficient bytecode that created an arguments
array on the stack, then applied it to the parent constructor.

Add a new opcode for initializing a derived class. Speeds up construction
by 500%, although sadly that is not visible in the web-tooling-benchmark,
only in micro-benchmarks.

Fixes: https://github.com/quickjs-ng/quickjs/issues/752
2025-01-05 22:01:37 +01:00
Saúl Ibarra Corretgé
f7f70fc579 Fix leak when interpreter exits due to exception
Fixes: https://github.com/quickjs-ng/quickjs/issues/720
2024-11-25 11:07:07 +01:00
Saúl Ibarra Corretgé
284510f781 Make Iterator.from spec compliant
Create a proper wrapper around the inner iterator and proxy the calls to
next / return.
2024-11-15 13:35:25 +01:00
Saúl Ibarra Corretgé
c41ee4f15f Implement Iterator.prototype.drop
Includes the scaffold for other iterator helper methods that require an
Iterator Helper object.
2024-11-11 22:25:24 +01:00
Ben Noordhuis
73cc00e57e
Improve line:column tracking (#660)
Emit source locations manually for more precise tracking. Don't infer
them from emitted bytecode opcodes because that leads to inaccurate
and sometimes surprising results.

Speeds up code generation (although infinitesimally) as a bonus.

Fixes: https://github.com/quickjs-ng/quickjs/issues/236
2024-11-07 22:03:00 +01:00
Ben Noordhuis
37fe427d59
Add resizable ArrayBuffers (#646)
This commit implements resizable ArrayBuffers - RABs for short - and
extends typed arrays (TAs) to support fixed-length and length-tracking
modes.

SharedArrayBuffers (SABs) also support the maxByteLength option now but
I cheated and allocate all memory upfront because atomically resizing
memory allocations is hard and this commit is already big and complex.

The lion's share is updating all the TA prototype methods to deal with
RABs resizing underneath them. Method arguments can be arbitrary objects
with arbitrary .valueOf methods and arbitrary side effects, like...
resizing the RAB we're currently operating on.

Fixes: https://github.com/quickjs-ng/quickjs/issues/477
2024-11-05 21:55:42 +01:00
Saúl Ibarra Corretgé
cc11a829e8
Prefix stdlib modules with "qjs:"
Fixes: https://github.com/quickjs-ng/quickjs/issues/616
2024-10-24 22:24:03 +02:00
Ben Noordhuis
aefdee7b9a
Add Iterator (#548) 2024-09-24 22:07:29 +02:00
Saúl Ibarra Corretgé
3a96b9cb6f Support private brand checks
Fixes: https://github.com/quickjs-ng/quickjs/issues/541
Ref: 3ab1c2b314
2024-09-24 18:37:02 +02:00
Saúl Ibarra Corretgé
c25aad7b49
Add ability to (de)serialize symbols
Fixes: https://github.com/quickjs-ng/quickjs/issues/481
2024-09-24 10:01:08 +02:00
Saúl Ibarra Corretgé
5f5170796e
regexp: fixed the zero advance logic in quantifiers
Ref: 10fc744ae4
2024-09-14 22:00:48 +02:00
zeromake
902cc2cf0e
Add native module support on Windows 2024-09-10 22:47:40 +02:00
Ben Noordhuis
8e81a88a18
Add Set.prototype.union (#499) 2024-09-06 09:24:21 +02:00
Ben Noordhuis
9bc41a8a00
Add Float16Array (#491) 2024-09-03 20:32:17 +02:00
Ben Noordhuis
3a58376485
Support (de)serializing Map and Set objects (#483)
Fixes: https://github.com/quickjs-ng/quickjs/issues/482
2024-08-19 12:20:42 +02:00
Tom Lienard
d3da56b630 Sync TLA implementation with upstream
Fixes: https://github.com/quickjs-ng/quickjs/issues/339
2024-06-07 15:46:44 +02:00
Charlie Gordon
f326a7a195
Add strip option in qjsc to reduce object size (#388)
- `-s` strips the source code
- `-ss` strips source and line/column numbers information
- `qjsc repl.js` generates an object size of **105726** bytes
- `qjsc -s repl.js` generates an object size of **20853** bytes
- `qjsc -ss repl.js` generates an object size of only **16147** bytes
- compile repl.js with `-ss`
- bump byte code version to 12
2024-04-19 08:41:12 +02:00
Charlie Gordon
5797f2a716
Improve DUMP_READ_OBJECT (#382)
- improve `JS_DumpString`: use `L` prefix for wide strings
- dump variable kind and flags for locals and closures
- disassemble byte code in DUMP_READ_OBJECT
- pass start_pos to `dump_byte_code` and `dump_single_byte_code`
- write constant pool before function bytecode (bump version to 11)
- update generated code
2024-04-16 09:24:21 +02:00
Saúl Ibarra Corretgé
569b238ec4
Add cross-platform Atomics support
Fixes: https://github.com/quickjs-ng/quickjs/issues/1
2024-04-02 21:50:42 +02:00
Ben Noordhuis
c7ca3febd3
Don't serialize IC opcodes (#334)
Translate IC opcodes to their non-IC variants before writing them out.
Before this commit they were not byte-swapped properly, breaking the
ability to load serialized bytecode containing ICs on systems with
different endianness. Inline caches are recomputed as needed now.

A pleasing side effect of this change is that serialized bytecode is,
on average, a little smaller because fewer atoms are duplicated now.
2024-03-27 12:07:11 +01:00
Saúl Ibarra Corretgé
7f928d289f Check-in all generated C files
Closes: https://github.com/quickjs-ng/quickjs/issues/262
2024-02-13 09:49:57 +01:00