Index: src/compiler/js-operator.h |
diff --git a/src/compiler/js-operator.h b/src/compiler/js-operator.h |
index cb49ce4a40cd5747ff0241d5a5ffa5c16cfccd02..4142a2b261f95e72dba6ce3ce51181e3e4ecb925 100644 |
--- a/src/compiler/js-operator.h |
+++ b/src/compiler/js-operator.h |
@@ -26,6 +26,37 @@ namespace compiler { |
class Operator; |
struct JSOperatorGlobalCache; |
+// Defines the frequency a given Call/Construct site was executed. For some |
+// call sites the frequency is not known. |
+class CallFrequency final { |
+ public: |
+ CallFrequency() : value_(std::numeric_limits<float>::quiet_NaN()) {} |
+ explicit CallFrequency(float value) : value_(value) { |
+ DCHECK(!std::isnan(value)); |
+ } |
+ |
+ bool IsKnown() const { return !IsUnknown(); } |
+ bool IsUnknown() const { return std::isnan(value_); } |
+ float value() const { |
+ DCHECK(IsKnown()); |
+ return value_; |
+ } |
+ |
+ bool operator==(CallFrequency const& that) const { |
+ return bit_cast<uint32_t>(this->value_) == bit_cast<uint32_t>(that.value_); |
+ } |
+ bool operator!=(CallFrequency const& that) const { return !(*this == that); } |
+ |
+ friend size_t hash_value(CallFrequency f) { |
+ return bit_cast<uint32_t>(f.value_); |
+ } |
+ |
+ private: |
+ float value_; |
+}; |
+ |
+std::ostream& operator<<(std::ostream&, CallFrequency); |
+ |
// Defines a pair of {FeedbackVector} and {FeedbackSlot}, which |
// is used to access the type feedback for a certain {Node}. |
class V8_EXPORT_PRIVATE VectorSlotPair { |
@@ -64,17 +95,17 @@ ToBooleanHints ToBooleanHintsOf(Operator const* op); |
// used as a parameter by JSConstruct operators. |
class ConstructParameters final { |
public: |
- ConstructParameters(uint32_t arity, float frequency, |
+ ConstructParameters(uint32_t arity, CallFrequency frequency, |
VectorSlotPair const& feedback) |
: arity_(arity), frequency_(frequency), feedback_(feedback) {} |
uint32_t arity() const { return arity_; } |
- float frequency() const { return frequency_; } |
+ CallFrequency frequency() const { return frequency_; } |
VectorSlotPair const& feedback() const { return feedback_; } |
private: |
uint32_t const arity_; |
- float const frequency_; |
+ CallFrequency const frequency_; |
VectorSlotPair const feedback_; |
}; |
@@ -152,8 +183,9 @@ CallForwardVarargsParameters const& CallForwardVarargsParametersOf( |
// used as a parameter by JSCall operators. |
class CallParameters final { |
public: |
- CallParameters(size_t arity, float frequency, VectorSlotPair const& feedback, |
- TailCallMode tail_call_mode, ConvertReceiverMode convert_mode) |
+ CallParameters(size_t arity, CallFrequency frequency, |
+ VectorSlotPair const& feedback, TailCallMode tail_call_mode, |
+ ConvertReceiverMode convert_mode) |
: bit_field_(ArityField::encode(arity) | |
ConvertReceiverModeField::encode(convert_mode) | |
TailCallModeField::encode(tail_call_mode)), |
@@ -161,7 +193,7 @@ class CallParameters final { |
feedback_(feedback) {} |
size_t arity() const { return ArityField::decode(bit_field_); } |
- float frequency() const { return frequency_; } |
+ CallFrequency frequency() const { return frequency_; } |
ConvertReceiverMode convert_mode() const { |
return ConvertReceiverModeField::decode(bit_field_); |
} |
@@ -187,7 +219,7 @@ class CallParameters final { |
typedef BitField<TailCallMode, 31, 1> TailCallModeField; |
uint32_t const bit_field_; |
- float const frequency_; |
+ CallFrequency const frequency_; |
VectorSlotPair const feedback_; |
}; |
@@ -636,7 +668,7 @@ class V8_EXPORT_PRIVATE JSOperatorBuilder final |
const Operator* CallForwardVarargs(uint32_t start_index, |
TailCallMode tail_call_mode); |
const Operator* Call( |
- size_t arity, float frequency = 0.0f, |
+ size_t arity, CallFrequency frequency = CallFrequency(), |
VectorSlotPair const& feedback = VectorSlotPair(), |
ConvertReceiverMode convert_mode = ConvertReceiverMode::kAny, |
TailCallMode tail_call_mode = TailCallMode::kDisallow); |
@@ -644,8 +676,9 @@ class V8_EXPORT_PRIVATE JSOperatorBuilder final |
const Operator* CallRuntime(Runtime::FunctionId id); |
const Operator* CallRuntime(Runtime::FunctionId id, size_t arity); |
const Operator* CallRuntime(const Runtime::Function* function, size_t arity); |
- const Operator* Construct(uint32_t arity, float frequency, |
- VectorSlotPair const& feedback); |
+ const Operator* Construct(uint32_t arity, |
+ CallFrequency frequency = CallFrequency(), |
+ VectorSlotPair const& feedback = VectorSlotPair()); |
const Operator* ConstructWithSpread(uint32_t arity); |
const Operator* ConvertReceiver(ConvertReceiverMode convert_mode); |