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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 // Emit a single byte. Must always be inlined. | 209 // Emit a single byte. Must always be inlined. |
210 #define EMIT(x) \ | 210 #define EMIT(x) \ |
211 *pc_++ = (x) | 211 *pc_++ = (x) |
212 | 212 |
213 | 213 |
214 #ifdef GENERATED_CODE_COVERAGE | 214 #ifdef GENERATED_CODE_COVERAGE |
215 static void InitCoverageLog(); | 215 static void InitCoverageLog(); |
216 #endif | 216 #endif |
217 | 217 |
218 Assembler::Assembler(Isolate* isolate, void* buffer, int buffer_size) | 218 Assembler::Assembler(Isolate* isolate, void* buffer, int buffer_size) |
219 : AssemblerBase(isolate, buffer, buffer_size), | 219 : AssemblerBase(isolate, buffer, buffer_size) { |
220 positions_recorder_(this) { | 220 // Clear the buffer in debug mode unless it was provided by the |
221 // Clear the buffer in debug mode unless it was provided by the | 221 // caller in which case we can't be sure it's okay to overwrite |
222 // caller in which case we can't be sure it's okay to overwrite | 222 // existing code in it; see CodePatcher::CodePatcher(...). |
223 // existing code in it; see CodePatcher::CodePatcher(...). | |
224 #ifdef DEBUG | 223 #ifdef DEBUG |
225 if (own_buffer_) { | 224 if (own_buffer_) { |
226 memset(buffer_, 0xCC, buffer_size_); // int3 | 225 memset(buffer_, 0xCC, buffer_size_); // int3 |
227 } | 226 } |
228 #endif | 227 #endif |
229 | 228 |
230 reloc_info_writer.Reposition(buffer_ + buffer_size_, pc_); | 229 reloc_info_writer.Reposition(buffer_ + buffer_size_, pc_); |
231 | 230 |
232 #ifdef GENERATED_CODE_COVERAGE | 231 #ifdef GENERATED_CODE_COVERAGE |
233 InitCoverageLog(); | 232 InitCoverageLog(); |
234 #endif | 233 #endif |
235 } | 234 } |
236 | 235 |
237 | 236 |
238 void Assembler::GetCode(CodeDesc* desc) { | 237 void Assembler::GetCode(CodeDesc* desc) { |
239 // Finalize code (at this point overflow() may be true, but the gap ensures | 238 // Finalize code (at this point overflow() may be true, but the gap ensures |
240 // that we are still not overlapping instructions and relocation info). | 239 // that we are still not overlapping instructions and relocation info). |
241 reloc_info_writer.Finish(); | |
242 DCHECK(pc_ <= reloc_info_writer.pos()); // No overlap. | 240 DCHECK(pc_ <= reloc_info_writer.pos()); // No overlap. |
243 // Set up code descriptor. | 241 // Set up code descriptor. |
244 desc->buffer = buffer_; | 242 desc->buffer = buffer_; |
245 desc->buffer_size = buffer_size_; | 243 desc->buffer_size = buffer_size_; |
246 desc->instr_size = pc_offset(); | 244 desc->instr_size = pc_offset(); |
247 desc->reloc_size = (buffer_ + buffer_size_) - reloc_info_writer.pos(); | 245 desc->reloc_size = (buffer_ + buffer_size_) - reloc_info_writer.pos(); |
248 desc->origin = this; | 246 desc->origin = this; |
249 desc->constant_pool_size = 0; | 247 desc->constant_pool_size = 0; |
250 desc->unwinding_info_size = 0; | 248 desc->unwinding_info_size = 0; |
251 desc->unwinding_info = nullptr; | 249 desc->unwinding_info = nullptr; |
(...skipping 1981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2233 fflush(coverage_log); | 2231 fflush(coverage_log); |
2234 } | 2232 } |
2235 } | 2233 } |
2236 | 2234 |
2237 #endif | 2235 #endif |
2238 | 2236 |
2239 } // namespace internal | 2237 } // namespace internal |
2240 } // namespace v8 | 2238 } // namespace v8 |
2241 | 2239 |
2242 #endif // V8_TARGET_ARCH_X87 | 2240 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |