summaryrefslogtreecommitdiff
path: root/deps/v8/src/type-feedback-vector.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/type-feedback-vector.h')
-rw-r--r--deps/v8/src/type-feedback-vector.h104
1 files changed, 96 insertions, 8 deletions
diff --git a/deps/v8/src/type-feedback-vector.h b/deps/v8/src/type-feedback-vector.h
index 5355ee7188..af69499b04 100644
--- a/deps/v8/src/type-feedback-vector.h
+++ b/deps/v8/src/type-feedback-vector.h
@@ -10,7 +10,8 @@
#include "src/base/logging.h"
#include "src/elements-kind.h"
#include "src/objects.h"
-#include "src/zone-containers.h"
+#include "src/type-hints.h"
+#include "src/zone/zone-containers.h"
namespace v8 {
namespace internal {
@@ -27,6 +28,8 @@ enum class FeedbackVectorSlotKind {
KEYED_LOAD_IC,
STORE_IC,
KEYED_STORE_IC,
+ INTERPRETER_BINARYOP_IC,
+ INTERPRETER_COMPARE_IC,
// This is a general purpose slot that occupies one feedback vector element.
GENERAL,
@@ -67,6 +70,14 @@ class FeedbackVectorSpecBase {
return AddSlot(FeedbackVectorSlotKind::KEYED_STORE_IC);
}
+ FeedbackVectorSlot AddInterpreterBinaryOpICSlot() {
+ return AddSlot(FeedbackVectorSlotKind::INTERPRETER_BINARYOP_IC);
+ }
+
+ FeedbackVectorSlot AddInterpreterCompareICSlot() {
+ return AddSlot(FeedbackVectorSlotKind::INTERPRETER_COMPARE_IC);
+ }
+
FeedbackVectorSlot AddGeneralSlot() {
return AddSlot(FeedbackVectorSlotKind::GENERAL);
}
@@ -207,7 +218,7 @@ class TypeFeedbackMetadata : public FixedArray {
static const char* Kind2String(FeedbackVectorSlotKind kind);
private:
- static const int kFeedbackVectorSlotKindBits = 4;
+ static const int kFeedbackVectorSlotKindBits = 5;
STATIC_ASSERT(static_cast<int>(FeedbackVectorSlotKind::KINDS_NUMBER) <
(1 << kFeedbackVectorSlotKindBits));
@@ -222,11 +233,10 @@ class TypeFeedbackMetadata : public FixedArray {
// The shape of the TypeFeedbackVector is an array with:
// 0: feedback metadata
-// 1: ics_with_types
-// 2: ics_with_generic_info
-// 3: feedback slot #0
+// 1: invocation count
+// 2: feedback slot #0
// ...
-// 3 + slot_count - 1: feedback slot #(slot_count-1)
+// 2 + slot_count - 1: feedback slot #(slot_count-1)
//
class TypeFeedbackVector : public FixedArray {
public:
@@ -234,9 +244,11 @@ class TypeFeedbackVector : public FixedArray {
static inline TypeFeedbackVector* cast(Object* obj);
static const int kMetadataIndex = 0;
- static const int kReservedIndexCount = 1;
+ static const int kInvocationCountIndex = 1;
+ static const int kReservedIndexCount = 2;
- inline void ComputeCounts(int* with_type_info, int* generic);
+ inline void ComputeCounts(int* with_type_info, int* generic,
+ int* vector_ic_count, bool code_is_interpreted);
inline bool is_empty() const;
@@ -244,6 +256,7 @@ class TypeFeedbackVector : public FixedArray {
inline int slot_count() const;
inline TypeFeedbackMetadata* metadata() const;
+ inline int invocation_count() const;
// Conversion from a slot to an integer index to the underlying array.
static int GetIndex(FeedbackVectorSlot slot) {
@@ -461,6 +474,7 @@ class CallICNexus final : public FeedbackNexus {
void Clear(Code* host);
+ void ConfigureUninitialized() override;
void ConfigureMonomorphicArray();
void ConfigureMonomorphic(Handle<JSFunction> function);
void ConfigureMegamorphic() final;
@@ -481,6 +495,10 @@ class CallICNexus final : public FeedbackNexus {
}
int ExtractCallCount();
+
+ // Compute the call frequency based on the call count and the invocation
+ // count (taken from the type feedback vector).
+ float ComputeCallFrequency();
};
@@ -548,6 +566,10 @@ class KeyedLoadICNexus : public FeedbackNexus {
: FeedbackNexus(vector, slot) {
DCHECK_EQ(FeedbackVectorSlotKind::KEYED_LOAD_IC, vector->GetKind(slot));
}
+ explicit KeyedLoadICNexus(Isolate* isolate)
+ : FeedbackNexus(
+ TypeFeedbackVector::DummyVector(isolate),
+ FeedbackVectorSlot(TypeFeedbackVector::kDummyKeyedLoadICSlot)) {}
KeyedLoadICNexus(TypeFeedbackVector* vector, FeedbackVectorSlot slot)
: FeedbackNexus(vector, slot) {
DCHECK_EQ(FeedbackVectorSlotKind::KEYED_LOAD_IC, vector->GetKind(slot));
@@ -630,6 +652,72 @@ class KeyedStoreICNexus : public FeedbackNexus {
InlineCacheState StateFromFeedback() const override;
Name* FindFirstName() const override;
};
+
+class BinaryOpICNexus final : public FeedbackNexus {
+ public:
+ BinaryOpICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot)
+ : FeedbackNexus(vector, slot) {
+ DCHECK_EQ(FeedbackVectorSlotKind::INTERPRETER_BINARYOP_IC,
+ vector->GetKind(slot));
+ }
+ BinaryOpICNexus(TypeFeedbackVector* vector, FeedbackVectorSlot slot)
+ : FeedbackNexus(vector, slot) {
+ DCHECK_EQ(FeedbackVectorSlotKind::INTERPRETER_BINARYOP_IC,
+ vector->GetKind(slot));
+ }
+
+ void Clear(Code* host);
+
+ InlineCacheState StateFromFeedback() const final;
+ BinaryOperationHint GetBinaryOperationFeedback() const;
+
+ int ExtractMaps(MapHandleList* maps) const final {
+ // BinaryOpICs don't record map feedback.
+ return 0;
+ }
+ MaybeHandle<Object> FindHandlerForMap(Handle<Map> map) const final {
+ return MaybeHandle<Code>();
+ }
+ bool FindHandlers(List<Handle<Object>>* code_list,
+ int length = -1) const final {
+ return length == 0;
+ }
+};
+
+class CompareICNexus final : public FeedbackNexus {
+ public:
+ CompareICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot)
+ : FeedbackNexus(vector, slot) {
+ DCHECK_EQ(FeedbackVectorSlotKind::INTERPRETER_COMPARE_IC,
+ vector->GetKind(slot));
+ }
+ CompareICNexus(TypeFeedbackVector* vector, FeedbackVectorSlot slot)
+ : FeedbackNexus(vector, slot) {
+ DCHECK_EQ(FeedbackVectorSlotKind::INTERPRETER_COMPARE_IC,
+ vector->GetKind(slot));
+ }
+
+ void Clear(Code* host);
+
+ InlineCacheState StateFromFeedback() const final;
+ CompareOperationHint GetCompareOperationFeedback() const;
+
+ int ExtractMaps(MapHandleList* maps) const final {
+ // BinaryOpICs don't record map feedback.
+ return 0;
+ }
+ MaybeHandle<Object> FindHandlerForMap(Handle<Map> map) const final {
+ return MaybeHandle<Code>();
+ }
+ bool FindHandlers(List<Handle<Object>>* code_list,
+ int length = -1) const final {
+ return length == 0;
+ }
+};
+
+inline BinaryOperationHint BinaryOperationHintFromFeedback(int type_feedback);
+inline CompareOperationHint CompareOperationHintFromFeedback(int type_feedback);
+
} // namespace internal
} // namespace v8