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

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

Issue 2154073002: [Turbofan]: Eliminate the check for -0 if it's not possible/observable. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixes. 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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-operator.h" 5 #include "src/compiler/simplified-operator.h"
6 6
7 #include "src/base/lazy-instance.h" 7 #include "src/base/lazy-instance.h"
8 #include "src/compiler/opcodes.h" 8 #include "src/compiler/opcodes.h"
9 #include "src/compiler/operator.h" 9 #include "src/compiler/operator.h"
10 #include "src/types.h" 10 #include "src/types.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } 194 }
195 UNREACHABLE(); 195 UNREACHABLE();
196 return os; 196 return os;
197 } 197 }
198 198
199 CheckFloat64HoleMode CheckFloat64HoleModeOf(const Operator* op) { 199 CheckFloat64HoleMode CheckFloat64HoleModeOf(const Operator* op) {
200 DCHECK_EQ(IrOpcode::kCheckFloat64Hole, op->opcode()); 200 DCHECK_EQ(IrOpcode::kCheckFloat64Hole, op->opcode());
201 return OpParameter<CheckFloat64HoleMode>(op); 201 return OpParameter<CheckFloat64HoleMode>(op);
202 } 202 }
203 203
204 CheckForMinusZeroMode CheckMinusZeroModeOf(const Operator* op) {
205 DCHECK_EQ(IrOpcode::kCheckedInt32Mul, op->opcode());
206 return OpParameter<CheckForMinusZeroMode>(op);
207 }
208
209 size_t hash_value(CheckForMinusZeroMode mode) {
210 return static_cast<size_t>(mode);
211 }
212
213 std::ostream& operator<<(std::ostream& os, CheckForMinusZeroMode mode) {
214 switch (mode) {
215 case CheckForMinusZeroMode::kCheckForMinusZero:
216 return os << "check-for-minus-zero";
217 case CheckForMinusZeroMode::kDontCheckForMinusZero:
218 return os << "dont-check-for-minus-zero";
219 }
220 UNREACHABLE();
221 return os;
222 }
223
204 size_t hash_value(CheckTaggedHoleMode mode) { 224 size_t hash_value(CheckTaggedHoleMode mode) {
205 return static_cast<size_t>(mode); 225 return static_cast<size_t>(mode);
206 } 226 }
207 227
208 std::ostream& operator<<(std::ostream& os, CheckTaggedHoleMode mode) { 228 std::ostream& operator<<(std::ostream& os, CheckTaggedHoleMode mode) {
209 switch (mode) { 229 switch (mode) {
210 case CheckTaggedHoleMode::kConvertHoleToUndefined: 230 case CheckTaggedHoleMode::kConvertHoleToUndefined:
211 return os << "convert-hole-to-undefined"; 231 return os << "convert-hole-to-undefined";
212 case CheckTaggedHoleMode::kNeverReturnHole: 232 case CheckTaggedHoleMode::kNeverReturnHole:
213 return os << "never-return-hole"; 233 return os << "never-return-hole";
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 V(CheckIf, 1, 0) \ 347 V(CheckIf, 1, 0) \
328 V(CheckNumber, 1, 1) \ 348 V(CheckNumber, 1, 1) \
329 V(CheckTaggedPointer, 1, 1) \ 349 V(CheckTaggedPointer, 1, 1) \
330 V(CheckTaggedSigned, 1, 1) \ 350 V(CheckTaggedSigned, 1, 1) \
331 V(CheckedInt32Add, 2, 1) \ 351 V(CheckedInt32Add, 2, 1) \
332 V(CheckedInt32Sub, 2, 1) \ 352 V(CheckedInt32Sub, 2, 1) \
333 V(CheckedInt32Div, 2, 1) \ 353 V(CheckedInt32Div, 2, 1) \
334 V(CheckedInt32Mod, 2, 1) \ 354 V(CheckedInt32Mod, 2, 1) \
335 V(CheckedUint32Div, 2, 1) \ 355 V(CheckedUint32Div, 2, 1) \
336 V(CheckedUint32Mod, 2, 1) \ 356 V(CheckedUint32Mod, 2, 1) \
337 V(CheckedInt32Mul, 2, 1) \
338 V(CheckedUint32ToInt32, 1, 1) \ 357 V(CheckedUint32ToInt32, 1, 1) \
339 V(CheckedFloat64ToInt32, 1, 1) \ 358 V(CheckedFloat64ToInt32, 1, 1) \
340 V(CheckedTaggedToInt32, 1, 1) \ 359 V(CheckedTaggedToInt32, 1, 1) \
341 V(CheckedTaggedToFloat64, 1, 1) 360 V(CheckedTaggedToFloat64, 1, 1)
342 361
343 struct SimplifiedOperatorGlobalCache final { 362 struct SimplifiedOperatorGlobalCache final {
344 #define PURE(Name, properties, input_count) \ 363 #define PURE(Name, properties, input_count) \
345 struct Name##Operator final : public Operator { \ 364 struct Name##Operator final : public Operator { \
346 Name##Operator() \ 365 Name##Operator() \
347 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ 366 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \
348 input_count, 0, 0, 1, 0, 0) {} \ 367 input_count, 0, 0, 1, 0, 0) {} \
349 }; \ 368 }; \
350 Name##Operator k##Name; 369 Name##Operator k##Name;
351 PURE_OP_LIST(PURE) 370 PURE_OP_LIST(PURE)
352 #undef PURE 371 #undef PURE
353 372
354 #define CHECKED(Name, value_input_count, value_output_count) \ 373 #define CHECKED(Name, value_input_count, value_output_count) \
355 struct Name##Operator final : public Operator { \ 374 struct Name##Operator final : public Operator { \
356 Name##Operator() \ 375 Name##Operator() \
357 : Operator(IrOpcode::k##Name, \ 376 : Operator(IrOpcode::k##Name, \
358 Operator::kFoldable | Operator::kNoThrow, #Name, \ 377 Operator::kFoldable | Operator::kNoThrow, #Name, \
359 value_input_count, 1, 1, value_output_count, 1, 0) {} \ 378 value_input_count, 1, 1, value_output_count, 1, 0) {} \
360 }; \ 379 }; \
361 Name##Operator k##Name; 380 Name##Operator k##Name;
362 CHECKED_OP_LIST(CHECKED) 381 CHECKED_OP_LIST(CHECKED)
363 #undef CHECKED 382 #undef CHECKED
364 383
384 template <CheckForMinusZeroMode kMode>
385 struct CheckedInt32MulOperator final
386 : public Operator1<CheckForMinusZeroMode> {
387 CheckedInt32MulOperator()
388 : Operator1<CheckForMinusZeroMode>(
389 IrOpcode::kCheckedInt32Mul,
390 Operator::kFoldable | Operator::kNoThrow, "CheckedInt32Mul", 2, 1,
391 1, 1, 1, 0, kMode) {}
392 };
393 CheckedInt32MulOperator<CheckForMinusZeroMode::kCheckForMinusZero>
394 kCheckedInt32MulCheckForMinusZeroOperator;
395 CheckedInt32MulOperator<CheckForMinusZeroMode::kDontCheckForMinusZero>
396 kCheckedInt32MulDontCheckForMinusZeroOperator;
397
365 template <CheckFloat64HoleMode kMode> 398 template <CheckFloat64HoleMode kMode>
366 struct CheckFloat64HoleNaNOperator final 399 struct CheckFloat64HoleNaNOperator final
367 : public Operator1<CheckFloat64HoleMode> { 400 : public Operator1<CheckFloat64HoleMode> {
368 CheckFloat64HoleNaNOperator() 401 CheckFloat64HoleNaNOperator()
369 : Operator1<CheckFloat64HoleMode>( 402 : Operator1<CheckFloat64HoleMode>(
370 IrOpcode::kCheckFloat64Hole, 403 IrOpcode::kCheckFloat64Hole,
371 Operator::kFoldable | Operator::kNoThrow, "CheckFloat64Hole", 1, 404 Operator::kFoldable | Operator::kNoThrow, "CheckFloat64Hole", 1,
372 1, 1, 1, 1, 0, kMode) {} 405 1, 1, 1, 1, 0, kMode) {}
373 }; 406 };
374 CheckFloat64HoleNaNOperator<CheckFloat64HoleMode::kAllowReturnHole> 407 CheckFloat64HoleNaNOperator<CheckFloat64HoleMode::kAllowReturnHole>
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 #define GET_FROM_CACHE(Name, properties, input_count) \ 467 #define GET_FROM_CACHE(Name, properties, input_count) \
435 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; } 468 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; }
436 PURE_OP_LIST(GET_FROM_CACHE) 469 PURE_OP_LIST(GET_FROM_CACHE)
437 #undef GET_FROM_CACHE 470 #undef GET_FROM_CACHE
438 471
439 #define GET_FROM_CACHE(Name, value_input_count, value_output_count) \ 472 #define GET_FROM_CACHE(Name, value_input_count, value_output_count) \
440 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; } 473 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; }
441 CHECKED_OP_LIST(GET_FROM_CACHE) 474 CHECKED_OP_LIST(GET_FROM_CACHE)
442 #undef GET_FROM_CACHE 475 #undef GET_FROM_CACHE
443 476
477 const Operator* SimplifiedOperatorBuilder::CheckedInt32Mul(
478 CheckForMinusZeroMode mode) {
479 switch (mode) {
480 case CheckForMinusZeroMode::kCheckForMinusZero:
481 return &cache_.kCheckedInt32MulCheckForMinusZeroOperator;
482 case CheckForMinusZeroMode::kDontCheckForMinusZero:
483 return &cache_.kCheckedInt32MulDontCheckForMinusZeroOperator;
484 }
485 UNREACHABLE();
486 return nullptr;
487 }
488
444 const Operator* SimplifiedOperatorBuilder::CheckFloat64Hole( 489 const Operator* SimplifiedOperatorBuilder::CheckFloat64Hole(
445 CheckFloat64HoleMode mode) { 490 CheckFloat64HoleMode mode) {
446 switch (mode) { 491 switch (mode) {
447 case CheckFloat64HoleMode::kAllowReturnHole: 492 case CheckFloat64HoleMode::kAllowReturnHole:
448 return &cache_.kCheckFloat64HoleAllowReturnHoleOperator; 493 return &cache_.kCheckFloat64HoleAllowReturnHoleOperator;
449 case CheckFloat64HoleMode::kNeverReturnHole: 494 case CheckFloat64HoleMode::kNeverReturnHole:
450 return &cache_.kCheckFloat64HoleNeverReturnHoleOperator; 495 return &cache_.kCheckFloat64HoleNeverReturnHoleOperator;
451 } 496 }
452 UNREACHABLE(); 497 UNREACHABLE();
453 return nullptr; 498 return nullptr;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 Operator::kNoDeopt | Operator::kNoThrow | properties, \ 601 Operator::kNoDeopt | Operator::kNoThrow | properties, \
557 #Name, value_input_count, 1, control_input_count, \ 602 #Name, value_input_count, 1, control_input_count, \
558 output_count, 1, 0, access); \ 603 output_count, 1, 0, access); \
559 } 604 }
560 ACCESS_OP_LIST(ACCESS) 605 ACCESS_OP_LIST(ACCESS)
561 #undef ACCESS 606 #undef ACCESS
562 607
563 } // namespace compiler 608 } // namespace compiler
564 } // namespace internal 609 } // namespace internal
565 } // namespace v8 610 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698