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

Side by Side Diff: src/x64/lithium-x64.cc

Issue 6246099: X64 Crankshaft: Add bit operations and shifts to x64 crankshaft. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « src/x64/lithium-codegen-x64.cc ('k') | no next file » | 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 155 }
156 156
157 157
158 const char* LArithmeticT::Mnemonic() const { 158 const char* LArithmeticT::Mnemonic() const {
159 switch (op()) { 159 switch (op()) {
160 case Token::ADD: return "add-t"; 160 case Token::ADD: return "add-t";
161 case Token::SUB: return "sub-t"; 161 case Token::SUB: return "sub-t";
162 case Token::MUL: return "mul-t"; 162 case Token::MUL: return "mul-t";
163 case Token::MOD: return "mod-t"; 163 case Token::MOD: return "mod-t";
164 case Token::DIV: return "div-t"; 164 case Token::DIV: return "div-t";
165 case Token::BIT_AND: return "bit-and-t";
166 case Token::BIT_OR: return "bit-or-t";
167 case Token::BIT_XOR: return "bit-xor-t";
168 case Token::SHL: return "sal-t";
169 case Token::SAR: return "sar-t";
170 case Token::SHR: return "shr-t";
165 default: 171 default:
166 UNREACHABLE(); 172 UNREACHABLE();
167 return NULL; 173 return NULL;
168 } 174 }
169 } 175 }
170 176
171 177
172 void LGoto::PrintDataTo(StringStream* stream) { 178 void LGoto::PrintDataTo(StringStream* stream) {
173 stream->Add("B%d", block_id()); 179 stream->Add("B%d", block_id());
174 } 180 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 stream->Add(" index "); 318 stream->Add(" index ");
313 index()->PrintTo(stream); 319 index()->PrintTo(stream);
314 } 320 }
315 321
316 322
317 int LChunk::GetNextSpillIndex(bool is_double) { 323 int LChunk::GetNextSpillIndex(bool is_double) {
318 return spill_slot_count_++; 324 return spill_slot_count_++;
319 } 325 }
320 326
321 327
322 LOperand* LChunk::GetNextSpillSlot(bool is_double) { 328 LOperand* LChunk::GetNextSpillSlot(bool is_double) {
323 // All stack slots are Double stack slots on x64. 329 // All stack slots are Double stack slots on x64.
324 // Alternatively, at some point, start using half-size 330 // Alternatively, at some point, start using half-size
325 // stack slots for int32 values. 331 // stack slots for int32 values.
326 int index = GetNextSpillIndex(is_double); 332 int index = GetNextSpillIndex(is_double);
327 if (is_double) { 333 if (is_double) {
328 return LDoubleStackSlot::Create(index); 334 return LDoubleStackSlot::Create(index);
329 } else { 335 } else {
330 return LStackSlot::Create(index); 336 return LStackSlot::Create(index);
331 } 337 }
332 } 338 }
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 } 740 }
735 741
736 742
737 LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) { 743 LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) {
738 return AssignEnvironment(new LDeoptimize); 744 return AssignEnvironment(new LDeoptimize);
739 } 745 }
740 746
741 747
742 LInstruction* LChunkBuilder::DoBit(Token::Value op, 748 LInstruction* LChunkBuilder::DoBit(Token::Value op,
743 HBitwiseBinaryOperation* instr) { 749 HBitwiseBinaryOperation* instr) {
744 Abort("Unimplemented: %s", "DoBit"); 750 if (instr->representation().IsInteger32()) {
745 return NULL; 751 ASSERT(instr->left()->representation().IsInteger32());
752 ASSERT(instr->right()->representation().IsInteger32());
753
754 LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand());
755 LOperand* right = UseOrConstantAtStart(instr->MostConstantOperand());
756 return DefineSameAsFirst(new LBitI(op, left, right));
757 } else {
758 ASSERT(instr->representation().IsTagged());
759 ASSERT(instr->left()->representation().IsTagged());
760 ASSERT(instr->right()->representation().IsTagged());
761
762 LOperand* left = UseFixed(instr->left(), rdx);
763 LOperand* right = UseFixed(instr->right(), rax);
764 LArithmeticT* result = new LArithmeticT(op, left, right);
765 return MarkAsCall(DefineFixed(result, rax), instr);
766 }
767 }
768
769
770 LInstruction* LChunkBuilder::DoShift(Token::Value op,
771 HBitwiseBinaryOperation* instr) {
772 if (instr->representation().IsTagged()) {
773 ASSERT(instr->left()->representation().IsTagged());
774 ASSERT(instr->right()->representation().IsTagged());
775
776 LOperand* left = UseFixed(instr->left(), rdx);
777 LOperand* right = UseFixed(instr->right(), rax);
778 LArithmeticT* result = new LArithmeticT(op, left, right);
779 return MarkAsCall(DefineFixed(result, rax), instr);
780 }
781
782 ASSERT(instr->representation().IsInteger32());
783 ASSERT(instr->OperandAt(0)->representation().IsInteger32());
784 ASSERT(instr->OperandAt(1)->representation().IsInteger32());
785 LOperand* left = UseRegisterAtStart(instr->OperandAt(0));
786
787 HValue* right_value = instr->OperandAt(1);
788 LOperand* right = NULL;
789 int constant_value = 0;
790 if (right_value->IsConstant()) {
791 HConstant* constant = HConstant::cast(right_value);
792 right = chunk_->DefineConstantOperand(constant);
793 constant_value = constant->Integer32Value() & 0x1f;
794 } else {
795 right = UseFixed(right_value, rcx);
796 }
797
798 // Shift operations can only deoptimize if we do a logical shift
799 // by 0 and the result cannot be truncated to int32.
800 bool can_deopt = (op == Token::SHR && constant_value == 0);
801 if (can_deopt) {
802 bool can_truncate = true;
803 for (int i = 0; i < instr->uses()->length(); i++) {
804 if (!instr->uses()->at(i)->CheckFlag(HValue::kTruncatingToInt32)) {
805 can_truncate = false;
806 break;
807 }
808 }
809 can_deopt = !can_truncate;
810 }
811
812 LShiftI* result = new LShiftI(op, left, right, can_deopt);
813 return can_deopt
814 ? AssignEnvironment(DefineSameAsFirst(result))
815 : DefineSameAsFirst(result);
746 } 816 }
747 817
748 818
749 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, 819 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op,
750 HArithmeticBinaryOperation* instr) { 820 HArithmeticBinaryOperation* instr) {
751 Abort("Unimplemented: %s", "DoArithmeticD"); 821 Abort("Unimplemented: %s", "DoArithmeticD");
752 return NULL; 822 return NULL;
753 } 823 }
754 824
755 825
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 } 1194 }
1125 1195
1126 1196
1127 LInstruction* LChunkBuilder::DoCallRuntime(HCallRuntime* instr) { 1197 LInstruction* LChunkBuilder::DoCallRuntime(HCallRuntime* instr) {
1128 argument_count_ -= instr->argument_count(); 1198 argument_count_ -= instr->argument_count();
1129 return MarkAsCall(DefineFixed(new LCallRuntime, rax), instr); 1199 return MarkAsCall(DefineFixed(new LCallRuntime, rax), instr);
1130 } 1200 }
1131 1201
1132 1202
1133 LInstruction* LChunkBuilder::DoShr(HShr* instr) { 1203 LInstruction* LChunkBuilder::DoShr(HShr* instr) {
1134 Abort("Unimplemented: %s", "DoShr"); 1204 return DoShift(Token::SHR, instr);
1135 return NULL;
1136 } 1205 }
1137 1206
1138 1207
1139 LInstruction* LChunkBuilder::DoSar(HSar* instr) { 1208 LInstruction* LChunkBuilder::DoSar(HSar* instr) {
1140 Abort("Unimplemented: %s", "DoSar"); 1209 return DoShift(Token::SAR, instr);
1141 return NULL;
1142 } 1210 }
1143 1211
1144 1212
1145 LInstruction* LChunkBuilder::DoShl(HShl* instr) { 1213 LInstruction* LChunkBuilder::DoShl(HShl* instr) {
1146 Abort("Unimplemented: %s", "DoShl"); 1214 return DoShift(Token::SHL, instr);
1147 return NULL;
1148 } 1215 }
1149 1216
1150 1217
1151 LInstruction* LChunkBuilder::DoBitAnd(HBitAnd* instr) { 1218 LInstruction* LChunkBuilder::DoBitAnd(HBitAnd* instr) {
1152 Abort("Unimplemented: %s", "DoBitAnd"); 1219 return DoBit(Token::BIT_AND, instr);
1153 return NULL;
1154 } 1220 }
1155 1221
1156 1222
1157 LInstruction* LChunkBuilder::DoBitNot(HBitNot* instr) { 1223 LInstruction* LChunkBuilder::DoBitNot(HBitNot* instr) {
1158 Abort("Unimplemented: %s", "DoBitNot"); 1224 ASSERT(instr->value()->representation().IsInteger32());
1159 return NULL; 1225 ASSERT(instr->representation().IsInteger32());
1226 LOperand* input = UseRegisterAtStart(instr->value());
1227 LBitNotI* result = new LBitNotI(input);
1228 return DefineSameAsFirst(result);
1160 } 1229 }
1161 1230
1162 1231
1163 LInstruction* LChunkBuilder::DoBitOr(HBitOr* instr) { 1232 LInstruction* LChunkBuilder::DoBitOr(HBitOr* instr) {
1164 Abort("Unimplemented: %s", "DoBitOr"); 1233 return DoBit(Token::BIT_OR, instr);
1165 return NULL;
1166 } 1234 }
1167 1235
1168 1236
1169 LInstruction* LChunkBuilder::DoBitXor(HBitXor* instr) { 1237 LInstruction* LChunkBuilder::DoBitXor(HBitXor* instr) {
1170 Abort("Unimplemented: %s", "DoBitXor"); 1238 return DoBit(Token::BIT_XOR, instr);
1171 return NULL;
1172 } 1239 }
1173 1240
1174 1241
1175 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) { 1242 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) {
1176 Abort("Unimplemented: %s", "DoDiv"); 1243 Abort("Unimplemented: %s", "DoDiv");
1177 return NULL; 1244 return NULL;
1178 } 1245 }
1179 1246
1180 1247
1181 LInstruction* LChunkBuilder::DoMod(HMod* instr) { 1248 LInstruction* LChunkBuilder::DoMod(HMod* instr) {
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
1722 1789
1723 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { 1790 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) {
1724 HEnvironment* outer = current_block_->last_environment()->outer(); 1791 HEnvironment* outer = current_block_->last_environment()->outer();
1725 current_block_->UpdateEnvironment(outer); 1792 current_block_->UpdateEnvironment(outer);
1726 return NULL; 1793 return NULL;
1727 } 1794 }
1728 1795
1729 } } // namespace v8::internal 1796 } } // namespace v8::internal
1730 1797
1731 #endif // V8_TARGET_ARCH_X64 1798 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/lithium-codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698