summaryrefslogtreecommitdiffstats
path: root/JavaScriptCore/bytecode
diff options
context:
space:
mode:
Diffstat (limited to 'JavaScriptCore/bytecode')
-rw-r--r--JavaScriptCore/bytecode/CodeBlock.cpp561
-rw-r--r--JavaScriptCore/bytecode/CodeBlock.h226
-rw-r--r--JavaScriptCore/bytecode/EvalCodeCache.h17
-rw-r--r--JavaScriptCore/bytecode/Instruction.h5
-rw-r--r--JavaScriptCore/bytecode/JumpTable.cpp2
-rw-r--r--JavaScriptCore/bytecode/JumpTable.h6
-rw-r--r--JavaScriptCore/bytecode/Opcode.cpp9
-rw-r--r--JavaScriptCore/bytecode/Opcode.h78
-rw-r--r--JavaScriptCore/bytecode/SamplingTool.cpp6
9 files changed, 514 insertions, 396 deletions
diff --git a/JavaScriptCore/bytecode/CodeBlock.cpp b/JavaScriptCore/bytecode/CodeBlock.cpp
index fd56ece..cbae990 100644
--- a/JavaScriptCore/bytecode/CodeBlock.cpp
+++ b/JavaScriptCore/bytecode/CodeBlock.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009, 2010 Apple Inc. All rights reserved.
* Copyright (C) 2008 Cameron Zwarich <cwzwarich@uwaterloo.ca>
*
* Redistribution and use in source and binary forms, with or without
@@ -30,13 +30,15 @@
#include "config.h"
#include "CodeBlock.h"
-#include "JIT.h"
-#include "JSValue.h"
+#include "BytecodeGenerator.h"
+#include "Debugger.h"
#include "Interpreter.h"
+#include "JIT.h"
+#include "JSActivation.h"
#include "JSFunction.h"
#include "JSStaticScopeObject.h"
-#include "Debugger.h"
-#include "BytecodeGenerator.h"
+#include "JSValue.h"
+#include "UStringConcatenate.h"
#include <stdio.h>
#include <wtf/StringExtras.h>
@@ -49,9 +51,9 @@ namespace JSC {
static UString escapeQuotes(const UString& str)
{
UString result = str;
- int pos = 0;
- while ((pos = result.find('\"', pos)) >= 0) {
- result = makeString(result.substr(0, pos), "\"\\\"\"", result.substr(pos + 1));
+ size_t pos = 0;
+ while ((pos = result.find('\"', pos)) != notFound) {
+ result = makeUString(result.substringSharingImpl(0, pos), "\"\\\"\"", result.substringSharingImpl(pos + 1));
pos += 4;
}
return result;
@@ -63,19 +65,19 @@ static UString valueToSourceString(ExecState* exec, JSValue val)
return "0";
if (val.isString())
- return makeString("\"", escapeQuotes(val.toString(exec)), "\"");
+ return makeUString("\"", escapeQuotes(val.toString(exec)), "\"");
return val.toString(exec);
}
static CString constantName(ExecState* exec, int k, JSValue value)
{
- return makeString(valueToSourceString(exec, value), "(@k", UString::from(k - FirstConstantRegisterIndex), ")").UTF8String();
+ return makeUString(valueToSourceString(exec, value), "(@k", UString::number(k - FirstConstantRegisterIndex), ")").utf8();
}
static CString idName(int id0, const Identifier& ident)
{
- return makeString(ident.ustring(), "(@id", UString::from(id0), ")").UTF8String();
+ return makeUString(ident.ustring(), "(@id", UString::number(id0), ")").utf8();
}
CString CodeBlock::registerName(ExecState* exec, int r) const
@@ -86,7 +88,7 @@ CString CodeBlock::registerName(ExecState* exec, int r) const
if (isConstantRegisterIndex(r))
return constantName(exec, r, getConstant(r));
- return makeString("r", UString::from(r)).UTF8String();
+ return makeUString("r", UString::number(r)).utf8();
}
static UString regexpToSourceString(RegExp* regExp)
@@ -100,12 +102,12 @@ static UString regexpToSourceString(RegExp* regExp)
if (regExp->multiline())
postfix[index] = 'm';
- return makeString("/", regExp->pattern(), postfix);
+ return makeUString("/", regExp->pattern(), postfix);
}
static CString regexpName(int re, RegExp* regexp)
{
- return makeString(regexpToSourceString(regexp), "(@re", UString::from(re), ")").UTF8String();
+ return makeUString(regexpToSourceString(regexp), "(@re", UString::number(re), ")").utf8();
}
static UString pointerToSourceString(void* p)
@@ -141,7 +143,7 @@ void CodeBlock::printUnaryOp(ExecState* exec, int location, Vector<Instruction>:
int r0 = (++it)->u.operand;
int r1 = (++it)->u.operand;
- printf("[%4d] %s\t\t %s, %s\n", location, op, registerName(exec, r0).c_str(), registerName(exec, r1).c_str());
+ printf("[%4d] %s\t\t %s, %s\n", location, op, registerName(exec, r0).data(), registerName(exec, r1).data());
}
void CodeBlock::printBinaryOp(ExecState* exec, int location, Vector<Instruction>::const_iterator& it, const char* op) const
@@ -149,14 +151,14 @@ void CodeBlock::printBinaryOp(ExecState* exec, int location, Vector<Instruction>
int r0 = (++it)->u.operand;
int r1 = (++it)->u.operand;
int r2 = (++it)->u.operand;
- printf("[%4d] %s\t\t %s, %s, %s\n", location, op, registerName(exec, r0).c_str(), registerName(exec, r1).c_str(), registerName(exec, r2).c_str());
+ printf("[%4d] %s\t\t %s, %s, %s\n", location, op, registerName(exec, r0).data(), registerName(exec, r1).data(), registerName(exec, r2).data());
}
void CodeBlock::printConditionalJump(ExecState* exec, const Vector<Instruction>::const_iterator&, Vector<Instruction>::const_iterator& it, int location, const char* op) const
{
int r0 = (++it)->u.operand;
int offset = (++it)->u.operand;
- printf("[%4d] %s\t\t %s, %d(->%d)\n", location, op, registerName(exec, r0).c_str(), offset, location + offset);
+ printf("[%4d] %s\t\t %s, %d(->%d)\n", location, op, registerName(exec, r0).data(), offset, location + offset);
}
void CodeBlock::printGetByIdOp(ExecState* exec, int location, Vector<Instruction>::const_iterator& it, const char* op) const
@@ -164,7 +166,7 @@ void CodeBlock::printGetByIdOp(ExecState* exec, int location, Vector<Instruction
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(exec, r0).c_str(), registerName(exec, r1).c_str(), idName(id0, m_identifiers[id0]).c_str());
+ printf("[%4d] %s\t %s, %s, %s\n", location, op, registerName(exec, r0).data(), registerName(exec, r1).data(), idName(id0, m_identifiers[id0]).data());
it += 4;
}
@@ -173,14 +175,14 @@ void CodeBlock::printPutByIdOp(ExecState* exec, int location, Vector<Instruction
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(exec, r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), registerName(exec, r1).c_str());
- it += 4;
+ printf("[%4d] %s\t %s, %s, %s\n", location, op, registerName(exec, r0).data(), idName(id0, m_identifiers[id0]).data(), registerName(exec, r1).data());
+ it += 5;
}
#if ENABLE(JIT)
static bool isGlobalResolve(OpcodeID opcodeID)
{
- return opcodeID == op_resolve_global;
+ return opcodeID == op_resolve_global || opcodeID == op_resolve_global_dynamic;
}
static bool isPropertyAccess(OpcodeID opcodeID)
@@ -223,32 +225,32 @@ static unsigned instructionOffsetForNth(ExecState* exec, const Vector<Instructio
static void printGlobalResolveInfo(const GlobalResolveInfo& resolveInfo, unsigned instructionOffset)
{
- printf(" [%4d] %s: %s\n", instructionOffset, "resolve_global", pointerToSourceString(resolveInfo.structure).UTF8String().c_str());
+ printf(" [%4d] %s: %s\n", instructionOffset, "resolve_global", pointerToSourceString(resolveInfo.structure).utf8().data());
}
static void printStructureStubInfo(const StructureStubInfo& stubInfo, unsigned instructionOffset)
{
switch (stubInfo.accessType) {
case access_get_by_id_self:
- printf(" [%4d] %s: %s\n", instructionOffset, "get_by_id_self", pointerToSourceString(stubInfo.u.getByIdSelf.baseObjectStructure).UTF8String().c_str());
+ printf(" [%4d] %s: %s\n", instructionOffset, "get_by_id_self", pointerToSourceString(stubInfo.u.getByIdSelf.baseObjectStructure).utf8().data());
return;
case access_get_by_id_proto:
- printf(" [%4d] %s: %s, %s\n", instructionOffset, "get_by_id_proto", pointerToSourceString(stubInfo.u.getByIdProto.baseObjectStructure).UTF8String().c_str(), pointerToSourceString(stubInfo.u.getByIdProto.prototypeStructure).UTF8String().c_str());
+ printf(" [%4d] %s: %s, %s\n", instructionOffset, "get_by_id_proto", pointerToSourceString(stubInfo.u.getByIdProto.baseObjectStructure).utf8().data(), pointerToSourceString(stubInfo.u.getByIdProto.prototypeStructure).utf8().data());
return;
case access_get_by_id_chain:
- printf(" [%4d] %s: %s, %s\n", instructionOffset, "get_by_id_chain", pointerToSourceString(stubInfo.u.getByIdChain.baseObjectStructure).UTF8String().c_str(), pointerToSourceString(stubInfo.u.getByIdChain.chain).UTF8String().c_str());
+ printf(" [%4d] %s: %s, %s\n", instructionOffset, "get_by_id_chain", pointerToSourceString(stubInfo.u.getByIdChain.baseObjectStructure).utf8().data(), pointerToSourceString(stubInfo.u.getByIdChain.chain).utf8().data());
return;
case access_get_by_id_self_list:
- printf(" [%4d] %s: %s (%d)\n", instructionOffset, "op_get_by_id_self_list", pointerToSourceString(stubInfo.u.getByIdSelfList.structureList).UTF8String().c_str(), stubInfo.u.getByIdSelfList.listSize);
+ printf(" [%4d] %s: %s (%d)\n", instructionOffset, "op_get_by_id_self_list", pointerToSourceString(stubInfo.u.getByIdSelfList.structureList).utf8().data(), stubInfo.u.getByIdSelfList.listSize);
return;
case access_get_by_id_proto_list:
- printf(" [%4d] %s: %s (%d)\n", instructionOffset, "op_get_by_id_proto_list", pointerToSourceString(stubInfo.u.getByIdProtoList.structureList).UTF8String().c_str(), stubInfo.u.getByIdProtoList.listSize);
+ printf(" [%4d] %s: %s (%d)\n", instructionOffset, "op_get_by_id_proto_list", pointerToSourceString(stubInfo.u.getByIdProtoList.structureList).utf8().data(), stubInfo.u.getByIdProtoList.listSize);
return;
case access_put_by_id_transition:
- printf(" [%4d] %s: %s, %s, %s\n", instructionOffset, "put_by_id_transition", pointerToSourceString(stubInfo.u.putByIdTransition.previousStructure).UTF8String().c_str(), pointerToSourceString(stubInfo.u.putByIdTransition.structure).UTF8String().c_str(), pointerToSourceString(stubInfo.u.putByIdTransition.chain).UTF8String().c_str());
+ printf(" [%4d] %s: %s, %s, %s\n", instructionOffset, "put_by_id_transition", pointerToSourceString(stubInfo.u.putByIdTransition.previousStructure).utf8().data(), pointerToSourceString(stubInfo.u.putByIdTransition.structure).utf8().data(), pointerToSourceString(stubInfo.u.putByIdTransition.chain).utf8().data());
return;
case access_put_by_id_replace:
- printf(" [%4d] %s: %s\n", instructionOffset, "put_by_id_replace", pointerToSourceString(stubInfo.u.putByIdReplace.baseObjectStructure).UTF8String().c_str());
+ printf(" [%4d] %s: %s\n", instructionOffset, "put_by_id_replace", pointerToSourceString(stubInfo.u.putByIdReplace.baseObjectStructure).utf8().data());
return;
case access_get_by_id:
printf(" [%4d] %s\n", instructionOffset, "get_by_id");
@@ -277,7 +279,7 @@ static void printStructureStubInfo(const StructureStubInfo& stubInfo, unsigned i
void CodeBlock::printStructure(const char* name, const Instruction* vPC, int operand) const
{
unsigned instructionOffset = vPC - m_instructions.begin();
- printf(" [%4d] %s: %s\n", instructionOffset, name, pointerToSourceString(vPC[operand].u.structure).UTF8String().c_str());
+ printf(" [%4d] %s: %s\n", instructionOffset, name, pointerToSourceString(vPC[operand].u.structure).utf8().data());
}
void CodeBlock::printStructures(const Instruction* vPC) const
@@ -294,15 +296,15 @@ void CodeBlock::printStructures(const Instruction* vPC) const
return;
}
if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_proto)) {
- printf(" [%4d] %s: %s, %s\n", instructionOffset, "get_by_id_proto", pointerToSourceString(vPC[4].u.structure).UTF8String().c_str(), pointerToSourceString(vPC[5].u.structure).UTF8String().c_str());
+ printf(" [%4d] %s: %s, %s\n", instructionOffset, "get_by_id_proto", pointerToSourceString(vPC[4].u.structure).utf8().data(), pointerToSourceString(vPC[5].u.structure).utf8().data());
return;
}
if (vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id_transition)) {
- printf(" [%4d] %s: %s, %s, %s\n", instructionOffset, "put_by_id_transition", pointerToSourceString(vPC[4].u.structure).UTF8String().c_str(), pointerToSourceString(vPC[5].u.structure).UTF8String().c_str(), pointerToSourceString(vPC[6].u.structureChain).UTF8String().c_str());
+ printf(" [%4d] %s: %s, %s, %s\n", instructionOffset, "put_by_id_transition", pointerToSourceString(vPC[4].u.structure).utf8().data(), pointerToSourceString(vPC[5].u.structure).utf8().data(), pointerToSourceString(vPC[6].u.structureChain).utf8().data());
return;
}
if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_chain)) {
- printf(" [%4d] %s: %s, %s\n", instructionOffset, "get_by_id_chain", pointerToSourceString(vPC[4].u.structure).UTF8String().c_str(), pointerToSourceString(vPC[5].u.structureChain).UTF8String().c_str());
+ printf(" [%4d] %s: %s, %s\n", instructionOffset, "get_by_id_chain", pointerToSourceString(vPC[4].u.structure).utf8().data(), pointerToSourceString(vPC[5].u.structureChain).utf8().data());
return;
}
if (vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id)) {
@@ -317,6 +319,10 @@ void CodeBlock::printStructures(const Instruction* vPC) const
printStructure("resolve_global", vPC, 4);
return;
}
+ if (vPC[0].u.opcode == interpreter->getOpcode(op_resolve_global_dynamic)) {
+ printStructure("resolve_global_dynamic", vPC, 4);
+ return;
+ }
// 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));
@@ -348,7 +354,7 @@ void CodeBlock::dump(ExecState* exec) const
printf("\nIdentifiers:\n");
size_t i = 0;
do {
- printf(" id%u = %s\n", static_cast<unsigned>(i), m_identifiers[i].ascii());
+ printf(" id%u = %s\n", static_cast<unsigned>(i), m_identifiers[i].ustring().utf8().data());
++i;
} while (i != m_identifiers.size());
}
@@ -358,7 +364,7 @@ void CodeBlock::dump(ExecState* exec) const
unsigned registerIndex = m_numVars;
size_t i = 0;
do {
- printf(" k%u = %s\n", registerIndex, valueToSourceString(exec, m_constantRegisters[i].jsValue()).ascii());
+ printf(" k%u = %s\n", registerIndex, valueToSourceString(exec, m_constantRegisters[i].jsValue()).utf8().data());
++i;
++registerIndex;
} while (i < m_constantRegisters.size());
@@ -368,7 +374,7 @@ void CodeBlock::dump(ExecState* exec) const
printf("\nm_regexps:\n");
size_t i = 0;
do {
- printf(" re%u = %s\n", static_cast<unsigned>(i), regexpToSourceString(m_rareData->m_regexps[i].get()).ascii());
+ printf(" re%u = %s\n", static_cast<unsigned>(i), regexpToSourceString(m_rareData->m_regexps[i].get()).utf8().data());
++i;
} while (i < m_rareData->m_regexps.size());
}
@@ -449,7 +455,7 @@ void CodeBlock::dump(ExecState* exec) const
continue;
ASSERT(!((i + m_rareData->m_characterSwitchJumpTables[i].min) & ~0xFFFF));
UChar ch = static_cast<UChar>(entry + m_rareData->m_characterSwitchJumpTables[i].min);
- printf("\t\t\"%s\" => %04d\n", UString(&ch, 1).ascii(), *iter);
+ printf("\t\t\"%s\" => %04d\n", UString(&ch, 1).utf8().data(), *iter);
}
printf(" }\n");
++i;
@@ -463,7 +469,7 @@ void CodeBlock::dump(ExecState* exec) const
printf(" %1d = {\n", i);
StringJumpTable::StringOffsetTable::const_iterator end = m_rareData->m_stringSwitchJumpTables[i].offsetTable.end();
for (StringJumpTable::StringOffsetTable::const_iterator iter = m_rareData->m_stringSwitchJumpTables[i].offsetTable.begin(); iter != end; ++iter)
- printf("\t\t\"%s\" => %04d\n", UString(iter->first).ascii(), iter->second.branchOffset);
+ printf("\t\t\"%s\" => %04d\n", UString(iter->first).utf8().data(), iter->second.branchOffset);
printf(" }\n");
++i;
} while (i < m_rareData->m_stringSwitchJumpTables.size());
@@ -480,46 +486,64 @@ void CodeBlock::dump(ExecState* exec, const Vector<Instruction>::const_iterator&
printf("[%4d] enter\n", location);
break;
}
- case op_enter_with_activation: {
+ case op_create_activation: {
int r0 = (++it)->u.operand;
- printf("[%4d] enter_with_activation %s\n", location, registerName(exec, r0).c_str());
+ printf("[%4d] create_activation %s\n", location, registerName(exec, r0).data());
break;
}
case op_create_arguments: {
- printf("[%4d] create_arguments\n", location);
+ int r0 = (++it)->u.operand;
+ printf("[%4d] create_arguments\t %s\n", location, registerName(exec, r0).data());
+ break;
+ }
+ case op_init_lazy_reg: {
+ int r0 = (++it)->u.operand;
+ printf("[%4d] init_lazy_reg\t %s\n", location, registerName(exec, r0).data());
break;
}
- case op_init_arguments: {
- printf("[%4d] init_arguments\n", location);
+ case op_get_callee: {
+ int r0 = (++it)->u.operand;
+ printf("[%4d] op_get_callee %s\n", location, registerName(exec, r0).data());
+ break;
+ }
+ case op_create_this: {
+ int r0 = (++it)->u.operand;
+ int r1 = (++it)->u.operand;
+ printf("[%4d] create_this %s %s\n", location, registerName(exec, r0).data(), registerName(exec, r1).data());
break;
}
case op_convert_this: {
int r0 = (++it)->u.operand;
- printf("[%4d] convert_this %s\n", location, registerName(exec, r0).c_str());
+ printf("[%4d] convert_this %s\n", location, registerName(exec, r0).data());
+ break;
+ }
+ case op_convert_this_strict: {
+ int r0 = (++it)->u.operand;
+ printf("[%4d] convert_this_strict %s\n", location, registerName(exec, r0).data());
break;
}
case op_new_object: {
int r0 = (++it)->u.operand;
- printf("[%4d] new_object\t %s\n", location, registerName(exec, r0).c_str());
+ printf("[%4d] new_object\t %s\n", location, registerName(exec, r0).data());
break;
}
case op_new_array: {
int dst = (++it)->u.operand;
int argv = (++it)->u.operand;
int argc = (++it)->u.operand;
- printf("[%4d] new_array\t %s, %s, %d\n", location, registerName(exec, dst).c_str(), registerName(exec, argv).c_str(), argc);
+ printf("[%4d] new_array\t %s, %s, %d\n", location, registerName(exec, dst).data(), registerName(exec, argv).data(), argc);
break;
}
case op_new_regexp: {
int r0 = (++it)->u.operand;
int re0 = (++it)->u.operand;
- printf("[%4d] new_regexp\t %s, %s\n", location, registerName(exec, r0).c_str(), regexpName(re0, regexp(re0)).c_str());
+ printf("[%4d] new_regexp\t %s, %s\n", location, registerName(exec, r0).data(), regexpName(re0, regexp(re0)).data());
break;
}
case op_mov: {
int r0 = (++it)->u.operand;
int r1 = (++it)->u.operand;
- printf("[%4d] mov\t\t %s, %s\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str());
+ printf("[%4d] mov\t\t %s, %s\n", location, registerName(exec, r0).data(), registerName(exec, r1).data());
break;
}
case op_not: {
@@ -560,12 +584,12 @@ void CodeBlock::dump(ExecState* exec, const Vector<Instruction>::const_iterator&
}
case op_pre_inc: {
int r0 = (++it)->u.operand;
- printf("[%4d] pre_inc\t\t %s\n", location, registerName(exec, r0).c_str());
+ printf("[%4d] pre_inc\t\t %s\n", location, registerName(exec, r0).data());
break;
}
case op_pre_dec: {
int r0 = (++it)->u.operand;
- printf("[%4d] pre_dec\t\t %s\n", location, registerName(exec, r0).c_str());
+ printf("[%4d] pre_dec\t\t %s\n", location, registerName(exec, r0).data());
break;
}
case op_post_inc: {
@@ -639,12 +663,17 @@ void CodeBlock::dump(ExecState* exec, const Vector<Instruction>::const_iterator&
printUnaryOp(exec, location, it, "bitnot");
break;
}
+ case op_check_has_instance: {
+ int base = (++it)->u.operand;
+ printf("[%4d] check_has_instance\t\t %s\n", location, registerName(exec, base).data());
+ break;
+ }
case op_instanceof: {
int r0 = (++it)->u.operand;
int r1 = (++it)->u.operand;
int r2 = (++it)->u.operand;
int r3 = (++it)->u.operand;
- printf("[%4d] instanceof\t\t %s, %s, %s, %s\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str(), registerName(exec, r2).c_str(), registerName(exec, r3).c_str());
+ printf("[%4d] instanceof\t\t %s, %s, %s, %s\n", location, registerName(exec, r0).data(), registerName(exec, r1).data(), registerName(exec, r2).data(), registerName(exec, r3).data());
break;
}
case op_typeof: {
@@ -682,63 +711,76 @@ void CodeBlock::dump(ExecState* exec, const Vector<Instruction>::const_iterator&
case op_resolve: {
int r0 = (++it)->u.operand;
int id0 = (++it)->u.operand;
- printf("[%4d] resolve\t\t %s, %s\n", location, registerName(exec, r0).c_str(), idName(id0, m_identifiers[id0]).c_str());
+ printf("[%4d] resolve\t\t %s, %s\n", location, registerName(exec, r0).data(), idName(id0, m_identifiers[id0]).data());
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(exec, r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), skipLevels);
+ printf("[%4d] resolve_skip\t %s, %s, %d\n", location, registerName(exec, r0).data(), idName(id0, m_identifiers[id0]).data(), skipLevels);
break;
}
case op_resolve_global: {
int r0 = (++it)->u.operand;
- JSValue scope = JSValue((++it)->u.jsCell);
int id0 = (++it)->u.operand;
- printf("[%4d] resolve_global\t %s, %s, %s\n", location, registerName(exec, r0).c_str(), valueToSourceString(exec, scope).ascii(), idName(id0, m_identifiers[id0]).c_str());
+ printf("[%4d] resolve_global\t %s, %s\n", location, registerName(exec, r0).data(), idName(id0, m_identifiers[id0]).data());
it += 2;
break;
}
+ case op_resolve_global_dynamic: {
+ int r0 = (++it)->u.operand;
+ int id0 = (++it)->u.operand;
+ JSValue scope = JSValue((++it)->u.jsCell);
+ ++it;
+ int depth = (++it)->u.operand;
+ printf("[%4d] resolve_global_dynamic\t %s, %s, %s, %d\n", location, registerName(exec, r0).data(), valueToSourceString(exec, scope).utf8().data(), idName(id0, m_identifiers[id0]).data(), depth);
+ break;
+ }
case op_get_scoped_var: {
int r0 = (++it)->u.operand;
int index = (++it)->u.operand;
int skipLevels = (++it)->u.operand;
- printf("[%4d] get_scoped_var\t %s, %d, %d\n", location, registerName(exec, r0).c_str(), index, skipLevels);
+ printf("[%4d] get_scoped_var\t %s, %d, %d\n", location, registerName(exec, r0).data(), index, skipLevels);
break;
}
case op_put_scoped_var: {
int index = (++it)->u.operand;
int skipLevels = (++it)->u.operand;
int r0 = (++it)->u.operand;
- printf("[%4d] put_scoped_var\t %d, %d, %s\n", location, index, skipLevels, registerName(exec, r0).c_str());
+ printf("[%4d] put_scoped_var\t %d, %d, %s\n", location, index, skipLevels, registerName(exec, r0).data());
break;
}
case op_get_global_var: {
int r0 = (++it)->u.operand;
- JSValue scope = JSValue((++it)->u.jsCell);
int index = (++it)->u.operand;
- printf("[%4d] get_global_var\t %s, %s, %d\n", location, registerName(exec, r0).c_str(), valueToSourceString(exec, scope).ascii(), index);
+ printf("[%4d] get_global_var\t %s, %d\n", location, registerName(exec, r0).data(), index);
break;
}
case op_put_global_var: {
- JSValue scope = JSValue((++it)->u.jsCell);
int index = (++it)->u.operand;
int r0 = (++it)->u.operand;
- printf("[%4d] put_global_var\t %s, %d, %s\n", location, valueToSourceString(exec, scope).ascii(), index, registerName(exec, r0).c_str());
+ printf("[%4d] put_global_var\t %d, %s\n", location, index, registerName(exec, r0).data());
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(exec, r0).c_str(), idName(id0, m_identifiers[id0]).c_str());
+ int isStrict = (++it)->u.operand;
+ printf("[%4d] resolve_base%s\t %s, %s\n", location, isStrict ? "_strict" : "", registerName(exec, r0).data(), idName(id0, m_identifiers[id0]).data());
+ break;
+ }
+ case op_ensure_property_exists: {
+ int r0 = (++it)->u.operand;
+ int id0 = (++it)->u.operand;
+ printf("[%4d] ensure_property_exists\t %s, %s\n", location, registerName(exec, r0).data(), idName(id0, m_identifiers[id0]).data());
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(exec, r0).c_str(), registerName(exec, r1).c_str(), idName(id0, m_identifiers[id0]).c_str());
+ printf("[%4d] resolve_with_base %s, %s, %s\n", location, registerName(exec, r0).data(), registerName(exec, r1).data(), idName(id0, m_identifiers[id0]).data());
break;
}
case op_get_by_id: {
@@ -765,6 +807,46 @@ void CodeBlock::dump(ExecState* exec, const Vector<Instruction>::const_iterator&
printGetByIdOp(exec, location, it, "get_by_id_chain");
break;
}
+ case op_get_by_id_getter_self: {
+ printGetByIdOp(exec, location, it, "get_by_id_getter_self");
+ break;
+ }
+ case op_get_by_id_getter_self_list: {
+ printGetByIdOp(exec, location, it, "get_by_id_getter_self_list");
+ break;
+ }
+ case op_get_by_id_getter_proto: {
+ printGetByIdOp(exec, location, it, "get_by_id_getter_proto");
+ break;
+ }
+ case op_get_by_id_getter_proto_list: {
+ printGetByIdOp(exec, location, it, "get_by_id_getter_proto_list");
+ break;
+ }
+ case op_get_by_id_getter_chain: {
+ printGetByIdOp(exec, location, it, "get_by_id_getter_chain");
+ break;
+ }
+ case op_get_by_id_custom_self: {
+ printGetByIdOp(exec, location, it, "get_by_id_custom_self");
+ break;
+ }
+ case op_get_by_id_custom_self_list: {
+ printGetByIdOp(exec, location, it, "get_by_id_custom_self_list");
+ break;
+ }
+ case op_get_by_id_custom_proto: {
+ printGetByIdOp(exec, location, it, "get_by_id_custom_proto");
+ break;
+ }
+ case op_get_by_id_custom_proto_list: {
+ printGetByIdOp(exec, location, it, "get_by_id_custom_proto_list");
+ break;
+ }
+ case op_get_by_id_custom_chain: {
+ printGetByIdOp(exec, location, it, "get_by_id_custom_chain");
+ break;
+ }
case op_get_by_id_generic: {
printGetByIdOp(exec, location, it, "get_by_id_generic");
break;
@@ -777,6 +859,11 @@ void CodeBlock::dump(ExecState* exec, const Vector<Instruction>::const_iterator&
printGetByIdOp(exec, location, it, "get_string_length");
break;
}
+ case op_get_arguments_length: {
+ printUnaryOp(exec, location, it, "get_arguments_length");
+ it++;
+ break;
+ }
case op_put_by_id: {
printPutByIdOp(exec, location, it, "put_by_id");
break;
@@ -797,14 +884,14 @@ void CodeBlock::dump(ExecState* exec, const Vector<Instruction>::const_iterator&
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(exec, r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), registerName(exec, r1).c_str());
+ printf("[%4d] put_getter\t %s, %s, %s\n", location, registerName(exec, r0).data(), idName(id0, m_identifiers[id0]).data(), registerName(exec, r1).data());
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(exec, r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), registerName(exec, r1).c_str());
+ printf("[%4d] put_setter\t %s, %s, %s\n", location, registerName(exec, r0).data(), idName(id0, m_identifiers[id0]).data(), registerName(exec, r1).data());
break;
}
case op_method_check: {
@@ -815,14 +902,21 @@ void CodeBlock::dump(ExecState* exec, const Vector<Instruction>::const_iterator&
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(exec, r0).c_str(), registerName(exec, r1).c_str(), idName(id0, m_identifiers[id0]).c_str());
+ printf("[%4d] del_by_id\t %s, %s, %s\n", location, registerName(exec, r0).data(), registerName(exec, r1).data(), idName(id0, m_identifiers[id0]).data());
break;
}
case op_get_by_val: {
int r0 = (++it)->u.operand;
int r1 = (++it)->u.operand;
int r2 = (++it)->u.operand;
- printf("[%4d] get_by_val\t %s, %s, %s\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str(), registerName(exec, r2).c_str());
+ printf("[%4d] get_by_val\t %s, %s, %s\n", location, registerName(exec, r0).data(), registerName(exec, r1).data(), registerName(exec, r2).data());
+ break;
+ }
+ case op_get_argument_by_val: {
+ int r0 = (++it)->u.operand;
+ int r1 = (++it)->u.operand;
+ int r2 = (++it)->u.operand;
+ printf("[%4d] get_argument_by_val\t %s, %s, %s\n", location, registerName(exec, r0).data(), registerName(exec, r1).data(), registerName(exec, r2).data());
break;
}
case op_get_by_pname: {
@@ -832,28 +926,28 @@ void CodeBlock::dump(ExecState* exec, const Vector<Instruction>::const_iterator&
int r3 = (++it)->u.operand;
int r4 = (++it)->u.operand;
int r5 = (++it)->u.operand;
- printf("[%4d] get_by_pname\t %s, %s, %s, %s, %s, %s\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str(), registerName(exec, r2).c_str(), registerName(exec, r3).c_str(), registerName(exec, r4).c_str(), registerName(exec, r5).c_str());
+ printf("[%4d] get_by_pname\t %s, %s, %s, %s, %s, %s\n", location, registerName(exec, r0).data(), registerName(exec, r1).data(), registerName(exec, r2).data(), registerName(exec, r3).data(), registerName(exec, r4).data(), registerName(exec, r5).data());
break;
}
case op_put_by_val: {
int r0 = (++it)->u.operand;
int r1 = (++it)->u.operand;
int r2 = (++it)->u.operand;
- printf("[%4d] put_by_val\t %s, %s, %s\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str(), registerName(exec, r2).c_str());
+ printf("[%4d] put_by_val\t %s, %s, %s\n", location, registerName(exec, r0).data(), registerName(exec, r1).data(), registerName(exec, r2).data());
break;
}
case op_del_by_val: {
int r0 = (++it)->u.operand;
int r1 = (++it)->u.operand;
int r2 = (++it)->u.operand;
- printf("[%4d] del_by_val\t %s, %s, %s\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str(), registerName(exec, r2).c_str());
+ printf("[%4d] del_by_val\t %s, %s, %s\n", location, registerName(exec, r0).data(), registerName(exec, r1).data(), registerName(exec, r2).data());
break;
}
case op_put_by_index: {
int r0 = (++it)->u.operand;
unsigned n0 = (++it)->u.operand;
int r1 = (++it)->u.operand;
- printf("[%4d] put_by_index\t %s, %u, %s\n", location, registerName(exec, r0).c_str(), n0, registerName(exec, r1).c_str());
+ printf("[%4d] put_by_index\t %s, %u, %s\n", location, registerName(exec, r0).data(), n0, registerName(exec, r1).data());
break;
}
case op_jmp: {
@@ -894,99 +988,104 @@ void CodeBlock::dump(ExecState* exec, const Vector<Instruction>::const_iterator&
int r0 = (++it)->u.operand;
int r1 = (++it)->u.operand;
int offset = (++it)->u.operand;
- printf("[%4d] jneq_ptr\t\t %s, %s, %d(->%d)\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str(), offset, location + offset);
+ printf("[%4d] jneq_ptr\t\t %s, %s, %d(->%d)\n", location, registerName(exec, r0).data(), registerName(exec, r1).data(), offset, location + offset);
break;
}
case op_jnless: {
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(exec, r0).c_str(), registerName(exec, r1).c_str(), offset, location + offset);
+ printf("[%4d] jnless\t\t %s, %s, %d(->%d)\n", location, registerName(exec, r0).data(), registerName(exec, r1).data(), offset, location + offset);
break;
}
case op_jnlesseq: {
int r0 = (++it)->u.operand;
int r1 = (++it)->u.operand;
int offset = (++it)->u.operand;
- printf("[%4d] jnlesseq\t\t %s, %s, %d(->%d)\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str(), offset, location + offset);
+ printf("[%4d] jnlesseq\t\t %s, %s, %d(->%d)\n", location, registerName(exec, r0).data(), registerName(exec, r1).data(), offset, location + 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(exec, r0).c_str(), registerName(exec, r1).c_str(), offset, location + offset);
+ printf("[%4d] loop_if_less\t %s, %s, %d(->%d)\n", location, registerName(exec, r0).data(), registerName(exec, r1).data(), offset, location + offset);
break;
}
case op_jless: {
int r0 = (++it)->u.operand;
int r1 = (++it)->u.operand;
int offset = (++it)->u.operand;
- printf("[%4d] jless\t\t %s, %s, %d(->%d)\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str(), offset, location + offset);
+ printf("[%4d] jless\t\t %s, %s, %d(->%d)\n", location, registerName(exec, r0).data(), registerName(exec, r1).data(), offset, location + offset);
+ break;
+ }
+ case op_jlesseq: {
+ int r0 = (++it)->u.operand;
+ int r1 = (++it)->u.operand;
+ int offset = (++it)->u.operand;
+ printf("[%4d] jlesseq\t\t %s, %s, %d(->%d)\n", location, registerName(exec, r0).data(), registerName(exec, r1).data(), offset, location + 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(exec, r0).c_str(), registerName(exec, r1).c_str(), offset, location + offset);
+ printf("[%4d] loop_if_lesseq\t %s, %s, %d(->%d)\n", location, registerName(exec, r0).data(), registerName(exec, r1).data(), offset, location + 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, location + defaultTarget, registerName(exec, scrutineeRegister).c_str());
+ printf("[%4d] switch_imm\t %d, %d(->%d), %s\n", location, tableIndex, defaultTarget, location + defaultTarget, registerName(exec, scrutineeRegister).data());
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, location + defaultTarget, registerName(exec, scrutineeRegister).c_str());
+ printf("[%4d] switch_char\t %d, %d(->%d), %s\n", location, tableIndex, defaultTarget, location + defaultTarget, registerName(exec, scrutineeRegister).data());
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, location + defaultTarget, registerName(exec, scrutineeRegister).c_str());
+ printf("[%4d] switch_string\t %d, %d(->%d), %s\n", location, tableIndex, defaultTarget, location + defaultTarget, registerName(exec, scrutineeRegister).data());
break;
}
case op_new_func: {
int r0 = (++it)->u.operand;
int f0 = (++it)->u.operand;
- printf("[%4d] new_func\t\t %s, f%d\n", location, registerName(exec, r0).c_str(), f0);
+ int shouldCheck = (++it)->u.operand;
+ printf("[%4d] new_func\t\t %s, f%d, %s\n", location, registerName(exec, r0).data(), f0, shouldCheck ? "<Checked>" : "<Unchecked>");
break;
}
case op_new_func_exp: {
int r0 = (++it)->u.operand;
int f0 = (++it)->u.operand;
- printf("[%4d] new_func_exp\t %s, f%d\n", location, registerName(exec, r0).c_str(), f0);
+ printf("[%4d] new_func_exp\t %s, f%d\n", location, registerName(exec, r0).data(), f0);
break;
}
case op_call: {
- int dst = (++it)->u.operand;
int func = (++it)->u.operand;
int argCount = (++it)->u.operand;
int registerOffset = (++it)->u.operand;
- printf("[%4d] call\t\t %s, %s, %d, %d\n", location, registerName(exec, dst).c_str(), registerName(exec, func).c_str(), argCount, registerOffset);
+ printf("[%4d] call\t\t %s, %d, %d\n", location, registerName(exec, func).data(), argCount, registerOffset);
break;
}
case op_call_eval: {
- int dst = (++it)->u.operand;
int func = (++it)->u.operand;
int argCount = (++it)->u.operand;
int registerOffset = (++it)->u.operand;
- printf("[%4d] call_eval\t %s, %s, %d, %d\n", location, registerName(exec, dst).c_str(), registerName(exec, func).c_str(), argCount, registerOffset);
+ printf("[%4d] call_eval\t %s, %d, %d\n", location, registerName(exec, func).data(), argCount, registerOffset);
break;
}
case op_call_varargs: {
- int dst = (++it)->u.operand;
int func = (++it)->u.operand;
int argCount = (++it)->u.operand;
int registerOffset = (++it)->u.operand;
- printf("[%4d] call_varargs\t %s, %s, %s, %d\n", location, registerName(exec, dst).c_str(), registerName(exec, func).c_str(), registerName(exec, argCount).c_str(), registerOffset);
+ printf("[%4d] call_varargs\t %s, %s, %d\n", location, registerName(exec, func).data(), registerName(exec, argCount).data(), registerOffset);
break;
}
case op_load_varargs: {
@@ -995,45 +1094,49 @@ void CodeBlock::dump(ExecState* exec, const Vector<Instruction>::const_iterator&
}
case op_tear_off_activation: {
int r0 = (++it)->u.operand;
- printf("[%4d] tear_off_activation\t %s\n", location, registerName(exec, r0).c_str());
+ int r1 = (++it)->u.operand;
+ printf("[%4d] tear_off_activation\t %s, %s\n", location, registerName(exec, r0).data(), registerName(exec, r1).data());
break;
}
case op_tear_off_arguments: {
- printf("[%4d] tear_off_arguments\n", location);
+ int r0 = (++it)->u.operand;
+ printf("[%4d] tear_off_arguments\t %s\n", location, registerName(exec, r0).data());
break;
}
case op_ret: {
int r0 = (++it)->u.operand;
- printf("[%4d] ret\t\t %s\n", location, registerName(exec, r0).c_str());
+ printf("[%4d] ret\t\t %s\n", location, registerName(exec, r0).data());
break;
}
- case op_construct: {
- int dst = (++it)->u.operand;
- int func = (++it)->u.operand;
- int argCount = (++it)->u.operand;
- int registerOffset = (++it)->u.operand;
- int proto = (++it)->u.operand;
- int thisRegister = (++it)->u.operand;
- printf("[%4d] construct\t %s, %s, %d, %d, %s, %s\n", location, registerName(exec, dst).c_str(), registerName(exec, func).c_str(), argCount, registerOffset, registerName(exec, proto).c_str(), registerName(exec, thisRegister).c_str());
+ case op_call_put_result: {
+ int r0 = (++it)->u.operand;
+ printf("[%4d] op_call_put_result\t\t %s\n", location, registerName(exec, r0).data());
break;
}
- case op_construct_verify: {
+ case op_ret_object_or_this: {
int r0 = (++it)->u.operand;
int r1 = (++it)->u.operand;
- printf("[%4d] construct_verify\t %s, %s\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str());
+ printf("[%4d] constructor_ret\t\t %s %s\n", location, registerName(exec, r0).data(), registerName(exec, r1).data());
+ break;
+ }
+ case op_construct: {
+ int func = (++it)->u.operand;
+ int argCount = (++it)->u.operand;
+ int registerOffset = (++it)->u.operand;
+ printf("[%4d] construct\t %s, %d, %d\n", location, registerName(exec, func).data(), argCount, registerOffset);
break;
}
case op_strcat: {
int r0 = (++it)->u.operand;
int r1 = (++it)->u.operand;
int count = (++it)->u.operand;
- printf("[%4d] strcat\t\t %s, %s, %d\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str(), count);
+ printf("[%4d] strcat\t\t %s, %s, %d\n", location, registerName(exec, r0).data(), registerName(exec, r1).data(), count);
break;
}
case op_to_primitive: {
int r0 = (++it)->u.operand;
int r1 = (++it)->u.operand;
- printf("[%4d] to_primitive\t %s, %s\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str());
+ printf("[%4d] to_primitive\t %s, %s\n", location, registerName(exec, r0).data(), registerName(exec, r1).data());
break;
}
case op_get_pnames: {
@@ -1042,21 +1145,24 @@ void CodeBlock::dump(ExecState* exec, const Vector<Instruction>::const_iterator&
int r2 = it[3].u.operand;
int r3 = it[4].u.operand;
int offset = it[5].u.operand;
- printf("[%4d] get_pnames\t %s, %s, %s, %s, %d(->%d)\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str(), registerName(exec, r2).c_str(), registerName(exec, r3).c_str(), offset, location + offset);
+ printf("[%4d] get_pnames\t %s, %s, %s, %s, %d(->%d)\n", location, registerName(exec, r0).data(), registerName(exec, r1).data(), registerName(exec, r2).data(), registerName(exec, r3).data(), offset, location + offset);
it += OPCODE_LENGTH(op_get_pnames) - 1;
break;
}
case op_next_pname: {
int dest = it[1].u.operand;
- int iter = it[4].u.operand;
- int offset = it[5].u.operand;
- printf("[%4d] next_pname\t %s, %s, %d(->%d)\n", location, registerName(exec, dest).c_str(), registerName(exec, iter).c_str(), offset, location + offset);
+ int base = it[2].u.operand;
+ int i = it[3].u.operand;
+ int size = it[4].u.operand;
+ int iter = it[5].u.operand;
+ int offset = it[6].u.operand;
+ printf("[%4d] next_pname\t %s, %s, %s, %s, %s, %d(->%d)\n", location, registerName(exec, dest).data(), registerName(exec, base).data(), registerName(exec, i).data(), registerName(exec, size).data(), registerName(exec, iter).data(), offset, location + offset);
it += OPCODE_LENGTH(op_next_pname) - 1;
break;
}
case op_push_scope: {
int r0 = (++it)->u.operand;
- printf("[%4d] push_scope\t %s\n", location, registerName(exec, r0).c_str());
+ printf("[%4d] push_scope\t %s\n", location, registerName(exec, r0).data());
break;
}
case op_pop_scope: {
@@ -1067,7 +1173,7 @@ void CodeBlock::dump(ExecState* exec, const Vector<Instruction>::const_iterator&
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(exec, r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), registerName(exec, r1).c_str());
+ printf("[%4d] push_new_scope \t%s, %s, %s\n", location, registerName(exec, r0).data(), idName(id0, m_identifiers[id0]).data(), registerName(exec, r1).data());
break;
}
case op_jmp_scopes: {
@@ -1078,30 +1184,33 @@ void CodeBlock::dump(ExecState* exec, const Vector<Instruction>::const_iterator&
}
case op_catch: {
int r0 = (++it)->u.operand;
- printf("[%4d] catch\t\t %s\n", location, registerName(exec, r0).c_str());
+ printf("[%4d] catch\t\t %s\n", location, registerName(exec, r0).data());
break;
}
case op_throw: {
int r0 = (++it)->u.operand;
- printf("[%4d] throw\t\t %s\n", location, registerName(exec, r0).c_str());
+ printf("[%4d] throw\t\t %s\n", location, registerName(exec, r0).data());
break;
}
- case op_new_error: {
- int r0 = (++it)->u.operand;
- int errorType = (++it)->u.operand;
+ case op_throw_reference_error: {
+ int k0 = (++it)->u.operand;
+ printf("[%4d] throw_reference_error\t %s\n", location, constantName(exec, k0, getConstant(k0)).data());
+ break;
+ }
+ case op_throw_syntax_error: {
int k0 = (++it)->u.operand;
- printf("[%4d] new_error\t %s, %d, %s\n", location, registerName(exec, r0).c_str(), errorType, constantName(exec, k0, getConstant(k0)).c_str());
+ printf("[%4d] throw_syntax_error\t %s\n", location, constantName(exec, k0, getConstant(k0)).data());
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(exec, retAddrDst).c_str(), offset, location + offset);
+ printf("[%4d] jsr\t\t %s, %d(->%d)\n", location, registerName(exec, retAddrDst).data(), offset, location + offset);
break;
}
case op_sret: {
int retAddrSrc = (++it)->u.operand;
- printf("[%4d] sret\t\t %s\n", location, registerName(exec, retAddrSrc).c_str());
+ printf("[%4d] sret\t\t %s\n", location, registerName(exec, retAddrSrc).data());
break;
}
case op_debug: {
@@ -1113,17 +1222,17 @@ void CodeBlock::dump(ExecState* exec, const Vector<Instruction>::const_iterator&
}
case op_profile_will_call: {
int function = (++it)->u.operand;
- printf("[%4d] profile_will_call %s\n", location, registerName(exec, function).c_str());
+ printf("[%4d] profile_will_call %s\n", location, registerName(exec, function).data());
break;
}
case op_profile_did_call: {
int function = (++it)->u.operand;
- printf("[%4d] profile_did_call\t %s\n", location, registerName(exec, function).c_str());
+ printf("[%4d] profile_did_call\t %s\n", location, registerName(exec, function).data());
break;
}
case op_end: {
int r0 = (++it)->u.operand;
- printf("[%4d] end\t\t %s\n", location, registerName(exec, r0).c_str());
+ printf("[%4d] end\t\t %s\n", location, registerName(exec, r0).data());
break;
}
}
@@ -1152,13 +1261,10 @@ static HashSet<CodeBlock*> liveCodeBlockSet;
macro(immediateSwitchJumpTables) \
macro(characterSwitchJumpTables) \
macro(stringSwitchJumpTables) \
- macro(functionRegisterInfos)
-
-#define FOR_EACH_MEMBER_VECTOR_EXCEPTION_INFO(macro) \
+ macro(evalCodeCache) \
macro(expressionInfo) \
macro(lineInfo) \
- macro(getByIdExceptionInfo) \
- macro(pcVector)
+ macro(callReturnIndexVector)
template<typename T>
static size_t sizeInBytes(const Vector<T>& vector)
@@ -1172,7 +1278,6 @@ void CodeBlock::dumpStatistics()
#define DEFINE_VARS(name) size_t name##IsNotEmpty = 0; size_t name##TotalSize = 0;
FOR_EACH_MEMBER_VECTOR(DEFINE_VARS)
FOR_EACH_MEMBER_VECTOR_RARE_DATA(DEFINE_VARS)
- FOR_EACH_MEMBER_VECTOR_EXCEPTION_INFO(DEFINE_VARS)
#undef DEFINE_VARS
// Non-vector data members
@@ -1181,7 +1286,6 @@ void CodeBlock::dumpStatistics()
size_t symbolTableIsNotEmpty = 0;
size_t symbolTableTotalSize = 0;
- size_t hasExceptionInfo = 0;
size_t hasRareData = 0;
size_t isFunctionCode = 0;
@@ -1201,13 +1305,6 @@ void CodeBlock::dumpStatistics()
symbolTableTotalSize += (codeBlock->m_symbolTable.capacity() * (sizeof(SymbolTable::KeyType) + sizeof(SymbolTable::MappedType)));
}
- if (codeBlock->m_exceptionInfo) {
- hasExceptionInfo++;
- #define GET_STATS(name) if (!codeBlock->m_exceptionInfo->m_##name.isEmpty()) { name##IsNotEmpty++; name##TotalSize += sizeInBytes(codeBlock->m_exceptionInfo->m_##name); }
- FOR_EACH_MEMBER_VECTOR_EXCEPTION_INFO(GET_STATS)
- #undef GET_STATS
- }
-
if (codeBlock->m_rareData) {
hasRareData++;
#define GET_STATS(name) if (!codeBlock->m_rareData->m_##name.isEmpty()) { name##IsNotEmpty++; name##TotalSize += sizeInBytes(codeBlock->m_rareData->m_##name); }
@@ -1236,7 +1333,6 @@ void CodeBlock::dumpStatistics()
#define GET_TOTAL_SIZE(name) totalSize += name##TotalSize;
FOR_EACH_MEMBER_VECTOR(GET_TOTAL_SIZE)
FOR_EACH_MEMBER_VECTOR_RARE_DATA(GET_TOTAL_SIZE)
- FOR_EACH_MEMBER_VECTOR_EXCEPTION_INFO(GET_TOTAL_SIZE)
#undef GET_TOTAL_SIZE
totalSize += symbolTableTotalSize;
@@ -1251,13 +1347,11 @@ void CodeBlock::dumpStatistics()
printf("Number of GlobalCode CodeBlocks: %zu (%.3f%%)\n", isGlobalCode, static_cast<double>(isGlobalCode) * 100.0 / liveCodeBlockSet.size());
printf("Number of EvalCode CodeBlocks: %zu (%.3f%%)\n", isEvalCode, static_cast<double>(isEvalCode) * 100.0 / liveCodeBlockSet.size());
- printf("Number of CodeBlocks with exception info: %zu (%.3f%%)\n", hasExceptionInfo, static_cast<double>(hasExceptionInfo) * 100.0 / liveCodeBlockSet.size());
printf("Number of CodeBlocks with rare data: %zu (%.3f%%)\n", hasRareData, static_cast<double>(hasRareData) * 100.0 / liveCodeBlockSet.size());
#define PRINT_STATS(name) printf("Number of CodeBlocks with " #name ": %zu\n", name##IsNotEmpty); printf("Size of all " #name ": %zu\n", name##TotalSize);
FOR_EACH_MEMBER_VECTOR(PRINT_STATS)
FOR_EACH_MEMBER_VECTOR_RARE_DATA(PRINT_STATS)
- FOR_EACH_MEMBER_VECTOR_EXCEPTION_INFO(PRINT_STATS)
#undef PRINT_STATS
printf("Number of CodeBlocks with evalCodeCache: %zu\n", evalCodeCacheIsNotEmpty);
@@ -1270,23 +1364,26 @@ void CodeBlock::dumpStatistics()
#endif
}
-CodeBlock::CodeBlock(ScriptExecutable* ownerExecutable, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, SymbolTable* symTab)
- : m_numCalleeRegisters(0)
+CodeBlock::CodeBlock(ScriptExecutable* ownerExecutable, CodeType codeType, JSGlobalObject *globalObject, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, SymbolTable* symTab, bool isConstructor)
+ : m_globalObject(globalObject)
+ , m_numCalleeRegisters(0)
, m_numVars(0)
, m_numParameters(0)
+ , m_isConstructor(isConstructor)
, m_ownerExecutable(ownerExecutable)
, m_globalData(0)
#ifndef NDEBUG
, m_instructionCount(0)
#endif
+ , m_argumentsRegister(-1)
, m_needsFullScopeChain(ownerExecutable->needsActivation())
, m_usesEval(ownerExecutable->usesEval())
, m_isNumericCompareFunction(false)
+ , m_isStrictMode(ownerExecutable->isStrictMode())
, m_codeType(codeType)
, m_source(sourceProvider)
, m_sourceOffset(sourceOffset)
, m_symbolTable(symTab)
- , m_exceptionInfo(new ExceptionInfo)
{
ASSERT(m_source);
@@ -1297,13 +1394,14 @@ CodeBlock::CodeBlock(ScriptExecutable* ownerExecutable, CodeType codeType, PassR
CodeBlock::~CodeBlock()
{
-#if !ENABLE(JIT)
+#if ENABLE(INTERPRETER)
for (size_t size = m_globalResolveInstructions.size(), i = 0; i < size; ++i)
derefStructures(&m_instructions[m_globalResolveInstructions[i]]);
for (size_t size = m_propertyAccessInstructions.size(), i = 0; i < size; ++i)
derefStructures(&m_instructions[m_propertyAccessInstructions[i]]);
-#else
+#endif
+#if ENABLE(JIT)
for (size_t size = m_globalResolveInfos.size(), i = 0; i < size; ++i) {
if (m_globalResolveInfos[i].structure)
m_globalResolveInfos[i].structure->deref();
@@ -1331,7 +1429,7 @@ CodeBlock::~CodeBlock()
unlinkCallers();
#endif
-#endif // !ENABLE(JIT)
+#endif // ENABLE(JIT)
#if DUMP_CODE_BLOCK_STATISTICS
liveCodeBlockSet.remove(this);
@@ -1344,7 +1442,7 @@ void CodeBlock::unlinkCallers()
size_t size = m_linkedCallerList.size();
for (size_t i = 0; i < size; ++i) {
CallLinkInfo* currentCaller = m_linkedCallerList[i];
- JIT::unlinkCall(currentCaller);
+ JIT::unlinkCallOrConstruct(currentCaller);
currentCaller->setUnlinked();
}
m_linkedCallerList.clear();
@@ -1355,16 +1453,16 @@ void CodeBlock::derefStructures(Instruction* vPC) const
{
Interpreter* interpreter = m_globalData->interpreter;
- if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_self)) {
+ if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_self) || vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_getter_self) || vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_custom_self)) {
vPC[4].u.structure->deref();
return;
}
- if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_proto)) {
+ if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_proto) || vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_getter_proto) || vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_custom_proto)) {
vPC[4].u.structure->deref();
vPC[5].u.structure->deref();
return;
}
- if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_chain)) {
+ if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_chain) || vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_getter_chain) || vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_custom_chain)) {
vPC[4].u.structure->deref();
vPC[5].u.structureChain->deref();
return;
@@ -1379,13 +1477,17 @@ void CodeBlock::derefStructures(Instruction* vPC) const
vPC[4].u.structure->deref();
return;
}
- if (vPC[0].u.opcode == interpreter->getOpcode(op_resolve_global)) {
- if(vPC[4].u.structure)
- vPC[4].u.structure->deref();
+ if (vPC[0].u.opcode == interpreter->getOpcode(op_resolve_global) || vPC[0].u.opcode == interpreter->getOpcode(op_resolve_global_dynamic)) {
+ if (vPC[3].u.structure)
+ vPC[3].u.structure->deref();
return;
}
if ((vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_proto_list))
- || (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_self_list))) {
+ || (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_self_list))
+ || (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_getter_proto_list))
+ || (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_getter_self_list))
+ || (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_custom_proto_list))
+ || (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_custom_self_list))) {
PolymorphicAccessStructureList* polymorphicStructures = vPC[4].u.polymorphicStructures;
polymorphicStructures->derefStructures(vPC[5].u.operand);
delete polymorphicStructures;
@@ -1400,16 +1502,16 @@ void CodeBlock::refStructures(Instruction* vPC) const
{
Interpreter* interpreter = m_globalData->interpreter;
- if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_self)) {
+ if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_self) || vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_getter_self) || vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_custom_self)) {
vPC[4].u.structure->ref();
return;
}
- if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_proto)) {
+ if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_proto) || vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_getter_proto) || vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_custom_proto)) {
vPC[4].u.structure->ref();
vPC[5].u.structure->ref();
return;
}
- if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_chain)) {
+ if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_chain) || vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_getter_chain) || vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_custom_chain)) {
vPC[4].u.structure->ref();
vPC[5].u.structureChain->ref();
return;
@@ -1437,27 +1539,7 @@ void CodeBlock::markAggregate(MarkStack& markStack)
m_functionExprs[i]->markAggregate(markStack);
for (size_t i = 0; i < m_functionDecls.size(); ++i)
m_functionDecls[i]->markAggregate(markStack);
-}
-
-void CodeBlock::reparseForExceptionInfoIfNecessary(CallFrame* callFrame)
-{
- if (m_exceptionInfo)
- return;
-
- ScopeChainNode* scopeChain = callFrame->scopeChain();
- if (m_needsFullScopeChain) {
- ScopeChain sc(scopeChain);
- int scopeDelta = sc.localDepth();
- if (m_codeType == EvalCode)
- scopeDelta -= static_cast<EvalCodeBlock*>(this)->baseScopeDepth();
- else if (m_codeType == FunctionCode)
- scopeDelta++; // Compilation of function code assumes activation is not on the scope chain yet.
- ASSERT(scopeDelta >= 0);
- while (scopeDelta--)
- scopeChain = scopeChain->next;
- }
-
- m_exceptionInfo.set(m_ownerExecutable->reparseExceptionInfo(m_globalData, scopeChain, this));
+ markStack.append(m_globalObject);
}
HandlerInfo* CodeBlock::handlerForBytecodeOffset(unsigned bytecodeOffset)
@@ -1478,124 +1560,68 @@ HandlerInfo* CodeBlock::handlerForBytecodeOffset(unsigned bytecodeOffset)
return 0;
}
-int CodeBlock::lineNumberForBytecodeOffset(CallFrame* callFrame, unsigned bytecodeOffset)
+int CodeBlock::lineNumberForBytecodeOffset(unsigned bytecodeOffset)
{
ASSERT(bytecodeOffset < m_instructionCount);
- reparseForExceptionInfoIfNecessary(callFrame);
- ASSERT(m_exceptionInfo);
+ if (!m_rareData)
+ return m_ownerExecutable->source().firstLine();
- if (!m_exceptionInfo->m_lineInfo.size())
- return m_ownerExecutable->source().firstLine(); // Empty function
+ Vector<LineInfo>& lineInfo = m_rareData->m_lineInfo;
int low = 0;
- int high = m_exceptionInfo->m_lineInfo.size();
+ int high = lineInfo.size();
while (low < high) {
int mid = low + (high - low) / 2;
- if (m_exceptionInfo->m_lineInfo[mid].instructionOffset <= bytecodeOffset)
+ if (lineInfo[mid].instructionOffset <= bytecodeOffset)
low = mid + 1;
else
high = mid;
}
-
+
if (!low)
return m_ownerExecutable->source().firstLine();
- return m_exceptionInfo->m_lineInfo[low - 1].lineNumber;
+ return lineInfo[low - 1].lineNumber;
}
-int CodeBlock::expressionRangeForBytecodeOffset(CallFrame* callFrame, unsigned bytecodeOffset, int& divot, int& startOffset, int& endOffset)
+void CodeBlock::expressionRangeForBytecodeOffset(unsigned bytecodeOffset, int& divot, int& startOffset, int& endOffset)
{
ASSERT(bytecodeOffset < m_instructionCount);
- reparseForExceptionInfoIfNecessary(callFrame);
- ASSERT(m_exceptionInfo);
-
- if (!m_exceptionInfo->m_expressionInfo.size()) {
- // We didn't think anything could throw. Apparently we were wrong.
+ if (!m_rareData) {
startOffset = 0;
endOffset = 0;
divot = 0;
- return lineNumberForBytecodeOffset(callFrame, bytecodeOffset);
+ return;
}
+ Vector<ExpressionRangeInfo>& expressionInfo = m_rareData->m_expressionInfo;
+
int low = 0;
- int high = m_exceptionInfo->m_expressionInfo.size();
+ int high = expressionInfo.size();
while (low < high) {
int mid = low + (high - low) / 2;
- if (m_exceptionInfo->m_expressionInfo[mid].instructionOffset <= bytecodeOffset)
+ if (expressionInfo[mid].instructionOffset <= bytecodeOffset)
low = mid + 1;
else
high = mid;
}
-
+
ASSERT(low);
if (!low) {
startOffset = 0;
endOffset = 0;
divot = 0;
- return lineNumberForBytecodeOffset(callFrame, bytecodeOffset);
- }
-
- startOffset = m_exceptionInfo->m_expressionInfo[low - 1].startOffset;
- endOffset = m_exceptionInfo->m_expressionInfo[low - 1].endOffset;
- divot = m_exceptionInfo->m_expressionInfo[low - 1].divotPoint + m_sourceOffset;
- return lineNumberForBytecodeOffset(callFrame, bytecodeOffset);
-}
-
-bool CodeBlock::getByIdExceptionInfoForBytecodeOffset(CallFrame* callFrame, unsigned bytecodeOffset, OpcodeID& opcodeID)
-{
- ASSERT(bytecodeOffset < m_instructionCount);
-
- reparseForExceptionInfoIfNecessary(callFrame);
- ASSERT(m_exceptionInfo);
-
- if (!m_exceptionInfo->m_getByIdExceptionInfo.size())
- return false;
-
- int low = 0;
- int high = m_exceptionInfo->m_getByIdExceptionInfo.size();
- while (low < high) {
- int mid = low + (high - low) / 2;
- if (m_exceptionInfo->m_getByIdExceptionInfo[mid].bytecodeOffset <= bytecodeOffset)
- low = mid + 1;
- else
- high = mid;
- }
-
- if (!low || m_exceptionInfo->m_getByIdExceptionInfo[low - 1].bytecodeOffset != bytecodeOffset)
- return false;
-
- opcodeID = m_exceptionInfo->m_getByIdExceptionInfo[low - 1].isOpConstruct ? op_construct : op_instanceof;
- return true;
-}
-
-#if ENABLE(JIT)
-bool CodeBlock::functionRegisterForBytecodeOffset(unsigned bytecodeOffset, int& functionRegisterIndex)
-{
- ASSERT(bytecodeOffset < m_instructionCount);
-
- if (!m_rareData || !m_rareData->m_functionRegisterInfos.size())
- return false;
-
- int low = 0;
- int high = m_rareData->m_functionRegisterInfos.size();
- while (low < high) {
- int mid = low + (high - low) / 2;
- if (m_rareData->m_functionRegisterInfos[mid].bytecodeOffset <= bytecodeOffset)
- low = mid + 1;
- else
- high = mid;
+ return;
}
- if (!low || m_rareData->m_functionRegisterInfos[low - 1].bytecodeOffset != bytecodeOffset)
- return false;
-
- functionRegisterIndex = m_rareData->m_functionRegisterInfos[low - 1].functionRegisterIndex;
- return true;
+ startOffset = expressionInfo[low - 1].startOffset;
+ endOffset = expressionInfo[low - 1].endOffset;
+ divot = expressionInfo[low - 1].divotPoint + m_sourceOffset;
+ return;
}
-#endif
-#if !ENABLE(JIT)
+#if ENABLE(INTERPRETER)
bool CodeBlock::hasGlobalResolveInstructionAtBytecodeOffset(unsigned bytecodeOffset)
{
if (m_globalResolveInstructions.isEmpty())
@@ -1615,7 +1641,8 @@ bool CodeBlock::hasGlobalResolveInstructionAtBytecodeOffset(unsigned bytecodeOff
return false;
return true;
}
-#else
+#endif
+#if ENABLE(JIT)
bool CodeBlock::hasGlobalResolveInfoAtBytecodeOffset(unsigned bytecodeOffset)
{
if (m_globalResolveInfos.isEmpty())
@@ -1641,10 +1668,11 @@ void CodeBlock::shrinkToFit()
{
m_instructions.shrinkToFit();
-#if !ENABLE(JIT)
+#if ENABLE(INTERPRETER)
m_propertyAccessInstructions.shrinkToFit();
m_globalResolveInstructions.shrinkToFit();
-#else
+#endif
+#if ENABLE(JIT)
m_structureStubInfos.shrinkToFit();
m_globalResolveInfos.shrinkToFit();
m_callLinkInfos.shrinkToFit();
@@ -1656,22 +1684,25 @@ void CodeBlock::shrinkToFit()
m_functionExprs.shrinkToFit();
m_constantRegisters.shrinkToFit();
- if (m_exceptionInfo) {
- m_exceptionInfo->m_expressionInfo.shrinkToFit();
- m_exceptionInfo->m_lineInfo.shrinkToFit();
- m_exceptionInfo->m_getByIdExceptionInfo.shrinkToFit();
- }
-
if (m_rareData) {
m_rareData->m_exceptionHandlers.shrinkToFit();
m_rareData->m_regexps.shrinkToFit();
m_rareData->m_immediateSwitchJumpTables.shrinkToFit();
m_rareData->m_characterSwitchJumpTables.shrinkToFit();
m_rareData->m_stringSwitchJumpTables.shrinkToFit();
-#if ENABLE(JIT)
- m_rareData->m_functionRegisterInfos.shrinkToFit();
-#endif
+ m_rareData->m_expressionInfo.shrinkToFit();
+ m_rareData->m_lineInfo.shrinkToFit();
}
}
+void CodeBlock::createActivation(CallFrame* callFrame)
+{
+ ASSERT(codeType() == FunctionCode);
+ ASSERT(needsFullScopeChain());
+ ASSERT(!callFrame->uncheckedR(activationRegister()).jsValue());
+ JSActivation* activation = new (callFrame) JSActivation(callFrame, static_cast<FunctionExecutable*>(ownerExecutable()));
+ callFrame->uncheckedR(activationRegister()) = JSValue(activation);
+ callFrame->setScopeChain(callFrame->scopeChain()->copy()->push(activation));
+}
+
} // namespace JSC
diff --git a/JavaScriptCore/bytecode/CodeBlock.h b/JavaScriptCore/bytecode/CodeBlock.h
index eb874cc..7eca72a 100644
--- a/JavaScriptCore/bytecode/CodeBlock.h
+++ b/JavaScriptCore/bytecode/CodeBlock.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009, 2010 Apple Inc. All rights reserved.
* Copyright (C) 2008 Cameron Zwarich <cwzwarich@uwaterloo.ca>
*
* Redistribution and use in source and binary forms, with or without
@@ -36,10 +36,10 @@
#include "JSGlobalObject.h"
#include "JumpTable.h"
#include "Nodes.h"
-#include "PtrAndFlags.h"
#include "RegExp.h"
#include "UString.h"
#include <wtf/FastAllocBase.h>
+#include <wtf/PassOwnPtr.h>
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
@@ -47,8 +47,8 @@
#include "StructureStubInfo.h"
#endif
-// Register numbers used in bytecode operations have different meaning accoring to their ranges:
-// 0x80000000-0xFFFFFFFF Negative indicies from the CallFrame pointer are entries in the call frame, see RegisterFile.h.
+// Register numbers used in bytecode operations have different meaning according to their ranges:
+// 0x80000000-0xFFFFFFFF Negative indices from the CallFrame pointer are entries in the call frame, see RegisterFile.h.
// 0x00000000-0x3FFFFFFF Forwards indices from the CallFrame pointer are local vars and temporaries with the function's callframe.
// 0x40000000-0x7FFFFFFF Positive indices from 0x40000000 specify entries in the constant pool on the CodeBlock.
static const int FirstConstantRegisterIndex = 0x40000000;
@@ -63,6 +63,8 @@ namespace JSC {
enum CodeType { GlobalCode, EvalCode, FunctionCode };
+ inline int unmodifiedArgumentsRegister(int argumentsRegister) { return argumentsRegister - 1; }
+
static ALWAYS_INLINE int missingThisObjectMarker() { return std::numeric_limits<int>::max(); }
struct HandlerInfo {
@@ -91,74 +93,66 @@ namespace JSC {
int32_t lineNumber;
};
- // Both op_construct and op_instanceof require a use of op_get_by_id to get
- // the prototype property from an object. The exception messages for exceptions
- // thrown by these instances op_get_by_id need to reflect this.
- struct GetByIdExceptionInfo {
- unsigned bytecodeOffset : 31;
- bool isOpConstruct : 1;
- };
-
#if ENABLE(JIT)
struct CallLinkInfo {
CallLinkInfo()
: callee(0)
+ , position(0)
+ , hasSeenShouldRepatch(0)
{
}
-
- unsigned bytecodeIndex;
+
CodeLocationNearCall callReturnLocation;
CodeLocationDataLabelPtr hotPathBegin;
CodeLocationNearCall hotPathOther;
- PtrAndFlags<CodeBlock, HasSeenShouldRepatch> ownerCodeBlock;
+ CodeBlock* ownerCodeBlock;
CodeBlock* callee;
- unsigned position;
+ unsigned position : 31;
+ unsigned hasSeenShouldRepatch : 1;
void setUnlinked() { callee = 0; }
bool isLinked() { return callee; }
bool seenOnce()
{
- return ownerCodeBlock.isFlagSet(hasSeenShouldRepatch);
+ return hasSeenShouldRepatch;
}
void setSeen()
{
- ownerCodeBlock.setFlag(hasSeenShouldRepatch);
+ hasSeenShouldRepatch = true;
}
};
struct MethodCallLinkInfo {
MethodCallLinkInfo()
: cachedStructure(0)
+ , cachedPrototypeStructure(0)
{
}
bool seenOnce()
{
- return cachedPrototypeStructure.isFlagSet(hasSeenShouldRepatch);
+ ASSERT(!cachedStructure);
+ return cachedPrototypeStructure;
}
void setSeen()
{
- cachedPrototypeStructure.setFlag(hasSeenShouldRepatch);
+ ASSERT(!cachedStructure && !cachedPrototypeStructure);
+ // We use the values of cachedStructure & cachedPrototypeStructure to indicate the
+ // current state.
+ // - In the initial state, both are null.
+ // - Once this transition has been taken once, cachedStructure is
+ // null and cachedPrototypeStructure is set to a nun-null value.
+ // - Once the call is linked both structures are set to non-null values.
+ cachedPrototypeStructure = (Structure*)1;
}
CodeLocationCall callReturnLocation;
CodeLocationDataLabelPtr structureLabel;
Structure* cachedStructure;
- PtrAndFlags<Structure, HasSeenShouldRepatch> cachedPrototypeStructure;
- };
-
- struct FunctionRegisterInfo {
- FunctionRegisterInfo(unsigned bytecodeOffset, int functionRegisterIndex)
- : bytecodeOffset(bytecodeOffset)
- , functionRegisterIndex(functionRegisterIndex)
- {
- }
-
- unsigned bytecodeOffset;
- int functionRegisterIndex;
+ Structure* cachedPrototypeStructure;
};
struct GlobalResolveInfo {
@@ -178,15 +172,15 @@ namespace JSC {
// (given as an offset in bytes into the JIT code) back to
// the bytecode index of the corresponding bytecode operation.
// This is then used to look up the corresponding handler.
- struct CallReturnOffsetToBytecodeIndex {
- CallReturnOffsetToBytecodeIndex(unsigned callReturnOffset, unsigned bytecodeIndex)
+ struct CallReturnOffsetToBytecodeOffset {
+ CallReturnOffsetToBytecodeOffset(unsigned callReturnOffset, unsigned bytecodeOffset)
: callReturnOffset(callReturnOffset)
- , bytecodeIndex(bytecodeIndex)
+ , bytecodeOffset(bytecodeOffset)
{
}
unsigned callReturnOffset;
- unsigned bytecodeIndex;
+ unsigned bytecodeOffset;
};
// valueAtPosition helpers for the binaryChop algorithm below.
@@ -206,7 +200,7 @@ namespace JSC {
return methodCallLinkInfo->callReturnLocation.executableAddress();
}
- inline unsigned getCallReturnOffset(CallReturnOffsetToBytecodeIndex* pc)
+ inline unsigned getCallReturnOffset(CallReturnOffsetToBytecodeOffset* pc)
{
return pc->callReturnOffset;
}
@@ -248,20 +242,13 @@ namespace JSC {
}
#endif
- struct ExceptionInfo : FastAllocBase {
- Vector<ExpressionRangeInfo> m_expressionInfo;
- Vector<LineInfo> m_lineInfo;
- Vector<GetByIdExceptionInfo> m_getByIdExceptionInfo;
-
-#if ENABLE(JIT)
- Vector<CallReturnOffsetToBytecodeIndex> m_callReturnIndexVector;
-#endif
- };
-
class CodeBlock : public FastAllocBase {
friend class JIT;
protected:
- CodeBlock(ScriptExecutable* ownerExecutable, CodeType, PassRefPtr<SourceProvider>, unsigned sourceOffset, SymbolTable* symbolTable);
+ CodeBlock(ScriptExecutable* ownerExecutable, CodeType, JSGlobalObject*, PassRefPtr<SourceProvider>, unsigned sourceOffset, SymbolTable* symbolTable, bool isConstructor);
+
+ JSGlobalObject* m_globalObject;
+
public:
virtual ~CodeBlock();
@@ -280,9 +267,11 @@ namespace JSC {
void printStructure(const char* name, const Instruction*, int operand) const;
#endif
+ bool isStrictMode() const { return m_isStrictMode; }
+
inline bool isKnownNotImmediate(int index)
{
- if (index == m_thisRegister)
+ if (index == m_thisRegister && !m_isStrictMode)
return true;
if (isConstantRegisterIndex(index))
@@ -297,9 +286,8 @@ namespace JSC {
}
HandlerInfo* handlerForBytecodeOffset(unsigned bytecodeOffset);
- int lineNumberForBytecodeOffset(CallFrame*, unsigned bytecodeOffset);
- int expressionRangeForBytecodeOffset(CallFrame*, unsigned bytecodeOffset, int& divot, int& startOffset, int& endOffset);
- bool getByIdExceptionInfoForBytecodeOffset(CallFrame*, unsigned bytecodeOffset, OpcodeID&);
+ int lineNumberForBytecodeOffset(unsigned bytecodeOffset);
+ void expressionRangeForBytecodeOffset(unsigned bytecodeOffset, int& divot, int& startOffset, int& endOffset);
#if ENABLE(JIT)
void addCaller(CallLinkInfo* caller)
@@ -336,13 +324,21 @@ namespace JSC {
return *(binaryChop<MethodCallLinkInfo, void*, getMethodCallLinkInfoReturnLocation>(m_methodCallLinkInfos.begin(), m_methodCallLinkInfos.size(), returnAddress.value()));
}
- unsigned getBytecodeIndex(CallFrame* callFrame, ReturnAddressPtr returnAddress)
+ unsigned bytecodeOffset(ReturnAddressPtr returnAddress)
{
- reparseForExceptionInfoIfNecessary(callFrame);
- return binaryChop<CallReturnOffsetToBytecodeIndex, unsigned, getCallReturnOffset>(callReturnIndexVector().begin(), callReturnIndexVector().size(), ownerExecutable()->generatedJITCode().offsetOf(returnAddress.value()))->bytecodeIndex;
+ if (!m_rareData)
+ return 1;
+ Vector<CallReturnOffsetToBytecodeOffset>& callIndices = m_rareData->m_callReturnIndexVector;
+ if (!callIndices.size())
+ return 1;
+ return binaryChop<CallReturnOffsetToBytecodeOffset, unsigned, getCallReturnOffset>(callIndices.begin(), callIndices.size(), getJITCode().offsetOf(returnAddress.value()))->bytecodeOffset;
+ }
+#endif
+#if ENABLE(INTERPRETER)
+ unsigned bytecodeOffset(Instruction* returnAddress)
+ {
+ return static_cast<Instruction*>(returnAddress) - instructions().begin();
}
-
- bool functionRegisterForBytecodeOffset(unsigned bytecodeOffset, int& functionRegisterIndex);
#endif
void setIsNumericCompareFunction(bool isNumericCompareFunction) { m_isNumericCompareFunction = isNumericCompareFunction; }
@@ -357,8 +353,8 @@ namespace JSC {
#endif
#if ENABLE(JIT)
- JITCode& getJITCode() { return ownerExecutable()->generatedJITCode(); }
- ExecutablePool* executablePool() { return ownerExecutable()->getExecutablePool(); }
+ JITCode& getJITCode() { return m_isConstructor ? ownerExecutable()->generatedJITCodeForConstruct() : ownerExecutable()->generatedJITCodeForCall(); }
+ ExecutablePool* executablePool() { return getJITCode().getExecutablePool(); }
#endif
ScriptExecutable* ownerExecutable() const { return m_ownerExecutable; }
@@ -372,8 +368,28 @@ namespace JSC {
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; }
+
+ void setArgumentsRegister(int argumentsRegister)
+ {
+ ASSERT(argumentsRegister != -1);
+ m_argumentsRegister = argumentsRegister;
+ ASSERT(usesArguments());
+ }
+ int argumentsRegister()
+ {
+ ASSERT(usesArguments());
+ return m_argumentsRegister;
+ }
+ void setActivationRegister(int activationRegister)
+ {
+ m_activationRegister = activationRegister;
+ }
+ int activationRegister()
+ {
+ ASSERT(needsFullScopeChain());
+ return m_activationRegister;
+ }
+ bool usesArguments() const { return m_argumentsRegister != -1; }
CodeType codeType() const { return m_codeType; }
@@ -385,11 +401,14 @@ namespace JSC {
unsigned jumpTarget(int index) const { return m_jumpTargets[index]; }
unsigned lastJumpTarget() const { return m_jumpTargets.last(); }
-#if !ENABLE(JIT)
+ void createActivation(CallFrame*);
+
+#if ENABLE(INTERPRETER)
void addPropertyAccessInstruction(unsigned propertyAccessInstruction) { m_propertyAccessInstructions.append(propertyAccessInstruction); }
void addGlobalResolveInstruction(unsigned globalResolveInstruction) { m_globalResolveInstructions.append(globalResolveInstruction); }
bool hasGlobalResolveInstructionAtBytecodeOffset(unsigned bytecodeOffset);
-#else
+#endif
+#if ENABLE(JIT)
size_t numberOfStructureStubInfos() const { return m_structureStubInfos.size(); }
void addStructureStubInfo(const StructureStubInfo& stubInfo) { m_structureStubInfos.append(stubInfo); }
StructureStubInfo& structureStubInfo(int index) { return m_structureStubInfos[index]; }
@@ -404,8 +423,6 @@ namespace JSC {
void addMethodCallLinkInfos(unsigned n) { m_methodCallLinkInfos.grow(n); }
MethodCallLinkInfo& methodCallLinkInfo(int index) { return m_methodCallLinkInfos[index]; }
-
- void addFunctionRegisterInfo(unsigned bytecodeOffset, int functionIndex) { createRareDataIfNecessary(); m_rareData->m_functionRegisterInfos.append(FunctionRegisterInfo(bytecodeOffset, functionIndex)); }
#endif
// Exception handling support
@@ -414,19 +431,36 @@ namespace JSC {
void addExceptionHandler(const HandlerInfo& hanler) { createRareDataIfNecessary(); return m_rareData->m_exceptionHandlers.append(hanler); }
HandlerInfo& exceptionHandler(int index) { ASSERT(m_rareData); return m_rareData->m_exceptionHandlers[index]; }
- bool hasExceptionInfo() const { return m_exceptionInfo; }
- void clearExceptionInfo() { m_exceptionInfo.clear(); }
- ExceptionInfo* extractExceptionInfo() { ASSERT(m_exceptionInfo); return m_exceptionInfo.release(); }
+ void addExpressionInfo(const ExpressionRangeInfo& expressionInfo)
+ {
+ createRareDataIfNecessary();
+ m_rareData->m_expressionInfo.append(expressionInfo);
+ }
- void addExpressionInfo(const ExpressionRangeInfo& expressionInfo) { ASSERT(m_exceptionInfo); m_exceptionInfo->m_expressionInfo.append(expressionInfo); }
- void addGetByIdExceptionInfo(const GetByIdExceptionInfo& info) { ASSERT(m_exceptionInfo); m_exceptionInfo->m_getByIdExceptionInfo.append(info); }
+ void addLineInfo(unsigned bytecodeOffset, int lineNo)
+ {
+ createRareDataIfNecessary();
+ Vector<LineInfo>& lineInfo = m_rareData->m_lineInfo;
+ if (!lineInfo.size() || lineInfo.last().lineNumber != lineNo) {
+ LineInfo info = { bytecodeOffset, lineNo };
+ lineInfo.append(info);
+ }
+ }
- size_t numberOfLineInfos() const { ASSERT(m_exceptionInfo); return m_exceptionInfo->m_lineInfo.size(); }
- void addLineInfo(const LineInfo& lineInfo) { ASSERT(m_exceptionInfo); m_exceptionInfo->m_lineInfo.append(lineInfo); }
- LineInfo& lastLineInfo() { ASSERT(m_exceptionInfo); return m_exceptionInfo->m_lineInfo.last(); }
+ bool hasExpressionInfo() { return m_rareData && m_rareData->m_expressionInfo.size(); }
+ bool hasLineInfo() { return m_rareData && m_rareData->m_lineInfo.size(); }
+ bool needsCallReturnIndices()
+ {
+ return m_rareData &&
+ (m_rareData->m_expressionInfo.size() || m_rareData->m_lineInfo.size() || m_rareData->m_exceptionHandlers.size());
+ }
#if ENABLE(JIT)
- Vector<CallReturnOffsetToBytecodeIndex>& callReturnIndexVector() { ASSERT(m_exceptionInfo); return m_exceptionInfo->m_callReturnIndexVector; }
+ Vector<CallReturnOffsetToBytecodeOffset>& callReturnIndexVector()
+ {
+ createRareDataIfNecessary();
+ return m_rareData->m_callReturnIndexVector;
+ }
#endif
// Constant Pool
@@ -450,6 +484,7 @@ namespace JSC {
unsigned addRegExp(RegExp* r) { createRareDataIfNecessary(); unsigned size = m_rareData->m_regexps.size(); m_rareData->m_regexps.append(r); return size; }
RegExp* regexp(int index) const { ASSERT(m_rareData); return m_rareData->m_regexps[index].get(); }
+ JSGlobalObject* globalObject() { return m_globalObject; }
// Jump Tables
@@ -477,7 +512,9 @@ namespace JSC {
int m_numCalleeRegisters;
int m_numVars;
+ int m_numCapturedVars;
int m_numParameters;
+ bool m_isConstructor;
private:
#if !defined(NDEBUG) || ENABLE(OPCODE_SAMPLING)
@@ -491,12 +528,10 @@ namespace JSC {
void printPutByIdOp(ExecState*, int location, Vector<Instruction>::const_iterator&, const char* op) const;
#endif
- void reparseForExceptionInfoIfNecessary(CallFrame*);
-
void createRareDataIfNecessary()
{
if (!m_rareData)
- m_rareData.set(new RareData);
+ m_rareData = adoptPtr(new RareData);
}
ScriptExecutable* m_ownerExecutable;
@@ -508,21 +543,24 @@ namespace JSC {
#endif
int m_thisRegister;
+ int m_argumentsRegister;
+ int m_activationRegister;
bool m_needsFullScopeChain;
bool m_usesEval;
- bool m_usesArguments;
bool m_isNumericCompareFunction;
+ bool m_isStrictMode;
CodeType m_codeType;
RefPtr<SourceProvider> m_source;
unsigned m_sourceOffset;
-#if !ENABLE(JIT)
+#if ENABLE(INTERPRETER)
Vector<unsigned> m_propertyAccessInstructions;
Vector<unsigned> m_globalResolveInstructions;
-#else
+#endif
+#if ENABLE(JIT)
Vector<StructureStubInfo> m_structureStubInfos;
Vector<GlobalResolveInfo> m_globalResolveInfos;
Vector<CallLinkInfo> m_callLinkInfos;
@@ -540,8 +578,6 @@ namespace JSC {
SymbolTable* m_symbolTable;
- OwnPtr<ExceptionInfo> m_exceptionInfo;
-
struct RareData : FastAllocBase {
Vector<HandlerInfo> m_exceptionHandlers;
@@ -555,8 +591,12 @@ namespace JSC {
EvalCodeCache m_evalCodeCache;
+ // Expression info - present if debugging.
+ Vector<ExpressionRangeInfo> m_expressionInfo;
+ // Line info - present if profiling or debugging.
+ Vector<LineInfo> m_lineInfo;
#if ENABLE(JIT)
- Vector<FunctionRegisterInfo> m_functionRegisterInfos;
+ Vector<CallReturnOffsetToBytecodeOffset> m_callReturnIndexVector;
#endif
};
OwnPtr<RareData> m_rareData;
@@ -567,9 +607,8 @@ namespace JSC {
class GlobalCodeBlock : public CodeBlock {
public:
- GlobalCodeBlock(ScriptExecutable* ownerExecutable, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, JSGlobalObject* globalObject)
- : CodeBlock(ownerExecutable, codeType, sourceProvider, sourceOffset, &m_unsharedSymbolTable)
- , m_globalObject(globalObject)
+ GlobalCodeBlock(ScriptExecutable* ownerExecutable, CodeType codeType, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset)
+ : CodeBlock(ownerExecutable, codeType, globalObject, sourceProvider, sourceOffset, &m_unsharedSymbolTable, false)
{
m_globalObject->codeBlocks().add(this);
}
@@ -583,14 +622,13 @@ namespace JSC {
void clearGlobalObject() { m_globalObject = 0; }
private:
- JSGlobalObject* m_globalObject; // For program and eval nodes, the global object that marks the constant pool.
SymbolTable m_unsharedSymbolTable;
};
class ProgramCodeBlock : public GlobalCodeBlock {
public:
ProgramCodeBlock(ProgramExecutable* ownerExecutable, CodeType codeType, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider)
- : GlobalCodeBlock(ownerExecutable, codeType, sourceProvider, 0, globalObject)
+ : GlobalCodeBlock(ownerExecutable, codeType, globalObject, sourceProvider, 0)
{
}
};
@@ -598,7 +636,7 @@ namespace JSC {
class EvalCodeBlock : public GlobalCodeBlock {
public:
EvalCodeBlock(EvalExecutable* ownerExecutable, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider, int baseScopeDepth)
- : GlobalCodeBlock(ownerExecutable, EvalCode, sourceProvider, 0, globalObject)
+ : GlobalCodeBlock(ownerExecutable, EvalCode, globalObject, sourceProvider, 0)
, m_baseScopeDepth(baseScopeDepth)
{
}
@@ -624,8 +662,8 @@ namespace JSC {
// as we need to initialise the CodeBlock before we could initialise any RefPtr to hold the shared
// symbol table, so we just pass as a raw pointer with a ref count of 1. We then manually deref
// in the destructor.
- FunctionCodeBlock(FunctionExecutable* ownerExecutable, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset)
- : CodeBlock(ownerExecutable, codeType, sourceProvider, sourceOffset, new SharedSymbolTable)
+ FunctionCodeBlock(FunctionExecutable* ownerExecutable, CodeType codeType, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, bool isConstructor)
+ : CodeBlock(ownerExecutable, codeType, globalObject, sourceProvider, sourceOffset, SharedSymbolTable::create().leakRef(), isConstructor)
{
}
~FunctionCodeBlock()
@@ -642,6 +680,12 @@ namespace JSC {
return this[index];
}
+ inline Register& ExecState::uncheckedR(int index)
+ {
+ ASSERT(index < FirstConstantRegisterIndex);
+ return this[index];
+ }
+
} // namespace JSC
#endif // CodeBlock_h
diff --git a/JavaScriptCore/bytecode/EvalCodeCache.h b/JavaScriptCore/bytecode/EvalCodeCache.h
index 05834fc..edd575f 100644
--- a/JavaScriptCore/bytecode/EvalCodeCache.h
+++ b/JavaScriptCore/bytecode/EvalCodeCache.h
@@ -37,26 +37,27 @@
#include "UString.h"
#include <wtf/HashMap.h>
#include <wtf/RefPtr.h>
+#include <wtf/text/StringHash.h>
namespace JSC {
class EvalCodeCache {
public:
- PassRefPtr<EvalExecutable> get(ExecState* exec, const UString& evalSource, ScopeChainNode* scopeChain, JSValue& exceptionValue)
+ PassRefPtr<EvalExecutable> get(ExecState* exec, bool inStrictContext, const UString& evalSource, ScopeChainNode* scopeChain, JSValue& exceptionValue)
{
RefPtr<EvalExecutable> evalExecutable;
- if (evalSource.size() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject())
- evalExecutable = m_cacheMap.get(evalSource.rep());
+ if (!inStrictContext && evalSource.length() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject())
+ evalExecutable = m_cacheMap.get(evalSource.impl());
if (!evalExecutable) {
- evalExecutable = EvalExecutable::create(exec, makeSource(evalSource));
+ evalExecutable = EvalExecutable::create(exec, makeSource(evalSource), inStrictContext);
exceptionValue = evalExecutable->compile(exec, scopeChain);
if (exceptionValue)
return 0;
- if (evalSource.size() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject() && m_cacheMap.size() < maxCacheEntries)
- m_cacheMap.set(evalSource.rep(), evalExecutable);
+ if (!inStrictContext && evalSource.length() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject() && m_cacheMap.size() < maxCacheEntries)
+ m_cacheMap.set(evalSource.impl(), evalExecutable);
}
return evalExecutable.release();
@@ -65,10 +66,10 @@ namespace JSC {
bool isEmpty() const { return m_cacheMap.isEmpty(); }
private:
- static const int maxCacheableSourceLength = 256;
+ static const unsigned maxCacheableSourceLength = 256;
static const int maxCacheEntries = 64;
- typedef HashMap<RefPtr<UString::Rep>, RefPtr<EvalExecutable> > EvalCacheMap;
+ typedef HashMap<RefPtr<StringImpl>, RefPtr<EvalExecutable> > EvalCacheMap;
EvalCacheMap m_cacheMap;
};
diff --git a/JavaScriptCore/bytecode/Instruction.h b/JavaScriptCore/bytecode/Instruction.h
index bcef7fb..c6468a5 100644
--- a/JavaScriptCore/bytecode/Instruction.h
+++ b/JavaScriptCore/bytecode/Instruction.h
@@ -31,6 +31,7 @@
#include "MacroAssembler.h"
#include "Opcode.h"
+#include "PropertySlot.h"
#include "Structure.h"
#include <wtf/VectorTraits.h>
@@ -124,7 +125,7 @@ namespace JSC {
struct Instruction {
Instruction(Opcode opcode)
{
-#if !HAVE(COMPUTED_GOTO)
+#if !ENABLE(COMPUTED_GOTO_INTERPRETER)
// We have to initialize one of the pointer members to ensure that
// the entire struct is initialized, when opcode is not a pointer.
u.jsCell = 0;
@@ -144,6 +145,7 @@ namespace JSC {
Instruction(StructureChain* structureChain) { u.structureChain = structureChain; }
Instruction(JSCell* jsCell) { u.jsCell = jsCell; }
Instruction(PolymorphicAccessStructureList* polymorphicStructures) { u.polymorphicStructures = polymorphicStructures; }
+ Instruction(PropertySlot::GetValueFunc getterFunc) { u.getterFunc = getterFunc; }
union {
Opcode opcode;
@@ -152,6 +154,7 @@ namespace JSC {
StructureChain* structureChain;
JSCell* jsCell;
PolymorphicAccessStructureList* polymorphicStructures;
+ PropertySlot::GetValueFunc getterFunc;
} u;
};
diff --git a/JavaScriptCore/bytecode/JumpTable.cpp b/JavaScriptCore/bytecode/JumpTable.cpp
index 175c1b3..ef7098b 100644
--- a/JavaScriptCore/bytecode/JumpTable.cpp
+++ b/JavaScriptCore/bytecode/JumpTable.cpp
@@ -30,6 +30,8 @@
#include "config.h"
#include "JumpTable.h"
+#include <wtf/text/StringHash.h>
+
namespace JSC {
int32_t SimpleJumpTable::offsetForValue(int32_t value, int32_t defaultOffset)
diff --git a/JavaScriptCore/bytecode/JumpTable.h b/JavaScriptCore/bytecode/JumpTable.h
index b4f8e44..5bbe047 100644
--- a/JavaScriptCore/bytecode/JumpTable.h
+++ b/JavaScriptCore/bytecode/JumpTable.h
@@ -45,13 +45,13 @@ namespace JSC {
};
struct StringJumpTable {
- typedef HashMap<RefPtr<UString::Rep>, OffsetLocation> StringOffsetTable;
+ typedef HashMap<RefPtr<StringImpl>, OffsetLocation> StringOffsetTable;
StringOffsetTable offsetTable;
#if ENABLE(JIT)
CodeLocationLabel ctiDefault; // FIXME: it should not be necessary to store this.
#endif
- inline int32_t offsetForValue(UString::Rep* value, int32_t defaultOffset)
+ inline int32_t offsetForValue(StringImpl* value, int32_t defaultOffset)
{
StringOffsetTable::const_iterator end = offsetTable.end();
StringOffsetTable::const_iterator loc = offsetTable.find(value);
@@ -61,7 +61,7 @@ namespace JSC {
}
#if ENABLE(JIT)
- inline CodeLocationLabel ctiForValue(UString::Rep* value)
+ inline CodeLocationLabel ctiForValue(StringImpl* value)
{
StringOffsetTable::const_iterator end = offsetTable.end();
StringOffsetTable::const_iterator loc = offsetTable.find(value);
diff --git a/JavaScriptCore/bytecode/Opcode.cpp b/JavaScriptCore/bytecode/Opcode.cpp
index bb7696d..0bb714b 100644
--- a/JavaScriptCore/bytecode/Opcode.cpp
+++ b/JavaScriptCore/bytecode/Opcode.cpp
@@ -30,6 +30,11 @@
#include "config.h"
#include "Opcode.h"
+#if ENABLE(OPCODE_STATS)
+#include <stdio.h>
+#include <wtf/FixedArray.h>
+#endif
+
using namespace std;
namespace JSC {
@@ -101,10 +106,10 @@ OpcodeStats::~OpcodeStats()
for (int j = 0; j < numOpcodeIDs; ++j)
totalInstructionPairs += opcodePairCounts[i][j];
- int sortedIndices[numOpcodeIDs];
+ FixedArray<int, numOpcodeIDs> sortedIndices;
for (int i = 0; i < numOpcodeIDs; ++i)
sortedIndices[i] = i;
- qsort(sortedIndices, numOpcodeIDs, sizeof(int), compareOpcodeIndices);
+ qsort(sortedIndices.data(), numOpcodeIDs, sizeof(int), compareOpcodeIndices);
pair<int, int> sortedPairIndices[numOpcodeIDs * numOpcodeIDs];
pair<int, int>* currentPairIndex = sortedPairIndices;
diff --git a/JavaScriptCore/bytecode/Opcode.h b/JavaScriptCore/bytecode/Opcode.h
index d9b2153..6c1c6b2 100644
--- a/JavaScriptCore/bytecode/Opcode.h
+++ b/JavaScriptCore/bytecode/Opcode.h
@@ -39,10 +39,13 @@ namespace JSC {
#define FOR_EACH_OPCODE_ID(macro) \
macro(op_enter, 1) \
- macro(op_enter_with_activation, 2) \
- macro(op_init_arguments, 1) \
- macro(op_create_arguments, 1) \
+ macro(op_create_activation, 2) \
+ macro(op_init_lazy_reg, 2) \
+ macro(op_create_arguments, 2) \
+ macro(op_create_this, 3) \
+ macro(op_get_callee, 2) \
macro(op_convert_this, 2) \
+ macro(op_convert_this_strict, 2) \
\
macro(op_new_object, 2) \
macro(op_new_array, 4) \
@@ -79,6 +82,7 @@ namespace JSC {
macro(op_bitor, 5) \
macro(op_bitnot, 3) \
\
+ macro(op_check_has_instance, 2) \
macro(op_instanceof, 5) \
macro(op_typeof, 3) \
macro(op_is_undefined, 3) \
@@ -91,12 +95,14 @@ namespace JSC {
\
macro(op_resolve, 3) \
macro(op_resolve_skip, 4) \
- macro(op_resolve_global, 6) \
+ macro(op_resolve_global, 5) \
+ macro(op_resolve_global_dynamic, 6) \
macro(op_get_scoped_var, 4) \
macro(op_put_scoped_var, 4) \
- macro(op_get_global_var, 4) \
- macro(op_put_global_var, 4) \
- macro(op_resolve_base, 3) \
+ macro(op_get_global_var, 3) \
+ macro(op_put_global_var, 3) \
+ macro(op_resolve_base, 4) \
+ macro(op_ensure_property_exists, 3) \
macro(op_resolve_with_base, 4) \
macro(op_get_by_id, 8) \
macro(op_get_by_id_self, 8) \
@@ -104,15 +110,27 @@ namespace JSC {
macro(op_get_by_id_proto, 8) \
macro(op_get_by_id_proto_list, 8) \
macro(op_get_by_id_chain, 8) \
+ macro(op_get_by_id_getter_self, 8) \
+ macro(op_get_by_id_getter_self_list, 8) \
+ macro(op_get_by_id_getter_proto, 8) \
+ macro(op_get_by_id_getter_proto_list, 8) \
+ macro(op_get_by_id_getter_chain, 8) \
+ macro(op_get_by_id_custom_self, 8) \
+ macro(op_get_by_id_custom_self_list, 8) \
+ macro(op_get_by_id_custom_proto, 8) \
+ macro(op_get_by_id_custom_proto_list, 8) \
+ macro(op_get_by_id_custom_chain, 8) \
macro(op_get_by_id_generic, 8) \
macro(op_get_array_length, 8) \
macro(op_get_string_length, 8) \
- macro(op_put_by_id, 8) \
- macro(op_put_by_id_transition, 8) \
- macro(op_put_by_id_replace, 8) \
- macro(op_put_by_id_generic, 8) \
+ macro(op_get_arguments_length, 4) \
+ macro(op_put_by_id, 9) \
+ macro(op_put_by_id_transition, 9) \
+ macro(op_put_by_id_replace, 9) \
+ macro(op_put_by_id_generic, 9) \
macro(op_del_by_id, 4) \
macro(op_get_by_val, 4) \
+ macro(op_get_argument_by_val, 4) \
macro(op_get_by_pname, 7) \
macro(op_put_by_val, 4) \
macro(op_del_by_val, 4) \
@@ -129,6 +147,7 @@ namespace JSC {
macro(op_jnless, 4) \
macro(op_jnlesseq, 4) \
macro(op_jless, 4) \
+ macro(op_jlesseq, 4) \
macro(op_jmp_scopes, 3) \
macro(op_loop, 2) \
macro(op_loop_if_true, 3) \
@@ -139,19 +158,20 @@ namespace JSC {
macro(op_switch_char, 4) \
macro(op_switch_string, 4) \
\
- macro(op_new_func, 3) \
+ macro(op_new_func, 4) \
macro(op_new_func_exp, 3) \
- macro(op_call, 5) \
- macro(op_call_eval, 5) \
- macro(op_call_varargs, 5) \
- macro(op_load_varargs, 3) \
- macro(op_tear_off_activation, 2) \
- macro(op_tear_off_arguments, 1) \
+ macro(op_call, 4) \
+ macro(op_call_eval, 4) \
+ macro(op_call_varargs, 4) \
+ macro(op_load_varargs, 4) \
+ macro(op_tear_off_activation, 3) \
+ macro(op_tear_off_arguments, 2) \
macro(op_ret, 2) \
+ macro(op_call_put_result, 2) \
+ macro(op_ret_object_or_this, 3) \
macro(op_method_check, 1) \
\
- macro(op_construct, 7) \
- macro(op_construct_verify, 3) \
+ macro(op_construct, 4) \
macro(op_strcat, 4) \
macro(op_to_primitive, 3) \
\
@@ -164,7 +184,8 @@ namespace JSC {
\
macro(op_catch, 2) \
macro(op_throw, 2) \
- macro(op_new_error, 4) \
+ macro(op_throw_reference_error, 2) \
+ macro(op_throw_syntax_error, 2) \
\
macro(op_jsr, 3) \
macro(op_sret, 2) \
@@ -195,8 +216,8 @@ namespace JSC {
FOR_EACH_OPCODE_ID(VERIFY_OPCODE_ID);
#undef VERIFY_OPCODE_ID
-#if HAVE(COMPUTED_GOTO)
-#if COMPILER(RVCT)
+#if ENABLE(COMPUTED_GOTO_INTERPRETER)
+#if COMPILER(RVCT) || COMPILER(INTEL)
typedef void* Opcode;
#else
typedef const void* Opcode;
@@ -239,6 +260,17 @@ namespace JSC {
#endif
+ inline size_t opcodeLength(OpcodeID opcode)
+ {
+ switch (opcode) {
+#define OPCODE_ID_LENGTHS(id, length) case id: return OPCODE_LENGTH(id);
+ FOR_EACH_OPCODE_ID(OPCODE_ID_LENGTHS)
+#undef OPCODE_ID_LENGTHS
+ }
+ ASSERT_NOT_REACHED();
+ return 0;
+ }
+
} // namespace JSC
#endif // Opcode_h
diff --git a/JavaScriptCore/bytecode/SamplingTool.cpp b/JavaScriptCore/bytecode/SamplingTool.cpp
index 3f0babc..f47e698 100644
--- a/JavaScriptCore/bytecode/SamplingTool.cpp
+++ b/JavaScriptCore/bytecode/SamplingTool.cpp
@@ -43,7 +43,7 @@ namespace JSC {
void SamplingFlags::sample()
{
- uint32_t mask = 1 << 31;
+ uint32_t mask = static_cast<uint32_t>(1 << 31);
unsigned index;
for (index = 0; index < 32; ++index) {
@@ -337,7 +337,7 @@ void SamplingTool::dump(ExecState* exec)
if (blockPercent >= 1) {
//Instruction* code = codeBlock->instructions().begin();
- printf("#%d: %s:%d: %d / %lld (%.3f%%)\n", i + 1, record->m_executable->sourceURL().UTF8String().c_str(), codeBlock->lineNumberForBytecodeOffset(exec, 0), record->m_sampleCount, m_sampleCount, blockPercent);
+ printf("#%d: %s:%d: %d / %lld (%.3f%%)\n", i + 1, record->m_executable->sourceURL().utf8().data(), codeBlock->lineNumberForBytecodeOffset(0), record->m_sampleCount, m_sampleCount, blockPercent);
if (i < 10) {
HashMap<unsigned,unsigned> lineCounts;
codeBlock->dump(exec);
@@ -347,7 +347,7 @@ void SamplingTool::dump(ExecState* exec)
int count = record->m_samples[op];
if (count) {
printf(" [% 4d] has sample count: % 4d\n", op, count);
- unsigned line = codeBlock->lineNumberForBytecodeOffset(exec, op);
+ unsigned line = codeBlock->lineNumberForBytecodeOffset(op);
lineCounts.set(line, (lineCounts.contains(line) ? lineCounts.get(line) : 0) + count);
}
}