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 21 matching lines...) Expand all Loading... |
32 #include "runtime-profiler.h" | 32 #include "runtime-profiler.h" |
33 | 33 |
34 namespace v8 { | 34 namespace v8 { |
35 namespace internal { | 35 namespace internal { |
36 | 36 |
37 // | 37 // |
38 // VMState class implementation. A simple stack of VM states held by the | 38 // VMState class implementation. A simple stack of VM states held by the |
39 // logger and partially threaded through the call stack. States are pushed by | 39 // logger and partially threaded through the call stack. States are pushed by |
40 // VMState construction and popped by destruction. | 40 // VMState construction and popped by destruction. |
41 // | 41 // |
42 #ifdef ENABLE_VMSTATE_TRACKING | |
43 inline const char* StateToString(StateTag state) { | 42 inline const char* StateToString(StateTag state) { |
44 switch (state) { | 43 switch (state) { |
45 case JS: | 44 case JS: |
46 return "JS"; | 45 return "JS"; |
47 case GC: | 46 case GC: |
48 return "GC"; | 47 return "GC"; |
49 case COMPILER: | 48 case COMPILER: |
50 return "COMPILER"; | 49 return "COMPILER"; |
51 case OTHER: | 50 case OTHER: |
52 return "OTHER"; | 51 return "OTHER"; |
53 case EXTERNAL: | 52 case EXTERNAL: |
54 return "EXTERNAL"; | 53 return "EXTERNAL"; |
55 default: | 54 default: |
56 UNREACHABLE(); | 55 UNREACHABLE(); |
57 return NULL; | 56 return NULL; |
58 } | 57 } |
59 } | 58 } |
60 | 59 |
61 | 60 |
62 VMState::VMState(Isolate* isolate, StateTag tag) | 61 VMState::VMState(Isolate* isolate, StateTag tag) |
63 : isolate_(isolate), previous_tag_(isolate->current_vm_state()) { | 62 : isolate_(isolate), previous_tag_(isolate->current_vm_state()) { |
64 #ifdef ENABLE_LOGGING_AND_PROFILING | |
65 if (FLAG_log_state_changes) { | 63 if (FLAG_log_state_changes) { |
66 LOG(isolate, UncheckedStringEvent("Entering", StateToString(tag))); | 64 LOG(isolate, UncheckedStringEvent("Entering", StateToString(tag))); |
67 LOG(isolate, UncheckedStringEvent("From", StateToString(previous_tag_))); | 65 LOG(isolate, UncheckedStringEvent("From", StateToString(previous_tag_))); |
68 } | 66 } |
69 #endif | |
70 | 67 |
71 isolate_->SetCurrentVMState(tag); | 68 isolate_->SetCurrentVMState(tag); |
72 } | 69 } |
73 | 70 |
74 | 71 |
75 VMState::~VMState() { | 72 VMState::~VMState() { |
76 #ifdef ENABLE_LOGGING_AND_PROFILING | |
77 if (FLAG_log_state_changes) { | 73 if (FLAG_log_state_changes) { |
78 LOG(isolate_, | 74 LOG(isolate_, |
79 UncheckedStringEvent("Leaving", | 75 UncheckedStringEvent("Leaving", |
80 StateToString(isolate_->current_vm_state()))); | 76 StateToString(isolate_->current_vm_state()))); |
81 LOG(isolate_, | 77 LOG(isolate_, |
82 UncheckedStringEvent("To", StateToString(previous_tag_))); | 78 UncheckedStringEvent("To", StateToString(previous_tag_))); |
83 } | 79 } |
84 #endif // ENABLE_LOGGING_AND_PROFILING | |
85 | 80 |
86 isolate_->SetCurrentVMState(previous_tag_); | 81 isolate_->SetCurrentVMState(previous_tag_); |
87 } | 82 } |
88 | 83 |
89 #endif // ENABLE_VMSTATE_TRACKING | |
90 | |
91 | |
92 #ifdef ENABLE_LOGGING_AND_PROFILING | |
93 | 84 |
94 ExternalCallbackScope::ExternalCallbackScope(Isolate* isolate, Address callback) | 85 ExternalCallbackScope::ExternalCallbackScope(Isolate* isolate, Address callback) |
95 : isolate_(isolate), previous_callback_(isolate->external_callback()) { | 86 : isolate_(isolate), previous_callback_(isolate->external_callback()) { |
96 isolate_->set_external_callback(callback); | 87 isolate_->set_external_callback(callback); |
97 } | 88 } |
98 | 89 |
99 ExternalCallbackScope::~ExternalCallbackScope() { | 90 ExternalCallbackScope::~ExternalCallbackScope() { |
100 isolate_->set_external_callback(previous_callback_); | 91 isolate_->set_external_callback(previous_callback_); |
101 } | 92 } |
102 | 93 |
103 #endif // ENABLE_LOGGING_AND_PROFILING | |
104 | |
105 | 94 |
106 } } // namespace v8::internal | 95 } } // namespace v8::internal |
107 | 96 |
108 #endif // V8_VM_STATE_INL_H_ | 97 #endif // V8_VM_STATE_INL_H_ |
OLD | NEW |