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

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

Issue 6237002: Remove the remaining LOperand-members from concrete LIR instructions.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 11 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
« src/ia32/lithium-ia32.h ('K') | « src/ia32/lithium-ia32.h ('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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 if (HasPointerMap()) { 80 if (HasPointerMap()) {
81 stream->Add(" "); 81 stream->Add(" ");
82 pointer_map()->PrintTo(stream); 82 pointer_map()->PrintTo(stream);
83 } 83 }
84 } 84 }
85 85
86 86
87 template<int R, int I, int T> 87 template<int R, int I, int T>
88 void LTemplateInstruction<R, I, T>::PrintDataTo(StringStream* stream) { 88 void LTemplateInstruction<R, I, T>::PrintDataTo(StringStream* stream) {
89 for (int i = 0; i < I; i++) { 89 stream->Add(" = ");
Kevin Millikin (Chromium) 2011/01/13 08:45:59 This adds a space before the '=' where before ther
fschneider 2011/01/13 13:03:25 Done.
90 stream->Add(i == 0 ? "= " : " "); 90 inputs_.PrintOperandsTo(stream);
91 inputs_.at(i)->PrintTo(stream);
92 }
93 } 91 }
94 92
95 93
96 template<int R, int I, int T> 94 template<int R, int I, int T>
97 void LTemplateInstruction<R, I, T>::PrintOutputOperandTo(StringStream* stream) { 95 void LTemplateInstruction<R, I, T>::PrintOutputOperandTo(StringStream* stream) {
98 if (this->HasResult()) { 96 outputs_.PrintOperandsTo(stream);
99 this->result()->PrintTo(stream); 97 }
100 stream->Add(" "); 98
99
100 template<typename T, int N>
101 void OperandContainer<T, N>::PrintOperandsTo(StringStream* stream) {
102 for (int i = 0; i < N; i++) {
103 if (i > 0) stream->Add(" ");
104 elems_[i]->PrintTo(stream);
101 } 105 }
102 } 106 }
103 107
104 108
105 void LLabel::PrintDataTo(StringStream* stream) { 109 void LLabel::PrintDataTo(StringStream* stream) {
106 LGap::PrintDataTo(stream); 110 LGap::PrintDataTo(stream);
107 LLabel* rep = replacement(); 111 LLabel* rep = replacement();
108 if (rep != NULL) { 112 if (rep != NULL) {
109 stream->Add(" Dead block replaced with B%d", rep->block_id()); 113 stream->Add(" Dead block replaced with B%d", rep->block_id());
110 } 114 }
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 if (current->has_position()) position_ = current->position(); 871 if (current->has_position()) position_ = current->position();
868 LInstruction* instr = current->CompileToLithium(this); 872 LInstruction* instr = current->CompileToLithium(this);
869 873
870 if (instr != NULL) { 874 if (instr != NULL) {
871 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { 875 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) {
872 instr = AssignPointerMap(instr); 876 instr = AssignPointerMap(instr);
873 } 877 }
874 if (FLAG_stress_environments && !instr->HasEnvironment()) { 878 if (FLAG_stress_environments && !instr->HasEnvironment()) {
875 instr = AssignEnvironment(instr); 879 instr = AssignEnvironment(instr);
876 } 880 }
877 if (current->IsBranch()) { 881 if (current->IsBranch() && !instr->IsGoto()) {
878 instr->set_hydrogen_value(HBranch::cast(current)->value()); 882 // TODO(fschneider): Handle branch instructions uniformly like
883 // other instructions. This requires us to generate the right
884 // branch instruction already at the HIR level.
885 ASSERT(instr->IsControl());
886 HBranch* branch = HBranch::cast(current);
887 instr->set_hydrogen_value(branch->value());
888 HBasicBlock* first = branch->FirstSuccessor();
889 HBasicBlock* second = branch->SecondSuccessor();
890 ASSERT(first != NULL && second != NULL);
891 instr->SetBranchTargets(first->block_id(), second->block_id());
879 } else { 892 } else {
880 instr->set_hydrogen_value(current); 893 instr->set_hydrogen_value(current);
881 } 894 }
882 895
883 int index = chunk_->AddInstruction(instr, current_block_); 896 int index = chunk_->AddInstruction(instr, current_block_);
884 allocator_->SummarizeInstruction(index); 897 allocator_->SummarizeInstruction(index);
885 } else { 898 } else {
886 // This instruction should be omitted. 899 // This instruction should be omitted.
887 allocator_->OmitInstruction(); 900 allocator_->OmitInstruction();
888 } 901 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 LGoto* result = new LGoto(instr->FirstSuccessor()->block_id(), 942 LGoto* result = new LGoto(instr->FirstSuccessor()->block_id(),
930 instr->include_stack_check()); 943 instr->include_stack_check());
931 return (instr->include_stack_check()) 944 return (instr->include_stack_check())
932 ? AssignPointerMap(result) 945 ? AssignPointerMap(result)
933 : result; 946 : result;
934 } 947 }
935 948
936 949
937 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { 950 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) {
938 HValue* v = instr->value(); 951 HValue* v = instr->value();
939 HBasicBlock* first = instr->FirstSuccessor();
940 HBasicBlock* second = instr->SecondSuccessor();
941 ASSERT(first != NULL && second != NULL);
942 int first_id = first->block_id();
943 int second_id = second->block_id();
944
945 if (v->EmitAtUses()) { 952 if (v->EmitAtUses()) {
946 if (v->IsClassOfTest()) { 953 if (v->IsClassOfTest()) {
947 HClassOfTest* compare = HClassOfTest::cast(v); 954 HClassOfTest* compare = HClassOfTest::cast(v);
948 ASSERT(compare->value()->representation().IsTagged()); 955 ASSERT(compare->value()->representation().IsTagged());
949 956
950 return new LClassOfTestAndBranch(UseTempRegister(compare->value()), 957 return new LClassOfTestAndBranch(UseTempRegister(compare->value()),
951 TempRegister(), 958 TempRegister(),
952 TempRegister(), 959 TempRegister());
953 first_id,
954 second_id);
955 } else if (v->IsCompare()) { 960 } else if (v->IsCompare()) {
956 HCompare* compare = HCompare::cast(v); 961 HCompare* compare = HCompare::cast(v);
957 Token::Value op = compare->token(); 962 Token::Value op = compare->token();
958 HValue* left = compare->left(); 963 HValue* left = compare->left();
959 HValue* right = compare->right(); 964 HValue* right = compare->right();
960 Representation r = compare->GetInputRepresentation(); 965 Representation r = compare->GetInputRepresentation();
961 if (r.IsInteger32()) { 966 if (r.IsInteger32()) {
962 ASSERT(left->representation().IsInteger32()); 967 ASSERT(left->representation().IsInteger32());
963 ASSERT(right->representation().IsInteger32()); 968 ASSERT(right->representation().IsInteger32());
964 969
965 return new LCmpIDAndBranch(UseRegisterAtStart(left), 970 return new LCmpIDAndBranch(UseRegisterAtStart(left),
966 UseOrConstantAtStart(right), 971 UseOrConstantAtStart(right));
967 first_id,
968 second_id);
969 } else if (r.IsDouble()) { 972 } else if (r.IsDouble()) {
970 ASSERT(left->representation().IsDouble()); 973 ASSERT(left->representation().IsDouble());
971 ASSERT(right->representation().IsDouble()); 974 ASSERT(right->representation().IsDouble());
972 975
973 return new LCmpIDAndBranch(UseRegisterAtStart(left), 976 return new LCmpIDAndBranch(UseRegisterAtStart(left),
974 UseRegisterAtStart(right), 977 UseRegisterAtStart(right));
975 first_id,
976 second_id);
977 } else { 978 } else {
978 ASSERT(left->representation().IsTagged()); 979 ASSERT(left->representation().IsTagged());
979 ASSERT(right->representation().IsTagged()); 980 ASSERT(right->representation().IsTagged());
980 bool reversed = op == Token::GT || op == Token::LTE; 981 bool reversed = op == Token::GT || op == Token::LTE;
981 LOperand* left_operand = UseFixed(left, reversed ? eax : edx); 982 LOperand* left_operand = UseFixed(left, reversed ? eax : edx);
982 LOperand* right_operand = UseFixed(right, reversed ? edx : eax); 983 LOperand* right_operand = UseFixed(right, reversed ? edx : eax);
983 LCmpTAndBranch* result = new LCmpTAndBranch(left_operand, 984 LCmpTAndBranch* result = new LCmpTAndBranch(left_operand,
984 right_operand, 985 right_operand);
985 first_id,
986 second_id);
987 return MarkAsCall(result, instr); 986 return MarkAsCall(result, instr);
988 } 987 }
989 } else if (v->IsIsSmi()) { 988 } else if (v->IsIsSmi()) {
990 HIsSmi* compare = HIsSmi::cast(v); 989 HIsSmi* compare = HIsSmi::cast(v);
991 ASSERT(compare->value()->representation().IsTagged()); 990 ASSERT(compare->value()->representation().IsTagged());
992 991
993 return new LIsSmiAndBranch(Use(compare->value()), 992 return new LIsSmiAndBranch(Use(compare->value()));
994 first_id,
995 second_id);
996 } else if (v->IsHasInstanceType()) { 993 } else if (v->IsHasInstanceType()) {
997 HHasInstanceType* compare = HHasInstanceType::cast(v); 994 HHasInstanceType* compare = HHasInstanceType::cast(v);
998 ASSERT(compare->value()->representation().IsTagged()); 995 ASSERT(compare->value()->representation().IsTagged());
999 996
1000 return new LHasInstanceTypeAndBranch(UseRegisterAtStart(compare->value()), 997 return new LHasInstanceTypeAndBranch(UseRegisterAtStart(compare->value()),
1001 TempRegister(), 998 TempRegister());
1002 first_id,
1003 second_id);
1004 } else if (v->IsHasCachedArrayIndex()) { 999 } else if (v->IsHasCachedArrayIndex()) {
1005 HHasCachedArrayIndex* compare = HHasCachedArrayIndex::cast(v); 1000 HHasCachedArrayIndex* compare = HHasCachedArrayIndex::cast(v);
1006 ASSERT(compare->value()->representation().IsTagged()); 1001 ASSERT(compare->value()->representation().IsTagged());
1007 1002
1008 return new LHasCachedArrayIndexAndBranch( 1003 return new LHasCachedArrayIndexAndBranch(
1009 UseRegisterAtStart(compare->value()), first_id, second_id); 1004 UseRegisterAtStart(compare->value()));
1010 } else if (v->IsIsNull()) { 1005 } else if (v->IsIsNull()) {
1011 HIsNull* compare = HIsNull::cast(v); 1006 HIsNull* compare = HIsNull::cast(v);
1012 ASSERT(compare->value()->representation().IsTagged()); 1007 ASSERT(compare->value()->representation().IsTagged());
1013 1008
1014 // We only need a temp register for non-strict compare. 1009 // We only need a temp register for non-strict compare.
1015 LOperand* temp = compare->is_strict() ? NULL : TempRegister(); 1010 LOperand* temp = compare->is_strict() ? NULL : TempRegister();
1016 return new LIsNullAndBranch(UseRegisterAtStart(compare->value()), 1011 return new LIsNullAndBranch(UseRegisterAtStart(compare->value()),
1017 temp, 1012 temp);
1018 first_id,
1019 second_id);
1020 } else if (v->IsIsObject()) { 1013 } else if (v->IsIsObject()) {
1021 HIsObject* compare = HIsObject::cast(v); 1014 HIsObject* compare = HIsObject::cast(v);
1022 ASSERT(compare->value()->representation().IsTagged()); 1015 ASSERT(compare->value()->representation().IsTagged());
1023 1016
1024 LOperand* temp1 = TempRegister(); 1017 LOperand* temp1 = TempRegister();
1025 LOperand* temp2 = TempRegister(); 1018 LOperand* temp2 = TempRegister();
1026 return new LIsObjectAndBranch(UseRegisterAtStart(compare->value()), 1019 return new LIsObjectAndBranch(UseRegisterAtStart(compare->value()),
1027 temp1, 1020 temp1,
1028 temp2, 1021 temp2);
1029 first_id,
1030 second_id);
1031 } else if (v->IsCompareJSObjectEq()) { 1022 } else if (v->IsCompareJSObjectEq()) {
1032 HCompareJSObjectEq* compare = HCompareJSObjectEq::cast(v); 1023 HCompareJSObjectEq* compare = HCompareJSObjectEq::cast(v);
1033 return new LCmpJSObjectEqAndBranch(UseRegisterAtStart(compare->left()), 1024 return new LCmpJSObjectEqAndBranch(UseRegisterAtStart(compare->left()),
1034 UseRegisterAtStart(compare->right()), 1025 UseRegisterAtStart(compare->right()));
1035 first_id,
1036 second_id);
1037 } else if (v->IsInstanceOf()) { 1026 } else if (v->IsInstanceOf()) {
1038 HInstanceOf* instance_of = HInstanceOf::cast(v); 1027 HInstanceOf* instance_of = HInstanceOf::cast(v);
1039 LInstanceOfAndBranch* result = 1028 LInstanceOfAndBranch* result =
1040 new LInstanceOfAndBranch( 1029 new LInstanceOfAndBranch(
1041 UseFixed(instance_of->left(), InstanceofStub::left()), 1030 UseFixed(instance_of->left(), InstanceofStub::left()),
1042 UseFixed(instance_of->right(), InstanceofStub::right()), 1031 UseFixed(instance_of->right(), InstanceofStub::right()));
1043 first_id,
1044 second_id);
1045 return MarkAsCall(result, instr); 1032 return MarkAsCall(result, instr);
1046 } else if (v->IsTypeofIs()) { 1033 } else if (v->IsTypeofIs()) {
1047 HTypeofIs* typeof_is = HTypeofIs::cast(v); 1034 HTypeofIs* typeof_is = HTypeofIs::cast(v);
1048 return new LTypeofIsAndBranch(UseTempRegister(typeof_is->value()), 1035 return new LTypeofIsAndBranch(UseTempRegister(typeof_is->value()));
1049 first_id,
1050 second_id);
1051 } else { 1036 } else {
1052 if (v->IsConstant()) { 1037 if (v->IsConstant()) {
1053 if (HConstant::cast(v)->handle()->IsTrue()) { 1038 if (HConstant::cast(v)->handle()->IsTrue()) {
1054 return new LGoto(first_id); 1039 return new LGoto(instr->FirstSuccessor()->block_id());
1055 } else if (HConstant::cast(v)->handle()->IsFalse()) { 1040 } else if (HConstant::cast(v)->handle()->IsFalse()) {
1056 return new LGoto(second_id); 1041 return new LGoto(instr->SecondSuccessor()->block_id());
1057 } 1042 }
1058 } 1043 }
1059 Abort("Undefined compare before branch"); 1044 Abort("Undefined compare before branch");
1060 return NULL; 1045 return NULL;
1061 } 1046 }
1062 } 1047 }
1063 return new LBranch(UseRegisterAtStart(v), first_id, second_id); 1048 return new LBranch(UseRegisterAtStart(v));
1064 } 1049 }
1065 1050
1066 1051
1067 LInstruction* LChunkBuilder::DoCompareMapAndBranch( 1052 LInstruction* LChunkBuilder::DoCompareMapAndBranch(
1068 HCompareMapAndBranch* instr) { 1053 HCompareMapAndBranch* instr) {
1069 ASSERT(instr->value()->representation().IsTagged()); 1054 ASSERT(instr->value()->representation().IsTagged());
1070 LOperand* value = UseRegisterAtStart(instr->value()); 1055 LOperand* value = UseRegisterAtStart(instr->value());
1071 return new LCmpMapAndBranch(value); 1056 return new LCmpMapAndBranch(value);
1072 } 1057 }
1073 1058
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 UNREACHABLE(); 1147 UNREACHABLE();
1163 return NULL; 1148 return NULL;
1164 } 1149 }
1165 } 1150 }
1166 } 1151 }
1167 1152
1168 1153
1169 LInstruction* LChunkBuilder::DoCallKeyed(HCallKeyed* instr) { 1154 LInstruction* LChunkBuilder::DoCallKeyed(HCallKeyed* instr) {
1170 ASSERT(instr->key()->representation().IsTagged()); 1155 ASSERT(instr->key()->representation().IsTagged());
1171 argument_count_ -= instr->argument_count(); 1156 argument_count_ -= instr->argument_count();
1172 UseFixed(instr->key(), ecx); 1157 LOperand* temp = UseFixed(instr->key(), ecx);
1173 return MarkAsCall(DefineFixed(new LCallKeyed, eax), instr); 1158 return MarkAsCall(DefineFixed(new LCallKeyed(temp), eax), instr);
1174 } 1159 }
1175 1160
1176 1161
1177 LInstruction* LChunkBuilder::DoCallNamed(HCallNamed* instr) { 1162 LInstruction* LChunkBuilder::DoCallNamed(HCallNamed* instr) {
1178 argument_count_ -= instr->argument_count(); 1163 argument_count_ -= instr->argument_count();
1179 return MarkAsCall(DefineFixed(new LCallNamed, eax), instr); 1164 return MarkAsCall(DefineFixed(new LCallNamed, eax), instr);
1180 } 1165 }
1181 1166
1182 1167
1183 LInstruction* LChunkBuilder::DoCallGlobal(HCallGlobal* instr) { 1168 LInstruction* LChunkBuilder::DoCallGlobal(HCallGlobal* instr) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 return DoBit(Token::BIT_XOR, instr); 1235 return DoBit(Token::BIT_XOR, instr);
1251 } 1236 }
1252 1237
1253 1238
1254 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) { 1239 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) {
1255 if (instr->representation().IsDouble()) { 1240 if (instr->representation().IsDouble()) {
1256 return DoArithmeticD(Token::DIV, instr); 1241 return DoArithmeticD(Token::DIV, instr);
1257 } else if (instr->representation().IsInteger32()) { 1242 } else if (instr->representation().IsInteger32()) {
1258 // The temporary operand is necessary to ensure that right is not allocated 1243 // The temporary operand is necessary to ensure that right is not allocated
1259 // into edx. 1244 // into edx.
1260 FixedTemp(edx); 1245 LOperand* temp = FixedTemp(edx);
1261 LOperand* value = UseFixed(instr->left(), eax); 1246 LOperand* value = UseFixed(instr->left(), eax);
1262 LOperand* divisor = UseRegister(instr->right()); 1247 LOperand* divisor = UseRegister(instr->right());
1263 return AssignEnvironment(DefineFixed(new LDivI(value, divisor), eax)); 1248 LDivI* result = new LDivI(value, divisor, temp);
1249 return AssignEnvironment(DefineFixed(result, eax));
1264 } else { 1250 } else {
1265 ASSERT(instr->representation().IsTagged()); 1251 ASSERT(instr->representation().IsTagged());
1266 return DoArithmeticT(Token::DIV, instr); 1252 return DoArithmeticT(Token::DIV, instr);
1267 } 1253 }
1268 } 1254 }
1269 1255
1270 1256
1271 LInstruction* LChunkBuilder::DoMod(HMod* instr) { 1257 LInstruction* LChunkBuilder::DoMod(HMod* instr) {
1272 if (instr->representation().IsInteger32()) { 1258 if (instr->representation().IsInteger32()) {
1273 ASSERT(instr->left()->representation().IsInteger32()); 1259 ASSERT(instr->left()->representation().IsInteger32());
1274 ASSERT(instr->right()->representation().IsInteger32()); 1260 ASSERT(instr->right()->representation().IsInteger32());
1275 // The temporary operand is necessary to ensure that right is not allocated 1261 // The temporary operand is necessary to ensure that right is not allocated
1276 // into edx. 1262 // into edx.
1277 FixedTemp(edx); 1263 LOperand* temp = FixedTemp(edx);
1278 LOperand* value = UseFixed(instr->left(), eax); 1264 LOperand* value = UseFixed(instr->left(), eax);
1279 LOperand* divisor = UseRegister(instr->right()); 1265 LOperand* divisor = UseRegister(instr->right());
1280 LModI* mod = new LModI(value, divisor); 1266 LModI* mod = new LModI(value, divisor, temp);
1281 LInstruction* result = DefineFixed(mod, edx); 1267 LInstruction* result = DefineFixed(mod, edx);
1282 return (instr->CheckFlag(HValue::kBailoutOnMinusZero) || 1268 return (instr->CheckFlag(HValue::kBailoutOnMinusZero) ||
1283 instr->CheckFlag(HValue::kCanBeDivByZero)) 1269 instr->CheckFlag(HValue::kCanBeDivByZero))
1284 ? AssignEnvironment(result) 1270 ? AssignEnvironment(result)
1285 : result; 1271 : result;
1286 } else if (instr->representation().IsTagged()) { 1272 } else if (instr->representation().IsTagged()) {
1287 return DoArithmeticT(Token::MOD, instr); 1273 return DoArithmeticT(Token::MOD, instr);
1288 } else { 1274 } else {
1289 ASSERT(instr->representation().IsDouble()); 1275 ASSERT(instr->representation().IsDouble());
1290 // We call a C function for double modulo. It can't trigger a GC. 1276 // We call a C function for double modulo. It can't trigger a GC.
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 1853
1868 1854
1869 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { 1855 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) {
1870 HEnvironment* outer = current_block_->last_environment()->outer(); 1856 HEnvironment* outer = current_block_->last_environment()->outer();
1871 current_block_->UpdateEnvironment(outer); 1857 current_block_->UpdateEnvironment(outer);
1872 return NULL; 1858 return NULL;
1873 } 1859 }
1874 1860
1875 1861
1876 } } // namespace v8::internal 1862 } } // namespace v8::internal
OLDNEW
« src/ia32/lithium-ia32.h ('K') | « src/ia32/lithium-ia32.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698