| 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 case greater_equal: | 244 case greater_equal: |
| 245 return less_equal; | 245 return less_equal; |
| 246 case less_equal: | 246 case less_equal: |
| 247 return greater_equal; | 247 return greater_equal; |
| 248 default: | 248 default: |
| 249 return cc; | 249 return cc; |
| 250 }; | 250 }; |
| 251 } | 251 } |
| 252 | 252 |
| 253 | 253 |
| 254 enum Hint { | |
| 255 no_hint = 0, | |
| 256 not_taken = 0x2e, | |
| 257 taken = 0x3e | |
| 258 }; | |
| 259 | |
| 260 | |
| 261 // The result of negating a hint is as if the corresponding condition | |
| 262 // were negated by NegateCondition. That is, no_hint is mapped to | |
| 263 // itself and not_taken and taken are mapped to each other. | |
| 264 inline Hint NegateHint(Hint hint) { | |
| 265 return (hint == no_hint) | |
| 266 ? no_hint | |
| 267 : ((hint == not_taken) ? taken : not_taken); | |
| 268 } | |
| 269 | |
| 270 | |
| 271 // ----------------------------------------------------------------------------- | 254 // ----------------------------------------------------------------------------- |
| 272 // Machine instruction Immediates | 255 // Machine instruction Immediates |
| 273 | 256 |
| 274 class Immediate BASE_EMBEDDED { | 257 class Immediate BASE_EMBEDDED { |
| 275 public: | 258 public: |
| 276 inline explicit Immediate(int x); | 259 inline explicit Immediate(int x); |
| 277 inline explicit Immediate(const ExternalReference& ext); | 260 inline explicit Immediate(const ExternalReference& ext); |
| 278 inline explicit Immediate(Handle<Object> handle); | 261 inline explicit Immediate(Handle<Object> handle); |
| 279 inline explicit Immediate(Smi* value); | 262 inline explicit Immediate(Smi* value); |
| 280 inline explicit Immediate(Address addr); | 263 inline explicit Immediate(Address addr); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 291 return -32768 <= x_ && x_ < 32768 && rmode_ == RelocInfo::NONE; | 274 return -32768 <= x_ && x_ < 32768 && rmode_ == RelocInfo::NONE; |
| 292 } | 275 } |
| 293 | 276 |
| 294 private: | 277 private: |
| 295 inline explicit Immediate(Label* value); | 278 inline explicit Immediate(Label* value); |
| 296 | 279 |
| 297 int x_; | 280 int x_; |
| 298 RelocInfo::Mode rmode_; | 281 RelocInfo::Mode rmode_; |
| 299 | 282 |
| 300 friend class Assembler; | 283 friend class Assembler; |
| 284 friend class MacroAssembler; |
| 301 }; | 285 }; |
| 302 | 286 |
| 303 | 287 |
| 304 // ----------------------------------------------------------------------------- | 288 // ----------------------------------------------------------------------------- |
| 305 // Machine instruction Operands | 289 // Machine instruction Operands |
| 306 | 290 |
| 307 enum ScaleFactor { | 291 enum ScaleFactor { |
| 308 times_1 = 0, | 292 times_1 = 0, |
| 309 times_2 = 1, | 293 times_2 = 1, |
| 310 times_4 = 2, | 294 times_4 = 2, |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 // Label L; // unbound label | 826 // Label L; // unbound label |
| 843 // j(cc, &L); // forward branch to unbound label | 827 // j(cc, &L); // forward branch to unbound label |
| 844 // bind(&L); // bind label to the current pc | 828 // bind(&L); // bind label to the current pc |
| 845 // j(cc, &L); // backward branch to bound label | 829 // j(cc, &L); // backward branch to bound label |
| 846 // bind(&L); // illegal: a label may be bound only once | 830 // bind(&L); // illegal: a label may be bound only once |
| 847 // | 831 // |
| 848 // Note: The same Label can be used for forward and backward branches | 832 // Note: The same Label can be used for forward and backward branches |
| 849 // but it may be bound only once. | 833 // but it may be bound only once. |
| 850 | 834 |
| 851 void bind(Label* L); // binds an unbound label L to the current code position | 835 void bind(Label* L); // binds an unbound label L to the current code position |
| 852 void bind(NearLabel* L); | |
| 853 | 836 |
| 854 // Calls | 837 // Calls |
| 855 void call(Label* L); | 838 void call(Label* L); |
| 856 void call(byte* entry, RelocInfo::Mode rmode); | 839 void call(byte* entry, RelocInfo::Mode rmode); |
| 857 int CallSize(const Operand& adr); | 840 int CallSize(const Operand& adr); |
| 858 void call(const Operand& adr); | 841 void call(const Operand& adr); |
| 859 int CallSize(Handle<Code> code, RelocInfo::Mode mode); | 842 int CallSize(Handle<Code> code, RelocInfo::Mode mode); |
| 860 void call(Handle<Code> code, | 843 void call(Handle<Code> code, |
| 861 RelocInfo::Mode rmode, | 844 RelocInfo::Mode rmode, |
| 862 unsigned ast_id = kNoASTId); | 845 unsigned ast_id = kNoASTId); |
| 863 | 846 |
| 864 // Jumps | 847 // Jumps |
| 865 void jmp(Label* L); // unconditional jump to L | 848 // unconditional jump to L |
| 849 void jmp(Label* L, Label::Distance distance = Label::kFar); |
| 866 void jmp(byte* entry, RelocInfo::Mode rmode); | 850 void jmp(byte* entry, RelocInfo::Mode rmode); |
| 867 void jmp(const Operand& adr); | 851 void jmp(const Operand& adr); |
| 868 void jmp(Handle<Code> code, RelocInfo::Mode rmode); | 852 void jmp(Handle<Code> code, RelocInfo::Mode rmode); |
| 869 | 853 |
| 870 // Short jump | |
| 871 void jmp(NearLabel* L); | |
| 872 | |
| 873 // Conditional jumps | 854 // Conditional jumps |
| 874 void j(Condition cc, Label* L, Hint hint = no_hint); | 855 void j(Condition cc, |
| 875 void j(Condition cc, byte* entry, RelocInfo::Mode rmode, Hint hint = no_hint); | 856 Label* L, |
| 876 void j(Condition cc, Handle<Code> code, Hint hint = no_hint); | 857 Label::Distance distance = Label::kFar); |
| 877 | 858 void j(Condition cc, byte* entry, RelocInfo::Mode rmode); |
| 878 // Conditional short jump | 859 void j(Condition cc, Handle<Code> code); |
| 879 void j(Condition cc, NearLabel* L, Hint hint = no_hint); | |
| 880 | 860 |
| 881 // Floating-point operations | 861 // Floating-point operations |
| 882 void fld(int i); | 862 void fld(int i); |
| 883 void fstp(int i); | 863 void fstp(int i); |
| 884 | 864 |
| 885 void fld1(); | 865 void fld1(); |
| 886 void fldz(); | 866 void fldz(); |
| 887 void fldpi(); | 867 void fldpi(); |
| 888 void fldln2(); | 868 void fldln2(); |
| 889 | 869 |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1118 void emit_farith(int b1, int b2, int i); | 1098 void emit_farith(int b1, int b2, int i); |
| 1119 | 1099 |
| 1120 // labels | 1100 // labels |
| 1121 void print(Label* L); | 1101 void print(Label* L); |
| 1122 void bind_to(Label* L, int pos); | 1102 void bind_to(Label* L, int pos); |
| 1123 | 1103 |
| 1124 // displacements | 1104 // displacements |
| 1125 inline Displacement disp_at(Label* L); | 1105 inline Displacement disp_at(Label* L); |
| 1126 inline void disp_at_put(Label* L, Displacement disp); | 1106 inline void disp_at_put(Label* L, Displacement disp); |
| 1127 inline void emit_disp(Label* L, Displacement::Type type); | 1107 inline void emit_disp(Label* L, Displacement::Type type); |
| 1108 inline void emit_near_disp(Label* L); |
| 1128 | 1109 |
| 1129 // record reloc info for current pc_ | 1110 // record reloc info for current pc_ |
| 1130 void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0); | 1111 void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0); |
| 1131 | 1112 |
| 1132 friend class CodePatcher; | 1113 friend class CodePatcher; |
| 1133 friend class EnsureSpace; | 1114 friend class EnsureSpace; |
| 1134 | 1115 |
| 1135 // Code buffer: | 1116 // Code buffer: |
| 1136 // The buffer into which code and relocation info are generated. | 1117 // The buffer into which code and relocation info are generated. |
| 1137 byte* buffer_; | 1118 byte* buffer_; |
| 1138 int buffer_size_; | 1119 int buffer_size_; |
| 1139 // True if the assembler owns the buffer, false if buffer is external. | 1120 // True if the assembler owns the buffer, false if buffer is external. |
| 1140 bool own_buffer_; | 1121 bool own_buffer_; |
| 1141 | 1122 |
| 1142 // code generation | 1123 // code generation |
| 1143 byte* pc_; // the program counter; moves forward | 1124 byte* pc_; // the program counter; moves forward |
| 1144 RelocInfoWriter reloc_info_writer; | 1125 RelocInfoWriter reloc_info_writer; |
| 1145 | 1126 |
| 1146 // push-pop elimination | |
| 1147 byte* last_pc_; | |
| 1148 | |
| 1149 PositionsRecorder positions_recorder_; | 1127 PositionsRecorder positions_recorder_; |
| 1150 | 1128 |
| 1151 bool emit_debug_code_; | 1129 bool emit_debug_code_; |
| 1152 | 1130 |
| 1153 friend class PositionsRecorder; | 1131 friend class PositionsRecorder; |
| 1154 }; | 1132 }; |
| 1155 | 1133 |
| 1156 | 1134 |
| 1157 // Helper class that ensures that there is enough space for generating | 1135 // Helper class that ensures that there is enough space for generating |
| 1158 // instructions and relocation information. The constructor makes | 1136 // instructions and relocation information. The constructor makes |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1177 private: | 1155 private: |
| 1178 Assembler* assembler_; | 1156 Assembler* assembler_; |
| 1179 #ifdef DEBUG | 1157 #ifdef DEBUG |
| 1180 int space_before_; | 1158 int space_before_; |
| 1181 #endif | 1159 #endif |
| 1182 }; | 1160 }; |
| 1183 | 1161 |
| 1184 } } // namespace v8::internal | 1162 } } // namespace v8::internal |
| 1185 | 1163 |
| 1186 #endif // V8_IA32_ASSEMBLER_IA32_H_ | 1164 #endif // V8_IA32_ASSEMBLER_IA32_H_ |
| OLD | NEW |