Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (99996 => 99997)
--- trunk/Source/_javascript_Core/ChangeLog 2011-11-11 19:28:34 UTC (rev 99996)
+++ trunk/Source/_javascript_Core/ChangeLog 2011-11-11 19:32:59 UTC (rev 99997)
@@ -1,5 +1,30 @@
2011-11-11 Mark Hahnenberg <mhahnenb...@apple.com>
+ De-virtualize supportsProfiling, supportsRichSourceInfo, shouldInterruptScript in JSGlobalObject
+ https://bugs.webkit.org/show_bug.cgi?id=72035
+
+ Reviewed by Geoffrey Garen.
+
+ De-virtualized the methods through the use of a new method table just for JSGlobalObject and subclasses.
+
+ * _javascript_Core.exp:
+ * _javascript_Core.vcproj/_javascript_Core/_javascript_Core.def:
+ * bytecompiler/BytecodeGenerator.cpp: Changed call sites to use the new GlobalObjectMethodTable.
+ (JSC::BytecodeGenerator::BytecodeGenerator):
+ * interpreter/Interpreter.cpp: Ditto.
+ (JSC::Interpreter::execute):
+ * runtime/JSGlobalObject.cpp: Added a static const GlobalObjectMethodTable with the correct function pointers.
+ * runtime/JSGlobalObject.h: Added a field in JSGlobalObject to keep track of the current method table.
+ (JSC::JSGlobalObject::JSGlobalObject):
+ (JSC::JSGlobalObject::globalObjectMethodTable): The new struct to contain the function pointers.
+ (JSC::JSGlobalObject::supportsProfiling): Made static to put in the method table.
+ (JSC::JSGlobalObject::supportsRichSourceInfo): Ditto.
+ (JSC::JSGlobalObject::shouldInterruptScript): Ditto.
+ * runtime/TimeoutChecker.cpp: Changed call sites to use the new GlobalObjectMethodTable for lookup.
+ (JSC::TimeoutChecker::didTimeOut):
+
+2011-11-11 Mark Hahnenberg <mhahnenb...@apple.com>
+
De-virtualize JSGlobalObject::allowsAccessFrom
https://bugs.webkit.org/show_bug.cgi?id=71969
Modified: trunk/Source/_javascript_Core/_javascript_Core.exp (99996 => 99997)
--- trunk/Source/_javascript_Core/_javascript_Core.exp 2011-11-11 19:28:34 UTC (rev 99996)
+++ trunk/Source/_javascript_Core/_javascript_Core.exp 2011-11-11 19:32:59 UTC (rev 99997)
@@ -173,6 +173,7 @@
__ZN3JSC14JSGlobalObject17putWithAttributesEPNS_8JSObjectEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueEj
__ZN3JSC14JSGlobalObject18getOwnPropertySlotEPNS_6JSCellEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
__ZN3JSC14JSGlobalObject24getOwnPropertyDescriptorEPNS_8JSObjectEPNS_9ExecStateERKNS_10IdentifierERNS_18PropertyDescriptorE
+__ZN3JSC14JSGlobalObject25s_globalObjectMethodTableE
__ZN3JSC14JSGlobalObject3putEPNS_6JSCellEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueERNS_15PutPropertySlotE
__ZN3JSC14JSGlobalObject4initEPNS_8JSObjectE
__ZN3JSC14JSGlobalObject6s_infoE
Modified: trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def (99996 => 99997)
--- trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def 2011-11-11 19:28:34 UTC (rev 99996)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def 2011-11-11 19:32:59 UTC (rev 99997)
@@ -285,6 +285,7 @@
?restoreAll@Profile@JSC@@QAEXXZ
?retrieveCaller@Interpreter@JSC@@QBE?AVJSValue@2@PAVExecState@2@PAVJSFunction@2@@Z
?retrieveLastCaller@Interpreter@JSC@@QBEXPAVExecState@2@AAH1AAVUString@2@AAVJSValue@2@@Z
+ ?s_globalObjectMethodTable@JSGlobalObject@JSC@@1UGlobalObjectMethodTable@2@B
?setAccessorDescriptor@PropertyDescriptor@JSC@@QAEXVJSValue@2@0I@Z
?setConfigurable@PropertyDescriptor@JSC@@QAEX_N@Z
?setDescriptor@PropertyDescriptor@JSC@@QAEXVJSValue@2@I@Z
Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp (99996 => 99997)
--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp 2011-11-11 19:28:34 UTC (rev 99996)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp 2011-11-11 19:32:59 UTC (rev 99997)
@@ -196,8 +196,8 @@
BytecodeGenerator::BytecodeGenerator(ProgramNode* programNode, ScopeChainNode* scopeChain, SymbolTable* symbolTable, ProgramCodeBlock* codeBlock, CompilationKind compilationKind)
: m_shouldEmitDebugHooks(scopeChain->globalObject->debugger())
- , m_shouldEmitProfileHooks(scopeChain->globalObject->supportsProfiling())
- , m_shouldEmitRichSourceInfo(scopeChain->globalObject->supportsRichSourceInfo())
+ , m_shouldEmitProfileHooks(scopeChain->globalObject->globalObjectMethodTable()->supportsProfiling(scopeChain->globalObject.get()))
+ , m_shouldEmitRichSourceInfo(scopeChain->globalObject->globalObjectMethodTable()->supportsRichSourceInfo(scopeChain->globalObject.get()))
, m_scopeChain(*scopeChain->globalData, scopeChain)
, m_symbolTable(symbolTable)
, m_scopeNode(programNode)
@@ -267,8 +267,8 @@
BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, ScopeChainNode* scopeChain, SymbolTable* symbolTable, CodeBlock* codeBlock, CompilationKind)
: m_shouldEmitDebugHooks(scopeChain->globalObject->debugger())
- , m_shouldEmitProfileHooks(scopeChain->globalObject->supportsProfiling())
- , m_shouldEmitRichSourceInfo(scopeChain->globalObject->supportsRichSourceInfo())
+ , m_shouldEmitProfileHooks(scopeChain->globalObject->globalObjectMethodTable()->supportsProfiling(scopeChain->globalObject.get()))
+ , m_shouldEmitRichSourceInfo(scopeChain->globalObject->globalObjectMethodTable()->supportsRichSourceInfo(scopeChain->globalObject.get()))
, m_scopeChain(*scopeChain->globalData, scopeChain)
, m_symbolTable(symbolTable)
, m_scopeNode(functionBody)
@@ -429,8 +429,8 @@
BytecodeGenerator::BytecodeGenerator(EvalNode* evalNode, ScopeChainNode* scopeChain, SymbolTable* symbolTable, EvalCodeBlock* codeBlock, CompilationKind)
: m_shouldEmitDebugHooks(scopeChain->globalObject->debugger())
- , m_shouldEmitProfileHooks(scopeChain->globalObject->supportsProfiling())
- , m_shouldEmitRichSourceInfo(scopeChain->globalObject->supportsRichSourceInfo())
+ , m_shouldEmitProfileHooks(scopeChain->globalObject->globalObjectMethodTable()->supportsProfiling(scopeChain->globalObject.get()))
+ , m_shouldEmitRichSourceInfo(scopeChain->globalObject->globalObjectMethodTable()->supportsRichSourceInfo(scopeChain->globalObject.get()))
, m_scopeChain(*scopeChain->globalData, scopeChain)
, m_symbolTable(symbolTable)
, m_scopeNode(evalNode)
Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.cpp (99996 => 99997)
--- trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2011-11-11 19:28:34 UTC (rev 99996)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2011-11-11 19:32:59 UTC (rev 99997)
@@ -790,10 +790,10 @@
const UString programSource = program->source().toString();
if (programSource.is8Bit()) {
LiteralParser<LChar> literalParser(callFrame, programSource.characters8(), programSource.length(), JSONP);
- parseResult = literalParser.tryJSONPParse(JSONPData, scopeChain->globalObject->supportsRichSourceInfo());
+ parseResult = literalParser.tryJSONPParse(JSONPData, scopeChain->globalObject->globalObjectMethodTable()->supportsRichSourceInfo(scopeChain->globalObject.get()));
} else {
LiteralParser<UChar> literalParser(callFrame, programSource.characters16(), programSource.length(), JSONP);
- parseResult = literalParser.tryJSONPParse(JSONPData, scopeChain->globalObject->supportsRichSourceInfo());
+ parseResult = literalParser.tryJSONPParse(JSONPData, scopeChain->globalObject->globalObjectMethodTable()->supportsRichSourceInfo(scopeChain->globalObject.get()));
}
if (parseResult) {
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp (99996 => 99997)
--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp 2011-11-11 19:28:34 UTC (rev 99996)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp 2011-11-11 19:32:59 UTC (rev 99997)
@@ -78,6 +78,8 @@
const ClassInfo JSGlobalObject::s_info = { "GlobalObject", &JSVariableObject::s_info, 0, ExecState::globalObjectTable, CREATE_METHOD_TABLE(JSGlobalObject) };
+const GlobalObjectMethodTable JSGlobalObject::s_globalObjectMethodTable = { &supportsProfiling, &supportsRichSourceInfo, &shouldInterruptScript };
+
/* Source for JSGlobalObject.lut.h
@begin globalObjectTable
parseInt globalFuncParseInt DontEnum|Function 2
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.h (99996 => 99997)
--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.h 2011-11-11 19:28:34 UTC (rev 99996)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.h 2011-11-11 19:32:59 UTC (rev 99997)
@@ -55,6 +55,17 @@
typedef Vector<ExecState*, 16> ExecStateStack;
+ struct GlobalObjectMethodTable {
+ typedef bool (*SupportsProfilingFunctionPtr)(const JSGlobalObject*);
+ SupportsProfilingFunctionPtr supportsProfiling;
+
+ typedef bool (*SupportsRichSourceInfoFunctionPtr)(const JSGlobalObject*);
+ SupportsRichSourceInfoFunctionPtr supportsRichSourceInfo;
+
+ typedef bool (*ShouldInterruptScriptFunctionPtr)(const JSGlobalObject*);
+ ShouldInterruptScriptFunctionPtr shouldInterruptScript;
+ };
+
class JSGlobalObject : public JSVariableObject {
private:
typedef HashSet<RefPtr<OpaqueJSWeakObjectMap> > WeakMapSet;
@@ -133,6 +144,9 @@
bool m_evalEnabled;
+ static JS_EXPORTDATA const GlobalObjectMethodTable s_globalObjectMethodTable;
+ const GlobalObjectMethodTable* m_globalObjectMethodTable;
+
void createRareDataIfNeeded()
{
if (m_rareData)
@@ -154,12 +168,13 @@
static JS_EXPORTDATA const ClassInfo s_info;
protected:
- explicit JSGlobalObject(JSGlobalData& globalData, Structure* structure)
+ explicit JSGlobalObject(JSGlobalData& globalData, Structure* structure, const GlobalObjectMethodTable* globalObjectMethodTable = 0)
: JSVariableObject(globalData, structure, &m_symbolTable, 0)
, m_registerArraySize(0)
, m_globalScopeChain()
, m_weakRandom(static_cast<unsigned>(randomNumber() * (std::numeric_limits<unsigned>::max() + 1.0)))
, m_evalEnabled(true)
+ , m_globalObjectMethodTable(globalObjectMethodTable ? globalObjectMethodTable : &s_globalObjectMethodTable)
{
}
@@ -262,14 +277,16 @@
Debugger* debugger() const { return m_debugger; }
void setDebugger(Debugger* debugger) { m_debugger = debugger; }
- virtual bool supportsProfiling() const { return false; }
- virtual bool supportsRichSourceInfo() const { return true; }
+ const GlobalObjectMethodTable* globalObjectMethodTable() const { return m_globalObjectMethodTable; }
+ static bool supportsProfiling(const JSGlobalObject*) { return false; }
+ static bool supportsRichSourceInfo(const JSGlobalObject*) { return true; }
+
ScopeChainNode* globalScopeChain() { return m_globalScopeChain.get(); }
ExecState* globalExec();
- virtual bool shouldInterruptScript() const { return true; }
+ static bool shouldInterruptScript(const JSGlobalObject*) { return true; }
bool isDynamicScope(bool& requiresDynamicChecks) const;
Modified: trunk/Source/_javascript_Core/runtime/TimeoutChecker.cpp (99996 => 99997)
--- trunk/Source/_javascript_Core/runtime/TimeoutChecker.cpp 2011-11-11 19:28:34 UTC (rev 99996)
+++ trunk/Source/_javascript_Core/runtime/TimeoutChecker.cpp 2011-11-11 19:32:59 UTC (rev 99997)
@@ -130,7 +130,7 @@
m_ticksUntilNextCheck = ticksUntilFirstCheck;
if (m_timeoutInterval && m_timeExecuting > m_timeoutInterval) {
- if (exec->dynamicGlobalObject()->shouldInterruptScript())
+ if (exec->dynamicGlobalObject()->globalObjectMethodTable()->shouldInterruptScript(exec->dynamicGlobalObject()))
return true;
reset();
Modified: trunk/Source/WebCore/ChangeLog (99996 => 99997)
--- trunk/Source/WebCore/ChangeLog 2011-11-11 19:28:34 UTC (rev 99996)
+++ trunk/Source/WebCore/ChangeLog 2011-11-11 19:32:59 UTC (rev 99997)
@@ -1,3 +1,23 @@
+2011-11-11 Mark Hahnenberg <mhahnenb...@apple.com>
+
+ De-virtualize supportsProfiling, supportsRichSourceInfo, shouldInterruptScript in JSGlobalObject
+ https://bugs.webkit.org/show_bug.cgi?id=72035
+
+ Reviewed by Geoffrey Garen.
+
+ No new tests.
+
+ * bindings/js/JSDOMGlobalObject.cpp: Changed constructor to support passing new GlobalObjectMethodTable pointer to parent class.
+ (WebCore::JSDOMGlobalObject::JSDOMGlobalObject):
+ * bindings/js/JSDOMGlobalObject.h:
+ * bindings/js/JSDOMWindowBase.cpp: Added static const GlobalObjectMethodTable and filled it in with the proper function pointers.
+ (WebCore::JSDOMWindowBase::JSDOMWindowBase):
+ (WebCore::JSDOMWindowBase::supportsProfiling): Changed to static to put in the method table.
+ (WebCore::JSDOMWindowBase::supportsRichSourceInfo): Ditto.
+ (WebCore::JSDOMWindowBase::shouldInterruptScript): Ditto.
+ * bindings/js/JSDOMWindowBase.h:
+
+
2011-11-11 Sheriff Bot <webkit.review....@gmail.com>
Unreviewed, rolling out r99869.
Modified: trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp (99996 => 99997)
--- trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp 2011-11-11 19:28:34 UTC (rev 99996)
+++ trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp 2011-11-11 19:32:59 UTC (rev 99997)
@@ -42,8 +42,8 @@
const ClassInfo JSDOMGlobalObject::s_info = { "DOMGlobalObject", &JSGlobalObject::s_info, 0, 0, CREATE_METHOD_TABLE(JSDOMGlobalObject) };
-JSDOMGlobalObject::JSDOMGlobalObject(JSGlobalData& globalData, Structure* structure, PassRefPtr<DOMWrapperWorld> world)
- : JSGlobalObject(globalData, structure)
+JSDOMGlobalObject::JSDOMGlobalObject(JSGlobalData& globalData, Structure* structure, PassRefPtr<DOMWrapperWorld> world, const GlobalObjectMethodTable* globalObjectMethodTable)
+ : JSGlobalObject(globalData, structure, globalObjectMethodTable)
, m_currentEvent(0)
, m_world(world)
{
Modified: trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.h (99996 => 99997)
--- trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.h 2011-11-11 19:28:34 UTC (rev 99996)
+++ trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.h 2011-11-11 19:32:59 UTC (rev 99997)
@@ -47,7 +47,7 @@
protected:
struct JSDOMGlobalObjectData;
- JSDOMGlobalObject(JSC::JSGlobalData&, JSC::Structure*, PassRefPtr<DOMWrapperWorld>);
+ JSDOMGlobalObject(JSC::JSGlobalData&, JSC::Structure*, PassRefPtr<DOMWrapperWorld>, const JSC::GlobalObjectMethodTable* = 0);
virtual ~JSDOMGlobalObject();
void finishCreation(JSC::JSGlobalData&);
void finishCreation(JSC::JSGlobalData&, JSC::JSGlobalThis*);
Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp (99996 => 99997)
--- trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp 2011-11-11 19:28:34 UTC (rev 99996)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp 2011-11-11 19:32:59 UTC (rev 99997)
@@ -43,8 +43,10 @@
const ClassInfo JSDOMWindowBase::s_info = { "Window", &JSDOMGlobalObject::s_info, 0, 0, CREATE_METHOD_TABLE(JSDOMWindowBase) };
+const GlobalObjectMethodTable JSDOMWindowBase::s_globalObjectMethodTable = { &supportsProfiling, &supportsRichSourceInfo, &shouldInterruptScript };
+
JSDOMWindowBase::JSDOMWindowBase(JSGlobalData& globalData, Structure* structure, PassRefPtr<DOMWindow> window, JSDOMWindowShell* shell)
- : JSDOMGlobalObject(globalData, structure, shell->world())
+ : JSDOMGlobalObject(globalData, structure, shell->world(), &s_globalObjectMethodTable)
, m_impl(window)
, m_shell(shell)
{
@@ -85,12 +87,13 @@
printErrorMessageForFrame(impl()->frame(), message);
}
-bool JSDOMWindowBase::supportsProfiling() const
+bool JSDOMWindowBase::supportsProfiling(const JSGlobalObject* object)
{
#if !ENABLE(_javascript__DEBUGGER) || !ENABLE(INSPECTOR)
return false;
#else
- Frame* frame = impl()->frame();
+ const JSDOMWindowBase* thisObject = static_cast<const JSDOMWindowBase*>(object);
+ Frame* frame = thisObject->impl()->frame();
if (!frame)
return false;
@@ -102,12 +105,13 @@
#endif
}
-bool JSDOMWindowBase::supportsRichSourceInfo() const
+bool JSDOMWindowBase::supportsRichSourceInfo(const JSGlobalObject* object)
{
#if !ENABLE(_javascript__DEBUGGER) || !ENABLE(INSPECTOR)
return false;
#else
- Frame* frame = impl()->frame();
+ const JSDOMWindowBase* thisObject = static_cast<const JSDOMWindowBase*>(object);
+ Frame* frame = thisObject->impl()->frame();
if (!frame)
return false;
@@ -116,16 +120,17 @@
return false;
bool enabled = page->inspectorController()->enabled();
- ASSERT(enabled || !debugger());
- ASSERT(enabled || !supportsProfiling());
+ ASSERT(enabled || !thisObject->debugger());
+ ASSERT(enabled || !supportsProfiling(thisObject));
return enabled;
#endif
}
-bool JSDOMWindowBase::shouldInterruptScript() const
+bool JSDOMWindowBase::shouldInterruptScript(const JSGlobalObject* object)
{
- ASSERT(impl()->frame());
- Page* page = impl()->frame()->page();
+ const JSDOMWindowBase* thisObject = static_cast<const JSDOMWindowBase*>(object);
+ ASSERT(thisObject->impl()->frame());
+ Page* page = thisObject->impl()->frame()->page();
// See <rdar://problem/5479443>. We don't think that page can ever be NULL
// in this case, but if it is, we've gotten into a state where we may have
Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowBase.h (99996 => 99997)
--- trunk/Source/WebCore/bindings/js/JSDOMWindowBase.h 2011-11-11 19:28:34 UTC (rev 99996)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowBase.h 2011-11-11 19:32:59 UTC (rev 99997)
@@ -56,10 +56,12 @@
return JSC::Structure::create(globalData, 0, prototype, JSC::TypeInfo(JSC::GlobalObjectType, StructureFlags), &s_info);
}
- virtual bool supportsProfiling() const;
- virtual bool supportsRichSourceInfo() const;
- virtual bool shouldInterruptScript() const;
+ static const JSC::GlobalObjectMethodTable s_globalObjectMethodTable;
+ static bool supportsProfiling(const JSC::JSGlobalObject*);
+ static bool supportsRichSourceInfo(const JSC::JSGlobalObject*);
+ static bool shouldInterruptScript(const JSC::JSGlobalObject*);
+
bool allowsAccessFrom(JSC::ExecState*) const;
bool allowsAccessFromNoErrorMessage(JSC::ExecState*) const;
bool allowsAccessFrom(JSC::ExecState*, String& message) const;