OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/x64/assembler-x64.h" | 5 #include "src/x64/assembler-x64.h" |
6 | 6 |
7 #include <cstring> | 7 #include <cstring> |
8 | 8 |
9 #if V8_TARGET_ARCH_X64 | 9 #if V8_TARGET_ARCH_X64 |
10 | 10 |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 | 278 |
279 | 279 |
280 // ----------------------------------------------------------------------------- | 280 // ----------------------------------------------------------------------------- |
281 // Implementation of Assembler. | 281 // Implementation of Assembler. |
282 | 282 |
283 #ifdef GENERATED_CODE_COVERAGE | 283 #ifdef GENERATED_CODE_COVERAGE |
284 static void InitCoverageLog(); | 284 static void InitCoverageLog(); |
285 #endif | 285 #endif |
286 | 286 |
287 Assembler::Assembler(Isolate* isolate, void* buffer, int buffer_size) | 287 Assembler::Assembler(Isolate* isolate, void* buffer, int buffer_size) |
288 : AssemblerBase(isolate, buffer, buffer_size), | 288 : AssemblerBase(isolate, buffer, buffer_size), code_targets_(100) { |
289 code_targets_(100), | 289 // Clear the buffer in debug mode unless it was provided by the |
290 positions_recorder_(this) { | 290 // caller in which case we can't be sure it's okay to overwrite |
291 // Clear the buffer in debug mode unless it was provided by the | 291 // existing code in it. |
292 // caller in which case we can't be sure it's okay to overwrite | |
293 // existing code in it. | |
294 #ifdef DEBUG | 292 #ifdef DEBUG |
295 if (own_buffer_) { | 293 if (own_buffer_) { |
296 memset(buffer_, 0xCC, buffer_size_); // int3 | 294 memset(buffer_, 0xCC, buffer_size_); // int3 |
297 } | 295 } |
298 #endif | 296 #endif |
299 | 297 |
300 reloc_info_writer.Reposition(buffer_ + buffer_size_, pc_); | 298 reloc_info_writer.Reposition(buffer_ + buffer_size_, pc_); |
301 | 299 |
302 | 300 |
303 #ifdef GENERATED_CODE_COVERAGE | 301 #ifdef GENERATED_CODE_COVERAGE |
304 InitCoverageLog(); | 302 InitCoverageLog(); |
305 #endif | 303 #endif |
306 } | 304 } |
307 | 305 |
308 | 306 |
309 void Assembler::GetCode(CodeDesc* desc) { | 307 void Assembler::GetCode(CodeDesc* desc) { |
310 // Finalize code (at this point overflow() may be true, but the gap ensures | 308 // Finalize code (at this point overflow() may be true, but the gap ensures |
311 // that we are still not overlapping instructions and relocation info). | 309 // that we are still not overlapping instructions and relocation info). |
312 reloc_info_writer.Finish(); | |
313 DCHECK(pc_ <= reloc_info_writer.pos()); // No overlap. | 310 DCHECK(pc_ <= reloc_info_writer.pos()); // No overlap. |
314 // Set up code descriptor. | 311 // Set up code descriptor. |
315 desc->buffer = buffer_; | 312 desc->buffer = buffer_; |
316 desc->buffer_size = buffer_size_; | 313 desc->buffer_size = buffer_size_; |
317 desc->instr_size = pc_offset(); | 314 desc->instr_size = pc_offset(); |
318 DCHECK(desc->instr_size > 0); // Zero-size code objects upset the system. | 315 DCHECK(desc->instr_size > 0); // Zero-size code objects upset the system. |
319 desc->reloc_size = | 316 desc->reloc_size = |
320 static_cast<int>((buffer_ + buffer_size_) - reloc_info_writer.pos()); | 317 static_cast<int>((buffer_ + buffer_size_) - reloc_info_writer.pos()); |
321 desc->origin = this; | 318 desc->origin = this; |
322 desc->constant_pool_size = 0; | 319 desc->constant_pool_size = 0; |
(...skipping 4246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4569 | 4566 |
4570 bool RelocInfo::IsInConstantPool() { | 4567 bool RelocInfo::IsInConstantPool() { |
4571 return false; | 4568 return false; |
4572 } | 4569 } |
4573 | 4570 |
4574 | 4571 |
4575 } // namespace internal | 4572 } // namespace internal |
4576 } // namespace v8 | 4573 } // namespace v8 |
4577 | 4574 |
4578 #endif // V8_TARGET_ARCH_X64 | 4575 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |