| OLD | NEW |
| 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 LabelToInt(on_end_of_input), | 191 LabelToInt(on_end_of_input), |
| 192 check_msg, | 192 check_msg, |
| 193 characters); | 193 characters); |
| 194 assembler_->LoadCurrentCharacter(cp_offset, | 194 assembler_->LoadCurrentCharacter(cp_offset, |
| 195 on_end_of_input, | 195 on_end_of_input, |
| 196 check_bounds, | 196 check_bounds, |
| 197 characters); | 197 characters); |
| 198 } | 198 } |
| 199 | 199 |
| 200 | 200 |
| 201 class PrintablePrinter { |
| 202 public: |
| 203 explicit PrintablePrinter(uc16 character) : character_(character) { } |
| 204 |
| 205 const char* operator*() { |
| 206 if (character_ >= ' ' && character_ <= '~') { |
| 207 buffer_[0] = '('; |
| 208 buffer_[1] = character_; |
| 209 buffer_[2] = ')'; |
| 210 buffer_[3] = '\0'; |
| 211 } else { |
| 212 buffer_[0] = '\0'; |
| 213 } |
| 214 return &buffer_[0]; |
| 215 }; |
| 216 |
| 217 private: |
| 218 uc16 character_; |
| 219 char buffer_[4]; |
| 220 }; |
| 221 |
| 222 |
| 201 void RegExpMacroAssemblerTracer::CheckCharacterLT(uc16 limit, Label* on_less) { | 223 void RegExpMacroAssemblerTracer::CheckCharacterLT(uc16 limit, Label* on_less) { |
| 202 PrintF(" CheckCharacterLT(c='u%04x', label[%08x]);\n", | 224 PrintablePrinter printable(limit); |
| 203 limit, LabelToInt(on_less)); | 225 PrintF(" CheckCharacterLT(c=0x%04x%s, label[%08x]);\n", |
| 226 limit, |
| 227 *printable, |
| 228 LabelToInt(on_less)); |
| 204 assembler_->CheckCharacterLT(limit, on_less); | 229 assembler_->CheckCharacterLT(limit, on_less); |
| 205 } | 230 } |
| 206 | 231 |
| 207 | 232 |
| 208 void RegExpMacroAssemblerTracer::CheckCharacterGT(uc16 limit, | 233 void RegExpMacroAssemblerTracer::CheckCharacterGT(uc16 limit, |
| 209 Label* on_greater) { | 234 Label* on_greater) { |
| 210 PrintF(" CheckCharacterGT(c='u%04x', label[%08x]);\n", | 235 PrintablePrinter printable(limit); |
| 211 limit, LabelToInt(on_greater)); | 236 PrintF(" CheckCharacterGT(c=0x%04x%s, label[%08x]);\n", |
| 237 limit, |
| 238 *printable, |
| 239 LabelToInt(on_greater)); |
| 212 assembler_->CheckCharacterGT(limit, on_greater); | 240 assembler_->CheckCharacterGT(limit, on_greater); |
| 213 } | 241 } |
| 214 | 242 |
| 215 | 243 |
| 216 void RegExpMacroAssemblerTracer::CheckCharacter(unsigned c, Label* on_equal) { | 244 void RegExpMacroAssemblerTracer::CheckCharacter(unsigned c, Label* on_equal) { |
| 217 PrintF(" CheckCharacter(c='u%04x', label[%08x]);\n", | 245 PrintablePrinter printable(c); |
| 218 c, LabelToInt(on_equal)); | 246 PrintF(" CheckCharacter(c=0x%04x%s, label[%08x]);\n", |
| 247 c, |
| 248 *printable, |
| 249 LabelToInt(on_equal)); |
| 219 assembler_->CheckCharacter(c, on_equal); | 250 assembler_->CheckCharacter(c, on_equal); |
| 220 } | 251 } |
| 221 | 252 |
| 222 | 253 |
| 223 void RegExpMacroAssemblerTracer::CheckAtStart(Label* on_at_start) { | 254 void RegExpMacroAssemblerTracer::CheckAtStart(Label* on_at_start) { |
| 224 PrintF(" CheckAtStart(label[%08x]);\n", LabelToInt(on_at_start)); | 255 PrintF(" CheckAtStart(label[%08x]);\n", LabelToInt(on_at_start)); |
| 225 assembler_->CheckAtStart(on_at_start); | 256 assembler_->CheckAtStart(on_at_start); |
| 226 } | 257 } |
| 227 | 258 |
| 228 | 259 |
| 229 void RegExpMacroAssemblerTracer::CheckNotAtStart(Label* on_not_at_start) { | 260 void RegExpMacroAssemblerTracer::CheckNotAtStart(Label* on_not_at_start) { |
| 230 PrintF(" CheckNotAtStart(label[%08x]);\n", LabelToInt(on_not_at_start)); | 261 PrintF(" CheckNotAtStart(label[%08x]);\n", LabelToInt(on_not_at_start)); |
| 231 assembler_->CheckNotAtStart(on_not_at_start); | 262 assembler_->CheckNotAtStart(on_not_at_start); |
| 232 } | 263 } |
| 233 | 264 |
| 234 | 265 |
| 235 void RegExpMacroAssemblerTracer::CheckNotCharacter(unsigned c, | 266 void RegExpMacroAssemblerTracer::CheckNotCharacter(unsigned c, |
| 236 Label* on_not_equal) { | 267 Label* on_not_equal) { |
| 237 PrintF(" CheckNotCharacter(c='u%04x', label[%08x]);\n", | 268 PrintablePrinter printable(c); |
| 238 c, LabelToInt(on_not_equal)); | 269 PrintF(" CheckNotCharacter(c=0x%04x%s, label[%08x]);\n", |
| 270 c, |
| 271 *printable, |
| 272 LabelToInt(on_not_equal)); |
| 239 assembler_->CheckNotCharacter(c, on_not_equal); | 273 assembler_->CheckNotCharacter(c, on_not_equal); |
| 240 } | 274 } |
| 241 | 275 |
| 242 | 276 |
| 243 void RegExpMacroAssemblerTracer::CheckCharacterAfterAnd( | 277 void RegExpMacroAssemblerTracer::CheckCharacterAfterAnd( |
| 244 unsigned c, | 278 unsigned c, |
| 245 unsigned mask, | 279 unsigned mask, |
| 246 Label* on_equal) { | 280 Label* on_equal) { |
| 247 PrintF(" CheckCharacterAfterAnd(c='u%04x', mask=0x%04x, label[%08x]);\n", | 281 PrintablePrinter printable(c); |
| 282 PrintF(" CheckCharacterAfterAnd(c=0x%04x%s, mask=0x%04x, label[%08x]);\n", |
| 248 c, | 283 c, |
| 284 *printable, |
| 249 mask, | 285 mask, |
| 250 LabelToInt(on_equal)); | 286 LabelToInt(on_equal)); |
| 251 assembler_->CheckCharacterAfterAnd(c, mask, on_equal); | 287 assembler_->CheckCharacterAfterAnd(c, mask, on_equal); |
| 252 } | 288 } |
| 253 | 289 |
| 254 | 290 |
| 255 void RegExpMacroAssemblerTracer::CheckNotCharacterAfterAnd( | 291 void RegExpMacroAssemblerTracer::CheckNotCharacterAfterAnd( |
| 256 unsigned c, | 292 unsigned c, |
| 257 unsigned mask, | 293 unsigned mask, |
| 258 Label* on_not_equal) { | 294 Label* on_not_equal) { |
| 259 PrintF(" CheckNotCharacterAfterAnd(c='u%04x', mask=0x%04x, label[%08x]);\n", | 295 PrintablePrinter printable(c); |
| 296 PrintF(" CheckNotCharacterAfterAnd(c=0x%04x%s, mask=0x%04x, label[%08x]);\n", |
| 260 c, | 297 c, |
| 298 *printable, |
| 261 mask, | 299 mask, |
| 262 LabelToInt(on_not_equal)); | 300 LabelToInt(on_not_equal)); |
| 263 assembler_->CheckNotCharacterAfterAnd(c, mask, on_not_equal); | 301 assembler_->CheckNotCharacterAfterAnd(c, mask, on_not_equal); |
| 264 } | 302 } |
| 265 | 303 |
| 266 | 304 |
| 267 void RegExpMacroAssemblerTracer::CheckNotCharacterAfterMinusAnd( | 305 void RegExpMacroAssemblerTracer::CheckNotCharacterAfterMinusAnd( |
| 268 uc16 c, | 306 uc16 c, |
| 269 uc16 minus, | 307 uc16 minus, |
| 270 uc16 mask, | 308 uc16 mask, |
| 271 Label* on_not_equal) { | 309 Label* on_not_equal) { |
| 272 PrintF(" CheckNotCharacterAfterMinusAnd(c='u%04x', minus=%04x, mask=0x%04x, " | 310 PrintF(" CheckNotCharacterAfterMinusAnd(c=0x%04x, minus=%04x, mask=0x%04x, " |
| 273 "label[%08x]);\n", | 311 "label[%08x]);\n", |
| 274 c, | 312 c, |
| 275 minus, | 313 minus, |
| 276 mask, | 314 mask, |
| 277 LabelToInt(on_not_equal)); | 315 LabelToInt(on_not_equal)); |
| 278 assembler_->CheckNotCharacterAfterMinusAnd(c, minus, mask, on_not_equal); | 316 assembler_->CheckNotCharacterAfterMinusAnd(c, minus, mask, on_not_equal); |
| 279 } | 317 } |
| 280 | 318 |
| 281 | 319 |
| 320 void RegExpMacroAssemblerTracer::CheckCharacterInRange( |
| 321 uc16 from, |
| 322 uc16 to, |
| 323 Label* on_not_in_range) { |
| 324 PrintablePrinter printable_from(from); |
| 325 PrintablePrinter printable_to(to); |
| 326 PrintF(" CheckCharacterInRange(from=0x%04x%s, to=0x%04x%s, label[%08x]);\n", |
| 327 from, |
| 328 *printable_from, |
| 329 to, |
| 330 *printable_to, |
| 331 LabelToInt(on_not_in_range)); |
| 332 assembler_->CheckCharacterInRange(from, to, on_not_in_range); |
| 333 } |
| 334 |
| 335 |
| 336 void RegExpMacroAssemblerTracer::CheckCharacterNotInRange( |
| 337 uc16 from, |
| 338 uc16 to, |
| 339 Label* on_in_range) { |
| 340 PrintablePrinter printable_from(from); |
| 341 PrintablePrinter printable_to(to); |
| 342 PrintF( |
| 343 " CheckCharacterNotInRange(from=0x%04x%s," " to=%04x%s, label[%08x]);\n", |
| 344 from, |
| 345 *printable_from, |
| 346 to, |
| 347 *printable_to, |
| 348 LabelToInt(on_in_range)); |
| 349 assembler_->CheckCharacterNotInRange(from, to, on_in_range); |
| 350 } |
| 351 |
| 352 |
| 353 void RegExpMacroAssemblerTracer::CheckBitInTable( |
| 354 Handle<ByteArray> table, Label* on_bit_set) { |
| 355 PrintF(" CheckBitInTable(label[%08x] ", LabelToInt(on_bit_set)); |
| 356 for (int i = 0; i < kTableSize; i++) { |
| 357 PrintF("%c", table->get(i) != 0 ? 'X' : '.'); |
| 358 if (i % 32 == 31 && i != kTableMask) { |
| 359 PrintF("\n "); |
| 360 } |
| 361 } |
| 362 PrintF(");\n"); |
| 363 assembler_->CheckBitInTable(table, on_bit_set); |
| 364 } |
| 365 |
| 366 |
| 282 void RegExpMacroAssemblerTracer::CheckNotBackReference(int start_reg, | 367 void RegExpMacroAssemblerTracer::CheckNotBackReference(int start_reg, |
| 283 Label* on_no_match) { | 368 Label* on_no_match) { |
| 284 PrintF(" CheckNotBackReference(register=%d, label[%08x]);\n", start_reg, | 369 PrintF(" CheckNotBackReference(register=%d, label[%08x]);\n", start_reg, |
| 285 LabelToInt(on_no_match)); | 370 LabelToInt(on_no_match)); |
| 286 assembler_->CheckNotBackReference(start_reg, on_no_match); | 371 assembler_->CheckNotBackReference(start_reg, on_no_match); |
| 287 } | 372 } |
| 288 | 373 |
| 289 | 374 |
| 290 void RegExpMacroAssemblerTracer::CheckNotBackReferenceIgnoreCase( | 375 void RegExpMacroAssemblerTracer::CheckNotBackReferenceIgnoreCase( |
| 291 int start_reg, | 376 int start_reg, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 307 } | 392 } |
| 308 | 393 |
| 309 | 394 |
| 310 void RegExpMacroAssemblerTracer::CheckCharacters(Vector<const uc16> str, | 395 void RegExpMacroAssemblerTracer::CheckCharacters(Vector<const uc16> str, |
| 311 int cp_offset, | 396 int cp_offset, |
| 312 Label* on_failure, | 397 Label* on_failure, |
| 313 bool check_end_of_string) { | 398 bool check_end_of_string) { |
| 314 PrintF(" %s(str=\"", | 399 PrintF(" %s(str=\"", |
| 315 check_end_of_string ? "CheckCharacters" : "CheckCharactersUnchecked"); | 400 check_end_of_string ? "CheckCharacters" : "CheckCharactersUnchecked"); |
| 316 for (int i = 0; i < str.length(); i++) { | 401 for (int i = 0; i < str.length(); i++) { |
| 317 PrintF("u%04x", str[i]); | 402 PrintF("0x%04x", str[i]); |
| 318 } | 403 } |
| 319 PrintF("\", cp_offset=%d, label[%08x])\n", | 404 PrintF("\", cp_offset=%d, label[%08x])\n", |
| 320 cp_offset, LabelToInt(on_failure)); | 405 cp_offset, LabelToInt(on_failure)); |
| 321 assembler_->CheckCharacters(str, cp_offset, on_failure, check_end_of_string); | 406 assembler_->CheckCharacters(str, cp_offset, on_failure, check_end_of_string); |
| 322 } | 407 } |
| 323 | 408 |
| 324 | 409 |
| 325 bool RegExpMacroAssemblerTracer::CheckSpecialCharacterClass( | 410 bool RegExpMacroAssemblerTracer::CheckSpecialCharacterClass( |
| 326 uc16 type, | 411 uc16 type, |
| 327 Label* on_no_match) { | 412 Label* on_no_match) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 return assembler_->Implementation(); | 449 return assembler_->Implementation(); |
| 365 } | 450 } |
| 366 | 451 |
| 367 | 452 |
| 368 Handle<HeapObject> RegExpMacroAssemblerTracer::GetCode(Handle<String> source) { | 453 Handle<HeapObject> RegExpMacroAssemblerTracer::GetCode(Handle<String> source) { |
| 369 PrintF(" GetCode(%s);\n", *(source->ToCString())); | 454 PrintF(" GetCode(%s);\n", *(source->ToCString())); |
| 370 return assembler_->GetCode(source); | 455 return assembler_->GetCode(source); |
| 371 } | 456 } |
| 372 | 457 |
| 373 }} // namespace v8::internal | 458 }} // namespace v8::internal |
| OLD | NEW |