You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by va...@apache.org on 2006/11/30 13:55:01 UTC
svn commit: r480913 [3/3] - in /harmony/enhanced/drlvm/trunk:
build/custom/msvc_2003/vmcore/ vm/em/src/ vm/gc_cc/src/
vm/gc_gen/src/common/ vm/include/open/ vm/interpreter/ vm/interpreter/src/
vm/jitrino/config/em64t/ vm/jitrino/config/ia32/ vm/jitrino...
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/parse_arguments.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/parse_arguments.cpp?view=diff&rev=480913&r1=480912&r2=480913
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/parse_arguments.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/parse_arguments.cpp Thu Nov 30 04:54:59 2006
@@ -74,8 +74,6 @@
extern bool parallel_jit;
extern const char * dump_file_name;
-static void print_help_on_nonstandard_options();
-
/**
* Check if a string begins with another string. Note, even gcc
* substitutes actual string length instead of strlen
@@ -128,6 +126,135 @@
" -X print help on non-standard options");
}
+static void print_help_on_nonstandard_options()
+{
+#ifdef _DEBUG
+# define DEBUG_OPTIONS_HELP \
+ " -Xlog[:<category>[:<file>]\n" \
+ " Switch debug logging on [for specified category only\n" \
+ " [and log that category to a file]]\n" \
+ " -Xtrace[:<category>[:<file>]\n" \
+ " Switch trace logging on [for specified category only\n" \
+ " [and log that category to a file]]\n"
+#else
+# define DEBUG_OPTIONS_HELP
+#endif //_DEBUG
+#ifdef VM_STATS
+# define STATS_OPTIONS_HELP \
+ " -Xstats:<mask>\n" \
+ " Generates different statistics\n"
+#else
+# define STATS_OPTIONS_HELP
+#endif // VM_STATS
+
+ ECHO(" -Xbootclasspath:<PATH>\n"
+ " Set bootclasspath to the specified value\n"
+ " -Xbootclasspath/a:<PATH>\n"
+ " Append specified directories and files to bootclasspath\n"
+ " -Xbootclasspath/p:<PATH>\n"
+ " Prepend specified directories and files to bootclasspath\n"
+ " -Xjit <JIT options>\n"
+ " Specify JIT specific options\n"
+ " -Xms<size>\n"
+ " Set Java heap size\n"
+ " -Xmx<size>\n"
+ " Set maximum Java heap size\n"
+ " -Xdebug\n"
+ " Does nothing, this is a compatibility option\n"
+ " -Xnoagent\n"
+ " Does nothing, this is a compatibility option\n"
+ " -Xrun\n"
+ " Specify debugger agent library\n"
+ " -Xverbose[:<category>[:<file>]\n"
+ " Switch logging on [for specified category only\n"
+ " [and log that category to a file]]\n"
+ " -Xwarn[:<category>[:<file>]\n"
+ " Switch verbose logging off [for specified category only\n"
+ " [and log that category to a file]]\n"
+ " -Xverboseconf:<file>\n"
+ " Set up logging via log4cxx configuration file\n"
+ " -Xverboselog:<file>\n"
+ " Log verbose output to a file\n"
+ " -Xverify\n"
+ " Do full bytecode verification\n"
+ " -Xfileline\n"
+ " Add source information to logging messages\n"
+ " -Xthread\n"
+ " Add thread id to logging messages\n"
+ " -Xcategory\n"
+ " Add category name to logging messages\n"
+ " -Xtimestamp\n"
+ " Add timestamp to logging messages\n"
+ " -Xfunction\n"
+ " Add function signature to logging messages\n"
+ DEBUG_OPTIONS_HELP
+ STATS_OPTIONS_HELP
+ " -Xint\n"
+ " Use interpreter to execute the program\n"
+ " -Xgc:<gc options>\n"
+ " Specify gc specific options\n"
+ " -Xem:<em options>\n"
+ " Specify em specific options\n"
+ " -Xdumpstubs\n"
+ " Writes stubs generated by LIL to disk\n"
+ " -Xparallel_jit\n"
+ " Launch compilation in parallel (default)\n"
+ " -Xno_parallel_jit\n"
+ " Do not launch compilation in parallel\n"
+ " -Xdumpfile:<file>\n"
+ " Specifies a file name for the dump\n"
+ " -XnoCleanupOnExit\n"
+ " Exit without cleaning internal resorces\n"
+ " -XD<name>=<value>\n"
+ " set an internal system property\n");
+} //print_help_on_nonstandard_options
+
+void print_vm_standard_properties()
+{
+#ifdef PLATFORM_POSIX
+# define PLATFORM_POSIX_STANDARD_PROPERTIES \
+ " vm.crash_handler (default FALSE):\n" \
+ " Invoke gdb on crashes.\n"
+#else
+# define PLATFORM_POSIX_STANDARD_PROPERTIES
+#endif // PLATFORM_POSIX
+
+ ECHO("Boolean-valued properties (set to one of {on,true,1,off,false,0} through -XD<name>=<value>):\n\n"
+ " vm.assert_dialog (default TRUE):\n"
+ " If false, prevent assertion failures from popping up a dialog box.\n"
+ PLATFORM_POSIX_STANDARD_PROPERTIES
+ " vm.finalize (default TRUE):\n"
+ " Run finalizers.\n"
+ " vm.jit_may_inline_sync (default TRUE):\n"
+ " The JIT is allowed to inline part of the synchronization sequence.\n"
+ " vm.use_interpreter (default FALSE):\n"
+ " Use interpreter not jit.\n"
+ " vm.use_verifier (default TRUE):\n"
+ " Use verifier.\n"
+ " vm.jvmti.enabled (default FALSE):\n"
+ " Whether JVMTI mode is enabled.\n"
+ " vm.cleanupOnExit (default FALSE):\n"
+ " Excplicitly free VM resources before exit.\n"
+ " vm.bootclasspath.appendclasspath (default FALSE):\n"
+ " Append classpath to the bootclasspath.\n"
+ "\nOther properties:\n\n"
+ " vm.boot.library.path:\n"
+ " List of directories which contain additional dynamic libraries to load into VM.\n"
+ " vm.boot.class.path:\n"
+ " Virtual machine bootclasspath.\n"
+ " vm.dlls:\n"
+ " A \'" PORT_PATH_SEPARATOR_STR "\'-delimited list of modular dlls (GC/etc.) to load at startup.\n"
+ " vm.em_dll:\n"
+ " A \'" PORT_PATH_SEPARATOR_STR "\'-execution manager (EM) dll to load at startup.\n"
+ " vm.other_natives_dlls:\n"
+ " A \'" PORT_PATH_SEPARATOR_STR "\'-delimited list of dlls contained native methods implementations to load at startup.\n"
+ " vm.components.<component>.classpath:\n"
+ " Part of a <component>'s classpath to append to the JDK booclasspath\n"
+ " vm.components.<component>.startupclass:\n"
+ " A <component> class to be initialized during startup\n");
+
+}
+
static inline Assertion_Registry* get_assert_reg(Global_Env *p_env) {
if (!p_env->assert_reg) {
void * mem = apr_palloc(p_env->mem_pool, sizeof(Assertion_Registry));
@@ -167,23 +294,14 @@
for (int i = 0; i < p_env->vm_arguments.nOptions; i++) {
const char* option = p_env->vm_arguments.options[i].optionString;
- if (begins_with(option,"-Dorg.apache.harmony.vm.vmdir=")) {
-
- /*
- * This is the directory where the virtual machine artifacts are located
- * (vm.dll, etc) including the kernel.jar GEIR
- */
- add_pair_to_properties(*p_env->properties, "org.apache.harmony.vm.vmdir",
- option + strlen("-Dorg.apache.harmony.vm.vmdir="));
- }
- else if (begins_with(option, XBOOTCLASSPATH)) {
+ if (begins_with(option, XBOOTCLASSPATH)) {
/*
* Override for bootclasspath -
* set in the environment- the boot classloader will be responsible for
* processing and setting up "vm.boot.class.path" and "sun.boot.class.path"
* Note that in the case of multiple arguments, the last one will be used
*/
- add_pair_to_properties(*p_env->properties, XBOOTCLASSPATH, option + strlen(XBOOTCLASSPATH));
+ p_env->VmProperties()->set(XBOOTCLASSPATH, option + strlen(XBOOTCLASSPATH));
}
else if (begins_with(option, XBOOTCLASSPATH_A)) {
/*
@@ -192,14 +310,12 @@
* Note that we accumulate if multiple, appending each time
*/
- const char *bcp_old = properties_get_string_property((PropertiesHandle)p_env->properties,
- XBOOTCLASSPATH_A);
+ char *bcp_old = p_env->VmProperties()->get(XBOOTCLASSPATH_A);
const char *value = option + strlen(XBOOTCLASSPATH_A);
-
char *bcp_new = NULL;
if (bcp_old) {
- char *tmp = (char *) malloc(strlen(bcp_old) + strlen(PORT_PATH_SEPARATOR_STR)
+ char *tmp = (char *) STD_MALLOC(strlen(bcp_old) + strlen(PORT_PATH_SEPARATOR_STR)
+ strlen(value) + 1);
strcpy(tmp, bcp_old);
@@ -209,11 +325,9 @@
bcp_new = tmp;
}
- add_pair_to_properties(*p_env->properties, XBOOTCLASSPATH_A, bcp_old ? bcp_new : value);
-
- if (bcp_new) {
- free(bcp_new);
- }
+ p_env->VmProperties()->set(XBOOTCLASSPATH_A, bcp_old ? bcp_new : value);
+ p_env->VmProperties()->destroy(bcp_old);
+ STD_FREE((void*)bcp_new);
}
else if (begins_with(option, XBOOTCLASSPATH_P)) {
/*
@@ -222,14 +336,13 @@
* Note that we accumulate if multiple, prepending each time
*/
- const char *bcp_old = properties_get_string_property((PropertiesHandle)p_env->properties,
- XBOOTCLASSPATH_P);
+ char *bcp_old = p_env->VmProperties()->get(XBOOTCLASSPATH_P);
const char *value = option + strlen(XBOOTCLASSPATH_P);
char *bcp_new = NULL;
if (bcp_old) {
- char *tmp = (char *) malloc(strlen(bcp_old) + strlen(PORT_PATH_SEPARATOR_STR)
+ char *tmp = (char *) STD_MALLOC(strlen(bcp_old) + strlen(PORT_PATH_SEPARATOR_STR)
+ strlen(value) + 1);
strcpy(tmp, value);
@@ -239,12 +352,11 @@
bcp_new = tmp;
}
- add_pair_to_properties(*p_env->properties, XBOOTCLASSPATH_P, bcp_old ? bcp_new : value);
-
- if (bcp_new) {
- free(bcp_new);
- }
- } else if (begins_with(option, "-Xhelp:")) {
+ p_env->VmProperties()->set(XBOOTCLASSPATH_P, bcp_old ? bcp_new : value);
+ p_env->VmProperties()->destroy(bcp_old);
+ STD_FREE((void*)bcp_new);
+ }
+ else if (begins_with(option, "-Xhelp:")) {
const char* arg = option + strlen("-Xhelp:");
if (begins_with(arg, "prop")) {
@@ -258,7 +370,7 @@
} else if (begins_with(option, "-Xjit:")) {
// Do nothing here, just skip this option for later parsing
} else if (strcmp(option, "-Xint") == 0) {
- add_pair_to_properties(*p_env->properties, "vm.use_interpreter", "true");
+ p_env->VmProperties()->set("vm.use_interpreter", "true");
#ifdef VM_STATS
} else if (begins_with(option, "-Xstats:")) {
vm_print_total_stats = true;
@@ -282,12 +394,12 @@
char* prop_key = strdup(option + strlen("-X"));
prop_key[2] = '.';
TRACE2("init", prop_key << " = 1");
- add_pair_to_properties(*p_env->properties, prop_key, "1");
+ p_env->VmProperties()->set(prop_key, "1");
free(prop_key);
} else if (begins_with(option, "-Xem:")) {
const char* arg = option + strlen("-Xem:");
- add_pair_to_properties(*p_env->properties, "em.properties", arg);
+ p_env->VmProperties()->set("em.properties", arg);
} else if (begins_with(option, "-Xms")) {
// cut -Xms
@@ -296,7 +408,7 @@
if (atoi(arg) == 0) {
ECHO("Negative or invalid heap size. Default value will be used!");
}
- add_pair_to_properties(*p_env->properties, "gc.ms", arg);
+ p_env->VmProperties()->set("gc.ms", arg);
} else if (begins_with(option, "-Xmx")) {
// cut -Xmx
@@ -305,7 +417,7 @@
if (atoi(arg) == 0) {
ECHO("Negative or invalid heap size. Default value will be used!");
}
- add_pair_to_properties(*p_env->properties, "gc.mx", arg);
+ p_env->VmProperties()->set("gc.mx", arg);
}
else if (begins_with(option, "-agentlib:")) {
p_env->TI->addAgent(option);
@@ -354,6 +466,8 @@
}
else if (strncmp(option, "-D", 2) == 0) {
}
+ else if (strncmp(option, "-XD", 3) == 0) {
+ }
else if (strcmp(option, "-Xdumpstubs") == 0) {
dump_stubs = true;
}
@@ -368,7 +482,7 @@
dump_file_name = arg;
}
else if (strcmp(option, "-XnoCleanupOnExit") == 0) {
- add_pair_to_properties(*p_env->properties, "vm.noCleanupOnExit", "true");
+ p_env->VmProperties()->set("vm.noCleanupOnExit", "true");
}
else if (strcmp(option, "_org.apache.harmony.vmi.portlib") == 0) {
// Store a pointer to the portlib
@@ -554,87 +668,6 @@
}
} // for (arg_num)
} //set_log_levels_from_cmd
-
-static void print_help_on_nonstandard_options()
-{
-#ifdef _DEBUG
-# define DEBUG_OPTIONS_HELP \
- " -Xlog[:<category>[:<file>]\n" \
- " Switch debug logging on [for specified category only\n" \
- " [and log that category to a file]]\n" \
- " -Xtrace[:<category>[:<file>]\n" \
- " Switch trace logging on [for specified category only\n" \
- " [and log that category to a file]]\n"
-#else
-# define DEBUG_OPTIONS_HELP
-#endif //_DEBUG
-#ifdef VM_STATS
-# define STATS_OPTIONS_HELP \
- " -Xstats:<mask>\n" \
- " Generates different statistics\n"
-#else
-# define STATS_OPTIONS_HELP
-#endif // VM_STATS
-
- ECHO(" -Xbootclasspath:<PATH>\n"
- " Set bootclasspath to the specified value\n"
- " -Xbootclasspath/a:<PATH>\n"
- " Append specified directories and files to bootclasspath\n"
- " -Xbootclasspath/p:<PATH>\n"
- " Prepend specified directories and files to bootclasspath\n"
- " -Xjit <JIT options>\n"
- " Specify JIT specific options\n"
- " -Xms<size>\n"
- " Set Java heap size\n"
- " -Xmx<size>\n"
- " Set maximum Java heap size\n"
- " -Xdebug\n"
- " Does nothing, this is a compatibility option\n"
- " -Xnoagent\n"
- " Does nothing, this is a compatibility option\n"
- " -Xrun\n"
- " Specify debugger agent library\n"
- " -Xverbose[:<category>[:<file>]\n"
- " Switch logging on [for specified category only\n"
- " [and log that category to a file]]\n"
- " -Xwarn[:<category>[:<file>]\n"
- " Switch verbose logging off [for specified category only\n"
- " [and log that category to a file]]\n"
- " -Xverboseconf:<file>\n"
- " Set up logging via log4cxx configuration file\n"
- " -Xverboselog:<file>\n"
- " Log verbose output to a file\n"
- " -Xverify\n"
- " Do full bytecode verification\n"
- " -Xfileline\n"
- " Add source information to logging messages\n"
- " -Xthread\n"
- " Add thread id to logging messages\n"
- " -Xcategory\n"
- " Add category name to logging messages\n"
- " -Xtimestamp\n"
- " Add timestamp to logging messages\n"
- " -Xfunction\n"
- " Add function signature to logging messages\n"
- DEBUG_OPTIONS_HELP
- STATS_OPTIONS_HELP
- " -Xint\n"
- " Use interpreter to execute the program\n"
- " -Xgc:<gc options>\n"
- " Specify gc specific options\n"
- " -Xem:<em options>\n"
- " Specify em specific options\n"
- " -Xdumpstubs\n"
- " Writes stubs generated by LIL to disk\n"
- " -Xparallel_jit\n"
- " Launch compilation in parallel (default)\n"
- " -Xno_parallel_jit\n"
- " Do not launch compilation in parallel\n"
- " -Xdumpfile:<file>\n"
- " Specifies a file name for the dump\n"
- " -XnoCleanupOnExit\n"
- " Exit without cleaning internal resorces\n");
-} //print_help_on_nonstandard_options
void initialize_vm_cmd_state(Global_Env *p_env, JavaVMInitArgs* arguments)
{
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/properties.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/properties.cpp?view=diff&rev=480913&r1=480912&r2=480913
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/properties.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/properties.cpp Thu Nov 30 04:54:59 2006
@@ -14,518 +14,160 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/**
- * @author Intel, Alexey V. Varlamov, Gregory Shimansky
- * @version $Revision: 1.1.2.2.4.14 $
- */
-
#define LOG_DOMAIN "init.properties"
#include "cxxlog.h"
-
#include "properties.h"
-#include "open/vm_util.h"
-#include <apr_file_io.h>
-#include <apr_file_info.h>
-#include <apr_env.h>
-#include <apr_strings.h>
-#include "port_dso.h"
-#include "port_filepath.h"
-#include "port_sysinfo.h"
-
-#include "vm_properties.h"
-
-#define PROP_ENV_NAME "VM_PROPERTIES"
-#define PROP_FILE_NAME "vm.properties"
-#define BOOT_PROPS_FILE_NAME "bootclasspath.properties"
-#define BOOTCLASSPATH_PROP_NAME "bootclasspath"
-
-#define MAX_PROP_LINE 5120
-
-// local memory pool for temporary allocation
-static apr_pool_t *prop_pool;
-const char *
-properties_get_string_property(PropertiesHandle prop, const char *key)
+class PropValue
{
- Prop_Value *val = ((Properties *) prop)->get(key);
- if (!val)
- return NULL;
- return val->as_string();
-}
+public:
+ char* value;
-static void
-read_properties(char *fname, Properties & prop)
-{
- apr_file_t *f;
- if (APR_SUCCESS != apr_file_open(&f, fname, APR_FOPEN_READ, 0, prop_pool))
- return;
- WARN("USAGE OF vm.properties FILE IS DEPRECATED. THIS FUNCTIONALITY WILL BE REMOVED SOON. ALL PROPERTIES SHOULD BE SET ON COMMAND LINE");
- char buf[MAX_PROP_LINE];
- while (!apr_file_eof(f) && !apr_file_gets(buf, MAX_PROP_LINE, f))
- {
- prop.add(buf);
+ PropValue(const char* v) {
+ value = (v == NULL ? NULL : (char*)strdup(v));
}
- apr_file_close(f);
-}
+ ~PropValue() {
+ STD_FREE(value);
+ }
+};
-void
-properties_set_string_property(PropertiesHandle ph, const char* key, const char* value)
+Properties::Properties()
{
- Properties* p = (Properties*)ph;
- add_pair_to_properties(*p, key, value);
+ if (APR_SUCCESS != apr_pool_create(&local_ht_pool, NULL)) {
+ DIE("Cannot initialize properties pool");
+ }
+ hashtables_array = apr_hash_make(local_ht_pool);
+ rwlock_array = NULL;
+ if (APR_SUCCESS != apr_thread_rwlock_create(&rwlock_array, local_ht_pool)) {
+ DIE("Cannot initialize properties table mutex");
+ }
}
-PropertiesIteratorHandle
-properties_iterator_create(PropertiesHandle ph)
+void Properties::set(const char * key, const char * value)
{
- Properties* p = (Properties*)ph;
- Properties::Iterator* it = p->getNewIterator();
- it->next();
- return (PropertiesIteratorHandle)it;
-}
+ TRACE("set property " << key << " = " << value);
-void
-properties_iterator_destroy(PropertiesHandle ph, PropertiesIteratorHandle pih)
-{
- Properties* p = (Properties*)ph;
- Properties::Iterator* it = (Properties::Iterator*)pih;
- p->destroyIterator(it);
+ if (APR_SUCCESS != apr_thread_rwlock_wrlock(rwlock_array)) {
+ DIE("Cannot lock properties table");
+ }
+ PropValue* val = (PropValue*) apr_hash_get(hashtables_array, (const void*) key, APR_HASH_KEY_STRING);
+ apr_hash_set(hashtables_array, (const void*) strdup(key), APR_HASH_KEY_STRING, (const void*) new PropValue(value));
+ if (val != NULL) {
+ delete(val);
+ }
+ if (APR_SUCCESS != apr_thread_rwlock_unlock(rwlock_array)) {
+ DIE("Cannot unlock properties table");
+ }
}
-Boolean
-properties_iterator_advance(PropertiesIteratorHandle pih)
-{
- Properties::Iterator* it = (Properties::Iterator*)pih;
- return it->next()!=NULL;
+char* Properties::get(const char * key) {
+ char* return_value= NULL;
+ if (APR_SUCCESS != apr_thread_rwlock_rdlock(rwlock_array)) {
+ DIE("Cannot lock properties table");
+ }
+ PropValue* val = (PropValue*) apr_hash_get(hashtables_array, (const void*) key, APR_HASH_KEY_STRING);
+ if (val != NULL) {
+ return_value = strdup(val->value);
+ }
+ if (APR_SUCCESS != apr_thread_rwlock_unlock(rwlock_array)) {
+ DIE("Cannot unlock properties table");
+ }
+ return return_value;
}
-const char*
-properties_get_name(PropertiesIteratorHandle pih)
-{
- Properties::Iterator* it = (Properties::Iterator*)pih;
- Prop_entry* p = it->currentEntry();
- return p->key;
+void Properties::destroy(char* value) {
+ STD_FREE((void*)value);
}
-const char*
-properties_get_string_value(PropertiesIteratorHandle pih)
-{
-
- Properties::Iterator* it = (Properties::Iterator*)pih;
- Prop_entry* p = it->currentEntry();
- return p->value->as_string();
+bool Properties::is_set(const char * key) {
+ if (apr_hash_get(hashtables_array, (const void*) key, APR_HASH_KEY_STRING) == NULL) {
+ return FALSE;
+ } else {
+ return TRUE;
+ }
}
-char *predefined_propeties[] =
-{
- // The following properties are added in define_undefined_predefined_properties
- // function: java.home, vm.boot.library.path, java.library.path, user.name,
- // user.home, java.io.tmpdir
-
- // Hardcoded properties
- "java.vm.specification.version=1.0",
- "java.vm.specification.vendor=Sun Microsystems Inc.",
- "java.vm.specification.name=Java Virtual Machine Specification",
- "java.specification.version=1.5",
- "java.specification.vendor=Sun Microsystems Inc.",
- "java.specification.name=Java Platform API Specification",
- "java.version=1.5.0",
- "java.vendor=Apache Software Foundation",
- "java.vm.vendor=Apache Software Foundation",
- "java.vm.version=11.2.0",
- "java.vm.name=DRLVM",
- "java.vm.info=no info",
- "java.class.version=49.0",
- NULL
-};
-
-
-
-#define API_DLL1 "harmonyvm"
-#define API_DLL2 "hythr"
-#define API_DLL3 "hysig"
-#define API_DLL4 "hyprt"
-#define API_DLL5 "hyzlib"
-#define API_DLL6 "hytext"
-#define API_DLL7 "hynio"
-#define API_DLL8 "vmi"
-#define API_DLLA "hyluni"
-#define API_DLLB "hyarchive"
-
-#define GC_DLL "gc_cc"
-#define EM_DLL "em"
-
-/**
- * Compose a string of file names each of them beginning with path,
- * names separated by PORT_PATH_SEPARATOR. If patch is NULL, no path
- * or separator willbe prefixed
- */
-static char *compose_full_files_path_names_list(const char *path,
- const char **dll_names,
- const int names_number,
- bool is_dll)
-{
- char* full_name = "";
- for (int iii = 0; iii < names_number; iii++)
- {
- const char *tmp = dll_names[iii];
- if (is_dll) {
- tmp = port_dso_name_decorate(tmp, prop_pool);
- }
-
- /*
- * if the path is non-null, prefix, otherwise do nothing
- * to avoid the problem of "/libfoo.so" when we don't want
- * a path attached
- */
-
- if (path != NULL) {
- tmp = port_filepath_merge(path, tmp, prop_pool);
+void Properties::unset(const char * key) {
+ apr_hash_index_t* hi;
+ const void* deleted_key;
+ if (APR_SUCCESS != apr_thread_rwlock_wrlock(rwlock_array)) {
+ DIE("Cannot lock properties table");
+ }
+ PropValue* val = (PropValue*) apr_hash_get(hashtables_array, (const void*) key, APR_HASH_KEY_STRING);
+ if (val != NULL) {
+ for (hi = apr_hash_first(local_ht_pool, hashtables_array); hi; hi = apr_hash_next(hi)) {
+ apr_hash_this(hi, &deleted_key, NULL, NULL);
+ if (!(strncmp(key, (const char*)deleted_key, strlen(key)) &&
+ strncmp((const char*)deleted_key, key, strlen((const char*)deleted_key)))) {
+ break;
+ }
}
-
- full_name = apr_pstrcat(prop_pool, full_name, tmp,
- (iii + 1 < names_number) ? PORT_PATH_SEPARATOR_STR : "", NULL);
+ apr_hash_set(hashtables_array, (const void*)key, APR_HASH_KEY_STRING, NULL);
+ STD_FREE((void*)deleted_key);
+ delete(val);
+ }
+ if (APR_SUCCESS != apr_thread_rwlock_unlock(rwlock_array)) {
+ DIE("Cannot unlock properties table");
}
-
- return full_name;
-}
-
-
-void post_initialize_ee_dlls(PropertiesHandle ph) {
- if (!prop_pool) {
- apr_pool_create(&prop_pool, 0);
- }
-
- Properties *properties = (Properties*) ph;
-
- const char *file_list;
- if ((file_list = properties_get_string_property(ph, "vm.em_dll"))) {
- TRACE( "vm.em_dll = " << file_list);
- return; // properties already set (may be in command line)
- }
-
- const char *library_path =
- properties_get_string_property(ph, "vm.boot.library.path");
-
- const char *em_dll_files[] = {
- EM_DLL
- };
- const char ** dll_files= em_dll_files;
- const int n_dll_files = sizeof(dll_files) / sizeof(char *);
-
- /*
- * pass NULL for the pathname as we don't want
- * any path pre-pended
- */
-
- char* path_buf = compose_full_files_path_names_list(
- NULL, dll_files, n_dll_files, true);
-
- assert(path_buf);
- add_pair_to_properties(*properties, "vm.em_dll", path_buf);
- TRACE( "vm.em_dll = " << path_buf);
-
- apr_pool_destroy(prop_pool);
- prop_pool = 0;
}
+char** Properties::get_keys() {
+ apr_hash_index_t* hi;
+ int properties_count = 0;
+ const void* key;
-
-static void define_undefined_predefined_properties(Properties & properties)
-{
- char *path_buf = NULL;
- char *base_path_buf;
-
- if (port_executable_name(&base_path_buf, prop_pool) != APR_SUCCESS) {
- DIE("Failed to find executable location");
+ if (APR_SUCCESS != apr_thread_rwlock_rdlock(rwlock_array)) {
+ DIE("Cannot lock properties table");
}
-
- // directory for the executable
- char *p = strrchr(base_path_buf, PORT_FILE_SEPARATOR);
- if (NULL == p)
- DIE("Failed to determine executable directory");
- *p = '\0';
-
- /*
- * vm.boot.library.path initialization, the value is the location of VM executable
- *
- * 2006-09-06 gmj : there's no reason to ever believe this is true given how the VM can be
- * launched in a mariad of ways, so just set to empty string.
- */
- add_pair_to_properties(properties, "vm.boot.library.path", "");
- TRACE( "vm.boot.library.path = ");
-
- // Added for compatibility with the external java JDWP agent
- add_pair_to_properties(properties, "sun.boot.library.path", base_path_buf);
- TRACE( "sun.boot.library.path = " << base_path_buf);
-
- /*
- * it's possible someone forgot to set this property - set to default of .
- */
- if (properties_get_string_property(reinterpret_cast<PropertiesHandle>(&properties), O_A_H_VM_VMDIR) == NULL) {
- TRACE2("init", "o.a.h.vm.vmdir not set - setting predefined value of as '.'");
- add_pair_to_properties(properties, O_A_H_VM_VMDIR, ".");
- }
-
- /*
- * also, do the same for java.class.path
- */
-
- if (properties_get_string_property(reinterpret_cast<PropertiesHandle>(&properties), "java.class.path") == NULL) {
- TRACE2("init", "java.class.path not set - setting predefined value of '.'");
- add_pair_to_properties(properties, "java.class.path", ".");
- }
-
- // vm.dlls initialization, the value is location of VM executable +
- // GC_DLL and on IPF JIT_DLL
- // FIXME, add JIT_DLL on other architectures when we have JIT in a dll on ia32
- const char *core_dll_files[] =
- {
- GC_DLL
- };
-
- const int n_core_dll_files = sizeof(core_dll_files) / sizeof(char *);
-
- // vm.other_natives_dlls initialization, the value is location of VM executable.
- const char *api_dll_files[] =
- {
- API_DLL1,
- API_DLL2,
- API_DLL3,
- API_DLL4,
- API_DLL5,
- API_DLL6,
- API_DLL7,
- API_DLL8,
- API_DLLA,
- API_DLLB
- };
- int n_api_dll_files = sizeof(api_dll_files) / sizeof(char *);
-
-
- /*
- * pass NULL for the pathname as we don't want
- * any path pre-pended
- */
- path_buf = compose_full_files_path_names_list(
- NULL, core_dll_files, n_core_dll_files, true);
-
- add_pair_to_properties(properties, "vm.dlls", path_buf);
- TRACE( "vm.dlls = " << path_buf);
-
- /*
- * pass NULL for the pathname as we don't want
- * any path pre-pended
- */
-
- path_buf = compose_full_files_path_names_list(
- NULL, api_dll_files, n_api_dll_files, true);
-
- add_pair_to_properties(properties, "vm.other_natives_dlls", path_buf);
- TRACE( "vm.other_natives_dlls = " << path_buf);
-
- // java.library.path initialization, the value is the location of VM executable,
- // prepended to OS library search path
- char *env;
- char *lib_path = base_path_buf;
- if (APR_SUCCESS == port_dso_search_path(&env, prop_pool))
- {
- lib_path = apr_pstrcat(prop_pool, base_path_buf, PORT_PATH_SEPARATOR_STR, env, NULL);
- }
-
- add_pair_to_properties(properties, "java.library.path", lib_path);
- TRACE( "java.library.path = " << lib_path);
-
- // java.home initialization, try to find absolute location of the executable and set
- // java.home to the parent directory.
- p = strrchr(base_path_buf, PORT_FILE_SEPARATOR);
- if (NULL == p)
- DIE("Failed to determine executable parent directory");
- *p = '\0';
- add_pair_to_properties(properties, "java.home", base_path_buf);
- TRACE( "java.home = " << base_path_buf);
-
- char *ext_path = port_filepath_merge(base_path_buf, "lib" PORT_FILE_SEPARATOR_STR "ext", prop_pool);
- add_pair_to_properties(properties, "java.ext.dirs", ext_path);
- TRACE( "java.ext.dirs = " << ext_path);
-
- // user.name initialization, try to get the name from the system
- char *user_buf;
- apr_status_t status = port_user_name(&user_buf, prop_pool);
- if (APR_SUCCESS != status) {
- DIE("Failed to get user name from the system. Error code " << status);
- }
- add_pair_to_properties(properties, "user.name", user_buf);
- TRACE( "user.name = " << user_buf);
-
- // user.home initialization, try to get home from the system.
- char *user_home;
- status = port_user_home(&user_home, prop_pool);
- if (APR_SUCCESS != status) {
- DIE("Failed to get user home from the system. Error code " << status);
- }
- add_pair_to_properties(properties, "user.home", user_home);
- TRACE( "user.home = " << user_home);
-
- // java.io.tmpdir initialization.
- const char *tmpdir;
- status = apr_temp_dir_get(&tmpdir, prop_pool);
- if (APR_SUCCESS != status) {
- tmpdir = user_home;
- }
-
- add_pair_to_properties(properties, "java.io.tmpdir", tmpdir);
- TRACE( "java.io.tmpdir = " << tmpdir);
-
- // FIXME: This is a workaround code for third party APIs which
- // depend on this property.
- add_pair_to_properties(properties, "java.util.prefs.PreferencesFactory",
-#ifdef PLATFORM_NT
- "java.util.prefs.RegistryPreferencesFactoryImpl");
-#else
- "java.util.prefs.FilePreferencesFactoryImpl");
-#endif
-
- // user.timezone initialization, required by java.util.TimeZone implementation
- char *user_tz;
- status = port_user_timezone(&user_tz, prop_pool);
- if (APR_SUCCESS != status) {
- INFO("Failed to get user timezone from the system. Error code " << status);
- user_tz = "GMT";
+ for (hi = apr_hash_first(local_ht_pool, hashtables_array); hi; hi = apr_hash_next(hi)) {
+ properties_count++;
+ }
+ char** return_value = (char**) STD_MALLOC(sizeof(char*) * (properties_count + 1));
+ properties_count = 0;
+ for (hi = apr_hash_first(local_ht_pool, hashtables_array); hi; hi = apr_hash_next(hi)) {
+ apr_hash_this(hi, &key, NULL, NULL);
+ return_value[properties_count++] = (char*)strdup((char*)key);
}
- add_pair_to_properties(properties, "user.timezone", user_tz);
- TRACE( "user.timezone = " << user_tz);
+ return_value[properties_count] = NULL;
+ if (APR_SUCCESS != apr_thread_rwlock_unlock(rwlock_array)) {
+ DIE("Cannot unlock properties table");
+ }
+ return return_value;
}
-void
-initialize_properties(Global_Env * p_env, Properties & prop)
-{
- if (!prop_pool) {
- apr_pool_create(&prop_pool, 0);
+char** Properties::get_keys_staring_with(const char* prefix) {
+ apr_hash_index_t* hi;
+ int properties_count = 0;
+ const void* key;
+
+ if (APR_SUCCESS != apr_thread_rwlock_rdlock(rwlock_array)) {
+ DIE("Cannot lock properties table");
}
-/*
- * gregory -
- * 0. Add predefined properties from property table
- */
-
-
- define_undefined_predefined_properties(*p_env->properties);
-
- char **pp = predefined_propeties;
- while (NULL != *pp)
- {
- p_env->properties->add(*pp);
- pp++;
- }
-
-/*
- * 1. VM looks for an environment variable, say,
- * VM_PROPERTIES=d:\xyz\eee\vm.Properties, read the Properties;
- */
- char *pf;
- if (apr_env_get(&pf, PROP_ENV_NAME, prop_pool) == APR_SUCCESS){
- read_properties(pf, prop);
- }
-/*
- * 2. Looks for vm.Properties in the directory where vm executable resides
- * (it's also a global file), read the Properties, if key is duplicated,
- * override the value;
- */
- char *buf;
- if (port_executable_name(&buf, prop_pool) == APR_SUCCESS)
- {
- char *p = strrchr(buf, PORT_FILE_SEPARATOR);
- if (p)
- {
- *(p + 1) = '\0';
- buf = apr_pstrcat(prop_pool, buf, PROP_FILE_NAME, NULL);
- read_properties(buf, prop);
- }
+ for (hi = apr_hash_first(local_ht_pool, hashtables_array); hi; hi = apr_hash_next(hi)) {
+ apr_hash_this(hi, &key, NULL, NULL);
+ if (!strncmp(prefix, (char*)key, strlen(prefix)))
+ properties_count++;
}
-
-/*
- * 3. Looks for it in current directory(it's an app-specific file), read the
- * Properties, if key is duplicated, override the value;
- */
- apr_filepath_get(&buf, 0, prop_pool);
- buf = port_filepath_merge(buf, PROP_FILE_NAME, prop_pool);
- read_properties(buf, prop);
-/*
- * 4. Check whether there is a command line option, say,
- * -Properties-file "d:\xyz\eee\vm.Properties" or -Droperties key=value,
- * read the Properties, if key is duplicated, override the value.
- */
- for (int arg_num = 0; arg_num < p_env->vm_arguments.nOptions; arg_num++)
- {
- char *option = p_env->vm_arguments.options[arg_num].optionString;
-
- if (strncmp(option, "-D", 2) == 0)
- {
- TRACE("setting property " << option + 2);
- add_to_properties(*p_env->properties, option + 2);
+ char** return_value = (char**) STD_MALLOC(sizeof(char*) * (properties_count + 1));
+ properties_count = 0;
+ for (hi = apr_hash_first(local_ht_pool, hashtables_array); hi; hi = apr_hash_next(hi)) {
+ apr_hash_this(hi, &key, NULL, NULL);
+ if (!strncmp(prefix, (char*)key, strlen(prefix))) {
+ return_value[properties_count++] = (char*)strdup((char*)key);
}
}
- apr_pool_clear(prop_pool);
-}
-
-void
-add_to_properties(Properties & prop, const char *line)
-{
- prop.add(line);
-}
-
-void
-add_pair_to_properties(Properties & prop, const char *key, const char *value)
-{
- Prop_entry *e = new Prop_entry();
- char* key_copy = strdup(key);
- char* value_copy = strdup(value);
- e->key = strdup(unquote(key_copy));
- e->value = new Prop_String(strdup(unquote(value_copy)));
- prop.add(e);
- free(key_copy);
- free(value_copy);
+ return_value[properties_count] = NULL;
+ if (APR_SUCCESS != apr_thread_rwlock_unlock(rwlock_array)) {
+ DIE("Cannot unlock properties table");
+ }
+ return return_value;
}
-void
-Properties::add(Prop_entry * e) /*Caller can NOT delete e */
-{
- const char *vmPrefix = "vm.";
- if (!strncmp(vmPrefix, e->key, strlen(vmPrefix)))
- {
- check_vm_standard_property(e->key, e->value->as_string());
- }
-
- int idx = index_of(e->key);
- if (bucket[idx])
- {
- Prop_entry *itr = bucket[idx];
- Prop_entry *prev = NULL;
- while (itr)
- {
- int cmp = itr->compareTo(e->key);
- if (cmp > 0)
- {
- e->next = itr;
- if (!prev)
- bucket[idx] = e;
- else
- prev->next = e;
- break;
- }
- if (cmp == 0)
- {
- itr->replace(e);
- delete e; /*Because this, e will be invalid */
- break;
- }
- prev = itr;
- itr = itr->next;
- }
- if (!itr)
- prev->next = e;
+void Properties::destroy(char** keys) {
+ int i = 0;
+ while (keys[i] != NULL) {
+ STD_FREE((void*)keys[i++]);
}
- else
- bucket[idx] = e;
+ STD_FREE(keys);
}
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm.cpp?view=diff&rev=480913&r1=480912&r2=480913
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm.cpp Thu Nov 30 04:54:59 2006
@@ -14,57 +14,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/**
- * @author Intel, Alexei Fedotov
- * @version $Revision: 1.1.2.3.4.4 $
- */
-
-#define LOG_DOMAIN "vm.core"
-#include "cxxlog.h"
-
-#include "platform_lowlevel.h"
-
-#include <assert.h>
-
-#include "vm_process.h"
-
-#include "open/types.h"
#include "Class.h"
-#include "classloader.h"
#include "environment.h"
-#include "method_lookup.h"
-#include "exceptions.h"
#include "compile.h"
#include "object_layout.h"
-#include "open/vm_util.h"
-#include "jit_intf.h"
-#include "object_handles.h"
-#include "vm_threads.h"
-#include "vm_stats.h"
-#include "vm_arrays.h"
-#include "nogc.h"
-
-#include "object_generic.h"
-
-#include "open/hythread_ext.h"
-#include "open/jthread.h"
-#include "component_manager.h"
-#include "lock_manager.h"
-#include "root_set_enum_internal.h"
-
-#include "natives_support.h"
-#include "properties.h"
Global_Env *VM_Global_State::loader_env = 0;
-
// tag pointer is not allocated by default, enabled by TI
bool ManagedObject::_tag_pointer = false;
-
/////////////////////////////////////////////////////////////////
// begin Class
/////////////////////////////////////////////////////////////////
@@ -85,149 +47,3 @@
/////////////////////////////////////////////////////////////////
// end Class
/////////////////////////////////////////////////////////////////
-
-
-
-static struct VmStandardProperty {
- const char *name; // Full name of the property
- const char *docString; // Documentation of the property
- bool isBoolean; // Whether it's a boolean-valued property
- Boolean value; // Value of a boolean-valued property (initialized to default value)
-} standardProperties[] = {
- // Sorted only for convenience.
- {"gc.verbose", "Controls GC verbosity",
- true, FALSE},
- {"vm.assert_dialog", "If false, prevent assertion failures from popping up a dialog box.",
- true, TRUE},
-#ifdef PLATFORM_POSIX
- {"vm.crash_handler", "Invoke gdb on crashes",
- true, FALSE},
-#endif // PLATFORM_POSIX
- {"vm.finalize", "Run finalizers",
- true, TRUE},
- {"vm.jit_may_inline_sync", "The JIT is allowed to inline part of the synchronization sequence.",
- true, TRUE},
- {"vm.multiple_dumpjit_files", "Split the dump file into multiple files with a maximum of approximated 10 million bytes",
- true, FALSE},
- {"vm.use_interpreter", "Use interpreter not jit.",
- true, FALSE},
- {"vm.use_verifier", "Use verifier.",
- true, TRUE},
- {"vm.jvmti.enabled", "Whether JVMTI mode is enabled.",
- true, FALSE},
- {"vm.noCleanupOnExit", "Exit without cleaning internal resorces.",
- true, FALSE},
- {"vm.bootclasspath.appendclasspath", "Append classpath to the bootclasspath",
- true, FALSE},
-
- // Non-boolean properties below. (sorted for convenience)
- {"vm.boot.library.path", "List of directories which contain additional dynamic libraries to load into VM"},
- {"vm.boot.class.path", "Virtual machine bootclasspath"},
- {"vm.bootclasspath.initmethod", "Set to \"java-home\" to use a JDK style bootclasspath based on java home."},
- {"vm.bootclasspath.prepend", "Prepended to the JDK style booclasspath."},
- {"vm.dlls", "A ';'-delimited list of modular dlls (GC/etc.) to load at startup."},
- {"vm.ee_dlls", "A ';'-delimited list of modular dlls (JIT/Interpreter/etc.) to load at startup."},
- {"vm.em_dll", "A ';'-execution manager (EM) dll to load at startup."},
- {"vm.other_natives_dlls", "A " EXPAND(PORT_PATH_SEPARATOR) "-delimited list of dlls contained native methods implementations to load at startup."},
- {"vm.components.<component>.classpath", "Part of a <component>'s classpath to append to the JDK booclasspath"},
- {"vm.components.<component>.startupclass", "A <component> class to be initialized during startup"}
-};
-
-static const int numStandardProperties = sizeof(standardProperties) / sizeof(standardProperties[0]);
-static bool areStandardPropertiesSet = false;
-
-
-void check_vm_standard_property(const char *propertyName, const char *propertyValue)
-{
- if (!strncmp(propertyName, "vm.components.", strlen("vm.components."))) {
- return;
- }
- for (int i=0; i<numStandardProperties; i++)
- {
- if (!strcmp(propertyName, standardProperties[i].name))
- {
- if (standardProperties[i].isBoolean)
- {
- areStandardPropertiesSet = true;
- if (!strcmp(propertyValue, "on") ||
- !strcmp(propertyValue, "true") ||
- !strcmp(propertyValue, "1"))
- standardProperties[i].value = TRUE;
- else if (!strcmp(propertyValue, "off") ||
- !strcmp(propertyValue, "false") ||
- !strcmp(propertyValue, "0"))
- standardProperties[i].value = FALSE;
- else
- {
- fprintf(stderr,"check_vm_standard_property: invalid boolean value '%s' for property '%s'\n",
- propertyValue, propertyName);
- fflush(stdout);
- }
- }
- return;
- }
- }
- fprintf(stderr,"check_vm_standard_property: unknown standard property used: '%s'\n", propertyName);
- fflush(stderr);
-}
-
-
-// This must be called while properties still hold their default values,
-// i.e. before any properties are loaded.
-void print_vm_standard_properties()
-{
- if (areStandardPropertiesSet)
- {
- printf("Warning: print_vm_standard_properties() called after properties are already set.\n");
- }
- printf("Boolean-valued properties (set to one of {on,true,1,off,false,0}):\n");
- int i;
- for (i=0; i<numStandardProperties; i++)
- {
- if (standardProperties[i].isBoolean)
- {
- printf("%s (default %s):\n %s\n",
- standardProperties[i].name,
- (standardProperties[i].value ? "TRUE" : "FALSE"),
- standardProperties[i].docString);
- }
- }
- printf("\nOther properties:\n");
- for (i=0; i<numStandardProperties; i++)
- {
- if (!standardProperties[i].isBoolean)
- {
- printf("%s:\n %s\n",
- standardProperties[i].name,
- standardProperties[i].docString);
- }
- }
- fflush(stdout);
-}
-
-
-
-Boolean vm_get_boolean_property_value_with_default(const char *property_name)
-{
- bool found = false;
- for (int i=0; !found && i<numStandardProperties; i++)
- {
- if (!strcmp(standardProperties[i].name, property_name))
- {
- found = true;
- if (!standardProperties[i].isBoolean)
- {
- {
- printf("vm_get_boolean_property_value_with_default: non-boolean property '%s'\n", property_name);
- fflush(stdout);
- }
- }
- return standardProperties[i].value;
- }
- }
- // XXX- print error
- printf("vm_get_boolean_property_value_with_default: standard property '%s' not found\n", property_name);
- fflush(stdout);
- return FALSE;
-} //vm_get_boolean_property_value_with_default
-
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp?view=diff&rev=480913&r1=480912&r2=480913
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp Thu Nov 30 04:54:59 2006
@@ -45,6 +45,7 @@
#include "nogc.h"
#include "vm_strings.h"
#include "slot.h"
+#include "classpath_const.h"
#ifdef PLATFORM_NT
// 20040427 Used to turn on heap checking on every allocation
@@ -114,17 +115,15 @@
*/
static jint process_properties_dlls(Global_Env * vm_env) {
jint status;
- char * tok;
- const char * dlls;
- const char delimiters[] = {PORT_PATH_SEPARATOR, 0};
-
- post_initialize_ee_dlls((PropertiesHandle)vm_env->properties);
+ if (!vm_env->VmProperties()->is_set("vm.em_dll")) {
+ vm_env->VmProperties()->set("vm.em_dll", PORT_DSO_NAME("em"));
+ }
- const char* dll = properties_get_string_property((PropertiesHandle)vm_env->properties, "vm.em_dll");
+ char* dll = vm_env->VmProperties()->get("vm.em_dll");
TRACE("analyzing em dll " << dll);
-
status = CmLoadComponent(dll, "EmInitialize");
+ vm_env->VmProperties()->destroy(dll);
if (status != JNI_OK) {
WARN("Cannot load EM component from " << dll);
return status;
@@ -143,13 +142,12 @@
return status;
}
- dlls = properties_get_string_property((PropertiesHandle)vm_env->properties, "vm.dlls");
- if (!dlls) return JNI_OK;
+ const char delimiters[] = {PORT_PATH_SEPARATOR, 0};
- dlls = strdup(dlls);
- assert(dlls);
+ char* dlls = vm_env->VmProperties()->get("vm.dlls");
+ if (!dlls) return JNI_OK;
- tok = strtok((char *)dlls, delimiters);
+ char* tok = strtok((char *)dlls, delimiters);
while (tok) {
TRACE("analyzing dll " << tok);
#ifndef USE_GC_STATIC
@@ -166,13 +164,14 @@
}
#endif
WARN("Mandatory library cannot be loaded: " << tok);
- return JNI_ERR;
+ status = JNI_ERR;
+ break;
next_dll:
tok = strtok(NULL, delimiters);
}
- STD_FREE((void*)dlls);
-
- return JNI_OK;
+
+ vm_env->VmProperties()->destroy(dlls);
+ return status;
}
/**
@@ -280,23 +279,22 @@
}
}
-
/**
* Extends bootstrap classpath with jars from components
*/
static void bootstrap_add_components_classpath(Global_Env *vm_env) {
static std::string VM_COMPONENT_BOOTSTRAP_PREFIX="vm.components.";
static std::string VM_COMPONENT_BOOTSTRAP_SUFFIX=".classpath";
-
+
// create temp pool for apr functions
apr_pool_t *tmp_pool;
apr_pool_create(&tmp_pool, NULL);
-
- std::string kernel_dir_path = vm_get_property_value(O_A_H_VM_VMDIR);
-
- PropertiesIteratorHandle ph = vm_properties_iterator_create();
- do {
- const char* key = vm_properties_get_name(ph);
+
+ std::string kernel_dir_path = get_property(O_A_H_VM_VMDIR, JAVA_PROPERTIES);
+
+ char** keys = get_properties_keys(JAVA_PROPERTIES);
+ for (unsigned i = 0; keys[i] != NULL; ++i) {
+ const char* key = keys[i];
//check if the property name is VM_COMPONENT_BOOTSTRAP_PREFIX.*.VM_COMPONENT_BOOTSTRAP_SUFFIX form
if (strncmp(VM_COMPONENT_BOOTSTRAP_PREFIX.c_str(), key, VM_COMPONENT_BOOTSTRAP_PREFIX.length())) {
continue;
@@ -310,7 +308,7 @@
}
//all checks passed
//extends boot class path with the property value
- const char* path = vm_properties_get_string_value(ph);
+ char* path = get_property(key, JAVA_PROPERTIES);
// check if path must be extended
std::string absPath;
if (strstr(path, PORT_FILE_SEPARATOR_STR)==NULL) {
@@ -318,11 +316,12 @@
} else {
absPath = path;
}
+ destroy_property_value(path);
vm_env->bootstrap_class_loader->SetBCPElement(absPath.c_str(), tmp_pool);
- } while(vm_properties_iterator_advance(ph));
+ }
+
+ destroy_properties_keys(keys);
- vm_properties_iterator_destroy(ph);
-
apr_pool_destroy(tmp_pool);
}
@@ -674,7 +673,7 @@
// 20030407 Note: property initialization must follow initialization of the default JITs to allow
// the command line to override those default JITs.
- initialize_properties(vm_env, *vm_env->properties);
+ initialize_properties(vm_env);
parse_vm_arguments(vm_env);
@@ -687,9 +686,9 @@
parse_jit_arguments(&vm_env->vm_arguments);
vm_env->pin_interned_strings =
- (bool)vm_get_property_value_boolean("vm.pin_interned_strings", FALSE);
+ (bool)get_boolean_property("vm.pin_interned_strings", FALSE, VM_PROPERTIES);
- if (!vm_get_boolean_property_value_with_default("vm.assert_dialog")) {
+ if (!get_boolean_property("vm.assert_dialog", TRUE, VM_PROPERTIES)) {
TRACE("disabling assertion dialogs");
disable_assert_dialogs();
}
@@ -821,7 +820,7 @@
hythread_suspend_enable();
- if (vm_get_boolean_property_value_with_default("vm.finalize")) {
+ if (get_boolean_property("vm.finalize", TRUE, VM_PROPERTIES)) {
// Load and initialize finalizer thread.
vm_env->finalizer_thread = preload_class(vm_env, "java/lang/FinalizerThread");
assert(vm_env->finalizer_thread);
Added: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_properties.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_properties.cpp?view=auto&rev=480913
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_properties.cpp (added)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_properties.cpp Thu Nov 30 04:54:59 2006
@@ -0,0 +1,380 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <apr_file_io.h>
+#include <apr_file_info.h>
+#include <apr_env.h>
+#include <apr_strings.h>
+#include "port_dso.h"
+#include "port_filepath.h"
+#include "port_sysinfo.h"
+
+#define LOG_DOMAIN "init.properties"
+#include "cxxlog.h"
+#include "properties.h"
+#include "vm_properties.h"
+#include "init.h"
+
+inline char* unquote(char *str)
+{
+ const char *tokens = " \t\n\r\'\"";
+ size_t i = strspn(str, tokens);
+ str += i;
+ char *p = str + strlen(str) - 1;
+ while(strchr(tokens, *p) && p >= str)
+ *(p--) = '\0';
+ return str;
+}
+
+#define PROP_ENV_NAME "VM_PROPERTIES"
+#define PROP_FILE_NAME "vm.properties"
+
+#define MAX_PROP_LINE 5120
+
+// local memory pool for temporary allocation
+static apr_pool_t *prop_pool;
+
+static void
+read_properties(char *fname, Properties & prop)
+{
+ apr_file_t *f;
+ char *src, *tok;
+ if (APR_SUCCESS != apr_file_open(&f, fname, APR_FOPEN_READ, 0, prop_pool))
+ return;
+ WARN("USAGE OF vm.properties FILE IS DEPRECATED. THIS FUNCTIONALITY WILL BE REMOVED SOON. ALL PROPERTIES SHOULD BE SET ON COMMAND LINE");
+ char buf[MAX_PROP_LINE];
+ while (!apr_file_eof(f) && !apr_file_gets(buf, MAX_PROP_LINE, f))
+ {
+ if (buf[0] != '#') {
+ src = strdup(buf);
+ tok = strchr(src, '=');
+ if(tok)
+ {
+ *tok = '\0';
+ prop.set(unquote(src), unquote(tok + 1));
+ }
+ STD_FREE(src);
+ }
+ }
+ apr_file_close(f);
+}
+
+#define API_DLL1 "harmonyvm"
+#define API_DLL2 "hythr"
+#define API_DLL3 "hysig"
+#define API_DLL4 "hyprt"
+#define API_DLL5 "hyzlib"
+#define API_DLL6 "hytext"
+#define API_DLL7 "hynio"
+#define API_DLL8 "vmi"
+#define API_DLLA "hyluni"
+#define API_DLLB "hyarchive"
+
+#define GC_DLL "gc_cc"
+
+/**
+ * Compose a string of file names each of them beginning with path,
+ * names separated by PORT_PATH_SEPARATOR. If patch is NULL, no path
+ * or separator will be prefixed
+ */
+static char *compose_full_files_path_names_list(const char *path,
+ const char **dll_names,
+ const int names_number,
+ bool is_dll)
+{
+ char* full_name = "";
+ for (int iii = 0; iii < names_number; iii++)
+ {
+ const char *tmp = dll_names[iii];
+ if (is_dll) {
+ tmp = port_dso_name_decorate(tmp, prop_pool);
+ }
+
+ /*
+ * if the path is non-null, prefix, otherwise do nothing
+ * to avoid the problem of "/libfoo.so" when we don't want
+ * a path attached
+ */
+
+ if (path != NULL) {
+ tmp = port_filepath_merge(path, tmp, prop_pool);
+ }
+
+ full_name = apr_pstrcat(prop_pool, full_name, tmp,
+ (iii + 1 < names_number) ? PORT_PATH_SEPARATOR_STR : "", NULL);
+ }
+
+ return full_name;
+}
+
+static void init_java_properties(Properties & properties)
+{
+ //java part
+ //!!! java.compiler property must be defined by EM
+
+ char *os_name, *os_version, *path;
+ const char *tmp;
+ char *path_buf = NULL;
+
+ port_OS_name_version(&os_name, &os_version, prop_pool);
+ apr_filepath_get(&path, APR_FILEPATH_NATIVE, prop_pool);
+ if (APR_SUCCESS != apr_temp_dir_get(&tmp, prop_pool)) {
+ tmp = ".";
+ }
+ properties.set("java.version", "1.5.0");
+ properties.set("java.vendor", "Apache Software Foundation");
+ properties.set("java.vendor.url", "http://harmony.apache.org");
+ // java.home initialization, try to find absolute location of the executable and set
+ // java.home to the parent directory.
+ char *base_path_buf;
+ if (port_executable_name(&base_path_buf, prop_pool) != APR_SUCCESS) {
+ DIE("Failed to find executable location");
+ }
+ // directory for the executable
+ char *p = strrchr(base_path_buf, PORT_FILE_SEPARATOR);
+ if (NULL == p)
+ DIE("Failed to determine executable parent directory");
+ *p = '\0';
+ properties.set("java.home", base_path_buf);
+ properties.set("java.vm.specification.version", "1.0");
+ properties.set("java.vm.specification.vendor", "Sun Microsystems Inc.");
+ properties.set("java.vm.specification.name", "Java Virtual Machine Specification");
+ properties.set("java.vm.version", "11.2.0");
+ properties.set("java.vm.vendor", "Apache Software Foundation");
+ properties.set("java.vm.name", "DRLVM");
+ properties.set("java.specification.version", "1.5");
+ properties.set("java.specification.vendor", "Sun Microsystems Inc.");
+ properties.set("java.specification.name", "Java Platform API Specification");
+ properties.set("java.class.version", "49.0");
+ properties.set("java.class.path", ".");
+
+ // java.library.path initialization, the value is the location of VM executable,
+ // prepended to OS library search path
+ char *env;
+ char *lib_path = base_path_buf;
+ if (APR_SUCCESS == port_dso_search_path(&env, prop_pool))
+ {
+ lib_path = apr_pstrcat(prop_pool, base_path_buf, PORT_PATH_SEPARATOR_STR,
+ base_path_buf, PORT_FILE_SEPARATOR_STR, "default",
+ PORT_PATH_SEPARATOR_STR, env, NULL);
+ }
+ properties.set("java.library.path", lib_path);
+ //java.ext.dirs initialization.
+ char *ext_path = port_filepath_merge(base_path_buf, "lib" PORT_FILE_SEPARATOR_STR "ext", prop_pool);
+ properties.set("java.ext.dirs", ext_path);
+ properties.set("os.name", os_name);
+ properties.set("os.arch", port_CPU_architecture());
+ properties.set("os.version", os_version);
+ properties.set("file.separator", PORT_FILE_SEPARATOR_STR);
+ properties.set("path.separator", PORT_PATH_SEPARATOR_STR);
+ properties.set("line.separator", APR_EOL_STR);
+ // user.name initialization, try to get the name from the system
+ char *user_buf;
+ apr_status_t status = port_user_name(&user_buf, prop_pool);
+ if (APR_SUCCESS != status) {
+ DIE("Failed to get user name from the system. Error code " << status);
+ }
+ properties.set("user.name", user_buf);
+ // user.home initialization, try to get home from the system.
+ char *user_home;
+ status = port_user_home(&user_home, prop_pool);
+ if (APR_SUCCESS != status) {
+ DIE("Failed to get user home from the system. Error code " << status);
+ }
+ properties.set("user.home", user_home);
+ // java.io.tmpdir initialization.
+ const char *tmpdir;
+ status = apr_temp_dir_get(&tmpdir, prop_pool);
+ if (APR_SUCCESS != status) {
+ tmpdir = user_home;
+ }
+ properties.set("java.io.tmpdir", tmpdir);
+ properties.set("user.dir", path);
+
+ // FIXME??? other (not required by api specification) properties
+
+ properties.set("java.vm.info", "no info");
+ properties.set("java.tmpdir", tmp);
+ properties.set("user.language", "en");
+ properties.set("user.region", "US");
+ properties.set("file.encoding", "8859_1");
+
+ // FIXME user.timezone initialization, required by java.util.TimeZone implementation
+ char *user_tz;
+ status = port_user_timezone(&user_tz, prop_pool);
+ if (APR_SUCCESS != status) {
+ INFO("Failed to get user timezone from the system. Error code " << status);
+ user_tz = "GMT";
+ }
+
+ properties.set("user.timezone", user_tz);
+
+ // FIXME: This is a workaround code for third party APIs which depend on this property.
+ properties.set("java.util.prefs.PreferencesFactory",
+#ifdef PLATFORM_NT
+ "java.util.prefs.RegistryPreferencesFactoryImpl");
+#else
+ "java.util.prefs.FilePreferencesFactoryImpl");
+#endif
+
+ // Added for compatibility with the external java JDWP agent
+ properties.set("sun.boot.library.path", base_path_buf);
+
+ /*
+ * it's possible someone forgot to set this property - set to default of .
+ */
+ if (!properties.is_set(O_A_H_VM_VMDIR)) {
+ TRACE2("init", "o.a.h.vm.vmdir not set - setting predefined value of as '.'");
+ properties.set(O_A_H_VM_VMDIR, ".");
+ }
+
+ /*
+ * also, do the same for java.class.path
+ */
+ if (!properties.is_set("java.class.path")) {
+ TRACE2("init", "java.class.path not set - setting predefined value of as '.'");
+ properties.set("java.class.path", ".");
+ }
+}
+
+//vm part
+static void init_vm_properties(Properties & properties)
+{
+ properties.set("vm.assert_dialog", "true");
+ properties.set("vm.crash_handler", "false");
+ properties.set("vm.finalize", "true");
+ properties.set("vm.jit_may_inline_sync", "true");
+ properties.set("vm.use_interpreter", "false");
+ properties.set("vm.use_verifier", "true");
+ properties.set("vm.jvmti.enabled", "false");
+ properties.set("vm.cleanupOnExit", "false");
+ properties.set("vm.bootclasspath.appendclasspath", "false");
+
+ /*
+ * vm.boot.library.path initialization, the value is the location of VM executable
+ *
+ * 2006-09-06 gmj : there's no reason to ever believe this is true given how the VM can be
+ * launched in a mariad of ways, so just set to empty string.
+ */
+ properties.set("vm.boot.library.path", "");
+
+ properties.set("vm.dlls", PORT_DSO_NAME(GC_DLL));
+
+ // vm.other_natives_dlls initialization, the value is location of VM executable.
+ const char *api_dll_files[] =
+ {
+ API_DLL1,
+ API_DLL2,
+ API_DLL3,
+ API_DLL4,
+ API_DLL5,
+ API_DLL6,
+ API_DLL7,
+ API_DLL8,
+ API_DLLA,
+ API_DLLB
+ };
+ int n_api_dll_files = sizeof(api_dll_files) / sizeof(char *);
+ /*
+ * pass NULL for the pathname as we don't want
+ * any path pre-pended
+ */
+ char* path_buf = compose_full_files_path_names_list(NULL, api_dll_files, n_api_dll_files, true);
+ properties.set("vm.other_natives_dlls", path_buf);
+}
+
+void
+initialize_properties(Global_Env * p_env)
+{
+ if (!prop_pool) {
+ apr_pool_create(&prop_pool, 0);
+ }
+/*
+ * 0. Add predefined properties from property table
+ */
+
+ init_java_properties(*p_env->JavaProperties());
+ init_vm_properties(*p_env->VmProperties());
+
+/*
+ * 1. VM looks for an environment variable, say,
+ * VM_PROPERTIES=d:\xyz\eee\vm.Properties, read the Properties;
+ */
+ char *pf;
+ if (apr_env_get(&pf, PROP_ENV_NAME, prop_pool) == APR_SUCCESS){
+ read_properties(pf, *p_env->JavaProperties());
+ }
+/*
+ * 2. Looks for vm.Properties in the directory where vm executable resides
+ * (it's also a global file), read the Properties, if key is duplicated,
+ * override the value;
+ */
+ char *buf;
+ if (port_executable_name(&buf, prop_pool) == APR_SUCCESS)
+ {
+ char *p = strrchr(buf, PORT_FILE_SEPARATOR);
+ if (p)
+ {
+ *(p + 1) = '\0';
+ buf = apr_pstrcat(prop_pool, buf, PROP_FILE_NAME, NULL);
+ read_properties(buf, *p_env->JavaProperties());
+ }
+ }
+
+/*
+ * 3. Looks for it in current directory(it's an app-specific file), read the
+ * Properties, if key is duplicated, override the value;
+ */
+ apr_filepath_get(&buf, 0, prop_pool);
+ buf = port_filepath_merge(buf, PROP_FILE_NAME, prop_pool);
+ read_properties(buf, *p_env->JavaProperties());
+/*
+ * 4. Check whether there is a command line option, say,
+ * -Properties-file "d:\xyz\eee\vm.Properties" or -Droperties key=value,
+ * read the Properties, if key is duplicated, override the value.
+ */
+ char *src, *tok;
+ for (int arg_num = 0; arg_num < p_env->vm_arguments.nOptions; arg_num++)
+ {
+ char *option = p_env->vm_arguments.options[arg_num].optionString;
+ if (strncmp(option, "-D", 2) == 0)
+ {
+ TRACE("setting property " << option + 2);
+ src = strdup(option + 2);
+ tok = strchr(src, '=');
+ if(tok)
+ {
+ *tok = '\0';
+ p_env->JavaProperties()->set(unquote(src), unquote(tok + 1));
+ }
+ STD_FREE(src);
+ }
+ else if (strncmp(option, "-XD", 3) == 0)
+ {
+ TRACE("setting internal property " << option + 3);
+ src = strdup(option + 3);
+ tok = strchr(src, '=');
+ if(tok)
+ {
+ *tok = '\0';
+ p_env->VmProperties()->set(unquote(src), unquote(tok + 1));
+ }
+ STD_FREE(src);
+ }
+ }
+ apr_pool_clear(prop_pool);
+}
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_shutdown.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_shutdown.cpp?view=diff&rev=480913&r1=480912&r2=480913
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_shutdown.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_shutdown.cpp Thu Nov 30 04:54:59 2006
@@ -147,7 +147,7 @@
while (native_thread = hythread_iterator_next(&it)) {
vm_thread = get_vm_thread(native_thread);
if (vm_thread != NULL && native_thread != current_native_thread) {
- add_pair_to_properties(*java_vm->vm_env->properties, "vm.noCleanupOnExit", "true");
+ java_vm->vm_env->VmProperties()->set("vm.noCleanupOnExit", "true");
hythread_iterator_release(&it);
return JNI_ERR;
}
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/interpreter/interp_exports.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/interpreter/interp_exports.cpp?view=diff&rev=480913&r1=480912&r2=480913
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/interpreter/interp_exports.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/interpreter/interp_exports.cpp Thu Nov 30 04:54:59 2006
@@ -40,7 +40,7 @@
static bool val;
if (!inited) {
val = interp_enabled &&
- vm_get_boolean_property_value_with_default("vm.use_interpreter");
+ get_boolean_property("vm.use_interpreter", FALSE, VM_PROPERTIES);
inited = true;
INFO2("init", "Use interpreter = " << val);
}
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti.cpp?view=diff&rev=480913&r1=480912&r2=480913
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti.cpp Thu Nov 30 04:54:59 2006
@@ -301,7 +301,7 @@
!strncmp(option, "-Xrun", 5))
{
TRACE2("jvmti", "Enabling EM JVMTI mode");
- add_pair_to_properties(*p_env->properties, "vm.jvmti.enabled", "true");
+ set_property("vm.jvmti.enabled", "true", VM_PROPERTIES);
break;
}
}
@@ -487,13 +487,14 @@
const char *lib_name,
char **p_path1, char **p_path2)
{
- const char *vm_libs = vm->vm_env->properties->get("vm.boot.library.path")->as_string();
+ char *vm_libs = vm->vm_env->VmProperties()->get("vm.boot.library.path");
assert(vm_libs);
char *path1 = apr_pstrdup(pool, vm_libs);
char *path2 = port_dso_name_decorate(lib_name, pool);
path1 = port_filepath_merge(path1, path2, pool);
*p_path1 = path1;
*p_path2 = path2;
+ vm->vm_env->VmProperties()->destroy(vm_libs);
}
jint load_agentlib(Agent *agent, const char *str, JavaVM_Internal *vm)
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_property.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_property.cpp?view=diff&rev=480913&r1=480912&r2=480913
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_property.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_property.cpp Thu Nov 30 04:54:59 2006
@@ -78,11 +78,7 @@
const char* bcp_property = XBOOTCLASSPATH_A;
// get bootclasspath property
- Global_Env *g_env = ((TIEnv*)env)->vm->vm_env;
- Properties *properties = g_env->properties;
- const char *bcp_prop = properties_get_string_property(
- reinterpret_cast<PropertiesHandle>(properties),
- bcp_property);
+ char *bcp_prop = get_property(bcp_property, VM_PROPERTIES);
size_t len_bcp = 0;
@@ -98,13 +94,17 @@
strcpy(new_bcp + len_bcp + 1, segment);
// update bootclasspath property
- add_pair_to_properties(*properties, bcp_property, new_bcp);
+ set_property(bcp_property, new_bcp, VM_PROPERTIES);
+ set_property(bcp_property, new_bcp, JAVA_PROPERTIES);
STD_FREE(new_bcp);
} else {
// update bootclasspath property
- add_pair_to_properties(*properties, bcp_property, segment);
+ set_property(bcp_property, segment, VM_PROPERTIES);
+ set_property(bcp_property, segment, JAVA_PROPERTIES);
}
+
+ destroy_property_value(bcp_prop);
return JVMTI_ERROR_NONE;
}
@@ -145,9 +145,8 @@
jint properties_count = 0;
- Properties::Iterator *iterator = ((TIEnv*)env)->vm->vm_env->properties->getIterator();
- const Prop_entry *next = NULL;
- while((next = iterator->next()))
+ char** keys = get_properties_keys(JAVA_PROPERTIES);
+ while(keys[properties_count] != NULL)
properties_count++;
char **prop_names_array;
@@ -156,24 +155,24 @@
return errorCode;
// Copy properties defined in properties list
- iterator = ((TIEnv*)env)->vm->vm_env->properties->getIterator();
for (int iii = 0; iii < properties_count; iii++)
{
- next = iterator->next();
- errorCode = _allocate(strlen(next->key) + 1, (unsigned char **)&prop_names_array[iii]);
+ errorCode = _allocate(strlen(keys[iii]) + 1, (unsigned char **)&prop_names_array[iii]);
if (JVMTI_ERROR_NONE != errorCode)
{
// Free everything that was allocated already
for (int jjj = 0; jjj < iii; jjj++)
_deallocate((unsigned char *)prop_names_array[iii]);
_deallocate((unsigned char *)prop_names_array);
+ destroy_properties_keys(keys);
return errorCode;
}
- strcpy(prop_names_array[iii], next->key);
+ strcpy(prop_names_array[iii], keys[iii]);
}
*count_ptr = properties_count;
*property_ptr = prop_names_array;
+ destroy_properties_keys(keys);
return JVMTI_ERROR_NONE;
}
@@ -202,23 +201,19 @@
if (NULL == property || NULL == value_ptr)
return JVMTI_ERROR_NULL_POINTER;
- Prop_Value *prop_value = ((TIEnv*)env)->vm->vm_env->properties->get(property);
- if (NULL == prop_value)
- return JVMTI_ERROR_NOT_AVAILABLE;
-
- const char *value = prop_value->as_string();
+ char *value = get_property(property, JAVA_PROPERTIES);
if (NULL == value)
return JVMTI_ERROR_NOT_AVAILABLE;
char *ret;
jvmtiError errorCode = _allocate(strlen(value) + 1, (unsigned char **)&ret);
- if (errorCode != JVMTI_ERROR_NONE)
- return errorCode;
-
- strcpy(ret, value);
- *value_ptr = ret;
+ if (errorCode == JVMTI_ERROR_NONE) {
+ strcpy(ret, value);
+ *value_ptr = ret;
+ }
+ destroy_property_value(value);
- return JVMTI_ERROR_NONE;
+ return errorCode;
}
/*
@@ -249,16 +244,7 @@
return JVMTI_ERROR_NOT_AVAILABLE;
Global_Env *vm_env = ((TIEnv*)env)->vm->vm_env;
- Prop_String *ps = new Prop_String(strdup(value));
- Prop_entry *e = new Prop_entry();
- e->key = strdup(property);
- e->value = ps;
-
- Prop_entry *pe = vm_env->properties->get_entry(property);
- if (NULL == pe)
- vm_env->properties->add(e);
- else
- pe->replace(e);
+ set_property(property, value, JAVA_PROPERTIES);
return JVMTI_ERROR_NONE;
}
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMExecutionEngine.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMExecutionEngine.cpp?view=diff&rev=480913&r1=480912&r2=480913
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMExecutionEngine.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMExecutionEngine.cpp Thu Nov 30 04:54:59 2006
@@ -14,10 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/**
- * @author Alexey V. Varlamov
- * @version $Revision: 1.1.2.2.4.4 $
- */
/**
* @file jjava_lang_VMExecutionEngine.cpp
@@ -145,53 +141,6 @@
return !exn_raised();
}
-static void insertSystemProperties(JNIEnv *jenv, jobject pProperties, apr_pool_t *pp)
-{
- char *os_name, *os_version, *path;
- port_OS_name_version(&os_name, &os_version, pp);
- apr_filepath_get(&path, APR_FILEPATH_NATIVE, pp);
- const char *tmp;
- if (APR_SUCCESS != apr_temp_dir_get(&tmp, pp)) {
- tmp = ".";
- }
- PropPut(jenv, pProperties, "java.tmpdir", tmp);
- PropPut(jenv, pProperties, "java.class.path",
- properties_get_string_property(
- reinterpret_cast<PropertiesHandle>(jni_get_vm_env(jenv)->properties),
- "java.class.path") );
-
- // TODO : fix this - it should come from Class.h
- PropPut(jenv, pProperties, "java.class.version", "49.0");
-
- // First, insert all the default properties.
- if (!PropPut(jenv, pProperties, "user.language", "en")
- || !PropPut(jenv, pProperties, "user.region", "US")
- || !PropPut(jenv, pProperties, "file.encoding", "8859_1")
- //PropPut(jenv, pProperties, "file.encoding", apr_os_default_encoding(p));
- || !PropPut(jenv, pProperties, "file.separator", PORT_FILE_SEPARATOR_STR)
- || !PropPut(jenv, pProperties, "path.separator", PORT_PATH_SEPARATOR_STR)
- || !PropPut(jenv, pProperties, "line.separator", APR_EOL_STR)
- || !PropPut(jenv, pProperties, "os.arch", port_CPU_architecture())
- || !PropPut(jenv, pProperties, "os.name", os_name)
- || !PropPut(jenv, pProperties, "os.version", os_version)
- || !PropPut(jenv, pProperties, "java.vendor.url", "http://www.intel.com/")
- || !PropPut(jenv, pProperties, "user.dir", path)
- || !PropPut(jenv, pProperties, "java.tmpdir", tmp)
- || !PropPut(jenv, pProperties, "java.class.version", "49.0") )
- {
- return;
- }
-
- // Next, add runtime specified properties.
- Properties::Iterator *iterator = VM_Global_State::loader_env->properties->getIterator();
- const Prop_entry *next = NULL;
- while((next = iterator->next())){
- if (!PropPut(jenv, pProperties, next->key, ((Prop_String*)next->value)->value)){
- break;
- }
- }
-} //insertSystemProperties
-
/*
* Class: java_lang_VMExecutionEngine
* Method: getProperties
@@ -204,11 +153,17 @@
VM_Global_State::loader_env->java_util_Properties_Class);
if (jprops) {
- apr_pool_t *pp;
- if (APR_SUCCESS == apr_pool_create(&pp, 0)) {
- insertSystemProperties(jenv, jprops, pp);
- apr_pool_destroy(pp);
+ Properties *pp = VM_Global_State::loader_env->JavaProperties();
+ char** keys = pp->get_keys();
+ for (int i = 0; keys[i] !=NULL; ++i) {
+ char* value = pp->get(keys[i]);
+ bool added = PropPut(jenv, jprops, keys[i], value);
+ pp->destroy(value);
+ if (!added) {
+ break;
+ }
}
+ pp->destroy(keys);
}
return jprops;
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/verify_stack_enumeration.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/verify_stack_enumeration.cpp?view=diff&rev=480913&r1=480912&r2=480913
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/verify_stack_enumeration.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/verify_stack_enumeration.cpp Thu Nov 30 04:54:59 2006
@@ -209,17 +209,15 @@
void initialize_verify_stack_enumeration()
{
- verify_stack_enumeration_flag = vm_get_property_value_boolean("verify.rse", false);
+ verify_stack_enumeration_flag = get_boolean_property("verify.rse", false, VM_PROPERTIES);
if (verify_stack_enumeration_flag) {
INFO("verify stack enumeration mode");
- const char* s = vm_get_property_value("verify.rse.after");
- int n = atoi(s);
+ int n = get_int_property("verify.rse.after", 0, VM_PROPERTIES);
if (n > 0) verify_stack_enumeration_counter = n;
INFO(">verify after " << verify_stack_enumeration_counter);
- s = vm_get_property_value("verify.rse.period");
- n = atoi(s);
+ n = get_int_property("verify.rse.period", 0, VM_PROPERTIES);
if (n > 0) verify_stack_enumeration_period = n;
INFO(">verify each " << verify_stack_enumeration_period
<< num_suffix(verify_stack_enumeration_period) << " iteration");
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ia32.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ia32.cpp?view=diff&rev=480913&r1=480912&r2=480913
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ia32.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ia32.cpp Thu Nov 30 04:54:59 2006
@@ -730,7 +730,7 @@
/* initialize the name of the executable (to be used by addr2line) */
get_executable_name(executable, sizeof(executable));
- if (vm_get_boolean_property_value_with_default("vm.crash_handler")) {
+ if (get_boolean_property("vm.crash_handler", FALSE, VM_PROPERTIES)) {
init_crash_handler();
// can't install crash handler immediately,
// as we have already SIGABRT and SIGSEGV handlers
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ipf.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ipf.cpp?view=diff&rev=480913&r1=480912&r2=480913
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ipf.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ipf.cpp Thu Nov 30 04:54:59 2006
@@ -418,7 +418,7 @@
/* initialize the name of the executable (to be used by addr2line) */
get_executable_name(executable, sizeof(executable));
- if (vm_get_boolean_property_value_with_default("vm.crash_handler")) {
+ if (get_boolean_property("vm.crash_handler", FALSE, VM_PROPERTIES)) {
init_crash_handler();
// can't install crash handler immediately,
// as we have already SIGABRT and SIGSEGV handlers
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/em64t/nt_exception_filter.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/em64t/nt_exception_filter.cpp?view=diff&rev=480913&r1=480912&r2=480913
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/em64t/nt_exception_filter.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/em64t/nt_exception_filter.cpp Thu Nov 30 04:54:59 2006
@@ -81,7 +81,7 @@
VM_Code_Type vmct =
vm_identify_eip((void *)p_NT_exception->ContextRecord->Eip);
if(vmct != VM_TYPE_JAVA) {
- if (!vm_get_boolean_property_value_with_default("vm.assert_dialog")) {
+ if (!get_boolean_property("vm.assert_dialog", TRUE, VM_PROPERTIES)) {
WARN("Fatal exception, terminating");
return EXCEPTION_EXECUTE_HANDLER;
}
Modified: harmony/enhanced/drlvm/trunk/vm/vmi/src/vmi.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmi/src/vmi.cpp?view=diff&rev=480913&r1=480912&r2=480913
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmi/src/vmi.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmi/src/vmi.cpp Thu Nov 30 04:54:59 2006
@@ -76,7 +76,7 @@
// First, try to get the portlib pointer from global env (must have been put there during args parse)
portLibPointer = (HyPortLibrary*)VM_Global_State::loader_env->portLib;
if (NULL != portLibPointer) {
- initialized = 1;
+ initialized = 1;
return portLibPointer;
}
// If the above fails, initialize portlib here
@@ -146,9 +146,9 @@
vmiError JNICALL
GetSystemProperty(VMInterface *vmi, char *key, char **valuePtr)
{
- *valuePtr = const_cast<char *>(
- properties_get_string_property(
- (PropertiesHandle)VM_Global_State::loader_env->properties, key));
+ char* value = get_property(key, JAVA_PROPERTIES);
+ *valuePtr = strdup(value);
+ destroy_property_value(value);
return VMI_ERROR_NONE;
}
@@ -159,34 +159,37 @@
/*
* The possible implemenation might be:
*/
- add_pair_to_properties(*VM_Global_State::loader_env->properties, key, value);
+ set_property(key, value, JAVA_PROPERTIES);
return VMI_ERROR_NONE;
}
vmiError JNICALL CountSystemProperties(VMInterface *vmi, int *countPtr)
{
- Properties *p = VM_Global_State::loader_env->properties;
- Properties::Iterator *iter = p->getIterator();
+ char** keys = get_properties_keys(JAVA_PROPERTIES);
int count = 0;
- const Prop_entry *next = NULL;
- while((next = iter->next()))
+ while(keys[count] != NULL) {
count++;
+ }
*countPtr = count;
+ destroy_properties_keys(keys);
return VMI_ERROR_NONE;
}
vmiError JNICALL IterateSystemProperties(VMInterface *vmi,
vmiSystemPropertyIterator iterator, void *userData)
{
- Properties *p = VM_Global_State::loader_env->properties;
- Properties::Iterator *iter = p->getIterator();
- const Prop_entry *next = NULL;
-
- while((next = iter->next()))
- iterator(next->key, const_cast<char *>(next->value->as_string()), userData);
+ char** keys = get_properties_keys(JAVA_PROPERTIES);
+ int count = 0;
+ while(keys[count] != NULL) {
+ char* value = get_property(keys[count], JAVA_PROPERTIES);
+ iterator((char*)strdup(keys[count]), (char*)strdup(value), userData);
+ destroy_property_value(value);
+ count++;
+ }
+ destroy_properties_keys(keys);
return VMI_ERROR_NONE;
}