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

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: Fix bug in test when running threaded. 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
« no previous file with comments | « src/handles.cc ('k') | src/heap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap.h
diff --git a/src/heap.h b/src/heap.h
index 361dbd58e9002e68a21d49160f57c8d093fd7bf0..a95e8fac583742052ca637bc30bd364c483d14ec 100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -77,6 +77,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) \
@@ -1214,6 +1215,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);
« no previous file with comments | « src/handles.cc ('k') | src/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698