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

Side by Side Diff: src/mips/simulator-mips.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, 4 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/ia32/assembler-ia32.cc ('k') | src/mips64/simulator-mips64.cc » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <limits.h> 5 #include <limits.h>
6 #include <stdarg.h> 6 #include <stdarg.h>
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "src/v8.h" 10 #include "src/v8.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 MipsDebugger::~MipsDebugger() { 86 MipsDebugger::~MipsDebugger() {
87 } 87 }
88 88
89 89
90 #ifdef GENERATED_CODE_COVERAGE 90 #ifdef GENERATED_CODE_COVERAGE
91 static FILE* coverage_log = NULL; 91 static FILE* coverage_log = NULL;
92 92
93 93
94 static void InitializeCoverage() { 94 static void InitializeCoverage() {
95 char* file_name = getenv("V8_GENERATED_CODE_COVERAGE_LOG"); 95 char* file_name = getenv("V8_GENERATED_CODE_COVERAGE_LOG");
96 if (file_name != NULL) { 96 if (file_name != NULL && NULL == coverage_log) {
97 coverage_log = fopen(file_name, "aw+"); 97 coverage_log = fopen(file_name, "aw+");
98 } 98 }
99 } 99 }
100 100
101 static void DeinitCoverageLog() {
102 if (coverage_log != NULL) {
103 fclose(coverage_log);
104 coverage_log = NULL;
105 }
106 }
101 107
102 void MipsDebugger::Stop(Instruction* instr) { 108 void MipsDebugger::Stop(Instruction* instr) {
103 // Get the stop code. 109 // Get the stop code.
104 uint32_t code = instr->Bits(25, 6); 110 uint32_t code = instr->Bits(25, 6);
105 // Retrieve the encoded address, which comes just after this stop. 111 // Retrieve the encoded address, which comes just after this stop.
106 char** msg_address = 112 char** msg_address =
107 reinterpret_cast<char**>(sim_->get_pc() + Instr::kInstrSize); 113 reinterpret_cast<char**>(sim_->get_pc() + Instr::kInstrSize);
108 char* msg = *msg_address; 114 char* msg = *msg_address;
109 ASSERT(msg != NULL); 115 ASSERT(msg != NULL);
110 116
(...skipping 13 matching lines...) Expand all
124 } 130 }
125 sim_->set_pc(sim_->get_pc() + 2 * Instruction::kInstructionSize); 131 sim_->set_pc(sim_->get_pc() + 2 * Instruction::kInstructionSize);
126 } 132 }
127 133
128 134
129 #else // GENERATED_CODE_COVERAGE 135 #else // GENERATED_CODE_COVERAGE
130 136
131 #define UNSUPPORTED() printf("Unsupported instruction.\n"); 137 #define UNSUPPORTED() printf("Unsupported instruction.\n");
132 138
133 static void InitializeCoverage() {} 139 static void InitializeCoverage() {}
140 static void DeinitCoverageLog() {}
134 141
135 142
136 void MipsDebugger::Stop(Instruction* instr) { 143 void MipsDebugger::Stop(Instruction* instr) {
137 // Get the stop code. 144 // Get the stop code.
138 uint32_t code = instr->Bits(25, 6); 145 uint32_t code = instr->Bits(25, 6);
139 // Retrieve the encoded address, which comes just after this stop. 146 // Retrieve the encoded address, which comes just after this stop.
140 char* msg = *reinterpret_cast<char**>(sim_->get_pc() + 147 char* msg = *reinterpret_cast<char**>(sim_->get_pc() +
141 Instruction::kInstrSize); 148 Instruction::kInstrSize);
142 // Update this stop description. 149 // Update this stop description.
143 if (!sim_->watched_stops_[code].desc) { 150 if (!sim_->watched_stops_[code].desc) {
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 InitializeCoverage(); 903 InitializeCoverage();
897 for (int i = 0; i < kNumExceptions; i++) { 904 for (int i = 0; i < kNumExceptions; i++) {
898 exceptions[i] = 0; 905 exceptions[i] = 0;
899 } 906 }
900 907
901 last_debugger_input_ = NULL; 908 last_debugger_input_ = NULL;
902 } 909 }
903 910
904 911
905 Simulator::~Simulator() { 912 Simulator::~Simulator() {
913 DeinitCoverageLog();
906 } 914 }
907 915
908 916
909 // When the generated code calls an external reference we need to catch that in 917 // When the generated code calls an external reference we need to catch that in
910 // the simulator. The external reference will be a function compiled for the 918 // the simulator. The external reference will be a function compiled for the
911 // host architecture. We need to call that function instead of trying to 919 // host architecture. We need to call that function instead of trying to
912 // execute it with the simulator. We do that by redirecting the external 920 // execute it with the simulator. We do that by redirecting the external
913 // reference to a swi (software-interrupt) instruction that is handled by 921 // reference to a swi (software-interrupt) instruction that is handled by
914 // the simulator. We write the original destination of the jump just at a known 922 // the simulator. We write the original destination of the jump just at a known
915 // offset from the swi instruction so the simulator knows what to call. 923 // offset from the swi instruction so the simulator knows what to call.
(...skipping 2002 matching lines...) Expand 10 before | Expand all | Expand 10 after
2918 } 2926 }
2919 2927
2920 2928
2921 #undef UNSUPPORTED 2929 #undef UNSUPPORTED
2922 2930
2923 } } // namespace v8::internal 2931 } } // namespace v8::internal
2924 2932
2925 #endif // USE_SIMULATOR 2933 #endif // USE_SIMULATOR
2926 2934
2927 #endif // V8_TARGET_ARCH_MIPS 2935 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/ia32/assembler-ia32.cc ('k') | src/mips64/simulator-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698