Skip to content

Commit 7679642

Browse files
梅世祺shiqimei
梅世祺
authored andcommitted
refactor: move quickjs into the root path
1 parent 0319d76 commit 7679642

File tree

350 files changed

+49433
-7148
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

350 files changed

+49433
-7148
lines changed
File renamed without changes.
File renamed without changes.

README.md

+61-50
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,74 @@
1-
# QuickJS Android
2-
3-
> Self-maintained QuickJS Android Bindings.
4-
5-
## Usage
6-
7-
1. Download the latest `.aar` archive from [release](https://github.com/shiqimei/quickjs-android/releases) page;
8-
2. In Android Studio: `File > New > New Module > Import .JAR/.AAR Package`, locate `.aar`, click `Finish`.
9-
10-
```Java
11-
QuickJS quickJS = new QuickJS.Builder().build();
12-
try (JSRuntime runtime = quickJS.createJSRuntime()) {
13-
try (JSContext context = runtime.createJSContext()) {
14-
String script1 = "" +
15-
"function fibonacci(n) {" +
16-
" if (n == 0 || n == 1) return n;" +
17-
" return fibonacci(n - 1) + fibonacci(n - 2);" +
18-
"}";
19-
// Evaluate a script without return value
20-
context.evaluate(script1, "fibonacci.js");
21-
22-
String script2 = "fibonacci(10);";
23-
// Evaluate a script with return value
24-
int result = context.evaluate(script2, "fibonacci.js", int.class);
25-
assertEquals(55, result);
26-
}
27-
}
28-
```
1+
# QuickJS
292

30-
See [Usages.md](./Usages.md) for advanced usages.
3+
> Self-maintained QuickJS
314
32-
## Develop
5+
### Optimizations
336

34-
```bash
35-
git clone --recurse-submodules https://github.com/shiqimei/quickjs-android.git
7+
In addition to the relevant features and optimizations in the [TODO](https://github.com/openwebf/quickjs/blob/master/TODO) file, the more important optimizations are:
8+
9+
- [x] Column number
10+
- [ ] Basic Debugger API
11+
- [x] Poly IC
12+
- [x] Self Poly IC
13+
- [x] Prototype Poly IC
14+
- [x] Replace malloc To [mimalloc](https://github.com/microsoft/mimalloc)
15+
- [ ] Improve The Performance Of GC
16+
17+
In our plan, we first complete the above optimizations and then gradually add the remaining parts.
18+
19+
### Develop
20+
21+
```shell
22+
> mkdir build
23+
> cd build
24+
> cmake .. && make -j4
3625
```
3726

38-
Open the folder `quickjs-android` in Android Studio.
27+
you can find `libquickjs.a` in lib folder and `qjs` / `qjsc` / `run-test262` in bin folder.
3928

40-
## Benchmark
29+
#### Debug
4130

42-
This is a non-serious benchmark. The purpose is to compare the performance of QuickJS and V8 on Android.
31+
Pass this argument to cmake enable debug log on release build.
4332

44-
| Engine | v8 | QuickJS (Script Mode) | QuickJS (Bytecode Mode) |
45-
| :----: | :--: | :-------------------: | :---------------------: |
46-
| init | 30ms | 18ms | 18ms |
47-
| eval | 29ms | 282ms | 48ms |
48-
| total | 59ms | 300ms | 56ms |
33+
```
34+
-DCONFIG_DEBUG_ON_RELEASE=1
35+
```
36+
37+
### Tests
4938

50-
- Device: Huawei P30 Pro (Kirin 980), Android 10.
51-
- Test JavaScript File: `asset:/sonic.js` (189 KB).
39+
```bash
40+
Average memory statistics for 75250 tests:
41+
42+
NAME COUNT SIZE
43+
memory allocated 1011 124975 (123.6 per block)
44+
memory used 967 117030 (0 overhead, 8.2 average slack)
45+
atoms 532 26858 (50.5 per atom)
46+
objects 172 12425 (72.2 per object)
47+
properties 876 15798 (5.1 per object)
48+
shapes 60 13809 (230.2 per shape)
49+
bytecode functions 13 1685
50+
bytecode 13 931 (71.6 per function)
51+
C functions 100
52+
arrays 1
53+
fast arrays 1
54+
elements 1 16 (1.0 per fast array)
55+
56+
Result: 515/75250 errors, 1392 excluded, 7972 skipped, 515 new
57+
```
5258

53-
### Conclusion
5459

55-
1. Even when operating in bytecode mode, QuickJS's evaluation time is notably higher than V8's, and this disparity intensifies as the JavaScript file size increases.
56-
2. QuickJS's initialization time is slightly lower than V8's, and this advantage is constant despite of file sizes.
60+
### Benchmark
5761

58-
## Acknowledgement
62+
> - Apple M1 Pro
63+
> - macOS Monterey 12.2.1
64+
> - Clang 13.0.0 arm64-apple-darwin21.3.0
5965
60-
1. [bellard/quickjs](https://github.com/bellard/quickjs) QuickJS official repository.
61-
2. [seven332/quickjs-android](https://github.com/seven332/quickjs-android) QuickJS Android Wrapper.
62-
3. [openwebf/quickjs](https://github.com/openwebf/quickjs) Optimized quickjs mantained by OpenWebF team.
63-
4. [taoweiji/quickjs-android](https://github.com/taoweiji/quickjs-android) Android Bindings for QuickJS, A fine little javascript engine.
66+
| | bellard/quickjs (2788d71) | openwebf/quickjs (latest) |
67+
| ------------- | ---------- | ---------- |
68+
| Richards | 1188 | 1457 |
69+
| Crypto | 1443 | 1527 |
70+
| RayTrace | 744 | 1995 |
71+
| NavierStokes | 2775 | 2979 |
72+
| DeltaBlue | 1100 | 1595 |
73+
| Total score | 1312 | 1840 (+40.2%) |
74+
| File Size(KB) | 1.3M | 1.4M |

quickjs/TODO renamed to TODO

File renamed without changes.

Usages.md

-183
This file was deleted.

quickjs/VERSION renamed to VERSION

File renamed without changes.

app/.gitignore

-1
This file was deleted.

app/build.gradle

-69
This file was deleted.

0 commit comments

Comments
 (0)