Changeset 29818 in webkit for trunk/JavaScriptCore/ChangeLog


Ignore:
Timestamp:
Jan 27, 2008, 1:38:01 AM (18 years ago)
Author:
Darin Adler
Message:

JavaScriptCore:

Reviewed by Oliver.

  • fix <rdar://problem/5657450> REGRESSION: const is broken

Test: fast/js/const.html

SunSpider said this was 0.3% slower. And I saw some Shark samples in
JSGlobalObject::put -- not a lot but a few. We may be able to regain the
speed, but for now we will take that small hit for correctness sake.

  • kjs/JSGlobalObject.cpp: (KJS::JSGlobalObject::put): Pass the checkReadOnly flag in to symbolTablePut instead of passing attributes.
  • kjs/JSVariableObject.h: (KJS::JSVariableObject::symbolTablePut): Removed the code to set attributes here, since we only set attributes when creating a property. Added the code to check read-only here, since we need that to implement const!
  • kjs/function.cpp: (KJS::ActivationImp::put): Pass the checkReadOnly flag in to symbolTablePut instead of passing attributes.
  • kjs/nodes.cpp: (KJS::isConstant): Added. (KJS::PostIncResolveNode::optimizeVariableAccess): Create a PostIncConstNode if optimizing for a local variable and the variable is constant. (KJS::PostDecResolveNode::optimizeVariableAccess): Ditto. But PostDecConstNode. (KJS::PreIncResolveNode::optimizeVariableAccess): Ditto. But PreIncConstNode. (KJS::PreDecResolveNode::optimizeVariableAccess): Ditto. But PreDecConstNode. (KJS::PreIncConstNode::evaluate): Return the value + 1. (KJS::PreDecConstNode::evaluate): Return the value - 1. (KJS::PostIncConstNode::evaluate): Return the value converted to a number. (KJS::PostDecConstNode::evaluate): Ditto. (KJS::ReadModifyResolveNode::optimizeVariableAccess): Create a ReadModifyConstNode if optimizing for a local variable and the variable is constant. (KJS::AssignResolveNode::optimizeVariableAccess): Ditto. But AssignConstNode. (KJS::ScopeNode::optimizeVariableAccess): Pass the local storage to the node optimizeVariableAccess functions, since that's where we need to look to figure out if a variable is constant. (KJS::FunctionBodyNode::processDeclarations): Moved the call to optimizeVariableAccess until after localStorage is set up. (KJS::ProgramNode::processDeclarations): Ditto.
  • kjs/nodes.h: Fixed the IsConstant and HasInitializer values. They are used as flag masks, so a value of 0 will not work for IsConstant. Changed the first parameter to optimizeVariableAccess to be a const reference to a symbol table and added a const reference to local storage. Added classes for const versions of local variable access: PostIncConstNode, PostDecConstNode, PreIncConstNode, PreDecConstNode, ReadModifyConstNode, and AssignConstNode.
  • kjs/object.cpp: (KJS::JSObject::put): Tweaked comments a bit, and changed the checkReadOnly expression to match the form used at the two other call sites.

LayoutTests:

Reviewed by Oliver.

  • tests for <rdar://problem/5657450> REGRESSION: const is broken
  • fast/js/const-expected.txt: Updated with results that express success rather than failure, and to include the many new tests I added.
  • fast/js/kde/const-expected.txt: Ditto.
  • fast/js/resources/const.js: Added many new tests, covering the various cases of const in globals, function locals, the slow case inside eval, the different node types, and the values of the expressions.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r29817 r29818  
     12008-01-27  Darin Adler  <[email protected]>
     2
     3        Reviewed by Oliver.
     4
     5        - fix <rdar://problem/5657450> REGRESSION: const is broken
     6
     7        Test: fast/js/const.html
     8
     9        SunSpider said this was 0.3% slower. And I saw some Shark samples in
     10        JSGlobalObject::put -- not a lot but a few. We may be able to regain the
     11        speed, but for now we will take that small hit for correctness sake.
     12
     13        * kjs/JSGlobalObject.cpp:
     14        (KJS::JSGlobalObject::put): Pass the checkReadOnly flag in to symbolTablePut
     15        instead of passing attributes.
     16
     17        * kjs/JSVariableObject.h:
     18        (KJS::JSVariableObject::symbolTablePut): Removed the code to set attributes
     19        here, since we only set attributes when creating a property. Added the code
     20        to check read-only here, since we need that to implement const!
     21
     22        * kjs/function.cpp:
     23        (KJS::ActivationImp::put): Pass the checkReadOnly flag in to symbolTablePut
     24        instead of passing attributes.
     25
     26        * kjs/nodes.cpp:
     27        (KJS::isConstant): Added.
     28        (KJS::PostIncResolveNode::optimizeVariableAccess): Create a PostIncConstNode
     29        if optimizing for a local variable and the variable is constant.
     30        (KJS::PostDecResolveNode::optimizeVariableAccess): Ditto. But PostDecConstNode.
     31        (KJS::PreIncResolveNode::optimizeVariableAccess): Ditto. But PreIncConstNode.
     32        (KJS::PreDecResolveNode::optimizeVariableAccess): Ditto. But PreDecConstNode.
     33        (KJS::PreIncConstNode::evaluate): Return the value + 1.
     34        (KJS::PreDecConstNode::evaluate): Return the value - 1.
     35        (KJS::PostIncConstNode::evaluate): Return the value converted to a number.
     36        (KJS::PostDecConstNode::evaluate): Ditto.
     37        (KJS::ReadModifyResolveNode::optimizeVariableAccess): Create a ReadModifyConstNode
     38        if optimizing for a local variable and the variable is constant.
     39        (KJS::AssignResolveNode::optimizeVariableAccess): Ditto. But AssignConstNode.
     40        (KJS::ScopeNode::optimizeVariableAccess): Pass the local storage to the
     41        node optimizeVariableAccess functions, since that's where we need to look to
     42        figure out if a variable is constant.
     43        (KJS::FunctionBodyNode::processDeclarations): Moved the call to
     44        optimizeVariableAccess until after localStorage is set up.
     45        (KJS::ProgramNode::processDeclarations): Ditto.
     46
     47        * kjs/nodes.h: Fixed the IsConstant and HasInitializer values. They are used
     48        as flag masks, so a value of 0 will not work for IsConstant. Changed the
     49        first parameter to optimizeVariableAccess to be a const reference to a symbol
     50        table and added a const reference to local storage. Added classes for const
     51        versions of local variable access: PostIncConstNode, PostDecConstNode,
     52        PreIncConstNode, PreDecConstNode, ReadModifyConstNode, and AssignConstNode.
     53
     54        * kjs/object.cpp:
     55        (KJS::JSObject::put): Tweaked comments a bit, and changed the checkReadOnly
     56        expression to match the form used at the two other call sites.
     57
    1582008-01-27  Darin Adler  <[email protected]>
    259
     
    274331        an int).
    275332       
    276 
    277333        * bindings/qt/qt_runtime.cpp:
    278334        (KJS::Bindings::convertValueToQVariant):
     
    310366        Code style cleanups.
    311367        Add spaces before/after braces in inline function.
    312        
    313368
    314369        * bindings/qt/qt_instance.h:
     
    320375        Code style cleanups.
    321376        Remove spaces and unneeded declared parameter names.
    322        
    323377
    324378        * bindings/qt/qt_instance.cpp:
     
    335389        could result in a stale JSObject being returned for
    336390        a valid Instance.
    337        
    338391
    339392        * bindings/qt/qt_instance.cpp:
     
    416469        Better support for converting lists, read/write only
    417470        QMetaProperty support, modified slot search order...)
    418        
    419471
    420472        * bindings/qt/qt_class.cpp:
Note: See TracChangeset for help on using the changeset viewer.