| 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 29 matching lines...) Expand all Loading... |
| 40 // VMState construction and popped by destruction. | 40 // VMState construction and popped by destruction. |
| 41 // | 41 // |
| 42 inline const char* StateToString(StateTag state) { | 42 inline const char* StateToString(StateTag state) { |
| 43 switch (state) { | 43 switch (state) { |
| 44 case JS: | 44 case JS: |
| 45 return "JS"; | 45 return "JS"; |
| 46 case GC: | 46 case GC: |
| 47 return "GC"; | 47 return "GC"; |
| 48 case COMPILER: | 48 case COMPILER: |
| 49 return "COMPILER"; | 49 return "COMPILER"; |
| 50 case PARALLEL_COMPILER: | |
| 51 return "PARALLEL_COMPILER"; | |
| 52 case OTHER: | 50 case OTHER: |
| 53 return "OTHER"; | 51 return "OTHER"; |
| 54 case EXTERNAL: | 52 case EXTERNAL: |
| 55 return "EXTERNAL"; | 53 return "EXTERNAL"; |
| 56 default: | 54 default: |
| 57 UNREACHABLE(); | 55 UNREACHABLE(); |
| 58 return NULL; | 56 return NULL; |
| 59 } | 57 } |
| 60 } | 58 } |
| 61 | 59 |
| 62 | 60 |
| 63 VMState::VMState(Isolate* isolate, StateTag tag) | 61 template <StateTag Tag> |
| 62 VMState<Tag>::VMState(Isolate* isolate) |
| 64 : isolate_(isolate), previous_tag_(isolate->current_vm_state()) { | 63 : isolate_(isolate), previous_tag_(isolate->current_vm_state()) { |
| 65 if (FLAG_log_state_changes) { | 64 if (FLAG_log_timer_events && previous_tag_ != EXTERNAL && Tag == EXTERNAL) { |
| 66 LOG(isolate, UncheckedStringEvent("Entering", StateToString(tag))); | 65 LOG(isolate_, |
| 67 LOG(isolate, UncheckedStringEvent("From", StateToString(previous_tag_))); | 66 TimerEvent(Logger::START, Logger::TimerEventScope::v8_external)); |
| 68 } | 67 } |
| 69 | 68 isolate_->set_current_vm_state(Tag); |
| 70 if (FLAG_log_timer_events && previous_tag_ != EXTERNAL && tag == EXTERNAL) { | |
| 71 LOG(isolate_, EnterExternal()); | |
| 72 } | |
| 73 | |
| 74 isolate_->SetCurrentVMState(tag); | |
| 75 } | 69 } |
| 76 | 70 |
| 77 | 71 |
| 78 VMState::~VMState() { | 72 template <StateTag Tag> |
| 79 if (FLAG_log_state_changes) { | 73 VMState<Tag>::~VMState() { |
| 74 if (FLAG_log_timer_events && previous_tag_ != EXTERNAL && Tag == EXTERNAL) { |
| 80 LOG(isolate_, | 75 LOG(isolate_, |
| 81 UncheckedStringEvent("Leaving", | 76 TimerEvent(Logger::END, Logger::TimerEventScope::v8_external)); |
| 82 StateToString(isolate_->current_vm_state()))); | |
| 83 LOG(isolate_, | |
| 84 UncheckedStringEvent("To", StateToString(previous_tag_))); | |
| 85 } | 77 } |
| 86 | 78 isolate_->set_current_vm_state(previous_tag_); |
| 87 if (FLAG_log_timer_events && | |
| 88 previous_tag_ != EXTERNAL && isolate_->current_vm_state() == EXTERNAL) { | |
| 89 LOG(isolate_, LeaveExternal()); | |
| 90 } | |
| 91 | |
| 92 isolate_->SetCurrentVMState(previous_tag_); | |
| 93 } | 79 } |
| 94 | 80 |
| 95 | 81 |
| 96 ExternalCallbackScope::ExternalCallbackScope(Isolate* isolate, Address callback) | 82 ExternalCallbackScope::ExternalCallbackScope(Isolate* isolate, Address callback) |
| 97 : isolate_(isolate), previous_callback_(isolate->external_callback()) { | 83 : isolate_(isolate), previous_callback_(isolate->external_callback()) { |
| 98 isolate_->set_external_callback(callback); | 84 isolate_->set_external_callback(callback); |
| 99 } | 85 } |
| 100 | 86 |
| 101 ExternalCallbackScope::~ExternalCallbackScope() { | 87 ExternalCallbackScope::~ExternalCallbackScope() { |
| 102 isolate_->set_external_callback(previous_callback_); | 88 isolate_->set_external_callback(previous_callback_); |
| 103 } | 89 } |
| 104 | 90 |
| 105 | 91 |
| 106 } } // namespace v8::internal | 92 } } // namespace v8::internal |
| 107 | 93 |
| 108 #endif // V8_VM_STATE_INL_H_ | 94 #endif // V8_VM_STATE_INL_H_ |
| OLD | NEW |