// Copyright 2016 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "src/compiler-dispatcher/unoptimized-compile-job.h" #include "src/assert-scope.h" #include "src/base/optional.h" #include "src/compiler-dispatcher/compiler-dispatcher-tracer.h" #include "src/compiler.h" #include "src/flags.h" #include "src/global-handles.h" #include "src/interpreter/interpreter.h" #include "src/isolate.h" #include "src/objects-inl.h" #include "src/parsing/parse-info.h" #include "src/parsing/parser.h" #include "src/parsing/scanner-character-streams.h" #include "src/unicode-cache.h" #include "src/unoptimized-compilation-info.h" #include "src/utils.h" namespace v8 { namespace internal { namespace { class OneByteWrapper : public v8::String::ExternalOneByteStringResource { public: OneByteWrapper(const void* data, int length) : data_(data), length_(length) {} ~OneByteWrapper() override = default; const char* data() const override { return reinterpret_cast(data_); } size_t length() const override { return static_cast(length_); } private: const void* data_; int length_; DISALLOW_COPY_AND_ASSIGN(OneByteWrapper); }; class TwoByteWrapper : public v8::String::ExternalStringResource { public: TwoByteWrapper(const void* data, int length) : data_(data), length_(length) {} ~TwoByteWrapper() override = default; const uint16_t* data() const override { return reinterpret_cast(data_); } size_t length() const override { return static_cast(length_); } private: const void* data_; int length_; DISALLOW_COPY_AND_ASSIGN(TwoByteWrapper); }; } // namespace UnoptimizedCompileJob::UnoptimizedCompileJob(Isolate* isolate, CompilerDispatcherTracer* tracer, Handle shared, size_t max_stack_size) : CompilerDispatcherJob(Type::kUnoptimizedCompile), main_thread_id_(isolate->thread_id().ToInteger()), tracer_(tracer), allocator_(isolate->allocator()), context_(isolate->global_handles()->Create(isolate->context())), shared_(isolate->global_handles()->Create(*shared)), max_stack_size_(max_stack_size), trace_compiler_dispatcher_jobs_(FLAG_trace_compiler_dispatcher_jobs) { DCHECK(!shared_->is_toplevel()); // TODO(rmcilroy): Handle functions with non-empty outer scope info. DCHECK(!shared_->HasOuterScopeInfo()); HandleScope scope(isolate); Handle