< prev index next >

src/hotspot/share/c1/c1_GraphBuilder.cpp

Print this page




 589     if (con) {
 590       switch (con->type()->tag()) {
 591         case intTag:    return con->type()->as_IntConstant()->value() == 0;
 592         case longTag:   return con->type()->as_LongConstant()->value() == 0;
 593         case floatTag:  return jint_cast(con->type()->as_FloatConstant()->value()) == 0;
 594         case doubleTag: return jlong_cast(con->type()->as_DoubleConstant()->value()) == jlong_cast(0);
 595         case objectTag: return con->type() == objectNull;
 596         default:  ShouldNotReachHere();
 597       }
 598     }
 599     return false;
 600   }
 601 
 602 
 603   // return either the actual value of a load or the load itself
 604   Value load(LoadField* load) {
 605     if (!EliminateFieldAccess) {
 606       return load;
 607     }
 608 
 609     if (RoundFPResults && UseSSE < 2 && load->type()->is_float_kind()) {
 610       // can't skip load since value might get rounded as a side effect
 611       return load;
 612     }
 613 
 614     ciField* field = load->field();
 615     Value object   = load->obj();
 616     if (field->holder()->is_loaded() && !field->is_volatile()) {
 617       int offset = field->offset();
 618       Value result = NULL;
 619       int index = _newobjects.find(object);
 620       if (index != -1) {
 621         result = _fields.at(index)->at(field);
 622       } else if (_objects.at_grow(offset, NULL) == object) {
 623         result = _values.at(field);
 624       }
 625       if (result != NULL) {
 626 #ifndef PRODUCT
 627         if (PrintIRDuringConstruction && Verbose) {
 628           tty->print_cr("Eliminated load: ");
 629           load->print_line();


2248   while (i-- > 0) dims->at_put(i, ipop());
2249   // create array
2250   NewArray* n = new NewMultiArray(klass, dims, state_before);
2251   apush(append_split(n));
2252 }
2253 
2254 
2255 void GraphBuilder::throw_op(int bci) {
2256   // We require that the debug info for a Throw be the "state before"
2257   // the Throw (i.e., exception oop is still on TOS)
2258   ValueStack* state_before = copy_state_before_with_bci(bci);
2259   Throw* t = new Throw(apop(), state_before);
2260   // operand stack not needed after a throw
2261   state()->truncate_stack(0);
2262   append_with_bci(t, bci);
2263 }
2264 
2265 
2266 Value GraphBuilder::round_fp(Value fp_value) {
2267   // no rounding needed if SSE2 is used
2268   if (RoundFPResults && UseSSE < 2) {
2269     // Must currently insert rounding node for doubleword values that
2270     // are results of expressions (i.e., not loads from memory or
2271     // constants)
2272     if (fp_value->type()->tag() == doubleTag &&
2273         fp_value->as_Constant() == NULL &&
2274         fp_value->as_Local() == NULL &&       // method parameters need no rounding
2275         fp_value->as_RoundFP() == NULL) {
2276       return append(new RoundFP(fp_value));
2277     }
2278   }
2279   return fp_value;
2280 }
2281 
2282 
2283 Instruction* GraphBuilder::append_with_bci(Instruction* instr, int bci) {
2284   Canonicalizer canon(compilation(), instr, bci);
2285   Instruction* i1 = canon.canonical();
2286   if (i1->is_linked() || !i1->can_be_linked()) {
2287     // Canonicalizer returned an instruction which was already
2288     // appended so simply return it.


3747 
3748 bool GraphBuilder::try_inline_full(ciMethod* callee, bool holder_known, bool ignore_return, Bytecodes::Code bc, Value receiver) {
3749   assert(!callee->is_native(), "callee must not be native");
3750   if (CompilationPolicy::policy()->should_not_inline(compilation()->env(), callee)) {
3751     INLINE_BAILOUT("inlining prohibited by policy");
3752   }
3753   // first perform tests of things it's not possible to inline
3754   if (callee->has_exception_handlers() &&
3755       !InlineMethodsWithExceptionHandlers) INLINE_BAILOUT("callee has exception handlers");
3756   if (callee->is_synchronized() &&
3757       !InlineSynchronizedMethods         ) INLINE_BAILOUT("callee is synchronized");
3758   if (!callee->holder()->is_initialized()) INLINE_BAILOUT("callee's klass not initialized yet");
3759   if (!callee->has_balanced_monitors())    INLINE_BAILOUT("callee's monitors do not match");
3760 
3761   // Proper inlining of methods with jsrs requires a little more work.
3762   if (callee->has_jsrs()                 ) INLINE_BAILOUT("jsrs not handled properly by inliner yet");
3763 
3764   // When SSE2 is used on intel, then no special handling is needed
3765   // for strictfp because the enum-constant is fixed at compile time,
3766   // the check for UseSSE2 is needed here
3767   if (strict_fp_requires_explicit_rounding && UseSSE < 2 && method()->is_strict() != callee->is_strict()) {
3768     INLINE_BAILOUT("caller and callee have different strict fp requirements");
3769   }
3770 
3771   if (is_profiling() && !callee->ensure_method_data()) {
3772     INLINE_BAILOUT("mdo allocation failed");
3773   }
3774 
3775   // now perform tests that are based on flag settings
3776   bool inlinee_by_directive = compilation()->directive()->should_inline(callee);
3777   if (callee->force_inline() || inlinee_by_directive) {
3778     if (inline_level() > MaxForceInlineLevel                    ) INLINE_BAILOUT("MaxForceInlineLevel");
3779     if (recursive_inline_level(callee) > MaxRecursiveInlineLevel) INLINE_BAILOUT("recursive inlining too deep");
3780 
3781     const char* msg = "";
3782     if (callee->force_inline())  msg = "force inline by annotation";
3783     if (inlinee_by_directive)    msg = "force inline by CompileCommand";
3784     print_inlining(callee, msg);
3785   } else {
3786     // use heuristic controls on inlining
3787     if (inline_level() > MaxInlineLevel                         ) INLINE_BAILOUT("inlining too deep");




 589     if (con) {
 590       switch (con->type()->tag()) {
 591         case intTag:    return con->type()->as_IntConstant()->value() == 0;
 592         case longTag:   return con->type()->as_LongConstant()->value() == 0;
 593         case floatTag:  return jint_cast(con->type()->as_FloatConstant()->value()) == 0;
 594         case doubleTag: return jlong_cast(con->type()->as_DoubleConstant()->value()) == jlong_cast(0);
 595         case objectTag: return con->type() == objectNull;
 596         default:  ShouldNotReachHere();
 597       }
 598     }
 599     return false;
 600   }
 601 
 602 
 603   // return either the actual value of a load or the load itself
 604   Value load(LoadField* load) {
 605     if (!EliminateFieldAccess) {
 606       return load;
 607     }
 608 
 609     if (RoundFPResults X86_ONLY(&& UseSSE < 2) && load->type()->is_float_kind()) {
 610       // can't skip load since value might get rounded as a side effect
 611       return load;
 612     }
 613 
 614     ciField* field = load->field();
 615     Value object   = load->obj();
 616     if (field->holder()->is_loaded() && !field->is_volatile()) {
 617       int offset = field->offset();
 618       Value result = NULL;
 619       int index = _newobjects.find(object);
 620       if (index != -1) {
 621         result = _fields.at(index)->at(field);
 622       } else if (_objects.at_grow(offset, NULL) == object) {
 623         result = _values.at(field);
 624       }
 625       if (result != NULL) {
 626 #ifndef PRODUCT
 627         if (PrintIRDuringConstruction && Verbose) {
 628           tty->print_cr("Eliminated load: ");
 629           load->print_line();


2248   while (i-- > 0) dims->at_put(i, ipop());
2249   // create array
2250   NewArray* n = new NewMultiArray(klass, dims, state_before);
2251   apush(append_split(n));
2252 }
2253 
2254 
2255 void GraphBuilder::throw_op(int bci) {
2256   // We require that the debug info for a Throw be the "state before"
2257   // the Throw (i.e., exception oop is still on TOS)
2258   ValueStack* state_before = copy_state_before_with_bci(bci);
2259   Throw* t = new Throw(apop(), state_before);
2260   // operand stack not needed after a throw
2261   state()->truncate_stack(0);
2262   append_with_bci(t, bci);
2263 }
2264 
2265 
2266 Value GraphBuilder::round_fp(Value fp_value) {
2267   // no rounding needed if SSE2 is used
2268   if (RoundFPResults X86_ONLY(&& UseSSE < 2)) {
2269     // Must currently insert rounding node for doubleword values that
2270     // are results of expressions (i.e., not loads from memory or
2271     // constants)
2272     if (fp_value->type()->tag() == doubleTag &&
2273         fp_value->as_Constant() == NULL &&
2274         fp_value->as_Local() == NULL &&       // method parameters need no rounding
2275         fp_value->as_RoundFP() == NULL) {
2276       return append(new RoundFP(fp_value));
2277     }
2278   }
2279   return fp_value;
2280 }
2281 
2282 
2283 Instruction* GraphBuilder::append_with_bci(Instruction* instr, int bci) {
2284   Canonicalizer canon(compilation(), instr, bci);
2285   Instruction* i1 = canon.canonical();
2286   if (i1->is_linked() || !i1->can_be_linked()) {
2287     // Canonicalizer returned an instruction which was already
2288     // appended so simply return it.


3747 
3748 bool GraphBuilder::try_inline_full(ciMethod* callee, bool holder_known, bool ignore_return, Bytecodes::Code bc, Value receiver) {
3749   assert(!callee->is_native(), "callee must not be native");
3750   if (CompilationPolicy::policy()->should_not_inline(compilation()->env(), callee)) {
3751     INLINE_BAILOUT("inlining prohibited by policy");
3752   }
3753   // first perform tests of things it's not possible to inline
3754   if (callee->has_exception_handlers() &&
3755       !InlineMethodsWithExceptionHandlers) INLINE_BAILOUT("callee has exception handlers");
3756   if (callee->is_synchronized() &&
3757       !InlineSynchronizedMethods         ) INLINE_BAILOUT("callee is synchronized");
3758   if (!callee->holder()->is_initialized()) INLINE_BAILOUT("callee's klass not initialized yet");
3759   if (!callee->has_balanced_monitors())    INLINE_BAILOUT("callee's monitors do not match");
3760 
3761   // Proper inlining of methods with jsrs requires a little more work.
3762   if (callee->has_jsrs()                 ) INLINE_BAILOUT("jsrs not handled properly by inliner yet");
3763 
3764   // When SSE2 is used on intel, then no special handling is needed
3765   // for strictfp because the enum-constant is fixed at compile time,
3766   // the check for UseSSE2 is needed here
3767   if (strict_fp_requires_explicit_rounding X86_ONLY(&& UseSSE < 2) && method()->is_strict() != callee->is_strict()) {
3768     INLINE_BAILOUT("caller and callee have different strict fp requirements");
3769   }
3770 
3771   if (is_profiling() && !callee->ensure_method_data()) {
3772     INLINE_BAILOUT("mdo allocation failed");
3773   }
3774 
3775   // now perform tests that are based on flag settings
3776   bool inlinee_by_directive = compilation()->directive()->should_inline(callee);
3777   if (callee->force_inline() || inlinee_by_directive) {
3778     if (inline_level() > MaxForceInlineLevel                    ) INLINE_BAILOUT("MaxForceInlineLevel");
3779     if (recursive_inline_level(callee) > MaxRecursiveInlineLevel) INLINE_BAILOUT("recursive inlining too deep");
3780 
3781     const char* msg = "";
3782     if (callee->force_inline())  msg = "force inline by annotation";
3783     if (inlinee_by_directive)    msg = "force inline by CompileCommand";
3784     print_inlining(callee, msg);
3785   } else {
3786     // use heuristic controls on inlining
3787     if (inline_level() > MaxInlineLevel                         ) INLINE_BAILOUT("inlining too deep");


< prev index next >