~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/3rdparty/webkit/WebCore/inspector/JavaScriptProfileNode.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include "config.h"
27
27
#include "JavaScriptProfileNode.h"
28
28
 
 
29
#if ENABLE(JAVASCRIPT_DEBUGGER)
 
30
 
29
31
#include "JSDOMBinding.h"
30
32
#include <profiler/ProfileNode.h>
31
33
#include <JavaScriptCore/APICast.h>
46
48
typedef HashMap<ProfileNode*, JSObject*> ProfileNodeMap;
47
49
 
48
50
static ProfileNodeMap& profileNodeCache()
49
 
 
51
{
50
52
    DEFINE_STATIC_LOCAL(ProfileNodeMap, staticProfileNodes, ());
51
53
    return staticProfileNodes;
52
54
}
82
84
 
83
85
static JSValueRef getTotalTime(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*)
84
86
{
85
 
    JSC::JSLock lock(false);
 
87
    JSC::JSLock lock(SilenceAssertionsOnly);
86
88
 
87
89
    if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
88
90
        return JSValueMakeUndefined(ctx);
93
95
 
94
96
static JSValueRef getSelfTime(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*)
95
97
{
96
 
    JSC::JSLock lock(false);
 
98
    JSC::JSLock lock(SilenceAssertionsOnly);
97
99
 
98
100
    if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
99
101
        return JSValueMakeUndefined(ctx);
104
106
 
105
107
static JSValueRef getTotalPercent(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*)
106
108
{
107
 
    JSC::JSLock lock(false);
 
109
    JSC::JSLock lock(SilenceAssertionsOnly);
108
110
 
109
111
    if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
110
112
        return JSValueMakeUndefined(ctx);
115
117
 
116
118
static JSValueRef getSelfPercent(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*)
117
119
{
118
 
    JSC::JSLock lock(false);
 
120
    JSC::JSLock lock(SilenceAssertionsOnly);
119
121
 
120
122
    if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
121
123
        return JSValueMakeUndefined(ctx);
126
128
 
127
129
static JSValueRef getNumberOfCalls(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*)
128
130
{
129
 
    JSC::JSLock lock(false);
 
131
    JSC::JSLock lock(SilenceAssertionsOnly);
130
132
 
131
133
    if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
132
134
        return JSValueMakeUndefined(ctx);
137
139
 
138
140
static JSValueRef getChildren(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef* exception)
139
141
{
140
 
    JSC::JSLock lock(false);
 
142
    JSC::JSLock lock(SilenceAssertionsOnly);
141
143
 
142
144
    if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
143
145
        return JSValueMakeUndefined(ctx);
162
164
        return JSValueMakeUndefined(ctx);
163
165
 
164
166
    JSRetainPtr<JSStringRef> pushString(Adopt, JSStringCreateWithUTF8CString("push"));
165
 
    
 
167
 
166
168
    JSValueRef pushProperty = JSObjectGetProperty(ctx, result, pushString.get(), exception);
167
169
    if (exception && *exception)
168
170
        return JSValueMakeUndefined(ctx);
171
173
    if (exception && *exception)
172
174
        return JSValueMakeUndefined(ctx);
173
175
 
 
176
    ExecState* exec = toJS(ctx);
174
177
    for (Vector<RefPtr<ProfileNode> >::const_iterator it = children.begin(); it != children.end(); ++it) {
175
 
        JSValueRef arg0 = toRef(toJS(toJS(ctx), (*it).get() ));
 
178
        JSValueRef arg0 = toRef(exec, toJS(exec, (*it).get() ));
176
179
        JSObjectCallAsFunction(ctx, pushFunction, result, 1, &arg0, exception);
177
180
        if (exception && *exception)
178
181
            return JSValueMakeUndefined(ctx);
181
184
    return result;
182
185
}
183
186
 
 
187
static JSValueRef getParent(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*)
 
188
{
 
189
    JSC::JSLock lock(SilenceAssertionsOnly);
 
190
 
 
191
    if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
 
192
        return JSValueMakeUndefined(ctx);
 
193
 
 
194
    ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));
 
195
    ExecState* exec = toJS(ctx);
 
196
    return toRef(exec, toJS(exec, profileNode->parent()));
 
197
}
 
198
 
 
199
static JSValueRef getHead(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*)
 
200
{
 
201
    JSC::JSLock lock(SilenceAssertionsOnly);
 
202
 
 
203
    if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
 
204
        return JSValueMakeUndefined(ctx);
 
205
 
 
206
    ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));
 
207
    ExecState* exec = toJS(ctx);
 
208
    return toRef(exec, toJS(exec, profileNode->head()));
 
209
}
 
210
 
184
211
static JSValueRef getVisible(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*)
185
212
{
186
 
    JSC::JSLock lock(false);
 
213
    JSC::JSLock lock(SilenceAssertionsOnly);
187
214
 
188
215
    if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
189
216
        return JSValueMakeUndefined(ctx);
192
219
    return JSValueMakeBoolean(ctx, profileNode->visible());
193
220
}
194
221
 
 
222
static JSValueRef getCallUID(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*)
 
223
{
 
224
    JSC::JSLock lock(SilenceAssertionsOnly);
 
225
 
 
226
    if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
 
227
        return JSValueMakeUndefined(ctx);
 
228
 
 
229
    ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));
 
230
    return JSValueMakeNumber(ctx, profileNode->callIdentifier().hash());
 
231
}
 
232
 
195
233
static void finalize(JSObjectRef object)
196
234
{
197
235
    ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(object));
211
249
        { "selfPercent", getSelfPercent, 0, kJSPropertyAttributeNone },
212
250
        { "numberOfCalls", getNumberOfCalls, 0, kJSPropertyAttributeNone },
213
251
        { "children", getChildren, 0, kJSPropertyAttributeNone },
 
252
        { "parent", getParent, 0, kJSPropertyAttributeNone },
 
253
        { "head", getHead, 0, kJSClassAttributeNone },
214
254
        { "visible", getVisible, 0, kJSPropertyAttributeNone },
 
255
        { "callUID", getCallUID, 0, kJSPropertyAttributeNone },
215
256
        { 0, 0, 0, 0 }
216
257
    };
217
258
 
224
265
    return profileNodeClass;
225
266
}
226
267
 
227
 
JSValuePtr toJS(ExecState* exec, ProfileNode* profileNode)
 
268
JSValue toJS(ExecState* exec, ProfileNode* profileNode)
228
269
{
229
270
    if (!profileNode)
230
271
        return jsNull();
241
282
}
242
283
 
243
284
} // namespace WebCore
 
285
 
 
286
#endif // ENABLE(JAVASCRIPT_DEBUGGER)