1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 03:47:35 +00:00

Ladybird+LibJS: Add CLI option to run browser with LibJS bytecode VM

This required quite a bit of plumbing, but now you can run

    ladybird --use-bytecode
This commit is contained in:
Andreas Kling 2023-06-17 13:16:35 +02:00
parent 7ec7015750
commit 9c568282dc
20 changed files with 91 additions and 38 deletions

View file

@ -35,7 +35,7 @@ OutOfProcessWebView::OutOfProcessWebView()
OutOfProcessWebView::~OutOfProcessWebView() = default;
void OutOfProcessWebView::create_client(EnableCallgrindProfiling)
void OutOfProcessWebView::create_client(EnableCallgrindProfiling, UseJavaScriptBytecode)
{
m_client_state = {};

View file

@ -78,7 +78,7 @@ private:
virtual void did_scroll() override;
// ^WebView::ViewImplementation
virtual void create_client(EnableCallgrindProfiling = EnableCallgrindProfiling::No) override;
virtual void create_client(EnableCallgrindProfiling = EnableCallgrindProfiling::No, UseJavaScriptBytecode = UseJavaScriptBytecode::No) override;
virtual void update_zoom() override;
virtual void notify_server_did_layout(Badge<WebContentClient>, Gfx::IntSize content_size) override;
virtual void notify_server_did_paint(Badge<WebContentClient>, i32 bitmap_id, Gfx::IntSize) override;

View file

@ -179,7 +179,7 @@ void ViewImplementation::handle_resize()
#if !defined(AK_OS_SERENITY)
ErrorOr<NonnullRefPtr<WebView::WebContentClient>> ViewImplementation::launch_web_content_process(ReadonlySpan<String> candidate_web_content_paths, EnableCallgrindProfiling enable_callgrind_profiling, IsLayoutTestMode is_layout_test_mode)
ErrorOr<NonnullRefPtr<WebView::WebContentClient>> ViewImplementation::launch_web_content_process(ReadonlySpan<String> candidate_web_content_paths, EnableCallgrindProfiling enable_callgrind_profiling, IsLayoutTestMode is_layout_test_mode, UseJavaScriptBytecode use_javascript_bytecode)
{
int socket_fds[2] {};
TRY(Core::System::socketpair(AF_LOCAL, SOCK_STREAM, 0, socket_fds));
@ -221,6 +221,8 @@ ErrorOr<NonnullRefPtr<WebView::WebContentClient>> ViewImplementation::launch_web
arguments.remove(0, callgrind_prefix_length);
if (is_layout_test_mode == IsLayoutTestMode::Yes)
arguments.append("--layout-test-mode"sv);
if (use_javascript_bytecode == UseJavaScriptBytecode::Yes)
arguments.append("--use-bytecode"sv);
result = Core::System::exec(arguments[0], arguments.span(), Core::System::SearchInPath::Yes);
if (!result.is_error())

View file

@ -30,6 +30,11 @@ enum class IsLayoutTestMode {
Yes
};
enum class UseJavaScriptBytecode {
No,
Yes
};
class ViewImplementation {
public:
virtual ~ViewImplementation() { }
@ -167,10 +172,10 @@ protected:
void request_repaint();
void handle_resize();
virtual void create_client(EnableCallgrindProfiling = EnableCallgrindProfiling::No) {};
virtual void create_client(EnableCallgrindProfiling = EnableCallgrindProfiling::No, UseJavaScriptBytecode = UseJavaScriptBytecode::No) { }
#if !defined(AK_OS_SERENITY)
ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_process(ReadonlySpan<String> candidate_web_content_paths, EnableCallgrindProfiling = EnableCallgrindProfiling::No, IsLayoutTestMode = IsLayoutTestMode::No);
ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_process(ReadonlySpan<String> candidate_web_content_paths, EnableCallgrindProfiling = EnableCallgrindProfiling::No, IsLayoutTestMode = IsLayoutTestMode::No, UseJavaScriptBytecode = UseJavaScriptBytecode::No);
#endif
void handle_web_content_process_crash();