Commit Graph

220 Commits

Author SHA1 Message Date
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
703e31512d * moved JVM-specific code of tloadvmtaddrnode.pass_1 to njvmmem
* create separate nodes for Objective-C in tloadvmtaddrnode.pass_1
    instead of implicitly relying on the fact that the Objective-C
    ISA field is at the same offset as the VMT of Object-Pascal
    classes
   o translate the resulting loads of ISA field into direct pointer
     accesses, so that even on non-fragile ABI platforms we don't
     go via an indirection (like clang/gcc)

git-svn-id: trunk@30947 -
2015-05-31 16:50:39 +00:00
Jonas Maebe
37c2d0e60d * use Object_getClass(obj) instead of obj._class to get the class of an
Objective-C instance on AArch64, as the latter helper from the runtime
    is a plain function call rather than an expensive message dispatch,
    and moreover it also works for protocols (the "class" method is part
    of NSObject, and protocols do not support it since there is no single
    root class and hence they may represent an instance of a class that
    does not derive from NSObject)
   o also call it to get the "self" pointer when calling class methods for
     protocols on AArch64 (fixes tobjc22a and tobjc22b on Darwin/AArch64)
   o also call it to get the metaclass of a class on Darwin/AArch64 (fixes
     tobjc25)
  - removed special handling of getting the Objective-C (meta)class for
    non-type nodes on other Darwin platforms, as this is also correctly
    handled by the generic pass_generate_code

git-svn-id: trunk@30018 -
2015-02-26 21:49:08 +00:00
Jonas Maebe
2c6e16e49e * accesses to the ISA pointer are guaranteed to be aligned -> ensure the
code generator knows this

git-svn-id: trunk@29944 -
2015-02-23 22:54:21 +00:00
Jonas Maebe
2340da410c * we cannot directly load the ISA pointer on AArch64, we have to call the
class instance method
   (http://www.sealiesoftware.com/blog/archive/2013/09/24/objc_explain_Non-pointer_isa.html )

git-svn-id: trunk@29943 -
2015-02-23 22:54:18 +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
Jeppe Johansen
7c34dc51a1 Removed vecn nodes from constant pointer address calculations to absolute variables, since only subscripts were being handled leading to problems like those described in issue #17118.
After the removal of vecn these values seem to be handled easily by subsequent optimizations anyway.

git-svn-id: trunk@28978 -
2014-11-03 20:12:19 +00:00
nickysn
235a37fad4 * moved the pass_1 handling of vecnodes for arraydefs to a new virtual method
tvecnode.first_arraydef. This will allow overriding it in the i8086 code
  generator in order to handle huge arrays.

git-svn-id: trunk@28271 -
2014-07-26 16:18:57 +00:00
nickysn
4b1e5f1c9a * in the vecnode, when indexing a pointer[], convert right to
tpointerdef.pointer_arithmetic_int_type instead of sinttype

git-svn-id: trunk@28269 -
2014-07-26 12:24:50 +00:00
nickysn
e6c5c35d65 * tarraydef.create_from_pointer changed to require the actual pointerdef as a
parameter, instead of the element def. This will allow e.g. creating huge
  arrays from huge pointers on i8086.

git-svn-id: trunk@28268 -
2014-07-26 10:39:18 +00:00
nickysn
02dff17ae0 * taddrnode: fixed getting the address of nested procs in tp mode in i8086 far
data memory models

git-svn-id: trunk@27816 -
2014-05-23 22:38:07 +00:00
nickysn
9f4dd78701 * the ifdef i8086 in taddrnode.pass_typecheck removed via using tabstractprocdef.address_type
git-svn-id: trunk@27547 -
2014-04-12 14:49:54 +00:00
florian
701cdf8ea2 * fix for #25956: left is not necessarily the array load node when accessing an open array/array of const element
git-svn-id: trunk@27487 -
2014-04-06 15:15:16 +00:00
Jonas Maebe
4a79481c51 * isolated segment-related functionality of tabsolutevarsym into i386/i8086-
specific descendent classes and moved the code that deals with this in the
    code generator also to target-specific classes -> only ifdefs left in
    pdecvar

git-svn-id: trunk@27379 -
2014-03-30 15:42:53 +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
nickysn
2908fa9123 + added type parentfpvoidpointertype, which is a void pointer with the same size
as the hidden parentfp parameter, passed to nested procs. On i8086 it is
  always a near pointer, unlike voidpointer (which changes according to the
  memory model). This fixes nested procs in i8086 far data memory models.

git-svn-id: trunk@26934 -
2014-03-02 22:55:52 +00:00
sergei
07ce8f46a4 * loadvmtaddrnode accesses global data only when left.nodetype=typen.
git-svn-id: trunk@26742 -
2014-02-09 17:44:14 +00:00
florian
cd6f4d4469 * fix tsubscriptnode to handle left.location being an fpu or mm register as well.
git-svn-id: trunk@26642 -
2014-02-01 13:08:21 +00:00
Károly Balogh
5e15e4b07d add basic constant handling to subscript nodes, avoid ie20060521 when building rgobj.pas with -O3/-O4
git-svn-id: trunk@26532 -
2014-01-20 12:00:48 +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
9fdd64e94c * indention and new line fixes
git-svn-id: trunk@25963 -
2013-11-06 21:10:28 +00:00
nickysn
f2763b98fa + implemented absolute seg:ofs vars on i8086
git-svn-id: trunk@25666 -
2013-10-05 22:16:33 +00:00
nickysn
6aae88578c + getting the address of a label now returns a far pointer in i8086 far code memory models; this fixes the call to fpc_raiseexception in the raise node
git-svn-id: trunk@25517 -
2013-09-17 22:45:13 +00:00
nickysn
c9096ef806 * far pointer fix in taddrnode.pass_typecheck
git-svn-id: trunk@24857 -
2013-06-09 23:07:30 +00:00
florian
b734c17c4f * formatting
git-svn-id: trunk@24580 -
2013-05-24 18:08:05 +00:00
nickysn
b0f7786782 + added support for special versions of near data pointers associated with a x86 segment register. They are supported on all x86 platforms: i8086, i386 and x86_64
git-svn-id: trunk@24453 -
2013-05-05 17:22:37 +00:00
paul
fe338013a5 compiler: calculate offset of record fields in taddrnode also for bitpacked structures (Jonas comment in bug #0019357)
git-svn-id: trunk@23437 -
2013-01-18 01:56:55 +00:00
Jonas Maebe
583eb3f9a4 * re-enabled loadvmtaddrnode for records on JVM targets, fixes
tests/test/jvm/tpvar.pp after r23417

git-svn-id: trunk@23430 -
2013-01-17 19:45:09 +00:00
paul
65cbb4e9ba compiler: calculate offset of record fields in taddrnode (based on patch of Jeppe Johansen, fixes bug #0019357)
git-svn-id: trunk@23428 -
2013-01-17 14:30:55 +00:00
paul
4d79a44e4c compiler: don't create loadvmtaddrnode for record references, they have no VMT (fixes bug #23130)
git-svn-id: trunk@23417 -
2013-01-17 07:30:00 +00:00
florian
761fcca4ec + is_dynamicstring
+ implement low/high for dynamic strings, resolves #15244 and #22936
+ basic support for $zerobasedstrings directive

git-svn-id: trunk@22933 -
2012-11-04 21:48:53 +00:00
pierre
bc04e83b25 Add pi_needs_got to current_procinfo.flags in pass_1 method if a label reference is used
git-svn-id: trunk@22448 -
2012-09-24 15:39:26 +00:00
Jonas Maebe
11e9f95580 * fixed (not harmless) class cast error when indexing an array[orddef] using
a non-orddef (e.g., a variant)

git-svn-id: trunk@21261 -
2012-05-08 20:02:26 +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
Jonas Maebe
284210ad48 * hardcode offset of the ISA field in Objective-C (meta)classes to be
0, just like gcc/clang. This results in more efficient code on
    non-fragile ABI platforms and removes a dependency of the name
    of the isa field in header translations

git-svn-id: trunk@20623 -
2012-03-25 12:55:18 +00:00
Jonas Maebe
ab9b52a003 * truncate indices into arrays from 64 to 32 bit on 32 bit
platforms so that their code generators don't get 64 bit
    operands (fixes internalerrors on at least ppc32  after r20108)

git-svn-id: trunk@20132 -
2012-01-20 22:43:55 +00:00
Jonas Maebe
ceee186f2f * typecheck all array indices, not just integer and boolean types
o allows converting indices to the proper type if required (such as
     variant, mantis #20873)
   o do not create temporary defs for this type checking anymore if not
     necessary
   o makes sure that errors are thrown in case of conversions considered
     as invalid by the compiler rather than that wrong code is silently
     generated (such as in mantis #20873 before this change)

git-svn-id: trunk@20108 -
2012-01-18 21:29:44 +00:00
Jonas Maebe
faaa86238c * enable support for creating loadvmtaddr nodes for Java interfaces, because
those are also supported by the Java language (intftype.class) and required
    in equivalent Pascal expressions (such as JLClass(intftype))

git-svn-id: branches/jvmbackend@19742 -
2011-12-04 14:48:48 +00:00
paul
c6ca9e5091 compiler:
- add helper function getansistringcodepage which returns explicitly set codepage or 0 in other case
  - add helper function getansistringdef which return a def with explicitly set codepage or cansistringtype in other case
  - change tstoreddef.createnai constructor to allow set codepage in constructor
  - don't convert string constants to rawbytestring. if string constant already has a codepage - preserve it or convert to ansistring codepage (delphi compatible)
  - don't perform string conversion from ansistring to strings with explicitly set codepage (by directive or by compiler switch) and vice versa (delphi compatible)
  + test which covers most of the cases

git-svn-id: trunk@19510 -
2011-10-19 02:45:52 +00:00
Jonas Maebe
67c2c7c166 * renamed cchartype to cansichartype
git-svn-id: branches/jvmbackend@18779 -
2011-08-20 08:35:24 +00:00
Jonas Maebe
979f55e1db + support for procedural variables for the JVM target
o every porocedural variable type is represented by a class with one
     public "invoke" method whose signature matches the signature of the
     procvar
   o internally, dispatching happens via java.lang.reflect.Method.invoke().
     WARNING: while this allows calling private/protected or other methods
     that are normally not accessible from another context, a security
     manger can override this. If such a security manager is installed,
     most procvars will cause security exceptions
   o such dispatching also requires that all arguments are wrapped, but
     that's done in the compiler-generated body of the invoke method,
     so that procvars can also be called conveniently from Java code
   o typecasting between a procedure of object and tmethod is supported,
     as well as Delphi-style replacing of only the method pointer via
     @procvar1=@procvar2.
   o nested procvars are not yet supported, but most of the basic
     infrastructure for them is already present
  * all units/programs now get an internal __FPC_JVM_Module_Class_Alias$
    type when compiled for the JVM target, which is an "external" class
    that maps to the unit name. This is required to look up the
    JLRMethod instances for regular functions/procedures
  + new tabstractprocdef.copyas() method that allows to create a procvar
    from a procdef and vice versa

git-svn-id: branches/jvmbackend@18690 -
2011-08-20 08:24:58 +00:00
Jonas Maebe
37aa2d8443 + full support for sets on the JVM target
o sets of enums are handled as JUEnumSet instances, others as JUBitSet
     derivatives (both smallsets and varsets, to make interoperability with
     Java easier)
   o special handling of set constants: these have to be constructed at run
     time. In case of constants in the code, create an internal constsym to
     represent them. These and regular constsyms are then aliased by an
     another internal staticvarsym that is used to initialise them in the
     unit initialisation code.
   o until they are constructed at run time, set constants are encoded as
     constant Java strings (with the characters containing the set bits)
   o hlcgobj conversion of tcginnode.pass_generate_code() for the genjumps
     part (that's the only part of the generic code that's used by the JVM
     target)
   o as far as explicit typecasting support is concerned, currently the
     following ones are supported (both from/to setdefs): ordinal types,
     enums, any other set types (whose size is the same on native targets)
   o enum setdefs also emit signatures
   o overloading routines for different ordinal set types, or for different
     enum set types, is not supported on the JVM target

git-svn-id: branches/jvmbackend@18662 -
2011-08-20 08:22:22 +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
1dca48bce5 * set reused left node to nil for JVM loadvmtaddrnodes that need to call a
helper
  * never call a helper for classrefdefs (in that case we have to load the
    classrefdef itself, not the classrefdef for the class representing
    classrefdefs)

git-svn-id: branches/jvmbackend@18575 -
2011-08-20 08:11:54 +00:00
Jonas Maebe
f187128428 * allow addrnodes for procdef (and procvardef in TP/Delphi mode), and
for JVM implicit pointer types (-> JLObject)

git-svn-id: branches/jvmbackend@18547 -
2011-08-20 08:09:21 +00:00
Jonas Maebe
6e0b73ad88 * handle string/jlstring/jlobject typecasts properly again after the reworked
typeconversion handling
  + support for class reference types in the JVM (although without class virtual
    methods, they're not that useful)

git-svn-id: branches/jvmbackend@18516 -
2011-08-20 08:06:25 +00:00
Jonas Maebe
fde622e050 * generate a loadvmtaddrnode wrapper around Java objectdef typenode arguments
to tasnode (like for regular Object Pascal classes)
  * don't collect WPO information for Java classes in tloadvmtaddrnode.pass_1()
    (devirtualization can't work for Java, since classes can always be loaded
     at run time, except for final/sealed classes -- but that's not yet
     implemented)
  + JVM is-node support, unified JVM type checking codegen for is- and as-nodes

git-svn-id: branches/jvmbackend@18383 -
2011-08-20 07:54:57 +00:00
Jonas Maebe
c1abc4a275 * call cgmessage() instead of message() for errors in
tloadvmtaddrnode.pass_typecheck(), because tas/isnode().pass_typecheck()
    checks codegenerror afterwards to determine whether an error occurred

git-svn-id: branches/jvmbackend@18382 -
2011-08-20 07:54:49 +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
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