Executable.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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/IdentifierTable.h>
  11. #include <LibJS/Bytecode/StringTable.h>
  12. #include <LibJS/Forward.h>
  13. #include <LibJS/Runtime/EnvironmentCoordinate.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_environment_variable_caches,
  37. size_t number_of_registers,
  38. Vector<NonnullOwnPtr<BasicBlock>>,
  39. bool is_strict_mode);
  40. ~Executable();
  41. DeprecatedFlyString name;
  42. Vector<PropertyLookupCache> property_lookup_caches;
  43. Vector<GlobalVariableCache> global_variable_caches;
  44. Vector<Optional<EnvironmentCoordinate>> environment_variable_caches;
  45. Vector<NonnullOwnPtr<BasicBlock>> basic_blocks;
  46. NonnullOwnPtr<StringTable> string_table;
  47. NonnullOwnPtr<IdentifierTable> identifier_table;
  48. NonnullOwnPtr<RegexTable> regex_table;
  49. NonnullRefPtr<SourceCode const> source_code;
  50. size_t number_of_registers { 0 };
  51. bool is_strict_mode { false };
  52. DeprecatedString const& get_string(StringTableIndex index) const { return string_table->get(index); }
  53. DeprecatedFlyString const& get_identifier(IdentifierTableIndex index) const { return identifier_table->get(index); }
  54. void dump() const;
  55. };
  56. }