| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 3566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3577 | 3577 |
| 3578 static Object* Runtime_StringToLowerCase(Arguments args) { | 3578 static Object* Runtime_StringToLowerCase(Arguments args) { |
| 3579 return ConvertCase<unibrow::ToLowercase>(args, &to_lower_mapping); | 3579 return ConvertCase<unibrow::ToLowercase>(args, &to_lower_mapping); |
| 3580 } | 3580 } |
| 3581 | 3581 |
| 3582 | 3582 |
| 3583 static Object* Runtime_StringToUpperCase(Arguments args) { | 3583 static Object* Runtime_StringToUpperCase(Arguments args) { |
| 3584 return ConvertCase<unibrow::ToUppercase>(args, &to_upper_mapping); | 3584 return ConvertCase<unibrow::ToUppercase>(args, &to_upper_mapping); |
| 3585 } | 3585 } |
| 3586 | 3586 |
| 3587 static inline bool IsTrimWhiteSpace(unibrow::uchar c) { |
| 3588 return unibrow::WhiteSpace::Is(c) || c == 0x200b; |
| 3589 } |
| 3590 |
| 3591 static Object* Runtime_StringTrim(Arguments args) { |
| 3592 NoHandleAllocation ha; |
| 3593 ASSERT(args.length() == 3); |
| 3594 |
| 3595 CONVERT_CHECKED(String, s, args[0]); |
| 3596 CONVERT_BOOLEAN_CHECKED(trimLeft, args[1]); |
| 3597 CONVERT_BOOLEAN_CHECKED(trimRight, args[2]); |
| 3598 |
| 3599 s->TryFlattenIfNotFlat(); |
| 3600 int length = s->length(); |
| 3601 |
| 3602 int left = 0; |
| 3603 if (trimLeft) { |
| 3604 while (left < length && IsTrimWhiteSpace(s->Get(left))) |
| 3605 left++; |
| 3606 } |
| 3607 |
| 3608 int right = length; |
| 3609 if (trimRight) { |
| 3610 while (right > left && IsTrimWhiteSpace(s->Get(right - 1))) |
| 3611 right--; |
| 3612 } |
| 3613 return s->Slice(left, right); |
| 3614 } |
| 3587 | 3615 |
| 3588 bool Runtime::IsUpperCaseChar(uint16_t ch) { | 3616 bool Runtime::IsUpperCaseChar(uint16_t ch) { |
| 3589 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; | 3617 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; |
| 3590 int char_length = to_upper_mapping.get(ch, 0, chars); | 3618 int char_length = to_upper_mapping.get(ch, 0, chars); |
| 3591 return char_length == 0; | 3619 return char_length == 0; |
| 3592 } | 3620 } |
| 3593 | 3621 |
| 3594 | 3622 |
| 3595 static Object* Runtime_NumberToString(Arguments args) { | 3623 static Object* Runtime_NumberToString(Arguments args) { |
| 3596 NoHandleAllocation ha; | 3624 NoHandleAllocation ha; |
| (...skipping 4125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7722 } else { | 7750 } else { |
| 7723 // Handle last resort GC and make sure to allow future allocations | 7751 // Handle last resort GC and make sure to allow future allocations |
| 7724 // to grow the heap without causing GCs (if possible). | 7752 // to grow the heap without causing GCs (if possible). |
| 7725 Counters::gc_last_resort_from_js.Increment(); | 7753 Counters::gc_last_resort_from_js.Increment(); |
| 7726 Heap::CollectAllGarbage(false); | 7754 Heap::CollectAllGarbage(false); |
| 7727 } | 7755 } |
| 7728 } | 7756 } |
| 7729 | 7757 |
| 7730 | 7758 |
| 7731 } } // namespace v8::internal | 7759 } } // namespace v8::internal |
| OLD | NEW |