summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-10-24 14:33:56 +0200
committerAndreas Kling <kling@serenityos.org>2021-10-24 17:18:06 +0200
commitf75d78f56a907d4b3641dacd7461c2827c31ec86 (patch)
tree9a1eac5271e74081744d8668207a03549ac7a9f1 /Userland/Libraries
parentc95dde971b7f0f5071ce778dc20da83cb15a6627 (diff)
downloadserenity-f75d78f56a907d4b3641dacd7461c2827c31ec86.zip
LibJS: Include executable name in bytecode dumps
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibJS/Bytecode/Executable.cpp1
-rw-r--r--Userland/Libraries/LibJS/Bytecode/Executable.h2
-rw-r--r--Userland/Libraries/LibJS/Bytecode/Generator.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp5
-rw-r--r--Userland/Libraries/LibTest/JavaScriptTestRunner.h2
5 files changed, 9 insertions, 3 deletions
diff --git a/Userland/Libraries/LibJS/Bytecode/Executable.cpp b/Userland/Libraries/LibJS/Bytecode/Executable.cpp
index caa34ba450..d2bd4423cc 100644
--- a/Userland/Libraries/LibJS/Bytecode/Executable.cpp
+++ b/Userland/Libraries/LibJS/Bytecode/Executable.cpp
@@ -10,6 +10,7 @@ namespace JS::Bytecode {
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()) {
diff --git a/Userland/Libraries/LibJS/Bytecode/Executable.h b/Userland/Libraries/LibJS/Bytecode/Executable.h
index 7b20e8004d..c861222d52 100644
--- a/Userland/Libraries/LibJS/Bytecode/Executable.h
+++ b/Userland/Libraries/LibJS/Bytecode/Executable.h
@@ -6,6 +6,7 @@
#pragma once
+#include <AK/FlyString.h>
#include <AK/NonnullOwnPtrVector.h>
#include <LibJS/Bytecode/BasicBlock.h>
#include <LibJS/Bytecode/StringTable.h>
@@ -13,6 +14,7 @@
namespace JS::Bytecode {
struct Executable {
+ FlyString name;
NonnullOwnPtrVector<BasicBlock> basic_blocks;
NonnullOwnPtr<StringTable> string_table;
size_t number_of_registers { 0 };
diff --git a/Userland/Libraries/LibJS/Bytecode/Generator.cpp b/Userland/Libraries/LibJS/Bytecode/Generator.cpp
index c01e47e937..7cf0718996 100644
--- a/Userland/Libraries/LibJS/Bytecode/Generator.cpp
+++ b/Userland/Libraries/LibJS/Bytecode/Generator.cpp
@@ -44,7 +44,7 @@ Executable Generator::generate(ASTNode const& node, bool is_in_generator_functio
generator.emit<Bytecode::Op::Yield>(nullptr);
}
}
- return { move(generator.m_root_basic_blocks), move(generator.m_string_table), generator.m_next_register };
+ return { {}, move(generator.m_root_basic_blocks), move(generator.m_string_table), generator.m_next_register };
}
void Generator::grow(size_t additional_size)
diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp
index b06b2235bc..accd057046 100644
--- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp
@@ -678,14 +678,15 @@ Completion ECMAScriptFunctionObject::ordinary_call_evaluate_body()
TRY(function_declaration_instantiation(nullptr));
if (!m_bytecode_executable.has_value()) {
m_bytecode_executable = Bytecode::Generator::generate(m_ecmascript_code, m_kind == FunctionKind::Generator);
+ m_bytecode_executable->name = m_name;
auto& passes = JS::Bytecode::Interpreter::optimization_pipeline();
passes.perform(*m_bytecode_executable);
if constexpr (JS_BYTECODE_DEBUG) {
dbgln("Optimisation passes took {}us", passes.elapsed());
dbgln("Compiled Bytecode::Block for function '{}':", m_name);
- for (auto& block : m_bytecode_executable->basic_blocks)
- block.dump(*m_bytecode_executable);
}
+ if (JS::Bytecode::g_dump_bytecode)
+ m_bytecode_executable->dump();
}
auto result = bytecode_interpreter->run(*m_bytecode_executable);
if (auto* exception = vm.exception())
diff --git a/Userland/Libraries/LibTest/JavaScriptTestRunner.h b/Userland/Libraries/LibTest/JavaScriptTestRunner.h
index 436c327d48..231986f847 100644
--- a/Userland/Libraries/LibTest/JavaScriptTestRunner.h
+++ b/Userland/Libraries/LibTest/JavaScriptTestRunner.h
@@ -337,6 +337,7 @@ inline JSFileResult TestRunner::run_file_test(const String& test_path)
if (g_run_bytecode) {
auto executable = JS::Bytecode::Generator::generate(m_test_script->parse_node());
+ executable.name = test_path;
if (JS::Bytecode::g_dump_bytecode)
executable.dump();
JS::Bytecode::Interpreter bytecode_interpreter(interpreter->global_object(), interpreter->realm());
@@ -352,6 +353,7 @@ inline JSFileResult TestRunner::run_file_test(const String& test_path)
return { test_path, file_script.error() };
if (g_run_bytecode) {
auto executable = JS::Bytecode::Generator::generate(file_script.value()->parse_node());
+ executable.name = test_path;
if (JS::Bytecode::g_dump_bytecode)
executable.dump();
JS::Bytecode::Interpreter bytecode_interpreter(interpreter->global_object(), interpreter->realm());