18e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/*
28e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Copyright (C) 2008 Apple Inc. All rights reserved.
38e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
48e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Redistribution and use in source and binary forms, with or without
58e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * modification, are permitted provided that the following conditions
68e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * are met:
78e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
88e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 1.  Redistributions of source code must retain the above copyright
98e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *     notice, this list of conditions and the following disclaimer.
108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 2.  Redistributions in binary form must reproduce the above copyright
118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *     notice, this list of conditions and the following disclaimer in the
128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *     documentation and/or other materials provided with the distribution.
138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *     its contributors may be used to endorse or promote products derived
158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *     from this software without specific prior written permission.
168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
238e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
248e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
258e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
268e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
288e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
298e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#ifndef Profiler_h
308e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#define Profiler_h
318e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
328e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "Profile.h"
338e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <wtf/PassRefPtr.h>
348e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <wtf/RefPtr.h>
358e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <wtf/Vector.h>
368e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
378e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectnamespace JSC {
388e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
398e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    class ExecState;
408e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    class JSGlobalData;
412bde8e466a4451c7319e3a072d118917957d6554Steve Block    class JSGlobalObject;
428e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    class JSObject;
435f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian    class JSValue;
448e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    class ProfileGenerator;
458e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    class UString;
460bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5Ben Murdoch    struct CallIdentifier;
478e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
48ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch    class Profiler {
49ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch        WTF_MAKE_FAST_ALLOCATED;
508e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    public:
518e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        static Profiler** enabledProfilerReference()
528e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        {
538e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project            return &s_sharedEnabledProfilerReference;
548e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        }
558e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
568e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        static Profiler* profiler();
57643ca7872b450ea4efacab6188849e5aac2ba161Steve Block        static CallIdentifier createCallIdentifier(ExecState* exec, JSValue, const UString& sourceURL, int lineNumber);
588e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
598e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        void startProfiling(ExecState*, const UString& title);
608e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        PassRefPtr<Profile> stopProfiling(ExecState*, const UString& title);
612bde8e466a4451c7319e3a072d118917957d6554Steve Block        void stopProfiling(JSGlobalObject*);
628e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
634576aa36e9a9671459299c7963ac95aa94beaea9Shimeng (Simon) Wang        void willExecute(ExecState* callerCallFrame, JSValue function);
644576aa36e9a9671459299c7963ac95aa94beaea9Shimeng (Simon) Wang        void willExecute(ExecState* callerCallFrame, const UString& sourceURL, int startingLineNumber);
654576aa36e9a9671459299c7963ac95aa94beaea9Shimeng (Simon) Wang        void didExecute(ExecState* callerCallFrame, JSValue function);
664576aa36e9a9671459299c7963ac95aa94beaea9Shimeng (Simon) Wang        void didExecute(ExecState* callerCallFrame, const UString& sourceURL, int startingLineNumber);
674576aa36e9a9671459299c7963ac95aa94beaea9Shimeng (Simon) Wang
684576aa36e9a9671459299c7963ac95aa94beaea9Shimeng (Simon) Wang        void exceptionUnwind(ExecState* handlerCallFrame);
698e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
708e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        const Vector<RefPtr<ProfileGenerator> >& currentProfiles() { return m_currentProfiles; };
718e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
728e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    private:
738e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        Vector<RefPtr<ProfileGenerator> > m_currentProfiles;
748e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        static Profiler* s_sharedProfiler;
758e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project        static Profiler* s_sharedEnabledProfilerReference;
768e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    };
778e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
788e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project} // namespace JSC
798e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
808e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#endif // Profiler_h
81