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

Side by Side Diff: src/compiler/effect-control-linearizer.cc

Issue 2233713002: [turbofan] Fix CheckedInt32Mod lowering. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Update. Created 4 years, 4 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 | « no previous file | test/mjsunit/compiler/regress-5278.js » ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/effect-control-linearizer.h" 5 #include "src/compiler/effect-control-linearizer.h"
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/compiler/access-builder.h" 8 #include "src/compiler/access-builder.h"
9 #include "src/compiler/js-graph.h" 9 #include "src/compiler/js-graph.h"
10 #include "src/compiler/linkage.h" 10 #include "src/compiler/linkage.h"
(...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 common()->DeoptimizeUnless(DeoptimizeReason::kLostPrecision), check, 1300 common()->DeoptimizeUnless(DeoptimizeReason::kLostPrecision), check,
1301 frame_state, effect, control); 1301 frame_state, effect, control);
1302 1302
1303 return ValueEffectControl(value, effect, control); 1303 return ValueEffectControl(value, effect, control);
1304 } 1304 }
1305 1305
1306 EffectControlLinearizer::ValueEffectControl 1306 EffectControlLinearizer::ValueEffectControl
1307 EffectControlLinearizer::LowerCheckedInt32Mod(Node* node, Node* frame_state, 1307 EffectControlLinearizer::LowerCheckedInt32Mod(Node* node, Node* frame_state,
1308 Node* effect, Node* control) { 1308 Node* effect, Node* control) {
1309 Node* zero = jsgraph()->Int32Constant(0); 1309 Node* zero = jsgraph()->Int32Constant(0);
1310 Node* one = jsgraph()->Int32Constant(1);
1310 Node* minusone = jsgraph()->Int32Constant(-1); 1311 Node* minusone = jsgraph()->Int32Constant(-1);
1311 Node* minint = jsgraph()->Int32Constant(std::numeric_limits<int32_t>::min());
1312 1312
1313 // General case for signed integer modulus, with optimization for (unknown) 1313 // General case for signed integer modulus, with optimization for (unknown)
1314 // power of 2 right hand side. 1314 // power of 2 right hand side.
1315 // 1315 //
1316 // if 0 < rhs then 1316 // if 1 < rhs then
1317 // msk = rhs - 1 1317 // msk = rhs - 1
1318 // if rhs & msk == 0 then 1318 // if rhs & msk == 0 then
1319 // if lhs < 0 then 1319 // if lhs < 0 then
1320 // -(-lhs & msk) 1320 // -(-lhs & msk)
1321 // else 1321 // else
1322 // lhs & msk 1322 // lhs & msk
1323 // else 1323 // else
1324 // lhs % rhs 1324 // lhs % rhs
1325 // else 1325 // else
1326 // if rhs < -1 then 1326 // if rhs < -1 then
1327 // lhs % rhs 1327 // lhs % rhs
1328 // else 1328 // else
1329 // deopt if rhs == 0 1329 // deopt if rhs == 0
1330 // deopt if lhs == minint 1330 // deopt if lhs < 0
1331 // zero 1331 // zero
1332 // 1332 //
1333 Node* lhs = node->InputAt(0); 1333 Node* lhs = node->InputAt(0);
1334 Node* rhs = node->InputAt(1); 1334 Node* rhs = node->InputAt(1);
1335 1335
1336 // Check if {rhs} is strictly positive. 1336 // Check if {rhs} is strictly greater than one.
1337 Node* check0 = graph()->NewNode(machine()->Int32LessThan(), zero, rhs); 1337 Node* check0 = graph()->NewNode(machine()->Int32LessThan(), one, rhs);
1338 Node* branch0 = 1338 Node* branch0 =
1339 graph()->NewNode(common()->Branch(BranchHint::kTrue), check0, control); 1339 graph()->NewNode(common()->Branch(BranchHint::kTrue), check0, control);
1340 1340
1341 Node* if_true0 = graph()->NewNode(common()->IfTrue(), branch0); 1341 Node* if_true0 = graph()->NewNode(common()->IfTrue(), branch0);
1342 Node* etrue0 = effect; 1342 Node* etrue0 = effect;
1343 Node* vtrue0; 1343 Node* vtrue0;
1344 { 1344 {
1345 Node* msk = graph()->NewNode(machine()->Int32Add(), rhs, minusone); 1345 Node* msk = graph()->NewNode(machine()->Int32Add(), rhs, minusone);
1346 1346
1347 // Check if {rhs} minus one is a valid mask. 1347 // Check if {rhs} minus one is a valid mask.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1); 1403 Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1);
1404 Node* efalse1 = efalse0; 1404 Node* efalse1 = efalse0;
1405 Node* vfalse1; 1405 Node* vfalse1;
1406 { 1406 {
1407 // Ensure that {rhs} is not zero. 1407 // Ensure that {rhs} is not zero.
1408 Node* check2 = graph()->NewNode(machine()->Word32Equal(), rhs, zero); 1408 Node* check2 = graph()->NewNode(machine()->Word32Equal(), rhs, zero);
1409 if_false1 = efalse1 = graph()->NewNode( 1409 if_false1 = efalse1 = graph()->NewNode(
1410 common()->DeoptimizeIf(DeoptimizeReason::kDivisionByZero), check2, 1410 common()->DeoptimizeIf(DeoptimizeReason::kDivisionByZero), check2,
1411 frame_state, efalse1, if_false1); 1411 frame_state, efalse1, if_false1);
1412 1412
1413 // Now we know that {rhs} is -1, so make sure {lhs} is not kMinInt, as 1413 // Now we know that {rhs} is -1, so make sure {lhs} is >= 0, as we would
1414 // we would otherwise have to return -0. 1414 // otherwise have to return -0.
1415 Node* check3 = graph()->NewNode(machine()->Word32Equal(), lhs, minint); 1415 Node* check3 = graph()->NewNode(machine()->Int32LessThan(), lhs, zero);
1416 if_false1 = efalse1 = 1416 if_false1 = efalse1 =
1417 graph()->NewNode(common()->DeoptimizeIf(DeoptimizeReason::kMinusZero), 1417 graph()->NewNode(common()->DeoptimizeIf(DeoptimizeReason::kMinusZero),
1418 check3, frame_state, efalse1, if_false1); 1418 check3, frame_state, efalse1, if_false1);
1419 1419
1420 // The remainder is zero. 1420 // The remainder is zero.
1421 vfalse1 = zero; 1421 vfalse1 = zero;
1422 } 1422 }
1423 1423
1424 if_false0 = graph()->NewNode(common()->Merge(2), if_true1, if_false1); 1424 if_false0 = graph()->NewNode(common()->Merge(2), if_true1, if_false1);
1425 efalse0 = 1425 efalse0 =
(...skipping 1863 matching lines...) Expand 10 before | Expand all | Expand 10 after
3289 isolate(), graph()->zone(), callable.descriptor(), 0, flags, 3289 isolate(), graph()->zone(), callable.descriptor(), 0, flags,
3290 Operator::kNoThrow); 3290 Operator::kNoThrow);
3291 to_number_operator_.set(common()->Call(desc)); 3291 to_number_operator_.set(common()->Call(desc));
3292 } 3292 }
3293 return to_number_operator_.get(); 3293 return to_number_operator_.get();
3294 } 3294 }
3295 3295
3296 } // namespace compiler 3296 } // namespace compiler
3297 } // namespace internal 3297 } // namespace internal
3298 } // namespace v8 3298 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/compiler/regress-5278.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698