| OLD | NEW |
| 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 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 bool RegExpNode::GoTo(RegExpCompiler* compiler) { | 859 bool RegExpNode::GoTo(RegExpCompiler* compiler) { |
| 860 if (label.is_bound()) { | 860 if (label.is_bound()) { |
| 861 compiler->macro_assembler()->GoTo(&label); | 861 compiler->macro_assembler()->GoTo(&label); |
| 862 return true; | 862 return true; |
| 863 } else { | 863 } else { |
| 864 return Emit(compiler); | 864 return Emit(compiler); |
| 865 } | 865 } |
| 866 } | 866 } |
| 867 | 867 |
| 868 | 868 |
| 869 void RegExpNode::EmitAddress(RegExpCompiler* compiler) { | 869 Label* RegExpNode::GetLabel() { |
| 870 compiler->macro_assembler()->EmitOrLink(&label); | 870 return &label; |
| 871 } | 871 } |
| 872 | 872 |
| 873 | 873 |
| 874 EndNode EndNode::kAccept(ACCEPT); | 874 EndNode EndNode::kAccept(ACCEPT); |
| 875 EndNode EndNode::kBacktrack(BACKTRACK); | 875 EndNode EndNode::kBacktrack(BACKTRACK); |
| 876 | 876 |
| 877 | 877 |
| 878 bool EndNode::Emit(RegExpCompiler* compiler) { | 878 bool EndNode::Emit(RegExpCompiler* compiler) { |
| 879 switch (action_) { | 879 switch (action_) { |
| 880 case ACCEPT: | 880 case ACCEPT: |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 visitor->Visit##Type(this); \ | 956 visitor->Visit##Type(this); \ |
| 957 } | 957 } |
| 958 FOR_EACH_NODE_TYPE(DEFINE_ACCEPT) | 958 FOR_EACH_NODE_TYPE(DEFINE_ACCEPT) |
| 959 #undef DEFINE_ACCEPT | 959 #undef DEFINE_ACCEPT |
| 960 | 960 |
| 961 | 961 |
| 962 // ------------------------------------------------------------------- | 962 // ------------------------------------------------------------------- |
| 963 // Emit code. | 963 // Emit code. |
| 964 | 964 |
| 965 | 965 |
| 966 bool ChoiceNode::Emit(RegExpCompiler* compiler) { | 966 void ChoiceNode::GenerateGuard(RegExpCompiler* compiler, |
| 967 // TODO(erikcorry): Implement this. | 967 Guard *guard, |
| 968 return false; | 968 Label* on_failure) { |
| 969 |
| 969 } | 970 } |
| 970 | 971 |
| 971 | 972 |
| 973 bool ChoiceNode::Emit(RegExpCompiler* compiler) { |
| 974 int choice_count = choices_->length(); |
| 975 RegExpMacroAssembler* macro_assembler = compiler->macro_assembler(); |
| 976 // For now we just call all choices one after the other. The idea ultimately |
| 977 // is to use the Dispatch table to try only the relevant ones. |
| 978 for (int i = 0; i < choice_count; i++) { |
| 979 GuardedAlternative alternative = (*choices_)[i]; |
| 980 Label after; |
| 981 Label* next_alternative; |
| 982 if (i < choice_count - 1) { |
| 983 next_alternative = &after; |
| 984 } else { |
| 985 next_alternative = on_failure_->GetLabel(); |
| 986 } |
| 987 ZoneList<Guard*>* guards = alternative.guards(); |
| 988 if (guards != NULL) { |
| 989 int guard_count = guards->length(); |
| 990 for (int j = 0; j < guard_count; j++) { |
| 991 GenerateGuard(compiler, (*guards)[i], next_alternative); |
| 992 } |
| 993 } |
| 994 macro_assembler->PushBacktrack(next_alternative); |
| 995 if (!alternative.node()->Emit(compiler)) { |
| 996 after.Unuse(); |
| 997 if (next_alternative != &after) { |
| 998 next_alternative->Unuse(); |
| 999 } |
| 1000 return false; |
| 1001 } |
| 1002 if (i < choice_count - 1) { |
| 1003 macro_assembler->Bind(&after); |
| 1004 } else { |
| 1005 after.Unuse(); |
| 1006 } |
| 1007 } |
| 1008 compiler->AddWork(on_failure_); |
| 1009 return true; |
| 1010 } |
| 1011 |
| 1012 |
| 972 bool ActionNode::Emit(RegExpCompiler* compiler) { | 1013 bool ActionNode::Emit(RegExpCompiler* compiler) { |
| 973 RegExpMacroAssembler* macro = compiler->macro_assembler(); | 1014 RegExpMacroAssembler* macro = compiler->macro_assembler(); |
| 974 switch (type_) { | 1015 switch (type_) { |
| 975 case STORE_REGISTER: | 1016 case STORE_REGISTER: |
| 976 macro->SetRegister(data_.u_store_register.reg, | 1017 macro->SetRegister(data_.u_store_register.reg, |
| 977 data_.u_store_register.value); | 1018 data_.u_store_register.value); |
| 978 break; | 1019 break; |
| 979 case INCREMENT_REGISTER: | 1020 case INCREMENT_REGISTER: |
| 980 macro->AdvanceRegister(data_.u_increment_register.reg, 1); | 1021 macro->AdvanceRegister(data_.u_increment_register.reg, 1); |
| 981 break; | 1022 break; |
| (...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1827 RegExpMacroAssembler::RegExpMacroAssembler() { | 1868 RegExpMacroAssembler::RegExpMacroAssembler() { |
| 1828 | 1869 |
| 1829 } | 1870 } |
| 1830 | 1871 |
| 1831 RegExpMacroAssembler::~RegExpMacroAssembler() { | 1872 RegExpMacroAssembler::~RegExpMacroAssembler() { |
| 1832 | 1873 |
| 1833 } | 1874 } |
| 1834 | 1875 |
| 1835 | 1876 |
| 1836 }} // namespace v8::internal | 1877 }} // namespace v8::internal |
| OLD | NEW |