OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 | 376 |
377 // Clear the buffer in debug mode unless it was provided by the | 377 // Clear the buffer in debug mode unless it was provided by the |
378 // caller in which case we can't be sure it's okay to overwrite | 378 // caller in which case we can't be sure it's okay to overwrite |
379 // existing code in it. | 379 // existing code in it. |
380 #ifdef DEBUG | 380 #ifdef DEBUG |
381 if (own_buffer_) { | 381 if (own_buffer_) { |
382 memset(buffer_, 0xCC, buffer_size); // int3 | 382 memset(buffer_, 0xCC, buffer_size); // int3 |
383 } | 383 } |
384 #endif | 384 #endif |
385 | 385 |
386 // Setup buffer pointers. | 386 // Set up buffer pointers. |
387 ASSERT(buffer_ != NULL); | 387 ASSERT(buffer_ != NULL); |
388 pc_ = buffer_; | 388 pc_ = buffer_; |
389 reloc_info_writer.Reposition(buffer_ + buffer_size, pc_); | 389 reloc_info_writer.Reposition(buffer_ + buffer_size, pc_); |
390 | 390 |
391 | 391 |
392 #ifdef GENERATED_CODE_COVERAGE | 392 #ifdef GENERATED_CODE_COVERAGE |
393 InitCoverageLog(); | 393 InitCoverageLog(); |
394 #endif | 394 #endif |
395 } | 395 } |
396 | 396 |
397 | 397 |
398 Assembler::~Assembler() { | 398 Assembler::~Assembler() { |
399 if (own_buffer_) { | 399 if (own_buffer_) { |
400 if (isolate() != NULL && | 400 if (isolate() != NULL && |
401 isolate()->assembler_spare_buffer() == NULL && | 401 isolate()->assembler_spare_buffer() == NULL && |
402 buffer_size_ == kMinimalBufferSize) { | 402 buffer_size_ == kMinimalBufferSize) { |
403 isolate()->set_assembler_spare_buffer(buffer_); | 403 isolate()->set_assembler_spare_buffer(buffer_); |
404 } else { | 404 } else { |
405 DeleteArray(buffer_); | 405 DeleteArray(buffer_); |
406 } | 406 } |
407 } | 407 } |
408 } | 408 } |
409 | 409 |
410 | 410 |
411 void Assembler::GetCode(CodeDesc* desc) { | 411 void Assembler::GetCode(CodeDesc* desc) { |
412 // Finalize code (at this point overflow() may be true, but the gap ensures | 412 // Finalize code (at this point overflow() may be true, but the gap ensures |
413 // that we are still not overlapping instructions and relocation info). | 413 // that we are still not overlapping instructions and relocation info). |
414 ASSERT(pc_ <= reloc_info_writer.pos()); // No overlap. | 414 ASSERT(pc_ <= reloc_info_writer.pos()); // No overlap. |
415 // Setup code descriptor. | 415 // Set up code descriptor. |
416 desc->buffer = buffer_; | 416 desc->buffer = buffer_; |
417 desc->buffer_size = buffer_size_; | 417 desc->buffer_size = buffer_size_; |
418 desc->instr_size = pc_offset(); | 418 desc->instr_size = pc_offset(); |
419 ASSERT(desc->instr_size > 0); // Zero-size code objects upset the system. | 419 ASSERT(desc->instr_size > 0); // Zero-size code objects upset the system. |
420 desc->reloc_size = | 420 desc->reloc_size = |
421 static_cast<int>((buffer_ + buffer_size_) - reloc_info_writer.pos()); | 421 static_cast<int>((buffer_ + buffer_size_) - reloc_info_writer.pos()); |
422 desc->origin = this; | 422 desc->origin = this; |
423 } | 423 } |
424 | 424 |
425 | 425 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 } else { | 495 } else { |
496 desc.buffer_size = 2*buffer_size_; | 496 desc.buffer_size = 2*buffer_size_; |
497 } | 497 } |
498 // Some internal data structures overflow for very large buffers, | 498 // Some internal data structures overflow for very large buffers, |
499 // they must ensure that kMaximalBufferSize is not too large. | 499 // they must ensure that kMaximalBufferSize is not too large. |
500 if ((desc.buffer_size > kMaximalBufferSize) || | 500 if ((desc.buffer_size > kMaximalBufferSize) || |
501 (desc.buffer_size > HEAP->MaxOldGenerationSize())) { | 501 (desc.buffer_size > HEAP->MaxOldGenerationSize())) { |
502 V8::FatalProcessOutOfMemory("Assembler::GrowBuffer"); | 502 V8::FatalProcessOutOfMemory("Assembler::GrowBuffer"); |
503 } | 503 } |
504 | 504 |
505 // Setup new buffer. | 505 // Set up new buffer. |
506 desc.buffer = NewArray<byte>(desc.buffer_size); | 506 desc.buffer = NewArray<byte>(desc.buffer_size); |
507 desc.instr_size = pc_offset(); | 507 desc.instr_size = pc_offset(); |
508 desc.reloc_size = | 508 desc.reloc_size = |
509 static_cast<int>((buffer_ + buffer_size_) - (reloc_info_writer.pos())); | 509 static_cast<int>((buffer_ + buffer_size_) - (reloc_info_writer.pos())); |
510 | 510 |
511 // Clear the buffer in debug mode. Use 'int3' instructions to make | 511 // Clear the buffer in debug mode. Use 'int3' instructions to make |
512 // sure to get into problems if we ever run uninitialized code. | 512 // sure to get into problems if we ever run uninitialized code. |
513 #ifdef DEBUG | 513 #ifdef DEBUG |
514 memset(desc.buffer, 0xCC, desc.buffer_size); | 514 memset(desc.buffer, 0xCC, desc.buffer_size); |
515 #endif | 515 #endif |
(...skipping 2525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3041 // specially coded on x64 means that it is a relative 32 bit address, as used | 3041 // specially coded on x64 means that it is a relative 32 bit address, as used |
3042 // by branch instructions. | 3042 // by branch instructions. |
3043 return (1 << rmode_) & kApplyMask; | 3043 return (1 << rmode_) & kApplyMask; |
3044 } | 3044 } |
3045 | 3045 |
3046 | 3046 |
3047 | 3047 |
3048 } } // namespace v8::internal | 3048 } } // namespace v8::internal |
3049 | 3049 |
3050 #endif // V8_TARGET_ARCH_X64 | 3050 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |