| OLD | NEW |
| 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 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 Move(expr->context(), eax); | 1117 Move(expr->context(), eax); |
| 1118 | 1118 |
| 1119 break; | 1119 break; |
| 1120 } | 1120 } |
| 1121 default: | 1121 default: |
| 1122 UNREACHABLE(); | 1122 UNREACHABLE(); |
| 1123 } | 1123 } |
| 1124 } | 1124 } |
| 1125 | 1125 |
| 1126 | 1126 |
| 1127 void FastCodeGenerator::VisitCompareOperation(CompareOperation* expr) { |
| 1128 ASSERT_EQ(Expression::kValue, expr->left()->context()); |
| 1129 ASSERT_EQ(Expression::kValue, expr->right()->context()); |
| 1130 Visit(expr->left()); |
| 1131 Visit(expr->right()); |
| 1132 |
| 1133 // Convert current context to test context: Pre-test code. |
| 1134 Label push_true; |
| 1135 Label push_false; |
| 1136 Label done; |
| 1137 Label* saved_true = true_label_; |
| 1138 Label* saved_false = false_label_; |
| 1139 switch (expr->context()) { |
| 1140 case Expression::kUninitialized: |
| 1141 UNREACHABLE(); |
| 1142 break; |
| 1143 |
| 1144 case Expression::kValue: |
| 1145 true_label_ = &push_true; |
| 1146 false_label_ = &push_false; |
| 1147 break; |
| 1148 |
| 1149 case Expression::kEffect: |
| 1150 true_label_ = &done; |
| 1151 false_label_ = &done; |
| 1152 break; |
| 1153 |
| 1154 case Expression::kTest: |
| 1155 break; |
| 1156 |
| 1157 case Expression::kValueTest: |
| 1158 true_label_ = &push_true; |
| 1159 break; |
| 1160 |
| 1161 case Expression::kTestValue: |
| 1162 false_label_ = &push_false; |
| 1163 break; |
| 1164 } |
| 1165 // Convert current context to test context: End pre-test code. |
| 1166 |
| 1167 switch (expr->op()) { |
| 1168 case Token::IN: { |
| 1169 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION); |
| 1170 __ cmp(eax, Factory::true_value()); |
| 1171 __ j(equal, true_label_); |
| 1172 __ jmp(false_label_); |
| 1173 break; |
| 1174 } |
| 1175 |
| 1176 case Token::INSTANCEOF: { |
| 1177 InstanceofStub stub; |
| 1178 __ CallStub(&stub); |
| 1179 __ test(eax, Operand(eax)); |
| 1180 __ j(zero, true_label_); // The stub returns 0 for true. |
| 1181 __ jmp(false_label_); |
| 1182 break; |
| 1183 } |
| 1184 |
| 1185 default: { |
| 1186 Condition cc = no_condition; |
| 1187 bool strict = false; |
| 1188 switch (expr->op()) { |
| 1189 case Token::EQ_STRICT: |
| 1190 strict = true; |
| 1191 // Fall through |
| 1192 case Token::EQ: |
| 1193 cc = equal; |
| 1194 __ pop(eax); |
| 1195 __ pop(edx); |
| 1196 break; |
| 1197 case Token::LT: |
| 1198 cc = less; |
| 1199 __ pop(eax); |
| 1200 __ pop(edx); |
| 1201 break; |
| 1202 case Token::GT: |
| 1203 // Reverse left and right sizes to obtain ECMA-262 conversion order. |
| 1204 cc = less; |
| 1205 __ pop(edx); |
| 1206 __ pop(eax); |
| 1207 break; |
| 1208 case Token::LTE: |
| 1209 // Reverse left and right sizes to obtain ECMA-262 conversion order. |
| 1210 cc = greater_equal; |
| 1211 __ pop(edx); |
| 1212 __ pop(eax); |
| 1213 break; |
| 1214 case Token::GTE: |
| 1215 cc = greater_equal; |
| 1216 __ pop(eax); |
| 1217 __ pop(edx); |
| 1218 break; |
| 1219 case Token::IN: |
| 1220 case Token::INSTANCEOF: |
| 1221 default: |
| 1222 UNREACHABLE(); |
| 1223 } |
| 1224 |
| 1225 // The comparison stub expects the smi vs. smi case to be handled |
| 1226 // before it is called. |
| 1227 Label slow_case; |
| 1228 __ mov(ecx, Operand(edx)); |
| 1229 __ or_(ecx, Operand(eax)); |
| 1230 __ test(ecx, Immediate(kSmiTagMask)); |
| 1231 __ j(not_zero, &slow_case, not_taken); |
| 1232 __ cmp(edx, Operand(eax)); |
| 1233 __ j(cc, true_label_); |
| 1234 __ jmp(false_label_); |
| 1235 |
| 1236 __ bind(&slow_case); |
| 1237 CompareStub stub(cc, strict); |
| 1238 __ CallStub(&stub); |
| 1239 __ test(eax, Operand(eax)); |
| 1240 __ j(cc, true_label_); |
| 1241 __ jmp(false_label_); |
| 1242 } |
| 1243 } |
| 1244 |
| 1245 // Convert current context to test context: Post-test code. |
| 1246 switch (expr->context()) { |
| 1247 case Expression::kUninitialized: |
| 1248 UNREACHABLE(); |
| 1249 break; |
| 1250 |
| 1251 case Expression::kValue: |
| 1252 __ bind(&push_true); |
| 1253 __ push(Immediate(Factory::true_value())); |
| 1254 __ jmp(&done); |
| 1255 __ bind(&push_false); |
| 1256 __ push(Immediate(Factory::false_value())); |
| 1257 __ bind(&done); |
| 1258 break; |
| 1259 |
| 1260 case Expression::kEffect: |
| 1261 __ bind(&done); |
| 1262 break; |
| 1263 |
| 1264 case Expression::kTest: |
| 1265 break; |
| 1266 |
| 1267 case Expression::kValueTest: |
| 1268 __ bind(&push_true); |
| 1269 __ push(Immediate(Factory::true_value())); |
| 1270 __ jmp(saved_true); |
| 1271 break; |
| 1272 |
| 1273 case Expression::kTestValue: |
| 1274 __ bind(&push_false); |
| 1275 __ push(Immediate(Factory::false_value())); |
| 1276 __ jmp(saved_false); |
| 1277 break; |
| 1278 } |
| 1279 true_label_ = saved_true; |
| 1280 false_label_ = saved_false; |
| 1281 // Convert current context to test context: End post-test code. |
| 1282 } |
| 1283 |
| 1284 |
| 1127 #undef __ | 1285 #undef __ |
| 1128 | 1286 |
| 1129 | 1287 |
| 1130 } } // namespace v8::internal | 1288 } } // namespace v8::internal |
| OLD | NEW |