Browse Source

--- Merging r30018 into '.':
U compiler/nmem.pas

git-svn-id: branches/fixes_3_0_ios@30036 -

Jonas Maebe 10 years ago
parent
commit
fdc255e6af
1 changed files with 9 additions and 29 deletions
  1. 9 29
      compiler/nmem.pas

+ 9 - 29
compiler/nmem.pas

@@ -248,36 +248,16 @@ implementation
            include(current_procinfo.flags,pi_needs_got);
            include(current_procinfo.flags,pi_needs_got);
          if left.nodetype<>typen then
          if left.nodetype<>typen then
            begin
            begin
-             if is_objcclass(left.resultdef) and
-                (left.nodetype<>typen) then
+             if (target_info.system=system_aarch64_darwin) and
+                (is_objc_class_or_protocol(left.resultdef) or
+                 is_objcclassref(left.resultdef)) then
                begin
                begin
-                 if target_info.system<>system_aarch64_darwin then
-                   begin
-                     { don't use the ISA field name, assume this field is at offset
-                       0 (just like gcc/clang) }
-                     result:=ctypeconvnode.create_internal(left,voidpointertype);
-                     result:=cderefnode.create(result);
-                     inserttypeconv_internal(result,resultdef);
-                     { the ISA pointer is guaranteed to be aligned, while
-                       dereferencing a void pointer is normally not aligned at
-                       all }
-                     result:=geninlinenode(in_aligned_x,false,result);
-                     { reused }
-                     left:=nil;
-                   end
-                 else
-                   begin
-                     { Darwin/AArch64, the isa field is opaque and we must call
-                       _class to obtain the actual ISA pointer }
-                     vs:=search_struct_member(tobjectdef(left.resultdef),'_CLASS');
-                     if not assigned(vs) or
-                        (tsym(vs).typ<>procsym) then
-                       internalerror(2011041901);
-                     result:=ccallnode.create(nil,tprocsym(vs),vs.owner,left,[]);
-                     inserttypeconv_explicit(result,resultdef);
-                     { reused }
-                     left:=nil;
-                   end;
+                 { on Darwin/AArch64, the isa field is opaque and we must
+                   call Object_getClass to obtain the actual ISA pointer }
+                 result:=ccallnode.createinternfromunit('OBJC','OBJECT_GETCLASS',ccallparanode.create(left,nil));
+                 inserttypeconv_explicit(result,resultdef);
+                 { reused }
+                 left:=nil;
                end
                end
              else if is_javaclass(left.resultdef) and
              else if is_javaclass(left.resultdef) and
                 (left.nodetype<>typen) and
                 (left.nodetype<>typen) and