mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-19 02:10:26 +00:00
LibJS+LibWeb: Parse modules off the main thread
Use the parse_off_thread() helper to submit parse_program(ProgramType::Module) to the ThreadPool for parsing on a worker thread. Bounce back to the main thread to compile and deliver the result via deferred_invoke. Falls back to synchronous parsing when the Rust pipeline is unavailable (LIBJS_CPP=1 or LIBJS_COMPARE_PIPELINES=1).
This commit is contained in:
parent
3f4d3d6108
commit
4c1e2aeb54
Notes:
github-actions[bot]
2026-03-06 12:07:23 +00:00
Author: https://github.com/awesomekling
Commit: 4c1e2aeb54
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8211
Reviewed-by: https://github.com/ADKaster
Reviewed-by: https://github.com/Zaggy1024
Reviewed-by: https://github.com/alimpfard
3 changed files with 28 additions and 7 deletions
|
|
@ -71,17 +71,14 @@ WebIDL::ExceptionOr<GC::Ptr<JavaScriptModuleScript>> JavaScriptModuleScript::cre
|
|||
return script;
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<GC::Ptr<JavaScriptModuleScript>> JavaScriptModuleScript::create_from_pre_parsed(ByteString const& filename, StringView source, JS::Realm& realm, URL::URL base_url, RustParsedProgram* parsed)
|
||||
WebIDL::ExceptionOr<GC::Ptr<JavaScriptModuleScript>> JavaScriptModuleScript::create_from_pre_parsed(ByteString const& filename, NonnullRefPtr<JS::SourceCode const> source_code, JS::Realm& realm, URL::URL base_url, RustParsedProgram* parsed)
|
||||
{
|
||||
if (HTML::is_scripting_disabled(realm))
|
||||
source = ""sv;
|
||||
|
||||
auto script = realm.create<JavaScriptModuleScript>(move(base_url), filename, realm);
|
||||
|
||||
script->set_parse_error(JS::js_null());
|
||||
script->set_error_to_rethrow(JS::js_null());
|
||||
|
||||
auto result = JS::SourceTextModule::parse_from_pre_parsed(parsed, source, realm, filename.view(), script);
|
||||
auto result = JS::SourceTextModule::parse_from_pre_parsed(parsed, move(source_code), realm, script);
|
||||
|
||||
if (result.is_error()) {
|
||||
auto& parse_error = result.error().first();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue