Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1233)

Unified Diff: src/objects.cc

Issue 184923002: Clear optimized code cache in shared function info when code gets deoptimized (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix assert Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 11c8ffcacdd5483351e8915cd8261f95b861eceb..aa6e2808b46d283c5178cbff07f05da6db8ebdbd 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -9631,46 +9631,42 @@ void SharedFunctionInfo::ClearOptimizedCodeMap() {
}
-void SharedFunctionInfo::EvictFromOptimizedCodeMap(Context* context,
+void SharedFunctionInfo::EvictFromOptimizedCodeMap(Code* optimized_code,
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());
- 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) {
+ for (i = kEntriesStart; i < code_map->length(); i += kEntryLength) {
titzer 2014/03/03 12:02:44 This code is relying on the code appearing only on
+ ASSERT(code_map->get(i)->IsNativeContext());
+ if (Code::cast(code_map->get(i + 1)) == optimized_code) {
titzer 2014/03/03 12:02:44 Please use kCachedCodeOffset here.
if (FLAG_trace_opt) {
PrintF("[evicting entry from optimizing code map (%s) for ", reason);
ShortPrint();
- BailoutId osr(Smi::cast(code_map->get(src + kOsrAstIdOffset))->value());
- if (osr.IsNone()) {
- PrintF("]\n");
- } else {
- PrintF(" (osr ast id %d)]\n", osr.ToInt());
- }
+ PrintF("]\n");
}
- 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));
+ removed_entry = true;
+ break;
}
- dst += kEntryLength;
}
- if (dst != length) {
+ 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) {
// Always trim even when array is cleared because of heap verifier.
- RightTrimFixedArray<FROM_MUTATOR>(GetHeap(), code_map, length - dst);
- if (code_map->length() == kEntriesStart) ClearOptimizedCodeMap();
+ RightTrimFixedArray<FROM_MUTATOR>(GetHeap(), code_map, kEntryLength);
+ if (code_map->length() == kEntriesStart) {
+ ClearOptimizedCodeMap();
+ }
}
}
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698