| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 void Assembler::GetCode(CodeDesc* desc) { | 330 void Assembler::GetCode(CodeDesc* desc) { |
| 331 // finalize code | 331 // finalize code |
| 332 // (at this point overflow() may be true, but the gap ensures that | 332 // (at this point overflow() may be true, but the gap ensures that |
| 333 // we are still not overlapping instructions and relocation info) | 333 // we are still not overlapping instructions and relocation info) |
| 334 ASSERT(pc_ <= reloc_info_writer.pos()); // no overlap | 334 ASSERT(pc_ <= reloc_info_writer.pos()); // no overlap |
| 335 // setup desc | 335 // setup desc |
| 336 desc->buffer = buffer_; | 336 desc->buffer = buffer_; |
| 337 desc->buffer_size = buffer_size_; | 337 desc->buffer_size = buffer_size_; |
| 338 desc->instr_size = pc_offset(); | 338 desc->instr_size = pc_offset(); |
| 339 ASSERT(desc->instr_size > 0); // Zero-size code objects upset the system. | 339 ASSERT(desc->instr_size > 0); // Zero-size code objects upset the system. |
| 340 desc->reloc_size = (buffer_ + buffer_size_) - reloc_info_writer.pos(); | 340 desc->reloc_size = |
| 341 static_cast<int>((buffer_ + buffer_size_) - reloc_info_writer.pos()); |
| 341 desc->origin = this; | 342 desc->origin = this; |
| 342 | 343 |
| 343 Counters::reloc_info_size.Increment(desc->reloc_size); | 344 Counters::reloc_info_size.Increment(desc->reloc_size); |
| 344 } | 345 } |
| 345 | 346 |
| 346 | 347 |
| 347 void Assembler::Align(int m) { | 348 void Assembler::Align(int m) { |
| 348 ASSERT(IsPowerOf2(m)); | 349 ASSERT(IsPowerOf2(m)); |
| 349 while ((pc_offset() & (m - 1)) != 0) { | 350 while ((pc_offset() & (m - 1)) != 0) { |
| 350 nop(); | 351 nop(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 // Some internal data structures overflow for very large buffers, | 394 // Some internal data structures overflow for very large buffers, |
| 394 // they must ensure that kMaximalBufferSize is not too large. | 395 // they must ensure that kMaximalBufferSize is not too large. |
| 395 if ((desc.buffer_size > kMaximalBufferSize) || | 396 if ((desc.buffer_size > kMaximalBufferSize) || |
| 396 (desc.buffer_size > Heap::MaxOldGenerationSize())) { | 397 (desc.buffer_size > Heap::MaxOldGenerationSize())) { |
| 397 V8::FatalProcessOutOfMemory("Assembler::GrowBuffer"); | 398 V8::FatalProcessOutOfMemory("Assembler::GrowBuffer"); |
| 398 } | 399 } |
| 399 | 400 |
| 400 // setup new buffer | 401 // setup new buffer |
| 401 desc.buffer = NewArray<byte>(desc.buffer_size); | 402 desc.buffer = NewArray<byte>(desc.buffer_size); |
| 402 desc.instr_size = pc_offset(); | 403 desc.instr_size = pc_offset(); |
| 403 desc.reloc_size = (buffer_ + buffer_size_) - (reloc_info_writer.pos()); | 404 desc.reloc_size = |
| 405 static_cast<int>((buffer_ + buffer_size_) - (reloc_info_writer.pos())); |
| 404 | 406 |
| 405 // Clear the buffer in debug mode. Use 'int3' instructions to make | 407 // Clear the buffer in debug mode. Use 'int3' instructions to make |
| 406 // sure to get into problems if we ever run uninitialized code. | 408 // sure to get into problems if we ever run uninitialized code. |
| 407 #ifdef DEBUG | 409 #ifdef DEBUG |
| 408 memset(desc.buffer, 0xCC, desc.buffer_size); | 410 memset(desc.buffer, 0xCC, desc.buffer_size); |
| 409 #endif | 411 #endif |
| 410 | 412 |
| 411 // copy the data | 413 // copy the data |
| 412 intptr_t pc_delta = desc.buffer - buffer_; | 414 intptr_t pc_delta = desc.buffer - buffer_; |
| 413 intptr_t rc_delta = (desc.buffer + desc.buffer_size) - | 415 intptr_t rc_delta = (desc.buffer + desc.buffer_size) - |
| (...skipping 2105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2519 written_position_ = current_position_; | 2521 written_position_ = current_position_; |
| 2520 } | 2522 } |
| 2521 } | 2523 } |
| 2522 | 2524 |
| 2523 | 2525 |
| 2524 const int RelocInfo::kApplyMask = RelocInfo::kCodeTargetMask | | 2526 const int RelocInfo::kApplyMask = RelocInfo::kCodeTargetMask | |
| 2525 1 << RelocInfo::INTERNAL_REFERENCE | | 2527 1 << RelocInfo::INTERNAL_REFERENCE | |
| 2526 1 << RelocInfo::JS_RETURN; | 2528 1 << RelocInfo::JS_RETURN; |
| 2527 | 2529 |
| 2528 } } // namespace v8::internal | 2530 } } // namespace v8::internal |
| OLD | NEW |