Commit 3cc2dd4b by Nicola Pero Committed by Nicola Pero

In gcc/: 2011-10-14 Nicola Pero <nicola.pero@meta-innovation.com>

In gcc/:
2011-10-14  Nicola Pero  <nicola.pero@meta-innovation.com>

	* gengtype.c (files_rules): Added rules for objc/objc-map.h and
	objc/objc-map.c.

In gcc/objc/:
2011-10-14  Nicola Pero  <nicola.pero@meta-innovation.com>

	* objc-map.h: New file.
	* objc-map.c: New file.	
	* config-lang.in (gtfiles): Added objc-map.h.
	* Make-lang.in (OBJC_OBJS): Added objc-map.o.
	(objc/objc-map.o): New rule.
	(objc/objc-act.o): Depend on objc/objc-map.h.
	* objc-next-runtime-abi-02.c: Added a TODO comment.
	* objc-act.c: Include objc-map.h.
	(nst_method_hash_list, cls_method_hash_list): Removed.
	(instance_method_map, class_method_map): New.
	(cls_name_hash_list, als_name_hash_list): Removed.
	(class_name_map, alias_name_map): Removed.
	(ivar_offset_hash_list): Removed.
	(hash_class_name_enter, hash_class_name_lookup, hash_enter,
	hash_lookup, hash_add_attr, add_method_to_hash_list): Removed.
	(interface_hash_init): New.
	(objc_init): Call interface_hash_init.
	(objc_write_global_declarations): Iterate over class_method_map
	and instance_method_map instead of cls_method_hash_list and
	nst_method_hash_list.
	(objc_declare_alias): Use alias_name_map instead of
	cls_name_hash_list.
	(objc_is_class_name): Use class_name_map and alias_name_map
	instead of cls_name_hash_list and als_name_hash_list.
	(interface_tuple, interface_htab, hash_interface, eq_interface):
	Removed.
	(interface_map): New.
	(add_class): Renamed to add_interface.  Use interface_map instead
	of interface_htab.
	(lookup_interface): Use interface_map instead of interface_htab.
	(check_duplicates): Changed first argument to be a tree,
	potentially a TREE_VEC, instead of a hash.  Changed implementation
	to match.
	(lookup_method_in_hash_lists): Use class_method_map and
	instance_method_map instead of cls_method_hash_list and
	nst_method_hash_list.
	(objc_build_selector_expr): Likewise.
	(hash_func): Removed.
	(hash_init): Create instance_method_map, class_method_map,
	class_name_map, and alias_name_map.  Do not create
	nst_method_hash_list, cls_method_hash_list, cls_name_hash_list,
	als_name_hash_list, and ivar_offset_hash_list.
	(insert_method_into_method_map): New.
	(objc_add_method): Use insert_method_into_method_map instead of
	add_method_to_hash_list.
	(start_class): Call add_interface instead of add_class.
	* objc-act.h (cls_name_hash_list, als_name_hash_list,
	nst_method_hash_list, cls_method_hash_list): Removed.

In gcc/objcp/:
2011-10-14  Nicola Pero  <nicola.pero@meta-innovation.com>

	* Make-lang.in (OBJCXX_OBJS): Added objc-map.o.
	(objcp/objc-map.o): New rule.
	(objcp/objcp-act.o): Depend on objc/objc-map.h.
	* config-lang.in (gtfiles): Added objc-map.h.

From-SVN: r179965
parent 5e678de8
2011-10-14 Nicola Pero <nicola.pero@meta-innovation.com>
* gengtype.c (files_rules): Added rules for objc/objc-map.h and
objc/objc-map.c.
2011-10-14 Paolo Carlini <paolo.carlini@oracle.com> 2011-10-14 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/17212 PR c++/17212
...@@ -1817,6 +1817,11 @@ struct file_rule_st files_rules[] = { ...@@ -1817,6 +1817,11 @@ struct file_rule_st files_rules[] = {
REG_EXTENDED, NULL_REGEX, REG_EXTENDED, NULL_REGEX,
"gt-objc-objc-act.h", "objc/objc-act.c", NULL_FRULACT }, "gt-objc-objc-act.h", "objc/objc-act.c", NULL_FRULACT },
/* objc/objc-map.h gives gt-objc-objc-map.h for objc/objc-map.c ! */
{ DIR_PREFIX_REGEX "objc/objc-map\\.h$",
REG_EXTENDED, NULL_REGEX,
"gt-objc-objc-map.h", "objc/objc-map.c", NULL_FRULACT },
/* General cases. For header *.h and source *.c files, we need /* General cases. For header *.h and source *.c files, we need
* special actions to handle the language. */ * special actions to handle the language. */
......
2011-10-14 Nicola Pero <nicola.pero@meta-innovation.com>
* objc-map.h: New file.
* objc-map.c: New file.
* config-lang.in (gtfiles): Added objc-map.h.
* Make-lang.in (OBJC_OBJS): Added objc-map.o.
(objc/objc-map.o): New rule.
(objc/objc-act.o): Depend on objc/objc-map.h.
* objc-next-runtime-abi-02.c: Added a TODO comment.
* objc-act.c: Include objc-map.h.
(nst_method_hash_list, cls_method_hash_list): Removed.
(instance_method_map, class_method_map): New.
(cls_name_hash_list, als_name_hash_list): Removed.
(class_name_map, alias_name_map): Removed.
(ivar_offset_hash_list): Removed.
(hash_class_name_enter, hash_class_name_lookup, hash_enter,
hash_lookup, hash_add_attr, add_method_to_hash_list): Removed.
(interface_hash_init): New.
(objc_init): Call interface_hash_init.
(objc_write_global_declarations): Iterate over class_method_map
and instance_method_map instead of cls_method_hash_list and
nst_method_hash_list.
(objc_declare_alias): Use alias_name_map instead of
cls_name_hash_list.
(objc_is_class_name): Use class_name_map and alias_name_map
instead of cls_name_hash_list and als_name_hash_list.
(interface_tuple, interface_htab, hash_interface, eq_interface):
Removed.
(interface_map): New.
(add_class): Renamed to add_interface. Use interface_map instead
of interface_htab.
(lookup_interface): Use interface_map instead of interface_htab.
(check_duplicates): Changed first argument to be a tree,
potentially a TREE_VEC, instead of a hash. Changed implementation
to match.
(lookup_method_in_hash_lists): Use class_method_map and
instance_method_map instead of cls_method_hash_list and
nst_method_hash_list.
(objc_build_selector_expr): Likewise.
(hash_func): Removed.
(hash_init): Create instance_method_map, class_method_map,
class_name_map, and alias_name_map. Do not create
nst_method_hash_list, cls_method_hash_list, cls_name_hash_list,
als_name_hash_list, and ivar_offset_hash_list.
(insert_method_into_method_map): New.
(objc_add_method): Use insert_method_into_method_map instead of
add_method_to_hash_list.
(start_class): Call add_interface instead of add_class.
* objc-act.h (cls_name_hash_list, als_name_hash_list,
nst_method_hash_list, cls_method_hash_list): Removed.
2011-10-11 Michael Meissner <meissner@linux.vnet.ibm.com> 2011-10-11 Michael Meissner <meissner@linux.vnet.ibm.com>
* objc-next-runtime-abi-01.c (objc_build_exc_ptr): Delete old * objc-next-runtime-abi-01.c (objc_build_exc_ptr): Delete old
......
...@@ -55,7 +55,8 @@ OBJC_OBJS = objc/objc-lang.o objc/objc-act.o \ ...@@ -55,7 +55,8 @@ OBJC_OBJS = objc/objc-lang.o objc/objc-act.o \
objc/objc-gnu-runtime-abi-01.o \ objc/objc-gnu-runtime-abi-01.o \
objc/objc-next-runtime-abi-01.o \ objc/objc-next-runtime-abi-01.o \
objc/objc-next-runtime-abi-02.o \ objc/objc-next-runtime-abi-02.o \
objc/objc-encoding.o objc/objc-encoding.o \
objc/objc-map.o
objc_OBJS = $(OBJC_OBJS) cc1obj-checksum.o objc_OBJS = $(OBJC_OBJS) cc1obj-checksum.o
...@@ -129,6 +130,7 @@ objc/objc-act.o : objc/objc-act.c \ ...@@ -129,6 +130,7 @@ objc/objc-act.o : objc/objc-act.c \
$(HASHTAB_H) $(GIMPLE_H) \ $(HASHTAB_H) $(GIMPLE_H) \
$(C_PRAGMA_H) $(C_TARGET_H) \ $(C_PRAGMA_H) $(C_TARGET_H) \
objc/objc-encoding.h \ objc/objc-encoding.h \
objc/objc-map.h \
objc/objc-runtime-hooks.h \ objc/objc-runtime-hooks.h \
objc/objc-runtime-shared-support.h objc/objc-runtime-shared-support.h
...@@ -139,6 +141,12 @@ objc/objc-encoding.o : objc/objc-encoding.c \ ...@@ -139,6 +141,12 @@ objc/objc-encoding.o : objc/objc-encoding.c \
objc/objc-encoding.h \ objc/objc-encoding.h \
objc/objc-runtime-shared-support.h objc/objc-runtime-shared-support.h
objc/objc-map.o : objc/objc-map.c \
$(START_HDRS) \
$(GGC_H) $(DIAGNOSTIC_CORE_H) $(FLAGS_H) input.h \
$(OBSTACK_H) \
objc/objc-map.h
objc.srcextra: objc.srcextra:
# #
......
...@@ -36,4 +36,4 @@ lang_requires="c" ...@@ -36,4 +36,4 @@ lang_requires="c"
# Order is important. If you change this list, make sure you test # Order is important. If you change this list, make sure you test
# building without C++ as well; that is, remove the gcc/cp directory, # building without C++ as well; that is, remove the gcc/cp directory,
# and build with --enable-languages=c,objc. # and build with --enable-languages=c,objc.
gtfiles="\$(srcdir)/c-family/c-objc.h \$(srcdir)/objc/objc-act.h \$(srcdir)/objc/objc-act.c \$(srcdir)/objc/objc-runtime-shared-support.c \$(srcdir)/objc/objc-gnu-runtime-abi-01.c \$(srcdir)/objc/objc-next-runtime-abi-01.c \$(srcdir)/objc/objc-next-runtime-abi-02.c \$(srcdir)/c-parser.c \$(srcdir)/c-tree.h \$(srcdir)/c-decl.c \$(srcdir)/c-lang.h \$(srcdir)/c-objc-common.c \$(srcdir)/c-family/c-common.c \$(srcdir)/c-family/c-common.h \$(srcdir)/c-family/c-cppbuiltin.c \$(srcdir)/c-family/c-pragma.h \$(srcdir)/c-family/c-pragma.c" gtfiles="\$(srcdir)/objc/objc-map.h \$(srcdir)/c-family/c-objc.h \$(srcdir)/objc/objc-act.h \$(srcdir)/objc/objc-act.c \$(srcdir)/objc/objc-runtime-shared-support.c \$(srcdir)/objc/objc-gnu-runtime-abi-01.c \$(srcdir)/objc/objc-next-runtime-abi-01.c \$(srcdir)/objc/objc-next-runtime-abi-02.c \$(srcdir)/c-parser.c \$(srcdir)/c-tree.h \$(srcdir)/c-decl.c \$(srcdir)/c-lang.h \$(srcdir)/c-objc-common.c \$(srcdir)/c-family/c-common.c \$(srcdir)/c-family/c-common.h \$(srcdir)/c-family/c-cppbuiltin.c \$(srcdir)/c-family/c-pragma.h \$(srcdir)/c-family/c-pragma.c"
...@@ -252,12 +252,6 @@ struct GTY(()) hashed_entry { ...@@ -252,12 +252,6 @@ struct GTY(()) hashed_entry {
#define SIZEHASHTABLE 257 #define SIZEHASHTABLE 257
extern GTY ((length ("SIZEHASHTABLE"))) hash *nst_method_hash_list;
extern GTY ((length ("SIZEHASHTABLE"))) hash *cls_method_hash_list;
extern GTY ((length ("SIZEHASHTABLE"))) hash *cls_name_hash_list;
extern GTY ((length ("SIZEHASHTABLE"))) hash *als_name_hash_list;
/* An array of all the local variables in the current function that /* An array of all the local variables in the current function that
need to be marked as volatile. */ need to be marked as volatile. */
extern GTY(()) VEC(tree,gc) *local_variables_to_volatilize; extern GTY(()) VEC(tree,gc) *local_variables_to_volatilize;
......
/* objc-map.c -- Implementation of map data structures for ObjC compiler
Copyright 2011 Free Software Foundation, Inc.
Written by Nicola Pero <nicola.pero@meta-innovation.com>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser Public License as published by the
Free Software Foundation; either version 3, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser Public License for more details.
You should have received a copy of the GNU Lesser Public License
along with this program; if not, write to the Free Software
Foundation, 51 Franklin Street - Fifth Floor,
Boston, MA 02110-1301, USA. */
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tree.h"
#include "ggc.h"
#include "objc-map.h"
#define OUT_OF_MEMORY { fprintf (stderr, "Out of memory\n"); abort (); }
static
size_t
ATTRIBUTE_PURE
next_power_of_two (size_t x)
{
size_t result = 1;
if (x < 2)
return 2;
/* Avoid the long calculation if x is already a power of two. Since
we internally always increase/shrink tables by powers of 2, the
calculation should only be done once, when the table is first
set up. */
if ((x & (x - 1)) == 0)
return x;
/* Calculate log_2 by counting how many times we can divide by 2
before reaching 0. */
while (x > 0)
{
x = x >> 1;
result = result << 1;
}
return result;
}
objc_map_t
objc_map_alloc_ggc (size_t initial_capacity)
{
objc_map_t map = (objc_map_t) ggc_internal_cleared_vec_alloc_stat (1, sizeof (struct objc_map_private));
if (map == NULL)
OUT_OF_MEMORY;
initial_capacity = next_power_of_two (initial_capacity);
map->number_of_slots = initial_capacity;
map->mask = initial_capacity - 1;
map->maximum_load_factor = 70;
map->max_number_of_non_empty_slots = (initial_capacity * map->maximum_load_factor) / 100;
map->slots = (tree *)ggc_internal_cleared_vec_alloc_stat (initial_capacity, sizeof (tree));
map->values = (tree *)ggc_internal_cleared_vec_alloc_stat (initial_capacity, sizeof (tree));
if (map->slots == NULL)
OUT_OF_MEMORY;
if (map->values == NULL)
OUT_OF_MEMORY;
return map;
}
void
objc_map_set_maximum_load_factor (objc_map_t map, int number_between_zero_and_one_hundred)
{
if (map->number_of_non_empty_slots != 0)
return;
map->maximum_load_factor = number_between_zero_and_one_hundred;
map->max_number_of_non_empty_slots = (map->number_of_slots * number_between_zero_and_one_hundred) / 100;
}
int
objc_map_maximum_load_factor (objc_map_t map)
{
return map->maximum_load_factor;
}
static void
objc_map_private_resize (objc_map_t map, size_t new_number_of_slots)
{
tree *old_slots = map->slots;
tree *old_values = map->values;
size_t i, old_number_of_slots = map->number_of_slots;
if (new_number_of_slots < (map->number_of_non_empty_slots))
new_number_of_slots = 2 * map->number_of_non_empty_slots;
new_number_of_slots = next_power_of_two (new_number_of_slots);
map->number_of_slots = new_number_of_slots;
map->mask = map->number_of_slots - 1;
map->max_number_of_non_empty_slots = (map->number_of_slots * map->maximum_load_factor) / 100;
map->slots = (tree *)ggc_internal_cleared_vec_alloc_stat (map->number_of_slots, sizeof (tree));
map->values = (tree *)ggc_internal_cleared_vec_alloc_stat (map->number_of_slots, sizeof (tree));
if (map->slots == NULL)
OUT_OF_MEMORY;
if (map->values == NULL)
OUT_OF_MEMORY;
for (i = 0; i < old_number_of_slots; i++)
if (old_slots[i] != OBJC_MAP_PRIVATE_EMPTY_SLOT)
{
size_t k = IDENTIFIER_HASH_VALUE (old_slots[i]) & map->mask;
if (map->slots[k] == OBJC_MAP_PRIVATE_EMPTY_SLOT)
{
map->slots[k] = old_slots[i];
map->values[k] = old_values[i];
}
else
{
size_t j = 1;
while (1)
{
k = (k + j) & map->mask;
if (map->slots[k] == OBJC_MAP_PRIVATE_EMPTY_SLOT)
{
map->slots[k] = old_slots[i];
map->values[k] = old_values[i];
break;
}
j++;
}
}
}
ggc_free (old_slots);
ggc_free (old_values);
}
void
objc_map_private_grow (struct objc_map_private *map)
{
objc_map_private_resize (map, map->number_of_slots * 2);
}
#include "gt-objc-objc-map.h"
...@@ -231,6 +231,7 @@ static tree begin_catch (struct objc_try_context **, tree, tree, tree, bool); ...@@ -231,6 +231,7 @@ static tree begin_catch (struct objc_try_context **, tree, tree, tree, bool);
static void finish_catch (struct objc_try_context **, tree); static void finish_catch (struct objc_try_context **, tree);
static tree finish_try_stmt (struct objc_try_context **); static tree finish_try_stmt (struct objc_try_context **);
/* TODO: Use an objc-map. */
static GTY ((length ("SIZEHASHTABLE"))) hash *extern_names; static GTY ((length ("SIZEHASHTABLE"))) hash *extern_names;
bool bool
......
2011-10-14 Nicola Pero <nicola.pero@meta-innovation.com>
* Make-lang.in (OBJCXX_OBJS): Added objc-map.o.
(objcp/objc-map.o): New rule.
(objcp/objcp-act.o): Depend on objc/objc-map.h.
* config-lang.in (gtfiles): Added objc-map.h.
2011-07-11 Nicola Pero <nicola.pero@meta-innovation.com> 2011-07-11 Nicola Pero <nicola.pero@meta-innovation.com>
* Make-lang.in (objcp/objc-runtime-shared-support.o): Do not * Make-lang.in (objcp/objc-runtime-shared-support.o): Do not
......
...@@ -58,6 +58,7 @@ OBJCXX_OBJS = objcp/objcp-act.o objcp/objcp-lang.o objcp/objcp-decl.o \ ...@@ -58,6 +58,7 @@ OBJCXX_OBJS = objcp/objcp-act.o objcp/objcp-lang.o objcp/objcp-decl.o \
objcp/objc-next-runtime-abi-01.o \ objcp/objc-next-runtime-abi-01.o \
objcp/objc-next-runtime-abi-02.o \ objcp/objc-next-runtime-abi-02.o \
objcp/objc-encoding.o \ objcp/objc-encoding.o \
objcp/objc-map.o \
$(CXX_AND_OBJCXX_OBJS) $(CXX_AND_OBJCXX_OBJS)
obj-c++_OBJS = $(OBJCXX_OBJS) cc1objplus-checksum.o obj-c++_OBJS = $(OBJCXX_OBJS) cc1objplus-checksum.o
...@@ -149,6 +150,7 @@ objcp/objcp-act.o : objc/objc-act.c \ ...@@ -149,6 +150,7 @@ objcp/objcp-act.o : objc/objc-act.c \
$(RTL_H) $(EXPR_H) $(TARGET_H) \ $(RTL_H) $(EXPR_H) $(TARGET_H) \
objcp/objcp-decl.h \ objcp/objcp-decl.h \
objc/objc-encoding.h \ objc/objc-encoding.h \
objc/objc-map.h \
objc/objc-runtime-hooks.h \ objc/objc-runtime-hooks.h \
objc/objc-runtime-shared-support.h \ objc/objc-runtime-shared-support.h \
objcp/objcp-decl.h objcp/objcp-decl.h
...@@ -165,6 +167,14 @@ objcp/objc-encoding.o : objc/objc-encoding.c \ ...@@ -165,6 +167,14 @@ objcp/objc-encoding.o : objc/objc-encoding.c \
$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< \ $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< \
$(OUTPUT_OPTION) $(OUTPUT_OPTION)
objcp/objc-map.o : objc/objc-map.c \
$(START_HDRS) \
$(GGC_H) $(DIAGNOSTIC_CORE_H) $(FLAGS_H) input.h \
$(OBSTACK_H) \
objc/objc-map.h
$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< \
$(OUTPUT_OPTION)
po-generated: po-generated:
# #
......
...@@ -46,5 +46,5 @@ subdir_requires="objc cp" ...@@ -46,5 +46,5 @@ subdir_requires="objc cp"
# This list is separated in two parts: the first one is identical to # This list is separated in two parts: the first one is identical to
# the C++ one, the second one contains our ObjC++ additions. # the C++ one, the second one contains our ObjC++ additions.
gtfiles="\$(srcdir)/cp/rtti.c \$(srcdir)/cp/mangle.c \$(srcdir)/cp/name-lookup.h \$(srcdir)/cp/name-lookup.c \$(srcdir)/cp/cp-tree.h \$(srcdir)/cp/decl.h \$(srcdir)/cp/call.c \$(srcdir)/cp/decl.c \$(srcdir)/cp/decl2.c \$(srcdir)/cp/pt.c \$(srcdir)/cp/repo.c \$(srcdir)/cp/semantics.c \$(srcdir)/cp/tree.c \$(srcdir)/cp/parser.h \$(srcdir)/cp/parser.c \$(srcdir)/cp/method.c \$(srcdir)/cp/typeck2.c \$(srcdir)/c-family/c-common.c \$(srcdir)/c-family/c-common.h \$(srcdir)/c-family/c-objc.h \$(srcdir)/c-family/c-lex.c \$(srcdir)/c-family/c-pragma.h \$(srcdir)/c-family/c-pragma.c \$(srcdir)/cp/class.c \$(srcdir)/cp/cp-objcp-common.c \ gtfiles="\$(srcdir)/cp/rtti.c \$(srcdir)/cp/mangle.c \$(srcdir)/cp/name-lookup.h \$(srcdir)/cp/name-lookup.c \$(srcdir)/cp/cp-tree.h \$(srcdir)/cp/decl.h \$(srcdir)/cp/call.c \$(srcdir)/cp/decl.c \$(srcdir)/cp/decl2.c \$(srcdir)/cp/pt.c \$(srcdir)/cp/repo.c \$(srcdir)/cp/semantics.c \$(srcdir)/cp/tree.c \$(srcdir)/cp/parser.h \$(srcdir)/cp/parser.c \$(srcdir)/cp/method.c \$(srcdir)/cp/typeck2.c \$(srcdir)/c-family/c-common.c \$(srcdir)/c-family/c-common.h \$(srcdir)/c-family/c-objc.h \$(srcdir)/c-family/c-lex.c \$(srcdir)/c-family/c-pragma.h \$(srcdir)/c-family/c-pragma.c \$(srcdir)/cp/class.c \$(srcdir)/cp/cp-objcp-common.c \
\$(srcdir)/objc/objc-act.h \$(srcdir)/objc/objc-act.c \$(srcdir)/objc/objc-runtime-shared-support.c \$(srcdir)/objc/objc-gnu-runtime-abi-01.c \$(srcdir)/objc/objc-next-runtime-abi-01.c \$(srcdir)/objc/objc-next-runtime-abi-02.c \$(srcdir)/c-family/c-cppbuiltin.c" \$(srcdir)/objc/objc-map.h \$(srcdir)/objc/objc-act.h \$(srcdir)/objc/objc-act.c \$(srcdir)/objc/objc-runtime-shared-support.c \$(srcdir)/objc/objc-gnu-runtime-abi-01.c \$(srcdir)/objc/objc-next-runtime-abi-01.c \$(srcdir)/objc/objc-next-runtime-abi-02.c \$(srcdir)/c-family/c-cppbuiltin.c"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment