Ignore:
Timestamp:
May 13, 2009, 2:10:02 AM (16 years ago)
Author:
[email protected]
Message:

2009-05-12 Gavin Barraclough <[email protected]>

Reviewed by Oliver Hunt.

Add SamplingCounter tool to provide a simple mechanism for counting events in JSC
(enabled using ENABLE(SAMPLING_COUNTERS)). To count events within a single function
use the class 'SamplingCounter', where the counter may be incremented from multiple
functions 'GlobalSamplingCounter' may be convenient; all other counters (stack or
heap allocated, rather than statically declared) should use the DeletableSamplingCounter.
Further description of these classes is provided alongside their definition in
SamplingTool.h.

Counters may be incremented from c++ by calling the 'count()' method on the counter,
or may be incremented by JIT code by using the 'emitCount()' method within the JIT.

This patch also fixes CODEBLOCK_SAMPLING, which was missing a null pointer check.

  • JavaScriptCore.exp:
  • assembler/MacroAssemblerX86.h: (JSC::MacroAssemblerX86::addWithCarry32): (JSC::MacroAssemblerX86::and32): (JSC::MacroAssemblerX86::or32):
  • assembler/MacroAssemblerX86Common.h: (JSC::MacroAssemblerX86Common::and32): (JSC::MacroAssemblerX86Common::or32):
  • assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::and32): (JSC::MacroAssemblerX86_64::or32): (JSC::MacroAssemblerX86_64::addPtr):
  • assembler/X86Assembler.h: (JSC::X86Assembler::): (JSC::X86Assembler::adcl_im): (JSC::X86Assembler::addq_im): (JSC::X86Assembler::andl_im): (JSC::X86Assembler::orl_im):
  • bytecode/SamplingTool.cpp: (JSC::AbstractSamplingCounter::dump):
  • bytecode/SamplingTool.h: (JSC::AbstractSamplingCounter::count): (JSC::GlobalSamplingCounter::name): (JSC::SamplingCounter::SamplingCounter):
  • jit/JIT.h:
  • jit/JITCall.cpp: (JSC::):
  • jit/JITInlineMethods.h: (JSC::JIT::setSamplingFlag): (JSC::JIT::clearSamplingFlag): (JSC::JIT::emitCount):
  • jsc.cpp: (runWithScripts):
  • parser/Nodes.cpp: (JSC::ScopeNode::ScopeNode):
  • wtf/Platform.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/assembler/X86Assembler.h

    r43434 r43619  
    194194        GROUP1_OP_ADD = 0,
    195195        GROUP1_OP_OR  = 1,
     196        GROUP1_OP_ADC = 2,
    196197        GROUP1_OP_AND = 4,
    197198        GROUP1_OP_SUB = 5,
     
    296297    // Arithmetic operations:
    297298
     299#if !PLATFORM(X86_64)
     300    void adcl_im(int imm, void* addr)
     301    {
     302        if (CAN_SIGN_EXTEND_8_32(imm)) {
     303            m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_ADC, addr);
     304            m_formatter.immediate8(imm);
     305        } else {
     306            m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_ADC, addr);
     307            m_formatter.immediate32(imm);
     308        }
     309    }
     310#endif
     311
    298312    void addl_rr(RegisterID src, RegisterID dst)
    299313    {
     
    341355        } else {
    342356            m_formatter.oneByteOp64(OP_GROUP1_EvIz, GROUP1_OP_ADD, dst);
     357            m_formatter.immediate32(imm);
     358        }
     359    }
     360
     361    void addq_im(int imm, int offset, RegisterID base)
     362    {
     363        if (CAN_SIGN_EXTEND_8_32(imm)) {
     364            m_formatter.oneByteOp64(OP_GROUP1_EvIb, GROUP1_OP_ADD, base, offset);
     365            m_formatter.immediate8(imm);
     366        } else {
     367            m_formatter.oneByteOp64(OP_GROUP1_EvIz, GROUP1_OP_ADD, base, offset);
    343368            m_formatter.immediate32(imm);
    344369        }
     
    373398    }
    374399
     400    void andl_im(int imm, int offset, RegisterID base)
     401    {
     402        if (CAN_SIGN_EXTEND_8_32(imm)) {
     403            m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_AND, base, offset);
     404            m_formatter.immediate8(imm);
     405        } else {
     406            m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_AND, base, offset);
     407            m_formatter.immediate32(imm);
     408        }
     409    }
     410
    375411#if PLATFORM(X86_64)
    376412    void andq_rr(RegisterID src, RegisterID dst)
     
    389425        }
    390426    }
     427#else
     428    void andl_im(int imm, void* addr)
     429    {
     430        if (CAN_SIGN_EXTEND_8_32(imm)) {
     431            m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_AND, addr);
     432            m_formatter.immediate8(imm);
     433        } else {
     434            m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_AND, addr);
     435            m_formatter.immediate32(imm);
     436        }
     437    }
    391438#endif
    392439
     
    417464    }
    418465
     466    void orl_im(int imm, int offset, RegisterID base)
     467    {
     468        if (CAN_SIGN_EXTEND_8_32(imm)) {
     469            m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_OR, base, offset);
     470            m_formatter.immediate8(imm);
     471        } else {
     472            m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_OR, base, offset);
     473            m_formatter.immediate32(imm);
     474        }
     475    }
     476
    419477#if PLATFORM(X86_64)
    420478    void orq_rr(RegisterID src, RegisterID dst)
     
    430488        } else {
    431489            m_formatter.oneByteOp64(OP_GROUP1_EvIz, GROUP1_OP_OR, dst);
     490            m_formatter.immediate32(imm);
     491        }
     492    }
     493#else
     494    void orl_im(int imm, void* addr)
     495    {
     496        if (CAN_SIGN_EXTEND_8_32(imm)) {
     497            m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_OR, addr);
     498            m_formatter.immediate8(imm);
     499        } else {
     500            m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_OR, addr);
    432501            m_formatter.immediate32(imm);
    433502        }
Note: See TracChangeset for help on using the changeset viewer.