Commit Graph

35172 Commits

Author SHA1 Message Date
Jonas Maebe
af9934cb6c * make sure that integers converted to widechar are always processed by an
i2c instruction for Dalvik verification purposes

git-svn-id: branches/jvmbackend@19826 -
2011-12-11 17:26:14 +00:00
Jonas Maebe
764502fbe4 * don't "and" loaded unsigned values of 1/2 bytes with 255/65535 in case
their upper bound is lower than 127/32767: not necessary, and in case
    of booleans not even allowed for Dalvik (because the "and" operation
    turns the boolean into an integer as far as Dalvik is concerned)

git-svn-id: branches/jvmbackend@19825 -
2011-12-11 17:25:58 +00:00
Jonas Maebe
c61e9a2f04 * fixed (harmless) invalid typecasts that caused run time errors with -CR
git-svn-id: branches/jvmbackend@19824 -
2011-12-11 17:25:50 +00:00
Jonas Maebe
f4f70f99b2 * call all operators with invokestatic, since they are always
class methods

git-svn-id: branches/jvmbackend@19823 -
2011-12-11 17:25:42 +00:00
Jonas Maebe
1950fb1fa8 + jvm/java support
git-svn-id: branches/jvmbackend@19822 -
2011-12-11 17:25:24 +00:00
Jonas Maebe
21e6401921 * no longer encode all pointers to other pointer types (such as
classes, interfaces, dynamic arrays, ...) as "array of JLObject",
    but instead as an array of the actual pointed-to type. The reason
    for the previous behaviour was mainly that the JVM threadvar
    implementation internally stores all threadvars that are
    such double pointer types into an "array of JLObject". Type casting
    this array to e.g. an "array of array of byte" causes an exception
    even if it only contains "array of byte" instances (since the outer
    array type is different). This is now solved by first taking the
    element of the array and then typecasting it to the destination
    type (so dynarrbyte(arr[0]) instead of pdynarrbyte(arr)^[0]).

    The reason for the new (more accurate) behaviour is because the
    old one caused type errors in case a double pointer field was
    internally created for the nestedfpstruct support (see added
    test)

git-svn-id: branches/jvmbackend@19821 -
2011-12-11 17:25:09 +00:00
Jonas Maebe
7230d076c4 * part of r19750, forgot to commit
git-svn-id: branches/jvmbackend@19751 -
2011-12-04 15:46:48 +00:00
Jonas Maebe
0418766417 * properly delete all generated .j files in case -a is not used
(previously, only the .j file for the unit itself was deleted,
     and the ones for classes/interfaces remained behind)

git-svn-id: branches/jvmbackend@19750 -
2011-12-04 15:43:41 +00:00
Jonas Maebe
b3cf95faf6 * use ' rather than " as quote character in generated shell scripts
on unix platforms, so that $ is not interpreted as the start of a
    variable name (several jvm assembler file names include $ signs)

   -- note: the behaviour of that code depended and still depends on
        on the platform for which the compiler was compiled, instead
        on the platform for which the script is generated. That still
        needs to be fixed

git-svn-id: branches/jvmbackend@19749 -
2011-12-04 15:43:37 +00:00
Jonas Maebe
c9e6bc8d49 + support for building jvm-java compiler/rtl via top-level
make CPU_TARGET=jvm OS_TARGET=java all
    ("make install" does not yet fully work: the classes under
     rtl/units/jvm-java/org/freepascal/rtl aren't installed yet)

git-svn-id: branches/jvmbackend@19747 -
2011-12-04 15:33:55 +00:00
Jonas Maebe
271c028813 * set OEXT (.class) and ASMEXT (.j) for JVM target
git-svn-id: branches/jvmbackend@19746 -
2011-12-04 15:33:49 +00:00
Jonas Maebe
bd990d1173 * generate JVM bytecode that passes the stringent requirements of the Dalvik
verifier when -Cpjvmdalvik is used (including debug information). Using
    -Cpjvmdalvik changes the semantics at the language-level in one case:
    boolean(bytevar) will no longer return a boolean that contains the same
    value as bytevar did, but will map the value to 0/1 (that also means that
    such expressions cannot be passed to var-parameters in case of
    -Cpjvmdalvik). Code compiled with -Cpjvmdalvik will also work fine on
    the regular JVM, but it may be somewhat slower (it won't necessarily
    be slower on Dalvik, because the .class -> .dex transformation
    applies many optimizations itself)

git-svn-id: branches/jvmbackend@19743 -
2011-12-04 14:48:54 +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
Jonas Maebe
08565ce5be * save/restore the current_except_loc instead of invalidating it after each
use (since try/except statements can be nested)

git-svn-id: branches/jvmbackend@19666 -
2011-11-21 18:48:19 +00:00
Jonas Maebe
4dee36b64b * copy the implicit pointer rather than the contents of var/out/constref
implicit pointer types into the nestedfpstruct, so that the original
    parameter is properly changed when updated from inside nested routines

git-svn-id: branches/jvmbackend@19645 -
2011-11-18 21:09:38 +00:00
Jonas Maebe
74510f9069 + generic infrastructure for target-specific switches
+ -CTcompactintarrayinit command line option to change the code generation
    for typed array of some kind of integer-type initialization so that it
    takes up less space in the bytecode (because the bytecode for all
    routines, including the class initialization code that contains the
    typed constant init code, is limited 64kb, large array or multiple
    array constants could fairly easily bump into that limit)

git-svn-id: branches/jvmbackend@19638 -
2011-11-14 22:57:41 +00:00
Jonas Maebe
38c090c1a2 * fixed buffer overrun in TExternalAssembler.AsmWrite(ansistring) in case the
ansistring's length is > AsmOutSize

git-svn-id: branches/jvmbackend@19637 -
2011-11-14 22:57:34 +00:00
Jonas Maebe
c42e4178c5 * fixed copy(unicodestring,x,y) with x<>1 (second parameter of
JLString.subString() is end index, not total length to copy)

git-svn-id: branches/jvmbackend@19618 -
2011-11-10 18:53:39 +00:00
Jonas Maebe
1401c4e573 * fixed popping the unused function results of methods returning implicit
function pointer type results (records, shorstrings, ...): always pop a
    single stack slot in that case

git-svn-id: branches/jvmbackend@19598 -
2011-11-06 14:01:12 +00:00
Jonas Maebe
8bca3e9b0b * don't mark nested interfaces as "static", only do so for classes
(static interfaces don't exist)

git-svn-id: branches/jvmbackend@19556 -
2011-10-28 21:19:16 +00:00
Jonas Maebe
cfca607b9b * in case of an enum without a type name (e.g., "type xx = set of (ea,eb)"),
set the external name of the underlying class type to the internal name
    instead of to an (invalid) empty string

git-svn-id: branches/jvmbackend@19555 -
2011-10-28 21:19:12 +00:00
Jonas Maebe
2d7e674168 * fixed error in r19248 whereby the namespace for automatically generated
classes was no longer set afterwards (and the new code is also much
    simpler)

git-svn-id: branches/jvmbackend@19554 -
2011-10-28 21:19:06 +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
1edaa922c1 * never define a cross-prefix in the generated fpc.cfg when the target cpu is
the JVM, because those are always cross-compilations and the utilities
    involved (such as the java binary) don't have a prefix. That's also why
    the JVM snapshots contain their own fpc.cfg file, because fpc.cfg files
    from current releases obviously don't contain a special case for the JVM
    target.

git-svn-id: branches/jvmbackend@19233 -
2011-09-25 19:05:30 +00:00
Jonas Maebe
26b19274a3 + create an nested interface type called "Callback" inside the classes that
are used to implement procvar types, and add a constructor to the procvar
    types that accept an instance implementing this interface -> much easier
    and more natural to use procvar types from Java code

git-svn-id: branches/jvmbackend@19216 -
2011-09-24 20:32:01 +00:00
Jonas Maebe
39adb3dfae * fixed loading the nested framepointer when calling another nested
routine at the same or a higher nesting level in case the current
    nested routine's framepointer was not part of the nestedfpstruct
    (because it doesn't have nested routines itself, or because those
     don't access any data in parent routines) on targets with explicit
    parentfpstruct management (JVM) + adapted test

git-svn-id: branches/jvmbackend@19164 -
2011-09-20 22:22:26 +00:00
Jonas Maebe
3b47c40ed2 * check whether methods that implement interface methods are public
or published, because interface methods are always public and
    hence mapping them to a private/protected method increases the
    visibility of the underlying method (error on JVM target because
    the JVM doesn't like that, warning on other platforms)

git-svn-id: branches/jvmbackend@19156 -
2011-09-19 21:22:44 +00:00
Jonas Maebe
5332263d46 * fixed r18981 (conversion of LOC_JUMP to something else must happen before
before the old jump labels are restored)

git-svn-id: branches/jvmbackend@19155 -
2011-09-19 21:22:35 +00:00
Jonas Maebe
583c9a3360 * replace assigned(dynarray) and dynarray=/<>nil with length(dynarray)=/<>0
on the JVM target because empty dynarrays are not always nil there

git-svn-id: branches/jvmbackend@19154 -
2011-09-19 19:59:32 +00:00
Jonas Maebe
f96f5f9e94 + {$VARPARACOPYOUTCHECK+/-} / -Cv switch to enable checking
var-parameters on the JVM target for changes to the value passed
    as var-parameter during the function call (because they are handled
    via copy-in/copy-out, this may indicate unexpected bahviour later on).

    out-parameters are checked in the same way, except if the out-parameter
    is a local variable because then reading it before the call may result
    in a bytecode verification error (since the variable may not yet be
    initialized)

git-svn-id: branches/jvmbackend@19153 -
2011-09-19 19:59:26 +00:00
Jonas Maebe
6cb32de339 + support for help screen lines prefixed by 'J' to mark them as JVM-specific
git-svn-id: branches/jvmbackend@19152 -
2011-09-19 19:59:19 +00:00
Jonas Maebe
633de3fe30 * give an error when calling a virtual constructor from another constructor
on the JVM target, because the generated code was invalid and I can't think
    of a generic way to solve it (see added comments in njvmcal.pas)

git-svn-id: branches/jvmbackend@19055 -
2011-09-12 18:08:46 +00:00
Jonas Maebe
125c0cf225 + support for generics on the JVM target:
o don't try to create .class files for generic types
   o still generate all JVM-specific wrappers for generic types even though they
     won't be written out, because when specializing all the defid's have to
     match exactly
   o add synthetic routine implementations after generating the specializations,
     so that the synthetic routines for those specializations are also generated
     (we don't specialize generic versions of the synthetic generic routines
      because it's not easy or even always possible to create valid generic
      versions of synthetic routines)
   o Note: these are Pascal-style generics, not Java-style generics. The generic
     types nor their specializations are usable from Java code (specializations
     may become usable in the future)

git-svn-id: branches/jvmbackend@19047 -
2011-09-11 11:54:37 +00:00
Jonas Maebe
fdab7122dd * catch JLRInvocationTargetException raised when using JLRMthod.invoke() to
call a procvar (includes virtual constructors and virtual class methods),
    and raise its getCause() so that the original exception is propagated to
    the caller

git-svn-id: branches/jvmbackend@19030 -
2011-09-08 15:03:55 +00:00
Jonas Maebe
019a58ab1d * always save/restore the current_filepos when injecting code, sometimes it
isn't reset yet before a message is printed after parsing injected source
    code

git-svn-id: branches/jvmbackend@18982 -
2011-09-05 17:41:44 +00:00
Jonas Maebe
c9ebd433db * fixed array indexing via LOC_JUMP on the JVM target
git-svn-id: branches/jvmbackend@18981 -
2011-09-05 17:41:40 +00:00
Jonas Maebe
015ed4d0b6 * fixed getsingletonarraydef() so that it actually returns are arraydef of
one element rather than of two elements

git-svn-id: branches/jvmbackend@18980 -
2011-09-05 17:41:35 +00:00
Jonas Maebe
644fffbdcb * add definition of SYSTEMUNIT variable in Makefile.fpc's that didn't have
it yet

git-svn-id: branches/jvmbackend@18948 -
2011-09-02 16:06:10 +00:00
Jonas Maebe
ab7f0a4461 * changed the parameters of the fpc_pchar_ansistr_intern_charmove() added in
r18906 from byte into sizeint (copy/paste error from the similar shortstring
    helper, where both source and destination are shortstrings)

git-svn-id: branches/jvmbackend@18939 -
2011-09-01 18:27:06 +00:00
Jonas Maebe
816f9c20c7 * part of r18925, forgot to commit
git-svn-id: branches/jvmbackend@18926 -
2011-08-31 20:14:21 +00:00
Jonas Maebe
b39e74362a * use separate defines for fpc_ansistr_Unique() and
fpc_truely_ansistr_Unique(), because the i386 target has an assembler
    implementation for the latter but not for the former

git-svn-id: branches/jvmbackend@18925 -
2011-08-31 19:49:47 +00:00
Jonas Maebe
c163a327d7 * fixed abstract method accounting for external Objective-C/Java classes:
in that case if an "override" directive is missing but we interpret
    the declaration as an "override" anyway, make sure to replace the vmtpd
    with the overriding definition or child classes will keep seeing
    the abstract method in the base class and keep decreasing their abstract
    method count below zero
  * only decrease the abstract method count in case we're not processing
    category methods

git-svn-id: branches/jvmbackend@18923 -
2011-08-31 19:20:59 +00:00
Jonas Maebe
1a7c024ad3 * sign extend all byte/ansichar/word parameters before passing them
to and returning them from sub routines, in order to follow the JVM
    specs to the letter (not checked by the JVM bytecode verifiers, but
    checked by the Android DEX verifier)
  * -> also zero-extend them again at the caller side after returning
    from such a function

git-svn-id: branches/jvmbackend@18919 -
2011-08-30 23:34:12 +00:00
Jonas Maebe
f21b34c954 * also resize the value on the stack in a_load_reg_ref() when
required based on the source/destination sizes (like in
    a_load_reg_reg(), a_load_ref_reg() and a_load_ref_ref())

git-svn-id: branches/jvmbackend@18918 -
2011-08-30 23:34:07 +00:00
Jonas Maebe
0e80844e33 * also zero-extend incoming byte/word const-parameters (instead of only
value parameters)
  * fixed upper bound check to determine whether zero-extending is required

git-svn-id: branches/jvmbackend@18917 -
2011-08-30 23:34:02 +00:00
Jonas Maebe
a4cf406189 * use generic string concatentation and comparison infrastructure for the
JVM target (and also the generic routines in case of shortstrings)

git-svn-id: branches/jvmbackend@18910 -
2011-08-29 22:59:25 +00:00
Jonas Maebe
1fbd8750f2 * preparations to use generic string concatentation/comparison code for JVM
targets:
   o initialize managed temps that are passed as var-parameters to the
     dests-parameter of the concat routines, because they will be read and
     stored in the var-parameter array (they are finalized and hence work
     fine on native targets, but finalization is a nop on the JVM target)
   o do not take the shortcut of comparing with nil when checking for an
     empty ansi/unicodestring on managed VM targets

git-svn-id: branches/jvmbackend@18909 -
2011-08-29 22:59:19 +00:00
Jonas Maebe
b570ddf010 * fixed comparing pointers on the JVM target: typecast both to JLObject rather
than to pchar, since all pointers are compatible with the former but not with
    the latter

git-svn-id: branches/jvmbackend@18908 -
2011-08-29 22:59:15 +00:00
Jonas Maebe
10c586146a * moved fpc_shortstr_shortstr/chararray_intern_charmove() from sstrings.inc
to generic.inc
  * converted fpc_shortstr_concat(_multi) to use those routines so can also be
    activated for the JVM port

git-svn-id: branches/jvmbackend@18907 -
2011-08-29 22:59:10 +00:00
Jonas Maebe
5496436349 * the generic astrings.inc is now also used to the extent possible on
the JVM target, and pos/insert/delete/val/str/uniquestring/setstring/
    stringofchar/... are now also available for ansistrings on the JVM
    target

git-svn-id: branches/jvmbackend@18906 -
2011-08-29 22:59:03 +00:00