Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Side by Side Diff: src/api.cc

Issue 968943002: check for null context on execution entry (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 EXCEPTION_BAILOUT_CHECK_GENERIC(isolate, value, ;) 96 EXCEPTION_BAILOUT_CHECK_GENERIC(isolate, value, ;)
97 97
98 98
99 #define PREPARE_FOR_EXECUTION_GENERIC(context, function_name, bailout_value, \ 99 #define PREPARE_FOR_EXECUTION_GENERIC(context, function_name, bailout_value, \
100 HandleScopeClass) \ 100 HandleScopeClass) \
101 auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate()); \ 101 auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate()); \
102 if (IsExecutionTerminatingCheck(isolate)) { \ 102 if (IsExecutionTerminatingCheck(isolate)) { \
103 return bailout_value; \ 103 return bailout_value; \
104 } \ 104 } \
105 HandleScopeClass handle_scope(isolate); \ 105 HandleScopeClass handle_scope(isolate); \
106 CallDepthScope call_depth_scope(isolate, false); \ 106 CallDepthScope call_depth_scope(isolate, context, false); \
107 v8::Context::Scope context_scope(context); \
108 LOG_API(isolate, function_name); \ 107 LOG_API(isolate, function_name); \
109 ENTER_V8(isolate); \ 108 ENTER_V8(isolate); \
110 bool has_pending_exception = false 109 bool has_pending_exception = false
111 110
112 111
113 #define PREPARE_FOR_EXECUTION(context, function_name, T) \ 112 #define PREPARE_FOR_EXECUTION(context, function_name, T) \
114 PREPARE_FOR_EXECUTION_GENERIC(context, function_name, MaybeLocal<T>(), \ 113 PREPARE_FOR_EXECUTION_GENERIC(context, function_name, MaybeLocal<T>(), \
115 InternalEscapableScope) 114 InternalEscapableScope)
116 115
117 116
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 152
154 class InternalEscapableScope : public v8::EscapableHandleScope { 153 class InternalEscapableScope : public v8::EscapableHandleScope {
155 public: 154 public:
156 explicit inline InternalEscapableScope(i::Isolate* isolate) 155 explicit inline InternalEscapableScope(i::Isolate* isolate)
157 : v8::EscapableHandleScope(reinterpret_cast<v8::Isolate*>(isolate)) {} 156 : v8::EscapableHandleScope(reinterpret_cast<v8::Isolate*>(isolate)) {}
158 }; 157 };
159 158
160 159
161 class CallDepthScope { 160 class CallDepthScope {
162 public: 161 public:
163 explicit CallDepthScope(i::Isolate* isolate, bool do_callback) 162 explicit CallDepthScope(i::Isolate* isolate, Local<Context> context,
164 : isolate_(isolate), escaped_(false), do_callback_(do_callback) { 163 bool do_callback)
164 : isolate_(isolate),
165 context_(context),
166 escaped_(false),
167 do_callback_(do_callback) {
168 // TODO(dcarney): remove this when blink stops crashing.
165 DCHECK(!isolate_->external_caught_exception()); 169 DCHECK(!isolate_->external_caught_exception());
166 isolate_->handle_scope_implementer()->IncrementCallDepth(); 170 isolate_->handle_scope_implementer()->IncrementCallDepth();
171 if (!context_.IsEmpty()) context_->Enter();
167 } 172 }
168 ~CallDepthScope() { 173 ~CallDepthScope() {
174 if (!context_.IsEmpty()) context_->Exit();
169 if (!escaped_) isolate_->handle_scope_implementer()->DecrementCallDepth(); 175 if (!escaped_) isolate_->handle_scope_implementer()->DecrementCallDepth();
170 if (do_callback_) isolate_->FireCallCompletedCallback(); 176 if (do_callback_) isolate_->FireCallCompletedCallback();
171 } 177 }
172 178
173 void Escape() { 179 void Escape() {
174 DCHECK(!escaped_); 180 DCHECK(!escaped_);
175 escaped_ = true; 181 escaped_ = true;
176 auto handle_scope_implementer = isolate_->handle_scope_implementer(); 182 auto handle_scope_implementer = isolate_->handle_scope_implementer();
177 handle_scope_implementer->DecrementCallDepth(); 183 handle_scope_implementer->DecrementCallDepth();
178 bool call_depth_is_zero = handle_scope_implementer->CallDepthIsZero(); 184 bool call_depth_is_zero = handle_scope_implementer->CallDepthIsZero();
179 isolate_->OptionalRescheduleException(call_depth_is_zero); 185 isolate_->OptionalRescheduleException(call_depth_is_zero);
180 } 186 }
181 187
182 private: 188 private:
183 i::Isolate* const isolate_; 189 i::Isolate* const isolate_;
190 Local<Context> context_;
184 bool escaped_; 191 bool escaped_;
185 bool do_callback_; 192 bool do_callback_;
186 }; 193 };
187 194
188 } // namespace 195 } // namespace
189 196
190 197
191 // --- E x c e p t i o n B e h a v i o r --- 198 // --- E x c e p t i o n B e h a v i o r ---
192 199
193 200
(...skipping 7773 matching lines...) Expand 10 before | Expand all | Expand 10 after
7967 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7974 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7968 Address callback_address = 7975 Address callback_address =
7969 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7976 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7970 VMState<EXTERNAL> state(isolate); 7977 VMState<EXTERNAL> state(isolate);
7971 ExternalCallbackScope call_scope(isolate, callback_address); 7978 ExternalCallbackScope call_scope(isolate, callback_address);
7972 callback(info); 7979 callback(info);
7973 } 7980 }
7974 7981
7975 7982
7976 } } // namespace v8::internal 7983 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698