OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compilation-cache.h" | 5 #include "src/compilation-cache.h" |
6 | 6 |
7 #include "src/assembler.h" | 7 #include "src/assembler.h" |
8 #include "src/counters.h" | 8 #include "src/counters.h" |
9 #include "src/factory.h" | 9 #include "src/factory.h" |
10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 } | 34 } |
35 } | 35 } |
36 | 36 |
37 | 37 |
38 CompilationCache::~CompilationCache() {} | 38 CompilationCache::~CompilationCache() {} |
39 | 39 |
40 | 40 |
41 Handle<CompilationCacheTable> CompilationSubCache::GetTable(int generation) { | 41 Handle<CompilationCacheTable> CompilationSubCache::GetTable(int generation) { |
42 DCHECK(generation < generations_); | 42 DCHECK(generation < generations_); |
43 Handle<CompilationCacheTable> result; | 43 Handle<CompilationCacheTable> result; |
44 if (tables_[generation]->IsUndefined()) { | 44 if (tables_[generation]->IsUndefined(isolate())) { |
45 result = CompilationCacheTable::New(isolate(), kInitialCacheSize); | 45 result = CompilationCacheTable::New(isolate(), kInitialCacheSize); |
46 tables_[generation] = *result; | 46 tables_[generation] = *result; |
47 } else { | 47 } else { |
48 CompilationCacheTable* table = | 48 CompilationCacheTable* table = |
49 CompilationCacheTable::cast(tables_[generation]); | 49 CompilationCacheTable::cast(tables_[generation]); |
50 result = Handle<CompilationCacheTable>(table, isolate()); | 50 result = Handle<CompilationCacheTable>(table, isolate()); |
51 } | 51 } |
52 return result; | 52 return result; |
53 } | 53 } |
54 | 54 |
55 | 55 |
56 void CompilationSubCache::Age() { | 56 void CompilationSubCache::Age() { |
57 // Don't directly age single-generation caches. | 57 // Don't directly age single-generation caches. |
58 if (generations_ == 1) { | 58 if (generations_ == 1) { |
59 if (tables_[0] != isolate()->heap()->undefined_value()) { | 59 if (!tables_[0]->IsUndefined(isolate())) { |
60 CompilationCacheTable::cast(tables_[0])->Age(); | 60 CompilationCacheTable::cast(tables_[0])->Age(); |
61 } | 61 } |
62 return; | 62 return; |
63 } | 63 } |
64 | 64 |
65 // Age the generations implicitly killing off the oldest. | 65 // Age the generations implicitly killing off the oldest. |
66 for (int i = generations_ - 1; i > 0; i--) { | 66 for (int i = generations_ - 1; i > 0; i--) { |
67 tables_[i] = tables_[i - 1]; | 67 tables_[i] = tables_[i - 1]; |
68 } | 68 } |
69 | 69 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 // when reporting errors, etc. | 114 // when reporting errors, etc. |
115 bool CompilationCacheScript::HasOrigin(Handle<SharedFunctionInfo> function_info, | 115 bool CompilationCacheScript::HasOrigin(Handle<SharedFunctionInfo> function_info, |
116 Handle<Object> name, int line_offset, | 116 Handle<Object> name, int line_offset, |
117 int column_offset, | 117 int column_offset, |
118 ScriptOriginOptions resource_options) { | 118 ScriptOriginOptions resource_options) { |
119 Handle<Script> script = | 119 Handle<Script> script = |
120 Handle<Script>(Script::cast(function_info->script()), isolate()); | 120 Handle<Script>(Script::cast(function_info->script()), isolate()); |
121 // If the script name isn't set, the boilerplate script should have | 121 // If the script name isn't set, the boilerplate script should have |
122 // an undefined name to have the same origin. | 122 // an undefined name to have the same origin. |
123 if (name.is_null()) { | 123 if (name.is_null()) { |
124 return script->name()->IsUndefined(); | 124 return script->name()->IsUndefined(isolate()); |
125 } | 125 } |
126 // Do the fast bailout checks first. | 126 // Do the fast bailout checks first. |
127 if (line_offset != script->line_offset()) return false; | 127 if (line_offset != script->line_offset()) return false; |
128 if (column_offset != script->column_offset()) return false; | 128 if (column_offset != script->column_offset()) return false; |
129 // Check that both names are strings. If not, no match. | 129 // Check that both names are strings. If not, no match. |
130 if (!name->IsString() || !script->name()->IsString()) return false; | 130 if (!name->IsString() || !script->name()->IsString()) return false; |
131 // Are the origin_options same? | 131 // Are the origin_options same? |
132 if (resource_options.Flags() != script->origin_options().Flags()) | 132 if (resource_options.Flags() != script->origin_options().Flags()) |
133 return false; | 133 return false; |
134 // Compare the two name strings for equality. | 134 // Compare the two name strings for equality. |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 | 397 |
398 | 398 |
399 void CompilationCache::Disable() { | 399 void CompilationCache::Disable() { |
400 enabled_ = false; | 400 enabled_ = false; |
401 Clear(); | 401 Clear(); |
402 } | 402 } |
403 | 403 |
404 | 404 |
405 } // namespace internal | 405 } // namespace internal |
406 } // namespace v8 | 406 } // namespace v8 |
OLD | NEW |