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) { |
Sven Panne
2013/04/24 14:03:41
Do we really don't want to call set_current_vm_sta
| |
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)); |
67 } else { | |
68 isolate_->set_current_vm_state(Tag); | |
68 } | 69 } |
69 | |
70 if (FLAG_log_timer_events && previous_tag_ != EXTERNAL && tag == EXTERNAL) { | |
71 LOG(isolate_, EnterExternal()); | |
72 } | |
73 | |
74 isolate_->SetCurrentVMState(tag); | |
75 } | 70 } |
76 | 71 |
77 | 72 |
78 VMState::~VMState() { | 73 template <StateTag Tag> |
79 if (FLAG_log_state_changes) { | 74 VMState<Tag>::~VMState() { |
75 if (FLAG_log_timer_events && previous_tag_ != EXTERNAL && Tag == EXTERNAL) { | |
80 LOG(isolate_, | 76 LOG(isolate_, |
81 UncheckedStringEvent("Leaving", | 77 TimerEvent(Logger::END, Logger::TimerEventScope::v8_external)); |
82 StateToString(isolate_->current_vm_state()))); | 78 } else { |
83 LOG(isolate_, | 79 isolate_->set_current_vm_state(previous_tag_); |
84 UncheckedStringEvent("To", StateToString(previous_tag_))); | |
85 } | 80 } |
86 | |
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 } | 81 } |
94 | 82 |
95 | 83 |
96 ExternalCallbackScope::ExternalCallbackScope(Isolate* isolate, Address callback) | 84 ExternalCallbackScope::ExternalCallbackScope(Isolate* isolate, Address callback) |
97 : isolate_(isolate), previous_callback_(isolate->external_callback()) { | 85 : isolate_(isolate), previous_callback_(isolate->external_callback()) { |
98 isolate_->set_external_callback(callback); | 86 isolate_->set_external_callback(callback); |
99 } | 87 } |
100 | 88 |
101 ExternalCallbackScope::~ExternalCallbackScope() { | 89 ExternalCallbackScope::~ExternalCallbackScope() { |
102 isolate_->set_external_callback(previous_callback_); | 90 isolate_->set_external_callback(previous_callback_); |
103 } | 91 } |
104 | 92 |
105 | 93 |
106 } } // namespace v8::internal | 94 } } // namespace v8::internal |
107 | 95 |
108 #endif // V8_VM_STATE_INL_H_ | 96 #endif // V8_VM_STATE_INL_H_ |
OLD | NEW |