Skip to content
This repository was archived by the owner on Jun 20, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions gcc/d/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2015-08-10 Iain Buclaw <ibuclaw@gdcproject.org>

* d-elem.cc(HaltExp::toElem): Use __builtin_trap to halt execution,
rather than the library abort() call.

2015-08-07 Iain Buclaw <ibuclaw@gdcproject.org>

* d-codegen.cc(build_closure): Update signature, update all callers.
Expand Down
3 changes: 1 addition & 2 deletions gcc/d/d-elem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1891,8 +1891,7 @@ FuncExp::toElem (IRState *)
elem *
HaltExp::toElem (IRState *)
{
// Needs improvement. Avoid library calls if possible..
return d_build_call_nary (builtin_decl_explicit (BUILT_IN_ABORT), 0);
return d_build_call_nary (builtin_decl_explicit (BUILT_IN_TRAP), 0);
}

elem *
Expand Down
7 changes: 2 additions & 5 deletions libphobos/libdruntime/gcc/deh.d
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ import gcc.unwind.pe;
import gcc.builtins;
import gcc.config;

import core.memory;
import core.stdc.stdlib;

extern(C)
{
int _d_isbaseof(ClassInfo, ClassInfo);
Expand Down Expand Up @@ -125,7 +122,7 @@ private void
__gdc_terminate()
{
// Replaces std::terminate and terminating with a specific handler
abort();
__builtin_trap();
}

// This is called by the unwinder.
Expand Down Expand Up @@ -408,7 +405,7 @@ else
return _URC_CONTINUE_UNWIND;

default:
abort();
__builtin_trap();
}
actions |= state & _US_FORCE_UNWIND;

Expand Down
85 changes: 42 additions & 43 deletions libphobos/libdruntime/gcc/unwind/generic.d
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,21 @@
module gcc.unwind.generic;

private import gcc.builtins;
private import core.stdc.stdlib; // for abort

/* This is derived from the C++ ABI for IA-64. Where we diverge
for cross-architecture compatibility are noted with "@@@". */

extern (C):
extern(C):

/* Level 1: Base ABI */

/* @@@ The IA-64 ABI uses uint64 throughout. Most places this is
inefficient for 32-bit and smaller machines. */
alias _Unwind_Word = __builtin_unwind_uint;
alias _Unwind_Sword = __builtin_unwind_int;
version (IA64)
version(IA64)
{
version (HPUX)
version(HPUX)
alias _Unwind_Ptr = __builtin_machine_uint;
else
alias _Unwind_Ptr = __builtin_pointer_uint;
Expand Down Expand Up @@ -110,55 +109,55 @@ enum
struct _Unwind_Context;

/* Raise an exception, passing along the given exception object. */
_Unwind_Reason_Code _Unwind_RaiseException (_Unwind_Exception *);
_Unwind_Reason_Code _Unwind_RaiseException(_Unwind_Exception *);

/* Raise an exception for forced unwinding. */

extern(C) alias _Unwind_Stop_Fn
= _Unwind_Reason_Code function (int, _Unwind_Action,
_Unwind_Exception_Class,
_Unwind_Exception *,
_Unwind_Context *, void *);
= _Unwind_Reason_Code function(int, _Unwind_Action,
_Unwind_Exception_Class,
_Unwind_Exception *,
_Unwind_Context *, void *);

_Unwind_Reason_Code _Unwind_ForcedUnwind (_Unwind_Exception *, _Unwind_Stop_Fn, void *);
_Unwind_Reason_Code _Unwind_ForcedUnwind(_Unwind_Exception *, _Unwind_Stop_Fn, void *);

/* Helper to invoke the exception_cleanup routine. */
void _Unwind_DeleteException (_Unwind_Exception *);
void _Unwind_DeleteException(_Unwind_Exception *);

/* Resume propagation of an existing exception. This is used after
e.g. executing cleanup code, and not to implement rethrowing. */
void _Unwind_Resume (_Unwind_Exception *);
void _Unwind_Resume(_Unwind_Exception *);

/* @@@ Resume propagation of an FORCE_UNWIND exception, or to rethrow
a normal exception that was handled. */
_Unwind_Reason_Code _Unwind_Resume_or_Rethrow (_Unwind_Exception *);
_Unwind_Reason_Code _Unwind_Resume_or_Rethrow(_Unwind_Exception *);

/* @@@ Use unwind data to perform a stack backtrace. The trace callback
is called for every stack frame in the call chain, but no cleanup
actions are performed. */
extern(C) alias _Unwind_Trace_Fn
= _Unwind_Reason_Code function (_Unwind_Context *, void *);
= _Unwind_Reason_Code function(_Unwind_Context *, void *);

_Unwind_Reason_Code _Unwind_Backtrace (_Unwind_Trace_Fn, void *);
_Unwind_Reason_Code _Unwind_Backtrace(_Unwind_Trace_Fn, void *);

/* These functions are used for communicating information about the unwind
context (i.e. the unwind descriptors and the user register state) between
the unwind library and the personality routine and landing pad. Only
selected registers may be manipulated. */

_Unwind_Word _Unwind_GetGR (_Unwind_Context *, int);
void _Unwind_SetGR (_Unwind_Context *, int, _Unwind_Word);
_Unwind_Word _Unwind_GetGR(_Unwind_Context *, int);
void _Unwind_SetGR(_Unwind_Context *, int, _Unwind_Word);

_Unwind_Ptr _Unwind_GetIP (_Unwind_Context *);
_Unwind_Ptr _Unwind_GetIPInfo (_Unwind_Context *, int *);
void _Unwind_SetIP (_Unwind_Context *, _Unwind_Ptr);
_Unwind_Ptr _Unwind_GetIP(_Unwind_Context *);
_Unwind_Ptr _Unwind_GetIPInfo(_Unwind_Context *, int *);
void _Unwind_SetIP(_Unwind_Context *, _Unwind_Ptr);

/* @@@ Retrieve the CFA of the given context. */
_Unwind_Word _Unwind_GetCFA (_Unwind_Context *);
_Unwind_Word _Unwind_GetCFA(_Unwind_Context *);

void *_Unwind_GetLanguageSpecificData (_Unwind_Context *);
void *_Unwind_GetLanguageSpecificData(_Unwind_Context *);

_Unwind_Ptr _Unwind_GetRegionStart (_Unwind_Context *);
_Unwind_Ptr _Unwind_GetRegionStart(_Unwind_Context *);


/* The personality routine is the function in the C++ (or other language)
Expand All @@ -176,55 +175,55 @@ _Unwind_Ptr _Unwind_GetRegionStart (_Unwind_Context *);
lack of code to handle the different data format. */

extern(C) alias _Unwind_Personality_Fn
= _Unwind_Reason_Code function (int, _Unwind_Action,
_Unwind_Exception_Class,
_Unwind_Exception *,
_Unwind_Context *);
= _Unwind_Reason_Code function(int, _Unwind_Action,
_Unwind_Exception_Class,
_Unwind_Exception *,
_Unwind_Context *);

/* @@@ The following alternate entry points are for setjmp/longjmp
based unwinding. */

struct SjLj_Function_Context;
extern void _Unwind_SjLj_Register (SjLj_Function_Context *);
extern void _Unwind_SjLj_Unregister (SjLj_Function_Context *);
extern void _Unwind_SjLj_Register(SjLj_Function_Context *);
extern void _Unwind_SjLj_Unregister(SjLj_Function_Context *);

_Unwind_Reason_Code _Unwind_SjLj_RaiseException (_Unwind_Exception *);
_Unwind_Reason_Code _Unwind_SjLj_ForcedUnwind (_Unwind_Exception *, _Unwind_Stop_Fn, void *);
void _Unwind_SjLj_Resume (_Unwind_Exception *);
_Unwind_Reason_Code _Unwind_SjLj_Resume_or_Rethrow (_Unwind_Exception *);
_Unwind_Reason_Code _Unwind_SjLj_RaiseException(_Unwind_Exception *);
_Unwind_Reason_Code _Unwind_SjLj_ForcedUnwind(_Unwind_Exception *, _Unwind_Stop_Fn, void *);
void _Unwind_SjLj_Resume(_Unwind_Exception *);
_Unwind_Reason_Code _Unwind_SjLj_Resume_or_Rethrow(_Unwind_Exception *);

/* @@@ The following provide access to the base addresses for text
and data-relative addressing in the LDSA. In order to stay link
compatible with the standard ABI for IA-64, we inline these. */

version (IA64)
version(IA64)
{
_Unwind_Ptr
_Unwind_GetDataRelBase (_Unwind_Context *_C)
_Unwind_GetDataRelBase(_Unwind_Context *_C)
{
/* The GP is stored in R1. */
return _Unwind_GetGR (_C, 1);
return _Unwind_GetGR(_C, 1);
}

_Unwind_Ptr
_Unwind_GetTextRelBase (_Unwind_Context *)
_Unwind_GetTextRelBase(_Unwind_Context *)
{
abort ();
__builtin_trap();
return 0;
}

/* @@@ Retrieve the Backing Store Pointer of the given context. */
_Unwind_Word _Unwind_GetBSP (_Unwind_Context *);
_Unwind_Word _Unwind_GetBSP(_Unwind_Context *);
}
else
{
_Unwind_Ptr _Unwind_GetDataRelBase (_Unwind_Context *);
_Unwind_Ptr _Unwind_GetTextRelBase (_Unwind_Context *);
_Unwind_Ptr _Unwind_GetDataRelBase(_Unwind_Context *);
_Unwind_Ptr _Unwind_GetTextRelBase(_Unwind_Context *);
}

/* @@@ Given an address, return the entry point of the function that
contains it. */
extern void * _Unwind_FindEnclosingFunction (void *pc);
extern void * _Unwind_FindEnclosingFunction(void *pc);


/* leb128 type numbers have a potentially unlimited size.
Expand All @@ -247,6 +246,6 @@ else static if (long.sizeof >= (void*).sizeof)
}
else
{
static assert (0, "What type shall we use for _sleb128_t?");
static assert(0, "What type shall we use for _sleb128_t?");
}

40 changes: 20 additions & 20 deletions libphobos/libdruntime/gcc/unwind/pe.d
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
module gcc.unwind.pe;

import gcc.unwind;
private import core.stdc.stdlib : abort;
import gcc.builtins;

/* Pointer encodings, from dwarf2.h. */
enum
Expand All @@ -48,13 +48,13 @@ enum
DW_EH_PE_indirect = 0x80
}

version (NO_SIZE_OF_ENCODED_VALUE) {}
version(NO_SIZE_OF_ENCODED_VALUE) {}
else
{
/* Given an encoding, return the number of bytes the format occupies.
This is only defined for fixed-size encodings, and so does not
include leb128. */
uint size_of_encoded_value (ubyte encoding)
uint size_of_encoded_value(ubyte encoding)
{
if (encoding == DW_EH_PE_omit)
return 0;
Expand All @@ -74,7 +74,7 @@ else
}
}

version (NO_BASE_OF_ENCODED_VALUE) {}
version(NO_BASE_OF_ENCODED_VALUE) {}
else
{
/* Given an encoding and an _Unwind_Context, return the base to which
Expand All @@ -83,7 +83,7 @@ else
not available. */

_Unwind_Ptr
base_of_encoded_value (ubyte encoding, _Unwind_Context *context)
base_of_encoded_value(ubyte encoding, _Unwind_Context *context)
{
if (encoding == DW_EH_PE_omit)
return cast(_Unwind_Ptr) 0;
Expand All @@ -96,13 +96,13 @@ else
return cast(_Unwind_Ptr) 0;

case DW_EH_PE_textrel:
return _Unwind_GetTextRelBase (context);
return _Unwind_GetTextRelBase(context);
case DW_EH_PE_datarel:
return _Unwind_GetDataRelBase (context);
return _Unwind_GetDataRelBase(context);
case DW_EH_PE_funcrel:
return _Unwind_GetRegionStart (context);
return _Unwind_GetRegionStart(context);
}
assert (0);
assert(0);
}
}

Expand All @@ -112,7 +112,7 @@ else
pointers should not be leb128 encoded on that target. */

ubyte *
read_uleb128 (ubyte *p, _uleb128_t *val)
read_uleb128(ubyte *p, _uleb128_t *val)
{
uint shift = 0;
ubyte a_byte;
Expand All @@ -134,7 +134,7 @@ read_uleb128 (ubyte *p, _uleb128_t *val)
/* Similar, but read a signed leb128 value. */

ubyte *
read_sleb128 (ubyte *p, _sleb128_t *val)
read_sleb128(ubyte *p, _sleb128_t *val)
{
uint shift = 0;
ubyte a_byte;
Expand Down Expand Up @@ -162,8 +162,8 @@ read_sleb128 (ubyte *p, _sleb128_t *val)
by base_of_encoded_value for this encoding in the appropriate context. */

ubyte *
read_encoded_value_with_base (ubyte encoding, _Unwind_Ptr base,
ubyte *p, _Unwind_Ptr *val)
read_encoded_value_with_base(ubyte encoding, _Unwind_Ptr base,
ubyte *p, _Unwind_Ptr *val)
{
union unaligned
{
Expand Down Expand Up @@ -199,15 +199,15 @@ read_encoded_value_with_base (ubyte encoding, _Unwind_Ptr base,
case DW_EH_PE_uleb128:
{
_uleb128_t tmp;
p = read_uleb128 (p, &tmp);
p = read_uleb128(p, &tmp);
result = cast(_Unwind_Internal_Ptr) tmp;
}
break;

case DW_EH_PE_sleb128:
{
_sleb128_t tmp;
p = read_sleb128 (p, &tmp);
p = read_sleb128(p, &tmp);
result = cast(_Unwind_Internal_Ptr) tmp;
}
break;
Expand Down Expand Up @@ -239,7 +239,7 @@ read_encoded_value_with_base (ubyte encoding, _Unwind_Ptr base,
break;

default:
abort ();
__builtin_trap();
}

if (result != 0)
Expand All @@ -262,11 +262,11 @@ else
rather than providing it directly. */

ubyte *
read_encoded_value (_Unwind_Context *context, ubyte encoding,
ubyte *p, _Unwind_Ptr *val)
read_encoded_value(_Unwind_Context *context, ubyte encoding,
ubyte *p, _Unwind_Ptr *val)
{
return read_encoded_value_with_base (encoding,
base_of_encoded_value (encoding, context),
return read_encoded_value_with_base(encoding,
base_of_encoded_value(encoding, context),
p, val);
}
}
Expand Down