comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java @ 15372:2cea065e419d

Truffle: print the source section in the rewrite trace.
author Chris Seaton <chris.seaton@oracle.com>
date Thu, 24 Apr 2014 23:29:28 +0100
parents 1cd02b4d90d1
children dd624471bd30
comparison
equal deleted inserted replaced
15371:c54f5fa05fd5 15372:2cea065e419d
338 traceRewrite(newNode, reason); 338 traceRewrite(newNode, reason);
339 } 339 }
340 } 340 }
341 341
342 private void traceRewrite(Node newNode, CharSequence reason) { 342 private void traceRewrite(Node newNode, CharSequence reason) {
343
344 if (TruffleOptions.TraceRewritesFilterFromCost != null) { 343 if (TruffleOptions.TraceRewritesFilterFromCost != null) {
345 if (filterByKind(this, TruffleOptions.TraceRewritesFilterFromCost)) { 344 if (filterByKind(this, TruffleOptions.TraceRewritesFilterFromCost)) {
346 return; 345 return;
347 } 346 }
348 } 347 }
358 Class<? extends Node> to = newNode.getClass(); 357 Class<? extends Node> to = newNode.getClass();
359 if (filter != null && (filterByContainsClassName(from, filter) || filterByContainsClassName(to, filter))) { 358 if (filter != null && (filterByContainsClassName(from, filter) || filterByContainsClassName(to, filter))) {
360 return; 359 return;
361 } 360 }
362 361
362 final SourceSection reportedSourceSection = getEncapsulatingSourceSection();
363
363 PrintStream out = System.out; 364 PrintStream out = System.out;
364 out.printf("[truffle] rewrite %-50s |From %-40s |To %-40s |Reason %s.%n", this.toString(), formatNodeInfo(this), formatNodeInfo(newNode), reason); 365 out.printf("[truffle] rewrite %-50s |From %-40s |To %-40s |Reason %s%s%n", this.toString(), formatNodeInfo(this), formatNodeInfo(newNode), reason != null && reason.length() > 0 ? reason
366 : "unknown", reportedSourceSection != null ? " at " + reportedSourceSection.getShortDescription() : "");
365 } 367 }
366 368
367 /** 369 /**
368 * Subclasses of {@link Node} can implement this method to execute extra functionality when a 370 * Subclasses of {@link Node} can implement this method to execute extra functionality when a
369 * node is effectively inserted into the AST. The {@code onAdopt} callback is called after the 371 * node is effectively inserted into the AST. The {@code onAdopt} callback is called after the