Mercurial > hg > graal-jvmci-8
diff src/share/vm/ci/ciInstanceKlass.cpp @ 1138:dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
Summary: C2 needs some additional optimizations to be able to handle MethodHandle invokes and invokedynamic instructions at the best performance.
Reviewed-by: kvn, never
author | twisti |
---|---|
date | Tue, 05 Jan 2010 15:21:25 +0100 |
parents | 7c57aead6d3e |
children | 4ce7240d622c |
line wrap: on
line diff
--- a/src/share/vm/ci/ciInstanceKlass.cpp Tue Jan 05 13:05:58 2010 +0100 +++ b/src/share/vm/ci/ciInstanceKlass.cpp Tue Jan 05 15:21:25 2010 +0100 @@ -232,8 +232,48 @@ // ------------------------------------------------------------------ // ciInstanceKlass::uses_default_loader bool ciInstanceKlass::uses_default_loader() { - VM_ENTRY_MARK; - return loader() == NULL; + // Note: We do not need to resolve the handle or enter the VM + // in order to test null-ness. + return _loader == NULL; +} + +// ------------------------------------------------------------------ +// ciInstanceKlass::is_in_package +// +// Is this klass in the given package? +bool ciInstanceKlass::is_in_package(const char* packagename, int len) { + // To avoid class loader mischief, this test always rejects application classes. + if (!uses_default_loader()) + return false; + GUARDED_VM_ENTRY( + return is_in_package_impl(packagename, len); + ) +} + +bool ciInstanceKlass::is_in_package_impl(const char* packagename, int len) { + ASSERT_IN_VM; + + // If packagename contains trailing '/' exclude it from the + // prefix-test since we test for it explicitly. + if (packagename[len - 1] == '/') + len--; + + if (!name()->starts_with(packagename, len)) + return false; + + // Test if the class name is something like "java/lang". + if ((len + 1) > name()->utf8_length()) + return false; + + // Test for trailing '/' + if ((char) name()->byte_at(len) != '/') + return false; + + // Make sure it's not actually in a subpackage: + if (name()->index_of_at(len+1, "/", 1) >= 0) + return false; + + return true; } // ------------------------------------------------------------------