Diff
Modified: branches/dfgFourthTier/Source/_javascript_Core/ChangeLog (149859 => 149860)
--- branches/dfgFourthTier/Source/_javascript_Core/ChangeLog 2013-05-10 01:46:32 UTC (rev 149859)
+++ branches/dfgFourthTier/Source/_javascript_Core/ChangeLog 2013-05-10 02:45:10 UTC (rev 149860)
@@ -1,5 +1,65 @@
2013-05-09 Filip Pizlo <[email protected]>
+ fourthTier: CodeBlock should be RefCounted
+ https://bugs.webkit.org/show_bug.cgi?id=115594
+
+ Reviewed by Geoffrey Garen.
+
+ This makes it possible to have the currently-being-compiled CodeBlock not be
+ installed in Executable, while also allowing it to point to its intended
+ alternative(). So long as we were using ownership and not reference counting, it
+ would have been difficult to have both CodeBlock::m_alternative and
+ Executable::m_codeBlockForBlah point to the previous CodeBlock.
+
+ I also took the opportunity to clean up a bunch of code that appears to have
+ rotted.
+
+ * assembler/MacroAssemblerCodeRef.h:
+ (MacroAssemblerCodePtr):
+ (JSC::MacroAssemblerCodePtr::operator==):
+ * bytecode/CodeBlock.cpp:
+ (JSC::CodeBlock::CodeBlock):
+ * bytecode/CodeBlock.h:
+ (JSC::CodeBlock::releaseAlternative):
+ (JSC::CodeBlock::setAlternative):
+ (CodeBlock):
+ (JSC::GlobalCodeBlock::GlobalCodeBlock):
+ (JSC::ProgramCodeBlock::ProgramCodeBlock):
+ (JSC::EvalCodeBlock::EvalCodeBlock):
+ (JSC::FunctionCodeBlock::FunctionCodeBlock):
+ * heap/DFGCodeBlocks.cpp:
+ (JSC::DFGCodeBlocks::~DFGCodeBlocks):
+ (JSC::DFGCodeBlocks::jettison):
+ (JSC::DFGCodeBlocks::deleteUnmarkedJettisonedCodeBlocks):
+ * heap/DFGCodeBlocks.h:
+ (DFGCodeBlocks):
+ * heap/Heap.cpp:
+ (JSC::Heap::jettisonDFGCodeBlock):
+ * heap/Heap.h:
+ * jit/JITDriver.h:
+ (JSC::jitCompileIfAppropriate):
+ (JSC::jitCompileFunctionIfAppropriate):
+ * runtime/Executable.cpp:
+ (JSC::jettisonCodeBlock):
+ (JSC::EvalExecutable::jitCompile):
+ (JSC::EvalExecutable::compileInternal):
+ (JSC::ProgramExecutable::jitCompile):
+ (JSC::ProgramExecutable::compileInternal):
+ (JSC::FunctionExecutable::jitCompileForCall):
+ (JSC::FunctionExecutable::jitCompileForConstruct):
+ (JSC::FunctionExecutable::produceCodeBlockFor):
+ (JSC::FunctionExecutable::compileForCallInternal):
+ (JSC::FunctionExecutable::compileForConstructInternal):
+ * runtime/Executable.h:
+ (EvalExecutable):
+ (FunctionExecutable):
+ (JSC::FunctionExecutable::codeBlockFor):
+ * runtime/ExecutionHarness.h:
+ (JSC::prepareForExecution):
+ (JSC::prepareFunctionForExecution):
+
+2013-05-09 Filip Pizlo <[email protected]>
+
fourthTier: DFG should have its own notion of StructureChain, and it should be possible to validate it after compilation finishes
https://bugs.webkit.org/show_bug.cgi?id=115841
Modified: branches/dfgFourthTier/Source/_javascript_Core/assembler/MacroAssemblerCodeRef.h (149859 => 149860)
--- branches/dfgFourthTier/Source/_javascript_Core/assembler/MacroAssemblerCodeRef.h 2013-05-10 01:46:32 UTC (rev 149859)
+++ branches/dfgFourthTier/Source/_javascript_Core/assembler/MacroAssemblerCodeRef.h 2013-05-10 02:45:10 UTC (rev 149860)
@@ -315,6 +315,11 @@
{
return !m_value;
}
+
+ bool operator==(const MacroAssemblerCodePtr& other) const
+ {
+ return m_value == other.m_value;
+ }
private:
void* m_value;
Modified: branches/dfgFourthTier/Source/_javascript_Core/bytecode/CodeBlock.cpp (149859 => 149860)
--- branches/dfgFourthTier/Source/_javascript_Core/bytecode/CodeBlock.cpp 2013-05-10 01:46:32 UTC (rev 149859)
+++ branches/dfgFourthTier/Source/_javascript_Core/bytecode/CodeBlock.cpp 2013-05-10 02:45:10 UTC (rev 149860)
@@ -1615,7 +1615,7 @@
}
}
-CodeBlock::CodeBlock(ScriptExecutable* ownerExecutable, UnlinkedCodeBlock* unlinkedCodeBlock, JSGlobalObject* globalObject, unsigned baseScopeDepth, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, PassOwnPtr<CodeBlock> alternative)
+CodeBlock::CodeBlock(ScriptExecutable* ownerExecutable, UnlinkedCodeBlock* unlinkedCodeBlock, JSGlobalObject* globalObject, unsigned baseScopeDepth, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset)
: m_globalObject(globalObject->vm(), ownerExecutable, globalObject)
, m_heap(&m_globalObject->vm().heap)
, m_numCalleeRegisters(unlinkedCodeBlock->m_numCalleeRegisters)
@@ -1632,7 +1632,6 @@
, m_source(sourceProvider)
, m_sourceOffset(sourceOffset)
, m_codeType(unlinkedCodeBlock->codeType())
- , m_alternative(alternative)
, m_osrExitCounter(0)
, m_optimizationDelayCounter(0)
, m_reoptimizationRetryCounter(0)
Modified: branches/dfgFourthTier/Source/_javascript_Core/bytecode/CodeBlock.h (149859 => 149860)
--- branches/dfgFourthTier/Source/_javascript_Core/bytecode/CodeBlock.h 2013-05-10 01:46:32 UTC (rev 149859)
+++ branches/dfgFourthTier/Source/_javascript_Core/bytecode/CodeBlock.h 2013-05-10 02:45:10 UTC (rev 149860)
@@ -90,7 +90,7 @@
static ALWAYS_INLINE int missingThisObjectMarker() { return std::numeric_limits<int>::max(); }
- class CodeBlock : public UnconditionalFinalizer, public WeakReferenceHarvester {
+class CodeBlock : public RefCounted<CodeBlock>, public UnconditionalFinalizer, public WeakReferenceHarvester {
WTF_MAKE_FAST_ALLOCATED;
friend class JIT;
friend class LLIntOffsetsExtractor;
@@ -99,7 +99,7 @@
protected:
CodeBlock(CopyParsedBlockTag, CodeBlock& other);
- CodeBlock(ScriptExecutable* ownerExecutable, UnlinkedCodeBlock*, JSGlobalObject*, unsigned baseScopeDepth, PassRefPtr<SourceProvider>, unsigned sourceOffset, PassOwnPtr<CodeBlock> alternative);
+ CodeBlock(ScriptExecutable* ownerExecutable, UnlinkedCodeBlock*, JSGlobalObject*, unsigned baseScopeDepth, PassRefPtr<SourceProvider>, unsigned sourceOffset);
WriteBarrier<JSGlobalObject> m_globalObject;
Heap* m_heap;
@@ -123,8 +123,8 @@
static ptrdiff_t offsetOfNumParameters() { return OBJECT_OFFSETOF(CodeBlock, m_numParameters); }
CodeBlock* alternative() { return m_alternative.get(); }
- PassOwnPtr<CodeBlock> releaseAlternative() { return m_alternative.release(); }
- void setAlternative(PassOwnPtr<CodeBlock> alternative) { m_alternative = alternative; }
+ PassRefPtr<CodeBlock> releaseAlternative() { return m_alternative.release(); }
+ void setAlternative(PassRefPtr<CodeBlock> alternative) { m_alternative = alternative; }
CodeSpecializationKind specializationKind() const
{
@@ -1082,7 +1082,7 @@
Vector<WriteBarrier<FunctionExecutable> > m_functionDecls;
Vector<WriteBarrier<FunctionExecutable> > m_functionExprs;
- OwnPtr<CodeBlock> m_alternative;
+ RefPtr<CodeBlock> m_alternative;
ExecutionCounter m_llintExecuteCounter;
@@ -1137,8 +1137,8 @@
{
}
- GlobalCodeBlock(ScriptExecutable* ownerExecutable, UnlinkedCodeBlock* unlinkedCodeBlock, JSGlobalObject* globalObject, unsigned baseScopeDepth, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, PassOwnPtr<CodeBlock> alternative)
- : CodeBlock(ownerExecutable, unlinkedCodeBlock, globalObject, baseScopeDepth, sourceProvider, sourceOffset, alternative)
+ GlobalCodeBlock(ScriptExecutable* ownerExecutable, UnlinkedCodeBlock* unlinkedCodeBlock, JSGlobalObject* globalObject, unsigned baseScopeDepth, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset)
+ : CodeBlock(ownerExecutable, unlinkedCodeBlock, globalObject, baseScopeDepth, sourceProvider, sourceOffset)
{
}
};
@@ -1150,8 +1150,8 @@
{
}
- ProgramCodeBlock(ProgramExecutable* ownerExecutable, UnlinkedProgramCodeBlock* unlinkedCodeBlock, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider, PassOwnPtr<CodeBlock> alternative)
- : GlobalCodeBlock(ownerExecutable, unlinkedCodeBlock, globalObject, 0, sourceProvider, 0, alternative)
+ ProgramCodeBlock(ProgramExecutable* ownerExecutable, UnlinkedProgramCodeBlock* unlinkedCodeBlock, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider)
+ : GlobalCodeBlock(ownerExecutable, unlinkedCodeBlock, globalObject, 0, sourceProvider, 0)
{
}
@@ -1172,8 +1172,8 @@
{
}
- EvalCodeBlock(EvalExecutable* ownerExecutable, UnlinkedEvalCodeBlock* unlinkedCodeBlock, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider, int baseScopeDepth, PassOwnPtr<CodeBlock> alternative)
- : GlobalCodeBlock(ownerExecutable, unlinkedCodeBlock, globalObject, baseScopeDepth, sourceProvider, 0, alternative)
+ EvalCodeBlock(EvalExecutable* ownerExecutable, UnlinkedEvalCodeBlock* unlinkedCodeBlock, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider, int baseScopeDepth)
+ : GlobalCodeBlock(ownerExecutable, unlinkedCodeBlock, globalObject, baseScopeDepth, sourceProvider, 0)
{
}
@@ -1200,8 +1200,8 @@
{
}
- FunctionCodeBlock(FunctionExecutable* ownerExecutable, UnlinkedFunctionCodeBlock* unlinkedCodeBlock, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, PassOwnPtr<CodeBlock> alternative = nullptr)
- : CodeBlock(ownerExecutable, unlinkedCodeBlock, globalObject, 0, sourceProvider, sourceOffset, alternative)
+ FunctionCodeBlock(FunctionExecutable* ownerExecutable, UnlinkedFunctionCodeBlock* unlinkedCodeBlock, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset)
+ : CodeBlock(ownerExecutable, unlinkedCodeBlock, globalObject, 0, sourceProvider, sourceOffset)
{
}
Modified: branches/dfgFourthTier/Source/_javascript_Core/heap/DFGCodeBlocks.cpp (149859 => 149860)
--- branches/dfgFourthTier/Source/_javascript_Core/heap/DFGCodeBlocks.cpp 2013-05-10 01:46:32 UTC (rev 149859)
+++ branches/dfgFourthTier/Source/_javascript_Core/heap/DFGCodeBlocks.cpp 2013-05-10 02:45:10 UTC (rev 149860)
@@ -38,20 +38,18 @@
DFGCodeBlocks::~DFGCodeBlocks()
{
- Vector<CodeBlock*, 16> toRemove;
+ Vector<RefPtr<CodeBlock>, 16> toRemove;
for (HashSet<CodeBlock*>::iterator iter = m_set.begin(); iter != m_set.end(); ++iter) {
if ((*iter)->getJITCode()->dfgCommon()->isJettisoned)
- toRemove.append(*iter);
+ toRemove.append(adoptRef(*iter));
}
-
- WTF::deleteAllValues(toRemove);
}
-void DFGCodeBlocks::jettison(PassOwnPtr<CodeBlock> codeBlockPtr)
+void DFGCodeBlocks::jettison(PassRefPtr<CodeBlock> codeBlockPtr)
{
// We don't want to delete it now; we just want its pointer.
- CodeBlock* codeBlock = codeBlockPtr.leakPtr();
+ CodeBlock* codeBlock = codeBlockPtr.leakRef();
ASSERT(codeBlock);
ASSERT(JITCode::isOptimizingJIT(codeBlock->getJITType()));
@@ -75,14 +73,12 @@
void DFGCodeBlocks::deleteUnmarkedJettisonedCodeBlocks()
{
- Vector<CodeBlock*, 16> toRemove;
+ Vector<RefPtr<CodeBlock>, 16> toRemove;
for (HashSet<CodeBlock*>::iterator iter = m_set.begin(); iter != m_set.end(); ++iter) {
if ((*iter)->getJITCode()->dfgCommon()->isJettisoned && !(*iter)->getJITCode()->dfgCommon()->mayBeExecuting)
- toRemove.append(*iter);
+ toRemove.append(adoptRef(*iter));
}
-
- WTF::deleteAllValues(toRemove);
}
void DFGCodeBlocks::traceMarkedCodeBlocks(SlotVisitor& visitor)
Modified: branches/dfgFourthTier/Source/_javascript_Core/heap/DFGCodeBlocks.h (149859 => 149860)
--- branches/dfgFourthTier/Source/_javascript_Core/heap/DFGCodeBlocks.h 2013-05-10 01:46:32 UTC (rev 149859)
+++ branches/dfgFourthTier/Source/_javascript_Core/heap/DFGCodeBlocks.h 2013-05-10 02:45:10 UTC (rev 149860)
@@ -59,7 +59,7 @@
// it. This is typically called either from a recompilation trigger, or from
// an unconditional finalizer associated with a CodeBlock that had weak
// references, where some subset of those references were dead.
- void jettison(PassOwnPtr<CodeBlock>);
+ void jettison(PassRefPtr<CodeBlock>);
// Clear all mark bits associated with DFG code blocks.
void clearMarks();
@@ -86,7 +86,7 @@
WTF_MAKE_FAST_ALLOCATED;
public:
- void jettison(PassOwnPtr<CodeBlock>);
+ void jettison(PassRefPtr<CodeBlock>);
void clearMarks() { }
void mark(void*) { }
void deleteUnmarkedJettisonedCodeBlocks() { }
Modified: branches/dfgFourthTier/Source/_javascript_Core/heap/Heap.cpp (149859 => 149860)
--- branches/dfgFourthTier/Source/_javascript_Core/heap/Heap.cpp 2013-05-10 01:46:32 UTC (rev 149859)
+++ branches/dfgFourthTier/Source/_javascript_Core/heap/Heap.cpp 2013-05-10 02:45:10 UTC (rev 149860)
@@ -350,7 +350,7 @@
return m_protectedValues.remove(k.asCell());
}
-void Heap::jettisonDFGCodeBlock(PassOwnPtr<CodeBlock> codeBlock)
+void Heap::jettisonDFGCodeBlock(PassRefPtr<CodeBlock> codeBlock)
{
m_dfgCodeBlocks.jettison(codeBlock);
}
Modified: branches/dfgFourthTier/Source/_javascript_Core/heap/Heap.h (149859 => 149860)
--- branches/dfgFourthTier/Source/_javascript_Core/heap/Heap.h 2013-05-10 01:46:32 UTC (rev 149859)
+++ branches/dfgFourthTier/Source/_javascript_Core/heap/Heap.h 2013-05-10 02:45:10 UTC (rev 149860)
@@ -138,7 +138,7 @@
JS_EXPORT_PRIVATE void protect(JSValue);
JS_EXPORT_PRIVATE bool unprotect(JSValue); // True when the protect count drops to 0.
- void jettisonDFGCodeBlock(PassOwnPtr<CodeBlock>);
+ void jettisonDFGCodeBlock(PassRefPtr<CodeBlock>);
JS_EXPORT_PRIVATE size_t size();
JS_EXPORT_PRIVATE size_t capacity();
Modified: branches/dfgFourthTier/Source/_javascript_Core/jit/JITDriver.h (149859 => 149860)
--- branches/dfgFourthTier/Source/_javascript_Core/jit/JITDriver.h 2013-05-10 01:46:32 UTC (rev 149859)
+++ branches/dfgFourthTier/Source/_javascript_Core/jit/JITDriver.h 2013-05-10 02:45:10 UTC (rev 149860)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -38,7 +38,7 @@
namespace JSC {
template<typename CodeBlockType>
-inline bool jitCompileIfAppropriate(ExecState* exec, OwnPtr<CodeBlockType>& codeBlock, RefPtr<JITCode>& jitCode, JITCode::JITType jitType, unsigned bytecodeIndex, JITCompilationEffort effort)
+inline bool jitCompileIfAppropriate(ExecState* exec, CodeBlockType* codeBlock, RefPtr<JITCode>& jitCode, JITCode::JITType jitType, unsigned bytecodeIndex, JITCompilationEffort effort)
{
VM& vm = exec->vm();
@@ -52,30 +52,27 @@
RefPtr<JITCode> oldJITCode = jitCode;
- bool dfgCompiled = false;
- if (JITCode::isOptimizingJIT(jitType))
- dfgCompiled = DFG::tryCompile(exec, codeBlock.get(), jitCode, bytecodeIndex);
- if (dfgCompiled) {
- if (codeBlock->alternative())
+ if (JITCode::isOptimizingJIT(jitType)) {
+ if (DFG::tryCompile(exec, codeBlock, jitCode, bytecodeIndex))
codeBlock->alternative()->unlinkIncomingCalls();
- } else {
- if (codeBlock->alternative()) {
- codeBlock = static_pointer_cast<CodeBlockType>(codeBlock->releaseAlternative());
- jitCode = oldJITCode;
+ else {
+ ASSERT(oldJITCode == jitCode);
return false;
}
- jitCode = JIT::compile(&vm, codeBlock.get(), effort);
- if (!jitCode) {
- jitCode = oldJITCode;
+ } else {
+ RefPtr<JITCode> result = JIT::compile(&vm, codeBlock, effort);
+ if (result)
+ jitCode = result;
+ else
return false;
- }
}
+
codeBlock->setJITCode(jitCode, MacroAssemblerCodePtr());
return true;
}
-inline bool jitCompileFunctionIfAppropriate(ExecState* exec, OwnPtr<FunctionCodeBlock>& codeBlock, RefPtr<JITCode>& jitCode, MacroAssemblerCodePtr& jitCodeWithArityCheck, JITCode::JITType jitType, unsigned bytecodeIndex, JITCompilationEffort effort)
+inline bool jitCompileFunctionIfAppropriate(ExecState* exec, FunctionCodeBlock* codeBlock, RefPtr<JITCode>& jitCode, MacroAssemblerCodePtr& jitCodeWithArityCheck, JITCode::JITType jitType, unsigned bytecodeIndex, JITCompilationEffort effort)
{
VM& vm = exec->vm();
@@ -90,26 +87,25 @@
RefPtr<JITCode> oldJITCode = jitCode;
MacroAssemblerCodePtr oldJITCodeWithArityCheck = jitCodeWithArityCheck;
- bool dfgCompiled = false;
- if (JITCode::isOptimizingJIT(jitType))
- dfgCompiled = DFG::tryCompileFunction(exec, codeBlock.get(), jitCode, jitCodeWithArityCheck, bytecodeIndex);
- if (dfgCompiled) {
- if (codeBlock->alternative())
+ if (JITCode::isOptimizingJIT(jitType)) {
+ if (DFG::tryCompileFunction(exec, codeBlock, jitCode, jitCodeWithArityCheck, bytecodeIndex))
codeBlock->alternative()->unlinkIncomingCalls();
- } else {
- if (codeBlock->alternative()) {
- codeBlock = static_pointer_cast<FunctionCodeBlock>(codeBlock->releaseAlternative());
- jitCode = oldJITCode;
- jitCodeWithArityCheck = oldJITCodeWithArityCheck;
+ else {
+ ASSERT(oldJITCode == jitCode);
+ ASSERT_UNUSED(oldJITCodeWithArityCheck, oldJITCodeWithArityCheck == jitCodeWithArityCheck);
return false;
}
- jitCode = JIT::compile(&vm, codeBlock.get(), effort, &jitCodeWithArityCheck);
- if (!jitCode) {
- jitCode = oldJITCode;
- jitCodeWithArityCheck = oldJITCodeWithArityCheck;
+ } else {
+ RefPtr<JITCode> result =
+ JIT::compile(&vm, codeBlock, effort, &jitCodeWithArityCheck);
+ if (result)
+ jitCode = result;
+ else {
+ ASSERT_UNUSED(oldJITCodeWithArityCheck, oldJITCodeWithArityCheck == jitCodeWithArityCheck);
return false;
}
}
+
codeBlock->setJITCode(jitCode, jitCodeWithArityCheck);
return true;
Modified: branches/dfgFourthTier/Source/_javascript_Core/runtime/Executable.cpp (149859 => 149860)
--- branches/dfgFourthTier/Source/_javascript_Core/runtime/Executable.cpp 2013-05-10 01:46:32 UTC (rev 149859)
+++ branches/dfgFourthTier/Source/_javascript_Core/runtime/Executable.cpp 2013-05-10 02:45:10 UTC (rev 149860)
@@ -94,11 +94,11 @@
#if ENABLE(JIT)
// Utility method used for jettisoning code blocks.
template<typename T>
-static void jettisonCodeBlock(VM& vm, OwnPtr<T>& codeBlock)
+static void jettisonCodeBlock(VM& vm, RefPtr<T>& codeBlock)
{
ASSERT(JITCode::isOptimizingJIT(codeBlock->getJITType()));
ASSERT(codeBlock->alternative());
- OwnPtr<T> codeBlockToJettison = codeBlock.release();
+ RefPtr<T> codeBlockToJettison = codeBlock.release();
codeBlock = static_pointer_cast<T>(codeBlockToJettison->releaseAlternative());
codeBlockToJettison->unlinkIncomingCalls();
vm.heap.jettisonDFGCodeBlock(static_pointer_cast<CodeBlock>(codeBlockToJettison.release()));
@@ -169,7 +169,7 @@
#if ENABLE(JIT)
bool EvalExecutable::jitCompile(ExecState* exec)
{
- return jitCompileIfAppropriate(exec, m_evalCodeBlock, m_jitCodeForCall, JITCode::bottomTierJIT(), UINT_MAX, JITCompilationCanFail);
+ return jitCompileIfAppropriate(exec, m_evalCodeBlock.get(), m_jitCodeForCall, JITCode::bottomTierJIT(), UINT_MAX, JITCompilationCanFail);
}
#endif
@@ -201,10 +201,11 @@
VM* vm = &exec->vm();
JSGlobalObject* lexicalGlobalObject = exec->lexicalGlobalObject();
+ RefPtr<EvalCodeBlock> newCodeBlock;
+
if (!!m_evalCodeBlock) {
- OwnPtr<EvalCodeBlock> newCodeBlock = adoptPtr(new EvalCodeBlock(CodeBlock::CopyParsedBlock, *m_evalCodeBlock));
- newCodeBlock->setAlternative(static_pointer_cast<CodeBlock>(m_evalCodeBlock.release()));
- m_evalCodeBlock = newCodeBlock.release();
+ newCodeBlock = adoptRef(new EvalCodeBlock(CodeBlock::CopyParsedBlock, *m_evalCodeBlock));
+ newCodeBlock->setAlternative(static_pointer_cast<CodeBlock>(m_evalCodeBlock));
} else {
UNUSED_PARAM(scope);
UNUSED_PARAM(vm);
@@ -217,17 +218,18 @@
if (!unlinkedEvalCode)
return exception;
- OwnPtr<CodeBlock> previousCodeBlock = m_evalCodeBlock.release();
- ASSERT((jitType == JITCode::bottomTierJIT()) == !previousCodeBlock);
m_unlinkedEvalCodeBlock.set(*vm, this, unlinkedEvalCode);
- m_evalCodeBlock = adoptPtr(new EvalCodeBlock(this, unlinkedEvalCode, lexicalGlobalObject, source().provider(), scope->localDepth(), previousCodeBlock.release()));
- m_evalCodeBlock->copyPostParseDataFromAlternative();
+ ASSERT((jitType == JITCode::bottomTierJIT()) == !m_evalCodeBlock);
+
+ newCodeBlock = adoptRef(new EvalCodeBlock(this, unlinkedEvalCode, lexicalGlobalObject, source().provider(), scope->localDepth()));
}
#if ENABLE(JIT)
- if (!prepareForExecution(exec, m_evalCodeBlock, m_jitCodeForCall, jitType, bytecodeIndex))
+ if (!prepareForExecution(exec, newCodeBlock.get(), m_jitCodeForCall, jitType, bytecodeIndex))
return 0;
#endif
+
+ m_evalCodeBlock = newCodeBlock;
#if ENABLE(JIT)
Heap::heap(this)->reportExtraMemoryCost(sizeof(*m_evalCodeBlock) + m_jitCodeForCall->size());
@@ -302,7 +304,7 @@
#if ENABLE(JIT)
bool ProgramExecutable::jitCompile(ExecState* exec)
{
- return jitCompileIfAppropriate(exec, m_programCodeBlock, m_jitCodeForCall, JITCode::bottomTierJIT(), UINT_MAX, JITCompilationCanFail);
+ return jitCompileIfAppropriate(exec, m_programCodeBlock.get(), m_jitCodeForCall, JITCode::bottomTierJIT(), UINT_MAX, JITCompilationCanFail);
}
#endif
@@ -315,21 +317,24 @@
UNUSED_PARAM(jitType);
UNUSED_PARAM(bytecodeIndex);
#endif
+
+ RefPtr<ProgramCodeBlock> newCodeBlock;
+
if (!!m_programCodeBlock) {
- OwnPtr<ProgramCodeBlock> newCodeBlock = adoptPtr(new ProgramCodeBlock(CodeBlock::CopyParsedBlock, *m_programCodeBlock));
- newCodeBlock->setAlternative(static_pointer_cast<CodeBlock>(m_programCodeBlock.release()));
- m_programCodeBlock = newCodeBlock.release();
+ newCodeBlock = adoptRef(new ProgramCodeBlock(CodeBlock::CopyParsedBlock, *m_programCodeBlock));
+ newCodeBlock->setAlternative(static_pointer_cast<CodeBlock>(m_programCodeBlock));
} else {
JSGlobalObject* globalObject = scope->globalObject();
- m_programCodeBlock = adoptPtr(new ProgramCodeBlock(this, m_unlinkedProgramCodeBlock.get(), globalObject, source().provider(), m_programCodeBlock.release()));
- m_programCodeBlock->copyPostParseDataFromAlternative();
+ newCodeBlock = adoptRef(new ProgramCodeBlock(this, m_unlinkedProgramCodeBlock.get(), globalObject, source().provider()));
}
#if ENABLE(JIT)
- if (!prepareForExecution(exec, m_programCodeBlock, m_jitCodeForCall, jitType, bytecodeIndex))
+ if (!prepareForExecution(exec, newCodeBlock.get(), m_jitCodeForCall, jitType, bytecodeIndex))
return 0;
#endif
+ m_programCodeBlock = newCodeBlock;
+
#if ENABLE(JIT)
Heap::heap(this)->reportExtraMemoryCost(sizeof(*m_programCodeBlock) + m_jitCodeForCall->size());
#else
@@ -482,19 +487,24 @@
#if ENABLE(JIT)
bool FunctionExecutable::jitCompileForCall(ExecState* exec)
{
- return jitCompileFunctionIfAppropriate(exec, m_codeBlockForCall, m_jitCodeForCall, m_jitCodeForCallWithArityCheck, JITCode::bottomTierJIT(), UINT_MAX, JITCompilationCanFail);
+ return jitCompileFunctionIfAppropriate(exec, m_codeBlockForCall.get(), m_jitCodeForCall, m_jitCodeForCallWithArityCheck, JITCode::bottomTierJIT(), UINT_MAX, JITCompilationCanFail);
}
bool FunctionExecutable::jitCompileForConstruct(ExecState* exec)
{
- return jitCompileFunctionIfAppropriate(exec, m_codeBlockForConstruct, m_jitCodeForConstruct, m_jitCodeForConstructWithArityCheck, JITCode::bottomTierJIT(), UINT_MAX, JITCompilationCanFail);
+ return jitCompileFunctionIfAppropriate(exec, m_codeBlockForConstruct.get(), m_jitCodeForConstruct, m_jitCodeForConstructWithArityCheck, JITCode::bottomTierJIT(), UINT_MAX, JITCompilationCanFail);
}
#endif
-PassOwnPtr<FunctionCodeBlock> FunctionExecutable::produceCodeBlockFor(JSScope* scope, CodeSpecializationKind specializationKind, JSObject*& exception)
+PassRefPtr<FunctionCodeBlock> FunctionExecutable::produceCodeBlockFor(JSScope* scope, CodeSpecializationKind specializationKind, JSObject*& exception)
{
- if (!!codeBlockFor(specializationKind))
- return adoptPtr(new FunctionCodeBlock(CodeBlock::CopyParsedBlock, *codeBlockFor(specializationKind)));
+ RefPtr<FunctionCodeBlock> alternative = codeBlockFor(specializationKind);
+
+ if (!!alternative) {
+ RefPtr<FunctionCodeBlock> result = adoptRef(new FunctionCodeBlock(CodeBlock::CopyParsedBlock, *codeBlockFor(specializationKind)));
+ result->setAlternative(alternative);
+ return result.release();
+ }
VM* vm = scope->vm();
JSGlobalObject* globalObject = scope->globalObject();
@@ -509,9 +519,7 @@
return nullptr;
}
- OwnPtr<FunctionCodeBlock> result = adoptPtr(new FunctionCodeBlock(this, unlinkedCodeBlock, globalObject, source().provider(), source().startOffset()));
- result->copyPostParseDataFrom(codeBlockFor(specializationKind).get());
- return result.release();
+ return adoptRef(new FunctionCodeBlock(this, unlinkedCodeBlock, globalObject, source().provider(), source().startOffset()));
}
@@ -527,22 +535,22 @@
#endif
ASSERT((jitType == JITCode::bottomTierJIT()) == !m_codeBlockForCall);
JSObject* exception;
- OwnPtr<FunctionCodeBlock> newCodeBlock = produceCodeBlockFor(scope, CodeForCall, exception);
+
+ RefPtr<FunctionCodeBlock> newCodeBlock = produceCodeBlockFor(scope, CodeForCall, exception);
if (!newCodeBlock)
return exception;
+
+#if ENABLE(JIT)
+ if (!prepareFunctionForExecution(exec, newCodeBlock.get(), m_jitCodeForCall, m_jitCodeForCallWithArityCheck, jitType, bytecodeIndex, CodeForCall))
+ return 0;
+#endif
- newCodeBlock->setAlternative(static_pointer_cast<CodeBlock>(m_codeBlockForCall.release()));
- m_codeBlockForCall = newCodeBlock.release();
+ m_codeBlockForCall = newCodeBlock;
m_numParametersForCall = m_codeBlockForCall->numParameters();
RELEASE_ASSERT(m_numParametersForCall);
#if ENABLE(JIT)
- if (!prepareFunctionForExecution(exec, m_codeBlockForCall, m_jitCodeForCall, m_jitCodeForCallWithArityCheck, jitType, bytecodeIndex, CodeForCall))
- return 0;
-#endif
-
-#if ENABLE(JIT)
Heap::heap(this)->reportExtraMemoryCost(sizeof(*m_codeBlockForCall) + m_jitCodeForCall->size());
#else
Heap::heap(this)->reportExtraMemoryCost(sizeof(*m_codeBlockForCall));
@@ -563,22 +571,21 @@
ASSERT((jitType == JITCode::bottomTierJIT()) == !m_codeBlockForConstruct);
JSObject* exception;
- OwnPtr<FunctionCodeBlock> newCodeBlock = produceCodeBlockFor(scope, CodeForConstruct, exception);
+ RefPtr<FunctionCodeBlock> newCodeBlock = produceCodeBlockFor(scope, CodeForConstruct, exception);
if (!newCodeBlock)
return exception;
- newCodeBlock->setAlternative(static_pointer_cast<CodeBlock>(m_codeBlockForConstruct.release()));
- m_codeBlockForConstruct = newCodeBlock.release();
+#if ENABLE(JIT)
+ if (!prepareFunctionForExecution(exec, newCodeBlock.get(), m_jitCodeForConstruct, m_jitCodeForConstructWithArityCheck, jitType, bytecodeIndex, CodeForConstruct))
+ return 0;
+#endif
+
+ m_codeBlockForConstruct = newCodeBlock;
m_numParametersForConstruct = m_codeBlockForConstruct->numParameters();
RELEASE_ASSERT(m_numParametersForConstruct);
#if ENABLE(JIT)
- if (!prepareFunctionForExecution(exec, m_codeBlockForConstruct, m_jitCodeForConstruct, m_jitCodeForConstructWithArityCheck, jitType, bytecodeIndex, CodeForConstruct))
- return 0;
-#endif
-
-#if ENABLE(JIT)
Heap::heap(this)->reportExtraMemoryCost(sizeof(*m_codeBlockForConstruct) + m_jitCodeForConstruct->size());
#else
Heap::heap(this)->reportExtraMemoryCost(sizeof(*m_codeBlockForConstruct));
Modified: branches/dfgFourthTier/Source/_javascript_Core/runtime/Executable.h (149859 => 149860)
--- branches/dfgFourthTier/Source/_javascript_Core/runtime/Executable.h 2013-05-10 01:46:32 UTC (rev 149859)
+++ branches/dfgFourthTier/Source/_javascript_Core/runtime/Executable.h 2013-05-10 02:45:10 UTC (rev 149860)
@@ -476,7 +476,7 @@
JSObject* compileInternal(ExecState*, JSScope*, JITCode::JITType, unsigned bytecodeIndex = UINT_MAX);
static void visitChildren(JSCell*, SlotVisitor&);
- OwnPtr<EvalCodeBlock> m_evalCodeBlock;
+ RefPtr<EvalCodeBlock> m_evalCodeBlock;
WriteBarrier<UnlinkedEvalCodeBlock> m_unlinkedEvalCodeBlock;
};
@@ -555,7 +555,7 @@
static void visitChildren(JSCell*, SlotVisitor&);
WriteBarrier<UnlinkedProgramCodeBlock> m_unlinkedProgramCodeBlock;
- OwnPtr<ProgramCodeBlock> m_programCodeBlock;
+ RefPtr<ProgramCodeBlock> m_programCodeBlock;
};
class FunctionExecutable : public ScriptExecutable {
@@ -590,7 +590,7 @@
return *m_codeBlockForConstruct;
}
- PassOwnPtr<FunctionCodeBlock> produceCodeBlockFor(JSScope*, CodeSpecializationKind, JSObject*& exception);
+ PassRefPtr<FunctionCodeBlock> produceCodeBlockFor(JSScope*, CodeSpecializationKind, JSObject*& exception);
JSObject* compileForCall(ExecState* exec, JSScope* scope)
{
@@ -742,7 +742,7 @@
JSObject* compileForCallInternal(ExecState*, JSScope*, JITCode::JITType, unsigned bytecodeIndex = UINT_MAX);
JSObject* compileForConstructInternal(ExecState*, JSScope*, JITCode::JITType, unsigned bytecodeIndex = UINT_MAX);
- OwnPtr<FunctionCodeBlock>& codeBlockFor(CodeSpecializationKind kind)
+ RefPtr<FunctionCodeBlock>& codeBlockFor(CodeSpecializationKind kind)
{
if (kind == CodeForCall)
return m_codeBlockForCall;
@@ -763,8 +763,8 @@
static const unsigned StructureFlags = OverridesVisitChildren | ScriptExecutable::StructureFlags;
WriteBarrier<UnlinkedFunctionExecutable> m_unlinkedExecutable;
- OwnPtr<FunctionCodeBlock> m_codeBlockForCall;
- OwnPtr<FunctionCodeBlock> m_codeBlockForConstruct;
+ RefPtr<FunctionCodeBlock> m_codeBlockForCall;
+ RefPtr<FunctionCodeBlock> m_codeBlockForConstruct;
};
inline JSFunction::JSFunction(VM& vm, FunctionExecutable* executable, JSScope* scope)
Modified: branches/dfgFourthTier/Source/_javascript_Core/runtime/ExecutionHarness.h (149859 => 149860)
--- branches/dfgFourthTier/Source/_javascript_Core/runtime/ExecutionHarness.h 2013-05-10 01:46:32 UTC (rev 149859)
+++ branches/dfgFourthTier/Source/_javascript_Core/runtime/ExecutionHarness.h 2013-05-10 02:45:10 UTC (rev 149860)
@@ -36,22 +36,22 @@
namespace JSC {
template<typename CodeBlockType>
-inline bool prepareForExecution(ExecState* exec, OwnPtr<CodeBlockType>& codeBlock, RefPtr<JITCode>& jitCode, JITCode::JITType jitType, unsigned bytecodeIndex)
+inline bool prepareForExecution(ExecState* exec, CodeBlockType* codeBlock, RefPtr<JITCode>& jitCode, JITCode::JITType jitType, unsigned bytecodeIndex)
{
#if ENABLE(LLINT)
if (JITCode::isBaselineCode(jitType)) {
// Start off in the low level interpreter.
- LLInt::getEntrypoint(exec->vm(), codeBlock.get(), jitCode);
+ LLInt::getEntrypoint(exec->vm(), codeBlock, jitCode);
codeBlock->setJITCode(jitCode, MacroAssemblerCodePtr());
if (exec->vm().m_perBytecodeProfiler)
- exec->vm().m_perBytecodeProfiler->ensureBytecodesFor(codeBlock.get());
+ exec->vm().m_perBytecodeProfiler->ensureBytecodesFor(codeBlock);
return true;
}
#endif // ENABLE(LLINT)
return jitCompileIfAppropriate(exec, codeBlock, jitCode, jitType, bytecodeIndex, JITCode::isBaselineCode(jitType) ? JITCompilationMustSucceed : JITCompilationCanFail);
}
-inline bool prepareFunctionForExecution(ExecState* exec, OwnPtr<FunctionCodeBlock>& codeBlock, RefPtr<JITCode>& jitCode, MacroAssemblerCodePtr& jitCodeWithArityCheck, JITCode::JITType jitType, unsigned bytecodeIndex, CodeSpecializationKind kind)
+inline bool prepareFunctionForExecution(ExecState* exec, FunctionCodeBlock* codeBlock, RefPtr<JITCode>& jitCode, MacroAssemblerCodePtr& jitCodeWithArityCheck, JITCode::JITType jitType, unsigned bytecodeIndex, CodeSpecializationKind kind)
{
#if ENABLE(LLINT)
if (JITCode::isBaselineCode(jitType)) {
@@ -59,7 +59,7 @@
LLInt::getFunctionEntrypoint(exec->vm(), kind, jitCode, jitCodeWithArityCheck);
codeBlock->setJITCode(jitCode, jitCodeWithArityCheck);
if (exec->vm().m_perBytecodeProfiler)
- exec->vm().m_perBytecodeProfiler->ensureBytecodesFor(codeBlock.get());
+ exec->vm().m_perBytecodeProfiler->ensureBytecodesFor(codeBlock);
return true;
}
#else