-
Notifications
You must be signed in to change notification settings - Fork 55
the plan for sablejs 2.0 #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Will v2 include the ability to evaluate a raw javascript string without compiling it at build times first? That seems a big limitation at the moment if the goal of the project is to be able to be used as a secure vm for plugins. |
@fabiospampinato If the compiler is included, then there is a risk of being decompiled, and there should be no plans to put the compiler and interpreter together at this time. |
Hello, will sablejs-2.0 support some new features in ES2016+? |
@npc1054657282 maybe not, i have little time to maintance this project, but you can add es2016+ features by yourself when 2.0 released. |
Great work! I have two questions: |
No, it still runs with stack ops, don't need eval or new Funcation. But maybe the schedule will be late, i'm really really busy and have no passion for 2.0 implementation. At the same time, i learn some optimization from v8, i think it will faster than i think before. But it needs some time. |
Any progress? |
I have same question about the progress( |
有生之年系列+1 😭 |
sablejs 1.x has been running well on YoTest, but because of the private opcode design, we don't open all code for community(preventing decompiling). After discussions, sablejs 2.0 will plan to open all code! To reach this goal, we will make a major upgrade to the current code of 1.x, include:
1. remove the private opcode design and transform for the stack operation directly
2. dynamically import inner object for sandbox
1. Transform Directly
Since sablejs 1.x is fully stack-based vm, we will have a big loop to execute the relevant opcode code. However, this approach causes a significant performance loss due to the failure of branch prediction:
After using the latest d8 and perf for profiling, about 30% of the performance consumption is wasted. To solve this problem, and to make V8 better able to help us with JIT, we will perform the equivalent transform operation directly, consider the following example:
In 1.x, we will get linear opcode bytes, which will then be executed by vm. But in 2.0, we will compile directly to the following code:
Here, stack manipulation methods such as
__pushNumber
are still provided by runtime. In this way, together with the relevant compilation optimizations in 1.x, there will be a relatively large performance improvment for frequent execution(benchmark can be followed by DoppioJVM Web JIT implement).At the same time, this brings the benefit of not having to rely on opcode, so we can directly open all of sablejs's code.
2. Dynamically Import Inner Object
In most of the usage of the current feedback, it is basically using sablejs for JSVMP. But sablejs 1.x is mainly designed with sandbox as the core, after 2.0 we will mainly aim at JSVMP while taking into account the functionality of sandbox,(the Inner Object will be import on demand according to your needs).
Also, when you are using JSVMP only, sablejs 2.0 will get a very big performance improvment thanks to V8's object optimization!
I considered for releasing sablejs 2.0 in mid-2022, please look forward to it! 😁
The text was updated successfully, but these errors were encountered: