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

Side by Side Diff: src/arm/fast-codegen-arm.cc

Issue 348039: Add comparison operations to the fast compiler. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 1 month 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 | « no previous file | src/compiler.cc » ('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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 Move(expr->context(), r0); 1103 Move(expr->context(), r0);
1104 1104
1105 break; 1105 break;
1106 } 1106 }
1107 default: 1107 default:
1108 UNREACHABLE(); 1108 UNREACHABLE();
1109 } 1109 }
1110 } 1110 }
1111 1111
1112 1112
1113 void FastCodeGenerator::VisitCompareOperation(CompareOperation* expr) {
1114 ASSERT_EQ(Expression::kValue, expr->left()->context());
1115 ASSERT_EQ(Expression::kValue, expr->right()->context());
1116 Visit(expr->left());
1117 Visit(expr->right());
1118
1119 // Convert current context to test context: Pre-test code.
1120 Label push_true;
1121 Label push_false;
1122 Label done;
1123 Label* saved_true = true_label_;
1124 Label* saved_false = false_label_;
1125 switch (expr->context()) {
1126 case Expression::kUninitialized:
1127 UNREACHABLE();
1128 break;
1129
1130 case Expression::kValue:
1131 true_label_ = &push_true;
1132 false_label_ = &push_false;
1133 break;
1134
1135 case Expression::kEffect:
1136 true_label_ = &done;
1137 false_label_ = &done;
1138 break;
1139
1140 case Expression::kTest:
1141 break;
1142
1143 case Expression::kValueTest:
1144 true_label_ = &push_true;
1145 break;
1146
1147 case Expression::kTestValue:
1148 false_label_ = &push_false;
1149 break;
1150 }
1151 // Convert current context to test context: End pre-test code.
1152
1153 switch (expr->op()) {
1154 case Token::IN: {
1155 __ InvokeBuiltin(Builtins::IN, CALL_JS);
1156 __ LoadRoot(ip, Heap::kTrueValueRootIndex);
1157 __ cmp(r0, ip);
1158 __ b(eq, true_label_);
1159 __ jmp(false_label_);
1160 break;
1161 }
1162
1163 case Token::INSTANCEOF: {
1164 InstanceofStub stub;
1165 __ CallStub(&stub);
1166 __ tst(r0, r0);
1167 __ b(eq, true_label_); // The stub returns 0 for true.
1168 __ jmp(false_label_);
1169 break;
1170 }
1171
1172 default: {
1173 Condition cc = eq;
1174 bool strict = false;
1175 switch (expr->op()) {
1176 case Token::EQ_STRICT:
1177 strict = true;
1178 // Fall through
1179 case Token::EQ:
1180 cc = eq;
1181 __ pop(r0);
1182 __ pop(r1);
1183 break;
1184 case Token::LT:
1185 cc = lt;
1186 __ pop(r0);
1187 __ pop(r1);
1188 break;
1189 case Token::GT:
1190 // Reverse left and right sizes to obtain ECMA-262 conversion order.
1191 cc = lt;
1192 __ pop(r1);
1193 __ pop(r0);
1194 break;
1195 case Token::LTE:
1196 // Reverse left and right sizes to obtain ECMA-262 conversion order.
1197 cc = ge;
1198 __ pop(r1);
1199 __ pop(r0);
1200 break;
1201 case Token::GTE:
1202 cc = ge;
1203 __ pop(r0);
1204 __ pop(r1);
1205 break;
1206 case Token::IN:
1207 case Token::INSTANCEOF:
1208 default:
1209 UNREACHABLE();
1210 }
1211
1212 // The comparison stub expects the smi vs. smi case to be handled
1213 // before it is called.
1214 Label slow_case;
1215 __ orr(r2, r0, Operand(r1));
1216 __ tst(r2, Operand(kSmiTagMask));
1217 __ b(ne, &slow_case);
1218 __ cmp(r1, r0);
1219 __ b(cc, true_label_);
1220 __ jmp(false_label_);
1221
1222 __ bind(&slow_case);
1223 CompareStub stub(cc, strict);
1224 __ CallStub(&stub);
1225 __ tst(r0, r0);
1226 __ b(cc, true_label_);
1227 __ jmp(false_label_);
1228 }
1229 }
1230
1231 // Convert current context to test context: Post-test code.
1232 switch (expr->context()) {
1233 case Expression::kUninitialized:
1234 UNREACHABLE();
1235 break;
1236
1237 case Expression::kValue:
1238 __ bind(&push_true);
1239 __ LoadRoot(ip, Heap::kTrueValueRootIndex);
1240 __ push(ip);
1241 __ jmp(&done);
1242 __ bind(&push_false);
1243 __ LoadRoot(ip, Heap::kFalseValueRootIndex);
1244 __ push(ip);
1245 __ bind(&done);
1246 break;
1247
1248 case Expression::kEffect:
1249 __ bind(&done);
1250 break;
1251
1252 case Expression::kTest:
1253 break;
1254
1255 case Expression::kValueTest:
1256 __ bind(&push_true);
1257 __ LoadRoot(ip, Heap::kTrueValueRootIndex);
1258 __ push(ip);
1259 __ jmp(saved_true);
1260 break;
1261
1262 case Expression::kTestValue:
1263 __ bind(&push_false);
1264 __ LoadRoot(ip, Heap::kFalseValueRootIndex);
1265 __ push(ip);
1266 __ jmp(saved_false);
1267 break;
1268 }
1269 true_label_ = saved_true;
1270 false_label_ = saved_false;
1271 // Convert current context to test context: End post-test code.
1272 }
1273
1274
1275 #undef __
1276
1277
1113 } } // namespace v8::internal 1278 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698