c1_LIRGenerator.cpp revision 2008
1472N/A * or visit www.oracle.com if you need additional information or have any
1879N/A#include "precompiled.hpp"
1879N/A#include "c1/c1_Compilation.hpp"
1879N/A#include "c1/c1_FrameMap.hpp"
1879N/A#include "c1/c1_Instruction.hpp"
1879N/A#include "c1/c1_LIRAssembler.hpp"
1879N/A#include "c1/c1_LIRGenerator.hpp"
1879N/A#include "c1/c1_ValueStack.hpp"
1879N/A#include "ci/ciArrayKlass.hpp"
1879N/A#include "ci/ciCPCache.hpp"
1879N/A#include "ci/ciInstance.hpp"
1879N/A#include "runtime/sharedRuntime.hpp"
1879N/A#include "runtime/stubRoutines.hpp"
1879N/A#include "utilities/bitMap.inline.hpp"
1879N/A#include "gc_implementation/g1/heapRegion.hpp"
0N/A assert(value()->operand()->is_illegal() || value()->operand()->is_constant(), "operand should never change");
0N/A if (PrintIRWithLIR) {
0N/A if (LIRTraceExecution &&
0N/A if (PrintIRWithLIR) {
0N/A assert(instr->operand() != LIR_OprFact::illegalOpr || instr->as_Constant() != NULL, "this root has not yet been visited");
0N/A // assert(instr->use_count() > 0 || instr->as_Phi() != NULL, "leaf instruction must have a use");
0N/ACodeEmitInfo* LIRGenerator::state_for(Instruction* x, ValueStack* state, bool ignore_xhandler) {
1739N/A for_each_state(s) {
1739N/A assert(s->stack_size() == 0 && s->locals_size() == 0 && (s->locks_size() == 0 || s->locks_size() == 1), "state must be empty");
0N/Avoid LIRGenerator::nio_range_check(LIR_Opr buffer, LIR_Opr index, LIR_Opr result, CodeEmitInfo* info) {
0N/A cmp_mem_int(lir_cond_belowEqual, buffer, java_nio_Buffer::limit_offset(), index->as_jint(), info);
0N/Avoid LIRGenerator::arithmetic_op(Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, bool is_strictfp, LIR_Opr tmp_op, CodeEmitInfo* info) {
0N/A if (is_strictfp) {
0N/A bool did_strength_reduce = false;
0N/A if (is_power_of_2(c)) {
0N/A did_strength_reduce = true;
0N/A if (!did_strength_reduce) {
0N/A if (is_strictfp) {
0N/A default: ShouldNotReachHere();
0N/Avoid LIRGenerator::arithmetic_op_int(Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr tmp) {
0N/Avoid LIRGenerator::arithmetic_op_long(Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, CodeEmitInfo* info) {
0N/Avoid LIRGenerator::arithmetic_op_fpu(Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, bool is_strictfp, LIR_Opr tmp) {
0N/Avoid LIRGenerator::shift_op(Bytecodes::Code code, LIR_Opr result_op, LIR_Opr value, LIR_Opr count, LIR_Opr tmp) {
0N/A default: ShouldNotReachHere();
0N/Avoid LIRGenerator::logic_op (Bytecodes::Code code, LIR_Opr result_op, LIR_Opr left_op, LIR_Opr right_op) {
0N/A default: ShouldNotReachHere();
0N/Avoid LIRGenerator::monitor_enter(LIR_Opr object, LIR_Opr lock, LIR_Opr hdr, LIR_Opr scratch, int monitor_no, CodeEmitInfo* info_for_exception, CodeEmitInfo* info) {
0N/A if (!GenerateSynchronizationCode) return;
0N/A // for handling NullPointerException, use debug info representing just the lock stack before this monitorenter
1601N/Avoid LIRGenerator::monitor_exit(LIR_Opr object, LIR_Opr lock, LIR_Opr new_hdr, LIR_Opr scratch, int monitor_no) {
0N/A if (!GenerateSynchronizationCode) return;
0N/Avoid LIRGenerator::new_instance(LIR_Opr dst, ciInstanceKlass* klass, LIR_Opr scratch1, LIR_Opr scratch2, LIR_Opr scratch3, LIR_Opr scratch4, LIR_Opr klass_reg, CodeEmitInfo* info) {
0N/A Runtime1::StubID stub_id = klass->is_initialized() ? Runtime1::fast_new_instance_id : Runtime1::fast_new_instance_init_check_id;
0N/A CodeStub* slow_path = new NewInstanceStub(klass_reg, dst, klass, info, Runtime1::new_instance_id);
1703N/A int t = taken_count_offset;
0N/A LIR_Address* fake_incr_value = new LIR_Address(data_reg, DataLayout::counter_increment, T_INT);
0N/A assert(block()->is_set(BlockBegin::exception_entry_flag), "ExceptionObject only allowed in exception handler block");
1909N/A __ move_wide(new LIR_Address(thread_reg, in_bytes(JavaThread::exception_oop_offset()), T_OBJECT),
0N/A// Code for a constant is generated lazily unless the constant is frequently used and can't be inlined.
0N/A call_runtime(&signature, args, CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit), voidType, NULL);
0N/A set_no_result(x);
0N/A if (x->needs_null_check()) {
0N/A __ move(new LIR_Address(rcvr.result(), oopDesc::klass_offset_in_bytes(), T_OBJECT), result, info);
1909N/A __ move_wide(new LIR_Address(getThreadPointer(), in_bytes(JavaThread::threadObj_offset()), T_OBJECT), reg);
0N/A set_no_result(x);
342N/Avoid LIRGenerator::G1SATBCardTableModRef_pre_barrier(LIR_Opr addr_opr, bool patch, CodeEmitInfo* info) {
342N/A if (G1DisablePreBarrier) return;
342N/Avoid LIRGenerator::G1SATBCardTableModRef_post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val) {
342N/A if (G1DisablePostBarrier) return;
342N/A if (TwoOperandLIRForm ) {
342N/A assert(sizeof(*((CardTableModRefBS*)_bs)->byte_map_base) == sizeof(jbyte), "adjust this code");
1601N/A __ move(new LIR_Address(FrameMap::Rthread_opr, in_bytes(JavaThread::card_table_base_offset()), T_ADDRESS), tmp);
1601N/A LIR_Address *card_addr = new LIR_Address(tmp, addr, (LIR_Address::Scale) -CardTableModRefBS::card_shift, 0, T_BYTE);
0N/A if (TwoOperandLIRForm) {
0N/A// Comment copied form templateTable_i486.cpp
0N/A// JMM's ReadAfterWrite.java test fails in -Xint mode without some kind of
0N/A if (needs_patching) {
0N/A } else if (x->needs_null_check()) {
0N/A set_no_result(x);
0N/A if (x->needs_null_check() &&
0N/A (needs_patching ||
0N/A if (needs_patching) {
0N/A if (is_volatile) {
0N/A if (needs_patching) {
0N/A } else if (x->needs_null_check()) {
0N/A if (x->needs_null_check() &&
0N/A (needs_patching ||
0N/A if (needs_patching) {
0N/A if (is_volatile) {
0N/A//------------------------java.nio.Buffer.checkIndex------------------------
0N/A// int java.nio.Buffer.checkIndex(int)
0N/A if (GenerateRangeChecks) {
0N/A cmp_mem_int(lir_cond_belowEqual, buf.result(), java_nio_Buffer::limit_offset(), index.result()->as_jint(), info);
0N/A if (x->needs_null_check()) {
0N/A __ load(new LIR_Address(array.result(), arrayOopDesc::length_offset_in_bytes(), T_INT), reg, info, lir_patch_none);
0N/A bool needs_range_check = true;
0N/A if (use_length) {
0N/A if (needs_range_check) {
0N/A if (x->needs_null_check()) {
0N/A LIR_Address* array_addr = emit_array_address(array.result(), index.result(), x->elt_type(), false);
0N/A if (use_length) {
0N/A set_no_result(x);
0N/A if (PrintC1Statistics) {
0N/A bool type_is_exact = true;
0N/A type_is_exact = false;
0N/A if (GenerateCompilerNullChecks &&
1739N/A __ null_check(exception_opr, new CodeEmitInfo(info, x->state()->copy(ValueStack::ExceptionState, x->state()->bci())));
0N/A assert(input_opr->is_single_fpu() || input_opr->is_double_fpu(), "input should be floating-point value");
0N/A int log2_scale = 0;
0N/A int log2_scale = 0;
0N/A set_no_result(x);
0N/A if (log2_scale != 0) {
0N/A set_no_result(x);
0N/A set_no_result(x);
0N/A do_UnsafePrefetch(x, false);
0N/A do_UnsafePrefetch(x, true);
0N/Avoid LIRGenerator::do_SwitchRanges(SwitchRangeArray* x, LIR_Opr value, BlockBegin* default_sux) {
0N/A set_no_result(x);
0N/A if (x->is_safepoint()) {
0N/A if (UseTableRanges) {
0N/A set_no_result(x);
0N/A if (x->is_safepoint()) {
0N/A if (UseTableRanges) {
0N/A set_no_result(x);
0N/A if (x->is_safepoint()) {
1703N/A if (x->should_profile()) {
0N/A int java_index = 0;
1601N/A#ifndef __SOFTFP__
0N/A call_runtime(&signature, args, CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry), voidType, NULL);
1739N/A CodeEmitInfo* info = new CodeEmitInfo(scope()->start()->state()->copy(ValueStack::StateBefore, SynchronizationEntryBCI), NULL);
1745N/A CodeEmitInfo* info = new CodeEmitInfo(scope()->start()->state()->copy(ValueStack::StateBefore, SynchronizationEntryBCI), NULL);
0N/Avoid LIRGenerator::invoke_load_arguments(Invoke* x, LIRItemList* args, const LIR_OprList* arg_list) {
0N/A if (x->has_receiver()) {
0N/A if (x->has_receiver()) {
1295N/A if (x->is_invokedynamic()) {
0N/A for (int i = 0; i < x->number_of_arguments(); i++) {
0N/A return argument_items;
0N/A if (x->has_receiver()) {
0N/A assert(receiver->is_illegal() || receiver->is_equal(LIR_Assembler::receiverOpr()), "must match");
0N/A } else if (x->vtable_index() < 0) {
0N/A int entry_offset = instanceKlass::vtable_start_offset() + x->vtable_index() * vtableEntry::size();
1295N/A __ load(new LIR_Address(tmp, java_dyn_CallSite::target_offset_in_bytes(), T_OBJECT), receiver);
0N/A assert(ttag == addressTag || ttag == intTag || ttag == objectTag || ttag == longTag, "cannot handle others");
0N/A do_FPIntrinsics(x);
0N/A // java.nio.Buffer.checkIndex
0N/A do_AttemptUpdate(x);
0N/A default: ShouldNotReachHere(); break;
1703N/A // Increment the appropriate invocation/backedge counter and notify the runtime.
1703N/A increment_event_counter_impl(info, info->scope()->method(), (1 << freq_log) - 1, bci, backedge, true);
0N/ALIR_Opr LIRGenerator::call_runtime(Value arg1, address entry, ValueType* result_type, CodeEmitInfo* info) {