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

Unified Diff: src/objects.cc

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: More tweaks. 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/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index d295b58e0a2c09f0a7f8f10d57795f3cce8c70cb..de93f32cedc7cd7e12ec818088c10fc5fb01863d 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -2588,7 +2588,8 @@ MaybeObject* JSObject::SetLocalPropertyIgnoreAttributes(
attributes);
}
- // Check for accessor in prototype chain removed here in clone.
+ // Unlike SetLocalProperty, we ignore the prototype chain and
+ // any accessors in it.
if (!result.IsFound()) {
// Neither properties nor transitions found.
return AddProperty(name, value, attributes, kNonStrictMode);
@@ -9704,6 +9705,8 @@ class SubStringAsciiSymbolKey : public HashTableKey {
ASSERT(length_ >= 0);
ASSERT(from_ + length_ <= string_->length());
StringHasher hasher(length_);
+ AssertNoAllocation no_alloc;
+ const char* chars = string_->GetChars() + from_;
// Very long strings have a trivial hash that doesn't inspect the
// string contents.
@@ -9714,16 +9717,14 @@ class SubStringAsciiSymbolKey : public HashTableKey {
// Do the iterative array index computation as long as there is a
// chance this is an array index.
while (i < length_ && hasher.is_array_index()) {
- hasher.AddCharacter(static_cast<uc32>(
- string_->SeqAsciiStringGet(i + from_)));
+ hasher.AddCharacter(static_cast<uc32>(chars[i]));
i++;
}
// Process the remaining characters without updating the array
// index.
while (i < length_) {
- hasher.AddCharacterNoIndex(static_cast<uc32>(
- string_->SeqAsciiStringGet(i + from_)));
+ hasher.AddCharacterNoIndex(static_cast<uc32>(chars[i]));
i++;
}
hash_field_ = hasher.GetHashField();
@@ -10550,7 +10551,11 @@ class TwoCharHashTableKey : public HashTableKey {
#ifdef DEBUG
StringHasher hasher(2);
hasher.AddCharacter(c1);
- hasher.AddCharacter(c2);
+ if (hasher.is_array_index()) {
+ hasher.AddCharacter(c2);
+ } else {
+ hasher.AddCharacterNoIndex(c2);
+ }
// If this assert fails then we failed to reproduce the two-character
// version of the string hashing algorithm above. One reason could be
// that we were passed two digits as characters, since the hash

Powered by Google App Engine
This is Rietveld 408576698