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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
8 | 8 |
9 #include "src/macro-assembler.h" | 9 #include "src/macro-assembler.h" |
10 #include "src/serialize.h" | 10 #include "src/serialize.h" |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 bind_to(L, pc_offset()); | 324 bind_to(L, pc_offset()); |
325 } | 325 } |
326 | 326 |
327 | 327 |
328 void Assembler::GrowBuffer() { | 328 void Assembler::GrowBuffer() { |
329 DCHECK(buffer_overflow()); | 329 DCHECK(buffer_overflow()); |
330 if (!own_buffer_) FATAL("external code buffer is too small"); | 330 if (!own_buffer_) FATAL("external code buffer is too small"); |
331 | 331 |
332 // Compute new buffer size. | 332 // Compute new buffer size. |
333 CodeDesc desc; // the new buffer | 333 CodeDesc desc; // the new buffer |
334 if (buffer_size_ < 4*KB) { | 334 if (buffer_size_ == 0) { |
335 desc.buffer_size = 4*KB; | 335 desc.buffer_size = kMinimalBufferSize; |
336 } else { | 336 } else { |
337 desc.buffer_size = 2*buffer_size_; | 337 desc.buffer_size = 2*buffer_size_; |
338 } | 338 } |
339 // Some internal data structures overflow for very large buffers, | 339 // Some internal data structures overflow for very large buffers, |
340 // they must ensure that kMaximalBufferSize is not too large. | 340 // they must ensure that kMaximalBufferSize is not too large. |
341 if ((desc.buffer_size > kMaximalBufferSize) || | 341 if ((desc.buffer_size > kMaximalBufferSize) || |
342 (desc.buffer_size > isolate()->heap()->MaxOldGenerationSize())) { | 342 (desc.buffer_size > isolate()->heap()->MaxOldGenerationSize())) { |
343 V8::FatalProcessOutOfMemory("Assembler::GrowBuffer"); | 343 V8::FatalProcessOutOfMemory("Assembler::GrowBuffer"); |
344 } | 344 } |
345 | 345 |
(...skipping 10 matching lines...) Expand all Loading... |
356 #endif | 356 #endif |
357 | 357 |
358 // Copy the data. | 358 // Copy the data. |
359 intptr_t pc_delta = desc.buffer - buffer_; | 359 intptr_t pc_delta = desc.buffer - buffer_; |
360 intptr_t rc_delta = (desc.buffer + desc.buffer_size) - | 360 intptr_t rc_delta = (desc.buffer + desc.buffer_size) - |
361 (buffer_ + buffer_size_); | 361 (buffer_ + buffer_size_); |
362 MemMove(desc.buffer, buffer_, desc.instr_size); | 362 MemMove(desc.buffer, buffer_, desc.instr_size); |
363 MemMove(rc_delta + reloc_info_writer.pos(), reloc_info_writer.pos(), | 363 MemMove(rc_delta + reloc_info_writer.pos(), reloc_info_writer.pos(), |
364 desc.reloc_size); | 364 desc.reloc_size); |
365 | 365 |
366 // Switch buffers. | 366 DeleteArray(buffer_); |
367 if (isolate() != NULL && | |
368 isolate()->assembler_spare_buffer() == NULL && | |
369 buffer_size_ == kMinimalBufferSize) { | |
370 isolate()->set_assembler_spare_buffer(buffer_); | |
371 } else { | |
372 DeleteArray(buffer_); | |
373 } | |
374 buffer_ = desc.buffer; | 367 buffer_ = desc.buffer; |
375 buffer_size_ = desc.buffer_size; | 368 buffer_size_ = desc.buffer_size; |
376 pc_ += pc_delta; | 369 pc_ += pc_delta; |
377 reloc_info_writer.Reposition(reloc_info_writer.pos() + rc_delta, | 370 reloc_info_writer.Reposition(reloc_info_writer.pos() + rc_delta, |
378 reloc_info_writer.last_pc() + pc_delta); | 371 reloc_info_writer.last_pc() + pc_delta); |
379 | 372 |
380 // Relocate runtime entries. | 373 // Relocate runtime entries. |
381 for (RelocIterator it(desc); !it.done(); it.next()) { | 374 for (RelocIterator it(desc); !it.done(); it.next()) { |
382 RelocInfo::Mode rmode = it.rinfo()->rmode(); | 375 RelocInfo::Mode rmode = it.rinfo()->rmode(); |
383 if (rmode == RelocInfo::INTERNAL_REFERENCE) { | 376 if (rmode == RelocInfo::INTERNAL_REFERENCE) { |
(...skipping 2611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2995 | 2988 |
2996 | 2989 |
2997 bool RelocInfo::IsInConstantPool() { | 2990 bool RelocInfo::IsInConstantPool() { |
2998 return false; | 2991 return false; |
2999 } | 2992 } |
3000 | 2993 |
3001 | 2994 |
3002 } } // namespace v8::internal | 2995 } } // namespace v8::internal |
3003 | 2996 |
3004 #endif // V8_TARGET_ARCH_X64 | 2997 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |