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

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

Issue 2149493002: [turbofan] Introduce CheckedUint32Div and CheckUint32Mod operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comment 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/effect-control-linearizer.h ('k') | src/compiler/opcodes.h » ('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 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 break; 635 break;
636 case IrOpcode::kCheckedInt32Sub: 636 case IrOpcode::kCheckedInt32Sub:
637 state = LowerCheckedInt32Sub(node, frame_state, *effect, *control); 637 state = LowerCheckedInt32Sub(node, frame_state, *effect, *control);
638 break; 638 break;
639 case IrOpcode::kCheckedInt32Div: 639 case IrOpcode::kCheckedInt32Div:
640 state = LowerCheckedInt32Div(node, frame_state, *effect, *control); 640 state = LowerCheckedInt32Div(node, frame_state, *effect, *control);
641 break; 641 break;
642 case IrOpcode::kCheckedInt32Mod: 642 case IrOpcode::kCheckedInt32Mod:
643 state = LowerCheckedInt32Mod(node, frame_state, *effect, *control); 643 state = LowerCheckedInt32Mod(node, frame_state, *effect, *control);
644 break; 644 break;
645 case IrOpcode::kCheckedUint32Div:
646 state = LowerCheckedUint32Div(node, frame_state, *effect, *control);
647 break;
648 case IrOpcode::kCheckedUint32Mod:
649 state = LowerCheckedUint32Mod(node, frame_state, *effect, *control);
650 break;
645 case IrOpcode::kCheckedUint32ToInt32: 651 case IrOpcode::kCheckedUint32ToInt32:
646 state = LowerCheckedUint32ToInt32(node, frame_state, *effect, *control); 652 state = LowerCheckedUint32ToInt32(node, frame_state, *effect, *control);
647 break; 653 break;
648 case IrOpcode::kCheckedFloat64ToInt32: 654 case IrOpcode::kCheckedFloat64ToInt32:
649 state = LowerCheckedFloat64ToInt32(node, frame_state, *effect, *control); 655 state = LowerCheckedFloat64ToInt32(node, frame_state, *effect, *control);
650 break; 656 break;
651 case IrOpcode::kCheckedTaggedToInt32: 657 case IrOpcode::kCheckedTaggedToInt32:
652 state = LowerCheckedTaggedToInt32(node, frame_state, *effect, *control); 658 state = LowerCheckedTaggedToInt32(node, frame_state, *effect, *control);
653 break; 659 break;
654 case IrOpcode::kCheckedTaggedToFloat64: 660 case IrOpcode::kCheckedTaggedToFloat64:
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 control = graph()->NewNode(common()->Merge(2), if_true0, if_false0); 1248 control = graph()->NewNode(common()->Merge(2), if_true0, if_false0);
1243 effect = graph()->NewNode(common()->EffectPhi(2), etrue0, efalse0, control); 1249 effect = graph()->NewNode(common()->EffectPhi(2), etrue0, efalse0, control);
1244 Node* value = 1250 Node* value =
1245 graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), vtrue0, 1251 graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), vtrue0,
1246 vfalse0, control); 1252 vfalse0, control);
1247 1253
1248 return ValueEffectControl(value, effect, control); 1254 return ValueEffectControl(value, effect, control);
1249 } 1255 }
1250 1256
1251 EffectControlLinearizer::ValueEffectControl 1257 EffectControlLinearizer::ValueEffectControl
1258 EffectControlLinearizer::LowerCheckedUint32Div(Node* node, Node* frame_state,
1259 Node* effect, Node* control) {
1260 Node* zero = jsgraph()->Int32Constant(0);
1261
1262 Node* lhs = node->InputAt(0);
1263 Node* rhs = node->InputAt(1);
1264
1265 // Ensure that {rhs} is not zero, otherwise we'd have to return NaN.
1266 Node* check = graph()->NewNode(machine()->Word32Equal(), rhs, zero);
1267 control = effect = graph()->NewNode(common()->DeoptimizeIf(), check,
1268 frame_state, effect, control);
1269
1270 // Perform the actual unsigned integer division.
1271 Node* value = graph()->NewNode(machine()->Uint32Div(), lhs, rhs, control);
1272
1273 // Check if the remainder is non-zero.
1274 check = graph()->NewNode(machine()->Word32Equal(), lhs,
1275 graph()->NewNode(machine()->Int32Mul(), rhs, value));
1276 control = effect = graph()->NewNode(common()->DeoptimizeUnless(), check,
1277 frame_state, effect, control);
1278
1279 return ValueEffectControl(value, effect, control);
1280 }
1281
1282 EffectControlLinearizer::ValueEffectControl
1283 EffectControlLinearizer::LowerCheckedUint32Mod(Node* node, Node* frame_state,
1284 Node* effect, Node* control) {
1285 Node* zero = jsgraph()->Int32Constant(0);
1286
1287 Node* lhs = node->InputAt(0);
1288 Node* rhs = node->InputAt(1);
1289
1290 // Ensure that {rhs} is not zero, otherwise we'd have to return NaN.
1291 Node* check = graph()->NewNode(machine()->Word32Equal(), rhs, zero);
1292 control = effect = graph()->NewNode(common()->DeoptimizeIf(), check,
1293 frame_state, effect, control);
1294
1295 // Perform the actual unsigned integer modulus.
1296 Node* value = graph()->NewNode(machine()->Uint32Mod(), lhs, rhs, control);
1297
1298 return ValueEffectControl(value, effect, control);
1299 }
1300
1301 EffectControlLinearizer::ValueEffectControl
1252 EffectControlLinearizer::LowerCheckedUint32ToInt32(Node* node, 1302 EffectControlLinearizer::LowerCheckedUint32ToInt32(Node* node,
1253 Node* frame_state, 1303 Node* frame_state,
1254 Node* effect, 1304 Node* effect,
1255 Node* control) { 1305 Node* control) {
1256 Node* value = node->InputAt(0); 1306 Node* value = node->InputAt(0);
1257 Node* max_int = jsgraph()->Int32Constant(std::numeric_limits<int32_t>::max()); 1307 Node* max_int = jsgraph()->Int32Constant(std::numeric_limits<int32_t>::max());
1258 Node* is_safe = 1308 Node* is_safe =
1259 graph()->NewNode(machine()->Uint32LessThanOrEqual(), value, max_int); 1309 graph()->NewNode(machine()->Uint32LessThanOrEqual(), value, max_int);
1260 control = effect = graph()->NewNode(common()->DeoptimizeUnless(), is_safe, 1310 control = effect = graph()->NewNode(common()->DeoptimizeUnless(), is_safe,
1261 frame_state, effect, control); 1311 frame_state, effect, control);
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
2010 isolate(), graph()->zone(), callable.descriptor(), 0, flags, 2060 isolate(), graph()->zone(), callable.descriptor(), 0, flags,
2011 Operator::kNoThrow); 2061 Operator::kNoThrow);
2012 to_number_operator_.set(common()->Call(desc)); 2062 to_number_operator_.set(common()->Call(desc));
2013 } 2063 }
2014 return to_number_operator_.get(); 2064 return to_number_operator_.get();
2015 } 2065 }
2016 2066
2017 } // namespace compiler 2067 } // namespace compiler
2018 } // namespace internal 2068 } // namespace internal
2019 } // namespace v8 2069 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/effect-control-linearizer.h ('k') | src/compiler/opcodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698