Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Unified Diff: ppapi/native_client/src/trusted/plugin/json_manifest.cc

Issue 12623004: Allow PNaCl NMF to set translator optimization options for experimentation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Default to -O0 instead of the default for now Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ppapi/native_client/src/trusted/plugin/json_manifest.cc
diff --git a/ppapi/native_client/src/trusted/plugin/json_manifest.cc b/ppapi/native_client/src/trusted/plugin/json_manifest.cc
index aeea96d4194526679f9c53d7483fe60d703dda25..730562f1e7337e72849794bd8ef01094f1c7b00c 100644
--- a/ppapi/native_client/src/trusted/plugin/json_manifest.cc
+++ b/ppapi/native_client/src/trusted/plugin/json_manifest.cc
@@ -16,6 +16,7 @@
#include "native_client/src/include/portability.h"
#include "native_client/src/shared/platform/nacl_check.h"
#include "native_client/src/trusted/plugin/plugin_error.h"
+#include "native_client/src/trusted/plugin/pnacl_options.h"
#include "native_client/src/trusted/plugin/utility.h"
#include "ppapi/cpp/dev/url_util_dev.h"
#include "ppapi/cpp/var.h"
@@ -39,8 +40,10 @@ const char* const kPortableKey = "portable";
const char* const kPnaclTranslateKey = "pnacl-translate";
const char* const kUrlKey = "url";
-// Cache support keys
+// Pnacl keys
const char* const kCacheIdentityKey = "sha256";
+const char* const kOptLevelKey = "-O";
+const char* const kPnaclExperimentalFlags = "experimental_flags";
// Sample manifest file:
// {
@@ -51,7 +54,8 @@ const char* const kCacheIdentityKey = "sha256";
// "portable": {
// "pnacl-translate": {
// "url": "myprogram.pexe",
-// "sha256": "..."
+// "sha256": "...",
+// "-O": 0
// }
// }
// },
@@ -254,8 +258,9 @@ bool IsValidISADictionary(const Json::Value& dictionary,
bool has_portable = dictionary.isMember(kPortableKey);
if (!has_isa && !has_portable) {
- error_info->SetReport(ERROR_MANIFEST_PROGRAM_MISSING_ARCH,
- nacl::string("manifest: no version of ") + parent_key+
+ error_info->SetReport(
+ ERROR_MANIFEST_PROGRAM_MISSING_ARCH,
+ nacl::string("manifest: no version of ") + parent_key +
" given for current arch and no portable version found.");
return false;
}
@@ -263,12 +268,23 @@ bool IsValidISADictionary(const Json::Value& dictionary,
return true;
}
-void GrabUrlAndCacheIdentity(const Json::Value& url_spec,
- nacl::string* url,
- nacl::string* cache_identity) {
+void GrabUrlAndPnaclOptions(const Json::Value& url_spec,
+ nacl::string* url,
+ PnaclOptions* pnacl_options) {
*url = url_spec[kUrlKey].asString();
if (url_spec.isMember(kCacheIdentityKey)) {
- *cache_identity = url_spec[kCacheIdentityKey].asString();
+ pnacl_options->set_bitcode_hash(url_spec[kCacheIdentityKey].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));
+ }
+ if (url_spec.isMember(kPnaclExperimentalFlags)) {
+ pnacl_options->set_experimental_flags(
+ url_spec[kPnaclExperimentalFlags].asString());
}
}
@@ -277,19 +293,15 @@ bool GetURLFromISADictionary(const Json::Value& dictionary,
const nacl::string& sandbox_isa,
bool prefer_portable,
nacl::string* url,
- nacl::string* cache_identity,
- ErrorInfo* error_info,
- bool* pnacl_translate) {
- if (url == NULL || cache_identity == NULL ||
- error_info == NULL || pnacl_translate == NULL)
+ PnaclOptions* pnacl_options,
+ ErrorInfo* error_info) {
+ if (url == NULL || pnacl_options == NULL || error_info == NULL)
return false;
if (!IsValidISADictionary(dictionary, parent_key, sandbox_isa, error_info))
return false;
*url = "";
- *cache_identity = "";
- *pnacl_translate = false;
// The call to IsValidISADictionary() above guarantees that either
// sandbox_isa or kPortableKey is present in the dictionary.
@@ -305,11 +317,11 @@ bool GetURLFromISADictionary(const Json::Value& dictionary,
// Check if this requires a pnacl-translate, otherwise just grab the URL.
// We may have pnacl-translate for isa-specific bitcode for CPU tuning.
if (isa_spec.isMember(kPnaclTranslateKey)) {
- GrabUrlAndCacheIdentity(isa_spec[kPnaclTranslateKey], url, cache_identity);
- *pnacl_translate = true;
+ GrabUrlAndPnaclOptions(isa_spec[kPnaclTranslateKey], url, pnacl_options);
+ pnacl_options->set_translate(true);
} else {
- GrabUrlAndCacheIdentity(isa_spec, url, cache_identity);
- *pnacl_translate = false;
+ *url = isa_spec[kUrlKey].asString();
+ pnacl_options->set_translate(false);
}
return true;
@@ -321,9 +333,8 @@ bool GetKeyUrl(const Json::Value& dictionary,
const Manifest* manifest,
bool prefer_portable,
nacl::string* full_url,
- nacl::string* cache_identity,
- ErrorInfo* error_info,
- bool* pnacl_translate) {
+ PnaclOptions* pnacl_options,
+ ErrorInfo* error_info) {
CHECK(full_url != NULL && error_info != NULL);
if (!dictionary.isMember(key)) {
error_info->SetReport(ERROR_MANIFEST_RESOLVE_URL,
@@ -333,8 +344,7 @@ bool GetKeyUrl(const Json::Value& dictionary,
const Json::Value& isa_dict = dictionary[key];
nacl::string relative_url;
if (!GetURLFromISADictionary(isa_dict, key, sandbox_isa, prefer_portable,
- &relative_url, cache_identity,
- error_info, pnacl_translate)) {
+ &relative_url, pnacl_options, error_info)) {
return false;
}
return manifest->ResolveURL(relative_url, full_url, error_info);
@@ -455,11 +465,9 @@ bool JsonManifest::ResolveURL(const nacl::string& relative_url,
}
bool JsonManifest::GetProgramURL(nacl::string* full_url,
- nacl::string* cache_identity,
- ErrorInfo* error_info,
- bool* pnacl_translate) const {
- if (full_url == NULL || cache_identity == NULL ||
- error_info == NULL || pnacl_translate == NULL)
+ PnaclOptions* pnacl_options,
+ ErrorInfo* error_info) const {
+ if (full_url == NULL || pnacl_options == NULL || error_info == NULL)
return false;
Json::Value program = dictionary_[kProgramKey];
@@ -472,9 +480,8 @@ bool JsonManifest::GetProgramURL(nacl::string* full_url,
sandbox_isa_,
prefer_portable_,
&nexe_url,
- cache_identity,
- error_info,
- pnacl_translate)) {
+ pnacl_options,
+ error_info)) {
return false;
}
@@ -497,19 +504,17 @@ bool JsonManifest::GetFileKeys(std::set<nacl::string>* keys) const {
bool JsonManifest::ResolveKey(const nacl::string& key,
nacl::string* full_url,
- nacl::string* cache_identity,
- ErrorInfo* error_info,
- bool* pnacl_translate) const {
+ PnaclOptions* pnacl_options,
+ ErrorInfo* error_info) const {
NaClLog(3, "JsonManifest::ResolveKey(%s)\n", key.c_str());
// key must be one of kProgramKey or kFileKey '/' file-section-key
- if (full_url == NULL || cache_identity == NULL ||
- error_info == NULL || pnacl_translate == NULL)
+ if (full_url == NULL || pnacl_options == NULL || error_info == NULL)
return false;
if (key == kProgramKey) {
return GetKeyUrl(dictionary_, key, sandbox_isa_, this, prefer_portable_,
- full_url, cache_identity, error_info, pnacl_translate);
+ full_url, pnacl_options, error_info);
}
nacl::string::const_iterator p = find(key.begin(), key.end(), '/');
if (p == key.end()) {
@@ -544,7 +549,7 @@ bool JsonManifest::ResolveKey(const nacl::string& key,
return false;
}
return GetKeyUrl(files, rest, sandbox_isa_, this, prefer_portable_,
- full_url, cache_identity, error_info, pnacl_translate);
+ full_url, pnacl_options, error_info);
}
} // namespace plugin
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/json_manifest.h ('k') | ppapi/native_client/src/trusted/plugin/manifest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698