|
7 | 7 | #include "OpaqueJSString.h" |
8 | 8 | #include "JSProfilerPrivate.h" |
9 | 9 | #include "JSStringRef.h" |
| 10 | +#include "String.h" |
10 | 11 |
|
11 | 12 | #include <YAJL/yajl_gen.h> |
12 | 13 |
|
@@ -114,48 +115,18 @@ static yajl_gen_status append_node_json(yajl_gen gen, const JSC::ProfileNode *no |
114 | 115 | return json_copy; |
115 | 116 | } |
116 | 117 |
|
117 | | -static char *JSEndProfilingAndRender(JSContextRef ctx, JSStringRef title) |
| 118 | +static const char *JSEndProfilingAndRender(JSContextRef ctx, const char *title) |
118 | 119 | { |
119 | 120 | JSC::ExecState *exec = toJS(ctx); |
120 | 121 | JSC::LegacyProfiler *profiler = JSC::LegacyProfiler::profiler(); |
121 | | - RefPtr<JSC::Profile> rawProfile = profiler->stopProfiling(exec, title->string()); |
| 122 | + RefPtr<JSC::Profile> rawProfile = profiler->stopProfiling(exec, WTF::String(title)); |
122 | 123 | return convert_to_json(rawProfile.get()); |
123 | 124 | } |
124 | 125 |
|
125 | | -JSValueRef nativeProfilerStart( |
126 | | - JSContextRef ctx, |
127 | | - JSObjectRef function, |
128 | | - JSObjectRef thisObject, |
129 | | - size_t argumentCount, |
130 | | - const JSValueRef arguments[], |
131 | | - JSValueRef *exception) { |
132 | | - if (argumentCount < 1) { |
133 | | - // Could raise an exception here. |
134 | | - return JSValueMakeUndefined(ctx); |
135 | | - } |
136 | | - |
137 | | - JSStringRef title = JSValueToStringCopy(ctx, arguments[0], NULL); |
138 | | - JSStartProfiling(ctx, title); |
139 | | - JSStringRelease(title); |
140 | | - return JSValueMakeUndefined(ctx); |
| 126 | +void nativeProfilerStart(JSContextRef ctx, const char *title) { |
| 127 | + JSStartProfiling(ctx, JSStringCreateWithUTF8CString(title)); |
141 | 128 | } |
142 | 129 |
|
143 | | -JSValueRef nativeProfilerEnd( |
144 | | - JSContextRef ctx, |
145 | | - JSObjectRef function, |
146 | | - JSObjectRef thisObject, |
147 | | - size_t argumentCount, |
148 | | - const JSValueRef arguments[], |
149 | | - JSValueRef *exception) { |
150 | | - if (argumentCount < 1) { |
151 | | - // Could raise an exception here. |
152 | | - return JSValueMakeUndefined(ctx); |
153 | | - } |
154 | | - |
155 | | - JSStringRef title = JSValueToStringCopy(ctx, arguments[0], NULL); |
156 | | - char *rendered = JSEndProfilingAndRender(ctx, title); |
157 | | - JSStringRelease(title); |
158 | | - JSStringRef profile = JSStringCreateWithUTF8CString(rendered); |
159 | | - free(rendered); |
160 | | - return JSValueMakeString(ctx, profile); |
| 130 | +const char *nativeProfilerEnd( JSContextRef ctx, const char *title) { |
| 131 | + return JSEndProfilingAndRender(ctx, title); |
161 | 132 | } |
0 commit comments