bool Globals::parse_argument(char* arg) { // range of acceptable characters spelled out for portability reasons char name[256]; #define NAME_RANGE "[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]" if (jvm_sscanf(arg, "-%" NAME_RANGE, name) == 1) { return bool_value_put(name, false); } if (jvm_sscanf(arg, "+%" NAME_RANGE, name) == 1) { return bool_value_put(name, true); } char value[256]; #define VALUE_RANGE "[-kmKM0123456789]" if (jvm_sscanf(arg, "=%" NAME_RANGE "%" VALUE_RANGE, name, value) == 2) { #if USE_SET_HEAP_LIMIT if (jvm_strcmp("HeapMin", name) == 0) { #ifdef AZZERT tty->print_cr("HeapMin flag is not supported in case USE_SET_HEAP_LIMIT = true!"); #endif return false; } #endif return set_numeric_flag(name, value); } return false; }
int SourceAssembler::find_gp_offset(const char *name) { #if !ENABLE_THUMB_GP_TABLE int offset = 256 * sizeof(OopDesc*); // skip the bytecode table if (ENABLE_DISPATCH_TABLE_PADDING) { offset += 8 * sizeof(OopDesc*); // 8 extra bytecodes. } #else int offset = 1 * sizeof(OopDesc*); // skip the nop bytecode #endif static const GPTemplate gp_templates[] = { GP_SYMBOLS_DO(DEFINE_GP_POINTER, DEFINE_GP_VALUE) {NULL, 0, 0, 0} }; for (const GPTemplate* tmpl = gp_templates; tmpl->name; tmpl++) { if (jvm_strcmp(name, tmpl->name) == 0) { return offset; } offset += tmpl->size; GUARANTEE((offset % 4) == 0, "must be word aligned"); } SHOULD_NOT_REACH_HERE(); return 0; }
PRODUCT_CONST JVMFlag* Globals::find_flag(char* name) { PRODUCT_CONST JVMFlag* flag; for (flag = &flagTable[0]; flag->name; flag++) { if (jvm_strcmp(flag->name, name) == 0) { return flag; } } return NULL; }
inline int EventLogger::add_event_type( const char name[] ) { enum { invalid_type = -1 }; if( !UseEventLogger || !validate_event_type( name ) ) { return invalid_type; } const char** p = _event_names; const char* event_name; for( ; (event_name = *p) != NULL && jvm_strcmp(event_name, name) != 0; p++ ); if( event_name == NULL ) { if( p == _event_names + Entry::max_event_types ) { return invalid_type; } *p = name; } return p - _event_names; }
bool VSFMergeTest::read_test_case(OsFile_Handle file, MergeTestCase * const test_case) { enum { BUFFER_SIZE = 256 }; char read_buffer[BUFFER_SIZE]; enum { FIRST_STATE = 0, LOCATION_COUNT = FIRST_STATE, TYPE, SRC_STATUS, DST_STATUS, SRC_WHERE, DST_WHERE, SRC_VALUE, DST_VALUE, LAST_STATE = DST_VALUE, STATE_COUNT }; int parse_state = FIRST_STATE; static const char * const end_of_suite_marker = "VSF_MERGE_SUITE_END"; static const char * const keywords[STATE_COUNT] = { "Location_count", "Types", "Source_status", "Target_status", "Source_where", "Target_where", "Source_value", "Target_value" }; const int TYPE_COUNT = 2; static const char * const type_names[TYPE_COUNT] = { "int", "long" }; static const BasicType types[TYPE_COUNT] = { T_INT, T_LONG }; static const char * const status_names[] = { "flushed", "cached", "changed" }; static const char * const where_names[] = { "nowhere", "immediate", "register" }; unsigned int location_count = 0; unsigned int index = 0; int value = 0; VSFMergeTest::initialize(); while (true) { const int bytes_read = CompilerTest::read_line(file, read_buffer, BUFFER_SIZE); if (bytes_read == 0) { // End-of-file. break; } if (bytes_read == BUFFER_SIZE) { tty->print_cr("Line too long"); break; } if (read_buffer[0] == '#') { continue; } char buffer[BUFFER_SIZE]; const char * p = read_buffer; // Read the first word to the buffer. if (jvm_sscanf(p, "%255s", buffer) != 1) { break; } // Check for the end of suite marker. if (parse_state == FIRST_STATE) { if (jvm_strcmp(buffer, end_of_suite_marker) == 0) { break; } } if (jvm_strcmp(buffer, keywords[parse_state]) != 0) { tty->print_cr("Unexpected keyword: %s", buffer); break; } switch (parse_state) { case LOCATION_COUNT: p = next_word(p); if (jvm_sscanf(p, "%d", &location_count) != 1) { tty->print_cr("Cannot read location count"); return false; } if (location_count > MAX_TEST_LOCATION_COUNT) { tty->print_cr("Too many locations %d > %d", location_count, MAX_TEST_LOCATION_COUNT); return false; } test_case->location_count = location_count; break; case TYPE: for (index = 0; index < location_count; index++) { p = next_word(p); if (jvm_sscanf(p, "%255s", buffer) != 1) { tty->print_cr("Cannot read type for location %d", index); return false; } value = CompilerTest::get_keyword_index(type_names, ARRAY_SIZE(type_names), buffer); if (value < 0 || value >= TYPE_COUNT) { tty->print_cr("Invalid type \"%s\" for location %d", buffer, index); return false; } BasicType type = types[value]; // For two-word types the type of the second location must be T_ILLEGAL. if (type == T_LONG) { if (index > 0 && test_case->types[index - 1] == T_LONG) { type = T_ILLEGAL; } } test_case->types[index] = type; } break; case SRC_STATUS: case DST_STATUS: { const bool is_source = parse_state == SRC_STATUS; const char * const frame_name = is_source ? "source" : "target"; for (index = 0; index < location_count; index++) { p = next_word(p); if (jvm_sscanf(p, "%255s", buffer) != 1) { tty->print_cr("Cannot read status for %s location %d", frame_name, index); return false; } value = CompilerTest::get_keyword_index(status_names, ARRAY_SIZE(status_names), buffer); if (value == -1) { tty->print_cr("Invalid status \"%s\" for %s location %d", buffer, frame_name, index); return false; } if (is_source) { test_case->src_status[index] = (RawLocation::Status)value; } else { test_case->dst_status[index] = (RawLocation::Status)value; } } break; } case SRC_WHERE: case DST_WHERE: { const bool is_source = parse_state == SRC_WHERE; const char * const frame_name = is_source ? "source" : "target"; for (index = 0; index < location_count; index++) { p = next_word(p); if (jvm_sscanf(p, "%255s", buffer) != 1) { tty->print_cr("Cannot read where for %s location %d", frame_name, index); return false; } value = CompilerTest::get_keyword_index(where_names, ARRAY_SIZE(where_names), buffer); if (value == -1) { tty->print_cr("Invalid where \"%s\" for %s location %d", buffer, frame_name, index); return false; } if (is_source) { test_case->src_where[index] = (Value::ValueLocation)value; } else { test_case->dst_where[index] = (Value::ValueLocation)value; } } break; } case SRC_VALUE: case DST_VALUE: { const bool is_source = parse_state == SRC_VALUE; const char * const frame_name = is_source ? "source" : "target"; for (index = 0; index < location_count; index++) { p = next_word(p); if (jvm_sscanf(p, "%d", &value) != 1) { tty->print_cr("Cannot read value for %s location %d", frame_name, index); return false; } const Value::ValueLocation where = is_source ? test_case->src_where[index] : test_case->dst_where[index]; int location_value = value; if (where == Value::T_REGISTER) { if (!is_valid_register(value)) { tty->print_cr("Invalid int register %d for %s location %d", value, frame_name, index); return false; } location_value = VSFMergeTest::available_int_register(value); } if (is_source) { test_case->src_value[index] = location_value; } else { test_case->dst_value[index] = location_value; } } break; } } if (parse_state == LAST_STATE) { return true; } parse_state++; } return false; }
bool is_int() const { return jvm_strcmp(type, "int") == 0; }
bool is_bool() const { return jvm_strcmp(type, "bool") == 0; }
int __cdecl compare_flags(const void* a, const void* b) { return jvm_strcmp((*((JVMFlag**) a))->name, (*((JVMFlag**) b))->name); }
int Arguments::parse_one_arg(int argc, char** argv) { if (argc <= 0) { // we already finished parsing. return 0; } int count = 1; // in most cases we find an argument of 1 word #if ENABLE_MULTIPLE_PROFILES_SUPPORT if ((jvm_strcmp(argv[0], "-profile") == 0) && argc >= 2) { JVM_SetProfile(argv[1]); count = 2; } else #endif // ENABLE_MULTIPLE_PROFILES_SUPPORT if (jvm_strcmp(argv[0], "-version") == 0) { Globals::print_version(); JVMSPI_Exit(0); ::jvm_exit(0); } else if ((jvm_strcmp(argv[0], "-?") == 0) || (jvm_strcmp(argv[0], "-help") == 0)) { JVMSPI_DisplayUsage(NULL); JVMSPI_Exit(1); ::jvm_exit(1); } else if (((jvm_strcmp(argv[0], "-classpath") == 0) || (jvm_strcmp(argv[0], "-cp") == 0)) && argc >= 2) { set_pathname_from_const_ascii(&_classpath, argv[1]); count = 2; } else if (jvm_strcmp(argv[0], "-int") == 0) { UseCompiler = false; } else if (jvm_strcmp(argv[0], "-comp") == 0) { MixedMode = false; UseCompiler = true; } else if ((*argv[0] == '-') && (*(argv[0]+1) == 'D')) { char *key; char *value; key = argv[0] + 2; for (value = key; *value ; value++) { if (*value == '=') { *value++ = 0; break; } } JVMSPI_SetSystemProperty(key, value); } #if ENABLE_INTERPRETER_GENERATOR || USE_SOURCE_IMAGE_GENERATOR else if (jvm_strcmp(argv[0], "-outputdir") == 0) { set_pathname_from_const_ascii(&_generator_output_dir, argv[1]); count = 2; } else if (jvm_strcmp(argv[0], "-generate") == 0) { GenerateDebugAssembly = true; GenerateAssemblyCode = true; } else if (jvm_strcmp(argv[0], "-generateoptimized") == 0) { GenerateDebugAssembly = false; GenerateAssemblyCode = true; } #endif #if ENABLE_JVMPI_PROFILE // To get the library name to be loaded else if(jvm_strncmp(argv[0], "-Xrun", 5) == 0) { Arguments::_jvmpi_profiler_lib = (char*)OsMemory_allocate(jvm_strlen(argv[0]) + 2); jvm_strcpy(Arguments::_jvmpi_profiler_lib, "lib"); jvm_strcat(Arguments::_jvmpi_profiler_lib, &(argv[0][5])); jvm_strcat(Arguments::_jvmpi_profiler_lib, ".so"); } #endif #if ENABLE_ROM_GENERATOR #if USE_SOURCE_IMAGE_GENERATOR else if (jvm_strcmp(argv[0], "-romconfig") == 0) { set_pathname_from_const_ascii(&_rom_config_file, argv[1]); count = 2; } else if (jvm_strcmp(argv[0], "-romincludepath") == 0) { ROMIncludePath *ptr = (ROMIncludePath*)OsMemory_allocate(sizeof(ROMIncludePath)); ptr->_next = _rom_include_paths; ptr->_file._path = NULL; set_pathname_from_const_ascii(&(ptr->_file), argv[1]); _rom_include_paths = ptr; count = 2; } else if (jvm_strcmp(argv[0], "-romize") == 0) { // Romize the system classes GenerateROMImage = true; #if ENABLE_TTY_TRACE TraceMirandaMethods = true; #endif count = 1; } #endif // USE_SOURCE_IMAGE_GENERATOR #if USE_BINARY_IMAGE_GENERATOR else if (jvm_strcmp(argv[0], "-convert") == 0) { // Romize an application GenerateROMImage = true; #if ENABLE_TTY_TRACE TraceMirandaMethods = true; #endif count = 1; } #if ENABLE_LIB_IMAGES else if (jvm_strcmp(argv[0], "-convertshared") == 0) { // Romize a library, so it could be used shared GenerateSharedROMImage = true; GenerateROMImage = true; #if ENABLE_TTY_TRACE TraceMirandaMethods = true; #endif count = 1; } #endif #endif else if (jvm_strcmp(argv[0], "-romoutputfile") == 0) { set_pathname_from_const_ascii(&_rom_output_file, argv[1]); count = 2; } #endif // ENABLE_ROM_GENERATOR #if USE_DEBUG_PRINTING else if (jvm_strcmp(argv[0], "-definitions") == 0) { Globals::print_definitions(); JVMSPI_Exit(1); ::jvm_exit(1); } else if (jvm_strcmp(argv[0], "-flags") == 0) { Globals::print_flags(); JVMSPI_Exit(1); ::jvm_exit(1); } else if (jvm_strcmp(argv[0], "-buildopts") == 0) { Globals::print_build_options(); JVMSPI_Exit(1); ::jvm_exit(1); } else if (jvm_strcmp(argv[0], "-errorcodes") == 0) { Globals::print_error_codes(); JVMSPI_Exit(1); ::jvm_exit(1); } #endif #if !defined(PRODUCT) || ENABLE_TTY_TRACE else if (jvm_strcmp(argv[0], "-verbose") == 0) { #if ENABLE_TTY_TRACE VerboseGC = true; VerboseClassLoading = true; #endif } // Parse the CompileOnlyXXX= option, if present, and record the // classes and methods that should always be compiled. This must // be done before the following to allow correct handling of // classes which start with the letters K or M else if (jvm_strncmp(argv[0], COMPILE_ONLY_METHOD, STATIC_STRLEN(COMPILE_ONLY_METHOD)) == 0) { _method_CompileOnly = argv[0] + STATIC_STRLEN(COMPILE_ONLY_METHOD); } else if (jvm_strncmp(argv[0], COMPILE_ONLY_CLASS, STATIC_STRLEN(COMPILE_ONLY_CLASS)) == 0) { _class_CompileOnly = argv[0] + STATIC_STRLEN(COMPILE_ONLY_CLASS); } #endif #if !defined(PRODUCT) else if (jvm_strcmp(argv[0], "-compilertestconfig") == 0) { if (argc < 2) { JVMSPI_DisplayUsage((char*)"Compiler test config file not specified."); JVMSPI_Exit(1); ::jvm_exit(1); } RunCompilerTests = true; set_pathname_from_const_ascii(&_compiler_test_config_file, argv[1]); count = 2; } #endif /* NOT PRODUCT */ #if ENABLE_METHOD_TRAPS else if (jvm_strncmp(argv[0], METHOD_TRAP, STATIC_STRLEN(METHOD_TRAP)) == 0) { if (!parse_method_trap_param(argv[0] + STATIC_STRLEN(METHOD_TRAP))) { JVMSPI_DisplayUsage((char*)"Invalid usage of MethodTrap argument"); JVMSPI_Exit(1); ::jvm_exit(1); } } #endif #if ENABLE_REMOTE_TRACER else if (((jvm_strcmp(argv[0], "-tracehost") == 0)) && argc > 2) { traceHost = argv[1]; count = 2; } #endif #if ENABLE_JAVA_DEBUGGER else if (jvm_strcmp(argv[0], "-debugger") == 0) { JavaDebugger::set_debugger_option_on(true); } else if (jvm_strcmp(argv[0], "-port") == 0) { _debugger_port = jvm_atoi(argv[1]); count=2; } else if (jvm_strcmp(argv[0], "-suspend") == 0) { JavaDebugger::set_suspend(true); } else if (jvm_strcmp(argv[0], "-nosuspend") == 0) { JavaDebugger::set_suspend(false); } #if ENABLE_ISOLATES else if (jvm_strcmp(argv[0], "-debug_isolate") == 0) { JavaDebugger::set_debug_isolate_option_on(true); } else if (jvm_strcmp(argv[0], "-debug_main") == 0) { JavaDebugger::set_debug_main_option_on(true); } #endif #endif #if ENABLE_MEMORY_PROFILER else if (jvm_strcmp(argv[0], "-memory_profiler") == 0) { JavaDebugger::set_debugger_option_on(true); } #endif #if ENABLE_MEMORY_MONITOR else if (jvm_strcmp(argv[0], "-monitormemory") == 0) { Arguments::_monitor_memory = 1; } #endif else if ((argv[0][0] == '-')||(argv[0][0] == '+') || (argv[0][0] == '=')) { if (!Globals::parse_argument(argv[0])) { count = -1; // Indicate parse error } #if ENABLE_ROM_GENERATOR if (jvm_strcmp(argv[0], "+EnableAllROMOptimizations") == 0) { // Turn on all available ROM optimizations, so you don't have to // enable them individually // // This also means you can selectively turn off some ROM // optimizations such as "+EnableAllROMOptimizations // -CompactROMFieldTables". Note that the order is important. AggressiveROMSymbolRenaming = true; CompactROMFieldTables = true; CompactROMMethodTables = true; CompactROMBytecodes = true; RenameNonPublicROMClasses = true; RenameNonPublicROMSymbols = true; SimpleROMInliner = true; RemoveDuplicatedROMStackmaps= true; RemoveDeadMethods = true; } #if ENABLE_ROM_JAVA_DEBUGGER if (jvm_strcmp(argv[0], "+MakeROMDebuggable") == 0) { // Turn off any optimizations that would change bytecode offsets CompactROMFieldTables = false; CompactROMMethodTables = false; CompactROMBytecodes = false; RenameNonPublicROMSymbols = false; AggressiveROMSymbolRenaming = false; } #endif if (jvm_strcmp(argv[0], "-EnableBaseOptimizations") == 0) { // Turn off all optimizations AggressiveROMSymbolRenaming = false; CompactROMFieldTables = false; CompactROMMethodTables = false; CompactROMBytecodes = false; RenameNonPublicROMClasses = false; RenameNonPublicROMSymbols = false; SimpleROMInliner = false; RemoveDuplicatedROMStackmaps= false; RemoveDeadMethods = false; RewriteROMConstantPool = false; } #endif } else { /* We don't recognize argv[0] as an argument */ count = 0; } return count; }
void GPTableGenerator::generate_constants_table() { int i; bind("gp_constants"); static const GPTemplate gp_templates[] = { GP_SYMBOLS_DO(DEFINE_GP_POINTER, DEFINE_GP_VALUE) {NULL, 0, 0, 0} }; for (const GPTemplate* tmpl = gp_templates; tmpl->name; tmpl++) { if (tmpl->is_pointer) { char buff[120]; jvm_sprintf(buff, "gp_%s_ptr", tmpl->name); bind(buff); Label L(tmpl->name); if (!tmpl->is_asm) { import(L); } define_long(L); } else { if (jvm_strcmp(tmpl->name, "current_thread") == 0) { bind("jvm_fast_globals"); } char buff[120]; jvm_sprintf(buff, "_%s", tmpl->name); bind(buff); if (jvm_strcmp(tmpl->name, "bit_selector") == 0) { // IMPL_NOTE: create a common framework to define initial values define_long(0x80808080); } else { define_zeros(tmpl->size); } } } if (!GenerateGPTableOnly) { // Some constants to check we've linked with the right ROM Label L1(XSTR(_ROM_LINKCHECK_HLE)); import(L1); define_long(L1); Label L2(XSTR(_ROM_LINKCHECK_MFFD)); import(L2); define_long(L2); Label L3(XSTR(_ROM_LINKCHECK_MFFL)); import(L3); define_long(L3); } if (ENABLE_THUMB_GP_TABLE && GenerateGPTableOnly) { // These symbols are necessary to link romgen. // We define a long for each entry, since they // should be bound to different addresses. bind("jvm_ladd"); define_long(0); bind("jvm_lsub"); define_long(0); bind("jvm_land"); define_long(0); bind("jvm_lor"); define_long(0); bind("jvm_lxor"); define_long(0); bind("jvm_lcmp"); define_long(0); bind("jvm_lmin"); define_long(0); bind("jvm_lmax"); define_long(0); bind("jvm_lmul"); define_long(0); bind("jvm_lshl"); define_long(0); bind("jvm_lshr"); define_long(0); bind("jvm_lushr"); define_long(0); } bind("gp_constants_end"); }