Skip to content

Commit

Permalink
[GR-19493] More robust and informative graaljdk creation.
Browse files Browse the repository at this point in the history
PullRequest: graal/4869
  • Loading branch information
dougxc committed Nov 12, 2019
2 parents 16f4b04 + aa31acb commit 112bc91
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
25 changes: 18 additions & 7 deletions compiler/mx.compiler/mx_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def __exit__(self, exc_type, exc_value, traceback):
# Try delete the target directory if it existed prior to creating
# self.workspace and has not been modified in between.
if self.target_timestamp.timestamp is not None and self.target_timestamp.timestamp == mx.TimeStampFile(self.target).timestamp:
old_target = join(self.workspace, 'to_deleted_' + basename(self.target))
old_target = join(self.workspace, 'to_delete_' + basename(self.target))
try:
os.rename(self.target, old_target)
except:
Expand Down Expand Up @@ -1198,18 +1198,30 @@ def _update_graaljdk(src_jdk, dst_jdk_dir=None, root_module_names=None, export_t
# may have changed and we want to pick up these changes.
source_jdk_timestamps_file = dst_jdk_dir + '.source_jdk_timestamps'
timestamps = []
nl = os.linesep
for root, _, filenames in os.walk(jdk.home):
for name in filenames:
ts = mx.TimeStampFile(join(root, name))
timestamps.append(str(ts))
jdk_timestamps = os.linesep.join(timestamps)
timestamps = sorted(timestamps)
jdk_timestamps = nl.join(timestamps)
jdk_timestamps_outdated = False
if exists(source_jdk_timestamps_file):
with open(source_jdk_timestamps_file) as fp:
old_jdk_timestamps = fp.read()
if old_jdk_timestamps != jdk_timestamps:
update_reason = 'source JDK was updated'
with open(source_jdk_timestamps_file, 'w') as fp:
fp.write(jdk_timestamps)
jdk_timestamps_outdated = True
import difflib
old_timestamps = old_jdk_timestamps.split(nl)
diff = difflib.unified_diff(timestamps, old_timestamps, 'new_timestamps.txt', 'old_timestamps.txt')
update_reason = 'source JDK was updated as shown by following time stamps diff:{}{}'.format(nl, nl.join(diff))
else:
jdk_timestamps_outdated = True

if jdk_timestamps_outdated:
with mx.SafeFileCreation(source_jdk_timestamps_file) as sfc:
with open(sfc.tmpPath, 'w') as fp:
fp.write(jdk_timestamps)

jvmci_release_file = mx.TimeStampFile(join(dst_jdk_dir, 'release.jvmci'))
if update_reason is None:
Expand All @@ -1223,10 +1235,9 @@ def _update_graaljdk(src_jdk, dst_jdk_dir=None, root_module_names=None, export_t
if update_reason is None:
return dst_jdk_dir, False

mx.log('Updating/creating {} from {} since {}'.format(dst_jdk_dir, src_jdk.home, update_reason))

with SafeDirectoryUpdater(dst_jdk_dir) as sdu:
tmp_dst_jdk_dir = sdu.directory
mx.log('Updating/creating {} from {} using intermediate directory {} since {}'.format(dst_jdk_dir, src_jdk.home, tmp_dst_jdk_dir, update_reason))
def _copy_file(src, dst):
mx.log('Copying {} to {}'.format(src, dst))
shutil.copyfile(src, dst)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void hashMapTest() {
for (IfNode ifNode : lastCompiledGraph.getNodes(IfNode.TYPE)) {
LogicNode condition = ifNode.condition();
if (ifNode.getTrueSuccessorProbability() < 0.4 && condition instanceof ObjectEqualsNode) {
assertTrue(ifNode.trueSuccessor().next() instanceof ReturnNode, "Expected return.", ifNode.trueSuccessor(), ifNode.trueSuccessor().next());
assertTrue(ifNode.trueSuccessor().next() instanceof ReturnNode, "Expected return but got %s (trueSuccessor: %s)", ifNode.trueSuccessor().next(), ifNode.trueSuccessor());
}
}
}
Expand Down

0 comments on commit 112bc91

Please sign in to comment.