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

Side by Side Diff: src/runtime/runtime-regexp.cc

Issue 2778953004: [regexp] Properly handle failed RegExp compilations (Closed)
Patch Set: --stack-size Created 3 years, 8 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
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-705934.js » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include <functional> 7 #include <functional>
8 8
9 #include "src/arguments.h" 9 #include "src/arguments.h"
10 #include "src/conversions-inl.h" 10 #include "src/conversions-inl.h"
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 Handle<String> replacement, Handle<RegExpMatchInfo> last_match_info) { 599 Handle<String> replacement, Handle<RegExpMatchInfo> last_match_info) {
600 DCHECK(subject->IsFlat()); 600 DCHECK(subject->IsFlat());
601 DCHECK(replacement->IsFlat()); 601 DCHECK(replacement->IsFlat());
602 602
603 int capture_count = regexp->CaptureCount(); 603 int capture_count = regexp->CaptureCount();
604 int subject_length = subject->length(); 604 int subject_length = subject->length();
605 605
606 JSRegExp::Type typeTag = regexp->TypeTag(); 606 JSRegExp::Type typeTag = regexp->TypeTag();
607 if (typeTag == JSRegExp::IRREGEXP) { 607 if (typeTag == JSRegExp::IRREGEXP) {
608 // Ensure the RegExp is compiled so we can access the capture-name map. 608 // Ensure the RegExp is compiled so we can access the capture-name map.
609 RegExpImpl::IrregexpPrepare(regexp, subject); 609 if (RegExpImpl::IrregexpPrepare(regexp, subject) == -1) {
610 DCHECK(isolate->has_pending_exception());
611 return isolate->heap()->exception();
612 }
610 } 613 }
611 614
612 // CompiledReplacement uses zone allocation. 615 // CompiledReplacement uses zone allocation.
613 Zone zone(isolate->allocator(), ZONE_NAME); 616 Zone zone(isolate->allocator(), ZONE_NAME);
614 CompiledReplacement compiled_replacement(&zone); 617 CompiledReplacement compiled_replacement(&zone);
615 Maybe<bool> maybe_simple_replace = compiled_replacement.Compile( 618 Maybe<bool> maybe_simple_replace = compiled_replacement.Compile(
616 regexp, replacement, capture_count, subject_length); 619 regexp, replacement, capture_count, subject_length);
617 if (maybe_simple_replace.IsNothing()) { 620 if (maybe_simple_replace.IsNothing()) {
618 THROW_NEW_ERROR_RETURN_FAILURE( 621 THROW_NEW_ERROR_RETURN_FAILURE(
619 isolate, NewSyntaxError(MessageTemplate::kRegExpInvalidReplaceString, 622 isolate, NewSyntaxError(MessageTemplate::kRegExpInvalidReplaceString,
(...skipping 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1935 1938
1936 RUNTIME_FUNCTION(Runtime_IsRegExp) { 1939 RUNTIME_FUNCTION(Runtime_IsRegExp) {
1937 SealHandleScope shs(isolate); 1940 SealHandleScope shs(isolate);
1938 DCHECK_EQ(1, args.length()); 1941 DCHECK_EQ(1, args.length());
1939 CONVERT_ARG_CHECKED(Object, obj, 0); 1942 CONVERT_ARG_CHECKED(Object, obj, 0);
1940 return isolate->heap()->ToBoolean(obj->IsJSRegExp()); 1943 return isolate->heap()->ToBoolean(obj->IsJSRegExp());
1941 } 1944 }
1942 1945
1943 } // namespace internal 1946 } // namespace internal
1944 } // namespace v8 1947 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-705934.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698