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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 // use externally provided buffer instead | 312 // use externally provided buffer instead |
313 ASSERT(buffer_size > 0); | 313 ASSERT(buffer_size > 0); |
314 buffer_ = static_cast<byte*>(buffer); | 314 buffer_ = static_cast<byte*>(buffer); |
315 buffer_size_ = buffer_size; | 315 buffer_size_ = buffer_size; |
316 own_buffer_ = false; | 316 own_buffer_ = false; |
317 } | 317 } |
318 | 318 |
319 // Clear the buffer in debug mode unless it was provided by the | 319 // Clear the buffer in debug mode unless it was provided by the |
320 // caller in which case we can't be sure it's okay to overwrite | 320 // caller in which case we can't be sure it's okay to overwrite |
321 // existing code in it; see CodePatcher::CodePatcher(...). | 321 // existing code in it; see CodePatcher::CodePatcher(...). |
322 if (kDebug && own_buffer_) { | 322 #ifdef DEBUG |
| 323 if (own_buffer_) { |
323 memset(buffer_, 0xCC, buffer_size); // int3 | 324 memset(buffer_, 0xCC, buffer_size); // int3 |
324 } | 325 } |
| 326 #endif |
325 | 327 |
326 // setup buffer pointers | 328 // setup buffer pointers |
327 ASSERT(buffer_ != NULL); | 329 ASSERT(buffer_ != NULL); |
328 pc_ = buffer_; | 330 pc_ = buffer_; |
329 reloc_info_writer.Reposition(buffer_ + buffer_size, pc_); | 331 reloc_info_writer.Reposition(buffer_ + buffer_size, pc_); |
330 | 332 |
331 last_pc_ = NULL; | 333 last_pc_ = NULL; |
332 current_statement_position_ = RelocInfo::kNoPosition; | 334 current_statement_position_ = RelocInfo::kNoPosition; |
333 current_position_ = RelocInfo::kNoPosition; | 335 current_position_ = RelocInfo::kNoPosition; |
334 written_statement_position_ = current_statement_position_; | 336 written_statement_position_ = current_statement_position_; |
(...skipping 1738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2073 V8::FatalProcessOutOfMemory("Assembler::GrowBuffer"); | 2075 V8::FatalProcessOutOfMemory("Assembler::GrowBuffer"); |
2074 } | 2076 } |
2075 | 2077 |
2076 // setup new buffer | 2078 // setup new buffer |
2077 desc.buffer = NewArray<byte>(desc.buffer_size); | 2079 desc.buffer = NewArray<byte>(desc.buffer_size); |
2078 desc.instr_size = pc_offset(); | 2080 desc.instr_size = pc_offset(); |
2079 desc.reloc_size = (buffer_ + buffer_size_) - (reloc_info_writer.pos()); | 2081 desc.reloc_size = (buffer_ + buffer_size_) - (reloc_info_writer.pos()); |
2080 | 2082 |
2081 // Clear the buffer in debug mode. Use 'int3' instructions to make | 2083 // Clear the buffer in debug mode. Use 'int3' instructions to make |
2082 // sure to get into problems if we ever run uninitialized code. | 2084 // sure to get into problems if we ever run uninitialized code. |
2083 if (kDebug) { | 2085 #ifdef DEBUG |
2084 memset(desc.buffer, 0xCC, desc.buffer_size); | 2086 memset(desc.buffer, 0xCC, desc.buffer_size); |
2085 } | 2087 #endif |
2086 | 2088 |
2087 // copy the data | 2089 // copy the data |
2088 int pc_delta = desc.buffer - buffer_; | 2090 int pc_delta = desc.buffer - buffer_; |
2089 int rc_delta = (desc.buffer + desc.buffer_size) - (buffer_ + buffer_size_); | 2091 int rc_delta = (desc.buffer + desc.buffer_size) - (buffer_ + buffer_size_); |
2090 memmove(desc.buffer, buffer_, desc.instr_size); | 2092 memmove(desc.buffer, buffer_, desc.instr_size); |
2091 memmove(rc_delta + reloc_info_writer.pos(), | 2093 memmove(rc_delta + reloc_info_writer.pos(), |
2092 reloc_info_writer.pos(), desc.reloc_size); | 2094 reloc_info_writer.pos(), desc.reloc_size); |
2093 | 2095 |
2094 // switch buffers | 2096 // switch buffers |
2095 if (spare_buffer_ == NULL && buffer_size_ == kMinimalBufferSize) { | 2097 if (spare_buffer_ == NULL && buffer_size_ == kMinimalBufferSize) { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2229 push_insn[1] = 13; // Skip over coverage insns. | 2231 push_insn[1] = 13; // Skip over coverage insns. |
2230 if (coverage_log != NULL) { | 2232 if (coverage_log != NULL) { |
2231 fprintf(coverage_log, "%s\n", file_line); | 2233 fprintf(coverage_log, "%s\n", file_line); |
2232 fflush(coverage_log); | 2234 fflush(coverage_log); |
2233 } | 2235 } |
2234 } | 2236 } |
2235 | 2237 |
2236 #endif | 2238 #endif |
2237 | 2239 |
2238 } } // namespace v8::internal | 2240 } } // namespace v8::internal |
OLD | NEW |