Chromium Code Reviews| Index: src/compiler/simplified-operator.cc |
| diff --git a/src/compiler/simplified-operator.cc b/src/compiler/simplified-operator.cc |
| index f360c4ac0fe419382b7f34e288c1973e8ccc906f..a5582f3668dd0b2e236ac45cc500e7d5c7bede8f 100644 |
| --- a/src/compiler/simplified-operator.cc |
| +++ b/src/compiler/simplified-operator.cc |
| @@ -388,9 +388,34 @@ NumberOperationHint NumberOperationHintOf(const Operator* op) { |
| return OpParameter<NumberOperationHint>(op); |
| } |
| +size_t hash_value(AllocationParameters info) { |
| + return base::hash_combine(info.type, info.pretenure); |
| +} |
| + |
| +V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, |
| + AllocationParameters info) { |
| + info.type->PrintTo(os); |
| + return os << ", " << info.pretenure; |
| +} |
| + |
| +bool operator==(AllocationParameters const& lhs, |
| + AllocationParameters const& rhs) { |
| + return lhs.pretenure == rhs.pretenure && lhs.type == rhs.type; |
| +} |
| + |
| +bool operator!=(AllocationParameters const& lhs, |
| + AllocationParameters const& rhs) { |
| + return !(lhs == rhs); |
| +} |
| + |
| PretenureFlag PretenureFlagOf(const Operator* op) { |
| DCHECK_EQ(IrOpcode::kAllocate, op->opcode()); |
| - return OpParameter<PretenureFlag>(op); |
| + return OpParameter<AllocationParameters>(op).pretenure; |
| +} |
| + |
| +Type* AllocateTypeOf(const Operator* op) { |
| + DCHECK_EQ(IrOpcode::kAllocate, op->opcode()); |
| + return OpParameter<AllocationParameters>(op).type; |
| } |
| UnicodeEncoding UnicodeEncodingOf(const Operator* op) { |
| @@ -646,16 +671,22 @@ struct SimplifiedOperatorGlobalCache final { |
| CheckFloat64HoleNaNOperator<CheckFloat64HoleMode::kNeverReturnHole> |
| kCheckFloat64HoleNeverReturnHoleOperator; |
| - template <PretenureFlag kPretenure> |
| - struct AllocateOperator final : public Operator1<PretenureFlag> { |
| - AllocateOperator() |
| - : Operator1<PretenureFlag>( |
| + struct AllocateOperator : public Operator1<AllocationParameters> { |
| + AllocateOperator(Type* type, PretenureFlag pretenure) |
| + : Operator1<AllocationParameters>( |
| IrOpcode::kAllocate, |
| Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, |
| - "Allocate", 1, 1, 1, 1, 1, 0, kPretenure) {} |
| + "Allocate", 1, 1, 1, 1, 1, 0, |
| + AllocationParameters(type, pretenure)) {} |
| }; |
| - AllocateOperator<NOT_TENURED> kAllocateNotTenuredOperator; |
| - AllocateOperator<TENURED> kAllocateTenuredOperator; |
| + |
| + template <PretenureFlag kPretenure> |
| + struct AllocateTypeAnyOperator final : public AllocateOperator { |
| + AllocateTypeAnyOperator() : AllocateOperator(Type::Any(), kPretenure) {} |
| + }; |
| + |
| + AllocateTypeAnyOperator<NOT_TENURED> kAllocateNotTenuredTypeAnyOperator; |
| + AllocateTypeAnyOperator<TENURED> kAllocateTenuredTypeAnyOperator; |
| struct EnsureWritableFastElementsOperator final : public Operator { |
| EnsureWritableFastElementsOperator() |
| @@ -864,15 +895,19 @@ bool IsRestLengthOf(const Operator* op) { |
| return OpParameter<ArgumentsLengthParameters>(op).is_rest_length; |
| } |
| -const Operator* SimplifiedOperatorBuilder::Allocate(PretenureFlag pretenure) { |
| - switch (pretenure) { |
| - case NOT_TENURED: |
| - return &cache_.kAllocateNotTenuredOperator; |
| - case TENURED: |
| - return &cache_.kAllocateTenuredOperator; |
| +const Operator* SimplifiedOperatorBuilder::Allocate(Type* type, |
| + PretenureFlag pretenure) { |
| + 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.
|
| + switch (pretenure) { |
| + case NOT_TENURED: |
| + return &cache_.kAllocateNotTenuredTypeAnyOperator; |
| + case TENURED: |
| + return &cache_.kAllocateTenuredTypeAnyOperator; |
| + } |
| + UNREACHABLE(); |
| } |
| - UNREACHABLE(); |
| - return nullptr; |
| + return new (zone()) |
| + SimplifiedOperatorGlobalCache::AllocateOperator(type, pretenure); |
| } |