Mercurial > hg > graal-jvmci-8
comparison src/share/vm/c1/c1_GraphBuilder.cpp @ 4966:701a83c86f28
7120481: storeStore barrier in constructor with final field
Summary: Issue storestore barrier before constructor return if the constructor write final field.
Reviewed-by: dholmes, jrose, roland, coleenp
Contributed-by: Jiangli Zhou <jiangli.zhou@oracle.com>
author | jiangli |
---|---|
date | Tue, 21 Feb 2012 13:14:55 -0500 |
parents | 80107dc493db |
children | e5f73be4c7f1 |
comparison
equal
deleted
inserted
replaced
4965:d79f8393df2b | 4966:701a83c86f28 |
---|---|
1416 if (RegisterFinalizersAtInit && | 1416 if (RegisterFinalizersAtInit && |
1417 method()->intrinsic_id() == vmIntrinsics::_Object_init) { | 1417 method()->intrinsic_id() == vmIntrinsics::_Object_init) { |
1418 call_register_finalizer(); | 1418 call_register_finalizer(); |
1419 } | 1419 } |
1420 | 1420 |
1421 bool need_mem_bar = false; | |
1422 if (method()->name() == ciSymbol::object_initializer_name() && | |
1423 scope()->wrote_final()) { | |
1424 need_mem_bar = true; | |
1425 } | |
1426 | |
1421 // Check to see whether we are inlining. If so, Return | 1427 // Check to see whether we are inlining. If so, Return |
1422 // instructions become Gotos to the continuation point. | 1428 // instructions become Gotos to the continuation point. |
1423 if (continuation() != NULL) { | 1429 if (continuation() != NULL) { |
1424 assert(!method()->is_synchronized() || InlineSynchronizedMethods, "can not inline synchronized methods yet"); | 1430 assert(!method()->is_synchronized() || InlineSynchronizedMethods, "can not inline synchronized methods yet"); |
1425 | 1431 |
1433 // If the inlined method is synchronized, the monitor must be | 1439 // If the inlined method is synchronized, the monitor must be |
1434 // released before we jump to the continuation block. | 1440 // released before we jump to the continuation block. |
1435 if (method()->is_synchronized()) { | 1441 if (method()->is_synchronized()) { |
1436 assert(state()->locks_size() == 1, "receiver must be locked here"); | 1442 assert(state()->locks_size() == 1, "receiver must be locked here"); |
1437 monitorexit(state()->lock_at(0), SynchronizationEntryBCI); | 1443 monitorexit(state()->lock_at(0), SynchronizationEntryBCI); |
1444 } | |
1445 | |
1446 if (need_mem_bar) { | |
1447 append(new MemBar(lir_membar_storestore)); | |
1438 } | 1448 } |
1439 | 1449 |
1440 // State at end of inlined method is the state of the caller | 1450 // State at end of inlined method is the state of the caller |
1441 // without the method parameters on stack, including the | 1451 // without the method parameters on stack, including the |
1442 // return value, if any, of the inlined method on operand stack. | 1452 // return value, if any, of the inlined method on operand stack. |
1454 | 1464 |
1455 // The current bci() is in the wrong scope, so use the bci() of | 1465 // The current bci() is in the wrong scope, so use the bci() of |
1456 // the continuation point. | 1466 // the continuation point. |
1457 append_with_bci(goto_callee, scope_data()->continuation()->bci()); | 1467 append_with_bci(goto_callee, scope_data()->continuation()->bci()); |
1458 incr_num_returns(); | 1468 incr_num_returns(); |
1459 | |
1460 return; | 1469 return; |
1461 } | 1470 } |
1462 | 1471 |
1463 state()->truncate_stack(0); | 1472 state()->truncate_stack(0); |
1464 if (method()->is_synchronized()) { | 1473 if (method()->is_synchronized()) { |
1468 receiver = _initial_state->local_at(0); | 1477 receiver = _initial_state->local_at(0); |
1469 } else { | 1478 } else { |
1470 receiver = append(new Constant(new ClassConstant(method()->holder()))); | 1479 receiver = append(new Constant(new ClassConstant(method()->holder()))); |
1471 } | 1480 } |
1472 append_split(new MonitorExit(receiver, state()->unlock())); | 1481 append_split(new MonitorExit(receiver, state()->unlock())); |
1482 } | |
1483 | |
1484 if (need_mem_bar) { | |
1485 append(new MemBar(lir_membar_storestore)); | |
1473 } | 1486 } |
1474 | 1487 |
1475 append(new Return(x)); | 1488 append(new Return(x)); |
1476 } | 1489 } |
1477 | 1490 |
1502 } else { | 1515 } else { |
1503 obj = new Constant(new InstanceConstant(holder->java_mirror())); | 1516 obj = new Constant(new InstanceConstant(holder->java_mirror())); |
1504 } | 1517 } |
1505 } | 1518 } |
1506 | 1519 |
1520 if (field->is_final() && (code == Bytecodes::_putfield)) { | |
1521 scope()->set_wrote_final(); | |
1522 } | |
1507 | 1523 |
1508 const int offset = !needs_patching ? field->offset() : -1; | 1524 const int offset = !needs_patching ? field->offset() : -1; |
1509 switch (code) { | 1525 switch (code) { |
1510 case Bytecodes::_getstatic: { | 1526 case Bytecodes::_getstatic: { |
1511 // check for compile-time constants, i.e., initialized static final fields | 1527 // check for compile-time constants, i.e., initialized static final fields |