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

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: Rebase 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
« no previous file with comments | « src/s390/simulator-s390.h ('k') | src/snapshot/partial-serializer.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_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, int size) {
737 int size) {
738 DCHECK(size <= CachePage::kPageSize); 736 DCHECK(size <= CachePage::kPageSize);
739 DCHECK(AllOnOnePage(start, size - 1)); 737 DCHECK(AllOnOnePage(start, size - 1));
740 DCHECK((start & CachePage::kLineMask) == 0); 738 DCHECK((start & CachePage::kLineMask) == 0);
741 DCHECK((size & CachePage::kLineMask) == 0); 739 DCHECK((size & CachePage::kLineMask) == 0);
742 void* page = reinterpret_cast<void*>(start & (~CachePage::kPageMask)); 740 void* page = reinterpret_cast<void*>(start & (~CachePage::kPageMask));
743 int offset = (start & CachePage::kPageMask); 741 int offset = (start & CachePage::kPageMask);
744 CachePage* cache_page = GetCachePage(i_cache, page); 742 CachePage* cache_page = GetCachePage(i_cache, page);
745 char* valid_bytemap = cache_page->ValidityByte(offset); 743 char* valid_bytemap = cache_page->ValidityByte(offset);
746 memset(valid_bytemap, CachePage::LINE_INVALID, size >> CachePage::kLineShift); 744 memset(valid_bytemap, CachePage::LINE_INVALID, size >> CachePage::kLineShift);
747 } 745 }
748 746
749 void Simulator::CheckICache(v8::internal::HashMap* i_cache, 747 void Simulator::CheckICache(base::HashMap* i_cache, Instruction* instr) {
750 Instruction* instr) {
751 intptr_t address = reinterpret_cast<intptr_t>(instr); 748 intptr_t address = reinterpret_cast<intptr_t>(instr);
752 void* page = reinterpret_cast<void*>(address & (~CachePage::kPageMask)); 749 void* page = reinterpret_cast<void*>(address & (~CachePage::kPageMask));
753 void* line = reinterpret_cast<void*>(address & (~CachePage::kLineMask)); 750 void* line = reinterpret_cast<void*>(address & (~CachePage::kLineMask));
754 int offset = (address & CachePage::kPageMask); 751 int offset = (address & CachePage::kPageMask);
755 CachePage* cache_page = GetCachePage(i_cache, page); 752 CachePage* cache_page = GetCachePage(i_cache, page);
756 char* cache_valid_byte = cache_page->ValidityByte(offset); 753 char* cache_valid_byte = cache_page->ValidityByte(offset);
757 bool cache_hit = (*cache_valid_byte == CachePage::LINE_VALID); 754 bool cache_hit = (*cache_valid_byte == CachePage::LINE_VALID);
758 char* cached_line = cache_page->CachedData(offset & ~CachePage::kLineMask); 755 char* cached_line = cache_page->CachedData(offset & ~CachePage::kLineMask);
759 if (cache_hit) { 756 if (cache_hit) {
760 // Check that the data in memory matches the contents of the I-cache. 757 // 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; 1503 EvalTable[STDY] = &Simulator::Evaluate_STDY;
1507 EvalTable[CZDT] = &Simulator::Evaluate_CZDT; 1504 EvalTable[CZDT] = &Simulator::Evaluate_CZDT;
1508 EvalTable[CZXT] = &Simulator::Evaluate_CZXT; 1505 EvalTable[CZXT] = &Simulator::Evaluate_CZXT;
1509 EvalTable[CDZT] = &Simulator::Evaluate_CDZT; 1506 EvalTable[CDZT] = &Simulator::Evaluate_CDZT;
1510 EvalTable[CXZT] = &Simulator::Evaluate_CXZT; 1507 EvalTable[CXZT] = &Simulator::Evaluate_CXZT;
1511 } // NOLINT 1508 } // NOLINT
1512 1509
1513 Simulator::Simulator(Isolate* isolate) : isolate_(isolate) { 1510 Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
1514 i_cache_ = isolate_->simulator_i_cache(); 1511 i_cache_ = isolate_->simulator_i_cache();
1515 if (i_cache_ == NULL) { 1512 if (i_cache_ == NULL) {
1516 i_cache_ = new v8::internal::HashMap(&ICacheMatch); 1513 i_cache_ = new base::HashMap(&ICacheMatch);
1517 isolate_->set_simulator_i_cache(i_cache_); 1514 isolate_->set_simulator_i_cache(i_cache_);
1518 } 1515 }
1519 Initialize(isolate); 1516 Initialize(isolate);
1520 // Set up simulator support first. Some of this information is needed to 1517 // Set up simulator support first. Some of this information is needed to
1521 // setup the architecture state. 1518 // setup the architecture state.
1522 #if V8_TARGET_ARCH_S390X 1519 #if V8_TARGET_ARCH_S390X
1523 size_t stack_size = FLAG_sim_stack_size * KB; 1520 size_t stack_size = FLAG_sim_stack_size * KB;
1524 #else 1521 #else
1525 size_t stack_size = MB; // allocate 1MB for stack 1522 size_t stack_size = MB; // allocate 1MB for stack
1526 #endif 1523 #endif
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 1644
1648 private: 1645 private:
1649 void* external_function_; 1646 void* external_function_;
1650 uint32_t swi_instruction_; 1647 uint32_t swi_instruction_;
1651 ExternalReference::Type type_; 1648 ExternalReference::Type type_;
1652 Redirection* next_; 1649 Redirection* next_;
1653 intptr_t function_descriptor_[3]; 1650 intptr_t function_descriptor_[3];
1654 }; 1651 };
1655 1652
1656 // static 1653 // static
1657 void Simulator::TearDown(HashMap* i_cache, Redirection* first) { 1654 void Simulator::TearDown(base::HashMap* i_cache, Redirection* first) {
1658 Redirection::DeleteChain(first); 1655 Redirection::DeleteChain(first);
1659 if (i_cache != nullptr) { 1656 if (i_cache != nullptr) {
1660 for (HashMap::Entry* entry = i_cache->Start(); entry != nullptr; 1657 for (base::HashMap::Entry* entry = i_cache->Start(); entry != nullptr;
1661 entry = i_cache->Next(entry)) { 1658 entry = i_cache->Next(entry)) {
1662 delete static_cast<CachePage*>(entry->value); 1659 delete static_cast<CachePage*>(entry->value);
1663 } 1660 }
1664 delete i_cache; 1661 delete i_cache;
1665 } 1662 }
1666 } 1663 }
1667 1664
1668 void* Simulator::RedirectExternalReference(Isolate* isolate, 1665 void* Simulator::RedirectExternalReference(Isolate* isolate,
1669 void* external_function, 1666 void* external_function,
1670 ExternalReference::Type type) { 1667 ExternalReference::Type type) {
(...skipping 10894 matching lines...) Expand 10 before | Expand all | Expand 10 after
12565 return 0; 12562 return 0;
12566 } 12563 }
12567 12564
12568 #undef EVALUATE 12565 #undef EVALUATE
12569 12566
12570 } // namespace internal 12567 } // namespace internal
12571 } // namespace v8 12568 } // namespace v8
12572 12569
12573 #endif // USE_SIMULATOR 12570 #endif // USE_SIMULATOR
12574 #endif // V8_TARGET_ARCH_S390 12571 #endif // V8_TARGET_ARCH_S390
OLDNEW
« no previous file with comments | « src/s390/simulator-s390.h ('k') | src/snapshot/partial-serializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698