Diff
Modified: branches/dfgFourthTier/Source/_javascript_Core/ChangeLog (151328 => 151329)
--- branches/dfgFourthTier/Source/_javascript_Core/ChangeLog 2013-06-07 18:20:09 UTC (rev 151328)
+++ branches/dfgFourthTier/Source/_javascript_Core/ChangeLog 2013-06-07 18:23:03 UTC (rev 151329)
@@ -1,3 +1,48 @@
+2013-06-07 Mark Lam <[email protected]>
+
+ 32-bit CallFrame::Location should use Instruction* for BytecodeLocation, not bytecodeOffset.
+ https://bugs.webkit.org/show_bug.cgi?id=117327.
+
+ Reviewed by Michael Saboff.
+
+ - Renamed CallFrame::Location's Type to TypeTag.
+ - Made the CallFrame::Location::TypeTag private, and provided type
+ specific encoder functions. This reduces verbosity in client code.
+ - Fixed the DFG's reifyInlinedCallFrames() on 32-bit ports to store a
+ bytecode Instruction* in the CallFrame location instead of a bytecode
+ offset.
+ - Fixed places in JIT and FTL code which populate the CallFrame location
+ (i.e. ArgumentCount tag) to use a Location encoder instead of storing
+ the bytecodeOffset directly. This doesn't make any semantic difference,
+ but it does assert that the stored value does not have bits where we
+ would expect Location TypeTags to be.
+
+ * dfg/DFGJITCompiler.h:
+ (JSC::DFG::JITCompiler::beginCall):
+ * dfg/DFGOSRExitCompilerCommon.cpp:
+ (JSC::DFG::reifyInlinedCallFrames):
+ * ftl/FTLLink.cpp:
+ (JSC::FTL::link):
+ * interpreter/CallFrame.cpp:
+ (JSC::CallFrame::setLocationAsBytecodeOffset):
+ * interpreter/CallFrame.h:
+ (Location):
+ * interpreter/CallFrameInlines.h:
+ (JSC::CallFrame::Location::encodeAsBytecodeOffset):
+ (JSC::CallFrame::Location::encodeAsBytecodeInstruction):
+ (JSC::CallFrame::Location::encodeAsCodeOriginIndex):
+ (JSC::CallFrame::Location::encodeAsInlinedCode):
+ (JSC::CallFrame::Location::isBytecodeLocation):
+ (JSC::CallFrame::setIsInlinedFrame):
+ (JSC::CallFrame::hasLocationAsBytecodeOffset):
+ (JSC::CallFrame::setLocationAsBytecodeOffset):
+ * jit/JITCall.cpp:
+ (JSC::JIT::compileOpCall):
+ * jit/JITCall32_64.cpp:
+ (JSC::JIT::compileOpCall):
+ * jit/JITInlines.h:
+ (JSC::JIT::updateTopCallFrame):
+
2013-06-06 Filip Pizlo <[email protected]>
fourthTier: Reenable the DFG optimization fixpoint now that it's profitable to do so with concurrent compilation
Modified: branches/dfgFourthTier/Source/_javascript_Core/dfg/DFGJITCompiler.h (151328 => 151329)
--- branches/dfgFourthTier/Source/_javascript_Core/dfg/DFGJITCompiler.h 2013-06-07 18:20:09 UTC (rev 151328)
+++ branches/dfgFourthTier/Source/_javascript_Core/dfg/DFGJITCompiler.h 2013-06-07 18:23:03 UTC (rev 151329)
@@ -314,7 +314,7 @@
void beginCall(CodeOrigin codeOrigin, CallBeginToken& token)
{
unsigned index = m_exceptionChecks.size();
- unsigned locationBits = CallFrame::Location::encode(CallFrame::Location::CodeOriginIndex, index);
+ unsigned locationBits = CallFrame::Location::encodeAsCodeOriginIndex(index);
store32(TrustedImm32(locationBits), tagFor(static_cast<VirtualRegister>(JSStack::ArgumentCount)));
token.set(codeOrigin, index);
}
Modified: branches/dfgFourthTier/Source/_javascript_Core/dfg/DFGOSRExitCompilerCommon.cpp (151328 => 151329)
--- branches/dfgFourthTier/Source/_javascript_Core/dfg/DFGOSRExitCompilerCommon.cpp 2013-06-07 18:20:09 UTC (rev 151328)
+++ branches/dfgFourthTier/Source/_javascript_Core/dfg/DFGOSRExitCompilerCommon.cpp 2013-06-07 18:23:03 UTC (rev 151329)
@@ -102,6 +102,8 @@
jit.store64(AssemblyHelpers::TrustedImm64(JSValue::encode(JSValue(inlineCallFrame->callee->scope()))), AssemblyHelpers::addressFor((VirtualRegister)(inlineCallFrame->stackOffset + JSStack::ScopeChain)));
jit.store64(callerFrameGPR, AssemblyHelpers::addressFor((VirtualRegister)(inlineCallFrame->stackOffset + JSStack::CallerFrame)));
jit.storePtr(AssemblyHelpers::TrustedImmPtr(jumpTarget), AssemblyHelpers::addressFor((VirtualRegister)(inlineCallFrame->stackOffset + JSStack::ReturnPC)));
+ uint32_t locationBits = CallFrame::Location::encodeAsBytecodeOffset(codeOrigin.bytecodeIndex);
+ jit.store32(AssemblyHelpers::TrustedImm32(locationBits), AssemblyHelpers::tagFor((VirtualRegister)(inlineCallFrame->stackOffset + JSStack::ArgumentCount)));
jit.store32(AssemblyHelpers::TrustedImm32(inlineCallFrame->arguments.size()), AssemblyHelpers::payloadFor((VirtualRegister)(inlineCallFrame->stackOffset + JSStack::ArgumentCount)));
if (!inlineCallFrame->isClosureCall())
jit.store64(AssemblyHelpers::TrustedImm64(JSValue::encode(JSValue(inlineCallFrame->callee.get()))), AssemblyHelpers::addressFor((VirtualRegister)(inlineCallFrame->stackOffset + JSStack::Callee)));
@@ -120,16 +122,23 @@
jit.store32(AssemblyHelpers::TrustedImm32(JSValue::CellTag), AssemblyHelpers::tagFor((VirtualRegister)(inlineCallFrame->stackOffset + JSStack::CallerFrame)));
jit.storePtr(callerFrameGPR, AssemblyHelpers::payloadFor((VirtualRegister)(inlineCallFrame->stackOffset + JSStack::CallerFrame)));
jit.storePtr(AssemblyHelpers::TrustedImmPtr(jumpTarget), AssemblyHelpers::payloadFor((VirtualRegister)(inlineCallFrame->stackOffset + JSStack::ReturnPC)));
+ Instruction* instruction = baselineCodeBlock->instructions().begin() + codeOrigin.bytecodeIndex;
+ uint32_t locationBits = CallFrame::Location::encodeAsBytecodeInstruction(instruction);
+ jit.store32(AssemblyHelpers::TrustedImm32(locationBits), AssemblyHelpers::tagFor((VirtualRegister)(inlineCallFrame->stackOffset + JSStack::ArgumentCount)));
jit.store32(AssemblyHelpers::TrustedImm32(inlineCallFrame->arguments.size()), AssemblyHelpers::payloadFor((VirtualRegister)(inlineCallFrame->stackOffset + JSStack::ArgumentCount)));
jit.store32(AssemblyHelpers::TrustedImm32(JSValue::CellTag), AssemblyHelpers::tagFor((VirtualRegister)(inlineCallFrame->stackOffset + JSStack::Callee)));
if (!inlineCallFrame->isClosureCall())
jit.storePtr(AssemblyHelpers::TrustedImmPtr(inlineCallFrame->callee.get()), AssemblyHelpers::payloadFor((VirtualRegister)(inlineCallFrame->stackOffset + JSStack::Callee)));
#endif // USE(JSVALUE64) // ending the #else part, so directly above is the 32-bit part
-
- jit.store32(AssemblyHelpers::TrustedImm32(codeOrigin.bytecodeIndex), AssemblyHelpers::tagFor((VirtualRegister)(inlineCallFrame->stackOffset + JSStack::ArgumentCount)));
}
- jit.store32(AssemblyHelpers::TrustedImm32(codeOrigin.bytecodeIndex), AssemblyHelpers::tagFor((VirtualRegister)(JSStack::ArgumentCount)));
+#if USE(JSVALUE64)
+ uint32_t locationBits = CallFrame::Location::encodeAsBytecodeOffset(codeOrigin.bytecodeIndex);
+#else
+ Instruction* instruction = jit.baselineCodeBlock()->instructions().begin() + codeOrigin.bytecodeIndex;
+ uint32_t locationBits = CallFrame::Location::encodeAsBytecodeInstruction(instruction);
+#endif
+ jit.store32(AssemblyHelpers::TrustedImm32(locationBits), AssemblyHelpers::tagFor((VirtualRegister)(JSStack::ArgumentCount)));
}
void adjustAndJumpToTarget(CCallHelpers& jit, const OSRExitBase& exit)
Modified: branches/dfgFourthTier/Source/_javascript_Core/ftl/FTLLink.cpp (151328 => 151329)
--- branches/dfgFourthTier/Source/_javascript_Core/ftl/FTLLink.cpp 2013-06-07 18:20:09 UTC (rev 151328)
+++ branches/dfgFourthTier/Source/_javascript_Core/ftl/FTLLink.cpp 2013-06-07 18:23:03 UTC (rev 151329)
@@ -86,7 +86,7 @@
OBJECT_OFFSETOF(struct JITStackFrame, callFrame) / sizeof(void*));
jit.store32(
- CCallHelpers::TrustedImm32(0),
+ CCallHelpers::TrustedImm32(CallFrame::Location::encodeAsBytecodeOffset(0)),
CCallHelpers::tagFor(static_cast<VirtualRegister>(JSStack::ArgumentCount)));
CCallHelpers::Call callStackCheck = jit.call();
// FIXME: need to make this call register with exception handling somehow. This is
@@ -108,7 +108,7 @@
GPRInfo::callFrameRegister,
OBJECT_OFFSETOF(struct JITStackFrame, callFrame) / sizeof(void*));
jit.store32(
- CCallHelpers::TrustedImm32(0),
+ CCallHelpers::TrustedImm32(CallFrame::Location::encodeAsBytecodeOffset(0)),
CCallHelpers::tagFor(static_cast<VirtualRegister>(JSStack::ArgumentCount)));
CCallHelpers::Call callArityCheck = jit.call();
// FIXME: need to make this call register with exception handling somehow. This is
Modified: branches/dfgFourthTier/Source/_javascript_Core/interpreter/CallFrame.cpp (151328 => 151329)
--- branches/dfgFourthTier/Source/_javascript_Core/interpreter/CallFrame.cpp 2013-06-07 18:20:09 UTC (rev 151328)
+++ branches/dfgFourthTier/Source/_javascript_Core/interpreter/CallFrame.cpp 2013-06-07 18:23:03 UTC (rev 151329)
@@ -52,7 +52,7 @@
void CallFrame::setLocationAsBytecodeOffset(unsigned offset)
{
ASSERT(codeBlock());
- ASSERT(Location::isBytecodeOffset(offset));
+ ASSERT(Location::isBytecodeLocation(offset));
setCurrentVPC(codeBlock()->instructions().begin() + offset);
ASSERT(hasLocationAsBytecodeOffset());
}
Modified: branches/dfgFourthTier/Source/_javascript_Core/interpreter/CallFrame.h (151328 => 151329)
--- branches/dfgFourthTier/Source/_javascript_Core/interpreter/CallFrame.h 2013-06-07 18:20:09 UTC (rev 151328)
+++ branches/dfgFourthTier/Source/_javascript_Core/interpreter/CallFrame.h 2013-06-07 18:23:03 UTC (rev 151329)
@@ -116,19 +116,30 @@
class Location {
public:
- enum Type {
- BytecodeOffset = 0,
- CodeOriginIndex = (1 << 0),
- IsInlinedCode = (1 << 1),
- };
+ static inline uint32_t decode(uint32_t bits);
- static inline uint32_t encode(Type, uint32_t bits);
- static inline uint32_t decode(uint32_t bits);
- static inline bool isBytecodeOffset(uint32_t bits);
+ static inline bool isBytecodeLocation(uint32_t bits);
+#if USE(JSVALUE64)
+ static inline uint32_t encodeAsBytecodeOffset(uint32_t bits);
+#else
+ static inline uint32_t encodeAsBytecodeInstruction(Instruction*);
+#endif
+
static inline bool isCodeOriginIndex(uint32_t bits);
+ static inline uint32_t encodeAsCodeOriginIndex(uint32_t bits);
+
static inline bool isInlinedCode(uint32_t bits);
+ static inline uint32_t encodeAsInlinedCode(uint32_t bits);
private:
+ enum TypeTag {
+ BytecodeLocationTag = 0,
+ CodeOriginIndexTag = 1,
+ IsInlinedCodeTag = 2,
+ };
+
+ static inline uint32_t encode(TypeTag, uint32_t bits);
+
static const uint32_t s_mask = 0x3;
#if USE(JSVALUE64)
static const uint32_t s_shift = 30;
Modified: branches/dfgFourthTier/Source/_javascript_Core/interpreter/CallFrameInlines.h (151328 => 151329)
--- branches/dfgFourthTier/Source/_javascript_Core/interpreter/CallFrameInlines.h 2013-06-07 18:20:09 UTC (rev 151328)
+++ branches/dfgFourthTier/Source/_javascript_Core/interpreter/CallFrameInlines.h 2013-06-07 18:23:03 UTC (rev 151329)
@@ -30,18 +30,18 @@
namespace JSC {
-inline uint32_t CallFrame::Location::encode(CallFrame::Location::Type type, uint32_t bits)
+inline uint32_t CallFrame::Location::encode(CallFrame::Location::TypeTag tag, uint32_t bits)
{
#if USE(JSVALUE64)
ASSERT(!(bits & s_shiftedMask));
- ASSERT(!(type & ~s_mask));
- return bits | (type << s_shift);
+ ASSERT(!(tag & ~s_mask));
+ return bits | (tag << s_shift);
#else
- ASSERT(!(type & ~s_mask));
- if (type & CodeOriginIndex)
+ ASSERT(!(tag & ~s_mask));
+ if (tag & CodeOriginIndexTag)
bits = (bits << s_shift);
ASSERT(!(bits & s_mask));
- bits |= type;
+ bits |= tag;
return bits;
#endif
}
@@ -57,28 +57,58 @@
#endif
}
-inline bool CallFrame::Location::isBytecodeOffset(uint32_t bits)
+#if USE(JSVALUE64)
+inline uint32_t CallFrame::Location::encodeAsBytecodeOffset(uint32_t bits)
{
+ uint32_t encodedBits = encode(BytecodeLocationTag, bits);
+ ASSERT(isBytecodeLocation(encodedBits));
+ return encodedBits;
+}
+#else
+inline uint32_t CallFrame::Location::encodeAsBytecodeInstruction(Instruction* instruction)
+{
+ uint32_t encodedBits = encode(BytecodeLocationTag, reinterpret_cast<uint32_t>(instruction));
+ ASSERT(isBytecodeLocation(encodedBits));
+ return encodedBits;
+}
+#endif
+
+inline uint32_t CallFrame::Location::encodeAsCodeOriginIndex(uint32_t bits)
+{
+ uint32_t encodedBits = encode(CodeOriginIndexTag, bits);
+ ASSERT(isCodeOriginIndex(encodedBits));
+ return encodedBits;
+}
+
+inline uint32_t CallFrame::Location::encodeAsInlinedCode(uint32_t bits)
+{
+ uint32_t encodedBits = encode(IsInlinedCodeTag, bits);
+ ASSERT(isInlinedCode(encodedBits));
+ return encodedBits;
+}
+
+inline bool CallFrame::Location::isBytecodeLocation(uint32_t bits)
+{
return !isCodeOriginIndex(bits);
}
inline bool CallFrame::Location::isCodeOriginIndex(uint32_t bits)
{
#if USE(JSVALUE64)
- Type type = static_cast<Type>(bits >> s_shift);
- return !!(type & CodeOriginIndex);
+ TypeTag tag = static_cast<TypeTag>(bits >> s_shift);
+ return !!(tag & CodeOriginIndexTag);
#else
- return !!(bits & CodeOriginIndex);
+ return !!(bits & CodeOriginIndexTag);
#endif
}
inline bool CallFrame::Location::isInlinedCode(uint32_t bits)
{
#if USE(JSVALUE64)
- Type type = static_cast<Type>(bits >> s_shift);
- return !!(type & IsInlinedCode);
+ TypeTag tag = static_cast<TypeTag>(bits >> s_shift);
+ return !!(tag & IsInlinedCodeTag);
#else
- return !!(bits & IsInlinedCode);
+ return !!(bits & IsInlinedCodeTag);
#endif
}
@@ -90,14 +120,14 @@
inline void CallFrame::setIsInlinedFrame()
{
ASSERT(codeBlock());
- uint32_t bits = Location::encode(Location::IsInlinedCode, locationAsRawBits());
+ uint32_t bits = Location::encodeAsInlinedCode(locationAsRawBits());
setLocationAsRawBits(bits);
ASSERT(isInlinedFrame());
}
inline bool CallFrame::hasLocationAsBytecodeOffset() const
{
- return Location::isBytecodeOffset(locationAsRawBits());
+ return Location::isBytecodeLocation(locationAsRawBits());
}
inline bool CallFrame::hasLocationAsCodeOriginIndex() const
@@ -126,7 +156,7 @@
inline void CallFrame::setLocationAsBytecodeOffset(unsigned offset)
{
ASSERT(codeBlock());
- setLocationAsRawBits(Location::encode(Location::BytecodeOffset, offset));
+ setLocationAsRawBits(Location::encodeAsBytecodeOffset(offset));
ASSERT(hasLocationAsBytecodeOffset());
}
#endif // USE(JSVALUE64)
Modified: branches/dfgFourthTier/Source/_javascript_Core/jit/JITCall.cpp (151328 => 151329)
--- branches/dfgFourthTier/Source/_javascript_Core/jit/JITCall.cpp 2013-06-07 18:20:09 UTC (rev 151328)
+++ branches/dfgFourthTier/Source/_javascript_Core/jit/JITCall.cpp 2013-06-07 18:23:03 UTC (rev 151329)
@@ -189,7 +189,9 @@
store32(TrustedImm32(argCount), Address(regT1, JSStack::ArgumentCount * static_cast<int>(sizeof(Register)) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload)));
} // regT1 holds newCallFrame with ArgumentCount initialized.
- store32(TrustedImm32(instruction - m_codeBlock->instructions().begin()), Address(callFrameRegister, JSStack::ArgumentCount * static_cast<int>(sizeof(Register)) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag)));
+ uint32_t bytecodeOffset = instruction - m_codeBlock->instructions().begin();
+ uint32_t locationBits = CallFrame::Location::encodeAsBytecodeOffset(bytecodeOffset);
+ store32(TrustedImm32(locationBits), Address(callFrameRegister, JSStack::ArgumentCount * static_cast<int>(sizeof(Register)) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag)));
emitGetVirtualRegister(callee, regT0); // regT0 holds callee.
store64(callFrameRegister, Address(regT1, JSStack::CallerFrame * static_cast<int>(sizeof(Register))));
Modified: branches/dfgFourthTier/Source/_javascript_Core/jit/JITCall32_64.cpp (151328 => 151329)
--- branches/dfgFourthTier/Source/_javascript_Core/jit/JITCall32_64.cpp 2013-06-07 18:20:09 UTC (rev 151328)
+++ branches/dfgFourthTier/Source/_javascript_Core/jit/JITCall32_64.cpp 2013-06-07 18:23:03 UTC (rev 151329)
@@ -261,7 +261,8 @@
store32(TrustedImm32(argCount), payloadFor(JSStack::ArgumentCount, regT3));
} // regT3 holds newCallFrame with ArgumentCount initialized.
- storePtr(TrustedImmPtr(instruction), tagFor(JSStack::ArgumentCount, callFrameRegister));
+ uint32_t locationBits = CallFrame::Location::encodeAsBytecodeInstruction(instruction);
+ store32(TrustedImm32(locationBits), tagFor(JSStack::ArgumentCount, callFrameRegister));
emitLoad(callee, regT1, regT0); // regT1, regT0 holds callee.
storePtr(callFrameRegister, Address(regT3, JSStack::CallerFrame * static_cast<int>(sizeof(Register))));
Modified: branches/dfgFourthTier/Source/_javascript_Core/jit/JITInlines.h (151328 => 151329)
--- branches/dfgFourthTier/Source/_javascript_Core/jit/JITInlines.h 2013-06-07 18:20:09 UTC (rev 151328)
+++ branches/dfgFourthTier/Source/_javascript_Core/jit/JITInlines.h 2013-06-07 18:23:03 UTC (rev 151329)
@@ -29,6 +29,8 @@
#if ENABLE(JIT)
+#include "CallFrameInlines.h"
+
namespace JSC {
ALWAYS_INLINE bool JIT::isOperandConstantImmediateDouble(unsigned src)
@@ -176,10 +178,12 @@
ASSERT(static_cast<int>(m_bytecodeOffset) >= 0);
if (m_bytecodeOffset) {
#if USE(JSVALUE32_64)
- storePtr(TrustedImmPtr(m_codeBlock->instructions().begin() + m_bytecodeOffset + 1), intTagFor(JSStack::ArgumentCount));
+ Instruction* instruction = m_codeBlock->instructions().begin() + m_bytecodeOffset + 1;
+ uint32_t locationBits = CallFrame::Location::encodeAsBytecodeInstruction(instruction);
#else
- store32(TrustedImm32(m_bytecodeOffset + 1), intTagFor(JSStack::ArgumentCount));
+ uint32_t locationBits = CallFrame::Location::encodeAsBytecodeOffset(m_bytecodeOffset + 1);
#endif
+ store32(TrustedImm32(locationBits), intTagFor(JSStack::ArgumentCount));
}
storePtr(callFrameRegister, &m_vm->topCallFrame);
}