Add support for dynamically allocate initial stack for Angle

By updating YYLTYPE_IS_TRIVIAL to true, YYSTACK_RELOCATE can be enabled, so
we can dynamically allocate stack size based on needs.

BUG=angleproject:3028

Change-Id: I1b9cc0768cd0c6955589695e703595c56d43f24a
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1593954
Commit-Queue: Yi Xu <yiyix@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
This commit is contained in:
Yi Xu 2019-04-30 16:21:24 -04:00 коммит произвёл Commit Bot
Родитель 467f174f02
Коммит 80147d11c8
3 изменённых файлов: 27 добавлений и 0 удалений

Просмотреть файл

@ -58,6 +58,7 @@ using namespace sh;
%code requires {
#define YYLTYPE TSourceLoc
#define YYLTYPE_IS_DECLARED 1
#define YYLTYPE_IS_TRIVIAL 1
}
%union {

Просмотреть файл

@ -129,6 +129,7 @@ extern int yydebug;
#define YYLTYPE TSourceLoc
#define YYLTYPE_IS_DECLARED 1
#define YYLTYPE_IS_TRIVIAL 1

Просмотреть файл

@ -508,6 +508,22 @@ class GLSLTest_ES31 : public GLSLTest
void SetUp() override { ANGLETest::SetUp(); }
};
std::string BuillBigInitialStackShader(int length)
{
std::string result;
result += "void main() { \n";
for (int i = 0; i < length; i++)
{
result += " if (true) { \n";
}
result += " int temp; \n";
for (int i = 0; i <= length; i++)
{
result += "} \n";
}
return result;
}
TEST_P(GLSLTest, NamelessScopedStructs)
{
constexpr char kFS[] = R"(precision mediump float;
@ -5518,6 +5534,15 @@ TEST_P(GLSLTest, FragData)
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
}
// Test angle can handle big initial stack size with dynamic stack allocation.
TEST_P(GLSLTest, MemoryExhaustedTest)
{
ANGLE_SKIP_TEST_IF(IsD3D11_FL93());
GLuint program =
CompileProgram(essl1_shaders::vs::Simple(), BuillBigInitialStackShader(36).c_str());
EXPECT_NE(0u, program);
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these
// tests should be run against.
ANGLE_INSTANTIATE_TEST(GLSLTest,