| Index: src/serialize.h
|
| diff --git a/src/serialize.h b/src/serialize.h
|
| index f8282f652994fa10f752049f0efcba04f725db28..66d6fb5111ea45c2f7ecf7b1d5fed7003fd9169c 100644
|
| --- a/src/serialize.h
|
| +++ b/src/serialize.h
|
| @@ -60,6 +60,52 @@ const int kDebugRegisterBits = 4;
|
| const int kDebugIdShift = kDebugRegisterBits;
|
|
|
|
|
| +// ExternalReferenceTable is a helper class that defines the relationship
|
| +// between external references and their encodings. It is used to build
|
| +// hashmaps in ExternalReferenceEncoder and ExternalReferenceDecoder.
|
| +class ExternalReferenceTable {
|
| + public:
|
| + static ExternalReferenceTable* instance(Isolate* isolate);
|
| +
|
| + ~ExternalReferenceTable() { }
|
| +
|
| + int size() const { return refs_.length(); }
|
| +
|
| + Address address(int i) { return refs_[i].address; }
|
| +
|
| + uint32_t code(int i) { return refs_[i].code; }
|
| +
|
| + const char* name(int i) { return refs_[i].name; }
|
| +
|
| + int max_id(int code) { return max_id_[code]; }
|
| +
|
| + private:
|
| + explicit ExternalReferenceTable(Isolate* isolate) : refs_(64) {
|
| + PopulateTable(isolate);
|
| + }
|
| +
|
| + struct ExternalReferenceEntry {
|
| + Address address;
|
| + uint32_t code;
|
| + const char* name;
|
| + };
|
| +
|
| + void PopulateTable(Isolate* isolate);
|
| +
|
| + // For a few types of references, we can get their address from their id.
|
| + void AddFromId(TypeCode type,
|
| + uint16_t id,
|
| + const char* name,
|
| + Isolate* isolate);
|
| +
|
| + // For other types of references, the caller will figure out the address.
|
| + void Add(Address address, TypeCode type, uint16_t id, const char* name);
|
| +
|
| + List<ExternalReferenceEntry> refs_;
|
| + int max_id_[kTypeCodeCount];
|
| +};
|
| +
|
| +
|
| class ExternalReferenceEncoder {
|
| public:
|
| ExternalReferenceEncoder();
|
|
|