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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 void* name, uint32_t hash, Interface* interface, bool* ok) { | 72 void* name, uint32_t hash, Interface* interface, bool* ok) { |
73 MakeModule(ok); | 73 MakeModule(ok); |
74 if (!*ok) return; | 74 if (!*ok) return; |
75 | 75 |
76 #ifdef DEBUG | 76 #ifdef DEBUG |
77 if (FLAG_print_interface_details) { | 77 if (FLAG_print_interface_details) { |
78 PrintF("%*s# Adding...\n", Nesting::current(), ""); | 78 PrintF("%*s# Adding...\n", Nesting::current(), ""); |
79 PrintF("%*sthis = ", Nesting::current(), ""); | 79 PrintF("%*sthis = ", Nesting::current(), ""); |
80 this->Print(Nesting::current()); | 80 this->Print(Nesting::current()); |
81 PrintF("%*s%s : ", Nesting::current(), "", | 81 PrintF("%*s%s : ", Nesting::current(), "", |
82 (*reinterpret_cast<String**>(name))->ToAsciiArray()); | 82 (*static_cast<String**>(name))->ToAsciiArray()); |
83 interface->Print(Nesting::current()); | 83 interface->Print(Nesting::current()); |
84 } | 84 } |
85 #endif | 85 #endif |
86 | 86 |
87 ZoneHashMap** map = &Chase()->exports_; | 87 ZoneHashMap** map = &Chase()->exports_; |
88 if (*map == NULL) *map = new ZoneHashMap(Match, 8); | 88 if (*map == NULL) *map = new ZoneHashMap(Match, 8); |
89 | 89 |
90 ZoneHashMap::Entry* p = (*map)->Lookup(name, hash, !IsFrozen()); | 90 ZoneHashMap::Entry* p = (*map)->Lookup(name, hash, !IsFrozen()); |
91 if (p == NULL) { | 91 if (p == NULL) { |
92 // This didn't have name but was frozen already, that's an error. | 92 // This didn't have name but was frozen already, that's an error. |
93 *ok = false; | 93 *ok = false; |
94 } else if (p->value == NULL) { | 94 } else if (p->value == NULL) { |
95 p->value = interface; | 95 p->value = interface; |
96 } else { | 96 } else { |
97 #ifdef DEBUG | 97 #ifdef DEBUG |
98 Nesting nested; | 98 Nesting nested; |
99 #endif | 99 #endif |
100 reinterpret_cast<Interface*>(p->value)->Unify(interface, ok); | 100 static_cast<Interface*>(p->value)->Unify(interface, ok); |
101 } | 101 } |
102 | 102 |
103 #ifdef DEBUG | 103 #ifdef DEBUG |
104 if (FLAG_print_interface_details) { | 104 if (FLAG_print_interface_details) { |
105 PrintF("%*sthis' = ", Nesting::current(), ""); | 105 PrintF("%*sthis' = ", Nesting::current(), ""); |
106 this->Print(Nesting::current()); | 106 this->Print(Nesting::current()); |
107 PrintF("%*s# Added.\n", Nesting::current(), ""); | 107 PrintF("%*s# Added.\n", Nesting::current(), ""); |
108 } | 108 } |
109 #endif | 109 #endif |
110 } | 110 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 173 |
174 // If the new interface is larger than that's, then there were members in | 174 // If the new interface is larger than that's, then there were members in |
175 // 'this' which 'that' didn't have. If 'that' was frozen that is an error. | 175 // 'this' which 'that' didn't have. If 'that' was frozen that is an error. |
176 int this_size = this->exports_ == NULL ? 0 : this->exports_->occupancy(); | 176 int this_size = this->exports_ == NULL ? 0 : this->exports_->occupancy(); |
177 int that_size = map == NULL ? 0 : map->occupancy(); | 177 int that_size = map == NULL ? 0 : map->occupancy(); |
178 if (that->IsFrozen() && this_size > that_size) { | 178 if (that->IsFrozen() && this_size > that_size) { |
179 *ok = false; | 179 *ok = false; |
180 return; | 180 return; |
181 } | 181 } |
182 | 182 |
| 183 // Merge instance. |
| 184 if (!that->instance_.is_null()) { |
| 185 if (!this->instance_.is_null() && *this->instance_ != *that->instance_) { |
| 186 *ok = false; |
| 187 return; |
| 188 } |
| 189 this->instance_ = that->instance_; |
| 190 } |
| 191 |
183 // Merge interfaces. | 192 // Merge interfaces. |
184 this->flags_ |= that->flags_; | 193 this->flags_ |= that->flags_; |
185 that->forward_ = this; | 194 that->forward_ = this; |
186 } | 195 } |
187 | 196 |
188 | 197 |
189 #ifdef DEBUG | 198 #ifdef DEBUG |
190 void Interface::Print(int n) { | 199 void Interface::Print(int n) { |
191 int n0 = n > 0 ? n : 0; | 200 int n0 = n > 0 ? n : 0; |
192 | 201 |
(...skipping 24 matching lines...) Expand all Loading... |
217 PrintF("%*s%s : ", n0 + 2, "", name->ToAsciiArray()); | 226 PrintF("%*s%s : ", n0 + 2, "", name->ToAsciiArray()); |
218 interface->Print(n0 + 2); | 227 interface->Print(n0 + 2); |
219 } | 228 } |
220 PrintF("%*s}\n", n0, ""); | 229 PrintF("%*s}\n", n0, ""); |
221 } | 230 } |
222 } | 231 } |
223 } | 232 } |
224 #endif | 233 #endif |
225 | 234 |
226 } } // namespace v8::internal | 235 } } // namespace v8::internal |
OLD | NEW |