Skip to content

Commit

Permalink
DREAMWEB: Re-optimize unbounded code blocks
Browse files Browse the repository at this point in the history
This gets rid of some unused labels. We need to be careful
not be optimize too much, as that could remove the very label
the unbounded block was added for.
  • Loading branch information
wjp committed Jun 16, 2011
1 parent 2c76a4a commit ae67a9a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
2 changes: 2 additions & 0 deletions devtools/tasmrecover/tasm/cpp.py
Expand Up @@ -483,6 +483,8 @@ def __proc(self, name, def_skip = 0):
self.proc.stmts.append(s)
self.proc.add("ret")
print "skipping %d instructions, todo: %d" %(start, len(self.proc.stmts) - start)
print "re-optimizing..."
self.proc.optimize(keep_labels=[label])
self.proc.visit(self, start)
self.body += "}\n";
self.translated.insert(0, self.body)
Expand Down
4 changes: 2 additions & 2 deletions devtools/tasmrecover/tasm/proc.py
Expand Up @@ -66,7 +66,7 @@ def optimize_sequence(self, cls):
i += 1
return

def optimize(self):
def optimize(self, keep_labels=[]):
print "optimizing..."
#trivial simplifications
while len(self.stmts) and isinstance(self.stmts[-1], op.label):
Expand Down Expand Up @@ -109,7 +109,7 @@ def optimize(self):
if not isinstance(s, op.label):
continue
print "checking label %s..." %s.name
used = False
used = s.name in keep_labels
if s.name not in self.retlabels:
for j in self.stmts:
if isinstance(j, op.basejmp) and j.label == s.name:
Expand Down
12 changes: 1 addition & 11 deletions engines/dreamweb/dreamgen.cpp
Expand Up @@ -3984,11 +3984,8 @@ void lockeddoorway(Context &context) {
context.ds.byte(context.di+17) = context.al;
context._cmp(context.cl, 5);
if (!context.flags.z())
goto notnearly;
return /* (notnearly) */;
context.data.byte(kThroughdoor) = 0;
notnearly:
return;
return;
}

void updatepeople(Context &context) {
Expand Down Expand Up @@ -7343,12 +7340,6 @@ void inventory(Context &context) {
justgetback:
context.data.byte(kInvopen) = 0;
context.data.byte(kOpenedob) = 255;
return;
examlist:
invlist1:
openchangesize:
withlist1:
return;
}

void setpickup(Context &context) {
Expand Down Expand Up @@ -13731,7 +13722,6 @@ void useaxe(Context &context) {
context.data.byte(kWatchspeed) = 1;
context.data.byte(kSpeedcount) = 1;
context.data.byte(kGetback) = 1;
return;
}

void useelvdoor(Context &context) {
Expand Down

0 comments on commit ae67a9a

Please sign in to comment.