Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 11 matching lines...) Expand all Loading... | |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_ISOLATE_H_ | 28 #ifndef V8_ISOLATE_H_ |
| 29 #define V8_ISOLATE_H_ | 29 #define V8_ISOLATE_H_ |
| 30 | 30 |
| 31 #include "heap.h" | 31 #include "heap.h" |
| 32 #include "zone.h" | |
| 32 | 33 |
| 33 namespace v8 { | 34 namespace v8 { |
| 34 namespace internal { | 35 namespace internal { |
| 35 | 36 |
| 36 class Bootstrapper; | 37 class Bootstrapper; |
| 37 class Deserializer; | 38 class Deserializer; |
| 38 class StubCache; | 39 class StubCache; |
| 39 | 40 |
| 41 #define ISOLATE_INIT_LIST(V) \ | |
| 42 V(bool, zone_allow_allocation, true) /* AssertNoZoneAllocation */ | |
| 43 | |
| 40 class Isolate { | 44 class Isolate { |
| 41 public: | 45 public: |
| 42 // Returns the single global isolate. | 46 // Returns the single global isolate. |
| 43 static Isolate* Current() { | 47 static Isolate* Current() { |
| 44 ASSERT(global_isolate != NULL); | 48 ASSERT(global_isolate != NULL); |
| 45 return global_isolate; | 49 return global_isolate; |
| 46 } | 50 } |
| 47 | 51 |
| 48 // Creates a new isolate (perhaps using a deserializer). Returns null | 52 // Creates a new isolate (perhaps using a deserializer). Returns null |
| 49 // on failure. | 53 // on failure. |
| 50 static Isolate* Create(Deserializer* des); | 54 static Isolate* Create(Deserializer* des); |
| 51 | 55 |
| 52 // Initialize process-wide state. | 56 // Initialize process-wide state. |
| 53 static void InitOnce(); | 57 static void InitOnce(); |
| 54 | 58 |
| 55 ~Isolate(); | 59 ~Isolate(); |
|
Vitaly Repeshko
2010/06/02 15:30:40
BTW, according to the style guide this should be t
| |
| 56 | 60 |
| 57 // Accessors. | 61 #define GLOBAL_ACCESSOR(type, name, initialvalue) \ |
| 62 type name() const { return name##_; } \ | |
| 63 void set_##name(type value) { name##_ = value; } | |
| 64 ISOLATE_INIT_LIST(GLOBAL_ACCESSOR) | |
| 65 #undef GLOBAL_ACCESSOR | |
| 66 | |
| 67 | |
| 58 Bootstrapper* bootstrapper() { return bootstrapper_; } | 68 Bootstrapper* bootstrapper() { return bootstrapper_; } |
| 59 Heap* heap() { return &heap_; } | 69 Heap* heap() { return &heap_; } |
| 60 StubCache* stub_cache() { return stub_cache_; } | 70 StubCache* stub_cache() { return stub_cache_; } |
| 61 | 71 Zone* zone() { return &zone_; } |
| 72 | |
| 62 private: | 73 private: |
| 63 Isolate(); | 74 Isolate(); |
| 64 | 75 |
| 65 static Isolate* global_isolate; | 76 static Isolate* global_isolate; |
| 66 | 77 |
| 67 bool Init(Deserializer* des); | 78 bool Init(Deserializer* des); |
| 68 | 79 |
| 69 Bootstrapper* bootstrapper_; | 80 Bootstrapper* bootstrapper_; |
| 70 Heap heap_; | 81 Heap heap_; |
| 71 StubCache* stub_cache_; | 82 StubCache* stub_cache_; |
| 83 Zone zone_; | |
| 84 | |
| 85 #define GLOBAL_BACKING_STORE(type, name, initialvalue) \ | |
| 86 type name##_; | |
| 87 ISOLATE_INIT_LIST(GLOBAL_BACKING_STORE) | |
| 88 #undef GLOBAL_BACKING_STORE | |
| 72 | 89 |
| 73 DISALLOW_COPY_AND_ASSIGN(Isolate); | 90 DISALLOW_COPY_AND_ASSIGN(Isolate); |
| 74 }; | 91 }; |
| 75 | 92 |
| 76 // Temporary macros for accessing fields off the global isolate. | 93 // Temporary macros for accessing fields off the global isolate. Define these |
| 94 // when reformatting code would become burdensome. | |
| 77 #define HEAP (v8::internal::Isolate::Current()->heap()) | 95 #define HEAP (v8::internal::Isolate::Current()->heap()) |
| 96 #define ZONE (v8::internal::Isolate::Current()->zone()) | |
| 78 | 97 |
| 79 | 98 |
| 80 // Temporary macro to be used to flag definitions that are indeed static | 99 // Temporary macro to be used to flag definitions that are indeed static |
| 81 // and not per-isolate. (It would be great to be able to grep for [static]!) | 100 // and not per-isolate. (It would be great to be able to grep for [static]!) |
| 82 #define RLYSTC static | 101 #define RLYSTC static |
| 83 | 102 |
| 84 | 103 |
| 104 // Temporary macro to be used to flag classes that should be static. | |
| 105 #define STATIC_CLASS class | |
|
Vitaly Repeshko
2010/06/02 15:30:40
Do we really need this?
| |
| 106 | |
| 107 | |
| 85 } } // namespace v8::internal | 108 } } // namespace v8::internal |
| 86 | 109 |
| 87 #endif // V8_ISOLATE_H_ | 110 #endif // V8_ISOLATE_H_ |
| OLD | NEW |