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

Side by Side Diff: src/assembler-ia32.cc

Issue 88025: * Add code to check coverage of generated code on IA32 port.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/builtins-ia32.cc » ('j') | src/codegen-ia32.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. 1 // Copyright (c) 1994-2006 Sun Microsystems Inc.
2 // All Rights Reserved. 2 // All Rights Reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions 5 // modification, are permitted provided that the following conditions
6 // are met: 6 // are met:
7 // 7 //
8 // - Redistributions of source code must retain the above copyright notice, 8 // - Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer. 9 // this list of conditions and the following disclaimer.
10 // 10 //
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 } 276 }
277 277
278 // ----------------------------------------------------------------------------- 278 // -----------------------------------------------------------------------------
279 // Implementation of Assembler 279 // Implementation of Assembler
280 280
281 // Emit a single byte. Must always be inlined. 281 // Emit a single byte. Must always be inlined.
282 #define EMIT(x) \ 282 #define EMIT(x) \
283 *pc_++ = (x) 283 *pc_++ = (x)
284 284
285 285
286 #ifdef GENERATED_CODE_COVERAGE
287 static void InitCoverageLog();
288 #endif
289
286 // spare_buffer_ 290 // spare_buffer_
287 static byte* spare_buffer_ = NULL; 291 static byte* spare_buffer_ = NULL;
288 292
289 Assembler::Assembler(void* buffer, int buffer_size) { 293 Assembler::Assembler(void* buffer, int buffer_size) {
290 if (buffer == NULL) { 294 if (buffer == NULL) {
291 // do our own buffer management 295 // do our own buffer management
292 if (buffer_size <= kMinimalBufferSize) { 296 if (buffer_size <= kMinimalBufferSize) {
293 buffer_size = kMinimalBufferSize; 297 buffer_size = kMinimalBufferSize;
294 298
295 if (spare_buffer_ != NULL) { 299 if (spare_buffer_ != NULL) {
(...skipping 26 matching lines...) Expand all
322 // setup buffer pointers 326 // setup buffer pointers
323 ASSERT(buffer_ != NULL); 327 ASSERT(buffer_ != NULL);
324 pc_ = buffer_; 328 pc_ = buffer_;
325 reloc_info_writer.Reposition(buffer_ + buffer_size, pc_); 329 reloc_info_writer.Reposition(buffer_ + buffer_size, pc_);
326 330
327 last_pc_ = NULL; 331 last_pc_ = NULL;
328 current_statement_position_ = RelocInfo::kNoPosition; 332 current_statement_position_ = RelocInfo::kNoPosition;
329 current_position_ = RelocInfo::kNoPosition; 333 current_position_ = RelocInfo::kNoPosition;
330 written_statement_position_ = current_statement_position_; 334 written_statement_position_ = current_statement_position_;
331 written_position_ = current_position_; 335 written_position_ = current_position_;
336 #ifdef GENERATED_CODE_COVERAGE
337 InitCoverageLog();
338 #endif
332 } 339 }
333 340
334 341
335 Assembler::~Assembler() { 342 Assembler::~Assembler() {
336 if (own_buffer_) { 343 if (own_buffer_) {
337 if (spare_buffer_ == NULL && buffer_size_ == kMinimalBufferSize) { 344 if (spare_buffer_ == NULL && buffer_size_ == kMinimalBufferSize) {
338 spare_buffer_ = buffer_; 345 spare_buffer_ = buffer_;
339 } else { 346 } else {
340 DeleteArray(buffer_); 347 DeleteArray(buffer_);
341 } 348 }
(...skipping 1853 matching lines...) Expand 10 before | Expand all | Expand 10 after
2195 void Assembler::WriteInternalReference(int position, const Label& bound_label) { 2202 void Assembler::WriteInternalReference(int position, const Label& bound_label) {
2196 ASSERT(bound_label.is_bound()); 2203 ASSERT(bound_label.is_bound());
2197 ASSERT(0 <= position); 2204 ASSERT(0 <= position);
2198 ASSERT(position + static_cast<int>(sizeof(uint32_t)) <= pc_offset()); 2205 ASSERT(position + static_cast<int>(sizeof(uint32_t)) <= pc_offset());
2199 ASSERT(long_at(position) == 0); // only initialize once! 2206 ASSERT(long_at(position) == 0); // only initialize once!
2200 2207
2201 uint32_t label_loc = reinterpret_cast<uint32_t>(addr_at(bound_label.pos())); 2208 uint32_t label_loc = reinterpret_cast<uint32_t>(addr_at(bound_label.pos()));
2202 long_at_put(position, label_loc); 2209 long_at_put(position, label_loc);
2203 } 2210 }
2204 2211
2212
2213 #ifdef GENERATED_CODE_COVERAGE
2214 static FILE* coverage_log = NULL;
2215
2216
2217 static void InitCoverageLog() {
2218 char* file_name = getenv("V8_GENERATED_CODE_COVERAGE_LOG");
2219 if (file_name != NULL) {
2220 coverage_log = fopen(file_name, "aw+");
2221 }
2222 }
2223
2224
2225 void LogGeneratedCodeCoverage(const char* file_line) {
2226 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?
2227 char* push_insn = const_cast<char*>(return_address - 12);
2228 push_insn[0] = 0xeb; // Relative branch insn.
2229 push_insn[1] = 13; // Skip over coverage insns.
2230 fprintf(coverage_log, "%s\n", file_line);
2231 fflush(coverage_log);
2232 }
2233
2234
2235 byte* ia32_coverage_function =
Christian Plesner Hansen 2009/04/21 11:47:32 As discussed, there must be a way to make this nas
2236 reinterpret_cast<byte*>(FUNCTION_ADDR(LogGeneratedCodeCoverage));
2237 #endif
2238
2205 } } // namespace v8::internal 2239 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/builtins-ia32.cc » ('j') | src/codegen-ia32.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698