Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: src/runtime.cc

Issue 10443114: Progress towards making Zones independent of Isolates and Threads. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix nits and rebase on current bleeding_edge Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/parser.cc ('k') | src/safepoint-table.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1728 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 // length of a string, i.e. it is always a Smi. We check anyway for security. 1739 // length of a string, i.e. it is always a Smi. We check anyway for security.
1740 CONVERT_SMI_ARG_CHECKED(index, 2); 1740 CONVERT_SMI_ARG_CHECKED(index, 2);
1741 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3); 1741 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3);
1742 RUNTIME_ASSERT(last_match_info->HasFastObjectElements()); 1742 RUNTIME_ASSERT(last_match_info->HasFastObjectElements());
1743 RUNTIME_ASSERT(index >= 0); 1743 RUNTIME_ASSERT(index >= 0);
1744 RUNTIME_ASSERT(index <= subject->length()); 1744 RUNTIME_ASSERT(index <= subject->length());
1745 isolate->counters()->regexp_entry_runtime()->Increment(); 1745 isolate->counters()->regexp_entry_runtime()->Increment();
1746 Handle<Object> result = RegExpImpl::Exec(regexp, 1746 Handle<Object> result = RegExpImpl::Exec(regexp,
1747 subject, 1747 subject,
1748 index, 1748 index,
1749 last_match_info); 1749 last_match_info,
1750 isolate->zone());
1750 if (result.is_null()) return Failure::Exception(); 1751 if (result.is_null()) return Failure::Exception();
1751 return *result; 1752 return *result;
1752 } 1753 }
1753 1754
1754 1755
1755 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpConstructResult) { 1756 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpConstructResult) {
1756 ASSERT(args.length() == 3); 1757 ASSERT(args.length() == 3);
1757 CONVERT_SMI_ARG_CHECKED(elements_count, 0); 1758 CONVERT_SMI_ARG_CHECKED(elements_count, 0);
1758 if (elements_count < 0 || 1759 if (elements_count < 0 ||
1759 elements_count > FixedArray::kMaxLength || 1760 elements_count > FixedArray::kMaxLength ||
(...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after
3047 HandleScope handles(isolate); 3048 HandleScope handles(isolate);
3048 3049
3049 int length = subject->length(); 3050 int length = subject->length();
3050 Handle<String> subject_handle(subject); 3051 Handle<String> subject_handle(subject);
3051 Handle<JSRegExp> regexp_handle(regexp); 3052 Handle<JSRegExp> regexp_handle(regexp);
3052 Handle<String> replacement_handle(replacement); 3053 Handle<String> replacement_handle(replacement);
3053 Handle<JSArray> last_match_info_handle(last_match_info); 3054 Handle<JSArray> last_match_info_handle(last_match_info);
3054 Handle<Object> match = RegExpImpl::Exec(regexp_handle, 3055 Handle<Object> match = RegExpImpl::Exec(regexp_handle,
3055 subject_handle, 3056 subject_handle,
3056 0, 3057 0,
3057 last_match_info_handle); 3058 last_match_info_handle,
3059 isolate->zone());
3058 if (match.is_null()) { 3060 if (match.is_null()) {
3059 return Failure::Exception(); 3061 return Failure::Exception();
3060 } 3062 }
3061 if (match->IsNull()) { 3063 if (match->IsNull()) {
3062 return *subject_handle; 3064 return *subject_handle;
3063 } 3065 }
3064 3066
3065 int capture_count = regexp_handle->CaptureCount(); 3067 int capture_count = regexp_handle->CaptureCount();
3066 3068
3067 // CompiledReplacement uses zone allocation. 3069 // CompiledReplacement uses zone allocation.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
3146 // Continue from where the match ended, unless it was an empty match. 3148 // Continue from where the match ended, unless it was an empty match.
3147 int next = end; 3149 int next = end;
3148 if (start == end) { 3150 if (start == end) {
3149 next = end + 1; 3151 next = end + 1;
3150 if (next > length) break; 3152 if (next > length) break;
3151 } 3153 }
3152 3154
3153 match = RegExpImpl::Exec(regexp_handle, 3155 match = RegExpImpl::Exec(regexp_handle,
3154 subject_handle, 3156 subject_handle,
3155 next, 3157 next,
3156 last_match_info_handle); 3158 last_match_info_handle,
3159 isolate->zone());
3157 if (match.is_null()) { 3160 if (match.is_null()) {
3158 return Failure::Exception(); 3161 return Failure::Exception();
3159 } 3162 }
3160 matched = !match->IsNull(); 3163 matched = !match->IsNull();
3161 } while (matched); 3164 } while (matched);
3162 3165
3163 if (prev < length) { 3166 if (prev < length) {
3164 builder.AddSubjectSlice(prev, length); 3167 builder.AddSubjectSlice(prev, length);
3165 } 3168 }
3166 3169
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3199 subject_handle, 3202 subject_handle,
3200 regexp_handle, 3203 regexp_handle,
3201 empty_string_handle, 3204 empty_string_handle,
3202 last_match_info_handle); 3205 last_match_info_handle);
3203 } 3206 }
3204 } 3207 }
3205 3208
3206 Handle<Object> match = RegExpImpl::Exec(regexp_handle, 3209 Handle<Object> match = RegExpImpl::Exec(regexp_handle,
3207 subject_handle, 3210 subject_handle,
3208 0, 3211 0,
3209 last_match_info_handle); 3212 last_match_info_handle,
3213 isolate->zone());
3210 if (match.is_null()) return Failure::Exception(); 3214 if (match.is_null()) return Failure::Exception();
3211 if (match->IsNull()) return *subject_handle; 3215 if (match->IsNull()) return *subject_handle;
3212 3216
3213 ASSERT(last_match_info_handle->HasFastObjectElements()); 3217 ASSERT(last_match_info_handle->HasFastObjectElements());
3214 3218
3215 int start, end; 3219 int start, end;
3216 { 3220 {
3217 AssertNoAllocation match_info_array_is_not_in_a_handle; 3221 AssertNoAllocation match_info_array_is_not_in_a_handle;
3218 FixedArray* match_info_array = 3222 FixedArray* match_info_array =
3219 FixedArray::cast(last_match_info_handle->elements()); 3223 FixedArray::cast(last_match_info_handle->elements());
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
3273 prev = end; 3277 prev = end;
3274 next = end; 3278 next = end;
3275 // Continue from where the match ended, unless it was an empty match. 3279 // Continue from where the match ended, unless it was an empty match.
3276 if (start == end) { 3280 if (start == end) {
3277 next++; 3281 next++;
3278 if (next > length) break; 3282 if (next > length) break;
3279 } 3283 }
3280 match = RegExpImpl::Exec(regexp_handle, 3284 match = RegExpImpl::Exec(regexp_handle,
3281 subject_handle, 3285 subject_handle,
3282 next, 3286 next,
3283 last_match_info_handle); 3287 last_match_info_handle,
3288 isolate->zone());
3284 if (match.is_null()) return Failure::Exception(); 3289 if (match.is_null()) return Failure::Exception();
3285 if (match->IsNull()) break; 3290 if (match->IsNull()) break;
3286 3291
3287 ASSERT(last_match_info_handle->HasFastObjectElements()); 3292 ASSERT(last_match_info_handle->HasFastObjectElements());
3288 HandleScope loop_scope(isolate); 3293 HandleScope loop_scope(isolate);
3289 { 3294 {
3290 AssertNoAllocation match_info_array_is_not_in_a_handle; 3295 AssertNoAllocation match_info_array_is_not_in_a_handle;
3291 FixedArray* match_info_array = 3296 FixedArray* match_info_array =
3292 FixedArray::cast(last_match_info_handle->elements()); 3297 FixedArray::cast(last_match_info_handle->elements());
3293 start = RegExpImpl::GetCapture(match_info_array, 0); 3298 start = RegExpImpl::GetCapture(match_info_array, 0);
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
3686 3691
3687 3692
3688 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) { 3693 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) {
3689 ASSERT_EQ(3, args.length()); 3694 ASSERT_EQ(3, args.length());
3690 3695
3691 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); 3696 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0);
3692 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1); 3697 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1);
3693 CONVERT_ARG_HANDLE_CHECKED(JSArray, regexp_info, 2); 3698 CONVERT_ARG_HANDLE_CHECKED(JSArray, regexp_info, 2);
3694 HandleScope handles; 3699 HandleScope handles;
3695 3700
3696 Handle<Object> match = RegExpImpl::Exec(regexp, subject, 0, regexp_info); 3701 Handle<Object> match = RegExpImpl::Exec(regexp, subject, 0, regexp_info,
3702 isolate->zone());
3697 3703
3698 if (match.is_null()) { 3704 if (match.is_null()) {
3699 return Failure::Exception(); 3705 return Failure::Exception();
3700 } 3706 }
3701 if (match->IsNull()) { 3707 if (match->IsNull()) {
3702 return isolate->heap()->null_value(); 3708 return isolate->heap()->null_value();
3703 } 3709 }
3704 int length = subject->length(); 3710 int length = subject->length();
3705 3711
3706 ZoneScope zone_space(isolate, DELETE_ON_EXIT); 3712 ZoneScope zone_space(isolate, DELETE_ON_EXIT);
3707 ZoneList<int> offsets(8); 3713 ZoneList<int> offsets(8);
3708 int start; 3714 int start;
3709 int end; 3715 int end;
3710 do { 3716 do {
3711 { 3717 {
3712 AssertNoAllocation no_alloc; 3718 AssertNoAllocation no_alloc;
3713 FixedArray* elements = FixedArray::cast(regexp_info->elements()); 3719 FixedArray* elements = FixedArray::cast(regexp_info->elements());
3714 start = Smi::cast(elements->get(RegExpImpl::kFirstCapture))->value(); 3720 start = Smi::cast(elements->get(RegExpImpl::kFirstCapture))->value();
3715 end = Smi::cast(elements->get(RegExpImpl::kFirstCapture + 1))->value(); 3721 end = Smi::cast(elements->get(RegExpImpl::kFirstCapture + 1))->value();
3716 } 3722 }
3717 offsets.Add(start); 3723 offsets.Add(start);
3718 offsets.Add(end); 3724 offsets.Add(end);
3719 if (start == end) if (++end > length) break; 3725 if (start == end) if (++end > length) break;
3720 match = RegExpImpl::Exec(regexp, subject, end, regexp_info); 3726 match = RegExpImpl::Exec(regexp, subject, end, regexp_info,
3727 isolate->zone());
3721 if (match.is_null()) { 3728 if (match.is_null()) {
3722 return Failure::Exception(); 3729 return Failure::Exception();
3723 } 3730 }
3724 } while (!match->IsNull()); 3731 } while (!match->IsNull());
3725 int matches = offsets.length() / 2; 3732 int matches = offsets.length() / 2;
3726 Handle<FixedArray> elements = isolate->factory()->NewFixedArray(matches); 3733 Handle<FixedArray> elements = isolate->factory()->NewFixedArray(matches);
3727 Handle<String> substring = isolate->factory()-> 3734 Handle<String> substring = isolate->factory()->
3728 NewSubString(subject, offsets.at(0), offsets.at(1)); 3735 NewSubString(subject, offsets.at(0), offsets.at(1));
3729 elements->set(0, *substring); 3736 elements->set(0, *substring);
3730 for (int i = 1; i < matches ; i++) { 3737 for (int i = 1; i < matches ; i++) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
3808 Isolate* isolate, 3815 Isolate* isolate,
3809 Handle<String> subject, 3816 Handle<String> subject,
3810 Handle<JSRegExp> regexp, 3817 Handle<JSRegExp> regexp,
3811 Handle<JSArray> last_match_array, 3818 Handle<JSArray> last_match_array,
3812 FixedArrayBuilder* builder) { 3819 FixedArrayBuilder* builder) {
3813 ASSERT(subject->IsFlat()); 3820 ASSERT(subject->IsFlat());
3814 ASSERT(regexp->CaptureCount() == 0); 3821 ASSERT(regexp->CaptureCount() == 0);
3815 int match_start = -1; 3822 int match_start = -1;
3816 int match_end = 0; 3823 int match_end = 0;
3817 int pos = 0; 3824 int pos = 0;
3818 int registers_per_match = RegExpImpl::IrregexpPrepare(regexp, subject); 3825 int registers_per_match = RegExpImpl::IrregexpPrepare(regexp, subject,
3826 isolate->zone());
3819 if (registers_per_match < 0) return RegExpImpl::RE_EXCEPTION; 3827 if (registers_per_match < 0) return RegExpImpl::RE_EXCEPTION;
3820 3828
3821 int max_matches; 3829 int max_matches;
3822 int num_registers = RegExpImpl::GlobalOffsetsVectorSize(regexp, 3830 int num_registers = RegExpImpl::GlobalOffsetsVectorSize(regexp,
3823 registers_per_match, 3831 registers_per_match,
3824 &max_matches); 3832 &max_matches);
3825 OffsetsVector registers(num_registers, isolate); 3833 OffsetsVector registers(num_registers, isolate);
3826 Vector<int32_t> register_vector(registers.vector(), registers.length()); 3834 Vector<int32_t> register_vector(registers.vector(), registers.length());
3827 int subject_length = subject->length(); 3835 int subject_length = subject->length();
3828 bool first = true; 3836 bool first = true;
3829 for (;;) { // Break on failure, return on exception. 3837 for (;;) { // Break on failure, return on exception.
3830 int num_matches = RegExpImpl::IrregexpExecRaw(regexp, 3838 int num_matches = RegExpImpl::IrregexpExecRaw(regexp,
3831 subject, 3839 subject,
3832 pos, 3840 pos,
3833 register_vector); 3841 register_vector,
3842 isolate->zone());
3834 if (num_matches > 0) { 3843 if (num_matches > 0) {
3835 for (int match_index = 0; match_index < num_matches; match_index++) { 3844 for (int match_index = 0; match_index < num_matches; match_index++) {
3836 int32_t* current_match = &register_vector[match_index * 2]; 3845 int32_t* current_match = &register_vector[match_index * 2];
3837 match_start = current_match[0]; 3846 match_start = current_match[0];
3838 builder->EnsureCapacity(kMaxBuilderEntriesPerRegExpMatch); 3847 builder->EnsureCapacity(kMaxBuilderEntriesPerRegExpMatch);
3839 if (match_end < match_start) { 3848 if (match_end < match_start) {
3840 ReplacementStringBuilder::AddSubjectSlice(builder, 3849 ReplacementStringBuilder::AddSubjectSlice(builder,
3841 match_end, 3850 match_end,
3842 match_start); 3851 match_start);
3843 } 3852 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
3893 // Only called from Runtime_RegExpExecMultiple so it doesn't need to maintain 3902 // Only called from Runtime_RegExpExecMultiple so it doesn't need to maintain
3894 // separate last match info. See comment on that function. 3903 // separate last match info. See comment on that function.
3895 static int SearchRegExpMultiple( 3904 static int SearchRegExpMultiple(
3896 Isolate* isolate, 3905 Isolate* isolate,
3897 Handle<String> subject, 3906 Handle<String> subject,
3898 Handle<JSRegExp> regexp, 3907 Handle<JSRegExp> regexp,
3899 Handle<JSArray> last_match_array, 3908 Handle<JSArray> last_match_array,
3900 FixedArrayBuilder* builder) { 3909 FixedArrayBuilder* builder) {
3901 3910
3902 ASSERT(subject->IsFlat()); 3911 ASSERT(subject->IsFlat());
3903 int registers_per_match = RegExpImpl::IrregexpPrepare(regexp, subject); 3912 int registers_per_match = RegExpImpl::IrregexpPrepare(regexp, subject,
3913 isolate->zone());
3904 if (registers_per_match < 0) return RegExpImpl::RE_EXCEPTION; 3914 if (registers_per_match < 0) return RegExpImpl::RE_EXCEPTION;
3905 3915
3906 int max_matches; 3916 int max_matches;
3907 int num_registers = RegExpImpl::GlobalOffsetsVectorSize(regexp, 3917 int num_registers = RegExpImpl::GlobalOffsetsVectorSize(regexp,
3908 registers_per_match, 3918 registers_per_match,
3909 &max_matches); 3919 &max_matches);
3910 OffsetsVector registers(num_registers, isolate); 3920 OffsetsVector registers(num_registers, isolate);
3911 Vector<int32_t> register_vector(registers.vector(), registers.length()); 3921 Vector<int32_t> register_vector(registers.vector(), registers.length());
3912 3922
3913 int num_matches = RegExpImpl::IrregexpExecRaw(regexp, 3923 int num_matches = RegExpImpl::IrregexpExecRaw(regexp,
3914 subject, 3924 subject,
3915 0, 3925 0,
3916 register_vector); 3926 register_vector,
3927 isolate->zone());
3917 3928
3918 int capture_count = regexp->CaptureCount(); 3929 int capture_count = regexp->CaptureCount();
3919 int subject_length = subject->length(); 3930 int subject_length = subject->length();
3920 3931
3921 // Position to search from. 3932 // Position to search from.
3922 int pos = 0; 3933 int pos = 0;
3923 // End of previous match. Differs from pos if match was empty. 3934 // End of previous match. Differs from pos if match was empty.
3924 int match_end = 0; 3935 int match_end = 0;
3925 bool first = true; 3936 bool first = true;
3926 3937
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
3992 } else { 4003 } else {
3993 pos = match_end + 1; 4004 pos = match_end + 1;
3994 if (pos > subject_length) { 4005 if (pos > subject_length) {
3995 break; 4006 break;
3996 } 4007 }
3997 } 4008 }
3998 4009
3999 num_matches = RegExpImpl::IrregexpExecRaw(regexp, 4010 num_matches = RegExpImpl::IrregexpExecRaw(regexp,
4000 subject, 4011 subject,
4001 pos, 4012 pos,
4002 register_vector); 4013 register_vector,
4014 isolate->zone());
4003 } while (num_matches > 0); 4015 } while (num_matches > 0);
4004 4016
4005 if (num_matches != RegExpImpl::RE_EXCEPTION) { 4017 if (num_matches != RegExpImpl::RE_EXCEPTION) {
4006 // Finished matching, with at least one match. 4018 // Finished matching, with at least one match.
4007 if (match_end < subject_length) { 4019 if (match_end < subject_length) {
4008 ReplacementStringBuilder::AddSubjectSlice(builder, 4020 ReplacementStringBuilder::AddSubjectSlice(builder,
4009 match_end, 4021 match_end,
4010 subject_length); 4022 subject_length);
4011 } 4023 }
4012 4024
(...skipping 9532 matching lines...) Expand 10 before | Expand all | Expand 10 after
13545 // Handle last resort GC and make sure to allow future allocations 13557 // Handle last resort GC and make sure to allow future allocations
13546 // to grow the heap without causing GCs (if possible). 13558 // to grow the heap without causing GCs (if possible).
13547 isolate->counters()->gc_last_resort_from_js()->Increment(); 13559 isolate->counters()->gc_last_resort_from_js()->Increment();
13548 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13560 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13549 "Runtime::PerformGC"); 13561 "Runtime::PerformGC");
13550 } 13562 }
13551 } 13563 }
13552 13564
13553 13565
13554 } } // namespace v8::internal 13566 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | src/safepoint-table.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698