Commit Graph

613 Commits

Author SHA1 Message Date
Jonas Maebe
7866bae173 * don't crash when trying to access the call_self_node in case it doesn't
exit, but instead give an error (bug introduced in r30950, mantis #28338)

git-svn-id: trunk@31150 -
2015-06-23 21:23:29 +00:00
Jonas Maebe
f40ea04540 * changed getarraydef() into a tarraydef.getreusable() class method
git-svn-id: trunk@31147 -
2015-06-23 21:23:18 +00:00
Jonas Maebe
f402b0d7df * changed getpointerdef() into a tpointerdef.getreusable() class method
o allows removing the ugly x86 hacks

git-svn-id: trunk@31144 -
2015-06-22 08:17:49 +00:00
Jonas Maebe
62784ef902 * copy the vmt_entry node in tcallnode.dogetcopy (mantis #28313)
o mention why it doesn't have to be compared in tcallnode.docompare

git-svn-id: trunk@31071 -
2015-06-16 21:24:55 +00:00
Jonas Maebe
3f736f6114 * handle the loading of VMT entries at the node level, so it's done in a
type-safe way (for LLVM, and also internal consistency checking between
    the VMT as generated in nobj.pas and ncgvmt.pas)
   o also converted the VMT validity checking to the node level

git-svn-id: trunk@30950 -
2015-05-31 16:50:47 +00:00
Jonas Maebe
0eab091e1a * factored symansistr-define-conditional handling of fforcedprocname into
a property

git-svn-id: trunk@30944 -
2015-05-31 16:50:30 +00:00
Jonas Maebe
ca5addff8e * fixed memory leaks introduced in r30908
git-svn-id: trunk@30911 -
2015-05-25 15:10:16 +00:00
Jonas Maebe
caea5ac8be * record a load node for the self/vmt tree of the current routine in the
tcallnode constructor, so that when it's needed later during pass 1,
    its value doesn't depend on the context in which pass 1 is executed
    (e.g. when inlining) (mantis #18121)

git-svn-id: trunk@30908 -
2015-05-25 12:55:40 +00:00
Jonas Maebe
6c3f1c3722 * stop tcallnode.pass_1 after we've detected a direct call to a helper/
category method, as this may lead to an internalerror later on after
    the following commits

git-svn-id: trunk@30907 -
2015-05-25 12:55:37 +00:00
Jonas Maebe
f51b11e969 * implemented tcallnode.create_procvar on top of tcallnode.create
git-svn-id: trunk@30906 -
2015-05-25 12:55:34 +00:00
Jonas Maebe
5bb89cc2f0 * keep track of the reason why a loadparentfpnode has been created: to
load a value from a nested context, or to pass a context to a nested
    routine. In case a target uses both the stack and frame pointer, this
    difference can matter.

git-svn-id: trunk@29937 -
2015-02-23 22:53:59 +00:00
Jonas Maebe
f69d2fe61d * AArch64 doesn't use *stret routines for Objective-C dispatching, because it
doesn't need special code for returning a struct by reference

git-svn-id: trunk@29936 -
2015-02-23 22:53:56 +00:00
Jonas Maebe
edb3124ae8 * copy arrays passed by value to cdecl routines on the callee side even on
platforms that normally must copy value parameters on the caller side,
    because
   o if we copy them on the caller side, then the behaviour will be different
     compared to other platforms if the called routine is implemented in C
     (since they are passed by reference, changes to the array contents will
      be visible on other platforms, while they wouldn't be visible if the
      copy is made on the caller side)
   o if we don't copy them on the caller nor on the callee side, then behaviour
     will be different compared to other platforms if the called routine is
     implemented in Pascal and modifies the array (since then changes won't be
     visible on the caller side, except on platforms that normally perform
     the copy on the caller side)

git-svn-id: trunk@29873 -
2015-02-23 22:50:29 +00:00
Jonas Maebe
6e12ad817f * don't make copies of arrays passed as value parameters to cdecl routines
(since C compilers don't copy such arrays either, as they're implciitly
     pointers)

git-svn-id: trunk@29871 -
2015-02-23 22:50:23 +00:00
Jonas Maebe
c6ba0bb6fb + support for targets that require by-reference value parameters to be
be copied on the caller instead of callee side
   o mark Darwin/Aarch64 as such a target (any AArch64 target will be like
     that normally, as its ABI specifies this behaviour)
   o don't mark by-reference value parameters on such targets as
     vo_has_local_copy, since a) they don't have one (the copy is on the
     caller side), and b) this ensures that all code handling such
     parameters automatically knows that they are still by reference
     after the init code has run
   o when making the copies on the caller side, don't increase the
     reference count for managed types except for variants, just like
     is done when making the copies on the callee side. This is because
     the reference count increasing code on the callee side only runs
     for non-assembler functions, and we cannot know 100% certain on the
     caller side whether the called function is assembler or not (e.g. in
     case of externally declared functions)
   o maybe over time we can reuse the Pascal code in
     tcallparanode.copy_value_by_ref_para to replace the equivalent code
     in hlcgobj and ncgutil also on the caller side for other targets

git-svn-id: trunk@29870 -
2015-02-23 22:50:20 +00:00
Jonas Maebe
aae879d28a * also set aktcallnode during tcallnode.pass_1, so that the callparanode
pass_1 code can make use of it

git-svn-id: trunk@29818 -
2015-02-23 22:47:41 +00:00
Jonas Maebe
863e81315e * changed goto usage in tcallnode.pass_typecheck into try/finally (and at
the same time solved some issues where "exit" instead of "goto errorexit"
    was used)

git-svn-id: trunk@29817 -
2015-02-23 22:47:38 +00:00
florian
d6bfb29313 * clean usercode_entry flag from outer block when copying a subroutine node tree for inlining, enables sometimes better inlining
git-svn-id: trunk@29627 -
2015-02-04 21:18:04 +00:00
florian
42020c8bb8 * when passing a parameter by var/out, its address leaves the current scope so the compiler has to take care of this
* when getting rid of temps. of inline parameters, take care if somewhere an alias of the variable might exist, resolves #24796 and #26534

git-svn-id: trunk@29616 -
2015-02-03 21:05:39 +00:00
Jonas Maebe
eb419b58c5 - disable inlining of routines that contain a call to a C-style varargs
function, as we don't save/restore the synthetic paravarsyms that
    are created for this

git-svn-id: trunk@29584 -
2015-01-30 19:31:22 +00:00
Jonas Maebe
146e3bcb9e * synchronised with trunk till r29513
git-svn-id: branches/blocks@29516 -
2015-01-21 23:28:34 +00:00
Jonas Maebe
e97f31541e - reverted partial commit of merge
git-svn-id: branches/blocks@29515 -
2015-01-21 23:24:37 +00:00
Jonas Maebe
a76bbf363d * synchronised with trunk r29513
git-svn-id: branches/blocks@29514 -
2015-01-21 23:18:29 +00:00
florian
681c1afe6c * limit inlined expansion and exponential code grow, resolves #23862
git-svn-id: trunk@29495 -
2015-01-17 13:52:41 +00:00
florian
ccb01d6196 * allow subtraction/addition of internally generated nodes, resolves #27256
git-svn-id: trunk@29456 -
2015-01-12 20:56:17 +00:00
florian
d540d56908 * unified internal errors
git-svn-id: trunk@29280 -
2014-12-13 11:46:59 +00:00
sergei
64af966eaa * Mantis #27044: copy Variant to temp if it cannot be passed by reference to fpc_dispinvoke_variant helper. This provides behavior consistent to implicit 'self' parameter of objects/records.
git-svn-id: trunk@29093 -
2014-11-20 18:36:10 +00:00
Jonas Maebe
b0639405ac * compare the actual target nodes when checking whether the result of an
inline function is getting assigned to one of its parameters, so that
    typecasts etc. are dealt with correctly (mantis #26536)

git-svn-id: trunk@28834 -
2014-10-16 17:49:02 +00:00
Jonas Maebe
bd09b88a5b + support for http://en.wikipedia.org/wiki/Blocks_(C_language_extension)
o blocks are implemented as a variation of procedure variables
   o declaration of a block variable: "test: procedure(c: char) is block;"
     (C equivalent: (void)(^test)(char c) )
   o the compiler automatically converts procedures/functions whose address
     is passed to a block parameter or assigned to a block variable into
     a "block". This consists of
    1) generating a block descriptor (containing the size of the "block
       literal" (see below) and the signature of the invocation function
       encoded as an Objective-C selector)
    2) generating a wrapper function around the original funcion (with C
       calling convention), that has an extra first hidden parameter
       (marked as vo_is_parentfp in the compiler) whose type is a pointer
       to the describing "block literal"
    3) generating the "block literal", which contains a pointer to an
       external variable indicating whether this block captures context or
       not, some flags (see compiler/blockutl.get_block_literal_flags for
       info), a pointer to the wrapper function and a pointer to the
       descriptor. In the future, it will also contain captured variables.
   o right now, only global procedures/functions can be converted to blocks
     (because they don't require state capturing). The next steps are (Object
     Pascal) methods (not Objective-C methods, because Objective-C method
     procvars don't exist) and finally nested functions
   o on Mac OS X, the functionality will only work on Mac OS X 10.7 and later,
     because we have to use the so-called "ABI.2010.3.16" to ensure that
     our blocks aren't called as variadic functions by the runtime (which
     came out after the Mac OS X 10.6 release)
   o while the currently implemented functionality does not require any
     library support at all, there's no use enabling it on other platforms
     because unless it has been confirmed to work with a blocks runtime,
     there's no point in using blocks (they're just somewhat bulky procvars
     right now). Enabling it on other platforms (in combination with the
     GNUStep Objective-C run time), should simply be a matter of adding
     the right {$linklib xxx} statement to rtl/inc/blockrtl.pp file, adding
     that file to Makefile.fpc for that platform and adding that platform
     to the compiler/systems.systems_blocks_supported set

git-svn-id: branches/blocks@28232 -
2014-07-18 09:15:22 +00:00
nickysn
24fcac9f87 + added support for nested procvars in the i8086 far data memory models
git-svn-id: trunk@27812 -
2014-05-22 23:44:09 +00:00
Jonas Maebe
5fa09fa2f4 * changed tcallnode.fforcedprocname from shortstring into tsymstr,
so it doesn't truncate mangled names for the JVM target (it's
    used there since r27149)
   o adapted a number of WPO helpers to use tsymstr instead of
     shortstring, but the WPO devirtualization functionality is
     still limited to shortstrings internally

git-svn-id: trunk@27741 -
2014-05-10 12:47:25 +00:00
Jonas Maebe
9f6d6f4aa8 * copy tcallnode.fforcedprocname field
git-svn-id: trunk@27740 -
2014-05-10 12:47:22 +00:00
florian
d88d644925 + support for FMA intrinsic: if there is no hardware support, the compiler throws an error.
Currently it is implemented only for x86-CPUs supporting the FMA extension. While it would
  be possible to implement it in software or simulate fma(<single>,<single>,<single>) using
  double operations, it makes no sense in my opinion to do so.

git-svn-id: trunk@27564 -
2014-04-13 19:21:54 +00:00
Jonas Maebe
9c7c64a3af * moved amiga/morphos-specific libsym-related field from tprocdef to
cpu-specific descendants (unfortunately causes some duplication, but the
    code is trivial and there is no easy way to avoid it)
  * also moved the use of the field in ncal to cpu-specific files (with same
    caveat)

git-svn-id: trunk@27438 -
2014-04-01 21:41:27 +00:00
Jonas Maebe
b57c95043f + support overriding tdef/tsym methods with target-specific functionality:
o made all (non-abstract) tdef and tsym constructors virtual
   o added c*def/c*sym classref types for every (non-abstract) t*def/t*sym
     class
   o added cpusym unit for every architecture that derives a tcpu*def/tcpu*sym
     class from the base classes, and initialises the c*def/c*sym classes with
     them. This is done so that the llvm target will be able to derive from
     the tcpu*def/sym classes without umpteen ifdefs, and it also means that
     the WPO can devirtualise everything because the c* variables are only
     initialised with one class type
   o replaced all t*def/t*sym constructor calls with c*def/c*sym constructor
     calls

git-svn-id: trunk@27361 -
2014-03-29 22:31:55 +00:00
Jonas Maebe
1ac4021178 * moved po_has_inlininginfo from procoptions to procimploptions so that
the availability of the body of a function declared as "inline" no
    longer changes the CRC and hence no longer triggers recompilations
    (mantis #24121)

git-svn-id: trunk@27192 -
2014-03-19 21:53:10 +00:00
Jonas Maebe
84442d05f9 * renamed fobjcforcedprocname to fforcedprocname and also use it for the
JVM target to force virtual method calls to be name-based rather than
    VMT-entry-based

git-svn-id: trunk@27149 -
2014-03-16 11:24:25 +00:00
sergei
df6837fa12 * Fixed cloning of varargs parameters in tcallnode.dogetcopy, resolves #23981.
git-svn-id: trunk@26758 -
2014-02-13 01:12:58 +00:00
florian
1366498255 + nf_addr_taken: it marks nodes which address is taken
+ check if tnodeflags is 4 bytes or less
* do not do cse on expressions which address is taken

git-svn-id: trunk@26713 -
2014-02-07 20:40:42 +00:00
sergei
52af9a2c89 * Changed passing of hidden parameters to constructors of class-style objects: VMT is always passed in the first ('self') parameter, and the second one ('vmt', although this name is now misleading) contains flag specifying the constructor behavior and meaning of 'self'. Together with r26656 this removes methodpointer sharing between two parameter node trees, it becomes possible not to put methodpointer into temp, but use node tree below 'self' parameter to do virtual calls. This also matches behavior of Delphi.
git-svn-id: trunk@26683 -
2014-02-06 12:26:47 +00:00
sergei
a1dfaa54dd * Fixed exception handling in constructors of TP-style objects to correctly handle cases of statically allocated objects (must call destructor but do not free memory) and objects without destructor (must free memory if it was allocated dynamically).
+ Test extended.

git-svn-id: trunk@26676 -
2014-02-05 18:19:13 +00:00
sergei
a5d5ce8eb2 * TP-style object destructors do not need actual VMT in hidden parameter, a constant flag indicating need to free memory is sufficient.
* Destructor called from exception block in constructor must have this flag set in order to free memory.
+ Test.

git-svn-id: trunk@26656 -
2014-02-03 00:20:42 +00:00
florian
e6b68d19c8 * reordered decision how arguments for inlining are handled
* improved comments for inline argument handling
* replace arguments more aggressively with a copy of their original node tree when inlining

git-svn-id: trunk@26649 -
2014-02-01 22:26:23 +00:00
florian
2a7dcf6c7b * formatting
git-svn-id: trunk@26646 -
2014-02-01 13:08:30 +00:00
florian
d71bfe4c6f * var parameters can be put in registers if the callee is inlined
git-svn-id: trunk@26643 -
2014-02-01 13:08:24 +00:00
Jonas Maebe
c05da62b0e * detect static data use by record methods and methods of nested classes/
records, so we avoid inlining them (mantis #25598)

git-svn-id: trunk@26617 -
2014-01-29 21:26:38 +00:00
sergei
1a3b46967e + Two more checks for access to global data and setting the pi_needs_got flag, intended for targets that require decision about PIC code generation strictly before pass 2.
git-svn-id: trunk@26292 -
2013-12-27 13:41:36 +00:00
florian
4d5119bf1c * fixes several issues which cause warnings by the dfa code when using it to detect uninitialized variables
git-svn-id: trunk@26161 -
2013-12-01 17:02:08 +00:00
florian
1d4a4d0684 + noreturn directive
git-svn-id: trunk@26003 -
2013-11-10 09:00:59 +00:00
svenbarth
798bb91e90 Extract tdef.is_related plus its overrides in tobjectdef, trecorddef and tstringdef into a new function def_is_related in unit defcmp.
defcmp.pas:
  + add new function "def_is_related" which combines the "is_related" overloads of "tobjectdef", "trecorddef" and "tstringdef" (it returns "false" for other def types which is what "tdef.is_related" did)
  * compare_defs_ext & compatible_childmethod_resultdef: change call from "x.is_related" to "def_is_related(x,...)"
symtype.pas, tdef:
  - remove "is_related" method
symdef.pas:
  - remove "is_related" in "tobjectdef", "trecorddef" and "tstringdef"
  * tobjectdef.needs_inittable: for checking whether a Corba interface somehow inherits from a IInterface don't use "is_related" anymore (we want to avoid the dependency after all), but mimic the necessary functionality of "def_is_related"
htypechk.pas, nadd.pas, ncal.pas, ncnv.pas, ngtcon.pas, nld.pas, optvirt.pas, pdecobj.pas, pdecvar.pas, pexpr.pas, pgenutil.pas:
  * change call from "x.is_related" to "def_is_related(x,...)"
symtable.pas
  + use unit defcmp
  * change call from "x.is_related" to "def_is_related(x,...)"
jvm/njvmcnv.pas, jvm/njvmflw.pas:
  * change call from "x.is_related" to "def_is_related(x,...)"

git-svn-id: trunk@25847 -
2013-10-25 19:44:27 +00:00