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

Side by Side Diff: src/regexp-macro-assembler.h

Issue 10830: * We want to be able to find atoms and character classes without advancing th... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/regexp2000/
Patch Set: Created 12 years, 1 month 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/jsregexp.cc ('k') | src/regexp-macro-assembler-re2k.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 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 16 matching lines...) Expand all
27 27
28 #ifndef V8_REGEXP_MACRO_ASSEMBLER_H_ 28 #ifndef V8_REGEXP_MACRO_ASSEMBLER_H_
29 #define V8_REGEXP_MACRO_ASSEMBLER_H_ 29 #define V8_REGEXP_MACRO_ASSEMBLER_H_
30 30
31 namespace v8 { namespace internal { 31 namespace v8 { namespace internal {
32 32
33 33
34 struct DisjunctDecisionRow { 34 struct DisjunctDecisionRow {
35 RegExpCharacterClass cc; 35 RegExpCharacterClass cc;
36 Label* on_match; 36 Label* on_match;
37 int actions;
38 }; 37 };
39 38
40 39
41 // Actions. These are things that can be specified to happen on a 40 class RegExpMacroAssembler {
42 // match or failure when generating code.
43 static const int kNoAction = 0x00;
44 // Pop the current position in the subject from the backtracking stack.
45 static const int kPopCurrentPosition = 0x01;
46 // Push the current position in the subject onto the backtracking stack.
47 static const int kPushCurrentPosition = 0x04;
48 // As above, but in CheckCharacter and CheckCharacterClass which take an
49 // offset, the offset is added to the current position first.
50 static const int kPushCurrentPositionPlusOffset = 0x06;
51 // Pop a new state from the stack and go to it.
52 static const int kBacktrack = 0x08;
53 // Goto the label that is given in another argument.
54 static const int kGotoLabel = 0x10;
55 // Advance current position (by the offset + 1).
56 static const int kAdvanceCurrentPosition = 0x20;
57 // Push the label that is given in another argument onto the backtrack stack.
58 static const int kPushBacktrackState = 0x40;
59 // The entire regexp has succeeded.
60 static const int kSuccess = 0x80;
61 // The entire regexp has failed to match.
62 static const int kFailure = 0x100;
63
64
65 template <typename SubjectChar>
66 class RegexpMacroAssembler {
67 public: 41 public:
68 RegexpMacroAssembler() { } 42 RegExpMacroAssembler() { }
69 virtual ~RegexpMacroAssembler() { } 43 virtual ~RegExpMacroAssembler();
70 virtual void Bind(Label* label) = 0; 44 virtual void Bind(Label* label) = 0;
71 // Writes the current position in the subject string into the given index of 45 virtual void EmitOrLink(Label* label) = 0;
Lasse Reichstein 2008/11/12 14:07:23 What does this do? Shouldn't this be in the underl
Erik Corry 2008/11/12 14:14:33 The switch code for Choice nodes needs to emit a t
72 // the captures array. The old value is pushed to the stack. 46 virtual void AdvanceCurrentPosition(int by) = 0; // Signed cp change.
73 virtual void WriteCurrentPositionToRegister(int index) = 0; 47 virtual void PopCurrentPosition() = 0;
74 // Pops the the given index of the capture array from the stack.
75 virtual void PopRegister(int index) = 0;
76 // Pushes the current position in the subject string onto the stack for later
77 // retrieval.
78 virtual void PushCurrentPosition() = 0; 48 virtual void PushCurrentPosition() = 0;
79 // Pops the current position in the subject string. 49 virtual void Backtrack() = 0;
80 virtual void PopCurrentPosition() = 0; 50 virtual void GoTo(Label* label) = 0;
81 // Check the current character for a match with a character class. Take 51 virtual void PushBacktrack(Label* label) = 0;
82 // one of the actions depending on whether there is a match. 52 virtual void Succeed() = 0;
83 virtual void AdvanceCurrentPosition(int by) = 0; 53 virtual void Fail() = 0;
84 // Looks at the next character from the subject and performs the corresponding 54 virtual void PopRegister(int register_index) = 0;
85 // action according to whether it matches. Success_action can only be one of 55 virtual void PushRegister(int register_index) = 0;
86 // kAdvanceCurrentPosition or kNoAction. 56 virtual void AdvanceRegister(int reg, int by) = 0; // r[reg] += by.
57 virtual void WriteCurrentPositionToRegister(int reg) = 0;
58 virtual void SetRegister(int register_index, int to) = 0;
59 // Looks at the next character from the subject and if it doesn't match
60 // then goto the on_failure label. End of input never matches. If the
61 // label is NULL then we should pop a backtrack address off the stack and
62 // go to that.
87 virtual void CheckCharacterClass( 63 virtual void CheckCharacterClass(
88 RegExpCharacterClass* cclass, 64 RegExpCharacterClass* cclass,
89 int success_action, 65 int cp_offset,
90 int fail_action, 66 Label* on_failure) = 0;
91 int offset, // Offset from current subject position. 67 // Check the current character for a match with a literal string. If we
92 Label* fail_state = NULL) = 0; // Used by kGotoLabel on failure. 68 // fail to match then goto the on_failure label. End of input always
93 // Check the current character for a match with a character class. Take 69 // matches. If the label is NULL then we should pop a backtrack address off
94 // one of the actions depending on whether there is a match. 70 // the stack abnd go to that.
95 virtual void CheckCharacters( 71 virtual void CheckCharacters(
96 Vector<uc16> str, 72 Vector<const uc16> str,
Lasse Reichstein 2008/11/12 14:07:23 This sends a raw vector as argument. Are we certai
Erik Corry 2008/11/12 14:14:33 I think the data that we are using as input is not
97 int fail_action, 73 int cp_offset,
98 int offset, 74 Label* on_failure) = 0;
99 Label* state = NULL) = 0; // Used by kGotoLabel on failure. 75 // Check the current input position against a register. If the register is
100 // Perform an action unconditionally. 76 // equal to the current position then go to the label. If the label is NULL
101 virtual void Action( 77 // then backtrack instead.
102 int action, 78 virtual void CheckCurrentPosition(
103 Label* state = NULL) = 0; 79 int register_index,
104 // Peek at the next character and find out which of the disjunct character 80 Label* on_equal) = 0;
105 // classes it is in. Perform the corresponding actions on the corresponding 81 // Check the current character against a bitmap. The range of the current
106 // label. 82 // character must be from start to start + length_of_bitmap_in_bits.
107 virtual void DisjunctCharacterPeekDispatch( 83 virtual void CheckBitmap(
108 Vector<DisjunctDecisionRow> outcomes) = 0; 84 uc16 start, // The bitmap is indexed from this character.
85 Label* bitmap, // Where the bitmap is emitted.
86 Label* on_zero) = 0; // Where to go if the bit is 0. Fall through on 1.
87 // Dispatch after looking the current character up in a 2-bits-per-entry
88 // map. The destinations vector has up to 4 labels.
89 virtual void DispatchHalfNibbleMap(
90 uc16 start,
91 Label* half_nibble_map,
92 const Vector<Label*>& destinations) = 0;
93 // Dispatch after looking the current character up in a byte map. The
94 // destinations vector has up to 256 labels.
95 virtual void DispatchByteMap(
96 uc16 start,
97 Label* byte_map,
98 const Vector<Label*>& destinations) = 0;
99 // Dispatch after looking the high byte of the current character up in a byte
100 // map. The destinations vector has up to 256 labels.
101 virtual void DispatchHighByteMap(
102 byte start,
103 Label* byte_map,
104 const Vector<Label*>& destinations) = 0;
105 // Check whether a register is < a given constant and go to a label if it is.
106 // Backtracks instead if the label is NULL.
107 virtual void IfRegisterLT(int reg, int comparand, Label* if_lt) = 0;
108 // Check whether a register is >= a given constant and go to a label if it
109 // is. Backtracks instead if the label is NULL.
110 virtual void IfRegisterGE(int reg, int comparand, Label* if_ge) = 0;
111
112 enum Re2kImplementation {
113 kIA32Implementation,
114 kARMImplementation,
115 kBytecodeImplementation};
116
117 virtual Re2kImplementation Implementation() = 0;
118 virtual Handle<Object> GetCode() = 0;
109 private: 119 private:
110 }; 120 };
111 121
112 122
113 } } // namespace v8::internal 123 } } // namespace v8::internal
114 124
115 #endif // V8_REGEXP_MACRO_ASSEMBLER_H_ 125 #endif // V8_REGEXP_MACRO_ASSEMBLER_H_
OLDNEW
« no previous file with comments | « src/jsregexp.cc ('k') | src/regexp-macro-assembler-re2k.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698