// 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 #include "include/v8.h" #include "src/api.h" #include "src/ast/ast.h" #include "src/ast/scopes.h" #include "src/base/platform/semaphore.h" #include "src/compiler-dispatcher/compiler-dispatcher-job.h" #include "src/compiler-dispatcher/compiler-dispatcher-tracer.h" #include "src/flags.h" #include "src/isolate-inl.h" #include "src/parsing/parse-info.h" #include "src/v8.h" #include "test/unittests/compiler-dispatcher/compiler-dispatcher-helper.h" #include "test/unittests/test-utils.h" #include "testing/gtest/include/gtest/gtest.h" namespace v8 { namespace internal { class CompilerDispatcherJobTest : public TestWithContext { public: CompilerDispatcherJobTest() : tracer_(i_isolate()) {} ~CompilerDispatcherJobTest() override {} CompilerDispatcherTracer* tracer() { return &tracer_; } static void SetUpTestCase() { old_flag_ = i::FLAG_ignition; i::FLAG_ignition = true; TestWithContext::SetUpTestCase(); } static void TearDownTestCase() { TestWithContext::TearDownTestCase(); i::FLAG_ignition = old_flag_; } private: CompilerDispatcherTracer tracer_; static bool old_flag_; DISALLOW_COPY_AND_ASSIGN(CompilerDispatcherJobTest); }; bool CompilerDispatcherJobTest::old_flag_; namespace { const char test_script[] = "(x) { x*x; }"; class ScriptResource : public v8::String::ExternalOneByteStringResource { public: ScriptResource(const char* data, size_t length) : data_(data), length_(length) {} ~ScriptResource() override = default; const char* data() const override { return data_; } size_t length() const override { return length_; } private: const char* data_; size_t length_; DISALLOW_COPY_AND_ASSIGN(ScriptResource); }; Handle CreateSharedFunctionInfo( Isolate* isolate, ExternalOneByteString::Resource* maybe_resource) { HandleScope scope(isolate); Handle source; if (maybe_resource) { source = isolate->factory() ->NewExternalStringFromOneByte(maybe_resource) .ToHandleChecked(); } else { source = isolate->factory()->NewStringFromAsciiChecked(test_script); } Handle