| OLD | NEW | 
|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/v8.h" | 5 #include "src/v8.h" | 
| 6 | 6 | 
| 7 #include "src/ast.h" | 7 #include "src/ast.h" | 
| 8 #include "src/base/platform/platform.h" | 8 #include "src/base/platform/platform.h" | 
| 9 #include "src/compilation-cache.h" | 9 #include "src/compilation-cache.h" | 
| 10 #include "src/compiler.h" | 10 #include "src/compiler.h" | 
| (...skipping 3428 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3439     } | 3439     } | 
| 3440     length += node_length; | 3440     length += node_length; | 
| 3441     SeqRegExpNode* seq_node = static_cast<SeqRegExpNode*>(node); | 3441     SeqRegExpNode* seq_node = static_cast<SeqRegExpNode*>(node); | 
| 3442     node = seq_node->on_success(); | 3442     node = seq_node->on_success(); | 
| 3443   } | 3443   } | 
| 3444   return length; | 3444   return length; | 
| 3445 } | 3445 } | 
| 3446 | 3446 | 
| 3447 | 3447 | 
| 3448 void LoopChoiceNode::AddLoopAlternative(GuardedAlternative alt) { | 3448 void LoopChoiceNode::AddLoopAlternative(GuardedAlternative alt) { | 
| 3449   DCHECK_EQ(loop_node_, NULL); | 3449   DCHECK_NULL(loop_node_); | 
| 3450   AddAlternative(alt); | 3450   AddAlternative(alt); | 
| 3451   loop_node_ = alt.node(); | 3451   loop_node_ = alt.node(); | 
| 3452 } | 3452 } | 
| 3453 | 3453 | 
| 3454 | 3454 | 
| 3455 void LoopChoiceNode::AddContinueAlternative(GuardedAlternative alt) { | 3455 void LoopChoiceNode::AddContinueAlternative(GuardedAlternative alt) { | 
| 3456   DCHECK_EQ(continue_node_, NULL); | 3456   DCHECK_NULL(continue_node_); | 
| 3457   AddAlternative(alt); | 3457   AddAlternative(alt); | 
| 3458   continue_node_ = alt.node(); | 3458   continue_node_ = alt.node(); | 
| 3459 } | 3459 } | 
| 3460 | 3460 | 
| 3461 | 3461 | 
| 3462 void LoopChoiceNode::Emit(RegExpCompiler* compiler, Trace* trace) { | 3462 void LoopChoiceNode::Emit(RegExpCompiler* compiler, Trace* trace) { | 
| 3463   RegExpMacroAssembler* macro_assembler = compiler->macro_assembler(); | 3463   RegExpMacroAssembler* macro_assembler = compiler->macro_assembler(); | 
| 3464   if (trace->stop_node() == this) { | 3464   if (trace->stop_node() == this) { | 
| 3465     // Back edge of greedy optimized loop node graph. | 3465     // Back edge of greedy optimized loop node graph. | 
| 3466     int text_length = | 3466     int text_length = | 
| 3467         GreedyLoopTextLengthForAlternative(&(alternatives_->at(0))); | 3467         GreedyLoopTextLengthForAlternative(&(alternatives_->at(0))); | 
| 3468     DCHECK(text_length != kNodeIsTooComplexForGreedyLoops); | 3468     DCHECK(text_length != kNodeIsTooComplexForGreedyLoops); | 
| 3469     // Update the counter-based backtracking info on the stack.  This is an | 3469     // Update the counter-based backtracking info on the stack.  This is an | 
| 3470     // optimization for greedy loops (see below). | 3470     // optimization for greedy loops (see below). | 
| 3471     DCHECK(trace->cp_offset() == text_length); | 3471     DCHECK(trace->cp_offset() == text_length); | 
| 3472     macro_assembler->AdvanceCurrentPosition(text_length); | 3472     macro_assembler->AdvanceCurrentPosition(text_length); | 
| 3473     macro_assembler->GoTo(trace->loop_label()); | 3473     macro_assembler->GoTo(trace->loop_label()); | 
| 3474     return; | 3474     return; | 
| 3475   } | 3475   } | 
| 3476   DCHECK(trace->stop_node() == NULL); | 3476   DCHECK_NULL(trace->stop_node()); | 
| 3477   if (!trace->is_trivial()) { | 3477   if (!trace->is_trivial()) { | 
| 3478     trace->Flush(compiler, this); | 3478     trace->Flush(compiler, this); | 
| 3479     return; | 3479     return; | 
| 3480   } | 3480   } | 
| 3481   ChoiceNode::Emit(compiler, trace); | 3481   ChoiceNode::Emit(compiler, trace); | 
| 3482 } | 3482 } | 
| 3483 | 3483 | 
| 3484 | 3484 | 
| 3485 int ChoiceNode::CalculatePreloadCharacters(RegExpCompiler* compiler, | 3485 int ChoiceNode::CalculatePreloadCharacters(RegExpCompiler* compiler, | 
| 3486                                            int eats_at_least) { | 3486                                            int eats_at_least) { | 
| (...skipping 1800 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5287   if (*target == NULL) *target = new(zone_) ZoneList<CharacterRange>(2, zone_); | 5287   if (*target == NULL) *target = new(zone_) ZoneList<CharacterRange>(2, zone_); | 
| 5288   (*target)->Add(CharacterRange(entry.from(), entry.to()), zone_); | 5288   (*target)->Add(CharacterRange(entry.from(), entry.to()), zone_); | 
| 5289 } | 5289 } | 
| 5290 | 5290 | 
| 5291 | 5291 | 
| 5292 void CharacterRange::Split(ZoneList<CharacterRange>* base, | 5292 void CharacterRange::Split(ZoneList<CharacterRange>* base, | 
| 5293                            Vector<const int> overlay, | 5293                            Vector<const int> overlay, | 
| 5294                            ZoneList<CharacterRange>** included, | 5294                            ZoneList<CharacterRange>** included, | 
| 5295                            ZoneList<CharacterRange>** excluded, | 5295                            ZoneList<CharacterRange>** excluded, | 
| 5296                            Zone* zone) { | 5296                            Zone* zone) { | 
| 5297   DCHECK_EQ(NULL, *included); | 5297   DCHECK_NULL(*included); | 
| 5298   DCHECK_EQ(NULL, *excluded); | 5298   DCHECK_NULL(*excluded); | 
| 5299   DispatchTable table(zone); | 5299   DispatchTable table(zone); | 
| 5300   for (int i = 0; i < base->length(); i++) | 5300   for (int i = 0; i < base->length(); i++) | 
| 5301     table.AddRange(base->at(i), CharacterRangeSplitter::kInBase, zone); | 5301     table.AddRange(base->at(i), CharacterRangeSplitter::kInBase, zone); | 
| 5302   for (int i = 0; i < overlay.length(); i += 2) { | 5302   for (int i = 0; i < overlay.length(); i += 2) { | 
| 5303     table.AddRange(CharacterRange(overlay[i], overlay[i + 1] - 1), | 5303     table.AddRange(CharacterRange(overlay[i], overlay[i + 1] - 1), | 
| 5304                    CharacterRangeSplitter::kInOverlay, zone); | 5304                    CharacterRangeSplitter::kInOverlay, zone); | 
| 5305   } | 5305   } | 
| 5306   CharacterRangeSplitter callback(included, excluded, zone); | 5306   CharacterRangeSplitter callback(included, excluded, zone); | 
| 5307   table.ForEach(&callback); | 5307   table.ForEach(&callback); | 
| 5308 } | 5308 } | 
| (...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 6153   Heap* heap = pattern->GetHeap(); | 6153   Heap* heap = pattern->GetHeap(); | 
| 6154   bool too_much = pattern->length() > RegExpImpl::kRegExpTooLargeToOptimize; | 6154   bool too_much = pattern->length() > RegExpImpl::kRegExpTooLargeToOptimize; | 
| 6155   if (heap->total_regexp_code_generated() > RegExpImpl::kRegExpCompiledLimit && | 6155   if (heap->total_regexp_code_generated() > RegExpImpl::kRegExpCompiledLimit && | 
| 6156       heap->isolate()->memory_allocator()->SizeExecutable() > | 6156       heap->isolate()->memory_allocator()->SizeExecutable() > | 
| 6157           RegExpImpl::kRegExpExecutableMemoryLimit) { | 6157           RegExpImpl::kRegExpExecutableMemoryLimit) { | 
| 6158     too_much = true; | 6158     too_much = true; | 
| 6159   } | 6159   } | 
| 6160   return too_much; | 6160   return too_much; | 
| 6161 } | 6161 } | 
| 6162 }}  // namespace v8::internal | 6162 }}  // namespace v8::internal | 
| OLD | NEW | 
|---|