< prev index next >

src/hotspot/share/c1/c1_GraphBuilder.cpp

Print this page




1307     return; // bailed out while parsing and inlining subroutine
1308   }
1309 }
1310 
1311 
1312 void GraphBuilder::ret(int local_index) {
1313   if (!parsing_jsr()) BAILOUT("ret encountered while not parsing subroutine");
1314 
1315   if (local_index != scope_data()->jsr_return_address_local()) {
1316     BAILOUT("can not handle complicated jsr/ret constructs");
1317   }
1318 
1319   // Rets simply become (NON-SAFEPOINT) gotos to the jsr continuation
1320   append(new Goto(scope_data()->jsr_continuation(), false));
1321 }
1322 
1323 
1324 void GraphBuilder::table_switch() {
1325   Bytecode_tableswitch sw(stream());
1326   const int l = sw.length();
1327   if (CanonicalizeNodes && l == 1) {
1328     // total of 2 successors => use If instead of switch
1329     // Note: This code should go into the canonicalizer as soon as it can
1330     //       can handle canonicalized forms that contain more than one node.
1331     Value key = append(new Constant(new IntConstant(sw.low_key())));
1332     BlockBegin* tsux = block_at(bci() + sw.dest_offset_at(0));
1333     BlockBegin* fsux = block_at(bci() + sw.default_offset());
1334     bool is_bb = tsux->bci() < bci() || fsux->bci() < bci();
1335     // In case of loop invariant code motion or predicate insertion
1336     // before the body of a loop the state is needed
1337     ValueStack* state_before = copy_state_if_bb(is_bb);
1338     append(new If(ipop(), If::eql, true, key, tsux, fsux, state_before, is_bb));
1339   } else {
1340     // collect successors
1341     BlockList* sux = new BlockList(l + 1, NULL);
1342     int i;
1343     bool has_bb = false;
1344     for (i = 0; i < l; i++) {
1345       sux->at_put(i, block_at(bci() + sw.dest_offset_at(i)));
1346       if (sw.dest_offset_at(i) < 0) has_bb = true;
1347     }


1351     // In case of loop invariant code motion or predicate insertion
1352     // before the body of a loop the state is needed
1353     ValueStack* state_before = copy_state_if_bb(has_bb);
1354     Instruction* res = append(new TableSwitch(ipop(), sux, sw.low_key(), state_before, has_bb));
1355 #ifdef ASSERT
1356     if (res->as_Goto()) {
1357       for (i = 0; i < l; i++) {
1358         if (sux->at(i) == res->as_Goto()->sux_at(0)) {
1359           assert(res->as_Goto()->is_safepoint() == sw.dest_offset_at(i) < 0, "safepoint state of Goto returned by canonicalizer incorrect");
1360         }
1361       }
1362     }
1363 #endif
1364   }
1365 }
1366 
1367 
1368 void GraphBuilder::lookup_switch() {
1369   Bytecode_lookupswitch sw(stream());
1370   const int l = sw.number_of_pairs();
1371   if (CanonicalizeNodes && l == 1) {
1372     // total of 2 successors => use If instead of switch
1373     // Note: This code should go into the canonicalizer as soon as it can
1374     //       can handle canonicalized forms that contain more than one node.
1375     // simplify to If
1376     LookupswitchPair pair = sw.pair_at(0);
1377     Value key = append(new Constant(new IntConstant(pair.match())));
1378     BlockBegin* tsux = block_at(bci() + pair.offset());
1379     BlockBegin* fsux = block_at(bci() + sw.default_offset());
1380     bool is_bb = tsux->bci() < bci() || fsux->bci() < bci();
1381     // In case of loop invariant code motion or predicate insertion
1382     // before the body of a loop the state is needed
1383     ValueStack* state_before = copy_state_if_bb(is_bb);;
1384     append(new If(ipop(), If::eql, true, key, tsux, fsux, state_before, is_bb));
1385   } else {
1386     // collect successors & keys
1387     BlockList* sux = new BlockList(l + 1, NULL);
1388     intArray* keys = new intArray(l, l, 0);
1389     int i;
1390     bool has_bb = false;
1391     for (i = 0; i < l; i++) {




1307     return; // bailed out while parsing and inlining subroutine
1308   }
1309 }
1310 
1311 
1312 void GraphBuilder::ret(int local_index) {
1313   if (!parsing_jsr()) BAILOUT("ret encountered while not parsing subroutine");
1314 
1315   if (local_index != scope_data()->jsr_return_address_local()) {
1316     BAILOUT("can not handle complicated jsr/ret constructs");
1317   }
1318 
1319   // Rets simply become (NON-SAFEPOINT) gotos to the jsr continuation
1320   append(new Goto(scope_data()->jsr_continuation(), false));
1321 }
1322 
1323 
1324 void GraphBuilder::table_switch() {
1325   Bytecode_tableswitch sw(stream());
1326   const int l = sw.length();
1327   if (CanonicalizeNodes && l == 1 && compilation()->env()->comp_level() != CompLevel_full_profile) {
1328     // total of 2 successors => use If instead of switch
1329     // Note: This code should go into the canonicalizer as soon as it can
1330     //       can handle canonicalized forms that contain more than one node.
1331     Value key = append(new Constant(new IntConstant(sw.low_key())));
1332     BlockBegin* tsux = block_at(bci() + sw.dest_offset_at(0));
1333     BlockBegin* fsux = block_at(bci() + sw.default_offset());
1334     bool is_bb = tsux->bci() < bci() || fsux->bci() < bci();
1335     // In case of loop invariant code motion or predicate insertion
1336     // before the body of a loop the state is needed
1337     ValueStack* state_before = copy_state_if_bb(is_bb);
1338     append(new If(ipop(), If::eql, true, key, tsux, fsux, state_before, is_bb));
1339   } else {
1340     // collect successors
1341     BlockList* sux = new BlockList(l + 1, NULL);
1342     int i;
1343     bool has_bb = false;
1344     for (i = 0; i < l; i++) {
1345       sux->at_put(i, block_at(bci() + sw.dest_offset_at(i)));
1346       if (sw.dest_offset_at(i) < 0) has_bb = true;
1347     }


1351     // In case of loop invariant code motion or predicate insertion
1352     // before the body of a loop the state is needed
1353     ValueStack* state_before = copy_state_if_bb(has_bb);
1354     Instruction* res = append(new TableSwitch(ipop(), sux, sw.low_key(), state_before, has_bb));
1355 #ifdef ASSERT
1356     if (res->as_Goto()) {
1357       for (i = 0; i < l; i++) {
1358         if (sux->at(i) == res->as_Goto()->sux_at(0)) {
1359           assert(res->as_Goto()->is_safepoint() == sw.dest_offset_at(i) < 0, "safepoint state of Goto returned by canonicalizer incorrect");
1360         }
1361       }
1362     }
1363 #endif
1364   }
1365 }
1366 
1367 
1368 void GraphBuilder::lookup_switch() {
1369   Bytecode_lookupswitch sw(stream());
1370   const int l = sw.number_of_pairs();
1371   if (CanonicalizeNodes && l == 1 && compilation()->env()->comp_level() != CompLevel_full_profile) {
1372     // total of 2 successors => use If instead of switch
1373     // Note: This code should go into the canonicalizer as soon as it can
1374     //       can handle canonicalized forms that contain more than one node.
1375     // simplify to If
1376     LookupswitchPair pair = sw.pair_at(0);
1377     Value key = append(new Constant(new IntConstant(pair.match())));
1378     BlockBegin* tsux = block_at(bci() + pair.offset());
1379     BlockBegin* fsux = block_at(bci() + sw.default_offset());
1380     bool is_bb = tsux->bci() < bci() || fsux->bci() < bci();
1381     // In case of loop invariant code motion or predicate insertion
1382     // before the body of a loop the state is needed
1383     ValueStack* state_before = copy_state_if_bb(is_bb);;
1384     append(new If(ipop(), If::eql, true, key, tsux, fsux, state_before, is_bb));
1385   } else {
1386     // collect successors & keys
1387     BlockList* sux = new BlockList(l + 1, NULL);
1388     intArray* keys = new intArray(l, l, 0);
1389     int i;
1390     bool has_bb = false;
1391     for (i = 0; i < l; i++) {


< prev index next >