1.1 --- a/jitcraft/SemanticAnalysis.cpp Fri Jul 20 00:03:10 2012 -0700
1.2 +++ b/jitcraft/SemanticAnalysis.cpp Mon Jul 23 01:19:44 2012 -0700
1.3 @@ -21,6 +21,7 @@
1.4 #include "Zone.h"
1.5 #include "TypeManager.h"
1.6 #include "Scopes.h"
1.7 +#include "NameBinding.h"
1.8 #include "Heap-inl.h"
1.9 #include "Strings.h"
1.10
1.11 @@ -111,6 +112,8 @@
1.12 if (cc_.failures())
1.13 return false;
1.14
1.15 + scope_ = tree_->scope();
1.16 +
1.17 for (size_t i = 0; i < tree_->statements()->length(); i++) {
1.18 Statement *statement = tree_->statements()->at(i);
1.19 if (statement->isFunctionStatement()) {
1.20 @@ -609,10 +612,11 @@
1.21 check = check->contained();
1.22 }
1.23
1.24 - // Right now, any array is allowed on the LIFO heap. In case the
1.25 - // runtime actually decides to use the LIFO heap, we must reserve
1.26 - // a slot so we can unwind the heap when the current scope leaves.
1.27 - scope_->setUsesLifoHeap();
1.28 + // If this variable is stack allocated, we could use the LIFO heap
1.29 + // to allocate it. If that's the case, make sure to reserve a slot
1.30 + // so we can unwind the LIFO heap at the end of this scope.
1.31 + if (!node->variable()->needsHeapAllocation())
1.32 + scope_->setUsesLifoHeap();
1.33 } else {
1.34 if (node->initialization()) {
1.35 Local<Type> right(zone_, visitForLoad(node->initialization()));
1.36 @@ -850,7 +854,7 @@
1.37 if (given->primitive() != actual->primitive()) {
1.38 // :TODO: leaks an interior pointer
1.39 const char *givenTag = given->tag() ? given->tag()->chars() : "_";
1.40 - const char *actualTag = given->tag() ? given->tag()->chars() : "_";
1.41 + const char *actualTag = actual->tag() ? actual->tag()->chars() : "_";
1.42 cc_.reportError(node->pos(), Message_TagMismatch, actualTag, givenTag);
1.43 return false;
1.44 }