OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/interface.h" | 7 #include "src/interface.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
11 | 11 |
12 Interface* Interface::Lookup(Handle<String> name, Zone* zone) { | 12 Interface* Interface::Lookup(Handle<String> name, Zone* zone) { |
13 ASSERT(IsModule()); | 13 DCHECK(IsModule()); |
14 ZoneHashMap* map = Chase()->exports_; | 14 ZoneHashMap* map = Chase()->exports_; |
15 if (map == NULL) return NULL; | 15 if (map == NULL) return NULL; |
16 ZoneAllocationPolicy allocator(zone); | 16 ZoneAllocationPolicy allocator(zone); |
17 ZoneHashMap::Entry* p = map->Lookup(name.location(), name->Hash(), false, | 17 ZoneHashMap::Entry* p = map->Lookup(name.location(), name->Hash(), false, |
18 allocator); | 18 allocator); |
19 if (p == NULL) return NULL; | 19 if (p == NULL) return NULL; |
20 ASSERT(*static_cast<String**>(p->key) == *name); | 20 DCHECK(*static_cast<String**>(p->key) == *name); |
21 ASSERT(p->value != NULL); | 21 DCHECK(p->value != NULL); |
22 return static_cast<Interface*>(p->value); | 22 return static_cast<Interface*>(p->value); |
23 } | 23 } |
24 | 24 |
25 | 25 |
26 #ifdef DEBUG | 26 #ifdef DEBUG |
27 // Current nesting depth for debug output. | 27 // Current nesting depth for debug output. |
28 class Nesting { | 28 class Nesting { |
29 public: | 29 public: |
30 Nesting() { current_ += 2; } | 30 Nesting() { current_ += 2; } |
31 ~Nesting() { current_ -= 2; } | 31 ~Nesting() { current_ -= 2; } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 this->Print(Nesting::current()); | 84 this->Print(Nesting::current()); |
85 PrintF("%*s# Added.\n", Nesting::current(), ""); | 85 PrintF("%*s# Added.\n", Nesting::current(), ""); |
86 } | 86 } |
87 #endif | 87 #endif |
88 } | 88 } |
89 | 89 |
90 | 90 |
91 void Interface::Unify(Interface* that, Zone* zone, bool* ok) { | 91 void Interface::Unify(Interface* that, Zone* zone, bool* ok) { |
92 if (this->forward_) return this->Chase()->Unify(that, zone, ok); | 92 if (this->forward_) return this->Chase()->Unify(that, zone, ok); |
93 if (that->forward_) return this->Unify(that->Chase(), zone, ok); | 93 if (that->forward_) return this->Unify(that->Chase(), zone, ok); |
94 ASSERT(this->forward_ == NULL); | 94 DCHECK(this->forward_ == NULL); |
95 ASSERT(that->forward_ == NULL); | 95 DCHECK(that->forward_ == NULL); |
96 | 96 |
97 *ok = true; | 97 *ok = true; |
98 if (this == that) return; | 98 if (this == that) return; |
99 if (this->IsValue()) { | 99 if (this->IsValue()) { |
100 that->MakeValue(ok); | 100 that->MakeValue(ok); |
101 if (*ok && this->IsConst()) that->MakeConst(ok); | 101 if (*ok && this->IsConst()) that->MakeConst(ok); |
102 return; | 102 return; |
103 } | 103 } |
104 if (that->IsValue()) { | 104 if (that->IsValue()) { |
105 this->MakeValue(ok); | 105 this->MakeValue(ok); |
(...skipping 25 matching lines...) Expand all Loading... |
131 this->Print(Nesting::current()); | 131 this->Print(Nesting::current()); |
132 PrintF("%*sthat' = ", Nesting::current(), ""); | 132 PrintF("%*sthat' = ", Nesting::current(), ""); |
133 that->Print(Nesting::current()); | 133 that->Print(Nesting::current()); |
134 PrintF("%*s# Unified.\n", Nesting::current(), ""); | 134 PrintF("%*s# Unified.\n", Nesting::current(), ""); |
135 } | 135 } |
136 #endif | 136 #endif |
137 } | 137 } |
138 | 138 |
139 | 139 |
140 void Interface::DoUnify(Interface* that, bool* ok, Zone* zone) { | 140 void Interface::DoUnify(Interface* that, bool* ok, Zone* zone) { |
141 ASSERT(this->forward_ == NULL); | 141 DCHECK(this->forward_ == NULL); |
142 ASSERT(that->forward_ == NULL); | 142 DCHECK(that->forward_ == NULL); |
143 ASSERT(!this->IsValue()); | 143 DCHECK(!this->IsValue()); |
144 ASSERT(!that->IsValue()); | 144 DCHECK(!that->IsValue()); |
145 ASSERT(this->index_ == -1); | 145 DCHECK(this->index_ == -1); |
146 ASSERT(that->index_ == -1); | 146 DCHECK(that->index_ == -1); |
147 ASSERT(*ok); | 147 DCHECK(*ok); |
148 | 148 |
149 #ifdef DEBUG | 149 #ifdef DEBUG |
150 Nesting nested; | 150 Nesting nested; |
151 #endif | 151 #endif |
152 | 152 |
153 // Try to merge all members from that into this. | 153 // Try to merge all members from that into this. |
154 ZoneHashMap* map = that->exports_; | 154 ZoneHashMap* map = that->exports_; |
155 if (map != NULL) { | 155 if (map != NULL) { |
156 for (ZoneHashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) { | 156 for (ZoneHashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) { |
157 this->DoAdd(p->key, p->hash, static_cast<Interface*>(p->value), zone, ok); | 157 this->DoAdd(p->key, p->hash, static_cast<Interface*>(p->value), zone, ok); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 PrintF("%*s%s : ", n0 + 2, "", name->ToAsciiArray()); | 207 PrintF("%*s%s : ", n0 + 2, "", name->ToAsciiArray()); |
208 interface->Print(n0 + 2); | 208 interface->Print(n0 + 2); |
209 } | 209 } |
210 PrintF("%*s}\n", n0, ""); | 210 PrintF("%*s}\n", n0, ""); |
211 } | 211 } |
212 } | 212 } |
213 } | 213 } |
214 #endif | 214 #endif |
215 | 215 |
216 } } // namespace v8::internal | 216 } } // namespace v8::internal |
OLD | NEW |