1643 abstract MethodHandle copyWith(MethodType mt, LambdaForm lf);
1644
1645 /** Require this method handle to be a BMH, or else replace it with a "wrapper" BMH.
1646 * Many transforms are implemented only for BMHs.
1647 * @return a behaviorally equivalent BMH
1648 */
1649 abstract BoundMethodHandle rebind();
1650
1651 /**
1652 * Replace the old lambda form of this method handle with a new one.
1653 * The new one must be functionally equivalent to the old one.
1654 * Threads may continue running the old form indefinitely,
1655 * but it is likely that the new one will be preferred for new executions.
1656 * Use with discretion.
1657 */
1658 /*non-public*/
1659 void updateForm(LambdaForm newForm) {
1660 assert(newForm.customized == null || newForm.customized == this);
1661 if (form == newForm) return;
1662 newForm.prepare(); // as in MethodHandle.<init>
1663 UNSAFE.putObject(this, FORM_OFFSET, newForm);
1664 UNSAFE.fullFence();
1665 }
1666
1667 /** Craft a LambdaForm customized for this particular MethodHandle */
1668 /*non-public*/
1669 void customize() {
1670 if (form.customized == null) {
1671 LambdaForm newForm = form.customize(this);
1672 updateForm(newForm);
1673 } else {
1674 assert(form.customized == this);
1675 }
1676 }
1677
1678 private static final long FORM_OFFSET
1679 = UNSAFE.objectFieldOffset(MethodHandle.class, "form");
1680 }
|
1643 abstract MethodHandle copyWith(MethodType mt, LambdaForm lf);
1644
1645 /** Require this method handle to be a BMH, or else replace it with a "wrapper" BMH.
1646 * Many transforms are implemented only for BMHs.
1647 * @return a behaviorally equivalent BMH
1648 */
1649 abstract BoundMethodHandle rebind();
1650
1651 /**
1652 * Replace the old lambda form of this method handle with a new one.
1653 * The new one must be functionally equivalent to the old one.
1654 * Threads may continue running the old form indefinitely,
1655 * but it is likely that the new one will be preferred for new executions.
1656 * Use with discretion.
1657 */
1658 /*non-public*/
1659 void updateForm(LambdaForm newForm) {
1660 assert(newForm.customized == null || newForm.customized == this);
1661 if (form == newForm) return;
1662 newForm.prepare(); // as in MethodHandle.<init>
1663 UNSAFE.putObjectVolatile(this, FORM_OFFSET, newForm);
1664 }
1665
1666 /** Craft a LambdaForm customized for this particular MethodHandle */
1667 /*non-public*/
1668 void customize() {
1669 final LambdaForm form = this.form;
1670 if (form.customized == null) {
1671 LambdaForm newForm = form.customize(this);
1672 updateForm(newForm);
1673 } else {
1674 assert(form.customized == this);
1675 }
1676 }
1677
1678 private static final long FORM_OFFSET
1679 = UNSAFE.objectFieldOffset(MethodHandle.class, "form");
1680 }
|