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

Side by Side Diff: ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc

Issue 447013002: Pepper: Fix caching for translated nexes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h" 5 #include "ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "native_client/src/include/checked_cast.h" 10 #include "native_client/src/include/checked_cast.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 pp::Var attrs_var(pp::PASS_REF, 56 pp::Var attrs_var(pp::PASS_REF,
57 plugin->nacl_interface()->GetCpuFeatureAttrs()); 57 plugin->nacl_interface()->GetCpuFeatureAttrs());
58 return attrs_var.AsString(); 58 return attrs_var.AsString();
59 } 59 }
60 60
61 void DidCacheHit(void* user_data, PP_FileHandle nexe_file_handle) { 61 void DidCacheHit(void* user_data, PP_FileHandle nexe_file_handle) {
62 PnaclCoordinator* coordinator = static_cast<PnaclCoordinator*>(user_data); 62 PnaclCoordinator* coordinator = static_cast<PnaclCoordinator*>(user_data);
63 coordinator->BitcodeStreamCacheHit(nexe_file_handle); 63 coordinator->BitcodeStreamCacheHit(nexe_file_handle);
64 } 64 }
65 65
66 void DidCacheMiss(void* user_data, int64_t expected_pexe_size) { 66 void DidCacheMiss(void* user_data, int64_t expected_pexe_size,
67 PP_FileHandle temp_nexe_file) {
67 PnaclCoordinator* coordinator = static_cast<PnaclCoordinator*>(user_data); 68 PnaclCoordinator* coordinator = static_cast<PnaclCoordinator*>(user_data);
68 coordinator->BitcodeStreamCacheMiss(expected_pexe_size); 69 coordinator->BitcodeStreamCacheMiss(expected_pexe_size,
70 temp_nexe_file);
69 } 71 }
70 72
71 void DidStreamData(void* user_data, const void* stream_data, int32_t length) { 73 void DidStreamData(void* user_data, const void* stream_data, int32_t length) {
72 PnaclCoordinator* coordinator = static_cast<PnaclCoordinator*>(user_data); 74 PnaclCoordinator* coordinator = static_cast<PnaclCoordinator*>(user_data);
73 coordinator->BitcodeStreamGotData(stream_data, length); 75 coordinator->BitcodeStreamGotData(stream_data, length);
74 } 76 }
75 77
76 void DidFinishStream(void* user_data, int32_t pp_error) { 78 void DidFinishStream(void* user_data, int32_t pp_error) {
77 PnaclCoordinator* coordinator = static_cast<PnaclCoordinator*>(user_data); 79 PnaclCoordinator* coordinator = static_cast<PnaclCoordinator*>(user_data);
78 coordinator->BitcodeStreamDidFinish(pp_error); 80 coordinator->BitcodeStreamDidFinish(pp_error);
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 nacl::string( 324 nacl::string(
323 "PnaclCoordinator: Got bad temp file handle from GetNexeFd")); 325 "PnaclCoordinator: Got bad temp file handle from GetNexeFd"));
324 BitcodeStreamDidFinish(PP_ERROR_FAILED); 326 BitcodeStreamDidFinish(PP_ERROR_FAILED);
325 return; 327 return;
326 } 328 }
327 temp_nexe_file_.reset(new TempFile(plugin_, handle)); 329 temp_nexe_file_.reset(new TempFile(plugin_, handle));
328 // Open it for reading as the cached nexe file. 330 // Open it for reading as the cached nexe file.
329 NexeReadDidOpen(temp_nexe_file_->Open(false)); 331 NexeReadDidOpen(temp_nexe_file_->Open(false));
330 } 332 }
331 333
332 void PnaclCoordinator::BitcodeStreamCacheMiss(int64_t expected_pexe_size) { 334 void PnaclCoordinator::BitcodeStreamCacheMiss(int64_t expected_pexe_size,
335 PP_FileHandle nexe_handle) {
333 expected_pexe_size_ = expected_pexe_size; 336 expected_pexe_size_ = expected_pexe_size;
334 337
335 for (int i = 0; i < split_module_count_; i++) { 338 for (int i = 0; i < split_module_count_; i++) {
336 PP_FileHandle obj_handle = 339 PP_FileHandle obj_handle =
337 plugin_->nacl_interface()->CreateTemporaryFile(plugin_->pp_instance()); 340 plugin_->nacl_interface()->CreateTemporaryFile(plugin_->pp_instance());
338 nacl::scoped_ptr<TempFile> temp_file(new TempFile(plugin_, obj_handle)); 341 nacl::scoped_ptr<TempFile> temp_file(new TempFile(plugin_, obj_handle));
339 int32_t pp_error = temp_file->Open(true); 342 int32_t pp_error = temp_file->Open(true);
340 if (pp_error != PP_OK) { 343 if (pp_error != PP_OK) {
341 ReportPpapiError(PP_NACL_ERROR_PNACL_CREATE_TEMP, 344 ReportPpapiError(PP_NACL_ERROR_PNACL_CREATE_TEMP,
342 pp_error, 345 pp_error,
343 "Failed to open scratch object file."); 346 "Failed to open scratch object file.");
344 return; 347 return;
345 } else { 348 } else {
346 obj_files_.push_back(temp_file.release()); 349 obj_files_.push_back(temp_file.release());
347 } 350 }
348 } 351 }
349 invalid_desc_wrapper_.reset(plugin_->wrapper_factory()->MakeInvalid()); 352 invalid_desc_wrapper_.reset(plugin_->wrapper_factory()->MakeInvalid());
350 353
351 PP_FileHandle nexe_handle =
352 plugin_->nacl_interface()->CreateTemporaryFile(plugin_->pp_instance());
353 temp_nexe_file_.reset(new TempFile(plugin_, nexe_handle)); 354 temp_nexe_file_.reset(new TempFile(plugin_, nexe_handle));
354 // Open the nexe file for connecting ld and sel_ldr. 355 // Open the nexe file for connecting ld and sel_ldr.
355 // Start translation when done with this last step of setup! 356 // Start translation when done with this last step of setup!
356 RunTranslate(temp_nexe_file_->Open(true)); 357 RunTranslate(temp_nexe_file_->Open(true));
357 } 358 }
358 359
359 void PnaclCoordinator::BitcodeStreamGotData(const void* data, int32_t length) { 360 void PnaclCoordinator::BitcodeStreamGotData(const void* data, int32_t length) {
360 DCHECK(translate_thread_.get()); 361 DCHECK(translate_thread_.get());
361 362
362 translate_thread_->PutBytes(data, length); 363 translate_thread_->PutBytes(data, length);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 invalid_desc_wrapper_.get(), 452 invalid_desc_wrapper_.get(),
452 &error_info_, 453 &error_info_,
453 resources_.get(), 454 resources_.get(),
454 &pnacl_options_, 455 &pnacl_options_,
455 architecture_attributes_, 456 architecture_attributes_,
456 this, 457 this,
457 plugin_); 458 plugin_);
458 } 459 }
459 460
460 } // namespace plugin 461 } // namespace plugin
OLDNEW
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698