From b40b49c3ccfacf423ceed6b8c88848c3217e6c7e Mon Sep 17 00:00:00 2001 From: Georg Neis Date: Wed, 25 Jul 2018 08:38:06 +0200 Subject: [PATCH] Move DisallowHeapAccess definition out of compiler and reuse it. Change-Id: I5cc5dc227a36ff38145df35b3afd067ebba2ad7c Reviewed-on: https://chromium-review.googlesource.com/1149361 Reviewed-by: Andreas Haas Reviewed-by: Sigurd Schneider Commit-Queue: Georg Neis Cr-Commit-Position: refs/heads/master@{#54694} --- src/assert-scope.h | 6 ++++++ src/compiler.cc | 24 +++++------------------- src/compiler/js-heap-broker.h | 7 ------- src/wasm/module-compiler.cc | 5 +---- 4 files changed, 12 insertions(+), 30 deletions(-) diff --git a/src/assert-scope.h b/src/assert-scope.h index 981a037f13..acf7649792 100644 --- a/src/assert-scope.h +++ b/src/assert-scope.h @@ -139,6 +139,12 @@ typedef PerThreadAssertScopeDebugOnly typedef PerThreadAssertScopeDebugOnly AllowCodeDependencyChange; +class DisallowHeapAccess { + DisallowHeapAllocation no_heap_allocation_; + DisallowHandleAllocation no_handle_allocation_; + DisallowHandleDereference no_handle_dereference_; + DisallowCodeDependencyChange no_dependency_change_; +}; // Per-isolate assert scopes. diff --git a/src/compiler.cc b/src/compiler.cc index 84a9ea22d2..8d36d76405 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -130,11 +130,7 @@ void LogFunctionCompilation(CodeEventListener::LogEventsAndTags tag, // Implementation of UnoptimizedCompilationJob CompilationJob::Status UnoptimizedCompilationJob::ExecuteJob() { - DisallowHeapAllocation no_allocation; - DisallowHandleAllocation no_handles; - DisallowHandleDereference no_deref; - DisallowCodeDependencyChange no_dependency_change; - + DisallowHeapAccess no_heap_access; // Delegate to the underlying implementation. DCHECK_EQ(state(), State::kReadyToExecute); ScopedTimer t(&time_taken_to_execute_); @@ -212,11 +208,7 @@ CompilationJob::Status OptimizedCompilationJob::PrepareJob(Isolate* isolate) { } CompilationJob::Status OptimizedCompilationJob::ExecuteJob() { - DisallowHeapAllocation no_allocation; - DisallowHandleAllocation no_handles; - DisallowHandleDereference no_deref; - DisallowCodeDependencyChange no_dependency_change; - + DisallowHeapAccess no_heap_access; // Delegate to the underlying implementation. DCHECK_EQ(state(), State::kReadyToExecute); ScopedTimer t(&time_taken_to_execute_); @@ -478,9 +470,7 @@ std::unique_ptr ExecuteUnoptimizedCompileJobs( std::unique_ptr GenerateUnoptimizedCode( ParseInfo* parse_info, AccountingAllocator* allocator, UnoptimizedCompilationJobList* inner_function_jobs) { - DisallowHeapAllocation no_allocation; - DisallowHandleAllocation no_handles; - DisallowHandleDereference no_deref; + DisallowHeapAccess no_heap_access; DCHECK(inner_function_jobs->empty()); if (!Compiler::Analyze(parse_info)) { @@ -922,9 +912,7 @@ MaybeHandle CompileToplevel(ParseInfo* parse_info, std::unique_ptr CompileTopLevelOnBackgroundThread( ParseInfo* parse_info, AccountingAllocator* allocator, UnoptimizedCompilationJobList* inner_function_jobs) { - DisallowHeapAllocation no_allocation; - DisallowHandleAllocation no_handles; - DisallowHandleDereference no_deref; + DisallowHeapAccess no_heap_access; TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileCodeBackground"); RuntimeCallTimerScope runtimeTimer( @@ -1003,9 +991,7 @@ BackgroundCompileTask::BackgroundCompileTask(ScriptStreamingData* source, void BackgroundCompileTask::Run() { TimedHistogramScope timer(timer_); - DisallowHeapAllocation no_allocation; - DisallowHandleAllocation no_handles; - DisallowHandleDereference no_deref; + DisallowHeapAccess no_heap_access; source_->info->set_on_background_thread(true); diff --git a/src/compiler/js-heap-broker.h b/src/compiler/js-heap-broker.h index 466436d032..e117dd0285 100644 --- a/src/compiler/js-heap-broker.h +++ b/src/compiler/js-heap-broker.h @@ -15,13 +15,6 @@ namespace v8 { namespace internal { namespace compiler { -class DisallowHeapAccess { - DisallowHeapAllocation no_heap_allocation_; - DisallowHandleAllocation no_handle_allocation_; - DisallowHandleDereference no_handle_dereference_; - DisallowCodeDependencyChange no_dependency_change_; -}; - enum class OddballType : uint8_t { kNone, // Not an Oddball. kBoolean, // True or False. diff --git a/src/wasm/module-compiler.cc b/src/wasm/module-compiler.cc index b49ad8ff7f..e730ca73af 100644 --- a/src/wasm/module-compiler.cc +++ b/src/wasm/module-compiler.cc @@ -526,10 +526,7 @@ class CompilationUnitBuilder { // within the result_mutex_ lock when no finishing task is running, i.e. when // the finisher_is_running_ flag is not set. bool FetchAndExecuteCompilationUnit(CompilationState* compilation_state) { - DisallowHeapAllocation no_allocation; - DisallowHandleAllocation no_handles; - DisallowHandleDereference no_deref; - DisallowCodeDependencyChange no_dependency_change; + DisallowHeapAccess no_heap_access; std::unique_ptr unit = compilation_state->GetNextCompilationUnit();