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

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

Issue 2369963002: [base] Remove PointersMatch, making a separate std::equals hashmap (Closed)
Patch Set: 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
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 25 matching lines...) Expand all
36 struct ForeignVariable { 36 struct ForeignVariable {
37 Handle<Name> name; 37 Handle<Name> name;
38 Variable* var; 38 Variable* var;
39 LocalType type; 39 LocalType type;
40 }; 40 };
41 41
42 class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> { 42 class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
43 public: 43 public:
44 AsmWasmBuilderImpl(Isolate* isolate, Zone* zone, FunctionLiteral* literal, 44 AsmWasmBuilderImpl(Isolate* isolate, Zone* zone, FunctionLiteral* literal,
45 AsmTyper* typer) 45 AsmTyper* typer)
46 : local_variables_(base::HashMap::PointersMatch, 46 : local_variables_(ZoneHashMap::kDefaultHashMapCapacity,
47 ZoneHashMap::kDefaultHashMapCapacity,
48 ZoneAllocationPolicy(zone)), 47 ZoneAllocationPolicy(zone)),
49 functions_(base::HashMap::PointersMatch, 48 functions_(ZoneHashMap::kDefaultHashMapCapacity,
50 ZoneHashMap::kDefaultHashMapCapacity,
51 ZoneAllocationPolicy(zone)), 49 ZoneAllocationPolicy(zone)),
52 global_variables_(base::HashMap::PointersMatch, 50 global_variables_(ZoneHashMap::kDefaultHashMapCapacity,
53 ZoneHashMap::kDefaultHashMapCapacity,
54 ZoneAllocationPolicy(zone)), 51 ZoneAllocationPolicy(zone)),
55 scope_(kModuleScope), 52 scope_(kModuleScope),
56 builder_(new (zone) WasmModuleBuilder(zone)), 53 builder_(new (zone) WasmModuleBuilder(zone)),
57 current_function_builder_(nullptr), 54 current_function_builder_(nullptr),
58 literal_(literal), 55 literal_(literal),
59 isolate_(isolate), 56 isolate_(isolate),
60 zone_(zone), 57 zone_(zone),
61 typer_(typer), 58 typer_(typer),
62 breakable_blocks_(zone), 59 breakable_blocks_(zone),
63 foreign_variables_(zone), 60 foreign_variables_(zone),
64 init_function_index_(0), 61 init_function_index_(0),
65 foreign_init_function_index_(0), 62 foreign_init_function_index_(0),
66 next_table_index_(0), 63 next_table_index_(0),
67 function_tables_(base::HashMap::PointersMatch, 64 function_tables_(ZoneHashMap::kDefaultHashMapCapacity,
68 ZoneHashMap::kDefaultHashMapCapacity,
69 ZoneAllocationPolicy(zone)), 65 ZoneAllocationPolicy(zone)),
70 imported_function_table_(this) { 66 imported_function_table_(this) {
71 InitializeAstVisitor(isolate); 67 InitializeAstVisitor(isolate);
72 } 68 }
73 69
74 void InitializeInitFunction() { 70 void InitializeInitFunction() {
75 init_function_index_ = builder_->AddFunction(); 71 init_function_index_ = builder_->AddFunction();
76 FunctionSig::Builder b(zone(), 0, 0); 72 FunctionSig::Builder b(zone(), 0, 0);
77 current_function_builder_ = builder_->FunctionAt(init_function_index_); 73 current_function_builder_ = builder_->FunctionAt(init_function_index_);
78 current_function_builder_->SetSignature(b.Build()); 74 current_function_builder_->SetSignature(b.Build());
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 WasmModuleBuilder::SignatureMap signature_to_index_; 681 WasmModuleBuilder::SignatureMap signature_to_index_;
686 682
687 ImportedFunctionIndices(const char* name, int name_length, Zone* zone) 683 ImportedFunctionIndices(const char* name, int name_length, Zone* zone)
688 : name_(name), name_length_(name_length), signature_to_index_(zone) {} 684 : name_(name), name_length_(name_length), signature_to_index_(zone) {}
689 }; 685 };
690 ZoneHashMap table_; 686 ZoneHashMap table_;
691 AsmWasmBuilderImpl* builder_; 687 AsmWasmBuilderImpl* builder_;
692 688
693 public: 689 public:
694 explicit ImportedFunctionTable(AsmWasmBuilderImpl* builder) 690 explicit ImportedFunctionTable(AsmWasmBuilderImpl* builder)
695 : table_(base::HashMap::PointersMatch, 691 : table_(ZoneHashMap::kDefaultHashMapCapacity,
696 ZoneHashMap::kDefaultHashMapCapacity,
697 ZoneAllocationPolicy(builder->zone())), 692 ZoneAllocationPolicy(builder->zone())),
698 builder_(builder) {} 693 builder_(builder) {}
699 694
700 void AddImport(Variable* v, const char* name, int name_length) { 695 void AddImport(Variable* v, const char* name, int name_length) {
701 ImportedFunctionIndices* indices = new (builder_->zone()) 696 ImportedFunctionIndices* indices = new (builder_->zone())
702 ImportedFunctionIndices(name, name_length, builder_->zone()); 697 ImportedFunctionIndices(name, name_length, builder_->zone());
703 ZoneHashMap::Entry* entry = table_.LookupOrInsert( 698 ZoneHashMap::Entry* entry = table_.LookupOrInsert(
704 v, ComputePointerHash(v), ZoneAllocationPolicy(builder_->zone())); 699 v, ComputePointerHash(v), ZoneAllocationPolicy(builder_->zone()));
705 entry->value = indices; 700 entry->value = indices;
706 } 701 }
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after
1800 impl.builder_->WriteTo(*buffer); 1795 impl.builder_->WriteTo(*buffer);
1801 return buffer; 1796 return buffer;
1802 } 1797 }
1803 1798
1804 const char* AsmWasmBuilder::foreign_init_name = "__foreign_init__"; 1799 const char* AsmWasmBuilder::foreign_init_name = "__foreign_init__";
1805 const char* AsmWasmBuilder::single_function_name = "__single_function__"; 1800 const char* AsmWasmBuilder::single_function_name = "__single_function__";
1806 1801
1807 } // namespace wasm 1802 } // namespace wasm
1808 } // namespace internal 1803 } // namespace internal
1809 } // namespace v8 1804 } // namespace v8
OLDNEW
« no previous file with comments | « src/asmjs/asm-typer.cc ('k') | src/ast/ast.h » ('j') | src/profiler/heap-snapshot-generator.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698