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

Side by Side Diff: src/s390/simulator-s390.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/s390/simulator-s390.h ('k') | src/zone/zone.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 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 intptr_t start_page = (start & ~CachePage::kPageMask); 653 intptr_t start_page = (start & ~CachePage::kPageMask);
654 intptr_t end_page = ((start + size) & ~CachePage::kPageMask); 654 intptr_t end_page = ((start + size) & ~CachePage::kPageMask);
655 return start_page == end_page; 655 return start_page == end_page;
656 } 656 }
657 657
658 void Simulator::set_last_debugger_input(char* input) { 658 void Simulator::set_last_debugger_input(char* input) {
659 DeleteArray(last_debugger_input_); 659 DeleteArray(last_debugger_input_);
660 last_debugger_input_ = input; 660 last_debugger_input_ = input;
661 } 661 }
662 662
663 void Simulator::FlushICache(base::HashMap* i_cache, void* start_addr, 663 void Simulator::FlushICache(base::CustomMatcherHashMap* i_cache,
664 size_t size) { 664 void* start_addr, size_t size) {
665 intptr_t start = reinterpret_cast<intptr_t>(start_addr); 665 intptr_t start = reinterpret_cast<intptr_t>(start_addr);
666 int intra_line = (start & CachePage::kLineMask); 666 int intra_line = (start & CachePage::kLineMask);
667 start -= intra_line; 667 start -= intra_line;
668 size += intra_line; 668 size += intra_line;
669 size = ((size - 1) | CachePage::kLineMask) + 1; 669 size = ((size - 1) | CachePage::kLineMask) + 1;
670 int offset = (start & CachePage::kPageMask); 670 int offset = (start & CachePage::kPageMask);
671 while (!AllOnOnePage(start, size - 1)) { 671 while (!AllOnOnePage(start, size - 1)) {
672 int bytes_to_flush = CachePage::kPageSize - offset; 672 int bytes_to_flush = CachePage::kPageSize - offset;
673 FlushOnePage(i_cache, start, bytes_to_flush); 673 FlushOnePage(i_cache, start, bytes_to_flush);
674 start += bytes_to_flush; 674 start += bytes_to_flush;
675 size -= bytes_to_flush; 675 size -= bytes_to_flush;
676 DCHECK_EQ(0, static_cast<int>(start & CachePage::kPageMask)); 676 DCHECK_EQ(0, static_cast<int>(start & CachePage::kPageMask));
677 offset = 0; 677 offset = 0;
678 } 678 }
679 if (size != 0) { 679 if (size != 0) {
680 FlushOnePage(i_cache, start, size); 680 FlushOnePage(i_cache, start, size);
681 } 681 }
682 } 682 }
683 683
684 CachePage* Simulator::GetCachePage(base::HashMap* i_cache, void* page) { 684 CachePage* Simulator::GetCachePage(base::CustomMatcherHashMap* i_cache,
685 void* page) {
685 base::HashMap::Entry* entry = i_cache->LookupOrInsert(page, ICacheHash(page)); 686 base::HashMap::Entry* entry = i_cache->LookupOrInsert(page, ICacheHash(page));
686 if (entry->value == NULL) { 687 if (entry->value == NULL) {
687 CachePage* new_page = new CachePage(); 688 CachePage* new_page = new CachePage();
688 entry->value = new_page; 689 entry->value = new_page;
689 } 690 }
690 return reinterpret_cast<CachePage*>(entry->value); 691 return reinterpret_cast<CachePage*>(entry->value);
691 } 692 }
692 693
693 // Flush from start up to and not including start + size. 694 // Flush from start up to and not including start + size.
694 void Simulator::FlushOnePage(base::HashMap* i_cache, intptr_t start, int size) { 695 void Simulator::FlushOnePage(base::CustomMatcherHashMap* i_cache,
696 intptr_t start, int size) {
695 DCHECK(size <= CachePage::kPageSize); 697 DCHECK(size <= CachePage::kPageSize);
696 DCHECK(AllOnOnePage(start, size - 1)); 698 DCHECK(AllOnOnePage(start, size - 1));
697 DCHECK((start & CachePage::kLineMask) == 0); 699 DCHECK((start & CachePage::kLineMask) == 0);
698 DCHECK((size & CachePage::kLineMask) == 0); 700 DCHECK((size & CachePage::kLineMask) == 0);
699 void* page = reinterpret_cast<void*>(start & (~CachePage::kPageMask)); 701 void* page = reinterpret_cast<void*>(start & (~CachePage::kPageMask));
700 int offset = (start & CachePage::kPageMask); 702 int offset = (start & CachePage::kPageMask);
701 CachePage* cache_page = GetCachePage(i_cache, page); 703 CachePage* cache_page = GetCachePage(i_cache, page);
702 char* valid_bytemap = cache_page->ValidityByte(offset); 704 char* valid_bytemap = cache_page->ValidityByte(offset);
703 memset(valid_bytemap, CachePage::LINE_INVALID, size >> CachePage::kLineShift); 705 memset(valid_bytemap, CachePage::LINE_INVALID, size >> CachePage::kLineShift);
704 } 706 }
705 707
706 void Simulator::CheckICache(base::HashMap* i_cache, Instruction* instr) { 708 void Simulator::CheckICache(base::CustomMatcherHashMap* i_cache,
709 Instruction* instr) {
707 intptr_t address = reinterpret_cast<intptr_t>(instr); 710 intptr_t address = reinterpret_cast<intptr_t>(instr);
708 void* page = reinterpret_cast<void*>(address & (~CachePage::kPageMask)); 711 void* page = reinterpret_cast<void*>(address & (~CachePage::kPageMask));
709 void* line = reinterpret_cast<void*>(address & (~CachePage::kLineMask)); 712 void* line = reinterpret_cast<void*>(address & (~CachePage::kLineMask));
710 int offset = (address & CachePage::kPageMask); 713 int offset = (address & CachePage::kPageMask);
711 CachePage* cache_page = GetCachePage(i_cache, page); 714 CachePage* cache_page = GetCachePage(i_cache, page);
712 char* cache_valid_byte = cache_page->ValidityByte(offset); 715 char* cache_valid_byte = cache_page->ValidityByte(offset);
713 bool cache_hit = (*cache_valid_byte == CachePage::LINE_VALID); 716 bool cache_hit = (*cache_valid_byte == CachePage::LINE_VALID);
714 char* cached_line = cache_page->CachedData(offset & ~CachePage::kLineMask); 717 char* cached_line = cache_page->CachedData(offset & ~CachePage::kLineMask);
715 if (cache_hit) { 718 if (cache_hit) {
716 // Check that the data in memory matches the contents of the I-cache. 719 // 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
1462 EvalTable[STDY] = &Simulator::Evaluate_STDY; 1465 EvalTable[STDY] = &Simulator::Evaluate_STDY;
1463 EvalTable[CZDT] = &Simulator::Evaluate_CZDT; 1466 EvalTable[CZDT] = &Simulator::Evaluate_CZDT;
1464 EvalTable[CZXT] = &Simulator::Evaluate_CZXT; 1467 EvalTable[CZXT] = &Simulator::Evaluate_CZXT;
1465 EvalTable[CDZT] = &Simulator::Evaluate_CDZT; 1468 EvalTable[CDZT] = &Simulator::Evaluate_CDZT;
1466 EvalTable[CXZT] = &Simulator::Evaluate_CXZT; 1469 EvalTable[CXZT] = &Simulator::Evaluate_CXZT;
1467 } // NOLINT 1470 } // NOLINT
1468 1471
1469 Simulator::Simulator(Isolate* isolate) : isolate_(isolate) { 1472 Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
1470 i_cache_ = isolate_->simulator_i_cache(); 1473 i_cache_ = isolate_->simulator_i_cache();
1471 if (i_cache_ == NULL) { 1474 if (i_cache_ == NULL) {
1472 i_cache_ = new base::HashMap(&ICacheMatch); 1475 i_cache_ = new base::CustomMatcherHashMap(&ICacheMatch);
1473 isolate_->set_simulator_i_cache(i_cache_); 1476 isolate_->set_simulator_i_cache(i_cache_);
1474 } 1477 }
1475 Initialize(isolate); 1478 Initialize(isolate);
1476 // Set up simulator support first. Some of this information is needed to 1479 // Set up simulator support first. Some of this information is needed to
1477 // setup the architecture state. 1480 // setup the architecture state.
1478 #if V8_TARGET_ARCH_S390X 1481 #if V8_TARGET_ARCH_S390X
1479 size_t stack_size = FLAG_sim_stack_size * KB; 1482 size_t stack_size = FLAG_sim_stack_size * KB;
1480 #else 1483 #else
1481 size_t stack_size = MB; // allocate 1MB for stack 1484 size_t stack_size = MB; // allocate 1MB for stack
1482 #endif 1485 #endif
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 1605
1603 private: 1606 private:
1604 void* external_function_; 1607 void* external_function_;
1605 uint32_t swi_instruction_; 1608 uint32_t swi_instruction_;
1606 ExternalReference::Type type_; 1609 ExternalReference::Type type_;
1607 Redirection* next_; 1610 Redirection* next_;
1608 intptr_t function_descriptor_[3]; 1611 intptr_t function_descriptor_[3];
1609 }; 1612 };
1610 1613
1611 // static 1614 // static
1612 void Simulator::TearDown(base::HashMap* i_cache, Redirection* first) { 1615 void Simulator::TearDown(base::CustomMatcherHashMap* i_cache,
1616 Redirection* first) {
1613 Redirection::DeleteChain(first); 1617 Redirection::DeleteChain(first);
1614 if (i_cache != nullptr) { 1618 if (i_cache != nullptr) {
1615 for (base::HashMap::Entry* entry = i_cache->Start(); entry != nullptr; 1619 for (base::HashMap::Entry* entry = i_cache->Start(); entry != nullptr;
1616 entry = i_cache->Next(entry)) { 1620 entry = i_cache->Next(entry)) {
1617 delete static_cast<CachePage*>(entry->value); 1621 delete static_cast<CachePage*>(entry->value);
1618 } 1622 }
1619 delete i_cache; 1623 delete i_cache;
1620 } 1624 }
1621 } 1625 }
1622 1626
(...skipping 11011 matching lines...) Expand 10 before | Expand all | Expand 10 after
12634 return 0; 12638 return 0;
12635 } 12639 }
12636 12640
12637 #undef EVALUATE 12641 #undef EVALUATE
12638 12642
12639 } // namespace internal 12643 } // namespace internal
12640 } // namespace v8 12644 } // namespace v8
12641 12645
12642 #endif // USE_SIMULATOR 12646 #endif // USE_SIMULATOR
12643 #endif // V8_TARGET_ARCH_S390 12647 #endif // V8_TARGET_ARCH_S390
OLDNEW
« no previous file with comments | « src/s390/simulator-s390.h ('k') | src/zone/zone.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698