| 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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 // register r is not encoded. | 322 // register r is not encoded. |
| 323 static const Instr kPopRegPattern = | 323 static const Instr kPopRegPattern = |
| 324 al | B26 | L | 4 | PostIndex | sp.code() * B16; | 324 al | B26 | L | 4 | PostIndex | sp.code() * B16; |
| 325 // mov lr, pc | 325 // mov lr, pc |
| 326 const Instr kMovLrPc = al | 13*B21 | pc.code() | lr.code() * B12; | 326 const Instr kMovLrPc = al | 13*B21 | pc.code() | lr.code() * B12; |
| 327 // ldr pc, [pc, #XXX] | 327 // ldr pc, [pc, #XXX] |
| 328 const Instr kLdrPCPattern = al | B26 | L | pc.code() * B16; | 328 const Instr kLdrPCPattern = al | B26 | L | pc.code() * B16; |
| 329 | 329 |
| 330 // spare_buffer_ | 330 // spare_buffer_ |
| 331 static const int kMinimalBufferSize = 4*KB; | 331 static const int kMinimalBufferSize = 4*KB; |
| 332 static byte* spare_buffer_ = NULL; | 332 class AssemblerData:public BasicAssemblerData { |
| 333 public: |
| 334 // A previously allocated buffer of kMinimalBufferSize bytes, or NULL. |
| 335 byte* spare_buffer_; |
| 336 private: |
| 337 AssemblerData() :spare_buffer_(NULL) {} |
| 338 ~AssemblerData() { delete spare_buffer_; } |
| 339 friend class Assembler; |
| 340 DISALLOW_COPY_AND_ASSIGN(AssemblerData); |
| 341 }; |
| 333 | 342 |
| 334 Assembler::Assembler(void* buffer, int buffer_size) { | 343 Assembler::Assembler(void* buffer, int buffer_size) { |
| 335 if (buffer == NULL) { | 344 if (buffer == NULL) { |
| 336 // do our own buffer management | 345 // do our own buffer management |
| 337 if (buffer_size <= kMinimalBufferSize) { | 346 if (buffer_size <= kMinimalBufferSize) { |
| 338 buffer_size = kMinimalBufferSize; | 347 buffer_size = kMinimalBufferSize; |
| 339 | 348 AssemblerData* const data = v8_context()->assembler_data_; |
| 340 if (spare_buffer_ != NULL) { | 349 if (data->spare_buffer_ != NULL) { |
| 341 buffer = spare_buffer_; | 350 buffer = data->spare_buffer_; |
| 342 spare_buffer_ = NULL; | 351 data->spare_buffer_ = NULL; |
| 343 } | 352 } |
| 344 } | 353 } |
| 345 if (buffer == NULL) { | 354 if (buffer == NULL) { |
| 346 buffer_ = NewArray<byte>(buffer_size); | 355 buffer_ = NewArray<byte>(buffer_size); |
| 347 } else { | 356 } else { |
| 348 buffer_ = static_cast<byte*>(buffer); | 357 buffer_ = static_cast<byte*>(buffer); |
| 349 } | 358 } |
| 350 buffer_size_ = buffer_size; | 359 buffer_size_ = buffer_size; |
| 351 own_buffer_ = true; | 360 own_buffer_ = true; |
| 352 | 361 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 369 last_bound_pos_ = 0; | 378 last_bound_pos_ = 0; |
| 370 current_statement_position_ = RelocInfo::kNoPosition; | 379 current_statement_position_ = RelocInfo::kNoPosition; |
| 371 current_position_ = RelocInfo::kNoPosition; | 380 current_position_ = RelocInfo::kNoPosition; |
| 372 written_statement_position_ = current_statement_position_; | 381 written_statement_position_ = current_statement_position_; |
| 373 written_position_ = current_position_; | 382 written_position_ = current_position_; |
| 374 } | 383 } |
| 375 | 384 |
| 376 | 385 |
| 377 Assembler::~Assembler() { | 386 Assembler::~Assembler() { |
| 378 if (own_buffer_) { | 387 if (own_buffer_) { |
| 379 if (spare_buffer_ == NULL && buffer_size_ == kMinimalBufferSize) { | 388 AssemblerData* const data = v8_context()->assembler_data_; |
| 380 spare_buffer_ = buffer_; | 389 if (data->spare_buffer_ == NULL && buffer_size_ == kMinimalBufferSize) { |
| 390 data->spare_buffer_ = buffer_; |
| 381 } else { | 391 } else { |
| 382 DeleteArray(buffer_); | 392 DeleteArray(buffer_); |
| 383 } | 393 } |
| 384 } | 394 } |
| 385 } | 395 } |
| 386 | 396 |
| 387 | 397 |
| 388 void Assembler::GetCode(CodeDesc* desc) { | 398 void Assembler::GetCode(CodeDesc* desc) { |
| 389 // emit constant pool if necessary | 399 // emit constant pool if necessary |
| 390 CheckConstPool(true, false); | 400 CheckConstPool(true, false); |
| (...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1820 | 1830 |
| 1821 if (after_pool.is_linked()) { | 1831 if (after_pool.is_linked()) { |
| 1822 bind(&after_pool); | 1832 bind(&after_pool); |
| 1823 } | 1833 } |
| 1824 | 1834 |
| 1825 // Since a constant pool was just emitted, move the check offset forward by | 1835 // Since a constant pool was just emitted, move the check offset forward by |
| 1826 // the standard interval. | 1836 // the standard interval. |
| 1827 next_buffer_check_ = pc_offset() + kCheckConstInterval; | 1837 next_buffer_check_ = pc_offset() + kCheckConstInterval; |
| 1828 } | 1838 } |
| 1829 | 1839 |
| 1840 void Assembler::PostConstruct() { |
| 1841 v8_context()->assembler_data_ = new AssemblerData(); |
| 1842 } |
| 1843 |
| 1844 void Assembler::PreDestroy() { |
| 1845 delete v8_context()->assembler_data_; |
| 1846 } |
| 1830 | 1847 |
| 1831 } } // namespace v8::internal | 1848 } } // namespace v8::internal |
| OLD | NEW |