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

Side by Side Diff: src/s390/simulator-s390.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 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_S390 9 #if V8_TARGET_ARCH_S390
10 10
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 intptr_t start_page = (start & ~CachePage::kPageMask); 694 intptr_t start_page = (start & ~CachePage::kPageMask);
695 intptr_t end_page = ((start + size) & ~CachePage::kPageMask); 695 intptr_t end_page = ((start + size) & ~CachePage::kPageMask);
696 return start_page == end_page; 696 return start_page == end_page;
697 } 697 }
698 698
699 void Simulator::set_last_debugger_input(char* input) { 699 void Simulator::set_last_debugger_input(char* input) {
700 DeleteArray(last_debugger_input_); 700 DeleteArray(last_debugger_input_);
701 last_debugger_input_ = input; 701 last_debugger_input_ = input;
702 } 702 }
703 703
704 void Simulator::FlushICache(v8::internal::HashMap* i_cache, void* start_addr, 704 void Simulator::FlushICache(base::HashMap* i_cache, void* start_addr,
705 size_t size) { 705 size_t size) {
706 intptr_t start = reinterpret_cast<intptr_t>(start_addr); 706 intptr_t start = reinterpret_cast<intptr_t>(start_addr);
707 int intra_line = (start & CachePage::kLineMask); 707 int intra_line = (start & CachePage::kLineMask);
708 start -= intra_line; 708 start -= intra_line;
709 size += intra_line; 709 size += intra_line;
710 size = ((size - 1) | CachePage::kLineMask) + 1; 710 size = ((size - 1) | CachePage::kLineMask) + 1;
711 int offset = (start & CachePage::kPageMask); 711 int offset = (start & CachePage::kPageMask);
712 while (!AllOnOnePage(start, size - 1)) { 712 while (!AllOnOnePage(start, size - 1)) {
713 int bytes_to_flush = CachePage::kPageSize - offset; 713 int bytes_to_flush = CachePage::kPageSize - offset;
714 FlushOnePage(i_cache, start, bytes_to_flush); 714 FlushOnePage(i_cache, start, bytes_to_flush);
715 start += bytes_to_flush; 715 start += bytes_to_flush;
716 size -= bytes_to_flush; 716 size -= bytes_to_flush;
717 DCHECK_EQ(0, static_cast<int>(start & CachePage::kPageMask)); 717 DCHECK_EQ(0, static_cast<int>(start & CachePage::kPageMask));
718 offset = 0; 718 offset = 0;
719 } 719 }
720 if (size != 0) { 720 if (size != 0) {
721 FlushOnePage(i_cache, start, size); 721 FlushOnePage(i_cache, start, size);
722 } 722 }
723 } 723 }
724 724
725 CachePage* Simulator::GetCachePage(v8::internal::HashMap* i_cache, void* page) { 725 CachePage* Simulator::GetCachePage(base::HashMap* i_cache, void* page) {
726 v8::internal::HashMap::Entry* entry = 726 base::HashMap::Entry* entry = i_cache->LookupOrInsert(page, ICacheHash(page));
727 i_cache->LookupOrInsert(page, ICacheHash(page));
728 if (entry->value == NULL) { 727 if (entry->value == NULL) {
729 CachePage* new_page = new CachePage(); 728 CachePage* new_page = new CachePage();
730 entry->value = new_page; 729 entry->value = new_page;
731 } 730 }
732 return reinterpret_cast<CachePage*>(entry->value); 731 return reinterpret_cast<CachePage*>(entry->value);
733 } 732 }
734 733
735 // Flush from start up to and not including start + size. 734 // Flush from start up to and not including start + size.
736 void Simulator::FlushOnePage(v8::internal::HashMap* i_cache, intptr_t start, 735 void Simulator::FlushOnePage(base::HashMap* i_cache, intptr_t start,
737 int size) { 736 int size) {
738 DCHECK(size <= CachePage::kPageSize); 737 DCHECK(size <= CachePage::kPageSize);
739 DCHECK(AllOnOnePage(start, size - 1)); 738 DCHECK(AllOnOnePage(start, size - 1));
740 DCHECK((start & CachePage::kLineMask) == 0); 739 DCHECK((start & CachePage::kLineMask) == 0);
741 DCHECK((size & CachePage::kLineMask) == 0); 740 DCHECK((size & CachePage::kLineMask) == 0);
742 void* page = reinterpret_cast<void*>(start & (~CachePage::kPageMask)); 741 void* page = reinterpret_cast<void*>(start & (~CachePage::kPageMask));
743 int offset = (start & CachePage::kPageMask); 742 int offset = (start & CachePage::kPageMask);
744 CachePage* cache_page = GetCachePage(i_cache, page); 743 CachePage* cache_page = GetCachePage(i_cache, page);
745 char* valid_bytemap = cache_page->ValidityByte(offset); 744 char* valid_bytemap = cache_page->ValidityByte(offset);
746 memset(valid_bytemap, CachePage::LINE_INVALID, size >> CachePage::kLineShift); 745 memset(valid_bytemap, CachePage::LINE_INVALID, size >> CachePage::kLineShift);
747 } 746 }
748 747
749 void Simulator::CheckICache(v8::internal::HashMap* i_cache, 748 void Simulator::CheckICache(base::HashMap* i_cache, Instruction* instr) {
750 Instruction* instr) {
751 intptr_t address = reinterpret_cast<intptr_t>(instr); 749 intptr_t address = reinterpret_cast<intptr_t>(instr);
752 void* page = reinterpret_cast<void*>(address & (~CachePage::kPageMask)); 750 void* page = reinterpret_cast<void*>(address & (~CachePage::kPageMask));
753 void* line = reinterpret_cast<void*>(address & (~CachePage::kLineMask)); 751 void* line = reinterpret_cast<void*>(address & (~CachePage::kLineMask));
754 int offset = (address & CachePage::kPageMask); 752 int offset = (address & CachePage::kPageMask);
755 CachePage* cache_page = GetCachePage(i_cache, page); 753 CachePage* cache_page = GetCachePage(i_cache, page);
756 char* cache_valid_byte = cache_page->ValidityByte(offset); 754 char* cache_valid_byte = cache_page->ValidityByte(offset);
757 bool cache_hit = (*cache_valid_byte == CachePage::LINE_VALID); 755 bool cache_hit = (*cache_valid_byte == CachePage::LINE_VALID);
758 char* cached_line = cache_page->CachedData(offset & ~CachePage::kLineMask); 756 char* cached_line = cache_page->CachedData(offset & ~CachePage::kLineMask);
759 if (cache_hit) { 757 if (cache_hit) {
760 // Check that the data in memory matches the contents of the I-cache. 758 // Check that the data in memory matches the contents of the I-cache.
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
1506 EvalTable[STDY] = &Simulator::Evaluate_STDY; 1504 EvalTable[STDY] = &Simulator::Evaluate_STDY;
1507 EvalTable[CZDT] = &Simulator::Evaluate_CZDT; 1505 EvalTable[CZDT] = &Simulator::Evaluate_CZDT;
1508 EvalTable[CZXT] = &Simulator::Evaluate_CZXT; 1506 EvalTable[CZXT] = &Simulator::Evaluate_CZXT;
1509 EvalTable[CDZT] = &Simulator::Evaluate_CDZT; 1507 EvalTable[CDZT] = &Simulator::Evaluate_CDZT;
1510 EvalTable[CXZT] = &Simulator::Evaluate_CXZT; 1508 EvalTable[CXZT] = &Simulator::Evaluate_CXZT;
1511 } // NOLINT 1509 } // NOLINT
1512 1510
1513 Simulator::Simulator(Isolate* isolate) : isolate_(isolate) { 1511 Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
1514 i_cache_ = isolate_->simulator_i_cache(); 1512 i_cache_ = isolate_->simulator_i_cache();
1515 if (i_cache_ == NULL) { 1513 if (i_cache_ == NULL) {
1516 i_cache_ = new v8::internal::HashMap(&ICacheMatch); 1514 i_cache_ = new base::HashMap(&ICacheMatch);
1517 isolate_->set_simulator_i_cache(i_cache_); 1515 isolate_->set_simulator_i_cache(i_cache_);
1518 } 1516 }
1519 Initialize(isolate); 1517 Initialize(isolate);
1520 // Set up simulator support first. Some of this information is needed to 1518 // Set up simulator support first. Some of this information is needed to
1521 // setup the architecture state. 1519 // setup the architecture state.
1522 #if V8_TARGET_ARCH_S390X 1520 #if V8_TARGET_ARCH_S390X
1523 size_t stack_size = FLAG_sim_stack_size * KB; 1521 size_t stack_size = FLAG_sim_stack_size * KB;
1524 #else 1522 #else
1525 size_t stack_size = MB; // allocate 1MB for stack 1523 size_t stack_size = MB; // allocate 1MB for stack
1526 #endif 1524 #endif
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 1645
1648 private: 1646 private:
1649 void* external_function_; 1647 void* external_function_;
1650 uint32_t swi_instruction_; 1648 uint32_t swi_instruction_;
1651 ExternalReference::Type type_; 1649 ExternalReference::Type type_;
1652 Redirection* next_; 1650 Redirection* next_;
1653 intptr_t function_descriptor_[3]; 1651 intptr_t function_descriptor_[3];
1654 }; 1652 };
1655 1653
1656 // static 1654 // static
1657 void Simulator::TearDown(HashMap* i_cache, Redirection* first) { 1655 void Simulator::TearDown(base::HashMap* i_cache, Redirection* first) {
1658 Redirection::DeleteChain(first); 1656 Redirection::DeleteChain(first);
1659 if (i_cache != nullptr) { 1657 if (i_cache != nullptr) {
1660 for (HashMap::Entry* entry = i_cache->Start(); entry != nullptr; 1658 for (base::HashMap::Entry* entry = i_cache->Start(); entry != nullptr;
1661 entry = i_cache->Next(entry)) { 1659 entry = i_cache->Next(entry)) {
1662 delete static_cast<CachePage*>(entry->value); 1660 delete static_cast<CachePage*>(entry->value);
1663 } 1661 }
1664 delete i_cache; 1662 delete i_cache;
1665 } 1663 }
1666 } 1664 }
1667 1665
1668 void* Simulator::RedirectExternalReference(Isolate* isolate, 1666 void* Simulator::RedirectExternalReference(Isolate* isolate,
1669 void* external_function, 1667 void* external_function,
1670 ExternalReference::Type type) { 1668 ExternalReference::Type type) {
(...skipping 10888 matching lines...) Expand 10 before | Expand all | Expand 10 after
12559 return 0; 12557 return 0;
12560 } 12558 }
12561 12559
12562 #undef EVALUATE 12560 #undef EVALUATE
12563 12561
12564 } // namespace internal 12562 } // namespace internal
12565 } // namespace v8 12563 } // namespace v8
12566 12564
12567 #endif // USE_SIMULATOR 12565 #endif // USE_SIMULATOR
12568 #endif // V8_TARGET_ARCH_S390 12566 #endif // V8_TARGET_ARCH_S390
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698