| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 void Logger::LogRuntime(Vector<const char> format, JSArray* args) { | 552 void Logger::LogRuntime(Vector<const char> format, JSArray* args) { |
| 553 #ifdef ENABLE_LOGGING_AND_PROFILING | 553 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 554 if (!Log::IsEnabled() || !FLAG_log_runtime) return; | 554 if (!Log::IsEnabled() || !FLAG_log_runtime) return; |
| 555 HandleScope scope; | 555 HandleScope scope; |
| 556 LogMessageBuilder msg; | 556 LogMessageBuilder msg; |
| 557 for (int i = 0; i < format.length(); i++) { | 557 for (int i = 0; i < format.length(); i++) { |
| 558 char c = format[i]; | 558 char c = format[i]; |
| 559 if (c == '%' && i <= format.length() - 2) { | 559 if (c == '%' && i <= format.length() - 2) { |
| 560 i++; | 560 i++; |
| 561 ASSERT('0' <= format[i] && format[i] <= '9'); | 561 ASSERT('0' <= format[i] && format[i] <= '9'); |
| 562 Object* obj = args->GetElement(format[i] - '0'); | 562 MaybeObject* maybe = args->GetElement(format[i] - '0'); |
| 563 Object* obj; |
| 564 if (!maybe->ToObject(&obj)) { |
| 565 msg.Append("<exception>"); |
| 566 continue; |
| 567 } |
| 563 i++; | 568 i++; |
| 564 switch (format[i]) { | 569 switch (format[i]) { |
| 565 case 's': | 570 case 's': |
| 566 msg.AppendDetailed(String::cast(obj), false); | 571 msg.AppendDetailed(String::cast(obj), false); |
| 567 break; | 572 break; |
| 568 case 'S': | 573 case 'S': |
| 569 msg.AppendDetailed(String::cast(obj), true); | 574 msg.AppendDetailed(String::cast(obj), true); |
| 570 break; | 575 break; |
| 571 case 'r': | 576 case 'r': |
| 572 Logger::LogRegExpSource(Handle<JSRegExp>(JSRegExp::cast(obj))); | 577 Logger::LogRegExpSource(Handle<JSRegExp>(JSRegExp::cast(obj))); |
| (...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1371 LogMessageBuilder msg; | 1376 LogMessageBuilder msg; |
| 1372 msg.Append("code-info,%s,%d\n", arch, Code::kHeaderSize); | 1377 msg.Append("code-info,%s,%d\n", arch, Code::kHeaderSize); |
| 1373 msg.WriteToLogFile(); | 1378 msg.WriteToLogFile(); |
| 1374 #endif // ENABLE_LOGGING_AND_PROFILING | 1379 #endif // ENABLE_LOGGING_AND_PROFILING |
| 1375 } | 1380 } |
| 1376 | 1381 |
| 1377 | 1382 |
| 1378 void Logger::LowLevelCodeCreateEvent(Code* code, LogMessageBuilder* msg) { | 1383 void Logger::LowLevelCodeCreateEvent(Code* code, LogMessageBuilder* msg) { |
| 1379 if (!FLAG_ll_prof || Log::output_code_handle_ == NULL) return; | 1384 if (!FLAG_ll_prof || Log::output_code_handle_ == NULL) return; |
| 1380 int pos = static_cast<int>(ftell(Log::output_code_handle_)); | 1385 int pos = static_cast<int>(ftell(Log::output_code_handle_)); |
| 1381 fwrite(code->instruction_start(), 1, code->instruction_size(), | 1386 size_t rv = fwrite(code->instruction_start(), 1, code->instruction_size(), |
| 1382 Log::output_code_handle_); | 1387 Log::output_code_handle_); |
| 1388 ASSERT(static_cast<size_t>(code->instruction_size()) == rv); |
| 1389 USE(rv); |
| 1383 msg->Append(",%d", pos); | 1390 msg->Append(",%d", pos); |
| 1384 } | 1391 } |
| 1385 | 1392 |
| 1386 | 1393 |
| 1387 void Logger::LogCodeObjects() { | 1394 void Logger::LogCodeObjects() { |
| 1388 AssertNoAllocation no_alloc; | 1395 AssertNoAllocation no_alloc; |
| 1389 HeapIterator iterator; | 1396 HeapIterator iterator; |
| 1390 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 1397 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { |
| 1391 if (obj->IsCode()) LogCodeObject(obj); | 1398 if (obj->IsCode()) LogCodeObject(obj); |
| 1392 } | 1399 } |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1639 } | 1646 } |
| 1640 // Otherwise, if the sliding state window computation has not been | 1647 // Otherwise, if the sliding state window computation has not been |
| 1641 // started we do it now. | 1648 // started we do it now. |
| 1642 if (sliding_state_window_ == NULL) { | 1649 if (sliding_state_window_ == NULL) { |
| 1643 sliding_state_window_ = new SlidingStateWindow(); | 1650 sliding_state_window_ = new SlidingStateWindow(); |
| 1644 } | 1651 } |
| 1645 #endif | 1652 #endif |
| 1646 } | 1653 } |
| 1647 | 1654 |
| 1648 } } // namespace v8::internal | 1655 } } // namespace v8::internal |
| OLD | NEW |