aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4dataview.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-08-04 18:53:51 +0200
committerLars Knoll <lars.knoll@qt.io>2017-08-08 18:58:14 +0000
commit50e7badd5f261bd69db9d8f03d5651e346087218 (patch)
tree73c2771fbc98168280182e77337b06efa39f4a7b /src/qml/jsruntime/qv4dataview.cpp
parent8abb6c41bf055d59c6b57a809e3b027293568848 (diff)
Remove Scope::result and convert calling convention for builtins
Allow for faster calling of builtins, and completely avoid scope creation in many cases. Change-Id: I0f1681e19e9908db10def85a74e134a87fc2e44c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4dataview.cpp')
-rw-r--r--src/qml/jsruntime/qv4dataview.cpp80
1 files changed, 40 insertions, 40 deletions
diff --git a/src/qml/jsruntime/qv4dataview.cpp b/src/qml/jsruntime/qv4dataview.cpp
index b4e21b7ce5..57b5045f57 100644
--- a/src/qml/jsruntime/qv4dataview.cpp
+++ b/src/qml/jsruntime/qv4dataview.cpp
@@ -119,60 +119,60 @@ void DataViewPrototype::init(ExecutionEngine *engine, Object *ctor)
defineDefaultProperty(QStringLiteral("setUInt32"), method_set<unsigned int>, 0);
}
-void DataViewPrototype::method_get_buffer(const BuiltinFunction *, Scope &scope, CallData *callData)
+ReturnedValue DataViewPrototype::method_get_buffer(const BuiltinFunction *b, CallData *callData)
{
- Scoped<DataView> v(scope, callData->thisObject);
+ DataView *v = callData->thisObject.as<DataView>();
if (!v)
- THROW_TYPE_ERROR();
+ return b->engine()->throwTypeError();
- scope.result = v->d()->buffer;
+ return v->d()->buffer->asReturnedValue();
}
-void DataViewPrototype::method_get_byteLength(const BuiltinFunction *, Scope &scope, CallData *callData)
+ReturnedValue DataViewPrototype::method_get_byteLength(const BuiltinFunction *b, CallData *callData)
{
- Scoped<DataView> v(scope, callData->thisObject);
+ DataView *v = callData->thisObject.as<DataView>();
if (!v)
- THROW_TYPE_ERROR();
+ return b->engine()->throwTypeError();
- scope.result = Encode(v->d()->byteLength);
+ return Encode(v->d()->byteLength);
}
-void DataViewPrototype::method_get_byteOffset(const BuiltinFunction *, Scope &scope, CallData *callData)
+ReturnedValue DataViewPrototype::method_get_byteOffset(const BuiltinFunction *b, CallData *callData)
{
- Scoped<DataView> v(scope, callData->thisObject);
+ DataView *v = callData->thisObject.as<DataView>();
if (!v)
- THROW_TYPE_ERROR();
+ return b->engine()->throwTypeError();
- scope.result = Encode(v->d()->byteOffset);
+ return Encode(v->d()->byteOffset);
}
template <typename T>
-void DataViewPrototype::method_getChar(const BuiltinFunction *, Scope &scope, CallData *callData)
+ReturnedValue DataViewPrototype::method_getChar(const BuiltinFunction *b, CallData *callData)
{
- Scoped<DataView> v(scope, callData->thisObject);
+ DataView *v = callData->thisObject.as<DataView>();
if (!v || callData->argc < 1)
- THROW_TYPE_ERROR();
+ return b->engine()->throwTypeError();
double l = callData->args[0].toNumber();
uint idx = (uint)l;
if (l != idx || idx + sizeof(T) > v->d()->byteLength)
- THROW_TYPE_ERROR();
+ return b->engine()->throwTypeError();
idx += v->d()->byteOffset;
T t = T(v->d()->buffer->data->data()[idx]);
- scope.result = Encode((int)t);
+ return Encode((int)t);
}
template <typename T>
-void DataViewPrototype::method_get(const BuiltinFunction *, Scope &scope, CallData *callData)
+ReturnedValue DataViewPrototype::method_get(const BuiltinFunction *b, CallData *callData)
{
- Scoped<DataView> v(scope, callData->thisObject);
+ DataView *v = callData->thisObject.as<DataView>();
if (!v || callData->argc < 1)
- THROW_TYPE_ERROR();
+ return b->engine()->throwTypeError();
double l = callData->args[0].toNumber();
uint idx = (uint)l;
if (l != idx || idx + sizeof(T) > v->d()->byteLength)
- THROW_TYPE_ERROR();
+ return b->engine()->throwTypeError();
idx += v->d()->byteOffset;
bool littleEndian = callData->argc < 2 ? false : callData->args[1].toBoolean();
@@ -181,19 +181,19 @@ void DataViewPrototype::method_get(const BuiltinFunction *, Scope &scope, CallDa
? qFromLittleEndian<T>((uchar *)v->d()->buffer->data->data() + idx)
: qFromBigEndian<T>((uchar *)v->d()->buffer->data->data() + idx);
- scope.result = Encode(t);
+ return Encode(t);
}
template <typename T>
-void DataViewPrototype::method_getFloat(const BuiltinFunction *, Scope &scope, CallData *callData)
+ReturnedValue DataViewPrototype::method_getFloat(const BuiltinFunction *b, CallData *callData)
{
- Scoped<DataView> v(scope, callData->thisObject);
+ DataView *v = callData->thisObject.as<DataView>();
if (!v || callData->argc < 1)
- THROW_TYPE_ERROR();
+ return b->engine()->throwTypeError();
double l = callData->args[0].toNumber();
uint idx = (uint)l;
if (l != idx || idx + sizeof(T) > v->d()->byteLength)
- THROW_TYPE_ERROR();
+ return b->engine()->throwTypeError();
idx += v->d()->byteOffset;
bool littleEndian = callData->argc < 2 ? false : callData->args[1].toBoolean();
@@ -207,7 +207,7 @@ void DataViewPrototype::method_getFloat(const BuiltinFunction *, Scope &scope, C
u.i = littleEndian
? qFromLittleEndian<uint>((uchar *)v->d()->buffer->data->data() + idx)
: qFromBigEndian<uint>((uchar *)v->d()->buffer->data->data() + idx);
- scope.result = Encode(u.f);
+ return Encode(u.f);
} else {
Q_ASSERT(sizeof(T) == 8);
union {
@@ -217,20 +217,20 @@ void DataViewPrototype::method_getFloat(const BuiltinFunction *, Scope &scope, C
u.i = littleEndian
? qFromLittleEndian<quint64>((uchar *)v->d()->buffer->data->data() + idx)
: qFromBigEndian<quint64>((uchar *)v->d()->buffer->data->data() + idx);
- scope.result = Encode(u.d);
+ return Encode(u.d);
}
}
template <typename T>
-void DataViewPrototype::method_setChar(const BuiltinFunction *, Scope &scope, CallData *callData)
+ReturnedValue DataViewPrototype::method_setChar(const BuiltinFunction *b, CallData *callData)
{
- Scoped<DataView> v(scope, callData->thisObject);
+ DataView *v = callData->thisObject.as<DataView>();
if (!v || callData->argc < 1)
- THROW_TYPE_ERROR();
+ return b->engine()->throwTypeError();
double l = callData->args[0].toNumber();
uint idx = (uint)l;
if (l != idx || idx + sizeof(T) > v->d()->byteLength)
- THROW_TYPE_ERROR();
+ return b->engine()->throwTypeError();
idx += v->d()->byteOffset;
int val = callData->argc >= 2 ? callData->args[1].toInt32() : 0;
@@ -240,15 +240,15 @@ void DataViewPrototype::method_setChar(const BuiltinFunction *, Scope &scope, Ca
}
template <typename T>
-void DataViewPrototype::method_set(const BuiltinFunction *, Scope &scope, CallData *callData)
+ReturnedValue DataViewPrototype::method_set(const BuiltinFunction *b, CallData *callData)
{
- Scoped<DataView> v(scope, callData->thisObject);
+ DataView *v = callData->thisObject.as<DataView>();
if (!v || callData->argc < 1)
- THROW_TYPE_ERROR();
+ return b->engine()->throwTypeError();
double l = callData->args[0].toNumber();
uint idx = (uint)l;
if (l != idx || idx + sizeof(T) > v->d()->byteLength)
- THROW_TYPE_ERROR();
+ return b->engine()->throwTypeError();
idx += v->d()->byteOffset;
int val = callData->argc >= 2 ? callData->args[1].toInt32() : 0;
@@ -264,15 +264,15 @@ void DataViewPrototype::method_set(const BuiltinFunction *, Scope &scope, CallDa
}
template <typename T>
-void DataViewPrototype::method_setFloat(const BuiltinFunction *, Scope &scope, CallData *callData)
+ReturnedValue DataViewPrototype::method_setFloat(const BuiltinFunction *b, CallData *callData)
{
- Scoped<DataView> v(scope, callData->thisObject);
+ DataView *v = callData->thisObject.as<DataView>();
if (!v || callData->argc < 1)
- THROW_TYPE_ERROR();
+ return b->engine()->throwTypeError();
double l = callData->args[0].toNumber();
uint idx = (uint)l;
if (l != idx || idx + sizeof(T) > v->d()->byteLength)
- THROW_TYPE_ERROR();
+ return b->engine()->throwTypeError();
idx += v->d()->byteOffset;
double val = callData->argc >= 2 ? callData->args[1].toNumber() : qt_qnan();