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

Side by Side Diff: src/interface.h

Issue 345513003: Revert "Parser: Delay internalizing strings and values." (r21841) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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/hydrogen.cc ('k') | src/interface.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 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 #ifndef V8_INTERFACE_H_ 5 #ifndef V8_INTERFACE_H_
6 #define V8_INTERFACE_H_ 6 #define V8_INTERFACE_H_
7 7
8 #include "src/ast-value-factory.h"
9 #include "src/zone-inl.h" // For operator new. 8 #include "src/zone-inl.h" // For operator new.
10 9
11 namespace v8 { 10 namespace v8 {
12 namespace internal { 11 namespace internal {
13 12
14 13
15 // This class implements the following abstract grammar of interfaces 14 // This class implements the following abstract grammar of interfaces
16 // (i.e. module types): 15 // (i.e. module types):
17 // interface ::= UNDETERMINED | VALUE | CONST | MODULE(exports) 16 // interface ::= UNDETERMINED | VALUE | CONST | MODULE(exports)
18 // exports ::= {name : interface, ...} 17 // exports ::= {name : interface, ...}
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 52
54 static Interface* NewModule(Zone* zone) { 53 static Interface* NewModule(Zone* zone) {
55 return new(zone) Interface(MODULE); 54 return new(zone) Interface(MODULE);
56 } 55 }
57 56
58 // --------------------------------------------------------------------------- 57 // ---------------------------------------------------------------------------
59 // Mutators. 58 // Mutators.
60 59
61 // Add a name to the list of exports. If it already exists, unify with 60 // Add a name to the list of exports. If it already exists, unify with
62 // interface, otherwise insert unless this is closed. 61 // interface, otherwise insert unless this is closed.
63 void Add(const AstString* name, Interface* interface, Zone* zone, 62 void Add(Handle<String> name, Interface* interface, Zone* zone, bool* ok) {
64 bool* ok) { 63 DoAdd(name.location(), name->Hash(), interface, zone, ok);
65 DoAdd(name, name->hash(), interface, zone, ok);
66 } 64 }
67 65
68 // Unify with another interface. If successful, both interface objects will 66 // Unify with another interface. If successful, both interface objects will
69 // represent the same type, and changes to one are reflected in the other. 67 // represent the same type, and changes to one are reflected in the other.
70 void Unify(Interface* that, Zone* zone, bool* ok); 68 void Unify(Interface* that, Zone* zone, bool* ok);
71 69
72 // Determine this interface to be a value interface. 70 // Determine this interface to be a value interface.
73 void MakeValue(bool* ok) { 71 void MakeValue(bool* ok) {
74 *ok = !IsModule(); 72 *ok = !IsModule();
75 if (*ok) Chase()->flags_ |= VALUE; 73 if (*ok) Chase()->flags_ |= VALUE;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // --------------------------------------------------------------------------- 139 // ---------------------------------------------------------------------------
142 // Iterators. 140 // Iterators.
143 141
144 // Use like: 142 // Use like:
145 // for (auto it = interface->iterator(); !it.done(); it.Advance()) { 143 // for (auto it = interface->iterator(); !it.done(); it.Advance()) {
146 // ... it.name() ... it.interface() ... 144 // ... it.name() ... it.interface() ...
147 // } 145 // }
148 class Iterator { 146 class Iterator {
149 public: 147 public:
150 bool done() const { return entry_ == NULL; } 148 bool done() const { return entry_ == NULL; }
151 const AstString* name() const { 149 Handle<String> name() const {
152 ASSERT(!done()); 150 ASSERT(!done());
153 return static_cast<const AstString*>(entry_->key); 151 return Handle<String>(*static_cast<String**>(entry_->key));
154 } 152 }
155 Interface* interface() const { 153 Interface* interface() const {
156 ASSERT(!done()); 154 ASSERT(!done());
157 return static_cast<Interface*>(entry_->value); 155 return static_cast<Interface*>(entry_->value);
158 } 156 }
159 void Advance() { entry_ = exports_->Next(entry_); } 157 void Advance() { entry_ = exports_->Next(entry_); }
160 158
161 private: 159 private:
162 friend class Interface; 160 friend class Interface;
163 explicit Iterator(const ZoneHashMap* exports) 161 explicit Iterator(const ZoneHashMap* exports)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 #endif 200 #endif
203 } 201 }
204 202
205 Interface* Chase() { 203 Interface* Chase() {
206 Interface* result = this; 204 Interface* result = this;
207 while (result->forward_ != NULL) result = result->forward_; 205 while (result->forward_ != NULL) result = result->forward_;
208 if (result != this) forward_ = result; // On-the-fly path compression. 206 if (result != this) forward_ = result; // On-the-fly path compression.
209 return result; 207 return result;
210 } 208 }
211 209
212 void DoAdd(const void* name, uint32_t hash, Interface* interface, Zone* zone, 210 void DoAdd(void* name, uint32_t hash, Interface* interface, Zone* zone,
213 bool* ok); 211 bool* ok);
214 void DoUnify(Interface* that, bool* ok, Zone* zone); 212 void DoUnify(Interface* that, bool* ok, Zone* zone);
215 }; 213 };
216 214
217 } } // namespace v8::internal 215 } } // namespace v8::internal
218 216
219 #endif // V8_INTERFACE_H_ 217 #endif // V8_INTERFACE_H_
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/interface.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698