提交 1a854f66 编写于 作者: V vlivanov

8005873: JRuby test_respond_to.rb asserts with: MT-unsafe modification of inline cache

Reviewed-by: vlivanov, jrose, psandoz
Contributed-by: tobias.hartmann@oracle.com
上级 7fa8a671
......@@ -482,7 +482,7 @@ class LambdaForm {
assert(m.getName().equals("interpret" + sig.substring(sig.indexOf('_'))));
LambdaForm form = new LambdaForm(sig);
form.vmentry = m;
mt.form().setCachedLambdaForm(MethodTypeForm.LF_COUNTER, form);
form = mt.form().setCachedLambdaForm(MethodTypeForm.LF_COUNTER, form);
// FIXME: get rid of PREPARED_FORMS; use MethodTypeForm cache only
forms.put(sig, form);
}
......
......@@ -692,8 +692,7 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
lform = new LambdaForm("guardWithCatch", lambdaType.parameterCount(), names);
basicType.form().setCachedLambdaForm(MethodTypeForm.LF_GWC, lform);
return lform;
return basicType.form().setCachedLambdaForm(MethodTypeForm.LF_GWC, lform);
}
static
......
......@@ -91,8 +91,10 @@ final class MethodTypeForm {
return lambdaForms[which];
}
public LambdaForm setCachedLambdaForm(int which, LambdaForm form) {
// Should we perform some sort of CAS, to avoid racy duplication?
synchronized public LambdaForm setCachedLambdaForm(int which, LambdaForm form) {
// Simulate a CAS, to avoid racy duplication of results.
LambdaForm prev = lambdaForms[which];
if (prev != null) return prev;
return lambdaForms[which] = form;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册