chromium/v8/test/cctest/wasm/test-streaming-compilation.cc

// Copyright 2017 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/libplatform/libplatform.h"
#include "src/api/api-inl.h"
#include "src/base/vector.h"
#include "src/handles/global-handles-inl.h"
#include "src/init/v8.h"
#include "src/objects/managed.h"
#include "src/objects/objects-inl.h"
#include "src/wasm/module-compiler.h"
#include "src/wasm/module-decoder.h"
#include "src/wasm/streaming-decoder.h"
#include "src/wasm/wasm-engine.h"
#include "src/wasm/wasm-module-builder.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-objects-inl.h"
#include "src/wasm/wasm-objects.h"
#include "src/wasm/wasm-serialization.h"
#include "test/cctest/cctest.h"
#include "test/common/wasm/flag-utils.h"
#include "test/common/wasm/test-signatures.h"
#include "test/common/wasm/wasm-macro-gen.h"
#include "test/common/wasm/wasm-module-runner.h"

namespace v8::internal::wasm {

class MockPlatform final : public TestPlatform {};

namespace {

enum class CompilationState {};

class TestResolver : public CompilationResultResolver {};

class StreamTester {};
}  // namespace

#define RUN_STREAM(name)

#define STREAM_TEST

constexpr const char* kExportNames[] =;

// Create a valid module with 3 functions.
ZoneBuffer GetValidModuleBytes(Zone* zone) {}

// Create the same valid module as above and serialize it to test streaming
// with compiled module caching.
ZoneBuffer GetValidCompiledModuleBytes(v8::Isolate* isolate, Zone* zone,
                                       ZoneBuffer wire_bytes) {}

// Test that all bytes arrive before doing any compilation. FinishStream is
// called immediately.
STREAM_TEST(TestAllBytesArriveImmediatelyStreamFinishesFirst) {}

// Test that all bytes arrive before doing any compilation. FinishStream is
// called after the compilation is done.
STREAM_TEST(TestAllBytesArriveAOTCompilerFinishesFirst) {}

size_t GetFunctionOffset(i::Isolate* isolate, base::Vector<const uint8_t> bytes,
                         size_t index) {}

// Test that some functions come in the beginning, some come after some
// functions already got compiled.
STREAM_TEST(TestCutAfterOneFunctionStreamFinishesFirst) {}

// Test that some functions come in the beginning, some come after some
// functions already got compiled. Call FinishStream after the compilation is
// done.
STREAM_TEST(TestCutAfterOneFunctionCompilerFinishesFirst) {}

// Create a module with an invalid global section.
ZoneBuffer GetModuleWithInvalidSection(Zone* zone) {}

// Test an error in a section, found by the ModuleDecoder.
STREAM_TEST(TestErrorInSectionStreamFinishesFirst) {}

STREAM_TEST(TestErrorInSectionCompilerFinishesFirst) {}

STREAM_TEST(TestErrorInSectionWithCuts) {}

ZoneBuffer GetModuleWithInvalidSectionSize(Zone* zone) {}

STREAM_TEST(TestErrorInSectionSizeStreamFinishesFirst) {}

STREAM_TEST(TestErrorInSectionSizeCompilerFinishesFirst) {}

STREAM_TEST(TestErrorInSectionSizeWithCuts) {}

// Test an error in the code section, found by the ModuleDecoder. The error is a
// functions count in the code section which differs from the functions count in
// the function section.
STREAM_TEST(TestErrorInCodeSectionDetectedByModuleDecoder) {}

STREAM_TEST(TestSectionOrderErrorWithEmptyCodeSection) {}

STREAM_TEST(TestSectionOrderErrorWithNonEmptyCodeSection) {}

// Test an error in the code section, found by the StreamingDecoder. The error
// is an invalid function body size, so that there are not enough bytes in the
// code section for the function body.
STREAM_TEST(TestErrorInCodeSectionDetectedByStreamingDecoder) {}

// Test an error in the code section, found by the Compiler. The error is an
// invalid return type.
STREAM_TEST(TestErrorInCodeSectionDetectedByCompiler) {}

// Test Abort before any bytes arrive.
STREAM_TEST(TestAbortImmediately) {}

// Test Abort within a section.
STREAM_TEST(TestAbortWithinSection1) {}

// Test Abort within a section.
STREAM_TEST(TestAbortWithinSection2) {}

// Test Abort just before the code section.
STREAM_TEST(TestAbortAfterSection) {}

// Test Abort after the function count in the code section. The compiler tasks
// execute before the abort.
STREAM_TEST(TestAbortAfterFunctionsCount1) {}

// Test Abort after the function count in the code section. The compiler tasks
// do not execute before the abort.
STREAM_TEST(TestAbortAfterFunctionsCount2) {}

// Test Abort after some functions got compiled. The compiler tasks execute
// before the abort.
STREAM_TEST(TestAbortAfterFunctionGotCompiled1) {}

// Test Abort after some functions got compiled. The compiler tasks execute
// before the abort.
STREAM_TEST(TestAbortAfterFunctionGotCompiled2) {}

// Test Abort after all functions got compiled.
STREAM_TEST(TestAbortAfterCodeSection1) {}

// Test Abort after all functions got compiled.
STREAM_TEST(TestAbortAfterCodeSection2) {}

STREAM_TEST(TestAbortAfterCompilationError1) {}

STREAM_TEST(TestAbortAfterCompilationError2) {}

STREAM_TEST(TestOnlyModuleHeader) {}

STREAM_TEST(TestModuleWithZeroFunctions) {}

STREAM_TEST(TestModuleWithMultipleFunctions) {}

STREAM_TEST(TestModuleWithDataSection) {}
// Test that all bytes arrive before doing any compilation. FinishStream is
// called immediately.
STREAM_TEST(TestModuleWithImportedFunction) {}

STREAM_TEST(TestIncrementalCaching) {}

STREAM_TEST(TestModuleWithErrorAfterDataSection) {}

// Test that cached bytes work.
STREAM_TEST(TestDeserializationBypassesCompilation) {}

// Test that bad cached bytes don't cause compilation of wire bytes to fail.
STREAM_TEST(TestDeserializationFails) {}

// Test that a non-empty function section with a missing code section fails.
STREAM_TEST(TestFunctionSectionWithoutCodeSection) {}

STREAM_TEST(TestMoreFunctionsCanBeSerializedCallback) {}

STREAM_TEST(TestMoreFunctionsCanBeSerializedCallbackWithTimeout) {}

STREAM_TEST(TestHardCachingThreshold) {}

// Test that a compile error contains the name of the function, even if the name
// section is not present at the time the error is detected.
STREAM_TEST(TestCompileErrorFunctionName) {}

STREAM_TEST(TestSetModuleCodeSection) {}

// Test that profiler does not crash when module is only partly compiled.
STREAM_TEST(TestProfilingMidStreaming) {}

STREAM_TEST(TierDownWithError) {}

STREAM_TEST(Regress1334651) {}

#undef STREAM_TEST

}  // namespace v8::internal::wasm