Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 14 matching lines...) Expand all Loading... | |
| 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 "compilation-cache.h" | 30 #include "compilation-cache.h" |
| 31 | 31 |
| 32 namespace v8 { namespace internal { | 32 namespace v8 { namespace internal { |
| 33 | 33 |
| 34 enum { | 34 enum { |
| 35 NUMBER_OF_ENTRY_KINDS = CompilationCache::EVAL_CONTEXTUAL + 1 | 35 NUMBER_OF_ENTRY_KINDS = CompilationCache::_LAST_ENTRY |
|
Kasper Lund
2008/10/24 06:42:50
LAST_ENTRY + 1
| |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 | 38 |
| 39 // Keep separate tables for the different entry kinds. | 39 // Keep separate tables for the different entry kinds. |
| 40 static Object* tables[NUMBER_OF_ENTRY_KINDS] = { 0, }; | 40 static Object* tables[NUMBER_OF_ENTRY_KINDS] = { 0, }; |
| 41 | 41 |
| 42 | 42 |
| 43 static Handle<CompilationCacheTable> AllocateTable(int size) { | 43 static Handle<CompilationCacheTable> AllocateTable(int size) { |
| 44 CALL_HEAP_FUNCTION(CompilationCacheTable::Allocate(size), | 44 CALL_HEAP_FUNCTION(CompilationCacheTable::Allocate(size), |
| 45 CompilationCacheTable); | 45 CompilationCacheTable); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 void CompilationCache::Associate(Handle<String> source, | 135 void CompilationCache::Associate(Handle<String> source, |
| 136 Entry entry, | 136 Entry entry, |
| 137 Handle<JSFunction> boilerplate) { | 137 Handle<JSFunction> boilerplate) { |
| 138 HandleScope scope; | 138 HandleScope scope; |
| 139 ASSERT(boilerplate->IsBoilerplate()); | 139 ASSERT(boilerplate->IsBoilerplate()); |
| 140 Handle<CompilationCacheTable> table = GetTable(entry); | 140 Handle<CompilationCacheTable> table = GetTable(entry); |
| 141 CALL_HEAP_FUNCTION_VOID(table->Put(*source, *boilerplate)); | 141 CALL_HEAP_FUNCTION_VOID(table->Put(*source, *boilerplate)); |
| 142 } | 142 } |
| 143 | 143 |
| 144 | 144 |
| 145 Handle<Object> CompilationCache::LookupRegExp(Handle<String> source, | |
| 146 int flags) { | |
| 147 Handle<CompilationCacheTable> table = GetTable(REGEXP); | |
|
Kasper Lund
2008/10/24 06:42:50
Shouldn't this be tracking compilation cache misse
Kasper Lund
2008/10/24 06:42:50
Be careful not to leak the table handle into the s
| |
| 148 return Handle<Object>(table->LookupRegExp(*source, flags)); | |
|
Kasper Lund
2008/10/24 06:42:50
The return value is different from the other looku
| |
| 149 } | |
| 150 | |
| 151 | |
| 152 void CompilationCache::PutRegExp(Handle<String> source, | |
| 153 int flags, | |
| 154 Handle<FixedArray> data) { | |
| 155 HandleScope scope; | |
| 156 Handle<CompilationCacheTable> table = GetTable(REGEXP); | |
| 157 CALL_HEAP_FUNCTION_VOID(table->PutRegExp(*source, flags, *data)); | |
| 158 } | |
| 159 | |
| 160 | |
| 145 void CompilationCache::Clear() { | 161 void CompilationCache::Clear() { |
| 146 for (int i = 0; i < NUMBER_OF_ENTRY_KINDS; i++) { | 162 for (int i = 0; i < NUMBER_OF_ENTRY_KINDS; i++) { |
| 147 tables[i] = Heap::undefined_value(); | 163 tables[i] = Heap::undefined_value(); |
| 148 } | 164 } |
| 149 } | 165 } |
| 150 | 166 |
| 151 | 167 |
| 152 void CompilationCache::Iterate(ObjectVisitor* v) { | 168 void CompilationCache::Iterate(ObjectVisitor* v) { |
| 153 v->VisitPointers(&tables[0], &tables[NUMBER_OF_ENTRY_KINDS]); | 169 v->VisitPointers(&tables[0], &tables[NUMBER_OF_ENTRY_KINDS]); |
| 154 } | 170 } |
| 155 | 171 |
| 156 | 172 |
| 157 } } // namespace v8::internal | 173 } } // namespace v8::internal |
| OLD | NEW |