Executable.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 Executable {
  24. DeprecatedFlyString name;
  25. Vector<PropertyLookupCache> property_lookup_caches;
  26. Vector<GlobalVariableCache> global_variable_caches;
  27. Vector<NonnullOwnPtr<BasicBlock>> basic_blocks;
  28. NonnullOwnPtr<StringTable> string_table;
  29. NonnullOwnPtr<IdentifierTable> identifier_table;
  30. NonnullOwnPtr<RegexTable> regex_table;
  31. size_t number_of_registers { 0 };
  32. bool is_strict_mode { false };
  33. DeprecatedString const& get_string(StringTableIndex index) const { return string_table->get(index); }
  34. DeprecatedFlyString const& get_identifier(IdentifierTableIndex index) const { return identifier_table->get(index); }
  35. void dump() const;
  36. };
  37. }