chromium/v8/test/unittests/execution/thread-termination-unittest.cc

// Copyright 2009 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above
//       copyright notice, this list of conditions and the following
//       disclaimer in the documentation and/or other materials provided
//       with the distribution.
//     * Neither the name of Google Inc. nor the names of its
//       contributors may be used to endorse or promote products derived
//       from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "include/v8-function.h"
#include "include/v8-locker.h"
#include "src/api/api-inl.h"
#include "src/base/platform/platform.h"
#include "src/execution/interrupts-scope.h"
#include "src/execution/isolate.h"
#include "src/init/v8.h"
#include "src/objects/objects-inl.h"
#include "test/unittests/test-utils.h"
#include "testing/gmock-support.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace v8 {

base::Semaphore* semaphore =;

class TerminatorThread : public base::Thread {};

void Signal(const FunctionCallbackInfo<Value>& info) {}

MaybeLocal<Value> CompileRun(Local<Context> context, Local<String> source) {}

MaybeLocal<Value> CompileRun(Local<Context> context, const char* source) {}

void DoLoop(const FunctionCallbackInfo<Value>& info) {}

void Fail(const FunctionCallbackInfo<Value>& info) {}

void Loop(const FunctionCallbackInfo<Value>& info) {}

void TerminateCurrentThread(const FunctionCallbackInfo<Value>& info) {}

class ThreadTerminationTest : public TestWithIsolate {};

void DoLoopNoCall(const FunctionCallbackInfo<Value>& info) {}

// Test that a single thread of JavaScript execution can terminate
// itself.
TEST_F(ThreadTerminationTest, TerminateOnlyV8ThreadFromThreadItself) {}

// Test that a single thread of JavaScript execution can terminate
// itself in a loop that performs no calls.
TEST_F(ThreadTerminationTest, TerminateOnlyV8ThreadFromThreadItselfNoLoop) {}

// Test that a single thread of JavaScript execution can be terminated
// from the side by another thread.
TEST_F(ThreadTerminationTest, TerminateOnlyV8ThreadFromOtherThread) {}

// Test that execution can be terminated from within JSON.stringify.
TEST_F(ThreadTerminationTest, TerminateJsonStringify) {}

TEST_F(ThreadTerminationTest, TerminateBigIntMultiplication) {}

TEST_F(ThreadTerminationTest, TerminateOptimizedBigIntMultiplication) {}

TEST_F(ThreadTerminationTest, TerminateBigIntDivision) {}

TEST_F(ThreadTerminationTest, TerminateOptimizedBigIntDivision) {}

TEST_F(ThreadTerminationTest, TerminateBigIntToString) {}

TEST_F(ThreadTerminationTest, TerminateBigIntFromString) {}

void LoopGetProperty(const FunctionCallbackInfo<Value>& info) {}

int call_count =;

void TerminateOrReturnObject(const FunctionCallbackInfo<Value>& info) {}

// Test that we correctly handle termination exceptions if they are
// triggered by the creation of error objects in connection with ICs.
TEST_F(ThreadTerminationTest, TerminateLoadICException) {}

Persistent<String> reenter_script_1;
Persistent<String> reenter_script_2;

void DoLoopCancelTerminate(const FunctionCallbackInfo<Value>& info) {}

// Test that a single thread of JavaScript execution can terminate
// itself and then resume execution.
TEST_F(ThreadTerminationTest, TerminateCancelTerminateFromThreadItself) {}

void MicrotaskShouldNotRun(const FunctionCallbackInfo<Value>& info) {}

void MicrotaskLoopForever(const FunctionCallbackInfo<Value>& info) {}

TEST_F(ThreadTerminationTest, TerminateFromOtherThreadWhileMicrotaskRunning) {}

static int callback_counter =;

static void CounterCallback(Isolate* isolate, void* data) {}

TEST_F(ThreadTerminationTest, PostponeTerminateException) {}

static void AssertFinishedCodeRun(Isolate* isolate) {}

void RequestTermianteAndCallAPI(const FunctionCallbackInfo<Value>& info) {}

TEST_F(ThreadTerminationTest, ErrorObjectAfterTermination) {}

void InnerTryCallTerminate(const FunctionCallbackInfo<Value>& info) {}

TEST_F(ThreadTerminationTest, TerminationInInnerTryCall) {}

TEST_F(ThreadTerminationTest, TerminateAndTryCall) {}

class ConsoleImpl : public debug::ConsoleDelegate {};

TEST_F(ThreadTerminationTest, TerminateConsole) {}

TEST_F(ThreadTerminationTest, TerminationClearArrayJoinStack) {}

class TerminatorSleeperThread : public base::Thread {};

TEST_F(ThreadTerminationTest, TerminateRegExp) {}

TEST_F(ThreadTerminationTest, TerminateInMicrotask) {}

void TerminationMicrotask(void* data) {}

void UnreachableMicrotask(void* data) {}

TEST_F(ThreadTerminationTest, TerminateInApiMicrotask) {}

}  // namespace v8