+2008-12-05 Sam Weinig <sam@webkit.org>
+
+ Reviewed by Cameron Zwarich.
+
+ Fix for https://bugs.webkit.org/show_bug.cgi?id=22715
+ Encapsulate more CodeBlock members in preparation
+ of moving some of them to a rare data structure.
+
+ * bytecode/CodeBlock.cpp:
+ (JSC::locationForOffset):
+ (JSC::printConditionalJump):
+ (JSC::printGetByIdOp):
+ (JSC::printPutByIdOp):
+ (JSC::CodeBlock::printStructure):
+ (JSC::CodeBlock::printStructures):
+ (JSC::CodeBlock::dump):
+ (JSC::CodeBlock::~CodeBlock):
+ (JSC::CodeBlock::unlinkCallers):
+ (JSC::CodeBlock::derefStructures):
+ (JSC::CodeBlock::refStructures):
+ (JSC::CodeBlock::mark):
+ (JSC::CodeBlock::getHandlerForVPC):
+ (JSC::CodeBlock::nativeExceptionCodeForHandlerVPC):
+ (JSC::CodeBlock::lineNumberForVPC):
+ (JSC::CodeBlock::expressionRangeForVPC):
+ (JSC::CodeBlock::shrinkToFit):
+ * bytecode/CodeBlock.h:
+ (JSC::CodeBlock::CodeBlock):
+ (JSC::CodeBlock::addCaller):
+ (JSC::CodeBlock::removeCaller):
+ (JSC::CodeBlock::isKnownNotImmediate):
+ (JSC::CodeBlock::isConstantRegisterIndex):
+ (JSC::CodeBlock::getConstant):
+ (JSC::CodeBlock::isTemporaryRegisterIndex):
+ (JSC::CodeBlock::getStubInfo):
+ (JSC::CodeBlock::getCallLinkInfo):
+ (JSC::CodeBlock::instructions):
+ (JSC::CodeBlock::setJITCode):
+ (JSC::CodeBlock::jitCode):
+ (JSC::CodeBlock::ownerNode):
+ (JSC::CodeBlock::setGlobalData):
+ (JSC::CodeBlock::setThisRegister):
+ (JSC::CodeBlock::thisRegister):
+ (JSC::CodeBlock::setNeedsFullScopeChain):
+ (JSC::CodeBlock::needsFullScopeChain):
+ (JSC::CodeBlock::setUsesEval):
+ (JSC::CodeBlock::usesEval):
+ (JSC::CodeBlock::setUsesArguments):
+ (JSC::CodeBlock::usesArguments):
+ (JSC::CodeBlock::codeType):
+ (JSC::CodeBlock::source):
+ (JSC::CodeBlock::sourceOffset):
+ (JSC::CodeBlock::addGlobalResolveInstruction):
+ (JSC::CodeBlock::numberOfPropertyAccessInstructions):
+ (JSC::CodeBlock::addPropertyAccessInstruction):
+ (JSC::CodeBlock::propertyAccessInstruction):
+ (JSC::CodeBlock::numberOfCallLinkInfos):
+ (JSC::CodeBlock::addCallLinkInfo):
+ (JSC::CodeBlock::callLinkInfo):
+ (JSC::CodeBlock::numberOfJumpTargets):
+ (JSC::CodeBlock::addJumpTarget):
+ (JSC::CodeBlock::jumpTarget):
+ (JSC::CodeBlock::lastJumpTarget):
+ (JSC::CodeBlock::numberOfExceptionHandlers):
+ (JSC::CodeBlock::addExceptionHandler):
+ (JSC::CodeBlock::exceptionHandler):
+ (JSC::CodeBlock::addExpressionInfo):
+ (JSC::CodeBlock::numberOfLineInfos):
+ (JSC::CodeBlock::addLineInfo):
+ (JSC::CodeBlock::lastLineInfo):
+ (JSC::CodeBlock::jitReturnAddressVPCMap):
+ (JSC::CodeBlock::numberOfIdentifiers):
+ (JSC::CodeBlock::addIdentifier):
+ (JSC::CodeBlock::identifier):
+ (JSC::CodeBlock::numberOfConstantRegisters):
+ (JSC::CodeBlock::addConstantRegister):
+ (JSC::CodeBlock::constantRegister):
+ (JSC::CodeBlock::addFunction):
+ (JSC::CodeBlock::function):
+ (JSC::CodeBlock::addFunctionExpression):
+ (JSC::CodeBlock::functionExpression):
+ (JSC::CodeBlock::addUnexpectedConstant):
+ (JSC::CodeBlock::unexpectedConstant):
+ (JSC::CodeBlock::addRegExp):
+ (JSC::CodeBlock::regexp):
+ (JSC::CodeBlock::symbolTable):
+ (JSC::CodeBlock::evalCodeCache):
+ New inline setters/getters.
+
+ (JSC::ProgramCodeBlock::ProgramCodeBlock):
+ (JSC::ProgramCodeBlock::~ProgramCodeBlock):
+ (JSC::ProgramCodeBlock::clearGlobalObject):
+ * bytecode/SamplingTool.cpp:
+ (JSC::ScopeSampleRecord::sample):
+ (JSC::SamplingTool::dump):
+ * bytecompiler/BytecodeGenerator.cpp:
+ * bytecompiler/BytecodeGenerator.h:
+ * bytecompiler/Label.h:
+ * interpreter/CallFrame.cpp:
+ * interpreter/Interpreter.cpp:
+ * jit/JIT.cpp:
+ * jit/JITCall.cpp:
+ * jit/JITInlineMethods.h:
+ * jit/JITPropertyAccess.cpp:
+ * parser/Nodes.cpp:
+ * runtime/Arguments.h:
+ * runtime/ExceptionHelpers.cpp:
+ * runtime/JSActivation.cpp:
+ * runtime/JSActivation.h:
+ * runtime/JSGlobalObject.cpp:
+ Change direct access to use new getter/setters.
+
2008-12-05 Gavin Barraclough <barraclough@apple.com>
Reviewed by Oliver Hunt.
return "";
}
-static int jumpTarget(const Vector<Instruction>::const_iterator& begin, Vector<Instruction>::const_iterator& it, int offset)
+static int locationForOffset(const Vector<Instruction>::const_iterator& begin, Vector<Instruction>::const_iterator& it, int offset)
{
return it - begin + offset;
}
{
int r0 = (++it)->u.operand;
int offset = (++it)->u.operand;
- printf("[%4d] %s\t\t %s, %d(->%d)\n", location, op, registerName(r0).c_str(), offset, jumpTarget(begin, it, offset));
+ printf("[%4d] %s\t\t %s, %d(->%d)\n", location, op, registerName(r0).c_str(), offset, locationForOffset(begin, it, offset));
}
-static void printGetByIdOp(int location, Vector<Instruction>::const_iterator& it, const Vector<Identifier>& identifiers, const char* op)
+static void printGetByIdOp(int location, Vector<Instruction>::const_iterator& it, const Vector<Identifier>& m_identifiers, const char* op)
{
int r0 = (++it)->u.operand;
int r1 = (++it)->u.operand;
int id0 = (++it)->u.operand;
- printf("[%4d] %s\t %s, %s, %s\n", location, op, registerName(r0).c_str(), registerName(r1).c_str(), idName(id0, identifiers[id0]).c_str());
+ printf("[%4d] %s\t %s, %s, %s\n", location, op, registerName(r0).c_str(), registerName(r1).c_str(), idName(id0, m_identifiers[id0]).c_str());
it += 4;
}
-static void printPutByIdOp(int location, Vector<Instruction>::const_iterator& it, const Vector<Identifier>& identifiers, const char* op)
+static void printPutByIdOp(int location, Vector<Instruction>::const_iterator& it, const Vector<Identifier>& m_identifiers, const char* op)
{
int r0 = (++it)->u.operand;
int id0 = (++it)->u.operand;
int r1 = (++it)->u.operand;
- printf("[%4d] %s\t %s, %s, %s\n", location, op, registerName(r0).c_str(), idName(id0, identifiers[id0]).c_str(), registerName(r1).c_str());
+ printf("[%4d] %s\t %s, %s, %s\n", location, op, registerName(r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), registerName(r1).c_str());
it += 4;
}
void CodeBlock::printStructure(const char* name, const Instruction* vPC, int operand) const
{
- unsigned instructionOffset = vPC - instructions.begin();
+ unsigned instructionOffset = vPC - m_instructions.begin();
printf(" [%4d] %s: %s\n", instructionOffset, name, pointerToSourceString(vPC[operand].u.structure).UTF8String().c_str());
}
void CodeBlock::printStructures(const Instruction* vPC) const
{
- Interpreter* interpreter = globalData->interpreter;
- unsigned instructionOffset = vPC - instructions.begin();
+ Interpreter* interpreter = m_globalData->interpreter;
+ unsigned instructionOffset = vPC - m_instructions.begin();
if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id)) {
printStructure("get_by_id", vPC, 4);
return;
}
- // These instructions doesn't ref Structures.
+ // These m_instructions doesn't ref Structures.
ASSERT(vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_generic) || vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id_generic) || vPC[0].u.opcode == interpreter->getOpcode(op_call) || vPC[0].u.opcode == interpreter->getOpcode(op_call_eval) || vPC[0].u.opcode == interpreter->getOpcode(op_construct));
}
void CodeBlock::dump(ExecState* exec) const
{
- Vector<Instruction>::const_iterator begin = instructions.begin();
- Vector<Instruction>::const_iterator end = instructions.end();
+ Vector<Instruction>::const_iterator begin = m_instructions.begin();
+ Vector<Instruction>::const_iterator end = m_instructions.end();
size_t instructionCount = 0;
for (Vector<Instruction>::const_iterator it = begin; it != end; ++it)
if (exec->interpreter()->isOpcode(it->u.opcode))
++instructionCount;
- printf("%lu instructions; %lu bytes at %p; %d parameter(s); %d callee register(s)\n\n",
+ printf("%lu m_instructions; %lu bytes at %p; %d parameter(s); %d callee register(s)\n\n",
static_cast<unsigned long>(instructionCount),
- static_cast<unsigned long>(instructions.size() * sizeof(Instruction)),
- this, numParameters, numCalleeRegisters);
+ static_cast<unsigned long>(m_instructions.size() * sizeof(Instruction)),
+ this, m_numParameters, m_numCalleeRegisters);
for (Vector<Instruction>::const_iterator it = begin; it != end; ++it)
dump(exec, begin, it);
- if (identifiers.size()) {
+ if (!m_identifiers.isEmpty()) {
printf("\nIdentifiers:\n");
size_t i = 0;
do {
- printf(" id%u = %s\n", static_cast<unsigned>(i), identifiers[i].ascii());
+ printf(" id%u = %s\n", static_cast<unsigned>(i), m_identifiers[i].ascii());
++i;
- } while (i != identifiers.size());
+ } while (i != m_identifiers.size());
}
- if (constantRegisters.size()) {
+ if (!m_constantRegisters.isEmpty()) {
printf("\nConstants:\n");
- unsigned registerIndex = numVars;
+ unsigned registerIndex = m_numVars;
size_t i = 0;
do {
- printf(" r%u = %s\n", registerIndex, valueToSourceString(exec, constantRegisters[i].jsValue(exec)).ascii());
+ printf(" r%u = %s\n", registerIndex, valueToSourceString(exec, m_constantRegisters[i].jsValue(exec)).ascii());
++i;
++registerIndex;
- } while (i < constantRegisters.size());
+ } while (i < m_constantRegisters.size());
}
- if (unexpectedConstants.size()) {
+ if (!m_unexpectedConstants.isEmpty()) {
printf("\nUnexpected Constants:\n");
size_t i = 0;
do {
- printf(" k%u = %s\n", static_cast<unsigned>(i), valueToSourceString(exec, unexpectedConstants[i]).ascii());
+ printf(" k%u = %s\n", static_cast<unsigned>(i), valueToSourceString(exec, m_unexpectedConstants[i]).ascii());
++i;
- } while (i < unexpectedConstants.size());
+ } while (i < m_unexpectedConstants.size());
}
- if (regexps.size()) {
- printf("\nRegExps:\n");
+ if (!m_regexps.isEmpty()) {
+ printf("\nm_regexps:\n");
size_t i = 0;
do {
- printf(" re%u = %s\n", static_cast<unsigned>(i), regexpToSourceString(regexps[i].get()).ascii());
+ printf(" re%u = %s\n", static_cast<unsigned>(i), regexpToSourceString(m_regexps[i].get()).ascii());
++i;
- } while (i < regexps.size());
+ } while (i < m_regexps.size());
}
- if (globalResolveInstructions.size() || propertyAccessInstructions.size())
+ if (!m_globalResolveInstructions.isEmpty() || !m_propertyAccessInstructions.isEmpty())
printf("\nStructures:\n");
- if (globalResolveInstructions.size()) {
+ if (!m_globalResolveInstructions.isEmpty()) {
size_t i = 0;
do {
- printStructures(&instructions[globalResolveInstructions[i]]);
+ printStructures(&m_instructions[m_globalResolveInstructions[i]]);
++i;
- } while (i < globalResolveInstructions.size());
+ } while (i < m_globalResolveInstructions.size());
}
- if (propertyAccessInstructions.size()) {
+ if (!m_propertyAccessInstructions.isEmpty()) {
size_t i = 0;
do {
- printStructures(&instructions[propertyAccessInstructions[i].bytecodeIndex]);
+ printStructures(&m_instructions[m_propertyAccessInstructions[i].bytecodeIndex]);
++i;
- } while (i < propertyAccessInstructions.size());
+ } while (i < m_propertyAccessInstructions.size());
}
- if (exceptionHandlers.size()) {
+ if (!m_exceptionHandlers.isEmpty()) {
printf("\nException Handlers:\n");
unsigned i = 0;
do {
- printf("\t %d: { start: [%4d] end: [%4d] target: [%4d] }\n", i + 1, exceptionHandlers[i].start, exceptionHandlers[i].end, exceptionHandlers[i].target);
+ printf("\t %d: { start: [%4d] end: [%4d] target: [%4d] }\n", i + 1, m_exceptionHandlers[i].start, m_exceptionHandlers[i].end, m_exceptionHandlers[i].target);
++i;
- } while (i < exceptionHandlers.size());
+ } while (i < m_exceptionHandlers.size());
}
if (!m_immediateSwitchJumpTables.isEmpty()) {
case op_unexpected_load: {
int r0 = (++it)->u.operand;
int k0 = (++it)->u.operand;
- printf("[%4d] unexpected_load\t %s, %s\n", location, registerName(r0).c_str(), constantName(exec, k0, unexpectedConstants[k0]).c_str());
+ printf("[%4d] unexpected_load\t %s, %s\n", location, registerName(r0).c_str(), constantName(exec, k0, m_unexpectedConstants[k0]).c_str());
break;
}
case op_new_object: {
case op_new_regexp: {
int r0 = (++it)->u.operand;
int re0 = (++it)->u.operand;
- printf("[%4d] new_regexp\t %s, %s\n", location, registerName(r0).c_str(), regexpName(re0, regexps[re0].get()).c_str());
+ printf("[%4d] new_regexp\t %s, %s\n", location, registerName(r0).c_str(), regexpName(re0, m_regexps[re0].get()).c_str());
break;
}
case op_mov: {
case op_resolve: {
int r0 = (++it)->u.operand;
int id0 = (++it)->u.operand;
- printf("[%4d] resolve\t\t %s, %s\n", location, registerName(r0).c_str(), idName(id0, identifiers[id0]).c_str());
+ printf("[%4d] resolve\t\t %s, %s\n", location, registerName(r0).c_str(), idName(id0, m_identifiers[id0]).c_str());
break;
}
case op_resolve_skip: {
int r0 = (++it)->u.operand;
int id0 = (++it)->u.operand;
int skipLevels = (++it)->u.operand;
- printf("[%4d] resolve_skip\t %s, %s, %d\n", location, registerName(r0).c_str(), idName(id0, identifiers[id0]).c_str(), skipLevels);
+ printf("[%4d] resolve_skip\t %s, %s, %d\n", location, registerName(r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), skipLevels);
break;
}
case op_resolve_global: {
int r0 = (++it)->u.operand;
JSValue* scope = static_cast<JSValue*>((++it)->u.jsCell);
int id0 = (++it)->u.operand;
- printf("[%4d] resolve_global\t %s, %s, %s\n", location, registerName(r0).c_str(), valueToSourceString(exec, scope).ascii(), idName(id0, identifiers[id0]).c_str());
+ printf("[%4d] resolve_global\t %s, %s, %s\n", location, registerName(r0).c_str(), valueToSourceString(exec, scope).ascii(), idName(id0, m_identifiers[id0]).c_str());
it += 2;
break;
}
case op_resolve_base: {
int r0 = (++it)->u.operand;
int id0 = (++it)->u.operand;
- printf("[%4d] resolve_base\t %s, %s\n", location, registerName(r0).c_str(), idName(id0, identifiers[id0]).c_str());
+ printf("[%4d] resolve_base\t %s, %s\n", location, registerName(r0).c_str(), idName(id0, m_identifiers[id0]).c_str());
break;
}
case op_resolve_with_base: {
int r0 = (++it)->u.operand;
int r1 = (++it)->u.operand;
int id0 = (++it)->u.operand;
- printf("[%4d] resolve_with_base %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), idName(id0, identifiers[id0]).c_str());
+ printf("[%4d] resolve_with_base %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), idName(id0, m_identifiers[id0]).c_str());
break;
}
case op_resolve_func: {
int r0 = (++it)->u.operand;
int r1 = (++it)->u.operand;
int id0 = (++it)->u.operand;
- printf("[%4d] resolve_func\t %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), idName(id0, identifiers[id0]).c_str());
+ printf("[%4d] resolve_func\t %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), idName(id0, m_identifiers[id0]).c_str());
break;
}
case op_get_by_id: {
- printGetByIdOp(location, it, identifiers, "get_by_id");
+ printGetByIdOp(location, it, m_identifiers, "get_by_id");
break;
}
case op_get_by_id_self: {
- printGetByIdOp(location, it, identifiers, "get_by_id_self");
+ printGetByIdOp(location, it, m_identifiers, "get_by_id_self");
break;
}
case op_get_by_id_self_list: {
- printGetByIdOp(location, it, identifiers, "get_by_id_self_list");
+ printGetByIdOp(location, it, m_identifiers, "get_by_id_self_list");
break;
}
case op_get_by_id_proto: {
- printGetByIdOp(location, it, identifiers, "get_by_id_proto");
+ printGetByIdOp(location, it, m_identifiers, "get_by_id_proto");
break;
}
case op_get_by_id_proto_list: {
- printGetByIdOp(location, it, identifiers, "op_get_by_id_proto_list");
+ printGetByIdOp(location, it, m_identifiers, "op_get_by_id_proto_list");
break;
}
case op_get_by_id_chain: {
- printGetByIdOp(location, it, identifiers, "get_by_id_chain");
+ printGetByIdOp(location, it, m_identifiers, "get_by_id_chain");
break;
}
case op_get_by_id_generic: {
- printGetByIdOp(location, it, identifiers, "get_by_id_generic");
+ printGetByIdOp(location, it, m_identifiers, "get_by_id_generic");
break;
}
case op_get_array_length: {
- printGetByIdOp(location, it, identifiers, "get_array_length");
+ printGetByIdOp(location, it, m_identifiers, "get_array_length");
break;
}
case op_get_string_length: {
- printGetByIdOp(location, it, identifiers, "get_string_length");
+ printGetByIdOp(location, it, m_identifiers, "get_string_length");
break;
}
case op_put_by_id: {
- printPutByIdOp(location, it, identifiers, "put_by_id");
+ printPutByIdOp(location, it, m_identifiers, "put_by_id");
break;
}
case op_put_by_id_replace: {
- printPutByIdOp(location, it, identifiers, "put_by_id_replace");
+ printPutByIdOp(location, it, m_identifiers, "put_by_id_replace");
break;
}
case op_put_by_id_transition: {
- printPutByIdOp(location, it, identifiers, "put_by_id_transition");
+ printPutByIdOp(location, it, m_identifiers, "put_by_id_transition");
break;
}
case op_put_by_id_generic: {
- printPutByIdOp(location, it, identifiers, "put_by_id_generic");
+ printPutByIdOp(location, it, m_identifiers, "put_by_id_generic");
break;
}
case op_put_getter: {
int r0 = (++it)->u.operand;
int id0 = (++it)->u.operand;
int r1 = (++it)->u.operand;
- printf("[%4d] put_getter\t %s, %s, %s\n", location, registerName(r0).c_str(), idName(id0, identifiers[id0]).c_str(), registerName(r1).c_str());
+ printf("[%4d] put_getter\t %s, %s, %s\n", location, registerName(r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), registerName(r1).c_str());
break;
}
case op_put_setter: {
int r0 = (++it)->u.operand;
int id0 = (++it)->u.operand;
int r1 = (++it)->u.operand;
- printf("[%4d] put_setter\t %s, %s, %s\n", location, registerName(r0).c_str(), idName(id0, identifiers[id0]).c_str(), registerName(r1).c_str());
+ printf("[%4d] put_setter\t %s, %s, %s\n", location, registerName(r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), registerName(r1).c_str());
break;
}
case op_del_by_id: {
int r0 = (++it)->u.operand;
int r1 = (++it)->u.operand;
int id0 = (++it)->u.operand;
- printf("[%4d] del_by_id\t %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), idName(id0, identifiers[id0]).c_str());
+ printf("[%4d] del_by_id\t %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), idName(id0, m_identifiers[id0]).c_str());
break;
}
case op_get_by_val: {
}
case op_jmp: {
int offset = (++it)->u.operand;
- printf("[%4d] jmp\t\t %d(->%d)\n", location, offset, jumpTarget(begin, it, offset));
+ printf("[%4d] jmp\t\t %d(->%d)\n", location, offset, locationForOffset(begin, it, offset));
break;
}
case op_loop: {
int offset = (++it)->u.operand;
- printf("[%4d] loop\t\t %d(->%d)\n", location, offset, jumpTarget(begin, it, offset));
+ printf("[%4d] loop\t\t %d(->%d)\n", location, offset, locationForOffset(begin, it, offset));
break;
}
case op_jtrue: {
int r0 = (++it)->u.operand;
int r1 = (++it)->u.operand;
int offset = (++it)->u.operand;
- printf("[%4d] jnless\t\t %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), offset, jumpTarget(begin, it, offset));
+ printf("[%4d] jnless\t\t %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), offset, locationForOffset(begin, it, offset));
break;
}
case op_loop_if_less: {
int r0 = (++it)->u.operand;
int r1 = (++it)->u.operand;
int offset = (++it)->u.operand;
- printf("[%4d] loop_if_less\t %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), offset, jumpTarget(begin, it, offset));
+ printf("[%4d] loop_if_less\t %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), offset, locationForOffset(begin, it, offset));
break;
}
case op_loop_if_lesseq: {
int r0 = (++it)->u.operand;
int r1 = (++it)->u.operand;
int offset = (++it)->u.operand;
- printf("[%4d] loop_if_lesseq\t %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), offset, jumpTarget(begin, it, offset));
+ printf("[%4d] loop_if_lesseq\t %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), offset, locationForOffset(begin, it, offset));
break;
}
case op_switch_imm: {
int tableIndex = (++it)->u.operand;
int defaultTarget = (++it)->u.operand;
int scrutineeRegister = (++it)->u.operand;
- printf("[%4d] switch_imm\t %d, %d(->%d), %s\n", location, tableIndex, defaultTarget, jumpTarget(begin, it, defaultTarget), registerName(scrutineeRegister).c_str());
+ printf("[%4d] switch_imm\t %d, %d(->%d), %s\n", location, tableIndex, defaultTarget, locationForOffset(begin, it, defaultTarget), registerName(scrutineeRegister).c_str());
break;
}
case op_switch_char: {
int tableIndex = (++it)->u.operand;
int defaultTarget = (++it)->u.operand;
int scrutineeRegister = (++it)->u.operand;
- printf("[%4d] switch_char\t %d, %d(->%d), %s\n", location, tableIndex, defaultTarget, jumpTarget(begin, it, defaultTarget), registerName(scrutineeRegister).c_str());
+ printf("[%4d] switch_char\t %d, %d(->%d), %s\n", location, tableIndex, defaultTarget, locationForOffset(begin, it, defaultTarget), registerName(scrutineeRegister).c_str());
break;
}
case op_switch_string: {
int tableIndex = (++it)->u.operand;
int defaultTarget = (++it)->u.operand;
int scrutineeRegister = (++it)->u.operand;
- printf("[%4d] switch_string\t %d, %d(->%d), %s\n", location, tableIndex, defaultTarget, jumpTarget(begin, it, defaultTarget), registerName(scrutineeRegister).c_str());
+ printf("[%4d] switch_string\t %d, %d(->%d), %s\n", location, tableIndex, defaultTarget, locationForOffset(begin, it, defaultTarget), registerName(scrutineeRegister).c_str());
break;
}
case op_new_func: {
int dest = (++it)->u.operand;
int iter = (++it)->u.operand;
int offset = (++it)->u.operand;
- printf("[%4d] next_pname\t %s, %s, %d(->%d)\n", location, registerName(dest).c_str(), registerName(iter).c_str(), offset, jumpTarget(begin, it, offset));
+ printf("[%4d] next_pname\t %s, %s, %d(->%d)\n", location, registerName(dest).c_str(), registerName(iter).c_str(), offset, locationForOffset(begin, it, offset));
break;
}
case op_push_scope: {
int r0 = (++it)->u.operand;
int id0 = (++it)->u.operand;
int r1 = (++it)->u.operand;
- printf("[%4d] push_new_scope \t%s, %s, %s\n", location, registerName(r0).c_str(), idName(id0, identifiers[id0]).c_str(), registerName(r1).c_str());
+ printf("[%4d] push_new_scope \t%s, %s, %s\n", location, registerName(r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), registerName(r1).c_str());
break;
}
case op_jmp_scopes: {
int scopeDelta = (++it)->u.operand;
int offset = (++it)->u.operand;
- printf("[%4d] jmp_scopes\t^%d, %d(->%d)\n", location, scopeDelta, offset, jumpTarget(begin, it, offset));
+ printf("[%4d] jmp_scopes\t^%d, %d(->%d)\n", location, scopeDelta, offset, locationForOffset(begin, it, offset));
break;
}
case op_catch: {
int r0 = (++it)->u.operand;
int errorType = (++it)->u.operand;
int k0 = (++it)->u.operand;
- printf("[%4d] new_error\t %s, %d, %s\n", location, registerName(r0).c_str(), errorType, constantName(exec, k0, unexpectedConstants[k0]).c_str());
+ printf("[%4d] new_error\t %s, %d, %s\n", location, registerName(r0).c_str(), errorType, constantName(exec, k0, m_unexpectedConstants[k0]).c_str());
break;
}
case op_jsr: {
int retAddrDst = (++it)->u.operand;
int offset = (++it)->u.operand;
- printf("[%4d] jsr\t\t %s, %d(->%d)\n", location, registerName(retAddrDst).c_str(), offset, jumpTarget(begin, it, offset));
+ printf("[%4d] jsr\t\t %s, %d(->%d)\n", location, registerName(retAddrDst).c_str(), offset, locationForOffset(begin, it, offset));
break;
}
case op_sret: {
CodeBlock::~CodeBlock()
{
- for (size_t size = globalResolveInstructions.size(), i = 0; i < size; ++i) {
- derefStructures(&instructions[globalResolveInstructions[i]]);
- }
+ for (size_t size = m_globalResolveInstructions.size(), i = 0; i < size; ++i)
+ derefStructures(&m_instructions[m_globalResolveInstructions[i]]);
- for (size_t size = propertyAccessInstructions.size(), i = 0; i < size; ++i) {
- derefStructures(&instructions[propertyAccessInstructions[i].bytecodeIndex]);
- if (propertyAccessInstructions[i].stubRoutine)
- WTF::fastFreeExecutable(propertyAccessInstructions[i].stubRoutine);
+ for (size_t size = m_propertyAccessInstructions.size(), i = 0; i < size; ++i) {
+ derefStructures(&m_instructions[m_propertyAccessInstructions[i].bytecodeIndex]);
+ if (m_propertyAccessInstructions[i].stubRoutine)
+ WTF::fastFreeExecutable(m_propertyAccessInstructions[i].stubRoutine);
}
- for (size_t size = callLinkInfos.size(), i = 0; i < size; ++i) {
- CallLinkInfo* callLinkInfo = &callLinkInfos[i];
+ for (size_t size = m_callLinkInfos.size(), i = 0; i < size; ++i) {
+ CallLinkInfo* callLinkInfo = &m_callLinkInfos[i];
if (callLinkInfo->isLinked())
callLinkInfo->callee->removeCaller(callLinkInfo);
}
#if ENABLE(JIT)
unlinkCallers();
- if (ctiCode)
- WTF::fastFreeExecutable(ctiCode);
+ if (m_jitCode)
+ WTF::fastFreeExecutable(m_jitCode);
#endif
}
#if ENABLE(JIT)
void CodeBlock::unlinkCallers()
{
- size_t size = linkedCallerList.size();
+ size_t size = m_linkedCallerList.size();
for (size_t i = 0; i < size; ++i) {
- CallLinkInfo* currentCaller = linkedCallerList[i];
+ CallLinkInfo* currentCaller = m_linkedCallerList[i];
JIT::unlinkCall(currentCaller);
currentCaller->setUnlinked();
}
- linkedCallerList.clear();
+ m_linkedCallerList.clear();
}
#endif
void CodeBlock::derefStructures(Instruction* vPC) const
{
- Interpreter* interpreter = globalData->interpreter;
+ Interpreter* interpreter = m_globalData->interpreter;
if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_self)) {
vPC[4].u.structure->deref();
void CodeBlock::refStructures(Instruction* vPC) const
{
- Interpreter* interpreter = globalData->interpreter;
+ Interpreter* interpreter = m_globalData->interpreter;
if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_self)) {
vPC[4].u.structure->ref();
void CodeBlock::mark()
{
- for (size_t i = 0; i < constantRegisters.size(); ++i)
- if (!constantRegisters[i].marked())
- constantRegisters[i].mark();
+ for (size_t i = 0; i < m_constantRegisters.size(); ++i)
+ if (!m_constantRegisters[i].marked())
+ m_constantRegisters[i].mark();
- for (size_t i = 0; i < unexpectedConstants.size(); ++i)
- if (!unexpectedConstants[i]->marked())
- unexpectedConstants[i]->mark();
+ for (size_t i = 0; i < m_unexpectedConstants.size(); ++i)
+ if (!m_unexpectedConstants[i]->marked())
+ m_unexpectedConstants[i]->mark();
- for (size_t i = 0; i < functions.size(); ++i)
- functions[i]->body()->mark();
+ for (size_t i = 0; i < m_functions.size(); ++i)
+ m_functions[i]->body()->mark();
- for (size_t i = 0; i < functionExpressions.size(); ++i)
- functionExpressions[i]->body()->mark();
+ for (size_t i = 0; i < m_functionExpressions.size(); ++i)
+ m_functionExpressions[i]->body()->mark();
}
bool CodeBlock::getHandlerForVPC(const Instruction* vPC, Instruction*& target, int& scopeDepth)
{
- Vector<HandlerInfo>::iterator ptr = exceptionHandlers.begin();
- Vector<HandlerInfo>::iterator end = exceptionHandlers.end();
- unsigned addressOffset = vPC - instructions.begin();
- ASSERT(addressOffset < instructions.size());
+ Vector<HandlerInfo>::iterator ptr = m_exceptionHandlers.begin();
+ Vector<HandlerInfo>::iterator end = m_exceptionHandlers.end();
+ unsigned addressOffset = vPC - m_instructions.begin();
+ ASSERT(addressOffset < m_instructions.size());
for (; ptr != end; ++ptr) {
// Handlers are ordered innermost first, so the first handler we encounter
// that contains the source address is the correct handler to use.
if (ptr->start <= addressOffset && ptr->end >= addressOffset) {
scopeDepth = ptr->scopeDepth;
- target = instructions.begin() + ptr->target;
+ target = m_instructions.begin() + ptr->target;
return true;
}
}
void* CodeBlock::nativeExceptionCodeForHandlerVPC(const Instruction* handlerVPC)
{
- Vector<HandlerInfo>::iterator ptr = exceptionHandlers.begin();
- Vector<HandlerInfo>::iterator end = exceptionHandlers.end();
+ Vector<HandlerInfo>::iterator ptr = m_exceptionHandlers.begin();
+ Vector<HandlerInfo>::iterator end = m_exceptionHandlers.end();
for (; ptr != end; ++ptr) {
- Instruction*target = instructions.begin() + ptr->target;
+ Instruction*target = m_instructions.begin() + ptr->target;
if (handlerVPC == target)
return ptr->nativeCode;
}
int CodeBlock::lineNumberForVPC(const Instruction* vPC)
{
- unsigned instructionOffset = vPC - instructions.begin();
- ASSERT(instructionOffset < instructions.size());
+ unsigned instructionOffset = vPC - m_instructions.begin();
+ ASSERT(instructionOffset < m_instructions.size());
- if (!lineInfo.size())
- return ownerNode->source().firstLine(); // Empty function
+ if (!m_lineInfo.size())
+ return m_ownerNode->source().firstLine(); // Empty function
int low = 0;
- int high = lineInfo.size();
+ int high = m_lineInfo.size();
while (low < high) {
int mid = low + (high - low) / 2;
- if (lineInfo[mid].instructionOffset <= instructionOffset)
+ if (m_lineInfo[mid].instructionOffset <= instructionOffset)
low = mid + 1;
else
high = mid;
}
if (!low)
- return ownerNode->source().firstLine();
- return lineInfo[low - 1].lineNumber;
+ return m_ownerNode->source().firstLine();
+ return m_lineInfo[low - 1].lineNumber;
}
int CodeBlock::expressionRangeForVPC(const Instruction* vPC, int& divot, int& startOffset, int& endOffset)
{
- unsigned instructionOffset = vPC - instructions.begin();
- ASSERT(instructionOffset < instructions.size());
+ unsigned instructionOffset = vPC - m_instructions.begin();
+ ASSERT(instructionOffset < m_instructions.size());
- if (!expressionInfo.size()) {
+ if (!m_expressionInfo.size()) {
// We didn't think anything could throw. Apparently we were wrong.
startOffset = 0;
endOffset = 0;
}
int low = 0;
- int high = expressionInfo.size();
+ int high = m_expressionInfo.size();
while (low < high) {
int mid = low + (high - low) / 2;
- if (expressionInfo[mid].instructionOffset <= instructionOffset)
+ if (m_expressionInfo[mid].instructionOffset <= instructionOffset)
low = mid + 1;
else
high = mid;
return lineNumberForVPC(vPC);
}
- startOffset = expressionInfo[low - 1].startOffset;
- endOffset = expressionInfo[low - 1].endOffset;
- divot = expressionInfo[low - 1].divotPoint + sourceOffset;
+ startOffset = m_expressionInfo[low - 1].startOffset;
+ endOffset = m_expressionInfo[low - 1].endOffset;
+ divot = m_expressionInfo[low - 1].divotPoint + m_sourceOffset;
return lineNumberForVPC(vPC);
}
void CodeBlock::shrinkToFit()
{
- instructions.shrinkToFit();
- globalResolveInstructions.shrinkToFit();
- propertyAccessInstructions.shrinkToFit();
- callLinkInfos.shrinkToFit();
- linkedCallerList.shrinkToFit();
- identifiers.shrinkToFit();
- functions.shrinkToFit();
- functionExpressions.shrinkToFit();
- constantRegisters.shrinkToFit();
- unexpectedConstants.shrinkToFit();
- regexps.shrinkToFit();
- exceptionHandlers.shrinkToFit();
- expressionInfo.shrinkToFit();
- lineInfo.shrinkToFit();
+ m_instructions.shrinkToFit();
+
+ m_globalResolveInstructions.shrinkToFit();
+ m_propertyAccessInstructions.shrinkToFit();
+ m_callLinkInfos.shrinkToFit();
+ m_linkedCallerList.shrinkToFit();
+
+ m_exceptionHandlers.shrinkToFit();
+ m_expressionInfo.shrinkToFit();
+ m_lineInfo.shrinkToFit();
+
+ m_identifiers.shrinkToFit();
+ m_functions.shrinkToFit();
+ m_functionExpressions.shrinkToFit();
+ m_constantRegisters.shrinkToFit();
+ m_unexpectedConstants.shrinkToFit();
+ m_regexps.shrinkToFit();
+
m_immediateSwitchJumpTables.shrinkToFit();
m_characterSwitchJumpTables.shrinkToFit();
m_stringSwitchJumpTables.shrinkToFit();
#endif
};
- struct CodeBlock {
+ class CodeBlock {
+ friend class JIT;
+ public:
CodeBlock(ScopeNode* ownerNode, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset)
- : ownerNode(ownerNode)
- , globalData(0)
+ : m_numCalleeRegisters(0)
+ , m_numConstants(0)
+ , m_numVars(0)
+ , m_numParameters(0)
+ , m_ownerNode(ownerNode)
+ , m_globalData(0)
#if ENABLE(JIT)
- , ctiCode(0)
+ , m_jitCode(0)
#endif
- , numCalleeRegisters(0)
- , numConstants(0)
- , numVars(0)
- , numParameters(0)
- , needsFullScopeChain(ownerNode->needsActivation())
- , usesEval(ownerNode->usesEval())
- , codeType(codeType)
- , source(sourceProvider)
- , sourceOffset(sourceOffset)
+ , m_needsFullScopeChain(ownerNode->needsActivation())
+ , m_usesEval(ownerNode->usesEval())
+ , m_codeType(codeType)
+ , m_source(sourceProvider)
+ , m_sourceOffset(sourceOffset)
{
- ASSERT(source);
+ ASSERT(m_source);
}
~CodeBlock();
void addCaller(CallLinkInfo* caller)
{
caller->callee = this;
- caller->position = linkedCallerList.size();
- linkedCallerList.append(caller);
+ caller->position = m_linkedCallerList.size();
+ m_linkedCallerList.append(caller);
}
void removeCaller(CallLinkInfo* caller)
{
unsigned pos = caller->position;
- unsigned lastPos = linkedCallerList.size() - 1;
+ unsigned lastPos = m_linkedCallerList.size() - 1;
if (pos != lastPos) {
- linkedCallerList[pos] = linkedCallerList[lastPos];
- linkedCallerList[pos]->position = pos;
+ m_linkedCallerList[pos] = m_linkedCallerList[lastPos];
+ m_linkedCallerList[pos]->position = pos;
}
- linkedCallerList.shrink(lastPos);
+ m_linkedCallerList.shrink(lastPos);
}
inline bool isKnownNotImmediate(int index)
{
- if (index == thisRegister)
+ if (index == m_thisRegister)
return true;
if (isConstantRegisterIndex(index))
ALWAYS_INLINE bool isConstantRegisterIndex(int index)
{
- return index >= numVars && index < numVars + numConstants;
+ return index >= m_numVars && index < m_numVars + m_numConstants;
}
ALWAYS_INLINE JSValue* getConstant(int index)
{
- return constantRegisters[index - numVars].getJSValue();
+ return m_constantRegisters[index - m_numVars].getJSValue();
}
ALWAYS_INLINE bool isTemporaryRegisterIndex(int index)
{
- return index >= numVars + numConstants;
+ return index >= m_numVars + m_numConstants;
}
#if !defined(NDEBUG) || ENABLE_OPCODE_SAMPLING
StructureStubInfo& getStubInfo(void* returnAddress)
{
- return *(binaryChop<StructureStubInfo, void*, getStructureStubInfoReturnLocation>(propertyAccessInstructions.begin(), propertyAccessInstructions.size(), returnAddress));
+ return *(binaryChop<StructureStubInfo, void*, getStructureStubInfoReturnLocation>(m_propertyAccessInstructions.begin(), m_propertyAccessInstructions.size(), returnAddress));
}
CallLinkInfo& getCallLinkInfo(void* returnAddress)
{
- return *(binaryChop<CallLinkInfo, void*, getCallLinkInfoReturnLocation>(callLinkInfos.begin(), callLinkInfos.size(), returnAddress));
+ return *(binaryChop<CallLinkInfo, void*, getCallLinkInfoReturnLocation>(m_callLinkInfos.begin(), m_callLinkInfos.size(), returnAddress));
}
- void shrinkToFit();
+
+ Vector<Instruction>& instructions() { return m_instructions; }
+#if ENABLE(JIT)
+ void setJITCode(void* jitCode) { m_jitCode = jitCode; }
+ void* jitCode() { return m_jitCode; }
+#endif
+
+ ScopeNode* ownerNode() const { return m_ownerNode; }
+
+ void setGlobalData(JSGlobalData* globalData) { m_globalData = globalData; }
+
+ void setThisRegister(int thisRegister) { m_thisRegister = thisRegister; }
+ int thisRegister() const { return m_thisRegister; }
+
+ void setNeedsFullScopeChain(bool needsFullScopeChain) { m_needsFullScopeChain = needsFullScopeChain; }
+ bool needsFullScopeChain() const { return m_needsFullScopeChain; }
+ void setUsesEval(bool usesEval) { m_usesEval = usesEval; }
+ bool usesEval() const { return m_usesEval; }
+ void setUsesArguments(bool usesArguments) { m_usesArguments = usesArguments; }
+ bool usesArguments() const { return m_usesArguments; }
+
+ CodeType codeType() const { return m_codeType; }
+
+ SourceProvider* source() const { return m_source.get(); }
+ unsigned sourceOffset() const { return m_sourceOffset; }
+
+ void addGlobalResolveInstruction(unsigned globalResolveInstructions) { m_globalResolveInstructions.append(globalResolveInstructions); }
+
+ size_t numberOfPropertyAccessInstructions() const { return m_propertyAccessInstructions.size(); }
+ void addPropertyAccessInstruction(unsigned propertyAccessInstructions) { m_propertyAccessInstructions.append(StructureStubInfo(propertyAccessInstructions)); }
+ StructureStubInfo& propertyAccessInstruction(int index) { return m_propertyAccessInstructions[index]; }
+
+ size_t numberOfCallLinkInfos() const { return m_callLinkInfos.size(); }
+ void addCallLinkInfo() { m_callLinkInfos.append(CallLinkInfo()); }
+ CallLinkInfo& callLinkInfo(int index) { return m_callLinkInfos[index]; }
+
+ size_t numberOfJumpTargets() const { return m_jumpTargets.size(); }
+ void addJumpTarget(unsigned jumpTarget) { m_jumpTargets.append(jumpTarget); }
+ unsigned jumpTarget(int index) const { return m_jumpTargets[index]; }
+ unsigned lastJumpTarget() const { return m_jumpTargets.last(); }
+
+ size_t numberOfExceptionHandlers() const { return m_exceptionHandlers.size(); }
+ void addExceptionHandler(const HandlerInfo& hanler) { return m_exceptionHandlers.append(hanler); }
+ HandlerInfo& exceptionHandler(int index) { return m_exceptionHandlers[index]; }
+
+ void addExpressionInfo(const ExpressionRangeInfo& expressionInfo) { return m_expressionInfo.append(expressionInfo); }
+
+ size_t numberOfLineInfos() const { return m_lineInfo.size(); }
+ void addLineInfo(const LineInfo& lineInfo) { return m_lineInfo.append(lineInfo); }
+ LineInfo& lastLineInfo() { return m_lineInfo.last(); }
+
+#if ENABLE(JIT)
+ HashMap<void*, unsigned>& jitReturnAddressVPCMap() { return m_jitReturnAddressVPCMap; }
+#endif
+
+ // Constant Pool
+
+ size_t numberOfIdentifiers() const { return m_identifiers.size(); }
+ void addIdentifier(const Identifier& i) { return m_identifiers.append(i); }
+ Identifier& identifier(int index) { return m_identifiers[index]; }
+
+ size_t numberOfConstantRegisters() const { return m_constantRegisters.size(); }
+ void addConstantRegister(const Register& r) { return m_constantRegisters.append(r); }
+ Register& constantRegister(int index) { return m_constantRegisters[index]; }
+
+ unsigned addFunction(FuncDeclNode* n) { unsigned size = m_functions.size(); m_functions.append(n); return size; }
+ FuncDeclNode* function(int index) const { return m_functions[index].get(); }
+
+ unsigned addFunctionExpression(FuncExprNode* n) { unsigned size = m_functionExpressions.size(); m_functionExpressions.append(n); return size; }
+ FuncExprNode* functionExpression(int index) const { return m_functionExpressions[index].get(); }
+
+ unsigned addUnexpectedConstant(JSValue* v) { unsigned size = m_unexpectedConstants.size(); m_unexpectedConstants.append(v); return size; }
+ JSValue* unexpectedConstant(int index) const { return m_unexpectedConstants[index]; }
+
+ unsigned addRegExp(RegExp* r) { unsigned size = m_regexps.size(); m_regexps.append(r); return size; }
+ RegExp* regexp(int index) const { return m_regexps[index].get(); }
+
+ // Jump Tables
size_t numberOfImmediateSwitchJumpTables() const { return m_immediateSwitchJumpTables.size(); }
SimpleJumpTable& addImmediateSwitchJumpTable() { m_immediateSwitchJumpTables.append(SimpleJumpTable()); return m_immediateSwitchJumpTables.last(); }
StringJumpTable& addStringSwitchJumpTable() { m_stringSwitchJumpTables.append(StringJumpTable()); return m_stringSwitchJumpTables.last(); }
StringJumpTable& stringSwitchJumpTable(int tableIndex) { return m_stringSwitchJumpTables[tableIndex]; }
- ScopeNode* ownerNode;
- JSGlobalData* globalData;
-#if ENABLE(JIT)
- void* ctiCode;
-#endif
- int numCalleeRegisters;
+ SymbolTable& symbolTable() { return m_symbolTable; }
+ EvalCodeCache& evalCodeCache() { return m_evalCodeCache; }
+ void shrinkToFit();
+
+ // FIXME: Make these remaining members private.
+
+ int m_numCalleeRegisters;
// NOTE: numConstants holds the number of constant registers allocated
// by the code generator, not the number of constant registers used.
// (Duplicate constants are uniqued during code generation, and spare
// constant registers may be allocated.)
- int numConstants;
- int numVars;
- int numParameters;
- int thisRegister;
- bool needsFullScopeChain;
- bool usesEval;
- bool usesArguments;
- CodeType codeType;
- RefPtr<SourceProvider> source;
- unsigned sourceOffset;
-
- Vector<Instruction> instructions;
- Vector<unsigned> globalResolveInstructions;
- Vector<StructureStubInfo> propertyAccessInstructions;
- Vector<CallLinkInfo> callLinkInfos;
- Vector<CallLinkInfo*> linkedCallerList;
-
- // Constant pool
- Vector<Identifier> identifiers;
- Vector<RefPtr<FuncDeclNode> > functions;
- Vector<RefPtr<FuncExprNode> > functionExpressions;
- Vector<Register> constantRegisters;
- Vector<JSValue*> unexpectedConstants;
- Vector<RefPtr<RegExp> > regexps;
- Vector<HandlerInfo> exceptionHandlers;
- Vector<ExpressionRangeInfo> expressionInfo;
- Vector<LineInfo> lineInfo;
+ int m_numConstants;
+ int m_numVars;
+ int m_numParameters;
+ private:
+#if !defined(NDEBUG) || ENABLE(OPCODE_SAMPLING)
+ void dump(ExecState*, const Vector<Instruction>::const_iterator& begin, Vector<Instruction>::const_iterator&) const;
+#endif
+
+ ScopeNode* m_ownerNode;
+ JSGlobalData* m_globalData;
+
+ Vector<Instruction> m_instructions;
#if ENABLE(JIT)
- HashMap<void*, unsigned> ctiReturnAddressVPCMap;
+ void* m_jitCode;
#endif
- Vector<unsigned> jumpTargets;
+ int m_thisRegister;
- EvalCodeCache evalCodeCache;
+ bool m_needsFullScopeChain;
+ bool m_usesEval;
+ bool m_usesArguments;
- SymbolTable symbolTable;
- private:
-#if !defined(NDEBUG) || ENABLE(OPCODE_SAMPLING)
- void dump(ExecState*, const Vector<Instruction>::const_iterator& begin, Vector<Instruction>::const_iterator&) const;
+ CodeType m_codeType;
+
+ RefPtr<SourceProvider> m_source;
+ unsigned m_sourceOffset;
+
+ Vector<unsigned> m_globalResolveInstructions;
+ Vector<StructureStubInfo> m_propertyAccessInstructions;
+ Vector<CallLinkInfo> m_callLinkInfos;
+ Vector<CallLinkInfo*> m_linkedCallerList;
+
+ Vector<unsigned> m_jumpTargets;
+
+ Vector<HandlerInfo> m_exceptionHandlers;
+ Vector<ExpressionRangeInfo> m_expressionInfo;
+ Vector<LineInfo> m_lineInfo;
+
+#if ENABLE(JIT)
+ HashMap<void*, unsigned> m_jitReturnAddressVPCMap;
#endif
+ // Constant Pool
+ Vector<Identifier> m_identifiers;
+ Vector<Register> m_constantRegisters;
+ Vector<RefPtr<FuncDeclNode> > m_functions;
+ Vector<RefPtr<FuncExprNode> > m_functionExpressions;
+ Vector<JSValue*> m_unexpectedConstants;
+ Vector<RefPtr<RegExp> > m_regexps;
+
+ // Jump Tables
Vector<SimpleJumpTable> m_immediateSwitchJumpTables;
Vector<SimpleJumpTable> m_characterSwitchJumpTables;
Vector<StringJumpTable> m_stringSwitchJumpTables;
+
+ SymbolTable m_symbolTable;
+
+ EvalCodeCache m_evalCodeCache;
};
// Program code is not marked by any function, so we make the global object
// responsible for marking it.
- struct ProgramCodeBlock : public CodeBlock {
+ class ProgramCodeBlock : public CodeBlock {
+ public:
ProgramCodeBlock(ScopeNode* ownerNode, CodeType codeType, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider)
: CodeBlock(ownerNode, codeType, sourceProvider, 0)
- , globalObject(globalObject)
+ , m_globalObject(globalObject)
{
- globalObject->codeBlocks().add(this);
+ m_globalObject->codeBlocks().add(this);
}
~ProgramCodeBlock()
{
- if (globalObject)
- globalObject->codeBlocks().remove(this);
+ if (m_globalObject)
+ m_globalObject->codeBlocks().remove(this);
}
- JSGlobalObject* globalObject; // For program and eval nodes, the global object that marks the constant pool.
+ void clearGlobalObject() { m_globalObject = 0; }
+
+ private:
+ JSGlobalObject* m_globalObject; // For program and eval nodes, the global object that marks the constant pool.
};
- struct EvalCodeBlock : public ProgramCodeBlock {
+ class EvalCodeBlock : public ProgramCodeBlock {
+ public:
EvalCodeBlock(ScopeNode* ownerNode, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider)
: ProgramCodeBlock(ownerNode, EvalCode, globalObject, sourceProvider)
{
void ScopeSampleRecord::sample(CodeBlock* codeBlock, Instruction* vPC)
{
if (!m_samples) {
- m_size = codeBlock->instructions.size();
+ m_size = codeBlock->instructions().size();
m_samples = static_cast<int*>(calloc(m_size, sizeof(int)));
m_codeBlock = codeBlock;
}
++m_sampleCount;
- unsigned offest = vPC - codeBlock->instructions.begin();
+ unsigned offest = vPC - codeBlock->instructions().begin();
// Since we don't read and write codeBlock and vPC atomically, this check
// can fail if we sample mid op_call / op_ret.
if (offest < m_size) {
double blockPercent = (record->m_sampleCount * 100.0) / m_sampleCount;
if (blockPercent >= 1) {
- Instruction* code = codeBlock->instructions.begin();
+ Instruction* code = codeBlock->instructions().begin();
printf("#%d: %s:%d: %d / %lld (%.3f%%)\n", i + 1, record->m_scope->sourceURL().UTF8String().c_str(), codeBlock->lineNumberForVPC(code), record->m_sampleCount, m_sampleCount, blockPercent);
if (i < 10) {
HashMap<unsigned,unsigned> lineCounts;
void BytecodeGenerator::generate()
{
- m_codeBlock->thisRegister = m_thisRegister.index();
+ m_codeBlock->setThisRegister(m_thisRegister.index());
m_scopeNode->emitBytecode(*this);
return false;
}
- ++m_codeBlock->numVars;
+ ++m_codeBlock->m_numVars;
r0 = newRegister();
return true;
}
void BytecodeGenerator::allocateConstants(size_t count)
{
- m_codeBlock->numConstants = count;
+ m_codeBlock->m_numConstants = count;
if (!count)
return;
, m_emitNodeDepth(0)
{
if (m_shouldEmitDebugHooks)
- m_codeBlock->needsFullScopeChain = true;
+ m_codeBlock->setNeedsFullScopeChain(true);
emitOpcode(op_enter);
- codeBlock->globalData = m_globalData;
+ codeBlock->setGlobalData(m_globalData);
// FIXME: Move code that modifies the global object to Interpreter::execute.
- m_codeBlock->numParameters = 1; // Allocate space for "this"
+ m_codeBlock->m_numParameters = 1; // Allocate space for "this"
JSGlobalObject* globalObject = scopeChain.globalObject();
ExecState* exec = globalObject->globalExec();
RegisterFile* registerFile = &exec->globalData().interpreter->registerFile();
// Shift register indexes in generated code to elide registers allocated by intermediate stack frames.
- m_globalVarStorageOffset = -RegisterFile::CallFrameHeaderSize - m_codeBlock->numParameters - registerFile->size();
+ m_globalVarStorageOffset = -RegisterFile::CallFrameHeaderSize - m_codeBlock->m_numParameters - registerFile->size();
// Add previously defined symbols to bookkeeping.
m_globals.grow(symbolTable->size());
, m_emitNodeDepth(0)
{
if (m_shouldEmitDebugHooks)
- m_codeBlock->needsFullScopeChain = true;
+ m_codeBlock->setNeedsFullScopeChain(true);
- codeBlock->globalData = m_globalData;
+ codeBlock->setGlobalData(m_globalData);
bool usesArguments = functionBody->usesArguments();
- codeBlock->usesArguments = usesArguments;
+ codeBlock->setUsesArguments(usesArguments);
if (usesArguments) {
m_argumentsRegister.setIndex(RegisterFile::OptionalCalleeArguments);
addVar(propertyNames().arguments, false);
}
- if (m_codeBlock->needsFullScopeChain) {
- ++m_codeBlock->numVars;
+ if (m_codeBlock->needsFullScopeChain()) {
+ ++m_codeBlock->m_numVars;
m_activationRegisterIndex = newRegister()->index();
emitOpcode(op_enter_with_activation);
instructions().append(m_activationRegisterIndex);
// Add "this" as a parameter
m_thisRegister.setIndex(m_nextParameterIndex);
++m_nextParameterIndex;
- ++m_codeBlock->numParameters;
+ ++m_codeBlock->m_numParameters;
if (functionBody->usesThis()) {
emitOpcode(op_convert_this);
, m_emitNodeDepth(0)
{
if (m_shouldEmitDebugHooks)
- m_codeBlock->needsFullScopeChain = true;
+ m_codeBlock->setNeedsFullScopeChain(true);
emitOpcode(op_enter);
- codeBlock->globalData = m_globalData;
- m_codeBlock->numParameters = 1; // Allocate space for "this"
+ codeBlock->setGlobalData(m_globalData);
+ m_codeBlock->m_numParameters = 1; // Allocate space for "this"
allocateConstants(evalNode->neededConstants());
}
// To maintain the calling convention, we have to allocate unique space for
// each parameter, even if the parameter doesn't make it into the symbol table.
++m_nextParameterIndex;
- ++m_codeBlock->numParameters;
+ ++m_codeBlock->m_numParameters;
return result;
}
RegisterID* BytecodeGenerator::newRegister()
{
m_calleeRegisters.append(m_calleeRegisters.size());
- m_codeBlock->numCalleeRegisters = max<int>(m_codeBlock->numCalleeRegisters, m_calleeRegisters.size());
+ m_codeBlock->m_numCalleeRegisters = max<int>(m_codeBlock->m_numCalleeRegisters, m_calleeRegisters.size());
return &m_calleeRegisters.last();
}
RegisterID* BytecodeGenerator::highestUsedRegister()
{
- size_t count = m_codeBlock->numCalleeRegisters;
+ size_t count = m_codeBlock->m_numCalleeRegisters;
while (m_calleeRegisters.size() < count)
newRegister();
return &m_calleeRegisters.last();
unsigned newLabelIndex = instructions().size();
l0->setLocation(newLabelIndex);
- if (m_codeBlock->jumpTargets.size() != 0) {
- unsigned lastLabelIndex = m_codeBlock->jumpTargets.last();
+ if (m_codeBlock->numberOfJumpTargets()) {
+ unsigned lastLabelIndex = m_codeBlock->lastJumpTarget();
ASSERT(lastLabelIndex <= newLabelIndex);
if (newLabelIndex == lastLabelIndex) {
// Peephole optimizations have already been disabled by emitting the last label
- return l0;
+ return l0;
}
}
- m_codeBlock->jumpTargets.append(newLabelIndex);
+ m_codeBlock->addJumpTarget(newLabelIndex);
// This disables peephole optimizations when an instruction is a jump target
m_lastOpcodeID = op_end;
unsigned BytecodeGenerator::addConstant(FuncDeclNode* n)
{
// No need to explicitly unique function body nodes -- they're unique already.
- int index = m_codeBlock->functions.size();
- m_codeBlock->functions.append(n);
- return index;
+ return m_codeBlock->addFunction(n);
}
unsigned BytecodeGenerator::addConstant(FuncExprNode* n)
{
// No need to explicitly unique function expression nodes -- they're unique already.
- int index = m_codeBlock->functionExpressions.size();
- m_codeBlock->functionExpressions.append(n);
- return index;
+ return m_codeBlock->addFunctionExpression(n);
}
unsigned BytecodeGenerator::addConstant(const Identifier& ident)
{
UString::Rep* rep = ident.ustring().rep();
- pair<IdentifierMap::iterator, bool> result = m_identifierMap.add(rep, m_codeBlock->identifiers.size());
+ pair<IdentifierMap::iterator, bool> result = m_identifierMap.add(rep, m_codeBlock->numberOfIdentifiers());
if (result.second) // new entry
- m_codeBlock->identifiers.append(Identifier(m_globalData, rep));
+ m_codeBlock->addIdentifier(Identifier(m_globalData, rep));
return result.first->second;
}
++m_nextConstantIndex;
- m_codeBlock->constantRegisters.append(v);
+ m_codeBlock->addConstantRegister(v);
return &constant;
}
unsigned BytecodeGenerator::addUnexpectedConstant(JSValue* v)
{
- int index = m_codeBlock->unexpectedConstants.size();
- m_codeBlock->unexpectedConstants.append(v);
- return index;
+ return m_codeBlock->addUnexpectedConstant(v);
}
unsigned BytecodeGenerator::addRegExp(RegExp* r)
{
- int index = m_codeBlock->regexps.size();
- m_codeBlock->regexps.append(r);
- return index;
+ return m_codeBlock->addRegExp(r);
}
RegisterID* BytecodeGenerator::emitMove(RegisterID* dst, RegisterID* src)
if (src1->index() == dstIndex
&& src1->isTemporary()
&& m_codeBlock->isConstantRegisterIndex(src2->index())
- && m_codeBlock->constantRegisters[src2->index() - m_codeBlock->numVars].jsValue(m_scopeChain->globalObject()->globalExec())->isString()) {
- const UString& value = asString(m_codeBlock->constantRegisters[src2->index() - m_codeBlock->numVars].jsValue(m_scopeChain->globalObject()->globalExec()))->value();
+ && m_codeBlock->constantRegister(src2->index() - m_codeBlock->m_numVars).jsValue(m_scopeChain->globalObject()->globalExec())->isString()) {
+ const UString& value = asString(m_codeBlock->constantRegister(src2->index() - m_codeBlock->m_numVars).jsValue(m_scopeChain->globalObject()->globalExec()))->value();
if (value == "undefined") {
rewindUnaryOp();
emitOpcode(op_is_undefined);
}
if (globalObject) {
- m_codeBlock->globalResolveInstructions.append(instructions().size());
+ m_codeBlock->addGlobalResolveInstruction(instructions().size());
emitOpcode(op_resolve_global);
instructions().append(dst->index());
instructions().append(globalObject);
RegisterID* BytecodeGenerator::emitGetById(RegisterID* dst, RegisterID* base, const Identifier& property)
{
- m_codeBlock->propertyAccessInstructions.append(instructions().size());
+ m_codeBlock->addPropertyAccessInstruction(instructions().size());
emitOpcode(op_get_by_id);
instructions().append(dst->index());
RegisterID* BytecodeGenerator::emitPutById(RegisterID* base, const Identifier& property, RegisterID* value)
{
- m_codeBlock->propertyAccessInstructions.append(instructions().size());
+ m_codeBlock->addPropertyAccessInstruction(instructions().size());
emitOpcode(op_put_by_id);
instructions().append(base->index());
}
emitExpressionInfo(divot, startOffset, endOffset);
- m_codeBlock->callLinkInfos.append(CallLinkInfo());
+ m_codeBlock->addCallLinkInfo();
// Emit call.
emitOpcode(opcodeID);
RegisterID* BytecodeGenerator::emitReturn(RegisterID* src)
{
- if (m_codeBlock->needsFullScopeChain) {
+ if (m_codeBlock->needsFullScopeChain()) {
emitOpcode(op_tear_off_activation);
instructions().append(m_activationRegisterIndex);
- } else if (m_codeBlock->usesArguments && m_codeBlock->numParameters > 1)
+ } else if (m_codeBlock->usesArguments() && m_codeBlock->m_numParameters > 1)
emitOpcode(op_tear_off_arguments);
return emitUnaryNoDstOp(op_ret, src);
callFrame.append(newTemporary());
emitExpressionInfo(divot, startOffset, endOffset);
- m_codeBlock->callLinkInfos.append(CallLinkInfo());
+ m_codeBlock->addCallLinkInfo();
emitOpcode(op_construct);
instructions().append(dst->index()); // dst
RegisterID* BytecodeGenerator::emitCatch(RegisterID* targetRegister, Label* start, Label* end)
{
HandlerInfo info = { start->offsetFrom(0), end->offsetFrom(0), instructions().size(), m_dynamicScopeDepth, 0 };
- exceptionHandlers().append(info);
+ m_codeBlock->addExceptionHandler(info);
emitOpcode(op_catch);
instructions().append(targetRegister->index());
return targetRegister;
RegisterID* destinationForAssignResult(RegisterID* dst)
{
- if (dst && dst != ignoredResult() && m_codeBlock->needsFullScopeChain)
+ if (dst && dst != ignoredResult() && m_codeBlock->needsFullScopeChain())
return dst->isTemporary() ? dst : newTemporary();
return 0;
}
{
// Node::emitCode assumes that dst, if provided, is either a local or a referenced temporary.
ASSERT(!dst || dst == ignoredResult() || !dst->isTemporary() || dst->refCount());
- if (!m_codeBlock->lineInfo.size() || m_codeBlock->lineInfo.last().lineNumber != n->lineNo()) {
+ if (!m_codeBlock->numberOfLineInfos() || m_codeBlock->lastLineInfo().lineNumber != n->lineNo()) {
LineInfo info = { instructions().size(), n->lineNo() };
- m_codeBlock->lineInfo.append(info);
+ m_codeBlock->addLineInfo(info);
}
if (m_emitNodeDepth >= s_maxEmitNodeDepth)
return emitThrowExpressionTooDeepException();
void emitExpressionInfo(unsigned divot, unsigned startOffset, unsigned endOffset)
{
- divot -= m_codeBlock->sourceOffset;
+ divot -= m_codeBlock->sourceOffset();
if (divot > ExpressionRangeInfo::MaxDivot) {
// Overflow has occurred, we can only give line number info for errors for this region
divot = 0;
info.divotPoint = divot;
info.startOffset = startOffset;
info.endOffset = endOffset;
- m_codeBlock->expressionInfo.append(info);
+ m_codeBlock->addExpressionInfo(info);
}
ALWAYS_INLINE bool leftHandSideNeedsCopy(bool rightHasAssignments, bool rightIsPure)
{
- return (m_codeType != FunctionCode || m_codeBlock->needsFullScopeChain || rightHasAssignments) && !rightIsPure;
+ return (m_codeType != FunctionCode || m_codeBlock->needsFullScopeChain() || rightHasAssignments) && !rightIsPure;
}
ALWAYS_INLINE PassRefPtr<RegisterID> emitNodeForLeftHandSide(ExpressionNode* n, bool rightHasAssignments, bool rightIsPure)
unsigned addUnexpectedConstant(JSValue*);
unsigned addRegExp(RegExp*);
- Vector<Instruction>& instructions() { return m_codeBlock->instructions; }
+ Vector<Instruction>& instructions() { return m_codeBlock->instructions(); }
SymbolTable& symbolTable() { return *m_symbolTable; }
- Vector<HandlerInfo>& exceptionHandlers() { return m_codeBlock->exceptionHandlers; }
bool shouldOptimizeLocals() { return (m_codeType != EvalCode) && !m_dynamicScopeDepth; }
- bool canOptimizeNonLocals() { return (m_codeType == FunctionCode) && !m_dynamicScopeDepth && !m_codeBlock->usesEval; }
+ bool canOptimizeNonLocals() { return (m_codeType == FunctionCode) && !m_dynamicScopeDepth && !m_codeBlock->usesEval(); }
RegisterID* emitThrowExpressionTooDeepException();
unsigned size = m_unresolvedJumps.size();
for (unsigned i = 0; i < size; ++i) {
unsigned j = m_unresolvedJumps[i];
- m_codeBlock->instructions[j].u.operand = m_location - j;
+ m_codeBlock->instructions()[j].u.operand = m_location - j;
}
}
JSValue* CallFrame::thisValue()
{
- return this[codeBlock()->thisRegister].jsValue(this);
+ return this[codeBlock()->thisRegister()].jsValue(this);
}
}
static ALWAYS_INLINE Instruction* vPCForPC(CodeBlock* codeBlock, void* pc)
{
- if (pc >= codeBlock->instructions.begin() && pc < codeBlock->instructions.end())
+ if (pc >= codeBlock->instructions().begin() && pc < codeBlock->instructions().end())
return static_cast<Instruction*>(pc);
- ASSERT(codeBlock->ctiReturnAddressVPCMap.contains(pc));
- unsigned vPCIndex = codeBlock->ctiReturnAddressVPCMap.get(pc);
- return codeBlock->instructions.begin() + vPCIndex;
+ ASSERT(codeBlock->jitReturnAddressVPCMap().contains(pc));
+ unsigned vPCIndex = codeBlock->jitReturnAddressVPCMap().get(pc);
+ return codeBlock->instructions().begin() + vPCIndex;
}
#else // ENABLE(JIT)
// Returns the depth of the scope chain within a given call frame.
static int depth(CodeBlock* codeBlock, ScopeChain& sc)
{
- if (!codeBlock->needsFullScopeChain)
+ if (!codeBlock->needsFullScopeChain())
return 0;
int scopeDepth = 0;
ScopeChainIterator iter = sc.begin();
ASSERT(iter != end);
CodeBlock* codeBlock = callFrame->codeBlock();
- Identifier& ident = codeBlock->identifiers[property];
+ Identifier& ident = codeBlock->identifier(property);
do {
JSObject* o = *iter;
PropertySlot slot(o);
int dst = (vPC + 1)->u.operand;
int property = (vPC + 2)->u.operand;
- int skip = (vPC + 3)->u.operand + codeBlock->needsFullScopeChain;
+ int skip = (vPC + 3)->u.operand + codeBlock->needsFullScopeChain();
ScopeChainNode* scopeChain = callFrame->scopeChain();
ScopeChainIterator iter = scopeChain->begin();
++iter;
ASSERT(iter != end);
}
- Identifier& ident = codeBlock->identifiers[property];
+ Identifier& ident = codeBlock->identifier(property);
do {
JSObject* o = *iter;
PropertySlot slot(o);
}
CodeBlock* codeBlock = callFrame->codeBlock();
- Identifier& ident = codeBlock->identifiers[property];
+ Identifier& ident = codeBlock->identifier(property);
PropertySlot slot(globalObject);
if (globalObject->getPropertySlot(callFrame, ident, slot)) {
JSValue* result = slot.getValue(callFrame, ident);
{
int dst = (vPC + 1)->u.operand;
int property = (vPC + 2)->u.operand;
- callFrame[dst] = inlineResolveBase(callFrame, callFrame->codeBlock()->identifiers[property], callFrame->scopeChain());
+ callFrame[dst] = inlineResolveBase(callFrame, callFrame->codeBlock()->identifier(property), callFrame->scopeChain());
}
NEVER_INLINE bool Interpreter::resolveBaseAndProperty(CallFrame* callFrame, Instruction* vPC, JSValue*& exceptionValue)
ASSERT(iter != end);
CodeBlock* codeBlock = callFrame->codeBlock();
- Identifier& ident = codeBlock->identifiers[property];
+ Identifier& ident = codeBlock->identifier(property);
JSObject* base;
do {
base = *iter;
ASSERT(iter != end);
CodeBlock* codeBlock = callFrame->codeBlock();
- Identifier& ident = codeBlock->identifiers[property];
+ Identifier& ident = codeBlock->identifier(property);
JSObject* base;
do {
base = *iter;
ALWAYS_INLINE CallFrame* Interpreter::slideRegisterWindowForCall(CodeBlock* newCodeBlock, RegisterFile* registerFile, CallFrame* callFrame, size_t registerOffset, int argc)
{
Register* r = callFrame->registers();
- Register* newEnd = r + registerOffset + newCodeBlock->numCalleeRegisters;
+ Register* newEnd = r + registerOffset + newCodeBlock->m_numCalleeRegisters;
- if (LIKELY(argc == newCodeBlock->numParameters)) { // correct number of arguments
+ if (LIKELY(argc == newCodeBlock->m_numParameters)) { // correct number of arguments
if (UNLIKELY(!registerFile->grow(newEnd)))
return 0;
r += registerOffset;
- } else if (argc < newCodeBlock->numParameters) { // too few arguments -- fill in the blanks
- size_t omittedArgCount = newCodeBlock->numParameters - argc;
+ } else if (argc < newCodeBlock->m_numParameters) { // too few arguments -- fill in the blanks
+ size_t omittedArgCount = newCodeBlock->m_numParameters - argc;
registerOffset += omittedArgCount;
newEnd += omittedArgCount;
if (!registerFile->grow(newEnd))
for (size_t i = 0; i < omittedArgCount; ++i)
argv[i] = jsUndefined();
} else { // too many arguments -- copy expected arguments, leaving the extra arguments behind
- size_t numParameters = newCodeBlock->numParameters;
+ size_t numParameters = newCodeBlock->m_numParameters;
registerOffset += numParameters;
newEnd += numParameters;
ScopeChainNode* scopeChain = callFrame->scopeChain();
CodeBlock* codeBlock = callFrame->codeBlock();
- RefPtr<EvalNode> evalNode = codeBlock->evalCodeCache.get(callFrame, programSource, scopeChain, exceptionValue);
+ RefPtr<EvalNode> evalNode = codeBlock->evalCodeCache().get(callFrame, programSource, scopeChain, exceptionValue);
JSValue* result = jsUndefined();
if (evalNode)
const Register* it;
const Register* end;
- if (codeBlock->codeType == GlobalCode) {
+ if (codeBlock->codeType() == GlobalCode) {
it = registerFile->lastGlobal();
end = it + registerFile->numGlobals();
while (it != end) {
printf("----------------------------------------------------\n");
}
- it = callFrame->registers() - RegisterFile::CallFrameHeaderSize - codeBlock->numParameters;
+ it = callFrame->registers() - RegisterFile::CallFrameHeaderSize - codeBlock->m_numParameters;
printf("[this] | %10p | %10p \n", it, (*it).v()); ++it;
- end = it + max(codeBlock->numParameters - 1, 0); // - 1 to skip "this"
+ end = it + max(codeBlock->m_numParameters - 1, 0); // - 1 to skip "this"
if (it != end) {
do {
printf("[param] | %10p | %10p \n", it, (*it).v());
int registerCount = 0;
- end = it + codeBlock->numVars;
+ end = it + codeBlock->m_numVars;
if (it != end) {
do {
printf("[r%2d] | %10p | %10p \n", registerCount, it, (*it).v());
}
printf("----------------------------------------------------\n");
- end = it + codeBlock->numConstants;
+ end = it + codeBlock->m_numConstants;
if (it != end) {
do {
printf("[r%2d] | %10p | %10p \n", registerCount, it, (*it).v());
}
printf("----------------------------------------------------\n");
- end = it + codeBlock->numCalleeRegisters - codeBlock->numConstants - codeBlock->numVars;
+ end = it + codeBlock->m_numCalleeRegisters - codeBlock->m_numConstants - codeBlock->m_numVars;
if (it != end) {
do {
printf("[r%2d] | %10p | %10p \n", registerCount, it, (*it).v());
if (Debugger* debugger = callFrame->dynamicGlobalObject()->debugger()) {
DebuggerCallFrame debuggerCallFrame(callFrame, exceptionValue);
if (callFrame->callee())
- debugger->returnEvent(debuggerCallFrame, codeBlock->ownerNode->sourceID(), codeBlock->ownerNode->lastLine());
+ debugger->returnEvent(debuggerCallFrame, codeBlock->ownerNode()->sourceID(), codeBlock->ownerNode()->lastLine());
else
- debugger->didExecuteProgram(debuggerCallFrame, codeBlock->ownerNode->sourceID(), codeBlock->ownerNode->lastLine());
+ debugger->didExecuteProgram(debuggerCallFrame, codeBlock->ownerNode()->sourceID(), codeBlock->ownerNode()->lastLine());
}
if (Profiler* profiler = *Profiler::enabledProfilerReference()) {
if (callFrame->callee())
profiler->didExecute(callFrame, callFrame->callee());
else
- profiler->didExecute(callFrame, codeBlock->ownerNode->sourceURL(), codeBlock->ownerNode->lineNo());
+ profiler->didExecute(callFrame, codeBlock->ownerNode()->sourceURL(), codeBlock->ownerNode()->lineNo());
}
// If this call frame created an activation or an 'arguments' object, tear it off.
- if (oldCodeBlock->codeType == FunctionCode && oldCodeBlock->needsFullScopeChain) {
+ if (oldCodeBlock->codeType() == FunctionCode && oldCodeBlock->needsFullScopeChain()) {
while (!scopeChain->object->isObject(&JSActivation::info))
scopeChain = scopeChain->pop();
static_cast<JSActivation*>(scopeChain->object)->copyRegisters(callFrame->optionalCalleeArguments());
arguments->copyRegisters();
}
- if (oldCodeBlock->needsFullScopeChain)
+ if (oldCodeBlock->needsFullScopeChain())
scopeChain->deref();
void* returnPC = callFrame->returnPC();
exception->putWithAttributes(callFrame, Identifier(callFrame, expressionEndOffsetPropertyName), jsNumber(callFrame, divotPoint + endOffset), ReadOnly | DontDelete);
} else
exception->putWithAttributes(callFrame, Identifier(callFrame, "line"), jsNumber(callFrame, codeBlock->lineNumberForVPC(vPC)), ReadOnly | DontDelete);
- exception->putWithAttributes(callFrame, Identifier(callFrame, "sourceId"), jsNumber(callFrame, codeBlock->ownerNode->sourceID()), ReadOnly | DontDelete);
- exception->putWithAttributes(callFrame, Identifier(callFrame, "sourceURL"), jsOwnedString(callFrame, codeBlock->ownerNode->sourceURL()), ReadOnly | DontDelete);
+ exception->putWithAttributes(callFrame, Identifier(callFrame, "sourceId"), jsNumber(callFrame, codeBlock->ownerNode()->sourceID()), ReadOnly | DontDelete);
+ exception->putWithAttributes(callFrame, Identifier(callFrame, "sourceURL"), jsOwnedString(callFrame, codeBlock->ownerNode()->sourceURL()), ReadOnly | DontDelete);
}
if (exception->isWatchdogException()) {
if (Debugger* debugger = callFrame->dynamicGlobalObject()->debugger()) {
DebuggerCallFrame debuggerCallFrame(callFrame, exceptionValue);
- debugger->exception(debuggerCallFrame, codeBlock->ownerNode->sourceID(), codeBlock->lineNumberForVPC(vPC));
+ debugger->exception(debuggerCallFrame, codeBlock->ownerNode()->sourceID(), codeBlock->lineNumberForVPC(vPC));
}
// If we throw in the middle of a call instruction, we need to notify
CodeBlock* codeBlock = &programNode->bytecode(scopeChain);
Register* oldEnd = m_registerFile.end();
- Register* newEnd = oldEnd + codeBlock->numParameters + RegisterFile::CallFrameHeaderSize + codeBlock->numCalleeRegisters;
+ Register* newEnd = oldEnd + codeBlock->m_numParameters + RegisterFile::CallFrameHeaderSize + codeBlock->m_numCalleeRegisters;
if (!m_registerFile.grow(newEnd)) {
*exception = createStackOverflowError(callFrame);
return jsNull();
JSGlobalObject* globalObject = callFrame->dynamicGlobalObject();
globalObject->copyGlobalsTo(m_registerFile);
- CallFrame* newCallFrame = CallFrame::create(oldEnd + codeBlock->numParameters + RegisterFile::CallFrameHeaderSize);
- newCallFrame[codeBlock->thisRegister] = thisObj;
+ CallFrame* newCallFrame = CallFrame::create(oldEnd + codeBlock->m_numParameters + RegisterFile::CallFrameHeaderSize);
+ newCallFrame[codeBlock->thisRegister()] = thisObj;
newCallFrame->init(codeBlock, 0, scopeChain, CallFrame::noCaller(), 0, 0, 0);
- if (codeBlock->needsFullScopeChain)
+ if (codeBlock->needsFullScopeChain())
scopeChain->ref();
Profiler** profiler = Profiler::enabledProfilerReference();
m_reentryDepth++;
#if ENABLE(JIT)
- if (!codeBlock->ctiCode)
+ if (!codeBlock->jitCode())
JIT::compile(scopeChain->globalData, codeBlock);
- result = JIT::execute(codeBlock->ctiCode, &m_registerFile, newCallFrame, scopeChain->globalData, exception);
+ result = JIT::execute(codeBlock->jitCode(), &m_registerFile, newCallFrame, scopeChain->globalData, exception);
#else
result = privateExecute(Normal, &m_registerFile, newCallFrame, exception);
#endif
m_reentryDepth++;
#if ENABLE(JIT)
- if (!codeBlock->ctiCode)
+ if (!codeBlock->jitCode())
JIT::compile(scopeChain->globalData, codeBlock);
- result = JIT::execute(codeBlock->ctiCode, &m_registerFile, newCallFrame, scopeChain->globalData, exception);
+ result = JIT::execute(codeBlock->jitCode(), &m_registerFile, newCallFrame, scopeChain->globalData, exception);
#else
result = privateExecute(Normal, &m_registerFile, newCallFrame, exception);
#endif
JSValue* Interpreter::execute(EvalNode* evalNode, CallFrame* callFrame, JSObject* thisObj, ScopeChainNode* scopeChain, JSValue** exception)
{
- return execute(evalNode, callFrame, thisObj, m_registerFile.size() + evalNode->bytecode(scopeChain).numParameters + RegisterFile::CallFrameHeaderSize, scopeChain, exception);
+ return execute(evalNode, callFrame, thisObj, m_registerFile.size() + evalNode->bytecode(scopeChain).m_numParameters + RegisterFile::CallFrameHeaderSize, scopeChain, exception);
}
JSValue* Interpreter::execute(EvalNode* evalNode, CallFrame* callFrame, JSObject* thisObj, int globalRegisterOffset, ScopeChainNode* scopeChain, JSValue** exception)
BatchedTransitionOptimizer optimizer(variableObject);
- const DeclarationStacks::VarStack& varStack = codeBlock->ownerNode->varStack();
+ const DeclarationStacks::VarStack& varStack = codeBlock->ownerNode()->varStack();
DeclarationStacks::VarStack::const_iterator varStackEnd = varStack.end();
for (DeclarationStacks::VarStack::const_iterator it = varStack.begin(); it != varStackEnd; ++it) {
const Identifier& ident = (*it).first;
}
}
- const DeclarationStacks::FunctionStack& functionStack = codeBlock->ownerNode->functionStack();
+ const DeclarationStacks::FunctionStack& functionStack = codeBlock->ownerNode()->functionStack();
DeclarationStacks::FunctionStack::const_iterator functionStackEnd = functionStack.end();
for (DeclarationStacks::FunctionStack::const_iterator it = functionStack.begin(); it != functionStackEnd; ++it) {
PutPropertySlot slot;
}
Register* oldEnd = m_registerFile.end();
- Register* newEnd = m_registerFile.start() + globalRegisterOffset + codeBlock->numCalleeRegisters;
+ Register* newEnd = m_registerFile.start() + globalRegisterOffset + codeBlock->m_numCalleeRegisters;
if (!m_registerFile.grow(newEnd)) {
*exception = createStackOverflowError(callFrame);
return jsNull();
CallFrame* newCallFrame = CallFrame::create(m_registerFile.start() + globalRegisterOffset);
// a 0 codeBlock indicates a built-in caller
- newCallFrame[codeBlock->thisRegister] = thisObj;
+ newCallFrame[codeBlock->thisRegister()] = thisObj;
newCallFrame->init(codeBlock, 0, scopeChain, callFrame->addHostCallFrameFlag(), 0, 0, 0);
- if (codeBlock->needsFullScopeChain)
+ if (codeBlock->needsFullScopeChain())
scopeChain->ref();
Profiler** profiler = Profiler::enabledProfilerReference();
m_reentryDepth++;
#if ENABLE(JIT)
- if (!codeBlock->ctiCode)
+ if (!codeBlock->jitCode())
JIT::compile(scopeChain->globalData, codeBlock);
- result = JIT::execute(codeBlock->ctiCode, &m_registerFile, newCallFrame, scopeChain->globalData, exception);
+ result = JIT::execute(codeBlock->jitCode(), &m_registerFile, newCallFrame, scopeChain->globalData, exception);
#else
result = privateExecute(Normal, &m_registerFile, newCallFrame, exception);
#endif
switch (debugHookID) {
case DidEnterCallFrame:
- debugger->callEvent(callFrame, callFrame->codeBlock()->ownerNode->sourceID(), firstLine);
+ debugger->callEvent(callFrame, callFrame->codeBlock()->ownerNode()->sourceID(), firstLine);
return;
case WillLeaveCallFrame:
- debugger->returnEvent(callFrame, callFrame->codeBlock()->ownerNode->sourceID(), lastLine);
+ debugger->returnEvent(callFrame, callFrame->codeBlock()->ownerNode()->sourceID(), lastLine);
return;
case WillExecuteStatement:
- debugger->atStatement(callFrame, callFrame->codeBlock()->ownerNode->sourceID(), firstLine);
+ debugger->atStatement(callFrame, callFrame->codeBlock()->ownerNode()->sourceID(), firstLine);
return;
case WillExecuteProgram:
- debugger->willExecuteProgram(callFrame, callFrame->codeBlock()->ownerNode->sourceID(), firstLine);
+ debugger->willExecuteProgram(callFrame, callFrame->codeBlock()->ownerNode()->sourceID(), firstLine);
return;
case DidExecuteProgram:
- debugger->didExecuteProgram(callFrame, callFrame->codeBlock()->ownerNode->sourceID(), lastLine);
+ debugger->didExecuteProgram(callFrame, callFrame->codeBlock()->ownerNode()->sourceID(), lastLine);
return;
case DidReachBreakpoint:
- debugger->didReachBreakpoint(callFrame, callFrame->codeBlock()->ownerNode->sourceID(), lastLine);
+ debugger->didReachBreakpoint(callFrame, callFrame->codeBlock()->ownerNode()->sourceID(), lastLine);
return;
}
}
{
int dst = (++vPC)->u.operand;
CodeBlock* codeBlock = callFrame->codeBlock();
- Identifier& property = codeBlock->identifiers[(++vPC)->u.operand];
+ Identifier& property = codeBlock->identifier((++vPC)->u.operand);
JSValue* value = callFrame[(++vPC)->u.operand].jsValue(callFrame);
JSObject* scope = new (callFrame) JSStaticScopeObject(callFrame, property, value, DontDelete);
callFrame[dst] = scope;
JSValue* exceptionValue = noValue();
Instruction* handlerVPC = 0;
- Instruction* vPC = callFrame->codeBlock()->instructions.begin();
+ Instruction* vPC = callFrame->codeBlock()->instructions().begin();
Profiler** enabledProfilerReference = Profiler::enabledProfilerReference();
unsigned tickCount = m_ticksUntilNextTimeoutCheck + 1;
*/
int dst = (++vPC)->u.operand;
int regExp = (++vPC)->u.operand;
- callFrame[dst] = new (globalData) RegExpObject(callFrame->scopeChain()->globalObject()->regExpStructure(), callFrame->codeBlock()->regexps[regExp]);
+ callFrame[dst] = new (globalData) RegExpObject(callFrame->scopeChain()->globalObject()->regExpStructure(), callFrame->codeBlock()->regexp(regExp));
++vPC;
NEXT_INSTRUCTION();
*/
int dst = (++vPC)->u.operand;
int index = (++vPC)->u.operand;
- int skip = (++vPC)->u.operand + callFrame->codeBlock()->needsFullScopeChain;
+ int skip = (++vPC)->u.operand + callFrame->codeBlock()->needsFullScopeChain();
ScopeChainNode* scopeChain = callFrame->scopeChain();
ScopeChainIterator iter = scopeChain->begin();
*/
int index = (++vPC)->u.operand;
- int skip = (++vPC)->u.operand + callFrame->codeBlock()->needsFullScopeChain;
+ int skip = (++vPC)->u.operand + callFrame->codeBlock()->needsFullScopeChain();
int value = (++vPC)->u.operand;
ScopeChainNode* scopeChain = callFrame->scopeChain();
int property = vPC[3].u.operand;
CodeBlock* codeBlock = callFrame->codeBlock();
- Identifier& ident = codeBlock->identifiers[property];
+ Identifier& ident = codeBlock->identifier(property);
JSValue* baseValue = callFrame[base].jsValue(callFrame);
PropertySlot slot(baseValue);
JSValue* result = baseValue->get(callFrame, ident, slot);
int dst = vPC[1].u.operand;
int offset = vPC[5].u.operand;
- ASSERT(baseObject->get(callFrame, callFrame->codeBlock()->identifiers[vPC[3].u.operand]) == baseObject->getDirectOffset(offset));
+ ASSERT(baseObject->get(callFrame, callFrame->codeBlock()->identifier(vPC[3].u.operand)) == baseObject->getDirectOffset(offset));
callFrame[dst] = baseObject->getDirectOffset(offset);
vPC += 8;
int dst = vPC[1].u.operand;
int offset = vPC[6].u.operand;
- ASSERT(protoObject->get(callFrame, callFrame->codeBlock()->identifiers[vPC[3].u.operand]) == protoObject->getDirectOffset(offset));
+ ASSERT(protoObject->get(callFrame, callFrame->codeBlock()->identifier(vPC[3].u.operand)) == protoObject->getDirectOffset(offset));
callFrame[dst] = protoObject->getDirectOffset(offset);
vPC += 8;
int dst = vPC[1].u.operand;
int offset = vPC[7].u.operand;
- ASSERT(baseObject->get(callFrame, callFrame->codeBlock()->identifiers[vPC[3].u.operand]) == baseObject->getDirectOffset(offset));
+ ASSERT(baseObject->get(callFrame, callFrame->codeBlock()->identifier(vPC[3].u.operand)) == baseObject->getDirectOffset(offset));
callFrame[dst] = baseObject->getDirectOffset(offset);
vPC += 8;
int base = vPC[2].u.operand;
int property = vPC[3].u.operand;
- Identifier& ident = callFrame->codeBlock()->identifiers[property];
+ Identifier& ident = callFrame->codeBlock()->identifier(property);
JSValue* baseValue = callFrame[base].jsValue(callFrame);
PropertySlot slot(baseValue);
JSValue* result = baseValue->get(callFrame, ident, slot);
CodeBlock* codeBlock = callFrame->codeBlock();
JSValue* baseValue = callFrame[base].jsValue(callFrame);
- Identifier& ident = codeBlock->identifiers[property];
+ Identifier& ident = codeBlock->identifier(property);
PutPropertySlot slot;
baseValue->put(callFrame, ident, callFrame[value].jsValue(callFrame), slot);
CHECK_FOR_EXCEPTION();
int value = vPC[3].u.operand;
unsigned offset = vPC[7].u.operand;
- ASSERT(baseObject->offsetForLocation(baseObject->getDirectLocation(callFrame->codeBlock()->identifiers[vPC[2].u.operand])) == offset);
+ ASSERT(baseObject->offsetForLocation(baseObject->getDirectLocation(callFrame->codeBlock()->identifier(vPC[2].u.operand))) == offset);
baseObject->putDirectOffset(offset, callFrame[value].jsValue(callFrame));
vPC += 8;
int value = vPC[3].u.operand;
unsigned offset = vPC[5].u.operand;
- ASSERT(baseObject->offsetForLocation(baseObject->getDirectLocation(callFrame->codeBlock()->identifiers[vPC[2].u.operand])) == offset);
+ ASSERT(baseObject->offsetForLocation(baseObject->getDirectLocation(callFrame->codeBlock()->identifier(vPC[2].u.operand))) == offset);
baseObject->putDirectOffset(offset, callFrame[value].jsValue(callFrame));
vPC += 8;
int value = vPC[3].u.operand;
JSValue* baseValue = callFrame[base].jsValue(callFrame);
- Identifier& ident = callFrame->codeBlock()->identifiers[property];
+ Identifier& ident = callFrame->codeBlock()->identifier(property);
PutPropertySlot slot;
baseValue->put(callFrame, ident, callFrame[value].jsValue(callFrame), slot);
CHECK_FOR_EXCEPTION();
int property = (++vPC)->u.operand;
JSObject* baseObj = callFrame[base].jsValue(callFrame)->toObject(callFrame);
- Identifier& ident = callFrame->codeBlock()->identifiers[property];
+ Identifier& ident = callFrame->codeBlock()->identifier(property);
JSValue* result = jsBoolean(baseObj->deleteProperty(callFrame, ident));
CHECK_FOR_EXCEPTION();
callFrame[dst] = result;
int dst = (++vPC)->u.operand;
int func = (++vPC)->u.operand;
- callFrame[dst] = callFrame->codeBlock()->functions[func]->makeFunction(callFrame, callFrame->scopeChain());
+ callFrame[dst] = callFrame->codeBlock()->function(func)->makeFunction(callFrame, callFrame->scopeChain());
++vPC;
NEXT_INSTRUCTION();
int dst = (++vPC)->u.operand;
int func = (++vPC)->u.operand;
- callFrame[dst] = callFrame->codeBlock()->functionExpressions[func]->makeFunction(callFrame, callFrame->scopeChain());
+ callFrame[dst] = callFrame->codeBlock()->functionExpression(func)->makeFunction(callFrame, callFrame->scopeChain());
++vPC;
NEXT_INSTRUCTION();
}
callFrame->init(newCodeBlock, vPC + 5, callDataScopeChain, previousCallFrame, dst, argCount, asFunction(v));
- vPC = newCodeBlock->instructions.begin();
+ vPC = newCodeBlock->instructions().begin();
#if ENABLE(OPCODE_STATS)
OpcodeStats::resetLastInstruction();
*/
int src = (++vPC)->u.operand;
- ASSERT(callFrame->codeBlock()->needsFullScopeChain);
+ ASSERT(callFrame->codeBlock()->needsFullScopeChain());
asActivation(callFrame[src].getJSValue())->copyRegisters(callFrame->optionalCalleeArguments());
This opcode should only be used immediately before op_ret.
*/
- ASSERT(callFrame->codeBlock()->usesArguments && !callFrame->codeBlock()->needsFullScopeChain);
+ ASSERT(callFrame->codeBlock()->usesArguments() && !callFrame->codeBlock()->needsFullScopeChain());
callFrame->optionalCalleeArguments()->copyRegisters();
int result = (++vPC)->u.operand;
- if (callFrame->codeBlock()->needsFullScopeChain)
+ if (callFrame->codeBlock()->needsFullScopeChain())
callFrame->scopeChain()->deref();
JSValue* returnValue = callFrame[result].jsValue(callFrame);
size_t i = 0;
CodeBlock* codeBlock = callFrame->codeBlock();
- for (size_t count = codeBlock->numVars; i < count; ++i)
+ for (size_t count = codeBlock->m_numVars; i < count; ++i)
callFrame[i] = jsUndefined();
- for (size_t count = codeBlock->constantRegisters.size(), j = 0; j < count; ++i, ++j)
- callFrame[i] = codeBlock->constantRegisters[j];
+ for (size_t count = codeBlock->numberOfConstantRegisters(), j = 0; j < count; ++i, ++j)
+ callFrame[i] = codeBlock->constantRegister(j);
++vPC;
NEXT_INSTRUCTION();
size_t i = 0;
CodeBlock* codeBlock = callFrame->codeBlock();
- for (size_t count = codeBlock->numVars; i < count; ++i)
+ for (size_t count = codeBlock->m_numVars; i < count; ++i)
callFrame[i] = jsUndefined();
- for (size_t count = codeBlock->constantRegisters.size(), j = 0; j < count; ++i, ++j)
- callFrame[i] = codeBlock->constantRegisters[j];
+ for (size_t count = codeBlock->numberOfConstantRegisters(), j = 0; j < count; ++i, ++j)
+ callFrame[i] = codeBlock->constantRegister(j);
int dst = (++vPC)->u.operand;
- JSActivation* activation = new (globalData) JSActivation(callFrame, static_cast<FunctionBodyNode*>(codeBlock->ownerNode));
+ JSActivation* activation = new (globalData) JSActivation(callFrame, static_cast<FunctionBodyNode*>(codeBlock->ownerNode()));
callFrame[dst] = activation;
callFrame->setScopeChain(callFrame->scopeChain()->copy()->push(activation));
}
callFrame->init(newCodeBlock, vPC + 7, callDataScopeChain, previousCallFrame, dst, argCount, asFunction(v));
- vPC = newCodeBlock->instructions.begin();
+ vPC = newCodeBlock->instructions().begin();
#if ENABLE(OPCODE_STATS)
OpcodeStats::resetLastInstruction();
*/
int dst = (++vPC)->u.operand;
int src = (++vPC)->u.operand;
- callFrame[dst] = callFrame->codeBlock()->unexpectedConstants[src];
+ callFrame[dst] = callFrame->codeBlock()->unexpectedConstant(src);
++vPC;
NEXT_INSTRUCTION();
int message = (++vPC)->u.operand;
CodeBlock* codeBlock = callFrame->codeBlock();
- callFrame[dst] = Error::create(callFrame, (ErrorType)type, codeBlock->unexpectedConstants[message]->toString(callFrame), codeBlock->lineNumberForVPC(vPC), codeBlock->ownerNode->sourceID(), codeBlock->ownerNode->sourceURL());
+ callFrame[dst] = Error::create(callFrame, (ErrorType)type, codeBlock->unexpectedConstant(message)->toString(callFrame), codeBlock->lineNumberForVPC(vPC), codeBlock->ownerNode()->sourceID(), codeBlock->ownerNode()->sourceURL());
++vPC;
NEXT_INSTRUCTION();
program. Return control to the calling native code.
*/
- if (callFrame->codeBlock()->needsFullScopeChain) {
+ if (callFrame->codeBlock()->needsFullScopeChain()) {
ScopeChainNode* scopeChain = callFrame->scopeChain();
ASSERT(scopeChain->refCount > 1);
scopeChain->deref();
ASSERT(callFrame[base].jsValue(callFrame)->isObject());
JSObject* baseObj = asObject(callFrame[base].jsValue(callFrame));
- Identifier& ident = callFrame->codeBlock()->identifiers[property];
+ Identifier& ident = callFrame->codeBlock()->identifier(property);
ASSERT(callFrame[function].jsValue(callFrame)->isObject());
baseObj->defineGetter(callFrame, ident, asObject(callFrame[function].jsValue(callFrame)));
ASSERT(callFrame[base].jsValue(callFrame)->isObject());
JSObject* baseObj = asObject(callFrame[base].jsValue(callFrame));
- Identifier& ident = callFrame->codeBlock()->identifiers[property];
+ Identifier& ident = callFrame->codeBlock()->identifier(property);
ASSERT(callFrame[function].jsValue(callFrame)->isObject());
baseObj->defineSetter(callFrame, ident, asObject(callFrame[function].jsValue(callFrame)));
return jsNull();
CodeBlock* codeBlock = functionCallFrame->codeBlock();
- if (codeBlock->usesArguments) {
- ASSERT(codeBlock->codeType == FunctionCode);
- SymbolTable& symbolTable = codeBlock->symbolTable;
+ if (codeBlock->usesArguments()) {
+ ASSERT(codeBlock->codeType() == FunctionCode);
+ SymbolTable& symbolTable = codeBlock->symbolTable();
int argumentsIndex = symbolTable.get(functionCallFrame->propertyNames().arguments.ustring().rep()).getIndex();
return functionCallFrame[argumentsIndex].jsValue(callFrame);
}
Instruction* vPC = vPCForPC(callerCodeBlock, callFrame->returnPC());
lineNumber = callerCodeBlock->lineNumberForVPC(vPC - 1);
- sourceID = callerCodeBlock->ownerNode->sourceID();
- sourceURL = callerCodeBlock->ownerNode->sourceURL();
+ sourceID = callerCodeBlock->ownerNode()->sourceID();
+ sourceURL = callerCodeBlock->ownerNode()->sourceURL();
function = callerFrame->callee();
}
// In the interpreter the last structure is trapped here; in CTI we use the
// *_second method to achieve a similar (but not quite the same) effect.
- unsigned vPCIndex = codeBlock->ctiReturnAddressVPCMap.get(returnAddress);
- Instruction* vPC = codeBlock->instructions.begin() + vPCIndex;
+ unsigned vPCIndex = codeBlock->jitReturnAddressVPCMap().get(returnAddress);
+ Instruction* vPC = codeBlock->instructions().begin() + vPCIndex;
// Cache hit: Specialize instruction and ref Structures.
// In the interpreter the last structure is trapped here; in CTI we use the
// *_second method to achieve a similar (but not quite the same) effect.
- unsigned vPCIndex = codeBlock->ctiReturnAddressVPCMap.get(returnAddress);
- Instruction* vPC = codeBlock->instructions.begin() + vPCIndex;
+ unsigned vPCIndex = codeBlock->jitReturnAddressVPCMap().get(returnAddress);
+ Instruction* vPC = codeBlock->instructions().begin() + vPCIndex;
// Cache hit: Specialize instruction and ref Structures.
{
CTI_STACK_HACK();
- if (LIKELY(ARG_registerFile->grow(ARG_callFrame + ARG_callFrame->codeBlock()->numCalleeRegisters)))
+ if (LIKELY(ARG_registerFile->grow(ARG_callFrame + ARG_callFrame->codeBlock()->m_numCalleeRegisters)))
return;
// Rewind to the previous call frame because op_call already optimistically
&& slot.slotBase() == baseValue) {
CodeBlock* codeBlock = callFrame->codeBlock();
- unsigned vPCIndex = codeBlock->ctiReturnAddressVPCMap.get(CTI_RETURN_ADDRESS);
- Instruction* vPC = codeBlock->instructions.begin() + vPCIndex;
+ unsigned vPCIndex = codeBlock->jitReturnAddressVPCMap().get(CTI_RETURN_ADDRESS);
+ Instruction* vPC = codeBlock->instructions().begin() + vPCIndex;
ASSERT(slot.slotBase()->isObject());
Structure* structure = asCell(baseValue)->structure();
CodeBlock* codeBlock = callFrame->codeBlock();
- Instruction* vPC = codeBlock->instructions.begin() + codeBlock->ctiReturnAddressVPCMap.get(CTI_RETURN_ADDRESS);
+ Instruction* vPC = codeBlock->instructions().begin() + codeBlock->jitReturnAddressVPCMap().get(CTI_RETURN_ADDRESS);
ASSERT(slot.slotBase()->isObject());
JSObject* slotBaseObject = asObject(slot.slotBase());
if (!baseVal->isObject()) {
CallFrame* callFrame = ARG_callFrame;
CodeBlock* codeBlock = callFrame->codeBlock();
- ASSERT(codeBlock->ctiReturnAddressVPCMap.contains(CTI_RETURN_ADDRESS));
- unsigned vPCIndex = codeBlock->ctiReturnAddressVPCMap.get(CTI_RETURN_ADDRESS);
- ARG_globalData->exception = createInvalidParamError(callFrame, "instanceof", baseVal, codeBlock->instructions.begin() + vPCIndex, codeBlock);
+ ASSERT(codeBlock->jitReturnAddressVPCMap().contains(CTI_RETURN_ADDRESS));
+ unsigned vPCIndex = codeBlock->jitReturnAddressVPCMap().get(CTI_RETURN_ADDRESS);
+ ARG_globalData->exception = createInvalidParamError(callFrame, "instanceof", baseVal, codeBlock->instructions().begin() + vPCIndex, codeBlock);
VM_THROW_EXCEPTION();
}
ScopeChainNode* callDataScopeChain = asFunction(ARG_src1)->m_scopeChain.node();
CodeBlock* newCodeBlock = &asFunction(ARG_src1)->body()->bytecode(callDataScopeChain);
- if (!newCodeBlock->ctiCode)
+ if (!newCodeBlock->jitCode())
JIT::compile(ARG_globalData, newCodeBlock);
return newCodeBlock;
CodeBlock* newCodeBlock = ARG_codeBlock4;
int argCount = ARG_int3;
- ASSERT(argCount != newCodeBlock->numParameters);
+ ASSERT(argCount != newCodeBlock->m_numParameters);
CallFrame* oldCallFrame = callFrame->callerFrame();
- if (argCount > newCodeBlock->numParameters) {
- size_t numParameters = newCodeBlock->numParameters;
+ if (argCount > newCodeBlock->m_numParameters) {
+ size_t numParameters = newCodeBlock->m_numParameters;
Register* r = callFrame->registers() + numParameters;
Register* argv = r - RegisterFile::CallFrameHeaderSize - numParameters - argCount;
callFrame = CallFrame::create(r);
callFrame->setCallerFrame(oldCallFrame);
} else {
- size_t omittedArgCount = newCodeBlock->numParameters - argCount;
+ size_t omittedArgCount = newCodeBlock->m_numParameters - argCount;
Register* r = callFrame->registers() + omittedArgCount;
- Register* newEnd = r + newCodeBlock->numCalleeRegisters;
+ Register* newEnd = r + newCodeBlock->m_numCalleeRegisters;
if (!ARG_registerFile->grow(newEnd)) {
// Rewind to the previous call frame because op_call already optimistically
// moved the call frame forward.
JSFunction* callee = asFunction(ARG_src1);
CodeBlock* codeBlock = &callee->body()->bytecode(callee->m_scopeChain.node());
- if (!codeBlock->ctiCode)
+ if (!codeBlock->jitCode())
JIT::compile(ARG_globalData, codeBlock);
ctiRepatchCallByReturnAddress(ARG_returnAddress2, ARG_globalData->interpreter->m_ctiVirtualCallLink);
- return codeBlock->ctiCode;
+ return codeBlock->jitCode();
}
void* Interpreter::cti_vm_lazyLinkCall(CTI_ARGS)
JSFunction* callee = asFunction(ARG_src1);
CodeBlock* codeBlock = &callee->body()->bytecode(callee->m_scopeChain.node());
- if (!codeBlock->ctiCode)
+ if (!codeBlock->jitCode())
JIT::compile(ARG_globalData, codeBlock);
CallLinkInfo* callLinkInfo = &ARG_callFrame->callerFrame()->codeBlock()->getCallLinkInfo(ARG_returnAddress2);
- JIT::linkCall(callee, codeBlock, codeBlock->ctiCode, callLinkInfo, ARG_int3);
+ JIT::linkCall(callee, codeBlock, codeBlock->jitCode(), callLinkInfo, ARG_int3);
- return codeBlock->ctiCode;
+ return codeBlock->jitCode();
}
JSObject* Interpreter::cti_op_push_activation(CTI_ARGS)
{
CTI_STACK_HACK();
- JSActivation* activation = new (ARG_globalData) JSActivation(ARG_callFrame, static_cast<FunctionBodyNode*>(ARG_callFrame->codeBlock()->ownerNode));
+ JSActivation* activation = new (ARG_globalData) JSActivation(ARG_callFrame, static_cast<FunctionBodyNode*>(ARG_callFrame->codeBlock()->ownerNode()));
ARG_callFrame->setScopeChain(ARG_callFrame->scopeChain()->copy()->push(activation));
return activation;
}
{
CTI_STACK_HACK();
- ASSERT(ARG_callFrame->codeBlock()->needsFullScopeChain);
+ ASSERT(ARG_callFrame->codeBlock()->needsFullScopeChain());
asActivation(ARG_src1)->copyRegisters(ARG_callFrame->optionalCalleeArguments());
}
{
CTI_STACK_HACK();
- ASSERT(ARG_callFrame->codeBlock()->usesArguments && !ARG_callFrame->codeBlock()->needsFullScopeChain);
+ ASSERT(ARG_callFrame->codeBlock()->usesArguments() && !ARG_callFrame->codeBlock()->needsFullScopeChain());
ARG_callFrame->optionalCalleeArguments()->copyRegisters();
}
{
CTI_STACK_HACK();
- ASSERT(ARG_callFrame->codeBlock()->needsFullScopeChain);
+ ASSERT(ARG_callFrame->codeBlock()->needsFullScopeChain());
ARG_callFrame->scopeChain()->deref();
}
} while (++iter != end);
CodeBlock* codeBlock = callFrame->codeBlock();
- ASSERT(codeBlock->ctiReturnAddressVPCMap.contains(CTI_RETURN_ADDRESS));
- unsigned vPCIndex = codeBlock->ctiReturnAddressVPCMap.get(CTI_RETURN_ADDRESS);
- ARG_globalData->exception = createUndefinedVariableError(callFrame, ident, codeBlock->instructions.begin() + vPCIndex, codeBlock);
+ ASSERT(codeBlock->jitReturnAddressVPCMap().contains(CTI_RETURN_ADDRESS));
+ unsigned vPCIndex = codeBlock->jitReturnAddressVPCMap().get(CTI_RETURN_ADDRESS);
+ ARG_globalData->exception = createUndefinedVariableError(callFrame, ident, codeBlock->instructions().begin() + vPCIndex, codeBlock);
VM_THROW_EXCEPTION();
}
} while (iter != end);
CodeBlock* codeBlock = callFrame->codeBlock();
- ASSERT(codeBlock->ctiReturnAddressVPCMap.contains(CTI_RETURN_ADDRESS));
- unsigned vPCIndex = codeBlock->ctiReturnAddressVPCMap.get(CTI_RETURN_ADDRESS);
- ARG_globalData->exception = createUndefinedVariableError(callFrame, ident, codeBlock->instructions.begin() + vPCIndex, codeBlock);
+ ASSERT(codeBlock->jitReturnAddressVPCMap().contains(CTI_RETURN_ADDRESS));
+ unsigned vPCIndex = codeBlock->jitReturnAddressVPCMap().get(CTI_RETURN_ADDRESS);
+ ARG_globalData->exception = createUndefinedVariableError(callFrame, ident, codeBlock->instructions().begin() + vPCIndex, codeBlock);
VM_THROW_EXCEPTION_2();
}
} while (++iter != end);
CodeBlock* codeBlock = callFrame->codeBlock();
- ASSERT(codeBlock->ctiReturnAddressVPCMap.contains(CTI_RETURN_ADDRESS));
- unsigned vPCIndex = codeBlock->ctiReturnAddressVPCMap.get(CTI_RETURN_ADDRESS);
- ARG_globalData->exception = createUndefinedVariableError(callFrame, ident, codeBlock->instructions.begin() + vPCIndex, codeBlock);
+ ASSERT(codeBlock->jitReturnAddressVPCMap().contains(CTI_RETURN_ADDRESS));
+ unsigned vPCIndex = codeBlock->jitReturnAddressVPCMap().get(CTI_RETURN_ADDRESS);
+ ARG_globalData->exception = createUndefinedVariableError(callFrame, ident, codeBlock->instructions().begin() + vPCIndex, codeBlock);
VM_THROW_EXCEPTION();
}
} while (iter != end);
CodeBlock* codeBlock = callFrame->codeBlock();
- ASSERT(codeBlock->ctiReturnAddressVPCMap.contains(CTI_RETURN_ADDRESS));
- unsigned vPCIndex = codeBlock->ctiReturnAddressVPCMap.get(CTI_RETURN_ADDRESS);
- ARG_globalData->exception = createUndefinedVariableError(callFrame, ident, codeBlock->instructions.begin() + vPCIndex, codeBlock);
+ ASSERT(codeBlock->jitReturnAddressVPCMap().contains(CTI_RETURN_ADDRESS));
+ unsigned vPCIndex = codeBlock->jitReturnAddressVPCMap().get(CTI_RETURN_ADDRESS);
+ ARG_globalData->exception = createUndefinedVariableError(callFrame, ident, codeBlock->instructions().begin() + vPCIndex, codeBlock);
VM_THROW_EXCEPTION_2();
}
CallFrame* callFrame = ARG_callFrame;
CodeBlock* codeBlock = callFrame->codeBlock();
- ASSERT(codeBlock->ctiReturnAddressVPCMap.contains(CTI_RETURN_ADDRESS));
- unsigned vPCIndex = codeBlock->ctiReturnAddressVPCMap.get(CTI_RETURN_ADDRESS);
+ ASSERT(codeBlock->jitReturnAddressVPCMap().contains(CTI_RETURN_ADDRESS));
+ unsigned vPCIndex = codeBlock->jitReturnAddressVPCMap().get(CTI_RETURN_ADDRESS);
JSValue* exceptionValue = ARG_src1;
ASSERT(exceptionValue);
- Instruction* handlerVPC = ARG_globalData->interpreter->throwException(callFrame, exceptionValue, codeBlock->instructions.begin() + vPCIndex, true);
+ Instruction* handlerVPC = ARG_globalData->interpreter->throwException(callFrame, exceptionValue, codeBlock->instructions().begin() + vPCIndex, true);
if (!handlerVPC) {
*ARG_exception = exceptionValue;
if (!baseVal->isObject()) {
CallFrame* callFrame = ARG_callFrame;
CodeBlock* codeBlock = callFrame->codeBlock();
- ASSERT(codeBlock->ctiReturnAddressVPCMap.contains(CTI_RETURN_ADDRESS));
- unsigned vPCIndex = codeBlock->ctiReturnAddressVPCMap.get(CTI_RETURN_ADDRESS);
- ARG_globalData->exception = createInvalidParamError(callFrame, "in", baseVal, codeBlock->instructions.begin() + vPCIndex, codeBlock);
+ ASSERT(codeBlock->jitReturnAddressVPCMap().contains(CTI_RETURN_ADDRESS));
+ unsigned vPCIndex = codeBlock->jitReturnAddressVPCMap().get(CTI_RETURN_ADDRESS);
+ ARG_globalData->exception = createInvalidParamError(callFrame, "in", baseVal, codeBlock->instructions().begin() + vPCIndex, codeBlock);
VM_THROW_EXCEPTION();
}
JSValue* message = ARG_src2;
unsigned lineNumber = ARG_int3;
- return Error::create(callFrame, static_cast<ErrorType>(type), message->toString(callFrame), lineNumber, codeBlock->ownerNode->sourceID(), codeBlock->ownerNode->sourceURL());
+ return Error::create(callFrame, static_cast<ErrorType>(type), message->toString(callFrame), lineNumber, codeBlock->ownerNode()->sourceID(), codeBlock->ownerNode()->sourceURL());
}
void Interpreter::cti_op_debug(CTI_ARGS)
CodeBlock* codeBlock = callFrame->codeBlock();
JSGlobalData* globalData = ARG_globalData;
- ASSERT(codeBlock->ctiReturnAddressVPCMap.contains(globalData->exceptionLocation));
- unsigned vPCIndex = codeBlock->ctiReturnAddressVPCMap.get(globalData->exceptionLocation);
+ ASSERT(codeBlock->jitReturnAddressVPCMap().contains(globalData->exceptionLocation));
+ unsigned vPCIndex = codeBlock->jitReturnAddressVPCMap().get(globalData->exceptionLocation);
JSValue* exceptionValue = globalData->exception;
ASSERT(exceptionValue);
globalData->exception = noValue();
- Instruction* handlerVPC = globalData->interpreter->throwException(callFrame, exceptionValue, codeBlock->instructions.begin() + vPCIndex, false);
+ Instruction* handlerVPC = globalData->interpreter->throwException(callFrame, exceptionValue, codeBlock->instructions().begin() + vPCIndex, false);
if (!handlerVPC) {
*ARG_exception = exceptionValue;
: m_interpreter(globalData->interpreter)
, m_globalData(globalData)
, m_codeBlock(codeBlock)
- , m_labels(codeBlock ? codeBlock->instructions.size() : 0)
- , m_propertyAccessCompilationInfo(codeBlock ? codeBlock->propertyAccessInstructions.size() : 0)
- , m_callStructureStubCompilationInfo(codeBlock ? codeBlock->callLinkInfos.size() : 0)
+ , m_labels(codeBlock ? codeBlock->instructions().size() : 0)
+ , m_propertyAccessCompilationInfo(codeBlock ? codeBlock->numberOfPropertyAccessInstructions() : 0)
+ , m_callStructureStubCompilationInfo(codeBlock ? codeBlock->numberOfCallLinkInfos() : 0)
, m_lastResultBytecodeRegister(std::numeric_limits<int>::max())
, m_jumpTargetsPosition(0)
{
void JIT::privateCompileMainPass()
{
- Instruction* instruction = m_codeBlock->instructions.begin();
- unsigned instructionCount = m_codeBlock->instructions.size();
+ Instruction* instruction = m_codeBlock->instructions().begin();
+ unsigned instructionCount = m_codeBlock->instructions().size();
unsigned propertyAccessInstructionIndex = 0;
unsigned callLinkInfoIndex = 0;
break;
}
case op_end: {
- if (m_codeBlock->needsFullScopeChain)
+ if (m_codeBlock->needsFullScopeChain())
emitCTICall(i, Interpreter::cti_op_end);
emitGetVirtualRegister(instruction[i + 1].u.operand, X86::eax, i);
__ pushl_m(RegisterFile::ReturnPC * static_cast<int>(sizeof(Register)), X86::edi);
break;
}
case op_put_by_id: {
- compilePutByIdHotPath(instruction[i + 1].u.operand, &(m_codeBlock->identifiers[instruction[i + 2].u.operand]), instruction[i + 3].u.operand, i, propertyAccessInstructionIndex++);
+ compilePutByIdHotPath(instruction[i + 1].u.operand, &(m_codeBlock->identifier(instruction[i + 2].u.operand)), instruction[i + 3].u.operand, i, propertyAccessInstructionIndex++);
i += 8;
break;
}
case op_get_by_id: {
- compileGetByIdHotPath(instruction[i + 1].u.operand, instruction[i + 2].u.operand, &(m_codeBlock->identifiers[instruction[i + 3].u.operand]), i, propertyAccessInstructionIndex++);
+ compileGetByIdHotPath(instruction[i + 1].u.operand, instruction[i + 2].u.operand, &(m_codeBlock->identifier(instruction[i + 3].u.operand)), i, propertyAccessInstructionIndex++);
i += 8;
break;
}
}
case op_del_by_id: {
emitPutCTIArgFromVirtualRegister(instruction[i + 2].u.operand, 0, X86::ecx);
- Identifier* ident = &(m_codeBlock->identifiers[instruction[i + 3].u.operand]);
+ Identifier* ident = &(m_codeBlock->identifier(instruction[i + 3].u.operand));
emitPutCTIArgConstant(reinterpret_cast<unsigned>(ident), 4);
emitCTICall(i, Interpreter::cti_op_del_by_id);
emitPutVirtualRegister(instruction[i + 1].u.operand);
break;
}
case op_new_func: {
- FuncDeclNode* func = (m_codeBlock->functions[instruction[i + 2].u.operand]).get();
+ FuncDeclNode* func = m_codeBlock->function(instruction[i + 2].u.operand);
emitPutCTIArgConstant(reinterpret_cast<unsigned>(func), 0);
emitCTICall(i, Interpreter::cti_op_new_func);
emitPutVirtualRegister(instruction[i + 1].u.operand);
break;
}
case op_get_scoped_var: {
- int skip = instruction[i + 3].u.operand + m_codeBlock->needsFullScopeChain;
+ int skip = instruction[i + 3].u.operand + m_codeBlock->needsFullScopeChain();
emitGetFromCallFrameHeader(RegisterFile::ScopeChain, X86::eax);
while (skip--)
break;
}
case op_put_scoped_var: {
- int skip = instruction[i + 2].u.operand + m_codeBlock->needsFullScopeChain;
+ int skip = instruction[i + 2].u.operand + m_codeBlock->needsFullScopeChain();
emitGetFromCallFrameHeader(RegisterFile::ScopeChain, X86::edx);
emitGetVirtualRegister(instruction[i + 3].u.operand, X86::eax, i);
}
case op_ret: {
// We could JIT generate the deref, only calling out to C when the refcount hits zero.
- if (m_codeBlock->needsFullScopeChain)
+ if (m_codeBlock->needsFullScopeChain())
emitCTICall(i, Interpreter::cti_op_ret_scopeChain);
// Return the result in %eax.
break;
}
case op_resolve: {
- Identifier* ident = &(m_codeBlock->identifiers[instruction[i + 2].u.operand]);
+ Identifier* ident = &(m_codeBlock->identifier(instruction[i + 2].u.operand));
emitPutCTIArgConstant(reinterpret_cast<unsigned>(ident), 0);
emitCTICall(i, Interpreter::cti_op_resolve);
emitPutVirtualRegister(instruction[i + 1].u.operand);
break;
}
case op_resolve_func: {
- Identifier* ident = &(m_codeBlock->identifiers[instruction[i + 3].u.operand]);
+ Identifier* ident = &(m_codeBlock->identifier(instruction[i + 3].u.operand));
emitPutCTIArgConstant(reinterpret_cast<unsigned>(ident), 0);
emitCTICall(i, Interpreter::cti_op_resolve_func);
emitPutVirtualRegister(instruction[i + 2].u.operand, X86::edx);
break;
};
case op_resolve_base: {
- Identifier* ident = &(m_codeBlock->identifiers[instruction[i + 2].u.operand]);
+ Identifier* ident = &(m_codeBlock->identifier(instruction[i + 2].u.operand));
emitPutCTIArgConstant(reinterpret_cast<unsigned>(ident), 0);
emitCTICall(i, Interpreter::cti_op_resolve_base);
emitPutVirtualRegister(instruction[i + 1].u.operand);
break;
}
case op_resolve_skip: {
- Identifier* ident = &(m_codeBlock->identifiers[instruction[i + 2].u.operand]);
+ Identifier* ident = &(m_codeBlock->identifier(instruction[i + 2].u.operand));
emitPutCTIArgConstant(reinterpret_cast<unsigned>(ident), 0);
- emitPutCTIArgConstant(instruction[i + 3].u.operand + m_codeBlock->needsFullScopeChain, 4);
+ emitPutCTIArgConstant(instruction[i + 3].u.operand + m_codeBlock->needsFullScopeChain(), 4);
emitCTICall(i, Interpreter::cti_op_resolve_skip);
emitPutVirtualRegister(instruction[i + 1].u.operand);
i += 4;
case op_resolve_global: {
// Fast case
unsigned globalObject = asInteger(instruction[i + 2].u.jsCell);
- Identifier* ident = &(m_codeBlock->identifiers[instruction[i + 3].u.operand]);
+ Identifier* ident = &(m_codeBlock->identifier(instruction[i + 3].u.operand));
void* structureAddress = reinterpret_cast<void*>(instruction + i + 4);
void* offsetAddr = reinterpret_cast<void*>(instruction + i + 5);
break;
}
case op_unexpected_load: {
- JSValue* v = m_codeBlock->unexpectedConstants[instruction[i + 2].u.operand];
+ JSValue* v = m_codeBlock->unexpectedConstant(instruction[i + 2].u.operand);
__ movl_i32r(asInteger(v), X86::eax);
emitPutVirtualRegister(instruction[i + 1].u.operand);
i += 3;
break;
}
case op_resolve_with_base: {
- Identifier* ident = &(m_codeBlock->identifiers[instruction[i + 3].u.operand]);
+ Identifier* ident = &(m_codeBlock->identifier(instruction[i + 3].u.operand));
emitPutCTIArgConstant(reinterpret_cast<unsigned>(ident), 0);
emitCTICall(i, Interpreter::cti_op_resolve_with_base);
emitPutVirtualRegister(instruction[i + 2].u.operand, X86::edx);
break;
}
case op_new_func_exp: {
- FuncExprNode* func = (m_codeBlock->functionExpressions[instruction[i + 2].u.operand]).get();
+ FuncExprNode* func = m_codeBlock->functionExpression(instruction[i + 2].u.operand);
emitPutCTIArgConstant(reinterpret_cast<unsigned>(func), 0);
emitCTICall(i, Interpreter::cti_op_new_func_exp);
emitPutVirtualRegister(instruction[i + 1].u.operand);
break;
}
case op_new_regexp: {
- RegExp* regExp = m_codeBlock->regexps[instruction[i + 2].u.operand].get();
+ RegExp* regExp = m_codeBlock->regexp(instruction[i + 2].u.operand);
emitPutCTIArgConstant(reinterpret_cast<unsigned>(regExp), 0);
emitCTICall(i, Interpreter::cti_op_new_regexp);
emitPutVirtualRegister(instruction[i + 1].u.operand);
break;
}
case op_push_new_scope: {
- Identifier* ident = &(m_codeBlock->identifiers[instruction[i + 2].u.operand]);
+ Identifier* ident = &(m_codeBlock->identifier(instruction[i + 2].u.operand));
emitPutCTIArgConstant(reinterpret_cast<unsigned>(ident), 0);
emitPutCTIArgFromVirtualRegister(instruction[i + 3].u.operand, 4, X86::ecx);
emitCTICall(i, Interpreter::cti_op_push_new_scope);
}
case op_put_getter: {
emitPutCTIArgFromVirtualRegister(instruction[i + 1].u.operand, 0, X86::ecx);
- Identifier* ident = &(m_codeBlock->identifiers[instruction[i + 2].u.operand]);
+ Identifier* ident = &(m_codeBlock->identifier(instruction[i + 2].u.operand));
emitPutCTIArgConstant(reinterpret_cast<unsigned>(ident), 4);
emitPutCTIArgFromVirtualRegister(instruction[i + 3].u.operand, 8, X86::ecx);
emitCTICall(i, Interpreter::cti_op_put_getter);
}
case op_put_setter: {
emitPutCTIArgFromVirtualRegister(instruction[i + 1].u.operand, 0, X86::ecx);
- Identifier* ident = &(m_codeBlock->identifiers[instruction[i + 2].u.operand]);
+ Identifier* ident = &(m_codeBlock->identifier(instruction[i + 2].u.operand));
emitPutCTIArgConstant(reinterpret_cast<unsigned>(ident), 4);
emitPutCTIArgFromVirtualRegister(instruction[i + 3].u.operand, 8, X86::ecx);
emitCTICall(i, Interpreter::cti_op_put_setter);
break;
}
case op_new_error: {
- JSValue* message = m_codeBlock->unexpectedConstants[instruction[i + 3].u.operand];
+ JSValue* message = m_codeBlock->unexpectedConstant(instruction[i + 3].u.operand);
emitPutCTIArgConstant(instruction[i + 2].u.operand, 0);
emitPutCTIArgConstant(asInteger(message), 4);
emitPutCTIArgConstant(m_codeBlock->lineNumberForVPC(&instruction[i]), 8);
// Even though CTI doesn't use them, we initialize our constant
// registers to zap stale pointers, to avoid unnecessarily prolonging
// object lifetime and increasing GC pressure.
- size_t count = m_codeBlock->numVars + m_codeBlock->constantRegisters.size();
+ size_t count = m_codeBlock->m_numVars + m_codeBlock->numberOfConstantRegisters();
for (size_t j = 0; j < count; ++j)
emitInitRegister(j);
// Even though CTI doesn't use them, we initialize our constant
// registers to zap stale pointers, to avoid unnecessarily prolonging
// object lifetime and increasing GC pressure.
- size_t count = m_codeBlock->numVars + m_codeBlock->constantRegisters.size();
+ size_t count = m_codeBlock->m_numVars + m_codeBlock->numberOfConstantRegisters();
for (size_t j = 0; j < count; ++j)
emitInitRegister(j);
break;
}
case op_create_arguments: {
- emitCTICall(i, (m_codeBlock->numParameters == 1) ? Interpreter::cti_op_create_arguments_no_params : Interpreter::cti_op_create_arguments);
+ emitCTICall(i, (m_codeBlock->m_numParameters == 1) ? Interpreter::cti_op_create_arguments_no_params : Interpreter::cti_op_create_arguments);
i += 1;
break;
}
}
}
- ASSERT(propertyAccessInstructionIndex == m_codeBlock->propertyAccessInstructions.size());
- ASSERT(callLinkInfoIndex == m_codeBlock->callLinkInfos.size());
+ ASSERT(propertyAccessInstructionIndex == m_codeBlock->numberOfPropertyAccessInstructions());
+ ASSERT(callLinkInfoIndex == m_codeBlock->numberOfCallLinkInfos());
}
unsigned propertyAccessInstructionIndex = 0;
unsigned callLinkInfoIndex = 0;
- Instruction* instruction = m_codeBlock->instructions.begin();
+ Instruction* instruction = m_codeBlock->instructions().begin();
for (Vector<SlowCaseEntry>::iterator iter = m_slowCases.begin(); iter != m_slowCases.end(); ++iter) {
// FIXME: enable peephole optimizations for slow cases when applicable
killLastResultRegister();
break;
}
case op_put_by_id: {
- compilePutByIdSlowCase(instruction[i + 1].u.operand, &(m_codeBlock->identifiers[instruction[i + 2].u.operand]), instruction[i + 3].u.operand, i, iter, propertyAccessInstructionIndex++);
+ compilePutByIdSlowCase(instruction[i + 1].u.operand, &(m_codeBlock->identifier(instruction[i + 2].u.operand)), instruction[i + 3].u.operand, i, iter, propertyAccessInstructionIndex++);
i += 8;
break;
}
case op_get_by_id: {
- compileGetByIdSlowCase(instruction[i + 1].u.operand, instruction[i + 2].u.operand, &(m_codeBlock->identifiers[instruction[i + 3].u.operand]), i, iter, propertyAccessInstructionIndex++);
+ compileGetByIdSlowCase(instruction[i + 1].u.operand, instruction[i + 2].u.operand, &(m_codeBlock->identifier(instruction[i + 3].u.operand)), i, iter, propertyAccessInstructionIndex++);
i += 8;
break;
}
__ link(__ jmp(), m_labels[i]);
}
- ASSERT(propertyAccessInstructionIndex == m_codeBlock->propertyAccessInstructions.size());
- ASSERT(callLinkInfoIndex == m_codeBlock->callLinkInfos.size());
+ ASSERT(propertyAccessInstructionIndex == m_codeBlock->numberOfPropertyAccessInstructions());
+ ASSERT(callLinkInfoIndex == m_codeBlock->numberOfCallLinkInfos());
}
void JIT::privateCompile()
__ movl_i32m(reinterpret_cast<unsigned>(m_codeBlock), m_interpreter->sampler()->codeBlockSlot());
#endif
#if ENABLE(OPCODE_SAMPLING)
- __ movl_i32m(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions.begin()), m_interpreter->sampler()->sampleSlot());
+ __ movl_i32m(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions().begin()), m_interpreter->sampler()->sampleSlot());
#endif
// Could use a popl_m, but would need to offset the following instruction if so.
JmpSrc slowRegisterFileCheck;
JmpDst afterRegisterFileCheck;
- if (m_codeBlock->codeType == FunctionCode) {
+ if (m_codeBlock->codeType() == FunctionCode) {
// In the case of a fast linked call, we do not set this up in the caller.
emitPutImmediateToCallFrameHeader(m_codeBlock, RegisterFile::CodeBlock);
emitGetCTIParam(CTI_ARGS_registerFile, X86::eax);
- __ leal_mr(m_codeBlock->numCalleeRegisters * sizeof(Register), X86::edi, X86::edx);
+ __ leal_mr(m_codeBlock->m_numCalleeRegisters * sizeof(Register), X86::edi, X86::edx);
__ cmpl_mr(FIELD_OFFSET(RegisterFile, m_end), X86::eax, X86::edx);
slowRegisterFileCheck = __ jg();
afterRegisterFileCheck = __ label();
privateCompileLinkPass();
privateCompileSlowCases();
- if (m_codeBlock->codeType == FunctionCode) {
+ if (m_codeBlock->codeType() == FunctionCode) {
__ link(slowRegisterFileCheck, __ label());
emitCTICall(0, Interpreter::cti_register_file_check);
JmpSrc backToBody = __ jmp();
}
}
- for (Vector<HandlerInfo>::iterator iter = m_codeBlock->exceptionHandlers.begin(); iter != m_codeBlock->exceptionHandlers.end(); ++iter)
- iter->nativeCode = __ getRelocatedAddress(code, m_labels[iter->target]);
+ for (size_t i = 0; i < m_codeBlock->numberOfExceptionHandlers(); ++i) {
+ HandlerInfo& handler = m_codeBlock->exceptionHandler(i);
+ handler.nativeCode = __ getRelocatedAddress(code, m_labels[handler.target]);
+ }
for (Vector<CallRecord>::iterator iter = m_calls.begin(); iter != m_calls.end(); ++iter) {
if (iter->to)
X86Assembler::link(code, iter->from, iter->to);
- m_codeBlock->ctiReturnAddressVPCMap.add(__ getRelocatedAddress(code, iter->from), iter->bytecodeIndex);
+ m_codeBlock->jitReturnAddressVPCMap().add(__ getRelocatedAddress(code, iter->from), iter->bytecodeIndex);
}
// Link absolute addresses for jsr
for (Vector<JSRInfo>::iterator iter = m_jsrSites.begin(); iter != m_jsrSites.end(); ++iter)
X86Assembler::linkAbsoluteAddress(code, iter->addrPosition, iter->target);
- for (unsigned i = 0; i < m_codeBlock->propertyAccessInstructions.size(); ++i) {
- StructureStubInfo& info = m_codeBlock->propertyAccessInstructions[i];
+ for (unsigned i = 0; i < m_codeBlock->numberOfPropertyAccessInstructions(); ++i) {
+ StructureStubInfo& info = m_codeBlock->propertyAccessInstruction(i);
info.callReturnLocation = X86Assembler::getRelocatedAddress(code, m_propertyAccessCompilationInfo[i].callReturnLocation);
info.hotPathBegin = X86Assembler::getRelocatedAddress(code, m_propertyAccessCompilationInfo[i].hotPathBegin);
}
- for (unsigned i = 0; i < m_codeBlock->callLinkInfos.size(); ++i) {
- CallLinkInfo& info = m_codeBlock->callLinkInfos[i];
+ for (unsigned i = 0; i < m_codeBlock->numberOfCallLinkInfos(); ++i) {
+ CallLinkInfo& info = m_codeBlock->callLinkInfo(i);
info.callReturnLocation = X86Assembler::getRelocatedAddress(code, m_callStructureStubCompilationInfo[i].callReturnLocation);
info.hotPathBegin = X86Assembler::getRelocatedAddress(code, m_callStructureStubCompilationInfo[i].hotPathBegin);
info.hotPathOther = X86Assembler::getRelocatedAddress(code, m_callStructureStubCompilationInfo[i].hotPathOther);
info.coldPathOther = X86Assembler::getRelocatedAddress(code, m_callStructureStubCompilationInfo[i].coldPathOther);
}
- m_codeBlock->ctiCode = code;
+ m_codeBlock->setJITCode(code);
}
void JIT::privateCompileCTIMachineTrampolines()
__ link(hasCodeBlock1, __ label());
// Check argCount matches callee arity.
- __ cmpl_rm(X86::edx, FIELD_OFFSET(CodeBlock, numParameters), X86::eax);
+ __ cmpl_rm(X86::edx, FIELD_OFFSET(CodeBlock, m_numParameters), X86::eax);
JmpSrc arityCheckOkay1 = __ je();
__ popl_r(X86::ebx);
emitPutCTIArg(X86::ebx, 4);
__ link(hasCodeBlock2, __ label());
// Check argCount matches callee arity.
- __ cmpl_rm(X86::edx, FIELD_OFFSET(CodeBlock, numParameters), X86::eax);
+ __ cmpl_rm(X86::edx, FIELD_OFFSET(CodeBlock, m_numParameters), X86::eax);
JmpSrc arityCheckOkay2 = __ je();
__ popl_r(X86::ebx);
emitPutCTIArg(X86::ebx, 4);
__ link(hasCodeBlock3, __ label());
// Check argCount matches callee arity.
- __ cmpl_rm(X86::edx, FIELD_OFFSET(CodeBlock, numParameters), X86::eax);
+ __ cmpl_rm(X86::edx, FIELD_OFFSET(CodeBlock, m_numParameters), X86::eax);
JmpSrc arityCheckOkay3 = __ je();
__ popl_r(X86::ebx);
emitPutCTIArg(X86::ebx, 4);
compileOpCallInitializeCallFrame();
// load ctiCode from the new codeBlock.
- __ movl_mr(FIELD_OFFSET(CodeBlock, ctiCode), X86::eax, X86::eax);
+ __ movl_mr(FIELD_OFFSET(CodeBlock, m_jitCode), X86::eax, X86::eax);
__ jmp_r(X86::eax);
void JIT::linkCall(JSFunction* callee, CodeBlock* calleeCodeBlock, void* ctiCode, CallLinkInfo* callLinkInfo, int callerArgCount)
{
// Currently we only link calls with the exact number of arguments.
- if (callerArgCount == calleeCodeBlock->numParameters) {
+ if (callerArgCount == calleeCodeBlock->m_numParameters) {
ASSERT(!callLinkInfo->isLinked());
calleeCodeBlock->addCaller(callLinkInfo);
if (src == m_lastResultBytecodeRegister && m_codeBlock->isTemporaryRegisterIndex(src)) {
bool atJumpTarget = false;
- while (m_jumpTargetsPosition < m_codeBlock->jumpTargets.size() && m_codeBlock->jumpTargets[m_jumpTargetsPosition] <= currentInstructionIndex) {
- if (m_codeBlock->jumpTargets[m_jumpTargetsPosition] == currentInstructionIndex)
+ while (m_jumpTargetsPosition < m_codeBlock->numberOfJumpTargets() && m_codeBlock->jumpTarget(m_jumpTargetsPosition) <= currentInstructionIndex) {
+ if (m_codeBlock->jumpTarget(m_jumpTargetsPosition) == currentInstructionIndex)
atJumpTarget = true;
++m_jumpTargetsPosition;
}
ALWAYS_INLINE JmpSrc JIT::emitCTICall(unsigned bytecodeIndex, CTIHelper_j helper)
{
#if ENABLE(OPCODE_SAMPLING)
- store32(Imm32(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions.begin() + bytecodeIndex, true)), m_interpreter->sampler()->sampleSlot());
+ store32(Imm32(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions().begin() + bytecodeIndex, true)), m_interpreter->sampler()->sampleSlot());
#endif
restoreArgumentReference();
emitPutCTIParam(callFrameRegister, CTI_ARGS_callFrame);
JmpSrc ctiCall = call();
m_calls.append(CallRecord(ctiCall, helper, bytecodeIndex));
#if ENABLE(OPCODE_SAMPLING)
- store32(Imm32(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions.begin() + bytecodeIndex, false)), m_interpreter->sampler()->sampleSlot());
+ store32(Imm32(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions().begin() + bytecodeIndex, false)), m_interpreter->sampler()->sampleSlot());
#endif
killLastResultRegister();
ALWAYS_INLINE JmpSrc JIT::emitCTICall(unsigned bytecodeIndex, CTIHelper_o helper)
{
#if ENABLE(OPCODE_SAMPLING)
- store32(Imm32(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions.begin() + bytecodeIndex, true)), m_interpreter->sampler()->sampleSlot());
+ store32(Imm32(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions().begin() + bytecodeIndex, true)), m_interpreter->sampler()->sampleSlot());
#endif
restoreArgumentReference();
emitPutCTIParam(callFrameRegister, CTI_ARGS_callFrame);
JmpSrc ctiCall = call();
m_calls.append(CallRecord(ctiCall, helper, bytecodeIndex));
#if ENABLE(OPCODE_SAMPLING)
- store32(Imm32(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions.begin() + bytecodeIndex, false)), m_interpreter->sampler()->sampleSlot());
+ store32(Imm32(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions().begin() + bytecodeIndex, false)), m_interpreter->sampler()->sampleSlot());
#endif
killLastResultRegister();
ALWAYS_INLINE JmpSrc JIT::emitCTICall(unsigned bytecodeIndex, CTIHelper_p helper)
{
#if ENABLE(OPCODE_SAMPLING)
- store32(Imm32(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions.begin() + bytecodeIndex, true)), m_interpreter->sampler()->sampleSlot());
+ store32(Imm32(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions().begin() + bytecodeIndex, true)), m_interpreter->sampler()->sampleSlot());
#endif
restoreArgumentReference();
emitPutCTIParam(callFrameRegister, CTI_ARGS_callFrame);
JmpSrc ctiCall = call();
m_calls.append(CallRecord(ctiCall, helper, bytecodeIndex));
#if ENABLE(OPCODE_SAMPLING)
- store32(Imm32(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions.begin() + bytecodeIndex, false)), m_interpreter->sampler()->sampleSlot());
+ store32(Imm32(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions().begin() + bytecodeIndex, false)), m_interpreter->sampler()->sampleSlot());
#endif
killLastResultRegister();
ALWAYS_INLINE JmpSrc JIT::emitCTICall(unsigned bytecodeIndex, CTIHelper_b helper)
{
#if ENABLE(OPCODE_SAMPLING)
- store32(Imm32(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions.begin() + bytecodeIndex, true)), m_interpreter->sampler()->sampleSlot());
+ store32(Imm32(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions().begin() + bytecodeIndex, true)), m_interpreter->sampler()->sampleSlot());
#endif
restoreArgumentReference();
emitPutCTIParam(callFrameRegister, CTI_ARGS_callFrame);
JmpSrc ctiCall = call();
m_calls.append(CallRecord(ctiCall, helper, bytecodeIndex));
#if ENABLE(OPCODE_SAMPLING)
- store32(Imm32(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions.begin() + bytecodeIndex, false)), m_interpreter->sampler()->sampleSlot());
+ store32(Imm32(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions().begin() + bytecodeIndex, false)), m_interpreter->sampler()->sampleSlot());
#endif
killLastResultRegister();
ALWAYS_INLINE JmpSrc JIT::emitCTICall(unsigned bytecodeIndex, CTIHelper_v helper)
{
#if ENABLE(OPCODE_SAMPLING)
- store32(Imm32(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions.begin() + bytecodeIndex, true)), m_interpreter->sampler()->sampleSlot());
+ store32(Imm32(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions().begin() + bytecodeIndex, true)), m_interpreter->sampler()->sampleSlot());
#endif
restoreArgumentReference();
emitPutCTIParam(callFrameRegister, CTI_ARGS_callFrame);
JmpSrc ctiCall = call();
m_calls.append(CallRecord(ctiCall, helper, bytecodeIndex));
#if ENABLE(OPCODE_SAMPLING)
- store32(Imm32(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions.begin() + bytecodeIndex, false)), m_interpreter->sampler()->sampleSlot());
+ store32(Imm32(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions().begin() + bytecodeIndex, false)), m_interpreter->sampler()->sampleSlot());
#endif
killLastResultRegister();
ALWAYS_INLINE JmpSrc JIT::emitCTICall(unsigned bytecodeIndex, CTIHelper_s helper)
{
#if ENABLE(OPCODE_SAMPLING)
- store32(Imm32(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions.begin() + bytecodeIndex, true)), m_interpreter->sampler()->sampleSlot());
+ store32(Imm32(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions().begin() + bytecodeIndex, true)), m_interpreter->sampler()->sampleSlot());
#endif
restoreArgumentReference();
emitPutCTIParam(callFrameRegister, CTI_ARGS_callFrame);
JmpSrc ctiCall = call();
m_calls.append(CallRecord(ctiCall, helper, bytecodeIndex));
#if ENABLE(OPCODE_SAMPLING)
- store32(Imm32(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions.begin() + bytecodeIndex, false)), m_interpreter->sampler()->sampleSlot());
+ store32(Imm32(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions().begin() + bytecodeIndex, false)), m_interpreter->sampler()->sampleSlot());
#endif
killLastResultRegister();
ALWAYS_INLINE JmpSrc JIT::emitCTICall(unsigned bytecodeIndex, CTIHelper_2 helper)
{
#if ENABLE(OPCODE_SAMPLING)
- store32(Imm32(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions.begin() + bytecodeIndex, true)), m_interpreter->sampler()->sampleSlot());
+ store32(Imm32(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions().begin() + bytecodeIndex, true)), m_interpreter->sampler()->sampleSlot());
#endif
restoreArgumentReference();
emitPutCTIParam(callFrameRegister, CTI_ARGS_callFrame);
JmpSrc ctiCall = call();
m_calls.append(CallRecord(ctiCall, helper, bytecodeIndex));
#if ENABLE(OPCODE_SAMPLING)
- store32(Imm32(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions.begin() + bytecodeIndex, false)), m_interpreter->sampler()->sampleSlot());
+ store32(Imm32(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions().begin() + bytecodeIndex, false)), m_interpreter->sampler()->sampleSlot());
#endif
killLastResultRegister();
emitGetVirtualRegister(baseVReg, X86::eax, i);
- ASSERT(m_codeBlock->propertyAccessInstructions[propertyAccessInstructionIndex].bytecodeIndex == i);
+ ASSERT(m_codeBlock->propertyAccessInstruction(propertyAccessInstructionIndex).bytecodeIndex == i);
emitJumpSlowCaseIfNotJSCell(X86::eax, i, baseVReg);
emitPutVirtualRegister(resultVReg);
// Track the location of the call; this will be used to recover repatch information.
- ASSERT(m_codeBlock->propertyAccessInstructions[propertyAccessInstructionIndex].bytecodeIndex == i);
+ ASSERT(m_codeBlock->propertyAccessInstruction(propertyAccessInstructionIndex).bytecodeIndex == i);
m_propertyAccessCompilationInfo[propertyAccessInstructionIndex].callReturnLocation = call;
}
emitGetVirtualRegisters(baseVReg, X86::eax, valueVReg, X86::edx, i);
- ASSERT(m_codeBlock->propertyAccessInstructions[propertyAccessInstructionIndex].bytecodeIndex == i);
+ ASSERT(m_codeBlock->propertyAccessInstruction(propertyAccessInstructionIndex).bytecodeIndex == i);
// Jump to a slow case if either the base object is an immediate, or if the Structure does not match.
emitJumpSlowCaseIfNotJSCell(X86::eax, i, baseVReg);
JmpSrc call = emitCTICall(i, Interpreter::cti_op_put_by_id);
// Track the location of the call; this will be used to recover repatch information.
- ASSERT(m_codeBlock->propertyAccessInstructions[propertyAccessInstructionIndex].bytecodeIndex == i);
+ ASSERT(m_codeBlock->propertyAccessInstruction(propertyAccessInstructionIndex).bytecodeIndex == i);
m_propertyAccessCompilationInfo[propertyAccessInstructionIndex].callReturnLocation = call;
}
m_code.set(new EvalCodeBlock(this, globalObject, source().provider()));
- BytecodeGenerator generator(this, globalObject->debugger(), scopeChain, &m_code->symbolTable, m_code.get());
+ BytecodeGenerator generator(this, globalObject->debugger(), scopeChain, &m_code->symbolTable(), m_code.get());
generator.generate();
// Eval code needs to hang on to its declaration stacks to keep declaration info alive until Interpreter::execute time,
m_code.set(new CodeBlock(this, FunctionCode, source().provider(), source().startOffset()));
- BytecodeGenerator generator(this, globalObject->debugger(), scopeChain, &m_code->symbolTable, m_code.get());
+ BytecodeGenerator generator(this, globalObject->debugger(), scopeChain, &m_code->symbolTable(), m_code.get());
generator.generate();
destroyData();
function = callFrame->callee();
CodeBlock* codeBlock = &function->body()->generatedBytecode();
- int numParameters = codeBlock->numParameters;
+ int numParameters = codeBlock->m_numParameters;
argc = callFrame->argumentCount();
if (argc <= numParameters)
{
ASSERT(!d()->registerArray);
- size_t numParametersMinusThis = d()->functionBody->generatedBytecode().numParameters - 1;
- size_t numVars = d()->functionBody->generatedBytecode().numVars;
+ size_t numParametersMinusThis = d()->functionBody->generatedBytecode().m_numParameters - 1;
+ size_t numVars = d()->functionBody->generatedBytecode().m_numVars;
size_t numLocals = numVars + numParametersMinusThis;
if (!numLocals)
int line = codeBlock->expressionRangeForVPC(vPC, divotPoint, startOffset, endOffset);
UString message = "Can't find variable: ";
message.append(ident.ustring());
- JSObject* exception = Error::create(exec, ReferenceError, message, line, codeBlock->ownerNode->sourceID(), codeBlock->ownerNode->sourceURL());
+ JSObject* exception = Error::create(exec, ReferenceError, message, line, codeBlock->ownerNode()->sourceID(), codeBlock->ownerNode()->sourceURL());
exception->putWithAttributes(exec, Identifier(exec, expressionBeginOffsetPropertyName), jsNumber(exec, divotPoint - startOffset), ReadOnly | DontDelete);
exception->putWithAttributes(exec, Identifier(exec, expressionCaretOffsetPropertyName), jsNumber(exec, divotPoint), ReadOnly | DontDelete);
exception->putWithAttributes(exec, Identifier(exec, expressionEndOffsetPropertyName), jsNumber(exec, divotPoint + endOffset), ReadOnly | DontDelete);
static UString createErrorMessage(ExecState* exec, CodeBlock* codeBlock, int, int expressionStart, int expressionStop, JSValue* value, UString error)
{
- if (!expressionStop || expressionStart > codeBlock->source->length()) {
+ if (!expressionStop || expressionStart > codeBlock->source()->length()) {
UString errorText = value->toString(exec);
errorText.append(" is ");
errorText.append(error);
if (expressionStart < expressionStop) {
errorText.append('\'');
- errorText.append(codeBlock->source->getRange(expressionStart, expressionStop));
+ errorText.append(codeBlock->source()->getRange(expressionStart, expressionStop));
errorText.append("' [");
errorText.append(value->toString(exec));
errorText.append("] is ");
} else {
// No range information, so give a few characters of context
- const UChar* data = codeBlock->source->data();
- int dataLength = codeBlock->source->length();
+ const UChar* data = codeBlock->source()->data();
+ int dataLength = codeBlock->source()->length();
int start = expressionStart;
int stop = expressionStart;
// Get up to 20 characters of context to the left and right of the divot, clamping to the line.
while (stop > expressionStart && isStrWhiteSpace(data[stop]))
stop--;
errorText.append("near '...");
- errorText.append(codeBlock->source->getRange(start, stop));
+ errorText.append(codeBlock->source()->getRange(start, stop));
errorText.append("...' [");
errorText.append(value->toString(exec));
errorText.append("] is ");
int divotPoint = 0;
int line = codeBlock->expressionRangeForVPC(vPC, divotPoint, startOffset, endOffset);
UString errorMessage = createErrorMessage(exec, codeBlock, line, divotPoint, divotPoint + endOffset, value, message);
- JSObject* exception = Error::create(exec, TypeError, errorMessage, line, codeBlock->ownerNode->sourceID(), codeBlock->ownerNode->sourceURL());
+ JSObject* exception = Error::create(exec, TypeError, errorMessage, line, codeBlock->ownerNode()->sourceID(), codeBlock->ownerNode()->sourceURL());
exception->putWithAttributes(exec, Identifier(exec, expressionBeginOffsetPropertyName), jsNumber(exec, divotPoint - startOffset), ReadOnly | DontDelete);
exception->putWithAttributes(exec, Identifier(exec, expressionCaretOffsetPropertyName), jsNumber(exec, divotPoint), ReadOnly | DontDelete);
exception->putWithAttributes(exec, Identifier(exec, expressionEndOffsetPropertyName), jsNumber(exec, divotPoint + endOffset), ReadOnly | DontDelete);
// We're in a "new" expression, so we need to skip over the "new.." part
int startPoint = divotPoint - (startOffset ? startOffset - 4 : 0); // -4 for "new "
- const UChar* data = codeBlock->source->data();
+ const UChar* data = codeBlock->source()->data();
while (startPoint < divotPoint && isStrWhiteSpace(data[startPoint]))
startPoint++;
UString errorMessage = createErrorMessage(exec, codeBlock, line, startPoint, divotPoint, value, "not a constructor");
- JSObject* exception = Error::create(exec, TypeError, errorMessage, line, codeBlock->ownerNode->sourceID(), codeBlock->ownerNode->sourceURL());
+ JSObject* exception = Error::create(exec, TypeError, errorMessage, line, codeBlock->ownerNode()->sourceID(), codeBlock->ownerNode()->sourceURL());
exception->putWithAttributes(exec, Identifier(exec, expressionBeginOffsetPropertyName), jsNumber(exec, divotPoint - startOffset), ReadOnly | DontDelete);
exception->putWithAttributes(exec, Identifier(exec, expressionCaretOffsetPropertyName), jsNumber(exec, divotPoint), ReadOnly | DontDelete);
exception->putWithAttributes(exec, Identifier(exec, expressionEndOffsetPropertyName), jsNumber(exec, divotPoint + endOffset), ReadOnly | DontDelete);
int divotPoint = 0;
int line = codeBlock->expressionRangeForVPC(vPC, divotPoint, startOffset, endOffset);
UString errorMessage = createErrorMessage(exec, codeBlock, line, divotPoint - startOffset, divotPoint, value, "not a function");
- JSObject* exception = Error::create(exec, TypeError, errorMessage, line, codeBlock->ownerNode->sourceID(), codeBlock->ownerNode->sourceURL());
+ JSObject* exception = Error::create(exec, TypeError, errorMessage, line, codeBlock->ownerNode()->sourceID(), codeBlock->ownerNode()->sourceURL());
exception->putWithAttributes(exec, Identifier(exec, expressionBeginOffsetPropertyName), jsNumber(exec, divotPoint - startOffset), ReadOnly | DontDelete);
exception->putWithAttributes(exec, Identifier(exec, expressionCaretOffsetPropertyName), jsNumber(exec, divotPoint), ReadOnly | DontDelete);
exception->putWithAttributes(exec, Identifier(exec, expressionEndOffsetPropertyName), jsNumber(exec, divotPoint + endOffset), ReadOnly | DontDelete);
int divotPoint = 0;
int line = codeBlock->expressionRangeForVPC(vPC, divotPoint, startOffset, endOffset);
UString errorMessage = createErrorMessage(exec, codeBlock, line, divotPoint - startOffset, divotPoint, error->isNull() ? jsNull() : jsUndefined(), "not an object");
- JSObject* exception = Error::create(exec, TypeError, errorMessage, line, codeBlock->ownerNode->sourceID(), codeBlock->ownerNode->sourceURL());
+ JSObject* exception = Error::create(exec, TypeError, errorMessage, line, codeBlock->ownerNode()->sourceID(), codeBlock->ownerNode()->sourceURL());
exception->putWithAttributes(exec, Identifier(exec, expressionBeginOffsetPropertyName), jsNumber(exec, divotPoint - startOffset), ReadOnly | DontDelete);
exception->putWithAttributes(exec, Identifier(exec, expressionCaretOffsetPropertyName), jsNumber(exec, divotPoint), ReadOnly | DontDelete);
exception->putWithAttributes(exec, Identifier(exec, expressionEndOffsetPropertyName), jsNumber(exec, divotPoint + endOffset), ReadOnly | DontDelete);
if (!registerArray)
return;
- size_t numParametersMinusThis = d()->functionBody->generatedBytecode().numParameters - 1;
+ size_t numParametersMinusThis = d()->functionBody->generatedBytecode().m_numParameters - 1;
size_t i = 0;
size_t count = numParametersMinusThis;
r.mark();
}
- size_t numVars = d()->functionBody->generatedBytecode().numVars;
+ size_t numVars = d()->functionBody->generatedBytecode().m_numVars;
// Skip the call frame, which sits between the parameters and vars.
i += RegisterFile::CallFrameHeaderSize;
private:
struct JSActivationData : public JSVariableObjectData {
JSActivationData(PassRefPtr<FunctionBodyNode> functionBody, Register* registers)
- : JSVariableObjectData(&functionBody->generatedBytecode().symbolTable, registers)
+ : JSVariableObjectData(&functionBody->generatedBytecode().symbolTable(), registers)
, functionBody(functionBody)
{
}
HashSet<ProgramCodeBlock*>::const_iterator end = codeBlocks().end();
for (HashSet<ProgramCodeBlock*>::const_iterator it = codeBlocks().begin(); it != end; ++it)
- (*it)->globalObject = 0;
+ (*it)->clearGlobalObject();
RegisterFile& registerFile = globalData()->interpreter->registerFile();
if (registerFile.globalObject() == this) {