2021-10-24 08:30:49 -03:00
|
|
|
/*
|
2023-07-08 12:43:26 -03:00
|
|
|
* Copyright (c) 2021-2023, Andreas Kling <kling@serenityos.org>
|
2021-10-24 08:30:49 -03:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2023-01-08 21:23:00 -03:00
|
|
|
#include <AK/DeprecatedFlyString.h>
|
2023-03-06 13:39:59 -03:00
|
|
|
#include <AK/NonnullOwnPtr.h>
|
2023-07-08 12:43:26 -03:00
|
|
|
#include <AK/WeakPtr.h>
|
2021-10-24 08:30:49 -03:00
|
|
|
#include <LibJS/Bytecode/BasicBlock.h>
|
2021-10-24 10:34:30 -03:00
|
|
|
#include <LibJS/Bytecode/IdentifierTable.h>
|
2023-07-13 05:49:07 -03:00
|
|
|
#include <LibJS/Bytecode/RegexTable.h>
|
2021-10-24 08:30:49 -03:00
|
|
|
#include <LibJS/Bytecode/StringTable.h>
|
|
|
|
|
|
|
|
|
|
namespace JS::Bytecode {
|
|
|
|
|
|
2023-07-08 12:43:26 -03:00
|
|
|
struct PropertyLookupCache {
|
|
|
|
|
WeakPtr<Shape> shape;
|
|
|
|
|
Optional<u32> property_offset;
|
2023-07-10 15:45:31 -03:00
|
|
|
u64 unique_shape_serial_number { 0 };
|
2023-07-08 12:43:26 -03:00
|
|
|
};
|
|
|
|
|
|
2023-07-11 23:06:59 -03:00
|
|
|
struct GlobalVariableCache : public PropertyLookupCache {
|
|
|
|
|
u64 environment_serial_number { 0 };
|
|
|
|
|
};
|
|
|
|
|
|
2023-09-01 11:53:55 -03:00
|
|
|
struct SourceRecord {
|
|
|
|
|
u32 source_start_offset {};
|
|
|
|
|
u32 source_end_offset {};
|
|
|
|
|
};
|
|
|
|
|
|
2021-10-24 08:30:49 -03:00
|
|
|
struct Executable {
|
2023-01-08 21:23:00 -03:00
|
|
|
DeprecatedFlyString name;
|
2023-07-08 12:43:26 -03:00
|
|
|
Vector<PropertyLookupCache> property_lookup_caches;
|
2023-07-11 23:06:59 -03:00
|
|
|
Vector<GlobalVariableCache> global_variable_caches;
|
2023-03-06 13:16:25 -03:00
|
|
|
Vector<NonnullOwnPtr<BasicBlock>> basic_blocks;
|
2021-10-24 08:30:49 -03:00
|
|
|
NonnullOwnPtr<StringTable> string_table;
|
2021-10-24 10:34:30 -03:00
|
|
|
NonnullOwnPtr<IdentifierTable> identifier_table;
|
2023-07-13 05:49:07 -03:00
|
|
|
NonnullOwnPtr<RegexTable> regex_table;
|
2023-09-01 11:53:55 -03:00
|
|
|
NonnullRefPtr<SourceCode const> source_code;
|
2021-10-24 08:30:49 -03:00
|
|
|
size_t number_of_registers { 0 };
|
2022-07-17 14:56:36 -03:00
|
|
|
bool is_strict_mode { false };
|
2021-10-24 08:30:49 -03:00
|
|
|
|
2022-12-04 15:02:33 -03:00
|
|
|
DeprecatedString const& get_string(StringTableIndex index) const { return string_table->get(index); }
|
2023-01-08 21:23:00 -03:00
|
|
|
DeprecatedFlyString const& get_identifier(IdentifierTableIndex index) const { return identifier_table->get(index); }
|
2021-10-24 08:30:49 -03:00
|
|
|
|
|
|
|
|
void dump() const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|