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

Side by Side Diff: src/regexp-macro-assembler-tracer.cc

Issue 1285163003: Move regexp implementation into its own folder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressed comment Created 5 years, 4 months 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
« no previous file with comments | « src/regexp-macro-assembler-tracer.h ('k') | src/regexp-stack.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "src/v8.h"
6
7 #include "src/ast.h"
8 #include "src/regexp-macro-assembler.h"
9 #include "src/regexp-macro-assembler-tracer.h"
10
11 namespace v8 {
12 namespace internal {
13
14 RegExpMacroAssemblerTracer::RegExpMacroAssemblerTracer(
15 Isolate* isolate, RegExpMacroAssembler* assembler)
16 : RegExpMacroAssembler(isolate, assembler->zone()), assembler_(assembler) {
17 unsigned int type = assembler->Implementation();
18 DCHECK(type < 6);
19 const char* impl_names[] = {"IA32", "ARM", "ARM64",
20 "MIPS", "X64", "X87", "Bytecode"};
21 PrintF("RegExpMacroAssembler%s();\n", impl_names[type]);
22 }
23
24
25 RegExpMacroAssemblerTracer::~RegExpMacroAssemblerTracer() {
26 }
27
28
29 void RegExpMacroAssemblerTracer::AbortedCodeGeneration() {
30 PrintF(" AbortedCodeGeneration\n");
31 assembler_->AbortedCodeGeneration();
32 }
33
34
35 // This is used for printing out debugging information. It makes an integer
36 // that is closely related to the address of an object.
37 static int LabelToInt(Label* label) {
38 return static_cast<int>(reinterpret_cast<intptr_t>(label));
39 }
40
41
42 void RegExpMacroAssemblerTracer::Bind(Label* label) {
43 PrintF("label[%08x]: (Bind)\n", LabelToInt(label));
44 assembler_->Bind(label);
45 }
46
47
48 void RegExpMacroAssemblerTracer::AdvanceCurrentPosition(int by) {
49 PrintF(" AdvanceCurrentPosition(by=%d);\n", by);
50 assembler_->AdvanceCurrentPosition(by);
51 }
52
53
54 void RegExpMacroAssemblerTracer::CheckGreedyLoop(Label* label) {
55 PrintF(" CheckGreedyLoop(label[%08x]);\n\n", LabelToInt(label));
56 assembler_->CheckGreedyLoop(label);
57 }
58
59
60 void RegExpMacroAssemblerTracer::PopCurrentPosition() {
61 PrintF(" PopCurrentPosition();\n");
62 assembler_->PopCurrentPosition();
63 }
64
65
66 void RegExpMacroAssemblerTracer::PushCurrentPosition() {
67 PrintF(" PushCurrentPosition();\n");
68 assembler_->PushCurrentPosition();
69 }
70
71
72 void RegExpMacroAssemblerTracer::Backtrack() {
73 PrintF(" Backtrack();\n");
74 assembler_->Backtrack();
75 }
76
77
78 void RegExpMacroAssemblerTracer::GoTo(Label* label) {
79 PrintF(" GoTo(label[%08x]);\n\n", LabelToInt(label));
80 assembler_->GoTo(label);
81 }
82
83
84 void RegExpMacroAssemblerTracer::PushBacktrack(Label* label) {
85 PrintF(" PushBacktrack(label[%08x]);\n", LabelToInt(label));
86 assembler_->PushBacktrack(label);
87 }
88
89
90 bool RegExpMacroAssemblerTracer::Succeed() {
91 bool restart = assembler_->Succeed();
92 PrintF(" Succeed();%s\n", restart ? " [restart for global match]" : "");
93 return restart;
94 }
95
96
97 void RegExpMacroAssemblerTracer::Fail() {
98 PrintF(" Fail();");
99 assembler_->Fail();
100 }
101
102
103 void RegExpMacroAssemblerTracer::PopRegister(int register_index) {
104 PrintF(" PopRegister(register=%d);\n", register_index);
105 assembler_->PopRegister(register_index);
106 }
107
108
109 void RegExpMacroAssemblerTracer::PushRegister(
110 int register_index,
111 StackCheckFlag check_stack_limit) {
112 PrintF(" PushRegister(register=%d, %s);\n",
113 register_index,
114 check_stack_limit ? "check stack limit" : "");
115 assembler_->PushRegister(register_index, check_stack_limit);
116 }
117
118
119 void RegExpMacroAssemblerTracer::AdvanceRegister(int reg, int by) {
120 PrintF(" AdvanceRegister(register=%d, by=%d);\n", reg, by);
121 assembler_->AdvanceRegister(reg, by);
122 }
123
124
125 void RegExpMacroAssemblerTracer::SetCurrentPositionFromEnd(int by) {
126 PrintF(" SetCurrentPositionFromEnd(by=%d);\n", by);
127 assembler_->SetCurrentPositionFromEnd(by);
128 }
129
130
131 void RegExpMacroAssemblerTracer::SetRegister(int register_index, int to) {
132 PrintF(" SetRegister(register=%d, to=%d);\n", register_index, to);
133 assembler_->SetRegister(register_index, to);
134 }
135
136
137 void RegExpMacroAssemblerTracer::WriteCurrentPositionToRegister(int reg,
138 int cp_offset) {
139 PrintF(" WriteCurrentPositionToRegister(register=%d,cp_offset=%d);\n",
140 reg,
141 cp_offset);
142 assembler_->WriteCurrentPositionToRegister(reg, cp_offset);
143 }
144
145
146 void RegExpMacroAssemblerTracer::ClearRegisters(int reg_from, int reg_to) {
147 PrintF(" ClearRegister(from=%d, to=%d);\n", reg_from, reg_to);
148 assembler_->ClearRegisters(reg_from, reg_to);
149 }
150
151
152 void RegExpMacroAssemblerTracer::ReadCurrentPositionFromRegister(int reg) {
153 PrintF(" ReadCurrentPositionFromRegister(register=%d);\n", reg);
154 assembler_->ReadCurrentPositionFromRegister(reg);
155 }
156
157
158 void RegExpMacroAssemblerTracer::WriteStackPointerToRegister(int reg) {
159 PrintF(" WriteStackPointerToRegister(register=%d);\n", reg);
160 assembler_->WriteStackPointerToRegister(reg);
161 }
162
163
164 void RegExpMacroAssemblerTracer::ReadStackPointerFromRegister(int reg) {
165 PrintF(" ReadStackPointerFromRegister(register=%d);\n", reg);
166 assembler_->ReadStackPointerFromRegister(reg);
167 }
168
169
170 void RegExpMacroAssemblerTracer::LoadCurrentCharacter(int cp_offset,
171 Label* on_end_of_input,
172 bool check_bounds,
173 int characters) {
174 const char* check_msg = check_bounds ? "" : " (unchecked)";
175 PrintF(" LoadCurrentCharacter(cp_offset=%d, label[%08x]%s (%d chars));\n",
176 cp_offset,
177 LabelToInt(on_end_of_input),
178 check_msg,
179 characters);
180 assembler_->LoadCurrentCharacter(cp_offset,
181 on_end_of_input,
182 check_bounds,
183 characters);
184 }
185
186
187 class PrintablePrinter {
188 public:
189 explicit PrintablePrinter(uc16 character) : character_(character) { }
190
191 const char* operator*() {
192 if (character_ >= ' ' && character_ <= '~') {
193 buffer_[0] = '(';
194 buffer_[1] = static_cast<char>(character_);
195 buffer_[2] = ')';
196 buffer_[3] = '\0';
197 } else {
198 buffer_[0] = '\0';
199 }
200 return &buffer_[0];
201 }
202
203 private:
204 uc16 character_;
205 char buffer_[4];
206 };
207
208
209 void RegExpMacroAssemblerTracer::CheckCharacterLT(uc16 limit, Label* on_less) {
210 PrintablePrinter printable(limit);
211 PrintF(" CheckCharacterLT(c=0x%04x%s, label[%08x]);\n",
212 limit,
213 *printable,
214 LabelToInt(on_less));
215 assembler_->CheckCharacterLT(limit, on_less);
216 }
217
218
219 void RegExpMacroAssemblerTracer::CheckCharacterGT(uc16 limit,
220 Label* on_greater) {
221 PrintablePrinter printable(limit);
222 PrintF(" CheckCharacterGT(c=0x%04x%s, label[%08x]);\n",
223 limit,
224 *printable,
225 LabelToInt(on_greater));
226 assembler_->CheckCharacterGT(limit, on_greater);
227 }
228
229
230 void RegExpMacroAssemblerTracer::CheckCharacter(unsigned c, Label* on_equal) {
231 PrintablePrinter printable(c);
232 PrintF(" CheckCharacter(c=0x%04x%s, label[%08x]);\n",
233 c,
234 *printable,
235 LabelToInt(on_equal));
236 assembler_->CheckCharacter(c, on_equal);
237 }
238
239
240 void RegExpMacroAssemblerTracer::CheckAtStart(Label* on_at_start) {
241 PrintF(" CheckAtStart(label[%08x]);\n", LabelToInt(on_at_start));
242 assembler_->CheckAtStart(on_at_start);
243 }
244
245
246 void RegExpMacroAssemblerTracer::CheckNotAtStart(Label* on_not_at_start) {
247 PrintF(" CheckNotAtStart(label[%08x]);\n", LabelToInt(on_not_at_start));
248 assembler_->CheckNotAtStart(on_not_at_start);
249 }
250
251
252 void RegExpMacroAssemblerTracer::CheckNotCharacter(unsigned c,
253 Label* on_not_equal) {
254 PrintablePrinter printable(c);
255 PrintF(" CheckNotCharacter(c=0x%04x%s, label[%08x]);\n",
256 c,
257 *printable,
258 LabelToInt(on_not_equal));
259 assembler_->CheckNotCharacter(c, on_not_equal);
260 }
261
262
263 void RegExpMacroAssemblerTracer::CheckCharacterAfterAnd(
264 unsigned c,
265 unsigned mask,
266 Label* on_equal) {
267 PrintablePrinter printable(c);
268 PrintF(" CheckCharacterAfterAnd(c=0x%04x%s, mask=0x%04x, label[%08x]);\n",
269 c,
270 *printable,
271 mask,
272 LabelToInt(on_equal));
273 assembler_->CheckCharacterAfterAnd(c, mask, on_equal);
274 }
275
276
277 void RegExpMacroAssemblerTracer::CheckNotCharacterAfterAnd(
278 unsigned c,
279 unsigned mask,
280 Label* on_not_equal) {
281 PrintablePrinter printable(c);
282 PrintF(" CheckNotCharacterAfterAnd(c=0x%04x%s, mask=0x%04x, label[%08x]);\n",
283 c,
284 *printable,
285 mask,
286 LabelToInt(on_not_equal));
287 assembler_->CheckNotCharacterAfterAnd(c, mask, on_not_equal);
288 }
289
290
291 void RegExpMacroAssemblerTracer::CheckNotCharacterAfterMinusAnd(
292 uc16 c,
293 uc16 minus,
294 uc16 mask,
295 Label* on_not_equal) {
296 PrintF(" CheckNotCharacterAfterMinusAnd(c=0x%04x, minus=%04x, mask=0x%04x, "
297 "label[%08x]);\n",
298 c,
299 minus,
300 mask,
301 LabelToInt(on_not_equal));
302 assembler_->CheckNotCharacterAfterMinusAnd(c, minus, mask, on_not_equal);
303 }
304
305
306 void RegExpMacroAssemblerTracer::CheckCharacterInRange(
307 uc16 from,
308 uc16 to,
309 Label* on_not_in_range) {
310 PrintablePrinter printable_from(from);
311 PrintablePrinter printable_to(to);
312 PrintF(" CheckCharacterInRange(from=0x%04x%s, to=0x%04x%s, label[%08x]);\n",
313 from,
314 *printable_from,
315 to,
316 *printable_to,
317 LabelToInt(on_not_in_range));
318 assembler_->CheckCharacterInRange(from, to, on_not_in_range);
319 }
320
321
322 void RegExpMacroAssemblerTracer::CheckCharacterNotInRange(
323 uc16 from,
324 uc16 to,
325 Label* on_in_range) {
326 PrintablePrinter printable_from(from);
327 PrintablePrinter printable_to(to);
328 PrintF(
329 " CheckCharacterNotInRange(from=0x%04x%s," " to=%04x%s, label[%08x]);\n",
330 from,
331 *printable_from,
332 to,
333 *printable_to,
334 LabelToInt(on_in_range));
335 assembler_->CheckCharacterNotInRange(from, to, on_in_range);
336 }
337
338
339 void RegExpMacroAssemblerTracer::CheckBitInTable(
340 Handle<ByteArray> table, Label* on_bit_set) {
341 PrintF(" CheckBitInTable(label[%08x] ", LabelToInt(on_bit_set));
342 for (int i = 0; i < kTableSize; i++) {
343 PrintF("%c", table->get(i) != 0 ? 'X' : '.');
344 if (i % 32 == 31 && i != kTableMask) {
345 PrintF("\n ");
346 }
347 }
348 PrintF(");\n");
349 assembler_->CheckBitInTable(table, on_bit_set);
350 }
351
352
353 void RegExpMacroAssemblerTracer::CheckNotBackReference(int start_reg,
354 Label* on_no_match) {
355 PrintF(" CheckNotBackReference(register=%d, label[%08x]);\n", start_reg,
356 LabelToInt(on_no_match));
357 assembler_->CheckNotBackReference(start_reg, on_no_match);
358 }
359
360
361 void RegExpMacroAssemblerTracer::CheckNotBackReferenceIgnoreCase(
362 int start_reg,
363 Label* on_no_match) {
364 PrintF(" CheckNotBackReferenceIgnoreCase(register=%d, label[%08x]);\n",
365 start_reg, LabelToInt(on_no_match));
366 assembler_->CheckNotBackReferenceIgnoreCase(start_reg, on_no_match);
367 }
368
369
370 bool RegExpMacroAssemblerTracer::CheckSpecialCharacterClass(
371 uc16 type,
372 Label* on_no_match) {
373 bool supported = assembler_->CheckSpecialCharacterClass(type,
374 on_no_match);
375 PrintF(" CheckSpecialCharacterClass(type='%c', label[%08x]): %s;\n",
376 type,
377 LabelToInt(on_no_match),
378 supported ? "true" : "false");
379 return supported;
380 }
381
382
383 void RegExpMacroAssemblerTracer::IfRegisterLT(int register_index,
384 int comparand, Label* if_lt) {
385 PrintF(" IfRegisterLT(register=%d, number=%d, label[%08x]);\n",
386 register_index, comparand, LabelToInt(if_lt));
387 assembler_->IfRegisterLT(register_index, comparand, if_lt);
388 }
389
390
391 void RegExpMacroAssemblerTracer::IfRegisterEqPos(int register_index,
392 Label* if_eq) {
393 PrintF(" IfRegisterEqPos(register=%d, label[%08x]);\n",
394 register_index, LabelToInt(if_eq));
395 assembler_->IfRegisterEqPos(register_index, if_eq);
396 }
397
398
399 void RegExpMacroAssemblerTracer::IfRegisterGE(int register_index,
400 int comparand, Label* if_ge) {
401 PrintF(" IfRegisterGE(register=%d, number=%d, label[%08x]);\n",
402 register_index, comparand, LabelToInt(if_ge));
403 assembler_->IfRegisterGE(register_index, comparand, if_ge);
404 }
405
406
407 RegExpMacroAssembler::IrregexpImplementation
408 RegExpMacroAssemblerTracer::Implementation() {
409 return assembler_->Implementation();
410 }
411
412
413 Handle<HeapObject> RegExpMacroAssemblerTracer::GetCode(Handle<String> source) {
414 PrintF(" GetCode(%s);\n", source->ToCString().get());
415 return assembler_->GetCode(source);
416 }
417
418 } // namespace internal
419 } // namespace v8
OLDNEW
« no previous file with comments | « src/regexp-macro-assembler-tracer.h ('k') | src/regexp-stack.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698