| 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 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 // The compilation cache keeps function boilerplates for compiled | 34 // The compilation cache keeps function boilerplates for compiled |
| 35 // scripts and evals. The boilerplates are looked up using the source | 35 // scripts and evals. The boilerplates are looked up using the source |
| 36 // string as the key. | 36 // string as the key. |
| 37 class CompilationCache { | 37 class CompilationCache { |
| 38 public: | 38 public: |
| 39 // The same source code string has different compiled code for | 39 // The same source code string has different compiled code for |
| 40 // scripts and evals. Internally, we use separate caches to avoid | 40 // scripts and evals. Internally, we use separate caches to avoid |
| 41 // getting the wrong kind of entry when looking up. | 41 // getting the wrong kind of entry when looking up. |
| 42 enum Entry { | 42 enum Entry { |
| 43 SCRIPT, | |
| 44 EVAL_GLOBAL, | 43 EVAL_GLOBAL, |
| 45 EVAL_CONTEXTUAL, | 44 EVAL_CONTEXTUAL, |
| 46 REGEXP, | 45 REGEXP, |
| 47 LAST_ENTRY = REGEXP | 46 SCRIPT, |
| 47 LAST_ENTRY = SCRIPT |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 // Finds the script function boilerplate for a source | 50 // Finds the script function boilerplate for a source |
| 51 // string. Returns an empty handle if the cache doesn't contain a | 51 // string. Returns an empty handle if the cache doesn't contain a |
| 52 // script for the given source string with the right origin. | 52 // script for the given source string with the right origin. |
| 53 static Handle<JSFunction> LookupScript(Handle<String> source, | 53 static Handle<JSFunction> LookupScript(Handle<String> source, |
| 54 Handle<Object> name, | 54 Handle<Object> name, |
| 55 int line_offset, | 55 int line_offset, |
| 56 int column_offset); | 56 int column_offset); |
| 57 | 57 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 86 Handle<FixedArray> data); | 86 Handle<FixedArray> data); |
| 87 | 87 |
| 88 // Clear the cache - also used to initialize the cache at startup. | 88 // Clear the cache - also used to initialize the cache at startup. |
| 89 static void Clear(); | 89 static void Clear(); |
| 90 | 90 |
| 91 // GC support. | 91 // GC support. |
| 92 static void Iterate(ObjectVisitor* v); | 92 static void Iterate(ObjectVisitor* v); |
| 93 | 93 |
| 94 // Notify the cache that a mark-sweep garbage collection is about to | 94 // Notify the cache that a mark-sweep garbage collection is about to |
| 95 // take place. This is used to retire entries from the cache to | 95 // take place. This is used to retire entries from the cache to |
| 96 // avoid keeping them alive too long without using them. For now, we | 96 // avoid keeping them alive too long without using them. |
| 97 // just clear the cache but we should consider are more | 97 static void MarkCompactPrologue(); |
| 98 // sophisticated LRU scheme. | |
| 99 static void MarkCompactPrologue() { Clear(); } | |
| 100 }; | 98 }; |
| 101 | 99 |
| 102 | 100 |
| 103 } } // namespace v8::internal | 101 } } // namespace v8::internal |
| 104 | 102 |
| 105 #endif // V8_COMPILATION_CACHE_H_ | 103 #endif // V8_COMPILATION_CACHE_H_ |
| OLD | NEW |