Changeset 37730 in webkit for trunk/JavaScriptCore/VM/Machine.h


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/Machine.h

    r37728 r37730  
    190190        static void SFX_CALL cti_op_tear_off_activation(CTI_ARGS);
    191191        static void SFX_CALL cti_op_tear_off_arguments(CTI_ARGS);
     192        static void SFX_CALL cti_op_profile_will_call(CTI_ARGS);
     193        static void SFX_CALL cti_op_profile_did_call(CTI_ARGS);
    192194        static void SFX_CALL cti_op_ret_scopeChain(CTI_ARGS);
    193195        static JSObject* SFX_CALL cti_op_new_array(CTI_ARGS);
     
    257259        static void SFX_CALL cti_op_debug(CTI_ARGS);
    258260
    259         static void SFX_CALL cti_op_call_profiler(CTI_ARGS);
    260         static void SFX_CALL cti_op_ret_profiler(CTI_ARGS);
    261 
    262261        static JSValue* SFX_CALL cti_vm_throw(CTI_ARGS);
    263262        static void* SFX_CALL cti_vm_compile(CTI_ARGS);
     
    308307        void tryCachePutByID(CallFrame*, CodeBlock*, Instruction*, JSValuePtr baseValue, const PutPropertySlot&);
    309308        void uncachePutByID(CodeBlock*, Instruction* vPC);
     309       
     310        bool isCallOpcode(Opcode opcode) { return opcode == getOpcode(op_call) || opcode == getOpcode(op_construct) || opcode == getOpcode(op_call_eval); }
    310311
    311312#if ENABLE(CTI)
Note: See TracChangeset for help on using the changeset viewer.