Ignore:
Timestamp:
Oct 20, 2008, 9:48:30 AM (17 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2008-10-20 Geoffrey Garen <[email protected]>

Reviewed by Darin Adler.


Fixed https://bugs.webkit.org/show_bug.cgi?id=21735
Emit profiling instrumentation only if the Web Inspector's profiling
feature is enabled

22.2% speedup on empty function call benchmark.
2.9% speedup on v8 benchmark.
0.7% speedup on SunSpider.


Lesser but similar speedups in bytecode.

  • VM/CTI.cpp: (JSC::CTI::compileOpCall): (JSC::CTI::privateCompileMainPass): (JSC::CTI::privateCompileSlowCases): Nixed JITed profiler hooks. Profiler hooks now have their own opcodes. Added support for compiling profiler hook opcodes.


(JSC::CodeBlock::dump): Dump support for the new profiling opcodes.

  • VM/CodeGenerator.h:
  • VM/CodeGenerator.cpp: (JSC::CodeGenerator::CodeGenerator): (JSC::CodeGenerator::emitCall): (JSC::CodeGenerator::emitConstruct): Conditionally emit profiling hooks around call and construct, at the call site. (It's easier to get things right this way, if you have profiled code calling non-profiled code. Also, you get a slightly more accurate profile, since you charge the full cost of the call / construct operation to the callee.)


Also, fixed a bug where construct would fetch the ".prototype" property
from the constructor before evaluating the arguments to the constructor,
incorrectly allowing an "invalid constructor" exception to short-circuit
argument evaluation. I encountered this bug when trying to make
constructor exceptions work with profiling.

  • VM/Machine.cpp: (JSC::Machine::callEval): Removed obsolete profiler hooks.

(JSC::Machine::throwException): Added a check for an exception thrown
within a call instruction. We didn't need this before because the call
instruction would check for a valid call before involing the profiler.
(JSC::Machine::execute): Added a didExecute hook at the end of top-level
function invocation, since op_ret no longer does this for us.

(JSC::Machine::privateExecute): Removed obsolete profiler hooks. Added
profiler opcodes. Changed some ++vPC to vPC[x] notation, since the
latter is better for performance, and it makes reasoning about the
current opcode in exception handling much simpler.

(JSC::Machine::cti_op_call_NotJSFunction): Removed obsolete profiler
hooks.

(JSC::Machine::cti_op_create_arguments_no_params): Added missing
CTI_STACK_HACK that I noticed when adding CTI_STACK_HACK to the new
profiler opcode functions.

(JSC::Machine::cti_op_profile_will_call):
(JSC::Machine::cti_op_profile_did_call): The new profiler opcode
functions.

(JSC::Machine::cti_op_construct_NotJSConstruct): Removed obsolete profiler
hooks.

  • VM/Machine.h: (JSC::Machine::isCallOpcode): Helper for exception handling.
  • VM/Opcode.h: Declare new opcodes.
  • kjs/JSGlobalObject.h: (JSC::JSGlobalObject::supportsProfiling): Added virtual interface that allows WebCore to specify whether the target global object has the Web Inspector's profiling feature enabled.
  • profiler/Profiler.cpp: (JSC::Profiler::willExecute): (JSC::Profiler::didExecute): (JSC::Profiler::createCallIdentifier):
  • profiler/Profiler.h: Added support for invoking the profiler with an arbitrary JSValue*, and not a known object. We didn't need this before because the call instruction would check for a valid call before involing the profiler.

WebCore:

2008-10-18 Geoffrey Garen <[email protected]>

Reviewed by Darin Adler.

Fixed https://bugs.webkit.org/show_bug.cgi?id=21735
Emit profiling instrumentation only if the Web Inspector's profiling
feature is enabled

  • bindings/js/JSDOMWindowBase.cpp: (WebCore::JSDOMWindowBase::supportsProfiling):
  • bindings/js/JSDOMWindowBase.h: Implemented the interface for specifying whether a target global object has the Web Inspector's profiling feature enabled.
  • inspector/JavaScriptDebugServer.cpp: (WebCore::JavaScriptDebugServer::recompileAllJSFunctionsSoon): (WebCore::JavaScriptDebugServer::didAddListener): (WebCore::JavaScriptDebugServer::didRemoveListener):
  • inspector/JavaScriptDebugServer.h: Exported an API for recompiling, used by the Settings object.
  • page/Settings.cpp: (WebCore::Settings::Settings): (WebCore::Settings::setDeveloperExtrasEnabled):
  • page/Settings.h: Recompile when the developer menu is enabled/disabled for the first time, to add/remove profiling hooks. In the future, with better Web Inspector UI, we can do this on a page-by-page basis, instead of a global basis.

LayoutTests:

2008-10-18 Geoffrey Garen <[email protected]>

Reviewed by Darin Adler.

Test for bugs fixed while working on https://bugs.webkit.org/show_bug.cgi?id=21735
Emit profiling instrumentation only if the Web Inspector's profiling
feature is enabled

  • fast/js/exception-thrown-from-new-expected.txt: Added.
  • fast/js/exception-thrown-from-new.html: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/VM/CodeGenerator.cpp

    r37712 r37730  
    196196CodeGenerator::CodeGenerator(ProgramNode* programNode, const Debugger* debugger, const ScopeChain& scopeChain, SymbolTable* symbolTable, CodeBlock* codeBlock, VarStack& varStack, FunctionStack& functionStack)
    197197    : m_shouldEmitDebugHooks(!!debugger)
     198    , m_shouldEmitProfileHooks(scopeChain.globalObject()->supportsProfiling())
    198199    , m_scopeChain(&scopeChain)
    199200    , m_symbolTable(symbolTable)
     
    274275CodeGenerator::CodeGenerator(FunctionBodyNode* functionBody, const Debugger* debugger, const ScopeChain& scopeChain, SymbolTable* symbolTable, CodeBlock* codeBlock)
    275276    : m_shouldEmitDebugHooks(!!debugger)
     277    , m_shouldEmitProfileHooks(scopeChain.globalObject()->supportsProfiling())
    276278    , m_scopeChain(&scopeChain)
    277279    , m_symbolTable(symbolTable)
     
    343345CodeGenerator::CodeGenerator(EvalNode* evalNode, const Debugger* debugger, const ScopeChain& scopeChain, SymbolTable* symbolTable, EvalCodeBlock* codeBlock)
    344346    : m_shouldEmitDebugHooks(!!debugger)
     347    , m_shouldEmitProfileHooks(scopeChain.globalObject()->supportsProfiling())
    345348    , m_scopeChain(&scopeChain)
    346349    , m_symbolTable(symbolTable)
     
    11591162        callFrame.append(newTemporary());
    11601163
     1164    if (m_shouldEmitProfileHooks) {
     1165        emitOpcode(op_profile_will_call);
     1166        instructions().append(func->index());
     1167    }
     1168
    11611169    emitExpressionInfo(divot, startOffset, endOffset);
    11621170    m_codeBlock->structureIDInstructions.append(instructions().size());
     
    11681176    instructions().append(argv.size()); // argc
    11691177    instructions().append(argv[0]->index() + argv.size() + RegisterFile::CallFrameHeaderSize); // registerOffset
     1178
     1179    if (m_shouldEmitProfileHooks) {
     1180        emitOpcode(op_profile_did_call);
     1181        instructions().append(func->index());
     1182    }
     1183
    11701184    return dst;
    11711185}
     
    11931207    ASSERT(func->refCount());
    11941208
    1195     // Load prototype.
    1196     emitExpressionInfo(divot, startOffset, endOffset);
    11971209    RefPtr<RegisterID> funcProto = newTemporary();
    1198     emitGetById(funcProto.get(), func, globalData()->propertyNames->prototype);
    11991210
    12001211    // Generate code for arguments.
     
    12061217    }
    12071218
     1219    if (m_shouldEmitProfileHooks) {
     1220        emitOpcode(op_profile_will_call);
     1221        instructions().append(func->index());
     1222    }
     1223
     1224    // Load prototype.
     1225    emitExpressionInfo(divot, startOffset, endOffset);
     1226    emitGetById(funcProto.get(), func, globalData()->propertyNames->prototype);
     1227
    12081228    // Reserve space for call frame.
    12091229    Vector<RefPtr<RegisterID>, RegisterFile::CallFrameHeaderSize> callFrame;
     
    12241244    instructions().append(dst->index());
    12251245    instructions().append(argv[0]->index());
     1246
     1247    if (m_shouldEmitProfileHooks) {
     1248        emitOpcode(op_profile_did_call);
     1249        instructions().append(func->index());
     1250    }
    12261251
    12271252    return dst;
Note: See TracChangeset for help on using the changeset viewer.