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

Side by Side Diff: src/factory.cc

Issue 7285031: Remove unmarked entries from per context map caches. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 5 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 | « src/contexts.h ('k') | src/mark-compact.h » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 1161
1162 MUST_USE_RESULT static MaybeObject* UpdateMapCacheWith(Context* context, 1162 MUST_USE_RESULT static MaybeObject* UpdateMapCacheWith(Context* context,
1163 FixedArray* keys, 1163 FixedArray* keys,
1164 Map* map) { 1164 Map* map) {
1165 Object* result; 1165 Object* result;
1166 { MaybeObject* maybe_result = 1166 { MaybeObject* maybe_result =
1167 MapCache::cast(context->map_cache())->Put(keys, map); 1167 MapCache::cast(context->map_cache())->Put(keys, map);
1168 if (!maybe_result->ToObject(&result)) return maybe_result; 1168 if (!maybe_result->ToObject(&result)) return maybe_result;
1169 } 1169 }
1170 context->set_map_cache(MapCache::cast(result)); 1170 context->set_map_cache(MapCache::cast(result));
1171 StatsCounter* counter =
1172 Isolate::Current()->counters()->max_map_cache_length();
1173 int length = FixedArray::cast(result)->length();
1174 if (counter->Enabled() && (*counter->GetInternalPointer()) < length) {
1175 counter->Set(length);
1176 }
1171 return result; 1177 return result;
1172 } 1178 }
1173 1179
1174 1180
1175 Handle<MapCache> Factory::AddToMapCache(Handle<Context> context, 1181 Handle<MapCache> Factory::AddToMapCache(Handle<Context> context,
1176 Handle<FixedArray> keys, 1182 Handle<FixedArray> keys,
1177 Handle<Map> map) { 1183 Handle<Map> map) {
1178 CALL_HEAP_FUNCTION(isolate(), 1184 CALL_HEAP_FUNCTION(isolate(),
1179 UpdateMapCacheWith(*context, *keys, *map), MapCache); 1185 UpdateMapCacheWith(*context, *keys, *map), MapCache);
1180 } 1186 }
1181 1187
1182 1188
1183 Handle<Map> Factory::ObjectLiteralMapFromCache(Handle<Context> context, 1189 Handle<Map> Factory::ObjectLiteralMapFromCache(Handle<Context> context,
1184 Handle<FixedArray> keys) { 1190 Handle<FixedArray> keys) {
1185 if (context->map_cache()->IsUndefined()) { 1191 if (context->map_cache()->IsUndefined()) {
1186 // Allocate the new map cache for the global context. 1192 // Allocate the new map cache for the global context.
1187 Handle<MapCache> new_cache = NewMapCache(24); 1193 Handle<MapCache> new_cache = NewMapCache(24);
1188 context->set_map_cache(*new_cache); 1194 context->set_map_cache(*new_cache);
1189 } 1195 }
1190 // Check to see whether there is a matching element in the cache. 1196 // Check to see whether there is a matching element in the cache.
1191 Handle<MapCache> cache = 1197 Handle<MapCache> cache =
1192 Handle<MapCache>(MapCache::cast(context->map_cache())); 1198 Handle<MapCache>(MapCache::cast(context->map_cache()));
1193 Handle<Object> result = Handle<Object>(cache->Lookup(*keys)); 1199 Handle<Object> result = Handle<Object>(cache->Lookup(*keys));
1194 if (result->IsMap()) return Handle<Map>::cast(result); 1200 if (result->IsMap()) {
1201 Isolate::Current()->counters()->map_cache_hits()->Increment();
1202 return Handle<Map>::cast(result);
1203 }
1204 Isolate::Current()->counters()->map_cache_misses()->Increment();
1195 // Create a new map and add it to the cache. 1205 // Create a new map and add it to the cache.
1196 Handle<Map> map = 1206 Handle<Map> map =
1197 CopyMap(Handle<Map>(context->object_function()->initial_map()), 1207 CopyMap(Handle<Map>(context->object_function()->initial_map()),
1198 keys->length()); 1208 keys->length());
1199 AddToMapCache(context, keys, map); 1209 AddToMapCache(context, keys, map);
1200 return Handle<Map>(map); 1210 return Handle<Map>(map);
1201 } 1211 }
1202 1212
1203 1213
1204 void Factory::SetRegExpAtomData(Handle<JSRegExp> regexp, 1214 void Factory::SetRegExpAtomData(Handle<JSRegExp> regexp,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 Execution::ConfigureInstance(instance, 1255 Execution::ConfigureInstance(instance,
1246 instance_template, 1256 instance_template,
1247 pending_exception); 1257 pending_exception);
1248 } else { 1258 } else {
1249 *pending_exception = false; 1259 *pending_exception = false;
1250 } 1260 }
1251 } 1261 }
1252 1262
1253 1263
1254 } } // namespace v8::internal 1264 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/contexts.h ('k') | src/mark-compact.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698