OLD | NEW |
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 2570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2581 if (IsJSGlobalProxy()) { | 2581 if (IsJSGlobalProxy()) { |
2582 Object* proto = GetPrototype(); | 2582 Object* proto = GetPrototype(); |
2583 if (proto->IsNull()) return value; | 2583 if (proto->IsNull()) return value; |
2584 ASSERT(proto->IsJSGlobalObject()); | 2584 ASSERT(proto->IsJSGlobalObject()); |
2585 return JSObject::cast(proto)->SetLocalPropertyIgnoreAttributes( | 2585 return JSObject::cast(proto)->SetLocalPropertyIgnoreAttributes( |
2586 name, | 2586 name, |
2587 value, | 2587 value, |
2588 attributes); | 2588 attributes); |
2589 } | 2589 } |
2590 | 2590 |
2591 // Check for accessor in prototype chain removed here in clone. | 2591 // Unlike SetLocalProperty, we ignore the prototype chain and |
| 2592 // any accessors in it. |
2592 if (!result.IsFound()) { | 2593 if (!result.IsFound()) { |
2593 // Neither properties nor transitions found. | 2594 // Neither properties nor transitions found. |
2594 return AddProperty(name, value, attributes, kNonStrictMode); | 2595 return AddProperty(name, value, attributes, kNonStrictMode); |
2595 } | 2596 } |
2596 | 2597 |
2597 PropertyDetails details = PropertyDetails(attributes, NORMAL); | 2598 PropertyDetails details = PropertyDetails(attributes, NORMAL); |
2598 | 2599 |
2599 // Check of IsReadOnly removed from here in clone. | 2600 // Check of IsReadOnly removed from here in clone. |
2600 switch (result.type()) { | 2601 switch (result.type()) { |
2601 case NORMAL: | 2602 case NORMAL: |
(...skipping 7095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9697 public: | 9698 public: |
9698 explicit SubStringAsciiSymbolKey(Handle<SeqAsciiString> string, | 9699 explicit SubStringAsciiSymbolKey(Handle<SeqAsciiString> string, |
9699 int from, | 9700 int from, |
9700 int length) | 9701 int length) |
9701 : string_(string), from_(from), length_(length) { } | 9702 : string_(string), from_(from), length_(length) { } |
9702 | 9703 |
9703 uint32_t Hash() { | 9704 uint32_t Hash() { |
9704 ASSERT(length_ >= 0); | 9705 ASSERT(length_ >= 0); |
9705 ASSERT(from_ + length_ <= string_->length()); | 9706 ASSERT(from_ + length_ <= string_->length()); |
9706 StringHasher hasher(length_); | 9707 StringHasher hasher(length_); |
| 9708 AssertNoAllocation no_alloc; |
| 9709 const char* chars = string_->GetChars() + from_; |
9707 | 9710 |
9708 // Very long strings have a trivial hash that doesn't inspect the | 9711 // Very long strings have a trivial hash that doesn't inspect the |
9709 // string contents. | 9712 // string contents. |
9710 if (hasher.has_trivial_hash()) { | 9713 if (hasher.has_trivial_hash()) { |
9711 hash_field_ = hasher.GetHashField(); | 9714 hash_field_ = hasher.GetHashField(); |
9712 } else { | 9715 } else { |
9713 int i = 0; | 9716 int i = 0; |
9714 // Do the iterative array index computation as long as there is a | 9717 // Do the iterative array index computation as long as there is a |
9715 // chance this is an array index. | 9718 // chance this is an array index. |
9716 while (i < length_ && hasher.is_array_index()) { | 9719 while (i < length_ && hasher.is_array_index()) { |
9717 hasher.AddCharacter(static_cast<uc32>( | 9720 hasher.AddCharacter(static_cast<uc32>(chars[i])); |
9718 string_->SeqAsciiStringGet(i + from_))); | |
9719 i++; | 9721 i++; |
9720 } | 9722 } |
9721 | 9723 |
9722 // Process the remaining characters without updating the array | 9724 // Process the remaining characters without updating the array |
9723 // index. | 9725 // index. |
9724 while (i < length_) { | 9726 while (i < length_) { |
9725 hasher.AddCharacterNoIndex(static_cast<uc32>( | 9727 hasher.AddCharacterNoIndex(static_cast<uc32>(chars[i])); |
9726 string_->SeqAsciiStringGet(i + from_))); | |
9727 i++; | 9728 i++; |
9728 } | 9729 } |
9729 hash_field_ = hasher.GetHashField(); | 9730 hash_field_ = hasher.GetHashField(); |
9730 } | 9731 } |
9731 | 9732 |
9732 uint32_t result = hash_field_ >> String::kHashShift; | 9733 uint32_t result = hash_field_ >> String::kHashShift; |
9733 ASSERT(result != 0); // Ensure that the hash value of 0 is never computed. | 9734 ASSERT(result != 0); // Ensure that the hash value of 0 is never computed. |
9734 return result; | 9735 return result; |
9735 } | 9736 } |
9736 | 9737 |
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10543 hash += hash << 10; | 10544 hash += hash << 10; |
10544 hash ^= hash >> 6; | 10545 hash ^= hash >> 6; |
10545 // GetHash. | 10546 // GetHash. |
10546 hash += hash << 3; | 10547 hash += hash << 3; |
10547 hash ^= hash >> 11; | 10548 hash ^= hash >> 11; |
10548 hash += hash << 15; | 10549 hash += hash << 15; |
10549 if (hash == 0) hash = 27; | 10550 if (hash == 0) hash = 27; |
10550 #ifdef DEBUG | 10551 #ifdef DEBUG |
10551 StringHasher hasher(2); | 10552 StringHasher hasher(2); |
10552 hasher.AddCharacter(c1); | 10553 hasher.AddCharacter(c1); |
10553 hasher.AddCharacter(c2); | 10554 if (hasher.is_array_index()) { |
| 10555 hasher.AddCharacter(c2); |
| 10556 } else { |
| 10557 hasher.AddCharacterNoIndex(c2); |
| 10558 } |
10554 // If this assert fails then we failed to reproduce the two-character | 10559 // If this assert fails then we failed to reproduce the two-character |
10555 // version of the string hashing algorithm above. One reason could be | 10560 // version of the string hashing algorithm above. One reason could be |
10556 // that we were passed two digits as characters, since the hash | 10561 // that we were passed two digits as characters, since the hash |
10557 // algorithm is different in that case. | 10562 // algorithm is different in that case. |
10558 ASSERT_EQ(static_cast<int>(hasher.GetHash()), static_cast<int>(hash)); | 10563 ASSERT_EQ(static_cast<int>(hasher.GetHash()), static_cast<int>(hash)); |
10559 #endif | 10564 #endif |
10560 hash_ = hash; | 10565 hash_ = hash; |
10561 } | 10566 } |
10562 | 10567 |
10563 bool IsMatch(Object* o) { | 10568 bool IsMatch(Object* o) { |
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11652 if (break_point_objects()->IsUndefined()) return 0; | 11657 if (break_point_objects()->IsUndefined()) return 0; |
11653 // Single break point. | 11658 // Single break point. |
11654 if (!break_point_objects()->IsFixedArray()) return 1; | 11659 if (!break_point_objects()->IsFixedArray()) return 1; |
11655 // Multiple break points. | 11660 // Multiple break points. |
11656 return FixedArray::cast(break_point_objects())->length(); | 11661 return FixedArray::cast(break_point_objects())->length(); |
11657 } | 11662 } |
11658 #endif | 11663 #endif |
11659 | 11664 |
11660 | 11665 |
11661 } } // namespace v8::internal | 11666 } } // namespace v8::internal |
OLD | NEW |