ProfilerBytecodes.cpp [plain text]
#include "config.h"
#include "ProfilerBytecodes.h"
#include "CodeBlock.h"
#include "JSGlobalObject.h"
#include "ObjectConstructor.h"
#include "JSCInlines.h"
#include <wtf/StringPrintStream.h>
namespace JSC { namespace Profiler {
Bytecodes::Bytecodes(size_t id, CodeBlock* codeBlock)
: BytecodeSequence(codeBlock)
, m_id(id)
, m_inferredName(codeBlock->inferredName())
, m_sourceCode(codeBlock->sourceCodeForTools())
, m_hash(codeBlock->hash())
, m_instructionCount(codeBlock->instructionCount())
{
}
Bytecodes::~Bytecodes() { }
void Bytecodes::dump(PrintStream& out) const
{
out.print("#", m_hash, "(", m_id, ")");
}
JSValue Bytecodes::toJS(ExecState* exec) const
{
JSObject* result = constructEmptyObject(exec);
result->putDirect(exec->vm(), exec->propertyNames().bytecodesID, jsNumber(m_id));
result->putDirect(exec->vm(), exec->propertyNames().inferredName, jsString(exec, String::fromUTF8(m_inferredName)));
result->putDirect(exec->vm(), exec->propertyNames().sourceCode, jsString(exec, String::fromUTF8(m_sourceCode)));
result->putDirect(exec->vm(), exec->propertyNames().hash, jsString(exec, String::fromUTF8(toCString(m_hash))));
result->putDirect(exec->vm(), exec->propertyNames().instructionCount, jsNumber(m_instructionCount));
addSequenceProperties(exec, result);
return result;
}
} }