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

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

Issue 2010243003: Move hashmap into base/. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 <limits.h> 5 #include <limits.h>
6 #include <stdarg.h> 6 #include <stdarg.h>
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <cmath> 8 #include <cmath>
9 9
10 #if V8_TARGET_ARCH_MIPS64 10 #if V8_TARGET_ARCH_MIPS64
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 return start_page == end_page; 795 return start_page == end_page;
796 } 796 }
797 797
798 798
799 void Simulator::set_last_debugger_input(char* input) { 799 void Simulator::set_last_debugger_input(char* input) {
800 DeleteArray(last_debugger_input_); 800 DeleteArray(last_debugger_input_);
801 last_debugger_input_ = input; 801 last_debugger_input_ = input;
802 } 802 }
803 803
804 804
805 void Simulator::FlushICache(v8::internal::HashMap* i_cache, 805 void Simulator::FlushICache(base::HashMap* i_cache,
806 void* start_addr, 806 void* start_addr,
807 size_t size) { 807 size_t size) {
808 int64_t start = reinterpret_cast<int64_t>(start_addr); 808 int64_t start = reinterpret_cast<int64_t>(start_addr);
809 int64_t intra_line = (start & CachePage::kLineMask); 809 int64_t intra_line = (start & CachePage::kLineMask);
810 start -= intra_line; 810 start -= intra_line;
811 size += intra_line; 811 size += intra_line;
812 size = ((size - 1) | CachePage::kLineMask) + 1; 812 size = ((size - 1) | CachePage::kLineMask) + 1;
813 int offset = (start & CachePage::kPageMask); 813 int offset = (start & CachePage::kPageMask);
814 while (!AllOnOnePage(start, size - 1)) { 814 while (!AllOnOnePage(start, size - 1)) {
815 int bytes_to_flush = CachePage::kPageSize - offset; 815 int bytes_to_flush = CachePage::kPageSize - offset;
816 FlushOnePage(i_cache, start, bytes_to_flush); 816 FlushOnePage(i_cache, start, bytes_to_flush);
817 start += bytes_to_flush; 817 start += bytes_to_flush;
818 size -= bytes_to_flush; 818 size -= bytes_to_flush;
819 DCHECK_EQ((int64_t)0, start & CachePage::kPageMask); 819 DCHECK_EQ((int64_t)0, start & CachePage::kPageMask);
820 offset = 0; 820 offset = 0;
821 } 821 }
822 if (size != 0) { 822 if (size != 0) {
823 FlushOnePage(i_cache, start, size); 823 FlushOnePage(i_cache, start, size);
824 } 824 }
825 } 825 }
826 826
827 827
828 CachePage* Simulator::GetCachePage(v8::internal::HashMap* i_cache, void* page) { 828 CachePage* Simulator::GetCachePage(base::HashMap* i_cache, void* page) {
829 v8::internal::HashMap::Entry* entry = 829 base::HashMap::Entry* entry =
830 i_cache->LookupOrInsert(page, ICacheHash(page)); 830 i_cache->LookupOrInsert(page, ICacheHash(page));
831 if (entry->value == NULL) { 831 if (entry->value == NULL) {
832 CachePage* new_page = new CachePage(); 832 CachePage* new_page = new CachePage();
833 entry->value = new_page; 833 entry->value = new_page;
834 } 834 }
835 return reinterpret_cast<CachePage*>(entry->value); 835 return reinterpret_cast<CachePage*>(entry->value);
836 } 836 }
837 837
838 838
839 // Flush from start up to and not including start + size. 839 // Flush from start up to and not including start + size.
840 void Simulator::FlushOnePage(v8::internal::HashMap* i_cache, intptr_t start, 840 void Simulator::FlushOnePage(base::HashMap* i_cache, intptr_t start,
841 size_t size) { 841 size_t size) {
842 DCHECK(size <= CachePage::kPageSize); 842 DCHECK(size <= CachePage::kPageSize);
843 DCHECK(AllOnOnePage(start, size - 1)); 843 DCHECK(AllOnOnePage(start, size - 1));
844 DCHECK((start & CachePage::kLineMask) == 0); 844 DCHECK((start & CachePage::kLineMask) == 0);
845 DCHECK((size & CachePage::kLineMask) == 0); 845 DCHECK((size & CachePage::kLineMask) == 0);
846 void* page = reinterpret_cast<void*>(start & (~CachePage::kPageMask)); 846 void* page = reinterpret_cast<void*>(start & (~CachePage::kPageMask));
847 int offset = (start & CachePage::kPageMask); 847 int offset = (start & CachePage::kPageMask);
848 CachePage* cache_page = GetCachePage(i_cache, page); 848 CachePage* cache_page = GetCachePage(i_cache, page);
849 char* valid_bytemap = cache_page->ValidityByte(offset); 849 char* valid_bytemap = cache_page->ValidityByte(offset);
850 memset(valid_bytemap, CachePage::LINE_INVALID, size >> CachePage::kLineShift); 850 memset(valid_bytemap, CachePage::LINE_INVALID, size >> CachePage::kLineShift);
851 } 851 }
852 852
853 853
854 void Simulator::CheckICache(v8::internal::HashMap* i_cache, 854 void Simulator::CheckICache(base::HashMap* i_cache,
855 Instruction* instr) { 855 Instruction* instr) {
856 int64_t address = reinterpret_cast<int64_t>(instr); 856 int64_t address = reinterpret_cast<int64_t>(instr);
857 void* page = reinterpret_cast<void*>(address & (~CachePage::kPageMask)); 857 void* page = reinterpret_cast<void*>(address & (~CachePage::kPageMask));
858 void* line = reinterpret_cast<void*>(address & (~CachePage::kLineMask)); 858 void* line = reinterpret_cast<void*>(address & (~CachePage::kLineMask));
859 int offset = (address & CachePage::kPageMask); 859 int offset = (address & CachePage::kPageMask);
860 CachePage* cache_page = GetCachePage(i_cache, page); 860 CachePage* cache_page = GetCachePage(i_cache, page);
861 char* cache_valid_byte = cache_page->ValidityByte(offset); 861 char* cache_valid_byte = cache_page->ValidityByte(offset);
862 bool cache_hit = (*cache_valid_byte == CachePage::LINE_VALID); 862 bool cache_hit = (*cache_valid_byte == CachePage::LINE_VALID);
863 char* cached_line = cache_page->CachedData(offset & ~CachePage::kLineMask); 863 char* cached_line = cache_page->CachedData(offset & ~CachePage::kLineMask);
864 if (cache_hit) { 864 if (cache_hit) {
(...skipping 13 matching lines...) Expand all
878 if (isolate->simulator_initialized()) return; 878 if (isolate->simulator_initialized()) return;
879 isolate->set_simulator_initialized(true); 879 isolate->set_simulator_initialized(true);
880 ::v8::internal::ExternalReference::set_redirector(isolate, 880 ::v8::internal::ExternalReference::set_redirector(isolate,
881 &RedirectExternalReference); 881 &RedirectExternalReference);
882 } 882 }
883 883
884 884
885 Simulator::Simulator(Isolate* isolate) : isolate_(isolate) { 885 Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
886 i_cache_ = isolate_->simulator_i_cache(); 886 i_cache_ = isolate_->simulator_i_cache();
887 if (i_cache_ == NULL) { 887 if (i_cache_ == NULL) {
888 i_cache_ = new v8::internal::HashMap(&ICacheMatch); 888 i_cache_ = new base::HashMap(&ICacheMatch);
889 isolate_->set_simulator_i_cache(i_cache_); 889 isolate_->set_simulator_i_cache(i_cache_);
890 } 890 }
891 Initialize(isolate); 891 Initialize(isolate);
892 // Set up simulator support first. Some of this information is needed to 892 // Set up simulator support first. Some of this information is needed to
893 // setup the architecture state. 893 // setup the architecture state.
894 stack_size_ = FLAG_sim_stack_size * KB; 894 stack_size_ = FLAG_sim_stack_size * KB;
895 stack_ = reinterpret_cast<char*>(malloc(stack_size_)); 895 stack_ = reinterpret_cast<char*>(malloc(stack_size_));
896 pc_modified_ = false; 896 pc_modified_ = false;
897 icount_ = 0; 897 icount_ = 0;
898 break_count_ = 0; 898 break_count_ = 0;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 993
994 private: 994 private:
995 void* external_function_; 995 void* external_function_;
996 uint32_t swi_instruction_; 996 uint32_t swi_instruction_;
997 ExternalReference::Type type_; 997 ExternalReference::Type type_;
998 Redirection* next_; 998 Redirection* next_;
999 }; 999 };
1000 1000
1001 1001
1002 // static 1002 // static
1003 void Simulator::TearDown(HashMap* i_cache, Redirection* first) { 1003 void Simulator::TearDown(base::HashMap* i_cache, Redirection* first) {
1004 Redirection::DeleteChain(first); 1004 Redirection::DeleteChain(first);
1005 if (i_cache != nullptr) { 1005 if (i_cache != nullptr) {
1006 for (HashMap::Entry* entry = i_cache->Start(); entry != nullptr; 1006 for (base::HashMap::Entry* entry = i_cache->Start(); entry != nullptr;
1007 entry = i_cache->Next(entry)) { 1007 entry = i_cache->Next(entry)) {
1008 delete static_cast<CachePage*>(entry->value); 1008 delete static_cast<CachePage*>(entry->value);
1009 } 1009 }
1010 delete i_cache; 1010 delete i_cache;
1011 } 1011 }
1012 } 1012 }
1013 1013
1014 1014
1015 void* Simulator::RedirectExternalReference(Isolate* isolate, 1015 void* Simulator::RedirectExternalReference(Isolate* isolate,
1016 void* external_function, 1016 void* external_function,
(...skipping 3926 matching lines...) Expand 10 before | Expand all | Expand 10 after
4943 } 4943 }
4944 4944
4945 4945
4946 #undef UNSUPPORTED 4946 #undef UNSUPPORTED
4947 } // namespace internal 4947 } // namespace internal
4948 } // namespace v8 4948 } // namespace v8
4949 4949
4950 #endif // USE_SIMULATOR 4950 #endif // USE_SIMULATOR
4951 4951
4952 #endif // V8_TARGET_ARCH_MIPS64 4952 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW
« src/base/hashmap.cc ('K') | « src/mips64/simulator-mips64.h ('k') | src/parsing/scanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698