1 // Copyright 2016 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "src/wasm/signature-map.h" 6 7 #include "src/signature.h" 8 9 namespace v8 { 10 namespace internal { 11 namespace wasm { 12 FindOrInsert(const FunctionSig & sig)13uint32_t SignatureMap::FindOrInsert(const FunctionSig& sig) { 14 CHECK(!frozen_); 15 auto pos = map_.find(sig); 16 if (pos != map_.end()) { 17 return pos->second; 18 } else { 19 uint32_t index = next_++; 20 map_[sig] = index; 21 return index; 22 } 23 } 24 Find(const FunctionSig & sig) const25int32_t SignatureMap::Find(const FunctionSig& sig) const { 26 auto pos = map_.find(sig); 27 if (pos != map_.end()) { 28 return static_cast<int32_t>(pos->second); 29 } else { 30 return -1; 31 } 32 } 33 34 } // namespace wasm 35 } // namespace internal 36 } // namespace v8 37