ladybird/Libraries/LibJS/Bytecode/ClassBlueprint.h
Andreas Kling 3d3e6f4226 LibJS+LibWeb: Keep cached script source text lazy
Avoid decoding warm-cache script responses into full UTF-16 SourceCode
buffers when a bytecode cache sidecar is available. SourceCode now keeps
the original immutable source bytes and source encoding, then decodes
only when full source text or a Function.toString() range is requested.

Compute the bytecode cache source hash while streaming decoded code
points from the response bytes, so cache validation does not force an
intermediate UTF-8 string. Function and class source text metadata now
stores SourceCode ranges instead of views into a materialized buffer.
2026-05-18 09:18:35 +02:00

47 lines
1,007 B
C++

/*
* Copyright (c) 2026, Andreas Kling <andreas@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Optional.h>
#include <AK/RefPtr.h>
#include <AK/Utf16FlyString.h>
#include <AK/Vector.h>
#include <LibJS/Forward.h>
#include <LibJS/Runtime/Value.h>
namespace JS::Bytecode {
struct ClassElementDescriptor {
enum class Kind : u8 {
Method,
Getter,
Setter,
Field,
StaticInitializer,
};
Kind kind;
bool is_static;
bool is_private;
Optional<Utf16FlyString> private_identifier;
Optional<u32> shared_function_data_index;
bool has_initializer { false };
Optional<Value> literal_value;
};
struct ClassBlueprint {
u32 constructor_shared_function_data_index;
bool has_super_class;
bool has_name;
Utf16FlyString name;
RefPtr<SourceCode const> source_code;
size_t source_text_offset { 0 };
size_t source_text_length { 0 };
Vector<ClassElementDescriptor> elements;
};
}