// 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/scopes.h" #include "src/compiler-dispatcher/compiler-dispatcher-job.h" #include "src/flags.h" #include "src/isolate-inl.h" #include "src/parsing/parse-info.h" #include "test/unittests/test-utils.h" #include "testing/gtest/include/gtest/gtest.h" namespace v8 { namespace internal { typedef TestWithContext CompilerDispatcherJobTest; 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 CreateFunction( 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