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 are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // 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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 // TODO(vitalyr): the assembler does not need an isolate. | 505 // TODO(vitalyr): the assembler does not need an isolate. |
506 Assembler(Isolate* isolate, void* buffer, int buffer_size); | 506 Assembler(Isolate* isolate, void* buffer, int buffer_size); |
507 virtual ~Assembler() { } | 507 virtual ~Assembler() { } |
508 | 508 |
509 // GetCode emits any pending (non-emitted) code and fills the descriptor | 509 // GetCode emits any pending (non-emitted) code and fills the descriptor |
510 // desc. GetCode() is idempotent; it returns the same result if no other | 510 // desc. GetCode() is idempotent; it returns the same result if no other |
511 // Assembler functions are invoked in between GetCode() calls. | 511 // Assembler functions are invoked in between GetCode() calls. |
512 void GetCode(CodeDesc* desc); | 512 void GetCode(CodeDesc* desc); |
513 | 513 |
514 // Read/Modify the code target in the branch/call instruction at pc. | 514 // Read/Modify the code target in the branch/call instruction at pc. |
515 inline static Address target_address_at(Address pc, | 515 inline static Address target_address_at(Address pc, Address constant_pool); |
516 ConstantPoolArray* constant_pool); | 516 inline static void set_target_address_at( |
517 inline static void set_target_address_at(Address pc, | 517 Address pc, Address constant_pool, Address target, |
518 ConstantPoolArray* constant_pool, | 518 ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); |
519 Address target, | |
520 ICacheFlushMode icache_flush_mode = | |
521 FLUSH_ICACHE_IF_NEEDED); | |
522 static inline Address target_address_at(Address pc, Code* code) { | 519 static inline Address target_address_at(Address pc, Code* code) { |
523 ConstantPoolArray* constant_pool = code ? code->constant_pool() : NULL; | 520 Address constant_pool = code ? code->constant_pool() : NULL; |
524 return target_address_at(pc, constant_pool); | 521 return target_address_at(pc, constant_pool); |
525 } | 522 } |
526 static inline void set_target_address_at(Address pc, | 523 static inline void set_target_address_at(Address pc, |
527 Code* code, | 524 Code* code, |
528 Address target, | 525 Address target, |
529 ICacheFlushMode icache_flush_mode = | 526 ICacheFlushMode icache_flush_mode = |
530 FLUSH_ICACHE_IF_NEEDED) { | 527 FLUSH_ICACHE_IF_NEEDED) { |
531 ConstantPoolArray* constant_pool = code ? code->constant_pool() : NULL; | 528 Address constant_pool = code ? code->constant_pool() : NULL; |
532 set_target_address_at(pc, constant_pool, target); | 529 set_target_address_at(pc, constant_pool, target); |
533 } | 530 } |
534 | 531 |
535 // Return the code target address at a call site from the return address | 532 // Return the code target address at a call site from the return address |
536 // of that call in the instruction stream. | 533 // of that call in the instruction stream. |
537 inline static Address target_address_from_return_address(Address pc); | 534 inline static Address target_address_from_return_address(Address pc); |
538 | 535 |
539 // Return the code target address of the patch debug break slot | 536 // Return the code target address of the patch debug break slot |
540 inline static Address break_address_from_return_address(Address pc); | 537 inline static Address break_address_from_return_address(Address pc); |
541 | 538 |
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1444 void RecordComment(const char* msg); | 1441 void RecordComment(const char* msg); |
1445 | 1442 |
1446 // Record a deoptimization reason that can be used by a log or cpu profiler. | 1443 // Record a deoptimization reason that can be used by a log or cpu profiler. |
1447 // Use --trace-deopt to enable. | 1444 // Use --trace-deopt to enable. |
1448 void RecordDeoptReason(const int reason, const SourcePosition position); | 1445 void RecordDeoptReason(const int reason, const SourcePosition position); |
1449 | 1446 |
1450 // Writes a single byte or word of data in the code stream. Used for | 1447 // Writes a single byte or word of data in the code stream. Used for |
1451 // inline tables, e.g., jump-tables. | 1448 // inline tables, e.g., jump-tables. |
1452 void db(uint8_t data); | 1449 void db(uint8_t data); |
1453 void dd(uint32_t data); | 1450 void dd(uint32_t data); |
| 1451 void dq(uint64_t data); |
| 1452 void dp(uintptr_t data) { dd(data); } |
1454 void dd(Label* label); | 1453 void dd(Label* label); |
1455 | 1454 |
1456 // Check if there is less than kGap bytes available in the buffer. | 1455 // Check if there is less than kGap bytes available in the buffer. |
1457 // If this is the case, we need to grow the buffer before emitting | 1456 // If this is the case, we need to grow the buffer before emitting |
1458 // an instruction or relocation information. | 1457 // an instruction or relocation information. |
1459 inline bool buffer_overflow() const { | 1458 inline bool buffer_overflow() const { |
1460 return pc_ >= reloc_info_writer.pos() - kGap; | 1459 return pc_ >= reloc_info_writer.pos() - kGap; |
1461 } | 1460 } |
1462 | 1461 |
1463 // Get the number of bytes available in the buffer. | 1462 // Get the number of bytes available in the buffer. |
1464 inline int available_space() const { return reloc_info_writer.pos() - pc_; } | 1463 inline int available_space() const { return reloc_info_writer.pos() - pc_; } |
1465 | 1464 |
1466 static bool IsNop(Address addr); | 1465 static bool IsNop(Address addr); |
1467 | 1466 |
1468 PositionsRecorder* positions_recorder() { return &positions_recorder_; } | 1467 PositionsRecorder* positions_recorder() { return &positions_recorder_; } |
1469 | 1468 |
1470 int relocation_writer_size() { | 1469 int relocation_writer_size() { |
1471 return (buffer_ + buffer_size_) - reloc_info_writer.pos(); | 1470 return (buffer_ + buffer_size_) - reloc_info_writer.pos(); |
1472 } | 1471 } |
1473 | 1472 |
1474 // Avoid overflows for displacements etc. | 1473 // Avoid overflows for displacements etc. |
1475 static const int kMaximalBufferSize = 512*MB; | 1474 static const int kMaximalBufferSize = 512*MB; |
1476 | 1475 |
1477 byte byte_at(int pos) { return buffer_[pos]; } | 1476 byte byte_at(int pos) { return buffer_[pos]; } |
1478 void set_byte_at(int pos, byte value) { buffer_[pos] = value; } | 1477 void set_byte_at(int pos, byte value) { buffer_[pos] = value; } |
1479 | 1478 |
1480 // Allocate a constant pool of the correct size for the generated code. | 1479 void PatchConstantPoolAccessInstruction(int pc_offset, int offset, |
1481 Handle<ConstantPoolArray> NewConstantPool(Isolate* isolate); | 1480 ConstantPoolEntry::Access access, |
1482 | 1481 ConstantPoolEntry::Type type) { |
1483 // Generate the constant pool for the generated code. | 1482 // No embedded constant pool support. |
1484 void PopulateConstantPool(ConstantPoolArray* constant_pool); | 1483 UNREACHABLE(); |
| 1484 } |
1485 | 1485 |
1486 protected: | 1486 protected: |
1487 void emit_sse_operand(XMMRegister reg, const Operand& adr); | 1487 void emit_sse_operand(XMMRegister reg, const Operand& adr); |
1488 void emit_sse_operand(XMMRegister dst, XMMRegister src); | 1488 void emit_sse_operand(XMMRegister dst, XMMRegister src); |
1489 void emit_sse_operand(Register dst, XMMRegister src); | 1489 void emit_sse_operand(Register dst, XMMRegister src); |
1490 void emit_sse_operand(XMMRegister dst, Register src); | 1490 void emit_sse_operand(XMMRegister dst, Register src); |
1491 | 1491 |
1492 byte* addr_at(int pos) { return buffer_ + pos; } | 1492 byte* addr_at(int pos) { return buffer_ + pos; } |
1493 | 1493 |
1494 | 1494 |
(...skipping 10 matching lines...) Expand all Loading... |
1505 inline void emit(uint32_t x); | 1505 inline void emit(uint32_t x); |
1506 inline void emit(Handle<Object> handle); | 1506 inline void emit(Handle<Object> handle); |
1507 inline void emit(uint32_t x, | 1507 inline void emit(uint32_t x, |
1508 RelocInfo::Mode rmode, | 1508 RelocInfo::Mode rmode, |
1509 TypeFeedbackId id = TypeFeedbackId::None()); | 1509 TypeFeedbackId id = TypeFeedbackId::None()); |
1510 inline void emit(Handle<Code> code, | 1510 inline void emit(Handle<Code> code, |
1511 RelocInfo::Mode rmode, | 1511 RelocInfo::Mode rmode, |
1512 TypeFeedbackId id = TypeFeedbackId::None()); | 1512 TypeFeedbackId id = TypeFeedbackId::None()); |
1513 inline void emit(const Immediate& x); | 1513 inline void emit(const Immediate& x); |
1514 inline void emit_w(const Immediate& x); | 1514 inline void emit_w(const Immediate& x); |
| 1515 inline void emit_q(uint64_t x); |
1515 | 1516 |
1516 // Emit the code-object-relative offset of the label's position | 1517 // Emit the code-object-relative offset of the label's position |
1517 inline void emit_code_relative_offset(Label* label); | 1518 inline void emit_code_relative_offset(Label* label); |
1518 | 1519 |
1519 // instruction generation | 1520 // instruction generation |
1520 void emit_arith_b(int op1, int op2, Register dst, int imm8); | 1521 void emit_arith_b(int op1, int op2, Register dst, int imm8); |
1521 | 1522 |
1522 // Emit a basic arithmetic instruction (i.e. first byte of the family is 0x81) | 1523 // Emit a basic arithmetic instruction (i.e. first byte of the family is 0x81) |
1523 // with a given destination expression and an immediate operand. It attempts | 1524 // with a given destination expression and an immediate operand. It attempts |
1524 // to use the shortest encoding possible. | 1525 // to use the shortest encoding possible. |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1598 private: | 1599 private: |
1599 Assembler* assembler_; | 1600 Assembler* assembler_; |
1600 #ifdef DEBUG | 1601 #ifdef DEBUG |
1601 int space_before_; | 1602 int space_before_; |
1602 #endif | 1603 #endif |
1603 }; | 1604 }; |
1604 | 1605 |
1605 } } // namespace v8::internal | 1606 } } // namespace v8::internal |
1606 | 1607 |
1607 #endif // V8_IA32_ASSEMBLER_IA32_H_ | 1608 #endif // V8_IA32_ASSEMBLER_IA32_H_ |
OLD | NEW |