OLD | NEW |
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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 117 |
118 | 118 |
119 void Interface::Unify(Interface* that, Zone* zone, bool* ok) { | 119 void Interface::Unify(Interface* that, Zone* zone, bool* ok) { |
120 if (this->forward_) return this->Chase()->Unify(that, zone, ok); | 120 if (this->forward_) return this->Chase()->Unify(that, zone, ok); |
121 if (that->forward_) return this->Unify(that->Chase(), zone, ok); | 121 if (that->forward_) return this->Unify(that->Chase(), zone, ok); |
122 ASSERT(this->forward_ == NULL); | 122 ASSERT(this->forward_ == NULL); |
123 ASSERT(that->forward_ == NULL); | 123 ASSERT(that->forward_ == NULL); |
124 | 124 |
125 *ok = true; | 125 *ok = true; |
126 if (this == that) return; | 126 if (this == that) return; |
127 if (this->IsValue()) return that->MakeValue(ok); | 127 if (this->IsValue()) { |
128 if (that->IsValue()) return this->MakeValue(ok); | 128 that->MakeValue(ok); |
| 129 if (*ok && this->IsConst()) that->MakeConst(ok); |
| 130 return; |
| 131 } |
| 132 if (that->IsValue()) { |
| 133 this->MakeValue(ok); |
| 134 if (*ok && that->IsConst()) this->MakeConst(ok); |
| 135 return; |
| 136 } |
129 | 137 |
130 #ifdef DEBUG | 138 #ifdef DEBUG |
131 if (FLAG_print_interface_details) { | 139 if (FLAG_print_interface_details) { |
132 PrintF("%*s# Unifying...\n", Nesting::current(), ""); | 140 PrintF("%*s# Unifying...\n", Nesting::current(), ""); |
133 PrintF("%*sthis = ", Nesting::current(), ""); | 141 PrintF("%*sthis = ", Nesting::current(), ""); |
134 this->Print(Nesting::current()); | 142 this->Print(Nesting::current()); |
135 PrintF("%*sthat = ", Nesting::current(), ""); | 143 PrintF("%*sthat = ", Nesting::current(), ""); |
136 that->Print(Nesting::current()); | 144 that->Print(Nesting::current()); |
137 } | 145 } |
138 #endif | 146 #endif |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 | 215 |
208 if (FLAG_print_interface_details) { | 216 if (FLAG_print_interface_details) { |
209 PrintF("%p", static_cast<void*>(this)); | 217 PrintF("%p", static_cast<void*>(this)); |
210 for (Interface* link = this->forward_; link != NULL; link = link->forward_) | 218 for (Interface* link = this->forward_; link != NULL; link = link->forward_) |
211 PrintF("->%p", static_cast<void*>(link)); | 219 PrintF("->%p", static_cast<void*>(link)); |
212 PrintF(" "); | 220 PrintF(" "); |
213 } | 221 } |
214 | 222 |
215 if (IsUnknown()) { | 223 if (IsUnknown()) { |
216 PrintF("unknown\n"); | 224 PrintF("unknown\n"); |
| 225 } else if (IsConst()) { |
| 226 PrintF("const\n"); |
217 } else if (IsValue()) { | 227 } else if (IsValue()) { |
218 PrintF("value\n"); | 228 PrintF("value\n"); |
219 } else if (IsModule()) { | 229 } else if (IsModule()) { |
220 PrintF("module %s{", IsFrozen() ? "" : "(unresolved) "); | 230 PrintF("module %s{", IsFrozen() ? "" : "(unresolved) "); |
221 ZoneHashMap* map = Chase()->exports_; | 231 ZoneHashMap* map = Chase()->exports_; |
222 if (map == NULL || map->occupancy() == 0) { | 232 if (map == NULL || map->occupancy() == 0) { |
223 PrintF("}\n"); | 233 PrintF("}\n"); |
224 } else if (n < 0 || n0 >= 2 * FLAG_print_interface_depth) { | 234 } else if (n < 0 || n0 >= 2 * FLAG_print_interface_depth) { |
225 // Avoid infinite recursion on cyclic types. | 235 // Avoid infinite recursion on cyclic types. |
226 PrintF("...}\n"); | 236 PrintF("...}\n"); |
227 } else { | 237 } else { |
228 PrintF("\n"); | 238 PrintF("\n"); |
229 for (ZoneHashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) { | 239 for (ZoneHashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) { |
230 String* name = *static_cast<String**>(p->key); | 240 String* name = *static_cast<String**>(p->key); |
231 Interface* interface = static_cast<Interface*>(p->value); | 241 Interface* interface = static_cast<Interface*>(p->value); |
232 PrintF("%*s%s : ", n0 + 2, "", name->ToAsciiArray()); | 242 PrintF("%*s%s : ", n0 + 2, "", name->ToAsciiArray()); |
233 interface->Print(n0 + 2); | 243 interface->Print(n0 + 2); |
234 } | 244 } |
235 PrintF("%*s}\n", n0, ""); | 245 PrintF("%*s}\n", n0, ""); |
236 } | 246 } |
237 } | 247 } |
238 } | 248 } |
239 #endif | 249 #endif |
240 | 250 |
241 } } // namespace v8::internal | 251 } } // namespace v8::internal |
OLD | NEW |