Commit Graph

553 Commits

Author SHA1 Message Date
nickysn
284f1c904a * fixed a parameter pushing order bug on the i8086
git-svn-id: branches/i8086@23986 -
2013-03-24 20:41:51 +00:00
florian
63f6afffd5 + make empty proc. removal switchable by removeemptyprocs
git-svn-id: trunk@23621 -
2013-02-14 21:40:04 +00:00
svenbarth
344571cb4e Added support for type helpers. In non Delphi modes they use "type helper" and in mode Delphi they use "record helper". They can also be used on constants.
symconst.pas:
  + extend "thelpertype" by "ht_type" which tells the code in "pdecobj.parse_extended_type" that a type helper declaration has been parsed
node.pas:
  + add a constant which identifies all constant node types
ptype.pas:
  + read_named_type: add a parameter "hadtypetoken" to tell the code whether a "type" token had been parsed before
  + read_named_type: if an identifier "helper" is parsed we need to check whether "hadtypetoken" is true and the modeswitch "m_class" is set, but the "m_delphi" one is not; in that case we have a "type helper" declaration
pgenutil.pas, generate_specialization:
  * adjust call to read_named_type
pdecl.pas, types_dec:
  * adjust call to read_named_type

pdecobj.pas:
  * parse_extended_type: extend for correct handling of primitive types (includes Delphi compatible handling as well) and reject types that are explicitly not allowed
  * method_dec: require "static" for class methods in type helpers
  * method_doc: allow constructors for type helpers as well
paramgr.pas, tparamanager:
  * set_common_funcretloc_info: handle type helper constructors like record constructors
  * handle_common_ret_in_param: the "self" value of a type helper constructor is also returned in a parameter
pexpr.pas:
  + add a function to postfixoperators which tries to find and apply a type helper for a given type
  * postfixoperators: try to apply type helpers for ordinal constants
  * postfixoperators: use the correct string type for string constants
  * postfixoperators: try to apply type helpers for enum constants
  * postfixoperators: try to apply type helpers for arrays
  * postfixoperators: try to apply type helpers for Variant
  * postfixoperators: try to apply type helpers for pointer types
  * postfixoperators: try to apply type helpers for other types
  * factor: check postfixoperators after _REALNUMBER, _CCHAR, _CWCHAR, _TRUE and _FALSE
  * factor: also check postfixoperators if a _POINT follows a _NIL

symdef.pas, tdefawaresymtablestack.addhelpers:
  * use "generate_objectpascal_helper_key" to generate the key
symtable.pas:
  + add function to generate the key value for the map of extended types using the extended def
  * adjust "search_last_objectpascal_helper" and "search_objectpascal_helper" to handle primitive types as well
  * use the new "generate_objectpascal_helper_key" function to generate the key

pparautl.pas:
  * insert_self_and_vmt_para: don't insert the $vmt symbol for record or type helpers (ToDo: check whether class helpers really need the symbol as well)
  * insert_self_and_vmt_para: pass "self" as var parameter for type helpers as well
psub.pas, generate_bodyentry_block: 
  * also allow type helpers for constructor methods
ncal.pas, tcallnode.gen_self_tree:
  * also use a temp variable for type helper constructors
ncgcal.pas, tcgcallnode.secondcallparan:
  * allow Pointers to be passed as address param if it is the Self value of a type helper extending a pointer type
  * correctly handle the location in case of type helper constructors

+ add tests

git-svn-id: trunk@23580 -
2013-02-06 09:49:35 +00:00
Jonas Maebe
9cbff6f5a6 + support for record constructors for the JVM target
git-svn-id: trunk@23510 -
2013-01-24 09:45:12 +00:00
Jonas Maebe
9145f1d67d * integrated potype_constructor check in maybe_create_funcret_node
git-svn-id: trunk@23507 -
2013-01-24 09:44:52 +00:00
florian
cad1309935 * don't write directly to the function result destination if we are inlining and if the destination is too complex to evaluate (threadvar etc.)
git-svn-id: trunk@23415 -
2013-01-16 20:25:49 +00:00
paul
b2a613c17f compiler: implement record constructors + tests
git-svn-id: trunk@23395 -
2013-01-16 02:07:42 +00:00
paul
51825b6f2e compiler: change ret_in_param to accept tabstractprocdef instead of tproccalloption to allow check more options (required for record constructor implementation)
git-svn-id: trunk@23394 -
2013-01-16 01:14:23 +00:00
florian
329257d76e * check for empty procedures after helper test so even empty helper methods cannot be called directly
* don't remove calls to subroutines taking arrays of const

git-svn-id: trunk@23302 -
2013-01-03 22:58:56 +00:00
florian
24f518f232 + redirect calls to empty virtual methods to FPC_EMPTYMETHOD
* do empty subroutine/method optimization only for O2 and higer

git-svn-id: trunk@23276 -
2013-01-01 16:43:27 +00:00
florian
4d6471fef6 * get rid of calls to empty procedures having parameters without side effect
git-svn-id: trunk@23274 -
2013-01-01 15:58:05 +00:00
Jonas Maebe
d9e67fc835 * don't add a separate high parameter for array-of-const parameters on the
JVM target (just like for open array parameters), since the array length
    is already encoded in the array itself there

git-svn-id: trunk@22968 -
2012-11-10 20:26:42 +00:00
svenbarth
2db54da2b3 m68k also uses a non fixed stack with an equivalent to PUSH/POP so don't reorder parameters
if the required stack offset tells otherwise.

git-svn-id: trunk@22742 -
2012-10-18 20:11:56 +00:00
Jonas Maebe
f5de7e34d3 * only remove the calculation of unused parameters of inline routines if
they don't have explicit side-effects, and if -Oodeadvalues (part of -O4)
    is active (because it can result in the removal of range check errors,
    segmentation faults, etc)

git-svn-id: trunk@22254 -
2012-08-26 21:04:46 +00:00
florian
1cd6f2355b * don't copy const parameters passed by reference even if their complexity is >1,
this is handled by wrapcomplexinlinepara

git-svn-id: trunk@22160 -
2012-08-21 16:31:58 +00:00
Jonas Maebe
f3ad4af343 * make sure valid_for_assign() returns false for inlined function bodies
(mantis #22613)

git-svn-id: trunk@22099 -
2012-08-16 19:22:17 +00:00
florian
bd47ba6ba4 * the address of complex inline parameters can be hold always in a register
git-svn-id: trunk@22076 -
2012-08-13 15:09:11 +00:00
florian
5b90a02e75 * inherit nf_write/nf_modify in tcallnode.replaceparaload also when replacing parameters
git-svn-id: trunk@22075 -
2012-08-13 15:06:16 +00:00
florian
2c122a9bf6 * inherit modification flag from load nodes when creating temp nodes when inlining, dfa/cse need this information
git-svn-id: trunk@22056 -
2012-08-10 21:16:54 +00:00
florian
4d86d25c6c * -O4 switch for optimizations which are correct but which might have unexpected effects
like field reordering (possible problems cracker classes) or using ebp as normal register (broken
      stack traces from dump_stack)
    + niln is also valid in a cse domain
    * parameters passed by reference shall have a complexity >1
    * load nodes from outer scopes shall have a complexity >1
    * better cse debugging
    + more node types added to cse
    * consider parameters passed by reference in cse
    * take care of cse in parameters in simple cases

git-svn-id: trunk@22050 -
2012-08-09 18:58:54 +00:00
Jonas Maebe
b50d0aa3d0 * only don't pre-finalize funcret temps that are passed by reference to the
called function, fixes webtbs/tw3742.pp after r21955 (looked at wrong
    testsuite results :/ )

git-svn-id: trunk@21963 -
2012-07-23 23:55:00 +00:00
Jonas Maebe
3414f91590 * minor reformatting, and removed superfluous assigned test (the value is
already used before that test)

git-svn-id: trunk@21502 -
2012-06-06 18:51:14 +00:00
Jonas Maebe
9412d4abd2 * add a reference to the procsym corresponding to the chosen overloaded
procdef, so that the unit containing it is marked as "used" (mantis #15966)

    Even better would be if the unit containing the originally found procsym
    were not also marked as used, but that would require a significant
    rewrite (all symbols found using symboltable helpers are automatically
    marked by those routines)

git-svn-id: trunk@21501 -
2012-06-06 18:46:01 +00:00
florian
af7bb6faab * ignore unused parameters when inlining
git-svn-id: trunk@21445 -
2012-05-31 18:48:38 +00:00
Jonas Maebe
baa8fa39a8 * converted code to trash variables (-gt) to operate at the node tree level,
and also use this code to trash local variables in inlined routines
   o fixes mantis #22088
   o makes it possible to also implement it for the jvm target in the future

git-svn-id: trunk@21393 -
2012-05-26 11:32:39 +00:00
florian
6c8eed21c4 + implement auto inlining (-Ooautoinline)
+ implement trashing of local variables if subroutine is inlined
* fix some errors releated to interproc. gotos and inlining
+ node_count function
* inline cannot be used with iochecking and safecall calling conventions
* track inherited usage
* don't inline if inherited is used

git-svn-id: trunk@21335 -
2012-05-19 13:30:02 +00:00
Jonas Maebe
834026bfb5 * synchronised with trunk up to r21067
git-svn-id: branches/jvmbackend@21068 -
2012-04-26 21:24:20 +00:00
sergei
04ca8a9126 * translate_disp_call: improved building the parameter block by using ttemprefnode.create_offset instead of taking address/pointer additions/dereference. Results in simpler node tree and lesser CPU instructions generated.
git-svn-id: trunk@21018 -
2012-04-24 12:51:36 +00:00
sergei
6d0dd50be3 * tcallnode.maybe_load_in_temp: treat asnode like callnode, because asnodes are converted into helper calls in pass 1. Improves code generated for expressions "(a as b).SomeMethod".
git-svn-id: trunk@21017 -
2012-04-24 12:31:21 +00:00
Jonas Maebe
aee5380ae0 * merged trunk up to r20882
o support for the new codepage-aware ansistrings in the jvm branch
   o empty ansistrings are now always represented by a nil pointer rather than
     by an empty string, because an empty string also has a code page which
     can confuse code (although this will make ansistrings harder to use
     in Java code)
   o more string helpers code shared between the general and jvm rtl
   o support for indexbyte/word in the jvm rtl (warning: first parameter
     is an open array rather than an untyped parameter there, so
     indexchar(pcharvar^,10,0) will be equivalent to
     indexchar[pcharvar^],10,0) there, which is different from what is
     intended; changing it to an untyped parameter wouldn't help though)
   o default() support is not yet complete
   o calling fpcres is currently broken due to limitations in
     sysutils.executeprocess() regarding handling unix quoting and
     the compiler using the same command lines for scripts and directly
     calling external programs
   o compiling the Java compiler currently requires adding ALLOW_WARNINGS=1
     to the make command line

git-svn-id: branches/jvmbackend@20887 -
2012-04-15 15:54:10 +00:00
florian
a7b46fc36f * don't create a temp. for a dereferenced pointer which is passed to a var parameter of an inline procedure
git-svn-id: trunk@20478 -
2012-03-07 21:17:09 +00:00
Jonas Maebe
1f83203117 * make self-pointer passed by reference not regable. Was not necessary
when we only had objects because they are never put in registers,
    but (advanced) records can be (mantis #21177)

git-svn-id: trunk@20192 -
2012-01-29 11:30:12 +00:00
Jonas Maebe
7f15423d76 * fixed copying order of callnode siblings (callcleanupblock must be
copied before funcretnode because it may contain tempdeletenodes
    that turn a temp to "delete on next use", with the use in the
    funcretnode)

git-svn-id: branches/jvmbackend@20141 -
2012-01-21 19:35:52 +00:00
sergei
cbad0abab5 + Platform-specific exception support for x86_64-win64. Enable by cycling with OPT=-dTEST_WIN64_SEH.
git-svn-id: trunk@20098 -
2012-01-16 23:13:31 +00:00
Jonas Maebe
0d5b2b84a8 + Android/JVM target, including a translation of the Android r14 SDK
(= Android 4.0) java headers: java.*, javax.*, org.*, junit.*, android.*).
    The RTL can also be used to target earlier versions of the Android
    platform, but you manually have to take care of not using APIs that
    weren't available yet. Adding separate units for separate platform
    versions would only partly solve the problem, because some of the
    classes used inside the system unit have also changed across
    versions.

    Use -Tandroid while compiling to select the Android OS as target
    platform.

git-svn-id: branches/jvmbackend@19830 -
2011-12-12 02:34:34 +00:00
Jonas Maebe
84bf45f0e2 * give an error when trying to call an interface/protocol/category method
using the type name of the interface/protcol/category (they are not
    entities themselves on which you can invoke those methods,
    mantis #20661)

git-svn-id: trunk@19651 -
2011-11-18 22:33:33 +00:00
florian
6ec0f2549a * factored load node flags out of node flags to gain space
+ implemented iso mode mod, resolves #17685

git-svn-id: trunk@19558 -
2011-10-30 15:14:21 +00:00
sergei
964eb8772a * Fixed tcallnode.expectloc for x87 floating-point results
git-svn-id: trunk@19514 -
2011-10-19 11:42:02 +00:00
florian
df75368d0b --- Merging r19281 into '.':
U    compiler\pdecsub.pas
U    compiler\symdef.pas
U    compiler\pdecobj.pas
U    compiler\htypechk.pas
U    compiler\ncal.pas
U    compiler\symtable.pas
--- Recording mergeinfo for merge of r19281 into '.':
 U   .
--- Merging r19282 into '.':
A    tests\webtbf\tw19975.pp
--- Recording mergeinfo for merge of r19282 into '.':
 G   .

git-svn-id: trunk@19343 -
2011-10-03 20:43:19 +00:00
Jonas Maebe
cf47b8d422 * fixed all known memory leaks in the code added for the JVM port
git-svn-id: branches/jvmbackend@19248 -
2011-09-26 19:31:34 +00:00
Jonas Maebe
6a7ff1cf75 * use temp-reference nodes rather than addrnodes to create references to
complex parameters passed to inlined routines on the JVM target, because
    it is not possible to take the address of any kind of node on the JVM
    target (temp-reference nodes work for any kind of LOC_(C)REFERENCE, but
    are currently only implemented for the JVM platform)

git-svn-id: branches/jvmbackend@18905 -
2011-08-29 22:58:55 +00:00
Jonas Maebe
951c023ca2 * when inlining, do not force creating a value-copy of const-parameters when
their address is taken if they are normally passed by reference (since then
    taking this address in the callee normally also gets the address of the
    original variable rather than of a copy)

git-svn-id: branches/jvmbackend@18834 -
2011-08-24 22:11:31 +00:00
Jonas Maebe
eb268fb2c4 + tcallnode.createinternmethodres() that allows specifying a forced
resultdef for internally generated method calls
  * force the resulttype of methods used to build non-unicode string
    constants on the JVM platform to the stringconstn's resultdef

git-svn-id: branches/jvmbackend@18832 -
2011-08-24 22:11:16 +00:00
Jonas Maebe
2428ea65c1 * replaced the old hack for non-formal var/out/constref support with
a generalized version of the formal var/out/constref support (this
    also fixes passing string[xyz] expressions to non-formal var/out/constref
    parameters)

git-svn-id: branches/jvmbackend@18774 -
2011-08-20 08:34:46 +00:00
Jonas Maebe
1a23a7cd27 * removed all remaining nounsupported ifdefs (except for the one about
variants)

git-svn-id: branches/jvmbackend@18770 -
2011-08-20 08:34:26 +00:00
Jonas Maebe
d6966e545b + support for formal var/out parameters on the JVM target:
o primitive types are first boxed
   o the parameter is passed inside an array of one class instance
   o changing the parameter inside the routine (by assigning a value to it
     like in Delphi.NET and different from regular Pascal code) will replace
     this class instance (again boxing the value if required)
   o on return, the class instance is extracted, unboxed if required, and
     assigned back to the original location
   o formal const parameters are handled without the extra array indirection,
     since they cannot be changed

  TODO: while writing tjvmcallparanode.handleformalcopyoutpara() I forgot that
    calling getcopy on ttemprefnodes whose ttempcreatenode hasn't been copied
    yet works fine, so that code is more complex than needed. Still have to
    fix.

git-svn-id: branches/jvmbackend@18675 -
2011-08-20 08:23:33 +00:00
Jonas Maebe
9ebf623895 + tcallnode.createinternmethod() constructor to easily call methods
(both instance and class/static methods)

git-svn-id: branches/jvmbackend@18661 -
2011-08-20 08:22:15 +00:00
Jonas Maebe
466f6751c8 + getpointerdef() function that returns a pointerdef for the passed def.
Multiple calls to getpointerdef() for the same def in a single module
    return the same pointerdef

git-svn-id: branches/jvmbackend@18644 -
2011-08-20 08:20:51 +00:00
Jonas Maebe
6154f1b0d9 * keep track of the number of abstract methods per class via a counter
* use this counter to mark classes containing abstract methods as
    "abstract" in the bytecode per the JVM spec
  * also use the counter to short-circuit printing of all abstract
    methods in a class when creating a new instance (we build the list
    of abstract methods every time a new instance is created, which is
    a waste of time if there are none in the first place)

git-svn-id: branches/jvmbackend@18635 -
2011-08-20 08:17:12 +00:00
Jonas Maebe
84640fe7f0 + support for non-static class methods on the JVM target
git-svn-id: branches/jvmbackend@18557 -
2011-08-20 08:10:11 +00:00