/* * Copyright (c) 2021, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include #include #include namespace JS::Bytecode { Executable::Executable( NonnullOwnPtr identifier_table, NonnullOwnPtr string_table, NonnullOwnPtr regex_table, NonnullRefPtr source_code, size_t number_of_property_lookup_caches, size_t number_of_global_variable_caches, size_t number_of_environment_variable_caches, size_t number_of_registers, Vector> basic_blocks, bool is_strict_mode) : basic_blocks(move(basic_blocks)) , string_table(move(string_table)) , identifier_table(move(identifier_table)) , regex_table(move(regex_table)) , source_code(move(source_code)) , number_of_registers(number_of_registers) , is_strict_mode(is_strict_mode) { property_lookup_caches.resize(number_of_property_lookup_caches); global_variable_caches.resize(number_of_global_variable_caches); environment_variable_caches.resize(number_of_environment_variable_caches); } Executable::~Executable() = default; void Executable::dump() const { dbgln("\033[33;1mJS::Bytecode::Executable\033[0m ({})", name); for (auto& block : basic_blocks) block->dump(*this); if (!string_table->is_empty()) { outln(); string_table->dump(); } if (!identifier_table->is_empty()) { outln(); identifier_table->dump(); } } JIT::NativeExecutable const* Executable::get_or_create_native_executable() { if (!m_did_try_jitting) { m_did_try_jitting = true; m_native_executable = JIT::Compiler::compile(*this); } return m_native_executable; } }