OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/nacl/renderer/ppb_nacl_private_impl.h" | 5 #include "components/nacl/renderer/ppb_nacl_private_impl.h" |
6 | 6 |
7 #include <numeric> | 7 #include <numeric> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 base::Bind(callback, base::Passed(base::File()), 0, 0)); | 260 base::Bind(callback, base::Passed(base::File()), 0, 0)); |
261 return; | 261 return; |
262 } | 262 } |
263 | 263 |
264 std::string url; | 264 std::string url; |
265 // TODO(teravest): Clean up pnacl_options logic in JsonManifest so we don't | 265 // TODO(teravest): Clean up pnacl_options logic in JsonManifest so we don't |
266 // have to initialize it like this here. | 266 // have to initialize it like this here. |
267 PP_PNaClOptions pnacl_options; | 267 PP_PNaClOptions pnacl_options; |
268 pnacl_options.translate = PP_FALSE; | 268 pnacl_options.translate = PP_FALSE; |
269 pnacl_options.is_debug = PP_FALSE; | 269 pnacl_options.is_debug = PP_FALSE; |
| 270 pnacl_options.use_subzero = PP_FALSE; |
270 pnacl_options.opt_level = 2; | 271 pnacl_options.opt_level = 2; |
271 bool is_helper_process = process_type_ == kPNaClTranslatorProcessType; | 272 bool is_helper_process = process_type_ == kPNaClTranslatorProcessType; |
272 if (!ManifestResolveKey(pp_instance_, is_helper_process, key, &url, | 273 if (!ManifestResolveKey(pp_instance_, is_helper_process, key, &url, |
273 &pnacl_options)) { | 274 &pnacl_options)) { |
274 base::MessageLoop::current()->PostTask( | 275 base::MessageLoop::current()->PostTask( |
275 FROM_HERE, | 276 FROM_HERE, |
276 base::Bind(callback, base::Passed(base::File()), 0, 0)); | 277 base::Bind(callback, base::Passed(base::File()), 0, 0)); |
277 return; | 278 return; |
278 } | 279 } |
279 | 280 |
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1051 if (manifest == NULL) | 1052 if (manifest == NULL) |
1052 return PP_FALSE; | 1053 return PP_FALSE; |
1053 | 1054 |
1054 bool uses_nonsfi_mode; | 1055 bool uses_nonsfi_mode; |
1055 std::string full_url; | 1056 std::string full_url; |
1056 JsonManifest::ErrorInfo error_info; | 1057 JsonManifest::ErrorInfo error_info; |
1057 if (manifest->GetProgramURL(&full_url, pnacl_options, &uses_nonsfi_mode, | 1058 if (manifest->GetProgramURL(&full_url, pnacl_options, &uses_nonsfi_mode, |
1058 &error_info)) { | 1059 &error_info)) { |
1059 *pp_full_url = ppapi::StringVar::StringToPPVar(full_url); | 1060 *pp_full_url = ppapi::StringVar::StringToPPVar(full_url); |
1060 *pp_uses_nonsfi_mode = PP_FromBool(uses_nonsfi_mode); | 1061 *pp_uses_nonsfi_mode = PP_FromBool(uses_nonsfi_mode); |
| 1062 // Check if we should use Subzero (x86-32 / non-debugging case for now). |
| 1063 if (pnacl_options->opt_level == 0 && !pnacl_options->is_debug && |
| 1064 strcmp(GetSandboxArch(), "x86-32") == 0 && |
| 1065 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1066 switches::kEnablePNaClSubzero)) { |
| 1067 pnacl_options->use_subzero = PP_TRUE; |
| 1068 // Subzero -O2 is closer to LLC -O0, so indicate -O2. |
| 1069 pnacl_options->opt_level = 2; |
| 1070 } |
1061 return PP_TRUE; | 1071 return PP_TRUE; |
1062 } | 1072 } |
1063 | 1073 |
1064 if (load_manager) | 1074 if (load_manager) |
1065 load_manager->ReportLoadError(error_info.error, error_info.string); | 1075 load_manager->ReportLoadError(error_info.error, error_info.string); |
1066 return PP_FALSE; | 1076 return PP_FALSE; |
1067 } | 1077 } |
1068 | 1078 |
1069 bool ManifestResolveKey(PP_Instance instance, | 1079 bool ManifestResolveKey(PP_Instance instance, |
1070 bool is_helper_process, | 1080 bool is_helper_process, |
(...skipping 21 matching lines...) Expand all Loading... |
1092 | 1102 |
1093 JsonManifest* manifest = GetJsonManifest(instance); | 1103 JsonManifest* manifest = GetJsonManifest(instance); |
1094 if (manifest == NULL) | 1104 if (manifest == NULL) |
1095 return false; | 1105 return false; |
1096 | 1106 |
1097 return manifest->ResolveKey(key, full_url, pnacl_options); | 1107 return manifest->ResolveKey(key, full_url, pnacl_options); |
1098 } | 1108 } |
1099 | 1109 |
1100 PP_Bool GetPNaClResourceInfo(PP_Instance instance, | 1110 PP_Bool GetPNaClResourceInfo(PP_Instance instance, |
1101 PP_Var* llc_tool_name, | 1111 PP_Var* llc_tool_name, |
1102 PP_Var* ld_tool_name) { | 1112 PP_Var* ld_tool_name, |
| 1113 PP_Var* subzero_tool_name) { |
1103 static const char kFilename[] = "chrome://pnacl-translator/pnacl.json"; | 1114 static const char kFilename[] = "chrome://pnacl-translator/pnacl.json"; |
1104 NexeLoadManager* load_manager = GetNexeLoadManager(instance); | 1115 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
1105 DCHECK(load_manager); | 1116 DCHECK(load_manager); |
1106 if (!load_manager) | 1117 if (!load_manager) |
1107 return PP_FALSE; | 1118 return PP_FALSE; |
1108 | 1119 |
1109 uint64_t nonce_lo = 0; | 1120 uint64_t nonce_lo = 0; |
1110 uint64_t nonce_hi = 0; | 1121 uint64_t nonce_hi = 0; |
1111 base::File file(GetReadonlyPnaclFd(kFilename, false /* is_executable */, | 1122 base::File file(GetReadonlyPnaclFd(kFilename, false /* is_executable */, |
1112 &nonce_lo, &nonce_hi)); | 1123 &nonce_lo, &nonce_hi)); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1169 if (!json_data.isObject()) { | 1180 if (!json_data.isObject()) { |
1170 load_manager->ReportLoadError( | 1181 load_manager->ReportLoadError( |
1171 PP_NACL_ERROR_PNACL_RESOURCE_FETCH, | 1182 PP_NACL_ERROR_PNACL_RESOURCE_FETCH, |
1172 "Parsing resource info failed: Malformed JSON dictionary"); | 1183 "Parsing resource info failed: Malformed JSON dictionary"); |
1173 return PP_FALSE; | 1184 return PP_FALSE; |
1174 } | 1185 } |
1175 | 1186 |
1176 if (json_data.isMember("pnacl-llc-name")) { | 1187 if (json_data.isMember("pnacl-llc-name")) { |
1177 Json::Value json_name = json_data["pnacl-llc-name"]; | 1188 Json::Value json_name = json_data["pnacl-llc-name"]; |
1178 if (json_name.isString()) { | 1189 if (json_name.isString()) { |
1179 std::string llc_tool_name_str = json_name.asString(); | 1190 *llc_tool_name = ppapi::StringVar::StringToPPVar(json_name.asString()); |
1180 *llc_tool_name = ppapi::StringVar::StringToPPVar(llc_tool_name_str); | |
1181 } | 1191 } |
1182 } | 1192 } |
1183 | 1193 |
1184 if (json_data.isMember("pnacl-ld-name")) { | 1194 if (json_data.isMember("pnacl-ld-name")) { |
1185 Json::Value json_name = json_data["pnacl-ld-name"]; | 1195 Json::Value json_name = json_data["pnacl-ld-name"]; |
1186 if (json_name.isString()) { | 1196 if (json_name.isString()) { |
1187 std::string ld_tool_name_str = json_name.asString(); | 1197 *ld_tool_name = ppapi::StringVar::StringToPPVar(json_name.asString()); |
1188 *ld_tool_name = ppapi::StringVar::StringToPPVar(ld_tool_name_str); | |
1189 } | 1198 } |
1190 } | 1199 } |
| 1200 |
| 1201 if (json_data.isMember("pnacl-sz-name")) { |
| 1202 Json::Value json_name = json_data["pnacl-sz-name"]; |
| 1203 if (json_name.isString()) { |
| 1204 *subzero_tool_name = |
| 1205 ppapi::StringVar::StringToPPVar(json_name.asString()); |
| 1206 } |
| 1207 } else { |
| 1208 // TODO(jvoung): remove fallback after one chrome release |
| 1209 // or when we bump the kMinPnaclVersion. |
| 1210 // TODO(jvoung): Just use strings instead of PP_Var! |
| 1211 *subzero_tool_name = ppapi::StringVar::StringToPPVar("pnacl-sz.nexe"); |
| 1212 } |
| 1213 |
1191 return PP_TRUE; | 1214 return PP_TRUE; |
1192 } | 1215 } |
1193 | 1216 |
1194 PP_Var GetCpuFeatureAttrs() { | 1217 PP_Var GetCpuFeatureAttrs() { |
1195 return ppapi::StringVar::StringToPPVar(GetCpuFeatures()); | 1218 return ppapi::StringVar::StringToPPVar(GetCpuFeatures()); |
1196 } | 1219 } |
1197 | 1220 |
1198 // Encapsulates some of the state for a call to DownloadNexe to prevent | 1221 // Encapsulates some of the state for a call to DownloadNexe to prevent |
1199 // argument lists from getting too long. | 1222 // argument lists from getting too long. |
1200 struct DownloadNexeRequest { | 1223 struct DownloadNexeRequest { |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1679 &StreamPexe | 1702 &StreamPexe |
1680 }; | 1703 }; |
1681 | 1704 |
1682 } // namespace | 1705 } // namespace |
1683 | 1706 |
1684 const PPB_NaCl_Private* GetNaClPrivateInterface() { | 1707 const PPB_NaCl_Private* GetNaClPrivateInterface() { |
1685 return &nacl_interface; | 1708 return &nacl_interface; |
1686 } | 1709 } |
1687 | 1710 |
1688 } // namespace nacl | 1711 } // namespace nacl |
OLD | NEW |