// print how long each step took #define VERBOSE // // This loads up a JavaScriptCore global object which only has a "write" // global function and then calls eval // // // Usage: // ./cold-jsc-start // ./cold-jsc-start -e "write('hey')" // #include "root.h" #include #include #include #include #include #include #include #include using namespace JSC; JSC_DEFINE_HOST_FUNCTION(jsFunctionWrite, (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callframe)) { if (callframe->argumentCount() < 1) return JSValue::encode(jsUndefined()); JSValue arg1 = callframe->argument(0); JSValue toWriteArg = callframe->argument(1); auto &vm = globalObject->vm(); auto scope = DECLARE_CATCH_SCOPE(vm); int32_t fd = STDOUT_FILENO; if (callframe->argumentCount() > 1) { fd = arg1.toInt32(globalObject); RETURN_IF_EXCEPTION(scope, encodedJSValue()); } else { toWriteArg = arg1; } if (auto *buffer = jsDynamicCast(toWriteArg)) { auto *data = buffer->vector(); auto length = buffer->byteLength(); auto written = write(fd, data, length); return JSValue::encode(jsNumber(written)); } auto string = toWriteArg.toWTFString(globalObject); RETURN_IF_EXCEPTION(scope, encodedJSValue()); auto utf8 = string.utf8(); auto length = utf8.length(); auto written = write(fd, utf8.data(), length); return JSValue::encode(jsNumber(written)); } int main(int argc, char **argv) { if (argc < 2) { fprintf(stderr, "Usage: %s \n", argv[0]); return 1; } #ifdef VERBOSE auto stopwatch = Stopwatch::create(); stopwatch->start(); #endif { WTF::initializeMainThread(); JSC::initialize(); { JSC::Options::AllowUnfinalizedAccessScope scope; JSC::Options::useConcurrentJIT() = true; // JSC::Options::useSigillCrashAnalyzer() = true; JSC::Options::useWebAssembly() = true; JSC::Options::useSourceProviderCache() = true; // JSC::Options::useUnlinkedCodeBlockJettisoning() = false; JSC::Options::exposeInternalModuleLoader() = true; JSC::Options::useSharedArrayBuffer() = true; JSC::Options::useJIT() = true; JSC::Options::useBBQJIT() = true; JSC::Options::useJITCage() = false; JSC::Options::useShadowRealm() = true; JSC::Options::useResizableArrayBuffer() = true; JSC::Options::showPrivateScriptsInStackTraces() = true; JSC::Options::useSetMethods() = true; JSC::Options::assertOptionsAreCoherent(); } } #ifdef VERBOSE fprintf(stderr, "JSC::Initialize took %f ms\n", stopwatch->elapsedTime().milliseconds()); stopwatch->reset(); stopwatch->start(); #endif auto &vm = JSC::VM::create(JSC::HeapType::Large).leakRef(); vm.heap.acquireAccess(); #ifdef VERBOSE fprintf(stderr, "JSC::VM::create took %f ms\n", stopwatch->elapsedTime().milliseconds()); stopwatch->reset(); stopwatch->start(); #endif JSC::JSLockHolder locker(vm); auto *globalObject = JSC::JSGlobalObject::create( vm, JSC::JSGlobalObject::createStructure(vm, JSC::jsNull())); #ifdef VERBOSE fprintf(stderr, "JSC::JSGlobalObject::create took %f ms\n", stopwatch->elapsedTime().milliseconds()); stopwatch->reset(); stopwatch->start(); #endif JSC::gcProtect(globalObject); globalObject->putDirectNativeFunction( vm, globalObject, PropertyName(JSC::Identifier::fromString(vm, "write"_s)), 0, jsFunctionWrite, ImplementationVisibility::Public, JSC::NoIntrinsic, JSC::PropertyAttribute::ReadOnly | 0); vm.ref(); if (argc > 2) { auto source = JSC::makeSource(WTF::String::fromUTF8(argv[argc - 1]), SourceOrigin(WTF::URL("file://eval.js"_s)), "eval.js"_s); NakedPtr evaluationException; JSValue returnValue = JSC::profiledEvaluate(globalObject, ProfilingReason::API, source, globalObject, evaluationException); #ifdef VERBOSE fprintf(stderr, "\neval took %f ms\n", stopwatch->elapsedTime().milliseconds()); stopwatch->reset(); #endif if (evaluationException) { fprintf( stderr, "Exception: %s\n", evaluationException->value().toWTFString(globalObject).utf8().data()); return 1; } else { return 0; } } WTF::String fileURLString = WTF::String::fromUTF8(argv[argc - 1]); if (auto contents = WTF::FileSystemImpl::readEntireFile(fileURLString)) { auto source = JSC::makeSource(WTF::String::fromUTF8(contents.value()), SourceOrigin(WTF::URL(fileURLString)), fileURLString); NakedPtr evaluationException; JSValue returnValue = JSC::profiledEvaluate(globalObject, ProfilingReason::API, source, globalObject, evaluationException); #ifdef VERBOSE fprintf(stderr, "eval took %f ms\n", stopwatch->elapsedTime().milliseconds()); stopwatch->reset(); #endif if (evaluationException) { fprintf( stderr, "Exception: %s\n", evaluationException->value().toWTFString(globalObject).utf8().data()); return 1; } else { return 0; } } else { fprintf(stderr, "Could not read file %s\n", argv[argc - 1]); return 1; } } 91/newsboat/commit/po/es.po?h=r2.37&id=7bc9f1e9d900818b10311100e5521934ae6ce55b&follow=1'>Update ES TranslationGravatar Roboron3042 1-9/+9 2024-09-15Update ES TranslationGravatar Roboron3042 1-30/+18 2024-09-12Chore(deps): bump curl-sys from 0.4.74+curl-8.9.0 to 0.4.75+curl-8.10.0Gravatar dependabot[bot] 2-3/+3 2024-09-11Updated Italian translationGravatar Mauro Scomparin 1-2/+2 2024-09-11Update Dutch translationGravatar Dennis van der Schagt 1-2/+2 2024-09-11Update German translationsGravatar Lysander Trischler 1-2/+2 2024-09-10update zh translationGravatar CookiePieWw 1-2/+2 2024-09-10Update Turkish translationsGravatar Emir SARI 1-2/+2 2024-09-09chore(l10n): Update Polish translation before 2.37 releaseGravatar Carno 1-3/+3 2024-09-09Update Russian and Ukrainian translationsGravatar Alexander Batischev 2-4/+4 2024-09-09Update .pot and .po filesGravatar Alexander Batischev 19-340/+340 2024-09-08Fixup scroll_offset when list is changed/resizedGravatar Dennis van der Schagt 2-1/+19 2024-09-02Chore(deps): bump gettext-rs from 0.7.0 to 0.7.1Gravatar dependabot[bot] 3-4/+4 2024-09-02Chore(deps): bump the cxx group with 2 updatesGravatar dependabot[bot] 1-8/+8 2024-09-02fix codestyleGravatar Mikhail Iumanov (tufsampla) 1-1/+2 2024-09-02Add tests on author name ending with a closing bracketGravatar Mikhail Iumanov (tufsampla) 4-0/+143 2024-09-02Update rss/rss09xparser.cppGravatar Mikhail Yumanov 1-1/+1 2024-09-01Update list of possible podboat download statesGravatar Dennis van der Schagt 1-1/+1 2024-08-31Remove "Searching..." message when search is finishedGravatar Dennis van der Schagt 1-1/+2 2024-08-31Podboat: Mark entry as missing if downloaded file does not existGravatar Dennis van der Schagt 5-31/+43 2024-08-31Update gettext-sys to 0.21.4Gravatar Dennis van der Schagt 2-4/+2