diff --git a/just.cc b/just.cc index 23463c534..fe94d4656 100644 --- a/just.cc +++ b/just.cc @@ -63,21 +63,21 @@ void just::builtins_add (const char* name, const char* source, void just::SET_METHOD(Isolate *isolate, Local recv, const char *name, FunctionCallback callback) { recv->Set(String::NewFromUtf8(isolate, name, - NewStringType::kNormal).ToLocalChecked(), + NewStringType::kInternalized).ToLocalChecked(), FunctionTemplate::New(isolate, callback)); } void just::SET_MODULE(Isolate *isolate, Local recv, const char *name, Local module) { recv->Set(String::NewFromUtf8(isolate, name, - NewStringType::kNormal).ToLocalChecked(), + NewStringType::kInternalized).ToLocalChecked(), module); } void just::SET_VALUE(Isolate *isolate, Local recv, const char *name, Local value) { recv->Set(String::NewFromUtf8(isolate, name, - NewStringType::kNormal).ToLocalChecked(), + NewStringType::kInternalized).ToLocalChecked(), value); } @@ -254,7 +254,6 @@ v8::MaybeLocal OnDynamicImport(v8::Local context, v8::Local referrer, v8::Local specifier, v8::Local import_assertions) { -fprintf(stderr, "OnDynamicImport\n"); v8::Local resolver = v8::Promise::Resolver::New(context).ToLocalChecked(); v8::MaybeLocal promise(resolver->GetPromise()); @@ -559,7 +558,8 @@ void just::Modules(const FunctionCallbackInfo &args) { } void just::HRTime(const FunctionCallbackInfo &args) { - args.GetReturnValue().Set(BigInt::New(args.GetIsolate(), just::hrtime())); + uint64_t* ptr = reinterpret_cast(Local::Cast(args[0])->Uint64Value()); + *ptr = just::hrtime(); } void just::Init(Isolate* isolate, Local target) { diff --git a/just.h b/just.h index 7bfcbd66d..902648100 100644 --- a/just.h +++ b/just.h @@ -8,6 +8,7 @@ #include #include #include +#include namespace just { diff --git a/just.js b/just.js index e1e9d16ce..00d30bdc7 100644 --- a/just.js +++ b/just.js @@ -1,4 +1,14 @@ (function () { + function wrapHRTime (hrtime) { + const buf = new ArrayBuffer(8) + const u64 = new BigUint64Array(buf) + const address = buf.getAddress() + return () => { + hrtime(address) + return u64[0] + } + } + function wrapMemoryUsage (memoryUsage) { const mem = new BigUint64Array(16) return () => { @@ -289,6 +299,7 @@ just.net.setNonBlocking = setNonBlocking just.require = global.require = require just.require.cache = cache + just.hrtime = wrapHRTime(just.hrtime) just.memoryUsage = wrapMemoryUsage(just.memoryUsage) just.cpuUsage = wrapCpuUsage(just.sys.cpuUsage) just.rUsage = wrapgetrUsage(just.sys.getrUsage)