1.1 --- a/src/BytecodeCompiler.cpp Sun Sep 16 22:49:54 2012 -0700
1.2 +++ b/src/BytecodeCompiler.cpp Sun Sep 16 23:15:13 2012 -0700
1.3 @@ -987,10 +987,17 @@
1.4 }
1.5 }
1.6 } else if (type->isStruct()) {
1.7 - Local<Map> map(zone_, type->newMap());
1.8 + Local<StructMap> map(zone_, StructMap::cast(type->newMap()));
1.9 +
1.10 + // Because structs can contain arrays, any sort of composition
1.11 + // triggers non-LIFO allocation. This is just for correctness.
1.12 + // We could do better by:
1.13 + // (1) Limiting to structs that just (recursively) contain arrays,
1.14 + // (2) Swap Stack for Default tenure in Struct::New
1.15 + // (3) JIT analysis
1.16 if (var->scope()->kind() == Scope::GLOBAL)
1.17 __ newstruct(map, Heap::Tenure_Old);
1.18 - else if (var->needsHeapAllocation())
1.19 + else if (var->needsHeapAllocation() || map->composed())
1.20 __ newstruct(map, Heap::Tenure_Default);
1.21 else
1.22 __ newstruct(map, Heap::Tenure_Stack);