| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "v8.h" | 5 #include "v8.h" |
| 6 | 6 |
| 7 #include "accessors.h" | 7 #include "accessors.h" |
| 8 #include "allocation-site-scopes.h" | 8 #include "allocation-site-scopes.h" |
| 9 #include "api.h" | 9 #include "api.h" |
| 10 #include "arguments.h" | 10 #include "arguments.h" |
| (...skipping 9650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9661 return true; | 9661 return true; |
| 9662 } | 9662 } |
| 9663 | 9663 |
| 9664 | 9664 |
| 9665 bool String::SlowAsArrayIndex(uint32_t* index) { | 9665 bool String::SlowAsArrayIndex(uint32_t* index) { |
| 9666 if (length() <= kMaxCachedArrayIndexLength) { | 9666 if (length() <= kMaxCachedArrayIndexLength) { |
| 9667 Hash(); // force computation of hash code | 9667 Hash(); // force computation of hash code |
| 9668 uint32_t field = hash_field(); | 9668 uint32_t field = hash_field(); |
| 9669 if ((field & kIsNotArrayIndexMask) != 0) return false; | 9669 if ((field & kIsNotArrayIndexMask) != 0) return false; |
| 9670 // Isolate the array index form the full hash field. | 9670 // Isolate the array index form the full hash field. |
| 9671 *index = (kArrayIndexHashMask & field) >> kHashShift; | 9671 *index = ArrayIndexValueBits::decode(field); |
| 9672 return true; | 9672 return true; |
| 9673 } else { | 9673 } else { |
| 9674 return ComputeArrayIndex(index); | 9674 return ComputeArrayIndex(index); |
| 9675 } | 9675 } |
| 9676 } | 9676 } |
| 9677 | 9677 |
| 9678 | 9678 |
| 9679 Handle<String> SeqString::Truncate(Handle<SeqString> string, int new_length) { | 9679 Handle<String> SeqString::Truncate(Handle<SeqString> string, int new_length) { |
| 9680 int new_size, old_size; | 9680 int new_size, old_size; |
| 9681 int old_length = string->length(); | 9681 int old_length = string->length(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9719 | 9719 |
| 9720 | 9720 |
| 9721 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) { | 9721 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) { |
| 9722 // For array indexes mix the length into the hash as an array index could | 9722 // For array indexes mix the length into the hash as an array index could |
| 9723 // be zero. | 9723 // be zero. |
| 9724 ASSERT(length > 0); | 9724 ASSERT(length > 0); |
| 9725 ASSERT(length <= String::kMaxArrayIndexSize); | 9725 ASSERT(length <= String::kMaxArrayIndexSize); |
| 9726 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) < | 9726 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) < |
| 9727 (1 << String::kArrayIndexValueBits)); | 9727 (1 << String::kArrayIndexValueBits)); |
| 9728 | 9728 |
| 9729 value <<= String::kHashShift; | 9729 value <<= String::ArrayIndexValueBits::kShift; |
| 9730 value |= length << String::kArrayIndexHashLengthShift; | 9730 value |= length << String::ArrayIndexLengthBits::kShift; |
| 9731 | 9731 |
| 9732 ASSERT((value & String::kIsNotArrayIndexMask) == 0); | 9732 ASSERT((value & String::kIsNotArrayIndexMask) == 0); |
| 9733 ASSERT((length > String::kMaxCachedArrayIndexLength) || | 9733 ASSERT((length > String::kMaxCachedArrayIndexLength) || |
| 9734 (value & String::kContainsCachedArrayIndexMask) == 0); | 9734 (value & String::kContainsCachedArrayIndexMask) == 0); |
| 9735 return value; | 9735 return value; |
| 9736 } | 9736 } |
| 9737 | 9737 |
| 9738 | 9738 |
| 9739 uint32_t StringHasher::GetHashField() { | 9739 uint32_t StringHasher::GetHashField() { |
| 9740 if (length_ <= String::kMaxHashCalcLength) { | 9740 if (length_ <= String::kMaxHashCalcLength) { |
| (...skipping 7528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17269 #define ERROR_MESSAGES_TEXTS(C, T) T, | 17269 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 17270 static const char* error_messages_[] = { | 17270 static const char* error_messages_[] = { |
| 17271 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 17271 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 17272 }; | 17272 }; |
| 17273 #undef ERROR_MESSAGES_TEXTS | 17273 #undef ERROR_MESSAGES_TEXTS |
| 17274 return error_messages_[reason]; | 17274 return error_messages_[reason]; |
| 17275 } | 17275 } |
| 17276 | 17276 |
| 17277 | 17277 |
| 17278 } } // namespace v8::internal | 17278 } } // namespace v8::internal |
| OLD | NEW |