Executable.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (c) 2021-2023, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/DeprecatedFlyString.h>
  8. #include <AK/NonnullOwnPtr.h>
  9. #include <AK/WeakPtr.h>
  10. #include <LibJS/Bytecode/BasicBlock.h>
  11. #include <LibJS/Bytecode/IdentifierTable.h>
  12. #include <LibJS/Bytecode/RegexTable.h>
  13. #include <LibJS/Bytecode/StringTable.h>
  14. namespace JS::Bytecode {
  15. struct PropertyLookupCache {
  16. WeakPtr<Shape> shape;
  17. Optional<u32> property_offset;
  18. u64 unique_shape_serial_number { 0 };
  19. };
  20. struct GlobalVariableCache : public PropertyLookupCache {
  21. u64 environment_serial_number { 0 };
  22. };
  23. struct SourceRecord {
  24. u32 source_start_offset {};
  25. u32 source_end_offset {};
  26. };
  27. struct Executable {
  28. DeprecatedFlyString name;
  29. Vector<PropertyLookupCache> property_lookup_caches;
  30. Vector<GlobalVariableCache> global_variable_caches;
  31. Vector<NonnullOwnPtr<BasicBlock>> basic_blocks;
  32. NonnullOwnPtr<StringTable> string_table;
  33. NonnullOwnPtr<IdentifierTable> identifier_table;
  34. NonnullOwnPtr<RegexTable> regex_table;
  35. NonnullRefPtr<SourceCode const> source_code;
  36. size_t number_of_registers { 0 };
  37. bool is_strict_mode { false };
  38. DeprecatedString const& get_string(StringTableIndex index) const { return string_table->get(index); }
  39. DeprecatedFlyString const& get_identifier(IdentifierTableIndex index) const { return identifier_table->get(index); }
  40. void dump() const;
  41. };
  42. }