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 3745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3756 Handle<JSRegExp> regexp, | 3756 Handle<JSRegExp> regexp, |
3757 Handle<JSArray> last_match_array, | 3757 Handle<JSArray> last_match_array, |
3758 FixedArrayBuilder* builder) { | 3758 FixedArrayBuilder* builder) { |
3759 ASSERT(subject->IsFlat()); | 3759 ASSERT(subject->IsFlat()); |
3760 int match_start = -1; | 3760 int match_start = -1; |
3761 int match_end = 0; | 3761 int match_end = 0; |
3762 int pos = 0; | 3762 int pos = 0; |
3763 int required_registers = RegExpImpl::IrregexpPrepare(regexp, subject); | 3763 int required_registers = RegExpImpl::IrregexpPrepare(regexp, subject); |
3764 if (required_registers < 0) return RegExpImpl::RE_EXCEPTION; | 3764 if (required_registers < 0) return RegExpImpl::RE_EXCEPTION; |
3765 | 3765 |
3766 OffsetsVector registers(required_registers); | 3766 OffsetsVector registers(required_registers, isolate); |
3767 Vector<int32_t> register_vector(registers.vector(), registers.length()); | 3767 Vector<int32_t> register_vector(registers.vector(), registers.length()); |
3768 int subject_length = subject->length(); | 3768 int subject_length = subject->length(); |
3769 bool first = true; | 3769 bool first = true; |
3770 | 3770 |
3771 for (;;) { // Break on failure, return on exception. | 3771 for (;;) { // Break on failure, return on exception. |
3772 RegExpImpl::IrregexpResult result = | 3772 RegExpImpl::IrregexpResult result = |
3773 RegExpImpl::IrregexpExecOnce(regexp, | 3773 RegExpImpl::IrregexpExecOnce(regexp, |
3774 subject, | 3774 subject, |
3775 pos, | 3775 pos, |
3776 register_vector); | 3776 register_vector); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3829 Isolate* isolate, | 3829 Isolate* isolate, |
3830 Handle<String> subject, | 3830 Handle<String> subject, |
3831 Handle<JSRegExp> regexp, | 3831 Handle<JSRegExp> regexp, |
3832 Handle<JSArray> last_match_array, | 3832 Handle<JSArray> last_match_array, |
3833 FixedArrayBuilder* builder) { | 3833 FixedArrayBuilder* builder) { |
3834 | 3834 |
3835 ASSERT(subject->IsFlat()); | 3835 ASSERT(subject->IsFlat()); |
3836 int required_registers = RegExpImpl::IrregexpPrepare(regexp, subject); | 3836 int required_registers = RegExpImpl::IrregexpPrepare(regexp, subject); |
3837 if (required_registers < 0) return RegExpImpl::RE_EXCEPTION; | 3837 if (required_registers < 0) return RegExpImpl::RE_EXCEPTION; |
3838 | 3838 |
3839 OffsetsVector registers(required_registers); | 3839 OffsetsVector registers(required_registers, isolate); |
3840 Vector<int32_t> register_vector(registers.vector(), registers.length()); | 3840 Vector<int32_t> register_vector(registers.vector(), registers.length()); |
3841 | 3841 |
3842 RegExpImpl::IrregexpResult result = | 3842 RegExpImpl::IrregexpResult result = |
3843 RegExpImpl::IrregexpExecOnce(regexp, | 3843 RegExpImpl::IrregexpExecOnce(regexp, |
3844 subject, | 3844 subject, |
3845 0, | 3845 0, |
3846 register_vector); | 3846 register_vector); |
3847 | 3847 |
3848 int capture_count = regexp->CaptureCount(); | 3848 int capture_count = regexp->CaptureCount(); |
3849 int subject_length = subject->length(); | 3849 int subject_length = subject->length(); |
3850 | 3850 |
3851 // Position to search from. | 3851 // Position to search from. |
3852 int pos = 0; | 3852 int pos = 0; |
3853 // End of previous match. Differs from pos if match was empty. | 3853 // End of previous match. Differs from pos if match was empty. |
3854 int match_end = 0; | 3854 int match_end = 0; |
3855 if (result == RegExpImpl::RE_SUCCESS) { | 3855 if (result == RegExpImpl::RE_SUCCESS) { |
3856 // Need to keep a copy of the previous match for creating last_match_info | 3856 // Need to keep a copy of the previous match for creating last_match_info |
3857 // at the end, so we have two vectors that we swap between. | 3857 // at the end, so we have two vectors that we swap between. |
3858 OffsetsVector registers2(required_registers); | 3858 OffsetsVector registers2(required_registers, isolate); |
3859 Vector<int> prev_register_vector(registers2.vector(), registers2.length()); | 3859 Vector<int> prev_register_vector(registers2.vector(), registers2.length()); |
3860 bool first = true; | 3860 bool first = true; |
3861 do { | 3861 do { |
3862 int match_start = register_vector[0]; | 3862 int match_start = register_vector[0]; |
3863 builder->EnsureCapacity(kMaxBuilderEntriesPerRegExpMatch); | 3863 builder->EnsureCapacity(kMaxBuilderEntriesPerRegExpMatch); |
3864 if (match_end < match_start) { | 3864 if (match_end < match_start) { |
3865 ReplacementStringBuilder::AddSubjectSlice(builder, | 3865 ReplacementStringBuilder::AddSubjectSlice(builder, |
3866 match_end, | 3866 match_end, |
3867 match_start); | 3867 match_start); |
3868 } | 3868 } |
(...skipping 5324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9193 | 9193 |
9194 RUNTIME_FUNCTION(MaybeObject*, Runtime_StackGuard) { | 9194 RUNTIME_FUNCTION(MaybeObject*, Runtime_StackGuard) { |
9195 ASSERT(args.length() == 0); | 9195 ASSERT(args.length() == 0); |
9196 | 9196 |
9197 // First check if this is a real stack overflow. | 9197 // First check if this is a real stack overflow. |
9198 if (isolate->stack_guard()->IsStackOverflow()) { | 9198 if (isolate->stack_guard()->IsStackOverflow()) { |
9199 NoHandleAllocation na; | 9199 NoHandleAllocation na; |
9200 return isolate->StackOverflow(); | 9200 return isolate->StackOverflow(); |
9201 } | 9201 } |
9202 | 9202 |
9203 return Execution::HandleStackGuardInterrupt(); | 9203 return Execution::HandleStackGuardInterrupt(isolate); |
9204 } | 9204 } |
9205 | 9205 |
9206 | 9206 |
9207 RUNTIME_FUNCTION(MaybeObject*, Runtime_Interrupt) { | 9207 RUNTIME_FUNCTION(MaybeObject*, Runtime_Interrupt) { |
9208 ASSERT(args.length() == 0); | 9208 ASSERT(args.length() == 0); |
9209 return Execution::HandleStackGuardInterrupt(); | 9209 return Execution::HandleStackGuardInterrupt(isolate); |
9210 } | 9210 } |
9211 | 9211 |
9212 | 9212 |
9213 static int StackSize() { | 9213 static int StackSize() { |
9214 int n = 0; | 9214 int n = 0; |
9215 for (JavaScriptFrameIterator it; !it.done(); it.Advance()) n++; | 9215 for (JavaScriptFrameIterator it; !it.done(); it.Advance()) n++; |
9216 return n; | 9216 return n; |
9217 } | 9217 } |
9218 | 9218 |
9219 | 9219 |
(...skipping 4401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13621 // Handle last resort GC and make sure to allow future allocations | 13621 // Handle last resort GC and make sure to allow future allocations |
13622 // to grow the heap without causing GCs (if possible). | 13622 // to grow the heap without causing GCs (if possible). |
13623 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13623 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13624 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13624 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13625 "Runtime::PerformGC"); | 13625 "Runtime::PerformGC"); |
13626 } | 13626 } |
13627 } | 13627 } |
13628 | 13628 |
13629 | 13629 |
13630 } } // namespace v8::internal | 13630 } } // namespace v8::internal |
OLD | NEW |