| 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 638 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   649   struct FunctionTableIndices : public ZoneObject { |   649   struct FunctionTableIndices : public ZoneObject { | 
|   650     uint32_t start_index; |   650     uint32_t start_index; | 
|   651     uint32_t signature_index; |   651     uint32_t signature_index; | 
|   652   }; |   652   }; | 
|   653  |   653  | 
|   654   void InsertFunctionTable(Variable* v, uint32_t start_index, |   654   void InsertFunctionTable(Variable* v, uint32_t start_index, | 
|   655                            uint32_t signature_index) { |   655                            uint32_t signature_index) { | 
|   656     FunctionTableIndices* container = new (zone()) FunctionTableIndices(); |   656     FunctionTableIndices* container = new (zone()) FunctionTableIndices(); | 
|   657     container->start_index = start_index; |   657     container->start_index = start_index; | 
|   658     container->signature_index = signature_index; |   658     container->signature_index = signature_index; | 
|   659     ZoneHashMap::Entry* entry = function_tables_.LookupOrInsert( |   659     ZoneHashMap::Entry* entry = | 
|   660         v, ComputePointerHash(v), ZoneAllocationPolicy(zone())); |   660         function_tables_.LookupOrInsert(v, ComputePointerHash(v)); | 
|   661     entry->value = container; |   661     entry->value = container; | 
|   662   } |   662   } | 
|   663  |   663  | 
|   664   FunctionTableIndices* LookupFunctionTable(Variable* v) { |   664   FunctionTableIndices* LookupFunctionTable(Variable* v) { | 
|   665     ZoneHashMap::Entry* entry = |   665     ZoneHashMap::Entry* entry = | 
|   666         function_tables_.Lookup(v, ComputePointerHash(v)); |   666         function_tables_.Lookup(v, ComputePointerHash(v)); | 
|   667     DCHECK_NOT_NULL(entry); |   667     DCHECK_NOT_NULL(entry); | 
|   668     return reinterpret_cast<FunctionTableIndices*>(entry->value); |   668     return reinterpret_cast<FunctionTableIndices*>(entry->value); | 
|   669   } |   669   } | 
|   670  |   670  | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
|   685    public: |   685    public: | 
|   686     explicit ImportedFunctionTable(AsmWasmBuilderImpl* builder) |   686     explicit ImportedFunctionTable(AsmWasmBuilderImpl* builder) | 
|   687         : table_(base::HashMap::PointersMatch, |   687         : table_(base::HashMap::PointersMatch, | 
|   688                  ZoneHashMap::kDefaultHashMapCapacity, |   688                  ZoneHashMap::kDefaultHashMapCapacity, | 
|   689                  ZoneAllocationPolicy(builder->zone())), |   689                  ZoneAllocationPolicy(builder->zone())), | 
|   690           builder_(builder) {} |   690           builder_(builder) {} | 
|   691  |   691  | 
|   692     void AddImport(Variable* v, const char* name, int name_length) { |   692     void AddImport(Variable* v, const char* name, int name_length) { | 
|   693       ImportedFunctionIndices* indices = new (builder_->zone()) |   693       ImportedFunctionIndices* indices = new (builder_->zone()) | 
|   694           ImportedFunctionIndices(name, name_length, builder_->zone()); |   694           ImportedFunctionIndices(name, name_length, builder_->zone()); | 
|   695       ZoneHashMap::Entry* entry = table_.LookupOrInsert( |   695       ZoneHashMap::Entry* entry = | 
|   696           v, ComputePointerHash(v), ZoneAllocationPolicy(builder_->zone())); |   696           table_.LookupOrInsert(v, ComputePointerHash(v)); | 
|   697       entry->value = indices; |   697       entry->value = indices; | 
|   698     } |   698     } | 
|   699  |   699  | 
|   700     uint32_t GetFunctionIndex(Variable* v, FunctionSig* sig) { |   700     uint32_t GetFunctionIndex(Variable* v, FunctionSig* sig) { | 
|   701       ZoneHashMap::Entry* entry = table_.Lookup(v, ComputePointerHash(v)); |   701       ZoneHashMap::Entry* entry = table_.Lookup(v, ComputePointerHash(v)); | 
|   702       DCHECK_NOT_NULL(entry); |   702       DCHECK_NOT_NULL(entry); | 
|   703       ImportedFunctionIndices* indices = |   703       ImportedFunctionIndices* indices = | 
|   704           reinterpret_cast<ImportedFunctionIndices*>(entry->value); |   704           reinterpret_cast<ImportedFunctionIndices*>(entry->value); | 
|   705       WasmModuleBuilder::SignatureMap::iterator pos = |   705       WasmModuleBuilder::SignatureMap::iterator pos = | 
|   706           indices->signature_to_index_.find(sig); |   706           indices->signature_to_index_.find(sig); | 
| (...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1679   uint32_t LookupOrInsertLocal(Variable* v, LocalType type) { |  1679   uint32_t LookupOrInsertLocal(Variable* v, LocalType type) { | 
|  1680     DCHECK_NOT_NULL(current_function_builder_); |  1680     DCHECK_NOT_NULL(current_function_builder_); | 
|  1681     ZoneHashMap::Entry* entry = |  1681     ZoneHashMap::Entry* entry = | 
|  1682         local_variables_.Lookup(v, ComputePointerHash(v)); |  1682         local_variables_.Lookup(v, ComputePointerHash(v)); | 
|  1683     if (entry == nullptr) { |  1683     if (entry == nullptr) { | 
|  1684       uint32_t index; |  1684       uint32_t index; | 
|  1685       DCHECK(!v->IsParameter()); |  1685       DCHECK(!v->IsParameter()); | 
|  1686       index = current_function_builder_->AddLocal(type); |  1686       index = current_function_builder_->AddLocal(type); | 
|  1687       IndexContainer* container = new (zone()) IndexContainer(); |  1687       IndexContainer* container = new (zone()) IndexContainer(); | 
|  1688       container->index = index; |  1688       container->index = index; | 
|  1689       entry = local_variables_.LookupOrInsert(v, ComputePointerHash(v), |  1689       entry = local_variables_.LookupOrInsert(v, ComputePointerHash(v)); | 
|  1690                                               ZoneAllocationPolicy(zone())); |  | 
|  1691       entry->value = container; |  1690       entry->value = container; | 
|  1692     } |  1691     } | 
|  1693     return (reinterpret_cast<IndexContainer*>(entry->value))->index; |  1692     return (reinterpret_cast<IndexContainer*>(entry->value))->index; | 
|  1694   } |  1693   } | 
|  1695  |  1694  | 
|  1696   void InsertParameter(Variable* v, LocalType type, uint32_t index) { |  1695   void InsertParameter(Variable* v, LocalType type, uint32_t index) { | 
|  1697     DCHECK(v->IsParameter()); |  1696     DCHECK(v->IsParameter()); | 
|  1698     DCHECK_NOT_NULL(current_function_builder_); |  1697     DCHECK_NOT_NULL(current_function_builder_); | 
|  1699     ZoneHashMap::Entry* entry = |  1698     ZoneHashMap::Entry* entry = | 
|  1700         local_variables_.Lookup(v, ComputePointerHash(v)); |  1699         local_variables_.Lookup(v, ComputePointerHash(v)); | 
|  1701     DCHECK_NULL(entry); |  1700     DCHECK_NULL(entry); | 
|  1702     IndexContainer* container = new (zone()) IndexContainer(); |  1701     IndexContainer* container = new (zone()) IndexContainer(); | 
|  1703     container->index = index; |  1702     container->index = index; | 
|  1704     entry = local_variables_.LookupOrInsert(v, ComputePointerHash(v), |  1703     entry = local_variables_.LookupOrInsert(v, ComputePointerHash(v)); | 
|  1705                                             ZoneAllocationPolicy(zone())); |  | 
|  1706     entry->value = container; |  1704     entry->value = container; | 
|  1707   } |  1705   } | 
|  1708  |  1706  | 
|  1709   uint32_t LookupOrInsertGlobal(Variable* v, LocalType type) { |  1707   uint32_t LookupOrInsertGlobal(Variable* v, LocalType type) { | 
|  1710     ZoneHashMap::Entry* entry = |  1708     ZoneHashMap::Entry* entry = | 
|  1711         global_variables_.Lookup(v, ComputePointerHash(v)); |  1709         global_variables_.Lookup(v, ComputePointerHash(v)); | 
|  1712     if (entry == nullptr) { |  1710     if (entry == nullptr) { | 
|  1713       uint32_t index = builder_->AddGlobal(type, 0); |  1711       uint32_t index = builder_->AddGlobal(type, 0); | 
|  1714       IndexContainer* container = new (zone()) IndexContainer(); |  1712       IndexContainer* container = new (zone()) IndexContainer(); | 
|  1715       container->index = index; |  1713       container->index = index; | 
|  1716       entry = global_variables_.LookupOrInsert(v, ComputePointerHash(v), |  1714       entry = global_variables_.LookupOrInsert(v, ComputePointerHash(v)); | 
|  1717                                                ZoneAllocationPolicy(zone())); |  | 
|  1718       entry->value = container; |  1715       entry->value = container; | 
|  1719     } |  1716     } | 
|  1720     return (reinterpret_cast<IndexContainer*>(entry->value))->index; |  1717     return (reinterpret_cast<IndexContainer*>(entry->value))->index; | 
|  1721   } |  1718   } | 
|  1722  |  1719  | 
|  1723   uint32_t LookupOrInsertFunction(Variable* v) { |  1720   uint32_t LookupOrInsertFunction(Variable* v) { | 
|  1724     DCHECK_NOT_NULL(builder_); |  1721     DCHECK_NOT_NULL(builder_); | 
|  1725     ZoneHashMap::Entry* entry = functions_.Lookup(v, ComputePointerHash(v)); |  1722     ZoneHashMap::Entry* entry = functions_.Lookup(v, ComputePointerHash(v)); | 
|  1726     if (entry == nullptr) { |  1723     if (entry == nullptr) { | 
|  1727       uint32_t index = builder_->AddFunction(); |  1724       uint32_t index = builder_->AddFunction(); | 
|  1728       IndexContainer* container = new (zone()) IndexContainer(); |  1725       IndexContainer* container = new (zone()) IndexContainer(); | 
|  1729       container->index = index; |  1726       container->index = index; | 
|  1730       entry = functions_.LookupOrInsert(v, ComputePointerHash(v), |  1727       entry = functions_.LookupOrInsert(v, ComputePointerHash(v)); | 
|  1731                                         ZoneAllocationPolicy(zone())); |  | 
|  1732       entry->value = container; |  1728       entry->value = container; | 
|  1733     } |  1729     } | 
|  1734     return (reinterpret_cast<IndexContainer*>(entry->value))->index; |  1730     return (reinterpret_cast<IndexContainer*>(entry->value))->index; | 
|  1735   } |  1731   } | 
|  1736  |  1732  | 
|  1737   LocalType TypeOf(Expression* expr) { return TypeFrom(typer_->TypeOf(expr)); } |  1733   LocalType TypeOf(Expression* expr) { return TypeFrom(typer_->TypeOf(expr)); } | 
|  1738  |  1734  | 
|  1739   LocalType TypeFrom(AsmType* type) { |  1735   LocalType TypeFrom(AsmType* type) { | 
|  1740     if (type->IsA(AsmType::Intish())) { |  1736     if (type->IsA(AsmType::Intish())) { | 
|  1741       return kAstI32; |  1737       return kAstI32; | 
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1788   AsmWasmBuilderImpl impl(isolate_, zone_, literal_, typer_); |  1784   AsmWasmBuilderImpl impl(isolate_, zone_, literal_, typer_); | 
|  1789   impl.Build(); |  1785   impl.Build(); | 
|  1790   *foreign_args = impl.GetForeignArgs(); |  1786   *foreign_args = impl.GetForeignArgs(); | 
|  1791   ZoneBuffer* buffer = new (zone_) ZoneBuffer(zone_); |  1787   ZoneBuffer* buffer = new (zone_) ZoneBuffer(zone_); | 
|  1792   impl.builder_->WriteTo(*buffer); |  1788   impl.builder_->WriteTo(*buffer); | 
|  1793   return buffer; |  1789   return buffer; | 
|  1794 } |  1790 } | 
|  1795 }  // namespace wasm |  1791 }  // namespace wasm | 
|  1796 }  // namespace internal |  1792 }  // namespace internal | 
|  1797 }  // namespace v8 |  1793 }  // namespace v8 | 
| OLD | NEW |