892 }
893 return (asTypeCache = wrapper);
894 }
895
896 // Customize target if counting happens for too long.
897 private int invocations = CUSTOMIZE_THRESHOLD;
898 private void maybeCustomizeTarget() {
899 int c = invocations;
900 if (c >= 0) {
901 if (c == 1) {
902 target.customize();
903 }
904 invocations = c - 1;
905 }
906 }
907
908 boolean countDown() {
909 int c = count;
910 maybeCustomizeTarget();
911 if (c <= 1) {
912 // Try to limit number of updates. MethodHandle.updateForm() doesn't guarantee LF update visibility.
913 if (isCounting) {
914 isCounting = false;
915 return true;
916 } else {
917 return false;
918 }
919 } else {
920 count = c - 1;
921 return false;
922 }
923 }
924
925 @Hidden
926 static void maybeStopCounting(Object o1) {
927 CountingWrapper wrapper = (CountingWrapper) o1;
928 if (wrapper.countDown()) {
929 // Reached invocation threshold. Replace counting behavior with a non-counting one.
930 LambdaForm lform = wrapper.nonCountingFormProducer.apply(wrapper.target);
931 lform.compileToBytecode(); // speed up warmup by avoiding LF interpretation again after transition
932 wrapper.updateForm(lform);
|
892 }
893 return (asTypeCache = wrapper);
894 }
895
896 // Customize target if counting happens for too long.
897 private int invocations = CUSTOMIZE_THRESHOLD;
898 private void maybeCustomizeTarget() {
899 int c = invocations;
900 if (c >= 0) {
901 if (c == 1) {
902 target.customize();
903 }
904 invocations = c - 1;
905 }
906 }
907
908 boolean countDown() {
909 int c = count;
910 maybeCustomizeTarget();
911 if (c <= 1) {
912 // Try to limit number of updates.
913 if (isCounting) {
914 isCounting = false;
915 return true;
916 } else {
917 return false;
918 }
919 } else {
920 count = c - 1;
921 return false;
922 }
923 }
924
925 @Hidden
926 static void maybeStopCounting(Object o1) {
927 CountingWrapper wrapper = (CountingWrapper) o1;
928 if (wrapper.countDown()) {
929 // Reached invocation threshold. Replace counting behavior with a non-counting one.
930 LambdaForm lform = wrapper.nonCountingFormProducer.apply(wrapper.target);
931 lform.compileToBytecode(); // speed up warmup by avoiding LF interpretation again after transition
932 wrapper.updateForm(lform);
|