Mercurial > hg > graal-compiler
comparison src/share/vm/graal/graalOptions.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 | |
children |
comparison
equal
deleted
inserted
replaced
21518:c2e58b2a2a76 | 21519:cecb4e39521c |
---|---|
1 /* | |
2 * Copyright (c) 2015, 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 #ifndef SHARE_VM_GRAAL_GRAAL_OPTIONS_HPP | |
25 #define SHARE_VM_GRAAL_GRAAL_OPTIONS_HPP | |
26 | |
27 #include "memory/allocation.hpp" | |
28 #include "utilities/exceptions.hpp" | |
29 #include "graal/graalHashtable.hpp" | |
30 | |
31 #define PRINT_FLAGS_ARG "PrintFlags" | |
32 #define PRINT_FLAGS_HELP "Prints all Graal flags (similar to XX's PrintFlagsFinal)" | |
33 | |
34 enum OptionType { | |
35 _string, | |
36 _int, | |
37 _long, | |
38 _float, | |
39 _double, | |
40 _boolean | |
41 }; | |
42 | |
43 struct OptionDesc { | |
44 const char* name; | |
45 const char* help; | |
46 OptionType type; | |
47 const char* declaringClass; | |
48 const char* fieldClass; | |
49 }; | |
50 | |
51 inline unsigned int compute_string_hash(const char *s, int n) { | |
52 unsigned int val = 0; | |
53 while (--n >= 0) { | |
54 val = *s++ + 31 * val; | |
55 } | |
56 return val; | |
57 } | |
58 | |
59 class OptionsTable : public GraalHashtable<const char*, OptionDesc> { | |
60 protected: | |
61 unsigned int compute_hash(const char* key) { return compute_string_hash(key, strlen(key)); } | |
62 bool key_equals(const char* k1, const char* k2) { return strcmp(k1, k2) == 0; } | |
63 const char* get_key(OptionDesc value) { return value.name; } ; | |
64 const char* get_key(OptionDesc* value) { return value->name; } ; | |
65 public: | |
66 OptionsTable() : GraalHashtable<const char*, OptionDesc>(100) {} | |
67 ~OptionsTable(); | |
68 using GraalHashtable<const char*, OptionDesc>::get; | |
69 OptionDesc* get(const char* name, size_t arglen); | |
70 OptionDesc * fuzzy_match(const char* name, size_t length); | |
71 | |
72 static OptionsTable* load_options(); | |
73 }; | |
74 | |
75 struct OptionValue { | |
76 OptionDesc desc; | |
77 union { | |
78 const char* string_value; | |
79 jint int_value; | |
80 jlong long_value; | |
81 jfloat float_value; | |
82 jdouble double_value; | |
83 jboolean boolean_value; | |
84 }; | |
85 }; | |
86 | |
87 class OptionsValueTable : public GraalHashtable<const char*, OptionValue> { | |
88 OptionsTable* _table; | |
89 protected: | |
90 unsigned int compute_hash(const char* key) { return compute_string_hash(key, strlen(key)); } | |
91 bool key_equals(const char* k1, const char* k2) { return strcmp(k1, k2) == 0; } | |
92 const char* get_key(OptionValue value) { return value.desc.name; } ; | |
93 const char* get_key(OptionValue* value) { return value->desc.name; } ; | |
94 public: | |
95 OptionsValueTable(OptionsTable* table) : _table(table), GraalHashtable<const char*, OptionValue>(100) {} | |
96 ~OptionsValueTable(); | |
97 using GraalHashtable<const char*, OptionValue>::get; | |
98 OptionValue* get(const char* name, size_t arglen); | |
99 OptionsTable* options_table() { return _table; } | |
100 }; | |
101 | |
102 | |
103 #endif // SHARE_VM_GRAAL_GRAAL_OPTIONS_HPP |