diff options
Diffstat (limited to 'libcilkrts/runtime/config/x86/cilk-abi-vla.c')
-rw-r--r-- | libcilkrts/runtime/config/x86/cilk-abi-vla.c | 78 |
1 files changed, 40 insertions, 38 deletions
diff --git a/libcilkrts/runtime/config/x86/cilk-abi-vla.c b/libcilkrts/runtime/config/x86/cilk-abi-vla.c index 38c2630a1e6..873757f98d8 100644 --- a/libcilkrts/runtime/config/x86/cilk-abi-vla.c +++ b/libcilkrts/runtime/config/x86/cilk-abi-vla.c @@ -2,11 +2,9 @@ * ************************************************************************* * - * @copyright - * Copyright (C) 2013, Intel Corporation + * Copyright (C) 2013-2016, Intel Corporation * All rights reserved. * - * @copyright * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -21,7 +19,6 @@ * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * - * @copyright * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -34,6 +31,20 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. + * + * ********************************************************************* + * + * PLEASE NOTE: This file is a downstream copy of a file mainitained in + * a repository at cilkplus.org. Changes made to this file that are not + * submitted through the contribution process detailed at + * http://www.cilkplus.org/submit-cilk-contribution will be lost the next + * time that a new version is released. Changes only submitted to the + * GNU compiler collection or posted to the git repository at + * https://bitbucket.org/intelcilkruntime/intel-cilk-runtime.git are + * not tracked. + * + * We welcome your contributions to this open source project. Thank you + * for your assistance in helping us improve Cilk Plus. * **************************************************************************/ @@ -58,37 +69,21 @@ #include <assert.h> #include <stdlib.h> #include <stdint.h> - -// Getting a definition for alloca appears to be a pain in the butt. Here's -// a variant on what's recommended in the autoconf doc -#if defined _MSC_VER -# include <malloc.h> -# define alloca _alloca -#elif defined HAVE_ALLOCA_H -# include <alloca.h> -#elif defined __GNUC__ -# define alloca __builtin_alloca -#elif defined _AIX -# define alloca __alloca -#else -# include <stddef.h> -# ifdef __cplusplus -extern "C" -# endif -void *alloca (size_t); -#endif +#include "declare-alloca.h" #ifdef _WIN32 -# define INLINE static __inline -# pragma warning(disable:1025) // Don't whine about zero extending result of unary operation +# define INLINE static __inline +# pragma warning(disable:1025) // Don't whine about zero extending result of unary operation #else -# define INLINE static inline +# define INLINE static inline #endif #include "internal/abi.h" #include "cilk-abi-vla-internal.h" +#ifdef __INTEL_COMPILER +// These functions are used only within __INTEL_COMPILER. #if defined(__x86_64) || defined(_M_X64) INLINE void setsp(void *val) { @@ -151,7 +146,7 @@ INLINE void copy_frame_up_and_move_bp( "movq %2, %%rcx;" "shrq $3, %%rcx;" "std; rep movsq; cld;" - "movl %3, %%rbp;" : + "movq %3, %%rbp;" : : "rm"(dst), "rm"(src), "rm"(cpy_bytes), "rm"(new_ebp) : "rsi", "rdi", "rcx", "rbp", "memory"); @@ -226,6 +221,7 @@ INLINE void copy_frame_up_and_move_bp( } #endif +#endif // __INTEL_COMPILER #define c_cilk_ptr_from_heap 0xc2f2f00d #define c_cilk_ptr_from_stack 0xc3f30d0f @@ -241,11 +237,17 @@ __cilkrts_stack_alloc( // be tagged ) { -#ifdef __INTEL_COMPILER // full_size will be a multiple of align, and contains // enough extra space to allocate a marker. size_t full_size = (size + align - 1) & ~(align - 1); +#ifndef __INTEL_COMPILER + // Allocate memory from the heap. The compiler is responsible + // for guaranteeing us a chance to free it before the function + // exits + return (void *)vla_internal_heap_alloc(sf, full_size, align); + +#else if (needs_tag) { full_size += align; } @@ -336,10 +338,7 @@ __cilkrts_stack_alloc( } return t; -#else // Not __INTEL_COMPILER - // Not supported unless we can figure out how to get the size of the frame - return NULL; -#endif +#endif // __INTEL_COMPILER } // This frees the space allocated for a variable length array. @@ -356,12 +355,17 @@ __cilkrts_stack_free( // on the stack, and therefore has no tag ) { -#ifdef __INTEL_COMPILER - uint32_t *t = (uint32_t*)p; - // full_size will be a multiple of align, and contains // enough extra space to allocate a marker if one was needed. size_t full_size = (size + align - 1) & ~(align - 1); + +#ifndef __INTEL_COMPILER + // Just free the allocated memory to the heap since we don't know + // how to expand/contract the calling frame + vla_internal_heap_free(p, full_size); + +#else + uint32_t *t = (uint32_t*)p; if (known_from_stack == 0) { // if the compiler hasn't told the run-time that this is // known to be on the stack, then this pointer must have been @@ -435,7 +439,5 @@ __cilkrts_stack_free( else { vla_internal_heap_free(t, full_size); } -#else // Not __INTEL_COMPILER - // Not supported unless we can figure out how to get the size of the frame -#endif +#endif // __INTEL_COMPILER } |