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

Unified Diff: src/x64/assembler-x64.cc

Issue 419343003: when open macro GENERATED_CODE_COVERAGE, fix compiler error and fd leak (Closed) Base URL: https://github.com/v8/v8.git@master
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/x64/assembler-x64.h ('k') | src/x87/assembler-x87.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/x64/assembler-x64.cc
diff --git a/src/x64/assembler-x64.cc b/src/x64/assembler-x64.cc
index 6d3750e3109c95426b9af2ef64116902765c274b..58491688ef074cfe3aa80cf74a66941d1a75ed28 100644
--- a/src/x64/assembler-x64.cc
+++ b/src/x64/assembler-x64.cc
@@ -225,6 +225,7 @@ bool Operand::AddressUsesRegister(Register reg) const {
#ifdef GENERATED_CODE_COVERAGE
static void InitCoverageLog();
+static void DeinitCoverageLog();
#endif
Assembler::Assembler(Isolate* isolate, void* buffer, int buffer_size)
@@ -248,6 +249,11 @@ Assembler::Assembler(Isolate* isolate, void* buffer, int buffer_size)
#endif
}
+Assembler::~Assembler() {
+#ifdef GENERATED_CODE_COVERAGE
+ DeinitCoverageLog();
+#endif
+}
void Assembler::GetCode(CodeDesc* desc) {
// Finalize code (at this point overflow() may be true, but the gap ensures
@@ -2971,6 +2977,36 @@ bool RelocInfo::IsInConstantPool() {
return false;
}
+#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 && NULL == coverage_log) {
+ coverage_log = fopen(file_name, "aw+");
+ }
+}
+
+static void DeinitCoverageLog() {
+ if (coverage_log != NULL) {
+ fclose(coverage_log);
+ coverage_log = NULL;
+ }
+}
+
+void LogGeneratedCodeCoverage(const char* file_line) {
+ const char* return_address = (&file_line)[-1];
+ char* push_insn = const_cast<char*>(return_address - 12);
+ push_insn[0] = 0xeb; // Relative branch insn.
+ push_insn[1] = 13; // Skip over coverage insns.
+ if (coverage_log != NULL) {
+ fprintf(coverage_log, "%s\n", file_line);
+ fflush(coverage_log);
+ }
+}
+
+#endif
} } // namespace v8::internal
« no previous file with comments | « src/x64/assembler-x64.h ('k') | src/x87/assembler-x87.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698