diff --git a/llvm_runtime.cpp b/llvm_runtime.cpp index 36a12b86dd..e70240484b 100644 --- a/llvm_runtime.cpp +++ b/llvm_runtime.cpp @@ -165,4 +165,9 @@ void __qmljs_llvm_call_activation_property(Context *context, Value *result, Stri __qmljs_call_activation_property(context, result, name, args, argc); } +void __qmljs_llvm_construct_activation_property(Context *context, Value *result, String *name, Value *args, int argc) +{ + __qmljs_construct_activation_property(context, result, name, args, argc); +} + } // extern "C" diff --git a/qv4isel_llvm.cpp b/qv4isel_llvm.cpp index f406862da3..f193979ea8 100644 --- a/qv4isel_llvm.cpp +++ b/qv4isel_llvm.cpp @@ -414,8 +414,45 @@ void LLVMInstructionSelection::visitCall(IR::Call *e) void LLVMInstructionSelection::visitNew(IR::New *e) { - llvm::Value *base = getLLVMValue(e->base); - Q_UNIMPLEMENTED(); + llvm::Value *func = 0; + llvm::Value *base = 0; + if (IR::Temp *t = e->base->asTemp()) { + base = getLLVMTemp(t); + func = _llvmModule->getFunction("__qmljs_llvm_construct_value"); + } else if (IR::Name *n = e->base->asName()) { + if (n->id) { + llvm::Value *str = getStringPtr(*n->id); + base = CreateCall2(_llvmModule->getFunction("__qmljs_llvm_get_identifier"), + _llvmFunction->arg_begin(), str); + func = _llvmModule->getFunction("__qmljs_llvm_construct_activation_property"); + } + } + + int argc = 0; + for (IR::ExprList *it = e->args; it; it = it->next) { + ++argc; + } + + llvm::Value *args = 0; + if (argc) + args = newLLVMTemp(_valueTy, getInt32(argc)); + else + args = llvm::Constant::getNullValue(_valueTy->getPointerTo()); + + int i = 0; + for (IR::ExprList *it = e->args; it; it = it->next) { + llvm::Value *arg = getLLVMValue(it->expr); + CreateStore(arg, CreateConstGEP1_32(args, i++)); + } + + if (func) { + llvm::Value *result = newLLVMTemp(_valueTy); + CreateStore(llvm::Constant::getNullValue(_valueTy), result); + CreateCall5(func, _llvmFunction->arg_begin(), result, base, args, getInt32(argc)); + _llvmValue = CreateLoad(result); + } else { + Q_UNIMPLEMENTED(); + } } void LLVMInstructionSelection::visitSubscript(IR::Subscript *) diff --git a/tests/simple.js b/tests/simple.js index e0a3984a3f..8a80bcb4d0 100644 --- a/tests/simple.js +++ b/tests/simple.js @@ -4,11 +4,12 @@ var b = 2 var c = 10 var d = 100 -for (i = 0; i < 1000000; i = i + 1) { +var d1 = new Date +for (var i = 0; i < 1000000; i = i + 1) { if (a == 1) d = d + a + b * c else d = 321 } -print("the result is", d) +print("the result is", d, "done in", new Date - d1)