#ifndef SamplingTool_h
#define SamplingTool_h
+#include "Strong.h"
+#include "Nodes.h"
+#include "Opcode.h"
#include <wtf/Assertions.h>
#include <wtf/HashMap.h>
#include <wtf/Threading.h>
-#include "Nodes.h"
-#include "Opcode.h"
-
namespace JSC {
+ class ScriptExecutable;
+
class SamplingFlags {
- friend class JIT;
public:
static void start();
static void stop();
int m_flag;
};
+ static const void* addressOfFlags()
+ {
+ return &s_flags;
+ }
+
#endif
private:
static uint32_t s_flags;
class ScopeNode;
struct Instruction;
- struct ScopeSampleRecord {
- ScopeSampleRecord(ScopeNode* scope)
- : m_scope(scope)
+ struct ScriptSampleRecord {
+ ScriptSampleRecord(JSGlobalData& globalData, ScriptExecutable* executable)
+ : m_executable(globalData, executable)
, m_codeBlock(0)
, m_sampleCount(0)
, m_opcodeSampleCount(0)
{
}
- ~ScopeSampleRecord()
+ ~ScriptSampleRecord()
{
if (m_samples)
free(m_samples);
void sample(CodeBlock*, Instruction*);
- RefPtr<ScopeNode> m_scope;
+ Strong<ScriptExecutable> m_executable;
CodeBlock* m_codeBlock;
int m_sampleCount;
int m_opcodeSampleCount;
unsigned m_size;
};
- typedef WTF::HashMap<ScopeNode*, ScopeSampleRecord*> ScopeSampleRecordMap;
+ typedef WTF::HashMap<ScriptExecutable*, ScriptSampleRecord*> ScriptSampleRecordMap;
class SamplingThread {
public:
class SamplingTool {
public:
- friend class CallRecord;
+ friend struct CallRecord;
friend class HostCallRecord;
#if ENABLE(OPCODE_SAMPLING)
- class CallRecord : Noncopyable {
+ class CallRecord {
+ WTF_MAKE_NONCOPYABLE(CallRecord);
public:
CallRecord(SamplingTool* samplingTool)
: m_samplingTool(samplingTool)
}
};
#else
- class CallRecord : Noncopyable {
+ class CallRecord {
+ WTF_MAKE_NONCOPYABLE(CallRecord);
public:
CallRecord(SamplingTool*)
{
, m_sampleCount(0)
, m_opcodeSampleCount(0)
#if ENABLE(CODEBLOCK_SAMPLING)
- , m_scopeSampleMap(new ScopeSampleRecordMap())
+ , m_scopeSampleMap(new ScriptSampleRecordMap())
#endif
{
memset(m_opcodeSamples, 0, sizeof(m_opcodeSamples));
void setup();
void dump(ExecState*);
- void notifyOfScope(ScopeNode* scope);
+ void notifyOfScope(ScriptExecutable* scope);
void sample(CodeBlock* codeBlock, Instruction* vPC)
{
unsigned m_opcodeSamplesInCTIFunctions[numOpcodeIDs];
#if ENABLE(CODEBLOCK_SAMPLING)
- Mutex m_scopeSampleMapMutex;
- OwnPtr<ScopeSampleRecordMap> m_scopeSampleMap;
+ Mutex m_scriptSampleMapMutex;
+ OwnPtr<ScriptSampleRecordMap> m_scopeSampleMap;
#endif
};
// Implements a named set of counters, printed on exit if ENABLE(SAMPLING_COUNTERS).
// See subclasses below, SamplingCounter, GlobalSamplingCounter and DeletableSamplingCounter.
class AbstractSamplingCounter {
- friend class JIT;
friend class DeletableSamplingCounter;
public:
void count(uint32_t count = 1)
static void dump();
+ int64_t* addressOfCounter() { return &m_counter; }
+
protected:
// Effectively the contructor, however called lazily in the case of GlobalSamplingCounter.
void init(const char* name)