summaryrefslogtreecommitdiff
path: root/rts/StgCRun.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix incorrect stack pointer usage in StgRun() on x86_64Ben Gamari2015-08-031-11/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The STG_RETURN code from StgCRun.c is incorrect for x86_64 variants where the ABI doesn't impose a mandatory red zone for the stack, like on Windows or Xen/HaLVM. The current implementation restores the stack pointer first, which effectively marks the area with the saved registers as reusable. Later, the CPU registers are restored from this "free" area. This ordering happens to work by accident on operating systems that strictly adhere to the System V ABI, because any interrupt/signal delivery is guaranteed to leave the first 128 bytes past the stack pointer untouched (red zone). On other systems this might result in corrupted CPU registers if an interruption happens just after restoring the stack pointer. The red zone is usually only used by small leaf functions to avoid updates to the stack pointer and exploiting it doesn't give us any advantage in this case. Reviewers: austin, rwbarton Reviewed By: rwbarton Subscribers: thomie, simonmar Differential Revision: https://phabricator.haskell.org/D1120 GHC Trac Issues: #10155
* Implement PowerPC 64-bit native code backend for LinuxPeter Trommler2015-07-031-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extend the PowerPC 32-bit native code generator for "64-bit PowerPC ELF Application Binary Interface Supplement 1.9" by Ian Lance Taylor and "Power Architecture 64-Bit ELF V2 ABI Specification -- OpenPOWER ABI for Linux Supplement" by IBM. The latter ABI is mainly used on POWER7/7+ and POWER8 Linux systems running in little-endian mode. The code generator supports both static and dynamic linking. PowerPC 64-bit code for ELF ABI 1.9 and 2 is mostly position independent anyway, and thus so is all the code emitted by the code generator. In other words, -fPIC does not make a difference. rts/stg/SMP.h support is implemented. Following the spirit of the introductory comment in PPC/CodeGen.hs, the rest of the code is a straightforward extension of the 32-bit implementation. Limitations: * Code is generated only in the medium code model, which is also gcc's default * Local symbols are not accessed directly, which seems to also be the case for 32-bit * LLVM does not work, but this does not work on 32-bit either * Must use the system runtime linker in GHCi, because the GHC linker for "static" object files (rts/Linker.c) for PPC 64-bit is not implemented. The system runtime (dynamic) linker works. * The handling of the system stack (register 1) is not ELF- compliant so stack traces break. Instead of allocating a new stack frame, spill code should use the "official" spill area in the current stack frame and deallocation code should restore the back chain * DWARF support is missing Fixes #9863 Test Plan: validate (on powerpc, too) Reviewers: simonmar, trofi, erikd, austin Reviewed By: trofi Subscribers: bgamari, arnons1, kgardas, thomie Differential Revision: https://phabricator.haskell.org/D629 GHC Trac Issues: #9863
* rts: Fix typo in commentErik de Castro Lopo2015-05-241-2/+2
|
* RTS : Fix StgRun for aarch64-linux (#9935).Erik de Castro Lopo2015-01-271-8/+10
| | | | | | | | | | | | | | | | | | | | Summary: The GCC assembler doesn't seem to recognise the 'fp' and 'lr' register names which are aliases for 'x29' and 'x30' respectively. Depends on D598. Test Plan: validate Reviewers: lukexi, bgamari, austin Reviewed By: austin Subscribers: carter, thomie Differential Revision: https://phabricator.haskell.org/D599 GHC Trac Issues: #9935
* arm64: 64bit iOS and SMP support (#7942)Luke Iannini2014-11-191-10/+22
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Revert "rts: add Emacs 'Local Variables' to every .c file"Simon Marlow2014-09-291-8/+0
| | | | This reverts commit 39b5c1cbd8950755de400933cecca7b8deb4ffcd.
* rts: add Emacs 'Local Variables' to every .c fileAustin Seipp2014-07-281-0/+8
| | | | | | | | This will hopefully help ensure some basic consistency in the forward by overriding buffer variables. In particular, it sets the wrap length, the offset to 4, and turns off tabs. Signed-off-by: Austin Seipp <austin@well-typed.com>
* ghc: initial AArch64 patchesColin Watson2014-04-211-0/+66
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Add support for iOS simulator (issue #8152).Austin Seipp2013-08-241-1/+1
| | | | | | | | The iOS simulator is essentially an iOS target but for an x86 machine instead. It doesn't support the native code generator either, though. Authored-by: Stephen Blackheath <...@blacksapphire.com> Signed-off-by: Austin Seipp <aseipp@pobox.com>
* Fix build on WindowsIan Lynagh2013-04-281-0/+4
|
* Fix mismatched visibility of assembler impls of StgRunIan Lynagh2013-04-271-8/+25
| | | | | | | | | Based on a patch from PHO, in trac #7813. We were previously declaring StgRun as a private symbol (in rts/StgRun.h), but were actually defining it as a public one (in rts/StgCRun.c). This caused a linkage problem with old binutils. See: http://www.haskell.org/pipermail/ghc-devs/2013-April/000932.html
* ios fix from Stephen Blackheath; part of #7707Ian Lynagh2013-03-021-0/+2
| | | | Apparently ios doesn't understand .type %function.
* Use 'r11' rather than 'fp' on Arm; part of #7707Ian Lynagh2013-03-021-3/+3
| | | | | They're both the same register, and Linux seems happy with both, but ios only accepts r11.
* Use .globl rather than .global on arm; part of #7707Ian Lynagh2013-03-021-1/+1
| | | | | Apparently ios only understands .globl, but Linux appears to understand both.
* Fix typosIan Lynagh2012-11-011-1/+1
|
* Fix rsp alignment on Win64Ian Lynagh2012-03-241-1/+1
|
* Fix caller/callee register saving on Win64Ian Lynagh2012-03-231-5/+22
|
* Use win32AllocStack on Win64 tooIan Lynagh2012-03-191-12/+12
|
* Fix the registers used in StgRun on Win64Ian Lynagh2012-03-191-0/+8
|
* Fixes for the threaded RTS on Win64Ian Lynagh2012-03-181-0/+8
|
* fix ARM StgCRun to not save and restore r11/fp register twiceKarel Gardas2012-02-161-2/+2
|
* fix ARM's StgCRun clobbered register list for both ARM and Thumb modesKarel Gardas2012-02-161-1/+15
|
* ARM StgRun: Ensure r11 state is preservedBen Gamari2012-02-071-3/+3
|
* Fix register clobber list in StgRun for ARMBen Gamari2012-01-301-1/+1
| | | | | | | | The ARM implementation of StgRun does not claim that it clobbers r7-r12. As a result, the compiler will sometimes put the returned RegTable in one of these registers, resulting in an invalid RegTable to be returned. Hilarity ensues. Signed-off-by: Ben Gamari <bgamari.foss@gmail.com>
* Fix for unregisterised compilation: we want registers when ↵Simon Marlow2012-01-051-1/+1
| | | | | | defined(USE_MINIINTERPRETER) Needed by #5357
* Hide STG register declarations for LLVM C compilersDavid M Peixotto2011-12-191-0/+12
| | | | | | | | | | | | | | | This commit swaps the import order of Rts.h and Stg.h in StgCRun.c for non-SPARC architectures. Swapping the import order prevents the declaration of the global registers thus allowing the GHC runtime to be compiled by LLVM-based C compilers. LLVM-base C compilers cannot use the global register declarations (for R1, R2, etc.) because they use GCC-specific extensions. The declarations are not needed in StgCRun.c except for the SPARC architecture. The other architectures use hand-written assembly that accesses the appropriate register directly.
* Remove registerised code for dead architectures: mips, ia64, alpha,David Terei2011-11-221-378/+4
| | | | hppa1, m68k
* Better documentation for stack alignment designDavid Terei2011-11-171-41/+41
|
* Tabs -> Spaces + formatting fixesDavid Terei2011-11-171-395/+387
|
* Fix #4211: No need to fixup stack using mangler on OSXDavid Terei2011-11-171-1/+1
| | | | | | | We now manage the stack correctly on both x86 and i386, keeping the stack align at (16n bytes - word size) on function entry and at (16n bytes) on function calls. This gives us compatability with LLVM and GCC.
* Change stack alignment to 16+8 bytes in STG codeDavid M Peixotto2011-11-011-20/+26
| | | | | | | | | | | | | | | | | This patch changes the STG code so that %rsp to be aligned to a 16-byte boundary + 8. This is the alignment required by the x86_64 ABI on entry to a function. Previously we kept %rsp aligned to a 16-byte boundary, but this was causing problems for the LLVM backend (see #4211). We now don't need to invoke llvm stack mangler on x86_64 targets. Since the stack is now 16+8 byte algined in STG land on x86_64, we don't need to mangle the stack manipulations with the llvm mangler. This patch only modifies the alignement for x86_64 backends. Signed-off-by: David Terei <davidterei@gmail.com>
* ARMv5 compatibility for registerized runtime changes.Stephen Blackheath2011-08-101-0/+4
| | | | | | | When the bootstrap compiler does not include this patch, you must add this line to mk/build.mk, otherwise the ARM architecture cannot be detected due to a -undef option given to the C pre-processor. SRC_HC_OPTS = -pgmP 'gcc -E -traditional'
* add support for STG floating-point regs using VFPv3Karel Gardas2011-08-101-0/+2
| | | | | | | This patch adds mapping for STG floating point registers using ARM VFPv3. Since I'm using just d8-d11 also processors with just VFPv3-D16 implemented should work (e.g. NVidia Tegra2, Marvell Dove)
* make StgReturn and cas functions Thumb friendlyKarel Gardas2011-08-101-3/+12
|
* Stephen Blackheath's GHC/ARM registerised portKarel Gardas2011-08-101-0/+50
| | | | | | This is the Stephen Blackheath's GHC/ARM registerised port which is using modified version of LLVM and which provides basic registerised build functionality
* Fix Windows breakage (#5322). When I modified StgRun to use the pureSimon Marlow2011-07-181-0/+12
| | | | | | | | assembly version as part of the fix for #5250, we inadvertently lost the Windows magic for extending the stack. Win32 requires that the stack is extended a page at a time, otherwise you get a segfault. The C compiler knows how to do this, so we now call a C stub to ensure there's enough stack space at each invocation of the scheduler.
* oops, fix the x86 version of the code in here. I validated on theSimon Marlow2011-06-271-1/+1
| | | | wrong platform by mistake.
* Keep the C stack pointer 16-byte aligned on all x86 platforms, not just Mac ↵Simon Marlow2011-06-271-25/+29
| | | | | | | | | | OS X (#5250). The OS X ABI requires the C stack pointer to be 16-byte aligned at a function call. As far as I know this is not a requirement on other x86 ABIs, but it seems that gcc is now generating SSE2 code that assumes stack alignment (-mincoming-stack-boundary defaults to 4), so we have to respect 16-byte alignment.
* Change some TARGET tests to HOST tests in the RTSIan Lynagh2010-07-131-1/+1
| | | | Which was being used seemed to be random
* RTS tidyup sweep, first phaseSimon Marlow2009-08-021-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The first phase of this tidyup is focussed on the header files, and in particular making sure we are exposinng publicly exactly what we need to, and no more. - Rts.h now includes everything that the RTS exposes publicly, rather than a random subset of it. - Most of the public header files have moved into subdirectories, and many of them have been renamed. But clients should not need to include any of the other headers directly, just #include the main public headers: Rts.h, HsFFI.h, RtsAPI.h. - All the headers needed for via-C compilation have moved into the stg subdirectory, which is self-contained. Most of the headers for the rest of the RTS APIs have moved into the rts subdirectory. - I left MachDeps.h where it is, because it is so widely used in Haskell code. - I left a deprecated stub for RtsFlags.h in place. The flag structures are now exposed by Rts.h. - Various internal APIs are no longer exposed by public header files. - Various bits of dead code and declarations have been removed - More gcc warnings are turned on, and the RTS code is more warning-clean. - More source files #include "PosixSource.h", and hence only use standard POSIX (1003.1c-1995) interfaces. There is a lot more tidying up still to do, this is just the first pass. I also intend to standardise the names for external RTS APIs (e.g use the rts_ prefix consistently), and declare the internal APIs as hidden for shared libraries.
* Do not #include external header files when compiling via CSimon Marlow2008-04-021-0/+2
| | | | | | | | | | | | | | | | | | | | | | | This has several advantages: - -fvia-C is consistent with -fasm with respect to FFI declarations: both bind to the ABI, not the API. - foreign calls can now be inlined freely across module boundaries, since a header file is not required when compiling the call. - bootstrapping via C will be more reliable, because this difference in behavour between the two backends has been removed. There is one disadvantage: - we get no checking by the C compiler that the FFI declaration is correct. So now, the c-includes field in a .cabal file is always ignored by GHC, as are header files specified in an FFI declaration. This was previously the case only for -fasm compilations, now it is also the case for -fvia-C too.
* Fix the IF_DEBUG(interpreter in StgCRun.cIan Lynagh2007-08-251-2/+0
|
* save two more FP registers on ia64red5_2@hotmail.com2007-03-271-4/+8
| | | | | | Save/restore two more registers in StgCRun(). The extra registers are used by ffi009.hs, when compiling with gcc 4.1.2.
* mangler and runtime updates for gcc 4 on ia64red5_2@hotmail.com2007-03-181-12/+31
| | | | | | | | | | | | | | | Gcc 4 is doing more clever optimizations than earlier gccs. These changes let ghc compile and run on ia64 with gcc 4.0.3. Register stack frames are enlarged so that all functions use the same size stack frame. The code to mangle tail calls has been cleaned up and made more general. Additional floating-point and special-purpose registers used by GCC are saved upon entering the STG runtime. More general handling of NOP instructions. Handling of functions with multiple epilogues or no epilogue.
* Initial support for x86_64-darwinwolfgang.thaller@gmx.net2006-11-271-3/+9
| | | | Basic -fvia-C code generation is there, not much testing.
* Fix unregisterised alpha buildsIan Lynagh2006-10-041-0/+2
|
* Mips registerised supportSimon Marlow2006-08-251-0/+33
| | | | Contributed by: Thiemo Seufer <ths@networkno.de>
* Fix unregisterised builds, and building on non-x86/amd64/powerpcIan Lynagh2006-08-251-0/+2
|
* Sparc fix: work around gcc optimising away the reserved stack chunkSimon Marlow2006-08-241-1/+4
| | | | | This bug causes crashse on Sparc when calling foreign functions with more than 13 arguments.
* Reorganisation of the source treeSimon Marlow2006-04-071-0/+897
Most of the other users of the fptools build system have migrated to Cabal, and with the move to darcs we can now flatten the source tree without losing history, so here goes. The main change is that the ghc/ subdir is gone, and most of what it contained is now at the top level. The build system now makes no pretense at being multi-project, it is just the GHC build system. No doubt this will break many things, and there will be a period of instability while we fix the dependencies. A straightforward build should work, but I haven't yet fixed binary/source distributions. Changes to the Building Guide will follow, too.