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

Side by Side Diff: src/jsregexp.cc

Issue 247013002: Replaced empty handle checks with MaybeHandles (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Removed unnecessary assert. Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/jsregexp.h ('k') | src/objects.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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 ASSERT(re->data()->IsFixedArray()); 229 ASSERT(re->data()->IsFixedArray());
230 // Compilation succeeded so the data is set on the regexp 230 // Compilation succeeded so the data is set on the regexp
231 // and we can store it in the cache. 231 // and we can store it in the cache.
232 Handle<FixedArray> data(FixedArray::cast(re->data())); 232 Handle<FixedArray> data(FixedArray::cast(re->data()));
233 compilation_cache->PutRegExp(pattern, flags, data); 233 compilation_cache->PutRegExp(pattern, flags, data);
234 234
235 return re; 235 return re;
236 } 236 }
237 237
238 238
239 Handle<Object> RegExpImpl::Exec(Handle<JSRegExp> regexp, 239 MaybeHandle<Object> RegExpImpl::Exec(Handle<JSRegExp> regexp,
240 Handle<String> subject, 240 Handle<String> subject,
241 int index, 241 int index,
242 Handle<JSArray> last_match_info) { 242 Handle<JSArray> last_match_info) {
243 switch (regexp->TypeTag()) { 243 switch (regexp->TypeTag()) {
244 case JSRegExp::ATOM: 244 case JSRegExp::ATOM:
245 return AtomExec(regexp, subject, index, last_match_info); 245 return AtomExec(regexp, subject, index, last_match_info);
246 case JSRegExp::IRREGEXP: { 246 case JSRegExp::IRREGEXP: {
247 Handle<Object> result = 247 return IrregexpExec(regexp, subject, index, last_match_info);
248 IrregexpExec(regexp, subject, index, last_match_info);
249 ASSERT(!result.is_null() ||
250 regexp->GetIsolate()->has_pending_exception());
251 return result;
252 } 248 }
253 default: 249 default:
254 UNREACHABLE(); 250 UNREACHABLE();
255 return Handle<Object>::null(); 251 return MaybeHandle<Object>();
256 } 252 }
257 } 253 }
258 254
259 255
260 // RegExp Atom implementation: Simple string search using indexOf. 256 // RegExp Atom implementation: Simple string search using indexOf.
261 257
262 258
263 void RegExpImpl::AtomCompile(Handle<JSRegExp> re, 259 void RegExpImpl::AtomCompile(Handle<JSRegExp> re,
264 Handle<String> pattern, 260 Handle<String> pattern,
265 JSRegExp::Flags flags, 261 JSRegExp::Flags flags,
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 } 630 }
635 if (result == RE_EXCEPTION) { 631 if (result == RE_EXCEPTION) {
636 ASSERT(!isolate->has_pending_exception()); 632 ASSERT(!isolate->has_pending_exception());
637 isolate->StackOverflow(); 633 isolate->StackOverflow();
638 } 634 }
639 return result; 635 return result;
640 #endif // V8_INTERPRETED_REGEXP 636 #endif // V8_INTERPRETED_REGEXP
641 } 637 }
642 638
643 639
644 Handle<Object> RegExpImpl::IrregexpExec(Handle<JSRegExp> regexp, 640 MaybeHandle<Object> RegExpImpl::IrregexpExec(Handle<JSRegExp> regexp,
645 Handle<String> subject, 641 Handle<String> subject,
646 int previous_index, 642 int previous_index,
647 Handle<JSArray> last_match_info) { 643 Handle<JSArray> last_match_info) {
648 Isolate* isolate = regexp->GetIsolate(); 644 Isolate* isolate = regexp->GetIsolate();
649 ASSERT_EQ(regexp->TypeTag(), JSRegExp::IRREGEXP); 645 ASSERT_EQ(regexp->TypeTag(), JSRegExp::IRREGEXP);
650 646
651 // Prepare space for the return values. 647 // Prepare space for the return values.
652 #if defined(V8_INTERPRETED_REGEXP) && defined(DEBUG) 648 #if defined(V8_INTERPRETED_REGEXP) && defined(DEBUG)
653 if (FLAG_trace_regexp_bytecodes) { 649 if (FLAG_trace_regexp_bytecodes) {
654 String* pattern = regexp->Pattern(); 650 String* pattern = regexp->Pattern();
655 PrintF("\n\nRegexp match: /%s/\n\n", pattern->ToCString().get()); 651 PrintF("\n\nRegexp match: /%s/\n\n", pattern->ToCString().get());
656 PrintF("\n\nSubject string: '%s'\n\n", subject->ToCString().get()); 652 PrintF("\n\nSubject string: '%s'\n\n", subject->ToCString().get());
657 } 653 }
658 #endif 654 #endif
659 int required_registers = RegExpImpl::IrregexpPrepare(regexp, subject); 655 int required_registers = RegExpImpl::IrregexpPrepare(regexp, subject);
660 if (required_registers < 0) { 656 if (required_registers < 0) {
661 // Compiling failed with an exception. 657 // Compiling failed with an exception.
662 ASSERT(isolate->has_pending_exception()); 658 ASSERT(isolate->has_pending_exception());
663 return Handle<Object>::null(); 659 return MaybeHandle<Object>();
664 } 660 }
665 661
666 int32_t* output_registers = NULL; 662 int32_t* output_registers = NULL;
667 if (required_registers > Isolate::kJSRegexpStaticOffsetsVectorSize) { 663 if (required_registers > Isolate::kJSRegexpStaticOffsetsVectorSize) {
668 output_registers = NewArray<int32_t>(required_registers); 664 output_registers = NewArray<int32_t>(required_registers);
669 } 665 }
670 SmartArrayPointer<int32_t> auto_release(output_registers); 666 SmartArrayPointer<int32_t> auto_release(output_registers);
671 if (output_registers == NULL) { 667 if (output_registers == NULL) {
672 output_registers = isolate->jsregexp_static_offsets_vector(); 668 output_registers = isolate->jsregexp_static_offsets_vector();
673 } 669 }
674 670
675 int res = RegExpImpl::IrregexpExecRaw( 671 int res = RegExpImpl::IrregexpExecRaw(
676 regexp, subject, previous_index, output_registers, required_registers); 672 regexp, subject, previous_index, output_registers, required_registers);
677 if (res == RE_SUCCESS) { 673 if (res == RE_SUCCESS) {
678 int capture_count = 674 int capture_count =
679 IrregexpNumberOfCaptures(FixedArray::cast(regexp->data())); 675 IrregexpNumberOfCaptures(FixedArray::cast(regexp->data()));
680 return SetLastMatchInfo( 676 return SetLastMatchInfo(
681 last_match_info, subject, capture_count, output_registers); 677 last_match_info, subject, capture_count, output_registers);
682 } 678 }
683 if (res == RE_EXCEPTION) { 679 if (res == RE_EXCEPTION) {
684 ASSERT(isolate->has_pending_exception()); 680 ASSERT(isolate->has_pending_exception());
685 return Handle<Object>::null(); 681 return MaybeHandle<Object>();
686 } 682 }
687 ASSERT(res == RE_FAILURE); 683 ASSERT(res == RE_FAILURE);
688 return isolate->factory()->null_value(); 684 return isolate->factory()->null_value();
689 } 685 }
690 686
691 687
692 Handle<JSArray> RegExpImpl::SetLastMatchInfo(Handle<JSArray> last_match_info, 688 Handle<JSArray> RegExpImpl::SetLastMatchInfo(Handle<JSArray> last_match_info,
693 Handle<String> subject, 689 Handle<String> subject,
694 int capture_count, 690 int capture_count,
695 int32_t* match) { 691 int32_t* match) {
(...skipping 5433 matching lines...) Expand 10 before | Expand all | Expand 10 after
6129 } 6125 }
6130 6126
6131 return compiler.Assemble(&macro_assembler, 6127 return compiler.Assemble(&macro_assembler,
6132 node, 6128 node,
6133 data->capture_count, 6129 data->capture_count,
6134 pattern); 6130 pattern);
6135 } 6131 }
6136 6132
6137 6133
6138 }} // namespace v8::internal 6134 }} // namespace v8::internal
OLDNEW
« no previous file with comments | « src/jsregexp.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698