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

Unified Diff: src/objects-inl.h

Issue 1780001: Clean JS function results cache on each major GC. (Closed)
Patch Set: Reoworking the test Created 10 years, 8 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-debug.cc ('k') | test/cctest/test-threads.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 59fdd86507591a38c062942d2254fc0942d7088a..4b5e62ce542a6bfe16a470f3940edcf44d0ac0a1 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -569,6 +569,22 @@ bool Object::IsSymbolTable() {
}
+bool Object::IsJSFunctionResultCache() {
+ if (!IsFixedArray()) return false;
+ FixedArray* self = FixedArray::cast(this);
+ int length = self->length();
+ if (length < JSFunctionResultCache::kEntriesIndex) return false;
+ if ((length - JSFunctionResultCache::kEntriesIndex)
+ % JSFunctionResultCache::kEntrySize != 0) {
+ return false;
+ }
+#ifdef DEBUG
+ reinterpret_cast<JSFunctionResultCache*>(this)->JSFunctionResultCacheVerify();
+#endif
+ return true;
+}
+
+
bool Object::IsCompilationCacheTable() {
return IsHashTable();
}
@@ -1594,6 +1610,7 @@ void NumberDictionary::set_requires_slow_elements() {
CAST_ACCESSOR(FixedArray)
CAST_ACCESSOR(DescriptorArray)
CAST_ACCESSOR(SymbolTable)
+CAST_ACCESSOR(JSFunctionResultCache)
CAST_ACCESSOR(CompilationCacheTable)
CAST_ACCESSOR(CodeCacheHashTable)
CAST_ACCESSOR(MapCache)
@@ -1838,6 +1855,20 @@ void ExternalTwoByteString::set_resource(
}
+void JSFunctionResultCache::MakeZeroSize() {
+ set(kFingerIndex, Smi::FromInt(kEntriesIndex));
+ set(kCacheSizeIndex, Smi::FromInt(kEntriesIndex));
+}
+
+
+void JSFunctionResultCache::Clear() {
+ int cache_size = Smi::cast(get(kCacheSizeIndex))->value();
+ Object** entries_start = RawField(this, OffsetOfElementAt(kEntriesIndex));
+ MemsetPointer(entries_start, Heap::the_hole_value(), cache_size);
+ MakeZeroSize();
+}
+
+
byte ByteArray::get(int index) {
ASSERT(index >= 0 && index < this->length());
return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize);
« no previous file with comments | « src/objects-debug.cc ('k') | test/cctest/test-threads.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698