2009-05-12  Gavin Barraclough  <barraclough@apple.com>

        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:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@43619 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/assembler/MacroAssemblerX86.h b/JavaScriptCore/assembler/MacroAssemblerX86.h
index 89ecd7f..094b53d 100644
--- a/JavaScriptCore/assembler/MacroAssemblerX86.h
+++ b/JavaScriptCore/assembler/MacroAssemblerX86.h
@@ -39,7 +39,9 @@
     static const Scale ScalePtr = TimesFour;
 
     using MacroAssemblerX86Common::add32;
+    using MacroAssemblerX86Common::and32;
     using MacroAssemblerX86Common::sub32;
+    using MacroAssemblerX86Common::or32;
     using MacroAssemblerX86Common::load32;
     using MacroAssemblerX86Common::store32;
     using MacroAssemblerX86Common::branch32;
@@ -55,6 +57,21 @@
         m_assembler.addl_im(imm.m_value, address.m_ptr);
     }
     
+    void addWithCarry32(Imm32 imm, AbsoluteAddress address)
+    {
+        m_assembler.adcl_im(imm.m_value, address.m_ptr);
+    }
+    
+    void and32(Imm32 imm, AbsoluteAddress address)
+    {
+        m_assembler.andl_im(imm.m_value, address.m_ptr);
+    }
+    
+    void or32(Imm32 imm, AbsoluteAddress address)
+    {
+        m_assembler.orl_im(imm.m_value, address.m_ptr);
+    }
+
     void sub32(Imm32 imm, AbsoluteAddress address)
     {
         m_assembler.subl_im(imm.m_value, address.m_ptr);