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

Side by Side Diff: src/compilation-cache.cc

Issue 7274024: Suspend runtime profiler as soon as we exit JS. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 5 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/compilation-cache.h ('k') | src/compiler.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 2008 the V8 project authors. All rights reserved. 1 // Copyright 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 // Initial size of each compilation cache table allocated. 45 // Initial size of each compilation cache table allocated.
46 static const int kInitialCacheSize = 64; 46 static const int kInitialCacheSize = 64;
47 47
48 48
49 CompilationCache::CompilationCache(Isolate* isolate) 49 CompilationCache::CompilationCache(Isolate* isolate)
50 : isolate_(isolate), 50 : isolate_(isolate),
51 script_(isolate, kScriptGenerations), 51 script_(isolate, kScriptGenerations),
52 eval_global_(isolate, kEvalGlobalGenerations), 52 eval_global_(isolate, kEvalGlobalGenerations),
53 eval_contextual_(isolate, kEvalContextualGenerations), 53 eval_contextual_(isolate, kEvalContextualGenerations),
54 reg_exp_(isolate, kRegExpGenerations), 54 reg_exp_(isolate, kRegExpGenerations),
55 enabled_(true), 55 enabled_(true) {
56 eager_optimizing_set_(NULL) {
57 CompilationSubCache* subcaches[kSubCacheCount] = 56 CompilationSubCache* subcaches[kSubCacheCount] =
58 {&script_, &eval_global_, &eval_contextual_, &reg_exp_}; 57 {&script_, &eval_global_, &eval_contextual_, &reg_exp_};
59 for (int i = 0; i < kSubCacheCount; ++i) { 58 for (int i = 0; i < kSubCacheCount; ++i) {
60 subcaches_[i] = subcaches[i]; 59 subcaches_[i] = subcaches[i];
61 } 60 }
62 } 61 }
63 62
64 63
65 CompilationCache::~CompilationCache() { 64 CompilationCache::~CompilationCache() {}
66 delete eager_optimizing_set_;
67 eager_optimizing_set_ = NULL;
68 }
69 65
70 66
71 static Handle<CompilationCacheTable> AllocateTable(Isolate* isolate, int size) { 67 static Handle<CompilationCacheTable> AllocateTable(Isolate* isolate, int size) {
72 CALL_HEAP_FUNCTION(isolate, 68 CALL_HEAP_FUNCTION(isolate,
73 CompilationCacheTable::Allocate(size), 69 CompilationCacheTable::Allocate(size),
74 CompilationCacheTable); 70 CompilationCacheTable);
75 } 71 }
76 72
77 73
78 Handle<CompilationCacheTable> CompilationSubCache::GetTable(int generation) { 74 Handle<CompilationCacheTable> CompilationSubCache::GetTable(int generation) {
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 JSRegExp::Flags flags, 446 JSRegExp::Flags flags,
451 Handle<FixedArray> data) { 447 Handle<FixedArray> data) {
452 if (!IsEnabled()) { 448 if (!IsEnabled()) {
453 return; 449 return;
454 } 450 }
455 451
456 reg_exp_.Put(source, flags, data); 452 reg_exp_.Put(source, flags, data);
457 } 453 }
458 454
459 455
460 static bool SourceHashCompare(void* key1, void* key2) {
461 return key1 == key2;
462 }
463
464
465 HashMap* CompilationCache::EagerOptimizingSet() {
466 if (eager_optimizing_set_ == NULL) {
467 eager_optimizing_set_ = new HashMap(&SourceHashCompare);
468 }
469 return eager_optimizing_set_;
470 }
471
472
473 bool CompilationCache::ShouldOptimizeEagerly(Handle<JSFunction> function) {
474 if (FLAG_opt_eagerly) return true;
475 uint32_t hash = function->SourceHash();
476 void* key = reinterpret_cast<void*>(hash);
477 return EagerOptimizingSet()->Lookup(key, hash, false) != NULL;
478 }
479
480
481 void CompilationCache::MarkForEagerOptimizing(Handle<JSFunction> function) {
482 uint32_t hash = function->SourceHash();
Kasper Lund 2011/06/28 13:49:45 It would be nice if you could get rid of JSFunctio
Vitaly Repeshko 2011/06/29 15:10:33 Removed.
483 void* key = reinterpret_cast<void*>(hash);
484 EagerOptimizingSet()->Lookup(key, hash, true);
485 }
486
487
488 void CompilationCache::MarkForLazyOptimizing(Handle<JSFunction> function) {
489 uint32_t hash = function->SourceHash();
490 void* key = reinterpret_cast<void*>(hash);
491 EagerOptimizingSet()->Remove(key, hash);
492 }
493
494
495 void CompilationCache::ResetEagerOptimizingData() {
496 HashMap* set = EagerOptimizingSet();
497 if (set->occupancy() > 0) set->Clear();
498 }
499
500
501 void CompilationCache::Clear() { 456 void CompilationCache::Clear() {
502 for (int i = 0; i < kSubCacheCount; i++) { 457 for (int i = 0; i < kSubCacheCount; i++) {
503 subcaches_[i]->Clear(); 458 subcaches_[i]->Clear();
504 } 459 }
505 } 460 }
506 461
507 462
508 void CompilationCache::Iterate(ObjectVisitor* v) { 463 void CompilationCache::Iterate(ObjectVisitor* v) {
509 for (int i = 0; i < kSubCacheCount; i++) { 464 for (int i = 0; i < kSubCacheCount; i++) {
510 subcaches_[i]->Iterate(v); 465 subcaches_[i]->Iterate(v);
(...skipping 20 matching lines...) Expand all
531 } 486 }
532 487
533 488
534 void CompilationCache::Disable() { 489 void CompilationCache::Disable() {
535 enabled_ = false; 490 enabled_ = false;
536 Clear(); 491 Clear();
537 } 492 }
538 493
539 494
540 } } // namespace v8::internal 495 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compilation-cache.h ('k') | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698