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

Unified Diff: src/objects.cc

Issue 3140: Use null instead of undefined for deleted elements in code caches.... (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
===================================================================
--- src/objects.cc (revision 338)
+++ src/objects.cc (working copy)
@@ -2379,9 +2379,15 @@
// First check whether we can update existing code cache without
// extending it.
int length = cache->length();
+ int deleted_index = -1;
for (int i = 0; i < length; i += 2) {
Object* key = cache->get(i);
+ if (key->IsNull()) {
+ if (deleted_index < 0) deleted_index = i;
+ continue;
+ }
if (key->IsUndefined()) {
+ if (deleted_index > 0) i = deleted_index;
Kasper Lund 2008/09/18 10:56:22 What if deleted_index is 0? Shouldn't you use that
cache->set(i + 0, name);
cache->set(i + 1, code);
return this;
@@ -2395,6 +2401,14 @@
}
}
+ // Reached the end of the code cache. If there were deleted
+ // elements, reuse the space for the first of them.
+ if (deleted_index > 0) {
Kasper Lund 2008/09/18 10:56:22 How about reusing if deleted_index is 0? Isn't tha
+ cache->set(deleted_index + 0, name);
+ cache->set(deleted_index + 1, code);
+ return this;
+ }
+
// Extend the code cache with some new entries (at least one).
int new_length = length + ((length >> 1) & ~1) + 2;
ASSERT((new_length & 1) == 0); // must be a multiple of two
@@ -2415,6 +2429,9 @@
int length = cache->length();
for (int i = 0; i < length; i += 2) {
Object* key = cache->get(i);
+ if (key->IsNull()) {
Kasper Lund 2008/09/18 10:56:22 Maybe add a comment here that explains that we're
+ continue;
+ }
if (key->IsUndefined()) {
return key;
}
@@ -2440,8 +2457,8 @@
void Map::RemoveFromCodeCache(int index) {
FixedArray* array = code_cache();
ASSERT(array->length() >= index && array->get(index)->IsCode());
- array->set_undefined(index - 1); // key
- array->set_undefined(index); // code
+ array->set_null(index - 1); // key
Kasper Lund 2008/09/18 10:56:22 Add comment that explains that deleted entries are
+ array->set_null(index); // code
}
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698