| 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 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 // TODO(vitalyr): the assembler does not need an isolate. | 488 // TODO(vitalyr): the assembler does not need an isolate. |
| 489 Assembler(Isolate* isolate, void* buffer, int buffer_size); | 489 Assembler(Isolate* isolate, void* buffer, int buffer_size); |
| 490 virtual ~Assembler() { } | 490 virtual ~Assembler() { } |
| 491 | 491 |
| 492 // GetCode emits any pending (non-emitted) code and fills the descriptor | 492 // GetCode emits any pending (non-emitted) code and fills the descriptor |
| 493 // desc. GetCode() is idempotent; it returns the same result if no other | 493 // desc. GetCode() is idempotent; it returns the same result if no other |
| 494 // Assembler functions are invoked in between GetCode() calls. | 494 // Assembler functions are invoked in between GetCode() calls. |
| 495 void GetCode(CodeDesc* desc); | 495 void GetCode(CodeDesc* desc); |
| 496 | 496 |
| 497 // Read/Modify the code target in the branch/call instruction at pc. | 497 // Read/Modify the code target in the branch/call instruction at pc. |
| 498 inline static Address target_address_at(Address pc, Address constant_pool); | 498 inline static Address target_address_at(Address pc, |
| 499 inline static void set_target_address_at( | 499 ConstantPoolArray* constant_pool); |
| 500 Address pc, Address constant_pool, Address target, | 500 inline static void set_target_address_at(Address pc, |
| 501 ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); | 501 ConstantPoolArray* constant_pool, |
| 502 Address target, |
| 503 ICacheFlushMode icache_flush_mode = |
| 504 FLUSH_ICACHE_IF_NEEDED); |
| 502 static inline Address target_address_at(Address pc, Code* code) { | 505 static inline Address target_address_at(Address pc, Code* code) { |
| 503 Address constant_pool = code ? code->constant_pool() : NULL; | 506 ConstantPoolArray* constant_pool = code ? code->constant_pool() : NULL; |
| 504 return target_address_at(pc, constant_pool); | 507 return target_address_at(pc, constant_pool); |
| 505 } | 508 } |
| 506 static inline void set_target_address_at(Address pc, | 509 static inline void set_target_address_at(Address pc, |
| 507 Code* code, | 510 Code* code, |
| 508 Address target, | 511 Address target, |
| 509 ICacheFlushMode icache_flush_mode = | 512 ICacheFlushMode icache_flush_mode = |
| 510 FLUSH_ICACHE_IF_NEEDED) { | 513 FLUSH_ICACHE_IF_NEEDED) { |
| 511 Address constant_pool = code ? code->constant_pool() : NULL; | 514 ConstantPoolArray* constant_pool = code ? code->constant_pool() : NULL; |
| 512 set_target_address_at(pc, constant_pool, target); | 515 set_target_address_at(pc, constant_pool, target); |
| 513 } | 516 } |
| 514 | 517 |
| 515 // Return the code target address at a call site from the return address | 518 // Return the code target address at a call site from the return address |
| 516 // of that call in the instruction stream. | 519 // of that call in the instruction stream. |
| 517 inline static Address target_address_from_return_address(Address pc); | 520 inline static Address target_address_from_return_address(Address pc); |
| 518 | 521 |
| 519 // Return the code target address of the patch debug break slot | 522 // Return the code target address of the patch debug break slot |
| 520 inline static Address break_address_from_return_address(Address pc); | 523 inline static Address break_address_from_return_address(Address pc); |
| 521 | 524 |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 942 void RecordComment(const char* msg); | 945 void RecordComment(const char* msg); |
| 943 | 946 |
| 944 // Record a deoptimization reason that can be used by a log or cpu profiler. | 947 // Record a deoptimization reason that can be used by a log or cpu profiler. |
| 945 // Use --trace-deopt to enable. | 948 // Use --trace-deopt to enable. |
| 946 void RecordDeoptReason(const int reason, const SourcePosition position); | 949 void RecordDeoptReason(const int reason, const SourcePosition position); |
| 947 | 950 |
| 948 // Writes a single byte or word of data in the code stream. Used for | 951 // Writes a single byte or word of data in the code stream. Used for |
| 949 // inline tables, e.g., jump-tables. | 952 // inline tables, e.g., jump-tables. |
| 950 void db(uint8_t data); | 953 void db(uint8_t data); |
| 951 void dd(uint32_t data); | 954 void dd(uint32_t data); |
| 952 void dq(uint64_t data); | |
| 953 void dp(uintptr_t data) { dd(data); } | |
| 954 void dd(Label* label); | 955 void dd(Label* label); |
| 955 | 956 |
| 956 // Check if there is less than kGap bytes available in the buffer. | 957 // Check if there is less than kGap bytes available in the buffer. |
| 957 // If this is the case, we need to grow the buffer before emitting | 958 // If this is the case, we need to grow the buffer before emitting |
| 958 // an instruction or relocation information. | 959 // an instruction or relocation information. |
| 959 inline bool buffer_overflow() const { | 960 inline bool buffer_overflow() const { |
| 960 return pc_ >= reloc_info_writer.pos() - kGap; | 961 return pc_ >= reloc_info_writer.pos() - kGap; |
| 961 } | 962 } |
| 962 | 963 |
| 963 // Get the number of bytes available in the buffer. | 964 // Get the number of bytes available in the buffer. |
| 964 inline int available_space() const { return reloc_info_writer.pos() - pc_; } | 965 inline int available_space() const { return reloc_info_writer.pos() - pc_; } |
| 965 | 966 |
| 966 static bool IsNop(Address addr); | 967 static bool IsNop(Address addr); |
| 967 | 968 |
| 968 PositionsRecorder* positions_recorder() { return &positions_recorder_; } | 969 PositionsRecorder* positions_recorder() { return &positions_recorder_; } |
| 969 | 970 |
| 970 int relocation_writer_size() { | 971 int relocation_writer_size() { |
| 971 return (buffer_ + buffer_size_) - reloc_info_writer.pos(); | 972 return (buffer_ + buffer_size_) - reloc_info_writer.pos(); |
| 972 } | 973 } |
| 973 | 974 |
| 974 // Avoid overflows for displacements etc. | 975 // Avoid overflows for displacements etc. |
| 975 static const int kMaximalBufferSize = 512*MB; | 976 static const int kMaximalBufferSize = 512*MB; |
| 976 | 977 |
| 977 byte byte_at(int pos) { return buffer_[pos]; } | 978 byte byte_at(int pos) { return buffer_[pos]; } |
| 978 void set_byte_at(int pos, byte value) { buffer_[pos] = value; } | 979 void set_byte_at(int pos, byte value) { buffer_[pos] = value; } |
| 979 | 980 |
| 980 void PatchConstantPoolAccessInstruction(int pc_offset, int offset, | 981 // Allocate a constant pool of the correct size for the generated code. |
| 981 ConstantPoolEntry::Access access, | 982 Handle<ConstantPoolArray> NewConstantPool(Isolate* isolate); |
| 982 ConstantPoolEntry::Type type) { | 983 |
| 983 // No embedded constant pool support. | 984 // Generate the constant pool for the generated code. |
| 984 UNREACHABLE(); | 985 void PopulateConstantPool(ConstantPoolArray* constant_pool); |
| 985 } | |
| 986 | 986 |
| 987 protected: | 987 protected: |
| 988 byte* addr_at(int pos) { return buffer_ + pos; } | 988 byte* addr_at(int pos) { return buffer_ + pos; } |
| 989 | 989 |
| 990 | 990 |
| 991 private: | 991 private: |
| 992 uint32_t long_at(int pos) { | 992 uint32_t long_at(int pos) { |
| 993 return *reinterpret_cast<uint32_t*>(addr_at(pos)); | 993 return *reinterpret_cast<uint32_t*>(addr_at(pos)); |
| 994 } | 994 } |
| 995 void long_at_put(int pos, uint32_t x) { | 995 void long_at_put(int pos, uint32_t x) { |
| 996 *reinterpret_cast<uint32_t*>(addr_at(pos)) = x; | 996 *reinterpret_cast<uint32_t*>(addr_at(pos)) = x; |
| 997 } | 997 } |
| 998 | 998 |
| 999 // code emission | 999 // code emission |
| 1000 void GrowBuffer(); | 1000 void GrowBuffer(); |
| 1001 inline void emit(uint32_t x); | 1001 inline void emit(uint32_t x); |
| 1002 inline void emit(Handle<Object> handle); | 1002 inline void emit(Handle<Object> handle); |
| 1003 inline void emit(uint32_t x, | 1003 inline void emit(uint32_t x, |
| 1004 RelocInfo::Mode rmode, | 1004 RelocInfo::Mode rmode, |
| 1005 TypeFeedbackId id = TypeFeedbackId::None()); | 1005 TypeFeedbackId id = TypeFeedbackId::None()); |
| 1006 inline void emit(Handle<Code> code, | 1006 inline void emit(Handle<Code> code, |
| 1007 RelocInfo::Mode rmode, | 1007 RelocInfo::Mode rmode, |
| 1008 TypeFeedbackId id = TypeFeedbackId::None()); | 1008 TypeFeedbackId id = TypeFeedbackId::None()); |
| 1009 inline void emit(const Immediate& x); | 1009 inline void emit(const Immediate& x); |
| 1010 inline void emit_w(const Immediate& x); | 1010 inline void emit_w(const Immediate& x); |
| 1011 inline void emit_q(uint64_t x); | |
| 1012 | 1011 |
| 1013 // Emit the code-object-relative offset of the label's position | 1012 // Emit the code-object-relative offset of the label's position |
| 1014 inline void emit_code_relative_offset(Label* label); | 1013 inline void emit_code_relative_offset(Label* label); |
| 1015 | 1014 |
| 1016 // instruction generation | 1015 // instruction generation |
| 1017 void emit_arith_b(int op1, int op2, Register dst, int imm8); | 1016 void emit_arith_b(int op1, int op2, Register dst, int imm8); |
| 1018 | 1017 |
| 1019 // Emit a basic arithmetic instruction (i.e. first byte of the family is 0x81) | 1018 // Emit a basic arithmetic instruction (i.e. first byte of the family is 0x81) |
| 1020 // with a given destination expression and an immediate operand. It attempts | 1019 // with a given destination expression and an immediate operand. It attempts |
| 1021 // to use the shortest encoding possible. | 1020 // to use the shortest encoding possible. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1080 private: | 1079 private: |
| 1081 Assembler* assembler_; | 1080 Assembler* assembler_; |
| 1082 #ifdef DEBUG | 1081 #ifdef DEBUG |
| 1083 int space_before_; | 1082 int space_before_; |
| 1084 #endif | 1083 #endif |
| 1085 }; | 1084 }; |
| 1086 | 1085 |
| 1087 } } // namespace v8::internal | 1086 } } // namespace v8::internal |
| 1088 | 1087 |
| 1089 #endif // V8_X87_ASSEMBLER_X87_H_ | 1088 #endif // V8_X87_ASSEMBLER_X87_H_ |
| OLD | NEW |