| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 5162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5173 if ((data->capture_count + 1) * 2 - 1 > RegExpMacroAssembler::kMaxRegister) { | 5173 if ((data->capture_count + 1) * 2 - 1 > RegExpMacroAssembler::kMaxRegister) { |
| 5174 return IrregexpRegExpTooBig(); | 5174 return IrregexpRegExpTooBig(); |
| 5175 } | 5175 } |
| 5176 RegExpCompiler compiler(data->capture_count, ignore_case, is_ascii); | 5176 RegExpCompiler compiler(data->capture_count, ignore_case, is_ascii); |
| 5177 // Wrap the body of the regexp in capture #0. | 5177 // Wrap the body of the regexp in capture #0. |
| 5178 RegExpNode* captured_body = RegExpCapture::ToNode(data->tree, | 5178 RegExpNode* captured_body = RegExpCapture::ToNode(data->tree, |
| 5179 0, | 5179 0, |
| 5180 &compiler, | 5180 &compiler, |
| 5181 compiler.accept()); | 5181 compiler.accept()); |
| 5182 RegExpNode* node = captured_body; | 5182 RegExpNode* node = captured_body; |
| 5183 bool is_end_anchored = data->tree->IsAnchoredAtEnd(); | 5183 if (!data->tree->IsAnchored()) { |
| 5184 bool is_start_anchored = data->tree->IsAnchoredAtStart(); | |
| 5185 int max_length = data->tree->max_match(); | |
| 5186 if (!is_start_anchored) { | |
| 5187 // Add a .*? at the beginning, outside the body capture, unless | 5184 // Add a .*? at the beginning, outside the body capture, unless |
| 5188 // this expression is anchored at the beginning. | 5185 // this expression is anchored at the beginning. |
| 5189 RegExpNode* loop_node = | 5186 RegExpNode* loop_node = |
| 5190 RegExpQuantifier::ToNode(0, | 5187 RegExpQuantifier::ToNode(0, |
| 5191 RegExpTree::kInfinity, | 5188 RegExpTree::kInfinity, |
| 5192 false, | 5189 false, |
| 5193 new RegExpCharacterClass('*'), | 5190 new RegExpCharacterClass('*'), |
| 5194 &compiler, | 5191 &compiler, |
| 5195 captured_body, | 5192 captured_body, |
| 5196 data->contains_anchor); | 5193 data->contains_anchor); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5232 #elif V8_TARGET_ARCH_ARM | 5229 #elif V8_TARGET_ARCH_ARM |
| 5233 RegExpMacroAssemblerARM macro_assembler(mode, (data->capture_count + 1) * 2); | 5230 RegExpMacroAssemblerARM macro_assembler(mode, (data->capture_count + 1) * 2); |
| 5234 #endif | 5231 #endif |
| 5235 | 5232 |
| 5236 #else // V8_INTERPRETED_REGEXP | 5233 #else // V8_INTERPRETED_REGEXP |
| 5237 // Interpreted regexp implementation. | 5234 // Interpreted regexp implementation. |
| 5238 EmbeddedVector<byte, 1024> codes; | 5235 EmbeddedVector<byte, 1024> codes; |
| 5239 RegExpMacroAssemblerIrregexp macro_assembler(codes); | 5236 RegExpMacroAssemblerIrregexp macro_assembler(codes); |
| 5240 #endif // V8_INTERPRETED_REGEXP | 5237 #endif // V8_INTERPRETED_REGEXP |
| 5241 | 5238 |
| 5242 // Inserted here, instead of in Assembler, because it depends on information | |
| 5243 // in the AST that isn't replicated in the Node structure. | |
| 5244 static const int kMaxBacksearchLimit = 1024; | |
| 5245 if (is_end_anchored && | |
| 5246 !is_start_anchored && | |
| 5247 max_length < kMaxBacksearchLimit) { | |
| 5248 macro_assembler.SetCurrentPositionFromEnd(max_length); | |
| 5249 } | |
| 5250 | |
| 5251 return compiler.Assemble(¯o_assembler, | 5239 return compiler.Assemble(¯o_assembler, |
| 5252 node, | 5240 node, |
| 5253 data->capture_count, | 5241 data->capture_count, |
| 5254 pattern); | 5242 pattern); |
| 5255 } | 5243 } |
| 5256 | 5244 |
| 5257 | 5245 |
| 5258 int OffsetsVector::static_offsets_vector_[ | 5246 int OffsetsVector::static_offsets_vector_[ |
| 5259 OffsetsVector::kStaticOffsetsVectorSize]; | 5247 OffsetsVector::kStaticOffsetsVectorSize]; |
| 5260 | 5248 |
| 5261 }} // namespace v8::internal | 5249 }} // namespace v8::internal |
| OLD | NEW |