Chromium Code Reviews| Index: src/assembler-ia32.cc |
| =================================================================== |
| --- src/assembler-ia32.cc (revision 1748) |
| +++ src/assembler-ia32.cc (working copy) |
| @@ -283,6 +283,10 @@ |
| *pc_++ = (x) |
| +#ifdef GENERATED_CODE_COVERAGE |
| +static void InitCoverageLog(); |
| +#endif |
| + |
| // spare_buffer_ |
| static byte* spare_buffer_ = NULL; |
| @@ -329,6 +333,9 @@ |
| current_position_ = RelocInfo::kNoPosition; |
| written_statement_position_ = current_statement_position_; |
| written_position_ = current_position_; |
| +#ifdef GENERATED_CODE_COVERAGE |
| + InitCoverageLog(); |
| +#endif |
| } |
| @@ -2202,4 +2209,31 @@ |
| long_at_put(position, label_loc); |
| } |
| + |
| +#ifdef GENERATED_CODE_COVERAGE |
| +static FILE* coverage_log = NULL; |
| + |
| + |
| +static void InitCoverageLog() { |
| + char* file_name = getenv("V8_GENERATED_CODE_COVERAGE_LOG"); |
| + if (file_name != NULL) { |
| + coverage_log = fopen(file_name, "aw+"); |
| + } |
| +} |
| + |
| + |
| +void LogGeneratedCodeCoverage(const char* file_line) { |
| + const char* return_address = (&file_line)[-1]; |
|
Christian Plesner Hansen
2009/04/21 11:47:32
Maybe check or assert that coverage_log is set?
|
| + char* push_insn = const_cast<char*>(return_address - 12); |
| + push_insn[0] = 0xeb; // Relative branch insn. |
| + push_insn[1] = 13; // Skip over coverage insns. |
| + fprintf(coverage_log, "%s\n", file_line); |
| + fflush(coverage_log); |
| +} |
| + |
| + |
| +byte* ia32_coverage_function = |
|
Christian Plesner Hansen
2009/04/21 11:47:32
As discussed, there must be a way to make this nas
|
| + reinterpret_cast<byte*>(FUNCTION_ADDR(LogGeneratedCodeCoverage)); |
| +#endif |
| + |
| } } // namespace v8::internal |