Deleted Added
full compact
dt_regset.c (178480) dt_regset.c (249367)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *

--- 5 unchanged lines hidden (view full) ---

14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *

--- 5 unchanged lines hidden (view full) ---

14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22
22/*
23 * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
23/*
24 * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
26 */
27
27#pragma ident "%Z%%M% %I% %E% SMI"
28/*
29 * Copyright (c) 2012 by Delphix. All rights reserved.
30 */
28
29#include <sys/types.h>
30#include <sys/bitmap.h>
31#include <assert.h>
32#include <strings.h>
33#include <stdlib.h>
34
35#include <dt_regset.h>
31
32#include <sys/types.h>
33#include <sys/bitmap.h>
34#include <assert.h>
35#include <strings.h>
36#include <stdlib.h>
37
38#include <dt_regset.h>
39#include <dt_impl.h>
36
37dt_regset_t *
40
41dt_regset_t *
38dt_regset_create(ulong_t size)
42dt_regset_create(ulong_t nregs)
39{
43{
40 ulong_t n = BT_BITOUL(size + 1); /* + 1 for %r0 */
44 ulong_t n = BT_BITOUL(nregs);
41 dt_regset_t *drp = malloc(sizeof (dt_regset_t));
42
43 if (drp == NULL)
44 return (NULL);
45
46 drp->dr_bitmap = malloc(sizeof (ulong_t) * n);
45 dt_regset_t *drp = malloc(sizeof (dt_regset_t));
46
47 if (drp == NULL)
48 return (NULL);
49
50 drp->dr_bitmap = malloc(sizeof (ulong_t) * n);
47 drp->dr_size = size + 1;
51 drp->dr_size = nregs;
48
49 if (drp->dr_bitmap == NULL) {
50 dt_regset_destroy(drp);
51 return (NULL);
52 }
53
54 bzero(drp->dr_bitmap, sizeof (ulong_t) * n);
55 return (drp);

--- 7 unchanged lines hidden (view full) ---

63}
64
65void
66dt_regset_reset(dt_regset_t *drp)
67{
68 bzero(drp->dr_bitmap, sizeof (ulong_t) * BT_BITOUL(drp->dr_size));
69}
70
52
53 if (drp->dr_bitmap == NULL) {
54 dt_regset_destroy(drp);
55 return (NULL);
56 }
57
58 bzero(drp->dr_bitmap, sizeof (ulong_t) * n);
59 return (drp);

--- 7 unchanged lines hidden (view full) ---

67}
68
69void
70dt_regset_reset(dt_regset_t *drp)
71{
72 bzero(drp->dr_bitmap, sizeof (ulong_t) * BT_BITOUL(drp->dr_size));
73}
74
75void
76dt_regset_assert_free(dt_regset_t *drp)
77{
78 int reg;
79 boolean_t fail = B_FALSE;
80 for (reg = 0; reg < drp->dr_size; reg++) {
81 if (BT_TEST(drp->dr_bitmap, reg) != 0) {
82 dt_dprintf("%%r%d was left allocated\n", reg);
83 fail = B_TRUE;
84 }
85 }
86
87 /*
88 * We set this during dtest runs to check for register leaks.
89 */
90 if (fail && getenv("DTRACE_DEBUG_REGSET") != NULL)
91 abort();
92}
93
71int
72dt_regset_alloc(dt_regset_t *drp)
73{
74 ulong_t nbits = drp->dr_size - 1;
75 ulong_t maxw = nbits >> BT_ULSHIFT;
76 ulong_t wx;
77
78 for (wx = 0; wx <= maxw; wx++) {

--- 11 unchanged lines hidden (view full) ---

90 if ((word & bit) == 0) {
91 reg = (int)((wx << BT_ULSHIFT) | bx);
92 BT_SET(drp->dr_bitmap, reg);
93 return (reg);
94 }
95 }
96 }
97
94int
95dt_regset_alloc(dt_regset_t *drp)
96{
97 ulong_t nbits = drp->dr_size - 1;
98 ulong_t maxw = nbits >> BT_ULSHIFT;
99 ulong_t wx;
100
101 for (wx = 0; wx <= maxw; wx++) {

--- 11 unchanged lines hidden (view full) ---

113 if ((word & bit) == 0) {
114 reg = (int)((wx << BT_ULSHIFT) | bx);
115 BT_SET(drp->dr_bitmap, reg);
116 return (reg);
117 }
118 }
119 }
120
98 return (-1); /* no available registers */
121 xyerror(D_NOREG, "Insufficient registers to generate code");
122 /*NOTREACHED*/
123 return (-1);
99}
100
101void
102dt_regset_free(dt_regset_t *drp, int reg)
103{
124}
125
126void
127dt_regset_free(dt_regset_t *drp, int reg)
128{
104 assert(reg > 0 && reg < drp->dr_size);
129 assert(reg >= 0 && reg < drp->dr_size);
105 assert(BT_TEST(drp->dr_bitmap, reg) != 0);
106 BT_CLEAR(drp->dr_bitmap, reg);
107}
130 assert(BT_TEST(drp->dr_bitmap, reg) != 0);
131 BT_CLEAR(drp->dr_bitmap, reg);
132}