Commit 0cabbd3d authored by cbruni's avatar cbruni Committed by Commit bot

[api] Templatize do_callback parameter in CallDepthScope

Drive-by-fix: mark isolates as const in stack-allocated scopes

BUG=chromium:630217

Review-Url: https://codereview.chromium.org/2220993003
Cr-Commit-Position: refs/heads/master@{#38496}
parent a7b7d691
...@@ -957,7 +957,7 @@ class V8_EXPORT SealHandleScope { ...@@ -957,7 +957,7 @@ class V8_EXPORT SealHandleScope {
void* operator new(size_t size); void* operator new(size_t size);
void operator delete(void*, size_t); void operator delete(void*, size_t);
internal::Isolate* isolate_; internal::Isolate* const isolate_;
internal::Object** prev_limit_; internal::Object** prev_limit_;
int prev_sealed_level_; int prev_sealed_level_;
}; };
...@@ -5694,7 +5694,7 @@ class V8_EXPORT Isolate { ...@@ -5694,7 +5694,7 @@ class V8_EXPORT Isolate {
~SuppressMicrotaskExecutionScope(); ~SuppressMicrotaskExecutionScope();
private: private:
internal::Isolate* isolate_; internal::Isolate* const isolate_;
// Prevent copying of Scope objects. // Prevent copying of Scope objects.
SuppressMicrotaskExecutionScope(const SuppressMicrotaskExecutionScope&); SuppressMicrotaskExecutionScope(const SuppressMicrotaskExecutionScope&);
......
...@@ -86,7 +86,7 @@ namespace v8 { ...@@ -86,7 +86,7 @@ namespace v8 {
return bailout_value; \ return bailout_value; \
} \ } \
HandleScopeClass handle_scope(isolate); \ HandleScopeClass handle_scope(isolate); \
CallDepthScope call_depth_scope(isolate, context, do_callback); \ CallDepthScope<do_callback> call_depth_scope(isolate, context); \
LOG_API(isolate, class_name, function_name); \ LOG_API(isolate, class_name, function_name); \
ENTER_V8(isolate); \ ENTER_V8(isolate); \
bool has_pending_exception = false bool has_pending_exception = false
...@@ -170,15 +170,11 @@ void CheckMicrotasksScopesConsistency(i::Isolate* isolate) { ...@@ -170,15 +170,11 @@ void CheckMicrotasksScopesConsistency(i::Isolate* isolate) {
} }
#endif #endif
template <bool do_callback>
class CallDepthScope { class CallDepthScope {
public: public:
explicit CallDepthScope(i::Isolate* isolate, Local<Context> context, explicit CallDepthScope(i::Isolate* isolate, Local<Context> context)
bool do_callback) : isolate_(isolate), context_(context), escaped_(false) {
: isolate_(isolate),
context_(context),
escaped_(false),
do_callback_(do_callback) {
// TODO(dcarney): remove this when blink stops crashing. // TODO(dcarney): remove this when blink stops crashing.
DCHECK(!isolate_->external_caught_exception()); DCHECK(!isolate_->external_caught_exception());
isolate_->IncrementJsCallsFromApiCounter(); isolate_->IncrementJsCallsFromApiCounter();
...@@ -194,14 +190,14 @@ class CallDepthScope { ...@@ -194,14 +190,14 @@ class CallDepthScope {
context_->Enter(); context_->Enter();
} }
} }
if (do_callback_) isolate_->FireBeforeCallEnteredCallback(); if (do_callback) isolate_->FireBeforeCallEnteredCallback();
} }
~CallDepthScope() { ~CallDepthScope() {
if (!context_.IsEmpty()) context_->Exit(); if (!context_.IsEmpty()) context_->Exit();
if (!escaped_) isolate_->handle_scope_implementer()->DecrementCallDepth(); if (!escaped_) isolate_->handle_scope_implementer()->DecrementCallDepth();
if (do_callback_) isolate_->FireCallCompletedCallback(); if (do_callback) isolate_->FireCallCompletedCallback();
#ifdef DEBUG #ifdef DEBUG
if (do_callback_) CheckMicrotasksScopesConsistency(isolate_); if (do_callback) CheckMicrotasksScopesConsistency(isolate_);
#endif #endif
} }
...@@ -909,12 +905,9 @@ i::Object** EscapableHandleScope::Escape(i::Object** escape_value) { ...@@ -909,12 +905,9 @@ i::Object** EscapableHandleScope::Escape(i::Object** escape_value) {
return escape_slot_; return escape_slot_;
} }
SealHandleScope::SealHandleScope(Isolate* isolate)
SealHandleScope::SealHandleScope(Isolate* isolate) { : isolate_(reinterpret_cast<i::Isolate*>(isolate)) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); i::HandleScopeData* current = isolate_->handle_scope_data();
isolate_ = internal_isolate;
i::HandleScopeData* current = internal_isolate->handle_scope_data();
prev_limit_ = current->limit; prev_limit_ = current->limit;
current->limit = current->next; current->limit = current->next;
prev_sealed_level_ = current->sealed_level; prev_sealed_level_ = current->sealed_level;
......
...@@ -1497,9 +1497,9 @@ class SaveContext BASE_EMBEDDED { ...@@ -1497,9 +1497,9 @@ class SaveContext BASE_EMBEDDED {
Isolate* isolate() { return isolate_; } Isolate* isolate() { return isolate_; }
private: private:
Isolate* isolate_; Isolate* const isolate_;
Handle<Context> context_; Handle<Context> context_;
SaveContext* prev_; SaveContext* const prev_;
Address c_entry_fp_; Address c_entry_fp_;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment