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

Side by Side Diff: src/jsregexp.cc

Issue 19538: The optimizations performed by Irregexp could possible hide bugs or... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 10 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/flag-definitions.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 1995 matching lines...) Expand 10 before | Expand all | Expand 10 after
2006 return DONE; 2006 return DONE;
2007 } 2007 }
2008 // Generate generic version of the node and bind the label for later use. 2008 // Generate generic version of the node and bind the label for later use.
2009 macro_assembler->Bind(&label_); 2009 macro_assembler->Bind(&label_);
2010 return CONTINUE; 2010 return CONTINUE;
2011 } 2011 }
2012 2012
2013 // We are being asked to make a non-generic version. Keep track of how many 2013 // We are being asked to make a non-generic version. Keep track of how many
2014 // non-generic versions we generate so as not to overdo it. 2014 // non-generic versions we generate so as not to overdo it.
2015 trace_count_++; 2015 trace_count_++;
2016 if (trace_count_ < kMaxCopiesCodeGenerated && 2016 if (FLAG_irregexp_optimization &&
2017 trace_count_ < kMaxCopiesCodeGenerated &&
2017 compiler->recursion_depth() <= RegExpCompiler::kMaxRecursion) { 2018 compiler->recursion_depth() <= RegExpCompiler::kMaxRecursion) {
2018 return CONTINUE; 2019 return CONTINUE;
2019 } 2020 }
2020 2021
2021 // If we get here code has been generated for this node too many times or 2022 // If we get here code has been generated for this node too many times or
2022 // recursion is too deep. Time to switch to a generic version. The code for 2023 // recursion is too deep. Time to switch to a generic version. The code for
2023 // generic versions above can handle deep recursion properly. 2024 // generic versions above can handle deep recursion properly.
2024 trace->Flush(compiler, this); 2025 trace->Flush(compiler, this);
2025 return DONE; 2026 return DONE;
2026 } 2027 }
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after
3110 Trace new_trace(*current_trace); 3111 Trace new_trace(*current_trace);
3111 new_trace.set_characters_preloaded(preload_is_current ? 3112 new_trace.set_characters_preloaded(preload_is_current ?
3112 preload_characters : 3113 preload_characters :
3113 0); 3114 0);
3114 if (preload_has_checked_bounds) { 3115 if (preload_has_checked_bounds) {
3115 new_trace.set_bound_checked_up_to(preload_characters); 3116 new_trace.set_bound_checked_up_to(preload_characters);
3116 } 3117 }
3117 new_trace.quick_check_performed()->Clear(); 3118 new_trace.quick_check_performed()->Clear();
3118 alt_gen->expects_preload = preload_is_current; 3119 alt_gen->expects_preload = preload_is_current;
3119 bool generate_full_check_inline = false; 3120 bool generate_full_check_inline = false;
3120 if (try_to_emit_quick_check_for_alternative(i) && 3121 if (FLAG_irregexp_optimization &&
3122 try_to_emit_quick_check_for_alternative(i) &&
3121 alternative.node()->EmitQuickCheck(compiler, 3123 alternative.node()->EmitQuickCheck(compiler,
3122 &new_trace, 3124 &new_trace,
3123 preload_has_checked_bounds, 3125 preload_has_checked_bounds,
3124 &alt_gen->possible_success, 3126 &alt_gen->possible_success,
3125 &alt_gen->quick_check_details, 3127 &alt_gen->quick_check_details,
3126 i < choice_count - 1)) { 3128 i < choice_count - 1)) {
3127 // Quick check was generated for this choice. 3129 // Quick check was generated for this choice.
3128 preload_is_current = true; 3130 preload_is_current = true;
3129 preload_has_checked_bounds = true; 3131 preload_has_checked_bounds = true;
3130 // On the last choice in the ChoiceNode we generated the quick 3132 // On the last choice in the ChoiceNode we generated the quick
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
3892 // this case. 3894 // this case.
3893 static const int kMaxUnrolledMinMatches = 3; // Unroll (foo)+ and (foo){3,} 3895 static const int kMaxUnrolledMinMatches = 3; // Unroll (foo)+ and (foo){3,}
3894 static const int kMaxUnrolledMaxMatches = 3; // Unroll (foo)? and (foo){x,3} 3896 static const int kMaxUnrolledMaxMatches = 3; // Unroll (foo)? and (foo){x,3}
3895 if (max == 0) return on_success; // This can happen due to recursion. 3897 if (max == 0) return on_success; // This can happen due to recursion.
3896 bool body_can_be_empty = (body->min_match() == 0); 3898 bool body_can_be_empty = (body->min_match() == 0);
3897 int body_start_reg = RegExpCompiler::kNoRegister; 3899 int body_start_reg = RegExpCompiler::kNoRegister;
3898 Interval capture_registers = body->CaptureRegisters(); 3900 Interval capture_registers = body->CaptureRegisters();
3899 bool needs_capture_clearing = !capture_registers.is_empty(); 3901 bool needs_capture_clearing = !capture_registers.is_empty();
3900 if (body_can_be_empty) { 3902 if (body_can_be_empty) {
3901 body_start_reg = compiler->AllocateRegister(); 3903 body_start_reg = compiler->AllocateRegister();
3902 } else if (!needs_capture_clearing) { 3904 } else if (FLAG_irregexp_optimization && !needs_capture_clearing) {
3903 // Only unroll if there are no captures and the body can't be 3905 // Only unroll if there are no captures and the body can't be
3904 // empty. 3906 // empty.
3905 if (min > 0 && min <= kMaxUnrolledMinMatches) { 3907 if (min > 0 && min <= kMaxUnrolledMinMatches) {
3906 int new_max = (max == kInfinity) ? max : max - min; 3908 int new_max = (max == kInfinity) ? max : max - min;
3907 // Recurse once to get the loop or optional matches after the fixed ones. 3909 // Recurse once to get the loop or optional matches after the fixed ones.
3908 RegExpNode* answer = 3910 RegExpNode* answer =
3909 ToNode(0, new_max, is_greedy, body, compiler, on_success); 3911 ToNode(0, new_max, is_greedy, body, compiler, on_success);
3910 // Unroll the forced matches from 0 to min. This can cause chains of 3912 // Unroll the forced matches from 0 to min. This can cause chains of
3911 // TextNodes (which the parser does not generate). These should be 3913 // TextNodes (which the parser does not generate). These should be
3912 // combined if it turns out they hinder good code generation. 3914 // combined if it turns out they hinder good code generation.
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after
4796 EmbeddedVector<byte, 1024> codes; 4798 EmbeddedVector<byte, 1024> codes;
4797 RegExpMacroAssemblerIrregexp macro_assembler(codes); 4799 RegExpMacroAssemblerIrregexp macro_assembler(codes);
4798 return compiler.Assemble(&macro_assembler, 4800 return compiler.Assemble(&macro_assembler,
4799 node, 4801 node,
4800 data->capture_count, 4802 data->capture_count,
4801 pattern); 4803 pattern);
4802 } 4804 }
4803 4805
4804 4806
4805 }} // namespace v8::internal 4807 }} // namespace v8::internal
OLDNEW
« no previous file with comments | « src/flag-definitions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698