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

Side by Side Diff: src/runtime.cc

Issue 10534139: One Zone per CompilationInfo. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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
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 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 return isolate->heap()->ToBoolean(obj->map()->is_extensible()); 1181 return isolate->heap()->ToBoolean(obj->map()->is_extensible());
1182 } 1182 }
1183 1183
1184 1184
1185 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpCompile) { 1185 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpCompile) {
1186 HandleScope scope(isolate); 1186 HandleScope scope(isolate);
1187 ASSERT(args.length() == 3); 1187 ASSERT(args.length() == 3);
1188 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, re, 0); 1188 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, re, 0);
1189 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1); 1189 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1);
1190 CONVERT_ARG_HANDLE_CHECKED(String, flags, 2); 1190 CONVERT_ARG_HANDLE_CHECKED(String, flags, 2);
1191 Handle<Object> result = RegExpImpl::Compile(re, pattern, flags); 1191 ZoneScope zone_scope(isolate->runtime_zone(), DELETE_ON_EXIT);
danno 2012/06/14 14:22:19 Why new new ZoneScope here?
sanjoy 2012/06/15 09:24:31 This runtime function is sometimes called without
1192 Handle<Object> result =
1193 RegExpImpl::Compile(re, pattern, flags, isolate->runtime_zone());
1192 if (result.is_null()) return Failure::Exception(); 1194 if (result.is_null()) return Failure::Exception();
1193 return *result; 1195 return *result;
1194 } 1196 }
1195 1197
1196 1198
1197 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateApiFunction) { 1199 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateApiFunction) {
1198 HandleScope scope(isolate); 1200 HandleScope scope(isolate);
1199 ASSERT(args.length() == 1); 1201 ASSERT(args.length() == 1);
1200 CONVERT_ARG_HANDLE_CHECKED(FunctionTemplateInfo, data, 0); 1202 CONVERT_ARG_HANDLE_CHECKED(FunctionTemplateInfo, data, 0);
1201 return *isolate->factory()->CreateApiFunction(data); 1203 return *isolate->factory()->CreateApiFunction(data);
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
1742 CONVERT_SMI_ARG_CHECKED(index, 2); 1744 CONVERT_SMI_ARG_CHECKED(index, 2);
1743 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3); 1745 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3);
1744 RUNTIME_ASSERT(last_match_info->HasFastObjectElements()); 1746 RUNTIME_ASSERT(last_match_info->HasFastObjectElements());
1745 RUNTIME_ASSERT(index >= 0); 1747 RUNTIME_ASSERT(index >= 0);
1746 RUNTIME_ASSERT(index <= subject->length()); 1748 RUNTIME_ASSERT(index <= subject->length());
1747 isolate->counters()->regexp_entry_runtime()->Increment(); 1749 isolate->counters()->regexp_entry_runtime()->Increment();
1748 Handle<Object> result = RegExpImpl::Exec(regexp, 1750 Handle<Object> result = RegExpImpl::Exec(regexp,
1749 subject, 1751 subject,
1750 index, 1752 index,
1751 last_match_info, 1753 last_match_info,
1752 isolate->zone()); 1754 isolate->runtime_zone());
1753 if (result.is_null()) return Failure::Exception(); 1755 if (result.is_null()) return Failure::Exception();
1754 return *result; 1756 return *result;
1755 } 1757 }
1756 1758
1757 1759
1758 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpConstructResult) { 1760 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpConstructResult) {
1759 ASSERT(args.length() == 3); 1761 ASSERT(args.length() == 3);
1760 CONVERT_SMI_ARG_CHECKED(elements_count, 0); 1762 CONVERT_SMI_ARG_CHECKED(elements_count, 0);
1761 if (elements_count < 0 || 1763 if (elements_count < 0 ||
1762 elements_count > FixedArray::kMaxLength || 1764 elements_count > FixedArray::kMaxLength ||
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after
2982 MUST_USE_RESULT static MaybeObject* StringReplaceAtomRegExpWithString( 2984 MUST_USE_RESULT static MaybeObject* StringReplaceAtomRegExpWithString(
2983 Isolate* isolate, 2985 Isolate* isolate,
2984 Handle<String> subject, 2986 Handle<String> subject,
2985 Handle<JSRegExp> pattern_regexp, 2987 Handle<JSRegExp> pattern_regexp,
2986 Handle<String> replacement, 2988 Handle<String> replacement,
2987 Handle<JSArray> last_match_info, 2989 Handle<JSArray> last_match_info,
2988 Zone* zone) { 2990 Zone* zone) {
2989 ASSERT(subject->IsFlat()); 2991 ASSERT(subject->IsFlat());
2990 ASSERT(replacement->IsFlat()); 2992 ASSERT(replacement->IsFlat());
2991 2993
2992 ZoneScope zone_space(isolate, DELETE_ON_EXIT); 2994 ZoneScope zone_space(isolate->runtime_zone(), DELETE_ON_EXIT);
2993 ZoneList<int> indices(8, isolate->zone()); 2995 ZoneList<int> indices(8, isolate->runtime_zone());
2994 ASSERT_EQ(JSRegExp::ATOM, pattern_regexp->TypeTag()); 2996 ASSERT_EQ(JSRegExp::ATOM, pattern_regexp->TypeTag());
2995 String* pattern = 2997 String* pattern =
2996 String::cast(pattern_regexp->DataAt(JSRegExp::kAtomPatternIndex)); 2998 String::cast(pattern_regexp->DataAt(JSRegExp::kAtomPatternIndex));
2997 int subject_len = subject->length(); 2999 int subject_len = subject->length();
2998 int pattern_len = pattern->length(); 3000 int pattern_len = pattern->length();
2999 int replacement_len = replacement->length(); 3001 int replacement_len = replacement->length();
3000 3002
3001 FindStringIndicesDispatch(isolate, *subject, pattern, &indices, 0xffffffff, 3003 FindStringIndicesDispatch(isolate, *subject, pattern, &indices, 0xffffffff,
3002 zone); 3004 zone);
3003 3005
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
3077 3079
3078 int length = subject->length(); 3080 int length = subject->length();
3079 Handle<String> subject_handle(subject); 3081 Handle<String> subject_handle(subject);
3080 Handle<JSRegExp> regexp_handle(regexp); 3082 Handle<JSRegExp> regexp_handle(regexp);
3081 Handle<String> replacement_handle(replacement); 3083 Handle<String> replacement_handle(replacement);
3082 Handle<JSArray> last_match_info_handle(last_match_info); 3084 Handle<JSArray> last_match_info_handle(last_match_info);
3083 Handle<Object> match = RegExpImpl::Exec(regexp_handle, 3085 Handle<Object> match = RegExpImpl::Exec(regexp_handle,
3084 subject_handle, 3086 subject_handle,
3085 0, 3087 0,
3086 last_match_info_handle, 3088 last_match_info_handle,
3087 isolate->zone()); 3089 zone);
3088 if (match.is_null()) { 3090 if (match.is_null()) {
3089 return Failure::Exception(); 3091 return Failure::Exception();
3090 } 3092 }
3091 if (match->IsNull()) { 3093 if (match->IsNull()) {
3092 return *subject_handle; 3094 return *subject_handle;
3093 } 3095 }
3094 3096
3095 int capture_count = regexp_handle->CaptureCount(); 3097 int capture_count = regexp_handle->CaptureCount();
3096 3098
3097 // CompiledReplacement uses zone allocation. 3099 // CompiledReplacement uses zone allocation.
3098 ZoneScope zonescope(isolate, DELETE_ON_EXIT); 3100 ZoneScope zonescope(zone, DELETE_ON_EXIT);
3099 CompiledReplacement compiled_replacement(isolate->zone()); 3101 CompiledReplacement compiled_replacement(zone);
3100 compiled_replacement.Compile(replacement_handle, 3102 compiled_replacement.Compile(replacement_handle,
3101 capture_count, 3103 capture_count,
3102 length); 3104 length);
3103 3105
3104 bool is_global = regexp_handle->GetFlags().is_global(); 3106 bool is_global = regexp_handle->GetFlags().is_global();
3105 3107
3106 // Shortcut for simple non-regexp global replacements 3108 // Shortcut for simple non-regexp global replacements
3107 if (is_global && 3109 if (is_global &&
3108 regexp_handle->TypeTag() == JSRegExp::ATOM && 3110 regexp_handle->TypeTag() == JSRegExp::ATOM &&
3109 compiled_replacement.simple_hint()) { 3111 compiled_replacement.simple_hint()) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
3179 int next = end; 3181 int next = end;
3180 if (start == end) { 3182 if (start == end) {
3181 next = end + 1; 3183 next = end + 1;
3182 if (next > length) break; 3184 if (next > length) break;
3183 } 3185 }
3184 3186
3185 match = RegExpImpl::Exec(regexp_handle, 3187 match = RegExpImpl::Exec(regexp_handle,
3186 subject_handle, 3188 subject_handle,
3187 next, 3189 next,
3188 last_match_info_handle, 3190 last_match_info_handle,
3189 isolate->zone()); 3191 zone);
3190 if (match.is_null()) { 3192 if (match.is_null()) {
3191 return Failure::Exception(); 3193 return Failure::Exception();
3192 } 3194 }
3193 matched = !match->IsNull(); 3195 matched = !match->IsNull();
3194 } while (matched); 3196 } while (matched);
3195 3197
3196 if (prev < length) { 3198 if (prev < length) {
3197 builder.AddSubjectSlice(prev, length); 3199 builder.AddSubjectSlice(prev, length);
3198 } 3200 }
3199 3201
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3236 empty_string_handle, 3238 empty_string_handle,
3237 last_match_info_handle, 3239 last_match_info_handle,
3238 zone); 3240 zone);
3239 } 3241 }
3240 } 3242 }
3241 3243
3242 Handle<Object> match = RegExpImpl::Exec(regexp_handle, 3244 Handle<Object> match = RegExpImpl::Exec(regexp_handle,
3243 subject_handle, 3245 subject_handle,
3244 0, 3246 0,
3245 last_match_info_handle, 3247 last_match_info_handle,
3246 isolate->zone()); 3248 zone);
3247 if (match.is_null()) return Failure::Exception(); 3249 if (match.is_null()) return Failure::Exception();
3248 if (match->IsNull()) return *subject_handle; 3250 if (match->IsNull()) return *subject_handle;
3249 3251
3250 ASSERT(last_match_info_handle->HasFastObjectElements()); 3252 ASSERT(last_match_info_handle->HasFastObjectElements());
3251 3253
3252 int start, end; 3254 int start, end;
3253 { 3255 {
3254 AssertNoAllocation match_info_array_is_not_in_a_handle; 3256 AssertNoAllocation match_info_array_is_not_in_a_handle;
3255 FixedArray* match_info_array = 3257 FixedArray* match_info_array =
3256 FixedArray::cast(last_match_info_handle->elements()); 3258 FixedArray::cast(last_match_info_handle->elements());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
3311 next = end; 3313 next = end;
3312 // Continue from where the match ended, unless it was an empty match. 3314 // Continue from where the match ended, unless it was an empty match.
3313 if (start == end) { 3315 if (start == end) {
3314 next++; 3316 next++;
3315 if (next > length) break; 3317 if (next > length) break;
3316 } 3318 }
3317 match = RegExpImpl::Exec(regexp_handle, 3319 match = RegExpImpl::Exec(regexp_handle,
3318 subject_handle, 3320 subject_handle,
3319 next, 3321 next,
3320 last_match_info_handle, 3322 last_match_info_handle,
3321 isolate->zone()); 3323 zone);
3322 if (match.is_null()) return Failure::Exception(); 3324 if (match.is_null()) return Failure::Exception();
3323 if (match->IsNull()) break; 3325 if (match->IsNull()) break;
3324 3326
3325 ASSERT(last_match_info_handle->HasFastObjectElements()); 3327 ASSERT(last_match_info_handle->HasFastObjectElements());
3326 HandleScope loop_scope(isolate); 3328 HandleScope loop_scope(isolate);
3327 { 3329 {
3328 AssertNoAllocation match_info_array_is_not_in_a_handle; 3330 AssertNoAllocation match_info_array_is_not_in_a_handle;
3329 FixedArray* match_info_array = 3331 FixedArray* match_info_array =
3330 FixedArray::cast(last_match_info_handle->elements()); 3332 FixedArray::cast(last_match_info_handle->elements());
3331 start = RegExpImpl::GetCapture(match_info_array, 0); 3333 start = RegExpImpl::GetCapture(match_info_array, 0);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
3387 } 3389 }
3388 } 3390 }
3389 replacement = String::cast(flat_replacement); 3391 replacement = String::cast(flat_replacement);
3390 } 3392 }
3391 3393
3392 CONVERT_ARG_CHECKED(JSRegExp, regexp, 1); 3394 CONVERT_ARG_CHECKED(JSRegExp, regexp, 1);
3393 CONVERT_ARG_CHECKED(JSArray, last_match_info, 3); 3395 CONVERT_ARG_CHECKED(JSArray, last_match_info, 3);
3394 3396
3395 ASSERT(last_match_info->HasFastObjectElements()); 3397 ASSERT(last_match_info->HasFastObjectElements());
3396 3398
3397 Zone* zone = isolate->zone(); 3399 Zone* zone = isolate->runtime_zone();
3398 if (replacement->length() == 0) { 3400 if (replacement->length() == 0) {
3399 if (subject->HasOnlyAsciiChars()) { 3401 if (subject->HasOnlyAsciiChars()) {
3400 return StringReplaceRegExpWithEmptyString<SeqAsciiString>( 3402 return StringReplaceRegExpWithEmptyString<SeqAsciiString>(
3401 isolate, subject, regexp, last_match_info, zone); 3403 isolate, subject, regexp, last_match_info, zone);
3402 } else { 3404 } else {
3403 return StringReplaceRegExpWithEmptyString<SeqTwoByteString>( 3405 return StringReplaceRegExpWithEmptyString<SeqTwoByteString>(
3404 isolate, subject, regexp, last_match_info, zone); 3406 isolate, subject, regexp, last_match_info, zone);
3405 } 3407 }
3406 } 3408 }
3407 3409
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
3726 3728
3727 3729
3728 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) { 3730 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) {
3729 ASSERT_EQ(3, args.length()); 3731 ASSERT_EQ(3, args.length());
3730 3732
3731 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); 3733 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0);
3732 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1); 3734 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1);
3733 CONVERT_ARG_HANDLE_CHECKED(JSArray, regexp_info, 2); 3735 CONVERT_ARG_HANDLE_CHECKED(JSArray, regexp_info, 2);
3734 HandleScope handles; 3736 HandleScope handles;
3735 3737
3738 Zone* zone = isolate->runtime_zone();
3736 Handle<Object> match = RegExpImpl::Exec(regexp, subject, 0, regexp_info, 3739 Handle<Object> match = RegExpImpl::Exec(regexp, subject, 0, regexp_info,
3737 isolate->zone()); 3740 zone);
3738 3741
3739 if (match.is_null()) { 3742 if (match.is_null()) {
3740 return Failure::Exception(); 3743 return Failure::Exception();
3741 } 3744 }
3742 if (match->IsNull()) { 3745 if (match->IsNull()) {
3743 return isolate->heap()->null_value(); 3746 return isolate->heap()->null_value();
3744 } 3747 }
3745 int length = subject->length(); 3748 int length = subject->length();
3746 3749
3747 Zone* zone = isolate->zone(); 3750 ZoneScope zone_space(zone, DELETE_ON_EXIT);
3748 ZoneScope zone_space(isolate, DELETE_ON_EXIT);
3749 ZoneList<int> offsets(8, zone); 3751 ZoneList<int> offsets(8, zone);
3750 int start; 3752 int start;
3751 int end; 3753 int end;
3752 do { 3754 do {
3753 { 3755 {
3754 AssertNoAllocation no_alloc; 3756 AssertNoAllocation no_alloc;
3755 FixedArray* elements = FixedArray::cast(regexp_info->elements()); 3757 FixedArray* elements = FixedArray::cast(regexp_info->elements());
3756 start = Smi::cast(elements->get(RegExpImpl::kFirstCapture))->value(); 3758 start = Smi::cast(elements->get(RegExpImpl::kFirstCapture))->value();
3757 end = Smi::cast(elements->get(RegExpImpl::kFirstCapture + 1))->value(); 3759 end = Smi::cast(elements->get(RegExpImpl::kFirstCapture + 1))->value();
3758 } 3760 }
3759 offsets.Add(start, zone); 3761 offsets.Add(start, zone);
3760 offsets.Add(end, zone); 3762 offsets.Add(end, zone);
3761 if (start == end) if (++end > length) break; 3763 if (start == end) if (++end > length) break;
3762 match = RegExpImpl::Exec(regexp, subject, end, regexp_info, 3764 match = RegExpImpl::Exec(regexp, subject, end, regexp_info,
3763 isolate->zone()); 3765 zone);
3764 if (match.is_null()) { 3766 if (match.is_null()) {
3765 return Failure::Exception(); 3767 return Failure::Exception();
3766 } 3768 }
3767 } while (!match->IsNull()); 3769 } while (!match->IsNull());
3768 int matches = offsets.length() / 2; 3770 int matches = offsets.length() / 2;
3769 Handle<FixedArray> elements = isolate->factory()->NewFixedArray(matches); 3771 Handle<FixedArray> elements = isolate->factory()->NewFixedArray(matches);
3770 Handle<String> substring = isolate->factory()-> 3772 Handle<String> substring = isolate->factory()->
3771 NewSubString(subject, offsets.at(0), offsets.at(1)); 3773 NewSubString(subject, offsets.at(0), offsets.at(1));
3772 elements->set(0, *substring); 3774 elements->set(0, *substring);
3773 for (int i = 1; i < matches ; i++) { 3775 for (int i = 1; i < matches ; i++) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
3848 3850
3849 3851
3850 static int SearchRegExpNoCaptureMultiple( 3852 static int SearchRegExpNoCaptureMultiple(
3851 Isolate* isolate, 3853 Isolate* isolate,
3852 Handle<String> subject, 3854 Handle<String> subject,
3853 Handle<JSRegExp> regexp, 3855 Handle<JSRegExp> regexp,
3854 Handle<JSArray> last_match_array, 3856 Handle<JSArray> last_match_array,
3855 FixedArrayBuilder* builder) { 3857 FixedArrayBuilder* builder) {
3856 ASSERT(subject->IsFlat()); 3858 ASSERT(subject->IsFlat());
3857 ASSERT(regexp->CaptureCount() == 0); 3859 ASSERT(regexp->CaptureCount() == 0);
3860 Zone* zone = isolate->runtime_zone();
3858 int match_start = -1; 3861 int match_start = -1;
3859 int match_end = 0; 3862 int match_end = 0;
3860 int pos = 0; 3863 int pos = 0;
3861 int registers_per_match = RegExpImpl::IrregexpPrepare(regexp, subject, 3864 int registers_per_match = RegExpImpl::IrregexpPrepare(regexp, subject,
3862 isolate->zone()); 3865 zone);
3863 if (registers_per_match < 0) return RegExpImpl::RE_EXCEPTION; 3866 if (registers_per_match < 0) return RegExpImpl::RE_EXCEPTION;
3864 3867
3865 int max_matches; 3868 int max_matches;
3866 int num_registers = RegExpImpl::GlobalOffsetsVectorSize(regexp, 3869 int num_registers = RegExpImpl::GlobalOffsetsVectorSize(regexp,
3867 registers_per_match, 3870 registers_per_match,
3868 &max_matches); 3871 &max_matches);
3869 OffsetsVector registers(num_registers, isolate); 3872 OffsetsVector registers(num_registers, isolate);
3870 Vector<int32_t> register_vector(registers.vector(), registers.length()); 3873 Vector<int32_t> register_vector(registers.vector(), registers.length());
3871 int subject_length = subject->length(); 3874 int subject_length = subject->length();
3872 bool first = true; 3875 bool first = true;
3873 for (;;) { // Break on failure, return on exception. 3876 for (;;) { // Break on failure, return on exception.
3874 int num_matches = RegExpImpl::IrregexpExecRaw(regexp, 3877 int num_matches = RegExpImpl::IrregexpExecRaw(regexp,
3875 subject, 3878 subject,
3876 pos, 3879 pos,
3877 register_vector, 3880 register_vector,
3878 isolate->zone()); 3881 zone);
3879 if (num_matches > 0) { 3882 if (num_matches > 0) {
3880 for (int match_index = 0; match_index < num_matches; match_index++) { 3883 for (int match_index = 0; match_index < num_matches; match_index++) {
3881 int32_t* current_match = &register_vector[match_index * 2]; 3884 int32_t* current_match = &register_vector[match_index * 2];
3882 match_start = current_match[0]; 3885 match_start = current_match[0];
3883 builder->EnsureCapacity(kMaxBuilderEntriesPerRegExpMatch); 3886 builder->EnsureCapacity(kMaxBuilderEntriesPerRegExpMatch);
3884 if (match_end < match_start) { 3887 if (match_end < match_start) {
3885 ReplacementStringBuilder::AddSubjectSlice(builder, 3888 ReplacementStringBuilder::AddSubjectSlice(builder,
3886 match_end, 3889 match_end,
3887 match_start); 3890 match_start);
3888 } 3891 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
3935 } 3938 }
3936 3939
3937 3940
3938 // Only called from Runtime_RegExpExecMultiple so it doesn't need to maintain 3941 // Only called from Runtime_RegExpExecMultiple so it doesn't need to maintain
3939 // separate last match info. See comment on that function. 3942 // separate last match info. See comment on that function.
3940 static int SearchRegExpMultiple( 3943 static int SearchRegExpMultiple(
3941 Isolate* isolate, 3944 Isolate* isolate,
3942 Handle<String> subject, 3945 Handle<String> subject,
3943 Handle<JSRegExp> regexp, 3946 Handle<JSRegExp> regexp,
3944 Handle<JSArray> last_match_array, 3947 Handle<JSArray> last_match_array,
3945 FixedArrayBuilder* builder) { 3948 FixedArrayBuilder* builder,
3949 Zone* zone) {
3946 3950
3947 ASSERT(subject->IsFlat()); 3951 ASSERT(subject->IsFlat());
3948 int registers_per_match = RegExpImpl::IrregexpPrepare(regexp, subject, 3952 int registers_per_match = RegExpImpl::IrregexpPrepare(regexp, subject,
3949 isolate->zone()); 3953 zone);
3950 if (registers_per_match < 0) return RegExpImpl::RE_EXCEPTION; 3954 if (registers_per_match < 0) return RegExpImpl::RE_EXCEPTION;
3951 3955
3952 int max_matches; 3956 int max_matches;
3953 int num_registers = RegExpImpl::GlobalOffsetsVectorSize(regexp, 3957 int num_registers = RegExpImpl::GlobalOffsetsVectorSize(regexp,
3954 registers_per_match, 3958 registers_per_match,
3955 &max_matches); 3959 &max_matches);
3956 OffsetsVector registers(num_registers, isolate); 3960 OffsetsVector registers(num_registers, isolate);
3957 Vector<int32_t> register_vector(registers.vector(), registers.length()); 3961 Vector<int32_t> register_vector(registers.vector(), registers.length());
3958 3962
3959 int num_matches = RegExpImpl::IrregexpExecRaw(regexp, 3963 int num_matches = RegExpImpl::IrregexpExecRaw(regexp,
3960 subject, 3964 subject,
3961 0, 3965 0,
3962 register_vector, 3966 register_vector,
3963 isolate->zone()); 3967 zone);
3964 3968
3965 int capture_count = regexp->CaptureCount(); 3969 int capture_count = regexp->CaptureCount();
3966 int subject_length = subject->length(); 3970 int subject_length = subject->length();
3967 3971
3968 // Position to search from. 3972 // Position to search from.
3969 int pos = 0; 3973 int pos = 0;
3970 // End of previous match. Differs from pos if match was empty. 3974 // End of previous match. Differs from pos if match was empty.
3971 int match_end = 0; 3975 int match_end = 0;
3972 bool first = true; 3976 bool first = true;
3973 3977
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
4040 pos = match_end + 1; 4044 pos = match_end + 1;
4041 if (pos > subject_length) { 4045 if (pos > subject_length) {
4042 break; 4046 break;
4043 } 4047 }
4044 } 4048 }
4045 4049
4046 num_matches = RegExpImpl::IrregexpExecRaw(regexp, 4050 num_matches = RegExpImpl::IrregexpExecRaw(regexp,
4047 subject, 4051 subject,
4048 pos, 4052 pos,
4049 register_vector, 4053 register_vector,
4050 isolate->zone()); 4054 zone);
4051 } while (num_matches > 0); 4055 } while (num_matches > 0);
4052 4056
4053 if (num_matches != RegExpImpl::RE_EXCEPTION) { 4057 if (num_matches != RegExpImpl::RE_EXCEPTION) {
4054 // Finished matching, with at least one match. 4058 // Finished matching, with at least one match.
4055 if (match_end < subject_length) { 4059 if (match_end < subject_length) {
4056 ReplacementStringBuilder::AddSubjectSlice(builder, 4060 ReplacementStringBuilder::AddSubjectSlice(builder,
4057 match_end, 4061 match_end,
4058 subject_length); 4062 subject_length);
4059 } 4063 }
4060 4064
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
4121 result = SearchRegExpNoCaptureMultiple(isolate, 4125 result = SearchRegExpNoCaptureMultiple(isolate,
4122 subject, 4126 subject,
4123 regexp, 4127 regexp,
4124 last_match_info, 4128 last_match_info,
4125 &builder); 4129 &builder);
4126 } else { 4130 } else {
4127 result = SearchRegExpMultiple(isolate, 4131 result = SearchRegExpMultiple(isolate,
4128 subject, 4132 subject,
4129 regexp, 4133 regexp,
4130 last_match_info, 4134 last_match_info,
4131 &builder); 4135 &builder,
4136 isolate->runtime_zone());
4132 } 4137 }
4133 if (result == RegExpImpl::RE_SUCCESS) return *builder.ToJSArray(result_array); 4138 if (result == RegExpImpl::RE_SUCCESS) return *builder.ToJSArray(result_array);
4134 if (result == RegExpImpl::RE_FAILURE) return isolate->heap()->null_value(); 4139 if (result == RegExpImpl::RE_FAILURE) return isolate->heap()->null_value();
4135 ASSERT_EQ(result, RegExpImpl::RE_EXCEPTION); 4140 ASSERT_EQ(result, RegExpImpl::RE_EXCEPTION);
4136 return Failure::Exception(); 4141 return Failure::Exception();
4137 } 4142 }
4138 4143
4139 4144
4140 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToRadixString) { 4145 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToRadixString) {
4141 NoHandleAllocation ha; 4146 NoHandleAllocation ha;
(...skipping 2314 matching lines...) Expand 10 before | Expand all | Expand 10 after
6456 } 6461 }
6457 6462
6458 // The limit can be very large (0xffffffffu), but since the pattern 6463 // The limit can be very large (0xffffffffu), but since the pattern
6459 // isn't empty, we can never create more parts than ~half the length 6464 // isn't empty, we can never create more parts than ~half the length
6460 // of the subject. 6465 // of the subject.
6461 6466
6462 if (!subject->IsFlat()) FlattenString(subject); 6467 if (!subject->IsFlat()) FlattenString(subject);
6463 6468
6464 static const int kMaxInitialListCapacity = 16; 6469 static const int kMaxInitialListCapacity = 16;
6465 6470
6466 Zone* zone = isolate->zone(); 6471 Zone* zone = isolate->runtime_zone();
6467 ZoneScope scope(isolate, DELETE_ON_EXIT); 6472 ZoneScope scope(zone, DELETE_ON_EXIT);
6468 6473
6469 // Find (up to limit) indices of separator and end-of-string in subject 6474 // Find (up to limit) indices of separator and end-of-string in subject
6470 int initial_capacity = Min<uint32_t>(kMaxInitialListCapacity, limit); 6475 int initial_capacity = Min<uint32_t>(kMaxInitialListCapacity, limit);
6471 ZoneList<int> indices(initial_capacity, zone); 6476 ZoneList<int> indices(initial_capacity, zone);
6472 if (!pattern->IsFlat()) FlattenString(pattern); 6477 if (!pattern->IsFlat()) FlattenString(pattern);
6473 6478
6474 FindStringIndicesDispatch(isolate, *subject, *pattern, &indices, limit, zone); 6479 FindStringIndicesDispatch(isolate, *subject, *pattern, &indices, limit, zone);
6475 6480
6476 if (static_cast<uint32_t>(indices.length()) < limit) { 6481 if (static_cast<uint32_t>(indices.length()) < limit) {
6477 indices.Add(subject_length, zone); 6482 indices.Add(subject_length, zone);
(...skipping 2828 matching lines...) Expand 10 before | Expand all | Expand 10 after
9306 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); 9311 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value();
9307 return JSGlobalObject::cast(global)->global_receiver(); 9312 return JSGlobalObject::cast(global)->global_receiver();
9308 } 9313 }
9309 9314
9310 9315
9311 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) { 9316 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) {
9312 HandleScope scope(isolate); 9317 HandleScope scope(isolate);
9313 ASSERT_EQ(1, args.length()); 9318 ASSERT_EQ(1, args.length());
9314 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); 9319 CONVERT_ARG_HANDLE_CHECKED(String, source, 0);
9315 9320
9316 Zone* zone = isolate->zone(); 9321 Zone* zone = isolate->runtime_zone();
9317 source = Handle<String>(source->TryFlattenGetString()); 9322 source = Handle<String>(source->TryFlattenGetString());
9318 // Optimized fast case where we only have ASCII characters. 9323 // Optimized fast case where we only have ASCII characters.
9319 Handle<Object> result; 9324 Handle<Object> result;
9320 if (source->IsSeqAsciiString()) { 9325 if (source->IsSeqAsciiString()) {
9321 result = JsonParser<true>::Parse(source, zone); 9326 result = JsonParser<true>::Parse(source, zone);
9322 } else { 9327 } else {
9323 result = JsonParser<false>::Parse(source, zone); 9328 result = JsonParser<false>::Parse(source, zone);
9324 } 9329 }
9325 if (result.is_null()) { 9330 if (result.is_null()) {
9326 // Syntax error or stack overflow in scanner. 9331 // Syntax error or stack overflow in scanner.
(...skipping 1810 matching lines...) Expand 10 before | Expand all | Expand 10 after
11137 ScopeIterator(Isolate* isolate, 11142 ScopeIterator(Isolate* isolate,
11138 JavaScriptFrame* frame, 11143 JavaScriptFrame* frame,
11139 int inlined_jsframe_index) 11144 int inlined_jsframe_index)
11140 : isolate_(isolate), 11145 : isolate_(isolate),
11141 frame_(frame), 11146 frame_(frame),
11142 inlined_jsframe_index_(inlined_jsframe_index), 11147 inlined_jsframe_index_(inlined_jsframe_index),
11143 function_(JSFunction::cast(frame->function())), 11148 function_(JSFunction::cast(frame->function())),
11144 context_(Context::cast(frame->context())), 11149 context_(Context::cast(frame->context())),
11145 nested_scope_chain_(4) { 11150 nested_scope_chain_(4) {
11146 11151
11152 Zone zone(isolate);
danno 2012/06/14 14:22:19 Why put this here and not closer to the Compilatio
sanjoy 2012/06/15 09:24:31 Because below a Scope allocated inside a Zone is b
11153 ZoneScope zone_scope(&zone, DELETE_ON_EXIT);
11147 // Catch the case when the debugger stops in an internal function. 11154 // Catch the case when the debugger stops in an internal function.
11148 Handle<SharedFunctionInfo> shared_info(function_->shared()); 11155 Handle<SharedFunctionInfo> shared_info(function_->shared());
11149 Handle<ScopeInfo> scope_info(shared_info->scope_info()); 11156 Handle<ScopeInfo> scope_info(shared_info->scope_info());
11150 if (shared_info->script() == isolate->heap()->undefined_value()) { 11157 if (shared_info->script() == isolate->heap()->undefined_value()) {
11151 while (context_->closure() == *function_) { 11158 while (context_->closure() == *function_) {
11152 context_ = Handle<Context>(context_->previous(), isolate_); 11159 context_ = Handle<Context>(context_->previous(), isolate_);
11153 } 11160 }
11154 return; 11161 return;
11155 } 11162 }
11156 11163
(...skipping 16 matching lines...) Expand all
11173 if (scope_info->HasContext()) { 11180 if (scope_info->HasContext()) {
11174 context_ = Handle<Context>(context_->declaration_context(), isolate_); 11181 context_ = Handle<Context>(context_->declaration_context(), isolate_);
11175 } else { 11182 } else {
11176 while (context_->closure() == *function_) { 11183 while (context_->closure() == *function_) {
11177 context_ = Handle<Context>(context_->previous(), isolate_); 11184 context_ = Handle<Context>(context_->previous(), isolate_);
11178 } 11185 }
11179 } 11186 }
11180 if (scope_info->Type() != EVAL_SCOPE) nested_scope_chain_.Add(scope_info); 11187 if (scope_info->Type() != EVAL_SCOPE) nested_scope_chain_.Add(scope_info);
11181 } else { 11188 } else {
11182 // Reparse the code and analyze the scopes. 11189 // Reparse the code and analyze the scopes.
11183 ZoneScope zone_scope(isolate, DELETE_ON_EXIT);
11184 Handle<Script> script(Script::cast(shared_info->script())); 11190 Handle<Script> script(Script::cast(shared_info->script()));
11185 Scope* scope = NULL; 11191 Scope* scope = NULL;
11186 11192
11187 // Check whether we are in global, eval or function code. 11193 // Check whether we are in global, eval or function code.
11188 Handle<ScopeInfo> scope_info(shared_info->scope_info()); 11194 Handle<ScopeInfo> scope_info(shared_info->scope_info());
11189 if (scope_info->Type() != FUNCTION_SCOPE) { 11195 if (scope_info->Type() != FUNCTION_SCOPE) {
11190 // Global or eval code. 11196 // Global or eval code.
11191 CompilationInfo info(script); 11197 CompilationInfo info(script, &zone);
11192 if (scope_info->Type() == GLOBAL_SCOPE) { 11198 if (scope_info->Type() == GLOBAL_SCOPE) {
11193 info.MarkAsGlobal(); 11199 info.MarkAsGlobal();
11194 } else { 11200 } else {
11195 ASSERT(scope_info->Type() == EVAL_SCOPE); 11201 ASSERT(scope_info->Type() == EVAL_SCOPE);
11196 info.MarkAsEval(); 11202 info.MarkAsEval();
11197 info.SetCallingContext(Handle<Context>(function_->context())); 11203 info.SetCallingContext(Handle<Context>(function_->context()));
11198 } 11204 }
11199 if (ParserApi::Parse(&info, kNoParsingFlags) && Scope::Analyze(&info)) { 11205 if (ParserApi::Parse(&info, kNoParsingFlags) && Scope::Analyze(&info)) {
11200 scope = info.function()->scope(); 11206 scope = info.function()->scope();
11201 } 11207 }
11202 } else { 11208 } else {
11203 // Function code 11209 // Function code
11204 CompilationInfo info(shared_info); 11210 CompilationInfo info(shared_info, &zone);
11205 if (ParserApi::Parse(&info, kNoParsingFlags) && Scope::Analyze(&info)) { 11211 if (ParserApi::Parse(&info, kNoParsingFlags) && Scope::Analyze(&info)) {
11206 scope = info.function()->scope(); 11212 scope = info.function()->scope();
11207 } 11213 }
11208 } 11214 }
11209 11215
11210 // Retrieve the scope chain for the current position. 11216 // Retrieve the scope chain for the current position.
11211 if (scope != NULL) { 11217 if (scope != NULL) {
11212 int source_position = shared_info->code()->SourcePosition(frame_->pc()); 11218 int source_position = shared_info->code()->SourcePosition(frame_->pc());
11213 scope->GetNestedScopeChain(&nested_scope_chain_, source_position); 11219 scope->GetNestedScopeChain(&nested_scope_chain_, source_position);
11214 } else { 11220 } else {
(...skipping 1554 matching lines...) Expand 10 before | Expand all | Expand 10 after
12769 // checks that none of them have activations on stacks (of any thread). 12775 // checks that none of them have activations on stacks (of any thread).
12770 // Returns array of the same length with corresponding results of 12776 // Returns array of the same length with corresponding results of
12771 // LiveEdit::FunctionPatchabilityStatus type. 12777 // LiveEdit::FunctionPatchabilityStatus type.
12772 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCheckAndDropActivations) { 12778 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCheckAndDropActivations) {
12773 ASSERT(args.length() == 2); 12779 ASSERT(args.length() == 2);
12774 HandleScope scope(isolate); 12780 HandleScope scope(isolate);
12775 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0); 12781 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0);
12776 CONVERT_BOOLEAN_ARG_CHECKED(do_drop, 1); 12782 CONVERT_BOOLEAN_ARG_CHECKED(do_drop, 1);
12777 12783
12778 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop, 12784 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop,
12779 isolate->zone()); 12785 isolate->runtime_zone());
12780 } 12786 }
12781 12787
12782 // Compares 2 strings line-by-line, then token-wise and returns diff in form 12788 // Compares 2 strings line-by-line, then token-wise and returns diff in form
12783 // of JSArray of triplets (pos1, pos1_end, pos2_end) describing list 12789 // of JSArray of triplets (pos1, pos1_end, pos2_end) describing list
12784 // of diff chunks. 12790 // of diff chunks.
12785 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCompareStrings) { 12791 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCompareStrings) {
12786 ASSERT(args.length() == 2); 12792 ASSERT(args.length() == 2);
12787 HandleScope scope(isolate); 12793 HandleScope scope(isolate);
12788 CONVERT_ARG_HANDLE_CHECKED(String, s1, 0); 12794 CONVERT_ARG_HANDLE_CHECKED(String, s1, 0);
12789 CONVERT_ARG_HANDLE_CHECKED(String, s2, 1); 12795 CONVERT_ARG_HANDLE_CHECKED(String, s2, 1);
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
13595 // Handle last resort GC and make sure to allow future allocations 13601 // Handle last resort GC and make sure to allow future allocations
13596 // to grow the heap without causing GCs (if possible). 13602 // to grow the heap without causing GCs (if possible).
13597 isolate->counters()->gc_last_resort_from_js()->Increment(); 13603 isolate->counters()->gc_last_resort_from_js()->Increment();
13598 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13604 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13599 "Runtime::PerformGC"); 13605 "Runtime::PerformGC");
13600 } 13606 }
13601 } 13607 }
13602 13608
13603 13609
13604 } } // namespace v8::internal 13610 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698