< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core/src/org/graalvm/compiler/core/CompilationWrapper.java

Print this page
rev 56282 : [mq]: graal
   1 /*
   2  * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 
  25 package org.graalvm.compiler.core;
  26 
  27 import static org.graalvm.compiler.core.CompilationWrapper.ExceptionAction.ExitVM;
  28 import static org.graalvm.compiler.core.GraalCompilerOptions.CompilationBailoutAsFailure;
  29 import static org.graalvm.compiler.core.GraalCompilerOptions.CompilationFailureAction;
  30 import static org.graalvm.compiler.core.GraalCompilerOptions.ExitVMOnException;
  31 import static org.graalvm.compiler.core.GraalCompilerOptions.MaxCompilationProblemsPerAction;

  32 import static org.graalvm.compiler.debug.DebugContext.VERBOSE_LEVEL;
  33 import static org.graalvm.compiler.debug.DebugOptions.Dump;
  34 import static org.graalvm.compiler.debug.DebugOptions.DumpPath;
  35 import static org.graalvm.compiler.debug.DebugOptions.MethodFilter;
  36 
  37 import java.io.ByteArrayOutputStream;
  38 import java.io.File;
  39 import java.io.FileOutputStream;
  40 import java.io.IOException;
  41 import java.io.PrintStream;
  42 import java.util.Map;
  43 
  44 import org.graalvm.compiler.debug.DebugContext;
  45 import org.graalvm.compiler.debug.DiagnosticsOutputDirectory;
  46 import org.graalvm.compiler.debug.PathUtilities;
  47 import org.graalvm.compiler.debug.TTY;
  48 import org.graalvm.compiler.options.OptionValues;
  49 
  50 import jdk.vm.ci.code.BailoutException;
  51 


 257                         ps.println("Not retrying compilation of " + this + " as the dump path could not be created.");
 258                     }
 259                     message = baos.toString();
 260                 }
 261 
 262                 TTY.print(message);
 263                 if (dumpPath == null) {
 264                     return handleException(cause);
 265                 }
 266 
 267                 File retryLogFile = new File(dumpPath, "retry.log");
 268                 try (PrintStream ps = new PrintStream(new FileOutputStream(retryLogFile))) {
 269                     ps.print(message);
 270                 } catch (IOException ioe) {
 271                     TTY.printf("Error writing to %s: %s%n", retryLogFile, ioe);
 272                 }
 273 
 274                 OptionValues retryOptions = new OptionValues(initialOptions,
 275                                 Dump, ":" + VERBOSE_LEVEL,
 276                                 MethodFilter, null,
 277                                 DumpPath, dumpPath.getPath());

 278 
 279                 ByteArrayOutputStream logBaos = new ByteArrayOutputStream();
 280                 PrintStream ps = new PrintStream(logBaos);
 281                 try (DebugContext retryDebug = createRetryDebugContext(initialDebug, retryOptions, ps)) {
 282                     T res = performCompilation(retryDebug);
 283                     ps.println("There was no exception during retry.");
 284                     maybeExitVM(action);
 285                     return res;
 286                 } catch (Throwable e) {
 287                     ps.println("Exception during retry:");
 288                     e.printStackTrace(ps);
 289                     // Failures during retry are silent
 290                     T res = handleException(cause);
 291                     maybeExitVM(action);
 292                     return res;
 293                 } finally {
 294                     ps.close();
 295                     try (FileOutputStream fos = new FileOutputStream(retryLogFile, true)) {
 296                         fos.write(logBaos.toByteArray());
 297                     } catch (Throwable e) {


   1 /*
   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.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 
  25 package org.graalvm.compiler.core;
  26 
  27 import static org.graalvm.compiler.core.CompilationWrapper.ExceptionAction.ExitVM;
  28 import static org.graalvm.compiler.core.GraalCompilerOptions.CompilationBailoutAsFailure;
  29 import static org.graalvm.compiler.core.GraalCompilerOptions.CompilationFailureAction;
  30 import static org.graalvm.compiler.core.GraalCompilerOptions.ExitVMOnException;
  31 import static org.graalvm.compiler.core.GraalCompilerOptions.MaxCompilationProblemsPerAction;
  32 import static org.graalvm.compiler.core.common.GraalOptions.TrackNodeSourcePosition;
  33 import static org.graalvm.compiler.debug.DebugContext.VERBOSE_LEVEL;
  34 import static org.graalvm.compiler.debug.DebugOptions.Dump;
  35 import static org.graalvm.compiler.debug.DebugOptions.DumpPath;
  36 import static org.graalvm.compiler.debug.DebugOptions.MethodFilter;
  37 
  38 import java.io.ByteArrayOutputStream;
  39 import java.io.File;
  40 import java.io.FileOutputStream;
  41 import java.io.IOException;
  42 import java.io.PrintStream;
  43 import java.util.Map;
  44 
  45 import org.graalvm.compiler.debug.DebugContext;
  46 import org.graalvm.compiler.debug.DiagnosticsOutputDirectory;
  47 import org.graalvm.compiler.debug.PathUtilities;
  48 import org.graalvm.compiler.debug.TTY;
  49 import org.graalvm.compiler.options.OptionValues;
  50 
  51 import jdk.vm.ci.code.BailoutException;
  52 


 258                         ps.println("Not retrying compilation of " + this + " as the dump path could not be created.");
 259                     }
 260                     message = baos.toString();
 261                 }
 262 
 263                 TTY.print(message);
 264                 if (dumpPath == null) {
 265                     return handleException(cause);
 266                 }
 267 
 268                 File retryLogFile = new File(dumpPath, "retry.log");
 269                 try (PrintStream ps = new PrintStream(new FileOutputStream(retryLogFile))) {
 270                     ps.print(message);
 271                 } catch (IOException ioe) {
 272                     TTY.printf("Error writing to %s: %s%n", retryLogFile, ioe);
 273                 }
 274 
 275                 OptionValues retryOptions = new OptionValues(initialOptions,
 276                                 Dump, ":" + VERBOSE_LEVEL,
 277                                 MethodFilter, null,
 278                                 DumpPath, dumpPath.getPath(),
 279                                 TrackNodeSourcePosition, true);
 280 
 281                 ByteArrayOutputStream logBaos = new ByteArrayOutputStream();
 282                 PrintStream ps = new PrintStream(logBaos);
 283                 try (DebugContext retryDebug = createRetryDebugContext(initialDebug, retryOptions, ps)) {
 284                     T res = performCompilation(retryDebug);
 285                     ps.println("There was no exception during retry.");
 286                     maybeExitVM(action);
 287                     return res;
 288                 } catch (Throwable e) {
 289                     ps.println("Exception during retry:");
 290                     e.printStackTrace(ps);
 291                     // Failures during retry are silent
 292                     T res = handleException(cause);
 293                     maybeExitVM(action);
 294                     return res;
 295                 } finally {
 296                     ps.close();
 297                     try (FileOutputStream fos = new FileOutputStream(retryLogFile, true)) {
 298                         fos.write(logBaos.toByteArray());
 299                     } catch (Throwable e) {


< prev index next >