diff options
author | Lars Knoll <lars.knoll@digia.com> | 2014-01-08 15:59:34 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-20 21:14:24 +0100 |
commit | e2d9917878968986a9df21c9cfafc32a2360aee7 (patch) | |
tree | 24c4009e65b0a358a1d30f36ab32ec546fe6cbe5 /src/qml/jsruntime/qv4objectproto.cpp | |
parent | 2ba2d245c152cdbb26f918bc4481c77b8004f3cd (diff) |
Changes to the structure of Property
Put the getter into the regular value, and the setter into
the next value following. Like this we can compress property
data to only use 8 bytes per property for regular properties
and simply allocate two slots for accessor properties.
Change-Id: I330b95dbd583ebc2658fed79d37ac3b53492c0cd
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4objectproto.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4objectproto.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp index 806da833ea..410f243a3c 100644 --- a/src/qml/jsruntime/qv4objectproto.cpp +++ b/src/qml/jsruntime/qv4objectproto.cpp @@ -501,14 +501,14 @@ ReturnedValue ObjectPrototype::method_defineGetter(CallContext *ctx) return ctx->throwTypeError(); Scope scope(ctx); - Scoped<String> prop(scope, ctx->argument(0), Scoped<String>::Convert); - if (scope.engine->hasException) - return Encode::undefined(); - Scoped<FunctionObject> f(scope, ctx->argument(1)); if (!f) return ctx->throwTypeError(); + Scoped<String> prop(scope, ctx->argument(0), Scoped<String>::Convert); + if (scope.engine->hasException) + return Encode::undefined(); + Scoped<Object> o(scope, ctx->callData->thisObject); if (!o) { if (!ctx->callData->thisObject.isUndefined()) @@ -516,7 +516,9 @@ ReturnedValue ObjectPrototype::method_defineGetter(CallContext *ctx) o = ctx->engine->globalObject; } - Property pd = Property::fromAccessor(f.getPointer(), 0); + Property pd; + pd.value = f; + pd.set = Primitive::emptyValue(); o->__defineOwnProperty__(ctx, prop, pd, Attr_Accessor); return Encode::undefined(); } @@ -527,14 +529,14 @@ ReturnedValue ObjectPrototype::method_defineSetter(CallContext *ctx) return ctx->throwTypeError(); Scope scope(ctx); - Scoped<String> prop(scope, ctx->argument(0), Scoped<String>::Convert); - if (scope.engine->hasException) - return Encode::undefined(); - Scoped<FunctionObject> f(scope, ctx->argument(1)); if (!f) return ctx->throwTypeError(); + Scoped<String> prop(scope, ctx->argument(0), Scoped<String>::Convert); + if (scope.engine->hasException) + return Encode::undefined(); + Scoped<Object> o(scope, ctx->callData->thisObject); if (!o) { if (!ctx->callData->thisObject.isUndefined()) @@ -542,7 +544,9 @@ ReturnedValue ObjectPrototype::method_defineSetter(CallContext *ctx) o = ctx->engine->globalObject; } - Property pd = Property::fromAccessor(0, f.getPointer()); + Property pd; + pd.value = Primitive::emptyValue(); + pd.set = f; o->__defineOwnProperty__(ctx, prop, pd, Attr_Accessor); return Encode::undefined(); } |