Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (201765 => 201766)
--- trunk/Source/_javascript_Core/ChangeLog 2016-06-07 19:31:16 UTC (rev 201765)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-06-07 19:51:41 UTC (rev 201766)
@@ -1,3 +1,54 @@
+2016-06-07 Mark Lam <[email protected]>
+
+ calculatedDisplayName() and friends actually need a VM& and not a ExecState/CallFrame.
+ https://bugs.webkit.org/show_bug.cgi?id=158488
+
+ Reviewed by Geoffrey Garen.
+
+ calculatedDisplayName() (and some of its friends) actually just need a VM&.
+ Their work has nothing to do with an ExecState at all. This patch will make that
+ clear by changing these functions to take a VM& arg instead of an ExecState* or
+ CallFrame*.
+
+ Also removed the JS_EXPORT_PRIVATE attribute from Interpreter::StackFrame::toString().
+ The JS_EXPORT_PRIVATE attribute was a holdover from the days when WebInspector
+ was entirely in WebCore. It is no longer needed.
+
+ * debugger/DebuggerCallFrame.cpp:
+ (JSC::DebuggerCallFrame::functionName):
+ * inspector/JSInjectedScriptHost.cpp:
+ (Inspector::JSInjectedScriptHost::functionDetails):
+ * inspector/ScriptCallStackFactory.cpp:
+ (Inspector::createScriptCallStackFromException):
+ * interpreter/CallFrame.cpp:
+ (JSC::CallFrame::friendlyFunctionName):
+ * interpreter/Interpreter.cpp:
+ (JSC::StackFrame::friendlySourceURL):
+ (JSC::StackFrame::friendlyFunctionName):
+ (JSC::StackFrame::expressionInfo):
+ (JSC::StackFrame::toString):
+ (JSC::Interpreter::stackTraceAsString):
+ * interpreter/Interpreter.h:
+ * interpreter/StackVisitor.cpp:
+ (JSC::StackVisitor::Frame::functionName):
+ * runtime/InternalFunction.cpp:
+ (JSC::InternalFunction::name):
+ (JSC::InternalFunction::displayName):
+ (JSC::InternalFunction::getCallData):
+ (JSC::InternalFunction::calculatedDisplayName):
+ * runtime/InternalFunction.h:
+ (JSC::InternalFunction::createStructure):
+ * runtime/JSFunction.cpp:
+ (JSC::JSFunction::name):
+ (JSC::JSFunction::displayName):
+ (JSC::JSFunction::calculatedDisplayName):
+ (JSC::JSFunction::getConstructData):
+ (JSC::getCalculatedDisplayName):
+ * runtime/JSFunction.h:
+ (JSC::JSFunction::executable):
+ * runtime/JSObject.cpp:
+ (JSC::JSObject::calculatedClassName):
+
2016-06-07 Yusuke Suzuki <[email protected]>
[JSC] Do not allocate unnecessary UTF-8 string for encodeXXX functions
Modified: trunk/Source/_javascript_Core/debugger/DebuggerCallFrame.cpp (201765 => 201766)
--- trunk/Source/_javascript_Core/debugger/DebuggerCallFrame.cpp 2016-06-07 19:31:16 UTC (rev 201765)
+++ trunk/Source/_javascript_Core/debugger/DebuggerCallFrame.cpp 2016-06-07 19:51:41 UTC (rev 201766)
@@ -138,7 +138,7 @@
if (isTailDeleted()) {
if (JSFunction* func = jsDynamicCast<JSFunction*>(m_shadowChickenFrame.callee))
- return func->calculatedDisplayName(m_validMachineFrame);
+ return func->calculatedDisplayName(m_validMachineFrame->vm());
return m_shadowChickenFrame.codeBlock->inferredName().data();
}
Modified: trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.cpp (201765 => 201766)
--- trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.cpp 2016-06-07 19:31:16 UTC (rev 201765)
+++ trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.cpp 2016-06-07 19:51:41 UTC (rev 201766)
@@ -220,22 +220,23 @@
if (columnNumber)
columnNumber -= 1;
+ VM& vm = exec->vm();
String scriptID = String::number(sourceCode->provider()->asID());
JSObject* location = constructEmptyObject(exec);
- location->putDirect(exec->vm(), Identifier::fromString(exec, "scriptId"), jsString(exec, scriptID));
- location->putDirect(exec->vm(), Identifier::fromString(exec, "lineNumber"), jsNumber(lineNumber));
- location->putDirect(exec->vm(), Identifier::fromString(exec, "columnNumber"), jsNumber(columnNumber));
+ location->putDirect(vm, Identifier::fromString(exec, "scriptId"), jsString(exec, scriptID));
+ location->putDirect(vm, Identifier::fromString(exec, "lineNumber"), jsNumber(lineNumber));
+ location->putDirect(vm, Identifier::fromString(exec, "columnNumber"), jsNumber(columnNumber));
JSObject* result = constructEmptyObject(exec);
- result->putDirect(exec->vm(), Identifier::fromString(exec, "location"), location);
+ result->putDirect(vm, Identifier::fromString(exec, "location"), location);
String name = function->name();
if (!name.isEmpty())
- result->putDirect(exec->vm(), Identifier::fromString(exec, "name"), jsString(exec, name));
+ result->putDirect(vm, Identifier::fromString(exec, "name"), jsString(exec, name));
- String displayName = function->displayName(exec);
+ String displayName = function->displayName(vm);
if (!displayName.isEmpty())
- result->putDirect(exec->vm(), Identifier::fromString(exec, "displayName"), jsString(exec, displayName));
+ result->putDirect(vm, Identifier::fromString(exec, "displayName"), jsString(exec, displayName));
// FIXME: provide function scope data in "scopesRaw" property when JSC supports it.
// <https://webkit.org/b/87192> [JSC] expose function (closure) inner context to debugger
Modified: trunk/Source/_javascript_Core/inspector/ScriptCallStackFactory.cpp (201765 => 201766)
--- trunk/Source/_javascript_Core/inspector/ScriptCallStackFactory.cpp 2016-06-07 19:31:16 UTC (rev 201765)
+++ trunk/Source/_javascript_Core/inspector/ScriptCallStackFactory.cpp 2016-06-07 19:51:41 UTC (rev 201766)
@@ -138,11 +138,12 @@
{
Vector<ScriptCallFrame> frames;
RefCountedArray<StackFrame> stackTrace = exception->stack();
+ VM& vm = exec->vm();
for (size_t i = 0; i < stackTrace.size() && i < maxStackSize; i++) {
unsigned line;
unsigned column;
stackTrace[i].computeLineAndColumn(line, column);
- String functionName = stackTrace[i].friendlyFunctionName(exec);
+ String functionName = stackTrace[i].friendlyFunctionName(vm);
frames.append(ScriptCallFrame(functionName, stackTrace[i].friendlySourceURL(), static_cast<SourceID>(stackTrace[i].sourceID), line, column));
}
Modified: trunk/Source/_javascript_Core/interpreter/CallFrame.cpp (201765 => 201766)
--- trunk/Source/_javascript_Core/interpreter/CallFrame.cpp 2016-06-07 19:31:16 UTC (rev 201765)
+++ trunk/Source/_javascript_Core/interpreter/CallFrame.cpp 2016-06-07 19:51:41 UTC (rev 201766)
@@ -229,7 +229,7 @@
return ASCIILiteral("global code");
case FunctionCode:
if (callee())
- return getCalculatedDisplayName(this, callee());
+ return getCalculatedDisplayName(vm(), callee());
return emptyString();
}
Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.cpp (201765 => 201766)
--- trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2016-06-07 19:31:16 UTC (rev 201765)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2016-06-07 19:51:41 UTC (rev 201766)
@@ -106,7 +106,7 @@
return traceLine.isNull() ? emptyString() : traceLine;
}
-String StackFrame::friendlyFunctionName(CallFrame* callFrame) const
+String StackFrame::friendlyFunctionName(VM& vm) const
{
String traceLine;
JSObject* stackFrameCallee = callee.get();
@@ -120,10 +120,10 @@
break;
case StackFrameNativeCode:
if (callee)
- traceLine = getCalculatedDisplayName(callFrame, stackFrameCallee).impl();
+ traceLine = getCalculatedDisplayName(vm, stackFrameCallee).impl();
break;
case StackFrameFunctionCode:
- traceLine = getCalculatedDisplayName(callFrame, stackFrameCallee).impl();
+ traceLine = getCalculatedDisplayName(vm, stackFrameCallee).impl();
break;
case StackFrameGlobalCode:
traceLine = "global code";
@@ -496,10 +496,10 @@
divot += characterOffset;
}
-String StackFrame::toString(CallFrame* callFrame)
+String StackFrame::toString(VM& vm)
{
StringBuilder traceBuild;
- String functionName = friendlyFunctionName(callFrame);
+ String functionName = friendlyFunctionName(vm);
String sourceURL = friendlySourceURL();
traceBuild.append(functionName);
if (!sourceURL.isEmpty()) {
@@ -593,8 +593,9 @@
{
// FIXME: JSStringJoiner could be more efficient than StringBuilder here.
StringBuilder builder;
+ VM& vm = exec->vm();
for (unsigned i = 0; i < stackTrace.size(); i++) {
- builder.append(String(stackTrace[i].toString(exec)));
+ builder.append(String(stackTrace[i].toString(vm)));
if (i != stackTrace.size() - 1)
builder.append('\n');
}
Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.h (201765 => 201766)
--- trunk/Source/_javascript_Core/interpreter/Interpreter.h 2016-06-07 19:31:16 UTC (rev 201765)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.h 2016-06-07 19:51:41 UTC (rev 201766)
@@ -95,9 +95,9 @@
unsigned bytecodeOffset;
String sourceURL;
intptr_t sourceID;
- JS_EXPORT_PRIVATE String toString(CallFrame*);
+ String toString(VM&);
String friendlySourceURL() const;
- String friendlyFunctionName(CallFrame*) const;
+ String friendlyFunctionName(VM&) const;
JS_EXPORT_PRIVATE void computeLineAndColumn(unsigned& line, unsigned& column);
private:
Modified: trunk/Source/_javascript_Core/interpreter/StackVisitor.cpp (201765 => 201766)
--- trunk/Source/_javascript_Core/interpreter/StackVisitor.cpp 2016-06-07 19:31:16 UTC (rev 201765)
+++ trunk/Source/_javascript_Core/interpreter/StackVisitor.cpp 2016-06-07 19:51:41 UTC (rev 201766)
@@ -223,10 +223,10 @@
break;
case CodeType::Native:
if (callee)
- traceLine = getCalculatedDisplayName(callFrame(), callee).impl();
+ traceLine = getCalculatedDisplayName(callFrame()->vm(), callee).impl();
break;
case CodeType::Function:
- traceLine = getCalculatedDisplayName(callFrame(), callee).impl();
+ traceLine = getCalculatedDisplayName(callFrame()->vm(), callee).impl();
break;
case CodeType::Global:
traceLine = ASCIILiteral("global code");
Modified: trunk/Source/_javascript_Core/runtime/InternalFunction.cpp (201765 => 201766)
--- trunk/Source/_javascript_Core/runtime/InternalFunction.cpp 2016-06-07 19:31:16 UTC (rev 201765)
+++ trunk/Source/_javascript_Core/runtime/InternalFunction.cpp 2016-06-07 19:51:41 UTC (rev 201766)
@@ -65,9 +65,9 @@
return name;
}
-const String InternalFunction::displayName(ExecState* exec)
+const String InternalFunction::displayName(VM& vm)
{
- JSValue displayName = getDirect(exec->vm(), exec->vm().propertyNames->displayName);
+ JSValue displayName = getDirect(vm, vm.propertyNames->displayName);
if (displayName && isJSString(displayName))
return asString(displayName)->tryGetValue();
@@ -81,9 +81,9 @@
return CallType::None;
}
-const String InternalFunction::calculatedDisplayName(ExecState* exec)
+const String InternalFunction::calculatedDisplayName(VM& vm)
{
- const String explicitName = displayName(exec);
+ const String explicitName = displayName(vm);
if (!explicitName.isEmpty())
return explicitName;
Modified: trunk/Source/_javascript_Core/runtime/InternalFunction.h (201765 => 201766)
--- trunk/Source/_javascript_Core/runtime/InternalFunction.h 2016-06-07 19:31:16 UTC (rev 201765)
+++ trunk/Source/_javascript_Core/runtime/InternalFunction.h 2016-06-07 19:51:41 UTC (rev 201766)
@@ -41,8 +41,8 @@
JS_EXPORT_PRIVATE static void visitChildren(JSCell*, SlotVisitor&);
JS_EXPORT_PRIVATE const String& name();
- const String displayName(ExecState*);
- const String calculatedDisplayName(ExecState*);
+ const String displayName(VM&);
+ const String calculatedDisplayName(VM&);
static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue proto)
{
Modified: trunk/Source/_javascript_Core/runtime/JSFunction.cpp (201765 => 201766)
--- trunk/Source/_javascript_Core/runtime/JSFunction.cpp 2016-06-07 19:31:16 UTC (rev 201765)
+++ trunk/Source/_javascript_Core/runtime/JSFunction.cpp 2016-06-07 19:51:41 UTC (rev 201766)
@@ -178,9 +178,9 @@
return jsExecutable()->name().string();
}
-String JSFunction::displayName(ExecState* exec)
+String JSFunction::displayName(VM& vm)
{
- JSValue displayName = getDirect(exec->vm(), exec->vm().propertyNames->displayName);
+ JSValue displayName = getDirect(vm, vm.propertyNames->displayName);
if (displayName && isJSString(displayName))
return asString(displayName)->tryGetValue();
@@ -188,9 +188,9 @@
return String();
}
-const String JSFunction::calculatedDisplayName(ExecState* exec)
+const String JSFunction::calculatedDisplayName(VM& vm)
{
- const String explicitName = displayName(exec);
+ const String explicitName = displayName(vm);
if (!explicitName.isEmpty())
return explicitName;
@@ -556,12 +556,12 @@
return ConstructType::JS;
}
-String getCalculatedDisplayName(CallFrame* callFrame, JSObject* object)
+String getCalculatedDisplayName(VM& vm, JSObject* object)
{
if (JSFunction* function = jsDynamicCast<JSFunction*>(object))
- return function->calculatedDisplayName(callFrame);
+ return function->calculatedDisplayName(vm);
if (InternalFunction* function = jsDynamicCast<InternalFunction*>(object))
- return function->calculatedDisplayName(callFrame);
+ return function->calculatedDisplayName(vm);
return emptyString();
}
Modified: trunk/Source/_javascript_Core/runtime/JSFunction.h (201765 => 201766)
--- trunk/Source/_javascript_Core/runtime/JSFunction.h 2016-06-07 19:31:16 UTC (rev 201765)
+++ trunk/Source/_javascript_Core/runtime/JSFunction.h 2016-06-07 19:51:41 UTC (rev 201766)
@@ -49,7 +49,7 @@
JS_EXPORT_PRIVATE EncodedJSValue JSC_HOST_CALL callHostFunctionAsConstructor(ExecState*);
-JS_EXPORT_PRIVATE String getCalculatedDisplayName(CallFrame*, JSObject*);
+JS_EXPORT_PRIVATE String getCalculatedDisplayName(VM&, JSObject*);
class JSFunction : public JSCallee {
friend class JIT;
@@ -82,8 +82,8 @@
static JSFunction* createBuiltinFunction(VM&, FunctionExecutable*, JSGlobalObject*, const String& name);
JS_EXPORT_PRIVATE String name();
- JS_EXPORT_PRIVATE String displayName(ExecState*);
- const String calculatedDisplayName(ExecState*);
+ JS_EXPORT_PRIVATE String displayName(VM&);
+ const String calculatedDisplayName(VM&);
ExecutableBase* executable() const { return m_executable.get(); }
Modified: trunk/Source/_javascript_Core/runtime/JSObject.cpp (201765 => 201766)
--- trunk/Source/_javascript_Core/runtime/JSObject.cpp 2016-06-07 19:31:16 UTC (rev 201765)
+++ trunk/Source/_javascript_Core/runtime/JSObject.cpp 2016-06-07 19:51:41 UTC (rev 201766)
@@ -319,10 +319,11 @@
if (constructorValue.isCell()) {
if (JSCell* constructorCell = constructorValue.asCell()) {
if (JSObject* ctorObject = constructorCell->getObject()) {
+ VM& vm = exec->vm();
if (JSFunction* constructorFunction = jsDynamicCast<JSFunction*>(ctorObject))
- prototypeFunctionName = constructorFunction->calculatedDisplayName(exec);
+ prototypeFunctionName = constructorFunction->calculatedDisplayName(vm);
else if (InternalFunction* constructorFunction = jsDynamicCast<InternalFunction*>(ctorObject))
- prototypeFunctionName = constructorFunction->calculatedDisplayName(exec);
+ prototypeFunctionName = constructorFunction->calculatedDisplayName(vm);
}
}
}