diff options
author | Andreas Gampe <agampe@google.com> | 2015-04-08 10:26:16 -0700 |
---|---|---|
committer | Andreas Gampe <agampe@google.com> | 2015-04-09 09:09:11 -0700 |
commit | 3f5881fda3606b27e30bf903052c73b03910f90b (patch) | |
tree | 0c60e00a3923d47658e2d224997ab2742c113877 /runtime/jni_env_ext.cc | |
parent | 1576be32be4a99a1cffdaaf209a3cd67e8b2f88a (diff) | |
download | art-3f5881fda3606b27e30bf903052c73b03910f90b.zip art-3f5881fda3606b27e30bf903052c73b03910f90b.tar.gz art-3f5881fda3606b27e30bf903052c73b03910f90b.tar.bz2 |
ART: IRT refactor
IRT creation might fail. Add a path that allows to bypass the aborts
and instead signal validity. Hide this path with a private constructor,
rewrite users to use a static Create method.
Bug: 20110201
Change-Id: I440499c3372cd7557eb970b70ce2c4543da520e4
Diffstat (limited to 'runtime/jni_env_ext.cc')
-rw-r--r-- | runtime/jni_env_ext.cc | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/runtime/jni_env_ext.cc b/runtime/jni_env_ext.cc index b2d3835..84fc404 100644 --- a/runtime/jni_env_ext.cc +++ b/runtime/jni_env_ext.cc @@ -28,11 +28,29 @@ static constexpr size_t kMonitorsMax = 4096; // Arbitrary sanity check. static constexpr size_t kLocalsInitial = 64; // Arbitrary. +// Checking "locals" requires the mutator lock, but at creation time we're really only interested +// in validity, which isn't changing. To avoid grabbing the mutator lock, factored out and tagged +// with NO_THREAD_SAFETY_ANALYSIS. +static bool CheckLocalsValid(JNIEnvExt* in) NO_THREAD_SAFETY_ANALYSIS { + if (in == nullptr) { + return false; + } + return in->locals.IsValid(); +} + +JNIEnvExt* JNIEnvExt::Create(Thread* self_in, JavaVMExt* vm_in) { + std::unique_ptr<JNIEnvExt> ret(new JNIEnvExt(self_in, vm_in)); + if (CheckLocalsValid(ret.get())) { + return ret.release(); + } + return nullptr; +} + JNIEnvExt::JNIEnvExt(Thread* self_in, JavaVMExt* vm_in) : self(self_in), vm(vm_in), local_ref_cookie(IRT_FIRST_SEGMENT), - locals(kLocalsInitial, kLocalsMax, kLocal), + locals(kLocalsInitial, kLocalsMax, kLocal, false), check_jni(false), critical(0), monitors("monitors", kMonitorsInitial, kMonitorsMax) { |