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

Side by Side Diff: src/interface.cc

Issue 11093074: Get rid of static module allocation, do it in code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed last comments; added other back-ends Created 8 years 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/interface.h ('k') | src/objects.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } 163 }
164 #endif 164 #endif
165 } 165 }
166 166
167 167
168 void Interface::DoUnify(Interface* that, bool* ok, Zone* zone) { 168 void Interface::DoUnify(Interface* that, bool* ok, Zone* zone) {
169 ASSERT(this->forward_ == NULL); 169 ASSERT(this->forward_ == NULL);
170 ASSERT(that->forward_ == NULL); 170 ASSERT(that->forward_ == NULL);
171 ASSERT(!this->IsValue()); 171 ASSERT(!this->IsValue());
172 ASSERT(!that->IsValue()); 172 ASSERT(!that->IsValue());
173 ASSERT(this->index_ == -1);
174 ASSERT(that->index_ == -1);
173 ASSERT(*ok); 175 ASSERT(*ok);
174 176
175 #ifdef DEBUG 177 #ifdef DEBUG
176 Nesting nested; 178 Nesting nested;
177 #endif 179 #endif
178 180
179 // Try to merge all members from that into this. 181 // Try to merge all members from that into this.
180 ZoneHashMap* map = that->exports_; 182 ZoneHashMap* map = that->exports_;
181 if (map != NULL) { 183 if (map != NULL) {
182 for (ZoneHashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) { 184 for (ZoneHashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) {
183 this->DoAdd(p->key, p->hash, static_cast<Interface*>(p->value), zone, ok); 185 this->DoAdd(p->key, p->hash, static_cast<Interface*>(p->value), zone, ok);
184 if (!*ok) return; 186 if (!*ok) return;
185 } 187 }
186 } 188 }
187 189
188 // If the new interface is larger than that's, then there were members in 190 // If the new interface is larger than that's, then there were members in
189 // 'this' which 'that' didn't have. If 'that' was frozen that is an error. 191 // 'this' which 'that' didn't have. If 'that' was frozen that is an error.
190 int this_size = this->exports_ == NULL ? 0 : this->exports_->occupancy(); 192 int this_size = this->exports_ == NULL ? 0 : this->exports_->occupancy();
191 int that_size = map == NULL ? 0 : map->occupancy(); 193 int that_size = map == NULL ? 0 : map->occupancy();
192 if (that->IsFrozen() && this_size > that_size) { 194 if (that->IsFrozen() && this_size > that_size) {
193 *ok = false; 195 *ok = false;
194 return; 196 return;
195 } 197 }
196 198
197 // Merge instance.
198 if (!that->instance_.is_null()) {
199 if (!this->instance_.is_null() && *this->instance_ != *that->instance_) {
200 *ok = false;
201 return;
202 }
203 this->instance_ = that->instance_;
204 }
205
206 // Merge interfaces. 199 // Merge interfaces.
207 this->flags_ |= that->flags_; 200 this->flags_ |= that->flags_;
208 that->forward_ = this; 201 that->forward_ = this;
209 } 202 }
210 203
211 204
212 #ifdef DEBUG 205 #ifdef DEBUG
213 void Interface::Print(int n) { 206 void Interface::Print(int n) {
214 int n0 = n > 0 ? n : 0; 207 int n0 = n > 0 ? n : 0;
215 208
216 if (FLAG_print_interface_details) { 209 if (FLAG_print_interface_details) {
217 PrintF("%p", static_cast<void*>(this)); 210 PrintF("%p", static_cast<void*>(this));
218 for (Interface* link = this->forward_; link != NULL; link = link->forward_) 211 for (Interface* link = this->forward_; link != NULL; link = link->forward_)
219 PrintF("->%p", static_cast<void*>(link)); 212 PrintF("->%p", static_cast<void*>(link));
220 PrintF(" "); 213 PrintF(" ");
221 } 214 }
222 215
223 if (IsUnknown()) { 216 if (IsUnknown()) {
224 PrintF("unknown\n"); 217 PrintF("unknown\n");
225 } else if (IsConst()) { 218 } else if (IsConst()) {
226 PrintF("const\n"); 219 PrintF("const\n");
227 } else if (IsValue()) { 220 } else if (IsValue()) {
228 PrintF("value\n"); 221 PrintF("value\n");
229 } else if (IsModule()) { 222 } else if (IsModule()) {
230 PrintF("module %s{", IsFrozen() ? "" : "(unresolved) "); 223 PrintF("module %d %s{", Index(), IsFrozen() ? "" : "(unresolved) ");
231 ZoneHashMap* map = Chase()->exports_; 224 ZoneHashMap* map = Chase()->exports_;
232 if (map == NULL || map->occupancy() == 0) { 225 if (map == NULL || map->occupancy() == 0) {
233 PrintF("}\n"); 226 PrintF("}\n");
234 } else if (n < 0 || n0 >= 2 * FLAG_print_interface_depth) { 227 } else if (n < 0 || n0 >= 2 * FLAG_print_interface_depth) {
235 // Avoid infinite recursion on cyclic types. 228 // Avoid infinite recursion on cyclic types.
236 PrintF("...}\n"); 229 PrintF("...}\n");
237 } else { 230 } else {
238 PrintF("\n"); 231 PrintF("\n");
239 for (ZoneHashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) { 232 for (ZoneHashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) {
240 String* name = *static_cast<String**>(p->key); 233 String* name = *static_cast<String**>(p->key);
241 Interface* interface = static_cast<Interface*>(p->value); 234 Interface* interface = static_cast<Interface*>(p->value);
242 PrintF("%*s%s : ", n0 + 2, "", name->ToAsciiArray()); 235 PrintF("%*s%s : ", n0 + 2, "", name->ToAsciiArray());
243 interface->Print(n0 + 2); 236 interface->Print(n0 + 2);
244 } 237 }
245 PrintF("%*s}\n", n0, ""); 238 PrintF("%*s}\n", n0, "");
246 } 239 }
247 } 240 }
248 } 241 }
249 #endif 242 #endif
250 243
251 } } // namespace v8::internal 244 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/interface.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698