| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 62 |
| 63 disabled_ = false; | 63 disabled_ = false; |
| 64 #if !defined(ENABLE_HEAP_PROTECTION) | 64 #if !defined(ENABLE_HEAP_PROTECTION) |
| 65 // When not protecting the heap, there is no difference between | 65 // When not protecting the heap, there is no difference between |
| 66 // EXTERNAL and OTHER. As an optimization in that case, we will not | 66 // EXTERNAL and OTHER. As an optimization in that case, we will not |
| 67 // perform EXTERNAL->OTHER transitions through the API. We thus | 67 // perform EXTERNAL->OTHER transitions through the API. We thus |
| 68 // compress the two states into one. | 68 // compress the two states into one. |
| 69 if (state == EXTERNAL) state = OTHER; | 69 if (state == EXTERNAL) state = OTHER; |
| 70 #endif | 70 #endif |
| 71 state_ = state; | 71 state_ = state; |
| 72 previous_ = Logger::current_state_; | 72 LoggerData& data = v8_context()->logger_data_; |
| 73 Logger::current_state_ = this; | 73 previous_ = data.current_state_; |
| 74 data.current_state_ = this; |
| 74 | 75 |
| 75 if (FLAG_log_state_changes) { | 76 if (FLAG_log_state_changes) { |
| 76 LOG(UncheckedStringEvent("Entering", StateToString(state_))); | 77 LOG(UncheckedStringEvent("Entering", StateToString(state_))); |
| 77 if (previous_ != NULL) { | 78 if (previous_ != NULL) { |
| 78 LOG(UncheckedStringEvent("From", StateToString(previous_->state_))); | 79 LOG(UncheckedStringEvent("From", StateToString(previous_->state_))); |
| 79 } | 80 } |
| 80 } | 81 } |
| 81 | 82 |
| 82 #ifdef ENABLE_HEAP_PROTECTION | 83 #ifdef ENABLE_HEAP_PROTECTION |
| 83 if (FLAG_protect_heap && previous_ != NULL) { | 84 if (FLAG_protect_heap && previous_ != NULL) { |
| 84 if (state_ == EXTERNAL) { | 85 if (state_ == EXTERNAL) { |
| 85 // We are leaving V8. | 86 // We are leaving V8. |
| 86 ASSERT(previous_->state_ != EXTERNAL); | 87 ASSERT(previous_->state_ != EXTERNAL); |
| 87 Heap::Protect(); | 88 Heap::Protect(); |
| 88 } else if (previous_->state_ == EXTERNAL) { | 89 } else if (previous_->state_ == EXTERNAL) { |
| 89 // We are entering V8. | 90 // We are entering V8. |
| 90 Heap::Unprotect(); | 91 Heap::Unprotect(); |
| 91 } | 92 } |
| 92 } | 93 } |
| 93 #endif | 94 #endif |
| 94 } | 95 } |
| 95 | 96 |
| 96 | 97 |
| 97 VMState::~VMState() { | 98 VMState::~VMState() { |
| 98 if (disabled_) return; | 99 if (disabled_) return; |
| 99 Logger::current_state_ = previous_; | 100 v8_context()->logger_data_.current_state_ = previous_; |
| 100 | 101 |
| 101 if (FLAG_log_state_changes) { | 102 if (FLAG_log_state_changes) { |
| 102 LOG(UncheckedStringEvent("Leaving", StateToString(state_))); | 103 LOG(UncheckedStringEvent("Leaving", StateToString(state_))); |
| 103 if (previous_ != NULL) { | 104 if (previous_ != NULL) { |
| 104 LOG(UncheckedStringEvent("To", StateToString(previous_->state_))); | 105 LOG(UncheckedStringEvent("To", StateToString(previous_->state_))); |
| 105 } | 106 } |
| 106 } | 107 } |
| 107 | 108 |
| 108 #ifdef ENABLE_HEAP_PROTECTION | 109 #ifdef ENABLE_HEAP_PROTECTION |
| 109 if (FLAG_protect_heap && previous_ != NULL) { | 110 if (FLAG_protect_heap && previous_ != NULL) { |
| 110 if (state_ == EXTERNAL) { | 111 if (state_ == EXTERNAL) { |
| 111 // We are reentering V8. | 112 // We are reentering V8. |
| 112 ASSERT(previous_->state_ != EXTERNAL); | 113 ASSERT(previous_->state_ != EXTERNAL); |
| 113 Heap::Unprotect(); | 114 Heap::Unprotect(); |
| 114 } else if (previous_->state_ == EXTERNAL) { | 115 } else if (previous_->state_ == EXTERNAL) { |
| 115 // We are leaving V8. | 116 // We are leaving V8. |
| 116 Heap::Protect(); | 117 Heap::Protect(); |
| 117 } | 118 } |
| 118 } | 119 } |
| 119 #endif | 120 #endif |
| 120 } | 121 } |
| 121 #endif | 122 #endif |
| 122 | 123 |
| 123 | 124 |
| 124 } } // namespace v8::internal | 125 } } // namespace v8::internal |
| 125 | 126 |
| 126 #endif // V8_LOG_INL_H_ | 127 #endif // V8_LOG_INL_H_ |
| OLD | NEW |