| Index: ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc
|
| diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc
|
| index e94de5f05db245cfa48e92d4eb52a7face5c0628..464dfa86d756d463dd683356388cf37e1bb586ba 100644
|
| --- a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc
|
| +++ b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc
|
| @@ -397,6 +397,8 @@ class PnaclLDManifest : public Manifest {
|
| const Manifest* extension_manifest_;
|
| };
|
|
|
| +static int64_t start_download_time = 0;
|
| +
|
| //////////////////////////////////////////////////////////////////////
|
| // The coordinator class.
|
| //////////////////////////////////////////////////////////////////////
|
| @@ -426,6 +428,8 @@ PnaclCoordinator* PnaclCoordinator::BitcodeToNative(
|
| resource_urls,
|
| resources_cb));
|
| CHECK(coordinator->resources_ != NULL);
|
| +
|
| + start_download_time = NaClGetTimeOfDayMicroseconds();
|
| coordinator->resources_->StartDownloads();
|
| // ResourcesDidLoad will be invoked when all resources have been received.
|
| return coordinator;
|
| @@ -623,9 +627,78 @@ void PnaclCoordinator::TranslateFailed(const nacl::string& error_string) {
|
| core->CallOnMainThread(0, report_translate_finished_, PP_ERROR_FAILED);
|
| }
|
|
|
| +
|
| +// DEBUGGING test junk -- to be removed before checkin and replaced
|
| +// with something like a test...
|
| +static void TestPnaclOpenFile(const nacl::string& filename, bool expect_works) {
|
| + PLUGIN_PRINTF(("JAN calling get_readonly_pnacl_fd: %s\n", filename.c_str()));
|
| + int fd = get_readonly_pnacl_fd(filename.c_str());
|
| + const char *expect_success_msg = expect_works ? "YAY!" : "NOO!";
|
| + const char *expect_fail_msg = expect_works ? "NOO!" : "YAY!";
|
| +
|
| + if (fd < 0) {
|
| + PLUGIN_PRINTF(("JAN get %s failed (fd='%d') %s\n",
|
| + filename.c_str(), fd, expect_fail_msg));
|
| + } else {
|
| + PLUGIN_PRINTF(("JAN get %s succeeded (fd='%d') %s\n",
|
| + filename.c_str(), fd, expect_success_msg));
|
| + // Try to stat the mofo.
|
| + struct stat stat_buf;
|
| + if (0 != fstat(fd, &stat_buf)) {
|
| + PLUGIN_PRINTF(("JAN stat %s fd failed: %s\n",
|
| + filename.c_str(), expect_fail_msg));
|
| + } else {
|
| + PLUGIN_PRINTF(("JAN stat %s fd (size='%d') succeed: %s\n",
|
| + filename.c_str(), stat_buf.st_size, expect_success_msg));
|
| + }
|
| + close(fd);
|
| + PLUGIN_PRINTF(("JAN got fd for %s and now closing: %d\n",
|
| + filename.c_str(), fd));
|
| + }
|
| +}
|
| +
|
| +static void WINAPI DoTestFileOpens(void* arg) {
|
| + nacl::string sandbox_isa = GetSandboxISA();
|
| + TestPnaclOpenFile(sandbox_isa + nacl::string("llc"), true);
|
| + TestPnaclOpenFile(sandbox_isa + "ld", true);
|
| + TestPnaclOpenFile(sandbox_isa + "crtbegin.o", true);
|
| + TestPnaclOpenFile("non-existent-file", false);
|
| + TestPnaclOpenFile("../../chrome_shutdown_ms.txt", false);
|
| + TestPnaclOpenFile("/bin/ls", false);
|
| + TestPnaclOpenFile("$HOME/.bashrc", false);
|
| +}
|
| +// END DEBUGGING test junk.
|
| +
|
| +
|
| void PnaclCoordinator::ResourcesDidLoad(int32_t pp_error) {
|
| PLUGIN_PRINTF(("PnaclCoordinator::ResourcesDidLoad (pp_error=%"
|
| NACL_PRId32")\n", pp_error));
|
| +
|
| + int64_t end_download_time = NaClGetTimeOfDayMicroseconds();
|
| + PLUGIN_PRINTF(("PnaclCoordinator:: url load time total=%"NACL_PRId64")\n",
|
| + end_download_time - start_download_time));
|
| +
|
| + // BEGIN debugging hack.
|
| + // On thread accesses work...
|
| + PLUGIN_PRINTF(("JAN Testing from main thread.\n"));
|
| + int64_t start_download_time2 = NaClGetTimeOfDayMicroseconds();
|
| + DoTestFileOpens(NULL);
|
| + int64_t end_download_time2 = NaClGetTimeOfDayMicroseconds();
|
| + PLUGIN_PRINTF(("PnaclCoordinator::fd load time total=%"NACL_PRId64")\n",
|
| + end_download_time2 - start_download_time2));
|
| +
|
| + // Off thread use doesn't seem to work...
|
| + // PLUGIN_PRINTF(("JAN Testing from secondary thread.\n"));
|
| + // static NaClThread *debugging_file_thread = new NaClThread();
|
| + // if (!NaClThreadCreateJoinable(debugging_file_thread,
|
| + // DoTestFileOpens,
|
| + // NULL,
|
| + // 128 * 1024)) {
|
| + // PLUGIN_PRINTF(("JAN Failed to creaate test thread\n"));
|
| + // }
|
| + PLUGIN_PRINTF(("JAN Testing all done!\n"));
|
| + // END debugging.
|
| +
|
| if (pp_error != PP_OK) {
|
| ReportPpapiError(pp_error, "resources failed to load.");
|
| return;
|
| @@ -736,6 +809,7 @@ void PnaclCoordinator::RunTranslate(int32_t pp_error) {
|
| if (fd < 0) {
|
| return;
|
| }
|
| +
|
| pexe_wrapper_.reset(plugin_->wrapper_factory()->MakeFileDesc(fd, O_RDONLY));
|
| // Invoke llc followed by ld off the main thread. This allows use of
|
| // blocking RPCs that would otherwise block the JavaScript main thread.
|
|
|