mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-10-31 09:32:00 +01:00 
			
		
		
		
	* made ttgobj.alloctemp/freetemp protected, and alloctemp also virtual
* made ttgobj.create virtual, added a "tgobjclass: class of ttgobj = ttgobj"
    variable and use that one to instantiate new temp allocators
  * created ttgjvm descendant that only allows allocations of 4 or 8 bytes
    (rounding allocations < 4 bytes up to 4 bytes), and that divides the
    offsets/sizes by 4 so we get stack slot numbers
git-svn-id: branches/jvmbackend@18282 -
			
			
This commit is contained in:
		
							parent
							
								
									2cb4514c07
								
							
						
					
					
						commit
						1e96eab55d
					
				
							
								
								
									
										1
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
								
							| @ -206,6 +206,7 @@ compiler/ia64/cpuinfo.pas svneol=native#text/plain | |||||||
| compiler/ia64/ia64reg.dat svneol=native#text/plain | compiler/ia64/ia64reg.dat svneol=native#text/plain | ||||||
| compiler/impdef.pas svneol=native#text/plain | compiler/impdef.pas svneol=native#text/plain | ||||||
| compiler/import.pas svneol=native#text/plain | compiler/import.pas svneol=native#text/plain | ||||||
|  | compiler/jvm/tgcpu.pas svneol=native#text/plain | ||||||
| compiler/link.pas svneol=native#text/plain | compiler/link.pas svneol=native#text/plain | ||||||
| compiler/m68k/aasmcpu.pas svneol=native#text/plain | compiler/m68k/aasmcpu.pas svneol=native#text/plain | ||||||
| compiler/m68k/ag68kgas.pas svneol=native#text/plain | compiler/m68k/ag68kgas.pas svneol=native#text/plain | ||||||
|  | |||||||
							
								
								
									
										62
									
								
								compiler/jvm/tgcpu.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								compiler/jvm/tgcpu.pas
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,62 @@ | |||||||
|  | { | ||||||
|  |     Copyright (C) 2010 by Jonas Maebe | ||||||
|  | 
 | ||||||
|  |     This unit handles the temporary variables for the JVM | ||||||
|  | 
 | ||||||
|  |     This program is free software; you can redistribute it and/or modify | ||||||
|  |     it under the terms of the GNU General Public License as published by | ||||||
|  |     the Free Software Foundation; either version 2 of the License, or | ||||||
|  |     (at your option) any later version. | ||||||
|  | 
 | ||||||
|  |     This program is distributed in the hope that it will be useful, | ||||||
|  |     but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  |     GNU General Public License for more details. | ||||||
|  | 
 | ||||||
|  |     You should have received a copy of the GNU General Public License | ||||||
|  |     along with this program; if not, write to the Free Software | ||||||
|  |     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||||||
|  | 
 | ||||||
|  |  **************************************************************************** | ||||||
|  | } | ||||||
|  | { | ||||||
|  |   This unit handles the temporary variables for the JVM. | ||||||
|  | } | ||||||
|  | unit tgcpu; | ||||||
|  | 
 | ||||||
|  | {$i fpcdefs.inc} | ||||||
|  | 
 | ||||||
|  |   interface | ||||||
|  | 
 | ||||||
|  |     uses | ||||||
|  |        tgobj; | ||||||
|  | 
 | ||||||
|  |     type | ||||||
|  | 
 | ||||||
|  |        { ttgjvm } | ||||||
|  | 
 | ||||||
|  |        ttgjvm = class(ttgobj) | ||||||
|  |         protected | ||||||
|  |          function alloctemp(list: TAsmList; size, alignment: longint; temptype: ttemptype; def: tdef): longint; override; | ||||||
|  |        end; | ||||||
|  | 
 | ||||||
|  | implementation | ||||||
|  | 
 | ||||||
|  | { ttgjvm } | ||||||
|  | 
 | ||||||
|  | function ttgjvm.alloctemp(list: TAsmList; size, alignment: longint; temptype: ttemptype; def: tdef): longint; | ||||||
|  | begin | ||||||
|  |   { the JVM only support s1 slot (= 4 bytes in FPC) and 2 slot (= 8 bytes in | ||||||
|  |     FPC) temps on the stack. double and int64 are 2 slots, the rest is one slot. | ||||||
|  |     There are no problems with reusing the same slot for a vakue of a different | ||||||
|  |     type. There are no alignment requirements either. } | ||||||
|  |   if size<4 then | ||||||
|  |     size:=4; | ||||||
|  |   if not(size in [4,8]) then | ||||||
|  |     internalerror(2010121401); | ||||||
|  |   Result:=inherited alloctemp(list, size div 4, 1, temptype, def); | ||||||
|  | end; | ||||||
|  | 
 | ||||||
|  | begin | ||||||
|  |   tgclass:=ttgjvm; | ||||||
|  | end. | ||||||
| @ -948,7 +948,7 @@ implementation | |||||||
|             create_hlcodegen; |             create_hlcodegen; | ||||||
| 
 | 
 | ||||||
|             { set the start offset to the start of the temp area in the stack } |             { set the start offset to the start of the temp area in the stack } | ||||||
|             tg:=ttgobj.create; |             tg:=tgobjclass.create; | ||||||
| 
 | 
 | ||||||
| {$if defined(x86) or defined(arm)} | {$if defined(x86) or defined(arm)} | ||||||
|             { try to strip the stack frame } |             { try to strip the stack frame } | ||||||
|  | |||||||
| @ -56,10 +56,10 @@ unit tgobj; | |||||||
| 
 | 
 | ||||||
|        {# Generates temporary variables } |        {# Generates temporary variables } | ||||||
|        ttgobj = class |        ttgobj = class | ||||||
|        private |        protected | ||||||
|           { contains all free temps using nextfree links } |           { contains all free temps using nextfree links } | ||||||
|           tempfreelist  : ptemprecord; |           tempfreelist  : ptemprecord; | ||||||
|           function alloctemp(list: TAsmList; size,alignment : longint; temptype : ttemptype; def:tdef) : longint; |           function alloctemp(list: TAsmList; size,alignment : longint; temptype : ttemptype; def:tdef) : longint; virtual; | ||||||
|           procedure freetemp(list: TAsmList; pos:longint;temptypes:ttemptypeset); |           procedure freetemp(list: TAsmList; pos:longint;temptypes:ttemptypeset); | ||||||
|        public |        public | ||||||
|           { contains all temps } |           { contains all temps } | ||||||
| @ -68,7 +68,7 @@ unit tgobj; | |||||||
|           firsttemp, |           firsttemp, | ||||||
|           lasttemp      : longint; |           lasttemp      : longint; | ||||||
|           direction : shortint; |           direction : shortint; | ||||||
|           constructor create; |           constructor create;virtual;reintroduce; | ||||||
|           {# Clear and free the complete linked list of temporary memory |           {# Clear and free the complete linked list of temporary memory | ||||||
|              locations. The list is set to nil.} |              locations. The list is set to nil.} | ||||||
|           procedure resettempgen; |           procedure resettempgen; | ||||||
| @ -105,9 +105,11 @@ unit tgobj; | |||||||
|           procedure getlocal(list: TAsmList; size : longint; alignment : shortint; def:tdef;var ref : treference); |           procedure getlocal(list: TAsmList; size : longint; alignment : shortint; def:tdef;var ref : treference); | ||||||
|           procedure UnGetLocal(list: TAsmList; const ref : treference); |           procedure UnGetLocal(list: TAsmList; const ref : treference); | ||||||
|        end; |        end; | ||||||
|  |        ttgobjclass = class of ttgobj; | ||||||
| 
 | 
 | ||||||
|      var |      var | ||||||
|        tg: ttgobj; |        tg: ttgobj; | ||||||
|  |        tgobjclass: ttgobjclass = ttgobj; | ||||||
| 
 | 
 | ||||||
|     procedure location_freetemp(list:TAsmList; const l : tlocation); |     procedure location_freetemp(list:TAsmList; const l : tlocation); | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Jonas Maebe
						Jonas Maebe