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

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

Issue 23618002: Hydrogenisation of binops (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebase Created 7 years, 3 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
« no previous file with comments | « src/code-stubs.cc ('k') | src/full-codegen.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stubs-hydrogen.cc
diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc
index 23d4269c849fa6cbd517b6f1d64deccb582fd570..f2de3b26e1e2df184ed1d8fc2251890ccea2e42c 100644
--- a/src/code-stubs-hydrogen.cc
+++ b/src/code-stubs-hydrogen.cc
@@ -812,6 +812,81 @@ Handle<Code> CompareNilICStub::GenerateCode(Isolate* isolate) {
template <>
+HValue* CodeStubGraphBuilder<BinaryOpStub>::BuildCodeInitializedStub() {
+ BinaryOpStub* stub = casted_stub();
+ HValue* left = GetParameter(0);
+ HValue* right = GetParameter(1);
+
+ Handle<Type> left_type = stub->GetLeftType(isolate());
+ Handle<Type> right_type = stub->GetRightType(isolate());
+ Handle<Type> result_type = stub->GetResultType(isolate());
+
+ HValue* res = NULL;
+ if (stub->operation() == Token::ADD &&
+ (left_type->Maybe(Type::String()) || right_type->Maybe(Type::String())) &&
+ !left_type->Is(Type::String()) && !right_type->Is(Type::String())) {
+ // For the generic add stub a fast case for String add is performance
+ // critical.
+ if (left_type->Maybe(Type::String())) {
+ IfBuilder left_string(this);
+ left_string.IfNot<HIsSmiAndBranch>(left);
+ left_string.AndIf<HIsStringAndBranch>(left);
+ left_string.Then();
+ Push(Add<HStringAdd>(left, right, STRING_ADD_CHECK_RIGHT));
+ left_string.Else();
+ Push(AddInstruction(BuildBinaryOperation(stub->operation(),
+ left, right, left_type, right_type, result_type,
+ stub->fixed_right_arg(), context())));
+ left_string.End();
+ res = Pop();
+ } else {
+ IfBuilder right_string(this);
+ right_string.IfNot<HIsSmiAndBranch>(right);
+ right_string.AndIf<HIsStringAndBranch>(right);
+ right_string.Then();
+ Push(Add<HStringAdd>(left, right, STRING_ADD_CHECK_LEFT));
+ right_string.Else();
+ Push(AddInstruction(BuildBinaryOperation(stub->operation(),
+ left, right, left_type, right_type, result_type,
+ stub->fixed_right_arg(), context())));
+ right_string.End();
+ res = Pop();
+ }
+ } else {
+ res = AddInstruction(BuildBinaryOperation(stub->operation(),
+ left, right, left_type, right_type, result_type,
+ stub->fixed_right_arg(), context()));
+ }
+
+ // If we encounter a generic argument, the number conversion is
+ // observable, thus we cannot afford to bail out after the fact.
+ if (!stub->HasSideEffects(isolate())) {
+ if (result_type->Is(Type::Smi())) {
+ if (stub->operation() == Token::SHR) {
+ // TODO(olivf) Replace this by a SmiTagU Instruction.
+ // 0x40000000: this number would convert to negative when interpreting
+ // the register as signed value;
+ IfBuilder if_of(this);
+ if_of.IfNot<HCompareNumericAndBranch>(res,
+ Add<HConstant>(static_cast<int>(0x40000000)), Token::EQ_STRICT);
+ if_of.Then();
+ if_of.ElseDeopt("UInt->Smi oveflow");
+ if_of.End();
+ }
+ }
+ res = EnforceNumberType(res, result_type);
+ }
+
+ return res;
+}
+
+
+Handle<Code> BinaryOpStub::GenerateCode(Isolate* isolate) {
+ return DoGenerateCode(isolate, this);
+}
+
+
+template <>
HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() {
ToBooleanStub* stub = casted_stub();
« no previous file with comments | « src/code-stubs.cc ('k') | src/full-codegen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698