<commit_before>#include "codegenerator.h"
#include "verifier.h"
#include "type.h"
#include "vmstate.h"
#include "rtlibrary.h"
#include "function.h"
#include "instructions.h"
#include "exceptions.h"
#include "stackjit.h"
#include "helpers.h"
#include "callingconvention.h"
#include <string.h>
#include <iostream>

namespace {
	void pushArray(std::vector<unsigned char>& dest, const std::vector<unsigned char>& values) {
		for (auto current : values) {
			dest.push_back(current);
		}
	}

	//Returns the offset for a stack operand
	int getStackOperandOffset(Function& function, int operandStackIndex) {
		return -(int)(Amd64Backend::REG_SIZE * (1 + function.numLocals() + function.numParams() + operandStackIndex));
	}

	//Indicates if the given value fits in a char
	bool validCharValue(int value) {
		return value >= -128 && value < 128;
	}

	//Generates a compile call for the given function
	std::size_t generateCompileCall(CodeGen& generatedCode, Function& function, const FunctionDefinition& funcToCall) {
		std::size_t callIndex;
		std::size_t checkEndIndex;

		Amd64Backend::moveLongToReg(generatedCode, RegisterCallArguments::Arg0, (PtrValue)&function); //The current function
		Amd64Backend::moveIntToReg(generatedCode, RegisterCallArguments::Arg1, 0); //Offset of the call
		callIndex = generatedCode.size() - sizeof(int);
		Amd64Backend::moveIntToReg(generatedCode, RegisterCallArguments::Arg2, (int)generatedCode.size()); //The offset for this check
		Amd64Backend::moveIntToReg(generatedCode, RegisterCallArguments::Arg3, 0); //The end of the this check
		checkEndIndex = generatedCode.size() - sizeof(int);

		//The function to compile
		Amd64Backend::subByteFromReg(generatedCode, Registers::SP, 8); //Alignment
		Amd64Backend::moveLongToReg(generatedCode, NumberedRegisters::R10, (PtrValue)(&funcToCall));
		Amd64Backend::pushReg(generatedCode, NumberedRegisters::R10);
		Amd64Backend::subByteFromReg(generatedCode, Registers::SP, 32); //Shadow space

		Amd64Backend::moveLongToReg(generatedCode, Registers::AX, (PtrValue)&Runtime::compileFunction);
		Amd64Backend::callInReg(generatedCode, Registers::AX);
		Amd64Backend::addByteToReg(generatedCode, Registers::SP, 16 + 32); //Used stack

		Helpers::setInt(generatedCode, checkEndIndex, (int)generatedCode.size());

		return callIndex;
#if defined(_WIN64) || defined(__MINGW32__)
		return 0;
#else
		std::size_t callIndex;
		std::size_t checkEndIndex;

		Amd64Backend::moveLongToReg(generatedCode, RegisterCallArguments::Arg0, (PtrValue)&function); //The current function
		Amd64Backend::moveIntToReg(generatedCode, RegisterCallArguments::Arg1, 0); //Offset of the call
		callIndex = generatedCode.size() - sizeof(int);
		Amd64Backend::moveIntToReg(generatedCode, RegisterCallArguments::Arg2, (int)generatedCode.size()); //The offset for this check
		Amd64Backend::moveIntToReg(generatedCode, RegisterCallArguments::Arg3, 0); //The end of the this check
		checkEndIndex = generatedCode.size() - sizeof(int);
		Amd64Backend::moveLongToReg(generatedCode, RegisterCallArguments::Arg4, (PtrValue)(&funcToCall)); //The function to compile<commit_msg>Incorrect conditional compilation.<commit_after>#include "codegenerator.h"
#include "verifier.h"
#include "type.h"
#include "vmstate.h"
#include "rtlibrary.h"
#include "function.h"
#include "instructions.h"
#include "exceptions.h"
#include "stackjit.h"
#include "helpers.h"
#include "callingconvention.h"
#include <string.h>
#include <iostream>

namespace {
	void pushArray(std::vector<unsigned char>& dest, const std::vector<unsigned char>& values) {
		for (auto current : values) {
			dest.push_back(current);
		}
	}

	//Returns the offset for a stack operand
	int getStackOperandOffset(Function& function, int operandStackIndex) {
		return -(int)(Amd64Backend::REG_SIZE * (1 + function.numLocals() + function.numParams() + operandStackIndex));
	}

	//Indicates if the given value fits in a char
	bool validCharValue(int value) {
		return value >= -128 && value < 128;
	}

	//Generates a compile call for the given function
	std::size_t generateCompileCall(CodeGen& generatedCode, Function& function, const FunctionDefinition& funcToCall) {
#if defined(_WIN64) || defined(__MINGW32__)
		std::size_t callIndex;
		std::size_t checkEndIndex;

		Amd64Backend::moveLongToReg(generatedCode, RegisterCallArguments::Arg0, (PtrValue)&function); //The current function
		Amd64Backend::moveIntToReg(generatedCode, RegisterCallArguments::Arg1, 0); //Offset of the call
		callIndex = generatedCode.size() - sizeof(int);
		Amd64Backend::moveIntToReg(generatedCode, RegisterCallArguments::Arg2, (int)generatedCode.size()); //The offset for this check
		Amd64Backend::moveIntToReg(generatedCode, RegisterCallArguments::Arg3, 0); //The end of the this check
		checkEndIndex = generatedCode.size() - sizeof(int);

		//The function to compile
		Amd64Backend::subByteFromReg(generatedCode, Registers::SP, 8); //Alignment
		Amd64Backend::moveLongToReg(generatedCode, NumberedRegisters::R10, (PtrValue)(&funcToCall));
		Amd64Backend::pushReg(generatedCode, NumberedRegisters::R10);
		Amd64Backend::subByteFromReg(generatedCode, Registers::SP, 32); //Shadow space

		Amd64Backend::moveLongToReg(generatedCode, Registers::AX, (PtrValue)&Runtime::compileFunction);
		Amd64Backend::callInReg(generatedCode, Registers::AX);
		Amd64Backend::addByteToReg(generatedCode, Registers::SP, 16 + 32); //Used stack

		Helpers::setInt(generatedCode, checkEndIndex, (int)generatedCode.size());

		return callIndex;
#else
		std::size_t callIndex;
		std::size_t checkEndIndex;

		Amd64Backend::moveLongToReg(generatedCode, RegisterCallArguments::Arg0, (PtrValue)&function); //The current function
		Amd64Backend::moveIntToReg(generatedCode, RegisterCallArguments::Arg1, 0); //Offset of the call
		callIndex = generatedCode.size() - sizeof(int);
		Amd64Backend::moveIntToReg(generatedCode, RegisterCallArguments::Arg2, (int)generatedCode.size()); //The offset for this check
		Amd64Backend::moveIntToReg(generatedCode, RegisterCallArguments::Arg3, 0); //The end of the this check
		checkEndIndex = generatedCode.size() - sizeof(int);
		Amd64Backend::moveLongToReg(generatedCode, RegisterCallArguments::Arg4, (PtrValue)(&funcToCall)); //The function to compile
{'fraction_non_alphanumeric': 0.12774835499919757, 'fraction_numerical': 0.022307815759910126, 'mean_word_length': 6.948979591836735, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1963578', 'n_tokens_mistral': 2076, 'n_tokens_neox': 1956, 'n_words': 435}