Commit 3200fafa authored by klaasb's avatar klaasb Committed by Commit bot

[interpreter] Compute and use type info percentage

Previously we would not have a total count of ICs when interpreting and
thus the check for sufficient type info would always succeed.
Also use the optimization checks for OSR while waiting for baseline
compilation and refactor the check.

BUG=v8:4280
BUG=chromium:634884

Review-Url: https://codereview.chromium.org/2360913003
Cr-Commit-Position: refs/heads/master@{#39677}
parent 73518a90
This diff is collapsed.
...@@ -13,6 +13,7 @@ namespace internal { ...@@ -13,6 +13,7 @@ namespace internal {
class Isolate; class Isolate;
class JavaScriptFrame; class JavaScriptFrame;
class JSFunction; class JSFunction;
enum class OptimizationReason : uint8_t;
class RuntimeProfiler { class RuntimeProfiler {
public: public:
...@@ -30,8 +31,13 @@ class RuntimeProfiler { ...@@ -30,8 +31,13 @@ class RuntimeProfiler {
int frame_count); int frame_count);
void MaybeBaselineIgnition(JSFunction* function, JavaScriptFrame* frame); void MaybeBaselineIgnition(JSFunction* function, JavaScriptFrame* frame);
void MaybeOptimizeIgnition(JSFunction* function, JavaScriptFrame* frame); void MaybeOptimizeIgnition(JSFunction* function, JavaScriptFrame* frame);
void Optimize(JSFunction* function, const char* reason); // Potentially attempts OSR from ignition and returns whether no other
void Baseline(JSFunction* function, const char* reason); // optimization attempts should be made.
bool MaybeOSRIgnition(JSFunction* function, JavaScriptFrame* frame);
OptimizationReason ShouldOptimizeIgnition(JSFunction* function,
JavaScriptFrame* frame);
void Optimize(JSFunction* function, OptimizationReason reason);
void Baseline(JSFunction* function, OptimizationReason reason);
Isolate* isolate_; Isolate* isolate_;
bool any_ic_changed_; bool any_ic_changed_;
......
...@@ -148,6 +148,7 @@ CompareOperationHint CompareOperationHintFromFeedback(int type_feedback) { ...@@ -148,6 +148,7 @@ CompareOperationHint CompareOperationHintFromFeedback(int type_feedback) {
} }
void TypeFeedbackVector::ComputeCounts(int* with_type_info, int* generic, void TypeFeedbackVector::ComputeCounts(int* with_type_info, int* generic,
int* vector_ic_count,
bool code_is_interpreted) { bool code_is_interpreted) {
Object* uninitialized_sentinel = Object* uninitialized_sentinel =
TypeFeedbackVector::RawUninitializedSentinel(GetIsolate()); TypeFeedbackVector::RawUninitializedSentinel(GetIsolate());
...@@ -155,14 +156,19 @@ void TypeFeedbackVector::ComputeCounts(int* with_type_info, int* generic, ...@@ -155,14 +156,19 @@ void TypeFeedbackVector::ComputeCounts(int* with_type_info, int* generic,
*TypeFeedbackVector::MegamorphicSentinel(GetIsolate()); *TypeFeedbackVector::MegamorphicSentinel(GetIsolate());
int with = 0; int with = 0;
int gen = 0; int gen = 0;
int total = 0;
TypeFeedbackMetadataIterator iter(metadata()); TypeFeedbackMetadataIterator iter(metadata());
while (iter.HasNext()) { while (iter.HasNext()) {
FeedbackVectorSlot slot = iter.Next(); FeedbackVectorSlot slot = iter.Next();
FeedbackVectorSlotKind kind = iter.kind(); FeedbackVectorSlotKind kind = iter.kind();
Object* obj = Get(slot); Object* obj = Get(slot);
if (obj != uninitialized_sentinel && if (kind == FeedbackVectorSlotKind::GENERAL) {
kind != FeedbackVectorSlotKind::GENERAL) { continue;
}
total++;
if (obj != uninitialized_sentinel) {
if (kind == FeedbackVectorSlotKind::INTERPRETER_COMPARE_IC || if (kind == FeedbackVectorSlotKind::INTERPRETER_COMPARE_IC ||
kind == FeedbackVectorSlotKind::INTERPRETER_BINARYOP_IC) { kind == FeedbackVectorSlotKind::INTERPRETER_BINARYOP_IC) {
// If we are not running interpreted code, we need to ignore // If we are not running interpreted code, we need to ignore
...@@ -202,6 +208,7 @@ void TypeFeedbackVector::ComputeCounts(int* with_type_info, int* generic, ...@@ -202,6 +208,7 @@ void TypeFeedbackVector::ComputeCounts(int* with_type_info, int* generic,
*with_type_info = with; *with_type_info = with;
*generic = gen; *generic = gen;
*vector_ic_count = total;
} }
Handle<Symbol> TypeFeedbackVector::UninitializedSentinel(Isolate* isolate) { Handle<Symbol> TypeFeedbackVector::UninitializedSentinel(Isolate* isolate) {
......
...@@ -248,7 +248,7 @@ class TypeFeedbackVector : public FixedArray { ...@@ -248,7 +248,7 @@ class TypeFeedbackVector : public FixedArray {
static const int kReservedIndexCount = 2; static const int kReservedIndexCount = 2;
inline void ComputeCounts(int* with_type_info, int* generic, inline void ComputeCounts(int* with_type_info, int* generic,
bool code_is_interpreted); int* vector_ic_count, bool code_is_interpreted);
inline bool is_empty() const; inline bool is_empty() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment