Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: src/serialize.h

Issue 7660016: Fix memory leaks in ~Zone and ~Isolate (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/isolate.cc ('k') | src/serialize.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 const int kTypeCodeCount = STUB_CACHE_TABLE + 1; 53 const int kTypeCodeCount = STUB_CACHE_TABLE + 1;
54 const int kFirstTypeCode = UNCLASSIFIED; 54 const int kFirstTypeCode = UNCLASSIFIED;
55 55
56 const int kReferenceIdBits = 16; 56 const int kReferenceIdBits = 16;
57 const int kReferenceIdMask = (1 << kReferenceIdBits) - 1; 57 const int kReferenceIdMask = (1 << kReferenceIdBits) - 1;
58 const int kReferenceTypeShift = kReferenceIdBits; 58 const int kReferenceTypeShift = kReferenceIdBits;
59 const int kDebugRegisterBits = 4; 59 const int kDebugRegisterBits = 4;
60 const int kDebugIdShift = kDebugRegisterBits; 60 const int kDebugIdShift = kDebugRegisterBits;
61 61
62 62
63 // ExternalReferenceTable is a helper class that defines the relationship
64 // between external references and their encodings. It is used to build
65 // hashmaps in ExternalReferenceEncoder and ExternalReferenceDecoder.
66 class ExternalReferenceTable {
67 public:
68 static ExternalReferenceTable* instance(Isolate* isolate);
69
70 ~ExternalReferenceTable() { }
71
72 int size() const { return refs_.length(); }
73
74 Address address(int i) { return refs_[i].address; }
75
76 uint32_t code(int i) { return refs_[i].code; }
77
78 const char* name(int i) { return refs_[i].name; }
79
80 int max_id(int code) { return max_id_[code]; }
81
82 private:
83 explicit ExternalReferenceTable(Isolate* isolate) : refs_(64) {
84 PopulateTable(isolate);
85 }
86
87 struct ExternalReferenceEntry {
88 Address address;
89 uint32_t code;
90 const char* name;
91 };
92
93 void PopulateTable(Isolate* isolate);
94
95 // For a few types of references, we can get their address from their id.
96 void AddFromId(TypeCode type,
97 uint16_t id,
98 const char* name,
99 Isolate* isolate);
100
101 // For other types of references, the caller will figure out the address.
102 void Add(Address address, TypeCode type, uint16_t id, const char* name);
103
104 List<ExternalReferenceEntry> refs_;
105 int max_id_[kTypeCodeCount];
106 };
107
108
63 class ExternalReferenceEncoder { 109 class ExternalReferenceEncoder {
64 public: 110 public:
65 ExternalReferenceEncoder(); 111 ExternalReferenceEncoder();
66 112
67 uint32_t Encode(Address key) const; 113 uint32_t Encode(Address key) const;
68 114
69 const char* NameOfAddress(Address key) const; 115 const char* NameOfAddress(Address key) const;
70 116
71 private: 117 private:
72 HashMap encodings_; 118 HashMap encodings_;
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 virtual int RootIndex(HeapObject* o) { return kInvalidRootIndex; } 627 virtual int RootIndex(HeapObject* o) { return kInvalidRootIndex; }
582 virtual bool ShouldBeInThePartialSnapshotCache(HeapObject* o) { 628 virtual bool ShouldBeInThePartialSnapshotCache(HeapObject* o) {
583 return false; 629 return false;
584 } 630 }
585 }; 631 };
586 632
587 633
588 } } // namespace v8::internal 634 } } // namespace v8::internal
589 635
590 #endif // V8_SERIALIZE_H_ 636 #endif // V8_SERIALIZE_H_
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | src/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698