1 /* |
1 /* |
2 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
300 OptionValues options = new OptionValues(getInitialOptions(), DefaultLoopPolicies.Options.UnrollMaxIterations, 2); |
300 OptionValues options = new OptionValues(getInitialOptions(), DefaultLoopPolicies.Options.UnrollMaxIterations, 2); |
301 StructuredGraph graph = parse(builder(method, StructuredGraph.AllowAssumptions.YES, id, options), getEagerGraphBuilderSuite()); |
301 StructuredGraph graph = parse(builder(method, StructuredGraph.AllowAssumptions.YES, id, options), getEagerGraphBuilderSuite()); |
302 try (DebugContext.Scope buildScope = graph.getDebug().scope(name, method, graph)) { |
302 try (DebugContext.Scope buildScope = graph.getDebug().scope(name, method, graph)) { |
303 MidTierContext context = new MidTierContext(getProviders(), getTargetProvider(), OptimisticOptimizations.ALL, null); |
303 MidTierContext context = new MidTierContext(getProviders(), getTargetProvider(), OptimisticOptimizations.ALL, null); |
304 |
304 |
305 CanonicalizerPhase canonicalizer = new CanonicalizerPhase(); |
305 CanonicalizerPhase canonicalizer = this.createCanonicalizerPhase(); |
306 canonicalizer.apply(graph, context); |
306 canonicalizer.apply(graph, context); |
307 new RemoveValueProxyPhase().apply(graph); |
307 new RemoveValueProxyPhase().apply(graph); |
308 new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context); |
308 new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context); |
309 new FloatingReadPhase().apply(graph); |
309 new FloatingReadPhase().apply(graph); |
310 new DeadCodeEliminationPhase().apply(graph); |
310 new DeadCodeEliminationPhase().apply(graph); |
336 |
336 |
337 public void testDuplicateBody(String reference, String test) { |
337 public void testDuplicateBody(String reference, String test) { |
338 |
338 |
339 StructuredGraph referenceGraph = buildGraph(reference, false); |
339 StructuredGraph referenceGraph = buildGraph(reference, false); |
340 StructuredGraph testGraph = buildGraph(test, true); |
340 StructuredGraph testGraph = buildGraph(test, true); |
341 CanonicalizerPhase canonicalizer = new CanonicalizerPhase(); |
341 CanonicalizerPhase canonicalizer = createCanonicalizerPhase(); |
342 canonicalizer.apply(testGraph, getDefaultMidTierContext()); |
342 canonicalizer.apply(testGraph, getDefaultMidTierContext()); |
343 canonicalizer.apply(referenceGraph, getDefaultMidTierContext()); |
343 canonicalizer.apply(referenceGraph, getDefaultMidTierContext()); |
344 assertEquals(referenceGraph, testGraph); |
344 assertEquals(referenceGraph, testGraph); |
345 } |
345 } |
346 } |
346 } |