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

Side by Side Diff: src/isolate.h

Issue 633363002: Get rid of isolate state. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates Created 6 years, 2 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/heap/incremental-marking.cc ('k') | src/isolate.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_ISOLATE_H_ 5 #ifndef V8_ISOLATE_H_
6 #define V8_ISOLATE_H_ 6 #define V8_ISOLATE_H_
7 7
8 #include "include/v8-debug.h" 8 #include "include/v8-debug.h"
9 #include "src/allocation.h" 9 #include "src/allocation.h"
10 #include "src/assert-scope.h" 10 #include "src/assert-scope.h"
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 504
505 // Usually called by Init(), but can be called early e.g. to allow 505 // Usually called by Init(), but can be called early e.g. to allow
506 // testing components that require logging but not the whole 506 // testing components that require logging but not the whole
507 // isolate. 507 // isolate.
508 // 508 //
509 // Safe to call more than once. 509 // Safe to call more than once.
510 void InitializeLoggingAndCounters(); 510 void InitializeLoggingAndCounters();
511 511
512 bool Init(Deserializer* des); 512 bool Init(Deserializer* des);
513 513
514 bool IsInitialized() { return state_ == INITIALIZED; }
515
516 // True if at least one thread Enter'ed this isolate. 514 // True if at least one thread Enter'ed this isolate.
517 bool IsInUse() { return entry_stack_ != NULL; } 515 bool IsInUse() { return entry_stack_ != NULL; }
518 516
519 // Destroys the non-default isolates. 517 // Destroys the non-default isolates.
520 // Sets default isolate into "has_been_disposed" state rather then destroying, 518 // Sets default isolate into "has_been_disposed" state rather then destroying,
521 // for legacy API reasons. 519 // for legacy API reasons.
522 void TearDown(); 520 void TearDown();
523 521
524 static void GlobalTearDown(); 522 static void GlobalTearDown();
525 523
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 DCHECK(slot < Internals::kNumIsolateDataSlots); 995 DCHECK(slot < Internals::kNumIsolateDataSlots);
998 embedder_data_[slot] = data; 996 embedder_data_[slot] = data;
999 } 997 }
1000 void* GetData(uint32_t slot) { 998 void* GetData(uint32_t slot) {
1001 DCHECK(slot < Internals::kNumIsolateDataSlots); 999 DCHECK(slot < Internals::kNumIsolateDataSlots);
1002 return embedder_data_[slot]; 1000 return embedder_data_[slot];
1003 } 1001 }
1004 1002
1005 THREAD_LOCAL_TOP_ACCESSOR(LookupResult*, top_lookup_result) 1003 THREAD_LOCAL_TOP_ACCESSOR(LookupResult*, top_lookup_result)
1006 1004
1007 void enable_serializer() {
1008 // The serializer can only be enabled before the isolate init.
1009 DCHECK(state_ != INITIALIZED);
1010 serializer_enabled_ = true;
1011 }
1012
1013 bool serializer_enabled() const { return serializer_enabled_; } 1005 bool serializer_enabled() const { return serializer_enabled_; }
1014 1006
1015 bool IsDead() { return has_fatal_error_; } 1007 bool IsDead() { return has_fatal_error_; }
1016 void SignalFatalError() { has_fatal_error_ = true; } 1008 void SignalFatalError() { has_fatal_error_ = true; }
1017 1009
1018 bool use_crankshaft() const; 1010 bool use_crankshaft() const;
1019 1011
1020 bool initialized_from_snapshot() { return initialized_from_snapshot_; } 1012 bool initialized_from_snapshot() { return initialized_from_snapshot_; }
1021 1013
1022 double time_millis_since_init() { 1014 double time_millis_since_init() {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 1098
1107 void EnqueueMicrotask(Handle<Object> microtask); 1099 void EnqueueMicrotask(Handle<Object> microtask);
1108 void RunMicrotasks(); 1100 void RunMicrotasks();
1109 1101
1110 void SetUseCounterCallback(v8::Isolate::UseCounterCallback callback); 1102 void SetUseCounterCallback(v8::Isolate::UseCounterCallback callback);
1111 void CountUsage(v8::Isolate::UseCounterFeature feature); 1103 void CountUsage(v8::Isolate::UseCounterFeature feature);
1112 1104
1113 BasicBlockProfiler* GetOrCreateBasicBlockProfiler(); 1105 BasicBlockProfiler* GetOrCreateBasicBlockProfiler();
1114 BasicBlockProfiler* basic_block_profiler() { return basic_block_profiler_; } 1106 BasicBlockProfiler* basic_block_profiler() { return basic_block_profiler_; }
1115 1107
1116 static Isolate* NewForTesting() { return new Isolate(); } 1108 static Isolate* NewForTesting() { return new Isolate(false); }
1117 1109
1118 private: 1110 private:
1119 Isolate(); 1111 explicit Isolate(bool enable_serializer);
1120 1112
1121 friend struct GlobalState; 1113 friend struct GlobalState;
1122 friend struct InitializeGlobalState; 1114 friend struct InitializeGlobalState;
1123 1115
1124 enum State {
1125 UNINITIALIZED, // Some components may not have been allocated.
1126 INITIALIZED // All components are fully initialized.
1127 };
1128
1129 // These fields are accessed through the API, offsets must be kept in sync 1116 // These fields are accessed through the API, offsets must be kept in sync
1130 // with v8::internal::Internals (in include/v8.h) constants. This is also 1117 // with v8::internal::Internals (in include/v8.h) constants. This is also
1131 // verified in Isolate::Init() using runtime checks. 1118 // verified in Isolate::Init() using runtime checks.
1132 void* embedder_data_[Internals::kNumIsolateDataSlots]; 1119 void* embedder_data_[Internals::kNumIsolateDataSlots];
1133 Heap heap_; 1120 Heap heap_;
1134 State state_; // Will be padded to kApiPointerSize.
1135 1121
1136 // The per-process lock should be acquired before the ThreadDataTable is 1122 // The per-process lock should be acquired before the ThreadDataTable is
1137 // modified. 1123 // modified.
1138 class ThreadDataTable { 1124 class ThreadDataTable {
1139 public: 1125 public:
1140 ThreadDataTable(); 1126 ThreadDataTable();
1141 ~ThreadDataTable(); 1127 ~ThreadDataTable();
1142 1128
1143 PerIsolateThreadData* Lookup(Isolate* isolate, ThreadId thread_id); 1129 PerIsolateThreadData* Lookup(Isolate* isolate, ThreadId thread_id);
1144 void Insert(PerIsolateThreadData* data); 1130 void Insert(PerIsolateThreadData* data);
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 } 1543 }
1558 1544
1559 EmbeddedVector<char, 128> filename_; 1545 EmbeddedVector<char, 128> filename_;
1560 FILE* file_; 1546 FILE* file_;
1561 int scope_depth_; 1547 int scope_depth_;
1562 }; 1548 };
1563 1549
1564 } } // namespace v8::internal 1550 } } // namespace v8::internal
1565 1551
1566 #endif // V8_ISOLATE_H_ 1552 #endif // V8_ISOLATE_H_
OLDNEW
« no previous file with comments | « src/heap/incremental-marking.cc ('k') | src/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698