OLD | NEW |
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 Loading... |
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 : public AstVisitor { | 42 class AsmWasmBuilderImpl : public AstVisitor { |
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_(HashMap::PointersMatch, | 46 : local_variables_(base::HashMap::PointersMatch, |
47 ZoneHashMap::kDefaultHashMapCapacity, | 47 ZoneHashMap::kDefaultHashMapCapacity, |
48 ZoneAllocationPolicy(zone)), | 48 ZoneAllocationPolicy(zone)), |
49 functions_(HashMap::PointersMatch, ZoneHashMap::kDefaultHashMapCapacity, | 49 functions_(base::HashMap::PointersMatch, |
| 50 ZoneHashMap::kDefaultHashMapCapacity, |
50 ZoneAllocationPolicy(zone)), | 51 ZoneAllocationPolicy(zone)), |
51 global_variables_(HashMap::PointersMatch, | 52 global_variables_(base::HashMap::PointersMatch, |
52 ZoneHashMap::kDefaultHashMapCapacity, | 53 ZoneHashMap::kDefaultHashMapCapacity, |
53 ZoneAllocationPolicy(zone)), | 54 ZoneAllocationPolicy(zone)), |
54 scope_(kModuleScope), | 55 scope_(kModuleScope), |
55 builder_(new (zone) WasmModuleBuilder(zone)), | 56 builder_(new (zone) WasmModuleBuilder(zone)), |
56 current_function_builder_(nullptr), | 57 current_function_builder_(nullptr), |
57 literal_(literal), | 58 literal_(literal), |
58 isolate_(isolate), | 59 isolate_(isolate), |
59 zone_(zone), | 60 zone_(zone), |
60 typer_(typer), | 61 typer_(typer), |
61 cache_(TypeCache::Get()), | 62 cache_(TypeCache::Get()), |
62 breakable_blocks_(zone), | 63 breakable_blocks_(zone), |
63 foreign_variables_(zone), | 64 foreign_variables_(zone), |
64 init_function_index_(0), | 65 init_function_index_(0), |
65 foreign_init_function_index_(0), | 66 foreign_init_function_index_(0), |
66 next_table_index_(0), | 67 next_table_index_(0), |
67 function_tables_(HashMap::PointersMatch, | 68 function_tables_(base::HashMap::PointersMatch, |
68 ZoneHashMap::kDefaultHashMapCapacity, | 69 ZoneHashMap::kDefaultHashMapCapacity, |
69 ZoneAllocationPolicy(zone)), | 70 ZoneAllocationPolicy(zone)), |
70 imported_function_table_(this), | 71 imported_function_table_(this), |
71 bounds_(typer->bounds()) { | 72 bounds_(typer->bounds()) { |
72 InitializeAstVisitor(isolate); | 73 InitializeAstVisitor(isolate); |
73 } | 74 } |
74 | 75 |
75 void InitializeInitFunction() { | 76 void InitializeInitFunction() { |
76 init_function_index_ = builder_->AddFunction(); | 77 init_function_index_ = builder_->AddFunction(); |
77 FunctionSig::Builder b(zone(), 0, 0); | 78 FunctionSig::Builder b(zone(), 0, 0); |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 WasmModuleBuilder::SignatureMap signature_to_index_; | 681 WasmModuleBuilder::SignatureMap signature_to_index_; |
681 | 682 |
682 ImportedFunctionIndices(const char* name, int name_length, Zone* zone) | 683 ImportedFunctionIndices(const char* name, int name_length, Zone* zone) |
683 : name_(name), name_length_(name_length), signature_to_index_(zone) {} | 684 : name_(name), name_length_(name_length), signature_to_index_(zone) {} |
684 }; | 685 }; |
685 ZoneHashMap table_; | 686 ZoneHashMap table_; |
686 AsmWasmBuilderImpl* builder_; | 687 AsmWasmBuilderImpl* builder_; |
687 | 688 |
688 public: | 689 public: |
689 explicit ImportedFunctionTable(AsmWasmBuilderImpl* builder) | 690 explicit ImportedFunctionTable(AsmWasmBuilderImpl* builder) |
690 : table_(HashMap::PointersMatch, ZoneHashMap::kDefaultHashMapCapacity, | 691 : table_(base::HashMap::PointersMatch, |
| 692 ZoneHashMap::kDefaultHashMapCapacity, |
691 ZoneAllocationPolicy(builder->zone())), | 693 ZoneAllocationPolicy(builder->zone())), |
692 builder_(builder) {} | 694 builder_(builder) {} |
693 | 695 |
694 void AddImport(Variable* v, const char* name, int name_length) { | 696 void AddImport(Variable* v, const char* name, int name_length) { |
695 ImportedFunctionIndices* indices = new (builder_->zone()) | 697 ImportedFunctionIndices* indices = new (builder_->zone()) |
696 ImportedFunctionIndices(name, name_length, builder_->zone()); | 698 ImportedFunctionIndices(name, name_length, builder_->zone()); |
697 ZoneHashMap::Entry* entry = table_.LookupOrInsert( | 699 ZoneHashMap::Entry* entry = table_.LookupOrInsert( |
698 v, ComputePointerHash(v), ZoneAllocationPolicy(builder_->zone())); | 700 v, ComputePointerHash(v), ZoneAllocationPolicy(builder_->zone())); |
699 entry->value = indices; | 701 entry->value = indices; |
700 } | 702 } |
(...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1763 AsmWasmBuilderImpl impl(isolate_, zone_, literal_, typer_); | 1765 AsmWasmBuilderImpl impl(isolate_, zone_, literal_, typer_); |
1764 impl.Build(); | 1766 impl.Build(); |
1765 *foreign_args = impl.GetForeignArgs(); | 1767 *foreign_args = impl.GetForeignArgs(); |
1766 ZoneBuffer* buffer = new (zone_) ZoneBuffer(zone_); | 1768 ZoneBuffer* buffer = new (zone_) ZoneBuffer(zone_); |
1767 impl.builder_->WriteTo(*buffer); | 1769 impl.builder_->WriteTo(*buffer); |
1768 return buffer; | 1770 return buffer; |
1769 } | 1771 } |
1770 } // namespace wasm | 1772 } // namespace wasm |
1771 } // namespace internal | 1773 } // namespace internal |
1772 } // namespace v8 | 1774 } // namespace v8 |
OLD | NEW |