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 #ifndef V8_EXTERNAL_REFERENCE_TABLE_H_ 6 #define V8_EXTERNAL_REFERENCE_TABLE_H_ 7 8 #include "src/address-map.h" 9 10 namespace v8 { 11 namespace internal { 12 13 class Isolate; 14 15 // ExternalReferenceTable is a helper class that defines the relationship 16 // between external references and their encodings. It is used to build 17 // hashmaps in ExternalReferenceEncoder and ExternalReferenceDecoder. 18 class ExternalReferenceTable { 19 public: 20 static ExternalReferenceTable* instance(Isolate* isolate); 21 size()22 int size() const { return refs_.length(); } address(int i)23 Address address(int i) { return refs_[i].address; } name(int i)24 const char* name(int i) { return refs_[i].name; } 25 NotAvailable()26 inline static Address NotAvailable() { return NULL; } 27 28 static const int kDeoptTableSerializeEntryCount = 64; 29 30 private: 31 struct ExternalReferenceEntry { 32 Address address; 33 const char* name; 34 }; 35 36 explicit ExternalReferenceTable(Isolate* isolate); 37 Add(Address address,const char * name)38 void Add(Address address, const char* name) { 39 ExternalReferenceEntry entry = {address, name}; 40 refs_.Add(entry); 41 } 42 43 List<ExternalReferenceEntry> refs_; 44 45 DISALLOW_COPY_AND_ASSIGN(ExternalReferenceTable); 46 }; 47 48 } // namespace internal 49 } // namespace v8 50 #endif // V8_EXTERNAL_REFERENCE_TABLE_H_ 51