summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/art_method.cc12
-rw-r--r--runtime/art_method.h5
-rw-r--r--runtime/interpreter/mterp/nterp.cc3
-rw-r--r--test/044-proxy/src/HotProxy.java55
-rw-r--r--test/044-proxy/src/Main.java1
5 files changed, 73 insertions, 3 deletions
diff --git a/runtime/art_method.cc b/runtime/art_method.cc
index 135e806244..cfb5928afa 100644
--- a/runtime/art_method.cc
+++ b/runtime/art_method.cc
@@ -762,9 +762,17 @@ void ArtMethod::CopyFrom(ArtMethod* src, PointerSize image_pointer_size) {
image_pointer_size);
}
}
- // Clear the profiling info for the same reasons as the JIT code.
+ if (interpreter::IsNterpSupported() &&
+ (GetEntryPointFromQuickCompiledCodePtrSize(image_pointer_size) ==
+ interpreter::GetNterpEntryPoint())) {
+ // If the entrypoint is nterp, it's too early to check if the new method
+ // will support it. So for simplicity, use the interpreter bridge.
+ SetEntryPointFromQuickCompiledCodePtrSize(GetQuickToInterpreterBridge(), image_pointer_size);
+ }
+
+ // Clear the data pointer, it will be set if needed by the caller.
if (!src->IsNative()) {
- SetProfilingInfoPtrSize(nullptr, image_pointer_size);
+ SetDataPtrSize(nullptr, image_pointer_size);
}
// Clear hotness to let the JIT properly decide when to compile this method.
hotness_count_ = 0;
diff --git a/runtime/art_method.h b/runtime/art_method.h
index 16b4648821..3d6b66a4dd 100644
--- a/runtime/art_method.h
+++ b/runtime/art_method.h
@@ -523,11 +523,14 @@ class ArtMethod final {
}
ALWAYS_INLINE void SetProfilingInfo(ProfilingInfo* info) REQUIRES_SHARED(Locks::mutator_lock_) {
- SetDataPtrSize(info, kRuntimePointerSize);
+ SetProfilingInfoPtrSize(info, kRuntimePointerSize);
}
ALWAYS_INLINE void SetProfilingInfoPtrSize(ProfilingInfo* info, PointerSize pointer_size)
REQUIRES_SHARED(Locks::mutator_lock_) {
+ DCHECK(!IsProxyMethod());
+ DCHECK(!IsNative());
+ DCHECK(IsInvokable());
SetDataPtrSize(info, pointer_size);
}
diff --git a/runtime/interpreter/mterp/nterp.cc b/runtime/interpreter/mterp/nterp.cc
index 1d47f29fd7..f1b60216e7 100644
--- a/runtime/interpreter/mterp/nterp.cc
+++ b/runtime/interpreter/mterp/nterp.cc
@@ -45,6 +45,9 @@ bool CanMethodUseNterp(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_)
return method->SkipAccessChecks() &&
!method->IsNative() &&
method->GetDexFile()->IsStandardDexFile() &&
+ // Proxy methods do not go through the JIT like other methods, so we don't
+ // run them with nterp.
+ !method->IsProxyMethod() &&
NterpGetFrameSize(method) < kNterpMaxFrame;
}
diff --git a/test/044-proxy/src/HotProxy.java b/test/044-proxy/src/HotProxy.java
new file mode 100644
index 0000000000..0c5ec1c8a4
--- /dev/null
+++ b/test/044-proxy/src/HotProxy.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.lang.reflect.*;
+
+public class HotProxy {
+
+ public static final String testName = "HotProxy";
+
+ interface MyInterface {
+ void voidFoo();
+ }
+
+ static void check(boolean x) {
+ if (!x) {
+ throw new AssertionError(testName + " Check failed");
+ }
+ }
+
+ static class MyInvocationHandler implements InvocationHandler {
+ public Object invoke(Object proxy, Method method, Object[] args) {
+ check(proxy instanceof Proxy);
+ check(method.getDeclaringClass() == MyInterface.class);
+ return null;
+ }
+ }
+
+ static void testProxy() {
+ MyInvocationHandler myHandler = new MyInvocationHandler();
+ MyInterface proxyMyInterface =
+ (MyInterface)Proxy.newProxyInstance(HotProxy.class.getClassLoader(),
+ new Class<?>[] { MyInterface.class },
+ myHandler);
+ // Invoke the proxy method multiple times to ensure it becomes hot and the JIT handles it.
+ for (int i = 0; i < 0x10000; i++) {
+ proxyMyInterface.voidFoo();
+ }
+ }
+
+ public static void main(String args[]) {
+ testProxy();
+ }
+}
diff --git a/test/044-proxy/src/Main.java b/test/044-proxy/src/Main.java
index 7b70e65b8c..8be09cf688 100644
--- a/test/044-proxy/src/Main.java
+++ b/test/044-proxy/src/Main.java
@@ -33,6 +33,7 @@ public class Main {
NativeProxy.main(args);
ConstructorProxy.main();
OOMEOnDispatch.main(args);
+ HotProxy.main(args);
}
// The following code maps from the actual proxy class names (eg $Proxy2) to their test output