NativeExecutable.cpp 693 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * Copyright (c) 2023, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibJS/Bytecode/Interpreter.h>
  7. #include <LibJS/JIT/NativeExecutable.h>
  8. #include <LibJS/Runtime/VM.h>
  9. #include <sys/mman.h>
  10. namespace JS::JIT {
  11. NativeExecutable::NativeExecutable(void* code, size_t size)
  12. : m_code(code)
  13. , m_size(size)
  14. {
  15. }
  16. NativeExecutable::~NativeExecutable()
  17. {
  18. munmap(m_code, m_size);
  19. }
  20. void NativeExecutable::run(VM& vm)
  21. {
  22. typedef void (*JITCode)(VM&, Value* registers, Value* locals);
  23. ((JITCode)m_code)(vm,
  24. vm.bytecode_interpreter().registers().data(),
  25. vm.running_execution_context().local_variables.data());
  26. }
  27. }