diff src/share/vm/graal/graalRuntime.hpp @ 21519:cecb4e39521c

Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Wed, 27 May 2015 17:40:26 +0200
parents fe4a77bec5b7
children b7ac67354c14
line wrap: on
line diff
--- a/src/share/vm/graal/graalRuntime.hpp	Mon May 18 18:30:43 2015 +0200
+++ b/src/share/vm/graal/graalRuntime.hpp	Wed May 27 17:40:26 2015 +0200
@@ -27,19 +27,23 @@
 #include "interpreter/interpreter.hpp"
 #include "memory/allocation.hpp"
 #include "runtime/deoptimization.hpp"
+#include "graal/graalOptions.hpp"
 
 class ParseClosure : public StackObj {
-protected:
   int _lineNo;
   char* _filename;
   bool _abort;
+protected:
   void abort() { _abort = true; }
   void warn_and_abort(const char* message) {
-    warning("Error at line %d while parsing %s: %s", _lineNo, _filename == NULL ? "?" : _filename, message);
+    warn(message);
     abort();
   }
+  void warn(const char* message) {
+    warning("Error at line %d while parsing %s: %s", _lineNo, _filename == NULL ? "?" : _filename, message);
+  }
  public:
-  ParseClosure() : _lineNo(0), _filename(NULL) {}
+  ParseClosure() : _lineNo(0), _filename(NULL), _abort(false) {}
   void parse_line(char* line) {
     _lineNo++;
     do_line(line);
@@ -47,86 +51,31 @@
   virtual void do_line(char* line) = 0;
   int lineNo() { return _lineNo; }
   bool is_aborted() { return _abort; }
-  void set_filename(char* path) {_filename = path; }
+  void set_filename(char* path) {_filename = path; _lineNo = 0;}
 };
 
+class GraalOptionParseClosure;
+
 class GraalRuntime: public CHeapObj<mtCompiler> {
+  friend GraalOptionParseClosure;
  private:
 
   static jobject _HotSpotGraalRuntime_instance;
   static bool _HotSpotGraalRuntime_initialized;
-  static const char* _generated_sources_sha1;
 
   static bool _shutdown_called;
 
   /**
-   * Reads the OptionValue object from a specified static field.
-   *
-   * @throws LinkageError if the field could not be resolved
-   */
-  static Handle get_OptionValue(const char* declaringClass, const char* fieldName, const char* fieldSig, TRAPS);
-
-  /**
-   * Parses the string form of a numeric, float or double option into a jlong (using raw bits for floats/doubles).
-   *
-   * @param spec 'i', 'f' or 'd' (see HotSpotOptions.setOption())
-   * @param name option name
-   * @param name_len length of option name
-   * @param value string value to parse
-   * @throws InternalError if value could not be parsed according to spec
-   */
-  static jlong parse_primitive_option_value(char spec, const char* name, size_t name_len, const char* value, TRAPS);
-
-  /**
    * Loads default option value overrides from a <jre_home>/lib/graal.options if it exists. Each
    * line in this file must have the format of a Graal command line option without the
    * leading "-G:" prefix. These option values are set prior to processing of any Graal
    * options present on the command line.
    */
-  static void parse_graal_options_file(KlassHandle hotSpotOptionsClass, TRAPS);
-
-  /**
-   * Searches for a Boolean Graal option denoted by a given name and sets it value.
-   *
-   * The definition of this method is in graalRuntime.inline.hpp
-   * which is generated by com.oracle.graal.hotspot.sourcegen.GenGraalRuntimeInlineHpp.
-   *
-   * @param hotSpotOptionsClass the HotSpotOptions klass or NULL if only checking for valid option
-   * @param name option name
-   * @param name_len length of option name
-   * @param value '+' to set the option, '-' to reset the option
-   * @returns true if the option was found
-   * @throws InternalError if there was a problem setting the option's value
-   */
-  static bool set_option_bool(KlassHandle hotSpotOptionsClass, char* name, size_t name_len, char value, TRAPS);
+  static void parse_graal_options_file(OptionsValueTable* options);
 
-  /**
-   * Searches for a Graal option denoted by a given name and sets it value.
-   *
-   * The definition of this method is in graalRuntime.inline.hpp
-   * which is generated by com.oracle.graal.hotspot.sourcegen.GenGraalRuntimeInlineHpp.
-   *
-   * @param hotSpotOptionsClass the HotSpotOptions klass or NULL if only checking for valid option
-   * @param name option name
-   * @param name_len length of option name
-   * @returns true if the option was found
-   * @throws InternalError if there was a problem setting the option's value
-   */
-  static bool set_option(KlassHandle hotSpotOptionsClass, char* name, size_t name_len, const char* value, TRAPS);
+  static bool parse_argument(OptionsValueTable* options, const char* arg);
 
-  /**
-   * Raises an InternalError for an option that expects a value but was specified without a "=<value>" prefix.
-   */
-  static void check_required_value(const char* name, size_t name_len, const char* value, TRAPS);
-
-  /**
-   * Java call to HotSpotOptions.setOption(String name, OptionValue<?> option, char spec, String stringValue, long primitiveValue)
-   *
-   * @param name option name
-   * @param name_len length of option name
-   */
-  static void set_option_helper(KlassHandle hotSpotOptionsClass, char* name, size_t name_len, Handle option, jchar spec, Handle stringValue, jlong primitiveValue);
-
+  static void print_flags_helper(TRAPS);
   /**
    * Instantiates a service object, calls its default constructor and returns it.
    *
@@ -134,19 +83,15 @@
    */
   static Handle create_Service(const char* name, TRAPS);
 
-  /**
-   * Checks that _generated_sources_sha1 equals GeneratedSourcesSha1.value.
-   */
-  static void check_generated_sources_sha1(TRAPS);
-
  public:
 
   /**
-   * Parses a given argument and sets the denoted Graal option.
-   *
-   * @throws InternalError if there was a problem parsing or setting the option
+   * Parses the Graal specific VM options that were presented by the launcher and sets
+   * the relevants Java fields.
    */
-  static void parse_argument(KlassHandle hotSpotOptionsClass, char* arg, TRAPS);
+  static OptionsValueTable* parse_arguments();
+
+  static void set_options(OptionsValueTable* options, TRAPS);
 
   /**
    * Ensures that the Graal class loader is initialized and the well known Graal classes are loaded.
@@ -199,7 +144,7 @@
    */
   static Handle get_service_impls(KlassHandle serviceKlass, TRAPS);
 
-  static void parse_lines(char* path, ParseClosure* closure, bool warnStatFailure, TRAPS);
+  static void parse_lines(char* path, ParseClosure* closure, bool warnStatFailure);
 
   /**
    * Aborts the VM due to an unexpected exception.
@@ -246,20 +191,6 @@
 
   static BufferBlob* initialize_buffer_blob();
 
-  /**
-   * Checks that all Graal specific VM options presented by the launcher are recognized
-   * and formatted correctly. To set relevant Java fields from the option, parse_arguments()
-   * must be called. This method makes no Java calls apart from creating exception objects
-   * if there is an errors in the Graal options.
-   */
-  static jint check_arguments(TRAPS);
-
-  /**
-   * Parses the Graal specific VM options that were presented by the launcher and sets
-   * the relevants Java fields.
-   */
-  static bool parse_arguments(KlassHandle hotSpotOptionsClass, TRAPS);
-
   static BasicType kindToBasicType(jchar ch);
 
   // The following routines are all called from compiled Graal code