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

Side by Side Diff: src/ppc/simulator-ppc.cc

Issue 2369963002: [base] Remove PointersMatch, making a separate std::equals hashmap (Closed)
Patch Set: Fix the other simulators Created 4 years, 2 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
« no previous file with comments | « src/ppc/simulator-ppc.h ('k') | src/profiler/heap-snapshot-generator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project 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 <stdarg.h> 5 #include <stdarg.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <cmath> 7 #include <cmath>
8 8
9 #if V8_TARGET_ARCH_PPC 9 #if V8_TARGET_ARCH_PPC
10 10
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 intptr_t end_page = ((start + size) & ~CachePage::kPageMask); 651 intptr_t end_page = ((start + size) & ~CachePage::kPageMask);
652 return start_page == end_page; 652 return start_page == end_page;
653 } 653 }
654 654
655 655
656 void Simulator::set_last_debugger_input(char* input) { 656 void Simulator::set_last_debugger_input(char* input) {
657 DeleteArray(last_debugger_input_); 657 DeleteArray(last_debugger_input_);
658 last_debugger_input_ = input; 658 last_debugger_input_ = input;
659 } 659 }
660 660
661 661 void Simulator::FlushICache(base::CustomMatcherHashMap* i_cache,
662 void Simulator::FlushICache(base::HashMap* i_cache, void* start_addr, 662 void* start_addr, size_t size) {
663 size_t size) {
664 intptr_t start = reinterpret_cast<intptr_t>(start_addr); 663 intptr_t start = reinterpret_cast<intptr_t>(start_addr);
665 int intra_line = (start & CachePage::kLineMask); 664 int intra_line = (start & CachePage::kLineMask);
666 start -= intra_line; 665 start -= intra_line;
667 size += intra_line; 666 size += intra_line;
668 size = ((size - 1) | CachePage::kLineMask) + 1; 667 size = ((size - 1) | CachePage::kLineMask) + 1;
669 int offset = (start & CachePage::kPageMask); 668 int offset = (start & CachePage::kPageMask);
670 while (!AllOnOnePage(start, size - 1)) { 669 while (!AllOnOnePage(start, size - 1)) {
671 int bytes_to_flush = CachePage::kPageSize - offset; 670 int bytes_to_flush = CachePage::kPageSize - offset;
672 FlushOnePage(i_cache, start, bytes_to_flush); 671 FlushOnePage(i_cache, start, bytes_to_flush);
673 start += bytes_to_flush; 672 start += bytes_to_flush;
674 size -= bytes_to_flush; 673 size -= bytes_to_flush;
675 DCHECK_EQ(0, static_cast<int>(start & CachePage::kPageMask)); 674 DCHECK_EQ(0, static_cast<int>(start & CachePage::kPageMask));
676 offset = 0; 675 offset = 0;
677 } 676 }
678 if (size != 0) { 677 if (size != 0) {
679 FlushOnePage(i_cache, start, size); 678 FlushOnePage(i_cache, start, size);
680 } 679 }
681 } 680 }
682 681
683 682 CachePage* Simulator::GetCachePage(base::CustomMatcherHashMap* i_cache,
684 CachePage* Simulator::GetCachePage(base::HashMap* i_cache, void* page) { 683 void* page) {
685 base::HashMap::Entry* entry = i_cache->LookupOrInsert(page, ICacheHash(page)); 684 base::HashMap::Entry* entry = i_cache->LookupOrInsert(page, ICacheHash(page));
686 if (entry->value == NULL) { 685 if (entry->value == NULL) {
687 CachePage* new_page = new CachePage(); 686 CachePage* new_page = new CachePage();
688 entry->value = new_page; 687 entry->value = new_page;
689 } 688 }
690 return reinterpret_cast<CachePage*>(entry->value); 689 return reinterpret_cast<CachePage*>(entry->value);
691 } 690 }
692 691
693 692
694 // Flush from start up to and not including start + size. 693 // Flush from start up to and not including start + size.
695 void Simulator::FlushOnePage(base::HashMap* i_cache, intptr_t start, int size) { 694 void Simulator::FlushOnePage(base::CustomMatcherHashMap* i_cache,
695 intptr_t start, int size) {
696 DCHECK(size <= CachePage::kPageSize); 696 DCHECK(size <= CachePage::kPageSize);
697 DCHECK(AllOnOnePage(start, size - 1)); 697 DCHECK(AllOnOnePage(start, size - 1));
698 DCHECK((start & CachePage::kLineMask) == 0); 698 DCHECK((start & CachePage::kLineMask) == 0);
699 DCHECK((size & CachePage::kLineMask) == 0); 699 DCHECK((size & CachePage::kLineMask) == 0);
700 void* page = reinterpret_cast<void*>(start & (~CachePage::kPageMask)); 700 void* page = reinterpret_cast<void*>(start & (~CachePage::kPageMask));
701 int offset = (start & CachePage::kPageMask); 701 int offset = (start & CachePage::kPageMask);
702 CachePage* cache_page = GetCachePage(i_cache, page); 702 CachePage* cache_page = GetCachePage(i_cache, page);
703 char* valid_bytemap = cache_page->ValidityByte(offset); 703 char* valid_bytemap = cache_page->ValidityByte(offset);
704 memset(valid_bytemap, CachePage::LINE_INVALID, size >> CachePage::kLineShift); 704 memset(valid_bytemap, CachePage::LINE_INVALID, size >> CachePage::kLineShift);
705 } 705 }
706 706
707 void Simulator::CheckICache(base::HashMap* i_cache, Instruction* instr) { 707 void Simulator::CheckICache(base::CustomMatcherHashMap* i_cache,
708 Instruction* instr) {
708 intptr_t address = reinterpret_cast<intptr_t>(instr); 709 intptr_t address = reinterpret_cast<intptr_t>(instr);
709 void* page = reinterpret_cast<void*>(address & (~CachePage::kPageMask)); 710 void* page = reinterpret_cast<void*>(address & (~CachePage::kPageMask));
710 void* line = reinterpret_cast<void*>(address & (~CachePage::kLineMask)); 711 void* line = reinterpret_cast<void*>(address & (~CachePage::kLineMask));
711 int offset = (address & CachePage::kPageMask); 712 int offset = (address & CachePage::kPageMask);
712 CachePage* cache_page = GetCachePage(i_cache, page); 713 CachePage* cache_page = GetCachePage(i_cache, page);
713 char* cache_valid_byte = cache_page->ValidityByte(offset); 714 char* cache_valid_byte = cache_page->ValidityByte(offset);
714 bool cache_hit = (*cache_valid_byte == CachePage::LINE_VALID); 715 bool cache_hit = (*cache_valid_byte == CachePage::LINE_VALID);
715 char* cached_line = cache_page->CachedData(offset & ~CachePage::kLineMask); 716 char* cached_line = cache_page->CachedData(offset & ~CachePage::kLineMask);
716 if (cache_hit) { 717 if (cache_hit) {
717 // Check that the data in memory matches the contents of the I-cache. 718 // Check that the data in memory matches the contents of the I-cache.
(...skipping 12 matching lines...) Expand all
730 if (isolate->simulator_initialized()) return; 731 if (isolate->simulator_initialized()) return;
731 isolate->set_simulator_initialized(true); 732 isolate->set_simulator_initialized(true);
732 ::v8::internal::ExternalReference::set_redirector(isolate, 733 ::v8::internal::ExternalReference::set_redirector(isolate,
733 &RedirectExternalReference); 734 &RedirectExternalReference);
734 } 735 }
735 736
736 737
737 Simulator::Simulator(Isolate* isolate) : isolate_(isolate) { 738 Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
738 i_cache_ = isolate_->simulator_i_cache(); 739 i_cache_ = isolate_->simulator_i_cache();
739 if (i_cache_ == NULL) { 740 if (i_cache_ == NULL) {
740 i_cache_ = new base::HashMap(&ICacheMatch); 741 i_cache_ = new base::CustomMatcherHashMap(&ICacheMatch);
741 isolate_->set_simulator_i_cache(i_cache_); 742 isolate_->set_simulator_i_cache(i_cache_);
742 } 743 }
743 Initialize(isolate); 744 Initialize(isolate);
744 // Set up simulator support first. Some of this information is needed to 745 // Set up simulator support first. Some of this information is needed to
745 // setup the architecture state. 746 // setup the architecture state.
746 #if V8_TARGET_ARCH_PPC64 747 #if V8_TARGET_ARCH_PPC64
747 size_t stack_size = FLAG_sim_stack_size * KB; 748 size_t stack_size = FLAG_sim_stack_size * KB;
748 #else 749 #else
749 size_t stack_size = MB; // allocate 1MB for stack 750 size_t stack_size = MB; // allocate 1MB for stack
750 #endif 751 #endif
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 private: 866 private:
866 void* external_function_; 867 void* external_function_;
867 uint32_t swi_instruction_; 868 uint32_t swi_instruction_;
868 ExternalReference::Type type_; 869 ExternalReference::Type type_;
869 Redirection* next_; 870 Redirection* next_;
870 intptr_t function_descriptor_[3]; 871 intptr_t function_descriptor_[3];
871 }; 872 };
872 873
873 874
874 // static 875 // static
875 void Simulator::TearDown(base::HashMap* i_cache, Redirection* first) { 876 void Simulator::TearDown(base::CustomMatcherHashMap* i_cache,
877 Redirection* first) {
876 Redirection::DeleteChain(first); 878 Redirection::DeleteChain(first);
877 if (i_cache != nullptr) { 879 if (i_cache != nullptr) {
878 for (base::HashMap::Entry* entry = i_cache->Start(); entry != nullptr; 880 for (base::HashMap::Entry* entry = i_cache->Start(); entry != nullptr;
879 entry = i_cache->Next(entry)) { 881 entry = i_cache->Next(entry)) {
880 delete static_cast<CachePage*>(entry->value); 882 delete static_cast<CachePage*>(entry->value);
881 } 883 }
882 delete i_cache; 884 delete i_cache;
883 } 885 }
884 } 886 }
885 887
(...skipping 3193 matching lines...) Expand 10 before | Expand all | Expand 10 after
4079 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp); 4081 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp);
4080 uintptr_t address = *stack_slot; 4082 uintptr_t address = *stack_slot;
4081 set_register(sp, current_sp + sizeof(uintptr_t)); 4083 set_register(sp, current_sp + sizeof(uintptr_t));
4082 return address; 4084 return address;
4083 } 4085 }
4084 } // namespace internal 4086 } // namespace internal
4085 } // namespace v8 4087 } // namespace v8
4086 4088
4087 #endif // USE_SIMULATOR 4089 #endif // USE_SIMULATOR
4088 #endif // V8_TARGET_ARCH_PPC 4090 #endif // V8_TARGET_ARCH_PPC
OLDNEW
« no previous file with comments | « src/ppc/simulator-ppc.h ('k') | src/profiler/heap-snapshot-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698