| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 6292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6303 // further simplified. | 6303 // further simplified. |
| 6304 ASSERT(0 < m && m < n); | 6304 ASSERT(0 < m && m < n); |
| 6305 // Has high bit set in every w byte less than n. | 6305 // Has high bit set in every w byte less than n. |
| 6306 uintptr_t tmp1 = kOneInEveryByte * (0x7F + n) - w; | 6306 uintptr_t tmp1 = kOneInEveryByte * (0x7F + n) - w; |
| 6307 // Has high bit set in every w byte greater than m. | 6307 // Has high bit set in every w byte greater than m. |
| 6308 uintptr_t tmp2 = w + kOneInEveryByte * (0x7F - m); | 6308 uintptr_t tmp2 = w + kOneInEveryByte * (0x7F - m); |
| 6309 return (tmp1 & tmp2 & (kOneInEveryByte * 0x80)); | 6309 return (tmp1 & tmp2 & (kOneInEveryByte * 0x80)); |
| 6310 } | 6310 } |
| 6311 | 6311 |
| 6312 | 6312 |
| 6313 #ifdef DEBUG |
| 6314 static bool CheckFastAsciiConvert(char* dst, |
| 6315 char* src, |
| 6316 int length, |
| 6317 bool changed, |
| 6318 bool is_to_lower) { |
| 6319 bool expected_changed = false; |
| 6320 for (int i = 0; i < length; i++) { |
| 6321 if (dst[i] == src[i]) continue; |
| 6322 expected_changed = true; |
| 6323 if (is_to_lower) { |
| 6324 ASSERT('A' <= src[i] && src[i] <= 'Z'); |
| 6325 ASSERT(dst[i] == src[i] + ('a' - 'A')); |
| 6326 } else { |
| 6327 ASSERT('a' <= src[i] && src[i] <= 'z'); |
| 6328 ASSERT(dst[i] == src[i] - ('a' - 'A')); |
| 6329 } |
| 6330 } |
| 6331 return (expected_changed == changed); |
| 6332 } |
| 6333 #endif |
| 6334 |
| 6335 |
| 6313 template<class Converter> | 6336 template<class Converter> |
| 6314 static bool FastAsciiConvert(char* dst, | 6337 static bool FastAsciiConvert(char* dst, |
| 6315 char* src, | 6338 char* src, |
| 6316 int length, | 6339 int length, |
| 6317 bool* changed_out) { | 6340 bool* changed_out) { |
| 6318 #ifdef DEBUG | 6341 #ifdef DEBUG |
| 6319 char* saved_dst = dst; | 6342 char* saved_dst = dst; |
| 6320 char* saved_src = src; | 6343 char* saved_src = src; |
| 6321 #endif | 6344 #endif |
| 6322 DisallowHeapAllocation no_gc; | 6345 DisallowHeapAllocation no_gc; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6374 return false; | 6397 return false; |
| 6375 } | 6398 } |
| 6376 | 6399 |
| 6377 ASSERT(CheckFastAsciiConvert( | 6400 ASSERT(CheckFastAsciiConvert( |
| 6378 saved_dst, saved_src, length, changed, Converter::kIsToLower)); | 6401 saved_dst, saved_src, length, changed, Converter::kIsToLower)); |
| 6379 | 6402 |
| 6380 *changed_out = changed; | 6403 *changed_out = changed; |
| 6381 return true; | 6404 return true; |
| 6382 } | 6405 } |
| 6383 | 6406 |
| 6384 #ifdef DEBUG | |
| 6385 static bool CheckFastAsciiConvert(char* dst, | |
| 6386 char* src, | |
| 6387 int length, | |
| 6388 bool changed, | |
| 6389 bool is_to_lower) { | |
| 6390 bool expected_changed = false; | |
| 6391 for (int i = 0; i < length; i++) { | |
| 6392 if (dst[i] == src[i]) continue; | |
| 6393 expected_changed = true; | |
| 6394 if (is_to_lower) { | |
| 6395 ASSERT('A' <= src[i] && src[i] <= 'Z'); | |
| 6396 ASSERT(dst[i] == src[i] + ('a' - 'A')); | |
| 6397 } else { | |
| 6398 ASSERT('a' <= src[i] && src[i] <= 'z'); | |
| 6399 ASSERT(dst[i] == src[i] - ('a' - 'A')); | |
| 6400 } | |
| 6401 } | |
| 6402 return (expected_changed == changed); | |
| 6403 } | |
| 6404 #endif | |
| 6405 | |
| 6406 } // namespace | 6407 } // namespace |
| 6407 | 6408 |
| 6408 | 6409 |
| 6409 template <class Converter> | 6410 template <class Converter> |
| 6410 MUST_USE_RESULT static MaybeObject* ConvertCase( | 6411 MUST_USE_RESULT static MaybeObject* ConvertCase( |
| 6411 Arguments args, | 6412 Arguments args, |
| 6412 Isolate* isolate, | 6413 Isolate* isolate, |
| 6413 unibrow::Mapping<Converter, 128>* mapping) { | 6414 unibrow::Mapping<Converter, 128>* mapping) { |
| 6414 SealHandleScope shs(isolate); | 6415 SealHandleScope shs(isolate); |
| 6415 CONVERT_ARG_CHECKED(String, s, 0); | 6416 CONVERT_ARG_CHECKED(String, s, 0); |
| (...skipping 8393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14809 // Handle last resort GC and make sure to allow future allocations | 14810 // Handle last resort GC and make sure to allow future allocations |
| 14810 // to grow the heap without causing GCs (if possible). | 14811 // to grow the heap without causing GCs (if possible). |
| 14811 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14812 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 14812 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14813 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 14813 "Runtime::PerformGC"); | 14814 "Runtime::PerformGC"); |
| 14814 } | 14815 } |
| 14815 } | 14816 } |
| 14816 | 14817 |
| 14817 | 14818 |
| 14818 } } // namespace v8::internal | 14819 } } // namespace v8::internal |
| OLD | NEW |