Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(789)

Unified Diff: src/code-stubs-hydrogen.cc

Issue 17229005: Convert UnaryOpStub to a HydrogenCodeStub (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/code-stubs-hydrogen.cc
diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc
index 11cd307451cc0017429d0ea84be0bbdc410982a5..f26ddf057768acdf65ece8a19f5e31f473a1e27f 100644
--- a/src/code-stubs-hydrogen.cc
+++ b/src/code-stubs-hydrogen.cc
@@ -750,6 +750,64 @@ HValue* CodeStubGraphBuilder<CompareNilICStub>::BuildCodeInitializedStub() {
}
+Handle<Code> UnaryOpStub::GenerateCode() {
+ return DoGenerateCode(this);
+}
+
+
+HInstruction* UnaryOpStub::ToHInstruction(HValue* input,
+ Handle<Type> type, HGraphBuilder* builder, HContext* context) {
+ switch (operation_) {
+ default:
+ UNREACHABLE();
+ case Token::SUB: {
+ HInstruction* minus = HMul::New(builder->zone(), context,
+ input, builder->graph()->GetConstantMinus1());
+ if (type->Maybe(Type::Double())) {
+ // We have to force a double multiplication if we have seen double,
+ // otherwise we will deopt again.
+ minus->AssumeRepresentation(Representation::Double());
danno 2013/06/21 16:38:04 Try to move this out with the other representation
+ }
+ return minus;
+ }
+ case Token::BIT_NOT:
+ return new(builder->zone()) HBitNot(input);
+ }
+}
+
+
+template <>
+HValue* CodeStubGraphBuilder<UnaryOpStub>::BuildCodeInitializedStub() {
+ UnaryOpStub* stub = casted_stub();
danno 2013/06/21 16:38:04 Please share this code with hydrogen, it should be
+ Handle<Type> type = stub->GetType(graph()->isolate());
+ HValue* input = GetParameter(0);
+
+ if (!type->Is(Type::Number())) {
+ // If we expect to see other things than Numbers, we will create a generic
+ // stub, which handles all numbers and calls into the runtime for the rest.
+ IfBuilder if_number(this);
+ if_number.If<HIsNumberAndBranch>(input);
+ if_number.Then();
+ HInstruction* res = stub->ToHInstruction(input, type, this, context());
+ if_number.Return(AddInstruction(res));
+ if_number.Else();
+ AddInstruction(new(zone()) HPushArgument(GetParameter(0)));
+ if_number.Return(AddInstruction(new(zone()) HCallConstantFunction(
+ stub->ToJSFunction(isolate()), 1)));
+ if_number.End();
+ return graph()->GetConstantUndefined();
+ }
+
+ if (type->Is(Type::Integer31())) {
+ AddInstruction(new(zone()) HCheckSmi(input));
danno 2013/06/21 16:38:04 Try to avoid the explicit checks by using force re
+ } else if (type->Is(Type::Double())) {
+ AddInstruction(new(zone()) HCheckNonSmi(input));
+ }
+
+ return AddInstruction(stub->ToHInstruction(input, type, this, context()));
+}
+
+
Handle<Code> CompareNilICStub::GenerateCode() {
return DoGenerateCode(this);
}

Powered by Google App Engine
This is Rietveld 408576698