Mercurial > hg > truffle
comparison 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 |
comparison
equal
deleted
inserted
replaced
21518:c2e58b2a2a76 | 21519:cecb4e39521c |
---|---|
25 #define SHARE_VM_GRAAL_GRAAL_RUNTIME_HPP | 25 #define SHARE_VM_GRAAL_GRAAL_RUNTIME_HPP |
26 | 26 |
27 #include "interpreter/interpreter.hpp" | 27 #include "interpreter/interpreter.hpp" |
28 #include "memory/allocation.hpp" | 28 #include "memory/allocation.hpp" |
29 #include "runtime/deoptimization.hpp" | 29 #include "runtime/deoptimization.hpp" |
30 #include "graal/graalOptions.hpp" | |
30 | 31 |
31 class ParseClosure : public StackObj { | 32 class ParseClosure : public StackObj { |
32 protected: | |
33 int _lineNo; | 33 int _lineNo; |
34 char* _filename; | 34 char* _filename; |
35 bool _abort; | 35 bool _abort; |
36 protected: | |
36 void abort() { _abort = true; } | 37 void abort() { _abort = true; } |
37 void warn_and_abort(const char* message) { | 38 void warn_and_abort(const char* message) { |
39 warn(message); | |
40 abort(); | |
41 } | |
42 void warn(const char* message) { | |
38 warning("Error at line %d while parsing %s: %s", _lineNo, _filename == NULL ? "?" : _filename, message); | 43 warning("Error at line %d while parsing %s: %s", _lineNo, _filename == NULL ? "?" : _filename, message); |
39 abort(); | |
40 } | 44 } |
41 public: | 45 public: |
42 ParseClosure() : _lineNo(0), _filename(NULL) {} | 46 ParseClosure() : _lineNo(0), _filename(NULL), _abort(false) {} |
43 void parse_line(char* line) { | 47 void parse_line(char* line) { |
44 _lineNo++; | 48 _lineNo++; |
45 do_line(line); | 49 do_line(line); |
46 } | 50 } |
47 virtual void do_line(char* line) = 0; | 51 virtual void do_line(char* line) = 0; |
48 int lineNo() { return _lineNo; } | 52 int lineNo() { return _lineNo; } |
49 bool is_aborted() { return _abort; } | 53 bool is_aborted() { return _abort; } |
50 void set_filename(char* path) {_filename = path; } | 54 void set_filename(char* path) {_filename = path; _lineNo = 0;} |
51 }; | 55 }; |
52 | 56 |
57 class GraalOptionParseClosure; | |
58 | |
53 class GraalRuntime: public CHeapObj<mtCompiler> { | 59 class GraalRuntime: public CHeapObj<mtCompiler> { |
60 friend GraalOptionParseClosure; | |
54 private: | 61 private: |
55 | 62 |
56 static jobject _HotSpotGraalRuntime_instance; | 63 static jobject _HotSpotGraalRuntime_instance; |
57 static bool _HotSpotGraalRuntime_initialized; | 64 static bool _HotSpotGraalRuntime_initialized; |
58 static const char* _generated_sources_sha1; | |
59 | 65 |
60 static bool _shutdown_called; | 66 static bool _shutdown_called; |
61 | |
62 /** | |
63 * Reads the OptionValue object from a specified static field. | |
64 * | |
65 * @throws LinkageError if the field could not be resolved | |
66 */ | |
67 static Handle get_OptionValue(const char* declaringClass, const char* fieldName, const char* fieldSig, TRAPS); | |
68 | |
69 /** | |
70 * Parses the string form of a numeric, float or double option into a jlong (using raw bits for floats/doubles). | |
71 * | |
72 * @param spec 'i', 'f' or 'd' (see HotSpotOptions.setOption()) | |
73 * @param name option name | |
74 * @param name_len length of option name | |
75 * @param value string value to parse | |
76 * @throws InternalError if value could not be parsed according to spec | |
77 */ | |
78 static jlong parse_primitive_option_value(char spec, const char* name, size_t name_len, const char* value, TRAPS); | |
79 | 67 |
80 /** | 68 /** |
81 * Loads default option value overrides from a <jre_home>/lib/graal.options if it exists. Each | 69 * Loads default option value overrides from a <jre_home>/lib/graal.options if it exists. Each |
82 * line in this file must have the format of a Graal command line option without the | 70 * line in this file must have the format of a Graal command line option without the |
83 * leading "-G:" prefix. These option values are set prior to processing of any Graal | 71 * leading "-G:" prefix. These option values are set prior to processing of any Graal |
84 * options present on the command line. | 72 * options present on the command line. |
85 */ | 73 */ |
86 static void parse_graal_options_file(KlassHandle hotSpotOptionsClass, TRAPS); | 74 static void parse_graal_options_file(OptionsValueTable* options); |
87 | 75 |
88 /** | 76 static bool parse_argument(OptionsValueTable* options, const char* arg); |
89 * Searches for a Boolean Graal option denoted by a given name and sets it value. | 77 |
90 * | 78 static void print_flags_helper(TRAPS); |
91 * The definition of this method is in graalRuntime.inline.hpp | |
92 * which is generated by com.oracle.graal.hotspot.sourcegen.GenGraalRuntimeInlineHpp. | |
93 * | |
94 * @param hotSpotOptionsClass the HotSpotOptions klass or NULL if only checking for valid option | |
95 * @param name option name | |
96 * @param name_len length of option name | |
97 * @param value '+' to set the option, '-' to reset the option | |
98 * @returns true if the option was found | |
99 * @throws InternalError if there was a problem setting the option's value | |
100 */ | |
101 static bool set_option_bool(KlassHandle hotSpotOptionsClass, char* name, size_t name_len, char value, TRAPS); | |
102 | |
103 /** | |
104 * Searches for a Graal option denoted by a given name and sets it value. | |
105 * | |
106 * The definition of this method is in graalRuntime.inline.hpp | |
107 * which is generated by com.oracle.graal.hotspot.sourcegen.GenGraalRuntimeInlineHpp. | |
108 * | |
109 * @param hotSpotOptionsClass the HotSpotOptions klass or NULL if only checking for valid option | |
110 * @param name option name | |
111 * @param name_len length of option name | |
112 * @returns true if the option was found | |
113 * @throws InternalError if there was a problem setting the option's value | |
114 */ | |
115 static bool set_option(KlassHandle hotSpotOptionsClass, char* name, size_t name_len, const char* value, TRAPS); | |
116 | |
117 /** | |
118 * Raises an InternalError for an option that expects a value but was specified without a "=<value>" prefix. | |
119 */ | |
120 static void check_required_value(const char* name, size_t name_len, const char* value, TRAPS); | |
121 | |
122 /** | |
123 * Java call to HotSpotOptions.setOption(String name, OptionValue<?> option, char spec, String stringValue, long primitiveValue) | |
124 * | |
125 * @param name option name | |
126 * @param name_len length of option name | |
127 */ | |
128 static void set_option_helper(KlassHandle hotSpotOptionsClass, char* name, size_t name_len, Handle option, jchar spec, Handle stringValue, jlong primitiveValue); | |
129 | |
130 /** | 79 /** |
131 * Instantiates a service object, calls its default constructor and returns it. | 80 * Instantiates a service object, calls its default constructor and returns it. |
132 * | 81 * |
133 * @param name the name of a class implementing com.oracle.graal.api.runtime.Service | 82 * @param name the name of a class implementing com.oracle.graal.api.runtime.Service |
134 */ | 83 */ |
135 static Handle create_Service(const char* name, TRAPS); | 84 static Handle create_Service(const char* name, TRAPS); |
136 | 85 |
137 /** | |
138 * Checks that _generated_sources_sha1 equals GeneratedSourcesSha1.value. | |
139 */ | |
140 static void check_generated_sources_sha1(TRAPS); | |
141 | |
142 public: | 86 public: |
143 | 87 |
144 /** | 88 /** |
145 * Parses a given argument and sets the denoted Graal option. | 89 * Parses the Graal specific VM options that were presented by the launcher and sets |
146 * | 90 * the relevants Java fields. |
147 * @throws InternalError if there was a problem parsing or setting the option | 91 */ |
148 */ | 92 static OptionsValueTable* parse_arguments(); |
149 static void parse_argument(KlassHandle hotSpotOptionsClass, char* arg, TRAPS); | 93 |
94 static void set_options(OptionsValueTable* options, TRAPS); | |
150 | 95 |
151 /** | 96 /** |
152 * Ensures that the Graal class loader is initialized and the well known Graal classes are loaded. | 97 * Ensures that the Graal class loader is initialized and the well known Graal classes are loaded. |
153 */ | 98 */ |
154 static void ensure_graal_class_loader_is_initialized(); | 99 static void ensure_graal_class_loader_is_initialized(); |
197 * The definition of this method is in graalRuntime.inline.hpp | 142 * The definition of this method is in graalRuntime.inline.hpp |
198 * which is generated by com.oracle.graal.hotspot.sourcegen.GenGraalRuntimeInlineHpp. | 143 * which is generated by com.oracle.graal.hotspot.sourcegen.GenGraalRuntimeInlineHpp. |
199 */ | 144 */ |
200 static Handle get_service_impls(KlassHandle serviceKlass, TRAPS); | 145 static Handle get_service_impls(KlassHandle serviceKlass, TRAPS); |
201 | 146 |
202 static void parse_lines(char* path, ParseClosure* closure, bool warnStatFailure, TRAPS); | 147 static void parse_lines(char* path, ParseClosure* closure, bool warnStatFailure); |
203 | 148 |
204 /** | 149 /** |
205 * Aborts the VM due to an unexpected exception. | 150 * Aborts the VM due to an unexpected exception. |
206 */ | 151 */ |
207 static void abort_on_pending_exception(Handle exception, const char* message, bool dump_core = false); | 152 static void abort_on_pending_exception(Handle exception, const char* message, bool dump_core = false); |
243 * Loads a given Graal class and aborts the VM if it fails. | 188 * Loads a given Graal class and aborts the VM if it fails. |
244 */ | 189 */ |
245 static Klass* load_required_class(Symbol* name); | 190 static Klass* load_required_class(Symbol* name); |
246 | 191 |
247 static BufferBlob* initialize_buffer_blob(); | 192 static BufferBlob* initialize_buffer_blob(); |
248 | |
249 /** | |
250 * Checks that all Graal specific VM options presented by the launcher are recognized | |
251 * and formatted correctly. To set relevant Java fields from the option, parse_arguments() | |
252 * must be called. This method makes no Java calls apart from creating exception objects | |
253 * if there is an errors in the Graal options. | |
254 */ | |
255 static jint check_arguments(TRAPS); | |
256 | |
257 /** | |
258 * Parses the Graal specific VM options that were presented by the launcher and sets | |
259 * the relevants Java fields. | |
260 */ | |
261 static bool parse_arguments(KlassHandle hotSpotOptionsClass, TRAPS); | |
262 | 193 |
263 static BasicType kindToBasicType(jchar ch); | 194 static BasicType kindToBasicType(jchar ch); |
264 | 195 |
265 // The following routines are all called from compiled Graal code | 196 // The following routines are all called from compiled Graal code |
266 | 197 |