comparison src/share/vm/opto/graphKit.cpp @ 20804:7848fc12602b

Merge with jdk8u40-b25
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Tue, 07 Apr 2015 14:58:49 +0200
parents 52b4284cb496 e7b3d177adda
children
comparison
equal deleted inserted replaced
20184:84105dcdb05b 20804:7848fc12602b
426 _gvn.set_type(phi, dsttype); 426 _gvn.set_type(phi, dsttype);
427 } 427 }
428 } 428 }
429 } 429 }
430 } 430 }
431 phi_map->merge_replaced_nodes_with(ex_map);
431 } 432 }
432 433
433 //--------------------------use_exception_state-------------------------------- 434 //--------------------------use_exception_state--------------------------------
434 Node* GraphKit::use_exception_state(SafePointNode* phi_map) { 435 Node* GraphKit::use_exception_state(SafePointNode* phi_map) {
435 if (failing()) { stop(); return top(); } 436 if (failing()) { stop(); return top(); }
639 debug_only(kit->verify_map()); 640 debug_only(kit->verify_map());
640 _kit = kit; 641 _kit = kit;
641 _map = kit->map(); // preserve the map 642 _map = kit->map(); // preserve the map
642 _sp = kit->sp(); 643 _sp = kit->sp();
643 kit->set_map(clone_map ? kit->clone_map() : NULL); 644 kit->set_map(clone_map ? kit->clone_map() : NULL);
644 Compile::current()->inc_preserve_jvm_state();
645 #ifdef ASSERT 645 #ifdef ASSERT
646 _bci = kit->bci(); 646 _bci = kit->bci();
647 Parse* parser = kit->is_Parse(); 647 Parse* parser = kit->is_Parse();
648 int block = (parser == NULL || parser->block() == NULL) ? -1 : parser->block()->rpo(); 648 int block = (parser == NULL || parser->block() == NULL) ? -1 : parser->block()->rpo();
649 _block = block; 649 _block = block;
657 int block = (parser == NULL || parser->block() == NULL) ? -1 : parser->block()->rpo(); 657 int block = (parser == NULL || parser->block() == NULL) ? -1 : parser->block()->rpo();
658 assert(block == _block, "block must not shift"); 658 assert(block == _block, "block must not shift");
659 #endif 659 #endif
660 kit->set_map(_map); 660 kit->set_map(_map);
661 kit->set_sp(_sp); 661 kit->set_sp(_sp);
662 Compile::current()->dec_preserve_jvm_state();
663 } 662 }
664 663
665 664
666 //-----------------------------BuildCutout------------------------------------- 665 //-----------------------------BuildCutout-------------------------------------
667 BuildCutout::BuildCutout(GraphKit* kit, Node* p, float prob, float cnt) 666 BuildCutout::BuildCutout(GraphKit* kit, Node* p, float prob, float cnt)
1149 Node* GraphKit::load_object_klass(Node* obj) { 1148 Node* GraphKit::load_object_klass(Node* obj) {
1150 // Special-case a fresh allocation to avoid building nodes: 1149 // Special-case a fresh allocation to avoid building nodes:
1151 Node* akls = AllocateNode::Ideal_klass(obj, &_gvn); 1150 Node* akls = AllocateNode::Ideal_klass(obj, &_gvn);
1152 if (akls != NULL) return akls; 1151 if (akls != NULL) return akls;
1153 Node* k_adr = basic_plus_adr(obj, oopDesc::klass_offset_in_bytes()); 1152 Node* k_adr = basic_plus_adr(obj, oopDesc::klass_offset_in_bytes());
1154 return _gvn.transform( LoadKlassNode::make(_gvn, immutable_memory(), k_adr, TypeInstPtr::KLASS) ); 1153 return _gvn.transform(LoadKlassNode::make(_gvn, NULL, immutable_memory(), k_adr, TypeInstPtr::KLASS));
1155 } 1154 }
1156 1155
1157 //-------------------------load_array_length----------------------------------- 1156 //-------------------------load_array_length-----------------------------------
1158 Node* GraphKit::load_array_length(Node* array) { 1157 Node* GraphKit::load_array_length(Node* array) {
1159 // Special-case a fresh allocation to avoid building nodes: 1158 // Special-case a fresh allocation to avoid building nodes:
1396 1395
1397 // Note: This operation potentially replaces any edge 1396 // Note: This operation potentially replaces any edge
1398 // on the map. This includes locals, stack, and monitors 1397 // on the map. This includes locals, stack, and monitors
1399 // of the current (innermost) JVM state. 1398 // of the current (innermost) JVM state.
1400 1399
1401 if (!ReplaceInParentMaps) { 1400 // don't let inconsistent types from profiling escape this
1401 // method
1402
1403 const Type* told = _gvn.type(old);
1404 const Type* tnew = _gvn.type(neww);
1405
1406 if (!tnew->higher_equal(told)) {
1402 return; 1407 return;
1403 } 1408 }
1404 1409
1405 // PreserveJVMState doesn't do a deep copy so we can't modify 1410 map()->record_replaced_node(old, neww);
1406 // parents
1407 if (Compile::current()->has_preserve_jvm_state()) {
1408 return;
1409 }
1410
1411 Parse* parser = is_Parse();
1412 bool progress = true;
1413 Node* ctrl = map()->in(0);
1414 // Follow the chain of parsers and see whether the update can be
1415 // done in the map of callers. We can do the replace for a caller if
1416 // the current control post dominates the control of a caller.
1417 while (parser != NULL && parser->caller() != NULL && progress) {
1418 progress = false;
1419 Node* parent_map = parser->caller()->map();
1420 assert(parser->exits().map()->jvms()->depth() == parser->caller()->depth(), "map mismatch");
1421
1422 Node* parent_ctrl = parent_map->in(0);
1423
1424 while (parent_ctrl->is_Region()) {
1425 Node* n = parent_ctrl->as_Region()->is_copy();
1426 if (n == NULL) {
1427 break;
1428 }
1429 parent_ctrl = n;
1430 }
1431
1432 for (;;) {
1433 if (ctrl == parent_ctrl) {
1434 // update the map of the exits which is the one that will be
1435 // used when compilation resume after inlining
1436 parser->exits().map()->replace_edge(old, neww);
1437 progress = true;
1438 break;
1439 }
1440 if (ctrl->is_Proj() && ctrl->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none)) {
1441 ctrl = ctrl->in(0)->in(0);
1442 } else if (ctrl->is_Region()) {
1443 Node* n = ctrl->as_Region()->is_copy();
1444 if (n == NULL) {
1445 break;
1446 }
1447 ctrl = n;
1448 } else {
1449 break;
1450 }
1451 }
1452
1453 parser = parser->parent_parser();
1454 }
1455 } 1411 }
1456 1412
1457 1413
1458 //============================================================================= 1414 //=============================================================================
1459 //--------------------------------memory--------------------------------------- 1415 //--------------------------------memory---------------------------------------
1853 } 1809 }
1854 } 1810 }
1855 1811
1856 1812
1857 // Replace the call with the current state of the kit. 1813 // Replace the call with the current state of the kit.
1858 void GraphKit::replace_call(CallNode* call, Node* result) { 1814 void GraphKit::replace_call(CallNode* call, Node* result, bool do_replaced_nodes) {
1859 JVMState* ejvms = NULL; 1815 JVMState* ejvms = NULL;
1860 if (has_exceptions()) { 1816 if (has_exceptions()) {
1861 ejvms = transfer_exceptions_into_jvms(); 1817 ejvms = transfer_exceptions_into_jvms();
1862 } 1818 }
1819
1820 ReplacedNodes replaced_nodes = map()->replaced_nodes();
1821 ReplacedNodes replaced_nodes_exception;
1822 Node* ex_ctl = top();
1863 1823
1864 SafePointNode* final_state = stop(); 1824 SafePointNode* final_state = stop();
1865 1825
1866 // Find all the needed outputs of this call 1826 // Find all the needed outputs of this call
1867 CallProjections callprojs; 1827 CallProjections callprojs;
1875 // Replace all the old call edges with the edges from the inlining result 1835 // Replace all the old call edges with the edges from the inlining result
1876 if (callprojs.fallthrough_catchproj != NULL) { 1836 if (callprojs.fallthrough_catchproj != NULL) {
1877 C->gvn_replace_by(callprojs.fallthrough_catchproj, final_ctl); 1837 C->gvn_replace_by(callprojs.fallthrough_catchproj, final_ctl);
1878 } 1838 }
1879 if (callprojs.fallthrough_memproj != NULL) { 1839 if (callprojs.fallthrough_memproj != NULL) {
1840 if (final_mem->is_MergeMem()) {
1841 // Parser's exits MergeMem was not transformed but may be optimized
1842 final_mem = _gvn.transform(final_mem);
1843 }
1880 C->gvn_replace_by(callprojs.fallthrough_memproj, final_mem); 1844 C->gvn_replace_by(callprojs.fallthrough_memproj, final_mem);
1881 } 1845 }
1882 if (callprojs.fallthrough_ioproj != NULL) { 1846 if (callprojs.fallthrough_ioproj != NULL) {
1883 C->gvn_replace_by(callprojs.fallthrough_ioproj, final_io); 1847 C->gvn_replace_by(callprojs.fallthrough_ioproj, final_io);
1884 } 1848 }
1906 } else { 1870 } else {
1907 GraphKit ekit(ejvms); 1871 GraphKit ekit(ejvms);
1908 1872
1909 // Load my combined exception state into the kit, with all phis transformed: 1873 // Load my combined exception state into the kit, with all phis transformed:
1910 SafePointNode* ex_map = ekit.combine_and_pop_all_exception_states(); 1874 SafePointNode* ex_map = ekit.combine_and_pop_all_exception_states();
1875 replaced_nodes_exception = ex_map->replaced_nodes();
1911 1876
1912 Node* ex_oop = ekit.use_exception_state(ex_map); 1877 Node* ex_oop = ekit.use_exception_state(ex_map);
1878
1913 if (callprojs.catchall_catchproj != NULL) { 1879 if (callprojs.catchall_catchproj != NULL) {
1914 C->gvn_replace_by(callprojs.catchall_catchproj, ekit.control()); 1880 C->gvn_replace_by(callprojs.catchall_catchproj, ekit.control());
1881 ex_ctl = ekit.control();
1915 } 1882 }
1916 if (callprojs.catchall_memproj != NULL) { 1883 if (callprojs.catchall_memproj != NULL) {
1917 C->gvn_replace_by(callprojs.catchall_memproj, ekit.reset_memory()); 1884 C->gvn_replace_by(callprojs.catchall_memproj, ekit.reset_memory());
1918 } 1885 }
1919 if (callprojs.catchall_ioproj != NULL) { 1886 if (callprojs.catchall_ioproj != NULL) {
1941 } 1908 }
1942 } 1909 }
1943 while (wl.size() > 0) { 1910 while (wl.size() > 0) {
1944 _gvn.transform(wl.pop()); 1911 _gvn.transform(wl.pop());
1945 } 1912 }
1913 }
1914
1915 if (callprojs.fallthrough_catchproj != NULL && !final_ctl->is_top() && do_replaced_nodes) {
1916 replaced_nodes.apply(C, final_ctl);
1917 }
1918 if (!ex_ctl->is_top() && do_replaced_nodes) {
1919 replaced_nodes_exception.apply(C, ex_ctl);
1946 } 1920 }
1947 } 1921 }
1948 1922
1949 1923
1950 //------------------------------increment_counter------------------------------ 1924 //------------------------------increment_counter------------------------------
2433 for (MergeMemStream mms(merged_memory(), new_mem->as_MergeMem()); mms.next_non_empty2(); ) { 2407 for (MergeMemStream mms(merged_memory(), new_mem->as_MergeMem()); mms.next_non_empty2(); ) {
2434 Node* old_slice = mms.force_memory(); 2408 Node* old_slice = mms.force_memory();
2435 Node* new_slice = mms.memory2(); 2409 Node* new_slice = mms.memory2();
2436 if (old_slice != new_slice) { 2410 if (old_slice != new_slice) {
2437 PhiNode* phi; 2411 PhiNode* phi;
2438 if (new_slice->is_Phi() && new_slice->as_Phi()->region() == region) { 2412 if (old_slice->is_Phi() && old_slice->as_Phi()->region() == region) {
2439 phi = new_slice->as_Phi(); 2413 if (mms.is_empty()) {
2440 #ifdef ASSERT 2414 // clone base memory Phi's inputs for this memory slice
2441 if (old_slice->is_Phi() && old_slice->as_Phi()->region() == region) 2415 assert(old_slice == mms.base_memory(), "sanity");
2442 old_slice = old_slice->in(new_path); 2416 phi = PhiNode::make(region, NULL, Type::MEMORY, mms.adr_type(C));
2443 // Caller is responsible for ensuring that any pre-existing 2417 _gvn.set_type(phi, Type::MEMORY);
2444 // phis are already aware of old memory. 2418 for (uint i = 1; i < phi->req(); i++) {
2445 int old_path = (new_path > 1) ? 1 : 2; // choose old_path != new_path 2419 phi->init_req(i, old_slice->in(i));
2446 assert(phi->in(old_path) == old_slice, "pre-existing phis OK"); 2420 }
2447 #endif 2421 } else {
2448 mms.set_memory(phi); 2422 phi = old_slice->as_Phi(); // Phi was generated already
2423 }
2449 } else { 2424 } else {
2450 phi = PhiNode::make(region, old_slice, Type::MEMORY, mms.adr_type(C)); 2425 phi = PhiNode::make(region, old_slice, Type::MEMORY, mms.adr_type(C));
2451 _gvn.set_type(phi, Type::MEMORY); 2426 _gvn.set_type(phi, Type::MEMORY);
2452 phi->set_req(new_path, new_slice);
2453 mms.set_memory(_gvn.transform(phi)); // assume it is complete
2454 } 2427 }
2428 phi->set_req(new_path, new_slice);
2429 mms.set_memory(phi);
2455 } 2430 }
2456 } 2431 }
2457 } 2432 }
2458 2433
2459 //------------------------------make_slow_call_ex------------------------------ 2434 //------------------------------make_slow_call_ex------------------------------
2565 Node *p2 = _gvn.transform( new (C) AddPNode(subklass,subklass,chk_off_X) ); 2540 Node *p2 = _gvn.transform( new (C) AddPNode(subklass,subklass,chk_off_X) );
2566 // For some types like interfaces the following loadKlass is from a 1-word 2541 // For some types like interfaces the following loadKlass is from a 1-word
2567 // cache which is mutable so can't use immutable memory. Other 2542 // cache which is mutable so can't use immutable memory. Other
2568 // types load from the super-class display table which is immutable. 2543 // types load from the super-class display table which is immutable.
2569 Node *kmem = might_be_cache ? memory(p2) : immutable_memory(); 2544 Node *kmem = might_be_cache ? memory(p2) : immutable_memory();
2570 Node *nkls = _gvn.transform( LoadKlassNode::make( _gvn, kmem, p2, _gvn.type(p2)->is_ptr(), TypeKlassPtr::OBJECT_OR_NULL ) ); 2545 Node* nkls = _gvn.transform(LoadKlassNode::make(_gvn, NULL, kmem, p2, _gvn.type(p2)->is_ptr(), TypeKlassPtr::OBJECT_OR_NULL));
2571 2546
2572 // Compile speed common case: ARE a subtype and we canNOT fail 2547 // Compile speed common case: ARE a subtype and we canNOT fail
2573 if( superklass == nkls ) 2548 if( superklass == nkls )
2574 return top(); // false path is dead; no test needed. 2549 return top(); // false path is dead; no test needed.
2575 2550