--- a/JavaVM.st Tue May 07 13:31:03 2013 +0100
+++ b/JavaVM.st Fri May 10 18:33:57 2013 +0100
@@ -4927,12 +4927,29 @@
This method *MUST* return the object for this may lead
into GC. See ___checkcast() VM function
"
+
+ | oclass |
object isNil ifTrue: [ ^ object ].
- (self canCast: object class to: class) ifFalse: [
+ oclass := object class.
+ (self canCast: oclass to: class) ifFalse: [
self throwClassCastException.
^ nil "Not reached"
- ].
+ ].
+%{
+ /* Now the nasty trick - if succeeded, bind to fast ___checkcast().
+ * abusing ilc's ilc_class to store obj class (!!!). See ___checkcast()
+ * in jinterpret.c
+ */
+ if ((__ILC_FLAGS(__pilc) & 0x0F) != I_PERF) {
+ if ( __qSpace(oclass) < NEWSPACE ) {
+ extern OBJ ___checkcast();
+ extern void ___ilcBindPrimitive();
+ /* printf("CHECKCAST: __pilc == 0x%x\n", __pilc); */
+ __ilcBindPrimitive(__pilc, oclass, &___checkcast, 2, __selector);
+ }
+ }
+%}.
^ object
"Created: / 08-01-1999 / 14:53:51 / cg"