perf(quickjs): 关闭函数源码保留以节省运行时内存

Open
#582 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
50/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
c, rust
Domain
performance

Research direction

Start from the pinned QuickJS header linked in the issue, around JS_SetStripInfo and JS_STRIP_SOURCE (lines 936-939 of quickjs.h). The payload does not name where pocketjs creates its runtime, so find that call site first. Verify that the flag is set only for release builds, and check whether QuickJS-NG supports it, as the issue asks. Done means the release runtime sets the flag, and error stack line numbers still appear.

Written by the indexing model from the issue text.

Description

仓库固定版本的 Bellard QuickJS 支持在编译应用前调用:

JS_SetStripInfo(runtime, JS_STRIP_SOURCE);

这可以关闭函数源码副本的保留,减少运行时内存占用,同时保留字节码和错误堆栈的文件、行号信息。可考虑在发布运行时采用。

可见行为变化是 Function.prototype.toString() 不再返回原函数源码。此开关不移除包内用于编译执行的 app.js;QuickJS-NG 的支持需另行核对。

参考:固定版本 QuickJS API。

Dominant language
TypeScript
Stars
1.6k
Forks
88
PR merge metrics
No merged PRs in 30d

Getting set up

We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pocket-stack/pocketjs

All issues in pocket-stack/pocketjs

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.