Chromium Code Reviews| 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 #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" | 8 #include "src/ast-value-factory.h" |
| 9 #include "src/base/lazy-instance.h" | |
|
Benedikt Meurer
2014/10/21 04:09:05
No need for this include, see comment below.
| |
| 9 #include "src/zone-inl.h" // For operator new. | 10 #include "src/zone-inl.h" // For operator new. |
| 10 | 11 |
| 11 namespace v8 { | 12 namespace v8 { |
| 12 namespace internal { | 13 namespace internal { |
| 13 | 14 |
| 14 | 15 |
| 15 // This class implements the following abstract grammar of interfaces | 16 // This class implements the following abstract grammar of interfaces |
| 16 // (i.e. module types): | 17 // (i.e. module types): |
| 17 // interface ::= UNDETERMINED | VALUE | CONST | MODULE(exports) | 18 // interface ::= UNDETERMINED | VALUE | CONST | MODULE(exports) |
| 18 // exports ::= {name : interface, ...} | 19 // exports ::= {name : interface, ...} |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 34 | 35 |
| 35 class Interface : public ZoneObject { | 36 class Interface : public ZoneObject { |
| 36 public: | 37 public: |
| 37 // --------------------------------------------------------------------------- | 38 // --------------------------------------------------------------------------- |
| 38 // Factory methods. | 39 // Factory methods. |
| 39 | 40 |
| 40 static Interface* NewUnknown(Zone* zone) { | 41 static Interface* NewUnknown(Zone* zone) { |
| 41 return new(zone) Interface(NONE); | 42 return new(zone) Interface(NONE); |
| 42 } | 43 } |
| 43 | 44 |
| 44 static Interface* NewValue() { | 45 static Interface* NewValue(); |
| 45 static Interface value_interface(VALUE + FROZEN); // Cached. | |
| 46 return &value_interface; | |
| 47 } | |
| 48 | 46 |
| 49 static Interface* NewConst() { | 47 static Interface* NewConst(); |
| 50 static Interface value_interface(VALUE + CONST + FROZEN); // Cached. | |
| 51 return &value_interface; | |
| 52 } | |
| 53 | 48 |
| 54 static Interface* NewModule(Zone* zone) { | 49 static Interface* NewModule(Zone* zone) { |
| 55 return new(zone) Interface(MODULE); | 50 return new(zone) Interface(MODULE); |
| 56 } | 51 } |
| 57 | 52 |
| 58 // --------------------------------------------------------------------------- | 53 // --------------------------------------------------------------------------- |
| 59 // Mutators. | 54 // Mutators. |
| 60 | 55 |
| 61 // Add a name to the list of exports. If it already exists, unify with | 56 // Add a name to the list of exports. If it already exists, unify with |
| 62 // interface, otherwise insert unless this is closed. | 57 // interface, otherwise insert unless this is closed. |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 : flags_(flags), | 190 : flags_(flags), |
| 196 forward_(NULL), | 191 forward_(NULL), |
| 197 exports_(NULL), | 192 exports_(NULL), |
| 198 index_(-1) { | 193 index_(-1) { |
| 199 #ifdef DEBUG | 194 #ifdef DEBUG |
| 200 if (FLAG_print_interface_details) | 195 if (FLAG_print_interface_details) |
| 201 PrintF("# Creating %p\n", static_cast<void*>(this)); | 196 PrintF("# Creating %p\n", static_cast<void*>(this)); |
| 202 #endif | 197 #endif |
| 203 } | 198 } |
| 204 | 199 |
| 200 struct ValueCreate; | |
| 201 struct ConstCreate; | |
| 202 static base::LazyInstance<Interface*, ValueCreate>::type value_interface_; | |
|
Benedikt Meurer
2014/10/21 04:09:05
Move the statics to the .cc file and hide them in
rossberg
2014/10/21 10:42:52
Done. Also changed them to do in-place constructio
| |
| 203 static base::LazyInstance<Interface*, ConstCreate>::type const_interface_; | |
| 204 | |
| 205 Interface* Chase() { | 205 Interface* Chase() { |
| 206 Interface* result = this; | 206 Interface* result = this; |
| 207 while (result->forward_ != NULL) result = result->forward_; | 207 while (result->forward_ != NULL) result = result->forward_; |
| 208 if (result != this) forward_ = result; // On-the-fly path compression. | 208 if (result != this) forward_ = result; // On-the-fly path compression. |
| 209 return result; | 209 return result; |
| 210 } | 210 } |
| 211 | 211 |
| 212 void DoAdd(const void* name, uint32_t hash, Interface* interface, Zone* zone, | 212 void DoAdd(const void* name, uint32_t hash, Interface* interface, Zone* zone, |
| 213 bool* ok); | 213 bool* ok); |
| 214 void DoUnify(Interface* that, bool* ok, Zone* zone); | 214 void DoUnify(Interface* that, bool* ok, Zone* zone); |
| 215 }; | 215 }; |
| 216 | 216 |
| 217 } } // namespace v8::internal | 217 } } // namespace v8::internal |
| 218 | 218 |
| 219 #endif // V8_INTERFACE_H_ | 219 #endif // V8_INTERFACE_H_ |
| OLD | NEW |