Comments (5)
I'll fix it.
from clay.
It is harder than I though. There are too much compiler internals that I don't understand. I give up.
from clay.
Isn't this enough?
diff --git a/compiler/codegen.cpp b/compiler/codegen.cpp
index 783e967..baccdf0 100644
--- a/compiler/codegen.cpp
+++ b/compiler/codegen.cpp
@@ -3547,6 +3547,11 @@ void codegenCallByName(InvokeEntry* entry,
++ctx->inlineDepth;
+ ++ctx->callByNameDepth;
+ if (ctx->callByNameDepth > 100) {
+ error("Alias stack overflow");
+ }
+
EnvPtr bodyEnv = new Env(entry->env);
bodyEnv->callByNameExprHead = callable;
@@ -3631,6 +3636,8 @@ void codegenCallByName(InvokeEntry* entry,
--ctx->inlineDepth;
assert(ctx->inlineDepth >= 0);
+ --ctx->callByNameDepth;
+ assert(ctx->callByNameDepth >= 0);
}
diff --git a/compiler/codegen.hpp b/compiler/codegen.hpp
index 7fe6bd5..467a9c6 100644
--- a/compiler/codegen.hpp
+++ b/compiler/codegen.hpp
@@ -140,6 +140,8 @@ struct CodegenContext {
int inlineDepth:31;
bool checkExceptions:1;
+ int callByNameDepth;
+
CodegenContext()
: llvmFunc(NULL),
initBuilder(NULL),
@@ -147,7 +149,8 @@ struct CodegenContext {
valueForStatics(NULL),
exceptionValue(NULL),
inlineDepth(0),
- checkExceptions(true)
+ checkExceptions(true),
+ callByNameDepth(0)
{
}
@@ -158,7 +161,8 @@ struct CodegenContext {
valueForStatics(NULL),
exceptionValue(NULL),
inlineDepth(0),
- checkExceptions(true)
+ checkExceptions(true),
+ callByNameDepth(0)
{
}
from clay.
@galchinsky Well, it is definitely better than current stack overlfow in the compiler. I'd commit your solution.
from clay.
@galchinsky OK, I'll commit your version with several tests I've written earlier. And everyone is welcome to write proper solution, that explicitly detects recursion.
from clay.
Related Issues (20)
- RFC: Replace tuples with record literals HOT 9
- lib-clay's opengl incorrectly declares "initGLFunctions" HOT 1
- -run linker search paths differ from clang linker HOT 4
- Compiling with -g doesn't work at all HOT 7
- Very minimal error reporting on missing return type in external functions HOT 3
- Poor error reporting for built-in constructor with evaled type expression using patterns HOT 1
- Update __intrinsics__ module implementation for LLVM 3.2 HOT 1
- lib-clay/parsing/combinators/strings/test.clay compilation failure HOT 28
- Investigate removing workarounds for LLVM 3.1 bugs
- Broken code involing predicates and number comparison HOT 2
- test/lib-clay/cocoa/util fails HOT 1
- Improve Function perfomance HOT 5
- `invalid static object` when calling filterValues HOT 6
- Maybe(#1) doesn't work HOT 1
- record static value parameter gets unwrapped
- LLVM_CONFIG-NOTFOUND failed HOT 5
- Link broken to http://claylabs.com/clay/ HOT 2
- Update the latest code
- Why LLVM 3.2? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clay.