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

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

Issue 11271: Building on regexp-ia32. (Closed)
Patch Set: Made it compile correctly. 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
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 15 matching lines...) Expand all
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef REGEXP_MACRO_ASSEMBLER_IA32_H_ 28 #ifndef REGEXP_MACRO_ASSEMBLER_IA32_H_
29 #define REGEXP_MACRO_ASSEMBLER_IA32_H_ 29 #define REGEXP_MACRO_ASSEMBLER_IA32_H_
30 30
31 #include "regexp-macro-assembler.h" 31 #include "regexp-macro-assembler.h"
32 #include "macro-assembler-ia32.h" 32 #include "macro-assembler-ia32.h"
33 33
34 namespace v8 { namespace internal { 34 namespace v8 { namespace internal {
35 35
36 template <typename SubjectChar> 36 class RegExpMacroAssemblerIA32: public RegExpMacroAssembler {
37 class RegExpMacroAssemblerIA32: public RegExpMacroAssembler<SubjectChar> {
38 public: 37 public:
39 RegExpMacroAssemblerIA32() { } 38 enum Mode {ASCII = 1, UC16 = 2};
40 virtual ~RegExpMacroAssembler(); 39 RegExpMacroAssemblerIA32(Mode mode, int registers_to_save, bool ignore_case);
41 void Initialize(int num_registers, bool ignore_case); 40 virtual ~RegExpMacroAssemblerIA32();
42 virtual void AdvanceCurrentPosition(int by); // Signed cp change. 41 virtual void AdvanceCurrentPosition(int by); // Signed cp change.
43 virtual void AdvanceRegister(int reg, int by); // r[reg] += by. 42 virtual void AdvanceRegister(int reg, int by); // r[reg] += by.
44 virtual void Backtrack(); 43 virtual void Backtrack();
45 virtual void Bind(Label* label); 44 virtual void Bind(Label* label);
46 virtual void LoadCurrentCharacter(int cp_offset, Label* on_end_of_input); 45 virtual void CheckBitmap(uc16 start, Label* bitmap, Label* on_zero);
47 46 virtual void CheckCharacter(uc16 c, Label* on_equal);
48 47 virtual void CheckCharacterGT(uc16 limit, Label* on_greater);
49 48 virtual void CheckCharacterLT(uc16 limit, Label* on_less);
50 // Check the current character against a bitmap. The range of the current 49 virtual void CheckCharacters(Vector<const uc16> str,
51 // character must be from start to start + length_of_bitmap_in_bits. 50 int cp_offset,
52 // Where to go if the bit is 0. Fall through on 1. 51 Label* on_failure);
53 virtual void CheckBitmap( 52 virtual void CheckCurrentPosition(int register_index, Label* on_equal);
54 uc16 start, // The bitmap is indexed from this character. 53 virtual void CheckNotCharacter(uc16 c, Label* on_not_equal);
55 Label* bitmap, // Where the bitmap is emitted.
56 Label* on_zero);
57
58
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.
63 virtual void CheckCharacterClass(
64 RegExpCharacterClass* cclass,
65 Label* on_failure);
66
67 // Check the current character for a match with a literal string. If we
68 // fail to match then goto the on_failure label. End of input always
69 // matches. If the label is NULL then we should pop a backtrack address off
70 // the stack and go to that.
71 virtual void CheckCharacters(
72 Vector<uc16> str,
73 Label* on_failure);
74
75 // Check the current input position against a register. If the register is
76 // equal to the current position then go to the label. If the label is NULL
77 // then backtrack instead.
78 virtual void CheckCurrentPosition(
79 int register_index,
80 Label* on_equal);
81
82 // Dispatch after looking the current character up in a byte map. The
83 // destinations vector has up to 256 labels.
84 virtual void DispatchByteMap( 54 virtual void DispatchByteMap(
85 uc16 start, 55 uc16 start,
86 Label* byte_map, 56 Label* byte_map,
87 Vector<Label*>& destinations); 57 const Vector<Label*>& destinations);
88
89 // Dispatch after looking the current character up in a 2-bits-per-entry
90 // map. The destinations vector has up to 4 labels.
91 virtual void DispatchHalfNibbleMap( 58 virtual void DispatchHalfNibbleMap(
92 uc16 start, 59 uc16 start,
93 Label* half_nibble_map, 60 Label* half_nibble_map,
94 Vector<Label*>& destinations); 61 const Vector<Label*>& destinations);
95
96 // Dispatch after looking the high byte of the current character up in a byte
97 // map. The destinations vector has up to 256 labels.
98 virtual void DispatchHighByteMap( 62 virtual void DispatchHighByteMap(
99 byte start, 63 byte start,
100 Label* byte_map, 64 Label* byte_map,
101 Vector<Label*>& destinations); 65 const Vector<Label*>& destinations);
102
103 virtual void EmitOrLink(Label* label); 66 virtual void EmitOrLink(Label* label);
104
105 virtual void Fail(); 67 virtual void Fail();
106
107 virtual Handle<Object> GetCode(); 68 virtual Handle<Object> GetCode();
108
109 virtual void GoTo(Label* label); 69 virtual void GoTo(Label* label);
110
111 // Check whether a register is >= a given constant and go to a label if it
112 // is. Backtracks instead if the label is NULL.
113 virtual void IfRegisterGE(int reg, int comparand, Label* if_ge); 70 virtual void IfRegisterGE(int reg, int comparand, Label* if_ge);
114
115 // Check whether a register is < a given constant and go to a label if it is.
116 // Backtracks instead if the label is NULL.
117 virtual void IfRegisterLT(int reg, int comparand, Label* if_lt); 71 virtual void IfRegisterLT(int reg, int comparand, Label* if_lt);
118
119 virtual Re2kImplementation Implementation(); 72 virtual Re2kImplementation Implementation();
120 73 virtual void LoadCurrentCharacter(int cp_offset, Label* on_end_of_input);
121 virtual void PopCurrentPosition(); 74 virtual void PopCurrentPosition();
122 virtual void PopRegister(int register_index); 75 virtual void PopRegister(int register_index);
123 virtual void PushBacktrack(Label* label); 76 virtual void PushBacktrack(Label* label);
124 virtual void PushCurrentPosition(); 77 virtual void PushCurrentPosition();
125 virtual void PushRegister(int register_index); 78 virtual void PushRegister(int register_index);
79 virtual void ReadCurrentPositionFromRegister(int reg);
80 virtual void ReadStackPointerFromRegister(int reg);
126 virtual void SetRegister(int register_index, int to); 81 virtual void SetRegister(int register_index, int to);
127 virtual void Succeed(); 82 virtual void Succeed();
128 virtual void WriteCurrentPositionToRegister(int reg); 83 virtual void WriteCurrentPositionToRegister(int reg);
84 virtual void WriteStackPointerToRegister(int reg);
129 private: 85 private:
86 // Offsets from ebp of arguments to function.
87 static const int kBackup_edi = 1 * sizeof(uint32_t);
88 static const int kBackup_esi= 2 * sizeof(uint32_t);
89 static const int kInputBuffer = 4 * sizeof(uint32_t);
90 static const int kInputStartOffset = 5 * sizeof(uint32_t);
91 static const int kInputEndOffset = 6 * sizeof(uint32_t);
92 static const int kRegisterOutput = 7 * sizeof(uint32_t);
93
130 Operand register_location(int register_index); 94 Operand register_location(int register_index);
131 bool ignore_case(); 95 bool ignore_case();
96 // Byte size of the string to match (decided by the Mode argument)
97 size_t char_size();
98 // Records that a register is used. At the end, we need the number of
99 // registers used.
100 void RecordRegister(int register_index);
101 // Equivalent to a conditional branch to the label, unless the label
102 // is NULL, in which case it is a conditional Backtrack.
103 void BranchOrBacktrack(Condition condition, Label* to);
132 // Generate code to perform case-canonicalization on the register. 104 // Generate code to perform case-canonicalization on the register.
133 void BranchOrBacktrack(Condition condition, Label* to);
134 void Canonicalize(Register register); 105 void Canonicalize(Register register);
135 void Exit(bool success);
136 // Read a character from input at the given offset from the current 106 // Read a character from input at the given offset from the current
137 // position. 107 // position.
138 void ReadChar(Register destination, int offset); 108 void ReadChar(Register destination, int offset);
139 109
140 template <typename T> 110 void LoadConstantBufferAddress(Register reg, ArraySlice* buffer);
141 void LoadConstantBufferAddress(Register reg, ArraySlice<T>* buffer);
142 111
143 // Read the current character into the destination register. 112 // Read the current character into the destination register.
144 void ReadCurrentChar(Register destination); 113 void ReadCurrentChar(Register destination);
145 114
115 static const size_t kRegExpCodeSize = 1024;
146 static const int kRegExpConstantsSize = 256; 116 static const int kRegExpConstantsSize = 256;
147 static const int kMaxInlineStringTests = 8; 117 static const int kMaxInlineStringTests = 8;
148 static const uint32_t kEndOfInput = ~0; 118 static const uint32_t kEndOfInput = ~0;
149 119
150 MacroAssembler* masm_; 120 MacroAssembler* masm_;
151 ByteArrayProvider constants_; 121 ByteArrayProvider constants_;
122 Mode mode_;
152 int num_registers_; 123 int num_registers_;
124 int num_saved_registers_;
153 bool ignore_case_; 125 bool ignore_case_;
126 Label entry_label_;
127 Label start_label_;
128 Label success_label_;
129 Label exit_label_;
130 Handle<Code> self_;
154 }; 131 };
155 }} 132 }}
156 133
157 #endif /* REGEXP_MACRO_ASSEMBLER_IA32_H_ */ 134 #endif /* REGEXP_MACRO_ASSEMBLER_IA32_H_ */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698