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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 | 343 |
344 // Clear the buffer in debug mode unless it was provided by the | 344 // Clear the buffer in debug mode unless it was provided by the |
345 // caller in which case we can't be sure it's okay to overwrite | 345 // caller in which case we can't be sure it's okay to overwrite |
346 // existing code in it; see CodePatcher::CodePatcher(...). | 346 // existing code in it; see CodePatcher::CodePatcher(...). |
347 #ifdef DEBUG | 347 #ifdef DEBUG |
348 if (own_buffer_) { | 348 if (own_buffer_) { |
349 memset(buffer_, 0xCC, buffer_size); // int3 | 349 memset(buffer_, 0xCC, buffer_size); // int3 |
350 } | 350 } |
351 #endif | 351 #endif |
352 | 352 |
353 // Setup buffer pointers. | 353 // Set up buffer pointers. |
354 ASSERT(buffer_ != NULL); | 354 ASSERT(buffer_ != NULL); |
355 pc_ = buffer_; | 355 pc_ = buffer_; |
356 reloc_info_writer.Reposition(buffer_ + buffer_size, pc_); | 356 reloc_info_writer.Reposition(buffer_ + buffer_size, pc_); |
357 | 357 |
358 #ifdef GENERATED_CODE_COVERAGE | 358 #ifdef GENERATED_CODE_COVERAGE |
359 InitCoverageLog(); | 359 InitCoverageLog(); |
360 #endif | 360 #endif |
361 } | 361 } |
362 | 362 |
363 | 363 |
364 Assembler::~Assembler() { | 364 Assembler::~Assembler() { |
365 if (own_buffer_) { | 365 if (own_buffer_) { |
366 if (isolate()->assembler_spare_buffer() == NULL && | 366 if (isolate()->assembler_spare_buffer() == NULL && |
367 buffer_size_ == kMinimalBufferSize) { | 367 buffer_size_ == kMinimalBufferSize) { |
368 isolate()->set_assembler_spare_buffer(buffer_); | 368 isolate()->set_assembler_spare_buffer(buffer_); |
369 } else { | 369 } else { |
370 DeleteArray(buffer_); | 370 DeleteArray(buffer_); |
371 } | 371 } |
372 } | 372 } |
373 } | 373 } |
374 | 374 |
375 | 375 |
376 void Assembler::GetCode(CodeDesc* desc) { | 376 void Assembler::GetCode(CodeDesc* desc) { |
377 // Finalize code (at this point overflow() may be true, but the gap ensures | 377 // Finalize code (at this point overflow() may be true, but the gap ensures |
378 // that we are still not overlapping instructions and relocation info). | 378 // that we are still not overlapping instructions and relocation info). |
379 ASSERT(pc_ <= reloc_info_writer.pos()); // No overlap. | 379 ASSERT(pc_ <= reloc_info_writer.pos()); // No overlap. |
380 // Setup code descriptor. | 380 // Set up code descriptor. |
381 desc->buffer = buffer_; | 381 desc->buffer = buffer_; |
382 desc->buffer_size = buffer_size_; | 382 desc->buffer_size = buffer_size_; |
383 desc->instr_size = pc_offset(); | 383 desc->instr_size = pc_offset(); |
384 desc->reloc_size = (buffer_ + buffer_size_) - reloc_info_writer.pos(); | 384 desc->reloc_size = (buffer_ + buffer_size_) - reloc_info_writer.pos(); |
385 desc->origin = this; | 385 desc->origin = this; |
386 } | 386 } |
387 | 387 |
388 | 388 |
389 void Assembler::Align(int m) { | 389 void Assembler::Align(int m) { |
390 ASSERT(IsPowerOf2(m)); | 390 ASSERT(IsPowerOf2(m)); |
(...skipping 2059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2450 } else { | 2450 } else { |
2451 desc.buffer_size = 2*buffer_size_; | 2451 desc.buffer_size = 2*buffer_size_; |
2452 } | 2452 } |
2453 // Some internal data structures overflow for very large buffers, | 2453 // Some internal data structures overflow for very large buffers, |
2454 // they must ensure that kMaximalBufferSize is not too large. | 2454 // they must ensure that kMaximalBufferSize is not too large. |
2455 if ((desc.buffer_size > kMaximalBufferSize) || | 2455 if ((desc.buffer_size > kMaximalBufferSize) || |
2456 (desc.buffer_size > isolate()->heap()->MaxOldGenerationSize())) { | 2456 (desc.buffer_size > isolate()->heap()->MaxOldGenerationSize())) { |
2457 V8::FatalProcessOutOfMemory("Assembler::GrowBuffer"); | 2457 V8::FatalProcessOutOfMemory("Assembler::GrowBuffer"); |
2458 } | 2458 } |
2459 | 2459 |
2460 // Setup new buffer. | 2460 // Set up new buffer. |
2461 desc.buffer = NewArray<byte>(desc.buffer_size); | 2461 desc.buffer = NewArray<byte>(desc.buffer_size); |
2462 desc.instr_size = pc_offset(); | 2462 desc.instr_size = pc_offset(); |
2463 desc.reloc_size = (buffer_ + buffer_size_) - (reloc_info_writer.pos()); | 2463 desc.reloc_size = (buffer_ + buffer_size_) - (reloc_info_writer.pos()); |
2464 | 2464 |
2465 // Clear the buffer in debug mode. Use 'int3' instructions to make | 2465 // Clear the buffer in debug mode. Use 'int3' instructions to make |
2466 // sure to get into problems if we ever run uninitialized code. | 2466 // sure to get into problems if we ever run uninitialized code. |
2467 #ifdef DEBUG | 2467 #ifdef DEBUG |
2468 memset(desc.buffer, 0xCC, desc.buffer_size); | 2468 memset(desc.buffer, 0xCC, desc.buffer_size); |
2469 #endif | 2469 #endif |
2470 | 2470 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2613 fprintf(coverage_log, "%s\n", file_line); | 2613 fprintf(coverage_log, "%s\n", file_line); |
2614 fflush(coverage_log); | 2614 fflush(coverage_log); |
2615 } | 2615 } |
2616 } | 2616 } |
2617 | 2617 |
2618 #endif | 2618 #endif |
2619 | 2619 |
2620 } } // namespace v8::internal | 2620 } } // namespace v8::internal |
2621 | 2621 |
2622 #endif // V8_TARGET_ARCH_IA32 | 2622 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |