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

Side by Side Diff: src/vm-state-inl.h

Issue 2840018: [Isolates] Moved more compilation-related globals (builtins, runtime, &c.)... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: rebase Created 10 years, 5 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
OLDNEW
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 return "OTHER"; 51 return "OTHER";
52 default: 52 default:
53 UNREACHABLE(); 53 UNREACHABLE();
54 return NULL; 54 return NULL;
55 } 55 }
56 } 56 }
57 57
58 VMState::VMState(StateTag state) 58 VMState::VMState(StateTag state)
59 : disabled_(true), 59 : disabled_(true),
60 state_(OTHER), 60 state_(OTHER),
61 external_callback_(NULL) { 61 external_callback_(NULL),
62 isolate_(Isolate::Current()) {
62 #ifdef ENABLE_LOGGING_AND_PROFILING 63 #ifdef ENABLE_LOGGING_AND_PROFILING
63 if (!LOGGER->is_logging() && !CpuProfiler::is_profiling()) { 64 if (!LOGGER->is_logging() && !CpuProfiler::is_profiling()) {
64 return; 65 return;
65 } 66 }
66 #endif 67 #endif
67 68
68 disabled_ = false; 69 disabled_ = false;
69 #if !defined(ENABLE_HEAP_PROTECTION) 70 #if !defined(ENABLE_HEAP_PROTECTION)
70 // When not protecting the heap, there is no difference between 71 // When not protecting the heap, there is no difference between
71 // EXTERNAL and OTHER. As an optimization in that case, we will not 72 // EXTERNAL and OTHER. As an optimization in that case, we will not
72 // perform EXTERNAL->OTHER transitions through the API. We thus 73 // perform EXTERNAL->OTHER transitions through the API. We thus
73 // compress the two states into one. 74 // compress the two states into one.
74 if (state == EXTERNAL) state = OTHER; 75 if (state == EXTERNAL) state = OTHER;
75 #endif 76 #endif
76 state_ = state; 77 state_ = state;
77 previous_ = current_state_; // Save the previous state. 78 previous_ = isolate_->vm_state(); // Save the previous state.
78 current_state_ = this; // Install the new state. 79 isolate_->set_vm_state(this); // Install the new state.
79 80
80 #ifdef ENABLE_LOGGING_AND_PROFILING 81 #ifdef ENABLE_LOGGING_AND_PROFILING
81 if (FLAG_log_state_changes) { 82 if (FLAG_log_state_changes) {
82 LOG(UncheckedStringEvent("Entering", StateToString(state_))); 83 LOG(UncheckedStringEvent("Entering", StateToString(state_)));
83 if (previous_ != NULL) { 84 if (previous_ != NULL) {
84 LOG(UncheckedStringEvent("From", StateToString(previous_->state_))); 85 LOG(UncheckedStringEvent("From", StateToString(previous_->state_)));
85 } 86 }
86 } 87 }
87 #endif 88 #endif
88 89
89 #ifdef ENABLE_HEAP_PROTECTION 90 #ifdef ENABLE_HEAP_PROTECTION
90 if (FLAG_protect_heap) { 91 if (FLAG_protect_heap) {
91 if (state_ == EXTERNAL) { 92 if (state_ == EXTERNAL) {
92 // We are leaving V8. 93 // We are leaving V8.
93 ASSERT((previous_ != NULL) && (previous_->state_ != EXTERNAL)); 94 ASSERT((previous_ != NULL) && (previous_->state_ != EXTERNAL));
94 Heap::Protect(); 95 Heap::Protect();
95 } else if ((previous_ == NULL) || (previous_->state_ == EXTERNAL)) { 96 } else if ((previous_ == NULL) || (previous_->state_ == EXTERNAL)) {
96 // We are entering V8. 97 // We are entering V8.
97 Heap::Unprotect(); 98 Heap::Unprotect();
98 } 99 }
99 } 100 }
100 #endif 101 #endif
101 } 102 }
102 103
103 104
104 VMState::~VMState() { 105 VMState::~VMState() {
106 ASSERT(isolate_ == Isolate::Current());
105 if (disabled_) return; 107 if (disabled_) return;
106 current_state_ = previous_; // Return to the previous state. 108 isolate_->set_vm_state(previous_); // Return to the previous state.
107 109
108 #ifdef ENABLE_LOGGING_AND_PROFILING 110 #ifdef ENABLE_LOGGING_AND_PROFILING
109 if (FLAG_log_state_changes) { 111 if (FLAG_log_state_changes) {
110 LOG(UncheckedStringEvent("Leaving", StateToString(state_))); 112 LOG(UncheckedStringEvent("Leaving", StateToString(state_)));
111 if (previous_ != NULL) { 113 if (previous_ != NULL) {
112 LOG(UncheckedStringEvent("To", StateToString(previous_->state_))); 114 LOG(UncheckedStringEvent("To", StateToString(previous_->state_)));
113 } 115 }
114 } 116 }
115 #endif // ENABLE_LOGGING_AND_PROFILING 117 #endif // ENABLE_LOGGING_AND_PROFILING
116 118
117 #ifdef ENABLE_HEAP_PROTECTION 119 #ifdef ENABLE_HEAP_PROTECTION
118 if (FLAG_protect_heap) { 120 if (FLAG_protect_heap) {
119 if (state_ == EXTERNAL) { 121 if (state_ == EXTERNAL) {
120 // We are reentering V8. 122 // We are reentering V8.
121 ASSERT((previous_ != NULL) && (previous_->state_ != EXTERNAL)); 123 ASSERT((previous_ != NULL) && (previous_->state_ != EXTERNAL));
122 Heap::Unprotect(); 124 Heap::Unprotect();
123 } else if ((previous_ == NULL) || (previous_->state_ == EXTERNAL)) { 125 } else if ((previous_ == NULL) || (previous_->state_ == EXTERNAL)) {
124 // We are leaving V8. 126 // We are leaving V8.
125 Heap::Protect(); 127 Heap::Protect();
126 } 128 }
127 } 129 }
128 #endif // ENABLE_HEAP_PROTECTION 130 #endif // ENABLE_HEAP_PROTECTION
129 } 131 }
130 #endif // ENABLE_VMSTATE_TRACKING 132 #endif // ENABLE_VMSTATE_TRACKING
131 133
132 } } // namespace v8::internal 134 } } // namespace v8::internal
133 135
134 #endif // V8_VM_STATE_INL_H_ 136 #endif // V8_VM_STATE_INL_H_
OLDNEW
« src/runtime.h ('K') | « src/vm-state.cc ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698