224 225 // Instruction boundaries (required when emitting relocatable values). 226 class InstructionMark: public StackObj { 227 private: 228 AbstractAssembler* _assm; 229 230 public: 231 InstructionMark(AbstractAssembler* assm) : _assm(assm) { 232 assert(assm->inst_mark() == NULL, "overlapping instructions"); 233 _assm->set_inst_mark(); 234 } 235 ~InstructionMark() { 236 _assm->clear_inst_mark(); 237 } 238 }; 239 friend class InstructionMark; 240 #ifdef ASSERT 241 // Make it return true on platforms which need to verify 242 // instruction boundaries for some operations. 243 inline static bool pd_check_instruction_mark(); 244 #endif 245 246 // Label functions 247 void print(Label& L); 248 249 public: 250 251 // Creation 252 AbstractAssembler(CodeBuffer* code); 253 254 // save end pointer back to code buf. 255 void sync(); 256 257 // ensure buf contains all code (call this before using/copying the code) 258 void flush(); 259 260 // min and max values for signed immediate ranges 261 static int min_simm(int nbits) { return -(intptr_t(1) << (nbits - 1)) ; } 262 static int max_simm(int nbits) { return (intptr_t(1) << (nbits - 1)) - 1; } 263 | 224 225 // Instruction boundaries (required when emitting relocatable values). 226 class InstructionMark: public StackObj { 227 private: 228 AbstractAssembler* _assm; 229 230 public: 231 InstructionMark(AbstractAssembler* assm) : _assm(assm) { 232 assert(assm->inst_mark() == NULL, "overlapping instructions"); 233 _assm->set_inst_mark(); 234 } 235 ~InstructionMark() { 236 _assm->clear_inst_mark(); 237 } 238 }; 239 friend class InstructionMark; 240 #ifdef ASSERT 241 // Make it return true on platforms which need to verify 242 // instruction boundaries for some operations. 243 inline static bool pd_check_instruction_mark(); 244 245 // Add delta to short branch distance to verify that it still fit into imm8. 246 int _short_branch_delta; 247 248 int short_branch_delta() const { return _short_branch_delta; } 249 void set_short_branch_delta() { _short_branch_delta = 32; } 250 void clear_short_branch_delta() { _short_branch_delta = 0; } 251 252 class ShortBranchVerifier: public StackObj { 253 private: 254 AbstractAssembler* _assm; 255 256 public: 257 ShortBranchVerifier(AbstractAssembler* assm) : _assm(assm) { 258 assert(assm->short_branch_delta() == 0, "overlapping instructions"); 259 _assm->set_short_branch_delta(); 260 } 261 ~ShortBranchVerifier() { 262 _assm->clear_short_branch_delta(); 263 } 264 }; 265 friend class ShortBranchVerifier; 266 #endif 267 268 // Label functions 269 void print(Label& L); 270 271 public: 272 273 // Creation 274 AbstractAssembler(CodeBuffer* code); 275 276 // save end pointer back to code buf. 277 void sync(); 278 279 // ensure buf contains all code (call this before using/copying the code) 280 void flush(); 281 282 // min and max values for signed immediate ranges 283 static int min_simm(int nbits) { return -(intptr_t(1) << (nbits - 1)) ; } 284 static int max_simm(int nbits) { return (intptr_t(1) << (nbits - 1)) - 1; } 285 |