Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(286)

Side by Side Diff: src/compilation-cache.h

Issue 140056: Add generations to the compilation cache for eval and regexp (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/compilation-cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 16 matching lines...) Expand all
27 27
28 #ifndef V8_COMPILATION_CACHE_H_ 28 #ifndef V8_COMPILATION_CACHE_H_
29 #define V8_COMPILATION_CACHE_H_ 29 #define V8_COMPILATION_CACHE_H_
30 30
31 namespace v8 { 31 namespace v8 {
32 namespace internal { 32 namespace internal {
33 33
34 34
35 // The compilation cache keeps function boilerplates for compiled 35 // The compilation cache keeps function boilerplates for compiled
36 // scripts and evals. The boilerplates are looked up using the source 36 // scripts and evals. The boilerplates are looked up using the source
37 // string as the key. 37 // string as the key. For regular expressions the compilation data is cached.
38 class CompilationCache { 38 class CompilationCache {
39 public: 39 public:
40 // The same source code string has different compiled code for
41 // scripts and evals. Internally, we use separate caches to avoid
42 // getting the wrong kind of entry when looking up.
43 enum Entry {
44 EVAL_GLOBAL,
45 EVAL_CONTEXTUAL,
46 REGEXP,
47 SCRIPT,
48 LAST_ENTRY = SCRIPT
49 };
50
51 // Finds the script function boilerplate for a source 40 // Finds the script function boilerplate for a source
52 // string. Returns an empty handle if the cache doesn't contain a 41 // string. Returns an empty handle if the cache doesn't contain a
53 // script for the given source string with the right origin. 42 // script for the given source string with the right origin.
54 static Handle<JSFunction> LookupScript(Handle<String> source, 43 static Handle<JSFunction> LookupScript(Handle<String> source,
55 Handle<Object> name, 44 Handle<Object> name,
56 int line_offset, 45 int line_offset,
57 int column_offset); 46 int column_offset);
58 47
59 // Finds the function boilerplate for a source string for eval in a 48 // Finds the function boilerplate for a source string for eval in a
60 // given context. Returns an empty handle if the cache doesn't 49 // given context. Returns an empty handle if the cache doesn't
61 // contain a script for the given source string. 50 // contain a script for the given source string.
62 static Handle<JSFunction> LookupEval(Handle<String> source, 51 static Handle<JSFunction> LookupEval(Handle<String> source,
63 Handle<Context> context, 52 Handle<Context> context,
64 Entry entry); 53 bool is_global);
65 54
66 // Returns the regexp data associated with the given regexp if it 55 // Returns the regexp data associated with the given regexp if it
67 // is in cache, otherwise an empty handle. 56 // is in cache, otherwise an empty handle.
68 static Handle<FixedArray> LookupRegExp(Handle<String> source, 57 static Handle<FixedArray> LookupRegExp(Handle<String> source,
69 JSRegExp::Flags flags); 58 JSRegExp::Flags flags);
70 59
71 // Associate the (source, kind) pair to the boilerplate. This may 60 // Associate the (source, kind) pair to the boilerplate. This may
72 // overwrite an existing mapping. 61 // overwrite an existing mapping.
73 static void PutScript(Handle<String> source, 62 static void PutScript(Handle<String> source,
74 Handle<JSFunction> boilerplate); 63 Handle<JSFunction> boilerplate);
75 64
76 // Associate the (source, context->closure()->shared(), kind) triple 65 // Associate the (source, context->closure()->shared(), kind) triple
77 // with the boilerplate. This may overwrite an existing mapping. 66 // with the boilerplate. This may overwrite an existing mapping.
78 static void PutEval(Handle<String> source, 67 static void PutEval(Handle<String> source,
79 Handle<Context> context, 68 Handle<Context> context,
80 Entry entry, 69 bool is_global,
81 Handle<JSFunction> boilerplate); 70 Handle<JSFunction> boilerplate);
82 71
83 // Associate the (source, flags) pair to the given regexp data. 72 // Associate the (source, flags) pair to the given regexp data.
84 // This may overwrite an existing mapping. 73 // This may overwrite an existing mapping.
85 static void PutRegExp(Handle<String> source, 74 static void PutRegExp(Handle<String> source,
86 JSRegExp::Flags flags, 75 JSRegExp::Flags flags,
87 Handle<FixedArray> data); 76 Handle<FixedArray> data);
88 77
89 // Clear the cache - also used to initialize the cache at startup. 78 // Clear the cache - also used to initialize the cache at startup.
90 static void Clear(); 79 static void Clear();
91 80
92 // GC support. 81 // GC support.
93 static void Iterate(ObjectVisitor* v); 82 static void Iterate(ObjectVisitor* v);
94 83
95 // Notify the cache that a mark-sweep garbage collection is about to 84 // Notify the cache that a mark-sweep garbage collection is about to
96 // take place. This is used to retire entries from the cache to 85 // take place. This is used to retire entries from the cache to
97 // avoid keeping them alive too long without using them. 86 // avoid keeping them alive too long without using them.
98 static void MarkCompactPrologue(); 87 static void MarkCompactPrologue();
99 88
100 // Enable/disable compilation cache. Used by debugger to disable compilation 89 // Enable/disable compilation cache. Used by debugger to disable compilation
101 // cache during debugging to make sure new scripts are always compiled. 90 // cache during debugging to make sure new scripts are always compiled.
102 static void Enable(); 91 static void Enable();
103 static void Disable(); 92 static void Disable();
104 }; 93 };
105 94
106 95
107 } } // namespace v8::internal 96 } } // namespace v8::internal
108 97
109 #endif // V8_COMPILATION_CACHE_H_ 98 #endif // V8_COMPILATION_CACHE_H_
OLDNEW
« no previous file with comments | « no previous file | src/compilation-cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698