summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstichnot <stichnot@chromium.org>2016-02-24 15:40:59 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-24 23:42:14 +0000
commit7040ac830ebb7c2ccb0cbc17667f4645d8bf37d4 (patch)
treef0eec1355d54914bd6b7faf4b26886c8d8cc0307
parent928d45668af849e2cf92c89167afb2e444103e4b (diff)
downloadchromium_src-7040ac830ebb7c2ccb0cbc17667f4645d8bf37d4.zip
chromium_src-7040ac830ebb7c2ccb0cbc17667f4645d8bf37d4.tar.gz
chromium_src-7040ac830ebb7c2ccb0cbc17667f4645d8bf37d4.tar.bz2
PNaCl: Force Subzero under --force-pnacl-subzero.
Repurposes the currently-dormant --enable-pnacl-subzero flag (renamed to --force-pnacl-subzero) to force the use of Subzero (pnacl-sz) for all translation, regardless of optlevel, architecture support, debug flag, etc. The idea is to allow PNaCl app developers to test Subzero on their application without having to modify their manifest file, or to test on e.g. ARM before Subzero is officially enabled on ARM. BUG=588337 TEST= git cl try -b linux_chromium_dbg_32_ng Review URL: https://codereview.chromium.org/1723413002 Cr-Commit-Position: refs/heads/master@{#377425}
-rw-r--r--chrome/browser/chrome_content_browser_client.cc6
-rw-r--r--chrome/test/nacl/nacl_browsertest_util.cc2
-rw-r--r--components/nacl/common/nacl_switches.cc4
-rw-r--r--components/nacl/common/nacl_switches.h2
-rw-r--r--components/nacl/renderer/ppb_nacl_private_impl.cc41
5 files changed, 34 insertions, 21 deletions
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 5da0960..0f05ef8 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -1628,13 +1628,15 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
#if !defined(DISABLE_NACL)
switches::kEnableNaClDebug,
switches::kEnableNaClNonSfiMode,
- switches::kEnablePNaClSubzero,
#endif
switches::kEnableNetBenchmarking,
switches::kEnableNewBookmarkApps,
#if defined(OS_ANDROID)
switches::kEnableOfflinePagesAsBookmarks,
#endif
+#if !defined(DISABLE_NACL)
+ switches::kForcePNaClSubzero,
+#endif
switches::kJavaScriptHarmony,
switches::kMessageLoopHistogrammer,
switches::kPpapiFlashArgs,
@@ -1678,7 +1680,7 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
#if !defined(DISABLE_NACL)
switches::kEnableNaClDebug,
switches::kEnableNaClNonSfiMode,
- switches::kEnablePNaClSubzero,
+ switches::kForcePNaClSubzero,
switches::kNaClDangerousNoSandboxNonSfi,
#endif
switches::kPpapiFlashPath,
diff --git a/chrome/test/nacl/nacl_browsertest_util.cc b/chrome/test/nacl/nacl_browsertest_util.cc
index 2b3e882..e9e7c81 100644
--- a/chrome/test/nacl/nacl_browsertest_util.cc
+++ b/chrome/test/nacl/nacl_browsertest_util.cc
@@ -283,7 +283,7 @@ bool NaClBrowserTestPnacl::IsAPnaclTest() {
void NaClBrowserTestPnaclSubzero::SetUpCommandLine(
base::CommandLine* command_line) {
NaClBrowserTestPnacl::SetUpCommandLine(command_line);
- command_line->AppendSwitch(switches::kEnablePNaClSubzero);
+ command_line->AppendSwitch(switches::kForcePNaClSubzero);
}
base::FilePath::StringType NaClBrowserTestNonSfiMode::Variant() {
diff --git a/components/nacl/common/nacl_switches.cc b/components/nacl/common/nacl_switches.cc
index 331e2a5..749d6fd 100644
--- a/components/nacl/common/nacl_switches.cc
+++ b/components/nacl/common/nacl_switches.cc
@@ -16,8 +16,8 @@ const char kEnableNaClDebug[] = "enable-nacl-debug";
// sandbox.
const char kEnableNaClNonSfiMode[] = "enable-nacl-nonsfi-mode";
-// Enable use of the Subzero as the PNaCl translator instead of LLC.
-const char kEnablePNaClSubzero[] = "enable-pnacl-subzero";
+// Force use of the Subzero as the PNaCl translator instead of LLC.
+const char kForcePNaClSubzero[] = "force-pnacl-subzero";
// Value for --type that causes the process to run as a NativeClient broker
// (used for launching NaCl loader processes on 64-bit Windows).
diff --git a/components/nacl/common/nacl_switches.h b/components/nacl/common/nacl_switches.h
index 8738946..9139960 100644
--- a/components/nacl/common/nacl_switches.h
+++ b/components/nacl/common/nacl_switches.h
@@ -14,7 +14,7 @@ namespace switches {
extern const char kDisablePnaclCrashThrottling[];
extern const char kEnableNaClDebug[];
extern const char kEnableNaClNonSfiMode[];
-extern const char kEnablePNaClSubzero[];
+extern const char kForcePNaClSubzero[];
extern const char kNaClBrokerProcess[];
extern const char kNaClDangerousNoSandboxNonSfi[];
extern const char kNaClDebugMask[];
diff --git a/components/nacl/renderer/ppb_nacl_private_impl.cc b/components/nacl/renderer/ppb_nacl_private_impl.cc
index 840cdfa..cb033d3 100644
--- a/components/nacl/renderer/ppb_nacl_private_impl.cc
+++ b/components/nacl/renderer/ppb_nacl_private_impl.cc
@@ -1086,6 +1086,28 @@ bool CreateJsonManifest(PP_Instance instance,
return false;
}
+bool ShouldUseSubzero(const PP_PNaClOptions* pnacl_options) {
+ // Always use Subzero if explicitly overridden on the command line.
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kForcePNaClSubzero))
+ return true;
+ // Otherwise, don't use Subzero for a debug pexe file since Subzero's parser
+ // is likely to reject an unfinalized pexe.
+ if (pnacl_options->is_debug)
+ return false;
+ // Only use Subzero for optlevel=0.
+ if (pnacl_options->opt_level != 0)
+ return false;
+ // Check a whitelist of architectures.
+ const char* arch = GetSandboxArch();
+ if (strcmp(arch, "x86-32") == 0)
+ return true;
+ if (strcmp(arch, "x86-64") == 0)
+ return true;
+
+ return false;
+}
+
PP_Bool ManifestGetProgramURL(PP_Instance instance,
PP_Var* pp_full_url,
PP_PNaClOptions* pnacl_options,
@@ -1103,21 +1125,10 @@ PP_Bool ManifestGetProgramURL(PP_Instance instance,
&error_info)) {
*pp_full_url = ppapi::StringVar::StringToPPVar(full_url);
*pp_uses_nonsfi_mode = PP_FromBool(uses_nonsfi_mode);
- // Check if we should use Subzero (x86-32 / non-debugging case for now).
- // TODO(stichnot): When phasing in Subzero for a new target architecture,
- // add it behind the --enable-pnacl-subzero flag, and add a clause here:
- // && base::CommandLine::ForCurrentProcess()->HasSwitch(
- // switches::kEnablePNaClSubzero)
- // Also modify the ValidationCacheOfTranslatorNexes test to match. When
- // Subzero is finally fully released for all sandbox architectures, the
- // --enable-pnacl-subzero flag can be removed.
- if (pnacl_options->opt_level == 0 && !pnacl_options->is_debug) {
- const char* arch = GetSandboxArch();
- if (strcmp(arch, "x86-32") == 0 || strcmp(arch, "x86-64") == 0) {
- pnacl_options->use_subzero = PP_TRUE;
- // Subzero -O2 is closer to LLC -O0, so indicate -O2.
- pnacl_options->opt_level = 2;
- }
+ if (ShouldUseSubzero(pnacl_options)) {
+ pnacl_options->use_subzero = PP_TRUE;
+ // Subzero -O2 is closer to LLC -O0, so indicate -O2.
+ pnacl_options->opt_level = 2;
}
return PP_TRUE;
}