Пример #1
0
Файл: eh.c Проект: MatzeB/liboo
ir_node *eh_new_Call(ir_node * irn_ptr, int arity, ir_node *const * in, ir_type* type)
{
	ir_node *jmp          = new_Jmp();
	ir_node *call_block   = new_immBlock();
	add_immBlock_pred(call_block, jmp);
	mature_immBlock(call_block);
	set_cur_block(call_block);

	ir_node *cur_mem      = get_store();
	ir_node *call         = new_Call(cur_mem, irn_ptr, arity, in, type);
	ir_set_throws_exception(call, 1);
	ir_node *proj_except  = new_Proj(call, mode_X, pn_Call_X_except);
	cur_mem               = new_Proj(call, mode_M, pn_Call_M);
	set_store(cur_mem);

	add_immBlock_pred(top->handler_header_block, proj_except);

	ir_node *proj_regular = new_Proj(call, mode_X, pn_Call_X_regular);
	ir_node *new_block    = new_immBlock();
	add_immBlock_pred(new_block, proj_regular);
	mature_immBlock(new_block);
	set_cur_block(new_block);

	top->used = true;

	return call;
}
Пример #2
0
Файл: eh.c Проект: MatzeB/liboo
void eh_add_handler(ir_type *catch_type, ir_node *catch_block)
{
	assert (top->prev); //e.g., not the default handler
	assert (top->cur_block && "Cannot add handler after an catch all was registered");

	ir_node *saved_block = get_cur_block();
	set_cur_block(top->cur_block);

	if (catch_type) {
		ir_node *cur_mem     = get_store();
		ir_node *instanceof  = new_InstanceOf(cur_mem, top->exception_object, catch_type);
		cur_mem              = new_Proj(instanceof, mode_M, pn_InstanceOf_M);
		ir_node *result      = new_Proj(instanceof, mode_b, pn_InstanceOf_res);
		ir_node *cond        = new_Cond(result);

		ir_node *proj_match  = new_Proj(cond, mode_X, pn_Cond_true);
		add_immBlock_pred(catch_block, proj_match);
		// will be matured elsewhere

		ir_node *proj_go_on  = new_Proj(cond, mode_X, pn_Cond_false);
		ir_node *new_block   = new_immBlock();
		add_immBlock_pred(new_block, proj_go_on);
		mature_immBlock(new_block);
		top->cur_block = new_block;
		set_store(cur_mem);
	} else {
		ir_node *jmp = new_Jmp();
		add_immBlock_pred(catch_block, jmp);
		top->cur_block = NULL;
	}

	set_cur_block(saved_block);
}
Пример #3
0
/* Parse command line and set global options. */
static void parse_command_line(int argc, char **argv) {
        static struct option opts [] = {
		{"store", required_argument, NULL, 's'},
                {"base", required_argument, NULL, 'b'},
                {"help", 0, NULL, 'h'},
                {"install", required_argument, NULL, 'i'},
                {"list-modules", 0, NULL, 'l'},
                {"verbose", 0, NULL, 'v'},
                {"remove", required_argument, NULL, 'r'},
                {"upgrade", required_argument, NULL, 'u'},
		{"reload", 0, NULL, 'R'},
		{"noreload", 0, NULL, 'n'},
                {"build", 0, NULL, 'B'},
                {NULL, 0, NULL, 0}
        };
        int i;
        verbose = 0;
	reload = 0;
	no_reload = 0;
	create_store = 0;
        while ((i = getopt_long(argc, argv, "s:b:hi:lvqr:u:RnB", opts, NULL)) != -1) {
                switch (i) {
                case 'b': set_mode(BASE_M, optarg); create_store = 1; break;
                case 'h': usage(argv[0]); exit(0);
                case 'i': set_mode(INSTALL_M, optarg); break;
                case 'l': set_mode(LIST_M, NULL); break;
                case 'v': verbose = 1; break;
                case 'r': set_mode(REMOVE_M, optarg); break;
                case 'u': set_mode(UPGRADE_M,optarg); break;
		case 's': set_store(optarg); break;
		case 'R': reload = 1; break;
		case 'n': no_reload = 1; break;
		case 'B': build = 1; break;
                case '?':
                default: {
                        usage(argv[0]);
                        exit(1);
                }
            }
        }
	if (optind < argc) {
		fprintf (stderr, "Extraneous arguments:  ");
		while (optind < argc)
			fprintf (stderr, "%s", argv[optind++]);
		fprintf(stderr, "\n");
		usage (argv [0]);
                cleanup();
		exit (1);
	}
	if ((build || reload) && num_commands) {
		fprintf(stderr, "build or reload should not be used with other commands\n");
		usage(argv[0]);
		exit(1);
	}
        if (num_commands == 0 && reload == 0 && build == 0) {
                fprintf(stderr, "At least one mode must be specified.\n");
                usage(argv[0]);
                exit(1);
        }
}
Пример #4
0
Файл: eh.c Проект: MatzeB/liboo
void eh_end_method(void)
{
	assert (! top->prev); // the explicit stuff is gone, we have the default handler

	if (top->used) {
		mature_immBlock(top->handler_header_block);

		assert (top->cur_block); // would fail if front end adds an catch all handler to the default handler

		ir_node *saved_block = get_cur_block();
		set_cur_block(top->cur_block);
		ir_node *cur_mem     = get_store();
		ir_node *raise       = new_Raise(cur_mem, top->exception_object);
		ir_node *proj        = new_Proj(raise, mode_X, pn_Raise_X);
		cur_mem              = new_Proj(raise, mode_M, pn_Raise_M);
		set_store(cur_mem);

		ir_node *end_block   = get_irg_end_block(get_current_ir_graph());
		add_immBlock_pred(end_block, proj);

		set_cur_block(saved_block);
	}

	obstack_free(&lpads, top);
	top = NULL;
}
Пример #5
0
ir_node *gcji_allocate_array(ir_type *eltype, ir_node *count)
{
	ir_node *jclass = gcji_get_runtime_classinfo(eltype);
	ir_node *res;
	ir_node *new_mem;
	if (is_Primitive_type(eltype)) {
		ir_node *addr      = new_Address(gcj_new_prim_array_entity);
		ir_node *args[]    = { jclass, count };
		ir_type *call_type = get_entity_type(gcj_new_prim_array_entity);
		ir_node *mem       = get_store();
		ir_node *call      = new_Call(mem, addr, ARRAY_SIZE(args), args,
		                              call_type);
		ir_node *ress      = new_Proj(call, mode_T, pn_Call_T_result);
		new_mem = new_Proj(call, mode_M, pn_Call_M);
		res     = new_r_Proj(ress, mode_reference, 0);
	} else {
		ir_node *addr      = new_Address(gcj_new_object_array_entity);
		ir_node *null      = new_Const(get_mode_null(mode_reference));
		ir_node *args[]    = { count, jclass, null };
		ir_type *call_type = get_entity_type(gcj_new_object_array_entity);
		ir_node *mem       = get_store();
		ir_node *call      = new_Call(mem, addr, ARRAY_SIZE(args), args,
		                              call_type);
		ir_node *ress      = new_Proj(call, mode_T, pn_Call_T_result);
		new_mem = new_Proj(call, mode_M, pn_Call_M);
		res     = new_Proj(ress, mode_reference, 0);
	}

	ir_node *assure_vptr = new_VptrIsSet(new_mem, res, type_jarray);
	ir_node *new_mem2    = new_Proj(assure_vptr, mode_M, pn_VptrIsSet_M);
	ir_node *res2        = new_Proj(assure_vptr, mode_reference,
	                                pn_VptrIsSet_res);
	set_store(new_mem2);
	return res2;
}
Пример #6
0
/* 0 files to go -> "0s " */
TEST word_adds_find_dupes() {
    set *s = set_new(2, dumb_hash, cmp);
    int duplicates[word_count];
    bzero(duplicates, word_count * sizeof(int));

    for (int i=0; i<word_count; i++) {
        char *w = words[i];
        ASSERT(w);
        if (set_known(s, w)) {
            duplicates[i] = 1;
        } else {
            if (set_store(s, (void *) w) == TABLE_SET_FAIL) FAIL();
        }
    }

    for (int i=0; i<word_count; i++) {
        if (0) printf("%d - %s %d\n", i, words[i], duplicates[i]);
    }

    for (int i=0; i<18; i++) {
        ASSERT_EQm("none of the first 18 are duplicates", 0, duplicates[i]);
    }

    ASSERT_EQm("words[19] (\"onion\") is a dup", 1, duplicates[19]);
    ASSERT_EQm("the last word (\"fennel\") is a dup", 1, duplicates[word_count - 1]);

    set_free(s, NULL);
    PASS();
}
Пример #7
0
ir_node *gcji_get_runtime_classinfo(ir_type *type)
{
	ir_node *block = get_cur_block();
	ir_node *mem   = get_store();
	ir_node *res   = gcji_get_runtime_classinfo_(block, &mem, type);
	set_store(mem);
	return res;
}
Пример #8
0
Файл: eh.c Проект: MatzeB/liboo
static void store_exception_object(ir_node *exo_ptr)
{
	ir_node *cur_mem  = get_store();

	ir_node *ex_symc  = new_Address(exception_object_entity);
	ir_node *ex_store = new_Store(cur_mem, ex_symc, exo_ptr, cons_none);
	cur_mem           = new_Proj(ex_store, mode_M, pn_Store_M);

	set_store(cur_mem);
}
Пример #9
0
void gcji_checkcast(ir_type *classtype, ir_node *objptr)
{
	ir_node *jclass    = gcji_get_runtime_classinfo(classtype);
	ir_node *addr      = new_Address(gcj_checkcast_entity);
	ir_type *call_type = get_entity_type(gcj_checkcast_entity);
	ir_node *args[]    = { jclass, objptr };
	ir_node *mem       = get_store();
	ir_node *call      = new_Call(mem, addr, ARRAY_SIZE(args), args, call_type);
	ir_node *new_mem   = new_Proj(call, mode_M, pn_Call_M);
	set_store(new_mem);
}
Пример #10
0
Файл: eh.c Проект: MatzeB/liboo
ir_node *eh_get_exception_object(void)
{
	ir_node *cur_mem = get_store();

	ir_node *ex_symc = new_Address(exception_object_entity);
	ir_node *ex_load = new_Load(cur_mem, ex_symc, mode_P, cons_none);
	cur_mem          = new_Proj(ex_load, mode_M, pn_Load_M);
	ir_node *ex_obj  = new_Proj(ex_load, mode_P, pn_Load_res);

	set_store(cur_mem);
	return ex_obj;
}
Пример #11
0
void gcji_class_init(ir_type *type)
{
	assert(is_Class_type(type));

	ir_node *addr      = new_Address(gcj_init_entity);
	ir_node *jclass    = gcji_get_runtime_classinfo(type);
	ir_node *args[]    = { jclass };
	ir_type *call_type = get_entity_type(gcj_init_entity);
	ir_node *mem       = get_store();
	ir_node *call      = new_Call(mem, addr, ARRAY_SIZE(args), args, call_type);
	ir_node *new_mem   = new_Proj(call, mode_M, pn_Call_M);
	set_store(new_mem);
}
Пример #12
0
TEST print_words_if_verbose() {
    set *s = set_new(2, dumb_hash, cmp);
    int duplicates[word_count];
    bzero(duplicates, word_count * sizeof(int));

    for (int i=0; i<word_count; i++) {
        char *w = words[i];
        if (set_store(s, (void *) w) == TABLE_SET_FAIL) FAIL();
    }

    set_apply(s, print_cb, NULL);

    set_free(s, NULL);
    PASS();
}
Пример #13
0
ir_node *gcji_new_multiarray(ir_node *array_class_ref, unsigned dims,
                             ir_node **sizes)
{
	ir_node *addr      = new_Address(gcj_new_multiarray_entity);
	ir_node *dims_arr  = alloc_dims_array(dims, sizes);
	ir_node *cnst      = new_Const_long(mode_int, dims);
	ir_node *args[]    = { array_class_ref, cnst, dims_arr };
	ir_type *call_type = get_entity_type(gcj_new_multiarray_entity);
	ir_node *mem       = get_store();
	ir_node *call      = new_Call(mem, addr, ARRAY_SIZE(args), args, call_type);
	ir_node *new_mem   = new_Proj(call, mode_M, pn_Call_M);
	ir_node *ress      = new_Proj(call, mode_T, pn_Call_T_result);
	ir_node *res       = new_Proj(ress, mode_reference, 0);
	set_store(new_mem);
	return res;
}
Пример #14
0
ir_node *gcji_new_string(ir_entity *bytes)
{
	ir_node *addr        = new_Address(gcj_new_string_entity);
	ir_node *string_symc = new_Address(bytes);
	ir_node *args[]      = { string_symc };
	ir_node *mem         = get_store();
	ir_type *call_type   = get_entity_type(gcj_new_string_entity);
	ir_node *call        = new_Call(mem, addr, ARRAY_SIZE(args), args,
	                                call_type);
	ir_node *new_mem     = new_Proj(call, mode_M, pn_Call_M);
	ir_node *ress        = new_Proj(call, mode_T, pn_Call_T_result);
	ir_node *res         = new_Proj(ress, mode_reference, 0);
	set_store(new_mem);

	// TODO: get type for java.lang.String from somewhere and use VptrIsSet
	// on the result
	return res;
}
Пример #15
0
static ir_node *alloc_dims_array(unsigned dims, ir_node **sizes)
{
	ir_mode *dim_mode   = mode_ushort;
	unsigned bytes      = dims * (get_mode_size_bits(dim_mode) / 8);
	ir_node *dims_const = new_Const_long(dim_mode, bytes);
	ir_node *mem        = get_store();
	ir_node *alloc      = new_Alloc(mem, dims_const, 1);
	ir_node *arr        = new_Proj(alloc, mode_reference, pn_Alloc_res);
	ir_node *new_mem    = new_Proj(alloc, mode_M, pn_Alloc_M);

	for (unsigned d = 0; d < dims; d++) {
		ir_node *index_const = new_Const_long(mode_int, d);
		ir_node *sel         = new_Sel(arr, index_const, type_array_int);
		ir_node *store       = new_Store(new_mem, sel, sizes[d], type_array_int, cons_none);
		new_mem = new_Proj(store, mode_M, pn_Store_M);
	}

	set_store(new_mem);
	return arr;
}
Пример #16
0
ir_node *gcji_allocate_object(ir_type *type)
{
	assert(is_Class_type(type));

	ir_node *addr      = new_Address(gcj_alloc_entity);
	ir_node *jclass    = gcji_get_runtime_classinfo(type);
	ir_node *args[]    = { jclass };
	ir_type *call_type = get_entity_type(gcj_alloc_entity);
	ir_node *mem       = get_store();
	ir_node *call      = new_Call(mem, addr, ARRAY_SIZE(args), args, call_type);
    ir_node *new_mem   = new_Proj(call, mode_M, pn_Call_M);
	ir_node *ress      = new_Proj(call, mode_T, pn_Call_T_result);
	ir_node *res       = new_Proj(ress, mode_reference, 0);

	ir_node *assure_vptr = new_VptrIsSet(new_mem, res, type);
	ir_node *new_mem2    = new_Proj(assure_vptr, mode_M, pn_VptrIsSet_M);
	ir_node *res2        = new_Proj(assure_vptr, mode_reference,
	                                pn_VptrIsSet_res);
	set_store(new_mem2);
	return res2;
}
Пример #17
0
ProcData::ProcData(int flags, Datastore *store, double min, double max, double depth, Interpolation interp, float scale, int skip, int custom_epi_height)
: _flags(flags), _min(min), _max(max), _depth(depth), _interpolation(interp), _scale(scale), _skip(skip), _custom_epi_height(custom_epi_height)
{  
  if (store)
    set_store(store);
}
Пример #18
0
/* Parse command line and set global options. */
static void parse_command_line(int argc, char **argv)
{
	static struct option opts[] = {
		{"store", required_argument, NULL, 's'},
		{"base", required_argument, NULL, 'b'},
		{"help", 0, NULL, 'h'},
		{"install", required_argument, NULL, 'i'},
		{"list-modules", 0, NULL, 'l'},
		{"verbose", 0, NULL, 'v'},
		{"enable", required_argument, NULL, 'e'},
		{"disable", required_argument, NULL, 'd'},
		{"remove", required_argument, NULL, 'r'},
		{"upgrade", required_argument, NULL, 'u'},
		{"reload", 0, NULL, 'R'},
		{"noreload", 0, NULL, 'n'},
		{"build", 0, NULL, 'B'},
		{"disable_dontaudit", 0, NULL, 'D'},
		{"preserve_tunables", 0, NULL, 'P'},
		{"path", required_argument, NULL, 'p'},
		{NULL, 0, NULL, 0}
	};
	int i;
	verbose = 0;
	reload = 0;
	no_reload = 0;
	create_store = 0;
	while ((i =
		getopt_long(argc, argv, "p:s:b:hi:lvqe:d:r:u:RnNBDP", opts,
			    NULL)) != -1) {
		switch (i) {
		case 'b':
			set_mode(BASE_M, optarg);
			create_store = 1;
			break;
		case 'h':
			usage(argv[0]);
			exit(0);
		case 'i':
			set_mode(INSTALL_M, optarg);
			break;
		case 'l':
			set_mode(LIST_M, NULL);
			break;
		case 'v':
			verbose = 1;
			break;
		case 'e':
			set_mode(ENABLE_M, optarg);
			break;
		case 'd':
			set_mode(DISABLE_M, optarg);
			break;
		case 'r':
			set_mode(REMOVE_M, optarg);
			break;
		case 'p':
			semanage_set_root(optarg);
			break;
		case 'u':
			set_mode(UPGRADE_M, optarg);
			break;
		case 's':
			set_store(optarg);
			break;
		case 'R':
			reload = 1;
			break;
		case 'n':
			no_reload = 1;
			break;
		case 'N':
			no_reload = 1;
			break;
		case 'B':
			build = 1;
			break;
		case 'D':
			disable_dontaudit = 1;
			break;
		case 'P':
			preserve_tunables = 1;
			break;
		case '?':
		default:{
				usage(argv[0]);
				exit(1);
			}
		}
	}
	if ((build || reload) && num_commands) {
		fprintf(stderr,
			"build or reload should not be used with other commands\n");
		usage(argv[0]);
		exit(1);
	}
	if (num_commands == 0 && reload == 0 && build == 0) {
		fprintf(stderr, "At least one mode must be specified.\n");
		usage(argv[0]);
		exit(1);
	}

	if (optind < argc) {
		int mode;
		/* if -i/u/r was the last command treat any remaining
		 * arguments as args. Will allow 'semodule -i *.pp' to
		 * work as expected.
		 */

		if (commands && commands[num_commands - 1].mode == INSTALL_M) {
			mode = INSTALL_M;
		} else if (commands && commands[num_commands - 1].mode == UPGRADE_M) {
			mode = UPGRADE_M;
		} else if (commands && commands[num_commands - 1].mode == REMOVE_M) {
			mode = REMOVE_M;
		} else if (commands && commands[num_commands - 1].mode == ENABLE_M) {
			mode = ENABLE_M;
		} else if (commands && commands[num_commands - 1].mode == DISABLE_M) {
			mode = DISABLE_M;
		} else {
			fprintf(stderr, "unknown additional arguments:\n");
			while (optind < argc)
				fprintf(stderr, " %s", argv[optind++]);
			fprintf(stderr, "\n\n");
			usage(argv[0]);
			exit(1);
		}
		while (optind < argc)
			set_mode(mode, argv[optind++]);
	}
}