diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-09-10 19:10:20 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-09-10 19:10:20 +0200 |
commit | 284837daa07b29d6a63a748544a90b1f5842ac5c (patch) | |
tree | ecd258180bde91fe741e0cfd2638beb3c6da7e8e /Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp | |
parent | 2e2ba8ff45915f40ed3e014101269c175f2a89a0 (diff) | |
download | qtwebkit-284837daa07b29d6a63a748544a90b1f5842ac5c.tar.gz |
Imported WebKit commit 68645295d2e3e09af2c942f092556f06aa5f8b0d (http://svn.webkit.org/repository/webkit/trunk@128073)
New snapshot
Diffstat (limited to 'Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp')
-rw-r--r-- | Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp | 64 |
1 files changed, 39 insertions, 25 deletions
diff --git a/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp b/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp index f9b1db9ab..b96b8d9a3 100644 --- a/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp +++ b/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp @@ -71,6 +71,7 @@ public: , m_inlineStackTop(0) , m_haveBuiltOperandMaps(false) , m_emptyJSValueIndex(UINT_MAX) + , m_currentInstruction(0) { ASSERT(m_profiledBlock); @@ -141,6 +142,9 @@ private: return getJSConstant(constant); } + if (operand == RegisterFile::Callee) + return getCallee(); + // Is this an argument? if (operandIsArgument(operand)) return getArgument(operand); @@ -364,11 +368,11 @@ private: InlineCallFrame* inlineCallFrame = stack->m_inlineCallFrame; if (!inlineCallFrame) break; - if (operand >= inlineCallFrame->stackOffset - RegisterFile::CallFrameHeaderSize) + if (operand >= static_cast<int>(inlineCallFrame->stackOffset - RegisterFile::CallFrameHeaderSize)) continue; if (operand == inlineCallFrame->stackOffset + CallFrame::thisArgumentOffset()) continue; - if (static_cast<unsigned>(operand) < inlineCallFrame->stackOffset - RegisterFile::CallFrameHeaderSize - inlineCallFrame->arguments.size()) + if (operand < static_cast<int>(inlineCallFrame->stackOffset - RegisterFile::CallFrameHeaderSize - inlineCallFrame->arguments.size())) continue; int argument = operandToArgument(operand - inlineCallFrame->stackOffset); return stack->m_argumentPositions[argument]; @@ -520,6 +524,11 @@ private: return resultIndex; } + NodeIndex getCallee() + { + return addToGraph(GetCallee); + } + // Helper functions to get/set the this value. NodeIndex getThis() { @@ -818,9 +827,14 @@ private: return getPrediction(m_graph.size(), m_currentProfilingIndex); } - Array::Mode getArrayModeWithoutOSRExit(Instruction* currentInstruction, NodeIndex base) + Array::Mode getArrayMode(ArrayProfile* profile) + { + profile->computeUpdatedPrediction(); + return fromObserved(profile->observedArrayModes(), false); + } + + Array::Mode getArrayModeAndEmitChecks(ArrayProfile* profile, NodeIndex base) { - ArrayProfile* profile = currentInstruction[4].u.arrayProfile; profile->computeUpdatedPrediction(); if (profile->hasDefiniteStructure()) addToGraph(CheckStructure, OpInfo(m_graph.addStructureSet(profile->expectedStructure())), base); @@ -838,16 +852,6 @@ private: return fromObserved(profile->observedArrayModes(), makeSafe); } - Array::Mode getArrayMode(Instruction* currentInstruction, NodeIndex base) - { - Array::Mode result = getArrayModeWithoutOSRExit(currentInstruction, base); - - if (result == Array::ForceExit) - addToGraph(ForceOSRExit); - - return result; - } - NodeIndex makeSafe(NodeIndex nodeIndex) { Node& node = m_graph[nodeIndex]; @@ -1130,7 +1134,10 @@ private: ASSERT(result >= FirstConstantRegisterIndex); return result; } - + + if (operand == RegisterFile::Callee) + return m_calleeVR; + return operand + m_inlineCallFrame->stackOffset; } }; @@ -1150,6 +1157,8 @@ private: // Cache of code blocks that we've generated bytecode for. ByteCodeCache<canInlineFunctionFor> m_codeBlockCache; + + Instruction* m_currentInstruction; }; #define NEXT_OPCODE(name) \ @@ -1553,7 +1562,10 @@ bool ByteCodeParser::handleIntrinsic(bool usesResult, int resultOperand, Intrins if (argumentCountIncludingThis != 2) return false; - NodeIndex arrayPush = addToGraph(ArrayPush, OpInfo(0), OpInfo(prediction), get(registerOffset + argumentToOperand(0)), get(registerOffset + argumentToOperand(1))); + Array::Mode arrayMode = getArrayMode(m_currentInstruction[5].u.arrayProfile); + if (!modeIsJSArray(arrayMode)) + return false; + NodeIndex arrayPush = addToGraph(ArrayPush, OpInfo(arrayMode), OpInfo(prediction), get(registerOffset + argumentToOperand(0)), get(registerOffset + argumentToOperand(1))); if (usesResult) set(resultOperand, arrayPush); @@ -1564,7 +1576,10 @@ bool ByteCodeParser::handleIntrinsic(bool usesResult, int resultOperand, Intrins if (argumentCountIncludingThis != 1) return false; - NodeIndex arrayPop = addToGraph(ArrayPop, OpInfo(0), OpInfo(prediction), get(registerOffset + argumentToOperand(0))); + Array::Mode arrayMode = getArrayMode(m_currentInstruction[5].u.arrayProfile); + if (!modeIsJSArray(arrayMode)) + return false; + NodeIndex arrayPop = addToGraph(ArrayPop, OpInfo(arrayMode), OpInfo(prediction), get(registerOffset + argumentToOperand(0))); if (usesResult) set(resultOperand, arrayPop); return true; @@ -1792,6 +1807,7 @@ bool ByteCodeParser::parseBlock(unsigned limit) // Switch on the current bytecode opcode. Instruction* currentInstruction = instructionsBegin + m_currentIndex; + m_currentInstruction = currentInstruction; // Some methods want to use this, and we'd rather not thread it through calls. OpcodeID opcodeID = interpreter->getOpcodeID(currentInstruction->u.opcode); switch (opcodeID) { @@ -1830,10 +1846,7 @@ bool ByteCodeParser::parseBlock(unsigned limit) } case op_create_this: { - if (m_inlineStackTop->m_inlineCallFrame) - set(currentInstruction[1].u.operand, addToGraph(CreateThis, getDirect(m_inlineStackTop->m_calleeVR))); - else - set(currentInstruction[1].u.operand, addToGraph(CreateThis, addToGraph(GetCallee))); + set(currentInstruction[1].u.operand, addToGraph(CreateThis, get(RegisterFile::Callee))); NEXT_OPCODE(op_create_this); } @@ -2177,7 +2190,7 @@ bool ByteCodeParser::parseBlock(unsigned limit) SpeculatedType prediction = getPrediction(); NodeIndex base = get(currentInstruction[2].u.operand); - Array::Mode arrayMode = getArrayMode(currentInstruction, base); + Array::Mode arrayMode = getArrayModeAndEmitChecks(currentInstruction[4].u.arrayProfile, base); NodeIndex property = get(currentInstruction[3].u.operand); NodeIndex getByVal = addToGraph(GetByVal, OpInfo(arrayMode), OpInfo(prediction), base, property); set(currentInstruction[1].u.operand, getByVal); @@ -2188,7 +2201,7 @@ bool ByteCodeParser::parseBlock(unsigned limit) case op_put_by_val: { NodeIndex base = get(currentInstruction[1].u.operand); - Array::Mode arrayMode = getArrayMode(currentInstruction, base); + Array::Mode arrayMode = getArrayModeAndEmitChecks(currentInstruction[4].u.arrayProfile, base); NodeIndex property = get(currentInstruction[2].u.operand); NodeIndex value = get(currentInstruction[3].u.operand); @@ -2196,6 +2209,7 @@ bool ByteCodeParser::parseBlock(unsigned limit) addVarArgChild(base); addVarArgChild(property); addVarArgChild(value); + addVarArgChild(NoNode); // Leave room for property storage. addToGraph(Node::VarArg, PutByVal, OpInfo(arrayMode), OpInfo(0)); NEXT_OPCODE(op_put_by_val); @@ -2406,7 +2420,7 @@ bool ByteCodeParser::parseBlock(unsigned limit) unsigned identifierNumber = m_inlineStackTop->m_identifierRemap[currentInstruction[3].u.operand]; Identifier identifier = m_codeBlock->identifier(identifierNumber); - SymbolTableEntry entry = globalObject->symbolTable().get(identifier.impl()); + SymbolTableEntry entry = globalObject->symbolTable()->get(identifier.impl()); if (!entry.couldBeWatched()) { NodeIndex getGlobalVar = addToGraph( GetGlobalVar, @@ -2459,7 +2473,7 @@ bool ByteCodeParser::parseBlock(unsigned limit) JSGlobalObject* globalObject = codeBlock->globalObject(); unsigned identifierNumber = m_inlineStackTop->m_identifierRemap[currentInstruction[4].u.operand]; Identifier identifier = m_codeBlock->identifier(identifierNumber); - SymbolTableEntry entry = globalObject->symbolTable().get(identifier.impl()); + SymbolTableEntry entry = globalObject->symbolTable()->get(identifier.impl()); if (!entry.couldBeWatched()) { addToGraph( PutGlobalVar, |