| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 | 990 |
| 991 RegExpEngine::CompilationResult RegExpCompiler::Assemble( | 991 RegExpEngine::CompilationResult RegExpCompiler::Assemble( |
| 992 RegExpMacroAssembler* macro_assembler, | 992 RegExpMacroAssembler* macro_assembler, |
| 993 RegExpNode* start, | 993 RegExpNode* start, |
| 994 int capture_count, | 994 int capture_count, |
| 995 Handle<String> pattern) { | 995 Handle<String> pattern) { |
| 996 Heap* heap = pattern->GetHeap(); | 996 Heap* heap = pattern->GetHeap(); |
| 997 | 997 |
| 998 bool use_slow_safe_regexp_compiler = false; | 998 bool use_slow_safe_regexp_compiler = false; |
| 999 if (heap->total_regexp_code_generated() > | 999 if (heap->total_regexp_code_generated() > |
| 1000 RegExpImpl::kRegWxpCompiledLimit && | 1000 RegExpImpl::kRegExpCompiledLimit && |
| 1001 heap->isolate()->memory_allocator()->SizeExecutable() > | 1001 heap->isolate()->memory_allocator()->SizeExecutable() > |
| 1002 RegExpImpl::kRegExpExecutableMemoryLimit) { | 1002 RegExpImpl::kRegExpExecutableMemoryLimit) { |
| 1003 use_slow_safe_regexp_compiler = true; | 1003 use_slow_safe_regexp_compiler = true; |
| 1004 } | 1004 } |
| 1005 | 1005 |
| 1006 macro_assembler->set_slow_safe(use_slow_safe_regexp_compiler); | 1006 macro_assembler->set_slow_safe(use_slow_safe_regexp_compiler); |
| 1007 | 1007 |
| 1008 #ifdef DEBUG | 1008 #ifdef DEBUG |
| 1009 if (FLAG_trace_regexp_assembler) | 1009 if (FLAG_trace_regexp_assembler) |
| 1010 macro_assembler_ = new RegExpMacroAssemblerTracer(macro_assembler); | 1010 macro_assembler_ = new RegExpMacroAssemblerTracer(macro_assembler); |
| (...skipping 2459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3470 if (map_count_ != kMapSize) { | 3470 if (map_count_ != kMapSize) { |
| 3471 map_count_ = kMapSize; | 3471 map_count_ = kMapSize; |
| 3472 for (int i = 0; i < kMapSize; i++) map_->at(i) = true; | 3472 for (int i = 0; i < kMapSize; i++) map_->at(i) = true; |
| 3473 } | 3473 } |
| 3474 } | 3474 } |
| 3475 | 3475 |
| 3476 | 3476 |
| 3477 BoyerMooreLookahead::BoyerMooreLookahead( | 3477 BoyerMooreLookahead::BoyerMooreLookahead( |
| 3478 int length, RegExpCompiler* compiler) | 3478 int length, RegExpCompiler* compiler) |
| 3479 : length_(length), | 3479 : length_(length), |
| 3480 compiler_(compiler) { | 3480 compiler_(compiler), |
| 3481 depth_(0) { |
| 3481 if (compiler->ascii()) { | 3482 if (compiler->ascii()) { |
| 3482 max_char_ = String::kMaxAsciiCharCode; | 3483 max_char_ = String::kMaxAsciiCharCode; |
| 3483 } else { | 3484 } else { |
| 3484 max_char_ = String::kMaxUtf16CodeUnit; | 3485 max_char_ = String::kMaxUtf16CodeUnit; |
| 3485 } | 3486 } |
| 3486 bitmaps_ = new ZoneList<BoyerMoorePositionInfo*>(length); | 3487 bitmaps_ = new ZoneList<BoyerMoorePositionInfo*>(length); |
| 3487 for (int i = 0; i < length; i++) { | 3488 for (int i = 0; i < length; i++) { |
| 3488 bitmaps_->Add(new BoyerMoorePositionInfo()); | 3489 bitmaps_->Add(new BoyerMoorePositionInfo()); |
| 3489 } | 3490 } |
| 3490 } | 3491 } |
| (...skipping 2090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5581 } | 5582 } |
| 5582 | 5583 |
| 5583 | 5584 |
| 5584 STATIC_ASSERT(BoyerMoorePositionInfo::kMapSize == | 5585 STATIC_ASSERT(BoyerMoorePositionInfo::kMapSize == |
| 5585 RegExpMacroAssembler::kTableSize); | 5586 RegExpMacroAssembler::kTableSize); |
| 5586 | 5587 |
| 5587 | 5588 |
| 5588 void ChoiceNode::FillInBMInfo( | 5589 void ChoiceNode::FillInBMInfo( |
| 5589 int offset, BoyerMooreLookahead* bm, bool not_at_start) { | 5590 int offset, BoyerMooreLookahead* bm, bool not_at_start) { |
| 5590 ZoneList<GuardedAlternative>* alts = alternatives(); | 5591 ZoneList<GuardedAlternative>* alts = alternatives(); |
| 5592 if (bm->MaxDepthExceeded()) { |
| 5593 bm->SetRest(offset); // Give up trying to fill in info. |
| 5594 SaveBMInfo(bm, not_at_start, offset); |
| 5595 return; |
| 5596 } |
| 5591 for (int i = 0; i < alts->length(); i++) { | 5597 for (int i = 0; i < alts->length(); i++) { |
| 5592 GuardedAlternative& alt = alts->at(i); | 5598 GuardedAlternative& alt = alts->at(i); |
| 5593 if (alt.guards() != NULL && alt.guards()->length() != 0) { | 5599 if (alt.guards() != NULL && alt.guards()->length() != 0) { |
| 5594 bm->SetRest(offset); // Give up trying to fill in info. | 5600 bm->SetRest(offset); // Give up trying to fill in info. |
| 5595 SaveBMInfo(bm, not_at_start, offset); | 5601 SaveBMInfo(bm, not_at_start, offset); |
| 5596 return; | 5602 return; |
| 5597 } | 5603 } |
| 5598 alt.node()->FillInBMInfo(offset, bm, not_at_start); | 5604 alt.node()->FillInBMInfo(offset, bm, not_at_start); |
| 5599 } | 5605 } |
| 5600 SaveBMInfo(bm, not_at_start, offset); | 5606 SaveBMInfo(bm, not_at_start, offset); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5884 } | 5890 } |
| 5885 | 5891 |
| 5886 return compiler.Assemble(¯o_assembler, | 5892 return compiler.Assemble(¯o_assembler, |
| 5887 node, | 5893 node, |
| 5888 data->capture_count, | 5894 data->capture_count, |
| 5889 pattern); | 5895 pattern); |
| 5890 } | 5896 } |
| 5891 | 5897 |
| 5892 | 5898 |
| 5893 }} // namespace v8::internal | 5899 }} // namespace v8::internal |
| OLD | NEW |