| 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 2510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2521 Heap* heap_; | 2521 Heap* heap_; |
| 2522 FixedArrayBuilder array_builder_; | 2522 FixedArrayBuilder array_builder_; |
| 2523 Handle<String> subject_; | 2523 Handle<String> subject_; |
| 2524 int character_count_; | 2524 int character_count_; |
| 2525 bool is_ascii_; | 2525 bool is_ascii_; |
| 2526 }; | 2526 }; |
| 2527 | 2527 |
| 2528 | 2528 |
| 2529 class CompiledReplacement { | 2529 class CompiledReplacement { |
| 2530 public: | 2530 public: |
| 2531 CompiledReplacement() | 2531 explicit CompiledReplacement(Zone* zone) |
| 2532 : parts_(1), replacement_substrings_(0), simple_hint_(false) {} | 2532 : parts_(1, zone), replacement_substrings_(0, zone), |
| 2533 simple_hint_(false), |
| 2534 zone_(zone) {} |
| 2533 | 2535 |
| 2534 void Compile(Handle<String> replacement, | 2536 void Compile(Handle<String> replacement, |
| 2535 int capture_count, | 2537 int capture_count, |
| 2536 int subject_length); | 2538 int subject_length); |
| 2537 | 2539 |
| 2538 void Apply(ReplacementStringBuilder* builder, | 2540 void Apply(ReplacementStringBuilder* builder, |
| 2539 int match_from, | 2541 int match_from, |
| 2540 int match_to, | 2542 int match_to, |
| 2541 Handle<JSArray> last_match_info); | 2543 Handle<JSArray> last_match_info); |
| 2542 | 2544 |
| 2543 // Number of distinct parts of the replacement pattern. | 2545 // Number of distinct parts of the replacement pattern. |
| 2544 int parts() { | 2546 int parts() { |
| 2545 return parts_.length(); | 2547 return parts_.length(); |
| 2546 } | 2548 } |
| 2547 | 2549 |
| 2548 bool simple_hint() { | 2550 bool simple_hint() { |
| 2549 return simple_hint_; | 2551 return simple_hint_; |
| 2550 } | 2552 } |
| 2551 | 2553 |
| 2554 Zone* zone() const { return zone_; } |
| 2555 |
| 2552 private: | 2556 private: |
| 2553 enum PartType { | 2557 enum PartType { |
| 2554 SUBJECT_PREFIX = 1, | 2558 SUBJECT_PREFIX = 1, |
| 2555 SUBJECT_SUFFIX, | 2559 SUBJECT_SUFFIX, |
| 2556 SUBJECT_CAPTURE, | 2560 SUBJECT_CAPTURE, |
| 2557 REPLACEMENT_SUBSTRING, | 2561 REPLACEMENT_SUBSTRING, |
| 2558 REPLACEMENT_STRING, | 2562 REPLACEMENT_STRING, |
| 2559 | 2563 |
| 2560 NUMBER_OF_PART_TYPES | 2564 NUMBER_OF_PART_TYPES |
| 2561 }; | 2565 }; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2603 // string ranging over -tag .. data. | 2607 // string ranging over -tag .. data. |
| 2604 // Is replaced by REPLACEMENT_{SUB,}STRING when we create the | 2608 // Is replaced by REPLACEMENT_{SUB,}STRING when we create the |
| 2605 // substring objects. | 2609 // substring objects. |
| 2606 int data; | 2610 int data; |
| 2607 }; | 2611 }; |
| 2608 | 2612 |
| 2609 template<typename Char> | 2613 template<typename Char> |
| 2610 static bool ParseReplacementPattern(ZoneList<ReplacementPart>* parts, | 2614 static bool ParseReplacementPattern(ZoneList<ReplacementPart>* parts, |
| 2611 Vector<Char> characters, | 2615 Vector<Char> characters, |
| 2612 int capture_count, | 2616 int capture_count, |
| 2613 int subject_length) { | 2617 int subject_length, |
| 2618 Zone* zone) { |
| 2614 int length = characters.length(); | 2619 int length = characters.length(); |
| 2615 int last = 0; | 2620 int last = 0; |
| 2616 for (int i = 0; i < length; i++) { | 2621 for (int i = 0; i < length; i++) { |
| 2617 Char c = characters[i]; | 2622 Char c = characters[i]; |
| 2618 if (c == '$') { | 2623 if (c == '$') { |
| 2619 int next_index = i + 1; | 2624 int next_index = i + 1; |
| 2620 if (next_index == length) { // No next character! | 2625 if (next_index == length) { // No next character! |
| 2621 break; | 2626 break; |
| 2622 } | 2627 } |
| 2623 Char c2 = characters[next_index]; | 2628 Char c2 = characters[next_index]; |
| 2624 switch (c2) { | 2629 switch (c2) { |
| 2625 case '$': | 2630 case '$': |
| 2626 if (i > last) { | 2631 if (i > last) { |
| 2627 // There is a substring before. Include the first "$". | 2632 // There is a substring before. Include the first "$". |
| 2628 parts->Add(ReplacementPart::ReplacementSubString(last, next_index)); | 2633 parts->Add(ReplacementPart::ReplacementSubString(last, next_index), |
| 2634 zone); |
| 2629 last = next_index + 1; // Continue after the second "$". | 2635 last = next_index + 1; // Continue after the second "$". |
| 2630 } else { | 2636 } else { |
| 2631 // Let the next substring start with the second "$". | 2637 // Let the next substring start with the second "$". |
| 2632 last = next_index; | 2638 last = next_index; |
| 2633 } | 2639 } |
| 2634 i = next_index; | 2640 i = next_index; |
| 2635 break; | 2641 break; |
| 2636 case '`': | 2642 case '`': |
| 2637 if (i > last) { | 2643 if (i > last) { |
| 2638 parts->Add(ReplacementPart::ReplacementSubString(last, i)); | 2644 parts->Add(ReplacementPart::ReplacementSubString(last, i), zone); |
| 2639 } | 2645 } |
| 2640 parts->Add(ReplacementPart::SubjectPrefix()); | 2646 parts->Add(ReplacementPart::SubjectPrefix(), zone); |
| 2641 i = next_index; | 2647 i = next_index; |
| 2642 last = i + 1; | 2648 last = i + 1; |
| 2643 break; | 2649 break; |
| 2644 case '\'': | 2650 case '\'': |
| 2645 if (i > last) { | 2651 if (i > last) { |
| 2646 parts->Add(ReplacementPart::ReplacementSubString(last, i)); | 2652 parts->Add(ReplacementPart::ReplacementSubString(last, i), zone); |
| 2647 } | 2653 } |
| 2648 parts->Add(ReplacementPart::SubjectSuffix(subject_length)); | 2654 parts->Add(ReplacementPart::SubjectSuffix(subject_length), zone); |
| 2649 i = next_index; | 2655 i = next_index; |
| 2650 last = i + 1; | 2656 last = i + 1; |
| 2651 break; | 2657 break; |
| 2652 case '&': | 2658 case '&': |
| 2653 if (i > last) { | 2659 if (i > last) { |
| 2654 parts->Add(ReplacementPart::ReplacementSubString(last, i)); | 2660 parts->Add(ReplacementPart::ReplacementSubString(last, i), zone); |
| 2655 } | 2661 } |
| 2656 parts->Add(ReplacementPart::SubjectMatch()); | 2662 parts->Add(ReplacementPart::SubjectMatch(), zone); |
| 2657 i = next_index; | 2663 i = next_index; |
| 2658 last = i + 1; | 2664 last = i + 1; |
| 2659 break; | 2665 break; |
| 2660 case '0': | 2666 case '0': |
| 2661 case '1': | 2667 case '1': |
| 2662 case '2': | 2668 case '2': |
| 2663 case '3': | 2669 case '3': |
| 2664 case '4': | 2670 case '4': |
| 2665 case '5': | 2671 case '5': |
| 2666 case '6': | 2672 case '6': |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2679 if ('0' <= c3 && c3 <= '9') { // Double digits. | 2685 if ('0' <= c3 && c3 <= '9') { // Double digits. |
| 2680 int double_digit_ref = capture_ref * 10 + c3 - '0'; | 2686 int double_digit_ref = capture_ref * 10 + c3 - '0'; |
| 2681 if (double_digit_ref <= capture_count) { | 2687 if (double_digit_ref <= capture_count) { |
| 2682 next_index = second_digit_index; | 2688 next_index = second_digit_index; |
| 2683 capture_ref = double_digit_ref; | 2689 capture_ref = double_digit_ref; |
| 2684 } | 2690 } |
| 2685 } | 2691 } |
| 2686 } | 2692 } |
| 2687 if (capture_ref > 0) { | 2693 if (capture_ref > 0) { |
| 2688 if (i > last) { | 2694 if (i > last) { |
| 2689 parts->Add(ReplacementPart::ReplacementSubString(last, i)); | 2695 parts->Add(ReplacementPart::ReplacementSubString(last, i), zone); |
| 2690 } | 2696 } |
| 2691 ASSERT(capture_ref <= capture_count); | 2697 ASSERT(capture_ref <= capture_count); |
| 2692 parts->Add(ReplacementPart::SubjectCapture(capture_ref)); | 2698 parts->Add(ReplacementPart::SubjectCapture(capture_ref), zone); |
| 2693 last = next_index + 1; | 2699 last = next_index + 1; |
| 2694 } | 2700 } |
| 2695 i = next_index; | 2701 i = next_index; |
| 2696 break; | 2702 break; |
| 2697 } | 2703 } |
| 2698 default: | 2704 default: |
| 2699 i = next_index; | 2705 i = next_index; |
| 2700 break; | 2706 break; |
| 2701 } | 2707 } |
| 2702 } | 2708 } |
| 2703 } | 2709 } |
| 2704 if (length > last) { | 2710 if (length > last) { |
| 2705 if (last == 0) { | 2711 if (last == 0) { |
| 2706 parts->Add(ReplacementPart::ReplacementString()); | 2712 parts->Add(ReplacementPart::ReplacementString(), zone); |
| 2707 return true; | 2713 return true; |
| 2708 } else { | 2714 } else { |
| 2709 parts->Add(ReplacementPart::ReplacementSubString(last, length)); | 2715 parts->Add(ReplacementPart::ReplacementSubString(last, length), zone); |
| 2710 } | 2716 } |
| 2711 } | 2717 } |
| 2712 return false; | 2718 return false; |
| 2713 } | 2719 } |
| 2714 | 2720 |
| 2715 ZoneList<ReplacementPart> parts_; | 2721 ZoneList<ReplacementPart> parts_; |
| 2716 ZoneList<Handle<String> > replacement_substrings_; | 2722 ZoneList<Handle<String> > replacement_substrings_; |
| 2717 bool simple_hint_; | 2723 bool simple_hint_; |
| 2724 Zone* zone_; |
| 2718 }; | 2725 }; |
| 2719 | 2726 |
| 2720 | 2727 |
| 2721 void CompiledReplacement::Compile(Handle<String> replacement, | 2728 void CompiledReplacement::Compile(Handle<String> replacement, |
| 2722 int capture_count, | 2729 int capture_count, |
| 2723 int subject_length) { | 2730 int subject_length) { |
| 2724 { | 2731 { |
| 2725 AssertNoAllocation no_alloc; | 2732 AssertNoAllocation no_alloc; |
| 2726 String::FlatContent content = replacement->GetFlatContent(); | 2733 String::FlatContent content = replacement->GetFlatContent(); |
| 2727 ASSERT(content.IsFlat()); | 2734 ASSERT(content.IsFlat()); |
| 2728 if (content.IsAscii()) { | 2735 if (content.IsAscii()) { |
| 2729 simple_hint_ = ParseReplacementPattern(&parts_, | 2736 simple_hint_ = ParseReplacementPattern(&parts_, |
| 2730 content.ToAsciiVector(), | 2737 content.ToAsciiVector(), |
| 2731 capture_count, | 2738 capture_count, |
| 2732 subject_length); | 2739 subject_length, |
| 2740 zone()); |
| 2733 } else { | 2741 } else { |
| 2734 ASSERT(content.IsTwoByte()); | 2742 ASSERT(content.IsTwoByte()); |
| 2735 simple_hint_ = ParseReplacementPattern(&parts_, | 2743 simple_hint_ = ParseReplacementPattern(&parts_, |
| 2736 content.ToUC16Vector(), | 2744 content.ToUC16Vector(), |
| 2737 capture_count, | 2745 capture_count, |
| 2738 subject_length); | 2746 subject_length, |
| 2747 zone()); |
| 2739 } | 2748 } |
| 2740 } | 2749 } |
| 2741 Isolate* isolate = replacement->GetIsolate(); | 2750 Isolate* isolate = replacement->GetIsolate(); |
| 2742 // Find substrings of replacement string and create them as String objects. | 2751 // Find substrings of replacement string and create them as String objects. |
| 2743 int substring_index = 0; | 2752 int substring_index = 0; |
| 2744 for (int i = 0, n = parts_.length(); i < n; i++) { | 2753 for (int i = 0, n = parts_.length(); i < n; i++) { |
| 2745 int tag = parts_[i].tag; | 2754 int tag = parts_[i].tag; |
| 2746 if (tag <= 0) { // A replacement string slice. | 2755 if (tag <= 0) { // A replacement string slice. |
| 2747 int from = -tag; | 2756 int from = -tag; |
| 2748 int to = parts_[i].data; | 2757 int to = parts_[i].data; |
| 2749 replacement_substrings_.Add( | 2758 replacement_substrings_.Add( |
| 2750 isolate->factory()->NewSubString(replacement, from, to)); | 2759 isolate->factory()->NewSubString(replacement, from, to), zone()); |
| 2751 parts_[i].tag = REPLACEMENT_SUBSTRING; | 2760 parts_[i].tag = REPLACEMENT_SUBSTRING; |
| 2752 parts_[i].data = substring_index; | 2761 parts_[i].data = substring_index; |
| 2753 substring_index++; | 2762 substring_index++; |
| 2754 } else if (tag == REPLACEMENT_STRING) { | 2763 } else if (tag == REPLACEMENT_STRING) { |
| 2755 replacement_substrings_.Add(replacement); | 2764 replacement_substrings_.Add(replacement, zone()); |
| 2756 parts_[i].data = substring_index; | 2765 parts_[i].data = substring_index; |
| 2757 substring_index++; | 2766 substring_index++; |
| 2758 } | 2767 } |
| 2759 } | 2768 } |
| 2760 } | 2769 } |
| 2761 | 2770 |
| 2762 | 2771 |
| 2763 void CompiledReplacement::Apply(ReplacementStringBuilder* builder, | 2772 void CompiledReplacement::Apply(ReplacementStringBuilder* builder, |
| 2764 int match_from, | 2773 int match_from, |
| 2765 int match_to, | 2774 int match_to, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2794 default: | 2803 default: |
| 2795 UNREACHABLE(); | 2804 UNREACHABLE(); |
| 2796 } | 2805 } |
| 2797 } | 2806 } |
| 2798 } | 2807 } |
| 2799 | 2808 |
| 2800 | 2809 |
| 2801 void FindAsciiStringIndices(Vector<const char> subject, | 2810 void FindAsciiStringIndices(Vector<const char> subject, |
| 2802 char pattern, | 2811 char pattern, |
| 2803 ZoneList<int>* indices, | 2812 ZoneList<int>* indices, |
| 2804 unsigned int limit) { | 2813 unsigned int limit, |
| 2814 Zone* zone) { |
| 2805 ASSERT(limit > 0); | 2815 ASSERT(limit > 0); |
| 2806 // Collect indices of pattern in subject using memchr. | 2816 // Collect indices of pattern in subject using memchr. |
| 2807 // Stop after finding at most limit values. | 2817 // Stop after finding at most limit values. |
| 2808 const char* subject_start = reinterpret_cast<const char*>(subject.start()); | 2818 const char* subject_start = reinterpret_cast<const char*>(subject.start()); |
| 2809 const char* subject_end = subject_start + subject.length(); | 2819 const char* subject_end = subject_start + subject.length(); |
| 2810 const char* pos = subject_start; | 2820 const char* pos = subject_start; |
| 2811 while (limit > 0) { | 2821 while (limit > 0) { |
| 2812 pos = reinterpret_cast<const char*>( | 2822 pos = reinterpret_cast<const char*>( |
| 2813 memchr(pos, pattern, subject_end - pos)); | 2823 memchr(pos, pattern, subject_end - pos)); |
| 2814 if (pos == NULL) return; | 2824 if (pos == NULL) return; |
| 2815 indices->Add(static_cast<int>(pos - subject_start)); | 2825 indices->Add(static_cast<int>(pos - subject_start), zone); |
| 2816 pos++; | 2826 pos++; |
| 2817 limit--; | 2827 limit--; |
| 2818 } | 2828 } |
| 2819 } | 2829 } |
| 2820 | 2830 |
| 2821 | 2831 |
| 2822 template <typename SubjectChar, typename PatternChar> | 2832 template <typename SubjectChar, typename PatternChar> |
| 2823 void FindStringIndices(Isolate* isolate, | 2833 void FindStringIndices(Isolate* isolate, |
| 2824 Vector<const SubjectChar> subject, | 2834 Vector<const SubjectChar> subject, |
| 2825 Vector<const PatternChar> pattern, | 2835 Vector<const PatternChar> pattern, |
| 2826 ZoneList<int>* indices, | 2836 ZoneList<int>* indices, |
| 2827 unsigned int limit) { | 2837 unsigned int limit, |
| 2838 Zone* zone) { |
| 2828 ASSERT(limit > 0); | 2839 ASSERT(limit > 0); |
| 2829 // Collect indices of pattern in subject. | 2840 // Collect indices of pattern in subject. |
| 2830 // Stop after finding at most limit values. | 2841 // Stop after finding at most limit values. |
| 2831 int pattern_length = pattern.length(); | 2842 int pattern_length = pattern.length(); |
| 2832 int index = 0; | 2843 int index = 0; |
| 2833 StringSearch<PatternChar, SubjectChar> search(isolate, pattern); | 2844 StringSearch<PatternChar, SubjectChar> search(isolate, pattern); |
| 2834 while (limit > 0) { | 2845 while (limit > 0) { |
| 2835 index = search.Search(subject, index); | 2846 index = search.Search(subject, index); |
| 2836 if (index < 0) return; | 2847 if (index < 0) return; |
| 2837 indices->Add(index); | 2848 indices->Add(index, zone); |
| 2838 index += pattern_length; | 2849 index += pattern_length; |
| 2839 limit--; | 2850 limit--; |
| 2840 } | 2851 } |
| 2841 } | 2852 } |
| 2842 | 2853 |
| 2843 | 2854 |
| 2844 void FindStringIndicesDispatch(Isolate* isolate, | 2855 void FindStringIndicesDispatch(Isolate* isolate, |
| 2845 String* subject, | 2856 String* subject, |
| 2846 String* pattern, | 2857 String* pattern, |
| 2847 ZoneList<int>* indices, | 2858 ZoneList<int>* indices, |
| 2848 unsigned int limit) { | 2859 unsigned int limit, |
| 2860 Zone* zone) { |
| 2849 { | 2861 { |
| 2850 AssertNoAllocation no_gc; | 2862 AssertNoAllocation no_gc; |
| 2851 String::FlatContent subject_content = subject->GetFlatContent(); | 2863 String::FlatContent subject_content = subject->GetFlatContent(); |
| 2852 String::FlatContent pattern_content = pattern->GetFlatContent(); | 2864 String::FlatContent pattern_content = pattern->GetFlatContent(); |
| 2853 ASSERT(subject_content.IsFlat()); | 2865 ASSERT(subject_content.IsFlat()); |
| 2854 ASSERT(pattern_content.IsFlat()); | 2866 ASSERT(pattern_content.IsFlat()); |
| 2855 if (subject_content.IsAscii()) { | 2867 if (subject_content.IsAscii()) { |
| 2856 Vector<const char> subject_vector = subject_content.ToAsciiVector(); | 2868 Vector<const char> subject_vector = subject_content.ToAsciiVector(); |
| 2857 if (pattern_content.IsAscii()) { | 2869 if (pattern_content.IsAscii()) { |
| 2858 Vector<const char> pattern_vector = pattern_content.ToAsciiVector(); | 2870 Vector<const char> pattern_vector = pattern_content.ToAsciiVector(); |
| 2859 if (pattern_vector.length() == 1) { | 2871 if (pattern_vector.length() == 1) { |
| 2860 FindAsciiStringIndices(subject_vector, | 2872 FindAsciiStringIndices(subject_vector, |
| 2861 pattern_vector[0], | 2873 pattern_vector[0], |
| 2862 indices, | 2874 indices, |
| 2863 limit); | 2875 limit, |
| 2876 zone); |
| 2864 } else { | 2877 } else { |
| 2865 FindStringIndices(isolate, | 2878 FindStringIndices(isolate, |
| 2866 subject_vector, | 2879 subject_vector, |
| 2867 pattern_vector, | 2880 pattern_vector, |
| 2868 indices, | 2881 indices, |
| 2869 limit); | 2882 limit, |
| 2883 zone); |
| 2870 } | 2884 } |
| 2871 } else { | 2885 } else { |
| 2872 FindStringIndices(isolate, | 2886 FindStringIndices(isolate, |
| 2873 subject_vector, | 2887 subject_vector, |
| 2874 pattern_content.ToUC16Vector(), | 2888 pattern_content.ToUC16Vector(), |
| 2875 indices, | 2889 indices, |
| 2876 limit); | 2890 limit, |
| 2891 zone); |
| 2877 } | 2892 } |
| 2878 } else { | 2893 } else { |
| 2879 Vector<const uc16> subject_vector = subject_content.ToUC16Vector(); | 2894 Vector<const uc16> subject_vector = subject_content.ToUC16Vector(); |
| 2880 if (pattern_content.IsAscii()) { | 2895 if (pattern_content.IsAscii()) { |
| 2881 FindStringIndices(isolate, | 2896 FindStringIndices(isolate, |
| 2882 subject_vector, | 2897 subject_vector, |
| 2883 pattern_content.ToAsciiVector(), | 2898 pattern_content.ToAsciiVector(), |
| 2884 indices, | 2899 indices, |
| 2885 limit); | 2900 limit, |
| 2901 zone); |
| 2886 } else { | 2902 } else { |
| 2887 FindStringIndices(isolate, | 2903 FindStringIndices(isolate, |
| 2888 subject_vector, | 2904 subject_vector, |
| 2889 pattern_content.ToUC16Vector(), | 2905 pattern_content.ToUC16Vector(), |
| 2890 indices, | 2906 indices, |
| 2891 limit); | 2907 limit, |
| 2908 zone); |
| 2892 } | 2909 } |
| 2893 } | 2910 } |
| 2894 } | 2911 } |
| 2895 } | 2912 } |
| 2896 | 2913 |
| 2897 | 2914 |
| 2898 // Two smis before and after the match, for very long strings. | 2915 // Two smis before and after the match, for very long strings. |
| 2899 const int kMaxBuilderEntriesPerRegExpMatch = 5; | 2916 const int kMaxBuilderEntriesPerRegExpMatch = 5; |
| 2900 | 2917 |
| 2901 | 2918 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2960 | 2977 |
| 2961 | 2978 |
| 2962 | 2979 |
| 2963 | 2980 |
| 2964 template<typename ResultSeqString> | 2981 template<typename ResultSeqString> |
| 2965 MUST_USE_RESULT static MaybeObject* StringReplaceAtomRegExpWithString( | 2982 MUST_USE_RESULT static MaybeObject* StringReplaceAtomRegExpWithString( |
| 2966 Isolate* isolate, | 2983 Isolate* isolate, |
| 2967 Handle<String> subject, | 2984 Handle<String> subject, |
| 2968 Handle<JSRegExp> pattern_regexp, | 2985 Handle<JSRegExp> pattern_regexp, |
| 2969 Handle<String> replacement, | 2986 Handle<String> replacement, |
| 2970 Handle<JSArray> last_match_info) { | 2987 Handle<JSArray> last_match_info, |
| 2988 Zone* zone) { |
| 2971 ASSERT(subject->IsFlat()); | 2989 ASSERT(subject->IsFlat()); |
| 2972 ASSERT(replacement->IsFlat()); | 2990 ASSERT(replacement->IsFlat()); |
| 2973 | 2991 |
| 2974 ZoneScope zone_space(isolate, DELETE_ON_EXIT); | 2992 ZoneScope zone_space(isolate, DELETE_ON_EXIT); |
| 2975 ZoneList<int> indices(8); | 2993 ZoneList<int> indices(8, isolate->zone()); |
| 2976 ASSERT_EQ(JSRegExp::ATOM, pattern_regexp->TypeTag()); | 2994 ASSERT_EQ(JSRegExp::ATOM, pattern_regexp->TypeTag()); |
| 2977 String* pattern = | 2995 String* pattern = |
| 2978 String::cast(pattern_regexp->DataAt(JSRegExp::kAtomPatternIndex)); | 2996 String::cast(pattern_regexp->DataAt(JSRegExp::kAtomPatternIndex)); |
| 2979 int subject_len = subject->length(); | 2997 int subject_len = subject->length(); |
| 2980 int pattern_len = pattern->length(); | 2998 int pattern_len = pattern->length(); |
| 2981 int replacement_len = replacement->length(); | 2999 int replacement_len = replacement->length(); |
| 2982 | 3000 |
| 2983 FindStringIndicesDispatch(isolate, *subject, pattern, &indices, 0xffffffff); | 3001 FindStringIndicesDispatch(isolate, *subject, pattern, &indices, 0xffffffff, |
| 3002 zone); |
| 2984 | 3003 |
| 2985 int matches = indices.length(); | 3004 int matches = indices.length(); |
| 2986 if (matches == 0) return *subject; | 3005 if (matches == 0) return *subject; |
| 2987 | 3006 |
| 2988 int result_len = (replacement_len - pattern_len) * matches + subject_len; | 3007 int result_len = (replacement_len - pattern_len) * matches + subject_len; |
| 2989 int subject_pos = 0; | 3008 int subject_pos = 0; |
| 2990 int result_pos = 0; | 3009 int result_pos = 0; |
| 2991 | 3010 |
| 2992 Handle<ResultSeqString> result; | 3011 Handle<ResultSeqString> result; |
| 2993 if (ResultSeqString::kHasAsciiEncoding) { | 3012 if (ResultSeqString::kHasAsciiEncoding) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3034 | 3053 |
| 3035 return *result; | 3054 return *result; |
| 3036 } | 3055 } |
| 3037 | 3056 |
| 3038 | 3057 |
| 3039 MUST_USE_RESULT static MaybeObject* StringReplaceRegExpWithString( | 3058 MUST_USE_RESULT static MaybeObject* StringReplaceRegExpWithString( |
| 3040 Isolate* isolate, | 3059 Isolate* isolate, |
| 3041 String* subject, | 3060 String* subject, |
| 3042 JSRegExp* regexp, | 3061 JSRegExp* regexp, |
| 3043 String* replacement, | 3062 String* replacement, |
| 3044 JSArray* last_match_info) { | 3063 JSArray* last_match_info, |
| 3064 Zone* zone) { |
| 3045 ASSERT(subject->IsFlat()); | 3065 ASSERT(subject->IsFlat()); |
| 3046 ASSERT(replacement->IsFlat()); | 3066 ASSERT(replacement->IsFlat()); |
| 3047 | 3067 |
| 3048 HandleScope handles(isolate); | 3068 HandleScope handles(isolate); |
| 3049 | 3069 |
| 3050 int length = subject->length(); | 3070 int length = subject->length(); |
| 3051 Handle<String> subject_handle(subject); | 3071 Handle<String> subject_handle(subject); |
| 3052 Handle<JSRegExp> regexp_handle(regexp); | 3072 Handle<JSRegExp> regexp_handle(regexp); |
| 3053 Handle<String> replacement_handle(replacement); | 3073 Handle<String> replacement_handle(replacement); |
| 3054 Handle<JSArray> last_match_info_handle(last_match_info); | 3074 Handle<JSArray> last_match_info_handle(last_match_info); |
| 3055 Handle<Object> match = RegExpImpl::Exec(regexp_handle, | 3075 Handle<Object> match = RegExpImpl::Exec(regexp_handle, |
| 3056 subject_handle, | 3076 subject_handle, |
| 3057 0, | 3077 0, |
| 3058 last_match_info_handle, | 3078 last_match_info_handle, |
| 3059 isolate->zone()); | 3079 isolate->zone()); |
| 3060 if (match.is_null()) { | 3080 if (match.is_null()) { |
| 3061 return Failure::Exception(); | 3081 return Failure::Exception(); |
| 3062 } | 3082 } |
| 3063 if (match->IsNull()) { | 3083 if (match->IsNull()) { |
| 3064 return *subject_handle; | 3084 return *subject_handle; |
| 3065 } | 3085 } |
| 3066 | 3086 |
| 3067 int capture_count = regexp_handle->CaptureCount(); | 3087 int capture_count = regexp_handle->CaptureCount(); |
| 3068 | 3088 |
| 3069 // CompiledReplacement uses zone allocation. | 3089 // CompiledReplacement uses zone allocation. |
| 3070 ZoneScope zone(isolate, DELETE_ON_EXIT); | 3090 ZoneScope zonescope(isolate, DELETE_ON_EXIT); |
| 3071 CompiledReplacement compiled_replacement; | 3091 CompiledReplacement compiled_replacement(isolate->zone()); |
| 3072 compiled_replacement.Compile(replacement_handle, | 3092 compiled_replacement.Compile(replacement_handle, |
| 3073 capture_count, | 3093 capture_count, |
| 3074 length); | 3094 length); |
| 3075 | 3095 |
| 3076 bool is_global = regexp_handle->GetFlags().is_global(); | 3096 bool is_global = regexp_handle->GetFlags().is_global(); |
| 3077 | 3097 |
| 3078 // Shortcut for simple non-regexp global replacements | 3098 // Shortcut for simple non-regexp global replacements |
| 3079 if (is_global && | 3099 if (is_global && |
| 3080 regexp_handle->TypeTag() == JSRegExp::ATOM && | 3100 regexp_handle->TypeTag() == JSRegExp::ATOM && |
| 3081 compiled_replacement.simple_hint()) { | 3101 compiled_replacement.simple_hint()) { |
| 3082 if (subject_handle->HasOnlyAsciiChars() && | 3102 if (subject_handle->HasOnlyAsciiChars() && |
| 3083 replacement_handle->HasOnlyAsciiChars()) { | 3103 replacement_handle->HasOnlyAsciiChars()) { |
| 3084 return StringReplaceAtomRegExpWithString<SeqAsciiString>( | 3104 return StringReplaceAtomRegExpWithString<SeqAsciiString>( |
| 3085 isolate, | 3105 isolate, |
| 3086 subject_handle, | 3106 subject_handle, |
| 3087 regexp_handle, | 3107 regexp_handle, |
| 3088 replacement_handle, | 3108 replacement_handle, |
| 3089 last_match_info_handle); | 3109 last_match_info_handle, |
| 3110 zone); |
| 3090 } else { | 3111 } else { |
| 3091 return StringReplaceAtomRegExpWithString<SeqTwoByteString>( | 3112 return StringReplaceAtomRegExpWithString<SeqTwoByteString>( |
| 3092 isolate, | 3113 isolate, |
| 3093 subject_handle, | 3114 subject_handle, |
| 3094 regexp_handle, | 3115 regexp_handle, |
| 3095 replacement_handle, | 3116 replacement_handle, |
| 3096 last_match_info_handle); | 3117 last_match_info_handle, |
| 3118 zone); |
| 3097 } | 3119 } |
| 3098 } | 3120 } |
| 3099 | 3121 |
| 3100 // Guessing the number of parts that the final result string is built | 3122 // Guessing the number of parts that the final result string is built |
| 3101 // from. Global regexps can match any number of times, so we guess | 3123 // from. Global regexps can match any number of times, so we guess |
| 3102 // conservatively. | 3124 // conservatively. |
| 3103 int expected_parts = | 3125 int expected_parts = |
| 3104 (compiled_replacement.parts() + 1) * (is_global ? 4 : 1) + 1; | 3126 (compiled_replacement.parts() + 1) * (is_global ? 4 : 1) + 1; |
| 3105 ReplacementStringBuilder builder(isolate->heap(), | 3127 ReplacementStringBuilder builder(isolate->heap(), |
| 3106 subject_handle, | 3128 subject_handle, |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3169 | 3191 |
| 3170 return *(builder.ToString()); | 3192 return *(builder.ToString()); |
| 3171 } | 3193 } |
| 3172 | 3194 |
| 3173 | 3195 |
| 3174 template <typename ResultSeqString> | 3196 template <typename ResultSeqString> |
| 3175 MUST_USE_RESULT static MaybeObject* StringReplaceRegExpWithEmptyString( | 3197 MUST_USE_RESULT static MaybeObject* StringReplaceRegExpWithEmptyString( |
| 3176 Isolate* isolate, | 3198 Isolate* isolate, |
| 3177 String* subject, | 3199 String* subject, |
| 3178 JSRegExp* regexp, | 3200 JSRegExp* regexp, |
| 3179 JSArray* last_match_info) { | 3201 JSArray* last_match_info, |
| 3202 Zone* zone) { |
| 3180 ASSERT(subject->IsFlat()); | 3203 ASSERT(subject->IsFlat()); |
| 3181 | 3204 |
| 3182 HandleScope handles(isolate); | 3205 HandleScope handles(isolate); |
| 3183 | 3206 |
| 3184 Handle<String> subject_handle(subject); | 3207 Handle<String> subject_handle(subject); |
| 3185 Handle<JSRegExp> regexp_handle(regexp); | 3208 Handle<JSRegExp> regexp_handle(regexp); |
| 3186 Handle<JSArray> last_match_info_handle(last_match_info); | 3209 Handle<JSArray> last_match_info_handle(last_match_info); |
| 3187 | 3210 |
| 3188 // Shortcut for simple non-regexp global replacements | 3211 // Shortcut for simple non-regexp global replacements |
| 3189 if (regexp_handle->GetFlags().is_global() && | 3212 if (regexp_handle->GetFlags().is_global() && |
| 3190 regexp_handle->TypeTag() == JSRegExp::ATOM) { | 3213 regexp_handle->TypeTag() == JSRegExp::ATOM) { |
| 3191 Handle<String> empty_string_handle(HEAP->empty_string()); | 3214 Handle<String> empty_string_handle(HEAP->empty_string()); |
| 3192 if (subject_handle->HasOnlyAsciiChars()) { | 3215 if (subject_handle->HasOnlyAsciiChars()) { |
| 3193 return StringReplaceAtomRegExpWithString<SeqAsciiString>( | 3216 return StringReplaceAtomRegExpWithString<SeqAsciiString>( |
| 3194 isolate, | 3217 isolate, |
| 3195 subject_handle, | 3218 subject_handle, |
| 3196 regexp_handle, | 3219 regexp_handle, |
| 3197 empty_string_handle, | 3220 empty_string_handle, |
| 3198 last_match_info_handle); | 3221 last_match_info_handle, |
| 3222 zone); |
| 3199 } else { | 3223 } else { |
| 3200 return StringReplaceAtomRegExpWithString<SeqTwoByteString>( | 3224 return StringReplaceAtomRegExpWithString<SeqTwoByteString>( |
| 3201 isolate, | 3225 isolate, |
| 3202 subject_handle, | 3226 subject_handle, |
| 3203 regexp_handle, | 3227 regexp_handle, |
| 3204 empty_string_handle, | 3228 empty_string_handle, |
| 3205 last_match_info_handle); | 3229 last_match_info_handle, |
| 3230 zone); |
| 3206 } | 3231 } |
| 3207 } | 3232 } |
| 3208 | 3233 |
| 3209 Handle<Object> match = RegExpImpl::Exec(regexp_handle, | 3234 Handle<Object> match = RegExpImpl::Exec(regexp_handle, |
| 3210 subject_handle, | 3235 subject_handle, |
| 3211 0, | 3236 0, |
| 3212 last_match_info_handle, | 3237 last_match_info_handle, |
| 3213 isolate->zone()); | 3238 isolate->zone()); |
| 3214 if (match.is_null()) return Failure::Exception(); | 3239 if (match.is_null()) return Failure::Exception(); |
| 3215 if (match->IsNull()) return *subject_handle; | 3240 if (match->IsNull()) return *subject_handle; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3354 } | 3379 } |
| 3355 } | 3380 } |
| 3356 replacement = String::cast(flat_replacement); | 3381 replacement = String::cast(flat_replacement); |
| 3357 } | 3382 } |
| 3358 | 3383 |
| 3359 CONVERT_ARG_CHECKED(JSRegExp, regexp, 1); | 3384 CONVERT_ARG_CHECKED(JSRegExp, regexp, 1); |
| 3360 CONVERT_ARG_CHECKED(JSArray, last_match_info, 3); | 3385 CONVERT_ARG_CHECKED(JSArray, last_match_info, 3); |
| 3361 | 3386 |
| 3362 ASSERT(last_match_info->HasFastObjectElements()); | 3387 ASSERT(last_match_info->HasFastObjectElements()); |
| 3363 | 3388 |
| 3389 Zone* zone = isolate->zone(); |
| 3364 if (replacement->length() == 0) { | 3390 if (replacement->length() == 0) { |
| 3365 if (subject->HasOnlyAsciiChars()) { | 3391 if (subject->HasOnlyAsciiChars()) { |
| 3366 return StringReplaceRegExpWithEmptyString<SeqAsciiString>( | 3392 return StringReplaceRegExpWithEmptyString<SeqAsciiString>( |
| 3367 isolate, subject, regexp, last_match_info); | 3393 isolate, subject, regexp, last_match_info, zone); |
| 3368 } else { | 3394 } else { |
| 3369 return StringReplaceRegExpWithEmptyString<SeqTwoByteString>( | 3395 return StringReplaceRegExpWithEmptyString<SeqTwoByteString>( |
| 3370 isolate, subject, regexp, last_match_info); | 3396 isolate, subject, regexp, last_match_info, zone); |
| 3371 } | 3397 } |
| 3372 } | 3398 } |
| 3373 | 3399 |
| 3374 return StringReplaceRegExpWithString(isolate, | 3400 return StringReplaceRegExpWithString(isolate, |
| 3375 subject, | 3401 subject, |
| 3376 regexp, | 3402 regexp, |
| 3377 replacement, | 3403 replacement, |
| 3378 last_match_info); | 3404 last_match_info, |
| 3405 zone); |
| 3379 } | 3406 } |
| 3380 | 3407 |
| 3381 | 3408 |
| 3382 Handle<String> Runtime::StringReplaceOneCharWithString(Isolate* isolate, | 3409 Handle<String> Runtime::StringReplaceOneCharWithString(Isolate* isolate, |
| 3383 Handle<String> subject, | 3410 Handle<String> subject, |
| 3384 Handle<String> search, | 3411 Handle<String> search, |
| 3385 Handle<String> replace, | 3412 Handle<String> replace, |
| 3386 bool* found, | 3413 bool* found, |
| 3387 int recursion_limit) { | 3414 int recursion_limit) { |
| 3388 if (recursion_limit == 0) return Handle<String>::null(); | 3415 if (recursion_limit == 0) return Handle<String>::null(); |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3702 isolate->zone()); | 3729 isolate->zone()); |
| 3703 | 3730 |
| 3704 if (match.is_null()) { | 3731 if (match.is_null()) { |
| 3705 return Failure::Exception(); | 3732 return Failure::Exception(); |
| 3706 } | 3733 } |
| 3707 if (match->IsNull()) { | 3734 if (match->IsNull()) { |
| 3708 return isolate->heap()->null_value(); | 3735 return isolate->heap()->null_value(); |
| 3709 } | 3736 } |
| 3710 int length = subject->length(); | 3737 int length = subject->length(); |
| 3711 | 3738 |
| 3739 Zone* zone = isolate->zone(); |
| 3712 ZoneScope zone_space(isolate, DELETE_ON_EXIT); | 3740 ZoneScope zone_space(isolate, DELETE_ON_EXIT); |
| 3713 ZoneList<int> offsets(8); | 3741 ZoneList<int> offsets(8, zone); |
| 3714 int start; | 3742 int start; |
| 3715 int end; | 3743 int end; |
| 3716 do { | 3744 do { |
| 3717 { | 3745 { |
| 3718 AssertNoAllocation no_alloc; | 3746 AssertNoAllocation no_alloc; |
| 3719 FixedArray* elements = FixedArray::cast(regexp_info->elements()); | 3747 FixedArray* elements = FixedArray::cast(regexp_info->elements()); |
| 3720 start = Smi::cast(elements->get(RegExpImpl::kFirstCapture))->value(); | 3748 start = Smi::cast(elements->get(RegExpImpl::kFirstCapture))->value(); |
| 3721 end = Smi::cast(elements->get(RegExpImpl::kFirstCapture + 1))->value(); | 3749 end = Smi::cast(elements->get(RegExpImpl::kFirstCapture + 1))->value(); |
| 3722 } | 3750 } |
| 3723 offsets.Add(start); | 3751 offsets.Add(start, zone); |
| 3724 offsets.Add(end); | 3752 offsets.Add(end, zone); |
| 3725 if (start == end) if (++end > length) break; | 3753 if (start == end) if (++end > length) break; |
| 3726 match = RegExpImpl::Exec(regexp, subject, end, regexp_info, | 3754 match = RegExpImpl::Exec(regexp, subject, end, regexp_info, |
| 3727 isolate->zone()); | 3755 isolate->zone()); |
| 3728 if (match.is_null()) { | 3756 if (match.is_null()) { |
| 3729 return Failure::Exception(); | 3757 return Failure::Exception(); |
| 3730 } | 3758 } |
| 3731 } while (!match->IsNull()); | 3759 } while (!match->IsNull()); |
| 3732 int matches = offsets.length() / 2; | 3760 int matches = offsets.length() / 2; |
| 3733 Handle<FixedArray> elements = isolate->factory()->NewFixedArray(matches); | 3761 Handle<FixedArray> elements = isolate->factory()->NewFixedArray(matches); |
| 3734 Handle<String> substring = isolate->factory()-> | 3762 Handle<String> substring = isolate->factory()-> |
| (...skipping 2685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6420 } | 6448 } |
| 6421 | 6449 |
| 6422 // The limit can be very large (0xffffffffu), but since the pattern | 6450 // The limit can be very large (0xffffffffu), but since the pattern |
| 6423 // isn't empty, we can never create more parts than ~half the length | 6451 // isn't empty, we can never create more parts than ~half the length |
| 6424 // of the subject. | 6452 // of the subject. |
| 6425 | 6453 |
| 6426 if (!subject->IsFlat()) FlattenString(subject); | 6454 if (!subject->IsFlat()) FlattenString(subject); |
| 6427 | 6455 |
| 6428 static const int kMaxInitialListCapacity = 16; | 6456 static const int kMaxInitialListCapacity = 16; |
| 6429 | 6457 |
| 6458 Zone* zone = isolate->zone(); |
| 6430 ZoneScope scope(isolate, DELETE_ON_EXIT); | 6459 ZoneScope scope(isolate, DELETE_ON_EXIT); |
| 6431 | 6460 |
| 6432 // Find (up to limit) indices of separator and end-of-string in subject | 6461 // Find (up to limit) indices of separator and end-of-string in subject |
| 6433 int initial_capacity = Min<uint32_t>(kMaxInitialListCapacity, limit); | 6462 int initial_capacity = Min<uint32_t>(kMaxInitialListCapacity, limit); |
| 6434 ZoneList<int> indices(initial_capacity); | 6463 ZoneList<int> indices(initial_capacity, zone); |
| 6435 if (!pattern->IsFlat()) FlattenString(pattern); | 6464 if (!pattern->IsFlat()) FlattenString(pattern); |
| 6436 | 6465 |
| 6437 FindStringIndicesDispatch(isolate, *subject, *pattern, &indices, limit); | 6466 FindStringIndicesDispatch(isolate, *subject, *pattern, &indices, limit, zone); |
| 6438 | 6467 |
| 6439 if (static_cast<uint32_t>(indices.length()) < limit) { | 6468 if (static_cast<uint32_t>(indices.length()) < limit) { |
| 6440 indices.Add(subject_length); | 6469 indices.Add(subject_length, zone); |
| 6441 } | 6470 } |
| 6442 | 6471 |
| 6443 // The list indices now contains the end of each part to create. | 6472 // The list indices now contains the end of each part to create. |
| 6444 | 6473 |
| 6445 // Create JSArray of substrings separated by separator. | 6474 // Create JSArray of substrings separated by separator. |
| 6446 int part_count = indices.length(); | 6475 int part_count = indices.length(); |
| 6447 | 6476 |
| 6448 Handle<JSArray> result = isolate->factory()->NewJSArray(part_count); | 6477 Handle<JSArray> result = isolate->factory()->NewJSArray(part_count); |
| 6449 MaybeObject* maybe_result = result->EnsureCanContainHeapObjectElements(); | 6478 MaybeObject* maybe_result = result->EnsureCanContainHeapObjectElements(); |
| 6450 if (maybe_result->IsFailure()) return maybe_result; | 6479 if (maybe_result->IsFailure()) return maybe_result; |
| (...skipping 2818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9269 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); | 9298 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); |
| 9270 return JSGlobalObject::cast(global)->global_receiver(); | 9299 return JSGlobalObject::cast(global)->global_receiver(); |
| 9271 } | 9300 } |
| 9272 | 9301 |
| 9273 | 9302 |
| 9274 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) { | 9303 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) { |
| 9275 HandleScope scope(isolate); | 9304 HandleScope scope(isolate); |
| 9276 ASSERT_EQ(1, args.length()); | 9305 ASSERT_EQ(1, args.length()); |
| 9277 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); | 9306 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); |
| 9278 | 9307 |
| 9308 Zone* zone = isolate->zone(); |
| 9279 source = Handle<String>(source->TryFlattenGetString()); | 9309 source = Handle<String>(source->TryFlattenGetString()); |
| 9280 // Optimized fast case where we only have ASCII characters. | 9310 // Optimized fast case where we only have ASCII characters. |
| 9281 Handle<Object> result; | 9311 Handle<Object> result; |
| 9282 if (source->IsSeqAsciiString()) { | 9312 if (source->IsSeqAsciiString()) { |
| 9283 result = JsonParser<true>::Parse(source); | 9313 result = JsonParser<true>::Parse(source, zone); |
| 9284 } else { | 9314 } else { |
| 9285 result = JsonParser<false>::Parse(source); | 9315 result = JsonParser<false>::Parse(source, zone); |
| 9286 } | 9316 } |
| 9287 if (result.is_null()) { | 9317 if (result.is_null()) { |
| 9288 // Syntax error or stack overflow in scanner. | 9318 // Syntax error or stack overflow in scanner. |
| 9289 ASSERT(isolate->has_pending_exception()); | 9319 ASSERT(isolate->has_pending_exception()); |
| 9290 return Failure::Exception(); | 9320 return Failure::Exception(); |
| 9291 } | 9321 } |
| 9292 return *result; | 9322 return *result; |
| 9293 } | 9323 } |
| 9294 | 9324 |
| 9295 | 9325 |
| (...skipping 3437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12733 // For array of SharedFunctionInfo's (each wrapped in JSValue) | 12763 // For array of SharedFunctionInfo's (each wrapped in JSValue) |
| 12734 // checks that none of them have activations on stacks (of any thread). | 12764 // checks that none of them have activations on stacks (of any thread). |
| 12735 // Returns array of the same length with corresponding results of | 12765 // Returns array of the same length with corresponding results of |
| 12736 // LiveEdit::FunctionPatchabilityStatus type. | 12766 // LiveEdit::FunctionPatchabilityStatus type. |
| 12737 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCheckAndDropActivations) { | 12767 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCheckAndDropActivations) { |
| 12738 ASSERT(args.length() == 2); | 12768 ASSERT(args.length() == 2); |
| 12739 HandleScope scope(isolate); | 12769 HandleScope scope(isolate); |
| 12740 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0); | 12770 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0); |
| 12741 CONVERT_BOOLEAN_ARG_CHECKED(do_drop, 1); | 12771 CONVERT_BOOLEAN_ARG_CHECKED(do_drop, 1); |
| 12742 | 12772 |
| 12743 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop); | 12773 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop, |
| 12774 isolate->zone()); |
| 12744 } | 12775 } |
| 12745 | 12776 |
| 12746 // Compares 2 strings line-by-line, then token-wise and returns diff in form | 12777 // Compares 2 strings line-by-line, then token-wise and returns diff in form |
| 12747 // of JSArray of triplets (pos1, pos1_end, pos2_end) describing list | 12778 // of JSArray of triplets (pos1, pos1_end, pos2_end) describing list |
| 12748 // of diff chunks. | 12779 // of diff chunks. |
| 12749 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCompareStrings) { | 12780 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCompareStrings) { |
| 12750 ASSERT(args.length() == 2); | 12781 ASSERT(args.length() == 2); |
| 12751 HandleScope scope(isolate); | 12782 HandleScope scope(isolate); |
| 12752 CONVERT_ARG_HANDLE_CHECKED(String, s1, 0); | 12783 CONVERT_ARG_HANDLE_CHECKED(String, s1, 0); |
| 12753 CONVERT_ARG_HANDLE_CHECKED(String, s2, 1); | 12784 CONVERT_ARG_HANDLE_CHECKED(String, s2, 1); |
| (...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13557 // Handle last resort GC and make sure to allow future allocations | 13588 // Handle last resort GC and make sure to allow future allocations |
| 13558 // to grow the heap without causing GCs (if possible). | 13589 // to grow the heap without causing GCs (if possible). |
| 13559 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13590 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13560 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13591 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 13561 "Runtime::PerformGC"); | 13592 "Runtime::PerformGC"); |
| 13562 } | 13593 } |
| 13563 } | 13594 } |
| 13564 | 13595 |
| 13565 | 13596 |
| 13566 } } // namespace v8::internal | 13597 } } // namespace v8::internal |
| OLD | NEW |