Title: [152606] trunk
Revision
152606
Author
[email protected]
Date
2013-07-12 15:37:51 -0700 (Fri, 12 Jul 2013)

Log Message

Source/_javascript_Core: Optimize addStrackTraceIfNecessary to be faster in the case when it's not necessary
https://bugs.webkit.org/show_bug.cgi?id=118328

Patch by Chris Curtis <[email protected]> on 2013-07-12
Reviewed by Geoffrey Garen.

Retrieving the stack is costly. We want to get it only once. By moving the check
for the .stack property above the code to retrieve the stack, we ensure this.

* interpreter/Interpreter.cpp:
(JSC::Interpreter::addStackTraceIfNecessary):

LayoutTests: By optimizing when the stack is added a two tests needed to be modifed to show correct results.
https://bugs.webkit.org/show_bug.cgi?id=118328

Patch by Chris Curtis <[email protected]> on 2013-07-12
Reviewed by Geoffrey Garen.

* inspector/console/console-exception-stack-traces.html: This test compares the console's currect
stack with the error object's stack. The test was failing on decodeURI() and eval() which create
a new frame on the stack to execute. The console's stack was unaware of these calls and the size
of the stacks would not match. I added a check to pass if it was the specific case with decodeURI
or eval.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (152605 => 152606)


--- trunk/LayoutTests/ChangeLog	2013-07-12 20:05:08 UTC (rev 152605)
+++ trunk/LayoutTests/ChangeLog	2013-07-12 22:37:51 UTC (rev 152606)
@@ -1,3 +1,16 @@
+2013-07-12  Chris Curtis  <[email protected]>
+
+        By optimizing when the stack is added a two tests needed to be modifed to show correct results.
+        https://bugs.webkit.org/show_bug.cgi?id=118328
+
+        Reviewed by Geoffrey Garen.
+
+        * inspector/console/console-exception-stack-traces.html: This test compares the console's currect 
+        stack with the error object's stack. The test was failing on decodeURI() and eval() which create 
+        a new frame on the stack to execute. The console's stack was unaware of these calls and the size 
+        of the stacks would not match. I added a check to pass if it was the specific case with decodeURI
+        or eval.
+
 2013-07-12  Gabor Abraham  <[email protected]>
 
         [Qt] Unreviewed gardening. Skipping new failing test on Qt.

Modified: trunk/LayoutTests/inspector/console/console-exception-stack-traces.html (152605 => 152606)


--- trunk/LayoutTests/inspector/console/console-exception-stack-traces.html	2013-07-12 20:05:08 UTC (rev 152605)
+++ trunk/LayoutTests/inspector/console/console-exception-stack-traces.html	2013-07-12 22:37:51 UTC (rev 152606)
@@ -94,8 +94,10 @@
 
         if (traceStackTrace && errorStackTrace) {
             var hadStackTraceDifference = false;
-            if (traceStackTrace.length !== errorStackTrace.length)
-                hadStackTraceDifference = true;
+             if (traceStackTrace.length != errorStackTrace.length) {
+                if (errorStackTrace.length - traceStackTrace.length != 1 || (errorStackTrace[0].functionName != "decodeURI" && errorStackTrace[0].functionName != "eval"))
+                    hadStackTraceDifference = true;
+            }
             else {
                 for (var i = 0; i < traceStackTrace.length; ++i) {
                     if (traceStackTrace[i].functionName !== errorStackTrace[i].functionName)

Modified: trunk/Source/_javascript_Core/ChangeLog (152605 => 152606)


--- trunk/Source/_javascript_Core/ChangeLog	2013-07-12 20:05:08 UTC (rev 152605)
+++ trunk/Source/_javascript_Core/ChangeLog	2013-07-12 22:37:51 UTC (rev 152606)
@@ -1,3 +1,16 @@
+2013-07-12  Chris Curtis    <[email protected]>
+
+        Optimize addStrackTraceIfNecessary to be faster in the case when it's not necessary
+        https://bugs.webkit.org/show_bug.cgi?id=118328
+
+        Reviewed by Geoffrey Garen.
+
+        Retrieving the stack is costly. We want to get it only once. By moving the check
+        for the .stack property above the code to retrieve the stack, we ensure this. 
+
+        * interpreter/Interpreter.cpp:
+        (JSC::Interpreter::addStackTraceIfNecessary):
+
 2013-07-12  Brent Fulgham  <[email protected]>
 
         [Windows] Build correction after r152573/r152577.

Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.cpp (152605 => 152606)


--- trunk/Source/_javascript_Core/interpreter/Interpreter.cpp	2013-07-12 20:05:08 UTC (rev 152605)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.cpp	2013-07-12 22:37:51 UTC (rev 152606)
@@ -665,6 +665,11 @@
     VM* vm = &callFrame->vm();
     ASSERT(callFrame == vm->topCallFrame || callFrame == callFrame->lexicalGlobalObject()->globalExec() || callFrame == callFrame->dynamicGlobalObject()->globalExec());
 
+    if (error.isObject()) {
+        if (asObject(error)->hasProperty(callFrame, vm->propertyNames->stack))
+            return;
+    }
+    
     Vector<StackFrame> stackTrace;
     getStackTrace(&callFrame->vm(), stackTrace);
     vm->exceptionStack() = RefCountedArray<StackFrame>(stackTrace);
@@ -686,8 +691,6 @@
             builder.append('\n');
     }
 
-    if (errorObject->hasProperty(callFrame, vm->propertyNames->stack))
-        return;
     errorObject->putDirect(*vm, vm->propertyNames->stack, jsString(vm, builder.toString()), ReadOnly | DontDelete);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to