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

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

Issue 1939: Fix issue 65 by making sure not to leak any of the cache... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 3 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 | test/cctest/test-api.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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 if (column_offset != script->column_offset()->value()) return false; 79 if (column_offset != script->column_offset()->value()) return false;
80 // Check that both names are strings. If not, no match. 80 // Check that both names are strings. If not, no match.
81 if (!name->IsString() || !script->name()->IsString()) return false; 81 if (!name->IsString() || !script->name()->IsString()) return false;
82 // Compare the two name strings for equality. 82 // Compare the two name strings for equality.
83 return String::cast(*name)->Equals(String::cast(script->name())); 83 return String::cast(*name)->Equals(String::cast(script->name()));
84 } 84 }
85 85
86 86
87 static Handle<JSFunction> Lookup(Handle<String> source, 87 static Handle<JSFunction> Lookup(Handle<String> source,
88 CompilationCache::Entry entry) { 88 CompilationCache::Entry entry) {
89 Handle<CompilationCacheTable> table = GetTable(entry); 89 // Make sure not to leak the table into the surrounding handle
90 Object* result = table->Lookup(*source); 90 // scope. Otherwise, we risk keeping old tables around even after
91 // having cleared the cache.
92 Object* result;
93 { HandleScope scope;
94 Handle<CompilationCacheTable> table = GetTable(entry);
95 result = table->Lookup(*source);
96 }
91 if (result->IsJSFunction()) { 97 if (result->IsJSFunction()) {
92 return Handle<JSFunction>(JSFunction::cast(result)); 98 return Handle<JSFunction>(JSFunction::cast(result));
93 } else { 99 } else {
94 return Handle<JSFunction>::null(); 100 return Handle<JSFunction>::null();
95 } 101 }
96 } 102 }
97 103
98 104
99 Handle<JSFunction> CompilationCache::LookupScript(Handle<String> source, 105 Handle<JSFunction> CompilationCache::LookupScript(Handle<String> source,
100 Handle<Object> name, 106 Handle<Object> name,
(...skipping 21 matching lines...) Expand all
122 } else { 128 } else {
123 Counters::compilation_cache_hits.Increment(); 129 Counters::compilation_cache_hits.Increment();
124 } 130 }
125 return result; 131 return result;
126 } 132 }
127 133
128 134
129 void CompilationCache::Associate(Handle<String> source, 135 void CompilationCache::Associate(Handle<String> source,
130 Entry entry, 136 Entry entry,
131 Handle<JSFunction> boilerplate) { 137 Handle<JSFunction> boilerplate) {
138 HandleScope scope;
132 ASSERT(boilerplate->IsBoilerplate()); 139 ASSERT(boilerplate->IsBoilerplate());
133 Handle<CompilationCacheTable> table = GetTable(entry); 140 Handle<CompilationCacheTable> table = GetTable(entry);
134 CALL_HEAP_FUNCTION_VOID(table->Put(*source, *boilerplate)); 141 CALL_HEAP_FUNCTION_VOID(table->Put(*source, *boilerplate));
135 } 142 }
136 143
137 144
138 void CompilationCache::Clear() { 145 void CompilationCache::Clear() {
139 for (int i = 0; i < NUMBER_OF_ENTRY_KINDS; i++) { 146 for (int i = 0; i < NUMBER_OF_ENTRY_KINDS; i++) {
140 tables[i] = Heap::undefined_value(); 147 tables[i] = Heap::undefined_value();
141 } 148 }
142 } 149 }
143 150
144 151
145 void CompilationCache::Iterate(ObjectVisitor* v) { 152 void CompilationCache::Iterate(ObjectVisitor* v) {
146 v->VisitPointers(&tables[0], &tables[NUMBER_OF_ENTRY_KINDS]); 153 v->VisitPointers(&tables[0], &tables[NUMBER_OF_ENTRY_KINDS]);
147 } 154 }
148 155
149 156
150 } } // namespace v8::internal 157 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698