| OLD | NEW |
| 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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 #ifdef ENABLE_LOGGING_AND_PROFILING | 343 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 344 if (logfile_ == NULL || !FLAG_prof) return; | 344 if (logfile_ == NULL || !FLAG_prof) return; |
| 345 ScopedLock sl(mutex_); | 345 ScopedLock sl(mutex_); |
| 346 fprintf(logfile_, "shared-library,\"%ls\",0x%08x,0x%08x\n", library_path, | 346 fprintf(logfile_, "shared-library,\"%ls\",0x%08x,0x%08x\n", library_path, |
| 347 start, end); | 347 start, end); |
| 348 #endif | 348 #endif |
| 349 } | 349 } |
| 350 | 350 |
| 351 | 351 |
| 352 #ifdef ENABLE_LOGGING_AND_PROFILING | 352 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 353 void Logger::LogString(Handle<String> str) { | 353 void Logger::LogString(Handle<String> str, bool show_impl_info) { |
| 354 StringShape shape(*str); | 354 StringShape shape(*str); |
| 355 int len = str->length(shape); | 355 int len = str->length(shape); |
| 356 if (len > 256) | 356 if (len > 0x1000) |
| 357 len = 256; | 357 len = 0x1000; |
| 358 if (show_impl_info) { |
| 359 fputc(shape.IsAsciiRepresentation() ? 'a' : '2', logfile_); |
| 360 if (shape.IsExternal()) |
| 361 fputc('e', logfile_); |
| 362 if (shape.IsSymbol()) |
| 363 fputc('#', logfile_); |
| 364 fprintf(logfile_, ":%i:", str->length()); |
| 365 } |
| 358 for (int i = 0; i < len; i++) { | 366 for (int i = 0; i < len; i++) { |
| 359 uc32 c = str->Get(shape, i); | 367 uc32 c = str->Get(shape, i); |
| 360 if (c > 0xff) { | 368 if (c > 0xff) { |
| 361 fprintf(logfile_, "\\u%04x", c); | 369 fprintf(logfile_, "\\u%04x", c); |
| 362 } else if (c < 32 || c > 126) { | 370 } else if (c < 32 || c > 126) { |
| 363 fprintf(logfile_, "\\x%02x", c); | 371 fprintf(logfile_, "\\x%02x", c); |
| 364 } else if (c == ',') { | 372 } else if (c == ',') { |
| 365 fprintf(logfile_, "\\,"); | 373 fprintf(logfile_, "\\,"); |
| 366 } else if (c == '\\') { | 374 } else if (c == '\\') { |
| 367 fprintf(logfile_, "\\\\"); | 375 fprintf(logfile_, "\\\\"); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 382 } | 390 } |
| 383 | 391 |
| 384 switch (regexp->TypeTag()) { | 392 switch (regexp->TypeTag()) { |
| 385 case JSRegExp::ATOM: | 393 case JSRegExp::ATOM: |
| 386 fprintf(logfile_, "a"); | 394 fprintf(logfile_, "a"); |
| 387 break; | 395 break; |
| 388 default: | 396 default: |
| 389 break; | 397 break; |
| 390 } | 398 } |
| 391 fprintf(logfile_, "/"); | 399 fprintf(logfile_, "/"); |
| 392 LogString(Handle<String>::cast(source)); | 400 LogString(Handle<String>::cast(source), false); |
| 393 fprintf(logfile_, "/"); | 401 fprintf(logfile_, "/"); |
| 394 | 402 |
| 395 // global flag | 403 // global flag |
| 396 Handle<Object> global = GetProperty(regexp, "global"); | 404 Handle<Object> global = GetProperty(regexp, "global"); |
| 397 if (global->IsTrue()) { | 405 if (global->IsTrue()) { |
| 398 fprintf(logfile_, "g"); | 406 fprintf(logfile_, "g"); |
| 399 } | 407 } |
| 400 // ignorecase flag | 408 // ignorecase flag |
| 401 Handle<Object> ignorecase = GetProperty(regexp, "ignoreCase"); | 409 Handle<Object> ignorecase = GetProperty(regexp, "ignoreCase"); |
| 402 if (ignorecase->IsTrue()) { | 410 if (ignorecase->IsTrue()) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 416 if (logfile_ == NULL || !FLAG_log_regexp) return; | 424 if (logfile_ == NULL || !FLAG_log_regexp) return; |
| 417 ScopedLock sl(mutex_); | 425 ScopedLock sl(mutex_); |
| 418 | 426 |
| 419 fprintf(logfile_, "regexp-compile,"); | 427 fprintf(logfile_, "regexp-compile,"); |
| 420 LogRegExpSource(regexp); | 428 LogRegExpSource(regexp); |
| 421 fprintf(logfile_, in_cache ? ",hit\n" : ",miss\n"); | 429 fprintf(logfile_, in_cache ? ",hit\n" : ",miss\n"); |
| 422 #endif | 430 #endif |
| 423 } | 431 } |
| 424 | 432 |
| 425 | 433 |
| 426 void Logger::RegExpExecEvent(Handle<JSRegExp> regexp, | 434 void Logger::LogRuntime(Vector<const char> format, JSArray* args) { |
| 427 int start_index, | |
| 428 Handle<String> input_string) { | |
| 429 #ifdef ENABLE_LOGGING_AND_PROFILING | |
| 430 if (logfile_ == NULL || !FLAG_log_regexp) return; | |
| 431 ScopedLock sl(mutex_); | 435 ScopedLock sl(mutex_); |
| 432 | 436 HandleScope scope; |
| 433 fprintf(logfile_, "regexp-run,"); | 437 for (int i = 0; i < format.length(); i++) { |
| 434 LogRegExpSource(regexp); | 438 char c = format[i]; |
| 435 fprintf(logfile_, ","); | 439 if (c == '%' && i <= format.length() - 2) { |
| 436 LogString(input_string); | 440 i++; |
| 437 fprintf(logfile_, ",%d..%d\n", start_index, input_string->length()); | 441 ASSERT('0' <= format[i] && format[i] <= '9'); |
| 438 #endif | 442 Object* obj = args->GetElement(format[i] - '0'); |
| 443 i++; |
| 444 switch (format[i]) { |
| 445 case 's': |
| 446 Logger::LogString(Handle<String>(String::cast(obj)), false); |
| 447 break; |
| 448 case 'S': |
| 449 Logger::LogString(Handle<String>(String::cast(obj)), true); |
| 450 break; |
| 451 case 'r': |
| 452 Logger::LogRegExpSource(Handle<JSRegExp>(JSRegExp::cast(obj))); |
| 453 break; |
| 454 case 'x': |
| 455 fprintf(logfile_, "0x%x", Smi::cast(obj)->value()); |
| 456 break; |
| 457 case 'i': |
| 458 fprintf(logfile_, "%i", Smi::cast(obj)->value()); |
| 459 break; |
| 460 default: |
| 461 UNREACHABLE(); |
| 462 } |
| 463 } else { |
| 464 fputc(c, logfile_); |
| 465 } |
| 466 } |
| 467 fputc('\n', logfile_); |
| 439 } | 468 } |
| 440 | 469 |
| 441 | 470 |
| 442 void Logger::ApiIndexedSecurityCheck(uint32_t index) { | 471 void Logger::ApiIndexedSecurityCheck(uint32_t index) { |
| 443 #ifdef ENABLE_LOGGING_AND_PROFILING | 472 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 444 if (logfile_ == NULL || !FLAG_log_api) return; | 473 if (logfile_ == NULL || !FLAG_log_api) return; |
| 445 ApiEvent("api,check-security,%u\n", index); | 474 ApiEvent("api,check-security,%u\n", index); |
| 446 #endif | 475 #endif |
| 447 } | 476 } |
| 448 | 477 |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 if (FLAG_log_state_changes) { | 915 if (FLAG_log_state_changes) { |
| 887 LOG(StringEvent("Leaving", StateToString(state_))); | 916 LOG(StringEvent("Leaving", StateToString(state_))); |
| 888 if (previous_) { | 917 if (previous_) { |
| 889 LOG(StringEvent("To", StateToString(previous_->state_))); | 918 LOG(StringEvent("To", StateToString(previous_->state_))); |
| 890 } | 919 } |
| 891 } | 920 } |
| 892 } | 921 } |
| 893 #endif | 922 #endif |
| 894 | 923 |
| 895 } } // namespace v8::internal | 924 } } // namespace v8::internal |
| OLD | NEW |