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

Side by Side Diff: src/compiler/mips/instruction-selector-mips.cc

Issue 1721103003: [turbofan] Introduce DeoptimizeIf And DeoptimizeUnless common operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add comments Created 4 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
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/base/adapters.h" 5 #include "src/base/adapters.h"
6 #include "src/base/bits.h" 6 #include "src/base/bits.h"
7 #include "src/compiler/instruction-selector-impl.h" 7 #include "src/compiler/instruction-selector-impl.h"
8 #include "src/compiler/node-matchers.h" 8 #include "src/compiler/node-matchers.h"
9 #include "src/compiler/node-properties.h" 9 #include "src/compiler/node-properties.h"
10 10
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 outputs[output_count++] = g.DefineAsRegister(node); 107 outputs[output_count++] = g.DefineAsRegister(node);
108 if (cont->IsSet()) { 108 if (cont->IsSet()) {
109 outputs[output_count++] = g.DefineAsRegister(cont->result()); 109 outputs[output_count++] = g.DefineAsRegister(cont->result());
110 } 110 }
111 111
112 DCHECK_NE(0u, input_count); 112 DCHECK_NE(0u, input_count);
113 DCHECK_NE(0u, output_count); 113 DCHECK_NE(0u, output_count);
114 DCHECK_GE(arraysize(inputs), input_count); 114 DCHECK_GE(arraysize(inputs), input_count);
115 DCHECK_GE(arraysize(outputs), output_count); 115 DCHECK_GE(arraysize(outputs), output_count);
116 116
117 selector->Emit(cont->Encode(opcode), output_count, outputs, input_count, 117 opcode = cont->Encode(opcode);
118 inputs); 118 if (cont->IsDeoptimize()) {
119 selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs,
120 cont->frame_state());
121 } else {
122 selector->Emit(opcode, output_count, outputs, input_count, inputs);
123 }
119 } 124 }
120 125
121 126
122 static void VisitBinop(InstructionSelector* selector, Node* node, 127 static void VisitBinop(InstructionSelector* selector, Node* node,
123 InstructionCode opcode) { 128 InstructionCode opcode) {
124 FlagsContinuation cont; 129 FlagsContinuation cont;
125 VisitBinop(selector, node, opcode, &cont); 130 VisitBinop(selector, node, opcode, &cont);
126 } 131 }
127 132
128 133
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 977
973 // Shared routine for multiple compare operations. 978 // Shared routine for multiple compare operations.
974 static void VisitCompare(InstructionSelector* selector, InstructionCode opcode, 979 static void VisitCompare(InstructionSelector* selector, InstructionCode opcode,
975 InstructionOperand left, InstructionOperand right, 980 InstructionOperand left, InstructionOperand right,
976 FlagsContinuation* cont) { 981 FlagsContinuation* cont) {
977 MipsOperandGenerator g(selector); 982 MipsOperandGenerator g(selector);
978 opcode = cont->Encode(opcode); 983 opcode = cont->Encode(opcode);
979 if (cont->IsBranch()) { 984 if (cont->IsBranch()) {
980 selector->Emit(opcode, g.NoOutput(), left, right, 985 selector->Emit(opcode, g.NoOutput(), left, right,
981 g.Label(cont->true_block()), g.Label(cont->false_block())); 986 g.Label(cont->true_block()), g.Label(cont->false_block()));
987 } else if (cont->IsDeoptimize()) {
988 selector->EmitDeoptimize(opcode, g.NoOutput(), left, right,
989 cont->frame_state());
982 } else { 990 } else {
983 DCHECK(cont->IsSet()); 991 DCHECK(cont->IsSet());
984 selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right); 992 selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right);
985 } 993 }
986 } 994 }
987 995
988 996
989 // Shared routine for multiple float32 compare operations. 997 // Shared routine for multiple float32 compare operations.
990 void VisitFloat32Compare(InstructionSelector* selector, Node* node, 998 void VisitFloat32Compare(InstructionSelector* selector, Node* node,
991 FlagsContinuation* cont) { 999 FlagsContinuation* cont) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 cont); 1085 cont);
1078 } 1086 }
1079 } 1087 }
1080 1088
1081 1089
1082 void VisitWordCompare(InstructionSelector* selector, Node* node, 1090 void VisitWordCompare(InstructionSelector* selector, Node* node,
1083 FlagsContinuation* cont) { 1091 FlagsContinuation* cont) {
1084 VisitWordCompare(selector, node, kMipsCmp, cont, false); 1092 VisitWordCompare(selector, node, kMipsCmp, cont, false);
1085 } 1093 }
1086 1094
1087 } // namespace
1088
1089
1090 // Shared routine for word comparisons against zero. 1095 // Shared routine for word comparisons against zero.
1091 void VisitWordCompareZero(InstructionSelector* selector, Node* user, 1096 void VisitWordCompareZero(InstructionSelector* selector, Node* user,
1092 Node* value, FlagsContinuation* cont) { 1097 Node* value, FlagsContinuation* cont) {
1093 while (selector->CanCover(user, value)) { 1098 while (selector->CanCover(user, value)) {
1094 switch (value->opcode()) { 1099 switch (value->opcode()) {
1095 case IrOpcode::kWord32Equal: { 1100 case IrOpcode::kWord32Equal: {
1096 // Combine with comparisons against 0 by simply inverting the 1101 // Combine with comparisons against 0 by simply inverting the
1097 // continuation. 1102 // continuation.
1098 Int32BinopMatcher m(value); 1103 Int32BinopMatcher m(value);
1099 if (m.right().Is(0)) { 1104 if (m.right().Is(0)) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 break; 1173 break;
1169 } 1174 }
1170 1175
1171 // Continuation could not be combined with a compare, emit compare against 0. 1176 // Continuation could not be combined with a compare, emit compare against 0.
1172 MipsOperandGenerator g(selector); 1177 MipsOperandGenerator g(selector);
1173 InstructionCode const opcode = cont->Encode(kMipsCmp); 1178 InstructionCode const opcode = cont->Encode(kMipsCmp);
1174 InstructionOperand const value_operand = g.UseRegister(value); 1179 InstructionOperand const value_operand = g.UseRegister(value);
1175 if (cont->IsBranch()) { 1180 if (cont->IsBranch()) {
1176 selector->Emit(opcode, g.NoOutput(), value_operand, g.TempImmediate(0), 1181 selector->Emit(opcode, g.NoOutput(), value_operand, g.TempImmediate(0),
1177 g.Label(cont->true_block()), g.Label(cont->false_block())); 1182 g.Label(cont->true_block()), g.Label(cont->false_block()));
1183 } else if (cont->IsDeoptimize()) {
1184 selector->EmitDeoptimize(opcode, g.NoOutput(), value_operand,
1185 g.TempImmediate(0), cont->frame_state());
1178 } else { 1186 } else {
1187 DCHECK(cont->IsSet());
1179 selector->Emit(opcode, g.DefineAsRegister(cont->result()), value_operand, 1188 selector->Emit(opcode, g.DefineAsRegister(cont->result()), value_operand,
1180 g.TempImmediate(0)); 1189 g.TempImmediate(0));
1181 } 1190 }
1182 } 1191 }
1183 1192
1193 } // namespace
1184 1194
1185 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, 1195 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch,
1186 BasicBlock* fbranch) { 1196 BasicBlock* fbranch) {
1187 FlagsContinuation cont(kNotEqual, tbranch, fbranch); 1197 FlagsContinuation cont(kNotEqual, tbranch, fbranch);
1188 VisitWordCompareZero(this, branch, branch->InputAt(0), &cont); 1198 VisitWordCompareZero(this, branch, branch->InputAt(0), &cont);
1189 } 1199 }
1190 1200
1201 void InstructionSelector::VisitDeoptimizeIf(Node* node) {
1202 FlagsContinuation cont =
1203 FlagsContinuation::ForDeoptimize(kNotEqual, node->InputAt(1));
1204 VisitWordCompareZero(this, node, node->InputAt(0), &cont);
1205 }
1206
1207 void InstructionSelector::VisitDeoptimizeUnless(Node* node) {
1208 FlagsContinuation cont =
1209 FlagsContinuation::ForDeoptimize(kEqual, node->InputAt(1));
1210 VisitWordCompareZero(this, node, node->InputAt(0), &cont);
1211 }
1191 1212
1192 void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) { 1213 void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) {
1193 MipsOperandGenerator g(this); 1214 MipsOperandGenerator g(this);
1194 InstructionOperand value_operand = g.UseRegister(node->InputAt(0)); 1215 InstructionOperand value_operand = g.UseRegister(node->InputAt(0));
1195 1216
1196 // Emit either ArchTableSwitch or ArchLookupSwitch. 1217 // Emit either ArchTableSwitch or ArchLookupSwitch.
1197 size_t table_space_cost = 9 + sw.value_range; 1218 size_t table_space_cost = 9 + sw.value_range;
1198 size_t table_time_cost = 3; 1219 size_t table_time_cost = 3;
1199 size_t lookup_space_cost = 2 + 2 * sw.case_count; 1220 size_t lookup_space_cost = 2 + 2 * sw.case_count;
1200 size_t lookup_time_cost = sw.case_count; 1221 size_t lookup_time_cost = sw.case_count;
(...skipping 10 matching lines...) Expand all
1211 // Generate a table lookup. 1232 // Generate a table lookup.
1212 return EmitTableSwitch(sw, index_operand); 1233 return EmitTableSwitch(sw, index_operand);
1213 } 1234 }
1214 1235
1215 // Generate a sequence of conditional jumps. 1236 // Generate a sequence of conditional jumps.
1216 return EmitLookupSwitch(sw, value_operand); 1237 return EmitLookupSwitch(sw, value_operand);
1217 } 1238 }
1218 1239
1219 1240
1220 void InstructionSelector::VisitWord32Equal(Node* const node) { 1241 void InstructionSelector::VisitWord32Equal(Node* const node) {
1221 FlagsContinuation cont(kEqual, node); 1242 FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node);
1222 Int32BinopMatcher m(node); 1243 Int32BinopMatcher m(node);
1223 if (m.right().Is(0)) { 1244 if (m.right().Is(0)) {
1224 return VisitWordCompareZero(this, m.node(), m.left().node(), &cont); 1245 return VisitWordCompareZero(this, m.node(), m.left().node(), &cont);
1225 } 1246 }
1226 VisitWordCompare(this, node, &cont); 1247 VisitWordCompare(this, node, &cont);
1227 } 1248 }
1228 1249
1229 1250
1230 void InstructionSelector::VisitInt32LessThan(Node* node) { 1251 void InstructionSelector::VisitInt32LessThan(Node* node) {
1231 FlagsContinuation cont(kSignedLessThan, node); 1252 FlagsContinuation cont = FlagsContinuation::ForSet(kSignedLessThan, node);
1232 VisitWordCompare(this, node, &cont); 1253 VisitWordCompare(this, node, &cont);
1233 } 1254 }
1234 1255
1235 1256
1236 void InstructionSelector::VisitInt32LessThanOrEqual(Node* node) { 1257 void InstructionSelector::VisitInt32LessThanOrEqual(Node* node) {
1237 FlagsContinuation cont(kSignedLessThanOrEqual, node); 1258 FlagsContinuation cont =
1259 FlagsContinuation::ForSet(kSignedLessThanOrEqual, node);
1238 VisitWordCompare(this, node, &cont); 1260 VisitWordCompare(this, node, &cont);
1239 } 1261 }
1240 1262
1241 1263
1242 void InstructionSelector::VisitUint32LessThan(Node* node) { 1264 void InstructionSelector::VisitUint32LessThan(Node* node) {
1243 FlagsContinuation cont(kUnsignedLessThan, node); 1265 FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node);
1244 VisitWordCompare(this, node, &cont); 1266 VisitWordCompare(this, node, &cont);
1245 } 1267 }
1246 1268
1247 1269
1248 void InstructionSelector::VisitUint32LessThanOrEqual(Node* node) { 1270 void InstructionSelector::VisitUint32LessThanOrEqual(Node* node) {
1249 FlagsContinuation cont(kUnsignedLessThanOrEqual, node); 1271 FlagsContinuation cont =
1272 FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node);
1250 VisitWordCompare(this, node, &cont); 1273 VisitWordCompare(this, node, &cont);
1251 } 1274 }
1252 1275
1253 1276
1254 void InstructionSelector::VisitInt32AddWithOverflow(Node* node) { 1277 void InstructionSelector::VisitInt32AddWithOverflow(Node* node) {
1255 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { 1278 if (Node* ovf = NodeProperties::FindProjection(node, 1)) {
1256 FlagsContinuation cont(kOverflow, ovf); 1279 FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf);
1257 return VisitBinop(this, node, kMipsAddOvf, &cont); 1280 return VisitBinop(this, node, kMipsAddOvf, &cont);
1258 } 1281 }
1259 FlagsContinuation cont; 1282 FlagsContinuation cont;
1260 VisitBinop(this, node, kMipsAddOvf, &cont); 1283 VisitBinop(this, node, kMipsAddOvf, &cont);
1261 } 1284 }
1262 1285
1263 1286
1264 void InstructionSelector::VisitInt32SubWithOverflow(Node* node) { 1287 void InstructionSelector::VisitInt32SubWithOverflow(Node* node) {
1265 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { 1288 if (Node* ovf = NodeProperties::FindProjection(node, 1)) {
1266 FlagsContinuation cont(kOverflow, ovf); 1289 FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf);
1267 return VisitBinop(this, node, kMipsSubOvf, &cont); 1290 return VisitBinop(this, node, kMipsSubOvf, &cont);
1268 } 1291 }
1269 FlagsContinuation cont; 1292 FlagsContinuation cont;
1270 VisitBinop(this, node, kMipsSubOvf, &cont); 1293 VisitBinop(this, node, kMipsSubOvf, &cont);
1271 } 1294 }
1272 1295
1273 1296
1274 void InstructionSelector::VisitFloat32Equal(Node* node) { 1297 void InstructionSelector::VisitFloat32Equal(Node* node) {
1275 FlagsContinuation cont(kEqual, node); 1298 FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node);
1276 VisitFloat32Compare(this, node, &cont); 1299 VisitFloat32Compare(this, node, &cont);
1277 } 1300 }
1278 1301
1279 1302
1280 void InstructionSelector::VisitFloat32LessThan(Node* node) { 1303 void InstructionSelector::VisitFloat32LessThan(Node* node) {
1281 FlagsContinuation cont(kUnsignedLessThan, node); 1304 FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node);
1282 VisitFloat32Compare(this, node, &cont); 1305 VisitFloat32Compare(this, node, &cont);
1283 } 1306 }
1284 1307
1285 1308
1286 void InstructionSelector::VisitFloat32LessThanOrEqual(Node* node) { 1309 void InstructionSelector::VisitFloat32LessThanOrEqual(Node* node) {
1287 FlagsContinuation cont(kUnsignedLessThanOrEqual, node); 1310 FlagsContinuation cont =
1311 FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node);
1288 VisitFloat32Compare(this, node, &cont); 1312 VisitFloat32Compare(this, node, &cont);
1289 } 1313 }
1290 1314
1291 1315
1292 void InstructionSelector::VisitFloat64Equal(Node* node) { 1316 void InstructionSelector::VisitFloat64Equal(Node* node) {
1293 FlagsContinuation cont(kEqual, node); 1317 FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node);
1294 VisitFloat64Compare(this, node, &cont); 1318 VisitFloat64Compare(this, node, &cont);
1295 } 1319 }
1296 1320
1297 1321
1298 void InstructionSelector::VisitFloat64LessThan(Node* node) { 1322 void InstructionSelector::VisitFloat64LessThan(Node* node) {
1299 FlagsContinuation cont(kUnsignedLessThan, node); 1323 FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node);
1300 VisitFloat64Compare(this, node, &cont); 1324 VisitFloat64Compare(this, node, &cont);
1301 } 1325 }
1302 1326
1303 1327
1304 void InstructionSelector::VisitFloat64LessThanOrEqual(Node* node) { 1328 void InstructionSelector::VisitFloat64LessThanOrEqual(Node* node) {
1305 FlagsContinuation cont(kUnsignedLessThanOrEqual, node); 1329 FlagsContinuation cont =
1330 FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node);
1306 VisitFloat64Compare(this, node, &cont); 1331 VisitFloat64Compare(this, node, &cont);
1307 } 1332 }
1308 1333
1309 1334
1310 void InstructionSelector::VisitFloat64ExtractLowWord32(Node* node) { 1335 void InstructionSelector::VisitFloat64ExtractLowWord32(Node* node) {
1311 MipsOperandGenerator g(this); 1336 MipsOperandGenerator g(this);
1312 Emit(kMipsFloat64ExtractLowWord32, g.DefineAsRegister(node), 1337 Emit(kMipsFloat64ExtractLowWord32, g.DefineAsRegister(node),
1313 g.UseRegister(node->InputAt(0))); 1338 g.UseRegister(node->InputAt(0)));
1314 } 1339 }
1315 1340
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 MachineOperatorBuilder::kFloat32Max | 1386 MachineOperatorBuilder::kFloat32Max |
1362 MachineOperatorBuilder::kFloat32RoundDown | 1387 MachineOperatorBuilder::kFloat32RoundDown |
1363 MachineOperatorBuilder::kFloat32RoundUp | 1388 MachineOperatorBuilder::kFloat32RoundUp |
1364 MachineOperatorBuilder::kFloat32RoundTruncate | 1389 MachineOperatorBuilder::kFloat32RoundTruncate |
1365 MachineOperatorBuilder::kFloat32RoundTiesEven; 1390 MachineOperatorBuilder::kFloat32RoundTiesEven;
1366 } 1391 }
1367 1392
1368 } // namespace compiler 1393 } // namespace compiler
1369 } // namespace internal 1394 } // namespace internal
1370 } // namespace v8 1395 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-native-context-specialization.cc ('k') | src/compiler/mips64/instruction-selector-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698