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

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

Issue 115500: Use a large enough variable in CompilationCache::LookupScript to avoid overfl... (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: '' Created 11 years, 7 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 | no next file » | 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 131
132 // TODO(245): Need to allow identical code from different contexts to 132 // TODO(245): Need to allow identical code from different contexts to
133 // be cached in the same script generation. Currently the first use 133 // be cached in the same script generation. Currently the first use
134 // will be cached, but subsequent code from different source / line 134 // will be cached, but subsequent code from different source / line
135 // won't. 135 // won't.
136 Handle<JSFunction> CompilationCache::LookupScript(Handle<String> source, 136 Handle<JSFunction> CompilationCache::LookupScript(Handle<String> source,
137 Handle<Object> name, 137 Handle<Object> name,
138 int line_offset, 138 int line_offset,
139 int column_offset) { 139 int column_offset) {
140 Object* result = NULL; 140 Object* result = NULL;
141 Entry generation = SCRIPT; // First generation. 141 // Using int below so value range propagation in gcc 4.3+ won't assume
142 // |generation| can only go up to LAST_ENTRY when in fact it can go
143 // up to SCRIPT + NUMBER_OF_SCRIPT_GENERATIONS.
144 int generation = static_cast<int>(SCRIPT); // First generation.
142 145
143 // Probe the script generation tables. Make sure not to leak handles 146 // Probe the script generation tables. Make sure not to leak handles
144 // into the caller's handle scope. 147 // into the caller's handle scope.
145 { HandleScope scope; 148 { HandleScope scope;
146 while (generation < SCRIPT + NUMBER_OF_SCRIPT_GENERATIONS) { 149 while (generation < SCRIPT + NUMBER_OF_SCRIPT_GENERATIONS) {
147 Handle<CompilationCacheTable> table = GetTable(generation); 150 Handle<CompilationCacheTable> table =
151 GetTable(static_cast<Entry>(generation));
148 Handle<Object> probe(table->Lookup(*source)); 152 Handle<Object> probe(table->Lookup(*source));
149 if (probe->IsJSFunction()) { 153 if (probe->IsJSFunction()) {
150 Handle<JSFunction> boilerplate = Handle<JSFunction>::cast(probe); 154 Handle<JSFunction> boilerplate = Handle<JSFunction>::cast(probe);
151 // Break when we've found a suitable boilerplate function that 155 // Break when we've found a suitable boilerplate function that
152 // matches the origin. 156 // matches the origin.
153 if (HasOrigin(boilerplate, name, line_offset, column_offset)) { 157 if (HasOrigin(boilerplate, name, line_offset, column_offset)) {
154 result = *boilerplate; 158 result = *boilerplate;
155 break; 159 break;
156 } 160 }
157 } 161 }
158 // Go to the next generation. 162 // Go to the next generation.
159 generation = static_cast<Entry>(generation + 1); 163 generation++;
160 } 164 }
161 } 165 }
162 166
163 // Once outside the menacles of the handle scope, we need to recheck 167 // Once outside the menacles of the handle scope, we need to recheck
164 // to see if we actually found a cached script. If so, we return a 168 // to see if we actually found a cached script. If so, we return a
165 // handle created in the caller's handle scope. 169 // handle created in the caller's handle scope.
166 if (result != NULL) { 170 if (result != NULL) {
167 Handle<JSFunction> boilerplate(JSFunction::cast(result)); 171 Handle<JSFunction> boilerplate(JSFunction::cast(result));
168 ASSERT(HasOrigin(boilerplate, name, line_offset, column_offset)); 172 ASSERT(HasOrigin(boilerplate, name, line_offset, column_offset));
169 // If the script was found in a later generation, we promote it to 173 // If the script was found in a later generation, we promote it to
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 for (int i = NUMBER_OF_TABLE_ENTRIES - 1; i > SCRIPT; i--) { 255 for (int i = NUMBER_OF_TABLE_ENTRIES - 1; i > SCRIPT; i--) {
252 tables[i] = tables[i - 1]; 256 tables[i] = tables[i - 1];
253 } 257 }
254 for (int j = 0; j <= LAST_ENTRY; j++) { 258 for (int j = 0; j <= LAST_ENTRY; j++) {
255 tables[j] = Heap::undefined_value(); 259 tables[j] = Heap::undefined_value();
256 } 260 }
257 } 261 }
258 262
259 263
260 } } // namespace v8::internal 264 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698