Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (154934 => 154935)
--- trunk/Source/_javascript_Core/ChangeLog 2013-09-01 00:21:16 UTC (rev 154934)
+++ trunk/Source/_javascript_Core/ChangeLog 2013-09-01 02:02:47 UTC (rev 154935)
@@ -1,3 +1,60 @@
+2013-08-30 Filip Pizlo <[email protected]>
+
+ CodeBlock refactoring broke profile dumping
+ https://bugs.webkit.org/show_bug.cgi?id=120551
+
+ Reviewed by Michael Saboff.
+
+ Fix the bug, and did a big clean-up of how Executable returns CodeBlocks. A lot
+ of the problems we have with code like CodeBlock::baselineVersion() is that we
+ were trying *way too hard* to side-step the fact that Executable can't return a
+ CodeBlock*. Previously it could only return CodeBlock&, so if it didn't have a
+ CodeBlock yet, you were screwed. And if you didn't know, or weren't sure, if it
+ did have a CodeBlock, you were really going to have a bad time. Also it really
+ bugs me that the methods were called generatedBytecode(). In all other contexts
+ if you ask for a CodeBlock, then method to call is codeBlock(). So I made all
+ of those changes.
+
+ * bytecode/CodeBlock.cpp:
+ (JSC::CodeBlock::baselineVersion):
+ (JSC::ProgramCodeBlock::replacement):
+ (JSC::EvalCodeBlock::replacement):
+ (JSC::FunctionCodeBlock::replacement):
+ (JSC::CodeBlock::globalObjectFor):
+ * bytecode/CodeOrigin.cpp:
+ (JSC::InlineCallFrame::hash):
+ * dfg/DFGOperations.cpp:
+ * interpreter/Interpreter.cpp:
+ (JSC::Interpreter::execute):
+ (JSC::Interpreter::executeCall):
+ (JSC::Interpreter::executeConstruct):
+ (JSC::Interpreter::prepareForRepeatCall):
+ * jit/JITCode.h:
+ (JSC::JITCode::isExecutableScript):
+ (JSC::JITCode::isLowerTier):
+ * jit/JITStubs.cpp:
+ (JSC::lazyLinkFor):
+ (JSC::DEFINE_STUB_FUNCTION):
+ * llint/LLIntSlowPaths.cpp:
+ (JSC::LLInt::traceFunctionPrologue):
+ (JSC::LLInt::LLINT_SLOW_PATH_DECL):
+ (JSC::LLInt::setUpCall):
+ * runtime/ArrayPrototype.cpp:
+ (JSC::isNumericCompareFunction):
+ * runtime/CommonSlowPaths.h:
+ (JSC::CommonSlowPaths::arityCheckFor):
+ * runtime/Executable.cpp:
+ (JSC::ScriptExecutable::installCode):
+ * runtime/Executable.h:
+ (JSC::EvalExecutable::codeBlock):
+ (JSC::ProgramExecutable::codeBlock):
+ (JSC::FunctionExecutable::eitherCodeBlock):
+ (JSC::FunctionExecutable::codeBlockForCall):
+ (JSC::FunctionExecutable::codeBlockForConstruct):
+ (JSC::FunctionExecutable::codeBlockFor):
+ * runtime/FunctionExecutableDump.cpp:
+ (JSC::FunctionExecutableDump::dump):
+
2013-08-30 Oliver Hunt <[email protected]>
Implement ES6 Set class
Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp (154934 => 154935)
--- trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp 2013-09-01 00:21:16 UTC (rev 154934)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp 2013-09-01 02:02:47 UTC (rev 154935)
@@ -2363,22 +2363,18 @@
CodeBlock* CodeBlock::baselineVersion()
{
-#if ENABLE(JIT)
- // When we're initializing the original baseline code block, we won't be able
- // to get its replacement. But we'll know that it's the original baseline code
- // block because it won't have JIT code yet and it won't have an alternative.
- if (jitType() == JITCode::None && !alternative())
+ if (JITCode::isBaselineCode(jitType()))
return this;
-
+#if ENABLE(JIT)
CodeBlock* result = replacement();
- ASSERT(result);
while (result->alternative())
result = result->alternative();
- ASSERT(result);
- ASSERT(JITCode::isBaselineCode(result->jitType()));
+ RELEASE_ASSERT(result);
+ RELEASE_ASSERT(JITCode::isBaselineCode(result->jitType()));
return result;
#else
- return this;
+ RELEASE_ASSERT_NOT_REACHED();
+ return 0;
#endif
}
@@ -2712,17 +2708,17 @@
CodeBlock* ProgramCodeBlock::replacement()
{
- return &static_cast<ProgramExecutable*>(ownerExecutable())->generatedBytecode();
+ return jsCast<ProgramExecutable*>(ownerExecutable())->codeBlock();
}
CodeBlock* EvalCodeBlock::replacement()
{
- return &static_cast<EvalExecutable*>(ownerExecutable())->generatedBytecode();
+ return jsCast<EvalExecutable*>(ownerExecutable())->codeBlock();
}
CodeBlock* FunctionCodeBlock::replacement()
{
- return &static_cast<FunctionExecutable*>(ownerExecutable())->generatedBytecodeFor(m_isConstructor ? CodeForConstruct : CodeForCall);
+ return jsCast<FunctionExecutable*>(ownerExecutable())->codeBlockFor(m_isConstructor ? CodeForConstruct : CodeForCall);
}
DFG::CapabilityLevel ProgramCodeBlock::capabilityLevelInternal()
@@ -2773,7 +2769,7 @@
{
if (!codeOrigin.inlineCallFrame)
return globalObject();
- return jsCast<FunctionExecutable*>(codeOrigin.inlineCallFrame->executable.get())->generatedBytecode().globalObject();
+ return jsCast<FunctionExecutable*>(codeOrigin.inlineCallFrame->executable.get())->eitherCodeBlock()->globalObject();
}
void CodeBlock::noticeIncomingCall(ExecState* callerFrame)
Modified: trunk/Source/_javascript_Core/bytecode/CodeOrigin.cpp (154934 => 154935)
--- trunk/Source/_javascript_Core/bytecode/CodeOrigin.cpp 2013-09-01 00:21:16 UTC (rev 154934)
+++ trunk/Source/_javascript_Core/bytecode/CodeOrigin.cpp 2013-09-01 02:02:47 UTC (rev 154935)
@@ -89,8 +89,8 @@
CodeBlockHash InlineCallFrame::hash() const
{
- return jsCast<FunctionExecutable*>(executable.get())->generatedBytecodeFor(
- specializationKind()).hash();
+ return jsCast<FunctionExecutable*>(executable.get())->codeBlockFor(
+ specializationKind())->hash();
}
CString InlineCallFrame::inferredName() const
Modified: trunk/Source/_javascript_Core/dfg/DFGOperations.cpp (154934 => 154935)
--- trunk/Source/_javascript_Core/dfg/DFGOperations.cpp 2013-09-01 00:21:16 UTC (rev 154934)
+++ trunk/Source/_javascript_Core/dfg/DFGOperations.cpp 2013-09-01 02:02:47 UTC (rev 154935)
@@ -1286,7 +1286,7 @@
vm->throwException(exec, createStackOverflowError(exec));
return reinterpret_cast<char*>(vm->getCTIStub(throwExceptionFromCallSlowPathGenerator).code().executableAddress());
}
- codeBlock = &functionExecutable->generatedBytecodeFor(kind);
+ codeBlock = functionExecutable->codeBlockFor(kind);
if (execCallee->argumentCountIncludingThis() < static_cast<size_t>(codeBlock->numParameters()))
codePtr = functionExecutable->generatedJITCodeWithArityCheckFor(kind);
else
@@ -1361,7 +1361,7 @@
if (callee->executable()->isHostFunction())
codeBlock = 0;
else {
- codeBlock = &jsCast<FunctionExecutable*>(callee->executable())->generatedBytecodeForCall();
+ codeBlock = jsCast<FunctionExecutable*>(callee->executable())->codeBlockForCall();
if (execCallee->argumentCountIncludingThis() < static_cast<size_t>(codeBlock->numParameters()))
return false;
}
Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.cpp (154934 => 154935)
--- trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2013-09-01 00:21:16 UTC (rev 154934)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2013-09-01 02:02:47 UTC (rev 154935)
@@ -737,7 +737,7 @@
if (JSObject* error = program->prepareForExecution(callFrame, scope, CodeForCall))
return checkedReturn(callFrame->vm().throwException(callFrame, error));
- ProgramCodeBlock* codeBlock = &program->generatedBytecode();
+ ProgramCodeBlock* codeBlock = program->codeBlock();
if (UNLIKELY(vm.watchdog.didFire(callFrame)))
return throwTerminatedExecutionException(callFrame);
@@ -807,7 +807,7 @@
if (UNLIKELY(!!compileError)) {
return checkedReturn(callFrame->vm().throwException(callFrame, compileError));
}
- newCodeBlock = &callData.js.functionExecutable->generatedBytecodeForCall();
+ newCodeBlock = callData.js.functionExecutable->codeBlockForCall();
ASSERT(!!newCodeBlock);
newCodeBlock->m_shouldAlwaysBeInlined = false;
} else
@@ -886,7 +886,7 @@
if (UNLIKELY(!!compileError)) {
return checkedReturn(callFrame->vm().throwException(callFrame, compileError));
}
- newCodeBlock = &constructData.js.functionExecutable->generatedBytecodeForConstruct();
+ newCodeBlock = constructData.js.functionExecutable->codeBlockForConstruct();
ASSERT(!!newCodeBlock);
newCodeBlock->m_shouldAlwaysBeInlined = false;
} else
@@ -961,7 +961,7 @@
callFrame->vm().throwException(callFrame, error);
return CallFrameClosure();
}
- CodeBlock* newCodeBlock = &functionExecutable->generatedBytecodeForCall();
+ CodeBlock* newCodeBlock = functionExecutable->codeBlockForCall();
newCodeBlock->m_shouldAlwaysBeInlined = false;
size_t argsCount = argumentCountIncludingThis;
@@ -1075,7 +1075,7 @@
JSObject* compileError = eval->prepareForExecution(callFrame, scope, CodeForCall);
if (UNLIKELY(!!compileError))
return checkedReturn(callFrame->vm().throwException(callFrame, compileError));
- EvalCodeBlock* codeBlock = &eval->generatedBytecode();
+ EvalCodeBlock* codeBlock = eval->codeBlock();
if (numVariables || numFunctions) {
BatchedTransitionOptimizer optimizer(vm, variableObject);
Modified: trunk/Source/_javascript_Core/jit/JITCode.h (154934 => 154935)
--- trunk/Source/_javascript_Core/jit/JITCode.h 2013-09-01 00:21:16 UTC (rev 154934)
+++ trunk/Source/_javascript_Core/jit/JITCode.h 2013-09-01 02:02:47 UTC (rev 154935)
@@ -80,6 +80,17 @@
}
}
+ static bool isExecutableScript(JITType jitType)
+ {
+ switch (jitType) {
+ case None:
+ case HostCallThunk:
+ return false;
+ default:
+ return true;
+ }
+ }
+
static bool couldBeInterpreted(JITType jitType)
{
switch (jitType) {
@@ -105,8 +116,8 @@
static bool isLowerTier(JITType expectedLower, JITType expectedHigher)
{
- RELEASE_ASSERT(isJIT(expectedLower));
- RELEASE_ASSERT(isJIT(expectedHigher));
+ RELEASE_ASSERT(isExecutableScript(expectedLower));
+ RELEASE_ASSERT(isExecutableScript(expectedHigher));
return expectedLower < expectedHigher;
}
Modified: trunk/Source/_javascript_Core/jit/JITStubs.cpp (154934 => 154935)
--- trunk/Source/_javascript_Core/jit/JITStubs.cpp 2013-09-01 00:21:16 UTC (rev 154934)
+++ trunk/Source/_javascript_Core/jit/JITStubs.cpp 2013-09-01 02:02:47 UTC (rev 154935)
@@ -1276,7 +1276,7 @@
callFrame->vm().throwException(callFrame, error);
return 0;
}
- codeBlock = &functionExecutable->generatedBytecodeFor(kind);
+ codeBlock = functionExecutable->codeBlockFor(kind);
if (callFrame->argumentCountIncludingThis() < static_cast<size_t>(codeBlock->numParameters())
|| callLinkInfo->callType == CallLinkInfo::CallVarargs)
codePtr = functionExecutable->generatedJITCodeWithArityCheckFor(kind);
@@ -1335,7 +1335,7 @@
ASSERT(executable->hasJITCodeForCall());
codePtr = executable->generatedJITCodeForCall()->addressForCall();
if (!callee->executable()->isHostFunction()) {
- calleeCodeBlock = &jsCast<FunctionExecutable*>(executable)->generatedBytecodeForCall();
+ calleeCodeBlock = jsCast<FunctionExecutable*>(executable)->codeBlockForCall();
if (callFrame->argumentCountIncludingThis() < static_cast<size_t>(calleeCodeBlock->numParameters())) {
shouldLink = false;
codePtr = executable->generatedJITCodeWithArityCheckFor(CodeForCall);
Modified: trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp (154934 => 154935)
--- trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp 2013-09-01 00:21:16 UTC (rev 154934)
+++ trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp 2013-09-01 02:02:47 UTC (rev 154935)
@@ -212,7 +212,7 @@
{
JSFunction* callee = jsCast<JSFunction*>(exec->callee());
FunctionExecutable* executable = callee->jsExecutable();
- CodeBlock* codeBlock = &executable->generatedBytecodeFor(kind);
+ CodeBlock* codeBlock = executable->codeBlockFor(kind);
dataLogF("%p / %p: in %s of function %p, executable %p; numVars = %u, numParameters = %u, numCalleeRegisters = %u, caller = %p.\n",
codeBlock, exec, comment, callee, executable,
codeBlock->m_numVars, codeBlock->numParameters(), codeBlock->m_numCalleeRegisters,
@@ -351,22 +351,22 @@
LLINT_SLOW_PATH_DECL(entry_osr_function_for_call)
{
- return entryOSR(exec, pc, &jsCast<JSFunction*>(exec->callee())->jsExecutable()->generatedBytecodeFor(CodeForCall), "entry_osr_function_for_call", Prologue);
+ return entryOSR(exec, pc, jsCast<JSFunction*>(exec->callee())->jsExecutable()->codeBlockForCall(), "entry_osr_function_for_call", Prologue);
}
LLINT_SLOW_PATH_DECL(entry_osr_function_for_construct)
{
- return entryOSR(exec, pc, &jsCast<JSFunction*>(exec->callee())->jsExecutable()->generatedBytecodeFor(CodeForConstruct), "entry_osr_function_for_construct", Prologue);
+ return entryOSR(exec, pc, jsCast<JSFunction*>(exec->callee())->jsExecutable()->codeBlockForConstruct(), "entry_osr_function_for_construct", Prologue);
}
LLINT_SLOW_PATH_DECL(entry_osr_function_for_call_arityCheck)
{
- return entryOSR(exec, pc, &jsCast<JSFunction*>(exec->callee())->jsExecutable()->generatedBytecodeFor(CodeForCall), "entry_osr_function_for_call_arityCheck", ArityCheck);
+ return entryOSR(exec, pc, jsCast<JSFunction*>(exec->callee())->jsExecutable()->codeBlockForCall(), "entry_osr_function_for_call_arityCheck", ArityCheck);
}
LLINT_SLOW_PATH_DECL(entry_osr_function_for_construct_arityCheck)
{
- return entryOSR(exec, pc, &jsCast<JSFunction*>(exec->callee())->jsExecutable()->generatedBytecodeFor(CodeForConstruct), "entry_osr_function_for_construct_arityCheck", ArityCheck);
+ return entryOSR(exec, pc, jsCast<JSFunction*>(exec->callee())->jsExecutable()->codeBlockForConstruct(), "entry_osr_function_for_construct_arityCheck", ArityCheck);
}
LLINT_SLOW_PATH_DECL(loop_osr)
@@ -1017,7 +1017,7 @@
JSObject* error = functionExecutable->prepareForExecution(execCallee, callee->scope(), kind);
if (error)
LLINT_CALL_THROW(execCallee->callerFrame(), pc, error);
- codeBlock = &functionExecutable->generatedBytecodeFor(kind);
+ codeBlock = functionExecutable->codeBlockFor(kind);
ASSERT(codeBlock);
if (execCallee->argumentCountIncludingThis() < static_cast<size_t>(codeBlock->numParameters()))
codePtr = functionExecutable->jsCodeWithArityCheckEntryFor(kind);
Modified: trunk/Source/_javascript_Core/runtime/ArrayPrototype.cpp (154934 => 154935)
--- trunk/Source/_javascript_Core/runtime/ArrayPrototype.cpp 2013-09-01 00:21:16 UTC (rev 154934)
+++ trunk/Source/_javascript_Core/runtime/ArrayPrototype.cpp 2013-09-01 02:02:47 UTC (rev 154935)
@@ -82,7 +82,7 @@
if (error)
return false;
- return executable->generatedBytecodeForCall().isNumericCompareFunction();
+ return executable->codeBlockForCall()->isNumericCompareFunction();
}
// ------------------------------ ArrayPrototype ----------------------------
Modified: trunk/Source/_javascript_Core/runtime/CommonSlowPaths.h (154934 => 154935)
--- trunk/Source/_javascript_Core/runtime/CommonSlowPaths.h 2013-09-01 00:21:16 UTC (rev 154934)
+++ trunk/Source/_javascript_Core/runtime/CommonSlowPaths.h 2013-09-01 02:02:47 UTC (rev 154935)
@@ -49,7 +49,7 @@
{
JSFunction* callee = jsCast<JSFunction*>(exec->callee());
ASSERT(!callee->isHostFunction());
- CodeBlock* newCodeBlock = &callee->jsExecutable()->generatedBytecodeFor(kind);
+ CodeBlock* newCodeBlock = callee->jsExecutable()->codeBlockFor(kind);
int argumentCountIncludingThis = exec->argumentCountIncludingThis();
// This ensures enough space for the worst case scenario of zero arguments passed by the caller.
Modified: trunk/Source/_javascript_Core/runtime/Executable.cpp (154934 => 154935)
--- trunk/Source/_javascript_Core/runtime/Executable.cpp 2013-09-01 00:21:16 UTC (rev 154934)
+++ trunk/Source/_javascript_Core/runtime/Executable.cpp 2013-09-01 02:02:47 UTC (rev 154935)
@@ -116,6 +116,7 @@
void ScriptExecutable::installCode(CodeBlock* genericCodeBlock)
{
RELEASE_ASSERT(genericCodeBlock->ownerExecutable() == this);
+ RELEASE_ASSERT(JITCode::isExecutableScript(genericCodeBlock->jitType()));
VM& vm = *genericCodeBlock->vm();
Modified: trunk/Source/_javascript_Core/runtime/Executable.h (154934 => 154935)
--- trunk/Source/_javascript_Core/runtime/Executable.h 2013-09-01 00:21:16 UTC (rev 154934)
+++ trunk/Source/_javascript_Core/runtime/Executable.h 2013-09-01 02:02:47 UTC (rev 154935)
@@ -449,10 +449,9 @@
void jettisonOptimizedCode(VM&);
#endif
- EvalCodeBlock& generatedBytecode()
+ EvalCodeBlock* codeBlock()
{
- ASSERT(m_evalCodeBlock);
- return *m_evalCodeBlock;
+ return m_evalCodeBlock.get();
}
static EvalExecutable* create(ExecState*, const SourceCode&, bool isInStrictContext);
@@ -511,10 +510,9 @@
void jettisonOptimizedCode(VM&);
#endif
- ProgramCodeBlock& generatedBytecode()
+ ProgramCodeBlock* codeBlock()
{
- ASSERT(m_programCodeBlock);
- return *m_programCodeBlock;
+ return m_programCodeBlock.get();
}
JSObject* checkSyntax(ExecState*);
@@ -576,12 +574,11 @@
// Returns either call or construct bytecode. This can be appropriate
// for answering questions that that don't vary between call and construct --
// for example, argumentsRegister().
- FunctionCodeBlock& generatedBytecode()
+ FunctionCodeBlock* eitherCodeBlock()
{
if (m_codeBlockForCall)
- return *m_codeBlockForCall;
- ASSERT(m_codeBlockForConstruct);
- return *m_codeBlockForConstruct;
+ return m_codeBlockForCall.get();
+ return m_codeBlockForConstruct.get();
}
#if ENABLE(JIT)
@@ -593,10 +590,9 @@
return m_codeBlockForCall;
}
- FunctionCodeBlock& generatedBytecodeForCall()
+ FunctionCodeBlock* codeBlockForCall()
{
- ASSERT(m_codeBlockForCall);
- return *m_codeBlockForCall;
+ return m_codeBlockForCall.get();
}
#if ENABLE(JIT)
@@ -608,10 +604,9 @@
return m_codeBlockForConstruct;
}
- FunctionCodeBlock& generatedBytecodeForConstruct()
+ FunctionCodeBlock* codeBlockForConstruct()
{
- ASSERT(m_codeBlockForConstruct);
- return *m_codeBlockForConstruct;
+ return m_codeBlockForConstruct.get();
}
#if ENABLE(JIT)
@@ -634,12 +629,12 @@
return isGeneratedForConstruct();
}
- FunctionCodeBlock& generatedBytecodeFor(CodeSpecializationKind kind)
+ FunctionCodeBlock* codeBlockFor(CodeSpecializationKind kind)
{
if (kind == CodeForCall)
- return generatedBytecodeForCall();
+ return codeBlockForCall();
ASSERT(kind == CodeForConstruct);
- return generatedBytecodeForConstruct();
+ return codeBlockForConstruct();
}
FunctionCodeBlock* baselineCodeBlockFor(CodeSpecializationKind);
@@ -673,14 +668,6 @@
private:
FunctionExecutable(VM&, const SourceCode&, UnlinkedFunctionExecutable*, unsigned firstLine, unsigned lastLine, unsigned startColumn);
- RefPtr<FunctionCodeBlock>& codeBlockFor(CodeSpecializationKind kind)
- {
- if (kind == CodeForCall)
- return m_codeBlockForCall;
- ASSERT(kind == CodeForConstruct);
- return m_codeBlockForConstruct;
- }
-
bool isCompiling()
{
#if ENABLE(JIT)
Modified: trunk/Source/_javascript_Core/runtime/FunctionExecutableDump.cpp (154934 => 154935)
--- trunk/Source/_javascript_Core/runtime/FunctionExecutableDump.cpp 2013-09-01 00:21:16 UTC (rev 154934)
+++ trunk/Source/_javascript_Core/runtime/FunctionExecutableDump.cpp 2013-09-01 02:02:47 UTC (rev 154935)
@@ -34,12 +34,12 @@
{
out.print(m_executable->inferredName().string(), "#");
if (m_executable->isGeneratedForCall())
- out.print(m_executable->generatedBytecodeForCall().hash());
+ out.print(m_executable->codeBlockForCall()->hash());
else
out.print("<nogen>");
out.print("/");
if (m_executable->isGeneratedForConstruct())
- out.print(m_executable->generatedBytecodeForConstruct().hash());
+ out.print(m_executable->codeBlockForConstruct()->hash());
else
out.print("<nogen>");
out.print(":[", RawPointer(m_executable), "]");