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

Side by Side Diff: src/heap.cc

Issue 1933: Generalized the EvalCache into a CompilationCache and enabled... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 3 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
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 13 matching lines...) Expand all
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "v8.h" 28 #include "v8.h"
29 29
30 #include "accessors.h" 30 #include "accessors.h"
31 #include "api.h" 31 #include "api.h"
32 #include "bootstrapper.h" 32 #include "bootstrapper.h"
33 #include "codegen-inl.h" 33 #include "codegen-inl.h"
34 #include "compilation-cache.h"
34 #include "debug.h" 35 #include "debug.h"
35 #include "global-handles.h" 36 #include "global-handles.h"
36 #include "jsregexp.h" 37 #include "jsregexp.h"
37 #include "mark-compact.h" 38 #include "mark-compact.h"
38 #include "natives.h" 39 #include "natives.h"
39 #include "scanner.h" 40 #include "scanner.h"
40 #include "scopeinfo.h" 41 #include "scopeinfo.h"
41 #include "v8threads.h" 42 #include "v8threads.h"
42 43
43 namespace v8 { namespace internal { 44 namespace v8 { namespace internal {
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 441
441 gc_state_ = NOT_IN_GC; 442 gc_state_ = NOT_IN_GC;
442 443
443 Shrink(); 444 Shrink();
444 445
445 Counters::objs_since_last_full.Set(0); 446 Counters::objs_since_last_full.Set(0);
446 } 447 }
447 448
448 449
449 void Heap::MarkCompactPrologue() { 450 void Heap::MarkCompactPrologue() {
450 // Empty eval caches 451 CompilationCache::MarkCompactPrologue();
451 Heap::eval_cache_global_ = Heap::null_value();
452 Heap::eval_cache_non_global_ = Heap::null_value();
453
454 RegExpImpl::OldSpaceCollectionPrologue(); 452 RegExpImpl::OldSpaceCollectionPrologue();
455 Top::MarkCompactPrologue(); 453 Top::MarkCompactPrologue();
456 ThreadManager::MarkCompactPrologue(); 454 ThreadManager::MarkCompactPrologue();
457 } 455 }
458 456
459 457
460 void Heap::MarkCompactEpilogue() { 458 void Heap::MarkCompactEpilogue() {
461 Top::MarkCompactEpilogue(); 459 Top::MarkCompactEpilogue();
462 ThreadManager::MarkCompactEpilogue(); 460 ThreadManager::MarkCompactEpilogue();
463 } 461 }
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 // Allocate cache for single character strings. 1199 // Allocate cache for single character strings.
1202 obj = AllocateFixedArray(String::kMaxAsciiCharCode+1); 1200 obj = AllocateFixedArray(String::kMaxAsciiCharCode+1);
1203 if (obj->IsFailure()) return false; 1201 if (obj->IsFailure()) return false;
1204 single_character_string_cache_ = FixedArray::cast(obj); 1202 single_character_string_cache_ = FixedArray::cast(obj);
1205 1203
1206 // Allocate cache for external strings pointing to native source code. 1204 // Allocate cache for external strings pointing to native source code.
1207 obj = AllocateFixedArray(Natives::GetBuiltinsCount()); 1205 obj = AllocateFixedArray(Natives::GetBuiltinsCount());
1208 if (obj->IsFailure()) return false; 1206 if (obj->IsFailure()) return false;
1209 natives_source_cache_ = FixedArray::cast(obj); 1207 natives_source_cache_ = FixedArray::cast(obj);
1210 1208
1211 // Initialized eval cache to null value. 1209 // Initialize compilation cache.
1212 eval_cache_global_ = null_value(); 1210 CompilationCache::Clear();
1213 eval_cache_non_global_ = null_value();
1214 1211
1215 return true; 1212 return true;
1216 } 1213 }
1217 1214
1218 1215
1219 static inline int double_get_hash(double d) { 1216 static inline int double_get_hash(double d) {
1220 DoubleRepresentation rep(d); 1217 DoubleRepresentation rep(d);
1221 return ((static_cast<int>(rep.bits) ^ static_cast<int>(rep.bits >> 32)) & 1218 return ((static_cast<int>(rep.bits) ^ static_cast<int>(rep.bits >> 32)) &
1222 (Heap::kNumberStringCacheSize - 1)); 1219 (Heap::kNumberStringCacheSize - 1));
1223 } 1220 }
(...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after
2272 Object* symbol = NULL; 2269 Object* symbol = NULL;
2273 Object* new_table = 2270 Object* new_table =
2274 SymbolTable::cast(symbol_table_)->LookupString(string, &symbol); 2271 SymbolTable::cast(symbol_table_)->LookupString(string, &symbol);
2275 if (new_table->IsFailure()) return new_table; 2272 if (new_table->IsFailure()) return new_table;
2276 symbol_table_ = new_table; 2273 symbol_table_ = new_table;
2277 ASSERT(symbol != NULL); 2274 ASSERT(symbol != NULL);
2278 return symbol; 2275 return symbol;
2279 } 2276 }
2280 2277
2281 2278
2282 Object* Heap::LookupEvalCache(bool is_global_context, String* src) {
2283 Object* cache = is_global_context ?
2284 eval_cache_global_ : eval_cache_non_global_;
2285 return cache == null_value() ?
2286 null_value() : EvalCache::cast(cache)->Lookup(src);
2287 }
2288
2289
2290 Object* Heap::PutInEvalCache(bool is_global_context, String* src,
2291 JSFunction* value) {
2292 Object** cache_ptr = is_global_context ?
2293 &eval_cache_global_ : &eval_cache_non_global_;
2294
2295 if (*cache_ptr == null_value()) {
2296 Object* obj = EvalCache::Allocate(kInitialEvalCacheSize);
2297 if (obj->IsFailure()) return false;
2298 *cache_ptr = obj;
2299 }
2300
2301 Object* new_cache =
2302 EvalCache::cast(*cache_ptr)->Put(src, value);
2303 if (new_cache->IsFailure()) return new_cache;
2304 *cache_ptr = new_cache;
2305
2306 return value;
2307 }
2308
2309
2310 #ifdef DEBUG 2279 #ifdef DEBUG
2311 void Heap::ZapFromSpace() { 2280 void Heap::ZapFromSpace() {
2312 ASSERT(HAS_HEAP_OBJECT_TAG(kFromSpaceZapValue)); 2281 ASSERT(HAS_HEAP_OBJECT_TAG(kFromSpaceZapValue));
2313 for (Address a = new_space_->FromSpaceLow(); 2282 for (Address a = new_space_->FromSpaceLow();
2314 a < new_space_->FromSpaceHigh(); 2283 a < new_space_->FromSpaceHigh();
2315 a += kPointerSize) { 2284 a += kPointerSize) {
2316 Memory::Address_at(a) = kFromSpaceZapValue; 2285 Memory::Address_at(a) = kFromSpaceZapValue;
2317 } 2286 }
2318 } 2287 }
2319 #endif // DEBUG 2288 #endif // DEBUG
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
2410 SYMBOL_LIST(SYMBOL_ITERATE) 2379 SYMBOL_LIST(SYMBOL_ITERATE)
2411 #undef SYMBOL_ITERATE 2380 #undef SYMBOL_ITERATE
2412 SYNCHRONIZE_TAG("symbol"); 2381 SYNCHRONIZE_TAG("symbol");
2413 2382
2414 Bootstrapper::Iterate(v); 2383 Bootstrapper::Iterate(v);
2415 SYNCHRONIZE_TAG("bootstrapper"); 2384 SYNCHRONIZE_TAG("bootstrapper");
2416 Top::Iterate(v); 2385 Top::Iterate(v);
2417 SYNCHRONIZE_TAG("top"); 2386 SYNCHRONIZE_TAG("top");
2418 Debug::Iterate(v); 2387 Debug::Iterate(v);
2419 SYNCHRONIZE_TAG("debug"); 2388 SYNCHRONIZE_TAG("debug");
2389 CompilationCache::Iterate(v);
2390 SYNCHRONIZE_TAG("compilationcache");
2420 2391
2421 // Iterate over local handles in handle scopes. 2392 // Iterate over local handles in handle scopes.
2422 HandleScopeImplementer::Iterate(v); 2393 HandleScopeImplementer::Iterate(v);
2423 SYNCHRONIZE_TAG("handlescope"); 2394 SYNCHRONIZE_TAG("handlescope");
2424 2395
2425 // Iterate over the builtin code objects and code stubs in the heap. Note 2396 // Iterate over the builtin code objects and code stubs in the heap. Note
2426 // that it is not strictly necessary to iterate over code objects on 2397 // that it is not strictly necessary to iterate over code objects on
2427 // scavenge collections. We still do it here because this same function 2398 // scavenge collections. We still do it here because this same function
2428 // is used by the mark-sweep collector and the deserializer. 2399 // is used by the mark-sweep collector and the deserializer.
2429 Builtins::IterateBuiltins(v); 2400 Builtins::IterateBuiltins(v);
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
3089 return "Scavenge"; 3060 return "Scavenge";
3090 case MARK_COMPACTOR: 3061 case MARK_COMPACTOR:
3091 return MarkCompactCollector::HasCompacted() ? "Mark-compact" 3062 return MarkCompactCollector::HasCompacted() ? "Mark-compact"
3092 : "Mark-sweep"; 3063 : "Mark-sweep";
3093 } 3064 }
3094 return "Unknown GC"; 3065 return "Unknown GC";
3095 } 3066 }
3096 3067
3097 3068
3098 } } // namespace v8::internal 3069 } } // namespace v8::internal
OLDNEW
« src/compilation-cache.h ('K') | « src/heap.h ('k') | src/heap-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698