Skip to content

Commit e5a5002

Browse files
authored
Merge pull request #35 from billywhizz/main
V8 Release 12.4
2 parents 1c77804 + 402280a commit e5a5002

33 files changed

+801
-257
lines changed

BOOK.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,25 @@ gzip compressed binary from github.
1616
on linux/x64
1717

1818
```shell
19-
curl -L -o lo.gz https://github.com/just-js/lo/releases/download/0.0.15-pre/lo-linux-x64.gz
19+
curl -L -o lo.gz https://github.com/just-js/lo/releases/download/0.0.16-pre/lo-linux-x64.gz
2020
```
2121

2222
on linux/arm64
2323

2424
```shell
25-
curl -L -o lo.gz https://github.com/just-js/lo/releases/download/0.0.15-pre/lo-linux-arm64.gz
25+
curl -L -o lo.gz https://github.com/just-js/lo/releases/download/0.0.16-pre/lo-linux-arm64.gz
2626
```
2727

2828
on macos/x64
2929

3030
```shell
31-
curl -L -o lo.gz https://github.com/just-js/lo/releases/download/0.0.15-pre/lo-mac-x64.gz
31+
curl -L -o lo.gz https://github.com/just-js/lo/releases/download/0.0.16-pre/lo-mac-x64.gz
3232
```
3333

3434
on macos/arm64 (apple silicon)
3535

3636
```shell
37-
curl -L -o lo.gz https://github.com/just-js/lo/releases/download/0.0.15-pre/lo-mac-arm64.gz
37+
curl -L -o lo.gz https://github.com/just-js/lo/releases/download/0.0.16-pre/lo-mac-arm64.gz
3838
```
3939

4040
Then, we need to decompress the downloaded file and make it executable
@@ -122,7 +122,7 @@ let's check the version number of lo and the embedded JS engine it is using
122122
```shell
123123
./lo --version
124124

125-
0.0.15-pre
125+
0.0.16-pre
126126
```
127127

128128
### evaluating JavaScript
@@ -165,9 +165,9 @@ lo has a very basic repl which you can invoke as follows
165165
⬛⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬛
166166
⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛
167167

168-
lo 0.0.15-pre v8 12.3.219.12
168+
lo 0.0.16-pre v8 12.4.254.18
169169
arch x64 os linux
170-
boot 5.67 ms rss 34078720
170+
boot 6.02 ms rss 34996224
171171

172172
>
173173
```
@@ -181,8 +181,8 @@ we downloaded.
181181

182182
{
183183
version: {
184-
lo: "0.0.15-pre",
185-
v8: "12.3.219.12"
184+
lo: "0.0.16-pre",
185+
v8: "12.4.254.18"
186186
},
187187
...
188188
}

Makefile

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ CCARGS=-std=c++17 -c -fno-omit-frame-pointer -fno-rtti -fno-exceptions
66
CARGS=-c -fno-omit-frame-pointer
77
WARN=-Werror -Wpedantic -Wall -Wextra -Wno-unused-parameter
88
OPT=-O3
9-
VERSION=0.0.15-pre
10-
V8_VERSION=12.3
9+
VERSION=0.0.16-pre
10+
V8_VERSION=12.4
1111
RUNTIME=lo
1212
LO_HOME=$(shell pwd)
1313
BINDINGS=core.o inflate.a curl.o
1414
ARCH=x64
1515
os=linux
1616
TARGET=${RUNTIME}
1717
LIBS=-ldl -lcurl -lssl -lz
18-
V8_FLAGS=-DV8_COMPRESS_POINTERS -DV8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=0 -DV8_INTL_SUPPORT=1
18+
V8_FLAGS=-DV8_COMPRESS_POINTERS -DV8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=0 -DV8_INTL_SUPPORT=1 -DENABLE_HUGEPAGE
1919
LIB_DIRS=
2020

2121
ifeq ($(OS),Windows_NT)
@@ -41,7 +41,7 @@ else
4141
endif
4242
endif
4343

44-
.PHONY: help clean
44+
.PHONY: help clean cleanall check install
4545

4646
help:
4747
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9\/_\.-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@@ -65,10 +65,8 @@ v8/libv8_monolith.a: ## download the v8 static libary for linux/macos
6565
gzip -d v8/libv8_monolith.a.gz
6666
rm -f v8/libv8_monolith.a.gz
6767

68-
v8/v8_monolith.lib.zip: ## download the v8 static library for windows
68+
v8/v8_monolith.lib: ## download the v8 static library for windows
6969
curl -L -o v8/v8_monolith.lib.zip https://github.com/just-js/v8/releases/download/${V8_VERSION}/libv8_monolith-${os}-${ARCH}.zip
70-
71-
v8/v8_monolith.lib: v8/v8_monolith.lib.zip ## download the v8 static library for windows
7270
tar -C v8 -xf v8/v8_monolith.lib.zip
7371

7472
main.o: ## compile the main.cc object file
@@ -111,10 +109,8 @@ lib/inflate/em_inflate.c:
111109
lib/inflate/em_inflate.o: lib/inflate/em_inflate.h lib/inflate/em_inflate.c ## build the em_inflate object
112110
$(CC) -fPIC $(CARGS) $(OPT) -I. -I./v8 -I./v8/include -Ilib/inflate -o lib/inflate/em_inflate.o lib/inflate/em_inflate.c
113111

114-
inflate.o: lib/inflate/inflate.cc lib/inflate/em_inflate.h ## build the em_inflate object
112+
inflate.a: lib/inflate/em_inflate.o ## build the inflate binding
115113
$(CXX) -fPIC $(CCARGS) $(OPT) -I. -I./v8 -I./v8/include -Ilib/inflate $(WARN) ${V8_FLAGS} -o inflate.o lib/inflate/inflate.cc
116-
117-
inflate.a: inflate.o lib/inflate/em_inflate.o ## build the inflate binding
118114
ar crsT inflate.a inflate.o lib/inflate/em_inflate.o
119115

120116
check: ## run the runtime sanity tests

globals.d.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,12 @@ interface Core {
267267
prot: number,
268268
flags: number,
269269
fd: number,
270-
offset: number,
271-
buf: Uint32Array
272-
): void;
270+
offset: number
271+
): number;
272+
calloc(num: number, size: number): number;
273+
memcpy(dest: number, src: number, size: number): number;
274+
aligned_alloc(alignment: number, size: number): number;
275+
memmove(dest: number, src: number, size: number): number;
273276
fork(): number;
274277
sysconf(num: number): number;
275278
times(buf: TypedArray): number;

lib/ada/api.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,40 @@
11
import { lib_api_typed } from 'lib/@typify/typify.js';
22

33
const api = lib_api_typed({
4-
ada_parse: {
4+
parse: {
55
parameters: ['pointer', 'u32'],
66
pointers: ['const char*'],
7-
result: 'pointer'
7+
result: 'pointer',
8+
name: 'ada_parse'
89
},
9-
ada_parse_str: {
10+
parse_str: {
1011
parameters: ['string', 'u32'],
1112
pointers: ['const char*'],
1213
result: 'pointer',
1314
name: 'ada_parse'
1415
},
15-
ada_can_parse: {
16+
can_parse: {
1617
parameters: ['pointer', 'u32'],
1718
pointers: ['const char*'],
18-
result: 'u32'
19+
result: 'u32',
20+
name: 'ada_can_parse'
1921
},
20-
ada_can_parse_str: {
22+
can_parse_str: {
2123
parameters: ['string', 'u32'],
2224
pointers: ['const char*'],
2325
result: 'u32',
2426
name: 'ada_can_parse'
2527
},
26-
ada_get_components: {
28+
get_components: {
2729
parameters: ['pointer'],
2830
result: 'pointer',
29-
rpointer: 'const void*'
31+
rpointer: 'const void*',
32+
name: 'ada_get_components'
3033
},
31-
ada_free: {
34+
free: {
3235
parameters: ['pointer'],
33-
result: 'void'
36+
result: 'void',
37+
name: 'ada_free'
3438
}
3539
})
3640

lib/asm.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ function compile (code) {
2424
const address = mmap(0, code.length, PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE,
2525
-1, u32)
2626
assert(address)
27-
memcpy(address, code.ptr, code.length, u32)
28-
assert(addr(u32) === address)
27+
assert(memcpy(address, code.ptr, code.length) === address)
2928
assert(mprotect(address, code.length, PROT_EXEC | PROT_READ) === 0)
3029
return address
3130
}

lib/asm/assembler.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,10 @@ class Assembler {
194194
this.#instr.push(`push %${reg}`)
195195
if (idx < 8) {
196196
this.#codes.push([op_push_r64 + idx])
197-
return
197+
return this
198198
}
199199
this.#codes.push([rex(0, 0, 0, 1), op_push_r64 + (idx % 8)])
200+
return this
200201
}
201202

202203
// url: https://www.felixcloutier.com/x86/pop
@@ -211,19 +212,22 @@ class Assembler {
211212
this.#instr.push(`pop %${reg}`)
212213
if (idx < 8) {
213214
this.#codes.push([op_pop_r64 + idx])
214-
return
215+
return this
215216
}
216217
this.#codes.push([rex(0, 0, 0, 1), op_pop_r64 + (idx % 8)])
218+
return this
217219
}
218220

219221
// url: https://www.felixcloutier.com/x86/add
220222
add (reg, bytes) {
221-
return this.#add_or_sub(reg, bytes, 'add')
223+
this.#add_or_sub(reg, bytes, 'add')
224+
return this
222225
}
223226

224227
// url: https://www.felixcloutier.com/x86/sub
225228
sub (reg, bytes) {
226-
return this.#add_or_sub(reg, bytes, 'sub')
229+
this.#add_or_sub(reg, bytes, 'sub')
230+
return this
227231
}
228232

229233
// url: https://www.felixcloutier.com/x86/call
@@ -233,6 +237,7 @@ class Assembler {
233237
// Op/En: M
234238
// 1: ModRM:r/m (r)
235239
this.#call_or_jmp(address, reg, 'call')
240+
return this
236241
}
237242

238243
// url: https://www.felixcloutier.com/x86/jmp
@@ -242,6 +247,7 @@ class Assembler {
242247
// Op/En: M
243248
// 1: ModRM:r/m (r)
244249
this.#call_or_jmp(address, reg, 'jmp')
250+
return this
245251
}
246252

247253
// url: https://www.felixcloutier.com/x86/mov
@@ -255,6 +261,7 @@ class Assembler {
255261
this.#instr.push(`movabs $${address}, %${reg}`)
256262
this.#codes.push([rex(1, 0, 0, idx < 8 ? 0 : 1), op_mov_imm64 + (idx % 8),
257263
...as_eight_bytes(address)])
264+
return this
258265
}
259266

260267
movreg (src, dest) {
@@ -268,6 +275,7 @@ class Assembler {
268275
this.#instr.push(`mov %${src}, %${dest}`)
269276
this.#codes.push([rex(1, src_idx > 7 ? 1 : 0, 0, dest_idx > 7 ? 1 : 0),
270277
op_mov_reg_reg, mod_rm(dest_idx % 8, src_idx % 8)])
278+
return this
271279
}
272280

273281
movsrc (src, dest, off) {
@@ -282,7 +290,7 @@ class Assembler {
282290
this.#instr.push(`mov (%${src}), %${dest}`)
283291
this.#codes.push([rex(1, dest_idx > 7 ? 1 : 0, 0, src_idx > 7 ? 1 : 0),
284292
op_mov_mem_reg, mod_rm(src_idx % 8, dest_idx % 8, funny_registers.includes(src) ? 1 : 0)])
285-
return
293+
return this
286294
}
287295
this.#instr.push(`mov ${off}(%${src}), %${dest}`)
288296
if (src === 'rsp' || src === 'r12') {
@@ -302,6 +310,7 @@ class Assembler {
302310
op_mov_mem_reg, mod_rm(src_idx % 8, dest_idx % 8, 0b10), ...as_four_bytes(off)])
303311
}
304312
}
313+
return this
305314
}
306315

307316
movdest (src, dest, off) {
@@ -316,7 +325,7 @@ class Assembler {
316325
this.#instr.push(`mov %${src}, (%${dest})`)
317326
this.#codes.push([rex(1, src_idx > 7 ? 1 : 0, 0, dest_idx > 7 ? 1 : 0),
318327
op_mov_reg_mem, mod_rm(dest_idx % 8, src_idx % 8, funny_registers.includes(dest) ? 1 : 0)])
319-
return
328+
return this
320329
}
321330
this.#instr.push(`mov %${src}, ${off}(%${dest})`)
322331
if (dest === 'rsp' || dest === 'r12') {
@@ -336,11 +345,13 @@ class Assembler {
336345
op_mov_reg_mem, mod_rm(dest_idx % 8, src_idx % 8, 0b10), ...as_four_bytes(off)])
337346
}
338347
}
348+
return this
339349
}
340350

341351
ret () {
342352
this.#instr.push('ret')
343353
this.#codes.push([0xc3])
354+
return this
344355
}
345356

346357
reset () {
@@ -349,6 +360,10 @@ class Assembler {
349360
return this
350361
}
351362

363+
bytes () {
364+
return new Uint8Array(this.#codes.flat())
365+
}
366+
352367
get src () {
353368
const { codes, instr } = this
354369
return instr.map((v, i) => [`# ${codes[i].map(v => '0x' + v.toString(16))}`, v]).flat().join('\n') + '\n'

lib/asm/compiler.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ class Compiler {
2323
const address = mmap(0, code.length, PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE,
2424
-1, u32)
2525
assert(address)
26-
memcpy(address, code.ptr, code.length, u32)
27-
assert(addr(u32) === address)
26+
assert(memcpy(address, code.ptr, code.length) === address)
2827
assert(mprotect(address, code.length, PROT_EXEC | PROT_READ) === 0)
2928
return address
3029
}

0 commit comments

Comments
 (0)