NativeExecutable.h 858 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (c) 2023, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Noncopyable.h>
  8. #include <AK/Types.h>
  9. #include <LibJS/Runtime/Completion.h>
  10. namespace JS::JIT {
  11. struct BytecodeMapping {
  12. size_t native_offset;
  13. size_t block_index;
  14. size_t bytecode_offset;
  15. // Special block index for labels outside any blocks.
  16. static constexpr auto EXECUTABLE = NumericLimits<size_t>::max();
  17. };
  18. class NativeExecutable {
  19. AK_MAKE_NONCOPYABLE(NativeExecutable);
  20. AK_MAKE_NONMOVABLE(NativeExecutable);
  21. public:
  22. NativeExecutable(void* code, size_t size, Vector<BytecodeMapping>);
  23. ~NativeExecutable();
  24. void run(VM&) const;
  25. void dump_disassembly() const;
  26. private:
  27. void* m_code { nullptr };
  28. size_t m_size { 0 };
  29. Vector<BytecodeMapping> m_mapping;
  30. };
  31. }