From: Lars Knoll Date: Wed, 13 Feb 2013 13:42:56 +0000 (+0100) Subject: Move get/set_property over to pointer based calling convention X-Git-Tag: upstream/5.2.1~669^2~659^2~267 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=322e1210d52213329593c88bdc3470b42399e8cc;p=platform%2Fupstream%2Fqtdeclarative.git Move get/set_property over to pointer based calling convention Change-Id: I4afc0e90bd4763d170e06adddf70cf133c9ebbf7 Reviewed-by: Simon Hausmann --- diff --git a/src/v4/llvm_runtime.cpp b/src/v4/llvm_runtime.cpp index 828fee3..c045507 100644 --- a/src/v4/llvm_runtime.cpp +++ b/src/v4/llvm_runtime.cpp @@ -431,7 +431,7 @@ void __qmljs_llvm_set_activation_property(ExecutionContext *ctx, String *name, V void __qmljs_llvm_get_property(ExecutionContext *ctx, Value *result, Value *object, String *name) { - *result = __qmljs_get_property(ctx, *object, name); + __qmljs_get_property(ctx, result, object, name); } void __qmljs_llvm_call_property(ExecutionContext *context, Value *result, const Value *base, String *name, Value *args, int argc) @@ -456,7 +456,7 @@ void __qmljs_llvm_set_element(ExecutionContext *ctx, Value *object, Value *index void __qmljs_llvm_set_property(ExecutionContext *ctx, Value *object, String *name, Value *value) { - __qmljs_set_property(ctx, *object, name, *value); + __qmljs_set_property(ctx, object, name, value); } void __qmljs_llvm_builtin_declare_var(ExecutionContext *ctx, bool deletable, String *name) diff --git a/src/v4/moth/qv4isel_moth.cpp b/src/v4/moth/qv4isel_moth.cpp index e9ec409..b054f13 100644 --- a/src/v4/moth/qv4isel_moth.cpp +++ b/src/v4/moth/qv4isel_moth.cpp @@ -446,7 +446,7 @@ void InstructionSelection::getProperty(IR::Temp *base, const QString &name, IR:: addInstruction(load); } -void InstructionSelection::setProperty(IR::Expr *source, IR::Temp *targetBase, const QString &targetName) +void InstructionSelection::setProperty(IR::Temp *source, IR::Temp *targetBase, const QString &targetName) { Instruction::StoreProperty store; store.base = getParam(targetBase); diff --git a/src/v4/moth/qv4isel_moth_p.h b/src/v4/moth/qv4isel_moth_p.h index 6dfc1e8..691dca2 100644 --- a/src/v4/moth/qv4isel_moth_p.h +++ b/src/v4/moth/qv4isel_moth_p.h @@ -69,7 +69,7 @@ protected: virtual void setActivationProperty(IR::Temp *source, const QString &targetName); virtual void initClosure(IR::Closure *closure, IR::Temp *target); virtual void getProperty(IR::Temp *base, const QString &name, IR::Temp *target); - virtual void setProperty(IR::Expr *source, IR::Temp *targetBase, const QString &targetName); + virtual void setProperty(IR::Temp *source, IR::Temp *targetBase, const QString &targetName); virtual void getElement(IR::Temp *base, IR::Temp *index, IR::Temp *target); virtual void setElement(IR::Expr *source, IR::Temp *targetBase, IR::Temp *targetIndex); virtual void copyValue(IR::Temp *sourceTemp, IR::Temp *targetTemp); diff --git a/src/v4/moth/qv4vme_moth.cpp b/src/v4/moth/qv4vme_moth.cpp index d526bf1..fba5364 100644 --- a/src/v4/moth/qv4vme_moth.cpp +++ b/src/v4/moth/qv4vme_moth.cpp @@ -194,11 +194,11 @@ VM::Value VME::operator()(QQmlJS::VM::ExecutionContext *context, const uchar *co MOTH_END_INSTR(StoreElement) MOTH_BEGIN_INSTR(LoadProperty) - VALUE(instr.result) = __qmljs_get_property(context, VALUE(instr.base), instr.name); + __qmljs_get_property(context, VALUEPTR(instr.result), VALUEPTR(instr.base), instr.name); MOTH_END_INSTR(LoadProperty) MOTH_BEGIN_INSTR(StoreProperty) - __qmljs_set_property(context, VALUE(instr.base), instr.name, VALUE(instr.source)); + __qmljs_set_property(context, VALUEPTR(instr.base), instr.name, VALUEPTR(instr.source)); MOTH_END_INSTR(StoreProperty) MOTH_BEGIN_INSTR(Push) diff --git a/src/v4/qmljs_runtime.cpp b/src/v4/qmljs_runtime.cpp index fcaa6a8..356d2a8 100644 --- a/src/v4/qmljs_runtime.cpp +++ b/src/v4/qmljs_runtime.cpp @@ -569,11 +569,10 @@ Value __qmljs_new_string_object(ExecutionContext *ctx, String *string) return Value::fromObject(ctx->engine->newStringObject(ctx, value)); } -void __qmljs_set_property(ExecutionContext *ctx, Value object, String *name, Value value) +void __qmljs_set_property(ExecutionContext *ctx, const Value *object, String *name, const Value *value) { - if (! object.isObject()) - object = __qmljs_to_object(object, ctx); - object.objectValue()->__put__(ctx, name, value); + Object *o = object->isObject() ? object->objectValue() : __qmljs_to_object(*object, ctx).objectValue(); + o->__put__(ctx, name, *value); } Value __qmljs_get_element(ExecutionContext *ctx, Value object, Value index) @@ -653,22 +652,20 @@ void __qmljs_set_activation_property(ExecutionContext *ctx, String *name, const ctx->setProperty(name, *value); } -Value __qmljs_get_property(ExecutionContext *ctx, Value object, String *name) +void __qmljs_get_property(ExecutionContext *ctx, Value *result, Value *object, String *name) { - if (object.isObject()) { - return object.objectValue()->__get__(ctx, name); - } else if (object.isString() && name->isEqualTo(ctx->engine->id_length)) { - return Value::fromInt32(object.stringValue()->toQString().length()); + Value res; + Object *o = object->asObject(); + if (o) { + res = o->__get__(ctx, name); + } else if (object->isString() && name->isEqualTo(ctx->engine->id_length)) { + res = Value::fromInt32(object->stringValue()->toQString().length()); } else { - object = __qmljs_to_object(object, ctx); - - if (object.isObject()) { - return object.objectValue()->__get__(ctx, name); - } else { - ctx->throwTypeError(); - return Value::undefinedValue(); - } + o = __qmljs_to_object(*object, ctx).objectValue(); + res = o->__get__(ctx, name); } + if (result) + *result = res; } void __qmljs_get_activation_property(ExecutionContext *ctx, Value *result, String *name) @@ -676,10 +673,11 @@ void __qmljs_get_activation_property(ExecutionContext *ctx, Value *result, Strin *result = ctx->getProperty(name); } -Value __qmljs_get_property_lookup(ExecutionContext *ctx, Value object, int lookupIndex) +void __qmljs_get_property_lookup(ExecutionContext *ctx, Value *result, const Value *object, int lookupIndex) { + Value res; Lookup *l = ctx->lookups + lookupIndex; - if (Object *o = object.asObject()) { + if (Object *o = object->asObject()) { PropertyDescriptor *p = 0; if (o->internalClass == l->mainClass) { if (!l->protoClass) { @@ -708,36 +706,29 @@ Value __qmljs_get_property_lookup(ExecutionContext *ctx, Value object, int looku } if (p) - return p->type == PropertyDescriptor::Data ? p->value : o->getValue(ctx, p); + res = p->type == PropertyDescriptor::Data ? p->value : o->getValue(ctx, p); else - return object.objectValue()->__get__(ctx, l->name); - } - - if (object.isString() && l->name->isEqualTo(ctx->engine->id_length)) { - return Value::fromInt32(object.stringValue()->toQString().length()); + res = o->__get__(ctx, l->name); } else { - object = __qmljs_to_object(object, ctx); - - if (object.isObject()) { - return object.objectValue()->__get__(ctx, l->name); + if (object->isString() && l->name->isEqualTo(ctx->engine->id_length)) { + res = Value::fromInt32(object->stringValue()->toQString().length()); } else { - ctx->throwTypeError(); - return Value::undefinedValue(); + o = __qmljs_to_object(*object, ctx).objectValue(); + res = o->__get__(ctx, l->name); } } + if (result) + *result = res; } -void __qmljs_set_property_lookup(ExecutionContext *ctx, Value object, int lookupIndex, Value value) +void __qmljs_set_property_lookup(ExecutionContext *ctx, const Value *object, int lookupIndex, const Value *value) { - if (! object.isObject()) - object = __qmljs_to_object(object, ctx); - - Object *o = object.objectValue(); + Object *o = object->isObject() ? object->objectValue() : __qmljs_to_object(*object, ctx).objectValue(); Lookup *l = ctx->lookups + lookupIndex; if (l->index != ArrayObject::LengthPropertyIndex || !o->isArrayObject()) { if (o->internalClass == l->mainClass) { - o->putValue(ctx, o->memberData + l->index, value); + o->putValue(ctx, o->memberData + l->index, *value); return; } @@ -745,11 +736,11 @@ void __qmljs_set_property_lookup(ExecutionContext *ctx, Value object, int lookup if (idx < UINT_MAX) { l->mainClass = o->internalClass; l->index = idx; - return o->putValue(ctx, o->memberData + idx, value); + return o->putValue(ctx, o->memberData + idx, *value); } } - o->__put__(ctx, l->name, value); + o->__put__(ctx, l->name, *value); } diff --git a/src/v4/qmljs_runtime.h b/src/v4/qmljs_runtime.h index 786deb0..97fa256 100644 --- a/src/v4/qmljs_runtime.h +++ b/src/v4/qmljs_runtime.h @@ -166,12 +166,12 @@ Value __qmljs_new_boolean_object(ExecutionContext *ctx, bool boolean); Value __qmljs_new_number_object(ExecutionContext *ctx, double n); Value __qmljs_new_string_object(ExecutionContext *ctx, String *string); void __qmljs_set_activation_property(ExecutionContext *ctx, String *name, const Value *value); -void __qmljs_set_property(ExecutionContext *ctx, Value object, String *name, Value value); -Value __qmljs_get_property(ExecutionContext *ctx, Value object, String *name); +void __qmljs_set_property(ExecutionContext *ctx, const Value *object, String *name, const Value *value); +void __qmljs_get_property(ExecutionContext *ctx, Value *result, Value *object, String *name); void __qmljs_get_activation_property(ExecutionContext *ctx, Value *result, String *name); -Value __qmljs_get_property_lookup(ExecutionContext *ctx, Value object, int lookupIndex); -void __qmljs_set_property_lookup(ExecutionContext *ctx, Value object, int lookupIndex, Value value); +void __qmljs_get_property_lookup(ExecutionContext *ctx, Value *result, const Value *object, int lookupIndex); +void __qmljs_set_property_lookup(ExecutionContext *ctx, const Value *object, int lookupIndex, const Value *value); Value __qmljs_get_element(ExecutionContext *ctx, Value object, Value index); diff --git a/src/v4/qv4codegen.cpp b/src/v4/qv4codegen.cpp index e3580fc..7faf22c 100644 --- a/src/v4/qv4codegen.cpp +++ b/src/v4/qv4codegen.cpp @@ -716,7 +716,7 @@ void Codegen::move(IR::Expr *target, IR::Expr *source, IR::AluOp op) _block->MOVE(_block->TEMP(t), source); source = _block->TEMP(t); } - if (target->asName() && source->asConst()) { + if (!target->asTemp() && source->asConst()) { unsigned t = _block->newTemp(); _block->MOVE(_block->TEMP(t), source); source = _block->TEMP(t); diff --git a/src/v4/qv4isel_llvm.cpp b/src/v4/qv4isel_llvm.cpp index 6460885..6131e30 100644 --- a/src/v4/qv4isel_llvm.cpp +++ b/src/v4/qv4isel_llvm.cpp @@ -625,7 +625,7 @@ void InstructionSelection::getProperty(IR::Temp *sourceBase, const QString &sour _llvmFunction->arg_begin(), t, base, name); } -void InstructionSelection::setProperty(IR::Expr *source, IR::Temp *targetBase, const QString &targetName) +void InstructionSelection::setProperty(IR::Temp *source, IR::Temp *targetBase, const QString &targetName) { llvm::Value *base = getLLVMTempReference(targetBase); llvm::Value *name = getIdentifier(targetName); diff --git a/src/v4/qv4isel_llvm_p.h b/src/v4/qv4isel_llvm_p.h index f306528..24ed317 100644 --- a/src/v4/qv4isel_llvm_p.h +++ b/src/v4/qv4isel_llvm_p.h @@ -113,7 +113,7 @@ public: // methods from InstructionSelection: virtual void setActivationProperty(IR::Temp *source, const QString &targetName); virtual void initClosure(IR::Closure *closure, IR::Temp *target); virtual void getProperty(IR::Temp *sourceBase, const QString &sourceName, IR::Temp *target); - virtual void setProperty(IR::Expr *source, IR::Temp *targetBase, const QString &targetName); + virtual void setProperty(IR::Temp *source, IR::Temp *targetBase, const QString &targetName); virtual void getElement(IR::Temp *sourceBase, IR::Temp *sourceIndex, IR::Temp *target); virtual void setElement(IR::Expr *source, IR::Temp *targetBase, IR::Temp *targetIndex); virtual void copyValue(IR::Temp *sourceTemp, IR::Temp *targetTemp); diff --git a/src/v4/qv4isel_masm.cpp b/src/v4/qv4isel_masm.cpp index c2f1811..2f8a5d2 100644 --- a/src/v4/qv4isel_masm.cpp +++ b/src/v4/qv4isel_masm.cpp @@ -689,20 +689,24 @@ void InstructionSelection::getProperty(IR::Temp *base, const QString &name, IR:: if (useFastLookups) { VM::String *s = identifier(name); uint index = addLookup(s); - generateFunctionCall(target, __qmljs_get_property_lookup, Assembler::ContextRegister, base, Assembler::TrustedImm32(index)); + generateFunctionCall(Assembler::Void, __qmljs_get_property_lookup, Assembler::ContextRegister, Assembler::PointerToValue(target), + Assembler::PointerToValue(base), Assembler::TrustedImm32(index)); } else { - generateFunctionCall(target, __qmljs_get_property, Assembler::ContextRegister, base, identifier(name)); + generateFunctionCall(Assembler::Void, __qmljs_get_property, Assembler::ContextRegister, Assembler::PointerToValue(target), + Assembler::PointerToValue(base), identifier(name)); } } -void InstructionSelection::setProperty(IR::Expr *source, IR::Temp *targetBase, const QString &targetName) +void InstructionSelection::setProperty(IR::Temp *source, IR::Temp *targetBase, const QString &targetName) { if (useFastLookups) { VM::String *s = identifier(targetName); uint index = addLookup(s); - generateFunctionCall(Assembler::Void, __qmljs_set_property_lookup, Assembler::ContextRegister, targetBase, Assembler::TrustedImm32(index), source); + generateFunctionCall(Assembler::Void, __qmljs_set_property_lookup, Assembler::ContextRegister, Assembler::PointerToValue(targetBase), + Assembler::TrustedImm32(index), Assembler::PointerToValue(source)); } else { - generateFunctionCall(Assembler::Void, __qmljs_set_property, Assembler::ContextRegister, targetBase, identifier(targetName), source); + generateFunctionCall(Assembler::Void, __qmljs_set_property, Assembler::ContextRegister, Assembler::PointerToValue(targetBase), + identifier(targetName), Assembler::PointerToValue(source)); } } diff --git a/src/v4/qv4isel_masm_p.h b/src/v4/qv4isel_masm_p.h index 7b42f11..ee9573e 100644 --- a/src/v4/qv4isel_masm_p.h +++ b/src/v4/qv4isel_masm_p.h @@ -712,7 +712,7 @@ protected: virtual void setActivationProperty(IR::Temp *source, const QString &targetName); virtual void initClosure(IR::Closure *closure, IR::Temp *target); virtual void getProperty(IR::Temp *base, const QString &name, IR::Temp *target); - virtual void setProperty(IR::Expr *source, IR::Temp *targetBase, const QString &targetName); + virtual void setProperty(IR::Temp *source, IR::Temp *targetBase, const QString &targetName); virtual void getElement(IR::Temp *base, IR::Temp *index, IR::Temp *target); virtual void setElement(IR::Expr *source, IR::Temp *targetBase, IR::Temp *targetIndex); virtual void copyValue(IR::Temp *sourceTemp, IR::Temp *targetTemp); diff --git a/src/v4/qv4isel_p.cpp b/src/v4/qv4isel_p.cpp index 2eb1b1d..35cd826 100644 --- a/src/v4/qv4isel_p.cpp +++ b/src/v4/qv4isel_p.cpp @@ -146,8 +146,8 @@ void InstructionSelection::visitMove(IR::Move *s) } } else if (IR::Member *m = s->target->asMember()) { if (IR::Temp *base = m->base->asTemp()) { - if (s->source->asTemp() || s->source->asConst()) { - setProperty(s->source, base, *m->name); + if (s->source->asTemp()) { + setProperty(s->source->asTemp(), base, *m->name); return; } } diff --git a/src/v4/qv4isel_p.h b/src/v4/qv4isel_p.h index d135cd3..cb04f0c 100644 --- a/src/v4/qv4isel_p.h +++ b/src/v4/qv4isel_p.h @@ -129,7 +129,7 @@ public: // to implement by subclasses: virtual void setActivationProperty(IR::Temp *source, const QString &targetName) = 0; virtual void initClosure(IR::Closure *closure, IR::Temp *target) = 0; virtual void getProperty(IR::Temp *base, const QString &name, IR::Temp *target) = 0; - virtual void setProperty(IR::Expr *source, IR::Temp *targetBase, const QString &targetName) = 0; + virtual void setProperty(IR::Temp *source, IR::Temp *targetBase, const QString &targetName) = 0; virtual void getElement(IR::Temp *base, IR::Temp *index, IR::Temp *target) = 0; virtual void setElement(IR::Expr *source, IR::Temp *targetBase, IR::Temp *targetIndex) = 0; virtual void copyValue(IR::Temp *sourceTemp, IR::Temp *targetTemp) = 0;