hotspot/src/share/vm/compiler/directivesParser.cpp
changeset 36597 ee256e343585
parent 35529 39376b4613b5
child 36607 dc9021790941
equal deleted inserted replaced
36595:3322a76f3a00 36597:ee256e343585
     1 /*
     1 /*
     2  * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    53     tmp = pop_tmp();
    53     tmp = pop_tmp();
    54   }
    54   }
    55   assert(_tmp_depth == 0, "Consistency");
    55   assert(_tmp_depth == 0, "Consistency");
    56 }
    56 }
    57 
    57 
    58 bool DirectivesParser::parse_string(const char* text, outputStream* st) {
    58 int DirectivesParser::parse_string(const char* text, outputStream* st) {
    59   DirectivesParser cd(text, st);
    59   DirectivesParser cd(text, st);
    60   if (cd.valid()) {
    60   if (cd.valid()) {
    61     return cd.install_directives();
    61     return cd.install_directives();
    62   } else {
    62   } else {
    63     cd.clean_tmp();
    63     cd.clean_tmp();
    64     st->flush();
    64     st->flush();
    65     st->print_cr("Parsing of compiler directives failed");
    65     st->print_cr("Parsing of compiler directives failed");
    66     return false;
    66     return -1;
    67   }
    67   }
    68 }
    68 }
    69 
    69 
    70 bool DirectivesParser::has_file() {
    70 bool DirectivesParser::has_file() {
    71   return CompilerDirectivesFile != NULL;
    71   return CompilerDirectivesFile != NULL;
    95       char* buffer = NEW_RESOURCE_ARRAY(char, st.st_size+1);
    95       char* buffer = NEW_RESOURCE_ARRAY(char, st.st_size+1);
    96       size_t num_read = os::read(file_handle, (char*) buffer, st.st_size);
    96       size_t num_read = os::read(file_handle, (char*) buffer, st.st_size);
    97       buffer[num_read] = '\0';
    97       buffer[num_read] = '\0';
    98       // close file
    98       // close file
    99       os::close(file_handle);
    99       os::close(file_handle);
   100       return parse_string(buffer, stream);
   100       return parse_string(buffer, stream) != -1;
   101     }
   101     }
   102   }
   102   }
   103   return false;
   103   return false;
   104 }
   104 }
   105 
   105 
   106 bool DirectivesParser::install_directives() {
   106 int DirectivesParser::install_directives() {
   107   // Check limit
   107   // Check limit
   108   if (!DirectivesStack::check_capacity(_tmp_depth, _st)) {
   108   if (!DirectivesStack::check_capacity(_tmp_depth, _st)) {
   109     clean_tmp();
   109     clean_tmp();
   110     return false;
   110     return 0;
   111   }
   111   }
   112 
   112 
   113   // Pop from internal temporary stack and push to compileBroker.
   113   // Pop from internal temporary stack and push to compileBroker.
   114   CompilerDirectives* tmp = pop_tmp();
   114   CompilerDirectives* tmp = pop_tmp();
   115   int i = 0;
   115   int i = 0;
   118     DirectivesStack::push(tmp);
   118     DirectivesStack::push(tmp);
   119     tmp = pop_tmp();
   119     tmp = pop_tmp();
   120   }
   120   }
   121   if (i == 0) {
   121   if (i == 0) {
   122     _st->print_cr("No directives in file");
   122     _st->print_cr("No directives in file");
   123     return false;
   123     return 0;
   124   } else {
   124   } else {
   125     _st->print_cr("%i compiler directives added", i);
   125     _st->print_cr("%i compiler directives added", i);
   126     if (CompilerDirectivesPrint) {
   126     if (CompilerDirectivesPrint) {
   127       // Print entire directives stack after new has been pushed.
   127       // Print entire directives stack after new has been pushed.
   128       DirectivesStack::print(_st);
   128       DirectivesStack::print(_st);
   129     }
   129     }
   130     return true;
   130     return i;
   131   }
   131   }
   132 }
   132 }
   133 
   133 
   134 DirectivesParser::DirectivesParser(const char* text, outputStream* st)
   134 DirectivesParser::DirectivesParser(const char* text, outputStream* st)
   135 : JSON(text, false, st), depth(0), current_directive(NULL), current_directiveset(NULL), _tmp_top(NULL), _tmp_depth(0) {
   135 : JSON(text, false, st), depth(0), current_directive(NULL), current_directiveset(NULL), _tmp_top(NULL), _tmp_depth(0) {