Unreviewed, rolling out r156474.

http://trac.webkit.org/changeset/156474
https://bugs.webkit.org/show_bug.cgi?id=121966

Broke the builds. (Requested by xenon on #webkit).

* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::registerName):
(JSC::CodeBlock::dumpBytecode):
(JSC::CodeBlock::CodeBlock):
(JSC::CodeBlock::createActivation):
(JSC::CodeBlock::nameForRegister):
* bytecode/CodeBlock.h:
(JSC::unmodifiedArgumentsRegister):
(JSC::CodeBlock::isKnownNotImmediate):
(JSC::CodeBlock::setThisRegister):
(JSC::CodeBlock::thisRegister):
(JSC::CodeBlock::setArgumentsRegister):
(JSC::CodeBlock::argumentsRegister):
(JSC::CodeBlock::uncheckedArgumentsRegister):
(JSC::CodeBlock::setActivationRegister):
(JSC::CodeBlock::activationRegister):
(JSC::CodeBlock::uncheckedActivationRegister):
(JSC::CodeBlock::usesArguments):
(JSC::CodeBlock::isCaptured):
* bytecode/Instruction.h:
* bytecode/LazyOperandValueProfile.h:
(JSC::LazyOperandValueProfileKey::LazyOperandValueProfileKey):
(JSC::LazyOperandValueProfileKey::operator!):
(JSC::LazyOperandValueProfileKey::hash):
(JSC::LazyOperandValueProfileKey::operand):
(JSC::LazyOperandValueProfileKey::isHashTableDeletedValue):
(JSC::LazyOperandValueProfile::LazyOperandValueProfile):
* bytecode/MethodOfGettingAValueProfile.cpp:
(JSC::MethodOfGettingAValueProfile::fromLazyOperand):
(JSC::MethodOfGettingAValueProfile::getSpecFailBucket):
* bytecode/Operands.h:
(JSC::localToOperand):
(JSC::operandIsLocal):
(JSC::operandToLocal):
(JSC::operandIsArgument):
(JSC::operandToArgument):
(JSC::argumentToOperand):
(JSC::Operands::operand):
(JSC::Operands::hasOperand):
(JSC::Operands::setOperand):
(JSC::Operands::operandForIndex):
(JSC::Operands::setOperandFirstTime):
* bytecode/UnlinkedCodeBlock.cpp:
(JSC::UnlinkedCodeBlock::UnlinkedCodeBlock):
* bytecode/UnlinkedCodeBlock.h:
(JSC::UnlinkedCodeBlock::setThisRegister):
(JSC::UnlinkedCodeBlock::setActivationRegister):
(JSC::UnlinkedCodeBlock::setArgumentsRegister):
(JSC::UnlinkedCodeBlock::usesArguments):
(JSC::UnlinkedCodeBlock::argumentsRegister):
(JSC::UnlinkedCodeBlock::usesGlobalObject):
(JSC::UnlinkedCodeBlock::setGlobalObjectRegister):
(JSC::UnlinkedCodeBlock::globalObjectRegister):
(JSC::UnlinkedCodeBlock::thisRegister):
(JSC::UnlinkedCodeBlock::activationRegister):
* bytecode/ValueRecovery.h:
(JSC::ValueRecovery::displacedInJSStack):
(JSC::ValueRecovery::virtualRegister):
(JSC::ValueRecovery::dumpInContext):
* bytecode/VirtualRegister.h:
(WTF::printInternal):
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::generate):
(JSC::BytecodeGenerator::addVar):
(JSC::BytecodeGenerator::BytecodeGenerator):
(JSC::BytecodeGenerator::createLazyRegisterIfNecessary):
(JSC::BytecodeGenerator::newRegister):
(JSC::BytecodeGenerator::emitLoadGlobalObject):
(JSC::BytecodeGenerator::emitGetArgumentsLength):
(JSC::BytecodeGenerator::emitGetArgumentByVal):
(JSC::BytecodeGenerator::createArgumentsIfNecessary):
(JSC::BytecodeGenerator::emitReturn):
* bytecompiler/BytecodeGenerator.h:
(JSC::BytecodeGenerator::registerFor):
* bytecompiler/RegisterID.h:
(JSC::RegisterID::RegisterID):
(JSC::RegisterID::setIndex):
(JSC::RegisterID::index):
* debugger/DebuggerCallFrame.cpp:
(JSC::DebuggerCallFrame::thisObject):
* dfg/DFGAbstractHeap.h:
(JSC::DFG::AbstractHeap::Payload::Payload):
* dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::::executeEffects):
(JSC::DFG::::clobberCapturedVars):
* dfg/DFGArgumentPosition.h:
(JSC::DFG::ArgumentPosition::dump):
* dfg/DFGArgumentsSimplificationPhase.cpp:
(JSC::DFG::ArgumentsSimplificationPhase::run):
(JSC::DFG::ArgumentsSimplificationPhase::observeBadArgumentsUse):
(JSC::DFG::ArgumentsSimplificationPhase::isOKToOptimize):
* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::newVariableAccessData):
(JSC::DFG::ByteCodeParser::getDirect):
(JSC::DFG::ByteCodeParser::get):
(JSC::DFG::ByteCodeParser::setDirect):
(JSC::DFG::ByteCodeParser::set):
(JSC::DFG::ByteCodeParser::getLocal):
(JSC::DFG::ByteCodeParser::setLocal):
(JSC::DFG::ByteCodeParser::getArgument):
(JSC::DFG::ByteCodeParser::setArgument):
(JSC::DFG::ByteCodeParser::findArgumentPositionForLocal):
(JSC::DFG::ByteCodeParser::findArgumentPosition):
(JSC::DFG::ByteCodeParser::flush):
(JSC::DFG::ByteCodeParser::flushDirect):
(JSC::DFG::ByteCodeParser::getToInt32):
(JSC::DFG::ByteCodeParser::getThis):
(JSC::DFG::ByteCodeParser::addCall):
(JSC::DFG::ByteCodeParser::InlineStackEntry::remapOperand):
(JSC::DFG::ByteCodeParser::handleCall):
(JSC::DFG::ByteCodeParser::emitFunctionChecks):
(JSC::DFG::ByteCodeParser::emitArgumentPhantoms):
(JSC::DFG::ByteCodeParser::handleInlining):
(JSC::DFG::ByteCodeParser::handleMinMax):
(JSC::DFG::ByteCodeParser::handleIntrinsic):
(JSC::DFG::ByteCodeParser::handleTypedArrayConstructor):
(JSC::DFG::ByteCodeParser::handleConstantInternalFunction):
(JSC::DFG::ByteCodeParser::handleGetByOffset):
(JSC::DFG::ByteCodeParser::handleGetById):
(JSC::DFG::ByteCodeParser::parseBlock):
(JSC::DFG::ByteCodeParser::InlineStackEntry::InlineStackEntry):
(JSC::DFG::ByteCodeParser::parse):
* dfg/DFGCFGSimplificationPhase.cpp:
* dfg/DFGCPSRethreadingPhase.cpp:
(JSC::DFG::CPSRethreadingPhase::canonicalizeGetLocal):
(JSC::DFG::CPSRethreadingPhase::canonicalizeFlushOrPhantomLocal):
(JSC::DFG::CPSRethreadingPhase::canonicalizeSetArgument):
* dfg/DFGCapabilities.cpp:
(JSC::DFG::capabilityLevel):
* dfg/DFGConstantFoldingPhase.cpp:
(JSC::DFG::ConstantFoldingPhase::isCapturedAtOrAfter):
* dfg/DFGFlushLivenessAnalysisPhase.cpp:
(JSC::DFG::FlushLivenessAnalysisPhase::setForNode):
* dfg/DFGGraph.cpp:
(JSC::DFG::Graph::dump):
* dfg/DFGGraph.h:
(JSC::DFG::Graph::argumentsRegisterFor):
(JSC::DFG::Graph::uncheckedArgumentsRegisterFor):
(JSC::DFG::Graph::uncheckedActivationRegisterFor):
(JSC::DFG::Graph::valueProfileFor):
* dfg/DFGJITCode.cpp:
(JSC::DFG::JITCode::reconstruct):
* dfg/DFGNode.h:
(JSC::DFG::Node::Node):
(JSC::DFG::Node::convertToGetLocalUnlinked):
(JSC::DFG::Node::hasVirtualRegister):
(JSC::DFG::Node::virtualRegister):
(JSC::DFG::Node::setVirtualRegister):
* dfg/DFGOSREntry.cpp:
(JSC::DFG::prepareOSREntry):
* dfg/DFGOSREntrypointCreationPhase.cpp:
(JSC::DFG::OSREntrypointCreationPhase::run):
* dfg/DFGOSRExit.h:
* dfg/DFGOSRExitCompiler32_64.cpp:
(JSC::DFG::OSRExitCompiler::compileExit):
* dfg/DFGOSRExitCompiler64.cpp:
(JSC::DFG::OSRExitCompiler::compileExit):
* dfg/DFGRegisterBank.h:
(JSC::DFG::RegisterBank::tryAllocate):
(JSC::DFG::RegisterBank::allocateSpecific):
(JSC::DFG::RegisterBank::retain):
(JSC::DFG::RegisterBank::isInUse):
(JSC::DFG::RegisterBank::dump):
(JSC::DFG::RegisterBank::releaseAtIndex):
(JSC::DFG::RegisterBank::allocateInternal):
(JSC::DFG::RegisterBank::MapEntry::MapEntry):
* dfg/DFGScoreBoard.h:
(JSC::DFG::ScoreBoard::allocate):
(JSC::DFG::ScoreBoard::use):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::SpeculativeJIT):
(JSC::DFG::SpeculativeJIT::checkConsistency):
(JSC::DFG::SpeculativeJIT::compileMovHint):
(JSC::DFG::SpeculativeJIT::compileInlineStart):
(JSC::DFG::SpeculativeJIT::compileCurrentBlock):
* dfg/DFGSpeculativeJIT.h:
(JSC::DFG::SpeculativeJIT::allocate):
(JSC::DFG::SpeculativeJIT::fprAllocate):
(JSC::DFG::SpeculativeJIT::silentSpillAllRegistersImpl):
(JSC::DFG::SpeculativeJIT::flushRegisters):
(JSC::DFG::SpeculativeJIT::isFlushed):
(JSC::DFG::SpeculativeJIT::argumentSlot):
(JSC::DFG::SpeculativeJIT::argumentTagSlot):
(JSC::DFG::SpeculativeJIT::argumentPayloadSlot):
(JSC::DFG::SpeculativeJIT::valueSourceForOperand):
(JSC::DFG::SpeculativeJIT::setNodeForOperand):
(JSC::DFG::SpeculativeJIT::valueSourceReferenceForOperand):
(JSC::DFG::SpeculativeJIT::recordSetLocal):
(JSC::DFG::SpeculativeJIT::generationInfoFromVirtualRegister):
(JSC::DFG::SpeculativeJIT::computeValueRecoveryFor):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* dfg/DFGValidate.cpp:
(JSC::DFG::Validate::validate):
(JSC::DFG::Validate::validateCPS):
(JSC::DFG::Validate::checkOperand):
(JSC::DFG::Validate::reportValidationContext):
* dfg/DFGValueRecoveryOverride.h:
(JSC::DFG::ValueRecoveryOverride::ValueRecoveryOverride):
* dfg/DFGVariableAccessData.h:
(JSC::DFG::VariableAccessData::operand):
(JSC::DFG::VariableAccessData::shouldUseDoubleFormatAccordingToVote):
(JSC::DFG::VariableAccessData::tallyVotesForShouldUseDoubleFormat):
(JSC::DFG::VariableAccessData::flushFormat):
* dfg/DFGVariableEvent.h:
(JSC::DFG::VariableEvent::spill):
(JSC::DFG::VariableEvent::setLocal):
* dfg/DFGVariableEventStream.cpp:
(JSC::DFG::VariableEventStream::reconstruct):
* dfg/DFGVirtualRegisterAllocationPhase.cpp:
(JSC::DFG::VirtualRegisterAllocationPhase::run):
* ftl/FTLExitArgumentForOperand.h:
(JSC::FTL::ExitArgumentForOperand::ExitArgumentForOperand):
(JSC::FTL::ExitArgumentForOperand::operand):
* ftl/FTLLink.cpp:
(JSC::FTL::link):
* ftl/FTLLowerDFGToLLVM.cpp:
(JSC::FTL::LowerDFGToLLVM::LowerDFGToLLVM):
(JSC::FTL::LowerDFGToLLVM::compileGetArgument):
(JSC::FTL::LowerDFGToLLVM::compileExtractOSREntryLocal):
(JSC::FTL::LowerDFGToLLVM::compileCallOrConstruct):
(JSC::FTL::LowerDFGToLLVM::appendOSRExit):
(JSC::FTL::LowerDFGToLLVM::observeMovHint):
(JSC::FTL::LowerDFGToLLVM::addressFor):
(JSC::FTL::LowerDFGToLLVM::payloadFor):
(JSC::FTL::LowerDFGToLLVM::tagFor):
* ftl/FTLOSREntry.cpp:
(JSC::FTL::prepareOSREntry):
* ftl/FTLOSRExit.cpp:
(JSC::FTL::OSRExit::convertToForward):
* ftl/FTLOSRExit.h:
* ftl/FTLOSRExitCompiler.cpp:
(JSC::FTL::compileStub):
* interpreter/CallFrame.h:
* interpreter/Interpreter.cpp:
(JSC::Interpreter::dumpRegisters):
(JSC::unwindCallFrame):
(JSC::Interpreter::unwind):
* jit/AssemblyHelpers.h:
(JSC::AssemblyHelpers::addressFor):
(JSC::AssemblyHelpers::tagFor):
(JSC::AssemblyHelpers::payloadFor):
(JSC::AssemblyHelpers::argumentsRegisterFor):
* jit/JIT.h:
* jit/JITCall.cpp:
(JSC::JIT::compileLoadVarargs):
* jit/JITInlines.h:
(JSC::JIT::emitGetVirtualRegister):
* jit/JITOpcodes.cpp:
(JSC::JIT::emit_op_tear_off_arguments):
(JSC::JIT::emit_op_get_pnames):
(JSC::JIT::emit_op_enter):
(JSC::JIT::emit_op_create_arguments):
(JSC::JIT::emitSlow_op_get_argument_by_val):
* jit/JITOpcodes32_64.cpp:
(JSC::JIT::emit_op_enter):
* jit/JITStubs.cpp:
(JSC::DEFINE_STUB_FUNCTION):
* llint/LLIntSlowPaths.cpp:
(JSC::LLInt::LLINT_SLOW_PATH_DECL):
* profiler/ProfilerBytecodeSequence.cpp:
(JSC::Profiler::BytecodeSequence::BytecodeSequence):
* runtime/CommonSlowPaths.cpp:
(JSC::SLOW_PATH_DECL):
* runtime/JSActivation.cpp:
(JSC::JSActivation::argumentsGetter):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156482 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5a75fb3a
This diff is collapsed.
......@@ -168,12 +168,12 @@ CString CodeBlock::registerName(int r) const
return constantName(r, getConstant(r));
if (operandIsArgument(r)) {
if (!VirtualRegister(r).toArgument())
if (!operandToArgument(r))
return "this";
return toCString("arg", VirtualRegister(r).toArgument());
return toCString("arg", operandToArgument(r));
}
return toCString("loc", VirtualRegister(r).toLocal());
return toCString("loc", operandToLocal(r));
}
static CString regexpToSourceString(RegExp* regExp)
......@@ -514,11 +514,11 @@ void CodeBlock::dumpBytecode(PrintStream& out)
if (usesArguments()) {
out.printf(
"; uses arguments, in r%d, r%d",
argumentsRegister().offset(),
unmodifiedArgumentsRegister(argumentsRegister()).offset());
argumentsRegister(),
unmodifiedArgumentsRegister(argumentsRegister()));
}
if (needsFullScopeChain() && codeType() == FunctionCode)
out.printf("; activation in r%d", activationRegister().offset());
out.printf("; activation in r%d", activationRegister());
out.printf("\n");
const Instruction* begin = instructions().begin();
......@@ -1619,7 +1619,7 @@ CodeBlock::CodeBlock(ScriptExecutable* ownerExecutable, UnlinkedCodeBlock* unlin
setConstantRegisters(unlinkedCodeBlock->constantRegisters());
if (unlinkedCodeBlock->usesGlobalObject())
m_constantRegisters[unlinkedCodeBlock->globalObjectRegister().offset()].set(*m_vm, ownerExecutable, m_globalObject.get());
m_constantRegisters[unlinkedCodeBlock->globalObjectRegister()].set(*m_vm, ownerExecutable, m_globalObject.get());
m_functionDecls.grow(unlinkedCodeBlock->numberOfFunctionDecls());
for (size_t count = unlinkedCodeBlock->numberOfFunctionDecls(), i = 0; i < count; ++i) {
UnlinkedFunctionExecutable* unlinkedExecutable = unlinkedCodeBlock->functionDecl(i);
......@@ -2557,9 +2557,9 @@ void CodeBlock::createActivation(CallFrame* callFrame)
{
ASSERT(codeType() == FunctionCode);
ASSERT(needsFullScopeChain());
ASSERT(!callFrame->uncheckedR(activationRegister().offset()).jsValue());
ASSERT(!callFrame->uncheckedR(activationRegister()).jsValue());
JSActivation* activation = JSActivation::create(callFrame->vm(), callFrame, this);
callFrame->uncheckedR(activationRegister().offset()) = JSValue(activation);
callFrame->uncheckedR(activationRegister()) = JSValue(activation);
callFrame->setScope(activation);
}
......@@ -3327,30 +3327,32 @@ bool CodeBlock::usesOpcode(OpcodeID opcodeID)
return false;
}
String CodeBlock::nameForRegister(VirtualRegister virtualRegister)
String CodeBlock::nameForRegister(int registerNumber)
{
ConcurrentJITLocker locker(symbolTable()->m_lock);
SymbolTable::Map::iterator end = symbolTable()->end(locker);
for (SymbolTable::Map::iterator ptr = symbolTable()->begin(locker); ptr != end; ++ptr) {
if (ptr->value.getIndex() == virtualRegister.offset()) {
if (ptr->value.getIndex() == registerNumber) {
// FIXME: This won't work from the compilation thread.
// https://bugs.webkit.org/show_bug.cgi?id=115300
return String(ptr->key);
}
}
if (needsActivation() && virtualRegister == activationRegister())
if (needsActivation() && registerNumber == activationRegister())
return ASCIILiteral("activation");
if (virtualRegister == thisRegister())
if (registerNumber == thisRegister())
return ASCIILiteral("this");
if (usesArguments()) {
if (virtualRegister == argumentsRegister())
if (registerNumber == argumentsRegister())
return ASCIILiteral("arguments");
if (unmodifiedArgumentsRegister(argumentsRegister()) == virtualRegister)
if (unmodifiedArgumentsRegister(argumentsRegister()) == registerNumber)
return ASCIILiteral("real arguments");
}
if (virtualRegister.isArgument())
return String::format("arguments[%3d]", virtualRegister.toArgument()).impl();
if (registerNumber < 0) {
int argumentPosition = -registerNumber;
argumentPosition -= JSStack::CallFrameHeaderSize + 1;
return String::format("arguments[%3d]", argumentPosition - 1).impl();
}
return "";
}
......
......@@ -71,7 +71,6 @@
#include "StructureStubInfo.h"
#include "UnconditionalFinalizer.h"
#include "ValueProfile.h"
#include "VirtualRegister.h"
#include "Watchpoint.h"
#include <wtf/FastMalloc.h>
#include <wtf/PassOwnPtr.h>
......@@ -87,7 +86,7 @@ class ExecState;
class LLIntOffsetsExtractor;
class RepatchBuffer;
inline VirtualRegister unmodifiedArgumentsRegister(VirtualRegister argumentsRegister) { return VirtualRegister(argumentsRegister.offset() + 1); }
inline int unmodifiedArgumentsRegister(int argumentsRegister) { return argumentsRegister + 1; }
static ALWAYS_INLINE int missingThisObjectMarker() { return std::numeric_limits<int>::max(); }
......@@ -149,7 +148,7 @@ public:
inline bool isKnownNotImmediate(int index)
{
if (index == m_thisRegister.offset() && !m_isStrictMode)
if (index == m_thisRegister && !m_isStrictMode)
return true;
if (isConstantRegisterIndex(index))
......@@ -299,61 +298,58 @@ public:
void setVM(VM* vm) { m_vm = vm; }
VM* vm() { return m_vm; }
void setThisRegister(VirtualRegister thisRegister) { m_thisRegister = thisRegister; }
VirtualRegister thisRegister() const { return m_thisRegister; }
void setThisRegister(int thisRegister) { m_thisRegister = thisRegister; }
int thisRegister() const { return m_thisRegister; }
bool needsFullScopeChain() const { return m_unlinkedCode->needsFullScopeChain(); }
bool usesEval() const { return m_unlinkedCode->usesEval(); }
void setArgumentsRegister(VirtualRegister argumentsRegister)
void setArgumentsRegister(int argumentsRegister)
{
ASSERT(argumentsRegister.isValid());
ASSERT(argumentsRegister != (int)InvalidVirtualRegister);
m_argumentsRegister = argumentsRegister;
ASSERT(usesArguments());
}
VirtualRegister argumentsRegister() const
int argumentsRegister() const
{
ASSERT(usesArguments());
return m_argumentsRegister;
}
VirtualRegister uncheckedArgumentsRegister()
int uncheckedArgumentsRegister()
{
if (!usesArguments())
return VirtualRegister();
return InvalidVirtualRegister;
return argumentsRegister();
}
void setActivationRegister(VirtualRegister activationRegister)
void setActivationRegister(int activationRegister)
{
m_activationRegister = activationRegister;
}
VirtualRegister activationRegister() const
int activationRegister() const
{
ASSERT(needsFullScopeChain());
return m_activationRegister;
}
VirtualRegister uncheckedActivationRegister()
int uncheckedActivationRegister()
{
if (!needsFullScopeChain())
return VirtualRegister();
return InvalidVirtualRegister;
return activationRegister();
}
bool usesArguments() const { return m_argumentsRegister.isValid(); }
bool usesArguments() const { return m_argumentsRegister != (int)InvalidVirtualRegister; }
bool needsActivation() const
{
return m_needsActivation;
}
bool isCaptured(VirtualRegister operand, InlineCallFrame* inlineCallFrame = 0) const
bool isCaptured(int operand, InlineCallFrame* inlineCallFrame = 0) const
{
if (operand.isArgument())
return operand.toArgument() && usesArguments();
if (operandIsArgument(operand))
return operandToArgument(operand) && usesArguments();
if (inlineCallFrame)
return inlineCallFrame->capturedVars.get(operand.toLocal());
return inlineCallFrame->capturedVars.get(operandToLocal(operand));
// The activation object isn't in the captured region, but it's "captured"
// in the sense that stores to its location can be observed indirectly.
......@@ -372,8 +368,8 @@ public:
if (!symbolTable())
return false;
return operand.offset() <= symbolTable()->captureStart()
&& operand.offset() > symbolTable()->captureEnd();
return operand <= symbolTable()->captureStart()
&& operand > symbolTable()->captureEnd();
}
CodeType codeType() const { return m_unlinkedCode->codeType(); }
......@@ -395,7 +391,7 @@ public:
void clearEvalCache();
String nameForRegister(VirtualRegister);
String nameForRegister(int registerNumber);
#if ENABLE(JIT)
void setNumberOfStructureStubInfos(size_t size) { m_structureStubInfos.grow(size); }
......@@ -1031,9 +1027,9 @@ private:
VM* m_vm;
RefCountedArray<Instruction> m_instructions;
VirtualRegister m_thisRegister;
VirtualRegister m_argumentsRegister;
VirtualRegister m_activationRegister;
int m_thisRegister;
int m_argumentsRegister;
int m_activationRegister;
bool m_isStrictMode;
bool m_needsActivation;
......
......@@ -35,7 +35,6 @@
#include "SpecialPointer.h"
#include "Structure.h"
#include "StructureChain.h"
#include "VirtualRegister.h"
#include <wtf/VectorTraits.h>
namespace JSC {
......
......@@ -46,26 +46,26 @@ class LazyOperandValueProfileKey {
public:
LazyOperandValueProfileKey()
: m_bytecodeOffset(0) // 0 = empty value
, m_operand(VirtualRegister()) // not a valid operand index in our current scheme
, m_operand(InvalidVirtualRegister) // not a valid operand index in our current scheme
{
}
LazyOperandValueProfileKey(WTF::HashTableDeletedValueType)
: m_bytecodeOffset(1) // 1 = deleted value
, m_operand(VirtualRegister()) // not a valid operand index in our current scheme
, m_operand(InvalidVirtualRegister) // not a valid operand index in our current scheme
{
}
LazyOperandValueProfileKey(unsigned bytecodeOffset, VirtualRegister operand)
LazyOperandValueProfileKey(unsigned bytecodeOffset, int operand)
: m_bytecodeOffset(bytecodeOffset)
, m_operand(operand)
{
ASSERT(m_operand.isValid());
ASSERT(operand != InvalidVirtualRegister);
}
bool operator!() const
{
return !m_operand.isValid();
return m_operand == InvalidVirtualRegister;
}
bool operator==(const LazyOperandValueProfileKey& other) const
......@@ -76,7 +76,7 @@ public:
unsigned hash() const
{
return WTF::intHash(m_bytecodeOffset) + m_operand.offset();
return WTF::intHash(m_bytecodeOffset) + m_operand;
}
unsigned bytecodeOffset() const
......@@ -84,8 +84,7 @@ public:
ASSERT(!!*this);
return m_bytecodeOffset;
}
VirtualRegister operand() const
int operand() const
{
ASSERT(!!*this);
return m_operand;
......@@ -93,11 +92,11 @@ public:
bool isHashTableDeletedValue() const
{
return !m_operand.isValid() && m_bytecodeOffset;
return m_operand == InvalidVirtualRegister && m_bytecodeOffset;
}
private:
unsigned m_bytecodeOffset;
VirtualRegister m_operand;
int m_operand;
};
struct LazyOperandValueProfileKeyHash {
......@@ -130,7 +129,7 @@ namespace JSC {
struct LazyOperandValueProfile : public MinimalValueProfile {
LazyOperandValueProfile()
: MinimalValueProfile()
, m_operand(VirtualRegister())
, m_operand(InvalidVirtualRegister)
{
}
......@@ -145,7 +144,7 @@ struct LazyOperandValueProfile : public MinimalValueProfile {
return LazyOperandValueProfileKey(m_bytecodeOffset, m_operand);
}
VirtualRegister m_operand;
int m_operand;
typedef SegmentedVector<LazyOperandValueProfile, 8> List;
};
......
......@@ -39,7 +39,7 @@ MethodOfGettingAValueProfile MethodOfGettingAValueProfile::fromLazyOperand(
result.m_kind = LazyOperand;
result.u.lazyOperand.codeBlock = codeBlock;
result.u.lazyOperand.bytecodeOffset = key.bytecodeOffset();
result.u.lazyOperand.operand = key.operand().offset();
result.u.lazyOperand.operand = key.operand();
return result;
}
......@@ -53,7 +53,7 @@ EncodedJSValue* MethodOfGettingAValueProfile::getSpecFailBucket(unsigned index)
return u.profile->specFailBucket(index);
case LazyOperand: {
LazyOperandValueProfileKey key(u.lazyOperand.bytecodeOffset, VirtualRegister(u.lazyOperand.operand));
LazyOperandValueProfileKey key(u.lazyOperand.bytecodeOffset, u.lazyOperand.operand);
ConcurrentJITLocker locker(u.lazyOperand.codeBlock->m_lock);
LazyOperandValueProfile* profile =
......
......@@ -28,13 +28,20 @@
#include "CallFrame.h"
#include "JSObject.h"
#include "VirtualRegister.h"
#include <wtf/PrintStream.h>
#include <wtf/Vector.h>
namespace JSC {
inline int localToOperand(int local) { return -local; }
inline bool operandIsLocal(int operand) { return operand <= 0; }
inline int operandToLocal(int operand) { return -operand; }
// argument 0 is 'this'.
inline bool operandIsArgument(int operand) { return operand > 0; }
inline int operandToArgument(int operand) { return operand - CallFrame::thisArgumentOffset(); }
inline int argumentToOperand(int argument) { return argument + CallFrame::thisArgumentOffset(); }
template<typename T> struct OperandValueTraits;
template<typename T>
......@@ -136,43 +143,33 @@ public:
T& operand(int operand)
{
if (operandIsArgument(operand)) {
int argument = VirtualRegister(operand).toArgument();
int argument = operandToArgument(operand);
return m_arguments[argument];
}
return m_locals[VirtualRegister(operand).toLocal()];
}
T& operand(VirtualRegister virtualRegister)
{
return operand(virtualRegister.offset());
return m_locals[operandToLocal(operand)];
}
const T& operand(int operand) const { return const_cast<const T&>(const_cast<Operands*>(this)->operand(operand)); }
bool hasOperand(int operand) const
{
if (operandIsArgument(operand))
return true;
return static_cast<size_t>(VirtualRegister(operand).toLocal()) < numberOfLocals();
return static_cast<size_t>(operandToLocal(operand)) < numberOfLocals();
}
void setOperand(int operand, const T& value)
{
if (operandIsArgument(operand)) {
int argument = VirtualRegister(operand).toArgument();
int argument = operandToArgument(operand);
m_arguments[argument] = value;
return;
}
setLocal(VirtualRegister(operand).toLocal(), value);
setLocal(operandToLocal(operand), value);
}
void setOperand(VirtualRegister virtualRegister, const T& value)
{
setOperand(virtualRegister.offset(), value);
}
size_t size() const { return numberOfArguments() + numberOfLocals(); }
const T& at(size_t index) const
{
......@@ -202,18 +199,18 @@ public:
int operandForIndex(size_t index) const
{
if (index < numberOfArguments())
return virtualRegisterForArgument(index).offset();
return virtualRegisterForLocal(index - numberOfArguments()).offset();
return argumentToOperand(index);
return localToOperand(index - numberOfArguments());
}
void setOperandFirstTime(int operand, const T& value)
{
if (operandIsArgument(operand)) {
setArgumentFirstTime(VirtualRegister(operand).toArgument(), value);
setArgumentFirstTime(operandToArgument(operand), value);
return;
}
setLocalFirstTime(VirtualRegister(operand).toLocal(), value);
setLocalFirstTime(operandToLocal(operand), value);
}
void fill(T value)
......
......@@ -194,8 +194,8 @@ UnlinkedCodeBlock::UnlinkedCodeBlock(VM* vm, Structure* structure, CodeType code
, m_numCalleeRegisters(0)
, m_numParameters(0)
, m_vm(vm)
, m_argumentsRegister(VirtualRegister())
, m_globalObjectRegister(VirtualRegister())
, m_argumentsRegister((int)InvalidVirtualRegister)
, m_globalObjectRegister((int)InvalidVirtualRegister)
, m_needsFullScopeChain(info.m_needsActivation)
, m_usesEval(info.m_usesEval)
, m_isNumericCompareFunction(false)
......
......@@ -254,17 +254,17 @@ public:
bool hasExpressionInfo() { return m_expressionInfo.size(); }
// Special registers
void setThisRegister(VirtualRegister thisRegister) { m_thisRegister = thisRegister; }
void setActivationRegister(VirtualRegister activationRegister) { m_activationRegister = activationRegister; }
void setThisRegister(int thisRegister) { m_thisRegister = thisRegister; }
void setActivationRegister(int activationRegister) { m_activationRegister = activationRegister; }
void setArgumentsRegister(VirtualRegister argumentsRegister) { m_argumentsRegister = argumentsRegister; }
bool usesArguments() const { return m_argumentsRegister.isValid(); }
VirtualRegister argumentsRegister() const { return m_argumentsRegister; }
void setArgumentsRegister(int argumentsRegister) { m_argumentsRegister = argumentsRegister; }
bool usesArguments() const { return m_argumentsRegister != (int)InvalidVirtualRegister; }
int argumentsRegister() const { return m_argumentsRegister; }
bool usesGlobalObject() const { return m_globalObjectRegister.isValid(); }
void setGlobalObjectRegister(VirtualRegister globalObjectRegister) { m_globalObjectRegister = globalObjectRegister; }
VirtualRegister globalObjectRegister() const { return m_globalObjectRegister; }
bool usesGlobalObject() const { return m_globalObjectRegister != (int)InvalidVirtualRegister; }
void setGlobalObjectRegister(int globalObjectRegister) { m_globalObjectRegister = globalObjectRegister; }
int globalObjectRegister() const { return m_globalObjectRegister; }
// Parameter information
void setNumParameters(int newValue) { m_numParameters = newValue; }
......@@ -399,8 +399,8 @@ public:
CodeType codeType() const { return m_codeType; }
VirtualRegister thisRegister() const { return m_thisRegister; }
VirtualRegister activationRegister() const { return m_activationRegister; }
int thisRegister() const { return m_thisRegister; }
int activationRegister() const { return m_activationRegister; }
void addPropertyAccessInstruction(unsigned propertyAccessInstruction)
......@@ -479,10 +479,10 @@ private:
int m_numParameters;
VM* m_vm;
VirtualRegister m_thisRegister;
VirtualRegister m_argumentsRegister;
VirtualRegister m_activationRegister;
VirtualRegister m_globalObjectRegister;
int m_thisRegister;
int m_argumentsRegister;
int m_activationRegister;
int m_globalObjectRegister;
bool m_needsFullScopeChain : 1;
bool m_usesEval : 1;
......
......@@ -211,7 +211,7 @@ public:
result.m_technique = DisplacedInJSStack;
break;
}
result.m_source.virtualReg = virtualReg.offset();
result.m_source.virtualReg = virtualReg;
return result;
}
......@@ -294,7 +294,7 @@ public:
VirtualRegister virtualRegister() const
{
ASSERT(m_technique == DisplacedInJSStack || m_technique == Int32DisplacedInJSStack || m_technique == DoubleDisplacedInJSStack || m_technique == CellDisplacedInJSStack || m_technique == BooleanDisplacedInJSStack || m_technique == Int52DisplacedInJSStack || m_technique == StrictInt52DisplacedInJSStack);
return VirtualRegister(m_source.virtualReg);
return m_source.virtualReg;
}
JSValue constant() const
......@@ -351,25 +351,25 @@ public:
return;
#endif
case DisplacedInJSStack:
out.printf("*%d", virtualRegister().offset());
out.printf("*%d", virtualRegister());
return;
case Int32DisplacedInJSStack:
out.printf("*int32(%d)", virtualRegister().offset());
out.printf("*int32(%d)", virtualRegister());
return;
case Int52DisplacedInJSStack:
out.printf("*int52(%d)", virtualRegister().offset());
out.printf("*int52(%d)", virtualRegister());
return;
case StrictInt52DisplacedInJSStack:
out.printf("*strictInt52(%d)", virtualRegister().offset());
out.printf("*strictInt52(%d)", virtualRegister());
return;
case DoubleDisplacedInJSStack:
out.printf("*double(%d)", virtualRegister().offset());
out.printf("*double(%d)", virtualRegister());
return;
case CellDisplacedInJSStack:
out.printf("*cell(%d)", virtualRegister().offset());
out.printf("*cell(%d)", virtualRegister());
return;
case BooleanDisplacedInJSStack:
out.printf("*bool(%d)", virtualRegister().offset());
out.printf("*bool(%d)", virtualRegister());
return;
case ArgumentsThatWereNotCreated:
out.printf("arguments");
......@@ -400,7 +400,7 @@ private:
MacroAssembler::RegisterID payloadGPR;
} pair;
#endif
int virtualReg;
VirtualRegister virtualReg;
EncodedJSValue constant;
} m_source;
};
......
......@@ -26,80 +26,23 @@
#ifndef VirtualRegister_h
#define VirtualRegister_h
#include "CallFrame.h"
#include <wtf/Platform.h>
#include <wtf/PrintStream.h>
namespace JSC {
inline bool operandIsLocal(int operand)
{
return operand <= 0;
}
inline bool operandIsArgument(int operand)
{
return operand > 0;
}
class VirtualRegister {
public:
friend VirtualRegister virtualRegisterForLocal(int);
friend VirtualRegister virtualRegisterForArgument(int, int);
VirtualRegister()
: m_virtualRegister(s_invalidVirtualRegister)
{ }
explicit VirtualRegister(int virtualRegister)
: m_virtualRegister(virtualRegister)
{ }
bool isValid() const { return (m_virtualRegister != s_invalidVirtualRegister); }
bool isLocal() const { return operandIsLocal(m_virtualRegister); }
bool isArgument() const { return operandIsArgument(m_virtualRegister); }
bool isConstant() const { return m_virtualRegister >= s_firstConstantRegisterIndex; }
int toLocal() const { ASSERT(isLocal()); return operandToLocal(m_virtualRegister); }
int toArgument() const { ASSERT(isArgument()); return operandToArgument(m_virtualRegister); }
int toConstantIndex() const { ASSERT(isConstant()); return m_virtualRegister - s_firstConstantRegisterIndex; }
int offset() const { return m_virtualRegister; }
bool operator==(const VirtualRegister other) const { return m_virtualRegister == other.m_virtualRegister; }
bool operator!=(const VirtualRegister other) const { return m_virtualRegister != other.m_virtualRegister; }
private:
static const int s_invalidVirtualRegister = 0x3fffffff;
static const int s_firstConstantRegisterIndex = 0x40000000;
static int localToOperand(int local) { return -local; }
static int operandToLocal(int operand) { return -operand; }
static int operandToArgument(int operand) { return operand - CallFrame::thisArgumentOffset(); }
static int argumentToOperand(int argument) { return argument + CallFrame::thisArgumentOffset(); }
int m_virtualRegister;
};
// Type for a virtual register number (spill location).
// Using an enum to make this type-checked at compile time, to avert programmer errors.
enum VirtualRegister { InvalidVirtualRegister = 0x3fffffff };
COMPILE_ASSERT(sizeof(VirtualRegister) == sizeof(int), VirtualRegister_is_32bit);