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

Side by Side Diff: src/asmjs/asm-wasm-builder.cc

Issue 2351393003: [base] Revert "Move hashmap allocator to a field" (Closed)
Patch Set: Whoops, patch sets should build 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/asmjs/asm-typer.cc ('k') | src/ast/ast.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 "src/v8.h" 5 #include "src/v8.h"
6 6
7 // Required to get M_E etc. in MSVC. 7 // Required to get M_E etc. in MSVC.
8 #if defined(_WIN32) 8 #if defined(_WIN32)
9 #define _USE_MATH_DEFINES 9 #define _USE_MATH_DEFINES
10 #endif 10 #endif
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 struct FunctionTableIndices : public ZoneObject { 657 struct FunctionTableIndices : public ZoneObject {
658 uint32_t start_index; 658 uint32_t start_index;
659 uint32_t signature_index; 659 uint32_t signature_index;
660 }; 660 };
661 661
662 void InsertFunctionTable(Variable* v, uint32_t start_index, 662 void InsertFunctionTable(Variable* v, uint32_t start_index,
663 uint32_t signature_index) { 663 uint32_t signature_index) {
664 FunctionTableIndices* container = new (zone()) FunctionTableIndices(); 664 FunctionTableIndices* container = new (zone()) FunctionTableIndices();
665 container->start_index = start_index; 665 container->start_index = start_index;
666 container->signature_index = signature_index; 666 container->signature_index = signature_index;
667 ZoneHashMap::Entry* entry = 667 ZoneHashMap::Entry* entry = function_tables_.LookupOrInsert(
668 function_tables_.LookupOrInsert(v, ComputePointerHash(v)); 668 v, ComputePointerHash(v), ZoneAllocationPolicy(zone()));
669 entry->value = container; 669 entry->value = container;
670 } 670 }
671 671
672 FunctionTableIndices* LookupFunctionTable(Variable* v) { 672 FunctionTableIndices* LookupFunctionTable(Variable* v) {
673 ZoneHashMap::Entry* entry = 673 ZoneHashMap::Entry* entry =
674 function_tables_.Lookup(v, ComputePointerHash(v)); 674 function_tables_.Lookup(v, ComputePointerHash(v));
675 DCHECK_NOT_NULL(entry); 675 DCHECK_NOT_NULL(entry);
676 return reinterpret_cast<FunctionTableIndices*>(entry->value); 676 return reinterpret_cast<FunctionTableIndices*>(entry->value);
677 } 677 }
678 678
(...skipping 14 matching lines...) Expand all
693 public: 693 public:
694 explicit ImportedFunctionTable(AsmWasmBuilderImpl* builder) 694 explicit ImportedFunctionTable(AsmWasmBuilderImpl* builder)
695 : table_(base::HashMap::PointersMatch, 695 : table_(base::HashMap::PointersMatch,
696 ZoneHashMap::kDefaultHashMapCapacity, 696 ZoneHashMap::kDefaultHashMapCapacity,
697 ZoneAllocationPolicy(builder->zone())), 697 ZoneAllocationPolicy(builder->zone())),
698 builder_(builder) {} 698 builder_(builder) {}
699 699
700 void AddImport(Variable* v, const char* name, int name_length) { 700 void AddImport(Variable* v, const char* name, int name_length) {
701 ImportedFunctionIndices* indices = new (builder_->zone()) 701 ImportedFunctionIndices* indices = new (builder_->zone())
702 ImportedFunctionIndices(name, name_length, builder_->zone()); 702 ImportedFunctionIndices(name, name_length, builder_->zone());
703 ZoneHashMap::Entry* entry = 703 ZoneHashMap::Entry* entry = table_.LookupOrInsert(
704 table_.LookupOrInsert(v, ComputePointerHash(v)); 704 v, ComputePointerHash(v), ZoneAllocationPolicy(builder_->zone()));
705 entry->value = indices; 705 entry->value = indices;
706 } 706 }
707 707
708 uint32_t GetFunctionIndex(Variable* v, FunctionSig* sig) { 708 uint32_t GetFunctionIndex(Variable* v, FunctionSig* sig) {
709 ZoneHashMap::Entry* entry = table_.Lookup(v, ComputePointerHash(v)); 709 ZoneHashMap::Entry* entry = table_.Lookup(v, ComputePointerHash(v));
710 DCHECK_NOT_NULL(entry); 710 DCHECK_NOT_NULL(entry);
711 ImportedFunctionIndices* indices = 711 ImportedFunctionIndices* indices =
712 reinterpret_cast<ImportedFunctionIndices*>(entry->value); 712 reinterpret_cast<ImportedFunctionIndices*>(entry->value);
713 WasmModuleBuilder::SignatureMap::iterator pos = 713 WasmModuleBuilder::SignatureMap::iterator pos =
714 indices->signature_to_index_.find(sig); 714 indices->signature_to_index_.find(sig);
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 uint32_t LookupOrInsertLocal(Variable* v, LocalType type) { 1687 uint32_t LookupOrInsertLocal(Variable* v, LocalType type) {
1688 DCHECK_NOT_NULL(current_function_builder_); 1688 DCHECK_NOT_NULL(current_function_builder_);
1689 ZoneHashMap::Entry* entry = 1689 ZoneHashMap::Entry* entry =
1690 local_variables_.Lookup(v, ComputePointerHash(v)); 1690 local_variables_.Lookup(v, ComputePointerHash(v));
1691 if (entry == nullptr) { 1691 if (entry == nullptr) {
1692 uint32_t index; 1692 uint32_t index;
1693 DCHECK(!v->IsParameter()); 1693 DCHECK(!v->IsParameter());
1694 index = current_function_builder_->AddLocal(type); 1694 index = current_function_builder_->AddLocal(type);
1695 IndexContainer* container = new (zone()) IndexContainer(); 1695 IndexContainer* container = new (zone()) IndexContainer();
1696 container->index = index; 1696 container->index = index;
1697 entry = local_variables_.LookupOrInsert(v, ComputePointerHash(v)); 1697 entry = local_variables_.LookupOrInsert(v, ComputePointerHash(v),
1698 ZoneAllocationPolicy(zone()));
1698 entry->value = container; 1699 entry->value = container;
1699 } 1700 }
1700 return (reinterpret_cast<IndexContainer*>(entry->value))->index; 1701 return (reinterpret_cast<IndexContainer*>(entry->value))->index;
1701 } 1702 }
1702 1703
1703 void InsertParameter(Variable* v, LocalType type, uint32_t index) { 1704 void InsertParameter(Variable* v, LocalType type, uint32_t index) {
1704 DCHECK(v->IsParameter()); 1705 DCHECK(v->IsParameter());
1705 DCHECK_NOT_NULL(current_function_builder_); 1706 DCHECK_NOT_NULL(current_function_builder_);
1706 ZoneHashMap::Entry* entry = 1707 ZoneHashMap::Entry* entry =
1707 local_variables_.Lookup(v, ComputePointerHash(v)); 1708 local_variables_.Lookup(v, ComputePointerHash(v));
1708 DCHECK_NULL(entry); 1709 DCHECK_NULL(entry);
1709 IndexContainer* container = new (zone()) IndexContainer(); 1710 IndexContainer* container = new (zone()) IndexContainer();
1710 container->index = index; 1711 container->index = index;
1711 entry = local_variables_.LookupOrInsert(v, ComputePointerHash(v)); 1712 entry = local_variables_.LookupOrInsert(v, ComputePointerHash(v),
1713 ZoneAllocationPolicy(zone()));
1712 entry->value = container; 1714 entry->value = container;
1713 } 1715 }
1714 1716
1715 uint32_t LookupOrInsertGlobal(Variable* v, LocalType type) { 1717 uint32_t LookupOrInsertGlobal(Variable* v, LocalType type) {
1716 ZoneHashMap::Entry* entry = 1718 ZoneHashMap::Entry* entry =
1717 global_variables_.Lookup(v, ComputePointerHash(v)); 1719 global_variables_.Lookup(v, ComputePointerHash(v));
1718 if (entry == nullptr) { 1720 if (entry == nullptr) {
1719 uint32_t index = builder_->AddGlobal(type, 0); 1721 uint32_t index = builder_->AddGlobal(type, 0);
1720 IndexContainer* container = new (zone()) IndexContainer(); 1722 IndexContainer* container = new (zone()) IndexContainer();
1721 container->index = index; 1723 container->index = index;
1722 entry = global_variables_.LookupOrInsert(v, ComputePointerHash(v)); 1724 entry = global_variables_.LookupOrInsert(v, ComputePointerHash(v),
1725 ZoneAllocationPolicy(zone()));
1723 entry->value = container; 1726 entry->value = container;
1724 } 1727 }
1725 return (reinterpret_cast<IndexContainer*>(entry->value))->index; 1728 return (reinterpret_cast<IndexContainer*>(entry->value))->index;
1726 } 1729 }
1727 1730
1728 uint32_t LookupOrInsertFunction(Variable* v) { 1731 uint32_t LookupOrInsertFunction(Variable* v) {
1729 DCHECK_NOT_NULL(builder_); 1732 DCHECK_NOT_NULL(builder_);
1730 ZoneHashMap::Entry* entry = functions_.Lookup(v, ComputePointerHash(v)); 1733 ZoneHashMap::Entry* entry = functions_.Lookup(v, ComputePointerHash(v));
1731 if (entry == nullptr) { 1734 if (entry == nullptr) {
1732 uint32_t index = builder_->AddFunction(); 1735 uint32_t index = builder_->AddFunction();
1733 IndexContainer* container = new (zone()) IndexContainer(); 1736 IndexContainer* container = new (zone()) IndexContainer();
1734 container->index = index; 1737 container->index = index;
1735 entry = functions_.LookupOrInsert(v, ComputePointerHash(v)); 1738 entry = functions_.LookupOrInsert(v, ComputePointerHash(v),
1739 ZoneAllocationPolicy(zone()));
1736 entry->value = container; 1740 entry->value = container;
1737 } 1741 }
1738 return (reinterpret_cast<IndexContainer*>(entry->value))->index; 1742 return (reinterpret_cast<IndexContainer*>(entry->value))->index;
1739 } 1743 }
1740 1744
1741 LocalType TypeOf(Expression* expr) { return TypeFrom(typer_->TypeOf(expr)); } 1745 LocalType TypeOf(Expression* expr) { return TypeFrom(typer_->TypeOf(expr)); }
1742 1746
1743 LocalType TypeFrom(AsmType* type) { 1747 LocalType TypeFrom(AsmType* type) {
1744 if (type->IsA(AsmType::Intish())) { 1748 if (type->IsA(AsmType::Intish())) {
1745 return kAstI32; 1749 return kAstI32;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1796 impl.builder_->WriteTo(*buffer); 1800 impl.builder_->WriteTo(*buffer);
1797 return buffer; 1801 return buffer;
1798 } 1802 }
1799 1803
1800 const char* AsmWasmBuilder::foreign_init_name = "__foreign_init__"; 1804 const char* AsmWasmBuilder::foreign_init_name = "__foreign_init__";
1801 const char* AsmWasmBuilder::single_function_name = "__single_function__"; 1805 const char* AsmWasmBuilder::single_function_name = "__single_function__";
1802 1806
1803 } // namespace wasm 1807 } // namespace wasm
1804 } // namespace internal 1808 } // namespace internal
1805 } // namespace v8 1809 } // namespace v8
OLDNEW
« no previous file with comments | « src/asmjs/asm-typer.cc ('k') | src/ast/ast.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698