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 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 WasmModuleBuilder::SignatureMap signature_to_index_; | 689 WasmModuleBuilder::SignatureMap signature_to_index_; |
689 | 690 |
690 ImportedFunctionIndices(const char* name, int name_length, Zone* zone) | 691 ImportedFunctionIndices(const char* name, int name_length, Zone* zone) |
691 : name_(name), name_length_(name_length), signature_to_index_(zone) {} | 692 : name_(name), name_length_(name_length), signature_to_index_(zone) {} |
692 }; | 693 }; |
693 ZoneHashMap table_; | 694 ZoneHashMap table_; |
694 AsmWasmBuilderImpl* builder_; | 695 AsmWasmBuilderImpl* builder_; |
695 | 696 |
696 public: | 697 public: |
697 explicit ImportedFunctionTable(AsmWasmBuilderImpl* builder) | 698 explicit ImportedFunctionTable(AsmWasmBuilderImpl* builder) |
698 : table_(HashMap::PointersMatch, ZoneHashMap::kDefaultHashMapCapacity, | 699 : table_(base::HashMap::PointersMatch, |
| 700 ZoneHashMap::kDefaultHashMapCapacity, |
699 ZoneAllocationPolicy(builder->zone())), | 701 ZoneAllocationPolicy(builder->zone())), |
700 builder_(builder) {} | 702 builder_(builder) {} |
701 | 703 |
702 void AddImport(Variable* v, const char* name, int name_length) { | 704 void AddImport(Variable* v, const char* name, int name_length) { |
703 ImportedFunctionIndices* indices = new (builder_->zone()) | 705 ImportedFunctionIndices* indices = new (builder_->zone()) |
704 ImportedFunctionIndices(name, name_length, builder_->zone()); | 706 ImportedFunctionIndices(name, name_length, builder_->zone()); |
705 ZoneHashMap::Entry* entry = table_.LookupOrInsert( | 707 ZoneHashMap::Entry* entry = table_.LookupOrInsert( |
706 v, ComputePointerHash(v), ZoneAllocationPolicy(builder_->zone())); | 708 v, ComputePointerHash(v), ZoneAllocationPolicy(builder_->zone())); |
707 entry->value = indices; | 709 entry->value = indices; |
708 } | 710 } |
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1776 AsmWasmBuilderImpl impl(isolate_, zone_, literal_, typer_); | 1778 AsmWasmBuilderImpl impl(isolate_, zone_, literal_, typer_); |
1777 impl.Build(); | 1779 impl.Build(); |
1778 *foreign_args = impl.GetForeignArgs(); | 1780 *foreign_args = impl.GetForeignArgs(); |
1779 ZoneBuffer* buffer = new (zone_) ZoneBuffer(zone_); | 1781 ZoneBuffer* buffer = new (zone_) ZoneBuffer(zone_); |
1780 impl.builder_->WriteTo(*buffer); | 1782 impl.builder_->WriteTo(*buffer); |
1781 return buffer; | 1783 return buffer; |
1782 } | 1784 } |
1783 } // namespace wasm | 1785 } // namespace wasm |
1784 } // namespace internal | 1786 } // namespace internal |
1785 } // namespace v8 | 1787 } // namespace v8 |
OLD | NEW |