Do not patch IC in deoptimized code.
authoryangguo <yangguo@chromium.org>
Tue, 26 May 2015 06:56:15 +0000 (23:56 -0700)
committerCommit bot <commit-bot@chromium.org>
Tue, 26 May 2015 06:56:21 +0000 (06:56 +0000)
R=mvstanton@chromium.org

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

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

src/ic/ic-inl.h
src/ic/ic.cc
src/ic/ic.h

index b0decf4c6a393b88ac332c82367c2974ccbebfa0..4db1b39510629e0753c4b0980ed1f0a49c10deb9 100644 (file)
@@ -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 1f6c90869d42c0a2af11adeb2c12e1e943901281..e47ad9a618e24fd4e186c4285b8407bf797be5da 100644 (file)
@@ -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 9eea509ec7723515a4bfa2bf91d23b4d4f6eb7fd..be1c6d2d5bad8e88e63b26eda31cb853f937bfe0 100644 (file)
@@ -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);