ExecutableBase.cpp [plain text]
#include "config.h"
#include "EvalCodeBlock.h"
#include "FunctionCodeBlock.h"
#include "JSCellInlines.h"
#include "ModuleProgramCodeBlock.h"
#include "NativeExecutable.h"
#include "ProgramCodeBlock.h"
#include <wtf/CommaPrinter.h>
namespace JSC {
const ClassInfo ExecutableBase::s_info = { "Executable", nullptr, nullptr, nullptr, CREATE_METHOD_TABLE(ExecutableBase) };
void ExecutableBase::destroy(JSCell* cell)
{
static_cast<ExecutableBase*>(cell)->ExecutableBase::~ExecutableBase();
}
void ExecutableBase::dump(PrintStream& out) const
{
ExecutableBase* realThis = const_cast<ExecutableBase*>(this);
switch (type()) {
case NativeExecutableType: {
NativeExecutable* native = jsCast<NativeExecutable*>(realThis);
out.print("NativeExecutable:", RawPointer(bitwise_cast<void*>(native->function())), "/", RawPointer(bitwise_cast<void*>(native->constructor())));
return;
}
case EvalExecutableType: {
EvalExecutable* eval = jsCast<EvalExecutable*>(realThis);
if (CodeBlock* codeBlock = eval->codeBlock())
out.print(*codeBlock);
else
out.print("EvalExecutable w/o CodeBlock");
return;
}
case ProgramExecutableType: {
ProgramExecutable* eval = jsCast<ProgramExecutable*>(realThis);
if (CodeBlock* codeBlock = eval->codeBlock())
out.print(*codeBlock);
else
out.print("ProgramExecutable w/o CodeBlock");
return;
}
case ModuleProgramExecutableType: {
ModuleProgramExecutable* executable = jsCast<ModuleProgramExecutable*>(realThis);
if (CodeBlock* codeBlock = executable->codeBlock())
out.print(*codeBlock);
else
out.print("ModuleProgramExecutable w/o CodeBlock");
return;
}
case FunctionExecutableType: {
FunctionExecutable* function = jsCast<FunctionExecutable*>(realThis);
if (!function->eitherCodeBlock())
out.print("FunctionExecutable w/o CodeBlock");
else {
CommaPrinter comma("/");
if (function->codeBlockForCall())
out.print(comma, *function->codeBlockForCall());
if (function->codeBlockForConstruct())
out.print(comma, *function->codeBlockForConstruct());
}
return;
}
default:
RELEASE_ASSERT_NOT_REACHED();
}
}
CodeBlockHash ExecutableBase::hashFor(CodeSpecializationKind kind) const
{
if (type() == NativeExecutableType)
return jsCast<const NativeExecutable*>(this)->hashFor(kind);
return jsCast<const ScriptExecutable*>(this)->hashFor(kind);
}
}