Pass load ic state through the Oracle.
authormvstanton <mvstanton@chromium.org>
Wed, 15 Apr 2015 01:24:40 +0000 (18:24 -0700)
committerCommit bot <commit-bot@chromium.org>
Wed, 15 Apr 2015 01:24:35 +0000 (01:24 +0000)
We'd like to know in optimized code with more precision what feedback
state was achieved for a load.

R=dcarney@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1083933002

Cr-Commit-Position: refs/heads/master@{#27826}

src/ast.h
src/compiler/js-type-feedback.cc
src/type-info.cc
src/type-info.h
src/typing.cc

index 7bfa02178faabb6e09af3c3f8d8f303393da88d1..a5d4bafb49ba26541de25e8c032f520a4704b4f8 100644 (file)
--- a/src/ast.h
+++ b/src/ast.h
@@ -1746,10 +1746,10 @@ class Property FINAL : public Expression {
     return !is_for_call() && HasNoTypeInformation();
   }
   bool HasNoTypeInformation() const {
-    return IsUninitializedField::decode(bit_field_);
+    return GetInlineCacheState() == UNINITIALIZED;
   }
-  void set_is_uninitialized(bool b) {
-    bit_field_ = IsUninitializedField::update(bit_field_, b);
+  InlineCacheState GetInlineCacheState() const {
+    return InlineCacheStateField::decode(bit_field_);
   }
   void set_is_string_access(bool b) {
     bit_field_ = IsStringAccessField::update(bit_field_, b);
@@ -1757,6 +1757,9 @@ class Property FINAL : public Expression {
   void set_key_type(IcCheckType key_type) {
     bit_field_ = KeyTypeField::update(bit_field_, key_type);
   }
+  void set_inline_cache_state(InlineCacheState state) {
+    bit_field_ = InlineCacheStateField::update(bit_field_, state);
+  }
   void mark_for_call() {
     bit_field_ = IsForCallField::update(bit_field_, true);
   }
@@ -1787,8 +1790,8 @@ class Property FINAL : public Expression {
   Property(Zone* zone, Expression* obj, Expression* key, int pos)
       : Expression(zone, pos),
         bit_field_(IsForCallField::encode(false) |
-                   IsUninitializedField::encode(false) |
-                   IsStringAccessField::encode(false)),
+                   IsStringAccessField::encode(false) |
+                   InlineCacheStateField::encode(UNINITIALIZED)),
         property_feedback_slot_(FeedbackVectorICSlot::Invalid()),
         obj_(obj),
         key_(key) {}
@@ -1798,9 +1801,9 @@ class Property FINAL : public Expression {
   int local_id(int n) const { return base_id() + parent_num_ids() + n; }
 
   class IsForCallField : public BitField8<bool, 0, 1> {};
-  class IsUninitializedField : public BitField8<bool, 1, 1> {};
-  class IsStringAccessField : public BitField8<bool, 2, 1> {};
-  class KeyTypeField : public BitField8<IcCheckType, 3, 1> {};
+  class IsStringAccessField : public BitField8<bool, 1, 1> {};
+  class KeyTypeField : public BitField8<IcCheckType, 2, 1> {};
+  class InlineCacheStateField : public BitField8<InlineCacheState, 3, 4> {};
   uint8_t bit_field_;
   FeedbackVectorICSlot property_feedback_slot_;
   Expression* obj_;
index a17f4f154264bf08e321c8de37027680f9beb767..d93dc5c11f3f38aa4b6fe71a0b541003058e3a81 100644 (file)
@@ -141,8 +141,11 @@ Reduction JSTypeFeedbackSpecializer::ReduceJSLoadNamed(Node* node) {
   // TODO(turbofan): type feedback currently requires deoptimization.
   if (!FLAG_turbo_deoptimization) return NoChange();
 
+  // TODO(turbofan): handle vector-based type feedback.
   TypeFeedbackId id = js_type_feedback_->find(node);
-  if (id.IsNone() || oracle()->LoadIsUninitialized(id)) return NoChange();
+  if (id.IsNone() || oracle()->LoadInlineCacheState(id) == UNINITIALIZED) {
+    return NoChange();
+  }
 
   const LoadNamedParameters& p = LoadNamedParametersOf(node->op());
   SmallMapList maps;
index 040e25ecf4e5178382a4578f8b061d2e84ec3024..4ad66f85573e78786bb0716be81550146bdd627a 100644 (file)
@@ -90,31 +90,33 @@ Handle<Object> TypeFeedbackOracle::GetInfo(FeedbackVectorICSlot slot) {
 }
 
 
-bool TypeFeedbackOracle::LoadIsUninitialized(TypeFeedbackId id) {
+InlineCacheState TypeFeedbackOracle::LoadInlineCacheState(TypeFeedbackId id) {
   Handle<Object> maybe_code = GetInfo(id);
   if (maybe_code->IsCode()) {
     Handle<Code> code = Handle<Code>::cast(maybe_code);
-    return code->is_inline_cache_stub() && code->ic_state() == UNINITIALIZED;
+    if (code->is_inline_cache_stub()) return code->ic_state();
   }
-  return false;
+
+  // If we can't find an IC, assume we've seen *something*, but we don't know
+  // what. PREMONOMORPHIC roughly encodes this meaning.
+  return PREMONOMORPHIC;
 }
 
 
-bool TypeFeedbackOracle::LoadIsUninitialized(FeedbackVectorICSlot slot) {
+InlineCacheState TypeFeedbackOracle::LoadInlineCacheState(
+    FeedbackVectorICSlot slot) {
   Code::Kind kind = feedback_vector_->GetKind(slot);
   if (kind == Code::LOAD_IC) {
     LoadICNexus nexus(feedback_vector_, slot);
-    return nexus.StateFromFeedback() == UNINITIALIZED;
+    return nexus.StateFromFeedback();
   } else if (kind == Code::KEYED_LOAD_IC) {
     KeyedLoadICNexus nexus(feedback_vector_, slot);
-    return nexus.StateFromFeedback() == UNINITIALIZED;
-  } else if (kind == Code::NUMBER_OF_KINDS) {
-    // Code::NUMBER_OF_KINDS indicates a slot that was never even compiled
-    // in full code.
-    return true;
+    return nexus.StateFromFeedback();
   }
 
-  return false;
+  // If we can't find an IC, assume we've seen *something*, but we don't know
+  // what. PREMONOMORPHIC roughly encodes this meaning.
+  return PREMONOMORPHIC;
 }
 
 
index bd275e671a8c62809d6ab4c40880e481ceecb531..76a45dc84770d9972f416dc6f4dec2b207c2e6ff 100644 (file)
@@ -23,8 +23,8 @@ class TypeFeedbackOracle: public ZoneObject {
                      Handle<TypeFeedbackVector> feedback_vector,
                      Handle<Context> native_context);
 
-  bool LoadIsUninitialized(TypeFeedbackId id);
-  bool LoadIsUninitialized(FeedbackVectorICSlot slot);
+  InlineCacheState LoadInlineCacheState(TypeFeedbackId id);
+  InlineCacheState LoadInlineCacheState(FeedbackVectorICSlot slot);
   bool StoreIsUninitialized(TypeFeedbackId id);
   bool CallIsUninitialized(FeedbackVectorICSlot slot);
   bool CallIsMonomorphic(FeedbackVectorICSlot slot);
index fd3f531d936477c6a1eecc9f11381fa390b65411..cbd40f37159e3fea52c107e04c9e0d2fd74d418a 100644 (file)
@@ -495,10 +495,10 @@ void AstTyper::VisitProperty(Property* expr) {
   TypeFeedbackId id(TypeFeedbackId::None());
   if (FLAG_vector_ics) {
     slot = expr->PropertyFeedbackSlot();
-    expr->set_is_uninitialized(oracle()->LoadIsUninitialized(slot));
+    expr->set_inline_cache_state(oracle()->LoadInlineCacheState(slot));
   } else {
     id = expr->PropertyFeedbackId();
-    expr->set_is_uninitialized(oracle()->LoadIsUninitialized(id));
+    expr->set_inline_cache_state(oracle()->LoadInlineCacheState(id));
   }
 
   if (!expr->IsUninitialized()) {