Esempio n. 1
0
 public void updateJob(ApplicationInfo appInfo, CIJob job) throws PhrescoException {
   if (debugEnabled) {
     S_LOGGER.debug(
         "Entering Method ProjectAdministratorImpl.updateJob(Project project, CIJob job)");
   }
   FileWriter writer = null;
   try {
     CIJobStatus jobStatus = configureJob(job, FrameworkConstants.CI_UPDATE_JOB_COMMAND);
     if (jobStatus.getCode() == -1) {
       throw new PhrescoException(jobStatus.getMessage());
     }
     if (debugEnabled) {
       S_LOGGER.debug("getCustomModules() ProjectInfo = " + appInfo);
     }
     updateJsonJob(appInfo, job);
   } catch (ClientHandlerException ex) {
     if (debugEnabled) {
       S_LOGGER.error(ex.getLocalizedMessage());
     }
     throw new PhrescoException(ex);
   } finally {
     if (writer != null) {
       try {
         writer.close();
       } catch (IOException e) {
         if (debugEnabled) {
           S_LOGGER.error(e.getLocalizedMessage());
         }
       }
     }
   }
 }
 /**
  * Create an Internet shortcut
  *
  * @param name name of the shortcut
  * @param where location of the shortcut
  * @param target URL
  * @param icon URL (ex. http://www.server.com/favicon.ico)
  */
 public static void createInternetShortcut(String name, String where, String target, String icon) {
   try (FileWriter fw = new FileWriter(where)) {
     fw.write("[InternetShortcut]\n");
     fw.write("URL=" + target + '\n');
     if (!icon.isEmpty()) fw.write("IconFile=" + icon + '\n');
   } catch (IOException iox) {
     /**/
   }
 }
  private static void writeCommandFile() {
    LineNumberReader inputReader = getInputReader();

    String output = generateCommands(inputReader);
    FileWriter commandOutput = getCommandWriter();
    try {
      commandOutput.write(output, 0, output.length());
      commandOutput.close();
    } catch (IOException e) {
      throw new RuntimeException("Could not output generated commands");
    }
    System.out.println("Goals generated");
  }
 /**
  * Write a single string to the assembler source file.
  *
  * @param String s The string to be written
  */
 private static void emit(String s) {
   try {
     out.write(s, 0, s.length());
   } catch (IOException e) {
     throw new Error(e);
   }
 }
  /**
   * This function performs the testing for a particular format indicated by the format string. It
   * subsequently sets up appropriate input and output streams for the format test, performs the
   * test, and the compares the test results to the goals. If the goals differ from the actual
   * results the test fails.
   *
   * @return false if any tests fail.
   */
  private static boolean execute() {
    LineNumberReader commandReader = getCommands();
    String output = performTest(commandReader);

    if (output == null) { // no errors
      return true;
    } else {
      FileWriter diffsOutput = getDiffsOutputWriter();
      try {
        diffsOutput.write(output, 0, output.length());
        diffsOutput.close();
      } catch (IOException e) {
        throw new RuntimeException("Could not output generated diffs");
      }
      return false;
    }
  }
Esempio n. 6
0
 private void writeJsonJobs(ApplicationInfo appInfo, List<CIJob> jobs, String status)
     throws PhrescoException {
   try {
     if (jobs == null) {
       return;
     }
     Gson gson = new Gson();
     List<CIJob> existingJobs = getJobs(appInfo);
     if (CI_CREATE_NEW_JOBS.equals(status) || existingJobs == null) {
       existingJobs = new ArrayList<CIJob>();
     }
     existingJobs.addAll(jobs);
     FileWriter writer = null;
     File ciJobFile = new File(getCIJobPath(appInfo));
     String jobJson = gson.toJson(existingJobs);
     writer = new FileWriter(ciJobFile);
     writer.write(jobJson);
     writer.flush();
   } catch (Exception e) {
     throw new PhrescoException(e);
   }
 }
Esempio n. 7
0
 private boolean adaptExistingJobs(ApplicationInfo appInfo) {
   try {
     CIJob existJob = getJob(appInfo);
     S_LOGGER.debug("Going to get existing jobs to relocate!!!!!");
     if (existJob != null) {
       S_LOGGER.debug("Existing job found " + existJob.getName());
       boolean deleteExistJob = deleteCIJobFile(appInfo);
       Gson gson = new Gson();
       List<CIJob> existingJobs = new ArrayList<CIJob>();
       existingJobs.addAll(Arrays.asList(existJob));
       FileWriter writer = null;
       File ciJobFile = new File(getCIJobPath(appInfo));
       String jobJson = gson.toJson(existingJobs);
       writer = new FileWriter(ciJobFile);
       writer.write(jobJson);
       writer.flush();
       S_LOGGER.debug("Existing job moved to new type of project!!");
     }
     return true;
   } catch (Exception e) {
     S_LOGGER.debug("It is already adapted !!!!! ");
   }
   return false;
 }
  /** Generate an assembler for the opt compiler */
  public static void main(String[] args) {
    try {
      out = new FileWriter(System.getProperty("generateToDir") + "/AssemblerOpt.java");
    } catch (IOException e) {
      throw new Error(e);
    }

    emit("package org.jikesrvm.compilers.opt.mir2mc.ia32;\n\n");
    emit("import org.jikesrvm.*;\n\n");
    emit("import org.jikesrvm.compilers.opt.*;\n\n");
    emit("import org.jikesrvm.compilers.opt.ir.*;\n\n");
    emit("import org.jikesrvm.compilers.opt.ir.ia32.*;\n\n");
    emit("import static org.jikesrvm.compilers.opt.ir.ia32.ArchOperators.*;\n\n");
    emit("import static org.jikesrvm.compilers.opt.OptimizingCompilerException.opt_assert;\n\n");
    emit("\n\n");

    emit("/**\n");
    emit(" *  This class is the automatically-generated assembler for\n");
    emit(" * the optimizing compiler.  It consists of methods that\n");
    emit(" * understand the possible operand combinations of each\n");
    emit(" * instruction type, and how to translate those operands to\n");
    emit(" * calls to the Assember low-level emit method\n");
    emit(" *\n");
    emit(" * It is generated by GenerateAssembler.java\n");
    emit(" *\n");
    emit(" */\n");
    emit("public class AssemblerOpt extends AssemblerBase {\n\n");

    emitTab(1);
    emit("/**\n");
    emitTab(1);
    emit(" * @see org.jikesrvm.ArchitectureSpecific.Assembler\n");
    emitTab(1);
    emit(" */\n");
    emitTab(1);
    emit("public AssemblerOpt(int bcSize, boolean print, IR ir) {\n");
    emitTab(2);
    emit("super(bcSize, print, ir);\n");
    emitTab(1);
    emit("}");
    emit("\n\n");

    Method[] emitters = lowLevelAsm.getDeclaredMethods();
    Set<String> opcodes = getOpcodes(emitters);

    Iterator<String> i = opcodes.iterator();
    while (i.hasNext()) {
      String opcode = (String) i.next();
      setCurrentOpcode(opcode);
      emitTab(1);
      emit("/**\n");
      emitTab(1);
      emit(" *  Emit the given instruction, assuming that\n");
      emitTab(1);
      emit(" * it is a " + currentFormat + " instruction\n");
      emitTab(1);
      emit(" * and has a " + currentOpcode + " operator\n");
      emitTab(1);
      emit(" *\n");
      emitTab(1);
      emit(" * @param inst the instruction to assemble\n");
      emitTab(1);
      emit(" */\n");
      emitTab(1);
      emit("private void do" + opcode + "(Instruction inst) {\n");
      EmitterSet emitter = buildSetForOpcode(emitters, opcode);
      boolean[][] tp = new boolean[4][ArgumentType.values().length];
      emitter.emitSet(opcode, tp, 2);
      emitTab(1);
      emit("}\n\n");
    }

    emitTab(1);
    emit("/**\n");
    emitTab(1);
    emit(" *  The number of instructions emitted so far\n");
    emitTab(1);
    emit(" */\n");
    emitTab(1);
    emit("private int instructionCount = 0;\n\n");

    emitTab(1);
    emit("/**\n");
    emitTab(1);
    emit(" *  Assemble the given instruction\n");
    emitTab(1);
    emit(" *\n");
    emitTab(1);
    emit(" * @param inst the instruction to assemble\n");
    emitTab(1);
    emit(" */\n");
    emitTab(1);
    emit("public void doInst(Instruction inst) {\n");
    emitTab(2);
    emit("instructionCount++;\n");
    emitTab(2);
    emit("resolveForwardReferences(instructionCount);\n");
    emitTab(2);
    emit("switch (inst.getOpcode()) {\n");

    Set<String> emittedOpcodes = new HashSet<String>();

    i = opcodes.iterator();
    while (i.hasNext()) {
      String opcode = i.next();
      Iterator<String> operators = getMatchingOperators(opcode).iterator();
      while (operators.hasNext()) {
        String operator = operators.next();
        emitTab(3);
        emittedOpcodes.add(operator);
        emit("case IA32_" + operator + "_opcode:\n");
      }
      emitTab(4);
      emit("do" + opcode + "(inst);\n");
      emitTab(4);
      emit("break;\n");
    }

    // Special case because doJCC is handwritten to add
    // logic for short-forward branches
    emittedOpcodes.add("JCC");
    emitTab(3);
    emit("case IA32_JCC_opcode:\n");
    emitTab(4);
    emit("doJCC(inst);\n");
    emitTab(4);
    emit("break;\n");

    // Special case because doJMP is handwritten to add
    // logic for short-forward branches
    emittedOpcodes.add("JMP");
    emitTab(3);
    emit("case IA32_JMP_opcode:\n");
    emitTab(4);
    emit("doJMP(inst);\n");
    emitTab(4);
    emit("break;\n");

    // Kludge for IA32_LOCK which needs to call emitLockNextInstruction
    emittedOpcodes.add("LOCK");
    emitTab(3);
    emit("case IA32_LOCK_opcode:\n");
    emitTab(4);
    emit("emitLockNextInstruction();\n");
    emitTab(4);
    emit("break;\n");

    // Kludge for PATCH_POINT
    emitTab(3);
    emit("case IG_PATCH_POINT_opcode:\n");
    emitTab(4);
    emit("emitPatchPoint();\n");
    emitTab(4);
    emit("break;\n");

    // Kludge for LOWTABLESWITCH
    emitTab(3);
    emit("case MIR_LOWTABLESWITCH_opcode:\n");
    emitTab(4);
    emit("doLOWTABLESWITCH(inst);\n");
    emitTab(4);
    emit("// kludge table switches that are unusually long instructions\n");
    emitTab(4);
    emit("instructionCount += MIR_LowTableSwitch.getNumberOfTargets(inst);\n");
    emitTab(4);
    emit("break;\n");

    Set<String> errorOpcodes = getErrorOpcodes(emittedOpcodes);
    if (!errorOpcodes.isEmpty()) {
      i = errorOpcodes.iterator();
      while (i.hasNext()) {
        emitTab(3);
        emit("case IA32_" + i.next() + "_opcode:\n");
      }
      emitTab(4);
      emit(
          "throw new OptimizingCompilerException(inst + \" has unimplemented IA32 opcode (check excludedOpcodes)\");\n");
    }

    emitTab(2);
    emit("}\n");
    emitTab(2);
    emit("inst.setmcOffset( mi );\n");
    emitTab(1);
    emit("}\n\n");

    emit("\n}\n");

    try {
      out.close();
    } catch (IOException e) {
      throw new Error(e);
    }
  }