Bug 18168 - Add emitCode support for unary operator nodes
Summary: Add emitCode support for unary operator nodes
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-27 16:21 PDT by Sam Weinig
Modified: 2008-03-27 20:43 PDT (History)
1 user (show)

See Also:


Attachments
patch (11.24 KB, patch)
2008-03-27 16:22 PDT, Sam Weinig
ggaren: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sam Weinig 2008-03-27 16:21:30 PDT
This includes UnaryPlusNode, NegateNode, BitwiseNotNode and LogicalNotNode.
Comment 1 Sam Weinig 2008-03-27 16:22:11 PDT
Created attachment 20140 [details]
patch
Comment 2 Geoffrey Garen 2008-03-27 20:13:46 PDT
+RegisterID* UnaryPlusNode::emitCode(CodeGenerator& generator, RegisterID* dst)
+{
+    RegisterID* r0 = generator.emitNode(m_expr.get());
+    return generator.emitToJSNumber(dst ? dst : generator.newTemporary(r0), r0);
+}
+

For cases like this (there are a few in your patch), there's no need to pass r0 to newTemporary(). Since r0 is not referenced, newTemporary() will autmatically return it.

The feature of passing a register to newTemporary was intended for situations where the codegen pattern forces you to put r0 in a RefPtr, but you want to advise newTemporary() that, despite your reference, r0 is eligible for reuse as the operation's destination register.

r=me
Comment 3 Geoffrey Garen 2008-03-27 20:14:25 PDT
Comment on attachment 20140 [details]
patch

run-sunspider --squirrelfish, please.
Comment 4 Sam Weinig 2008-03-27 20:43:29 PDT
Landed in r31382.