chromium/v8/test/unittests/compiler/compiler-unittest.cc

// Copyright 2022 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/codegen/compiler.h"

#include <stdlib.h>
#include <wchar.h>

#include <memory>

#include "include/v8-function.h"
#include "include/v8-local-handle.h"
#include "include/v8-profiler.h"
#include "include/v8-script.h"
#include "src/api/api-inl.h"
#include "src/codegen/compilation-cache.h"
#include "src/codegen/script-details.h"
#include "src/heap/factory.h"
#include "src/objects/allocation-site-inl.h"
#include "src/objects/objects-inl.h"
#include "src/objects/shared-function-info.h"
#include "test/unittests/heap/heap-utils.h"  // For ManualGCScope.
#include "test/unittests/test-utils.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace v8 {

using CompilerTest = TestWithContext;
namespace internal {

static Handle<Object> GetGlobalProperty(const char* name) {}

static void SetGlobalProperty(const char* name, Tagged<Object> value) {}

static Handle<JSFunction> Compile(const char* source) {}

static double Inc(Isolate* isolate, int x) {}

TEST_F(CompilerTest, Inc) {}

static double Add(Isolate* isolate, int x, int y) {}

TEST_F(CompilerTest, Add) {}

static double Abs(Isolate* isolate, int x) {}

TEST_F(CompilerTest, Abs) {}

static double Sum(Isolate* isolate, int n) {}

TEST_F(CompilerTest, Sum) {}

using CompilerPrintTest = WithPrintExtensionMixin<v8::TestWithIsolate>;

TEST_F(CompilerPrintTest, Print) {}

// The following test method stems from my coding efforts today. It
// tests all the functionality I have added to the compiler today
TEST_F(CompilerTest, Stuff) {}

TEST_F(CompilerTest, UncaughtThrow) {}

using CompilerC2JSFramesTest = WithPrintExtensionMixin<v8::TestWithIsolate>;

// Tests calling a builtin function from C/C++ code, and the builtin function
// performs GC. It creates a stack frame looks like following:
//   | C (PerformGC) |
//   |   JS-to-C     |
//   |      JS       |
//   |   C-to-JS     |
TEST_F(CompilerC2JSFramesTest, C2JSFrames) {}

// Regression 236. Calling InitLineEnds on a Script with undefined
// source resulted in crash.
TEST_F(CompilerTest, Regression236) {}

TEST_F(CompilerTest, GetScriptLineNumber) {}

TEST_F(CompilerTest, FeedbackVectorPreservedAcrossRecompiles) {}

TEST_F(CompilerTest, FeedbackVectorUnaffectedByScopeChanges) {}

// Test that optimized code for different closures is actually shared.
TEST_F(CompilerTest, OptimizedCodeSharing1) {}

TEST_F(CompilerTest, CompileFunction) {}

TEST_F(CompilerTest, CompileFunctionComplex) {}

TEST_F(CompilerTest, CompileFunctionArgs) {}

TEST_F(CompilerTest, CompileFunctionComments) {}

TEST_F(CompilerTest, CompileFunctionNonIdentifierArgs) {}

TEST_F(CompilerTest, CompileFunctionRenderCallSite) {}

TEST_F(CompilerTest, CompileFunctionQuirks) {}

TEST_F(CompilerTest, CompileFunctionScriptOrigin) {}

TEST_F(CompilerTest, CompileFunctionFunctionToString) {}

TEST_F(CompilerTest, InvocationCount) {}

TEST_F(CompilerTest, ShallowEagerCompilation) {}

TEST_F(CompilerTest, DeepEagerCompilation) {}

TEST_F(CompilerTest, DeepEagerCompilationPeakMemory) {}

namespace {

// Dummy external source stream which returns the whole source in one go.
class DummySourceStream : public v8::ScriptCompiler::ExternalSourceStream {};

}  // namespace

// Tests that doing something that causes source positions to need to be
// collected after a background compilation task has started does result in
// source positions being collected.
TEST_F(CompilerTest, ProfilerEnabledDuringBackgroundCompile) {}

using BackgroundMergeTest = TestWithNativeContext;

// Tests that a GC during merge doesn't break the merge.
TEST_F(BackgroundMergeTest, GCDuringMerge) {}

}  // namespace internal
}  // namespace v8