Skip to content

Commit

Permalink
update v8 and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
billywhizz committed Sep 4, 2022
1 parent 259b493 commit d2675a1
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CC=g++
RELEASE=0.1.12
RELEASE=0.1.13
INSTALL=/usr/local/bin
LIBS=lib/loop.js lib/path.js lib/fs.js lib/process.js lib/build.js lib/repl.js lib/acorn.js lib/configure.js
MODULES=modules/net/net.o modules/epoll/epoll.o modules/fs/fs.o modules/sys/sys.o modules/vm/vm.o
Expand Down
7 changes: 4 additions & 3 deletions just.cc
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,10 @@ v8::Local<v8::Value> execModule(v8::Local<v8::Module> mod,
}

v8::MaybeLocal<v8::Promise> OnDynamicImport(v8::Local<v8::Context> context,
v8::Local<v8::ScriptOrModule> referrer,
v8::Local<v8::String> specifier,
v8::Local<v8::FixedArray> import_assertions) {
v8::Local<v8::Data> host_defined_options,
v8::Local<v8::Value> resource_name,
v8::Local<v8::String> specifier,
v8::Local<v8::FixedArray> import_assertions) {
v8::Local<v8::Promise::Resolver> resolver =
v8::Promise::Resolver::New(context).ToLocalChecked();
v8::MaybeLocal<v8::Promise> promise(resolver->GetPromise());
Expand Down
1 change: 0 additions & 1 deletion just.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/utsname.h>
#include <v8-fast-api-calls.h>

namespace just {

Expand Down
6 changes: 3 additions & 3 deletions just.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@
const timerfd = just.sys.timer(repeat, timeout)
loop.add(timerfd, (fd, event) => {
callback()
just.net.read(fd, buf, 0, buf.byteLength)
just.fs.read(fd, buf, 0, buf.byteLength)
if (repeat === 0) {
loop.remove(fd)
just.net.close(fd)
just.fs.close(fd)
}
})
return timerfd
Expand All @@ -214,7 +214,7 @@

function clearTimeout (fd, loop = just.factory.loop) {
loop.remove(fd)
just.net.close(fd)
just.fs.close(fd)
}

class SystemError extends Error {
Expand Down
18 changes: 8 additions & 10 deletions lib/repl.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const { net, sys, vm } = just
const { fs, sys, vm } = just
const { EPOLLERR, EPOLLHUP } = just.loop
const { errno } = just.sys
const { EAGAIN } = just.net
const { errno, EAGAIN, O_NONBLOCK } = just.sys

const stringify = (o, sp = ' ') => JSON.stringify(o, (k, v) => (typeof v === 'bigint') ? v.toString() : v, sp)

Expand All @@ -18,7 +17,7 @@ function writeString (fd, str) {
let bytes = 0
for (let i = 0, off = 0; i < chunks;) {
const towrite = Math.min(len - off, 4096)
bytes = net.write(fd, buf, towrite, off)
bytes = fs.write(fd, buf, towrite, off)
if (bytes === 0) {
// closing
break
Expand All @@ -45,22 +44,21 @@ function notEmpty (result) {

function repl (loop = just.factory.loop, buf = new ArrayBuffer(4096), stdin = sys.STDIN_FILENO, stdout = sys.STDOUT_FILENO) {
const { EPOLLIN } = just.loop
const { O_NONBLOCK, EAGAIN } = just.net
sys.fcntl(stdin, sys.F_SETFL, (sys.fcntl(stdin, sys.F_GETFL, 0) | O_NONBLOCK))
const current = []
const context = {}
let r = loop.add(stdin, async (fd, event) => {
if (event & EPOLLERR || event & EPOLLHUP) {
net.close(fd)
fs.close(fd)
return
}
if (event & EPOLLIN) {
const bytes = net.read(fd, buf, 0, buf.byteLength)
const bytes = fs.read(fd, buf, 0, buf.byteLength)
if (bytes < 0) {
const err = sys.errno()
if (err !== EAGAIN) {
just.print(`read error: ${sys.strerror(err)} (${err})`)
net.close(fd)
fs.close(fd)
}
return
}
Expand All @@ -75,8 +73,8 @@ function repl (loop = just.factory.loop, buf = new ArrayBuffer(4096), stdin = sy
if (command === '.exit') {
loop.remove(stdin)
loop.remove(stdout)
net.close(stdin)
net.close(stdout)
fs.close(stdin)
fs.close(stdout)
return
}
let result
Expand Down
3 changes: 1 addition & 2 deletions main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ int main(int argc, char** argv) {
setvbuf(stderr, nullptr, _IONBF, 0);
std::unique_ptr<v8::Platform> platform = v8::platform::NewDefaultPlatform();
v8::V8::InitializePlatform(platform.get());
v8::V8::Initialize();
v8::V8::SetFlagsFromString(v8flags);
if (_v8flags_from_commandline == 1) {
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
}
v8::V8::Initialize();
register_builtins();
if (_use_index) {
just::CreateIsolate(argc, argv, just_js, just_js_len,
Expand All @@ -21,7 +21,6 @@ int main(int argc, char** argv) {
just::CreateIsolate(argc, argv, just_js, just_js_len, start);
}
v8::V8::Dispose();
v8::V8::ShutdownPlatform();
platform.reset();
return 0;
}

0 comments on commit d2675a1

Please sign in to comment.