Changeset 233658 in webkit


Ignore:
Timestamp:
Jul 9, 2018 2:55:48 PM (6 years ago)
Author:
mark.lam@apple.com
Message:

Add --traceLLIntExecution and --traceLLIntSlowPath options.
https://bugs.webkit.org/show_bug.cgi?id=187479

Reviewed by Yusuke Suzuki and Saam Barati.

These options are only available if LLINT_TRACING is enabled in LLIntCommon.h.

The details:

  1. LLINT_TRACING consolidates and replaces LLINT_EXECUTION_TRACING and LLINT_SLOW_PATH_TRACING.
  2. Tracing is now guarded behind runtime options --traceLLIntExecution and --traceLLIntSlowPath. This makes it such that enabling LLINT_TRACING doesn't means that we'll continually spammed with logging until we rebuild.
  3. Fixed slow path LLINT tracing to work with exception check validation.
  • llint/LLIntCommon.h:
  • llint/LLIntExceptions.cpp:

(JSC::LLInt::returnToThrow):
(JSC::LLInt::callToThrow):

  • llint/LLIntOfflineAsmConfig.h:
  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::slowPathLog):
(JSC::LLInt::slowPathLn):
(JSC::LLInt::slowPathLogF):
(JSC::LLInt::slowPathLogLn):
(JSC::LLInt::llint_trace_operand):
(JSC::LLInt::llint_trace_value):
(JSC::LLInt::LLINT_SLOW_PATH_DECL):
(JSC::LLInt::traceFunctionPrologue):
(JSC::LLInt::handleHostCall):
(JSC::LLInt::setUpCall):

  • llint/LLIntSlowPaths.h:
  • llint/LowLevelInterpreter.asm:
  • runtime/CommonSlowPathsExceptions.cpp:

(JSC::CommonSlowPaths::interpreterThrowInCaller):

  • runtime/Options.cpp:

(JSC::Options::isAvailable):

  • runtime/Options.h:
Location:
trunk/Source/JavaScriptCore
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r233657 r233658  
     12018-07-09  Mark Lam  <mark.lam@apple.com>
     2
     3        Add --traceLLIntExecution and --traceLLIntSlowPath options.
     4        https://bugs.webkit.org/show_bug.cgi?id=187479
     5
     6        Reviewed by Yusuke Suzuki and Saam Barati.
     7
     8        These options are only available if LLINT_TRACING is enabled in LLIntCommon.h.
     9
     10        The details:
     11        1. LLINT_TRACING consolidates and replaces LLINT_EXECUTION_TRACING and LLINT_SLOW_PATH_TRACING.
     12        2. Tracing is now guarded behind runtime options --traceLLIntExecution and --traceLLIntSlowPath.
     13           This makes it such that enabling LLINT_TRACING doesn't means that we'll
     14           continually spammed with logging until we rebuild.
     15        3. Fixed slow path LLINT tracing to work with exception check validation.
     16
     17        * llint/LLIntCommon.h:
     18        * llint/LLIntExceptions.cpp:
     19        (JSC::LLInt::returnToThrow):
     20        (JSC::LLInt::callToThrow):
     21        * llint/LLIntOfflineAsmConfig.h:
     22        * llint/LLIntSlowPaths.cpp:
     23        (JSC::LLInt::slowPathLog):
     24        (JSC::LLInt::slowPathLn):
     25        (JSC::LLInt::slowPathLogF):
     26        (JSC::LLInt::slowPathLogLn):
     27        (JSC::LLInt::llint_trace_operand):
     28        (JSC::LLInt::llint_trace_value):
     29        (JSC::LLInt::LLINT_SLOW_PATH_DECL):
     30        (JSC::LLInt::traceFunctionPrologue):
     31        (JSC::LLInt::handleHostCall):
     32        (JSC::LLInt::setUpCall):
     33        * llint/LLIntSlowPaths.h:
     34        * llint/LowLevelInterpreter.asm:
     35        * runtime/CommonSlowPathsExceptions.cpp:
     36        (JSC::CommonSlowPaths::interpreterThrowInCaller):
     37        * runtime/Options.cpp:
     38        (JSC::Options::isAvailable):
     39        * runtime/Options.h:
     40
    1412018-07-09  Yusuke Suzuki  <utatane.tea@gmail.com>
    242
  • trunk/Source/JavaScriptCore/llint/LLIntCommon.h

    r229478 r233658  
    11/*
    2  * Copyright (C) 2012-2013, 2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#pragma once
    2727
    28 // Print every instruction executed.
    29 #define LLINT_EXECUTION_TRACING 0
    30 
    31 // Print some information for some of the more subtle slow paths.
    32 #define LLINT_SLOW_PATH_TRACING 0
     28// Enables LLINT tracing.
     29// - Prints every instruction executed if Options::traceLLIntExecution() is enabled.
     30// - Prints some information for some of the more subtle slow paths if
     31//   Options::traceLLIntSlowPath() is enabled.
     32#define LLINT_TRACING 0
    3333
    3434// Disable inline allocation in the interpreter. This is great if you're changing
  • trunk/Source/JavaScriptCore/llint/LLIntExceptions.cpp

    r230865 r233658  
    3434#include "JSCInlines.h"
    3535
    36 #if LLINT_SLOW_PATH_TRACING
     36#if LLINT_TRACING
    3737#include "Exception.h"
    3838#endif
     
    4343{
    4444    UNUSED_PARAM(exec);
    45 #if LLINT_SLOW_PATH_TRACING
    46     VM* vm = &exec->vm();
    47     auto scope = DECLARE_THROW_SCOPE(*vm);
    48     dataLog("Throwing exception ", JSValue(scope.exception()), " (returnToThrow).\n");
     45#if LLINT_TRACING
     46    if (UNLIKELY(Options::traceLLIntSlowPath())) {
     47        VM* vm = &exec->vm();
     48        auto scope = DECLARE_CATCH_SCOPE(*vm);
     49        dataLog("Throwing exception ", JSValue(scope.exception()), " (returnToThrow).\n");
     50    }
    4951#endif
    5052    return LLInt::exceptionInstructions();
     
    5456{
    5557    UNUSED_PARAM(exec);
    56 #if LLINT_SLOW_PATH_TRACING
    57     VM* vm = &exec->vm();
    58     auto scope = DECLARE_THROW_SCOPE(*vm);
    59     dataLog("Throwing exception ", JSValue(scope.exception()), " (callToThrow).\n");
     58#if LLINT_TRACING
     59    if (UNLIKELY(Options::traceLLIntSlowPath())) {
     60        VM* vm = &exec->vm();
     61        auto scope = DECLARE_CATCH_SCOPE(*vm);
     62        dataLog("Throwing exception ", JSValue(scope.exception()), " (callToThrow).\n");
     63    }
    6064#endif
    6165    return LLInt::getCodePtr<ExceptionHandlerPtrTag>(llint_throw_during_call_trampoline).executableAddress();
  • trunk/Source/JavaScriptCore/llint/LLIntOfflineAsmConfig.h

    r229482 r233658  
    164164#endif
    165165
    166 #if LLINT_EXECUTION_TRACING
    167 #define OFFLINE_ASM_EXECUTION_TRACING 1
     166#if LLINT_TRACING
     167#define OFFLINE_ASM_TRACING 1
    168168#else
    169 #define OFFLINE_ASM_EXECUTION_TRACING 0
     169#define OFFLINE_ASM_TRACING 0
    170170#endif
    171171
  • trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp

    r233657 r233658  
    189189        LLINT_RETURN_TWO(pc, __rcf_exec);                               \
    190190    } while (false)
    191    
     191
     192#if LLINT_TRACING
     193
     194template<typename... Types>
     195void slowPathLog(const Types&... values)
     196{
     197    dataLogIf(Options::traceLLIntSlowPath(), values...);
     198}
     199
     200template<typename... Types>
     201void slowPathLn(const Types&... values)
     202{
     203    dataLogLnIf(Options::traceLLIntSlowPath(), values...);
     204}
     205
     206template<typename... Types>
     207void slowPathLogF(const char* format, const Types&... values)
     208{
     209#if COMPILER(GCC_OR_CLANG)
     210#pragma GCC diagnostic push
     211#pragma GCC diagnostic ignored "-Wformat-nonliteral"
     212#pragma GCC diagnostic ignored "-Wformat-security"
     213#endif
     214    if (Options::traceLLIntSlowPath())
     215        dataLogF(format, values...);
     216#if COMPILER(GCC_OR_CLANG)
     217#pragma GCC diagnostic pop
     218#endif
     219}
     220
     221#else // not LLINT_TRACING
     222
     223template<typename... Types> void slowPathLog(const Types&...) { }
     224template<typename... Types> void slowPathLogLn(const Types&...) { }
     225template<typename... Types> void slowPathLogF(const char*, const Types&...) { }
     226
     227#endif // LLINT_TRACING
     228
    192229extern "C" SlowPathReturnType llint_trace_operand(ExecState* exec, Instruction* pc, int fromWhere, int operand)
    193230{
     231    if (!Options::traceLLIntExecution())
     232        LLINT_END_IMPL();
     233
    194234    LLINT_BEGIN();
    195235    dataLogF("<%p> %p / %p: executing bc#%zu, op#%u: Trace(%d): %d: %d\n",
     
    207247extern "C" SlowPathReturnType llint_trace_value(ExecState* exec, Instruction* pc, int fromWhere, int operand)
    208248{
     249    if (!Options::traceLLIntExecution())
     250        LLINT_END_IMPL();
     251
    209252    JSValue value = LLINT_OP_C(operand).jsValue();
    210253    union {
     
    234277LLINT_SLOW_PATH_DECL(trace_prologue)
    235278{
     279    if (!Options::traceLLIntExecution())
     280        LLINT_END_IMPL();
     281
    236282    dataLogF("<%p> %p / %p: in prologue of ", &Thread::current(), exec->codeBlock(), exec);
    237     dataLog(*exec->codeBlock(), "\n");
     283    dataLog(exec->codeBlock(), "\n");
    238284    LLINT_END_IMPL();
    239285}
     
    241287static void traceFunctionPrologue(ExecState* exec, const char* comment, CodeSpecializationKind kind)
    242288{
     289    if (!Options::traceLLIntExecution())
     290        return;
     291
    243292    JSFunction* callee = jsCast<JSFunction*>(exec->jsCallee());
    244293    FunctionExecutable* executable = callee->jsExecutable();
    245294    CodeBlock* codeBlock = executable->codeBlockFor(kind);
    246295    dataLogF("<%p> %p / %p: in %s of ", &Thread::current(), codeBlock, exec, comment);
    247     dataLog(*codeBlock);
     296    dataLog(codeBlock);
    248297    dataLogF(" function %p, executable %p; numVars = %u, numParameters = %u, numCalleeLocals = %u, caller = %p.\n",
    249298        callee, executable, codeBlock->numVars(), codeBlock->numParameters(), codeBlock->numCalleeLocals(), exec->callerFrame());
     
    276325LLINT_SLOW_PATH_DECL(trace)
    277326{
     327    if (!Options::traceLLIntExecution())
     328        LLINT_END_IMPL();
     329
    278330    OpcodeID opcodeID = Interpreter::getOpcodeID(pc[0].u.opcode);
    279331    dataLogF("<%p> %p / %p: executing bc#%zu, %s, pc = %p\n",
     
    294346}
    295347
    296 LLINT_SLOW_PATH_DECL(special_trace)
    297 {
    298     dataLogF("<%p> %p / %p: executing special case bc#%zu, op#%u, return PC is %p\n",
    299             &Thread::current(),
    300             exec->codeBlock(),
    301             exec,
    302             static_cast<intptr_t>(exec->codeBlock()->bytecodeOffset(pc)),
    303             Interpreter::getOpcodeID(pc[0].u.opcode),
    304             exec->returnPC().value());
    305     LLINT_END_IMPL();
    306 }
    307 
    308348enum EntryKind { Prologue, ArityCheck };
    309349
     
    496536    LLINT_SET_PC_FOR_STUBS();
    497537
    498 #if LLINT_SLOW_PATH_TRACING
    499     dataLogF("Checking stack height with exec = %p.\n", exec);
    500     dataLog("CodeBlock = ", *exec->codeBlock(), "\n");
    501     dataLogF("Num callee registers = %u.\n", exec->codeBlock()->numCalleeLocals());
    502     dataLogF("Num vars = %u.\n", exec->codeBlock()->numVars());
    503 
    504     dataLogF("Current OS stack end is at %p.\n", vm.softStackLimit());
     538    CodeBlock* codeBlock = exec->codeBlock();
     539    slowPathLogF("Checking stack height with exec = %p.\n", exec);
     540    slowPathLog("CodeBlock = ", codeBlock, "\n");
     541    if (codeBlock) {
     542        slowPathLogF("Num callee registers = %u.\n", codeBlock->numCalleeLocals());
     543        slowPathLogF("Num vars = %u.\n", codeBlock->numVars());
     544    }
     545    slowPathLogF("Current OS stack end is at %p.\n", vm.softStackLimit());
    505546#if !ENABLE(JIT)
    506     dataLogF("Current C Loop stack end is at %p.\n", vm.cloopStackLimit());
     547    slowPathLogF("Current C Loop stack end is at %p.\n", vm.cloopStackLimit());
    507548#endif
    508549
    509 #endif
    510550    // If the stack check succeeds and we don't need to throw the error, then
    511551    // we'll return 0 instead. The prologue will check for a non-zero value
     
    12631303    CodeBlock* codeBlock = exec->codeBlock();
    12641304    JSScope* scope = exec->uncheckedR(pc[2].u.operand).Register::scope();
    1265 #if LLINT_SLOW_PATH_TRACING
    1266     dataLogF("Creating function!\n");
    1267 #endif
     1305    slowPathLogF("Creating function!\n");
    12681306    LLINT_RETURN(JSFunction::create(vm, codeBlock->functionDecl(pc[3].u.operand), scope));
    12691307}
     
    12741312    CodeBlock* codeBlock = exec->codeBlock();
    12751313    JSScope* scope = exec->uncheckedR(pc[2].u.operand).Register::scope();
    1276 #if LLINT_SLOW_PATH_TRACING
    1277     dataLogF("Creating function!\n");
    1278 #endif
     1314    slowPathLogF("Creating function!\n");
    12791315    LLINT_RETURN(JSGeneratorFunction::create(vm, codeBlock->functionDecl(pc[3].u.operand), scope));
    12801316}
     
    12851321    CodeBlock* codeBlock = exec->codeBlock();
    12861322    JSScope* scope = exec->uncheckedR(pc[2].u.operand).Register::scope();
    1287 #if LLINT_SLOW_PATH_TRACING
    1288     dataLogF("Creating async function!\n");
    1289 #endif
     1323    slowPathLogF("Creating async function!\n");
    12901324    LLINT_RETURN(JSAsyncFunction::create(vm, codeBlock->functionDecl(pc[3].u.operand), scope));
    12911325}
     
    12961330    CodeBlock* codeBlock = exec->codeBlock();
    12971331    JSScope* scope = exec->uncheckedR(pc[2].u.operand).Register::scope();
    1298 #if LLINT_SLOW_PATH_TRACING
    1299     dataLogF("Creating async generator function!\n");
    1300 #endif
     1332    slowPathLogF("Creating async generator function!\n");
    13011333    LLINT_RETURN(JSAsyncGeneratorFunction::create(vm, codeBlock->functionDecl(pc[3].u.operand), scope));
    13021334}
     
    13591391    UNUSED_PARAM(pc);
    13601392
    1361 #if LLINT_SLOW_PATH_TRACING
    1362     dataLog("Performing host call.\n");
    1363 #endif
     1393    slowPathLog("Performing host call.\n");
    13641394   
    13651395    ExecState* exec = execCallee->callerFrame();
     
    13851415        }
    13861416       
    1387 #if LLINT_SLOW_PATH_TRACING
    1388         dataLog("Call callee is not a function: ", callee, "\n");
    1389 #endif
     1417        slowPathLog("Call callee is not a function: ", callee, "\n");
    13901418
    13911419        ASSERT(callType == CallType::None);
     
    14091437    }
    14101438   
    1411 #if LLINT_SLOW_PATH_TRACING
    1412     dataLog("Constructor callee is not a function: ", callee, "\n");
    1413 #endif
     1439    slowPathLog("Constructor callee is not a function: ", callee, "\n");
    14141440
    14151441    ASSERT(constructType == ConstructType::None);
     
    14231449    auto throwScope = DECLARE_THROW_SCOPE(vm);
    14241450
    1425 #if LLINT_SLOW_PATH_TRACING
    1426     dataLogF("Performing call with recorded PC = %p\n", exec->currentVPC());
    1427 #endif
     1451    slowPathLogF("Performing call with recorded PC = %p\n", exec->currentVPC());
    14281452   
    14291453    JSCell* calleeAsFunctionCell = getJSFunction(calleeAsValue);
  • trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.h

    r230376 r233658  
    11/*
    2  * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2011-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5353LLINT_SLOW_PATH_HIDDEN_DECL(trace_arityCheck_for_construct);
    5454LLINT_SLOW_PATH_HIDDEN_DECL(trace);
    55 LLINT_SLOW_PATH_HIDDEN_DECL(special_trace);
    5655LLINT_SLOW_PATH_HIDDEN_DECL(entry_osr);
    5756LLINT_SLOW_PATH_HIDDEN_DECL(entry_osr_function_for_call);
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm

    r232658 r233658  
    840840
    841841macro traceExecution()
    842     if EXECUTION_TRACING
     842    if TRACING
    843843        callSlowPath(_llint_trace)
    844844    end
     
    10071007    preserveCallerPCAndCFR()
    10081008
    1009     if EXECUTION_TRACING
     1009    if TRACING
    10101010        subp maxFrameExtentForSlowPathCall, sp
    10111011        callSlowPath(traceSlowPath)
  • trunk/Source/JavaScriptCore/runtime/CommonSlowPathsExceptions.cpp

    r218794 r233658  
    3535#include "JSCInlines.h"
    3636
    37 #if LLINT_SLOW_PATH_TRACING
     37#if LLINT_TRACING
    3838#include "Exception.h"
    3939#endif
     
    4848
    4949    throwException(exec, scope, error);
    50 #if LLINT_SLOW_PATH_TRACING
    51     dataLog("Throwing exception ", JSValue(scope.exception()), ".\n");
     50#if LLINT_TRACING
     51    if (UNLIKELY(Options::traceLLIntSlowPath()))
     52        dataLog("Throwing exception ", JSValue(scope.exception()), ".\n");
    5253#endif
    5354}
  • trunk/Source/JavaScriptCore/runtime/Options.cpp

    r232733 r233658  
    2828
    2929#include "AssemblerCommon.h"
     30#include "LLIntCommon.h"
    3031#include "MinimumReservedZoneSize.h"
    3132#include "SigillCrashAnalyzer.h"
     
    159160        return true;
    160161#endif
     162    if (id == traceLLIntExecutionID)
     163        return !!LLINT_TRACING;
     164    if (id == traceLLIntSlowPathID)
     165        return !!LLINT_TRACING;
    161166    return false;
    162167}
  • trunk/Source/JavaScriptCore/runtime/Options.h

    r233378 r233658  
    514514    v(bool, forcePolyProto, false, Normal, "If true, create_this will always create an object with a poly proto structure.") \
    515515    v(bool, forceMiniVMMode, false, Normal, "If true, it will force mini VM mode on.") \
    516     v(bool, useTracePoints, false, Normal, nullptr)
     516    v(bool, useTracePoints, false, Normal, nullptr) \
     517    v(bool, traceLLIntExecution, false, Configurable, nullptr) \
     518    v(bool, traceLLIntSlowPath, false, Configurable, nullptr) \
    517519
    518520
Note: See TracChangeset for help on using the changeset viewer.