소스 검색

+ support for constant array indices in treference for the JVM target
(art_indexconst)

git-svn-id: branches/jvmbackend@18366 -

Jonas Maebe 14 년 전
부모
커밋
2a6caa539c
2개의 변경된 파일22개의 추가작업 그리고 14개의 파일을 삭제
  1. 1 1
      compiler/cgutils.pas
  2. 21 13
      compiler/jvm/hlcgcpu.pas

+ 1 - 1
compiler/cgutils.pas

@@ -34,7 +34,7 @@ unit cgutils;
 
     type
 {$ifdef jvm}
-      tarrayreftype = (art_none,art_indexreg,art_indexref);
+      tarrayreftype = (art_none,art_indexreg,art_indexref,art_indexconst);
 {$endif jvm}
       { reference record, reordered for best alignment }
       preference = ^treference;

+ 21 - 13
compiler/jvm/hlcgcpu.pas

@@ -631,19 +631,27 @@ implementation
           a_load_reg_stack(list,voidpointertype,ref.base);
           { index can either be in a register, or located in a simple memory
             location (since we have to load it anyway) }
-          if ref.arrayreftype=art_indexreg then
-            begin
-              if ref.index=NR_NO then
-                internalerror(2010120513);
-              { all array indices in Java are 32 bit ints }
-              a_load_reg_stack(list,s32inttype,ref.index);
-            end
-          else
-            begin
-              reference_reset_base(href,ref.indexbase,ref.indexoffset,4);
-              href.symbol:=href.indexsymbol;
-              a_load_ref_stack(list,s32inttype,href,prepare_stack_for_ref(list,href,false));
-            end;
+          case ref.arrayreftype of
+            art_indexreg:
+              begin
+                if ref.index=NR_NO then
+                  internalerror(2010120513);
+                { all array indices in Java are 32 bit ints }
+                a_load_reg_stack(list,s32inttype,ref.index);
+              end;
+            art_indexref:
+              begin
+                reference_reset_base(href,ref.indexbase,ref.indexoffset,4);
+                href.symbol:=ref.indexsymbol;
+                a_load_ref_stack(list,s32inttype,href,prepare_stack_for_ref(list,href,false));
+              end;
+            art_indexconst:
+              begin
+                a_load_const_stack(list,s32inttype,ref.indexoffset,R_INTREGISTER);
+              end;
+            else
+              internalerror(2011012001);
+          end;
           { adjustment of the index }
           if ref.offset<>0 then
             a_op_const_stack(list,OP_ADD,s32inttype,ref.offset);