Mercurial > hg > graal-compiler
comparison src/share/vm/c1/c1_GraphBuilder.cpp @ 2352:425688247f3d
6965570: assert(!needs_patching && x->is_loaded(),"how do we know it's volatile if it's not loaded")
Reviewed-by: iveresov
author | never |
---|---|
date | Sun, 06 Mar 2011 22:09:23 -0800 |
parents | 6f3746e69a78 |
children | c7f3d0b4570f |
comparison
equal
deleted
inserted
replaced
2351:8e72cd29b15d | 2352:425688247f3d |
---|---|
1454 ciField* field = stream()->get_field(will_link); | 1454 ciField* field = stream()->get_field(will_link); |
1455 ciInstanceKlass* holder = field->holder(); | 1455 ciInstanceKlass* holder = field->holder(); |
1456 BasicType field_type = field->type()->basic_type(); | 1456 BasicType field_type = field->type()->basic_type(); |
1457 ValueType* type = as_ValueType(field_type); | 1457 ValueType* type = as_ValueType(field_type); |
1458 // call will_link again to determine if the field is valid. | 1458 // call will_link again to determine if the field is valid. |
1459 const bool is_loaded = holder->is_loaded() && | 1459 const bool needs_patching = !holder->is_loaded() || |
1460 field->will_link(method()->holder(), code); | 1460 !field->will_link(method()->holder(), code) || |
1461 const bool is_initialized = is_loaded && holder->is_initialized(); | 1461 PatchALot; |
1462 | 1462 |
1463 ValueStack* state_before = NULL; | 1463 ValueStack* state_before = NULL; |
1464 if (!is_initialized || PatchALot) { | 1464 if (!holder->is_initialized() || needs_patching) { |
1465 // save state before instruction for debug info when | 1465 // save state before instruction for debug info when |
1466 // deoptimization happens during patching | 1466 // deoptimization happens during patching |
1467 state_before = copy_state_before(); | 1467 state_before = copy_state_before(); |
1468 } | 1468 } |
1469 | 1469 |
1470 Value obj = NULL; | 1470 Value obj = NULL; |
1471 if (code == Bytecodes::_getstatic || code == Bytecodes::_putstatic) { | 1471 if (code == Bytecodes::_getstatic || code == Bytecodes::_putstatic) { |
1472 // commoning of class constants should only occur if the class is | |
1473 // fully initialized and resolved in this constant pool. The will_link test | |
1474 // above essentially checks if this class is resolved in this constant pool | |
1475 // so, the is_initialized flag should be suffiect. | |
1476 if (state_before != NULL) { | 1472 if (state_before != NULL) { |
1477 // build a patching constant | 1473 // build a patching constant |
1478 obj = new Constant(new ClassConstant(holder), state_before); | 1474 obj = new Constant(new ClassConstant(holder), state_before); |
1479 } else { | 1475 } else { |
1480 obj = new Constant(new ClassConstant(holder)); | 1476 obj = new Constant(new ClassConstant(holder)); |
1481 } | 1477 } |
1482 } | 1478 } |
1483 | 1479 |
1484 | 1480 |
1485 const int offset = is_loaded ? field->offset() : -1; | 1481 const int offset = !needs_patching ? field->offset() : -1; |
1486 switch (code) { | 1482 switch (code) { |
1487 case Bytecodes::_getstatic: { | 1483 case Bytecodes::_getstatic: { |
1488 // check for compile-time constants, i.e., initialized static final fields | 1484 // check for compile-time constants, i.e., initialized static final fields |
1489 Instruction* constant = NULL; | 1485 Instruction* constant = NULL; |
1490 if (field->is_constant() && !PatchALot) { | 1486 if (field->is_constant() && !PatchALot) { |
1507 } else { | 1503 } else { |
1508 if (state_before == NULL) { | 1504 if (state_before == NULL) { |
1509 state_before = copy_state_for_exception(); | 1505 state_before = copy_state_for_exception(); |
1510 } | 1506 } |
1511 push(type, append(new LoadField(append(obj), offset, field, true, | 1507 push(type, append(new LoadField(append(obj), offset, field, true, |
1512 state_before, is_loaded, is_initialized))); | 1508 state_before, needs_patching))); |
1513 } | 1509 } |
1514 break; | 1510 break; |
1515 } | 1511 } |
1516 case Bytecodes::_putstatic: | 1512 case Bytecodes::_putstatic: |
1517 { Value val = pop(type); | 1513 { Value val = pop(type); |
1518 if (state_before == NULL) { | 1514 if (state_before == NULL) { |
1519 state_before = copy_state_for_exception(); | 1515 state_before = copy_state_for_exception(); |
1520 } | 1516 } |
1521 append(new StoreField(append(obj), offset, field, val, true, state_before, is_loaded, is_initialized)); | 1517 append(new StoreField(append(obj), offset, field, val, true, state_before, needs_patching)); |
1522 } | 1518 } |
1523 break; | 1519 break; |
1524 case Bytecodes::_getfield : | 1520 case Bytecodes::_getfield : |
1525 { | 1521 { |
1526 if (state_before == NULL) { | 1522 if (state_before == NULL) { |
1527 state_before = copy_state_for_exception(); | 1523 state_before = copy_state_for_exception(); |
1528 } | 1524 } |
1529 LoadField* load = new LoadField(apop(), offset, field, false, state_before, is_loaded, true); | 1525 LoadField* load = new LoadField(apop(), offset, field, false, state_before, needs_patching); |
1530 Value replacement = is_loaded ? _memory->load(load) : load; | 1526 Value replacement = !needs_patching ? _memory->load(load) : load; |
1531 if (replacement != load) { | 1527 if (replacement != load) { |
1532 assert(replacement->is_linked() || !replacement->can_be_linked(), "should already by linked"); | 1528 assert(replacement->is_linked() || !replacement->can_be_linked(), "should already by linked"); |
1533 push(type, replacement); | 1529 push(type, replacement); |
1534 } else { | 1530 } else { |
1535 push(type, append(load)); | 1531 push(type, append(load)); |
1540 case Bytecodes::_putfield : | 1536 case Bytecodes::_putfield : |
1541 { Value val = pop(type); | 1537 { Value val = pop(type); |
1542 if (state_before == NULL) { | 1538 if (state_before == NULL) { |
1543 state_before = copy_state_for_exception(); | 1539 state_before = copy_state_for_exception(); |
1544 } | 1540 } |
1545 StoreField* store = new StoreField(apop(), offset, field, val, false, state_before, is_loaded, true); | 1541 StoreField* store = new StoreField(apop(), offset, field, val, false, state_before, needs_patching); |
1546 if (is_loaded) store = _memory->store(store); | 1542 if (!needs_patching) store = _memory->store(store); |
1547 if (store != NULL) { | 1543 if (store != NULL) { |
1548 append(store); | 1544 append(store); |
1549 } | 1545 } |
1550 } | 1546 } |
1551 break; | 1547 break; |