// Copyright 2023 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 <optional> #include "include/v8-function-callback.h" #include "include/v8-function.h" #include "src/base/strings.h" #include "test/cctest/cctest.h" Context; External; Function; FunctionTemplate; HandleScope; Integer; Isolate; Local; MaybeLocal; Object; String; Value; namespace { void EmptyHandler(const v8::FunctionCallbackInfo<v8::Value>& info) { … } struct IncumbentTestExpectations { … }; // This callback checks that the incumbent context equals to the expected one // and returns the function's context ID (i.e. "globalThis.id"). void FunctionWithIncumbentCheck( const v8::FunctionCallbackInfo<v8::Value>& info) { … } // Creates test contexts in the folloing way: // 1) Each context can access other contexts, // 2) Each context is equipped with various user-level function that call // other functions provided as an argument, // 3) The helper functions in i-th context are optimized to i-th level: // Ignition, Sparkplug, Maglev, TurboFan. // 4) Each callee function is supposed to be monomorphic in each testing // scenario so that the optimizing compiler could inling the callee. // 5) Each context gets an Api function "f" which checks current context // and incumbent context against expected ones. The function can be called // as a constructor. // 6) The tests should setup a call chain in such a way that function "f" is // called from each context, thus we can test that GetIncumbentContext // works correctly for each compiler. v8::LocalVector<Context> SetupCrossContextTest( Isolate* isolate, IncumbentTestExpectations* expected) { … } void Run(const char* source) { … } void IncumbentContextTest_Api(bool with_api_incumbent) { … } } // namespace THREADED_TEST(IncumbentContextTest_Api) { … } THREADED_TEST(IncumbentContextTest_ApiWithIncumbent) { … } THREADED_TEST(IncumbentContextTest_Basic1) { … } THREADED_TEST(IncumbentContextTest_Basic2) { … } THREADED_TEST(IncumbentContextTest_WithBuiltins3) { … } THREADED_TEST(IncumbentContextTest_WithBuiltins4) { … }