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

Side by Side Diff: src/hydrogen.cc

Issue 6852015: Support string add in crankshaft: (Closed)
Patch Set: Review fixes and ports Created 9 years, 8 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 unified diff | Download patch
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 4870 matching lines...) Expand 10 before | Expand all | Expand 10 after
4881 HStringLength* length = new(zone()) HStringLength(string); 4881 HStringLength* length = new(zone()) HStringLength(string);
4882 AddInstruction(length); 4882 AddInstruction(length);
4883 AddInstruction(new(zone()) HBoundsCheck(index, length)); 4883 AddInstruction(new(zone()) HBoundsCheck(index, length));
4884 return new(zone()) HStringCharCodeAt(string, index); 4884 return new(zone()) HStringCharCodeAt(string, index);
4885 } 4885 }
4886 4886
4887 4887
4888 HInstruction* HGraphBuilder::BuildBinaryOperation(BinaryOperation* expr, 4888 HInstruction* HGraphBuilder::BuildBinaryOperation(BinaryOperation* expr,
4889 HValue* left, 4889 HValue* left,
4890 HValue* right) { 4890 HValue* right) {
4891 TypeInfo info = oracle()->BinaryType(expr);
4891 HInstruction* instr = NULL; 4892 HInstruction* instr = NULL;
4892 switch (expr->op()) { 4893 switch (expr->op()) {
4893 case Token::ADD: 4894 case Token::ADD:
4894 instr = new(zone()) HAdd(left, right); 4895 if (info.IsString()) {
4896 AddInstruction(new(zone()) HCheckNonSmi(left));
4897 AddInstruction(new(zone()) HCheckInstanceType(
4898 left, FIRST_STRING_TYPE, LAST_STRING_TYPE));
4899 AddInstruction(new(zone()) HCheckNonSmi(right));
4900 AddInstruction(new(zone()) HCheckInstanceType(
4901 right, FIRST_STRING_TYPE, LAST_STRING_TYPE));
4902 instr = new(zone()) HStringAdd(left, right);
4903 } else {
4904 instr = new(zone()) HAdd(left, right);
4905 }
4895 break; 4906 break;
4896 case Token::SUB: 4907 case Token::SUB:
4897 instr = new(zone()) HSub(left, right); 4908 instr = new(zone()) HSub(left, right);
4898 break; 4909 break;
4899 case Token::MUL: 4910 case Token::MUL:
4900 instr = new(zone()) HMul(left, right); 4911 instr = new(zone()) HMul(left, right);
4901 break; 4912 break;
4902 case Token::MOD: 4913 case Token::MOD:
4903 instr = new(zone()) HMod(left, right); 4914 instr = new(zone()) HMod(left, right);
4904 break; 4915 break;
(...skipping 14 matching lines...) Expand all
4919 break; 4930 break;
4920 case Token::SHR: 4931 case Token::SHR:
4921 instr = new(zone()) HShr(left, right); 4932 instr = new(zone()) HShr(left, right);
4922 break; 4933 break;
4923 case Token::SHL: 4934 case Token::SHL:
4924 instr = new(zone()) HShl(left, right); 4935 instr = new(zone()) HShl(left, right);
4925 break; 4936 break;
4926 default: 4937 default:
4927 UNREACHABLE(); 4938 UNREACHABLE();
4928 } 4939 }
4929 TypeInfo info = oracle()->BinaryType(expr);
4930 // If we hit an uninitialized binary op stub we will get type info 4940 // If we hit an uninitialized binary op stub we will get type info
4931 // for a smi operation. If one of the operands is a constant string 4941 // for a smi operation. If one of the operands is a constant string
4932 // do not generate code assuming it is a smi operation. 4942 // do not generate code assuming it is a smi operation.
4933 if (info.IsSmi() && 4943 if (info.IsSmi() &&
4934 ((left->IsConstant() && HConstant::cast(left)->HasStringValue()) || 4944 ((left->IsConstant() && HConstant::cast(left)->HasStringValue()) ||
4935 (right->IsConstant() && HConstant::cast(right)->HasStringValue()))) { 4945 (right->IsConstant() && HConstant::cast(right)->HasStringValue()))) {
4936 return instr; 4946 return instr;
4937 } 4947 }
4938 if (FLAG_trace_representation) { 4948 if (FLAG_trace_representation) {
4939 PrintF("Info: %s/%s\n", info.ToString(), ToRepresentation(info).Mnemonic()); 4949 PrintF("Info: %s/%s\n", info.ToString(), ToRepresentation(info).Mnemonic());
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after
6126 } 6136 }
6127 } 6137 }
6128 6138
6129 #ifdef DEBUG 6139 #ifdef DEBUG
6130 if (graph_ != NULL) graph_->Verify(); 6140 if (graph_ != NULL) graph_->Verify();
6131 if (allocator_ != NULL) allocator_->Verify(); 6141 if (allocator_ != NULL) allocator_->Verify();
6132 #endif 6142 #endif
6133 } 6143 }
6134 6144
6135 } } // namespace v8::internal 6145 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698