Reviewers: mvstanton,

Description:
Do not patch IC in deoptimized code.

[email protected]

Please review this at https://codereview.chromium.org/1152243002/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+22, -10 lines):
  M src/ic/ic.h
  M src/ic/ic.cc
  M src/ic/ic-inl.h


Index: src/ic/ic-inl.h
diff --git a/src/ic/ic-inl.h b/src/ic/ic-inl.h
index b0decf4c6a393b88ac332c82367c2974ccbebfa0..4db1b39510629e0753c4b0980ed1f0a49c10deb9 100644
--- a/src/ic/ic-inl.h
+++ b/src/ic/ic-inl.h
@@ -95,6 +95,8 @@ Code* IC::GetTargetAtAddress(Address address,

 void IC::SetTargetAtAddress(Address address, Code* target,
                             ConstantPoolArray* constant_pool) {
+  if (AddressIsDeoptimizedCode(target->GetIsolate(), address)) return;
+
   DCHECK(target->is_inline_cache_stub() || target->is_compare_ic_stub());

   // Don't use this for load_ics when --vector-ics is turned on.
@@ -212,12 +214,25 @@ Handle<Map> IC::GetICCacheHolder(Handle<Map> map, Isolate* isolate,
 }


-inline Code* IC::get_host() {
+Code* IC::get_host() {
   return isolate()
       ->inner_pointer_to_code_cache()
       ->GetCacheEntry(address())
       ->code;
 }
+
+
+bool IC::AddressIsDeoptimizedCode() const {
+  return AddressIsDeoptimizedCode(isolate(), address());
+}
+
+
+bool IC::AddressIsDeoptimizedCode(Isolate* isolate, Address address) {
+  Code* host =
+      isolate->inner_pointer_to_code_cache()->GetCacheEntry(address)->code;
+  return (host->kind() == Code::OPTIMIZED_FUNCTION &&
+          host->marked_for_deoptimization());
+}
 }
 }  // namespace v8::internal

Index: src/ic/ic.cc
diff --git a/src/ic/ic.cc b/src/ic/ic.cc
index 1f6c90869d42c0a2af11adeb2c12e1e943901281..e47ad9a618e24fd4e186c4285b8407bf797be5da 100644
--- a/src/ic/ic.cc
+++ b/src/ic/ic.cc
@@ -89,6 +89,7 @@ const char* GetTransitionMarkModifier(KeyedAccessStoreMode mode) {

 void IC::TraceIC(const char* type, Handle<Object> name) {
   if (FLAG_trace_ic) {
+    if (AddressIsDeoptimizedCode()) return;
     State new_state =
UseVector() ? nexus()->StateFromFeedback() : raw_target()->ic_state();
     TraceIC(type, name, state(), new_state);
@@ -230,14 +231,6 @@ bool IC::AddressIsOptimizedCode() const {
 }


-bool IC::AddressIsDeoptimizedCode() const {
-  Code* host =
- isolate()->inner_pointer_to_code_cache()->GetCacheEntry(address())->code;
-  return host->kind() == Code::OPTIMIZED_FUNCTION &&
-         host->marked_for_deoptimization();
-}
-
-
 static void LookupForRead(LookupIterator* it) {
   for (; it->IsFound(); it->Next()) {
     switch (it->state()) {
Index: src/ic/ic.h
diff --git a/src/ic/ic.h b/src/ic/ic.h
index 9eea509ec7723515a4bfa2bf91d23b4d4f6eb7fd..b63e7c727b438c6500a0b200bcf8e7d1f25c0be9 100644
--- a/src/ic/ic.h
+++ b/src/ic/ic.h
@@ -134,7 +134,9 @@ class IC {
   Code* GetOriginalCode() const;

   bool AddressIsOptimizedCode() const;
-  bool AddressIsDeoptimizedCode() const;
+  inline bool AddressIsDeoptimizedCode() const;
+  inline static bool AddressIsDeoptimizedCode(Isolate* isolate,
+                                              Address address);

   // Set the call-site target.
   inline void set_target(Code* code);
@@ -252,6 +254,8 @@ class IC {

   inline Code* get_host();

+  inline static bool CheckForLazyDeopt(Isolate* isolate, Address address);
+
  private:
   inline Code* raw_target() const;
   inline ConstantPoolArray* constant_pool() const;


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to