Skip to content

Commit

Permalink
Add native bif wrapper generation for Epiphany
Browse files Browse the repository at this point in the history
  • Loading branch information
margnus1 committed Aug 20, 2015
1 parent de7dd54 commit bc53f46
Show file tree
Hide file tree
Showing 17 changed files with 811 additions and 181 deletions.
6 changes: 3 additions & 3 deletions erts/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -5025,11 +5025,11 @@ if test X$enable_slave_emulator != Xno; then
fi
fi

ERTS_BUILD_SLAVE_EMU=no
SLAVE_ENABLED=
if test X$enable_slave_emulator != Xno; then
ERTS_BUILD_SLAVE_EMU=yes
SLAVE_ENABLED=yes
fi
AC_SUBST(ERTS_BUILD_SLAVE_EMU)
AC_SUBST(SLAVE_ENABLED)

dnl ----------------------------------------------------------------------
dnl Output the result.
Expand Down
18 changes: 9 additions & 9 deletions erts/emulator/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,14 @@ endif

ERTS_ENABLE_KERNEL_POLL=@ERTS_ENABLE_KERNEL_POLL@

BUILD_SLAVE_EMU=no
ifeq (@ERTS_BUILD_SLAVE_EMU@, yes)
BUILD_SLAVE=
ifdef SLAVE_ENABLED
# We only include slave support in the smp build
ifeq ($(FLAVOR),smp)
# This script requires $(TF_MARKER), so we include it down here
include slave/info.mk

BUILD_SLAVE_EMU=yes
BUILD_SLAVE=yes
ENABLE_ALLOC_TYPE_VARS += slave
FLAVOR_FLAGS+=-DERTS_SLAVE_EMU_ENABLED
endif
Expand Down Expand Up @@ -465,7 +465,7 @@ clean:
$(RM) -rf zlib/obj/$(TARGET)
$(RM) -rf bin/$(TARGET)
cd $(ERTS_LIB_DIR) && $(MAKE) clean
ifeq ($(BUILD_SLAVE_EMU), yes)
ifdef BUILD_SLAVE
$(V_at)( cd slave && $(MAKE) FLAVOR=$(FLAVOR) clean )
endif

Expand Down Expand Up @@ -611,7 +611,7 @@ GENERATE += $(TARGET)/erl_version.h
$(TTF_DIR)/driver_tab.c: Makefile.in utils/make_driver_tab
$(gen_verbose)LANG=C $(PERL) utils/make_driver_tab -o $@ -nifs $(STATIC_NIF_LIBS) -drivers $(DRV_OBJS) $(STATIC_DRIVER_LIBS)

ifeq ($(BUILD_SLAVE_EMU), yes)
ifdef BUILD_SLAVE
# Poor mans cross-architecture linking; we generate a header file that, for each
# symbol [symbol] in the slave emulator, defines SLAVE_SYM_[symbol] to a numeric
# literal of the address of [symbol].
Expand Down Expand Up @@ -953,10 +953,10 @@ HIPE_epiphany_OBJS=$(OBJDIR)/hipe_epiphany.o $(OBJDIR)/hipe_epiphany_glue.o $(OB
HIPE_noarch_OBJS=
HIPE_ARCH_OBJS=$(HIPE_$(ARCH)_OBJS)

ifeq ($(BUILD_SLAVE_EMU), yes)
ifdef BUILD_SLAVE
HIPE_SLAVE_epiphany_OBJS=$(OBJDIR)/hipe_epiphany_slave.o
HIPE_SLAVE_ARCH_OBJS=$(HIPE_SLAVE_$(SLAVE_ARCH)_OBJS)
HIPE_OBJS += $(HIPE_SLAVE_ARCH_OBJS)
HIPE_ARCH_OBJS += $(HIPE_SLAVE_ARCH_OBJS)
endif

HIPE_OBJS= \
Expand All @@ -975,7 +975,7 @@ ifdef HIPE_ENABLED
EXTRA_BASE_OBJS += $(HIPE_OBJS)
endif

ifeq ($(BUILD_SLAVE_EMU), yes)
ifdef BUILD_SLAVE
SLAVE_OBJS = \
$(OBJDIR)/slave_alloc.o \
$(OBJDIR)/slave_bif.o \
Expand Down Expand Up @@ -1099,7 +1099,7 @@ $(OBJDIR)/hipe_epiphany_bifs.o: $(TTF_DIR)/hipe_epiphany_bifs.S \
# end of HiPE section
########################################

ifeq ($(BUILD_SLAVE_EMU), yes)
ifdef BUILD_SLAVE

$(SLAVE_EXECUTABLE): FORCE
$(V_at)( cd slave && $(MAKE) FLAVOR=$(FLAVOR) )
Expand Down
24 changes: 9 additions & 15 deletions erts/emulator/beam/binary.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ erts_realloc_binary(Eterm bin, size_t size)
}
return bin;
}
#endif
#endif /* !ERTS_SLAVE */

byte*
erts_get_aligned_binary_bytes_extra(Eterm bin, byte** base_ptr, ErtsAlcType_t allocator, unsigned extra)
Expand Down Expand Up @@ -475,8 +475,6 @@ static BIF_RETTYPE binary_to_list_continue(BIF_ALIST_1)
1);
}

HIPE_WRAPPER_BIF_DISABLE_GC(binary_to_list, 1)

BIF_RETTYPE binary_to_list_1(BIF_ALIST_1)
{
Eterm real_bin;
Expand Down Expand Up @@ -505,8 +503,6 @@ BIF_RETTYPE binary_to_list_1(BIF_ALIST_1)
BIF_ERROR(BIF_P, BADARG);
}

HIPE_WRAPPER_BIF_DISABLE_GC(binary_to_list, 3)

BIF_RETTYPE binary_to_list_3(BIF_ALIST_3)
{
byte* bytes;
Expand Down Expand Up @@ -537,8 +533,6 @@ BIF_RETTYPE binary_to_list_3(BIF_ALIST_3)
BIF_ERROR(BIF_P, BADARG);
}

HIPE_WRAPPER_BIF_DISABLE_GC(bitstring_to_list, 1)

BIF_RETTYPE bitstring_to_list_1(BIF_ALIST_1)
{
Eterm real_bin;
Expand Down Expand Up @@ -903,15 +897,11 @@ BIF_RETTYPE erts_list_to_binary_bif(Process *c_p, Eterm arg, Export *bif)
return ret;
}

HIPE_WRAPPER_BIF_DISABLE_GC(list_to_binary, 1)

BIF_RETTYPE list_to_binary_1(BIF_ALIST_1)
{
return erts_list_to_binary_bif(BIF_P, BIF_ARG_1, bif_export[BIF_list_to_binary_1]);
}

HIPE_WRAPPER_BIF_DISABLE_GC(iolist_to_binary, 1)

BIF_RETTYPE iolist_to_binary_1(BIF_ALIST_1)
{
if (is_binary(BIF_ARG_1)) {
Expand All @@ -924,8 +914,6 @@ static int bitstr_list_len(ErtsIOListState *);
static ErlDrvSizeT list_to_bitstr_buf_yielding(ErtsIOList2BufState *);
static ErlDrvSizeT list_to_bitstr_buf_not_yielding(ErtsIOList2BufState *);

HIPE_WRAPPER_BIF_DISABLE_GC(list_to_bitstring, 1)

BIF_RETTYPE list_to_bitstring_1(BIF_ALIST_1)
{
BIF_RETTYPE ret;
Expand Down Expand Up @@ -1013,7 +1001,13 @@ BIF_RETTYPE list_to_bitstring_1(BIF_ALIST_1)

return ret;
}
#endif
#endif /* !ERTS_SLAVE */
HIPE_WRAPPER_BIF_DISABLE_GC(binary_to_list, 1)
HIPE_WRAPPER_BIF_DISABLE_GC(binary_to_list, 3)
HIPE_WRAPPER_BIF_DISABLE_GC(bitstring_to_list, 1)
HIPE_WRAPPER_BIF_DISABLE_GC(list_to_binary, 1)
HIPE_WRAPPER_BIF_DISABLE_GC(iolist_to_binary, 1)
HIPE_WRAPPER_BIF_DISABLE_GC(list_to_bitstring, 1)

BIF_RETTYPE split_binary_2(BIF_ALIST_2)
{
Expand Down Expand Up @@ -1542,4 +1536,4 @@ bitstr_list_len(ErtsIOListState *state)
ESTACK_SAVE(s, &state->estack);
return ERTS_IOLIST_YIELD;
}
#endif
#endif /* !ERTS_SLAVE */
4 changes: 4 additions & 0 deletions erts/emulator/beam/erl_alloc.types
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,10 @@ type SL_MPATHS SHORT_LIVED SYSTEM sl_migration_paths
# Currently most hipe code use this type.
type HIPE SYSTEM SYSTEM hipe_data

+if slave
type HIPE_SLAVE SLAVE SYSTEM hipe_slave_data
+endif

+endif

+if heap_frag_elim_test
Expand Down
37 changes: 0 additions & 37 deletions erts/emulator/hipe/hipe_bif0.c
Original file line number Diff line number Diff line change
Expand Up @@ -991,43 +991,6 @@ BIF_RETTYPE hipe_bifs_term_to_word_1(BIF_ALIST_1)
BIF_RET(Uint_to_term(BIF_ARG_1, BIF_P));
}

/* XXX: this is really a primop, not a BIF */
BIF_RETTYPE hipe_conv_big_to_float(BIF_ALIST_1)
{
Eterm res;
Eterm *hp;
FloatDef f;

if (is_not_big(BIF_ARG_1))
BIF_ERROR(BIF_P, BADARG);
if (big_to_double(BIF_ARG_1, &f.fd) < 0)
BIF_ERROR(BIF_P, BADARG);
hp = HAlloc(BIF_P, FLOAT_SIZE_OBJECT);
res = make_float(hp);
PUT_DOUBLE(f, hp);
BIF_RET(res);
}

#ifdef NO_FPE_SIGNALS

/*
This is the current solution to make hipe run without FPE.
The native code is the same except that a call to this primop
is made after _every_ float operation to check the result.
The native fcheckerror still done later will detect if an
"emulated" FPE has occured.
We use p->hipe.float_result to avoid passing a 'double' argument,
which has its own calling convention (on amd64 at least).
Simple and slow...
*/
void hipe_emulate_fpe(Process* p)
{
if (!isfinite(p->hipe.float_result)) {
p->fp_exception = 1;
}
}
#endif

#if 0 /* XXX: unused */
/*
* At least parts of this should be inlined in native code.
Expand Down
Loading

0 comments on commit bc53f46

Please sign in to comment.