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

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

Issue 4469002: Improve positions recording for calls. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 10 years, 1 month 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
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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 *pc_++ = (x) 291 *pc_++ = (x)
292 292
293 293
294 #ifdef GENERATED_CODE_COVERAGE 294 #ifdef GENERATED_CODE_COVERAGE
295 static void InitCoverageLog(); 295 static void InitCoverageLog();
296 #endif 296 #endif
297 297
298 // Spare buffer. 298 // Spare buffer.
299 byte* Assembler::spare_buffer_ = NULL; 299 byte* Assembler::spare_buffer_ = NULL;
300 300
301 Assembler::Assembler(void* buffer, int buffer_size) { 301 Assembler::Assembler(void* buffer, int buffer_size)
302 : positions_recorder_(this) {
302 if (buffer == NULL) { 303 if (buffer == NULL) {
303 // Do our own buffer management. 304 // Do our own buffer management.
304 if (buffer_size <= kMinimalBufferSize) { 305 if (buffer_size <= kMinimalBufferSize) {
305 buffer_size = kMinimalBufferSize; 306 buffer_size = kMinimalBufferSize;
306 307
307 if (spare_buffer_ != NULL) { 308 if (spare_buffer_ != NULL) {
308 buffer = spare_buffer_; 309 buffer = spare_buffer_;
309 spare_buffer_ = NULL; 310 spare_buffer_ = NULL;
310 } 311 }
311 } 312 }
(...skipping 20 matching lines...) Expand all
332 memset(buffer_, 0xCC, buffer_size); // int3 333 memset(buffer_, 0xCC, buffer_size); // int3
333 } 334 }
334 #endif 335 #endif
335 336
336 // Setup buffer pointers. 337 // Setup buffer pointers.
337 ASSERT(buffer_ != NULL); 338 ASSERT(buffer_ != NULL);
338 pc_ = buffer_; 339 pc_ = buffer_;
339 reloc_info_writer.Reposition(buffer_ + buffer_size, pc_); 340 reloc_info_writer.Reposition(buffer_ + buffer_size, pc_);
340 341
341 last_pc_ = NULL; 342 last_pc_ = NULL;
342 current_statement_position_ = RelocInfo::kNoPosition;
343 current_position_ = RelocInfo::kNoPosition;
344 written_statement_position_ = current_statement_position_;
345 written_position_ = current_position_;
346 #ifdef GENERATED_CODE_COVERAGE 343 #ifdef GENERATED_CODE_COVERAGE
347 InitCoverageLog(); 344 InitCoverageLog();
348 #endif 345 #endif
349 } 346 }
350 347
351 348
352 Assembler::~Assembler() { 349 Assembler::~Assembler() {
353 if (own_buffer_) { 350 if (own_buffer_) {
354 if (spare_buffer_ == NULL && buffer_size_ == kMinimalBufferSize) { 351 if (spare_buffer_ == NULL && buffer_size_ == kMinimalBufferSize) {
355 spare_buffer_ = buffer_; 352 spare_buffer_ = buffer_;
(...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 1571
1575 void Assembler::call(const Operand& adr) { 1572 void Assembler::call(const Operand& adr) {
1576 EnsureSpace ensure_space(this); 1573 EnsureSpace ensure_space(this);
1577 last_pc_ = pc_; 1574 last_pc_ = pc_;
1578 EMIT(0xFF); 1575 EMIT(0xFF);
1579 emit_operand(edx, adr); 1576 emit_operand(edx, adr);
1580 } 1577 }
1581 1578
1582 1579
1583 void Assembler::call(Handle<Code> code, RelocInfo::Mode rmode) { 1580 void Assembler::call(Handle<Code> code, RelocInfo::Mode rmode) {
1584 WriteRecordedPositions(); 1581 positions_recorder()->WriteRecordedPositions();
1585 EnsureSpace ensure_space(this); 1582 EnsureSpace ensure_space(this);
1586 last_pc_ = pc_; 1583 last_pc_ = pc_;
1587 ASSERT(RelocInfo::IsCodeTarget(rmode)); 1584 ASSERT(RelocInfo::IsCodeTarget(rmode));
1588 EMIT(0xE8); 1585 EMIT(0xE8);
1589 emit(reinterpret_cast<intptr_t>(code.location()), rmode); 1586 emit(reinterpret_cast<intptr_t>(code.location()), rmode);
1590 } 1587 }
1591 1588
1592 1589
1593 void Assembler::jmp(Label* L) { 1590 void Assembler::jmp(Label* L) {
1594 EnsureSpace ensure_space(this); 1591 EnsureSpace ensure_space(this);
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
2457 EMIT(0xC0 | dst.code() << 3 | src.code()); 2454 EMIT(0xC0 | dst.code() << 3 | src.code());
2458 } 2455 }
2459 2456
2460 2457
2461 void Assembler::Print() { 2458 void Assembler::Print() {
2462 Disassembler::Decode(stdout, buffer_, pc_); 2459 Disassembler::Decode(stdout, buffer_, pc_);
2463 } 2460 }
2464 2461
2465 2462
2466 void Assembler::RecordJSReturn() { 2463 void Assembler::RecordJSReturn() {
2467 WriteRecordedPositions(); 2464 positions_recorder()->WriteRecordedPositions();
2468 EnsureSpace ensure_space(this); 2465 EnsureSpace ensure_space(this);
2469 RecordRelocInfo(RelocInfo::JS_RETURN); 2466 RecordRelocInfo(RelocInfo::JS_RETURN);
2470 } 2467 }
2471 2468
2472 2469
2473 void Assembler::RecordDebugBreakSlot() { 2470 void Assembler::RecordDebugBreakSlot() {
2474 WriteRecordedPositions(); 2471 positions_recorder()->WriteRecordedPositions();
2475 EnsureSpace ensure_space(this); 2472 EnsureSpace ensure_space(this);
2476 RecordRelocInfo(RelocInfo::DEBUG_BREAK_SLOT); 2473 RecordRelocInfo(RelocInfo::DEBUG_BREAK_SLOT);
2477 } 2474 }
2478 2475
2479 2476
2480 void Assembler::RecordComment(const char* msg) { 2477 void Assembler::RecordComment(const char* msg) {
2481 if (FLAG_debug_code) { 2478 if (FLAG_debug_code) {
2482 EnsureSpace ensure_space(this); 2479 EnsureSpace ensure_space(this);
2483 RecordRelocInfo(RelocInfo::COMMENT, reinterpret_cast<intptr_t>(msg)); 2480 RecordRelocInfo(RelocInfo::COMMENT, reinterpret_cast<intptr_t>(msg));
2484 } 2481 }
2485 } 2482 }
2486 2483
2487 2484
2488 void Assembler::RecordPosition(int pos) {
2489 ASSERT(pos != RelocInfo::kNoPosition);
2490 ASSERT(pos >= 0);
2491 current_position_ = pos;
2492 }
2493
2494
2495 void Assembler::RecordStatementPosition(int pos) {
2496 ASSERT(pos != RelocInfo::kNoPosition);
2497 ASSERT(pos >= 0);
2498 current_statement_position_ = pos;
2499 }
2500
2501
2502 bool Assembler::WriteRecordedPositions() {
2503 bool written = false;
2504
2505 // Write the statement position if it is different from what was written last
2506 // time.
2507 if (current_statement_position_ != written_statement_position_) {
2508 EnsureSpace ensure_space(this);
2509 RecordRelocInfo(RelocInfo::STATEMENT_POSITION, current_statement_position_);
2510 written_statement_position_ = current_statement_position_;
2511 written = true;
2512 }
2513
2514 // Write the position if it is different from what was written last time and
2515 // also different from the written statement position.
2516 if (current_position_ != written_position_ &&
2517 current_position_ != written_statement_position_) {
2518 EnsureSpace ensure_space(this);
2519 RecordRelocInfo(RelocInfo::POSITION, current_position_);
2520 written_position_ = current_position_;
2521 written = true;
2522 }
2523
2524 // Return whether something was written.
2525 return written;
2526 }
2527
2528
2529 void Assembler::GrowBuffer() { 2485 void Assembler::GrowBuffer() {
2530 ASSERT(overflow()); 2486 ASSERT(overflow());
2531 if (!own_buffer_) FATAL("external code buffer is too small"); 2487 if (!own_buffer_) FATAL("external code buffer is too small");
2532 2488
2533 // Compute new buffer size. 2489 // Compute new buffer size.
2534 CodeDesc desc; // the new buffer 2490 CodeDesc desc; // the new buffer
2535 if (buffer_size_ < 4*KB) { 2491 if (buffer_size_ < 4*KB) {
2536 desc.buffer_size = 4*KB; 2492 desc.buffer_size = 4*KB;
2537 } else { 2493 } else {
2538 desc.buffer_size = 2*buffer_size_; 2494 desc.buffer_size = 2*buffer_size_;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
2696 fprintf(coverage_log, "%s\n", file_line); 2652 fprintf(coverage_log, "%s\n", file_line);
2697 fflush(coverage_log); 2653 fflush(coverage_log);
2698 } 2654 }
2699 } 2655 }
2700 2656
2701 #endif 2657 #endif
2702 2658
2703 } } // namespace v8::internal 2659 } } // namespace v8::internal
2704 2660
2705 #endif // V8_TARGET_ARCH_IA32 2661 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« src/assembler.h ('K') | « src/ia32/assembler-ia32.h ('k') | src/ia32/codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698