OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/ast.h" | 7 #include "src/ast.h" |
8 #include "src/base/platform/platform.h" | 8 #include "src/base/platform/platform.h" |
9 #include "src/compilation-cache.h" | 9 #include "src/compilation-cache.h" |
10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 } | 611 } |
612 if (res == RE_EXCEPTION) { | 612 if (res == RE_EXCEPTION) { |
613 DCHECK(isolate->has_pending_exception()); | 613 DCHECK(isolate->has_pending_exception()); |
614 return MaybeHandle<Object>(); | 614 return MaybeHandle<Object>(); |
615 } | 615 } |
616 DCHECK(res == RE_FAILURE); | 616 DCHECK(res == RE_FAILURE); |
617 return isolate->factory()->null_value(); | 617 return isolate->factory()->null_value(); |
618 } | 618 } |
619 | 619 |
620 | 620 |
| 621 static void EnsureSize(Handle<JSArray> array, uint32_t minimum_size) { |
| 622 if (static_cast<uint32_t>(array->elements()->length()) < minimum_size) { |
| 623 JSArray::SetLength(array, minimum_size); |
| 624 } |
| 625 } |
| 626 |
| 627 |
621 Handle<JSArray> RegExpImpl::SetLastMatchInfo(Handle<JSArray> last_match_info, | 628 Handle<JSArray> RegExpImpl::SetLastMatchInfo(Handle<JSArray> last_match_info, |
622 Handle<String> subject, | 629 Handle<String> subject, |
623 int capture_count, | 630 int capture_count, |
624 int32_t* match) { | 631 int32_t* match) { |
625 DCHECK(last_match_info->HasFastObjectElements()); | 632 DCHECK(last_match_info->HasFastObjectElements()); |
626 int capture_register_count = (capture_count + 1) * 2; | 633 int capture_register_count = (capture_count + 1) * 2; |
627 JSArray::SetLength(last_match_info, | 634 EnsureSize(last_match_info, capture_register_count + kLastMatchOverhead); |
628 capture_register_count + kLastMatchOverhead); | |
629 DisallowHeapAllocation no_allocation; | 635 DisallowHeapAllocation no_allocation; |
630 FixedArray* array = FixedArray::cast(last_match_info->elements()); | 636 FixedArray* array = FixedArray::cast(last_match_info->elements()); |
631 if (match != NULL) { | 637 if (match != NULL) { |
632 for (int i = 0; i < capture_register_count; i += 2) { | 638 for (int i = 0; i < capture_register_count; i += 2) { |
633 SetCapture(array, i, match[i]); | 639 SetCapture(array, i, match[i]); |
634 SetCapture(array, i + 1, match[i + 1]); | 640 SetCapture(array, i + 1, match[i + 1]); |
635 } | 641 } |
636 } | 642 } |
637 SetLastCaptureCount(array, capture_register_count); | 643 SetLastCaptureCount(array, capture_register_count); |
638 SetLastSubject(array, *subject); | 644 SetLastSubject(array, *subject); |
(...skipping 5710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6349 bool too_much = pattern->length() > RegExpImpl::kRegExpTooLargeToOptimize; | 6355 bool too_much = pattern->length() > RegExpImpl::kRegExpTooLargeToOptimize; |
6350 if (heap->total_regexp_code_generated() > RegExpImpl::kRegExpCompiledLimit && | 6356 if (heap->total_regexp_code_generated() > RegExpImpl::kRegExpCompiledLimit && |
6351 heap->isolate()->memory_allocator()->SizeExecutable() > | 6357 heap->isolate()->memory_allocator()->SizeExecutable() > |
6352 RegExpImpl::kRegExpExecutableMemoryLimit) { | 6358 RegExpImpl::kRegExpExecutableMemoryLimit) { |
6353 too_much = true; | 6359 too_much = true; |
6354 } | 6360 } |
6355 return too_much; | 6361 return too_much; |
6356 } | 6362 } |
6357 } // namespace internal | 6363 } // namespace internal |
6358 } // namespace v8 | 6364 } // namespace v8 |
OLD | NEW |