| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/jsregexp-inl.h" | 8 #include "src/jsregexp-inl.h" |
| 9 #include "src/jsregexp.h" | 9 #include "src/jsregexp.h" |
| 10 #include "src/runtime/runtime-utils.h" | 10 #include "src/runtime/runtime-utils.h" |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 length += increment; | 600 length += increment; |
| 601 } | 601 } |
| 602 | 602 |
| 603 Handle<SeqTwoByteString> answer; | 603 Handle<SeqTwoByteString> answer; |
| 604 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 604 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 605 isolate, answer, isolate->factory()->NewRawTwoByteString(length)); | 605 isolate, answer, isolate->factory()->NewRawTwoByteString(length)); |
| 606 | 606 |
| 607 DisallowHeapAllocation no_gc; | 607 DisallowHeapAllocation no_gc; |
| 608 | 608 |
| 609 uc16* sink = answer->GetChars(); | 609 uc16* sink = answer->GetChars(); |
| 610 #ifdef DEBUG | 610 #if DCHECK_IS_ON |
| 611 uc16* end = sink + length; | 611 uc16* end = sink + length; |
| 612 #endif | 612 #endif |
| 613 | 613 |
| 614 RUNTIME_ASSERT(fixed_array->get(0)->IsString()); | 614 RUNTIME_ASSERT(fixed_array->get(0)->IsString()); |
| 615 String* first = String::cast(fixed_array->get(0)); | 615 String* first = String::cast(fixed_array->get(0)); |
| 616 String* separator_raw = *separator; | 616 String* separator_raw = *separator; |
| 617 int first_length = first->length(); | 617 int first_length = first->length(); |
| 618 String::WriteToFlat(first, sink, 0, first_length); | 618 String::WriteToFlat(first, sink, 0, first_length); |
| 619 sink += first_length; | 619 sink += first_length; |
| 620 | 620 |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 // further simplified. | 971 // further simplified. |
| 972 DCHECK(0 < m && m < n); | 972 DCHECK(0 < m && m < n); |
| 973 // Has high bit set in every w byte less than n. | 973 // Has high bit set in every w byte less than n. |
| 974 uintptr_t tmp1 = kOneInEveryByte * (0x7F + n) - w; | 974 uintptr_t tmp1 = kOneInEveryByte * (0x7F + n) - w; |
| 975 // Has high bit set in every w byte greater than m. | 975 // Has high bit set in every w byte greater than m. |
| 976 uintptr_t tmp2 = w + kOneInEveryByte * (0x7F - m); | 976 uintptr_t tmp2 = w + kOneInEveryByte * (0x7F - m); |
| 977 return (tmp1 & tmp2 & (kOneInEveryByte * 0x80)); | 977 return (tmp1 & tmp2 & (kOneInEveryByte * 0x80)); |
| 978 } | 978 } |
| 979 | 979 |
| 980 | 980 |
| 981 #ifdef DEBUG | 981 #if DCHECK_IS_ON |
| 982 static bool CheckFastAsciiConvert(char* dst, const char* src, int length, | 982 static bool CheckFastAsciiConvert(char* dst, const char* src, int length, |
| 983 bool changed, bool is_to_lower) { | 983 bool changed, bool is_to_lower) { |
| 984 bool expected_changed = false; | 984 bool expected_changed = false; |
| 985 for (int i = 0; i < length; i++) { | 985 for (int i = 0; i < length; i++) { |
| 986 if (dst[i] == src[i]) continue; | 986 if (dst[i] == src[i]) continue; |
| 987 expected_changed = true; | 987 expected_changed = true; |
| 988 if (is_to_lower) { | 988 if (is_to_lower) { |
| 989 DCHECK('A' <= src[i] && src[i] <= 'Z'); | 989 DCHECK('A' <= src[i] && src[i] <= 'Z'); |
| 990 DCHECK(dst[i] == src[i] + ('a' - 'A')); | 990 DCHECK(dst[i] == src[i] + ('a' - 'A')); |
| 991 } else { | 991 } else { |
| 992 DCHECK('a' <= src[i] && src[i] <= 'z'); | 992 DCHECK('a' <= src[i] && src[i] <= 'z'); |
| 993 DCHECK(dst[i] == src[i] - ('a' - 'A')); | 993 DCHECK(dst[i] == src[i] - ('a' - 'A')); |
| 994 } | 994 } |
| 995 } | 995 } |
| 996 return (expected_changed == changed); | 996 return (expected_changed == changed); |
| 997 } | 997 } |
| 998 #endif | 998 #endif |
| 999 | 999 |
| 1000 | 1000 |
| 1001 template <class Converter> | 1001 template <class Converter> |
| 1002 static bool FastAsciiConvert(char* dst, const char* src, int length, | 1002 static bool FastAsciiConvert(char* dst, const char* src, int length, |
| 1003 bool* changed_out) { | 1003 bool* changed_out) { |
| 1004 #ifdef DEBUG | 1004 #if DCHECK_IS_ON |
| 1005 char* saved_dst = dst; | 1005 char* saved_dst = dst; |
| 1006 const char* saved_src = src; | 1006 const char* saved_src = src; |
| 1007 #endif | 1007 #endif |
| 1008 DisallowHeapAllocation no_gc; | 1008 DisallowHeapAllocation no_gc; |
| 1009 // We rely on the distance between upper and lower case letters | 1009 // We rely on the distance between upper and lower case letters |
| 1010 // being a known power of 2. | 1010 // being a known power of 2. |
| 1011 DCHECK('a' - 'A' == (1 << 5)); | 1011 DCHECK('a' - 'A' == (1 << 5)); |
| 1012 // Boundaries for the range of input characters than require conversion. | 1012 // Boundaries for the range of input characters than require conversion. |
| 1013 static const char lo = Converter::kIsToLower ? 'A' - 1 : 'a' - 1; | 1013 static const char lo = Converter::kIsToLower ? 'A' - 1 : 'a' - 1; |
| 1014 static const char hi = Converter::kIsToLower ? 'Z' + 1 : 'z' + 1; | 1014 static const char hi = Converter::kIsToLower ? 'Z' + 1 : 'z' + 1; |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1296 return __RT_impl_Runtime_StringAdd(args, isolate); | 1296 return __RT_impl_Runtime_StringAdd(args, isolate); |
| 1297 } | 1297 } |
| 1298 | 1298 |
| 1299 | 1299 |
| 1300 RUNTIME_FUNCTION(RuntimeReference_IsStringWrapperSafeForDefaultValueOf) { | 1300 RUNTIME_FUNCTION(RuntimeReference_IsStringWrapperSafeForDefaultValueOf) { |
| 1301 UNIMPLEMENTED(); | 1301 UNIMPLEMENTED(); |
| 1302 return NULL; | 1302 return NULL; |
| 1303 } | 1303 } |
| 1304 } | 1304 } |
| 1305 } // namespace v8::internal | 1305 } // namespace v8::internal |
| OLD | NEW |