#include "src/interpreter/bytecode-generator.h"
#include <fstream>
#include "src/init/v8.h"
#include "src/interpreter/bytecode-array-iterator.h"
#include "src/interpreter/interpreter.h"
#include "src/objects/objects-inl.h"
#include "test/unittests/interpreter/bytecode-expectations-printer.h"
#include "test/unittests/test-utils.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace v8 {
namespace internal {
namespace interpreter {
class BytecodeGeneratorTest : public TestWithContext { … };
int global_counter = …;
std::string LoadUniqueProperties(int n) { … }
std::string UniqueVars(int n) { … }
std::string Repeat(std::string s, int n) { … }
static const char* kGoldenFileDirectory = …;
void SkipGoldenFileHeader(std::istream* stream) { … }
std::string LoadGolden(const std::string& golden_filename) { … }
template <size_t N>
std::string BuildActual(const BytecodeExpectationsPrinter& printer,
std::string (&snippet_list)[N],
const char* prologue = nullptr,
const char* epilogue = nullptr) { … }
static inline void ltrim(std::string* str) { … }
static inline void rtrim(std::string* str) { … }
static inline std::string trim(std::string* str) { … }
bool CompareTexts(const std::string& generated, const std::string& expected) { … }
TEST_F(BytecodeGeneratorTest, PrimitiveReturnStatements) { … }
TEST_F(BytecodeGeneratorTest, PrimitiveExpressions) { … }
TEST_F(BytecodeGeneratorTest, LogicalExpressions) { … }
TEST_F(BytecodeGeneratorTest, Parameters) { … }
TEST_F(BytecodeGeneratorTest, IntegerConstants) { … }
TEST_F(BytecodeGeneratorTest, HeapNumberConstants) { … }
TEST_F(BytecodeGeneratorTest, StringConstants) { … }
TEST_F(BytecodeGeneratorTest, PropertyLoads) { … }
TEST_F(BytecodeGeneratorTest, PropertyLoadStore) { … }
TEST_F(BytecodeGeneratorTest, IIFE) { … }
TEST_F(BytecodeGeneratorTest, PropertyStores) { … }
#define FUNC_ARG …
TEST_F(BytecodeGeneratorTest, PropertyCall) { … }
TEST_F(BytecodeGeneratorTest, LoadGlobal) { … }
TEST_F(BytecodeGeneratorTest, StoreGlobal) { … }
TEST_F(BytecodeGeneratorTest, CallGlobal) { … }
TEST_F(BytecodeGeneratorTest, CallRuntime) { … }
TEST_F(BytecodeGeneratorTest, IfConditions) { … }
TEST_F(BytecodeGeneratorTest, DeclareGlobals) { … }
TEST_F(BytecodeGeneratorTest, BreakableBlocks) { … }
TEST_F(BytecodeGeneratorTest, BasicLoops) { … }
TEST_F(BytecodeGeneratorTest, UnaryOperators) { … }
TEST_F(BytecodeGeneratorTest, Typeof) { … }
TEST_F(BytecodeGeneratorTest, CompareTypeOf) { … }
TEST_F(BytecodeGeneratorTest, VariableWithHint) { … }
TEST_F(BytecodeGeneratorTest, CompareBoolean) { … }
TEST_F(BytecodeGeneratorTest, CompareNil) { … }
TEST_F(BytecodeGeneratorTest, Delete) { … }
TEST_F(BytecodeGeneratorTest, GlobalDelete) { … }
TEST_F(BytecodeGeneratorTest, FunctionLiterals) { … }
TEST_F(BytecodeGeneratorTest, RegExpLiterals) { … }
TEST_F(BytecodeGeneratorTest, ArrayLiterals) { … }
TEST_F(BytecodeGeneratorTest, ObjectLiterals) { … }
TEST_F(BytecodeGeneratorTest, TopLevelObjectLiterals) { … }
TEST_F(BytecodeGeneratorTest, TryCatch) { … }
TEST_F(BytecodeGeneratorTest, TryFinally) { … }
TEST_F(BytecodeGeneratorTest, Throw) { … }
TEST_F(BytecodeGeneratorTest, CallNew) { … }
TEST_F(BytecodeGeneratorTest, ContextVariables) { … }
TEST_F(BytecodeGeneratorTest, ContextParameters) { … }
TEST_F(BytecodeGeneratorTest, OuterContextVariables) { … }
TEST_F(BytecodeGeneratorTest, CountOperators) { … }
TEST_F(BytecodeGeneratorTest, GlobalCountOperators) { … }
TEST_F(BytecodeGeneratorTest, CompoundExpressions) { … }
TEST_F(BytecodeGeneratorTest, GlobalCompoundExpressions) { … }
TEST_F(BytecodeGeneratorTest, CreateArguments) { … }
TEST_F(BytecodeGeneratorTest, CreateRestParameter) { … }
TEST_F(BytecodeGeneratorTest, ForIn) { … }
TEST_F(BytecodeGeneratorTest, ForOf) { … }
TEST_F(BytecodeGeneratorTest, Conditional) { … }
TEST_F(BytecodeGeneratorTest, Switch) { … }
TEST_F(BytecodeGeneratorTest, BasicBlockToBoolean) { … }
TEST_F(BytecodeGeneratorTest, DeadCodeRemoval) { … }
TEST_F(BytecodeGeneratorTest, ThisFunction) { … }
TEST_F(BytecodeGeneratorTest, NewTarget) { … }
TEST_F(BytecodeGeneratorTest, RemoveRedundantLdar) { … }
TEST_F(BytecodeGeneratorTest, GenerateTestUndetectable) { … }
TEST_F(BytecodeGeneratorTest, AssignmentsInBinaryExpression) { … }
TEST_F(BytecodeGeneratorTest, DestructuringAssignment) { … }
TEST_F(BytecodeGeneratorTest, Eval) { … }
TEST_F(BytecodeGeneratorTest, LookupSlot) { … }
TEST_F(BytecodeGeneratorTest, CallLookupSlot) { … }
TEST_F(BytecodeGeneratorTest, LookupSlotInEval) { … }
TEST_F(BytecodeGeneratorTest, DeleteLookupSlotInEval) { … }
TEST_F(BytecodeGeneratorTest, WideRegisters) { … }
TEST_F(BytecodeGeneratorTest, ConstVariable) { … }
TEST_F(BytecodeGeneratorTest, LetVariable) { … }
TEST_F(BytecodeGeneratorTest, ConstVariableContextSlot) { … }
TEST_F(BytecodeGeneratorTest, LetVariableContextSlot) { … }
TEST_F(BytecodeGeneratorTest, WithStatement) { … }
TEST_F(BytecodeGeneratorTest, DoDebugger) { … }
TEST_F(BytecodeGeneratorTest, ClassDeclarations) { … }
TEST_F(BytecodeGeneratorTest, ClassAndSuperClass) { … }
TEST_F(BytecodeGeneratorTest, PublicClassFields) { … }
TEST_F(BytecodeGeneratorTest, PrivateClassFields) { … }
TEST_F(BytecodeGeneratorTest, PrivateClassFieldAccess) { … }
TEST_F(BytecodeGeneratorTest, PrivateMethodDeclaration) { … }
TEST_F(BytecodeGeneratorTest, PrivateMethodAccess) { … }
TEST_F(BytecodeGeneratorTest, PrivateAccessorAccess) { … }
TEST_F(BytecodeGeneratorTest, StaticPrivateMethodDeclaration) { … }
TEST_F(BytecodeGeneratorTest, StaticPrivateMethodAccess) { … }
TEST_F(BytecodeGeneratorTest, PrivateAccessorDeclaration) { … }
TEST_F(BytecodeGeneratorTest, StaticClassFields) { … }
TEST_F(BytecodeGeneratorTest, Generators) { … }
TEST_F(BytecodeGeneratorTest, AsyncGenerators) { … }
TEST_F(BytecodeGeneratorTest, Modules) { … }
TEST_F(BytecodeGeneratorTest, AsyncModules) { … }
TEST_F(BytecodeGeneratorTest, SuperCallAndSpread) { … }
TEST_F(BytecodeGeneratorTest, CallAndSpread) { … }
TEST_F(BytecodeGeneratorTest, NewAndSpread) { … }
TEST_F(BytecodeGeneratorTest, ForAwaitOf) { … }
TEST_F(BytecodeGeneratorTest, StandardForLoop) { … }
TEST_F(BytecodeGeneratorTest, ForOfLoop) { … }
TEST_F(BytecodeGeneratorTest, StringConcat) { … }
TEST_F(BytecodeGeneratorTest, TemplateLiterals) { … }
TEST_F(BytecodeGeneratorTest, ElideRedundantLoadOperationOfImmutableContext) { … }
TEST_F(BytecodeGeneratorTest, ElideRedundantHoleChecks) { … }
}
}
}