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

Side by Side Diff: src/log.cc

Issue 6076: Added special case for atomic regular expressions. (Closed)
Patch Set: Created 12 years, 2 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/jsregexp.cc ('k') | src/objects.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 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 FILE* Logger::logfile_ = NULL; 251 FILE* Logger::logfile_ = NULL;
252 Profiler* Logger::profiler_ = NULL; 252 Profiler* Logger::profiler_ = NULL;
253 Mutex* Logger::mutex_ = NULL; 253 Mutex* Logger::mutex_ = NULL;
254 VMState* Logger::current_state_ = NULL; 254 VMState* Logger::current_state_ = NULL;
255 SlidingStateWindow* Logger::sliding_state_window_ = NULL; 255 SlidingStateWindow* Logger::sliding_state_window_ = NULL;
256 256
257 #endif // ENABLE_LOGGING_AND_PROFILING 257 #endif // ENABLE_LOGGING_AND_PROFILING
258 258
259 void Logger::Preamble(const char* content) { 259 void Logger::Preamble(const char* content) {
260 #ifdef ENABLE_LOGGING_AND_PROFILING 260 #ifdef ENABLE_LOGGING_AND_PROFILING
261 if (logfile_ == NULL) return; 261 if (logfile_ == NULL || !FLAG_log) return;
262 ScopedLock sl(mutex_); 262 ScopedLock sl(mutex_);
263 fprintf(logfile_, "%s", content); 263 fprintf(logfile_, "%s", content);
264 #endif 264 #endif
265 } 265 }
266 266
267 267
268 void Logger::StringEvent(const char* name, const char* value) { 268 void Logger::StringEvent(const char* name, const char* value) {
269 #ifdef ENABLE_LOGGING_AND_PROFILING 269 #ifdef ENABLE_LOGGING_AND_PROFILING
270 if (logfile_ == NULL) return; 270 if (logfile_ == NULL || !FLAG_log) return;
271 ScopedLock sl(mutex_); 271 ScopedLock sl(mutex_);
272 fprintf(logfile_, "%s,\"%s\"\n", name, value); 272 fprintf(logfile_, "%s,\"%s\"\n", name, value);
273 #endif 273 #endif
274 } 274 }
275 275
276 276
277 void Logger::IntEvent(const char* name, int value) { 277 void Logger::IntEvent(const char* name, int value) {
278 #ifdef ENABLE_LOGGING_AND_PROFILING 278 #ifdef ENABLE_LOGGING_AND_PROFILING
279 if (logfile_ == NULL) return; 279 if (logfile_ == NULL || !FLAG_log) return;
280 ScopedLock sl(mutex_); 280 ScopedLock sl(mutex_);
281 fprintf(logfile_, "%s,%d\n", name, value); 281 fprintf(logfile_, "%s,%d\n", name, value);
282 #endif 282 #endif
283 } 283 }
284 284
285 285
286 void Logger::HandleEvent(const char* name, Object** location) { 286 void Logger::HandleEvent(const char* name, Object** location) {
287 #ifdef ENABLE_LOGGING_AND_PROFILING 287 #ifdef ENABLE_LOGGING_AND_PROFILING
288 if (logfile_ == NULL || !FLAG_log_handles) return; 288 if (logfile_ == NULL || !FLAG_log_handles) return;
289 ScopedLock sl(mutex_); 289 ScopedLock sl(mutex_);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 // (re.global?"g":"") + (re.ignorecase?"i":"") + (re.multiline?"m":"") 353 // (re.global?"g":"") + (re.ignorecase?"i":"") + (re.multiline?"m":"")
354 354
355 Handle<Object> source = GetProperty(regexp, "source"); 355 Handle<Object> source = GetProperty(regexp, "source");
356 if (!source->IsString()) { 356 if (!source->IsString()) {
357 fprintf(logfile_, "no source"); 357 fprintf(logfile_, "no source");
358 return; 358 return;
359 } 359 }
360 Handle<String> source_string = Handle<String>::cast(source); 360 Handle<String> source_string = Handle<String>::cast(source);
361 361
362 SmartPointer<uc16> cstring = source_string->ToWideCString(); 362 SmartPointer<uc16> cstring = source_string->ToWideCString();
363 if (regexp->type()->IsSmi()) {
364 switch (regexp->type_tag()) {
365 case JSRegExp::ATOM:
366 fprintf(logfile_, "a");
367 break;
368 default:
369 break;
370 }
371 }
363 fprintf(logfile_, "/"); 372 fprintf(logfile_, "/");
364 for (int i = 0, n = source_string->length(); i < n; i++) { 373 for (int i = 0, n = source_string->length(); i < n; i++) {
365 uc16 c = cstring[i]; 374 uc16 c = cstring[i];
366 if (c < 32 || (c > 126 && c <= 255)) { 375 if (c < 32 || (c > 126 && c <= 255)) {
367 fprintf(logfile_, "\\x%02x", c); 376 fprintf(logfile_, "\\x%02x", c);
368 } else if (c > 255) { 377 } else if (c > 255) {
369 fprintf(logfile_, "\\u%04x", c); 378 fprintf(logfile_, "\\u%04x", c);
370 } else { 379 } else {
371 fprintf(logfile_, "%lc", c); 380 fprintf(logfile_, "%lc", c);
372 } 381 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 void Logger::ApiEntryCall(const char* name) { 477 void Logger::ApiEntryCall(const char* name) {
469 #ifdef ENABLE_LOGGING_AND_PROFILING 478 #ifdef ENABLE_LOGGING_AND_PROFILING
470 if (logfile_ == NULL || !FLAG_log_api) return; 479 if (logfile_ == NULL || !FLAG_log_api) return;
471 Logger::ApiEvent("api,%s\n", name); 480 Logger::ApiEvent("api,%s\n", name);
472 #endif 481 #endif
473 } 482 }
474 483
475 484
476 void Logger::NewEvent(const char* name, void* object, size_t size) { 485 void Logger::NewEvent(const char* name, void* object, size_t size) {
477 #ifdef ENABLE_LOGGING_AND_PROFILING 486 #ifdef ENABLE_LOGGING_AND_PROFILING
478 if (logfile_ == NULL) return; 487 if (logfile_ == NULL || !FLAG_log) return;
479 ScopedLock sl(mutex_); 488 ScopedLock sl(mutex_);
480 fprintf(logfile_, "new,%s,0x%x,%u\n", name, 489 fprintf(logfile_, "new,%s,0x%x,%u\n", name,
481 reinterpret_cast<unsigned int>(object), 490 reinterpret_cast<unsigned int>(object),
482 static_cast<unsigned int>(size)); 491 static_cast<unsigned int>(size));
483 #endif 492 #endif
484 } 493 }
485 494
486 495
487 void Logger::DeleteEvent(const char* name, void* object) { 496 void Logger::DeleteEvent(const char* name, void* object) {
488 #ifdef ENABLE_LOGGING_AND_PROFILING 497 #ifdef ENABLE_LOGGING_AND_PROFILING
489 if (logfile_ == NULL) return; 498 if (logfile_ == NULL || !FLAG_log) return;
490 ScopedLock sl(mutex_); 499 ScopedLock sl(mutex_);
491 fprintf(logfile_, "delete,%s,0x%x\n", name, 500 fprintf(logfile_, "delete,%s,0x%x\n", name,
492 reinterpret_cast<unsigned int>(object)); 501 reinterpret_cast<unsigned int>(object));
493 #endif 502 #endif
494 } 503 }
495 504
496 505
497 void Logger::CodeCreateEvent(const char* tag, Code* code, const char* comment) { 506 void Logger::CodeCreateEvent(const char* tag, Code* code, const char* comment) {
498 #ifdef ENABLE_LOGGING_AND_PROFILING 507 #ifdef ENABLE_LOGGING_AND_PROFILING
499 if (logfile_ == NULL || !FLAG_log_code) return; 508 if (logfile_ == NULL || !FLAG_log_code) return;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 #ifdef ENABLE_LOGGING_AND_PROFILING 561 #ifdef ENABLE_LOGGING_AND_PROFILING
553 if (logfile_ == NULL || !FLAG_log_code) return; 562 if (logfile_ == NULL || !FLAG_log_code) return;
554 ScopedLock sl(mutex_); 563 ScopedLock sl(mutex_);
555 fprintf(logfile_, "code-delete,0x%x\n", reinterpret_cast<unsigned int>(from)); 564 fprintf(logfile_, "code-delete,0x%x\n", reinterpret_cast<unsigned int>(from));
556 #endif 565 #endif
557 } 566 }
558 567
559 568
560 void Logger::ResourceEvent(const char* name, const char* tag) { 569 void Logger::ResourceEvent(const char* name, const char* tag) {
561 #ifdef ENABLE_LOGGING_AND_PROFILING 570 #ifdef ENABLE_LOGGING_AND_PROFILING
562 if (logfile_ == NULL) return; 571 if (logfile_ == NULL || !FLAG_log) return;
563 ScopedLock sl(mutex_); 572 ScopedLock sl(mutex_);
564 fprintf(logfile_, "%s,%s,", name, tag); 573 fprintf(logfile_, "%s,%s,", name, tag);
565 574
566 uint32_t sec, usec; 575 uint32_t sec, usec;
567 if (OS::GetUserTime(&sec, &usec) != -1) { 576 if (OS::GetUserTime(&sec, &usec) != -1) {
568 fprintf(logfile_, "%d,%d,", sec, usec); 577 fprintf(logfile_, "%d,%d,", sec, usec);
569 } 578 }
570 fprintf(logfile_, "%.0f", OS::TimeCurrentMillis()); 579 fprintf(logfile_, "%.0f", OS::TimeCurrentMillis());
571 580
572 fprintf(logfile_, "\n"); 581 fprintf(logfile_, "\n");
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 #ifdef ENABLE_LOGGING_AND_PROFILING 618 #ifdef ENABLE_LOGGING_AND_PROFILING
610 if (logfile_ == NULL || !FLAG_log_gc) return; 619 if (logfile_ == NULL || !FLAG_log_gc) return;
611 ScopedLock sl(mutex_); 620 ScopedLock sl(mutex_);
612 fprintf(logfile_, "heap-sample-item,%s,%d,%d\n", type, number, bytes); 621 fprintf(logfile_, "heap-sample-item,%s,%d,%d\n", type, number, bytes);
613 #endif 622 #endif
614 } 623 }
615 624
616 625
617 void Logger::DebugTag(const char* call_site_tag) { 626 void Logger::DebugTag(const char* call_site_tag) {
618 #ifdef ENABLE_LOGGING_AND_PROFILING 627 #ifdef ENABLE_LOGGING_AND_PROFILING
619 if (logfile_ == NULL) return; 628 if (logfile_ == NULL || !FLAG_log) return;
620 ScopedLock sl(mutex_); 629 ScopedLock sl(mutex_);
621 fprintf(logfile_, "debug-tag,%s\n", call_site_tag); 630 fprintf(logfile_, "debug-tag,%s\n", call_site_tag);
622 #endif 631 #endif
623 } 632 }
624 633
625 634
626 void Logger::DebugEvent(const char* event_type, Vector<uint16_t> parameter) { 635 void Logger::DebugEvent(const char* event_type, Vector<uint16_t> parameter) {
627 #ifdef ENABLE_LOGGING_AND_PROFILING 636 #ifdef ENABLE_LOGGING_AND_PROFILING
628 if (logfile_ == NULL) return; 637 if (logfile_ == NULL || !FLAG_log) return;
629 StringBuilder s(parameter.length() + 1); 638 StringBuilder s(parameter.length() + 1);
630 for (int i = 0; i < parameter.length(); ++i) { 639 for (int i = 0; i < parameter.length(); ++i) {
631 s.AddCharacter(static_cast<char>(parameter[i])); 640 s.AddCharacter(static_cast<char>(parameter[i]));
632 } 641 }
633 char* parameter_string = s.Finalize(); 642 char* parameter_string = s.Finalize();
634 ScopedLock sl(mutex_); 643 ScopedLock sl(mutex_);
635 fprintf(logfile_, 644 fprintf(logfile_,
636 "debug-queue-event,%s,%15.3f,%s\n", 645 "debug-queue-event,%s,%15.3f,%s\n",
637 event_type, 646 event_type,
638 OS::TimeCurrentMillis(), 647 OS::TimeCurrentMillis(),
639 parameter_string); 648 parameter_string);
640 DeleteArray(parameter_string); 649 DeleteArray(parameter_string);
641 #endif 650 #endif
642 } 651 }
643 652
644 653
645 #ifdef ENABLE_LOGGING_AND_PROFILING 654 #ifdef ENABLE_LOGGING_AND_PROFILING
646 void Logger::TickEvent(TickSample* sample, bool overflow) { 655 void Logger::TickEvent(TickSample* sample, bool overflow) {
647 if (logfile_ == NULL) return; 656 if (logfile_ == NULL || !FLAG_log) return;
648 ScopedLock sl(mutex_); 657 ScopedLock sl(mutex_);
649 fprintf(logfile_, "tick,0x%x,0x%x,%d", sample->pc, sample->sp, 658 fprintf(logfile_, "tick,0x%x,0x%x,%d", sample->pc, sample->sp,
650 static_cast<int>(sample->state)); 659 static_cast<int>(sample->state));
651 if (overflow) fprintf(logfile_, ",overflow"); 660 if (overflow) fprintf(logfile_, ",overflow");
652 fprintf(logfile_, "\n"); 661 fprintf(logfile_, "\n");
653 } 662 }
654 #endif 663 #endif
655 664
656 665
657 bool Logger::Setup() { 666 bool Logger::Setup() {
658 #ifdef ENABLE_LOGGING_AND_PROFILING 667 #ifdef ENABLE_LOGGING_AND_PROFILING
659 // --log-all enables all the log flags. 668 // --log-all enables all the log flags.
660 if (FLAG_log_all) { 669 if (FLAG_log_all) {
661 FLAG_log_api = true; 670 FLAG_log_api = true;
662 FLAG_log_code = true; 671 FLAG_log_code = true;
663 FLAG_log_gc = true; 672 FLAG_log_gc = true;
664 FLAG_log_suspect = true; 673 FLAG_log_suspect = true;
665 FLAG_log_handles = true; 674 FLAG_log_handles = true;
666 FLAG_log_regexp = true; 675 FLAG_log_regexp = true;
667 } 676 }
668 677
669 // --prof implies --log-code. 678 // --prof implies --log-code.
670 if (FLAG_prof) FLAG_log_code = true; 679 if (FLAG_prof) FLAG_log_code = true;
671 680
672 // Each of the individual log flags implies --log. Check after 681 bool open_log_file = FLAG_log || FLAG_log_api || FLAG_log_code
673 // checking --log-all and --prof in case they set --log-code. 682 || FLAG_log_gc || FLAG_log_handles || FLAG_log_suspect
674 if (FLAG_log_api || FLAG_log_code || FLAG_log_gc || 683 || FLAG_log_regexp;
675 FLAG_log_handles || FLAG_log_suspect || FLAG_log_regexp) {
676 FLAG_log = true;
677 }
678 684
679 // If we're logging anything, we need to open the log file. 685 // If we're logging anything, we need to open the log file.
680 if (FLAG_log) { 686 if (open_log_file) {
681 if (strcmp(FLAG_logfile, "-") == 0) { 687 if (strcmp(FLAG_logfile, "-") == 0) {
682 logfile_ = stdout; 688 logfile_ = stdout;
683 } else { 689 } else {
684 logfile_ = OS::FOpen(FLAG_logfile, "w"); 690 logfile_ = OS::FOpen(FLAG_logfile, "w");
685 } 691 }
686 mutex_ = OS::CreateMutex(); 692 mutex_ = OS::CreateMutex();
687 } 693 }
688 694
689 current_state_ = new VMState(OTHER); 695 current_state_ = new VMState(OTHER);
690 696
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 if (FLAG_log_state_changes) { 797 if (FLAG_log_state_changes) {
792 LOG(StringEvent("Leaving", StateToString(state_))); 798 LOG(StringEvent("Leaving", StateToString(state_)));
793 if (previous_) { 799 if (previous_) {
794 LOG(StringEvent("To", StateToString(previous_->state_))); 800 LOG(StringEvent("To", StateToString(previous_->state_)));
795 } 801 }
796 } 802 }
797 } 803 }
798 #endif 804 #endif
799 805
800 } } // namespace v8::internal 806 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/jsregexp.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698