Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (173599 => 173600)
--- trunk/Source/_javascript_Core/ChangeLog 2014-09-13 02:18:56 UTC (rev 173599)
+++ trunk/Source/_javascript_Core/ChangeLog 2014-09-13 05:21:44 UTC (rev 173600)
@@ -1,3 +1,51 @@
+2014-09-12 Michael Saboff <msab...@apple.com>
+
+ Add JSCallee to program and eval CallFrames
+ https://bugs.webkit.org/show_bug.cgi?id=136785
+
+ Reviewed by Mark Lam.
+
+ Populated Callee slot for program and call eval CallFrames with a JSCallee objects.
+ Made supporting changes including adding a JSCallee structure to global object and adding
+ JSCallee::create() method. Added code so that the newly added callee object won't be
+ returned by Function.caller. Changed null pointer checks of callee to check the if
+ the type is JSFunction* or JSCallee*.
+
+ * debugger/DebuggerCallFrame.cpp:
+ (JSC::DebuggerCallFrame::functionName):
+ (JSC::DebuggerCallFrame::type):
+ * profiler/LegacyProfiler.cpp:
+ (JSC::LegacyProfiler::createCallIdentifier):
+ * interpreter/Interpreter.cpp:
+ (JSC::unwindCallFrame):
+ Changed checks of callee is a JSFunction* or JSCallee* instead of just checking
+ if it is null or not.
+
+ * interpreter/Interpreter.cpp:
+ (JSC::Interpreter::execute): Create and use JSCallee objects for execute(EvalExecutable, ...)
+ and execute(ProgramExecutable, ...)
+
+ * jit/JITCode.cpp:
+ (JSC::JITCode::execute): Use jsDynamicCast to cast only JSFunctions.
+
+ * runtime/JSCallee.cpp:
+ (JSC::JSCallee::create): Not used, therefore deleted.
+
+ * runtime/JSCallee.h:
+ (JSC::JSCallee::create): Added.
+
+ * runtime/JSFunction.cpp:
+ (JSC::JSFunction::callerGetter): Added test to return null for JSCallee's that aren't
+ JSFunction's. This can only be the case when the JSCallee comes from a program or
+ call eval CallFrame.
+
+ * runtime/JSGlobalObject.cpp:
+ (JSC::JSGlobalObject::reset):
+ (JSC::JSGlobalObject::visitChildren):
+ * runtime/JSGlobalObject.h:
+ (JSC::JSGlobalObject::calleeStructure):
+ Added new JSCallee structure.
+
2014-09-10 Jon Honeycutt <jhoneyc...@apple.com>
Re-add the request autocomplete feature
Modified: trunk/Source/_javascript_Core/debugger/DebuggerCallFrame.cpp (173599 => 173600)
--- trunk/Source/_javascript_Core/debugger/DebuggerCallFrame.cpp 2014-09-13 02:18:56 UTC (rev 173599)
+++ trunk/Source/_javascript_Core/debugger/DebuggerCallFrame.cpp 2014-09-13 05:21:44 UTC (rev 173600)
@@ -128,7 +128,7 @@
ASSERT(isValid());
if (!isValid())
return String();
- JSObject* function = m_callFrame->callee();
+ JSFunction* function = jsDynamicCast<JSFunction*>(m_callFrame->callee());
if (!function)
return String();
@@ -162,7 +162,7 @@
if (!isValid())
return ProgramType;
- if (m_callFrame->callee())
+ if (jsDynamicCast<JSFunction*>(m_callFrame->callee()))
return FunctionType;
return ProgramType;
Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.cpp (173599 => 173600)
--- trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2014-09-13 02:18:56 UTC (rev 173599)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2014-09-13 05:21:44 UTC (rev 173600)
@@ -443,7 +443,7 @@
if (Debugger* debugger = callFrame->vmEntryGlobalObject()->debugger()) {
ClearExceptionScope scope(&callFrame->vm());
- if (callFrame->callee())
+ if (jsDynamicCast<JSFunction*>(callFrame->callee()))
debugger->returnEvent(callFrame);
else
debugger->didExecuteProgram(callFrame);
@@ -914,7 +914,7 @@
ASSERT(codeBlock->numParameters() == 1); // 1 parameter for 'this'.
ProtoCallFrame protoCallFrame;
- protoCallFrame.init(codeBlock, scope, 0, thisObj, 1);
+ protoCallFrame.init(codeBlock, scope, JSCallee::create(vm, scope->globalObject(), scope), thisObj, 1);
if (LegacyProfiler* profiler = vm.enabledProfiler())
profiler->willExecute(callFrame, program->sourceURL(), program->lineNo(), program->startColumn());
@@ -1195,7 +1195,7 @@
ASSERT(codeBlock->numParameters() == 1); // 1 parameter for 'this'.
ProtoCallFrame protoCallFrame;
- protoCallFrame.init(codeBlock, scope, 0, thisValue, 1);
+ protoCallFrame.init(codeBlock, scope, JSCallee::create(vm, scope->globalObject(), scope), thisValue, 1);
if (LegacyProfiler* profiler = vm.enabledProfiler())
profiler->willExecute(callFrame, eval->sourceURL(), eval->lineNo(), eval->startColumn());
Modified: trunk/Source/_javascript_Core/jit/JITCode.cpp (173599 => 173600)
--- trunk/Source/_javascript_Core/jit/JITCode.cpp 2014-09-13 02:18:56 UTC (rev 173599)
+++ trunk/Source/_javascript_Core/jit/JITCode.cpp 2014-09-13 05:21:44 UTC (rev 173600)
@@ -46,7 +46,7 @@
JSValue JITCode::execute(VM* vm, ProtoCallFrame* protoCallFrame)
{
void* entryAddress;
- JSFunction* function = jsCast<JSFunction*>(protoCallFrame->callee());
+ JSFunction* function = jsDynamicCast<JSFunction*>(protoCallFrame->callee());
if (!function || !protoCallFrame->needArityCheck()) {
ASSERT(!protoCallFrame->needArityCheck());
Modified: trunk/Source/_javascript_Core/profiler/LegacyProfiler.cpp (173599 => 173600)
--- trunk/Source/_javascript_Core/profiler/LegacyProfiler.cpp 2014-09-13 02:18:56 UTC (rev 173599)
+++ trunk/Source/_javascript_Core/profiler/LegacyProfiler.cpp 2014-09-13 05:21:44 UTC (rev 173600)
@@ -198,6 +198,8 @@
return CallIdentifier(ASCIILiteral("(unknown)"), defaultSourceURL, defaultLineNumber, defaultColumnNumber);
if (asObject(functionValue)->inherits(JSFunction::info()) || asObject(functionValue)->inherits(InternalFunction::info()))
return createCallIdentifierFromFunctionImp(exec, asObject(functionValue), defaultSourceURL, defaultLineNumber, defaultColumnNumber);
+ if (asObject(functionValue)->inherits(JSCallee::info()))
+ return CallIdentifier(ASCIILiteral(GlobalCodeExecution), defaultSourceURL, defaultLineNumber, defaultColumnNumber);
return CallIdentifier(asObject(functionValue)->methodTable()->className(asObject(functionValue)), defaultSourceURL, defaultLineNumber, defaultColumnNumber);
}
Modified: trunk/Source/_javascript_Core/runtime/JSCallee.cpp (173599 => 173600)
--- trunk/Source/_javascript_Core/runtime/JSCallee.cpp 2014-09-13 02:18:56 UTC (rev 173599)
+++ trunk/Source/_javascript_Core/runtime/JSCallee.cpp 2014-09-13 05:21:44 UTC (rev 173600)
@@ -39,13 +39,6 @@
const ClassInfo JSCallee::s_info = { "Callee", &Base::s_info, 0, CREATE_METHOD_TABLE(JSCallee) };
-JSCallee* JSCallee::create(VM& vm, JSGlobalObject* globalObject)
-{
- JSCallee* function = new (NotNull, allocateCell<JSCallee>(vm.heap)) JSCallee(vm, globalObject, globalObject->functionStructure());
- function->finishCreation(vm);
- return function;
-}
-
void JSCallee::destroy(JSCell* cell)
{
static_cast<JSCallee*>(cell)->JSCallee::~JSCallee();
Modified: trunk/Source/_javascript_Core/runtime/JSCallee.h (173599 => 173600)
--- trunk/Source/_javascript_Core/runtime/JSCallee.h 2014-09-13 02:18:56 UTC (rev 173599)
+++ trunk/Source/_javascript_Core/runtime/JSCallee.h 2014-09-13 05:21:44 UTC (rev 173600)
@@ -27,6 +27,7 @@
#define JSCallee_h
#include "JSDestructibleObject.h"
+#include "JSGlobalObject.h"
#include "JSScope.h"
namespace JSC {
@@ -46,8 +47,13 @@
public:
typedef JSDestructibleObject Base;
- JS_EXPORT_PRIVATE static JSCallee* create(VM&, JSGlobalObject*);
-
+ static JSCallee* create(VM& vm, JSGlobalObject* globalObject, JSScope* scope)
+ {
+ JSCallee* callee = new (NotNull, allocateCell<JSCallee>(vm.heap)) JSCallee(vm, scope, globalObject->calleeStructure());
+ callee->finishCreation(vm);
+ return callee;
+ }
+
static void destroy(JSCell*);
JSScope* scope()
Modified: trunk/Source/_javascript_Core/runtime/JSFunction.cpp (173599 => 173600)
--- trunk/Source/_javascript_Core/runtime/JSFunction.cpp 2014-09-13 02:18:56 UTC (rev 173599)
+++ trunk/Source/_javascript_Core/runtime/JSFunction.cpp 2014-09-13 05:21:44 UTC (rev 173600)
@@ -289,8 +289,12 @@
JSValue caller = retrieveCallerFunction(exec, thisObj);
// See ES5.1 15.3.5.4 - Function.caller may not be used to retrieve a strict caller.
- if (!caller.isObject() || !asObject(caller)->inherits(JSFunction::info()))
+ if (!caller.isObject() || !asObject(caller)->inherits(JSFunction::info())) {
+ // It isn't a JSFunction, but if it is a JSCallee from a program or call eval, return null.
+ if (jsDynamicCast<JSCallee*>(caller))
+ return JSValue::encode(jsNull());
return JSValue::encode(caller);
+ }
JSFunction* function = jsCast<JSFunction*>(caller);
if (function->isHostOrBuiltinFunction() || !function->jsExecutable()->isStrictMode())
return JSValue::encode(caller);
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp (173599 => 173600)
--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp 2014-09-13 02:18:56 UTC (rev 173599)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp 2014-09-13 05:21:44 UTC (rev 173600)
@@ -280,6 +280,7 @@
VM& vm = exec->vm();
m_functionPrototype.set(vm, this, FunctionPrototype::create(vm, FunctionPrototype::createStructure(vm, this, jsNull()))); // The real prototype will be set once ObjectPrototype is created.
+ m_calleeStructure.set(vm, this, JSCallee::createStructure(vm, this, jsNull()));
m_functionStructure.set(vm, this, JSFunction::createStructure(vm, this, m_functionPrototype.get()));
m_boundFunctionStructure.set(vm, this, JSBoundFunction::createStructure(vm, this, m_functionPrototype.get()));
m_namedFunctionStructure.set(vm, this, Structure::addPropertyTransition(vm, m_functionStructure.get(), vm.propertyNames->name, DontDelete | ReadOnly | DontEnum, m_functionNameOffset));
@@ -684,6 +685,7 @@
#endif
visitor.append(&thisObject->m_nullPrototypeObjectStructure);
visitor.append(&thisObject->m_errorStructure);
+ visitor.append(&thisObject->m_calleeStructure);
visitor.append(&thisObject->m_functionStructure);
visitor.append(&thisObject->m_boundFunctionStructure);
visitor.append(&thisObject->m_namedFunctionStructure);
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.h (173599 => 173600)
--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.h 2014-09-13 02:18:56 UTC (rev 173599)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.h 2014-09-13 05:21:44 UTC (rev 173600)
@@ -206,6 +206,7 @@
WriteBarrier<Structure> m_objcWrapperObjectStructure;
#endif
WriteBarrier<Structure> m_nullPrototypeObjectStructure;
+ WriteBarrier<Structure> m_calleeStructure;
WriteBarrier<Structure> m_functionStructure;
WriteBarrier<Structure> m_boundFunctionStructure;
WriteBarrier<Structure> m_namedFunctionStructure;
@@ -429,6 +430,7 @@
Structure* dateStructure() const { return m_dateStructure.get(); }
Structure* nullPrototypeObjectStructure() const { return m_nullPrototypeObjectStructure.get(); }
Structure* errorStructure() const { return m_errorStructure.get(); }
+ Structure* calleeStructure() const { return m_calleeStructure.get(); }
Structure* functionStructure() const { return m_functionStructure.get(); }
Structure* boundFunctionStructure() const { return m_boundFunctionStructure.get(); }
Structure* namedFunctionStructure() const { return m_namedFunctionStructure.get(); }