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

Side by Side Diff: src/compiler/simplified-lowering.cc

Issue 2149583002: [turbofan] Extend undefined-to-number truncation to all oddballs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « src/compiler/representation-change.cc ('k') | src/compiler/type-hint-analyzer.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 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/compiler/simplified-lowering.h" 5 #include "src/compiler/simplified-lowering.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/address-map.h" 9 #include "src/address-map.h"
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
(...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 1123
1124 if (hint == BinaryOperationHints::kSignedSmall || 1124 if (hint == BinaryOperationHints::kSignedSmall ||
1125 hint == BinaryOperationHints::kSigned32) { 1125 hint == BinaryOperationHints::kSigned32) {
1126 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(), 1126 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(),
1127 MachineRepresentation::kWord32, Type::Signed32()); 1127 MachineRepresentation::kWord32, Type::Signed32());
1128 if (lower()) ChangeToInt32OverflowOp(node); 1128 if (lower()) ChangeToInt32OverflowOp(node);
1129 return; 1129 return;
1130 } 1130 }
1131 1131
1132 // default case => Float64Add/Sub 1132 // default case => Float64Add/Sub
1133 VisitBinop(node, UseInfo::CheckedNumberOrUndefinedAsFloat64(), 1133 VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(),
1134 MachineRepresentation::kFloat64, Type::Number()); 1134 MachineRepresentation::kFloat64, Type::Number());
1135 if (lower()) { 1135 if (lower()) {
1136 ChangeToPureOp(node, Float64Op(node)); 1136 ChangeToPureOp(node, Float64Op(node));
1137 } 1137 }
1138 return; 1138 return;
1139 } 1139 }
1140 1140
1141 // Dispatching routine for visiting the node {node} with the usage {use}. 1141 // Dispatching routine for visiting the node {node} with the usage {use}.
1142 // Depending on the operator, propagate new usage info to the inputs. 1142 // Depending on the operator, propagate new usage info to the inputs.
1143 void VisitNode(Node* node, Truncation truncation, 1143 void VisitNode(Node* node, Truncation truncation,
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 } 1276 }
1277 // Try to use type feedback. 1277 // Try to use type feedback.
1278 CompareOperationHints::Hint hint = CompareOperationHintOf(node->op()); 1278 CompareOperationHints::Hint hint = CompareOperationHintOf(node->op());
1279 1279
1280 if (hint == CompareOperationHints::kSignedSmall) { 1280 if (hint == CompareOperationHints::kSignedSmall) {
1281 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(), 1281 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(),
1282 MachineRepresentation::kBit); 1282 MachineRepresentation::kBit);
1283 if (lower()) ChangeToPureOp(node, Int32Op(node)); 1283 if (lower()) ChangeToPureOp(node, Int32Op(node));
1284 return; 1284 return;
1285 } 1285 }
1286 DCHECK_EQ(CompareOperationHints::kNumber, hint); 1286 DCHECK_EQ(CompareOperationHints::kNumberOrOddball, hint);
1287 // default case => Float64 comparison 1287 // default case => Float64 comparison
1288 VisitBinop(node, UseInfo::CheckedNumberOrUndefinedAsFloat64(), 1288 VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(),
1289 MachineRepresentation::kBit); 1289 MachineRepresentation::kBit);
1290 if (lower()) ChangeToPureOp(node, Float64Op(node)); 1290 if (lower()) ChangeToPureOp(node, Float64Op(node));
1291 return; 1291 return;
1292 } 1292 }
1293 1293
1294 case IrOpcode::kNumberAdd: 1294 case IrOpcode::kNumberAdd:
1295 case IrOpcode::kNumberSubtract: { 1295 case IrOpcode::kNumberSubtract: {
1296 if (BothInputsAre(node, Type::Signed32()) && 1296 if (BothInputsAre(node, Type::Signed32()) &&
1297 NodeProperties::GetType(node)->Is(Type::Signed32())) { 1297 NodeProperties::GetType(node)->Is(Type::Signed32())) {
1298 // int32 + int32 = int32 1298 // int32 + int32 = int32
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 return; 1331 return;
1332 } 1332 }
1333 // Number x Number => Float64Mul 1333 // Number x Number => Float64Mul
1334 if (BothInputsAre(node, Type::NumberOrUndefined())) { 1334 if (BothInputsAre(node, Type::NumberOrUndefined())) {
1335 VisitFloat64Binop(node); 1335 VisitFloat64Binop(node);
1336 if (lower()) ChangeToPureOp(node, Float64Op(node)); 1336 if (lower()) ChangeToPureOp(node, Float64Op(node));
1337 return; 1337 return;
1338 } 1338 }
1339 // Checked float64 x float64 => float64 1339 // Checked float64 x float64 => float64
1340 DCHECK_EQ(IrOpcode::kSpeculativeNumberMultiply, node->opcode()); 1340 DCHECK_EQ(IrOpcode::kSpeculativeNumberMultiply, node->opcode());
1341 VisitBinop(node, UseInfo::CheckedNumberOrUndefinedAsFloat64(), 1341 VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(),
1342 MachineRepresentation::kFloat64, Type::Number()); 1342 MachineRepresentation::kFloat64, Type::Number());
1343 if (lower()) ChangeToPureOp(node, Float64Op(node)); 1343 if (lower()) ChangeToPureOp(node, Float64Op(node));
1344 return; 1344 return;
1345 } 1345 }
1346 case IrOpcode::kSpeculativeNumberDivide: { 1346 case IrOpcode::kSpeculativeNumberDivide: {
1347 if (BothInputsAreUnsigned32(node) && truncation.TruncatesToWord32()) { 1347 if (BothInputsAreUnsigned32(node) && truncation.TruncatesToWord32()) {
1348 // => unsigned Uint32Div 1348 // => unsigned Uint32Div
1349 VisitWord32TruncatingBinop(node); 1349 VisitWord32TruncatingBinop(node);
1350 if (lower()) DeferReplacement(node, lowering->Uint32Div(node)); 1350 if (lower()) DeferReplacement(node, lowering->Uint32Div(node));
1351 return; 1351 return;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 if (lower()) DeferReplacement(node, lowering->Int32Div(node)); 1402 if (lower()) DeferReplacement(node, lowering->Int32Div(node));
1403 } else { 1403 } else {
1404 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(), 1404 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(),
1405 MachineRepresentation::kWord32, Type::Signed32()); 1405 MachineRepresentation::kWord32, Type::Signed32());
1406 if (lower()) ChangeToInt32OverflowOp(node); 1406 if (lower()) ChangeToInt32OverflowOp(node);
1407 } 1407 }
1408 return; 1408 return;
1409 } 1409 }
1410 1410
1411 // default case => Float64Div 1411 // default case => Float64Div
1412 VisitBinop(node, UseInfo::CheckedNumberOrUndefinedAsFloat64(), 1412 VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(),
1413 MachineRepresentation::kFloat64, Type::Number()); 1413 MachineRepresentation::kFloat64, Type::Number());
1414 if (lower()) ChangeToPureOp(node, Float64Op(node)); 1414 if (lower()) ChangeToPureOp(node, Float64Op(node));
1415 return; 1415 return;
1416 } 1416 }
1417 case IrOpcode::kNumberDivide: { 1417 case IrOpcode::kNumberDivide: {
1418 if (BothInputsAreUnsigned32(node) && truncation.TruncatesToWord32()) { 1418 if (BothInputsAreUnsigned32(node) && truncation.TruncatesToWord32()) {
1419 // => unsigned Uint32Div 1419 // => unsigned Uint32Div
1420 VisitWord32TruncatingBinop(node); 1420 VisitWord32TruncatingBinop(node);
1421 if (lower()) DeferReplacement(node, lowering->Uint32Div(node)); 1421 if (lower()) DeferReplacement(node, lowering->Uint32Div(node));
1422 return; 1422 return;
(...skipping 13 matching lines...) Expand all
1436 } 1436 }
1437 } 1437 }
1438 // Number x Number => Float64Div 1438 // Number x Number => Float64Div
1439 if (BothInputsAre(node, Type::NumberOrUndefined())) { 1439 if (BothInputsAre(node, Type::NumberOrUndefined())) {
1440 VisitFloat64Binop(node); 1440 VisitFloat64Binop(node);
1441 if (lower()) ChangeToPureOp(node, Float64Op(node)); 1441 if (lower()) ChangeToPureOp(node, Float64Op(node));
1442 return; 1442 return;
1443 } 1443 }
1444 // Checked float64 x float64 => float64 1444 // Checked float64 x float64 => float64
1445 DCHECK_EQ(IrOpcode::kSpeculativeNumberDivide, node->opcode()); 1445 DCHECK_EQ(IrOpcode::kSpeculativeNumberDivide, node->opcode());
1446 VisitBinop(node, UseInfo::CheckedNumberOrUndefinedAsFloat64(), 1446 VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(),
1447 MachineRepresentation::kFloat64, Type::Number()); 1447 MachineRepresentation::kFloat64, Type::Number());
1448 if (lower()) ChangeToPureOp(node, Float64Op(node)); 1448 if (lower()) ChangeToPureOp(node, Float64Op(node));
1449 return; 1449 return;
1450 } 1450 }
1451 case IrOpcode::kSpeculativeNumberModulus: { 1451 case IrOpcode::kSpeculativeNumberModulus: {
1452 if (BothInputsAreUnsigned32(node) && truncation.TruncatesToWord32()) { 1452 if (BothInputsAreUnsigned32(node) && truncation.TruncatesToWord32()) {
1453 // => unsigned Uint32Mod 1453 // => unsigned Uint32Mod
1454 VisitWord32TruncatingBinop(node); 1454 VisitWord32TruncatingBinop(node);
1455 if (lower()) DeferReplacement(node, lowering->Uint32Mod(node)); 1455 if (lower()) DeferReplacement(node, lowering->Uint32Mod(node));
1456 return; 1456 return;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 if (lower()) DeferReplacement(node, lowering->Int32Mod(node)); 1507 if (lower()) DeferReplacement(node, lowering->Int32Mod(node));
1508 } else { 1508 } else {
1509 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(), 1509 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(),
1510 MachineRepresentation::kWord32, Type::Signed32()); 1510 MachineRepresentation::kWord32, Type::Signed32());
1511 if (lower()) ChangeToInt32OverflowOp(node); 1511 if (lower()) ChangeToInt32OverflowOp(node);
1512 } 1512 }
1513 return; 1513 return;
1514 } 1514 }
1515 1515
1516 // default case => Float64Mod 1516 // default case => Float64Mod
1517 VisitBinop(node, UseInfo::CheckedNumberOrUndefinedAsFloat64(), 1517 VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(),
1518 MachineRepresentation::kFloat64, Type::Number()); 1518 MachineRepresentation::kFloat64, Type::Number());
1519 if (lower()) ChangeToPureOp(node, Float64Op(node)); 1519 if (lower()) ChangeToPureOp(node, Float64Op(node));
1520 return; 1520 return;
1521 } 1521 }
1522 case IrOpcode::kNumberModulus: { 1522 case IrOpcode::kNumberModulus: {
1523 if (BothInputsAreUnsigned32(node) && truncation.TruncatesToWord32()) { 1523 if (BothInputsAreUnsigned32(node) && truncation.TruncatesToWord32()) {
1524 // => unsigned Uint32Mod 1524 // => unsigned Uint32Mod
1525 VisitWord32TruncatingBinop(node); 1525 VisitWord32TruncatingBinop(node);
1526 if (lower()) DeferReplacement(node, lowering->Uint32Mod(node)); 1526 if (lower()) DeferReplacement(node, lowering->Uint32Mod(node));
1527 return; 1527 return;
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1962 return; 1962 return;
1963 } 1963 }
1964 case IrOpcode::kPlainPrimitiveToNumber: { 1964 case IrOpcode::kPlainPrimitiveToNumber: {
1965 if (InputIs(node, Type::Boolean())) { 1965 if (InputIs(node, Type::Boolean())) {
1966 VisitUnop(node, UseInfo::Bool(), MachineRepresentation::kWord32); 1966 VisitUnop(node, UseInfo::Bool(), MachineRepresentation::kWord32);
1967 if (lower()) DeferReplacement(node, node->InputAt(0)); 1967 if (lower()) DeferReplacement(node, node->InputAt(0));
1968 } else if (InputIs(node, Type::String())) { 1968 } else if (InputIs(node, Type::String())) {
1969 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged); 1969 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged);
1970 if (lower()) lowering->DoStringToNumber(node); 1970 if (lower()) lowering->DoStringToNumber(node);
1971 } else if (truncation.TruncatesToWord32()) { 1971 } else if (truncation.TruncatesToWord32()) {
1972 // TODO(jarin): Extend this to Number \/ Oddball 1972 if (InputIs(node, Type::NumberOrOddball())) {
1973 if (InputIs(node, Type::NumberOrUndefined())) {
1974 VisitUnop(node, UseInfo::TruncatingWord32(), 1973 VisitUnop(node, UseInfo::TruncatingWord32(),
1975 MachineRepresentation::kWord32); 1974 MachineRepresentation::kWord32);
1976 if (lower()) DeferReplacement(node, node->InputAt(0)); 1975 if (lower()) DeferReplacement(node, node->InputAt(0));
1977 } else { 1976 } else {
1978 VisitUnop(node, UseInfo::AnyTagged(), 1977 VisitUnop(node, UseInfo::AnyTagged(),
1979 MachineRepresentation::kWord32); 1978 MachineRepresentation::kWord32);
1980 if (lower()) { 1979 if (lower()) {
1981 NodeProperties::ChangeOp(node, 1980 NodeProperties::ChangeOp(node,
1982 simplified()->PlainPrimitiveToWord32()); 1981 simplified()->PlainPrimitiveToWord32());
1983 } 1982 }
1984 } 1983 }
1985 } else if (truncation.TruncatesToFloat64()) { 1984 } else if (truncation.TruncatesToFloat64()) {
1986 // TODO(jarin): Extend this to Number \/ Oddball 1985 if (InputIs(node, Type::NumberOrOddball())) {
1987 if (InputIs(node, Type::NumberOrUndefined())) {
1988 VisitUnop(node, UseInfo::TruncatingFloat64(), 1986 VisitUnop(node, UseInfo::TruncatingFloat64(),
1989 MachineRepresentation::kFloat64); 1987 MachineRepresentation::kFloat64);
1990 if (lower()) DeferReplacement(node, node->InputAt(0)); 1988 if (lower()) DeferReplacement(node, node->InputAt(0));
1991 } else { 1989 } else {
1992 VisitUnop(node, UseInfo::AnyTagged(), 1990 VisitUnop(node, UseInfo::AnyTagged(),
1993 MachineRepresentation::kFloat64); 1991 MachineRepresentation::kFloat64);
1994 if (lower()) { 1992 if (lower()) {
1995 NodeProperties::ChangeOp(node, 1993 NodeProperties::ChangeOp(node,
1996 simplified()->PlainPrimitiveToFloat64()); 1994 simplified()->PlainPrimitiveToFloat64());
1997 } 1995 }
(...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after
3271 isolate(), graph()->zone(), callable.descriptor(), 0, flags, 3269 isolate(), graph()->zone(), callable.descriptor(), 0, flags,
3272 Operator::kNoProperties); 3270 Operator::kNoProperties);
3273 to_number_operator_.set(common()->Call(desc)); 3271 to_number_operator_.set(common()->Call(desc));
3274 } 3272 }
3275 return to_number_operator_.get(); 3273 return to_number_operator_.get();
3276 } 3274 }
3277 3275
3278 } // namespace compiler 3276 } // namespace compiler
3279 } // namespace internal 3277 } // namespace internal
3280 } // namespace v8 3278 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/representation-change.cc ('k') | src/compiler/type-hint-analyzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698