Mercurial > hg > truffle
comparison src/cpu/ppc/vm/interp_masm_ppc_64.cpp @ 20418:b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
Reviewed-by: kvn, goetz
Contributed-by: asmundak@google.com
author | kvn |
---|---|
date | Thu, 17 Jul 2014 15:40:04 -0700 |
parents | fd1b9f02cc91 |
children | f6bde7889409 |
comparison
equal
deleted
inserted
replaced
20416:99f0593d8c9f | 20418:b384ba33c9a0 |
---|---|
117 bne(CCR0, L); | 117 bne(CCR0, L); |
118 | 118 |
119 // Call the Interpreter::remove_activation_preserving_args_entry() | 119 // Call the Interpreter::remove_activation_preserving_args_entry() |
120 // func to get the address of the same-named entrypoint in the | 120 // func to get the address of the same-named entrypoint in the |
121 // generated interpreter code. | 121 // generated interpreter code. |
122 #if defined(ABI_ELFv2) | |
123 call_c(CAST_FROM_FN_PTR(address, | |
124 Interpreter::remove_activation_preserving_args_entry), | |
125 relocInfo::none); | |
126 #else | |
122 call_c(CAST_FROM_FN_PTR(FunctionDescriptor*, | 127 call_c(CAST_FROM_FN_PTR(FunctionDescriptor*, |
123 Interpreter::remove_activation_preserving_args_entry), | 128 Interpreter::remove_activation_preserving_args_entry), |
124 relocInfo::none); | 129 relocInfo::none); |
130 #endif | |
125 | 131 |
126 // Jump to Interpreter::_remove_activation_preserving_args_entry. | 132 // Jump to Interpreter::_remove_activation_preserving_args_entry. |
127 mtctr(R3_RET); | 133 mtctr(R3_RET); |
128 bctr(); | 134 bctr(); |
129 | 135 |
329 } | 335 } |
330 | 336 |
331 void InterpreterMacroAssembler::get_2_byte_integer_at_bcp(int bcp_offset, | 337 void InterpreterMacroAssembler::get_2_byte_integer_at_bcp(int bcp_offset, |
332 Register Rdst, | 338 Register Rdst, |
333 signedOrNot is_signed) { | 339 signedOrNot is_signed) { |
340 #if defined(VM_LITTLE_ENDIAN) | |
341 if (bcp_offset) { | |
342 load_const_optimized(Rdst, bcp_offset); | |
343 lhbrx(Rdst, R14_bcp, Rdst); | |
344 } else { | |
345 lhbrx(Rdst, R14_bcp); | |
346 } | |
347 if (is_signed == Signed) { | |
348 extsh(Rdst, Rdst); | |
349 } | |
350 #else | |
334 // Read Java big endian format. | 351 // Read Java big endian format. |
335 if (is_signed == Signed) { | 352 if (is_signed == Signed) { |
336 lha(Rdst, bcp_offset, R14_bcp); | 353 lha(Rdst, bcp_offset, R14_bcp); |
337 } else { | 354 } else { |
338 lhz(Rdst, bcp_offset, R14_bcp); | 355 lhz(Rdst, bcp_offset, R14_bcp); |
339 } | 356 } |
340 #if 0 | |
341 assert(Rtmp != Rdst, "need separate temp register"); | |
342 Register Rfirst = Rtmp; | |
343 lbz(Rfirst, bcp_offset, R14_bcp); // first byte | |
344 lbz(Rdst, bcp_offset+1, R14_bcp); // second byte | |
345 | |
346 // Rdst = ((Rfirst<<8) & 0xFF00) | (Rdst &~ 0xFF00) | |
347 rldimi(/*RA=*/Rdst, /*RS=*/Rfirst, /*sh=*/8, /*mb=*/48); | |
348 if (is_signed == Signed) { | |
349 extsh(Rdst, Rdst); | |
350 } | |
351 #endif | 357 #endif |
352 } | 358 } |
353 | 359 |
354 void InterpreterMacroAssembler::get_4_byte_integer_at_bcp(int bcp_offset, | 360 void InterpreterMacroAssembler::get_4_byte_integer_at_bcp(int bcp_offset, |
355 Register Rdst, | 361 Register Rdst, |
356 signedOrNot is_signed) { | 362 signedOrNot is_signed) { |
363 #if defined(VM_LITTLE_ENDIAN) | |
364 if (bcp_offset) { | |
365 load_const_optimized(Rdst, bcp_offset); | |
366 lwbrx(Rdst, R14_bcp, Rdst); | |
367 } else { | |
368 lwbrx(Rdst, R14_bcp); | |
369 } | |
370 if (is_signed == Signed) { | |
371 extsw(Rdst, Rdst); | |
372 } | |
373 #else | |
357 // Read Java big endian format. | 374 // Read Java big endian format. |
358 if (bcp_offset & 3) { // Offset unaligned? | 375 if (bcp_offset & 3) { // Offset unaligned? |
359 load_const_optimized(Rdst, bcp_offset); | 376 load_const_optimized(Rdst, bcp_offset); |
360 if (is_signed == Signed) { | 377 if (is_signed == Signed) { |
361 lwax(Rdst, R14_bcp, Rdst); | 378 lwax(Rdst, R14_bcp, Rdst); |
367 lwa(Rdst, bcp_offset, R14_bcp); | 384 lwa(Rdst, bcp_offset, R14_bcp); |
368 } else { | 385 } else { |
369 lwz(Rdst, bcp_offset, R14_bcp); | 386 lwz(Rdst, bcp_offset, R14_bcp); |
370 } | 387 } |
371 } | 388 } |
372 } | 389 #endif |
390 } | |
391 | |
373 | 392 |
374 // Load the constant pool cache index from the bytecode stream. | 393 // Load the constant pool cache index from the bytecode stream. |
375 // | 394 // |
376 // Kills / writes: | 395 // Kills / writes: |
377 // - Rdst, Rscratch | 396 // - Rdst, Rscratch |
378 void InterpreterMacroAssembler::get_cache_index_at_bcp(Register Rdst, int bcp_offset, size_t index_size) { | 397 void InterpreterMacroAssembler::get_cache_index_at_bcp(Register Rdst, int bcp_offset, size_t index_size) { |
379 assert(bcp_offset > 0, "bcp is still pointing to start of bytecode"); | 398 assert(bcp_offset > 0, "bcp is still pointing to start of bytecode"); |
399 // Cache index is always in the native format, courtesy of Rewriter. | |
380 if (index_size == sizeof(u2)) { | 400 if (index_size == sizeof(u2)) { |
381 get_2_byte_integer_at_bcp(bcp_offset, Rdst, Unsigned); | 401 lhz(Rdst, bcp_offset, R14_bcp); |
382 } else if (index_size == sizeof(u4)) { | 402 } else if (index_size == sizeof(u4)) { |
383 assert(EnableInvokeDynamic, "giant index used only for JSR 292"); | 403 assert(EnableInvokeDynamic, "giant index used only for JSR 292"); |
384 get_4_byte_integer_at_bcp(bcp_offset, Rdst, Signed); | 404 if (bcp_offset & 3) { |
405 load_const_optimized(Rdst, bcp_offset); | |
406 lwax(Rdst, R14_bcp, Rdst); | |
407 } else { | |
408 lwa(Rdst, bcp_offset, R14_bcp); | |
409 } | |
385 assert(ConstantPool::decode_invokedynamic_index(~123) == 123, "else change next line"); | 410 assert(ConstantPool::decode_invokedynamic_index(~123) == 123, "else change next line"); |
386 nand(Rdst, Rdst, Rdst); // convert to plain index | 411 nand(Rdst, Rdst, Rdst); // convert to plain index |
387 } else if (index_size == sizeof(u1)) { | 412 } else if (index_size == sizeof(u1)) { |
388 lbz(Rdst, bcp_offset, R14_bcp); | 413 lbz(Rdst, bcp_offset, R14_bcp); |
389 } else { | 414 } else { |
394 | 419 |
395 void InterpreterMacroAssembler::get_cache_and_index_at_bcp(Register cache, int bcp_offset, size_t index_size) { | 420 void InterpreterMacroAssembler::get_cache_and_index_at_bcp(Register cache, int bcp_offset, size_t index_size) { |
396 get_cache_index_at_bcp(cache, bcp_offset, index_size); | 421 get_cache_index_at_bcp(cache, bcp_offset, index_size); |
397 sldi(cache, cache, exact_log2(in_words(ConstantPoolCacheEntry::size()) * BytesPerWord)); | 422 sldi(cache, cache, exact_log2(in_words(ConstantPoolCacheEntry::size()) * BytesPerWord)); |
398 add(cache, R27_constPoolCache, cache); | 423 add(cache, R27_constPoolCache, cache); |
424 } | |
425 | |
426 // Load 4-byte signed or unsigned integer in Java format (that is, big-endian format) | |
427 // from (Rsrc)+offset. | |
428 void InterpreterMacroAssembler::get_u4(Register Rdst, Register Rsrc, int offset, | |
429 signedOrNot is_signed) { | |
430 #if defined(VM_LITTLE_ENDIAN) | |
431 if (offset) { | |
432 load_const_optimized(Rdst, offset); | |
433 lwbrx(Rdst, Rdst, Rsrc); | |
434 } else { | |
435 lwbrx(Rdst, Rsrc); | |
436 } | |
437 if (is_signed == Signed) { | |
438 extsw(Rdst, Rdst); | |
439 } | |
440 #else | |
441 if (is_signed == Signed) { | |
442 lwa(Rdst, offset, Rsrc); | |
443 } else { | |
444 lwz(Rdst, offset, Rsrc); | |
445 } | |
446 #endif | |
399 } | 447 } |
400 | 448 |
401 // Load object from cpool->resolved_references(index). | 449 // Load object from cpool->resolved_references(index). |
402 void InterpreterMacroAssembler::load_resolved_reference_at_index(Register result, Register index) { | 450 void InterpreterMacroAssembler::load_resolved_reference_at_index(Register result, Register index) { |
403 assert_different_registers(result, index); | 451 assert_different_registers(result, index); |