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

Side by Side Diff: src/heap.cc

Issue 457: Added a EvalCache that caches eval'ed scripts and compiled function boilerpla... (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 Google Inc. All Rights Reserved. 1 // Copyright 2006-2008 Google Inc. 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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 428
429 gc_state_ = NOT_IN_GC; 429 gc_state_ = NOT_IN_GC;
430 430
431 Shrink(); 431 Shrink();
432 432
433 Counters::objs_since_last_full.Set(0); 433 Counters::objs_since_last_full.Set(0);
434 } 434 }
435 435
436 436
437 void Heap::MarkCompactPrologue() { 437 void Heap::MarkCompactPrologue() {
438 // Empty eval caches
439 Heap::eval_cache_global_ = Heap::null_value();
440 Heap::eval_cache_non_global_ = Heap::null_value();
441
438 RegExpImpl::OldSpaceCollectionPrologue(); 442 RegExpImpl::OldSpaceCollectionPrologue();
439 Top::MarkCompactPrologue(); 443 Top::MarkCompactPrologue();
440 ThreadManager::MarkCompactPrologue(); 444 ThreadManager::MarkCompactPrologue();
441 } 445 }
442 446
443 447
444 void Heap::MarkCompactEpilogue() { 448 void Heap::MarkCompactEpilogue() {
445 Top::MarkCompactEpilogue(); 449 Top::MarkCompactEpilogue();
446 ThreadManager::MarkCompactEpilogue(); 450 ThreadManager::MarkCompactEpilogue();
447 } 451 }
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 // Allocate cache for single character strings. 1191 // Allocate cache for single character strings.
1188 obj = AllocateFixedArray(String::kMaxAsciiCharCode+1); 1192 obj = AllocateFixedArray(String::kMaxAsciiCharCode+1);
1189 if (obj->IsFailure()) return false; 1193 if (obj->IsFailure()) return false;
1190 single_character_string_cache_ = FixedArray::cast(obj); 1194 single_character_string_cache_ = FixedArray::cast(obj);
1191 1195
1192 // Allocate cache for external strings pointing to native source code. 1196 // Allocate cache for external strings pointing to native source code.
1193 obj = AllocateFixedArray(Natives::GetBuiltinsCount()); 1197 obj = AllocateFixedArray(Natives::GetBuiltinsCount());
1194 if (obj->IsFailure()) return false; 1198 if (obj->IsFailure()) return false;
1195 natives_source_cache_ = FixedArray::cast(obj); 1199 natives_source_cache_ = FixedArray::cast(obj);
1196 1200
1201 // Initialized eval cache to null value.
1202 eval_cache_global_ = null_value();
1203 eval_cache_non_global_ = null_value();
1204
1197 return true; 1205 return true;
1198 } 1206 }
1199 1207
1200 1208
1201 static inline int double_get_hash(double d) { 1209 static inline int double_get_hash(double d) {
1202 DoubleRepresentation rep(d); 1210 DoubleRepresentation rep(d);
1203 return ((static_cast<int>(rep.bits) ^ static_cast<int>(rep.bits >> 32)) & 1211 return ((static_cast<int>(rep.bits) ^ static_cast<int>(rep.bits >> 32)) &
1204 (Heap::kNumberStringCacheSize - 1)); 1212 (Heap::kNumberStringCacheSize - 1));
1205 } 1213 }
1206 1214
(...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after
2246 Object* symbol = NULL; 2254 Object* symbol = NULL;
2247 Object* new_table = 2255 Object* new_table =
2248 SymbolTable::cast(symbol_table_)->LookupString(string, &symbol); 2256 SymbolTable::cast(symbol_table_)->LookupString(string, &symbol);
2249 if (new_table->IsFailure()) return new_table; 2257 if (new_table->IsFailure()) return new_table;
2250 symbol_table_ = new_table; 2258 symbol_table_ = new_table;
2251 ASSERT(symbol != NULL); 2259 ASSERT(symbol != NULL);
2252 return symbol; 2260 return symbol;
2253 } 2261 }
2254 2262
2255 2263
2264 Object* Heap::LookupEvalCache(bool is_global_context, String* src) {
2265 Object* cache = is_global_context ?
2266 eval_cache_global_ : eval_cache_non_global_;
2267 return cache == null_value() ?
2268 null_value() : EvalCache::cast(cache)->Lookup(src);
2269 }
2270
2271
2272 Object* Heap::PutInEvalCache(bool is_global_context, String* src,
2273 JSFunction* value) {
2274 Object** cache_ptr = is_global_context ?
2275 &eval_cache_global_ : &eval_cache_non_global_;
2276
2277 if (*cache_ptr == null_value()) {
2278 Object* obj = EvalCache::Allocate(kInitialEvalCacheSize);
2279 if (obj->IsFailure()) return false;
2280 *cache_ptr = obj;
2281 }
2282
2283 Object* new_cache =
2284 EvalCache::cast(*cache_ptr)->Put(src, value);
2285 if (new_cache->IsFailure()) return new_cache;
2286 *cache_ptr = new_cache;
2287
2288 return value;
2289 }
2290
2291
2256 #ifdef DEBUG 2292 #ifdef DEBUG
2257 void Heap::ZapFromSpace() { 2293 void Heap::ZapFromSpace() {
2258 ASSERT(HAS_HEAP_OBJECT_TAG(kFromSpaceZapValue)); 2294 ASSERT(HAS_HEAP_OBJECT_TAG(kFromSpaceZapValue));
2259 for (Address a = new_space_->FromSpaceLow(); 2295 for (Address a = new_space_->FromSpaceLow();
2260 a < new_space_->FromSpaceHigh(); 2296 a < new_space_->FromSpaceHigh();
2261 a += kPointerSize) { 2297 a += kPointerSize) {
2262 Memory::Address_at(a) = kFromSpaceZapValue; 2298 Memory::Address_at(a) = kFromSpaceZapValue;
2263 } 2299 }
2264 } 2300 }
2265 #endif // DEBUG 2301 #endif // DEBUG
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
2961 return "Scavenge"; 2997 return "Scavenge";
2962 case MARK_COMPACTOR: 2998 case MARK_COMPACTOR:
2963 return MarkCompactCollector::HasCompacted() ? "Mark-compact" 2999 return MarkCompactCollector::HasCompacted() ? "Mark-compact"
2964 : "Mark-sweep"; 3000 : "Mark-sweep";
2965 } 3001 }
2966 return "Unknown GC"; 3002 return "Unknown GC";
2967 } 3003 }
2968 3004
2969 3005
2970 } } // namespace v8::internal 3006 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698