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

Side by Side Diff: src/compiler/js-typed-lowering.cc

Issue 1102923002: [strong] Disallow implicit conversions for bitwise ops, shifts (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: cl feedback 2 Created 5 years, 8 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/builtins.h ('k') | src/ic/ic.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/code-factory.h" 5 #include "src/code-factory.h"
6 #include "src/compiler/access-builder.h" 6 #include "src/compiler/access-builder.h"
7 #include "src/compiler/js-graph.h" 7 #include "src/compiler/js-graph.h"
8 #include "src/compiler/js-typed-lowering.h" 8 #include "src/compiler/js-typed-lowering.h"
9 #include "src/compiler/linkage.h" 9 #include "src/compiler/linkage.h"
10 #include "src/compiler/node-matchers.h" 10 #include "src/compiler/node-matchers.h"
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 } 340 }
341 #endif 341 #endif
342 return NoChange(); 342 return NoChange();
343 } 343 }
344 344
345 345
346 Reduction JSTypedLowering::ReduceNumberBinop(Node* node, 346 Reduction JSTypedLowering::ReduceNumberBinop(Node* node,
347 const Operator* numberOp) { 347 const Operator* numberOp) {
348 JSBinopReduction r(this, node); 348 JSBinopReduction r(this, node);
349 if (is_strong(OpParameter<LanguageMode>(node))) { 349 if (is_strong(OpParameter<LanguageMode>(node))) {
350 if (r.left_type()->Is(Type::Number()) && 350 if (r.BothInputsAre(Type::Number())) {
351 (r.right_type()->Is(Type::Number()))) {
352 return r.ChangeToPureOperator(numberOp, Type::Number()); 351 return r.ChangeToPureOperator(numberOp, Type::Number());
353 } 352 }
354 return NoChange(); 353 return NoChange();
355 } 354 }
356 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1); 355 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1);
357 r.ConvertInputsToNumber(frame_state); 356 r.ConvertInputsToNumber(frame_state);
358 return r.ChangeToPureOperator(numberOp, Type::Number()); 357 return r.ChangeToPureOperator(numberOp, Type::Number());
359 } 358 }
360 359
361 360
362 Reduction JSTypedLowering::ReduceInt32Binop(Node* node, const Operator* intOp) { 361 Reduction JSTypedLowering::ReduceInt32Binop(Node* node, const Operator* intOp) {
363 JSBinopReduction r(this, node); 362 JSBinopReduction r(this, node);
363 if (is_strong(OpParameter<LanguageMode>(node))) {
364 if (r.BothInputsAre(Type::Number())) {
365 r.ConvertInputsToUI32(kSigned, kSigned);
366 return r.ChangeToPureOperator(intOp, Type::Integral32());
367 }
368 return NoChange();
369 }
364 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1); 370 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1);
365 r.ConvertInputsToNumber(frame_state); 371 r.ConvertInputsToNumber(frame_state);
366 r.ConvertInputsToUI32(kSigned, kSigned); 372 r.ConvertInputsToUI32(kSigned, kSigned);
367 return r.ChangeToPureOperator(intOp, Type::Integral32()); 373 return r.ChangeToPureOperator(intOp, Type::Integral32());
368 } 374 }
369 375
370 376
371 Reduction JSTypedLowering::ReduceUI32Shift(Node* node, 377 Reduction JSTypedLowering::ReduceUI32Shift(Node* node,
372 Signedness left_signedness, 378 Signedness left_signedness,
373 const Operator* shift_op) { 379 const Operator* shift_op) {
374 JSBinopReduction r(this, node); 380 JSBinopReduction r(this, node);
375 if (r.BothInputsAre(Type::Primitive())) { 381 Type* reduce_type = is_strong(
382 OpParameter<LanguageMode>(node)) ? Type::Number() :
383 Type::Primitive();
384 if (r.BothInputsAre(reduce_type)) {
376 r.ConvertInputsForShift(left_signedness); 385 r.ConvertInputsForShift(left_signedness);
377 return r.ChangeToPureOperator(shift_op, Type::Integral32()); 386 return r.ChangeToPureOperator(shift_op, Type::Integral32());
378 } 387 }
379 return NoChange(); 388 return NoChange();
380 } 389 }
381 390
382 391
383 Reduction JSTypedLowering::ReduceJSComparison(Node* node) { 392 Reduction JSTypedLowering::ReduceJSComparison(Node* node) {
384 JSBinopReduction r(this, node); 393 JSBinopReduction r(this, node);
385 if (r.BothInputsAre(Type::String())) { 394 if (r.BothInputsAre(Type::String())) {
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 } 1177 }
1169 1178
1170 1179
1171 MachineOperatorBuilder* JSTypedLowering::machine() const { 1180 MachineOperatorBuilder* JSTypedLowering::machine() const {
1172 return jsgraph()->machine(); 1181 return jsgraph()->machine();
1173 } 1182 }
1174 1183
1175 } // namespace compiler 1184 } // namespace compiler
1176 } // namespace internal 1185 } // namespace internal
1177 } // namespace v8 1186 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins.h ('k') | src/ic/ic.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698