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

Unified Diff: src/objects.cc

Issue 14604007: Only flush SharedFunctionInfo optimized code cache when necessary (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback Created 7 years, 7 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
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index dfcb29b6027aafbdfab53181fecb10d5f52b542c..1d560fd03d74ef81d8f6621885ea621d9ed2e040 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -9034,7 +9034,7 @@ void SharedFunctionInfo::InstallFromOptimizedCodeMap(JSFunction* function,
void SharedFunctionInfo::ClearOptimizedCodeMap(const char* reason) {
if (!optimized_code_map()->IsSmi()) {
if (FLAG_trace_opt) {
- PrintF("[clearing optimizing code map (%s) for ", reason);
+ PrintF("[clearing entire optimizing code map (%s) for ", reason);
ShortPrint();
PrintF("]\n");
}
@@ -9043,6 +9043,47 @@ void SharedFunctionInfo::ClearOptimizedCodeMap(const char* reason) {
}
+void SharedFunctionInfo::EvictFromOptimizedCodeMap(Code* optimized_code,
+ const char* reason) {
+ if (optimized_code_map()->IsSmi()) return;
+
+ int i;
+ bool removed_entry = false;
+ FixedArray* code_map = FixedArray::cast(optimized_code_map());
+ for (i = 0; i < code_map->length(); i += kEntryLength) {
+ ASSERT(code_map->get(i)->IsNativeContext());
+ if (Code::cast(code_map->get(i + 1)) == optimized_code) {
+ if (FLAG_trace_opt) {
+ PrintF("[clearing optimizing code map (%s) for ", reason);
+ ShortPrint();
+ PrintF("]\n");
+ }
+ removed_entry = true;
+ break;
+ }
+ }
+ while (i < (code_map->length() - kEntryLength)) {
+ code_map->set(i, code_map->get(i + 1 + kEntryLength));
Michael Starzinger 2013/05/13 14:26:46 The indices look suspiciously off in this loop!
danno 2013/05/13 15:23:10 Done.
+ code_map->set(i + 1, code_map->get(i + 2 + kEntryLength));
+ code_map->set(i + 2, code_map->get(i + 3 + kEntryLength));
+ i += kEntryLength;
+ }
+ if (removed_entry) {
+ Heap* heap = GetHeap();
+ int new_length = code_map->length() - kEntryLength;
+ if (new_length == 0) {
+ ClearOptimizedCodeMap(reason);
+ return;
+ }
+ Address filler_start = reinterpret_cast<Address>(
+ code_map->GetFirstElementAddress() + new_length);
+ heap->CreateFillerObjectAt(filler_start,
Michael Starzinger 2013/05/13 14:26:46 This will destroy live-bytes count if incremental
danno 2013/05/13 15:23:10 Done.
danno 2013/05/13 15:23:10 Oh, this is much better! Thanks! On 2013/05/13 14:
+ kEntryLength * kPointerSize);
+ code_map->set_length(new_length);
+ }
+}
+
+
bool JSFunction::CompileLazy(Handle<JSFunction> function,
ClearExceptionFlag flag) {
bool result = true;

Powered by Google App Engine
This is Rietveld 408576698