Changeset 26617 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Oct 15, 2007, 1:36:57 PM (18 years ago)
Author:
ggaren
Message:

JavaScriptCore:

Reviewed by Maciej Stachowiak.


Fixed http://bugs.webkit.org/show_bug.cgi?id=15490
Iteration statements sometimes incorrectly evaluate to the empty value
(KDE r670547).


[ Broken off from http://bugs.webkit.org/show_bug.cgi?id=14868 ]


This patch is a merge of KDE r670547, with substantial modification
for performance.


It fixes do-while statements to evaluate to a value. (They used
to evaluate to the empty value in all cases.)

It also fixes SourceElementsNode to maintain the value of abnormal
completions like "break" and "continue."


It also re-works the main execution loop in SourceElementsNode so that
it (1) makes a little more sense and (2) avoids unnecessary work. This
is a .28% speedup on command-line JS iBench.

  • kjs/nodes.cpp: (DoWhileNode::execute): (SourceElementsNode::execute):

LayoutTests:

Reviewed by Maciej Stachowiak.


Layout tests for http://bugs.webkit.org/show_bug.cgi?id=15490
Iteration statements sometimes incorrectly evaluate to the empty value
(KDE r670547)

  • fast/js/do-while-expression-value-expected.txt: Added.
  • fast/js/do-while-expression-value.html: Added.
  • fast/js/while-expression-value-expected.txt: Added.
  • fast/js/while-expression-value.html: Added.
Location:
trunk/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r26603 r26617  
     12007-10-12  Geoffrey Garen  <[email protected]>
     2
     3        Reviewed by Maciej Stachowiak.
     4       
     5        Fixed http://bugs.webkit.org/show_bug.cgi?id=15490
     6        Iteration statements sometimes incorrectly evaluate to the empty value
     7        (KDE r670547).
     8       
     9        [ Broken off from http://bugs.webkit.org/show_bug.cgi?id=14868 ]
     10       
     11        This patch is a merge of KDE r670547, with substantial modification
     12        for performance.
     13       
     14        It fixes do-while statements to evaluate to a value. (They used
     15        to evaluate to the empty value in all cases.)
     16
     17        It also fixes SourceElementsNode to maintain the value of abnormal
     18        completions like "break" and "continue."
     19       
     20        It also re-works the main execution loop in SourceElementsNode so that
     21        it (1) makes a little more sense and (2) avoids unnecessary work. This
     22        is a .28% speedup on command-line JS iBench.
     23
     24        * kjs/nodes.cpp:
     25        (DoWhileNode::execute):
     26        (SourceElementsNode::execute):
     27
    1282007-10-15  Simon Hausmann  <[email protected]>
    229
  • trunk/JavaScriptCore/kjs/completion.h

    r20310 r26617  
    5353    ComplType complType() const { return comp; }
    5454    JSValue *value() const { return val; }
     55    void setValue(JSValue* v) { val = v; }
    5556    Identifier target() const { return tar; }
    5657    bool isValueCompletion() const { return !!val; }
  • trunk/JavaScriptCore/kjs/nodes.cpp

    r26582 r26617  
    18081808  JSValue *bv;
    18091809  Completion c;
     1810  JSValue* value = 0;
    18101811
    18111812  do {
     
    18201821        return Completion(Interrupted);
    18211822
     1823    if (c.isValueCompletion())
     1824        value = c.value();
     1825
    18221826    if (!((c.complType() == Continue) && ls.contains(c.target()))) {
    18231827      if ((c.complType() == Break) && ls.contains(c.target()))
    1824         return Completion(Normal, 0);
     1828        return Completion(Normal, value);
    18251829      if (c.complType() != Normal)
    18261830        return c;
     
    18301834  } while (bv->toBoolean(exec));
    18311835
    1832   return Completion(Normal, 0);
     1836  return Completion(Normal, value);
    18331837}
    18341838
     
    25602564{
    25612565  KJS_CHECKEXCEPTION
    2562 
    2563   Completion c1 = node->execute(exec);
    2564   KJS_CHECKEXCEPTION;
    2565   if (c1.complType() != Normal)
    2566     return c1;
    2567  
    2568   for (SourceElementsNode *n = next.get(); n; n = n->next.get()) {
    2569     Completion c2 = n->node->execute(exec);
    2570     if (c2.complType() != Normal)
    2571       return c2;
    2572     // The spec says to return c2 here, but it seems that mozilla returns c1 if
    2573     // c2 doesn't have a value
    2574     if (c2.value())
    2575       c1 = c2;
    2576   }
    2577  
    2578   return c1;
     2566  JSValue* v = 0;
     2567  SourceElementsNode* n = this;
     2568  while (1) {
     2569    Completion c = n->node->execute(exec);
     2570
     2571    if (JSValue* v2 = c.value())
     2572      v = v2;
     2573    c.setValue(v);
     2574
     2575    if (c.complType() != Normal)
     2576        return c;
     2577
     2578    n = n->next.get();
     2579    if (!n)
     2580        return c;
     2581  }
    25792582}
    25802583
Note: See TracChangeset for help on using the changeset viewer.