Executable.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. class Executable final : public RefCounted<Executable> {
  28. public:
  29. Executable(
  30. NonnullOwnPtr<IdentifierTable>,
  31. NonnullOwnPtr<StringTable>,
  32. NonnullOwnPtr<RegexTable>,
  33. NonnullRefPtr<SourceCode const>,
  34. size_t number_of_property_lookup_caches,
  35. size_t number_of_global_variable_caches,
  36. size_t number_of_registers,
  37. Vector<NonnullOwnPtr<BasicBlock>>,
  38. bool is_strict_mode);
  39. ~Executable();
  40. DeprecatedFlyString name;
  41. Vector<PropertyLookupCache> property_lookup_caches;
  42. Vector<GlobalVariableCache> global_variable_caches;
  43. Vector<NonnullOwnPtr<BasicBlock>> basic_blocks;
  44. NonnullOwnPtr<StringTable> string_table;
  45. NonnullOwnPtr<IdentifierTable> identifier_table;
  46. NonnullOwnPtr<RegexTable> regex_table;
  47. NonnullRefPtr<SourceCode const> source_code;
  48. size_t number_of_registers { 0 };
  49. bool is_strict_mode { false };
  50. DeprecatedString const& get_string(StringTableIndex index) const { return string_table->get(index); }
  51. DeprecatedFlyString const& get_identifier(IdentifierTableIndex index) const { return identifier_table->get(index); }
  52. void dump() const;
  53. };
  54. }