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/counters.h" | 7 #include "src/counters.h" |
8 #include "src/factory.h" | 8 #include "src/factory.h" |
9 #include "src/globals.h" | 9 #include "src/globals.h" |
10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 result = InfoVectorPair(*function_info, | 163 result = InfoVectorPair(*function_info, |
164 probe.has_vector() ? *vector_handle : nullptr); | 164 probe.has_vector() ? *vector_handle : nullptr); |
165 } | 165 } |
166 } | 166 } |
167 } | 167 } |
168 | 168 |
169 // Once outside the manacles of the handle scope, we need to recheck | 169 // Once outside the manacles of the handle scope, we need to recheck |
170 // to see if we actually found a cached script. If so, we return a | 170 // to see if we actually found a cached script. If so, we return a |
171 // handle created in the caller's handle scope. | 171 // handle created in the caller's handle scope. |
172 if (result.has_shared()) { | 172 if (result.has_shared()) { |
| 173 #ifdef DEBUG |
| 174 // Since HasOrigin can allocate, we need to protect the SharedFunctionInfo |
| 175 // and the FeedbackVector with handles during the call. |
173 Handle<SharedFunctionInfo> shared(result.shared(), isolate()); | 176 Handle<SharedFunctionInfo> shared(result.shared(), isolate()); |
174 // TODO(mvstanton): Make sure HasOrigin can't allocate, or it will | 177 Handle<Cell> vector_handle; |
175 // mess up our InfoVectorPair. | 178 if (result.has_vector()) { |
| 179 vector_handle = Handle<Cell>(result.vector(), isolate()); |
| 180 } |
176 DCHECK( | 181 DCHECK( |
177 HasOrigin(shared, name, line_offset, column_offset, resource_options)); | 182 HasOrigin(shared, name, line_offset, column_offset, resource_options)); |
| 183 result = |
| 184 InfoVectorPair(*shared, result.has_vector() ? *vector_handle : nullptr); |
| 185 #endif |
178 isolate()->counters()->compilation_cache_hits()->Increment(); | 186 isolate()->counters()->compilation_cache_hits()->Increment(); |
179 } else { | 187 } else { |
180 isolate()->counters()->compilation_cache_misses()->Increment(); | 188 isolate()->counters()->compilation_cache_misses()->Increment(); |
181 } | 189 } |
182 return result; | 190 return result; |
183 } | 191 } |
184 | 192 |
185 void CompilationCacheScript::Put(Handle<String> source, Handle<Context> context, | 193 void CompilationCacheScript::Put(Handle<String> source, Handle<Context> context, |
186 LanguageMode language_mode, | 194 LanguageMode language_mode, |
187 Handle<SharedFunctionInfo> function_info, | 195 Handle<SharedFunctionInfo> function_info, |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 | 393 |
386 | 394 |
387 void CompilationCache::Disable() { | 395 void CompilationCache::Disable() { |
388 enabled_ = false; | 396 enabled_ = false; |
389 Clear(); | 397 Clear(); |
390 } | 398 } |
391 | 399 |
392 | 400 |
393 } // namespace internal | 401 } // namespace internal |
394 } // namespace v8 | 402 } // namespace v8 |
OLD | NEW |