Fix call stack reported by profiler when entering event handlers.
authoroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 May 2008 11:37:32 +0000 (11:37 +0000)
committeroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 May 2008 11:37:32 +0000 (11:37 +0000)
Reviewed by Tim H

JSObject::call was arbitrarily notifying the profiler when it was
called, even if it was JS code, which notifies the profile on entry
in any case.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@34074 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/kjs/object.cpp

index 13c163b..c760260 100644 (file)
@@ -1,3 +1,16 @@
+2008-05-23  Oliver Hunt  <oliver@apple.com>
+
+        Reviewed by Tim H.
+
+        Fix call stack reported by profiler when entering event handlers.
+
+        JSObject::call was arbitrarily notifying the profiler when it was
+        called, even if it was JS code, which notifies the profile on entry
+        in any case.
+
+        * kjs/object.cpp:
+        (KJS::JSObject::call):
+
 2008-05-23  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by Oliver.
index 7d41ab1..71c81bb 100644 (file)
@@ -91,13 +91,22 @@ JSValue *JSObject::call(ExecState *exec, JSObject *thisObj, const List &args)
     return throwError(exec, RangeError, "Maximum call stack size exceeded.");
   }
 #endif
-
-    Profiler::profiler()->willExecute(exec, this);
-  
-    JSValue *ret = callAsFunction(exec,thisObj,args); 
-
-    Profiler::profiler()->didExecute(exec, this);
-
+    CallData data;
+    JSValue *ret;
+    if (this->getCallData(data) == CallTypeJS) {
+        // A native function will enter the VM, which will allow the profiler 
+        // to detect entry
+        ret = callAsFunction(exec,thisObj,args); 
+    } else {
+        Profiler** profiler = Profiler::enabledProfilerReference();
+        if (*profiler)
+            (*profiler)->willExecute(exec, this);
+        
+        ret = callAsFunction(exec,thisObj,args); 
+        
+        if (*profiler)
+            (*profiler)->didExecute(exec, this);
+    }
 #if KJS_MAX_STACK > 0
   --depth;
 #endif