Changeset 26582 in webkit
- Timestamp:
- Oct 14, 2007 4:31:58 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r26581 r26582 1 2007-10-14 Cameron Zwarich <cwzwarich@uwaterloo.ca> 2 3 Reviewed by Darin. 4 5 Adds NegateNode optimization from KJS. The relevant revision in KDE 6 is 666736. 7 8 * kjs/grammar.y: 9 * kjs/nodes.cpp: 10 (NumberNode::evaluate): 11 * kjs/nodes.h: 12 (KJS::Node::): 13 (KJS::NumberNode::): 14 * kjs/nodes2string.cpp: 15 (NumberNode::streamTo): 16 1 17 2007-10-14 Jason Foreman <jason@threeve.org> 2 18 -
trunk/JavaScriptCore/kjs/grammar.y
r25934 r26582 64 64 static Node *makeTypeOfNode(Node *expr); 65 65 static Node *makeDeleteNode(Node *expr); 66 static Node *makeNegateNode(Node *expr); 66 67 67 68 #if COMPILER(MSVC) … … 360 361 | AUTOMINUSMINUS UnaryExpr { $$ = makePrefixNode($2, OpMinusMinus); } 361 362 | '+' UnaryExpr { $$ = new UnaryPlusNode($2); } 362 | '-' UnaryExpr { $$ = newNegateNode($2); }363 | '-' UnaryExpr { $$ = makeNegateNode($2); } 363 364 | '~' UnaryExpr { $$ = new BitwiseNotNode($2); } 364 365 | '!' UnaryExpr { $$ = new LogicalNotNode($2); } … … 1004 1005 } 1005 1006 1007 static Node* makeNegateNode(Node *n) 1008 { 1009 if (n->isNumber()) { 1010 NumberNode* number = static_cast<NumberNode*>(n); 1011 1012 if (number->value() > 0.0) { 1013 number->setValue(-number->value()); 1014 return number; 1015 } 1016 } 1017 1018 return new NegateNode(n); 1019 } 1020 1006 1021 /* called by yyparse on error */ 1007 1022 int yyerror(const char *) -
trunk/JavaScriptCore/kjs/nodes.cpp
r24633 r26582 350 350 JSValue *NumberNode::evaluate(ExecState *) 351 351 { 352 return jsNumber(val ue);352 return jsNumber(val); 353 353 } 354 354 -
trunk/JavaScriptCore/kjs/nodes.h
r24532 r26582 101 101 virtual Node *nodeInsideAllParens() KJS_FAST_CALL; 102 102 103 virtual bool isNumber() const KJS_FAST_CALL { return false; } 103 104 virtual bool isLocation() const KJS_FAST_CALL { return false; } 104 105 virtual bool isResolveNode() const KJS_FAST_CALL { return false; } … … 168 169 class NumberNode : public Node { 169 170 public: 170 NumberNode(double v) KJS_FAST_CALL : value(v) {} 171 JSValue* evaluate(ExecState*) KJS_FAST_CALL; 172 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 173 private: 174 double value; 171 NumberNode(double v) KJS_FAST_CALL : val(v) {} 172 JSValue* evaluate(ExecState*) KJS_FAST_CALL; 173 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 174 175 virtual bool isNumber() const KJS_FAST_CALL { return true; } 176 double value() const KJS_FAST_CALL { return val; } 177 void setValue(double v) KJS_FAST_CALL { val = v; } 178 private: 179 double val; 175 180 }; 176 181 -
trunk/JavaScriptCore/kjs/nodes2string.cpp
r24924 r26582 141 141 } 142 142 143 void NumberNode::streamTo(SourceStream &s) const { s << val ue; }143 void NumberNode::streamTo(SourceStream &s) const { s << val; } 144 144 145 145 void StringNode::streamTo(SourceStream &s) const -
trunk/LayoutTests/ChangeLog
r26581 r26582 1 2007-10-14 Cameron Zwarich <cwzwarich@uwaterloo.ca> 2 3 Reviewed by Darin. 4 5 Adds serialization test cases for NegateNode optimization from KDE. 6 7 * fast/js/function-decompilation-operators-expected.txt: 8 * fast/js/function-decompilation-operators.html: 9 1 10 2007-10-14 Jason Foreman <jason@threeve.org> 2 11 -
trunk/LayoutTests/fast/js/function-decompilation-operators-expected.txt
r24924 r26582 50 50 PASS decompiledFunction is 'function () { - + x;}' 51 51 PASS decompiledFunction is 'function () { - - x;}' 52 PASS decompiledFunction is 'function () { 1;}' 53 PASS decompiledFunction is 'function () { -1;}' 54 PASS decompiledFunction is 'function () { - -1;}' 55 PASS decompiledFunction is 'function () { - - 0;}' 56 PASS decompiledFunction is 'function () { - - NaN;}' 52 57 PASS successfullyParsed is true 53 58 -
trunk/LayoutTests/fast/js/function-decompilation-operators.html
r24924 r26582 58 58 "+ - x", 59 59 "- + x", 60 "- - x" 60 "- - x", 61 "1", 62 "-1", 63 "- -1", 64 "- - 0", 65 "- - NaN" 61 66 ]; 62 67
Note: See TracChangeset
for help on using the changeset viewer.