1 /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */
2 /* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */
3 /* ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is [Open Source Virtual Machine.].
18 * The Initial Developer of the Original Code is
19 * Adobe System Incorporated.
20 * Portions created by the Initial Developer are Copyright (C) 2004-2006
21 * the Initial Developer. All Rights Reserved.
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 #ifndef __avmplus_SamplerScript__
41 #define __avmplus_SamplerScript__
47 class TraceClass
: public ClassClosure
50 TraceClass(VTable
* cvtable
);
52 int getLevel(int target
);
53 Atom
setLevel(int lvl
, int target
);
54 Atom
setListener(FunctionObject
* f
);
55 FunctionObject
* getListener();
57 DECLARE_SLOTS_TraceClass
;
63 static bool trusted(ScriptObject
* self
) { return self
->toplevel()->sampler_trusted(self
); }
64 explicit SamplerScript(); // unimplemented, not constructable
67 enum { GET
= 1, SET
= 2 };
69 static double getSize(ScriptObject
* self
, Atom o
);
70 static Atom
getMemberNames(ScriptObject
* self
, Atom o
, bool instanceNames
);
71 static Atom
_getSamples(ScriptObject
* self
, ClassClosure
* cf
);
72 static void clearSamples(ScriptObject
* self
);
73 static void startSampling(ScriptObject
* self
);
74 static void stopSampling(ScriptObject
* self
);
75 static void pauseSampling(ScriptObject
* self
);
76 static void sampleInternalAllocs(ScriptObject
* self
, bool b
);
77 static double getSampleCount(ScriptObject
* self
);
78 static void _setSamplerCallback(ScriptObject
* self
, ScriptObject
* callback
);
79 static double _getInvocationCount(ScriptObject
* self
, Atom a
, QNameObject
* qname
, uint32_t type
);
80 static bool isGetterSetter(ScriptObject
* self
, Atom a
, QNameObject
* name
);
82 static ArrayObject
* getLexicalScopes(ScriptObject
* self
, FunctionObject
*function
);
83 static Atom
getSavedThis(ScriptObject
* self
, FunctionObject
*method
);
85 static Stringp
getMasterString(ScriptObject
* self
, Stringp str
);
89 static ClassClosure
* getType(Toplevel
* toplevel
, SamplerObjectType sot
, const void *obj
);
91 friend class SampleIterator
;
92 static ScriptObject
* makeSample(ScriptObject
* self
, ClassFactoryClass
* cf
, const Sample
& sample
);
93 static bool set_stack(ScriptObject
* self
, ClassFactoryClass
* cf
, const Sample
& sample
, SampleObject
* sam
);
97 class SampleClass
: public ClassClosure
100 SampleClass(VTable
*vtable
);
102 DECLARE_SLOTS_SampleClass
;
105 class SampleObject
: public ScriptObject
107 friend class SamplerScript
;
109 SampleObject(VTable
*vtable
, ScriptObject
*delegate
);
111 DECLARE_SLOTS_SampleObject
;
114 class NewObjectSampleObject
: public SampleObject
116 friend class SamplerScript
;
118 NewObjectSampleObject(VTable
*vtable
, ScriptObject
*delegate
);
121 void setRef(AvmPlusScriptableObject
* o
) { obj
= o
; }
122 void setSize(uint64_t s
) { size
= s
; }
124 DRCWB(AvmPlusScriptableObject
*) obj
;
127 DECLARE_SLOTS_NewObjectSampleObject
;
130 class NewObjectSampleClass
: public SampleClass
133 NewObjectSampleClass(VTable
*vtable
);
135 DECLARE_SLOTS_NewObjectSampleClass
;
138 class DeleteObjectSampleObject
: public SampleObject
140 friend class SamplerScript
;
142 DeleteObjectSampleObject(VTable
*vtable
, ScriptObject
*delegate
);
144 DECLARE_SLOTS_DeleteObjectSampleObject
;
147 class DeleteObjectSampleClass
: public SampleClass
150 DeleteObjectSampleClass(VTable
*vtable
);
152 DECLARE_SLOTS_DeleteObjectSampleClass
;
155 class StackFrameObject
: public ScriptObject
157 friend class SamplerScript
;
159 StackFrameObject(VTable
*vtable
, ScriptObject
*delegate
) : ScriptObject(vtable
, delegate
) {}
161 DECLARE_SLOTS_StackFrameObject
;
164 class StackFrameClass
: public ClassClosure
167 StackFrameClass(VTable
*vtable
) : ClassClosure(vtable
) { createVanillaPrototype(); }
169 DECLARE_SLOTS_StackFrameClass
;
172 class ClassFactoryClass
: public ClassClosure
174 friend class SamplerScript
;
176 ClassFactoryClass(VTable
*vtable
) : ClassClosure(vtable
) { createVanillaPrototype(); }
178 DECLARE_SLOTS_ClassFactoryClass
;
181 #endif // __avmplus_SamplerScript__