diff options
7 files changed, 39 insertions, 52 deletions
diff --git a/chrome/test/data/nacl/pnacl_nmf_options/pnacl_o_0.nmf b/chrome/test/data/nacl/pnacl_nmf_options/pnacl_o_0.nmf index d8c6e4a..e1322bb 100644 --- a/chrome/test/data/nacl/pnacl_nmf_options/pnacl_o_0.nmf +++ b/chrome/test/data/nacl/pnacl_nmf_options/pnacl_o_0.nmf @@ -2,7 +2,7 @@ "program": { "portable": { "pnacl-translate": { - "-O": 0, + "optlevel": 0, "url": "pnacl_options_newlib_pnacl.pexe" } } diff --git a/chrome/test/data/nacl/pnacl_nmf_options/pnacl_o_2.nmf b/chrome/test/data/nacl/pnacl_nmf_options/pnacl_o_2.nmf index 59d8c34..650983e 100644 --- a/chrome/test/data/nacl/pnacl_nmf_options/pnacl_o_2.nmf +++ b/chrome/test/data/nacl/pnacl_nmf_options/pnacl_o_2.nmf @@ -2,7 +2,7 @@ "program": { "portable": { "pnacl-translate": { - "-O": 2, + "optlevel": 2, "url": "pnacl_options_newlib_pnacl.pexe" } } diff --git a/chrome/test/data/nacl/pnacl_nmf_options/pnacl_o_large.nmf b/chrome/test/data/nacl/pnacl_nmf_options/pnacl_o_large.nmf index 9dfb0c6..65cf918 100644 --- a/chrome/test/data/nacl/pnacl_nmf_options/pnacl_o_large.nmf +++ b/chrome/test/data/nacl/pnacl_nmf_options/pnacl_o_large.nmf @@ -2,7 +2,7 @@ "program": { "portable": { "pnacl-translate": { - "-O": 257, + "optlevel": 257, "url": "pnacl_options_newlib_pnacl.pexe" } } diff --git a/ppapi/native_client/src/trusted/plugin/json_manifest.cc b/ppapi/native_client/src/trusted/plugin/json_manifest.cc index 6b9a971..12d3c10 100644 --- a/ppapi/native_client/src/trusted/plugin/json_manifest.cc +++ b/ppapi/native_client/src/trusted/plugin/json_manifest.cc @@ -40,10 +40,12 @@ const char* const kPortableKey = "portable"; const char* const kPnaclTranslateKey = "pnacl-translate"; const char* const kUrlKey = "url"; -// Pnacl keys -const char* const kOptLevelKey = "-O"; +// PNaCl keys +const char* const kOptLevelKey = "optlevel"; +// DEPRECATED! TODO(jvoung): remove the error message after launch. +const char* const kOptLevelKeyDeprecated = "-O"; -// Sample NaCL manifest file: +// Sample NaCl manifest file: // { // "program": { // "x86-32": {"url": "myprogram_x86-32.nexe"}, @@ -75,7 +77,7 @@ const char* const kOptLevelKey = "-O"; // "portable": { // "pnacl-translate": { // "url": "myprogram.pexe", -// "-O": 0 +// "optlevel": 0 // } // } // }, @@ -211,6 +213,14 @@ bool IsValidUrlSpec(const Json::Value& url_spec, *error_string = error_stream.str(); return false; } + if (url_spec.isMember(kOptLevelKeyDeprecated)) { + nacl::stringstream error_stream; + error_stream << parent_key << " property '" << container_key << + "' has deprecated key '" << kOptLevelKeyDeprecated << + "' please use '" << kOptLevelKey << "' instead."; + *error_string = error_stream.str(); + return false; + } return true; } @@ -363,11 +373,9 @@ void GrabUrlAndPnaclOptions(const Json::Value& url_spec, PnaclOptions* pnacl_options) { *url = url_spec[kUrlKey].asString(); if (url_spec.isMember(kOptLevelKey)) { - uint32_t opt_raw = url_spec[kOptLevelKey].asUInt(); - // Clamp the opt value to fit into an int8_t. - if (opt_raw > 3) - opt_raw = 3; - pnacl_options->set_opt_level(static_cast<int8_t>(opt_raw)); + int32_t opt_raw = url_spec[kOptLevelKey].asInt(); + // set_opt_level will normalize the values. + pnacl_options->set_opt_level(opt_raw); } } diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_options.cc b/ppapi/native_client/src/trusted/plugin/pnacl_options.cc index 83e2b55..0e684bb 100644 --- a/ppapi/native_client/src/trusted/plugin/pnacl_options.cc +++ b/ppapi/native_client/src/trusted/plugin/pnacl_options.cc @@ -26,8 +26,7 @@ nacl::string ReplaceBadFSChars(nacl::string str, namespace plugin { -// Default to -O0 for now. -PnaclOptions::PnaclOptions() : translate_(false), opt_level_(0) { } +PnaclOptions::PnaclOptions() : translate_(false), opt_level_(2) { } PnaclOptions::~PnaclOptions() { } @@ -51,28 +50,22 @@ nacl::string PnaclOptions::GetCacheKey() const { return key; } -void PnaclOptions::set_opt_level(int8_t l) { - if (l < 0) { +void PnaclOptions::set_opt_level(int32_t l) { + if (l <= 0) { opt_level_ = 0; return; } - if (l > 3) { - opt_level_ = 3; - return; - } - opt_level_ = l; + // Currently only allow 0 or 2, since that is what we test. + opt_level_ = 2; } std::vector<char> PnaclOptions::GetOptCommandline() const { std::vector<char> result; nacl::string str; - if (opt_level_ != -1) { - nacl::stringstream ss; - // Cast as int so that it doesn't think it's a char. - ss << "-O" << static_cast<int>(opt_level_); - str = ss.str(); - } + nacl::stringstream ss; + ss << "-O" << opt_level_; + str = ss.str(); std::copy(str.begin(), str.end(), std::back_inserter(result)); result.push_back('\x00'); diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_options.h b/ppapi/native_client/src/trusted/plugin/pnacl_options.h index 3845c87..f998b2c 100644 --- a/ppapi/native_client/src/trusted/plugin/pnacl_options.h +++ b/ppapi/native_client/src/trusted/plugin/pnacl_options.h @@ -29,20 +29,14 @@ class PnaclOptions { // as well as the commandline options). nacl::string GetCacheKey() const; - // Return true if the manifest did not specify any special options - // (just using the default). - bool HasDefaultOpts() const { - return opt_level_ == -1; - } - // Return a character array of \x00 delimited commandline options. std::vector<char> GetOptCommandline() const; bool translate() const { return translate_; } void set_translate(bool t) { translate_ = t; } - uint8_t opt_level() const { return opt_level_; } - void set_opt_level(int8_t l); + int32_t opt_level() const { return opt_level_; } + void set_opt_level(int32_t l); void set_cache_validators(const nacl::string& c) { cache_validators_ = c; @@ -53,7 +47,7 @@ class PnaclOptions { // Currently the default copy constructor is good enough, but // double-check that it is the case when more fields are added. bool translate_; - int8_t opt_level_; + int32_t opt_level_; nacl::string cache_validators_; }; diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc b/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc index 23254cd..2df7457 100644 --- a/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc +++ b/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc @@ -153,22 +153,14 @@ void PnaclTranslateThread::DoTranslate() { int64_t compile_start_time = NaClGetTimeOfDayMicroseconds(); bool init_success; - if (pnacl_options_->HasDefaultOpts()) { - PLUGIN_PRINTF(("PnaclCoordinator: StreamInit with default options\n")); - init_success = llc_subprocess_->InvokeSrpcMethod("StreamInit", - "h", - ¶ms, - llc_out_file->desc()); - } else { - std::vector<char> options = pnacl_options_->GetOptCommandline(); - init_success = llc_subprocess_->InvokeSrpcMethod( - "StreamInitWithOverrides", - "hC", - ¶ms, - llc_out_file->desc(), - &options[0], - options.size()); - } + std::vector<char> options = pnacl_options_->GetOptCommandline(); + init_success = llc_subprocess_->InvokeSrpcMethod( + "StreamInitWithOverrides", + "hC", + ¶ms, + llc_out_file->desc(), + &options[0], + options.size()); if (!init_success) { if (llc_subprocess_->srpc_client()->GetLastError() == |