// 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. // Test specific cases of the lazy/eager-parse decision. // // Note that presently most unit tests for parsing are found in // parsing-unittest.cc. #include #include "include/v8-local-handle.h" #include "include/v8-primitive.h" #include "src/api/api-inl.h" #include "src/execution/isolate.h" #include "src/handles/handles-inl.h" #include "src/objects/objects-inl.h" #include "src/objects/shared-function-info-inl.h" #include "src/utils/utils.h" #include "test/unittests/test-utils.h" #include "testing/gtest/include/gtest/gtest.h" namespace v8 { namespace internal { class ParseDecisionTest : public TestWithContext { public: Local Compile(const char* source) { return v8::Script::Compile( context(), v8::String::NewFromUtf8(isolate(), source).ToLocalChecked()) .ToLocalChecked(); } }; namespace { // Record the 'compiled' state of all top level functions. void GetTopLevelFunctionInfo( v8::Local script, std::unordered_map* is_compiled) { // Get the v8::internal::Script object from the API v8::Script. // The API object 'wraps' the compiled top-level function, not the i::Script. DirectHandle toplevel_fn = v8::Utils::OpenDirectHandle(*script); SharedFunctionInfo::ScriptIterator iterator( toplevel_fn->GetIsolate(), Cast