diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-04-14 23:08:01 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2013-04-15 10:50:14 +0200 |
commit | 58ad517474606057a7777073dffded982ae9c85d (patch) | |
tree | 481430cf28eea2296047c8a80a4f4b1499147969 /src | |
parent | 6f7a22208db0435b1c761dbbea2bfd2cc68cc8b6 (diff) |
Implement fast lookup for constructor calls to the global object
Change-Id: I8a03089032aabdd7cf07c3dd197f6f47dabd66ab
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/v4/qv4isel_masm.cpp | 13 | ||||
-rw-r--r-- | src/v4/qv4runtime.cpp | 18 | ||||
-rw-r--r-- | src/v4/qv4runtime.h | 1 |
3 files changed, 32 insertions, 0 deletions
diff --git a/src/v4/qv4isel_masm.cpp b/src/v4/qv4isel_masm.cpp index 13a3cc111a..4e49c599ff 100644 --- a/src/v4/qv4isel_masm.cpp +++ b/src/v4/qv4isel_masm.cpp @@ -1078,6 +1078,19 @@ void InstructionSelection::constructActivationProperty(V4IR::Name *func, V4IR::E { assert(func != 0); + if (useFastLookups && func->global) { + int argc = prepareVariableArguments(args); + VM::String *s = identifier(*func->id); + + uint index = addGlobalLookup(s); + generateFunctionCall(Assembler::Void, __qmljs_construct_global_lookup, + Assembler::ContextRegister, Assembler::PointerToValue(result), + Assembler::TrustedImm32(index), + baseAddressForCallArguments(), + Assembler::TrustedImm32(argc)); + return; + } + callRuntimeMethod(result, __qmljs_construct_activation_property, func, args); } diff --git a/src/v4/qv4runtime.cpp b/src/v4/qv4runtime.cpp index bf871ffd3e..d15be7bd9e 100644 --- a/src/v4/qv4runtime.cpp +++ b/src/v4/qv4runtime.cpp @@ -929,6 +929,24 @@ void __qmljs_call_value(ExecutionContext *context, Value *result, const Value *t *result = res; } + +void __qmljs_construct_global_lookup(ExecutionContext *context, Value *result, uint index, Value *args, int argc) +{ + Lookup *l = context->lookups + index; + Value func; + l->lookupGlobal(l, context, &func); + + if (Object *f = func.asObject()) { + Value res = f->construct(context, args, argc); + if (result) + *result = res; + return; + } + + context->throwTypeError(); +} + + void __qmljs_construct_activation_property(ExecutionContext *context, Value *result, String *name, Value *args, int argc) { Value func = context->getProperty(name); diff --git a/src/v4/qv4runtime.h b/src/v4/qv4runtime.h index ff34257fcc..dfdaedef47 100644 --- a/src/v4/qv4runtime.h +++ b/src/v4/qv4runtime.h @@ -168,6 +168,7 @@ void __qmljs_get_activation_property(ExecutionContext *ctx, Value *result, Strin void __qmljs_get_global_lookup(ExecutionContext *ctx, Value *result, int lookupIndex); void __qmljs_call_global_lookup(ExecutionContext *context, Value *result, uint index, Value *args, int argc); +void __qmljs_construct_global_lookup(ExecutionContext *context, Value *result, uint index, Value *args, int argc); 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); |