Remove the obsolete is_marked method

This commit is contained in:
Nigel Tao committed 2018-04-28 10:13:32 +10:00
1 parent 6b2f7815da
commit 124a329e73
7 files changed
+8 -59

No files matched your search

+1 -12
View File
@@ -172,7 +172,6 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, rp replacementPolicy, pp pare
aPrefix, bPrefix, aPrefix)
return nil
}
// TODO: io_reader.is_marked, not just io_writer.is_marked?
if isInDst(g.tm, n, t.IDLimit, 1) {
return fmt.Errorf(`TODO: cgen an "in.dst.limit" expression`)
}
@@ -190,7 +189,7 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, rp replacementPolicy, pp pare
// TODO: drop the "true" in the "if true", provided that the
// benchmark numbers improve.
len0, len1 := "", ""
if true || !n.BoundsCheckOptimized() {
if true {
len0 = aPrefix + "dst.private_impl.bounds[0] ?"
len1 = ": 0"
}
@@ -200,16 +199,6 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, rp replacementPolicy, pp pare
aPrefix, len0, bPrefix, aPrefix, len1)
return nil
}
if isInDst(g.tm, n, t.IDIsMarked, 0) {
if pp == parenthesesMandatory {
b.writeb('(')
}
b.printf("%sdst.private_impl.bounds[0] != NULL", aPrefix)
if pp == parenthesesMandatory {
b.writeb(')')
}
return nil
}
if isInDst(g.tm, n, t.IDCopyFromReader32, 2) {
b.printf("wuffs_base__io_writer__copy_from_reader32(&%swptr_dst, %swend_dst",
bPrefix, bPrefix)
-1
View File
@@ -834,7 +834,6 @@ func isInDst(tm *t.Map, n *a.Expr, methodName t.ID, nArgs int) bool {
methodName != t.IDCopyFromSlice32 &&
methodName != t.IDCopyFromSlice &&
methodName != t.IDSinceMark &&
methodName != t.IDIsMarked &&
methodName != t.IDMark &&
methodName != t.IDLimit
// TODO: check that n.Args() is "(x:bar)".
-4
View File
@@ -2939,10 +2939,6 @@ static wuffs_deflate__status wuffs_deflate__decoder__decode_huffman_fast(
b_rend_src = b_rptr_src + len;
}
if (!(a_dst.private_impl.bounds[0] != NULL)) {
status = WUFFS_DEFLATE__ERROR_BAD_ARGUMENT;
goto exit;
}
if ((self->private_impl.f_n_bits >= 8) ||
((self->private_impl.f_bits >> self->private_impl.f_n_bits) != 0)) {
status = WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_N_BITS;
-2
View File
@@ -104,7 +104,6 @@ var Funcs = []string{
"io_reader.read_u64le?()(ret u64)",
"io_reader.available()(ret u64)",
"io_reader.is_marked()(ret bool)",
"io_reader.limit(l u64)(ret io_reader)",
"io_reader.mark()()",
"io_reader.since_mark()(ret slice u8)",
@@ -125,7 +124,6 @@ var Funcs = []string{
"io_writer.copy_from_reader32(r io_reader, length u32)(ret u32)",
"io_writer.copy_from_slice(s slice u8)(ret u64)",
"io_writer.copy_from_slice32(s slice u8, length u32)(ret u32)",
"io_writer.is_marked()(ret bool)",
"io_writer.limit(l u64)(ret io_writer)",
"io_writer.mark()()",
"io_writer.since_mark()(ret slice u8)",
+6 -27
View File
@@ -65,14 +65,6 @@ func (q *checker) optimizeNonSuspendible(n *a.Expr) error {
switch nMethod {
case t.IDCopyFromHistory32:
return q.optimizeCopyFromHistory32(n)
case t.IDSinceMark:
for _, x := range q.facts {
xReceiver, xMethod, _ := splitReceiverMethodArgs(x)
if xMethod == t.IDIsMarked && xReceiver.Eq(nReceiver) {
n.SetBoundsCheckOptimized()
return nil
}
}
}
return nil
@@ -81,7 +73,6 @@ func (q *checker) optimizeNonSuspendible(n *a.Expr) error {
// optimizeCopyFromHistory32 checks if the code generator can call the Bounds
// Check Optimized version of CopyFromHistory32. As per cgen/base-impl.h, the
// conditions are:
// - start != NULL // TODO: obsolete.
// - distance > 0
// - distance <= (*ptr_ptr - start)
// - length <= (end - *ptr_ptr)
@@ -94,20 +85,8 @@ func (q *checker) optimizeCopyFromHistory32(n *a.Expr) error {
d := args[0].Arg().Value()
l := args[1].Arg().Value()
// Check "start != NULL".
check0:
for {
for _, x := range q.facts {
xReceiver, xMethod, _ := splitReceiverMethodArgs(x)
if xMethod == t.IDIsMarked && xReceiver.Eq(nReceiver) {
break check0
}
}
return nil
}
// Check "distance > 0".
check1:
check0:
for {
for _, x := range q.facts {
if x.Operator() != t.IDXBinaryGreaterThan {
@@ -119,13 +98,13 @@ check1:
if rcv := x.RHS().Expr().ConstValue(); rcv == nil || rcv.Sign() != 0 {
continue
}
break check1
break check0
}
return nil
}
// Check "distance <= (*ptr_ptr - start)".
check2:
check1:
for {
for _, x := range q.facts {
if x.Operator() != t.IDXBinaryLessEq {
@@ -155,13 +134,13 @@ check2:
continue
}
break check2
break check1
}
return nil
}
// Check "length <= (end - *ptr_ptr)".
check3:
check2:
for {
for _, x := range q.facts {
if x.Operator() != t.IDXBinaryLessEq {
@@ -187,7 +166,7 @@ check3:
continue
}
break check3
break check2
}
return nil
}
-2
View File
@@ -412,7 +412,6 @@ const (
IDLowBits = ID(0xCE)
IDHighBits = ID(0xCF)
IDUnreadU8 = ID(0xD0)
IDIsMarked = ID(0xD1) // TODO: obsolete; delete.
)
var builtInsByID = [nBuiltInIDs]string{
@@ -585,7 +584,6 @@ var builtInsByID = [nBuiltInIDs]string{
IDLowBits: "low_bits",
IDHighBits: "high_bits",
IDUnreadU8: "unread_u8",
IDIsMarked: "is_marked",
}
var builtInsByName = map[string]ID{}
+1 -11
View File
@@ -20,11 +20,6 @@ pri func decoder.decode_huffman_fast?(dst base.io_writer, src base.io_reader)()
// decode_huffman_*.wuffs files as small as possible, while retaining both
// correctness and performance.
// TODO: make this a func pre-condition.
if not in.dst.is_marked() {
return error "bad argument"
}
if (this.n_bits >= 8) or ((this.bits >> this.n_bits) != 0) {
return error "internal error: inconsistent n_bits"
}
@@ -64,9 +59,7 @@ pri func decoder.decode_huffman_fast?(dst base.io_writer, src base.io_reader)()
// for each. There are also up to 13 extra bits, or 2 bytes. Thus, each
// code requires up to 2 + 2 + 2 == 6 bytes, and there are two codes (one
// from H-L and one from H-D). Therefore, we check for at least 12 bytes.
while:loop(in.dst.available() >= 258) and (in.src.available() >= 12),
inv in.dst.is_marked(),
{
while:loop(in.dst.available() >= 258) and (in.src.available() >= 12) {
// Ensure that we have at least 15 bits of input.
if n_bits < 15 {
assert n_bits >= 0 // TODO: this shouldn't be necessary.
@@ -278,7 +271,6 @@ pri func decoder.decode_huffman_fast?(dst base.io_writer, src base.io_reader)()
while true,
pre length <= 258,
pre in.dst.available() >= 258,
inv in.dst.is_marked(),
{
// Copy from this.history.
if ((dist_minus_1 + 1) as base.u64) > in.dst.since_mark().length() {
@@ -322,7 +314,6 @@ pri func decoder.decode_huffman_fast?(dst base.io_writer, src base.io_reader)()
while true,
inv length <= 258,
inv in.dst.available() >= 258,
inv in.dst.is_marked(),
{
// TODO: copy_from_slice32 should probably update the
// "in.dst.available() >= 258" fact. It should certainly
@@ -350,7 +341,6 @@ pri func decoder.decode_huffman_fast?(dst base.io_writer, src base.io_reader)()
assert length <= 258
assert ((dist_minus_1 + 1) as base.u64) <= in.dst.since_mark().length()
assert in.dst.available() >= 258
assert in.dst.is_marked()
// We can therefore prove:
assert (dist_minus_1 + 1) > 0