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 |
70 // Set the first generation as unborn. | 70 // Set the first generation as unborn. |
71 tables_[0] = isolate()->heap()->undefined_value(); | 71 tables_[0] = isolate()->heap()->undefined_value(); |
72 } | 72 } |
73 | 73 |
74 | 74 |
75 void CompilationSubCache::IterateFunctions(ObjectVisitor* v) { | 75 void CompilationSubCache::IterateFunctions(ObjectVisitor* v) { |
76 Object* undefined = isolate()->heap()->undefined_value(); | |
77 for (int i = 0; i < generations_; i++) { | 76 for (int i = 0; i < generations_; i++) { |
78 if (tables_[i] != undefined) { | 77 if (!tables_[i]->IsUndefined(isolate())) { |
79 reinterpret_cast<CompilationCacheTable*>(tables_[i])->IterateElements(v); | 78 reinterpret_cast<CompilationCacheTable*>(tables_[i])->IterateElements(v); |
80 } | 79 } |
81 } | 80 } |
82 } | 81 } |
83 | 82 |
84 | 83 |
85 void CompilationSubCache::Iterate(ObjectVisitor* v) { | 84 void CompilationSubCache::Iterate(ObjectVisitor* v) { |
86 v->VisitPointers(&tables_[0], &tables_[generations_]); | 85 v->VisitPointers(&tables_[0], &tables_[generations_]); |
87 } | 86 } |
88 | 87 |
(...skipping 25 matching lines...) Expand all Loading... |
114 // when reporting errors, etc. | 113 // when reporting errors, etc. |
115 bool CompilationCacheScript::HasOrigin(Handle<SharedFunctionInfo> function_info, | 114 bool CompilationCacheScript::HasOrigin(Handle<SharedFunctionInfo> function_info, |
116 Handle<Object> name, int line_offset, | 115 Handle<Object> name, int line_offset, |
117 int column_offset, | 116 int column_offset, |
118 ScriptOriginOptions resource_options) { | 117 ScriptOriginOptions resource_options) { |
119 Handle<Script> script = | 118 Handle<Script> script = |
120 Handle<Script>(Script::cast(function_info->script()), isolate()); | 119 Handle<Script>(Script::cast(function_info->script()), isolate()); |
121 // If the script name isn't set, the boilerplate script should have | 120 // If the script name isn't set, the boilerplate script should have |
122 // an undefined name to have the same origin. | 121 // an undefined name to have the same origin. |
123 if (name.is_null()) { | 122 if (name.is_null()) { |
124 return script->name()->IsUndefined(); | 123 return script->name()->IsUndefined(isolate()); |
125 } | 124 } |
126 // Do the fast bailout checks first. | 125 // Do the fast bailout checks first. |
127 if (line_offset != script->line_offset()) return false; | 126 if (line_offset != script->line_offset()) return false; |
128 if (column_offset != script->column_offset()) return false; | 127 if (column_offset != script->column_offset()) return false; |
129 // Check that both names are strings. If not, no match. | 128 // Check that both names are strings. If not, no match. |
130 if (!name->IsString() || !script->name()->IsString()) return false; | 129 if (!name->IsString() || !script->name()->IsString()) return false; |
131 // Are the origin_options same? | 130 // Are the origin_options same? |
132 if (resource_options.Flags() != script->origin_options().Flags()) | 131 if (resource_options.Flags() != script->origin_options().Flags()) |
133 return false; | 132 return false; |
134 // Compare the two name strings for equality. | 133 // Compare the two name strings for equality. |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 | 396 |
398 | 397 |
399 void CompilationCache::Disable() { | 398 void CompilationCache::Disable() { |
400 enabled_ = false; | 399 enabled_ = false; |
401 Clear(); | 400 Clear(); |
402 } | 401 } |
403 | 402 |
404 | 403 |
405 } // namespace internal | 404 } // namespace internal |
406 } // namespace v8 | 405 } // namespace v8 |
OLD | NEW |