Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
c69402d8
Commit
c69402d8
authored
Dec 10, 2013
by
Carl Shapiro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runtime: remove outdated comment and related indentation
R=golang-dev, iant CC=golang-dev
https://golang.org/cl/39810043
parent
ddbad5ef
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
103 additions
and
109 deletions
+103
-109
src/pkg/runtime/mgc0.c
src/pkg/runtime/mgc0.c
+103
-109
No files found.
src/pkg/runtime/mgc0.c
View file @
c69402d8
...
...
@@ -409,131 +409,125 @@ flushptrbuf(Scanbuf *sbuf)
runtime
·
throw
(
"ptrbuf has to be smaller than WorkBuf"
);
}
// TODO(atom): This block is a branch of an if-then-else statement.
// The single-threaded branch may be added in a next CL.
{
// Multi-threaded version.
while
(
ptrbuf
<
ptrbuf_end
)
{
obj
=
ptrbuf
->
p
;
ti
=
ptrbuf
->
ti
;
ptrbuf
++
;
// obj belongs to interval [mheap.arena_start, mheap.arena_used).
if
(
Debug
>
1
)
{
if
(
obj
<
runtime
·
mheap
.
arena_start
||
obj
>=
runtime
·
mheap
.
arena_used
)
runtime
·
throw
(
"object is outside of mheap"
);
}
while
(
ptrbuf
<
ptrbuf_end
)
{
obj
=
ptrbuf
->
p
;
ti
=
ptrbuf
->
ti
;
ptrbuf
++
;
// obj may be a pointer to a live object.
// Try to find the beginning of the object.
// obj belongs to interval [mheap.arena_start, mheap.arena_used).
if
(
Debug
>
1
)
{
if
(
obj
<
runtime
·
mheap
.
arena_start
||
obj
>=
runtime
·
mheap
.
arena_used
)
runtime
·
throw
(
"object is outside of mheap"
);
}
// Round down to word boundary.
if
(((
uintptr
)
obj
&
((
uintptr
)
PtrSize
-
1
))
!=
0
)
{
obj
=
(
void
*
)((
uintptr
)
obj
&
~
((
uintptr
)
PtrSize
-
1
));
ti
=
0
;
}
// obj may be a pointer to a live object.
// Try to find the beginning of the object.
// Find bits for this word.
off
=
(
uintptr
*
)
obj
-
(
uintptr
*
)
arena_start
;
bitp
=
(
uintptr
*
)
arena_start
-
off
/
wordsPerBitmapWord
-
1
;
shift
=
off
%
wordsPerBitmapWord
;
xbits
=
*
bitp
;
bits
=
xbits
>>
shift
;
// Round down to word boundary.
if
(((
uintptr
)
obj
&
((
uintptr
)
PtrSize
-
1
))
!=
0
)
{
obj
=
(
void
*
)((
uintptr
)
obj
&
~
((
uintptr
)
PtrSize
-
1
));
ti
=
0
;
}
// Pointing at the beginning of a block?
if
((
bits
&
(
bitAllocated
|
bitBlockBoundary
))
!=
0
)
{
if
(
CollectStats
)
runtime
·
xadd64
(
&
gcstats
.
flushptrbuf
.
foundbit
,
1
)
;
goto
found
;
}
// Find bits for this word.
off
=
(
uintptr
*
)
obj
-
(
uintptr
*
)
arena_start
;
bitp
=
(
uintptr
*
)
arena_start
-
off
/
wordsPerBitmapWord
-
1
;
shift
=
off
%
wordsPerBitmapWord
;
xbits
=
*
bitp
;
bits
=
xbits
>>
shift
;
ti
=
0
;
// Pointing at the beginning of a block?
if
((
bits
&
(
bitAllocated
|
bitBlockBoundary
))
!=
0
)
{
if
(
CollectStats
)
runtime
·
xadd64
(
&
gcstats
.
flushptrbuf
.
foundbit
,
1
);
goto
found
;
}
// Pointing just past the beginning?
// Scan backward a little to find a block boundary.
for
(
j
=
shift
;
j
-->
0
;
)
{
if
(((
xbits
>>
j
)
&
(
bitAllocated
|
bitBlockBoundary
))
!=
0
)
{
obj
=
(
byte
*
)
obj
-
(
shift
-
j
)
*
PtrSize
;
shift
=
j
;
bits
=
xbits
>>
shift
;
if
(
CollectStats
)
runtime
·
xadd64
(
&
gcstats
.
flushptrbuf
.
foundword
,
1
);
goto
found
;
}
}
ti
=
0
;
// Otherwise consult span table to find beginning.
// (Manually inlined copy of MHeap_LookupMaybe.)
k
=
(
uintptr
)
obj
>>
PageShift
;
x
=
k
;
if
(
sizeof
(
void
*
)
==
8
)
x
-=
(
uintptr
)
arena_start
>>
PageShift
;
s
=
runtime
·
mheap
.
spans
[
x
];
if
(
s
==
nil
||
k
<
s
->
start
||
obj
>=
s
->
limit
||
s
->
state
!=
MSpanInUse
)
continue
;
p
=
(
byte
*
)((
uintptr
)
s
->
start
<<
PageShift
);
if
(
s
->
sizeclass
==
0
)
{
obj
=
p
;
}
else
{
size
=
s
->
elemsize
;
int32
i
=
((
byte
*
)
obj
-
p
)
/
size
;
obj
=
p
+
i
*
size
;
// Pointing just past the beginning?
// Scan backward a little to find a block boundary.
for
(
j
=
shift
;
j
-->
0
;
)
{
if
(((
xbits
>>
j
)
&
(
bitAllocated
|
bitBlockBoundary
))
!=
0
)
{
obj
=
(
byte
*
)
obj
-
(
shift
-
j
)
*
PtrSize
;
shift
=
j
;
bits
=
xbits
>>
shift
;
if
(
CollectStats
)
runtime
·
xadd64
(
&
gcstats
.
flushptrbuf
.
foundword
,
1
);
goto
found
;
}
}
// Now that we know the object header, reload bits.
off
=
(
uintptr
*
)
obj
-
(
uintptr
*
)
arena_start
;
bitp
=
(
uintptr
*
)
arena_start
-
off
/
wordsPerBitmapWord
-
1
;
shift
=
off
%
wordsPerBitmapWord
;
xbits
=
*
bitp
;
bits
=
xbits
>>
shift
;
if
(
CollectStats
)
runtime
·
xadd64
(
&
gcstats
.
flushptrbuf
.
foundspan
,
1
);
// Otherwise consult span table to find beginning.
// (Manually inlined copy of MHeap_LookupMaybe.)
k
=
(
uintptr
)
obj
>>
PageShift
;
x
=
k
;
if
(
sizeof
(
void
*
)
==
8
)
x
-=
(
uintptr
)
arena_start
>>
PageShift
;
s
=
runtime
·
mheap
.
spans
[
x
];
if
(
s
==
nil
||
k
<
s
->
start
||
obj
>=
s
->
limit
||
s
->
state
!=
MSpanInUse
)
continue
;
p
=
(
byte
*
)((
uintptr
)
s
->
start
<<
PageShift
);
if
(
s
->
sizeclass
==
0
)
{
obj
=
p
;
}
else
{
size
=
s
->
elemsize
;
int32
i
=
((
byte
*
)
obj
-
p
)
/
size
;
obj
=
p
+
i
*
size
;
}
found:
// Now we have bits, bitp, and shift correct for
// obj pointing at the base of the object.
// Only care about allocated and not marked.
if
((
bits
&
(
bitAllocated
|
bitMarked
))
!=
bitAllocated
)
continue
;
if
(
work
.
nproc
==
1
)
*
bitp
|=
bitMarked
<<
shift
;
else
{
for
(;;)
{
x
=
*
bitp
;
if
(
x
&
(
bitMarked
<<
shift
))
goto
continue_obj
;
if
(
runtime
·
casp
((
void
**
)
bitp
,
(
void
*
)
x
,
(
void
*
)(
x
|
(
bitMarked
<<
shift
))))
break
;
}
// Now that we know the object header, reload bits.
off
=
(
uintptr
*
)
obj
-
(
uintptr
*
)
arena_start
;
bitp
=
(
uintptr
*
)
arena_start
-
off
/
wordsPerBitmapWord
-
1
;
shift
=
off
%
wordsPerBitmapWord
;
xbits
=
*
bitp
;
bits
=
xbits
>>
shift
;
if
(
CollectStats
)
runtime
·
xadd64
(
&
gcstats
.
flushptrbuf
.
foundspan
,
1
);
found:
// Now we have bits, bitp, and shift correct for
// obj pointing at the base of the object.
// Only care about allocated and not marked.
if
((
bits
&
(
bitAllocated
|
bitMarked
))
!=
bitAllocated
)
continue
;
if
(
work
.
nproc
==
1
)
*
bitp
|=
bitMarked
<<
shift
;
else
{
for
(;;)
{
x
=
*
bitp
;
if
(
x
&
(
bitMarked
<<
shift
))
goto
continue_obj
;
if
(
runtime
·
casp
((
void
**
)
bitp
,
(
void
*
)
x
,
(
void
*
)(
x
|
(
bitMarked
<<
shift
))))
break
;
}
}
// If object has no pointers, don't need to scan further.
if
((
bits
&
bitNoScan
)
!=
0
)
continue
;
// If object has no pointers, don't need to scan further.
if
((
bits
&
bitNoScan
)
!=
0
)
continue
;
// Ask span about size class.
// (Manually inlined copy of MHeap_Lookup.)
x
=
(
uintptr
)
obj
>>
PageShift
;
if
(
sizeof
(
void
*
)
==
8
)
x
-=
(
uintptr
)
arena_start
>>
PageShift
;
s
=
runtime
·
mheap
.
spans
[
x
];
// Ask span about size class.
// (Manually inlined copy of MHeap_Lookup.)
x
=
(
uintptr
)
obj
>>
PageShift
;
if
(
sizeof
(
void
*
)
==
8
)
x
-=
(
uintptr
)
arena_start
>>
PageShift
;
s
=
runtime
·
mheap
.
spans
[
x
];
PREFETCH
(
obj
);
PREFETCH
(
obj
);
*
wp
=
(
Obj
){
obj
,
s
->
elemsize
,
ti
};
wp
++
;
nobj
++
;
continue_obj:
;
}
*
wp
=
(
Obj
){
obj
,
s
->
elemsize
,
ti
};
wp
++
;
nobj
++
;
continue_obj:
;
}
// If another proc wants a pointer, give it some.
if
(
work
.
nwait
>
0
&&
nobj
>
handoffThreshold
&&
work
.
full
==
0
)
{
wbuf
->
nobj
=
nobj
;
wbuf
=
handoff
(
wbuf
);
nobj
=
wbuf
->
nobj
;
wp
=
wbuf
->
obj
+
nobj
;
}
// If another proc wants a pointer, give it some.
if
(
work
.
nwait
>
0
&&
nobj
>
handoffThreshold
&&
work
.
full
==
0
)
{
wbuf
->
nobj
=
nobj
;
wbuf
=
handoff
(
wbuf
);
nobj
=
wbuf
->
nobj
;
wp
=
wbuf
->
obj
+
nobj
;
}
sbuf
->
wp
=
wp
;
...
...
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