diff -r 43287eef2fff -r 072f1114ea5d src/compiler/HIR.cpp --- a/src/compiler/HIR.cpp Mon Dec 24 02:56:02 2012 -0800 +++ b/src/compiler/HIR.cpp Mon Dec 24 16:09:13 2012 -0800 @@ -75,11 +75,8 @@ { __ object(hir->array()); - if (!hir->type()->isConst()) { - // If the type isn't const, we have to assume a consumer may modify - // the array, and therefore we have to duplicate it here. + if (hir->duplicate()) __ duparray(); - } } void @@ -355,16 +352,30 @@ HIRTranslator::visitStore(HStore *store) { store->lval()->bind(this, emitter_); + if (store->kind() == TOK_ASSIGN) { - store->rval()->accept(this); + // Fixed-length arrays and structs have copy semantics. + Local type(zone_, store->lval()->type()); + if (type->isArray() && ArrayType::cast(type)->isFixedLength()) { + store->lval()->load(emitter_); + store->rval()->accept(this); + __ copyarray(); + } else if (type->isStruct()) { + store->lval()->load(emitter_); + store->rval()->accept(this); + __ copystruct(); + } else { + store->rval()->accept(this); + store->lval()->store(emitter_); + } } else { // Advanced case: dup the ref, load, op, store. store->lval()->hold(emitter_); store->lval()->load(emitter_); store->rval()->accept(this); __ binary(TokenToOpcode(store->kind())); + store->lval()->store(emitter_); } - store->lval()->store(emitter_); } void