Revision: 19603
Author:   [email protected]
Date:     Fri Feb 28 12:27:31 2014 UTC
Log: Evict from optimized code map in sync with removing from optimized functions list.

[email protected]

Review URL: https://codereview.chromium.org/184443002
http://code.google.com/p/v8/source/detail?r=19603

Added:
 /branches/bleeding_edge/test/mjsunit/regress/regress-3135.js
 /branches/bleeding_edge/test/mjsunit/regress/regress-330046.js
 /branches/bleeding_edge/test/mjsunit/regress/regress-333594.js
 /branches/bleeding_edge/test/mjsunit/regress-sync-optimized-lists.js
Deleted:
 /branches/bleeding_edge/test/mjsunit/regress-3135.js
 /branches/bleeding_edge/test/mjsunit/regress-330046.js
 /branches/bleeding_edge/test/mjsunit/regress-333594.js
Modified:
 /branches/bleeding_edge/src/compiler.cc
 /branches/bleeding_edge/src/deoptimizer.cc
 /branches/bleeding_edge/src/factory.cc
 /branches/bleeding_edge/src/objects-inl.h
 /branches/bleeding_edge/src/objects.cc
 /branches/bleeding_edge/src/objects.h
 /branches/bleeding_edge/src/runtime.cc

=======================================
--- /dev/null
+++ /branches/bleeding_edge/test/mjsunit/regress/regress-3135.js Fri Feb 28 12:27:31 2014 UTC
@@ -0,0 +1,53 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Properties are serialized once.
+assertEquals('{"x":1}', JSON.stringify({ x : 1 }, ["x", 1, "x", 1]));
+assertEquals('{"1":1}', JSON.stringify({ 1 : 1 }, ["x", 1, "x", 1]));
+assertEquals('{"1":1}', JSON.stringify({ 1 : 1 }, ["1", 1, "1", 1]));
+assertEquals('{"1":1}', JSON.stringify({ 1 : 1 }, [1, "1", 1, "1"]));
+
+// Properties are visited at most once.
+var fired = 0;
+var getter_obj = { get x() { fired++; return 2; } };
+assertEquals('{"x":2}', JSON.stringify(getter_obj, ["x", "y", "x"]));
+assertEquals(1, fired);
+
+// Order of the replacer array is followed.
+assertEquals('{"y":4,"x":3}', JSON.stringify({ x : 3, y : 4}, ["y", "x"]));
+assertEquals('{"y":4,"1":2,"x":3}',
+             JSON.stringify({ x : 3, y : 4, 1 : 2 }, ["y", 1, "x"]));
+
+// __proto__ is ignored and doesn't break anything.
+var a = { x : 8 };
+a.__proto__ = { x : 7 };
+assertEquals('{"x":8}', JSON.stringify(a, ["__proto__", "x", "__proto__"]));
+
+// Arrays are not affected by the replacer array.
+assertEquals("[9,8,7]", JSON.stringify([9, 8, 7], [1, 1]));
+var mixed_arr = [11,12,13];
+mixed_arr.x = 10;
+assertEquals('[11,12,13]', JSON.stringify(mixed_arr, [1, 0, 1]));
+
+// Array elements of objects are affected.
+var mixed_obj = { x : 3 };
+mixed_obj[0] = 6;
+mixed_obj[1] = 5;
+assertEquals('{"1":5,"0":6}', JSON.stringify(mixed_obj, [1, 0, 1]));
+
+// Nested object.
+assertEquals('{"z":{"x":3},"x":1}',
+             JSON.stringify({ x: 1, y:2, z: {x:3, b:4}}, ["z","x"]));
+
+// Objects in the replacer array are ignored.
+assertEquals('{}',
+             JSON.stringify({ x : 1, "1": 1 }, [{}]));
+assertEquals('{}',
+             JSON.stringify({ x : 1, "1": 1 }, [true, undefined, null]));
+assertEquals('{}',
+             JSON.stringify({ x : 1, "1": 1 },
+                            [{ toString: function() { return "x";} }]));
+assertEquals('{}',
+             JSON.stringify({ x : 1, "1": 1 },
+                            [{ valueOf: function() { return 1;} }]));
=======================================
--- /dev/null
+++ /branches/bleeding_edge/test/mjsunit/regress/regress-330046.js Fri Feb 28 12:27:31 2014 UTC
@@ -0,0 +1,61 @@
+// Copyright 2013 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Flags: --use-osr --allow-natives-syntax --crankshaft
+
+var o1 = {a : 10};
+var o2 = { };
+o2.__proto__ = o1;
+var o3 = { };
+o3.__proto__ = o2;
+
+function f(n, x, b) {
+  var sum = x.a;
+  for (var i = 0; i < n; i++) {
+    sum = 1.0 / i;
+  }
+  return sum;
+}
+
+f(10, o3);
+f(20, o3);
+f(30, o3);
+%OptimizeFunctionOnNextCall(f, "concurrent");
+f(100000, o3);
+// At this point OSR replaces already optimized code.
+// Check that it evicts old code from cache.
+
+// This causes all code for f to be lazily deopted.
+o2.a = 5;
+
+// If OSR did not evict the old code, it will be installed in f here.
+%OptimizeFunctionOnNextCall(f);
+f(10, o3);
+
+// The old code is already deoptimized, but f still points to it.
+// Disassembling it will crash.
+%DebugDisassembleFunction(f);
=======================================
--- /dev/null
+++ /branches/bleeding_edge/test/mjsunit/regress/regress-333594.js Fri Feb 28 12:27:31 2014 UTC
@@ -0,0 +1,42 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Flags: --allow-natives-syntax
+
+var a = { x: 1.1 };
+a.x = 0;
+var G = a.x;
+var o = { x: {} };
+
+function func() {
+  return {x: G};
+}
+
+func();
+func();
+%OptimizeFunctionOnNextCall(func);
+assertEquals(0, func().x);
=======================================
--- /dev/null
+++ /branches/bleeding_edge/test/mjsunit/regress-sync-optimized-lists.js Fri Feb 28 12:27:31 2014 UTC
@@ -0,0 +1,45 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --allow-natives-syntax --block-concurrent-recompilation
+// Flags: --no-concurrent-osr
+
+function Ctor() {
+  this.a = 1;
+}
+
+function get_closure() {
+  return function add_field(obj, osr) {
+    obj.c = 3;
+    var x = 0;
+    if (osr) {
+      %OptimizeFunctionOnNextCall(add_field, "osr");
+    }
+    for (var i = 0; i < 10; i++) {
+      x = i + 1;
+    }
+    return x;
+  }
+}
+
+var f1 = get_closure();
+f1(new Ctor(), false);
+f1(new Ctor(), false);
+
+%OptimizeFunctionOnNextCall(f1, "concurrent");
+
+// Kick off concurrent recompilation and OSR.
+var o = new Ctor();
+f1(o, true);
+assertOptimized(f1, "no sync");
+
+// Flush the optimizing compiler's queue.
+%NotifyContextDisposed();
+assertUnoptimized(f1, "no sync");
+
+// Trigger deopt.
+o.c = 2.2;
+
+var f2 = get_closure();
+f2(new Ctor(), true);
=======================================
--- /branches/bleeding_edge/test/mjsunit/regress-3135.js Tue Feb 11 10:45:39 2014 UTC
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2014 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Properties are serialized once.
-assertEquals('{"x":1}', JSON.stringify({ x : 1 }, ["x", 1, "x", 1]));
-assertEquals('{"1":1}', JSON.stringify({ 1 : 1 }, ["x", 1, "x", 1]));
-assertEquals('{"1":1}', JSON.stringify({ 1 : 1 }, ["1", 1, "1", 1]));
-assertEquals('{"1":1}', JSON.stringify({ 1 : 1 }, [1, "1", 1, "1"]));
-
-// Properties are visited at most once.
-var fired = 0;
-var getter_obj = { get x() { fired++; return 2; } };
-assertEquals('{"x":2}', JSON.stringify(getter_obj, ["x", "y", "x"]));
-assertEquals(1, fired);
-
-// Order of the replacer array is followed.
-assertEquals('{"y":4,"x":3}', JSON.stringify({ x : 3, y : 4}, ["y", "x"]));
-assertEquals('{"y":4,"1":2,"x":3}',
-             JSON.stringify({ x : 3, y : 4, 1 : 2 }, ["y", 1, "x"]));
-
-// __proto__ is ignored and doesn't break anything.
-var a = { x : 8 };
-a.__proto__ = { x : 7 };
-assertEquals('{"x":8}', JSON.stringify(a, ["__proto__", "x", "__proto__"]));
-
-// Arrays are not affected by the replacer array.
-assertEquals("[9,8,7]", JSON.stringify([9, 8, 7], [1, 1]));
-var mixed_arr = [11,12,13];
-mixed_arr.x = 10;
-assertEquals('[11,12,13]', JSON.stringify(mixed_arr, [1, 0, 1]));
-
-// Array elements of objects are affected.
-var mixed_obj = { x : 3 };
-mixed_obj[0] = 6;
-mixed_obj[1] = 5;
-assertEquals('{"1":5,"0":6}', JSON.stringify(mixed_obj, [1, 0, 1]));
-
-// Nested object.
-assertEquals('{"z":{"x":3},"x":1}',
-             JSON.stringify({ x: 1, y:2, z: {x:3, b:4}}, ["z","x"]));
-
-// Objects in the replacer array are ignored.
-assertEquals('{}',
-             JSON.stringify({ x : 1, "1": 1 }, [{}]));
-assertEquals('{}',
-             JSON.stringify({ x : 1, "1": 1 }, [true, undefined, null]));
-assertEquals('{}',
-             JSON.stringify({ x : 1, "1": 1 },
-                            [{ toString: function() { return "x";} }]));
-assertEquals('{}',
-             JSON.stringify({ x : 1, "1": 1 },
-                            [{ valueOf: function() { return 1;} }]));
=======================================
--- /branches/bleeding_edge/test/mjsunit/regress-330046.js Fri Dec 27 09:22:56 2013 UTC
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2013 the V8 project authors. All rights reserved.
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-//       notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-//       copyright notice, this list of conditions and the following
-//       disclaimer in the documentation and/or other materials provided
-//       with the distribution.
-//     * Neither the name of Google Inc. nor the names of its
-//       contributors may be used to endorse or promote products derived
-//       from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// Flags: --use-osr --allow-natives-syntax --crankshaft
-
-var o1 = {a : 10};
-var o2 = { };
-o2.__proto__ = o1;
-var o3 = { };
-o3.__proto__ = o2;
-
-function f(n, x, b) {
-  var sum = x.a;
-  for (var i = 0; i < n; i++) {
-    sum = 1.0 / i;
-  }
-  return sum;
-}
-
-f(10, o3);
-f(20, o3);
-f(30, o3);
-%OptimizeFunctionOnNextCall(f, "concurrent");
-f(100000, o3);
-// At this point OSR replaces already optimized code.
-// Check that it evicts old code from cache.
-
-// This causes all code for f to be lazily deopted.
-o2.a = 5;
-
-// If OSR did not evict the old code, it will be installed in f here.
-%OptimizeFunctionOnNextCall(f);
-f(10, o3);
-
-// The old code is already deoptimized, but f still points to it.
-// Disassembling it will crash.
-%DebugDisassembleFunction(f);
=======================================
--- /branches/bleeding_edge/test/mjsunit/regress-333594.js Mon Jan 20 19:00:11 2014 UTC
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2014 the V8 project authors. All rights reserved.
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-//       notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-//       copyright notice, this list of conditions and the following
-//       disclaimer in the documentation and/or other materials provided
-//       with the distribution.
-//     * Neither the name of Google Inc. nor the names of its
-//       contributors may be used to endorse or promote products derived
-//       from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// Flags: --allow-natives-syntax
-
-var a = { x: 1.1 };
-a.x = 0;
-var G = a.x;
-var o = { x: {} };
-
-function func() {
-  return {x: G};
-}
-
-func();
-func();
-%OptimizeFunctionOnNextCall(func);
-assertEquals(0, func().x);
=======================================
--- /branches/bleeding_edge/src/compiler.cc     Mon Feb 24 17:48:09 2014 UTC
+++ /branches/bleeding_edge/src/compiler.cc     Fri Feb 28 12:27:31 2014 UTC
@@ -1070,7 +1070,10 @@
       }
FixedArray* literals = shared->GetLiteralsFromOptimizedCodeMap(index);
       if (literals != NULL) function->set_literals(literals);
-      return Handle<Code>(shared->GetCodeFromOptimizedCodeMap(index));
+      Handle<Code> code(shared->GetCodeFromOptimizedCodeMap(index));
+      if (!code->marked_for_deoptimization()) return code;
+ shared->EvictFromOptimizedCodeMap(function->context()->native_context(), + "code was already marked for deopt");
     }
   }
   return Handle<Code>::null();
=======================================
--- /branches/bleeding_edge/src/deoptimizer.cc  Thu Feb 27 15:12:12 2014 UTC
+++ /branches/bleeding_edge/src/deoptimizer.cc  Fri Feb 28 12:27:31 2014 UTC
@@ -342,7 +342,8 @@
       // Unlink this function and evict from optimized code map.
       SharedFunctionInfo* shared = function->shared();
       function->set_code(shared->code());
-      shared->EvictFromOptimizedCodeMap(code, "deoptimized function");
+ shared->EvictFromOptimizedCodeMap(function->context()->native_context(),
+                                        "deoptimized function");

       if (FLAG_trace_deopt) {
CodeTracer::Scope scope(code->GetHeap()->isolate()->GetCodeTracer());
=======================================
--- /branches/bleeding_edge/src/factory.cc      Thu Feb 13 08:43:53 2014 UTC
+++ /branches/bleeding_edge/src/factory.cc      Fri Feb 28 12:27:31 2014 UTC
@@ -967,7 +967,9 @@
     FixedArray* literals =
         function_info->GetLiteralsFromOptimizedCodeMap(index);
     if (literals != NULL) result->set_literals(literals);
-    result->ReplaceCode(function_info->GetCodeFromOptimizedCodeMap(index));
+    Code* code = function_info->GetCodeFromOptimizedCodeMap(index);
+    ASSERT(!code->marked_for_deoptimization());
+    result->ReplaceCode(code);
     return result;
   }

=======================================
--- /branches/bleeding_edge/src/objects-inl.h   Tue Feb 25 12:18:30 2014 UTC
+++ /branches/bleeding_edge/src/objects-inl.h   Fri Feb 28 12:27:31 2014 UTC
@@ -5427,11 +5427,6 @@
   bool was_optimized = IsOptimized();
   bool is_optimized = code->kind() == Code::OPTIMIZED_FUNCTION;

-  if (was_optimized && is_optimized) {
-    shared()->EvictFromOptimizedCodeMap(
-      this->code(), "Replacing with another optimized code");
-  }
-
   set_code(code);

   // Add/remove the function from the list of optimized functions for this
@@ -5442,6 +5437,8 @@
   if (was_optimized && !is_optimized) {
     // TODO(titzer): linear in the number of optimized functions; fix!
     context()->native_context()->RemoveOptimizedFunction(this);
+    shared()->EvictFromOptimizedCodeMap(context()->native_context(),
+                                        "Removing optimized code");
   }
 }

=======================================
--- /branches/bleeding_edge/src/objects.cc      Thu Feb 27 16:07:44 2014 UTC
+++ /branches/bleeding_edge/src/objects.cc      Fri Feb 28 12:27:31 2014 UTC
@@ -9631,42 +9631,46 @@
 }


-void SharedFunctionInfo::EvictFromOptimizedCodeMap(Code* optimized_code,
+void SharedFunctionInfo::EvictFromOptimizedCodeMap(Context* context,
                                                    const char* reason) {
+  ASSERT(context->IsNativeContext());
   if (optimized_code_map()->IsSmi()) return;

-  int i;
-  bool removed_entry = false;
   FixedArray* code_map = FixedArray::cast(optimized_code_map());
-  for (i = kEntriesStart; i < code_map->length(); i += kEntryLength) {
-    ASSERT(code_map->get(i)->IsNativeContext());
-    if (Code::cast(code_map->get(i + 1)) == optimized_code) {
+  int dst = kEntriesStart;
+  int length = code_map->length();
+  for (int src = kEntriesStart; src < length; src += kEntryLength) {
+    Context* context_key = Context::cast(code_map->get(src));
+    ASSERT(context->IsNativeContext());
+    if (context_key == context) {
       if (FLAG_trace_opt) {
PrintF("[evicting entry from optimizing code map (%s) for ", reason);
         ShortPrint();
-        PrintF("]\n");
+ BailoutId osr(Smi::cast(code_map->get(src + kOsrAstIdOffset))->value());
+        if (osr.IsNone()) {
+          PrintF("]\n");
+        } else {
+          PrintF(" (osr ast id %d)]\n", osr.ToInt());
+        }
       }
-      removed_entry = true;
-      break;
+      continue;
     }
+    if (dst != src) {
+      code_map->set(dst + kContextOffset,
+                    code_map->get(src + kContextOffset));
+      code_map->set(dst + kCachedCodeOffset,
+                    code_map->get(src + kCachedCodeOffset));
+      code_map->set(dst + kLiteralsOffset,
+                    code_map->get(src + kLiteralsOffset));
+      code_map->set(dst + kOsrAstIdOffset,
+                    code_map->get(src + kOsrAstIdOffset));
+    }
+    dst += kEntryLength;
   }
-  while (i < (code_map->length() - kEntryLength)) {
-    code_map->set(i + kContextOffset,
-                  code_map->get(i + kContextOffset + kEntryLength));
-    code_map->set(i + kCachedCodeOffset,
-                  code_map->get(i + kCachedCodeOffset + kEntryLength));
-    code_map->set(i + kLiteralsOffset,
-                  code_map->get(i + kLiteralsOffset + kEntryLength));
-    code_map->set(i + kOsrAstIdOffset,
-                  code_map->get(i + kOsrAstIdOffset + kEntryLength));
-    i += kEntryLength;
-  }
-  if (removed_entry) {
+  if (dst != length) {
     // Always trim even when array is cleared because of heap verifier.
-    RightTrimFixedArray<FROM_MUTATOR>(GetHeap(), code_map, kEntryLength);
-    if (code_map->length() == kEntriesStart) {
-      ClearOptimizedCodeMap();
-    }
+    RightTrimFixedArray<FROM_MUTATOR>(GetHeap(), code_map, length - dst);
+    if (code_map->length() == kEntriesStart) ClearOptimizedCodeMap();
   }
 }

=======================================
--- /branches/bleeding_edge/src/objects.h       Fri Feb 28 08:57:38 2014 UTC
+++ /branches/bleeding_edge/src/objects.h       Fri Feb 28 12:27:31 2014 UTC
@@ -6661,8 +6661,9 @@
   // Clear optimized code map.
   void ClearOptimizedCodeMap();

-  // Removed a specific optimized code object from the optimized code map.
-  void EvictFromOptimizedCodeMap(Code* optimized_code, const char* reason);
+  // Removed code objects associated to the given native context from
+  // the optimized code map.
+  void EvictFromOptimizedCodeMap(Context* context, const char* reason);

   // Trims the optimized code map after entries have been removed.
   void TrimOptimizedCodeMap(int shrink_by);
=======================================
--- /branches/bleeding_edge/src/runtime.cc      Fri Feb 28 08:45:07 2014 UTC
+++ /branches/bleeding_edge/src/runtime.cc      Fri Feb 28 12:27:31 2014 UTC
@@ -8532,8 +8532,8 @@
   }
// Evict optimized code for this function from the cache so that it doesn't
   // get used for new closures.
-  function->shared()->EvictFromOptimizedCodeMap(*optimized_code,
-                                                "notify deoptimized");
+  function->shared()->EvictFromOptimizedCodeMap(
+      function->context()->native_context(), "notify deoptimized");

   return isolate->heap()->undefined_value();
 }

--
--
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/groups/opt_out.

Reply via email to