2456 } |
2456 } |
2457 } |
2457 } |
2458 |
2458 |
2459 //------------------------------make_slow_call_ex------------------------------ |
2459 //------------------------------make_slow_call_ex------------------------------ |
2460 // Make the exception handler hookups for the slow call |
2460 // Make the exception handler hookups for the slow call |
2461 void GraphKit::make_slow_call_ex(Node* call, ciInstanceKlass* ex_klass, bool separate_io_proj) { |
2461 void GraphKit::make_slow_call_ex(Node* call, ciInstanceKlass* ex_klass, bool separate_io_proj, bool deoptimize) { |
2462 if (stopped()) return; |
2462 if (stopped()) return; |
2463 |
2463 |
2464 // Make a catch node with just two handlers: fall-through and catch-all |
2464 // Make a catch node with just two handlers: fall-through and catch-all |
2465 Node* i_o = _gvn.transform( new (C) ProjNode(call, TypeFunc::I_O, separate_io_proj) ); |
2465 Node* i_o = _gvn.transform( new (C) ProjNode(call, TypeFunc::I_O, separate_io_proj) ); |
2466 Node* catc = _gvn.transform( new (C) CatchNode(control(), i_o, 2) ); |
2466 Node* catc = _gvn.transform( new (C) CatchNode(control(), i_o, 2) ); |
2470 { PreserveJVMState pjvms(this); |
2470 { PreserveJVMState pjvms(this); |
2471 set_control(excp); |
2471 set_control(excp); |
2472 set_i_o(i_o); |
2472 set_i_o(i_o); |
2473 |
2473 |
2474 if (excp != top()) { |
2474 if (excp != top()) { |
2475 // Create an exception state also. |
2475 if (deoptimize) { |
2476 // Use an exact type if the caller has specified a specific exception. |
2476 // Deoptimize if an exception is caught. Don't construct exception state in this case. |
2477 const Type* ex_type = TypeOopPtr::make_from_klass_unique(ex_klass)->cast_to_ptr_type(TypePtr::NotNull); |
2477 uncommon_trap(Deoptimization::Reason_unhandled, |
2478 Node* ex_oop = new (C) CreateExNode(ex_type, control(), i_o); |
2478 Deoptimization::Action_none); |
2479 add_exception_state(make_exception_state(_gvn.transform(ex_oop))); |
2479 } else { |
|
2480 // Create an exception state also. |
|
2481 // Use an exact type if the caller has specified a specific exception. |
|
2482 const Type* ex_type = TypeOopPtr::make_from_klass_unique(ex_klass)->cast_to_ptr_type(TypePtr::NotNull); |
|
2483 Node* ex_oop = new (C) CreateExNode(ex_type, control(), i_o); |
|
2484 add_exception_state(make_exception_state(_gvn.transform(ex_oop))); |
|
2485 } |
2480 } |
2486 } |
2481 } |
2487 } |
2482 |
2488 |
2483 // Get the no-exception control from the CatchNode. |
2489 // Get the no-exception control from the CatchNode. |
2484 set_control(norm); |
2490 set_control(norm); |
3288 kit.set_memory(init_out_raw, alias_idx); |
3294 kit.set_memory(init_out_raw, alias_idx); |
3289 } |
3295 } |
3290 |
3296 |
3291 //---------------------------set_output_for_allocation------------------------- |
3297 //---------------------------set_output_for_allocation------------------------- |
3292 Node* GraphKit::set_output_for_allocation(AllocateNode* alloc, |
3298 Node* GraphKit::set_output_for_allocation(AllocateNode* alloc, |
3293 const TypeOopPtr* oop_type) { |
3299 const TypeOopPtr* oop_type, |
|
3300 bool deoptimize_on_exception) { |
3294 int rawidx = Compile::AliasIdxRaw; |
3301 int rawidx = Compile::AliasIdxRaw; |
3295 alloc->set_req( TypeFunc::FramePtr, frameptr() ); |
3302 alloc->set_req( TypeFunc::FramePtr, frameptr() ); |
3296 add_safepoint_edges(alloc); |
3303 add_safepoint_edges(alloc); |
3297 Node* allocx = _gvn.transform(alloc); |
3304 Node* allocx = _gvn.transform(alloc); |
3298 set_control( _gvn.transform(new (C) ProjNode(allocx, TypeFunc::Control) ) ); |
3305 set_control( _gvn.transform(new (C) ProjNode(allocx, TypeFunc::Control) ) ); |
3299 // create memory projection for i_o |
3306 // create memory projection for i_o |
3300 set_memory ( _gvn.transform( new (C) ProjNode(allocx, TypeFunc::Memory, true) ), rawidx ); |
3307 set_memory ( _gvn.transform( new (C) ProjNode(allocx, TypeFunc::Memory, true) ), rawidx ); |
3301 make_slow_call_ex(allocx, env()->Throwable_klass(), true); |
3308 make_slow_call_ex(allocx, env()->Throwable_klass(), true, deoptimize_on_exception); |
3302 |
3309 |
3303 // create a memory projection as for the normal control path |
3310 // create a memory projection as for the normal control path |
3304 Node* malloc = _gvn.transform(new (C) ProjNode(allocx, TypeFunc::Memory)); |
3311 Node* malloc = _gvn.transform(new (C) ProjNode(allocx, TypeFunc::Memory)); |
3305 set_memory(malloc, rawidx); |
3312 set_memory(malloc, rawidx); |
3306 |
3313 |
3374 // for either, and the graph will fold nicely if the optimizer later reduces |
3381 // for either, and the graph will fold nicely if the optimizer later reduces |
3375 // the type to a constant. |
3382 // the type to a constant. |
3376 // The optional arguments are for specialized use by intrinsics: |
3383 // The optional arguments are for specialized use by intrinsics: |
3377 // - If 'extra_slow_test' if not null is an extra condition for the slow-path. |
3384 // - If 'extra_slow_test' if not null is an extra condition for the slow-path. |
3378 // - If 'return_size_val', report the the total object size to the caller. |
3385 // - If 'return_size_val', report the the total object size to the caller. |
|
3386 // - deoptimize_on_exception controls how Java exceptions are handled (rethrow vs deoptimize) |
3379 Node* GraphKit::new_instance(Node* klass_node, |
3387 Node* GraphKit::new_instance(Node* klass_node, |
3380 Node* extra_slow_test, |
3388 Node* extra_slow_test, |
3381 Node* *return_size_val) { |
3389 Node* *return_size_val, |
|
3390 bool deoptimize_on_exception) { |
3382 // Compute size in doublewords |
3391 // Compute size in doublewords |
3383 // The size is always an integral number of doublewords, represented |
3392 // The size is always an integral number of doublewords, represented |
3384 // as a positive bytewise size stored in the klass's layout_helper. |
3393 // as a positive bytewise size stored in the klass's layout_helper. |
3385 // The layout_helper also encodes (in a low bit) the need for a slow path. |
3394 // The layout_helper also encodes (in a low bit) the need for a slow path. |
3386 jint layout_con = Klass::_lh_neutral_value; |
3395 jint layout_con = Klass::_lh_neutral_value; |
3445 = new (C) AllocateNode(C, AllocateNode::alloc_type(Type::TOP), |
3454 = new (C) AllocateNode(C, AllocateNode::alloc_type(Type::TOP), |
3446 control(), mem, i_o(), |
3455 control(), mem, i_o(), |
3447 size, klass_node, |
3456 size, klass_node, |
3448 initial_slow_test); |
3457 initial_slow_test); |
3449 |
3458 |
3450 return set_output_for_allocation(alloc, oop_type); |
3459 return set_output_for_allocation(alloc, oop_type, deoptimize_on_exception); |
3451 } |
3460 } |
3452 |
3461 |
3453 //-------------------------------new_array------------------------------------- |
3462 //-------------------------------new_array------------------------------------- |
3454 // helper for both newarray and anewarray |
3463 // helper for both newarray and anewarray |
3455 // The 'length' parameter is (obviously) the length of the array. |
3464 // The 'length' parameter is (obviously) the length of the array. |
3456 // See comments on new_instance for the meaning of the other arguments. |
3465 // See comments on new_instance for the meaning of the other arguments. |
3457 Node* GraphKit::new_array(Node* klass_node, // array klass (maybe variable) |
3466 Node* GraphKit::new_array(Node* klass_node, // array klass (maybe variable) |
3458 Node* length, // number of array elements |
3467 Node* length, // number of array elements |
3459 int nargs, // number of arguments to push back for uncommon trap |
3468 int nargs, // number of arguments to push back for uncommon trap |
3460 Node* *return_size_val) { |
3469 Node* *return_size_val, |
|
3470 bool deoptimize_on_exception) { |
3461 jint layout_con = Klass::_lh_neutral_value; |
3471 jint layout_con = Klass::_lh_neutral_value; |
3462 Node* layout_val = get_layout_helper(klass_node, layout_con); |
3472 Node* layout_val = get_layout_helper(klass_node, layout_con); |
3463 int layout_is_con = (layout_val == NULL); |
3473 int layout_is_con = (layout_val == NULL); |
3464 |
3474 |
3465 if (!layout_is_con && !StressReflectiveCode && |
3475 if (!layout_is_con && !StressReflectiveCode && |
3598 if (ary_type->isa_aryptr() && length_type != NULL) { |
3608 if (ary_type->isa_aryptr() && length_type != NULL) { |
3599 // Try to get a better type than POS for the size |
3609 // Try to get a better type than POS for the size |
3600 ary_type = ary_type->is_aryptr()->cast_to_size(length_type); |
3610 ary_type = ary_type->is_aryptr()->cast_to_size(length_type); |
3601 } |
3611 } |
3602 |
3612 |
3603 Node* javaoop = set_output_for_allocation(alloc, ary_type); |
3613 Node* javaoop = set_output_for_allocation(alloc, ary_type, deoptimize_on_exception); |
3604 |
3614 |
3605 // Cast length on remaining path to be as narrow as possible |
3615 // Cast length on remaining path to be as narrow as possible |
3606 if (map()->find_edge(length) >= 0) { |
3616 if (map()->find_edge(length) >= 0) { |
3607 Node* ccast = alloc->make_ideal_length(ary_type, &_gvn); |
3617 Node* ccast = alloc->make_ideal_length(ary_type, &_gvn); |
3608 if (ccast != length) { |
3618 if (ccast != length) { |