Commit 30fc0f4a authored by darin@apple.com's avatar darin@apple.com

Reviewed by Sam.

        - http://bugs.webkit.org/show_bug.cgi?id=15915
          add an evaluation path for booleans like the one we have for numbers

        Gives 1.1% on SunSpider.

        * kjs/grammar.y: Create TrueNode and FalseNode instead of BooleanNode.

        * kjs/nodes.h: Changed to use Noncopyable. Moved optimizeForUnnecessaryResult
        down from Node to ExpressionNode. Changed some classes to not inherit from
        ExpressionNode where not necessary, and removed unnneeded evaluate functions
        as well as evaluate functions that need not be virtual. Call the
        optimizeForUnnecessaryResult function on the start of a for loop too.
        * kjs/nodes.cpp:
        (KJS::ExpressionNode::evaluateToBoolean): Added.
        (KJS::FalseNode::evaluate): Added.
        (KJS::TrueNode::evaluate): Added.
        (KJS::NumberNode::evaluateToBoolean): Added.
        (KJS::StringNode::evaluateToBoolean): Added.
        (KJS::LocalVarAccessNode::evaluateToBoolean): Added.
        (KJS::BracketAccessorNode::evaluateToBoolean): Added.
        (KJS::LogicalNotNode::evaluate): Changed to call evaluateToBoolean.
        (KJS::LogicalNotNode::evaluateToBoolean): Added.
        (KJS::lessThan): Changed to return bool.
        (KJS::lessThanEq): Ditto.
        (KJS::LessNode::evaluate): Changed since lessThan returns bool.
        (KJS::LessNode::evaluateToBoolean): Added.
        (KJS::GreaterNode::evaluate): Changed since lessThanEq returns bool.
        (KJS::GreaterNode::evaluateToBoolean): Added.
        (KJS::LessEqNode::evaluate): Changed since lessThanEq returns bool.
        (KJS::LessEqNode::evaluateToBoolean): Added.
        (KJS::GreaterEqNode::evaluate): Changed since lessThan returns bool.
        (KJS::GreaterEqNode::evaluateToBoolean): Added.
        (KJS::InstanceOfNode::evaluateToBoolean): Added.
        (KJS::InNode::evaluateToBoolean): Added.
        (KJS::EqualNode::evaluateToBoolean): Added.
        (KJS::NotEqualNode::evaluateToBoolean): Added.
        (KJS::StrictEqualNode::evaluateToBoolean): Added.
        (KJS::NotStrictEqualNode::evaluateToBoolean): Added.
        (KJS::ConditionalNode::evaluate): Changed to call evaluateToBoolean.
        (KJS::IfNode::execute): Ditto.
        (KJS::DoWhileNode::execute): Ditto.
        (KJS::WhileNode::execute): Ditto.
        (KJS::ForNode::execute): Ditto.

        * kjs/nodes2string.cpp:
        (KJS::FalseNode::streamTo): Added.
        (KJS::TrueNode::streamTo): Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@27664 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ea89623b
2007-11-10 Darin Adler <darin@apple.com>
Reviewed by Sam.
- http://bugs.webkit.org/show_bug.cgi?id=15915
add an evaluation path for booleans like the one we have for numbers
Gives 1.1% on SunSpider.
* kjs/grammar.y: Create TrueNode and FalseNode instead of BooleanNode.
* kjs/nodes.h: Changed to use Noncopyable. Moved optimizeForUnnecessaryResult
down from Node to ExpressionNode. Changed some classes to not inherit from
ExpressionNode where not necessary, and removed unnneeded evaluate functions
as well as evaluate functions that need not be virtual. Call the
optimizeForUnnecessaryResult function on the start of a for loop too.
* kjs/nodes.cpp:
(KJS::ExpressionNode::evaluateToBoolean): Added.
(KJS::FalseNode::evaluate): Added.
(KJS::TrueNode::evaluate): Added.
(KJS::NumberNode::evaluateToBoolean): Added.
(KJS::StringNode::evaluateToBoolean): Added.
(KJS::LocalVarAccessNode::evaluateToBoolean): Added.
(KJS::BracketAccessorNode::evaluateToBoolean): Added.
(KJS::LogicalNotNode::evaluate): Changed to call evaluateToBoolean.
(KJS::LogicalNotNode::evaluateToBoolean): Added.
(KJS::lessThan): Changed to return bool.
(KJS::lessThanEq): Ditto.
(KJS::LessNode::evaluate): Changed since lessThan returns bool.
(KJS::LessNode::evaluateToBoolean): Added.
(KJS::GreaterNode::evaluate): Changed since lessThanEq returns bool.
(KJS::GreaterNode::evaluateToBoolean): Added.
(KJS::LessEqNode::evaluate): Changed since lessThanEq returns bool.
(KJS::LessEqNode::evaluateToBoolean): Added.
(KJS::GreaterEqNode::evaluate): Changed since lessThan returns bool.
(KJS::GreaterEqNode::evaluateToBoolean): Added.
(KJS::InstanceOfNode::evaluateToBoolean): Added.
(KJS::InNode::evaluateToBoolean): Added.
(KJS::EqualNode::evaluateToBoolean): Added.
(KJS::NotEqualNode::evaluateToBoolean): Added.
(KJS::StrictEqualNode::evaluateToBoolean): Added.
(KJS::NotStrictEqualNode::evaluateToBoolean): Added.
(KJS::ConditionalNode::evaluate): Changed to call evaluateToBoolean.
(KJS::IfNode::execute): Ditto.
(KJS::DoWhileNode::execute): Ditto.
(KJS::WhileNode::execute): Ditto.
(KJS::ForNode::execute): Ditto.
* kjs/nodes2string.cpp:
(KJS::FalseNode::streamTo): Added.
(KJS::TrueNode::streamTo): Added.
2007-11-09 Adam Roben <aroben@apple.com>
Windows build fix
......
......@@ -566,24 +566,16 @@
<Filter
Name="PCRE"
>
<File
RelativePath="..\..\wtf\FastMallocPCRE.cpp"
>
</File>
<File
RelativePath="..\..\pcre\pcre-config.h"
>
</File>
<File
RelativePath="..\..\pcre\pcre.h"
>
</File>
<File
RelativePath="..\..\pcre\pcre_compile.c"
RelativePath="..\..\pcre\pcre_compile.cpp"
>
</File>
<File
RelativePath="..\..\pcre\pcre_exec.c"
RelativePath="..\..\pcre\pcre_exec.cpp"
>
</File>
<File
......@@ -591,19 +583,19 @@
>
</File>
<File
RelativePath="..\..\pcre\pcre_ord2utf8.c"
RelativePath="..\..\pcre\pcre_ord2utf8.cpp"
>
</File>
<File
RelativePath="..\..\pcre\pcre_tables.c"
RelativePath="..\..\pcre\pcre_tables.cpp"
>
</File>
<File
RelativePath="..\..\pcre\pcre_ucp_searchfuncs.c"
RelativePath="..\..\pcre\pcre_ucp_searchfuncs.cpp"
>
</File>
<File
RelativePath="..\..\pcre\pcre_xclass.c"
RelativePath="..\..\pcre\pcre_xclass.cpp"
>
</File>
<File
......
......@@ -99,7 +99,7 @@
</References>
<Files>
<File
RelativePath="..\..\pcre\dftables.c"
RelativePath="..\..\pcre\dftables.cpp"
>
</File>
</Files>
......
......@@ -206,9 +206,9 @@ static NumberNode* makeNumberNode(double);
%%
Literal:
NULLTOKEN { $$ = new NullNode(); }
| TRUETOKEN { $$ = new BooleanNode(true); }
| FALSETOKEN { $$ = new BooleanNode(false); }
NULLTOKEN { $$ = new NullNode; }
| TRUETOKEN { $$ = new TrueNode; }
| FALSETOKEN { $$ = new FalseNode; }
| NUMBER { $$ = makeNumberNode($1); }
| STRING { $$ = new StringNode($1); }
| '/' /* regexp */ {
......
This diff is collapsed.
This diff is collapsed.
......@@ -268,9 +268,14 @@ void NullNode::streamTo(SourceStream& s) const
s << "null";
}
void BooleanNode::streamTo(SourceStream& s) const
void FalseNode::streamTo(SourceStream& s) const
{
s << (value ? "true" : "false");
s << "false";
}
void TrueNode::streamTo(SourceStream& s) const
{
s << "true";
}
void NumberNode::streamTo(SourceStream& s) const
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment