Commit Graph

540 Commits

Author SHA1 Message Date
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
Jonas Maebe
694ccf3df3 + dummy support for untyped var/const/out parameters on the JVM target
o includes basic "auto-boxing" infrastructure to support Delphi.NET-
     compatible untyped parameters as described at
     http://hallvards.blogspot.com/2007/10/dn4dp24-net-vs-win32-untyped-parameters.html

git-svn-id: branches/jvmbackend@18510 -
2011-08-20 08:05:54 +00:00
Jonas Maebe
d1a1d30e04 * unless compiled with -dnounsupported, the compiler will now accept not
only JVM constructs that are already implemented, but also ones that
    will be supported in the future but that aren't implemented yet (to
    make it easier to already adapt code to the future changes)

git-svn-id: branches/jvmbackend@18498 -
2011-08-20 08:04:51 +00:00
Jonas Maebe
96b0ee0827 * added more options to format the result of tprocdef.fullprocname() via
a new customprocname() method and tprocnameoption flags (add parameter
    names, add "function"/"procedure", add name of owning struct or not,
    don't add the "class" prefix for class methods)
   Reason: for internal use by the compiler so it can output the procdef
    into something that can be fed back to the parser for reuse (seems
    easier than manually constructing a new procdef, or duplicating it
    inside of another objectdef)

git-svn-id: branches/jvmbackend@18426 -
2011-08-20 07:58:39 +00:00
Jonas Maebe
28740dce2d - removed extra "fordefinition" parameter again from tprocdef.mangledname(),
since the definition-specific adorning of JVM mangled names is Jasmin-
    specific, and such code has no place in symdef
  * moved code to adorn JVM mangled names for Jasmin definitions to agjasmin

git-svn-id: branches/jvmbackend@18346 -
2011-08-20 07:49:31 +00:00
Jonas Maebe
eb5814a868 * implemented declaring and calling constructors for Java classes
o handle them like for regular classes (return a class instance,
     although this is technically not true since they don't return
     anything; will be changed in the future)
   o because of the previous point, make sure that we handle the
     "function result" properly and don't pop too many values from
     the evaluation stack when calling one constructor from another
   o added "extra_pre_call_code" method used by njvmcal to insert
     the "new" opcode to create the new class instance before
     calling a constructor
   o when a constructor does not call any other constructor (inherited
     or otherwise), automatically insert a call to the inherited
     parameterless constructor as required by the jvm standard)
   TODO: check that *if* an inherited or other constructor is called
     from another constructor, that it does so as the first statement/
     call

git-svn-id: branches/jvmbackend@18328 -
2011-08-20 07:46:37 +00:00
Jonas Maebe
9a9ea1f257 + limited thlcg.gen_load_cgpara_loc() implementation (only loc_reference
support), passed through to original ncgutils version in thlcg2ll
  + thlcgobj.location_force_mem() implementation
  * order parameters for jvm similar to those for i386 without fixed_stack,
    so we don't need temporary paralocations
  * converted most of ncgcal to thlcg
  * disabled special handling for virtual methods for jvm in ncgcal, as all
    invocations are name-based there
  + njvmcal with special jvm callnode support:
   o always move the function result into a memory temp
   o when freeing an unused function result, use a_pop(2) and adjust
     the internal evaluation stack height counter
   o after the call instruction, adjust the evaluation stack height counter
     by subtracting the number of the pushed parameter slots, adjusted for
     the slots taken up by the function result

git-svn-id: branches/jvmbackend@18325 -
2011-08-20 07:46:22 +00:00
Jonas Maebe
0ee702b3a2 * tprocdef.mangledname now gets an extra boolean parameter indicating
whether the mangled name is for defining a symbol, or for referencing
    it later (e.g. for a call or load of its address). The reason is that
    on the JVM both cases are different.
  + jvmdef unit to encode types according to the JVM rules
  + tprocdef.jvmmangledname() to encode a procdef's JVM mangled name
    (the common part of defining/referencing it; tprocdef.mangledname
     afterwards adorns it as required)

git-svn-id: branches/jvmbackend@18288 -
2011-08-20 07:22:00 +00:00
Jonas Maebe
9195506c56 * make sure that anonymous inherited calls only call through to the
overridden method, rather than to any method that can accept similar
    parameters as the current one (Delphi-compatible, and corresponds to
    what is described in our documentation)
  * do not flag "inherited" call nodes that are not "anonymous inherited"
    calls using the cnf_anon_inherited flag

git-svn-id: trunk@18162 -
2011-08-10 17:26:19 +00:00
Jonas Maebe
20c3809c3a * when a constant Objective-C class reference is used for anything but
the methodpointer of a call, transform it into a call to the classclass
    method because otherwise it can be used before the first call to any
    method of the class (such as in the packages/cocoaint/src/IvarSize test)
    and this can result in crashes

git-svn-id: trunk@18124 -
2011-08-06 19:49:59 +00:00
florian
570f3c4b39 * merges recent class helper fixes by Sven Barth
git-svn-id: trunk@17887 -
2011-06-30 18:54:46 +00:00
florian
d35d1ed357 + initial support for pascal booleans with sizes 2, 4 and 8
git-svn-id: branches/pasboolxx@17836 -
2011-06-26 15:02:37 +00:00
florian
fda10ff098 * insert type conversions to the prototype type for internal procedures as well, rol/ror/sar and friends require the exact type
git-svn-id: trunk@17808 -
2011-06-23 20:50:47 +00:00
florian
58893a7342 * fix formatting: mainly wrapped extremely long lines
git-svn-id: trunk@17351 -
2011-04-20 08:18:50 +00:00