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

Unified Diff: src/heap.h

Issue 7977001: Added ability to lock strings to prevent their representation or encoding from changing. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed review comments Created 9 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
Index: src/heap.h
diff --git a/src/heap.h b/src/heap.h
index db258e782641753e0865a289c3e2dcae1e139194..d389655fb967319b136ffb3173dc230c435536a7 100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -76,6 +76,7 @@ inline Heap* _inline_get_heap_();
V(Map, hash_table_map, HashTableMap) \
V(Smi, stack_limit, StackLimit) \
V(FixedArray, number_string_cache, NumberStringCache) \
+ V(FixedArray, string_locks, StringLocks) \
V(Object, instanceof_cache_function, InstanceofCacheFunction) \
V(Object, instanceof_cache_map, InstanceofCacheMap) \
V(Object, instanceof_cache_answer, InstanceofCacheAnswer) \
@@ -1210,6 +1211,25 @@ class Heap {
// the string representation of the number. Otherwise return undefined.
Object* GetNumberStringCache(Object* number);
+ // Locks a string to prevent changes to the string's representation or
+ // encoding, e.g., due to externalization.
+ // It does not prevent moving the string during a GC
+ // (i.e., it's not a way to keep a pointer to an underlying character
+ // sequence valid). Might fail if the underlying data structure can't
+ // grow to accomodate the string, otherwise returns the string itself.
+ //
+ // Stores data in Heap::string_locks(), a FixedArray with the number
+ // of filled in elements in the first position, and that number of
+ // string pointers in the following positions (in no particular order).
+ // The FixedArray is padded with undefined or similar uninteresting values.
+ MaybeObject* LockString(String* string);
+ // Removes the lock on the string.
+ void UnlockString(String* string);
+ // Check if a string is locked.
+ bool IsStringLocked(String* string);
+ // Initializes the data structure underlying LockString.
+ MaybeObject* InitializeStringLocks();
+
// Update the cache with a new number-string pair.
void SetNumberStringCache(Object* number, String* str);

Powered by Google App Engine
This is Rietveld 408576698