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

Side by Side 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: Fix bug 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 9016 matching lines...) Expand 10 before | Expand all | Expand 10 after
9027 Code* code = Code::cast(code_map->get(index)); 9027 Code* code = Code::cast(code_map->get(index));
9028 ASSERT(code != NULL); 9028 ASSERT(code != NULL);
9029 ASSERT(function->context()->native_context() == code_map->get(index - 1)); 9029 ASSERT(function->context()->native_context() == code_map->get(index - 1));
9030 function->ReplaceCode(code); 9030 function->ReplaceCode(code);
9031 } 9031 }
9032 9032
9033 9033
9034 void SharedFunctionInfo::ClearOptimizedCodeMap(const char* reason) { 9034 void SharedFunctionInfo::ClearOptimizedCodeMap(const char* reason) {
9035 if (!optimized_code_map()->IsSmi()) { 9035 if (!optimized_code_map()->IsSmi()) {
9036 if (FLAG_trace_opt) { 9036 if (FLAG_trace_opt) {
9037 PrintF("[clearing optimizing code map (%s) for ", reason); 9037 PrintF("[clearing entire optimizing code map (%s) for ", reason);
9038 ShortPrint(); 9038 ShortPrint();
9039 PrintF("]\n"); 9039 PrintF("]\n");
9040 } 9040 }
9041 set_optimized_code_map(Smi::FromInt(0)); 9041 set_optimized_code_map(Smi::FromInt(0));
9042 } 9042 }
9043 } 9043 }
9044 9044
9045 9045
9046 void SharedFunctionInfo::EvictFromOptimizedCodeMap(Code* optimized_code,
9047 const char* reason) {
9048 if (optimized_code_map()->IsSmi()) return;
9049
9050 int i;
9051 bool removed_entry = false;
9052 FixedArray* code_map = FixedArray::cast(optimized_code_map());
9053 for (i = 0; i < code_map->length(); i += kEntryLength) {
9054 ASSERT(code_map->get(i)->IsNativeContext());
9055 if (Code::cast(code_map->get(i + 1)) == optimized_code) {
9056 if (FLAG_trace_opt) {
9057 PrintF("[clearing optimizing code map (%s) for ", reason);
9058 ShortPrint();
9059 PrintF("]\n");
9060 }
9061 removed_entry = true;
9062 break;
9063 }
9064 }
9065 while (i < (code_map->length() - kEntryLength)) {
9066 code_map->set(i, code_map->get(i + kEntryLength));
9067 code_map->set(i + 1, code_map->get(i + 1 + kEntryLength));
9068 code_map->set(i + 2, code_map->get(i + 2 + kEntryLength));
9069 i += kEntryLength;
9070 }
9071 if (removed_entry) {
9072 if (code_map->length() > kEntryLength) {
9073 RightTrimFixedArray<FROM_MUTATOR>(GetHeap(), code_map, kEntryLength);
9074 } else {
9075 ClearOptimizedCodeMap(reason);
9076 }
9077 }
9078 }
9079
9080
9046 bool JSFunction::CompileLazy(Handle<JSFunction> function, 9081 bool JSFunction::CompileLazy(Handle<JSFunction> function,
9047 ClearExceptionFlag flag) { 9082 ClearExceptionFlag flag) {
9048 bool result = true; 9083 bool result = true;
9049 if (function->shared()->is_compiled()) { 9084 if (function->shared()->is_compiled()) {
9050 function->ReplaceCode(function->shared()->code()); 9085 function->ReplaceCode(function->shared()->code());
9051 function->shared()->set_code_age(0); 9086 function->shared()->set_code_age(0);
9052 } else { 9087 } else {
9053 ASSERT(function->shared()->allows_lazy_compilation()); 9088 ASSERT(function->shared()->allows_lazy_compilation());
9054 CompilationInfoWithZone info(function); 9089 CompilationInfoWithZone info(function);
9055 result = CompileLazyHelper(&info, flag); 9090 result = CompileLazyHelper(&info, flag);
(...skipping 6298 matching lines...) Expand 10 before | Expand all | Expand 10 after
15354 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 15389 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
15355 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 15390 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
15356 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 15391 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
15357 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 15392 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
15358 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 15393 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
15359 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 15394 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
15360 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 15395 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
15361 } 15396 }
15362 15397
15363 } } // namespace v8::internal 15398 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698