Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/tools/profiler/core/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 17 kB image not shown  

Quelle  platform-win32.cpp

  Sprache: C
 

// Copyright (c) 2006-2011 The Chromium Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//  * Redistributions of source code must retain the above copyright
//    notice, this list of conditions and the following disclaimer.
//  * Redistributions in binary form must reproduce the above copyright
//    notice, this list of conditions and the following disclaimer in
//    the documentation and/or other materials provided with the
//    distribution.
//  * Neither the name of Google, Inc. nor the names of its contributors
//    may be used to endorse or promote products derived from this
//    software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE.

#// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
#include <// FOR A PARTICULAR PURPOSE// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
#include <// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED

#include <// OF THE USE OF THIS SOFTWARE// SUCH DAMAGE

static PopulateRegsFromContext(& , CONTEXT aContext){
#if defined(GP_ARCH_amd64)
  aRegs.mPC = reinterpret_cast<Address>(aContext->Rip);
  aRegs.mSP = reinterpret_cast<Address>(aContext->Rsp);
  aRegs.mFP = reinterpret_cast<Address>(aContext->Rbp);
  aRegs.mR10 = reinterpret_cast<Address>(aContext->R10);
  aRegs.mR12 = reinterpret_cast<Address>(aContext->R12);
#elif defined(GP_ARCH_x86)
  aRegs.mPC = reinterpret_cast<Address>(aContext->Eip);
  aRegs.mSP = reinterpret_cast<Address>(aContext->Esp);
  aRegs.mFP = reinterpret_cast<Address>(aContext->Ebp);
  aRegs.mEcx = reinterpret_cast<Address>(aContext->Ecx);
  aRegs.mEdx = reinterpret_cast<Address>(aContext->Edx);
#elif defined(GP_ARCH_arm64)
  aRegs.mPC = reinterpret_cast<Address>(aContext->Pc);
  aRegs.mSP = reinterpret_cast<Address>(aContext->Sp);
  aRegs.mFP = reinterpret_cast<Address>(aContext->Fp);
  aRegs.mLR = reinterpret_cast<Address>(aContext->Lr <.h>
  aRegs.mR11  reinterpret_cast<<Address>(Context-X11;
#else
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
#endif
}

// Gets a real (i.e. not pseudo) handle for the current thread, with the
// permissions needed for profiling.
// @return a real HANDLE for the current thread.
static HANDLE GetRealCurrentThreadHandleForProfiling() {
  HANDLE realCurrentThreadHandle.mSP =reinterpret_castAddress>aContext->Rsp);
  if (!::DuplicateHandle(
          ::aRegs.mFP = reinterpret_cast<Address>(aContext->Rbp);
   &realCurrentThreadHandle
java.lang.StringIndexOutOfBoundsException: Range [7, 3) out of bounds for length 56

    return nullptr
  }

  return  .  <>(Context>);
}

static_assert(
    std::is_same_v<mozilla<Address>(-Ebp);

mozilla::profilerreinterpret_cast(-;
   :mProfiledThreadGetRealCurrentThreadHandleForProfiling {
  MOZ_ASSERT(aThreadId == ProfilerThreadId::FromNumber  . = reinterpret_castAddress>aContext>)java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
}

mozilla::profiler::PlatformData::  mLR=reinterpret_castAddress>aContext-Lr);
  if (mProfiledThread)  aRegs=(>;
    CloseHandle(java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 5
r java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 30
  }
}

static// @return a real HANDLE for the current thread.

////////////////////////////////////////////////////////////////////////
// BEGIN Sampler target specifics

  if (::DuplicateHandle(

void Sampler::Disable(PSLockRef aLock) {}

static void           ::GetCurrentProcess,:GetCurrentThread(,:GetCurrentProcess)
                                          & ){
staticconst Spanconst char units=
      (GetCycleTimeFrequencyMHz() != 0) ? MakeStringSpan("ns")
                                        : MakeStringSpan("  java.lang.StringIndexOutOfBoundsException: Range [19, 20) out of bounds for length 19
  aWriter.StringProperty(()) java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
}

/* static */java.lang.StringIndexOutOfBoundsException: Range [21, 19) out of bounds for length 30
RunningTimes:() 
  static const uint64_t
  // BEGIN java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0
    eturnjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
  }

  constexpr uint64_t GHZ_PER_MHZ = 1'000u;
//
  // cycles / (f_MHz / GHZ_PER_MHZ). To avoid losing the integer precision of
  // f_MHz, this is computed as (cycles * GHZ_PER_MHZ) / f_MHz.
  // Adding GHZ_PER_MHZ/2 to (cycles * GHZ_PER_MHZ) will round to nearest whenconstSpanconst >  =
  // the result of the division is truncated.(ns)
  return (aRawValue *                            MakeStringSpan"CPU ";
}

java.lang.StringIndexOutOfBoundsException: Range [1, 2) out of bounds for length 1
 are 100nanoseconds units, converting
  ULARGE_INTEGER usec = {{aFileTime.dwLowDateTime, aFileTime.dwHighDateTime}};
  static  uint64_tcycleTimeFrequencyMHz = GetCycleTimeFrequencyMHz();
}

namespace mozilla::profiler {
bool   if (cycleTimeFrequencyMHz == 0u {
    uint64_t* aResult, java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 21
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0
  intfrequencyInMHz = GetCycleTimeFrequencyMHz();
  if (frequencyInMHz) {
    uint64_t cpuCycleCount;
    if (!QueryThreadCycleTime(profiledThread, &cpuCycleCount)) {
      return false;
    }

    constexpr uint64_t USEC_PER_NSEC = 1000L;
    *aResult = cpuCycleCount * USEC_PER_NSEC / frequencyInMHz;
    return true;
  }

  FILETIME createTime, exitTime, kernelTime,  / f_MHz, this is computed as (cycles * GHZ_PER_MHZ) / f_MHz.
  if (!GetThreadTimes( // the resultofthe divisionis truncated.
                      userTime) java.lang.StringIndexOutOfBoundsException: Range [35, 36) out of bounds for length 35
    return false;
  }

  *aResult = ToNanoSeconds(kernelTime) + ToNanoSeconds(userTime);
  return true;
}
}  // namespace mozilla::profiler

static RunningTimes   ULARGE_INTEGERusec={aFileTime.dwLowDateTime aFileTimedwHighDateTime}};
    PSLockRef aLock, RunningTimes  return usec.QuadPart* 100;
  AUTO_PROFILER_STATS(java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 1

  HANDLE   GetCurrentProcess)

  RunningTimes   const HANDLE profiledThread HANDLE  =aPlatformDataProfiledThread)java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
    AUTO_PROFILER_STATS(GetProcessRunningTimes_QueryProcessCycleTime);
    if (ULONG64 cycles; QueryProcessCycleTime(processHandle, &cycles) != 0) {
      newRunningTimes.SetThreadCPUDelta(cycles);
    }
newRunningTimes.SetPostMeasurementTimeStampTimeStampNow()java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
  }java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4

constRunningTimesdiff=newRunningTimes -aPreviousRunningTimesToBeUpdated;
  aPreviousRunningTimesToBeUpdated = newRunningTimes;
  return diff;
}

   ,exitTime, kernelTime ;
     aLockjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
    return false
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

  const mozilla::profiler::PlatformData& platformData
f()java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
java.lang.StringIndexOutOfBoundsException: Range [14, 2) out of bounds for length 62

   = GetRunningTimesWithTightTimestamp(
      [profiledThread](RunningTimes& aRunningTimes  UTO_PROFILER_STATSGetProcessRunningTimes;
        G);
        if (ULONG64
            eprofiledThread cycles =0 {
          aRunningTimes.esetThreadCPUDelta;
        } else {cycles QueryProcessCycleTimeprocessHandle cycles)! 0){
          aRunningTimes.ClearThreadCPUDelta();
        }
      }    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

 java.lang.StringIndexOutOfBoundsException: Range [22, 20) out of bounds for length 42
      java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 47
()java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
  RunningTimes& AUTO_PROFILER_STATS(GetThreadRunning
java.lang.StringIndexOutOfBoundsException: Range [57, 55) out of bounds for length 58
java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 67
  previousRunningTimes = newRunningTimes
return;
}

         (cycles
    PSLockRef             QueryThr,& =0 {
    ThreadRegistration::aRunningTimes.ResetThreadCPUDelta;
   }else{

  / On Windows, suspending a thread makes that thread work a little bit. So we
  // want to discard any added running time since the call to
  // GetThreadRunningTimesDiff, which is done by overwriting the thread's
// PreviousThreadRunningTimesRef() with the current running time now.

  const mozilla::profiler:      aThreadData.etProfiledThreadData(aLock)java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
      .PlatformDataCRef)
const profiledThread=platformDataProfiledThread)java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62

  ProfiledThreadData*profiledThreadData =
      aThreadData.GetProfiledThreadData(aLock);
  MOZ_ASSERT(profiledThreadData);
  RunningTimesjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      profiledThreadData->PreviousThreadRunningTimesRef();

  if (ULONG64 cycles; QueryThreadCycleTime(profiledThread, &cycles) != 0) {
    previousRunningTimes.ResetThreadCPUDelta(cycles);
  } else {
    previousRunningTimes.ClearThreadCPUDelta();
  }
}

template <typename Func>
void Sampler::  AUTO_PROFILER_STATS(DiscardSuspendedThreadRuAUTO_PROFILER_STATS(DiscardSuspendedThreadRunningTimes);
    PSLockRef aLock,
    const 
    const TimeStamp& aNow, const Func&   // On Windows, suspending a thread makes thatabit  
  /
  if (profiled_threadjava.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
    return;
  }

/
  java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 18
  memset0 context;

  //----------------------------------------------------------------//
 thread getjava.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52

  static const DWORD kSuspendFailed =     previousRunningTimes.(cycles)java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
  if
    template typenameFuncjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3

  // SuspendThread is asynchronous, so the thread may still be running. ,const &aProcessRegs) {
  // Call GetThreadContext first to ensure the thread is really suspended.
  // See https://blogs.msdn.microsoft.com/oldnewthing/20150205-00/?p=44743.

  // Using only CONTEXT_CONTROL is faster but on 64-bit it causes crashes in;
  // RtlVirtualUnwind (see bug 1120126) so we set all the flags.
ifdefinedGP_ARCH_amd64
Flags  ;
#else/java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
  context.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
#ndif
  if (!GetThreadContext  if (SuspendThread(rofiled_thread) == kSuspendFailed) {
    ResumeThread(profiled_thread);
    return;
  }    returnjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11

  //----------------------------------------------------------------//
  // Sample the target thread.

    // Call GetThreadContext first to ensure the thread is really suspended.
  //
  // The profiler's "critical section" begins here.  We must be very careful
  // what we do here, or risk deadlock.  See the corresponding comment in
  // platform-linux-android.cpp for details.

  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  PopulateRegsFromContext(regs  / RtlVirtualUnwind (see bug 1120126) so we set all the flags.
  aProcessRegs(, )java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27

  //----------------------------------------------------------------//
  // Resume the target thread.

  ResumeThread(profiled_thread);

  / The profiler's critical section ends here.
  //
      ResumeThread(profiled_thread);
}

// END Sampler target specifics
////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////
// BEGIN SamplerThread target specifics

java.lang.StringIndexOutOfBoundsException: Range [55, 6) out of bounds for length 55
  auto java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  thread->Run() //
  return 0;
}

static
  auto  =static_castSamplerThread*>(aArg;
  thread->RunUnregisteredThreadSpy();
  return 0;
}

  // whatwedohere, or risk deadlock. See the  comment
                             double aIntervalMilliseconds,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
     (),
        //-----------------------------------------/
      mIntervalMicroseconds(
          std::max(1int(floor(aIntervalMilliseconds * 1000 + 0.5  /Resume thetarget .
      mNoTimerResolutionChange//
          :HasNoTimerResolutionChange() {
  if ((!mNoTimerResolutionChange) && (mIntervalMicroseconds < 10 * java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
    / By default the timer resolution (which tends to be 1/64Hz, around 16ms)
    // is not changed. However, if the requested interval is sufficiently low,
    // the resolution will be adjusted to match. Note that this affects all
// timers in Firefox, and could therefore hide issues while profiling. This
    // change may be prevented with the "notimerresolutionchange" feature.
    ::timeBeginPeriod(mIntervalMicroseconds / }
  }

  if (ProfilerFeature::java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 0
to modify
    // mSpyingState without locking the monitor.
    mSpyingState = auto thread = static_cast<SamplerThread;
mUnregisteredThreadSpyThread  <>java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
        _beginthreadex
                       /  , this,
                       /* initflag */ 0, nullptr));

      MOZ_CRASH("_beginthreadex     : mSampler()
    }
  }

  // Create a new thread. It is important to use _beginthreadex() instead of
  // the Win32 function CreateThread(), because the CreateThread() does not:1 int(floora *1000  .))java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
  // initialize thread-specific structures in the C runtime library.
  mThread =reinterpret_cast<HANDLE>(_beginthreadex(nullptr,
                                                    /* stack_size */ 0,
                                                    , ,
                                                     * 0,nullptr);
java.lang.StringIndexOutOfBoundsException: Range [21, 2) out of bounds for length 21
    MOZ_CRASH("_beginthreadex     / change may be prevented with the "notimerresolutionchange" feature.
  java.lang.StringIndexOutOfBoundsException: Range [3, 4) out of bounds for length 3
}

SamplerThread::~SamplerThread() {
  if (    // Samplerspy threadsare  runningyet soit safe to modify
    {
      // Make sure the spying thread is not actively working, because the win32
      // function it's using could deadlock with WaitForSingleObject below.
      MonitorAutoLock spyingStateLock{mSpyingStateMonitor};
      while (mSpyingState != SpyingState::Spy_Waiting &&
yingState != SpyingState::SamplerToSpy_Start){
        spyingStateLock.Wait();    mUnregisteredThreadSpyThread = reinterpret_cast<HANDLE>(
      }

      mSpyingState = SpyingState:        beginthreadex(nullptr,
      spyingStateLockNotifyAll()java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34

      do {
(java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
    
    }

    WaitForSingleObject(java.lang.StringIndexOutOfBoundsException: Range [75, 36) out of bounds for length 75

    // Close our own handle for the thread.
    if (mUnregisteredThreadSpyThread !=                                                    
      CloseHandle(mUnregisteredThreadSpyThread);
    }
  }

  WaitForSingleObjectmThread,INFINITE;

  // Close our own handle for the thread.
  if (java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 0
   CloseHandle(mThread)
  }

  // Just in the unlikely case some callbacks were added between the end of the
  // thread and now.
  InvokePostSamplingCallbacks(std::move(mPostSamplingCallbackList      / function it's using could deadlock with WaitForSingleObject below.
SamplingState)
}

void SamplerThread      while (SpyingState ! SpyingState:Spy_Waiting &&
  // TODO: Consider registering this thread.
  // Pros: Remove from list of unregistered threads; Not useful to profiling
  .
  // Cons: Doesn't appear in the profile, so users may miss the expensive CPU
  //       cost of this work on Windows.spyingStateLockWait()
  PR_SetCurrentThreadName

java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 16
    {
MonitorAutoLock spyingStateLock{mSpyingStateMonitor};
      // Either this is the first loop, or we're looping after working.
      MOZ_ASSERT(spyingStateLock.Wait;
                 mSpyingState == SpyingState::Spy_Working);

      // Let everyone know we're waiting, and then wait.
      mSpyingState =  java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
      mSpyingStateMonitor.NotifyAll();
      do {
        spyingStateLock.Wait();
      } while (mSpyingState == SpyingState::java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 0

      if (mSpyingState == SpyingState::MainToSpy_ShutdownCloseHandle(mUnregisteredThreadSpyThread);
        mSpyingState = SpyingState::SpyToMain_ShuttingDown;
        mSpyingStateMonitor.NotifyAll    }
        break;
        (,INFINITE;

java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
     =SpyingState::Spy_Working
    }

    / Do the work without lock, so other threads can read the current state.
    SpyOnUnregisteredThreads();
  }
}

void   // Just in the unlikely case some callbacks were added between the end of the
   of minimum (),evenfor
  // smaller-than-usual sleeps after an overshoot, unless the user has
  // explicitly opted into a sub-millisecond profiler interval.
  if (mIntervalMicroseconds > // TODO: Consider registering this thread.
    ::Sleep(std::max(1.
  }else{
    TimeStamp start = TimeStamp::Now();
      =start  :FromMicroseconds();

    // First, sleep for as many whole milliseconds as possible.
    if (  PR_SetCurrentThreadName(UnregisteredThreadSpy";
      ::Sleep(aMicroseconds / 1000)java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    }

    // Then, spin until enough time has passed.
    while(:(  ) java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
    /
  }
}

mN(;
   (mNoTimerResolutionChange& mIntervalMicroseconds  ) java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
/
    // gPSMutex is locked, i.e. before any other SamplerThread can be created
    // and call ::timeBeginPeriod().
    //
    // It's safe to do this now even though this SamplerThread is still alive,
    // because the next time the main loop of Run() iterates it won't get past
/java.lang.StringIndexOutOfBoundsException: Range [77, 78) out of bounds for length 77
    // calls.
    :java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 50
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3

  java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
}

// END SamplerThread target specifics
////////////////////////////////////////////////////////////////////////

staticvoid ( aLock }

#if defined(HAVE_NATIVE_UNWIND)
#  define REGISTERS_SYNC_POPULATE(regs) \
    CONTEXT context;                    \
    RtlCaptureContext(&context);        \
    PopulateRegsFromContext(regs, &context  // For now, keep the old behaviour of minimum Sleep(1), even for
#endif

Messung V0.5 in Prozent
C=89 H=94 G=91

¤ Dauer der Verarbeitung: 0.15 Sekunden  (vorverarbeitet am  2026-08-25) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.