diff options
author | Felix Lange <fjl@users.noreply.github.com> | 2017-09-11 03:04:36 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-11 03:04:36 +0800 |
commit | 42a5b54bf50a340bce624da91bffbf2827dad622 (patch) | |
tree | 7801652013e5f13074a52be502113bc508bca437 /core | |
parent | d6681ed36037c48bc95c7940e9914b9369e35170 (diff) | |
download | go-tangerine-42a5b54bf50a340bce624da91bffbf2827dad622.tar.gz go-tangerine-42a5b54bf50a340bce624da91bffbf2827dad622.tar.zst go-tangerine-42a5b54bf50a340bce624da91bffbf2827dad622.zip |
core/vm: improve bitvec comments
Diffstat (limited to 'core')
-rw-r--r-- | core/vm/analysis.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/core/vm/analysis.go b/core/vm/analysis.go index e6a2df7b0..f9c4298d3 100644 --- a/core/vm/analysis.go +++ b/core/vm/analysis.go @@ -44,8 +44,9 @@ func (d destinations) has(codehash common.Hash, code []byte, dest *big.Int) bool return OpCode(code[udest]) == JUMPDEST && m.codeSegment(udest) } -// bitvec is a bit vector which maps bytes in a program -// An unset bit means the byte is a code-segemnt, a set bit means it's data-segment +// bitvec is a bit vector which maps bytes in a program. +// An unset bit means the byte is an opcode, a set bit means +// it's data (i.e. argument of PUSHxx). type bitvec []byte func (bits *bitvec) set(pos uint64) { @@ -56,15 +57,14 @@ func (bits *bitvec) set8(pos uint64) { (*bits)[pos/8+1] |= ^(0xFF >> (pos % 8)) } -// codeSegment checks if the position is in a code segment +// codeSegment checks if the position is in a code segment. func (bits *bitvec) codeSegment(pos uint64) bool { return ((*bits)[pos/8] & (0x80 >> (pos % 8))) == 0 } -// jumpdests creates a bitmap of the code, where 1 represents a DATA-segment, -// and 0 represents code-segment -func codeBitmap(code []byte) []byte { - //The map is 4 bytes longer than necessary, in case the code +// codeBitmap collects data locations in code. +func codeBitmap(code []byte) bitvec { + // The bitmap is 4 bytes longer than necessary, in case the code // ends with a PUSH32, the algorithm will push zeroes onto the // bitvector outside the bounds of the actual code. bits := make(bitvec, len(code)/8+1+4) |