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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2753 matching lines...) Expand 10 before | Expand all | Expand 10 after
2764 if (IsJSGlobalProxy()) { 2764 if (IsJSGlobalProxy()) {
2765 Object* proto = GetPrototype(); 2765 Object* proto = GetPrototype();
2766 if (proto->IsNull()) return value; 2766 if (proto->IsNull()) return value;
2767 ASSERT(proto->IsJSGlobalObject()); 2767 ASSERT(proto->IsJSGlobalObject());
2768 return JSObject::cast(proto)->SetLocalPropertyIgnoreAttributes( 2768 return JSObject::cast(proto)->SetLocalPropertyIgnoreAttributes(
2769 name, 2769 name,
2770 value, 2770 value,
2771 attributes); 2771 attributes);
2772 } 2772 }
2773 2773
2774 // Check for accessor in prototype chain removed here in clone. 2774 // Unlike SetLocalProperty, we ignore the prototype chain and
2775 // any accessors in it.
2775 if (!result.IsFound()) { 2776 if (!result.IsFound()) {
2776 // Neither properties nor transitions found. 2777 // Neither properties nor transitions found.
2777 return AddProperty(name, value, attributes, kNonStrictMode); 2778 return AddProperty(name, value, attributes, kNonStrictMode);
2778 } 2779 }
2779 2780
2780 PropertyDetails details = PropertyDetails(attributes, NORMAL); 2781 PropertyDetails details = PropertyDetails(attributes, NORMAL);
2781 2782
2782 // Check of IsReadOnly removed from here in clone. 2783 // Check of IsReadOnly removed from here in clone.
2783 switch (result.type()) { 2784 switch (result.type()) {
2784 case NORMAL: 2785 case NORMAL:
(...skipping 7277 matching lines...) Expand 10 before | Expand all | Expand 10 after
10062 public: 10063 public:
10063 explicit SubStringAsciiSymbolKey(Handle<SeqAsciiString> string, 10064 explicit SubStringAsciiSymbolKey(Handle<SeqAsciiString> string,
10064 int from, 10065 int from,
10065 int length) 10066 int length)
10066 : string_(string), from_(from), length_(length) { } 10067 : string_(string), from_(from), length_(length) { }
10067 10068
10068 uint32_t Hash() { 10069 uint32_t Hash() {
10069 ASSERT(length_ >= 0); 10070 ASSERT(length_ >= 0);
10070 ASSERT(from_ + length_ <= string_->length()); 10071 ASSERT(from_ + length_ <= string_->length());
10071 StringHasher hasher(length_); 10072 StringHasher hasher(length_);
10073 AssertNoAllocation no_alloc;
10074 const char* chars = string_->GetChars() + from_;
10072 10075
10073 // Very long strings have a trivial hash that doesn't inspect the 10076 // Very long strings have a trivial hash that doesn't inspect the
10074 // string contents. 10077 // string contents.
10075 if (hasher.has_trivial_hash()) { 10078 if (hasher.has_trivial_hash()) {
10076 hash_field_ = hasher.GetHashField(); 10079 hash_field_ = hasher.GetHashField();
10077 } else { 10080 } else {
10078 int i = 0; 10081 int i = 0;
10079 // Do the iterative array index computation as long as there is a 10082 // Do the iterative array index computation as long as there is a
10080 // chance this is an array index. 10083 // chance this is an array index.
10081 while (i < length_ && hasher.is_array_index()) { 10084 while (i < length_ && hasher.is_array_index()) {
10082 hasher.AddCharacter(static_cast<uc32>( 10085 hasher.AddCharacter(static_cast<uc32>(chars[i]));
10083 string_->SeqAsciiStringGet(i + from_)));
10084 i++; 10086 i++;
10085 } 10087 }
10086 10088
10087 // Process the remaining characters without updating the array 10089 // Process the remaining characters without updating the array
10088 // index. 10090 // index.
10089 while (i < length_) { 10091 while (i < length_) {
10090 hasher.AddCharacterNoIndex(static_cast<uc32>( 10092 hasher.AddCharacterNoIndex(static_cast<uc32>(chars[i]));
10091 string_->SeqAsciiStringGet(i + from_)));
10092 i++; 10093 i++;
10093 } 10094 }
10094 hash_field_ = hasher.GetHashField(); 10095 hash_field_ = hasher.GetHashField();
10095 } 10096 }
10096 10097
10097 uint32_t result = hash_field_ >> String::kHashShift; 10098 uint32_t result = hash_field_ >> String::kHashShift;
10098 ASSERT(result != 0); // Ensure that the hash value of 0 is never computed. 10099 ASSERT(result != 0); // Ensure that the hash value of 0 is never computed.
10099 return result; 10100 return result;
10100 } 10101 }
10101 10102
(...skipping 1916 matching lines...) Expand 10 before | Expand all | Expand 10 after
12018 if (break_point_objects()->IsUndefined()) return 0; 12019 if (break_point_objects()->IsUndefined()) return 0;
12019 // Single break point. 12020 // Single break point.
12020 if (!break_point_objects()->IsFixedArray()) return 1; 12021 if (!break_point_objects()->IsFixedArray()) return 1;
12021 // Multiple break points. 12022 // Multiple break points.
12022 return FixedArray::cast(break_point_objects())->length(); 12023 return FixedArray::cast(break_point_objects())->length();
12023 } 12024 }
12024 #endif 12025 #endif
12025 12026
12026 12027
12027 } } // namespace v8::internal 12028 } } // namespace v8::internal
OLDNEW
« 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