Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
0eebf9e5
Commit
0eebf9e5
authored
Apr 19, 2000
by
Bryce McKinlay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial revision
From-SVN: r33241
parent
48a840d9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
488 additions
and
0 deletions
+488
-0
boehm-gc/dbg_mlc.h
+102
-0
boehm-gc/gcj_mlc.c
+285
-0
boehm-gc/include/gc_gcj.h
+101
-0
No files found.
boehm-gc/dbg_mlc.h
0 → 100644
View file @
0eebf9e5
/*
* Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
* Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved.
* Copyright (c) 1997 by Silicon Graphics. All rights reserved.
* Copyright (c) 1999 by Hewlett-Packard Company. All rights reserved.
*
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
*
* Permission is hereby granted to use or copy this program
* for any purpose, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
/*
* This is mostly an internal header file. Typical clients should
* not use it. Clients that define their own object kinds with
* debugging allocators will probably want to include this, however.
* No attempt is made to keep the namespace clean. This should not be
* included from header filrd that are frequently included by clients.
*/
#ifndef _DBG_MLC_H
#define _DBG_MLC_H
# define I_HIDE_POINTERS
# include "gc_priv.h"
# ifdef KEEP_BACK_PTRS
# include "backptr.h"
# endif
# define START_FLAG ((word)0xfedcedcb)
# define END_FLAG ((word)0xbcdecdef)
/* Stored both one past the end of user object, and one before */
/* the end of the object as seen by the allocator. */
/* Object header */
typedef
struct
{
# ifdef KEEP_BACK_PTRS
ptr_t
oh_back_ptr
;
# define MARKED_FOR_FINALIZATION (ptr_t)(-1)
/* Object was marked because it is finalizable. */
# define MARKED_FROM_REGISTER (ptr_t)(-2)
/* Object was marked from a rgister. Hence the */
/* source of the reference doesn't have an address. */
# ifdef ALIGN_DOUBLE
word
oh_dummy
;
# endif
# endif
char
*
oh_string
;
/* object descriptor string */
word
oh_int
;
/* object descriptor integers */
# ifdef NEED_CALLINFO
struct
callinfo
oh_ci
[
NFRAMES
];
# endif
word
oh_sz
;
/* Original malloc arg. */
word
oh_sf
;
/* start flag */
}
oh
;
/* The size of the above structure is assumed not to dealign things, */
/* and to be a multiple of the word length. */
#define DEBUG_BYTES (sizeof (oh) + sizeof (word))
#define USR_PTR_FROM_BASE(p) ((ptr_t)(p) + sizeof(oh))
/* There is no reason to ever add a byte at the end explicitly, since we */
/* already add a guard word. */
#undef ROUNDED_UP_WORDS
#define ROUNDED_UP_WORDS(n) BYTES_TO_WORDS((n) + WORDS_TO_BYTES(1) - 1)
#ifdef SAVE_CALL_CHAIN
# define ADD_CALL_CHAIN(base, ra) GC_save_callers(((oh *)(base)) -> oh_ci)
# define PRINT_CALL_CHAIN(base) GC_print_callers(((oh *)(base)) -> oh_ci)
#else
# ifdef GC_ADD_CALLER
# define ADD_CALL_CHAIN(base, ra) ((oh *)(base)) -> oh_ci[0].ci_pc = (ra)
# define PRINT_CALL_CHAIN(base) GC_print_callers(((oh *)(base)) -> oh_ci)
# else
# define ADD_CALL_CHAIN(base, ra)
# define PRINT_CALL_CHAIN(base)
# endif
#endif
# ifdef GC_ADD_CALLER
# define OPT_RA ra,
# else
# define OPT_RA
# endif
/* Check whether object with base pointer p has debugging info */
/* p is assumed to point to a legitimate object in our part */
/* of the heap. */
GC_bool
GC_has_debug_info
(
/* p */
);
/* Store debugging info into p. Return displaced pointer. */
/* Assumes we don't hold allocation lock. */
ptr_t
GC_store_debug_info
(
/* p, sz, string, integer */
);
#endif
/* _DBG_MLC_H */
boehm-gc/gcj_mlc.c
0 → 100644
View file @
0eebf9e5
/*
* Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
* Copyright (c) 1999 by Hewlett-Packard Company. All rights reserved.
*
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
*
* Permission is hereby granted to use or copy this program
* for any purpose, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
/* Boehm, July 31, 1995 5:02 pm PDT */
#ifdef GC_GCJ_SUPPORT
/*
* This is an allocator interface tuned for gcj (the GNU/Cygnus static
* java compiler).
*
* Each allocated object has a pointer in its first word to a vtable,
* which for our purposes is simply a structure describing the type of
* the object.
* This descriptor structur contains a GC marking descriptor at offset
* MARK_DESCR_OFFSET.
*
* It is hoped that this interface may also be useful for other systems,
* possibly with some tuning of the constants. But the immediate goal
* is to get better gcj performance.
*
* We assume:
* 1) We have an ANSI conforming C compiler.
* 2) Counting on explicit initialization of this interface is OK.
* 3) FASTLOCK is not a significant win.
*/
#include "gc_priv.h"
#include "gc_mark.h"
#include "include/gc_gcj.h"
#include "dbg_mlc.h"
GC_bool
GC_gcj_malloc_initialized
=
FALSE
;
int
GC_gcj_kind
;
/* Object kind for objects with descriptors */
/* in "vtable". */
int
GC_gcj_debug_kind
;
/* The kind of objects that is always marked */
/* with a mark proc call. */
ptr_t
*
GC_gcjobjfreelist
;
ptr_t
*
GC_gcjdebugobjfreelist
;
void
*
GC_default_oom_action
(
void
)
{
return
0
;
}
void
*
(
*
GC_oom_action
)(
void
)
=
GC_default_oom_action
;
/* Caller does not hold allocation lock. */
void
GC_init_gcj_malloc
(
int
mp_index
,
void
*
/* really mark_proc */
mp
)
{
register
int
i
;
DCL_LOCK_STATE
;
GC_init
();
/* In case it's not already done. */
DISABLE_SIGNALS
();
LOCK
();
if
(
GC_gcj_malloc_initialized
)
{
UNLOCK
();
ENABLE_SIGNALS
();
return
;
}
GC_gcj_malloc_initialized
=
TRUE
;
GC_mark_procs
[
mp_index
]
=
(
mark_proc
)
mp
;
if
(
mp_index
>=
GC_n_mark_procs
)
ABORT
(
"GC_init_gcj_malloc: bad index"
);
/* Set up object kind gcj-style indirect descriptor. */
GC_gcjobjfreelist
=
(
ptr_t
*
)
GC_generic_malloc_inner
((
MAXOBJSZ
+
1
)
*
sizeof
(
ptr_t
),
PTRFREE
);
if
(
GC_gcjobjfreelist
==
0
)
ABORT
(
"Couldn't allocate GC_gcjobjfreelist"
);
BZERO
(
GC_gcjobjfreelist
,
(
MAXOBJSZ
+
1
)
*
sizeof
(
ptr_t
));
GC_gcj_kind
=
GC_n_kinds
++
;
GC_obj_kinds
[
GC_gcj_kind
].
ok_freelist
=
GC_gcjobjfreelist
;
GC_obj_kinds
[
GC_gcj_kind
].
ok_reclaim_list
=
0
;
GC_obj_kinds
[
GC_gcj_kind
].
ok_descriptor
=
(((
word
)(
-
MARK_DESCR_OFFSET
-
INDIR_PER_OBJ_BIAS
))
|
DS_PER_OBJECT
);
GC_obj_kinds
[
GC_gcj_kind
].
ok_relocate_descr
=
FALSE
;
GC_obj_kinds
[
GC_gcj_kind
].
ok_init
=
TRUE
;
/* Set up object kind for objects that require mark proc call. */
GC_gcjdebugobjfreelist
=
(
ptr_t
*
)
GC_generic_malloc_inner
((
MAXOBJSZ
+
1
)
*
sizeof
(
ptr_t
),
PTRFREE
);
if
(
GC_gcjdebugobjfreelist
==
0
)
ABORT
(
"Couldn't allocate GC_gcjdebugobjfreelist"
);
BZERO
(
GC_gcjdebugobjfreelist
,
(
MAXOBJSZ
+
1
)
*
sizeof
(
ptr_t
));
GC_gcj_debug_kind
=
GC_n_kinds
++
;
GC_obj_kinds
[
GC_gcj_debug_kind
].
ok_freelist
=
GC_gcjdebugobjfreelist
;
GC_obj_kinds
[
GC_gcj_debug_kind
].
ok_reclaim_list
=
0
;
GC_obj_kinds
[
GC_gcj_debug_kind
].
ok_descriptor
=
MAKE_PROC
(
mp_index
,
1
/* allocated with debug info */
);
GC_obj_kinds
[
GC_gcj_debug_kind
].
ok_relocate_descr
=
FALSE
;
GC_obj_kinds
[
GC_gcj_debug_kind
].
ok_init
=
TRUE
;
UNLOCK
();
ENABLE_SIGNALS
();
}
ptr_t
GC_clear_stack
();
#define GENERAL_MALLOC(lb,k) \
(GC_PTR)GC_clear_stack(GC_generic_malloc_inner((word)lb, k))
#define GENERAL_MALLOC_IOP(lb,k) \
(GC_PTR)GC_clear_stack(GC_generic_malloc_inner_ignore_off_page(lb, k))
/* Allocate an object, clear it, and store the pointer to the */
/* type structure (vtable in gcj). */
/* This adds a byte at the end of the object if GC_malloc would.*/
void
*
GC_gcj_malloc
(
size_t
lb
,
void
*
ptr_to_struct_containing_descr
)
{
register
ptr_t
op
;
register
ptr_t
*
opp
;
register
word
lw
;
DCL_LOCK_STATE
;
if
(
SMALL_OBJ
(
lb
)
)
{
# ifdef MERGE_SIZES
lw
=
GC_size_map
[
lb
];
# else
lw
=
ALIGNED_WORDS
(
lb
);
# endif
opp
=
&
(
GC_gcjobjfreelist
[
lw
]);
LOCK
();
if
(
(
op
=
*
opp
)
==
0
)
{
op
=
(
ptr_t
)
GENERAL_MALLOC
((
word
)
lb
,
GC_gcj_kind
);
if
(
0
==
op
)
{
UNLOCK
();
return
(
GC_oom_action
());
}
# ifdef MERGE_SIZES
lw
=
GC_size_map
[
lb
];
/* May have been uninitialized. */
# endif
}
else
{
*
opp
=
obj_link
(
op
);
GC_words_allocd
+=
lw
;
FASTUNLOCK
();
}
*
(
void
**
)
op
=
ptr_to_struct_containing_descr
;
UNLOCK
();
}
else
{
LOCK
();
op
=
(
ptr_t
)
GENERAL_MALLOC
((
word
)
lb
,
GC_gcj_kind
);
if
(
0
==
op
)
{
UNLOCK
();
return
(
GC_oom_action
());
}
*
(
void
**
)
op
=
ptr_to_struct_containing_descr
;
UNLOCK
();
}
return
((
GC_PTR
)
op
);
}
/* Similar to GC_gcj_malloc, but add debug info. This is allocated */
/* with GC_gcj_debug_kind. */
GC_PTR
GC_debug_gcj_malloc
(
size_t
lb
,
void
*
ptr_to_struct_containing_descr
,
GC_EXTRA_PARAMS
)
{
GC_PTR
result
;
/* We clone the code from GC_debug_gcj_malloc, so that we */
/* dont end up with extra frames on the stack, which could */
/* confuse the backtrace. */
LOCK
();
result
=
GC_generic_malloc_inner
(
lb
+
DEBUG_BYTES
,
GC_gcj_debug_kind
);
if
(
result
==
0
)
{
UNLOCK
();
GC_err_printf2
(
"GC_debug_gcj_malloc(%ld, 0x%lx) returning NIL ("
,
(
unsigned
long
)
lb
,
(
unsigned
long
)
ptr_to_struct_containing_descr
);
GC_err_puts
(
s
);
GC_err_printf1
(
":%ld)
\n
"
,
(
unsigned
long
)
i
);
return
(
GC_oom_action
());
}
*
((
void
**
)((
ptr_t
)
result
+
sizeof
(
oh
)))
=
ptr_to_struct_containing_descr
;
UNLOCK
();
if
(
!
GC_debugging_started
)
{
GC_start_debugging
();
}
ADD_CALL_CHAIN
(
result
,
ra
);
return
(
GC_store_debug_info
(
result
,
(
word
)
lb
,
s
,
(
word
)
i
));
}
/* Similar to GC_gcj_malloc, but the size is in words, and we don't */
/* adjust it. The size is assumed to be such that it can be */
/* allocated as a small object. */
void
*
GC_gcj_fast_malloc
(
size_t
lw
,
void
*
ptr_to_struct_containing_descr
)
{
ptr_t
op
;
ptr_t
*
opp
;
DCL_LOCK_STATE
;
opp
=
&
(
GC_gcjobjfreelist
[
lw
]);
LOCK
();
if
(
(
op
=
*
opp
)
==
0
)
{
op
=
(
ptr_t
)
GC_clear_stack
(
GC_generic_malloc_words_small_inner
(
lw
,
GC_gcj_kind
));
if
(
0
==
op
)
{
UNLOCK
();
return
(
GC_oom_action
());
}
}
else
{
*
opp
=
obj_link
(
op
);
GC_words_allocd
+=
lw
;
}
*
(
void
**
)
op
=
ptr_to_struct_containing_descr
;
UNLOCK
();
return
((
GC_PTR
)
op
);
}
/* And a debugging version of the above: */
void
*
GC_debug_gcj_fast_malloc
(
size_t
lw
,
void
*
ptr_to_struct_containing_descr
,
GC_EXTRA_PARAMS
)
{
GC_PTR
result
;
size_t
lb
=
WORDS_TO_BYTES
(
lw
);
/* We clone the code from GC_debug_gcj_malloc, so that we */
/* dont end up with extra frames on the stack, which could */
/* confuse the backtrace. */
LOCK
();
result
=
GC_generic_malloc_inner
(
lb
+
DEBUG_BYTES
,
GC_gcj_debug_kind
);
if
(
result
==
0
)
{
UNLOCK
();
GC_err_printf2
(
"GC_debug_gcj_fast_malloc(%ld, 0x%lx) returning NIL ("
,
(
unsigned
long
)
lw
,
(
unsigned
long
)
ptr_to_struct_containing_descr
);
GC_err_puts
(
s
);
GC_err_printf1
(
":%ld)
\n
"
,
(
unsigned
long
)
i
);
return
(
GC_oom_action
());
}
*
((
void
**
)((
ptr_t
)
result
+
sizeof
(
oh
)))
=
ptr_to_struct_containing_descr
;
UNLOCK
();
if
(
!
GC_debugging_started
)
{
GC_start_debugging
();
}
ADD_CALL_CHAIN
(
result
,
ra
);
return
(
GC_store_debug_info
(
result
,
(
word
)
lb
,
s
,
(
word
)
i
));
}
void
*
GC_gcj_malloc_ignore_off_page
(
size_t
lb
,
void
*
ptr_to_struct_containing_descr
)
{
register
ptr_t
op
;
register
ptr_t
*
opp
;
register
word
lw
;
DCL_LOCK_STATE
;
if
(
SMALL_OBJ
(
lb
)
)
{
# ifdef MERGE_SIZES
lw
=
GC_size_map
[
lb
];
# else
lw
=
ALIGNED_WORDS
(
lb
);
# endif
opp
=
&
(
GC_gcjobjfreelist
[
lw
]);
LOCK
();
if
(
(
op
=
*
opp
)
==
0
)
{
op
=
(
ptr_t
)
GENERAL_MALLOC_IOP
(
lb
,
GC_gcj_kind
);
# ifdef MERGE_SIZES
lw
=
GC_size_map
[
lb
];
/* May have been uninitialized. */
# endif
}
else
{
*
opp
=
obj_link
(
op
);
GC_words_allocd
+=
lw
;
FASTUNLOCK
();
}
*
(
void
**
)
op
=
ptr_to_struct_containing_descr
;
UNLOCK
();
}
else
{
op
=
(
ptr_t
)
GENERAL_MALLOC_IOP
(
lb
,
GC_gcj_kind
);
if
(
0
!=
op
)
{
*
(
void
**
)
op
=
ptr_to_struct_containing_descr
;
}
UNLOCK
();
}
return
((
GC_PTR
)
op
);
}
#endif
/* GC_GCJ_SUPPORT */
boehm-gc/include/gc_gcj.h
0 → 100644
View file @
0eebf9e5
/*
* Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
* Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved.
* Copyright 1996-1999 by Silicon Graphics. All rights reserved.
* Copyright 1999 by Hewlett-Packard Company. All rights reserved.
*
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
*
* Permission is hereby granted to use or copy this program
* for any purpose, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
/* This file assumes the collector has been compiled with GC_GCJ_SUPPORT */
/* and that an ANSI C compiler is available. */
/*
* We allocate objects whose first word contains a pointer to a struct
* describing the object type. This struct contains a garbage collector mark
* descriptor at offset MARK_DESCR_OFFSET. Alternatively, the objects
* may be marked by the mark procedure passed to GC_init_gcj_malloc.
*/
#ifndef MARK_DESCR_OFFSET
# define MARK_DESCR_OFFSET sizeof(word)
#endif
/* Gcj keeps GC descriptor as second word of vtable. This */
/* probably needs to be adjusted for other clients. */
/* We currently assume that this offset is such that: */
/* - all objects of this kind are large enough to have */
/* a value at that offset, and */
/* - it is not zero. */
/* These assumptions allow objects on the free list to be */
/* marked normally. */
#ifndef _GC_H
# include "gc.h"
#endif
/* The following allocators signal an out of memory condition with */
/* return GC_oom_action(); */
/* The default GC_oom_action returns 0. */
/* This functionality is currently restricted to the gcj allocators. */
/* We may want to extend it to the others. */
extern
void
*
(
*
GC_oom_action
)(
void
);
/* The following function must be called before the gcj allocators */
/* can be invoked. */
/* mp_index and mp are the index and mark_proc (see gc_mark.h) */
/* respectively for the allocated objects. Mark_proc will be */
/* used to build the descriptor for objects allocated through the */
/* debugging interface. The mark_proc will be invoked on all such */
/* objects with an "environment" value of 1. The client may chose */
/* to use the same mark_proc for some of its generated mark descriptors.*/
/* In that case, it should use a different "environment" value to */
/* detect the presence or absence of the debug header. */
/* the debugging interface. */
/* Mp is really of type mark_proc, as defined in gc_mark.h. We don't */
/* want to include that here for namespace pollution reasons. */
extern
void
GC_init_gcj_malloc
(
int
mp_index
,
void
*
/* really mark_proc */
mp
);
/* Allocate an object, clear it, and store the pointer to the */
/* type structure (vtable in gcj). */
/* This adds a byte at the end of the object if GC_malloc would.*/
extern
void
*
GC_gcj_malloc
(
size_t
lb
,
void
*
ptr_to_struct_containing_descr
);
/* The debug versions allocate such that the specified mark_proc */
/* is always invoked. */
extern
void
*
GC_debug_gcj_malloc
(
size_t
lb
,
void
*
ptr_to_struct_containing_descr
,
GC_EXTRA_PARAMS
);
/* Similar to the above, but the size is in words, and we don't */
/* adjust it. The size is assumed to be such that it can be */
/* allocated as a small object. */
extern
void
*
GC_gcj_fast_malloc
(
size_t
lw
,
void
*
ptr_to_struct_containing_descr
);
extern
void
*
GC_debug_gcj_fast_malloc
(
size_t
lw
,
void
*
ptr_to_struct_containing_descr
,
GC_EXTRA_PARAMS
);
/* Similar to GC_gcj_malloc, but assumes that a pointer to near the */
/* beginning of the resulting object is always maintained. */
extern
void
*
GC_gcj_malloc_ignore_off_page
(
size_t
lb
,
void
*
ptr_to_struct_containing_descr
);
# ifdef GC_DEBUG
# define GC_GCJ_MALLOC(s,d) GC_debug_gcj_malloc(s,d,GC_EXTRAS)
# define GC_GCJ_FAST_MALLOC(s,d) GC_debug_gcj_fast_malloc(s,d,GC_EXTRAS)
# define GC_GCJ_MALLOC_IGNORE_OFF_PAGE(s,d) GC_gcj_debug_malloc(s,d,GC_EXTRAS)
# else
# define GC_GCJ_MALLOC(s,d) GC_gcj_malloc(s,d)
# define GC_GCJ_FAST_MALLOC(s,d) GC_gcj_fast_malloc(s,d)
# define GC_GCJ_MALLOC_IGNORE_OFF_PAGE(s,d) \
GC_gcj_debug_malloc_ignore_off_page(s,d)
# endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment