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

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

Issue 2797993006: [turbofan] Add type to the allocation operator. (Closed)
Patch Set: Rename Created 3 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
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/compiler/types.h" 10 #include "src/compiler/types.h"
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 op->opcode() == IrOpcode::kSpeculativeNumberShiftRightLogical || 381 op->opcode() == IrOpcode::kSpeculativeNumberShiftRightLogical ||
382 op->opcode() == IrOpcode::kSpeculativeNumberBitwiseAnd || 382 op->opcode() == IrOpcode::kSpeculativeNumberBitwiseAnd ||
383 op->opcode() == IrOpcode::kSpeculativeNumberBitwiseOr || 383 op->opcode() == IrOpcode::kSpeculativeNumberBitwiseOr ||
384 op->opcode() == IrOpcode::kSpeculativeNumberBitwiseXor || 384 op->opcode() == IrOpcode::kSpeculativeNumberBitwiseXor ||
385 op->opcode() == IrOpcode::kSpeculativeNumberEqual || 385 op->opcode() == IrOpcode::kSpeculativeNumberEqual ||
386 op->opcode() == IrOpcode::kSpeculativeNumberLessThan || 386 op->opcode() == IrOpcode::kSpeculativeNumberLessThan ||
387 op->opcode() == IrOpcode::kSpeculativeNumberLessThanOrEqual); 387 op->opcode() == IrOpcode::kSpeculativeNumberLessThanOrEqual);
388 return OpParameter<NumberOperationHint>(op); 388 return OpParameter<NumberOperationHint>(op);
389 } 389 }
390 390
391 size_t hash_value(AllocationParameters info) {
392 return base::hash_combine(info.type, info.pretenure);
393 }
394
395 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
396 AllocationParameters info) {
397 info.type->PrintTo(os);
398 return os << ", " << info.pretenure;
399 }
400
401 bool operator==(AllocationParameters const& lhs,
402 AllocationParameters const& rhs) {
403 return lhs.pretenure == rhs.pretenure && lhs.type == rhs.type;
404 }
405
406 bool operator!=(AllocationParameters const& lhs,
407 AllocationParameters const& rhs) {
408 return !(lhs == rhs);
409 }
410
391 PretenureFlag PretenureFlagOf(const Operator* op) { 411 PretenureFlag PretenureFlagOf(const Operator* op) {
392 DCHECK_EQ(IrOpcode::kAllocate, op->opcode()); 412 DCHECK_EQ(IrOpcode::kAllocate, op->opcode());
393 return OpParameter<PretenureFlag>(op); 413 return OpParameter<AllocationParameters>(op).pretenure;
414 }
415
416 Type* AllocateTypeOf(const Operator* op) {
417 DCHECK_EQ(IrOpcode::kAllocate, op->opcode());
418 return OpParameter<AllocationParameters>(op).type;
394 } 419 }
395 420
396 UnicodeEncoding UnicodeEncodingOf(const Operator* op) { 421 UnicodeEncoding UnicodeEncodingOf(const Operator* op) {
397 DCHECK(op->opcode() == IrOpcode::kStringFromCodePoint); 422 DCHECK(op->opcode() == IrOpcode::kStringFromCodePoint);
398 return OpParameter<UnicodeEncoding>(op); 423 return OpParameter<UnicodeEncoding>(op);
399 } 424 }
400 425
401 #define PURE_OP_LIST(V) \ 426 #define PURE_OP_LIST(V) \
402 V(BooleanNot, Operator::kNoProperties, 1, 0) \ 427 V(BooleanNot, Operator::kNoProperties, 1, 0) \
403 V(NumberEqual, Operator::kCommutative, 2, 0) \ 428 V(NumberEqual, Operator::kCommutative, 2, 0) \
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 : Operator1<CheckFloat64HoleMode>( 664 : Operator1<CheckFloat64HoleMode>(
640 IrOpcode::kCheckFloat64Hole, 665 IrOpcode::kCheckFloat64Hole,
641 Operator::kFoldable | Operator::kNoThrow, "CheckFloat64Hole", 1, 666 Operator::kFoldable | Operator::kNoThrow, "CheckFloat64Hole", 1,
642 1, 1, 1, 1, 0, kMode) {} 667 1, 1, 1, 1, 0, kMode) {}
643 }; 668 };
644 CheckFloat64HoleNaNOperator<CheckFloat64HoleMode::kAllowReturnHole> 669 CheckFloat64HoleNaNOperator<CheckFloat64HoleMode::kAllowReturnHole>
645 kCheckFloat64HoleAllowReturnHoleOperator; 670 kCheckFloat64HoleAllowReturnHoleOperator;
646 CheckFloat64HoleNaNOperator<CheckFloat64HoleMode::kNeverReturnHole> 671 CheckFloat64HoleNaNOperator<CheckFloat64HoleMode::kNeverReturnHole>
647 kCheckFloat64HoleNeverReturnHoleOperator; 672 kCheckFloat64HoleNeverReturnHoleOperator;
648 673
649 template <PretenureFlag kPretenure> 674 struct AllocateOperator : public Operator1<AllocationParameters> {
650 struct AllocateOperator final : public Operator1<PretenureFlag> { 675 AllocateOperator(Type* type, PretenureFlag pretenure)
651 AllocateOperator() 676 : Operator1<AllocationParameters>(
652 : Operator1<PretenureFlag>(
653 IrOpcode::kAllocate, 677 IrOpcode::kAllocate,
654 Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, 678 Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite,
655 "Allocate", 1, 1, 1, 1, 1, 0, kPretenure) {} 679 "Allocate", 1, 1, 1, 1, 1, 0,
680 AllocationParameters(type, pretenure)) {}
656 }; 681 };
657 AllocateOperator<NOT_TENURED> kAllocateNotTenuredOperator; 682
658 AllocateOperator<TENURED> kAllocateTenuredOperator; 683 template <PretenureFlag kPretenure>
684 struct AllocateTypeAnyOperator final : public AllocateOperator {
685 AllocateTypeAnyOperator() : AllocateOperator(Type::Any(), kPretenure) {}
686 };
687
688 AllocateTypeAnyOperator<NOT_TENURED> kAllocateNotTenuredTypeAnyOperator;
689 AllocateTypeAnyOperator<TENURED> kAllocateTenuredTypeAnyOperator;
659 690
660 struct EnsureWritableFastElementsOperator final : public Operator { 691 struct EnsureWritableFastElementsOperator final : public Operator {
661 EnsureWritableFastElementsOperator() 692 EnsureWritableFastElementsOperator()
662 : Operator( // -- 693 : Operator( // --
663 IrOpcode::kEnsureWritableFastElements, // opcode 694 IrOpcode::kEnsureWritableFastElements, // opcode
664 Operator::kNoDeopt | Operator::kNoThrow, // flags 695 Operator::kNoDeopt | Operator::kNoThrow, // flags
665 "EnsureWritableFastElements", // name 696 "EnsureWritableFastElements", // name
666 2, 1, 1, 1, 1, 0) {} // counts 697 2, 1, 1, 1, 1, 0) {} // counts
667 }; 698 };
668 EnsureWritableFastElementsOperator kEnsureWritableFastElements; 699 EnsureWritableFastElementsOperator kEnsureWritableFastElements;
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 int FormalParameterCountOf(const Operator* op) { 888 int FormalParameterCountOf(const Operator* op) {
858 DCHECK(op->opcode() == IrOpcode::kArgumentsLength); 889 DCHECK(op->opcode() == IrOpcode::kArgumentsLength);
859 return OpParameter<ArgumentsLengthParameters>(op).formal_parameter_count; 890 return OpParameter<ArgumentsLengthParameters>(op).formal_parameter_count;
860 } 891 }
861 892
862 bool IsRestLengthOf(const Operator* op) { 893 bool IsRestLengthOf(const Operator* op) {
863 DCHECK(op->opcode() == IrOpcode::kArgumentsLength); 894 DCHECK(op->opcode() == IrOpcode::kArgumentsLength);
864 return OpParameter<ArgumentsLengthParameters>(op).is_rest_length; 895 return OpParameter<ArgumentsLengthParameters>(op).is_rest_length;
865 } 896 }
866 897
867 const Operator* SimplifiedOperatorBuilder::Allocate(PretenureFlag pretenure) { 898 const Operator* SimplifiedOperatorBuilder::Allocate(Type* type,
868 switch (pretenure) { 899 PretenureFlag pretenure) {
869 case NOT_TENURED: 900 if (Type::Any()->Is(type)) {
Benedikt Meurer 2017/04/06 12:08:05 I'd rather remove the caching completely. We don't
Jarin 2017/04/06 15:11:29 Done.
870 return &cache_.kAllocateNotTenuredOperator; 901 switch (pretenure) {
871 case TENURED: 902 case NOT_TENURED:
872 return &cache_.kAllocateTenuredOperator; 903 return &cache_.kAllocateNotTenuredTypeAnyOperator;
904 case TENURED:
905 return &cache_.kAllocateTenuredTypeAnyOperator;
906 }
907 UNREACHABLE();
873 } 908 }
874 UNREACHABLE(); 909 return new (zone())
875 return nullptr; 910 SimplifiedOperatorGlobalCache::AllocateOperator(type, pretenure);
876 } 911 }
877 912
878 913
879 const Operator* SimplifiedOperatorBuilder::LoadBuffer(BufferAccess access) { 914 const Operator* SimplifiedOperatorBuilder::LoadBuffer(BufferAccess access) {
880 switch (access.external_array_type()) { 915 switch (access.external_array_type()) {
881 #define LOAD_BUFFER(Type, type, TYPE, ctype, size) \ 916 #define LOAD_BUFFER(Type, type, TYPE, ctype, size) \
882 case kExternal##Type##Array: \ 917 case kExternal##Type##Array: \
883 return &cache_.kLoadBuffer##Type; 918 return &cache_.kLoadBuffer##Type;
884 TYPED_ARRAYS(LOAD_BUFFER) 919 TYPED_ARRAYS(LOAD_BUFFER)
885 #undef LOAD_BUFFER 920 #undef LOAD_BUFFER
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 Operator::kNoDeopt | Operator::kNoThrow | properties, \ 982 Operator::kNoDeopt | Operator::kNoThrow | properties, \
948 #Name, value_input_count, 1, control_input_count, \ 983 #Name, value_input_count, 1, control_input_count, \
949 output_count, 1, 0, access); \ 984 output_count, 1, 0, access); \
950 } 985 }
951 ACCESS_OP_LIST(ACCESS) 986 ACCESS_OP_LIST(ACCESS)
952 #undef ACCESS 987 #undef ACCESS
953 988
954 } // namespace compiler 989 } // namespace compiler
955 } // namespace internal 990 } // namespace internal
956 } // namespace v8 991 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698