Skip to content

Commit 5e566f8

Browse files
committed
Increased call stack size.
1 parent 3b97540 commit 5e566f8

3 files changed

Lines changed: 48 additions & 12 deletions

File tree

spec/inputs/unicode/macro.yue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ $链式调用(
201201
选择可见!
202202
标签等于 "fx"
203203
其中 (x)-> x.名称\结尾为 "(克隆)"
204+
摧毁!
204205
)
205206

206207
macro 链式调用B = (...)->

spec/outputs/unicode/macro.lua

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -273,19 +273,22 @@ local _call_1 = ((function()
273273
local _call_1 = ((function()
274274
local _call_1 = ((function()
275275
local _call_1 = ((function()
276-
local _call_1 = (_anon_func_2(_u539f_u70b9))
277-
return _call_1["后代"](_call_1)
276+
local _call_1 = ((function()
277+
local _call_1 = (_anon_func_2(_u539f_u70b9))
278+
return _call_1["后代"](_call_1)
279+
end)())
280+
return _call_1["选择启用"](_call_1)
278281
end)())
279-
return _call_1["选择启用"](_call_1)
282+
return _call_1["选择可见"](_call_1)
280283
end)())
281-
return _call_1["选择可见"](_call_1)
284+
return _call_1["标签等于"](_call_1, "fx")
282285
end)())
283-
return _call_1["标签等于"](_call_1, "fx")
286+
return _call_1["其中"](_call_1, function(x)
287+
local _call_2 = x["名称"]
288+
return _call_2["结尾为"](_call_2, "(克隆)")
289+
end)
284290
end)())
285-
_u7ed3_u679c = _call_1["其中"](_call_1, function(x)
286-
local _call_2 = x["名称"]
287-
return _call_2["结尾为"](_call_2, "(克隆)")
288-
end)
291+
_u7ed3_u679c = _call_1["摧毁"](_call_1)
289292
do
290293
do
291294
local _1
@@ -343,7 +346,7 @@ _u6253_u5370((setmetatable({
343346
return 998
344347
end
345348
}))
346-
_u6253_u5370("当前代码行数: " .. tostring(267))
349+
_u6253_u5370("当前代码行数: " .. tostring(268))
347350
do
348351
do
349352
-- 待实现

src/yue.cpp

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,38 @@ using namespace std::chrono_literals;
3030
#include "ghc/fs_std.hpp"
3131
#include "linenoise.hpp"
3232

33+
#if __has_include(<pthread.h>)
34+
#include <pthread.h>
35+
template<class R>
36+
std::future<R> async(const std::function<R()>& f) {
37+
using Fn = std::packaged_task<R()>;
38+
auto task = new Fn(f);
39+
std::future<R> fut = task->get_future();
40+
41+
pthread_attr_t attr;
42+
pthread_attr_init(&attr);
43+
pthread_attr_setstacksize(&attr, 8 * 1024 * 1024);
44+
45+
pthread_t th;
46+
pthread_create(&th, &attr,
47+
[](void* p)->void* {
48+
std::unique_ptr<Fn> fn(static_cast<Fn*>(p));
49+
(*fn)();
50+
return nullptr;
51+
},
52+
task);
53+
pthread_attr_destroy(&attr);
54+
pthread_detach(th);
55+
return fut;
56+
}
57+
#else
58+
template<class R>
59+
std::future<R> async(const std::function<R()>& f) {
60+
// fallback: ignore stack size
61+
return std::async(std::launch::async, f);
62+
}
63+
#endif
64+
3365
#if not(defined YUE_NO_MACRO && defined YUE_COMPILER_ONLY)
3466
#define _DEFER(code, line) std::shared_ptr<void> _defer_##line(nullptr, [&](auto) { \
3567
code; \
@@ -699,7 +731,7 @@ int main(int narg, const char** args) {
699731
}
700732
std::list<std::future<std::string>> results;
701733
for (const auto& file : files) {
702-
auto task = std::async(std::launch::async, [=]() {
734+
auto task = async<std::string>([=]() {
703735
#ifndef YUE_COMPILER_ONLY
704736
return compileFile(fs::absolute(file.first), config, fullWorkPath, fullTargetPath, minify, rewrite);
705737
#else
@@ -737,7 +769,7 @@ int main(int narg, const char** args) {
737769
#endif // YUE_NO_WATCHER
738770
std::list<std::future<std::tuple<int, std::string, std::string>>> results;
739771
for (const auto& file : files) {
740-
auto task = std::async(std::launch::async, [=]() {
772+
auto task = async<std::tuple<int, std::string, std::string>>([=]() {
741773
std::ifstream input(file.first, std::ios::in);
742774
if (input) {
743775
std::string s(

0 commit comments

Comments
 (0)