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 7535004: Merge bleeding edge up to 8774 into the GC branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 years, 4 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
« no previous file with comments | « src/vm-state.h ('k') | src/x64/assembler-x64.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 21 matching lines...) Expand all
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
73 #ifdef ENABLE_HEAP_PROTECTION
74 if (FLAG_protect_heap) {
75 if (tag == EXTERNAL) {
76 // We are leaving V8.
77 ASSERT(previous_tag_ != EXTERNAL);
78 isolate_->heap()->Protect();
79 } else if (previous_tag_ = EXTERNAL) {
80 // We are entering V8.
81 isolate_->heap()->Unprotect();
82 }
83 }
84 #endif
85 } 69 }
86 70
87 71
88 VMState::~VMState() { 72 VMState::~VMState() {
89 #ifdef ENABLE_LOGGING_AND_PROFILING
90 if (FLAG_log_state_changes) { 73 if (FLAG_log_state_changes) {
91 LOG(isolate_, 74 LOG(isolate_,
92 UncheckedStringEvent("Leaving", 75 UncheckedStringEvent("Leaving",
93 StateToString(isolate_->current_vm_state()))); 76 StateToString(isolate_->current_vm_state())));
94 LOG(isolate_, 77 LOG(isolate_,
95 UncheckedStringEvent("To", StateToString(previous_tag_))); 78 UncheckedStringEvent("To", StateToString(previous_tag_)));
96 } 79 }
97 #endif // ENABLE_LOGGING_AND_PROFILING
98
99 #ifdef ENABLE_HEAP_PROTECTION
100 StateTag tag = isolate_->current_vm_state();
101 #endif
102 80
103 isolate_->SetCurrentVMState(previous_tag_); 81 isolate_->SetCurrentVMState(previous_tag_);
104
105 #ifdef ENABLE_HEAP_PROTECTION
106 if (FLAG_protect_heap) {
107 if (tag == EXTERNAL) {
108 // We are reentering V8.
109 ASSERT(previous_tag_ != EXTERNAL);
110 isolate_->heap()->Unprotect();
111 } else if (previous_tag_ == EXTERNAL) {
112 // We are leaving V8.
113 isolate_->heap()->Protect();
114 }
115 }
116 #endif // ENABLE_HEAP_PROTECTION
117 } 82 }
118 83
119 #endif // ENABLE_VMSTATE_TRACKING
120
121
122 #ifdef ENABLE_LOGGING_AND_PROFILING
123 84
124 ExternalCallbackScope::ExternalCallbackScope(Isolate* isolate, Address callback) 85 ExternalCallbackScope::ExternalCallbackScope(Isolate* isolate, Address callback)
125 : isolate_(isolate), previous_callback_(isolate->external_callback()) { 86 : isolate_(isolate), previous_callback_(isolate->external_callback()) {
126 isolate_->set_external_callback(callback); 87 isolate_->set_external_callback(callback);
127 } 88 }
128 89
129 ExternalCallbackScope::~ExternalCallbackScope() { 90 ExternalCallbackScope::~ExternalCallbackScope() {
130 isolate_->set_external_callback(previous_callback_); 91 isolate_->set_external_callback(previous_callback_);
131 } 92 }
132 93
133 #endif // ENABLE_LOGGING_AND_PROFILING
134
135 94
136 } } // namespace v8::internal 95 } } // namespace v8::internal
137 96
138 #endif // V8_VM_STATE_INL_H_ 97 #endif // V8_VM_STATE_INL_H_
OLDNEW
« no previous file with comments | « src/vm-state.h ('k') | src/x64/assembler-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698