OLD | NEW |
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 2479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2490 } | 2490 } |
2491 } | 2491 } |
2492 | 2492 |
2493 | 2493 |
2494 void Assembler::GrowBuffer() { | 2494 void Assembler::GrowBuffer() { |
2495 DCHECK(buffer_overflow()); | 2495 DCHECK(buffer_overflow()); |
2496 if (!own_buffer_) FATAL("external code buffer is too small"); | 2496 if (!own_buffer_) FATAL("external code buffer is too small"); |
2497 | 2497 |
2498 // Compute new buffer size. | 2498 // Compute new buffer size. |
2499 CodeDesc desc; // the new buffer | 2499 CodeDesc desc; // the new buffer |
2500 if (buffer_size_ < 4*KB) { | 2500 if (buffer_size_ == 0) { |
2501 desc.buffer_size = 4*KB; | 2501 desc.buffer_size = kMinimalBufferSize; |
2502 } else { | 2502 } else { |
2503 desc.buffer_size = 2*buffer_size_; | 2503 desc.buffer_size = 2*buffer_size_; |
2504 } | 2504 } |
2505 // Some internal data structures overflow for very large buffers, | 2505 // Some internal data structures overflow for very large buffers, |
2506 // they must ensure that kMaximalBufferSize is not too large. | 2506 // they must ensure that kMaximalBufferSize is not too large. |
2507 if ((desc.buffer_size > kMaximalBufferSize) || | 2507 if ((desc.buffer_size > kMaximalBufferSize) || |
2508 (desc.buffer_size > isolate()->heap()->MaxOldGenerationSize())) { | 2508 (desc.buffer_size > isolate()->heap()->MaxOldGenerationSize())) { |
2509 V8::FatalProcessOutOfMemory("Assembler::GrowBuffer"); | 2509 V8::FatalProcessOutOfMemory("Assembler::GrowBuffer"); |
2510 } | 2510 } |
2511 | 2511 |
2512 // Set up new buffer. | 2512 // Set up new buffer. |
2513 desc.buffer = NewArray<byte>(desc.buffer_size); | 2513 desc.buffer = NewArray<byte>(desc.buffer_size); |
2514 desc.instr_size = pc_offset(); | 2514 desc.instr_size = pc_offset(); |
2515 desc.reloc_size = (buffer_ + buffer_size_) - (reloc_info_writer.pos()); | 2515 desc.reloc_size = (buffer_ + buffer_size_) - (reloc_info_writer.pos()); |
2516 | 2516 |
2517 // Clear the buffer in debug mode. Use 'int3' instructions to make | 2517 // Clear the buffer in debug mode. Use 'int3' instructions to make |
2518 // sure to get into problems if we ever run uninitialized code. | 2518 // sure to get into problems if we ever run uninitialized code. |
2519 #ifdef DEBUG | 2519 #ifdef DEBUG |
2520 memset(desc.buffer, 0xCC, desc.buffer_size); | 2520 memset(desc.buffer, 0xCC, desc.buffer_size); |
2521 #endif | 2521 #endif |
2522 | 2522 |
2523 // Copy the data. | 2523 // Copy the data. |
2524 int pc_delta = desc.buffer - buffer_; | 2524 int pc_delta = desc.buffer - buffer_; |
2525 int rc_delta = (desc.buffer + desc.buffer_size) - (buffer_ + buffer_size_); | 2525 int rc_delta = (desc.buffer + desc.buffer_size) - (buffer_ + buffer_size_); |
2526 MemMove(desc.buffer, buffer_, desc.instr_size); | 2526 MemMove(desc.buffer, buffer_, desc.instr_size); |
2527 MemMove(rc_delta + reloc_info_writer.pos(), reloc_info_writer.pos(), | 2527 MemMove(rc_delta + reloc_info_writer.pos(), reloc_info_writer.pos(), |
2528 desc.reloc_size); | 2528 desc.reloc_size); |
2529 | 2529 |
2530 // Switch buffers. | 2530 DeleteArray(buffer_); |
2531 if (isolate()->assembler_spare_buffer() == NULL && | |
2532 buffer_size_ == kMinimalBufferSize) { | |
2533 isolate()->set_assembler_spare_buffer(buffer_); | |
2534 } else { | |
2535 DeleteArray(buffer_); | |
2536 } | |
2537 buffer_ = desc.buffer; | 2531 buffer_ = desc.buffer; |
2538 buffer_size_ = desc.buffer_size; | 2532 buffer_size_ = desc.buffer_size; |
2539 pc_ += pc_delta; | 2533 pc_ += pc_delta; |
2540 reloc_info_writer.Reposition(reloc_info_writer.pos() + rc_delta, | 2534 reloc_info_writer.Reposition(reloc_info_writer.pos() + rc_delta, |
2541 reloc_info_writer.last_pc() + pc_delta); | 2535 reloc_info_writer.last_pc() + pc_delta); |
2542 | 2536 |
2543 // Relocate runtime entries. | 2537 // Relocate runtime entries. |
2544 for (RelocIterator it(desc); !it.done(); it.next()) { | 2538 for (RelocIterator it(desc); !it.done(); it.next()) { |
2545 RelocInfo::Mode rmode = it.rinfo()->rmode(); | 2539 RelocInfo::Mode rmode = it.rinfo()->rmode(); |
2546 if (rmode == RelocInfo::INTERNAL_REFERENCE) { | 2540 if (rmode == RelocInfo::INTERNAL_REFERENCE) { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2670 fprintf(coverage_log, "%s\n", file_line); | 2664 fprintf(coverage_log, "%s\n", file_line); |
2671 fflush(coverage_log); | 2665 fflush(coverage_log); |
2672 } | 2666 } |
2673 } | 2667 } |
2674 | 2668 |
2675 #endif | 2669 #endif |
2676 | 2670 |
2677 } } // namespace v8::internal | 2671 } } // namespace v8::internal |
2678 | 2672 |
2679 #endif // V8_TARGET_ARCH_IA32 | 2673 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |