/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "c1/c1_Compilation.hpp"
#include "c1/c1_FrameMap.hpp"
#include "c1/c1_Instruction.hpp"
#include "c1/c1_LIRAssembler.hpp"
#include "c1/c1_LIRGenerator.hpp"
#include "c1/c1_Runtime1.hpp"
#include "c1/c1_ValueStack.hpp"
#include "ci/ciArray.hpp"
#include "ci/ciObjArrayKlass.hpp"
#include "ci/ciTypeArrayKlass.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/stubRoutines.hpp"
#include "vmreg_x86.inline.hpp"
#ifdef ASSERT
#else
#endif
// Item will be loaded into a byte register; Intel only
load_item();
// make sure that it is a byte register
"can't load floats in byte register");
}
}
if (r->is_constant()) {
_result = r;
} else {
load_item();
}
}
//--------------------------------------------------------------
// LIRGenerator
//--------------------------------------------------------------
case addressTag:
}
return opr;
}
return reg;
}
//--------- loading items into registers --------------------------------
// i486 instructions can inline constants
// there is no immediate move of word values in asembler_i486.?pp
return false;
}
Constant* c = v->as_Constant();
if (c && c->state_before() == NULL) {
// constants of any type can be stored directly, except for
// unloaded object constants.
return true;
}
return false;
}
}
}
return LIR_OprFact::illegalOpr;
}
if (index->is_constant()) {
return new LIR_Address(base,
type);
} else {
}
}
if (index_opr->is_constant()) {
} else {
#ifdef _LP64
}
#endif // _LP64
}
if (needs_card_mark) {
// This store will need a precise card mark, so go ahead and
// compute the full adddres instead of computing once for the
// store and again for the card mark.
} else {
return addr;
}
}
LIR_Opr r;
r = LIR_OprFact::longConst(x);
r = LIR_OprFact::intConst(x);
} else {
}
return r;
}
}
}
void LIRGenerator::cmp_mem_int(LIR_Condition condition, LIR_Opr base, int disp, int c, CodeEmitInfo* info) {
}
void LIRGenerator::cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr base, int disp, BasicType type, CodeEmitInfo* info) {
}
void LIRGenerator::cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr base, LIR_Opr disp, BasicType type, CodeEmitInfo* info) {
}
if (is_power_of_2(c + 1)) {
return true;
} else if (is_power_of_2(c - 1)) {
return true;
}
}
return false;
}
}
//----------------------------------------------------------------------
// visitor functions
//----------------------------------------------------------------------
bool needs_range_check = true;
x->should_profile());
if (use_length) {
if (needs_range_check) {
}
}
if (needs_store_check) {
} else {
}
set_no_result(x);
// the CodeEmitInfo must be duplicated for each different
// LIR-instruction because spilling can occur anywhere between two
// instructions and so the debug information must be different
if (x->needs_null_check()) {
}
// emit array address setup early so it schedules better
LIR_Address* array_addr = emit_array_address(array.result(), index.result(), x->elt_type(), obj_store);
if (GenerateRangeChecks && needs_range_check) {
if (use_length) {
} else {
// range_check also does the null check
}
}
if (GenerateArrayStoreCheck && needs_store_check) {
__ store_check(value.result(), array.result(), tmp1, tmp2, tmp3, store_check_info, x->profiled_method(), x->profiled_bci());
}
if (obj_store) {
// Needs GC write barriers.
// Seems to be a precise
} else {
}
}
set_no_result(x);
// "lock" stores the address of the monitor stack slot, so this is not an oop
// Need a scratch register for biased locking on x86
if (UseBiasedLocking) {
}
if (x->needs_null_check()) {
info_for_exception = state_for(x);
}
// this CodeEmitInfo must not have the xhandlers because here the
// object is already locked (xhandlers expect object to be unlocked)
}
set_no_result(x);
}
// _ineg, _lneg, _fneg, _dneg
}
// for _fadd, _fmul, _fsub, _fdiv, _frem
// _dadd, _dmul, _dsub, _ddiv, _drem
} else {
}
// do not load right operand if it is a constant. only 0 and 1 are
// loaded because there are special instructions for loading them
// without memory access (not needed for SSE2 instructions)
bool must_load_right = false;
if (right.is_constant()) {
} else {
}
}
if (must_load_both) {
// frem and drem destroy also right operand, so move it to a new register
} else {
}
}
// special handling for frem and drem: no SSE instruction, so must use FPU with temporary fpu stack slots
} else {
}
} else {
}
}
// for _ladd, _lmul, _lsub, _ldiv, _lrem
// long division is implemented as a direct call into the runtime
// the check for division by zero destroys the right operand
// check for division by zero (destroys registers of right operand!)
switch (x->op()) {
break; // check if dividend is 0 is done elsewhere
break; // check if dividend is 0 is done elsewhere
break;
default:
}
// missing test if instr is commutative and if we should swap
// right register is destroyed by the long mul, so it must be
// copied to a new register.
} else {
// missing test if instr is commutative and if we should swap
// don't load constants to save register
rlock_result(x);
}
}
// for: _iadd, _imul, _isub, _idiv, _irem
// The requirements for division and modulo
// input : rax,: dividend min_int
// reg: divisor (may not be rax,/rdx) -1
//
// output: rax,: quotient (= rax, idiv reg) min_int
// rdx: remainder (= rax, irem reg) 0
// rax, and rdx will be destroyed
// Note: does this invalidate the spec ???
// call state_for before load_item_force because state_for may
// force the evaluation of other instructions that are needed for
// correct debug info. Otherwise the live range of the fix
// register might be too long.
result_reg = divOutOpr();
} else {
result_reg = remOutOpr();
}
if (!ImplicitDiv0Checks) {
}
} else {
}
} else {
// missing test if instr is commutative and if we should swap
// swap them if left is real stack (or cached) and right is real register(not cached)
}
// do not need to load right, as we can handle stack and constants
// check if we can use shift instead
bool use_constant = false;
bool use_tmp = false;
if (right_arg->is_constant()) {
if (iconst > 0) {
if (is_power_of_2(iconst)) {
use_constant = true;
use_constant = true;
use_tmp = true;
}
}
}
if (use_constant) {
} else {
}
if (use_tmp) {
}
rlock_result(x);
} else {
rlock_result(x);
}
}
}
// when an operand with use count 1 is the left operand, then it is
// likely that no move for 2-operand-LIR-form is necessary
if (x->is_commutative() && x->y()->as_Constant() == NULL && x->x()->use_count() > x->y()->use_count()) {
x->swap_operands();
}
switch (tag) {
case floatTag:
case doubleTag: do_ArithmeticOp_FPU(x); return;
case longTag: do_ArithmeticOp_Long(x); return;
case intTag: do_ArithmeticOp_Int(x); return;
}
}
// _ishl, _lshl, _ishr, _lshr, _iushr, _lushr
// count must always be in rcx
if (must_load_count) {
// count for long must be in register
} else {
}
}
// _iand, _land, _ior, _lor, _ixor, _lxor
// when an operand with use count 1 is the left operand, then it is
// likely that no move for 2-operand-LIR-form is necessary
if (x->is_commutative() && x->y()->as_Constant() == NULL && x->x()->use_count() > x->y()->use_count()) {
x->swap_operands();
}
}
// _lcmp, _fcmpl, _fcmpg, _dcmpl, _dcmpg
}
if (x->x()->type()->is_float_kind()) {
__ fcmp2int(left.result(), right.result(), reg, (code == Bytecodes::_fcmpl || code == Bytecodes::_dcmpl));
} else {
}
}
// In 64bit the type can be long, sparc doesn't have this assert
// assert(offset.type()->tag() == intTag, "invalid type");
// get address of field
if (type == objectType) {
} else {
}
LIR_Address* a;
#ifdef _LP64
(jint)c,
as_BasicType(type));
} else {
tmp,
as_BasicType(type));
}
#else
as_BasicType(type));
#endif
} else {
0,
as_BasicType(type));
}
// Do the pre-write barrier, if any.
}
if (type == objectType)
else {
}
// generate conditional move of boolean result
// Seems to be precise
}
}
assert(x->number_of_arguments() == 1 || (x->number_of_arguments() == 2 && x->id() == vmIntrinsics::_dpow), "wrong type");
bool use_fpu = false;
if (UseSSE >= 2) {
switch(x->id()) {
case vmIntrinsics::_dsin:
case vmIntrinsics::_dcos:
case vmIntrinsics::_dtan:
case vmIntrinsics::_dlog:
case vmIntrinsics::_dlog10:
case vmIntrinsics::_dexp:
case vmIntrinsics::_dpow:
use_fpu = true;
}
} else {
}
if (UseSSE < 2) {
}
}
// sin, cos, pow and exp need two free fpu stack slots, so register
// two temporary operands
if (use_fpu) {
if (calc_input2 != NULL) {
tmp_start = 2;
calc_input2 = tmp;
}
calc_input = tmp;
calc_result = tmp;
}
switch(x->id()) {
case vmIntrinsics::_dexp: __ exp (calc_input, calc_result, tmp1, tmp2, FrameMap::rax_opr, FrameMap::rcx_opr, FrameMap::rdx_opr); break;
case vmIntrinsics::_dpow: __ pow (calc_input, calc_input2, calc_result, tmp1, tmp2, FrameMap::rax_opr, FrameMap::rcx_opr, FrameMap::rdx_opr); break;
default: ShouldNotReachHere();
}
if (use_fpu) {
}
}
// Make all state_for calls early since they can emit code
// operands for arraycopy must use fixed registers, otherwise
// LinearScan will fail allocation (because arraycopy always needs a
// call)
#ifndef _LP64
#else
// The java calling convention will give us enough registers
// so that on the stub side the args will be perfect already.
// positions are not similar enough to pick one as the best.
// Also because the java calling convention is a "shifted" version
// of the C convention we can process the java args trivially into C
// args without worry of overwriting during the xfer
#endif // LP64
set_no_result(x);
int flags;
__ arraycopy(src.result(), src_pos.result(), dst.result(), dst_pos.result(), length.result(), tmp, expected_type, flags, info); // does add_safepoint
}
// _i2l, _i2f, _i2d, _l2i, _l2f, _l2d, _f2i, _f2l, _f2d, _d2i, _d2l, _d2f
// _i2b, _i2c, _i2s
switch (type) {
}
}
// flags that vary for the different operations and different SSE-settings
switch (x->op()) {
case Bytecodes::_i2s: fixed_input = false; fixed_result = false; round_result = false; needs_stub = false; break;
case Bytecodes::_f2d: fixed_input = UseSSE == 1; fixed_result = false; round_result = false; needs_stub = false; break;
case Bytecodes::_d2f: fixed_input = false; fixed_result = UseSSE == 1; round_result = UseSSE < 1; needs_stub = false; break;
case Bytecodes::_i2f: fixed_input = false; fixed_result = false; round_result = UseSSE < 1; needs_stub = false; break;
case Bytecodes::_i2d: fixed_input = false; fixed_result = false; round_result = false; needs_stub = false; break;
case Bytecodes::_f2i: fixed_input = false; fixed_result = false; round_result = false; needs_stub = true; break;
case Bytecodes::_d2i: fixed_input = false; fixed_result = false; round_result = false; needs_stub = true; break;
case Bytecodes::_l2f: fixed_input = false; fixed_result = UseSSE >= 1; round_result = UseSSE < 1; needs_stub = false; break;
case Bytecodes::_l2d: fixed_input = false; fixed_result = UseSSE >= 2; round_result = UseSSE < 2; needs_stub = false; break;
case Bytecodes::_f2l: fixed_input = true; fixed_result = true; round_result = false; needs_stub = false; break;
case Bytecodes::_d2l: fixed_input = true; fixed_result = true; round_result = false; needs_stub = false; break;
default: ShouldNotReachHere();
}
// arguments of lir_convert
if (fixed_input) {
}
if (fixed_result) {
} else if (round_result) {
}
if (needs_stub) {
}
if (result != conv_result) {
}
set_result(x, result);
}
#ifndef PRODUCT
}
#endif
}
}
// in case of patching (i.e., object class is not yet loaded), we need to reexecute the instruction
// and therefore provide the state before the parameters have been consumed
}
BAILOUT("encountered unloaded_ciobjarrayklass due to out of memory error");
}
}
while (i-- > 0) {
}
// Evaluate state_for early since it may emit code.
// Cannot re-use same xhandlers for multiple CodeEmitInfos, so
// clone all handlers (NOTE: Usually this is handled transparently
// by the CodeEmitInfo cloning logic in CodeStub constructors but
// is done explicitly here because a stub isn't being used).
}
while (i-- > 0) {
size->load_nonconstant();
}
}
// nothing to do for now
}
// must do this before locking the destination register as an oop register,
// and before the obj is loaded (the latter is for deoptimization)
}
// info for exceptions
if (x->is_incompatible_class_change_check()) {
stub = new SimpleExceptionStub(Runtime1::throw_incompatible_class_change_error_id, LIR_OprFact::illegalOpr, info_for_exception);
} else {
stub = new SimpleExceptionStub(Runtime1::throw_class_cast_exception_id, obj.result(), info_for_exception);
}
}
x->profiled_method(), x->profiled_bci());
}
// result and test object may not be in same register
// must do this before locking the destination register as an oop register
}
}
}
// for longs, only conditions "eql", "neq", "lss", "geq" are valid;
// mirror for other conditions
}
}
if (tag == longTag && yin->is_constant() && yin->get_jlong_constant() == 0 && (cond == If::eql || cond == If::neq)) {
// inline long zero
yin->dont_load_item();
// longs cannot handle constants at right side
} else {
yin->dont_load_item();
}
// add safepoint before generating condition code so it can be recomputed
if (x->is_safepoint()) {
// increment backedge counter if needed
}
set_no_result(x);
// Generate branch profiling. Profiling code doesn't kill flags.
profile_branch(x, cond);
move_to_phi(x->state());
if (x->x()->type()->is_float_kind()) {
} else {
}
}
#ifdef _LP64
#else
return result;
#endif //
}
}
CodeEmitInfo* info) {
// Transfer the value atomically by using FP moves. This means
// the value has to be moved between CPU and FPU registers. It
// always has to be moved through spill slot since there's no
// quick way to pack the value into an SSE register.
} else {
}
}
CodeEmitInfo* info) {
// Transfer the value atomically by using FP moves. This means
// the value has to be moved between CPU and FPU registers. In
// SSE0 and SSE1 mode it has to be moved through spill slot but in
// SSE2+ mode it can be moved directly.
if (UseSSE < 2) {
// no spill slot needed in SSE2 mode because xmm->cpu register move is possible
}
} else {
}
}
} else {
}
}
} else {
if (is_obj) {
// Do the pre-write barrier, if any.
// Seems to be a precise address
} else {
}
}
}
assert (type == T_INT || (!x->is_add() && is_obj) LP64_ONLY( || type == T_LONG ), "unexpected type");
if (offset->is_constant()) {
#ifdef _LP64
} else {
}
#else
#endif
} else {
}
}
if (x->is_add()) {
} else {
if (is_obj) {
// Do the pre-write barrier, if any.
}
if (is_obj) {
// Seems to be a precise address
}
}
}