Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4typedarray.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||
5 | using namespace QV4; | - | ||||||||||||||||||||||||
6 | - | |||||||||||||||||||||||||
7 | const QV4::VTable IntrinsicTypedArrayCtor::static_vtbl = { (std::is_same<IntrinsicTypedArrayCtor::SuperClass, Object>::value) ? nullptr : &IntrinsicTypedArrayCtor::SuperClass::static_vtbl, (sizeof(IntrinsicTypedArrayCtor::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), (sizeof(IntrinsicTypedArrayCtor::Data) + (IntrinsicTypedArrayCtor::NInlineProperties*sizeof(QV4::Value)) + QV4::Chunk::SlotSize - 1)/QV4::Chunk::SlotSize*QV4::Chunk::SlotSize/sizeof(QV4::Value) - (sizeof(IntrinsicTypedArrayCtor::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), IntrinsicTypedArrayCtor::IsExecutionContext, IntrinsicTypedArrayCtor::IsString, IntrinsicTypedArrayCtor::IsObject, IntrinsicTypedArrayCtor::IsFunctionObject, IntrinsicTypedArrayCtor::IsErrorObject, IntrinsicTypedArrayCtor::IsArrayData, IntrinsicTypedArrayCtor::IsStringOrSymbol, IntrinsicTypedArrayCtor::MyType, { 0, 0, 0, 0 }, "IntrinsicTypedArrayCtor", IntrinsicTypedArrayCtor::virtualDestroy, IntrinsicTypedArrayCtor::Data::markObjects, IntrinsicTypedArrayCtor::virtualIsEqualTo, IntrinsicTypedArrayCtor::virtualGet, IntrinsicTypedArrayCtor::virtualPut, IntrinsicTypedArrayCtor::virtualDeleteProperty, IntrinsicTypedArrayCtor::virtualHasProperty, IntrinsicTypedArrayCtor::virtualGetOwnProperty, IntrinsicTypedArrayCtor::virtualDefineOwnProperty, IntrinsicTypedArrayCtor::virtualIsExtensible, IntrinsicTypedArrayCtor::virtualPreventExtensions, IntrinsicTypedArrayCtor::virtualGetPrototypeOf, IntrinsicTypedArrayCtor::virtualSetPrototypeOf, IntrinsicTypedArrayCtor::virtualGetLength, IntrinsicTypedArrayCtor::virtualAdvanceIterator, IntrinsicTypedArrayCtor::virtualInstanceOf, IntrinsicTypedArrayCtor::virtualCall, IntrinsicTypedArrayCtor::virtualCallAsConstructor, }; | - | ||||||||||||||||||||||||
8 | const QV4::VTable IntrinsicTypedArrayPrototype::static_vtbl = { (std::is_same<IntrinsicTypedArrayPrototype::SuperClass, Object>::value) ? nullptr : &IntrinsicTypedArrayPrototype::SuperClass::static_vtbl, (sizeof(IntrinsicTypedArrayPrototype::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), (sizeof(IntrinsicTypedArrayPrototype::Data) + (IntrinsicTypedArrayPrototype::NInlineProperties*sizeof(QV4::Value)) + QV4::Chunk::SlotSize - 1)/QV4::Chunk::SlotSize*QV4::Chunk::SlotSize/sizeof(QV4::Value) - (sizeof(IntrinsicTypedArrayPrototype::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), IntrinsicTypedArrayPrototype::IsExecutionContext, IntrinsicTypedArrayPrototype::IsString, IntrinsicTypedArrayPrototype::IsObject, IntrinsicTypedArrayPrototype::IsFunctionObject, IntrinsicTypedArrayPrototype::IsErrorObject, IntrinsicTypedArrayPrototype::IsArrayData, IntrinsicTypedArrayPrototype::IsStringOrSymbol, IntrinsicTypedArrayPrototype::MyType, { 0, 0, 0, 0 }, "IntrinsicTypedArrayPrototype", IntrinsicTypedArrayPrototype::virtualDestroy, IntrinsicTypedArrayPrototype::Data::markObjects, IntrinsicTypedArrayPrototype::virtualIsEqualTo, IntrinsicTypedArrayPrototype::virtualGet, IntrinsicTypedArrayPrototype::virtualPut, IntrinsicTypedArrayPrototype::virtualDeleteProperty, IntrinsicTypedArrayPrototype::virtualHasProperty, IntrinsicTypedArrayPrototype::virtualGetOwnProperty, IntrinsicTypedArrayPrototype::virtualDefineOwnProperty, IntrinsicTypedArrayPrototype::virtualIsExtensible, IntrinsicTypedArrayPrototype::virtualPreventExtensions, IntrinsicTypedArrayPrototype::virtualGetPrototypeOf, IntrinsicTypedArrayPrototype::virtualSetPrototypeOf, IntrinsicTypedArrayPrototype::virtualGetLength, IntrinsicTypedArrayPrototype::virtualAdvanceIterator, IntrinsicTypedArrayPrototype::virtualInstanceOf, IntrinsicTypedArrayPrototype::virtualCall, IntrinsicTypedArrayPrototype::virtualCallAsConstructor, }; | - | ||||||||||||||||||||||||
9 | const QV4::VTable TypedArrayCtor::static_vtbl = { (std::is_same<TypedArrayCtor::SuperClass, Object>::value) ? nullptr : &TypedArrayCtor::SuperClass::static_vtbl, (sizeof(TypedArrayCtor::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), (sizeof(TypedArrayCtor::Data) + (TypedArrayCtor::NInlineProperties*sizeof(QV4::Value)) + QV4::Chunk::SlotSize - 1)/QV4::Chunk::SlotSize*QV4::Chunk::SlotSize/sizeof(QV4::Value) - (sizeof(TypedArrayCtor::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), TypedArrayCtor::IsExecutionContext, TypedArrayCtor::IsString, TypedArrayCtor::IsObject, TypedArrayCtor::IsFunctionObject, TypedArrayCtor::IsErrorObject, TypedArrayCtor::IsArrayData, TypedArrayCtor::IsStringOrSymbol, TypedArrayCtor::MyType, { 0, 0, 0, 0 }, "TypedArrayCtor", TypedArrayCtor::virtualDestroy, TypedArrayCtor::Data::markObjects, TypedArrayCtor::virtualIsEqualTo, TypedArrayCtor::virtualGet, TypedArrayCtor::virtualPut, TypedArrayCtor::virtualDeleteProperty, TypedArrayCtor::virtualHasProperty, TypedArrayCtor::virtualGetOwnProperty, TypedArrayCtor::virtualDefineOwnProperty, TypedArrayCtor::virtualIsExtensible, TypedArrayCtor::virtualPreventExtensions, TypedArrayCtor::virtualGetPrototypeOf, TypedArrayCtor::virtualSetPrototypeOf, TypedArrayCtor::virtualGetLength, TypedArrayCtor::virtualAdvanceIterator, TypedArrayCtor::virtualInstanceOf, TypedArrayCtor::virtualCall, TypedArrayCtor::virtualCallAsConstructor, }; | - | ||||||||||||||||||||||||
10 | const QV4::VTable TypedArrayPrototype::static_vtbl = { (std::is_same<TypedArrayPrototype::SuperClass, Object>::value) ? nullptr : &TypedArrayPrototype::SuperClass::static_vtbl, (sizeof(TypedArrayPrototype::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), (sizeof(TypedArrayPrototype::Data) + (TypedArrayPrototype::NInlineProperties*sizeof(QV4::Value)) + QV4::Chunk::SlotSize - 1)/QV4::Chunk::SlotSize*QV4::Chunk::SlotSize/sizeof(QV4::Value) - (sizeof(TypedArrayPrototype::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), TypedArrayPrototype::IsExecutionContext, TypedArrayPrototype::IsString, TypedArrayPrototype::IsObject, TypedArrayPrototype::IsFunctionObject, TypedArrayPrototype::IsErrorObject, TypedArrayPrototype::IsArrayData, TypedArrayPrototype::IsStringOrSymbol, TypedArrayPrototype::MyType, { 0, 0, 0, 0 }, "TypedArrayPrototype", TypedArrayPrototype::virtualDestroy, TypedArrayPrototype::Data::markObjects, TypedArrayPrototype::virtualIsEqualTo, TypedArrayPrototype::virtualGet, TypedArrayPrototype::virtualPut, TypedArrayPrototype::virtualDeleteProperty, TypedArrayPrototype::virtualHasProperty, TypedArrayPrototype::virtualGetOwnProperty, TypedArrayPrototype::virtualDefineOwnProperty, TypedArrayPrototype::virtualIsExtensible, TypedArrayPrototype::virtualPreventExtensions, TypedArrayPrototype::virtualGetPrototypeOf, TypedArrayPrototype::virtualSetPrototypeOf, TypedArrayPrototype::virtualGetLength, TypedArrayPrototype::virtualAdvanceIterator, TypedArrayPrototype::virtualInstanceOf, TypedArrayPrototype::virtualCall, TypedArrayPrototype::virtualCallAsConstructor, }; | - | ||||||||||||||||||||||||
11 | const QV4::VTable TypedArray::static_vtbl = { (std::is_same<TypedArray::SuperClass, Object>::value) ? nullptr : &TypedArray::SuperClass::static_vtbl, (sizeof(TypedArray::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), (sizeof(TypedArray::Data) + (TypedArray::NInlineProperties*sizeof(QV4::Value)) + QV4::Chunk::SlotSize - 1)/QV4::Chunk::SlotSize*QV4::Chunk::SlotSize/sizeof(QV4::Value) - (sizeof(TypedArray::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), TypedArray::IsExecutionContext, TypedArray::IsString, TypedArray::IsObject, TypedArray::IsFunctionObject, TypedArray::IsErrorObject, TypedArray::IsArrayData, TypedArray::IsStringOrSymbol, TypedArray::MyType, { 0, 0, 0, 0 }, "TypedArray", TypedArray::virtualDestroy, TypedArray::Data::markObjects, TypedArray::virtualIsEqualTo, TypedArray::virtualGet, TypedArray::virtualPut, TypedArray::virtualDeleteProperty, TypedArray::virtualHasProperty, TypedArray::virtualGetOwnProperty, TypedArray::virtualDefineOwnProperty, TypedArray::virtualIsExtensible, TypedArray::virtualPreventExtensions, TypedArray::virtualGetPrototypeOf, TypedArray::virtualSetPrototypeOf, TypedArray::virtualGetLength, TypedArray::virtualAdvanceIterator, TypedArray::virtualInstanceOf, TypedArray::virtualCall, TypedArray::virtualCallAsConstructor, }; | - | ||||||||||||||||||||||||
12 | - | |||||||||||||||||||||||||
13 | static_assert(bool((int)ExecutionEngine::NTypedArrayTypes == (int)Heap::TypedArray::NTypes), "(int)ExecutionEngine::NTypedArrayTypes == (int)Heap::TypedArray::NTypes"); | - | ||||||||||||||||||||||||
14 | - | |||||||||||||||||||||||||
15 | ReturnedValue Int8ArrayRead(const char *data, int index) | - | ||||||||||||||||||||||||
16 | { | - | ||||||||||||||||||||||||
17 | return executed 2866 times by 1 test: Encode((int)(signed char)data[index]);return Encode((int)(signed char)data[index]); Executed by:
executed 2866 times by 1 test: return Encode((int)(signed char)data[index]); Executed by:
| 2866 | ||||||||||||||||||||||||
18 | } | - | ||||||||||||||||||||||||
19 | - | |||||||||||||||||||||||||
20 | void Int8ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value) | - | ||||||||||||||||||||||||
21 | { | - | ||||||||||||||||||||||||
22 | signed char v = (signed char)value.toUInt32(); | - | ||||||||||||||||||||||||
23 | if (e->hasException
| 46-2890 | ||||||||||||||||||||||||
24 | return; executed 46 times by 1 test: return; Executed by:
| 46 | ||||||||||||||||||||||||
25 | data[index] = v; | - | ||||||||||||||||||||||||
26 | } executed 2890 times by 1 test: end of block Executed by:
| 2890 | ||||||||||||||||||||||||
27 | - | |||||||||||||||||||||||||
28 | ReturnedValue UInt8ArrayRead(const char *data, int index) | - | ||||||||||||||||||||||||
29 | { | - | ||||||||||||||||||||||||
30 | return executed 8704 times by 1 test: Encode((int)(unsigned char)data[index]);return Encode((int)(unsigned char)data[index]); Executed by:
executed 8704 times by 1 test: return Encode((int)(unsigned char)data[index]); Executed by:
| 8704 | ||||||||||||||||||||||||
31 | } | - | ||||||||||||||||||||||||
32 | - | |||||||||||||||||||||||||
33 | void UInt8ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value) | - | ||||||||||||||||||||||||
34 | { | - | ||||||||||||||||||||||||
35 | unsigned char v = (unsigned char)value.toUInt32(); | - | ||||||||||||||||||||||||
36 | if (e->hasException
| 46-34972 | ||||||||||||||||||||||||
37 | return; executed 46 times by 1 test: return; Executed by:
| 46 | ||||||||||||||||||||||||
38 | data[index] = v; | - | ||||||||||||||||||||||||
39 | } executed 34971 times by 2 tests: end of block Executed by:
| 34971 | ||||||||||||||||||||||||
40 | - | |||||||||||||||||||||||||
41 | void UInt8ClampedArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value) | - | ||||||||||||||||||||||||
42 | { | - | ||||||||||||||||||||||||
43 | if (value.isInteger()
| 570-2289 | ||||||||||||||||||||||||
44 | data[index] = (char)(unsigned char)qBound(0, value.integerValue(), 255); | - | ||||||||||||||||||||||||
45 | return; executed 2289 times by 1 test: return; Executed by:
| 2289 | ||||||||||||||||||||||||
46 | } | - | ||||||||||||||||||||||||
47 | double d = value.toNumber(); | - | ||||||||||||||||||||||||
48 | if (e->hasException
| 46-524 | ||||||||||||||||||||||||
49 | return; executed 46 times by 1 test: return; Executed by:
| 46 | ||||||||||||||||||||||||
50 | - | |||||||||||||||||||||||||
51 | if (d <= 0
| 64-348 | ||||||||||||||||||||||||
52 | data[index] = 0; | - | ||||||||||||||||||||||||
53 | return; executed 240 times by 1 test: return; Executed by:
| 240 | ||||||||||||||||||||||||
54 | } | - | ||||||||||||||||||||||||
55 | if (d >= 255
| 124-160 | ||||||||||||||||||||||||
56 | data[index] = (char)(255); | - | ||||||||||||||||||||||||
57 | return; executed 124 times by 1 test: return; Executed by:
| 124 | ||||||||||||||||||||||||
58 | } | - | ||||||||||||||||||||||||
59 | double f = std::floor(d); | - | ||||||||||||||||||||||||
60 | if (f + 0.5 < d
| 48-112 | ||||||||||||||||||||||||
61 | data[index] = (unsigned char)(f + 1); | - | ||||||||||||||||||||||||
62 | return; executed 48 times by 1 test: return; Executed by:
| 48 | ||||||||||||||||||||||||
63 | } | - | ||||||||||||||||||||||||
64 | if (d < f + 0.5
| 16-96 | ||||||||||||||||||||||||
65 | data[index] = (unsigned char)(f); | - | ||||||||||||||||||||||||
66 | return; executed 96 times by 1 test: return; Executed by:
| 96 | ||||||||||||||||||||||||
67 | } | - | ||||||||||||||||||||||||
68 | if (int(f) % 2
| 0-16 | ||||||||||||||||||||||||
69 | - | |||||||||||||||||||||||||
70 | data[index] = (unsigned char)(f + 1); | - | ||||||||||||||||||||||||
71 | return; never executed: return; | 0 | ||||||||||||||||||||||||
72 | } | - | ||||||||||||||||||||||||
73 | data[index] = (unsigned char)(f); | - | ||||||||||||||||||||||||
74 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||||||||||||||
75 | - | |||||||||||||||||||||||||
76 | ReturnedValue Int16ArrayRead(const char *data, int index) | - | ||||||||||||||||||||||||
77 | { | - | ||||||||||||||||||||||||
78 | return executed 2232 times by 1 test: Encode((int)*(const short *)(data + index));return Encode((int)*(const short *)(data + index)); Executed by:
executed 2232 times by 1 test: return Encode((int)*(const short *)(data + index)); Executed by:
| 2232 | ||||||||||||||||||||||||
79 | } | - | ||||||||||||||||||||||||
80 | - | |||||||||||||||||||||||||
81 | void Int16ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value) | - | ||||||||||||||||||||||||
82 | { | - | ||||||||||||||||||||||||
83 | short v = (short)value.toInt32(); | - | ||||||||||||||||||||||||
84 | if (e->hasException
| 46-2912 | ||||||||||||||||||||||||
85 | return; executed 46 times by 1 test: return; Executed by:
| 46 | ||||||||||||||||||||||||
86 | *(short *)(data + index) = v; | - | ||||||||||||||||||||||||
87 | } executed 2912 times by 1 test: end of block Executed by:
| 2912 | ||||||||||||||||||||||||
88 | - | |||||||||||||||||||||||||
89 | ReturnedValue UInt16ArrayRead(const char *data, int index) | - | ||||||||||||||||||||||||
90 | { | - | ||||||||||||||||||||||||
91 | return executed 2201 times by 1 test: Encode((int)*(const unsigned short *)(data + index));return Encode((int)*(const unsigned short *)(data + index)); Executed by:
executed 2201 times by 1 test: return Encode((int)*(const unsigned short *)(data + index)); Executed by:
| 2201 | ||||||||||||||||||||||||
92 | } | - | ||||||||||||||||||||||||
93 | - | |||||||||||||||||||||||||
94 | void UInt16ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value) | - | ||||||||||||||||||||||||
95 | { | - | ||||||||||||||||||||||||
96 | unsigned short v = (unsigned short)value.toInt32(); | - | ||||||||||||||||||||||||
97 | if (e->hasException
| 46-2916 | ||||||||||||||||||||||||
98 | return; executed 46 times by 1 test: return; Executed by:
| 46 | ||||||||||||||||||||||||
99 | *(unsigned short *)(data + index) = v; | - | ||||||||||||||||||||||||
100 | } executed 2916 times by 1 test: end of block Executed by:
| 2916 | ||||||||||||||||||||||||
101 | - | |||||||||||||||||||||||||
102 | ReturnedValue Int32ArrayRead(const char *data, int index) | - | ||||||||||||||||||||||||
103 | { | - | ||||||||||||||||||||||||
104 | return executed 2203 times by 1 test: Encode(*(const int *)(data + index));return Encode(*(const int *)(data + index)); Executed by:
executed 2203 times by 1 test: return Encode(*(const int *)(data + index)); Executed by:
| 2203 | ||||||||||||||||||||||||
105 | } | - | ||||||||||||||||||||||||
106 | - | |||||||||||||||||||||||||
107 | void Int32ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value) | - | ||||||||||||||||||||||||
108 | { | - | ||||||||||||||||||||||||
109 | int v = (int)value.toInt32(); | - | ||||||||||||||||||||||||
110 | if (e->hasException
| 46-2912 | ||||||||||||||||||||||||
111 | return; executed 46 times by 1 test: return; Executed by:
| 46 | ||||||||||||||||||||||||
112 | *(int *)(data + index) = v; | - | ||||||||||||||||||||||||
113 | } executed 2912 times by 1 test: end of block Executed by:
| 2912 | ||||||||||||||||||||||||
114 | - | |||||||||||||||||||||||||
115 | ReturnedValue UInt32ArrayRead(const char *data, int index) | - | ||||||||||||||||||||||||
116 | { | - | ||||||||||||||||||||||||
117 | return executed 2204 times by 1 test: Encode(*(const unsigned int *)(data + index));return Encode(*(const unsigned int *)(data + index)); Executed by:
executed 2204 times by 1 test: return Encode(*(const unsigned int *)(data + index)); Executed by:
| 2204 | ||||||||||||||||||||||||
118 | } | - | ||||||||||||||||||||||||
119 | - | |||||||||||||||||||||||||
120 | void UInt32ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value) | - | ||||||||||||||||||||||||
121 | { | - | ||||||||||||||||||||||||
122 | unsigned int v = (unsigned int)value.toUInt32(); | - | ||||||||||||||||||||||||
123 | if (e->hasException
| 46-2911 | ||||||||||||||||||||||||
124 | return; executed 46 times by 1 test: return; Executed by:
| 46 | ||||||||||||||||||||||||
125 | *(unsigned int *)(data + index) = v; | - | ||||||||||||||||||||||||
126 | } executed 2910 times by 1 test: end of block Executed by:
| 2910 | ||||||||||||||||||||||||
127 | - | |||||||||||||||||||||||||
128 | ReturnedValue Float32ArrayRead(const char *data, int index) | - | ||||||||||||||||||||||||
129 | { | - | ||||||||||||||||||||||||
130 | return executed 2460 times by 1 test: Encode(*(const float *)(data + index));return Encode(*(const float *)(data + index)); Executed by:
executed 2460 times by 1 test: return Encode(*(const float *)(data + index)); Executed by:
| 2460 | ||||||||||||||||||||||||
131 | } | - | ||||||||||||||||||||||||
132 | - | |||||||||||||||||||||||||
133 | void Float32ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value) | - | ||||||||||||||||||||||||
134 | { | - | ||||||||||||||||||||||||
135 | float v = value.toNumber(); | - | ||||||||||||||||||||||||
136 | if (e->hasException
| 46-3186 | ||||||||||||||||||||||||
137 | return; executed 46 times by 1 test: return; Executed by:
| 46 | ||||||||||||||||||||||||
138 | *(float *)(data + index) = v; | - | ||||||||||||||||||||||||
139 | } executed 3186 times by 1 test: end of block Executed by:
| 3186 | ||||||||||||||||||||||||
140 | - | |||||||||||||||||||||||||
141 | ReturnedValue Float64ArrayRead(const char *data, int index) | - | ||||||||||||||||||||||||
142 | { | - | ||||||||||||||||||||||||
143 | return executed 3456 times by 1 test: Encode(*(const double *)(data + index));return Encode(*(const double *)(data + index)); Executed by:
executed 3456 times by 1 test: return Encode(*(const double *)(data + index)); Executed by:
| 3456 | ||||||||||||||||||||||||
144 | } | - | ||||||||||||||||||||||||
145 | - | |||||||||||||||||||||||||
146 | void Float64ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value) | - | ||||||||||||||||||||||||
147 | { | - | ||||||||||||||||||||||||
148 | double v = value.toNumber(); | - | ||||||||||||||||||||||||
149 | if (e->hasException
| 60-6460 | ||||||||||||||||||||||||
150 | return; executed 60 times by 1 test: return; Executed by:
| 60 | ||||||||||||||||||||||||
151 | *(double *)(data + index) = v; | - | ||||||||||||||||||||||||
152 | } executed 6460 times by 1 test: end of block Executed by:
| 6460 | ||||||||||||||||||||||||
153 | - | |||||||||||||||||||||||||
154 | const TypedArrayOperations operations[Heap::TypedArray::NTypes] = { | - | ||||||||||||||||||||||||
155 | { 1, "Int8Array", Int8ArrayRead, Int8ArrayWrite }, | - | ||||||||||||||||||||||||
156 | { 1, "Uint8Array", UInt8ArrayRead, UInt8ArrayWrite }, | - | ||||||||||||||||||||||||
157 | { 1, "Uint8ClampedArray", UInt8ArrayRead, UInt8ClampedArrayWrite }, | - | ||||||||||||||||||||||||
158 | { 2, "Int16Array", Int16ArrayRead, Int16ArrayWrite }, | - | ||||||||||||||||||||||||
159 | { 2, "Uint16Array", UInt16ArrayRead, UInt16ArrayWrite }, | - | ||||||||||||||||||||||||
160 | { 4, "Int32Array", Int32ArrayRead, Int32ArrayWrite }, | - | ||||||||||||||||||||||||
161 | { 4, "Uint32Array", UInt32ArrayRead, UInt32ArrayWrite }, | - | ||||||||||||||||||||||||
162 | { 4, "Float32Array", Float32ArrayRead, Float32ArrayWrite }, | - | ||||||||||||||||||||||||
163 | { 8, "Float64Array", Float64ArrayRead, Float64ArrayWrite }, | - | ||||||||||||||||||||||||
164 | }; | - | ||||||||||||||||||||||||
165 | - | |||||||||||||||||||||||||
166 | - | |||||||||||||||||||||||||
167 | void Heap::TypedArrayCtor::init(QV4::ExecutionContext *scope, TypedArray::Type t) | - | ||||||||||||||||||||||||
168 | { | - | ||||||||||||||||||||||||
169 | Heap::FunctionObject::init(scope, QLatin1String(operations[t].name)); | - | ||||||||||||||||||||||||
170 | type = t; | - | ||||||||||||||||||||||||
171 | } executed 892477 times by 153 tests: end of block Executed by:
| 892477 | ||||||||||||||||||||||||
172 | - | |||||||||||||||||||||||||
173 | ReturnedValue TypedArrayCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *) | - | ||||||||||||||||||||||||
174 | { | - | ||||||||||||||||||||||||
175 | Scope scope(f->engine()); | - | ||||||||||||||||||||||||
176 | const TypedArrayCtor *that = static_cast<const TypedArrayCtor *>(f); | - | ||||||||||||||||||||||||
177 | - | |||||||||||||||||||||||||
178 | if (!argc
| 2359-23119 | ||||||||||||||||||||||||
179 | - | |||||||||||||||||||||||||
180 | qint64 l = argc
| 2359-3621 | ||||||||||||||||||||||||
181 | if (scope.engine->hasException
| 36-5939 | ||||||||||||||||||||||||
182 | return executed 36 times by 1 test: Encode::undefined();return Encode::undefined(); Executed by:
executed 36 times by 1 test: return Encode::undefined(); Executed by:
| 36 | ||||||||||||||||||||||||
183 | - | |||||||||||||||||||||||||
184 | if (l < 0
| 0-5834 | ||||||||||||||||||||||||
185 | (0x7fffffff * 2U + 1U)
| 0-5834 | ||||||||||||||||||||||||
186 | ) | - | ||||||||||||||||||||||||
187 | return executed 108 times by 1 test: scope.engine->throwRangeError(QLatin1String("Index out of range."));return scope.engine->throwRangeError(QLatin1String("Index out of range.")); Executed by:
executed 108 times by 1 test: return scope.engine->throwRangeError(QLatin1String("Index out of range.")); Executed by:
| 108 | ||||||||||||||||||||||||
188 | uint len = (uint)l; | - | ||||||||||||||||||||||||
189 | if (l != len
| 0-5836 | ||||||||||||||||||||||||
190 | scope.engine->throwRangeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "Non integer length for typed array.")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Non integer length for typed array." }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp; never executed: }()));return qstring_literal_temp; never executed: scope.engine->throwRangeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "Non integer length for typed array.")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Non integer length for typed array." }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())); | 0 | ||||||||||||||||||||||||
191 | uint byteLength = len * operations[that->d()->type].bytesPerElement; | - | ||||||||||||||||||||||||
192 | Scoped<ArrayBuffer> buffer(scope, scope.engine->newArrayBuffer(byteLength)); | - | ||||||||||||||||||||||||
193 | if (scope.engine->hasException
| 0-5831 | ||||||||||||||||||||||||
194 | return never executed: Encode::undefined();return Encode::undefined(); never executed: return Encode::undefined(); | 0 | ||||||||||||||||||||||||
195 | - | |||||||||||||||||||||||||
196 | Scoped<TypedArray> array(scope, TypedArray::create(scope.engine, that->d()->type)); | - | ||||||||||||||||||||||||
197 | array->d()->buffer.set(scope.engine, buffer->d()); | - | ||||||||||||||||||||||||
198 | array->d()->byteLength = byteLength; | - | ||||||||||||||||||||||||
199 | array->d()->byteOffset = 0; | - | ||||||||||||||||||||||||
200 | - | |||||||||||||||||||||||||
201 | return executed 5828 times by 1 test: array.asReturnedValue();return array.asReturnedValue(); Executed by:
executed 5828 times by 1 test: return array.asReturnedValue(); Executed by:
| 5828 | ||||||||||||||||||||||||
202 | } | - | ||||||||||||||||||||||||
203 | Scoped<TypedArray> typedArray(scope, argc ? argv[0] : Primitive::undefinedValue()); | - | ||||||||||||||||||||||||
204 | if (!!typedArray
| 568-18937 | ||||||||||||||||||||||||
205 | - | |||||||||||||||||||||||||
206 | Scoped<ArrayBuffer> buffer(scope, typedArray->d()->buffer); | - | ||||||||||||||||||||||||
207 | uint srcElementSize = typedArray->d()->type->bytesPerElement; | - | ||||||||||||||||||||||||
208 | uint destElementSize = operations[that->d()->type].bytesPerElement; | - | ||||||||||||||||||||||||
209 | uint byteLength = typedArray->d()->byteLength; | - | ||||||||||||||||||||||||
210 | uint destByteLength = byteLength*destElementSize/srcElementSize; | - | ||||||||||||||||||||||||
211 | - | |||||||||||||||||||||||||
212 | Scoped<ArrayBuffer> newBuffer(scope, scope.engine->newArrayBuffer(destByteLength)); | - | ||||||||||||||||||||||||
213 | if (scope.engine->hasException
| 0-568 | ||||||||||||||||||||||||
214 | return never executed: Encode::undefined();return Encode::undefined(); never executed: return Encode::undefined(); | 0 | ||||||||||||||||||||||||
215 | - | |||||||||||||||||||||||||
216 | Scoped<TypedArray> array(scope, TypedArray::create(scope.engine, that->d()->type)); | - | ||||||||||||||||||||||||
217 | array->d()->buffer.set(scope.engine, newBuffer->d()); | - | ||||||||||||||||||||||||
218 | array->d()->byteLength = destByteLength; | - | ||||||||||||||||||||||||
219 | array->d()->byteOffset = 0; | - | ||||||||||||||||||||||||
220 | - | |||||||||||||||||||||||||
221 | const char *src = buffer->d()->data->data() + typedArray->d()->byteOffset; | - | ||||||||||||||||||||||||
222 | char *dest = newBuffer->d()->data->data(); | - | ||||||||||||||||||||||||
223 | - | |||||||||||||||||||||||||
224 | - | |||||||||||||||||||||||||
225 | if (srcElementSize == destElementSize
| 252-316 | ||||||||||||||||||||||||
226 | memcpy(dest, src, byteLength); | - | ||||||||||||||||||||||||
227 | } executed 316 times by 1 test: else {end of block Executed by:
| 316 | ||||||||||||||||||||||||
228 | - | |||||||||||||||||||||||||
229 | uint l = typedArray->length(); | - | ||||||||||||||||||||||||
230 | TypedArrayRead read = typedArray->d()->type->read; | - | ||||||||||||||||||||||||
231 | TypedArrayWrite write =array->d()->type->write; | - | ||||||||||||||||||||||||
232 | for (uint i = 0; i < l
| 252-660 | ||||||||||||||||||||||||
233 | Primitive val; | - | ||||||||||||||||||||||||
234 | val.setRawValue(read(src, i*srcElementSize)); | - | ||||||||||||||||||||||||
235 | write(scope.engine, dest, i*destElementSize, val); | - | ||||||||||||||||||||||||
236 | } executed 660 times by 1 test: end of block Executed by:
| 660 | ||||||||||||||||||||||||
237 | } executed 252 times by 1 test: end of block Executed by:
| 252 | ||||||||||||||||||||||||
238 | - | |||||||||||||||||||||||||
239 | return executed 568 times by 1 test: array.asReturnedValue();return array.asReturnedValue(); Executed by:
executed 568 times by 1 test: return array.asReturnedValue(); Executed by:
| 568 | ||||||||||||||||||||||||
240 | } | - | ||||||||||||||||||||||||
241 | Scoped<ArrayBuffer> buffer(scope, argc ? argv[0] : Primitive::undefinedValue()); | - | ||||||||||||||||||||||||
242 | if (!!buffer
| 6061-12865 | ||||||||||||||||||||||||
243 | - | |||||||||||||||||||||||||
244 | - | |||||||||||||||||||||||||
245 | double dbyteOffset = argc > 1
| 454-5607 | ||||||||||||||||||||||||
246 | uint byteOffset = (uint)dbyteOffset; | - | ||||||||||||||||||||||||
247 | uint elementSize = operations[that->d()->type].bytesPerElement; | - | ||||||||||||||||||||||||
248 | if (dbyteOffset < 0
| 48-5989 | ||||||||||||||||||||||||
249 | return executed 192 times by 1 test: scope.engine->throwRangeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "new TypedArray: invalid byteOffset")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "new TypedArray: invalid byteOffset" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); returnreturn scope.engine->throwRangeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "new TypedArray: invalid byteOffset")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "new TypedArray: invalid byteOffset" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())); Executed by:
executed 192 times by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 192 times by 1 test: }()));return qstring_literal_temp; Executed by:
executed 192 times by 1 test: return scope.engine->throwRangeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "new TypedArray: invalid byteOffset")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "new TypedArray: invalid byteOffset" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())); Executed by:
| 192 | ||||||||||||||||||||||||
250 | - | |||||||||||||||||||||||||
251 | uint byteLength; | - | ||||||||||||||||||||||||
252 | if (argc < 3
| 24-4550 | ||||||||||||||||||||||||
253 | byteLength = buffer->byteLength() - byteOffset; | - | ||||||||||||||||||||||||
254 | if (buffer->byteLength() < byteOffset
| 0-1346 | ||||||||||||||||||||||||
255 | return executed 48 times by 1 test: scope.engine->throwRangeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "new TypedArray: invalid length")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "new TypedArray: invalid length" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); returnreturn scope.engine->throwRangeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "new TypedArray: invalid length")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "new TypedArray: invalid length" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())); Executed by:
executed 48 times by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 48 times by 1 test: }()));return qstring_literal_temp; Executed by:
executed 48 times by 1 test: return scope.engine->throwRangeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "new TypedArray: invalid length")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "new TypedArray: invalid length" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())); Executed by:
| 48 | ||||||||||||||||||||||||
256 | } executed 1298 times by 2 tests: else {end of block Executed by:
| 1298 | ||||||||||||||||||||||||
257 | double l = qBound(0., argv[2].toInteger(), (double) | - | ||||||||||||||||||||||||
258 | (0x7fffffff * 2U + 1U) | - | ||||||||||||||||||||||||
259 | ); | - | ||||||||||||||||||||||||
260 | if (scope.engine->hasException
| 76-4451 | ||||||||||||||||||||||||
261 | return executed 76 times by 1 test: Encode::undefined();return Encode::undefined(); Executed by:
executed 76 times by 1 test: return Encode::undefined(); Executed by:
| 76 | ||||||||||||||||||||||||
262 | l *= elementSize; | - | ||||||||||||||||||||||||
263 | if (buffer->byteLength() - byteOffset < l
| 36-4415 | ||||||||||||||||||||||||
264 | return executed 36 times by 1 test: scope.engine->throwRangeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "new TypedArray: invalid length")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "new TypedArray: invalid length" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); returnreturn scope.engine->throwRangeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "new TypedArray: invalid length")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "new TypedArray: invalid length" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())); Executed by:
executed 36 times by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 36 times by 1 test: }()));return qstring_literal_temp; Executed by:
executed 36 times by 1 test: return scope.engine->throwRangeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "new TypedArray: invalid length")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "new TypedArray: invalid length" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())); Executed by:
| 36 | ||||||||||||||||||||||||
265 | byteLength = (uint)l; | - | ||||||||||||||||||||||||
266 | } executed 4414 times by 1 test: end of block Executed by:
| 4414 | ||||||||||||||||||||||||
267 | - | |||||||||||||||||||||||||
268 | Scoped<TypedArray> array(scope, TypedArray::create(scope.engine, that->d()->type)); | - | ||||||||||||||||||||||||
269 | array->d()->buffer.set(scope.engine, buffer->d()); | - | ||||||||||||||||||||||||
270 | array->d()->byteLength = byteLength; | - | ||||||||||||||||||||||||
271 | array->d()->byteOffset = byteOffset; | - | ||||||||||||||||||||||||
272 | return executed 5713 times by 2 tests: array.asReturnedValue();return array.asReturnedValue(); Executed by:
executed 5713 times by 2 tests: return array.asReturnedValue(); Executed by:
| 5713 | ||||||||||||||||||||||||
273 | } | - | ||||||||||||||||||||||||
274 | - | |||||||||||||||||||||||||
275 | - | |||||||||||||||||||||||||
276 | - | |||||||||||||||||||||||||
277 | ScopedObject o(scope, argc ? argv[0] : Primitive::undefinedValue()); | - | ||||||||||||||||||||||||
278 | uint l = (uint) qBound(0., ScopedValue(scope, o->get(scope.engine->id_length()))->toInteger(), (double) | - | ||||||||||||||||||||||||
279 | (0x7fffffff * 2U + 1U) | - | ||||||||||||||||||||||||
280 | ); | - | ||||||||||||||||||||||||
281 | if (scope.engine->hasException
| 72-12805 | ||||||||||||||||||||||||
282 | return executed 72 times by 1 test: scope.engine->throwTypeError();return scope.engine->throwTypeError(); Executed by:
executed 72 times by 1 test: return scope.engine->throwTypeError(); Executed by:
| 72 | ||||||||||||||||||||||||
283 | - | |||||||||||||||||||||||||
284 | uint elementSize = operations[that->d()->type].bytesPerElement; | - | ||||||||||||||||||||||||
285 | size_t bufferSize; | - | ||||||||||||||||||||||||
286 | if (mul_overflow(size_t(l), size_t(elementSize), &bufferSize)
| 0-12805 | ||||||||||||||||||||||||
287 | return never executed: scope.engine->throwRangeError(QLatin1String("new TypedArray: invalid length"));return scope.engine->throwRangeError(QLatin1String("new TypedArray: invalid length")); never executed: return scope.engine->throwRangeError(QLatin1String("new TypedArray: invalid length")); | 0 | ||||||||||||||||||||||||
288 | Scoped<ArrayBuffer> newBuffer(scope, scope.engine->newArrayBuffer(bufferSize)); | - | ||||||||||||||||||||||||
289 | if (scope.engine->hasException
| 36-12765 | ||||||||||||||||||||||||
290 | return executed 36 times by 1 test: Encode::undefined();return Encode::undefined(); Executed by:
executed 36 times by 1 test: return Encode::undefined(); Executed by:
| 36 | ||||||||||||||||||||||||
291 | - | |||||||||||||||||||||||||
292 | Scoped<TypedArray> array(scope, TypedArray::create(scope.engine, that->d()->type)); | - | ||||||||||||||||||||||||
293 | array->d()->buffer.set(scope.engine, newBuffer->d()); | - | ||||||||||||||||||||||||
294 | array->d()->byteLength = l * elementSize; | - | ||||||||||||||||||||||||
295 | array->d()->byteOffset = 0; | - | ||||||||||||||||||||||||
296 | - | |||||||||||||||||||||||||
297 | uint idx = 0; | - | ||||||||||||||||||||||||
298 | char *b = newBuffer->d()->data->data(); | - | ||||||||||||||||||||||||
299 | ScopedValue val(scope); | - | ||||||||||||||||||||||||
300 | while (idx < l
| 12486-38153 | ||||||||||||||||||||||||
301 | val = o->get(idx); | - | ||||||||||||||||||||||||
302 | array->d()->type->write(scope.engine, b, 0, val); | - | ||||||||||||||||||||||||
303 | if (scope.engine->hasException
| 288-37869 | ||||||||||||||||||||||||
304 | return executed 288 times by 1 test: Encode::undefined();return Encode::undefined(); Executed by:
executed 288 times by 1 test: return Encode::undefined(); Executed by:
| 288 | ||||||||||||||||||||||||
305 | ++idx; | - | ||||||||||||||||||||||||
306 | b += elementSize; | - | ||||||||||||||||||||||||
307 | } executed 37870 times by 2 tests: end of block Executed by:
| 37870 | ||||||||||||||||||||||||
308 | - | |||||||||||||||||||||||||
309 | - | |||||||||||||||||||||||||
310 | return executed 12487 times by 2 tests: array.asReturnedValue();return array.asReturnedValue(); Executed by:
executed 12487 times by 2 tests: return array.asReturnedValue(); Executed by:
| 12487 | ||||||||||||||||||||||||
311 | } | - | ||||||||||||||||||||||||
312 | - | |||||||||||||||||||||||||
313 | ReturnedValue TypedArrayCtor::virtualCall(const FunctionObject *f, const Value *, const Value *, int) | - | ||||||||||||||||||||||||
314 | { | - | ||||||||||||||||||||||||
315 | return executed 252 times by 1 test: f->engine()->throwTypeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "calling a TypedArray constructor without new is invalid")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "calling a TypedArray constructor without new is invalid" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); returnreturn f->engine()->throwTypeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "calling a TypedArray constructor without new is invalid")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "calling a TypedArray constructor without new is invalid" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())); Executed by:
executed 252 times by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 252 times by 1 test: }()));return qstring_literal_temp; Executed by:
executed 252 times by 1 test: return f->engine()->throwTypeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "calling a TypedArray constructor without new is invalid")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "calling a TypedArray constructor without new is invalid" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())); Executed by:
| 252 | ||||||||||||||||||||||||
316 | } | - | ||||||||||||||||||||||||
317 | - | |||||||||||||||||||||||||
318 | void Heap::TypedArray::init(Type t) | - | ||||||||||||||||||||||||
319 | { | - | ||||||||||||||||||||||||
320 | Object::init(); | - | ||||||||||||||||||||||||
321 | type = operations + t; | - | ||||||||||||||||||||||||
322 | arrayType = t; | - | ||||||||||||||||||||||||
323 | } executed 24870 times by 2 tests: end of block Executed by:
| 24870 | ||||||||||||||||||||||||
324 | - | |||||||||||||||||||||||||
325 | Heap::TypedArray *TypedArray::create(ExecutionEngine *e, Heap::TypedArray::Type t) | - | ||||||||||||||||||||||||
326 | { | - | ||||||||||||||||||||||||
327 | Scope scope(e); | - | ||||||||||||||||||||||||
328 | Scoped<InternalClass> ic(scope, e->newInternalClass(staticVTable(), e->typedArrayPrototype + t)); | - | ||||||||||||||||||||||||
329 | return executed 24882 times by 2 tests: e->memoryManager->allocObject<TypedArray>(ic->d(), t);return e->memoryManager->allocObject<TypedArray>(ic->d(), t); Executed by:
executed 24882 times by 2 tests: return e->memoryManager->allocObject<TypedArray>(ic->d(), t); Executed by:
| 24882 | ||||||||||||||||||||||||
330 | } | - | ||||||||||||||||||||||||
331 | - | |||||||||||||||||||||||||
332 | ReturnedValue TypedArray::virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty) | - | ||||||||||||||||||||||||
333 | { | - | ||||||||||||||||||||||||
334 | if (!id.isArrayIndex()
| 24199-51879 | ||||||||||||||||||||||||
335 | return executed 51876 times by 2 tests: Object::virtualGet(m, id, receiver, hasProperty);return Object::virtualGet(m, id, receiver, hasProperty); Executed by:
executed 51876 times by 2 tests: return Object::virtualGet(m, id, receiver, hasProperty); Executed by:
| 51876 | ||||||||||||||||||||||||
336 | - | |||||||||||||||||||||||||
337 | uint index = id.asArrayIndex(); | - | ||||||||||||||||||||||||
338 | Scope scope(static_cast<const Object *>(m)->engine()); | - | ||||||||||||||||||||||||
339 | Scoped<TypedArray> a(scope, static_cast<const TypedArray *>(m)); | - | ||||||||||||||||||||||||
340 | - | |||||||||||||||||||||||||
341 | uint bytesPerElement = a->d()->type->bytesPerElement; | - | ||||||||||||||||||||||||
342 | uint byteOffset = a->d()->byteOffset + index * bytesPerElement; | - | ||||||||||||||||||||||||
343 | if (byteOffset + bytesPerElement > (uint)a->d()->buffer->byteLength()
| 432-23757 | ||||||||||||||||||||||||
344 | if (hasProperty
| 108-324 | ||||||||||||||||||||||||
345 | * executed 108 times by 1 test: hasProperty = false;*hasProperty = false; Executed by:
executed 108 times by 1 test: *hasProperty = false; Executed by:
| 108 | ||||||||||||||||||||||||
346 | return executed 432 times by 1 test: Encode::undefined();return Encode::undefined(); Executed by:
executed 432 times by 1 test: return Encode::undefined(); Executed by:
| 432 | ||||||||||||||||||||||||
347 | } | - | ||||||||||||||||||||||||
348 | if (hasProperty
| 108-23649 | ||||||||||||||||||||||||
349 | * executed 108 times by 1 test: hasProperty = true;*hasProperty = true; Executed by:
executed 108 times by 1 test: *hasProperty = true; Executed by:
| 108 | ||||||||||||||||||||||||
350 | return executed 23752 times by 1 test: a->d()->type->read(a->d()->buffer->data->data(), byteOffset);return a->d()->type->read(a->d()->buffer->data->data(), byteOffset); Executed by:
executed 23752 times by 1 test: return a->d()->type->read(a->d()->buffer->data->data(), byteOffset); Executed by:
| 23752 | ||||||||||||||||||||||||
351 | } | - | ||||||||||||||||||||||||
352 | - | |||||||||||||||||||||||||
353 | bool TypedArray::virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver) | - | ||||||||||||||||||||||||
354 | { | - | ||||||||||||||||||||||||
355 | if (!id.isArrayIndex()
| 2759-18262 | ||||||||||||||||||||||||
356 | return executed 2759 times by 1 test: Object::virtualPut(m, id, value, receiver);return Object::virtualPut(m, id, value, receiver); Executed by:
executed 2759 times by 1 test: return Object::virtualPut(m, id, value, receiver); Executed by:
| 2759 | ||||||||||||||||||||||||
357 | - | |||||||||||||||||||||||||
358 | uint index = id.asArrayIndex(); | - | ||||||||||||||||||||||||
359 | ExecutionEngine *v4 = static_cast<Object *>(m)->engine(); | - | ||||||||||||||||||||||||
360 | if (v4->hasException
| 0-18262 | ||||||||||||||||||||||||
361 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
362 | - | |||||||||||||||||||||||||
363 | Scope scope(v4); | - | ||||||||||||||||||||||||
364 | Scoped<TypedArray> a(scope, static_cast<TypedArray *>(m)); | - | ||||||||||||||||||||||||
365 | - | |||||||||||||||||||||||||
366 | uint bytesPerElement = a->d()->type->bytesPerElement; | - | ||||||||||||||||||||||||
367 | uint byteOffset = a->d()->byteOffset + index * bytesPerElement; | - | ||||||||||||||||||||||||
368 | if (byteOffset + bytesPerElement > (uint)a->d()->buffer->byteLength()
| 38-18224 | ||||||||||||||||||||||||
369 | return executed 38 times by 1 test: false;return false; Executed by:
executed 38 times by 1 test: return false; Executed by:
| 38 | ||||||||||||||||||||||||
370 | - | |||||||||||||||||||||||||
371 | a->d()->type->write(scope.engine, a->d()->buffer->data->data(), byteOffset, value); | - | ||||||||||||||||||||||||
372 | return executed 18224 times by 1 test: true;return true; Executed by:
executed 18224 times by 1 test: return true; Executed by:
| 18224 | ||||||||||||||||||||||||
373 | } | - | ||||||||||||||||||||||||
374 | - | |||||||||||||||||||||||||
375 | void TypedArrayPrototype::init(ExecutionEngine *engine, TypedArrayCtor *ctor) | - | ||||||||||||||||||||||||
376 | { | - | ||||||||||||||||||||||||
377 | Scope scope(engine); | - | ||||||||||||||||||||||||
378 | ScopedObject o(scope); | - | ||||||||||||||||||||||||
379 | - | |||||||||||||||||||||||||
380 | ctor->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(3)); | - | ||||||||||||||||||||||||
381 | ctor->defineReadonlyProperty(engine->id_prototype(), *this); | - | ||||||||||||||||||||||||
382 | ctor->defineReadonlyProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "BYTES_PER_ELEMENT")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "BYTES_PER_ELEMENT" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 890617 times by 153 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 890617 times by 153 tests: }()), Primitive::fromInt32(operations[ctor->d()->type].bytesPerElement));return qstring_literal_temp; Executed by:
| 890617 | ||||||||||||||||||||||||
383 | ctor->setPrototypeOf(engine->intrinsicTypedArrayCtor()); | - | ||||||||||||||||||||||||
384 | - | |||||||||||||||||||||||||
385 | setPrototypeOf(engine->intrinsicTypedArrayPrototype()); | - | ||||||||||||||||||||||||
386 | defineDefaultProperty(engine->id_constructor(), (o = ctor)); | - | ||||||||||||||||||||||||
387 | defineReadonlyProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "BYTES_PER_ELEMENT")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "BYTES_PER_ELEMENT" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 888809 times by 153 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 888809 times by 153 tests: }()), Primitive::fromInt32(operations[ctor->d()->type].bytesPerElement));return qstring_literal_temp; Executed by:
| 888809 | ||||||||||||||||||||||||
388 | } executed 891567 times by 153 tests: end of block Executed by:
| 891567 | ||||||||||||||||||||||||
389 | - | |||||||||||||||||||||||||
390 | ReturnedValue IntrinsicTypedArrayPrototype::method_get_buffer(const FunctionObject *b, const Value *thisObject, const Value *, int) | - | ||||||||||||||||||||||||
391 | { | - | ||||||||||||||||||||||||
392 | ExecutionEngine *v4 = b->engine(); | - | ||||||||||||||||||||||||
393 | const TypedArray *v = thisObject->as<TypedArray>(); | - | ||||||||||||||||||||||||
394 | if (!v
| 88-1739 | ||||||||||||||||||||||||
395 | return executed 88 times by 1 test: v4->throwTypeError();return v4->throwTypeError(); Executed by:
executed 88 times by 1 test: return v4->throwTypeError(); Executed by:
| 88 | ||||||||||||||||||||||||
396 | - | |||||||||||||||||||||||||
397 | return executed 1739 times by 2 tests: v->d()->buffer->asReturnedValue();return v->d()->buffer->asReturnedValue(); Executed by:
executed 1739 times by 2 tests: return v->d()->buffer->asReturnedValue(); Executed by:
| 1739 | ||||||||||||||||||||||||
398 | } | - | ||||||||||||||||||||||||
399 | - | |||||||||||||||||||||||||
400 | ReturnedValue IntrinsicTypedArrayPrototype::method_get_byteLength(const FunctionObject *b, const Value *thisObject, const Value *, int) | - | ||||||||||||||||||||||||
401 | { | - | ||||||||||||||||||||||||
402 | ExecutionEngine *v4 = b->engine(); | - | ||||||||||||||||||||||||
403 | const TypedArray *v = thisObject->as<TypedArray>(); | - | ||||||||||||||||||||||||
404 | if (!v
| 52-78 | ||||||||||||||||||||||||
405 | return executed 52 times by 1 test: v4->throwTypeError();return v4->throwTypeError(); Executed by:
executed 52 times by 1 test: return v4->throwTypeError(); Executed by:
| 52 | ||||||||||||||||||||||||
406 | - | |||||||||||||||||||||||||
407 | return executed 78 times by 2 tests: Encode(v->d()->byteLength);return Encode(v->d()->byteLength); Executed by:
executed 78 times by 2 tests: return Encode(v->d()->byteLength); Executed by:
| 78 | ||||||||||||||||||||||||
408 | } | - | ||||||||||||||||||||||||
409 | - | |||||||||||||||||||||||||
410 | ReturnedValue IntrinsicTypedArrayPrototype::method_get_byteOffset(const FunctionObject *b, const Value *thisObject, const Value *, int) | - | ||||||||||||||||||||||||
411 | { | - | ||||||||||||||||||||||||
412 | ExecutionEngine *v4 = b->engine(); | - | ||||||||||||||||||||||||
413 | const TypedArray *v = thisObject->as<TypedArray>(); | - | ||||||||||||||||||||||||
414 | if (!v
| 51-732 | ||||||||||||||||||||||||
415 | return executed 51 times by 1 test: v4->throwTypeError();return v4->throwTypeError(); Executed by:
executed 51 times by 1 test: return v4->throwTypeError(); Executed by:
| 51 | ||||||||||||||||||||||||
416 | - | |||||||||||||||||||||||||
417 | return executed 732 times by 1 test: Encode(v->d()->byteOffset);return Encode(v->d()->byteOffset); Executed by:
executed 732 times by 1 test: return Encode(v->d()->byteOffset); Executed by:
| 732 | ||||||||||||||||||||||||
418 | } | - | ||||||||||||||||||||||||
419 | - | |||||||||||||||||||||||||
420 | ReturnedValue IntrinsicTypedArrayPrototype::method_get_length(const FunctionObject *b, const Value *thisObject, const Value *, int) | - | ||||||||||||||||||||||||
421 | { | - | ||||||||||||||||||||||||
422 | ExecutionEngine *v4 = b->engine(); | - | ||||||||||||||||||||||||
423 | const TypedArray *v = thisObject->as<TypedArray>(); | - | ||||||||||||||||||||||||
424 | if (!v
| 52-24677 | ||||||||||||||||||||||||
425 | return executed 52 times by 1 test: v4->throwTypeError();return v4->throwTypeError(); Executed by:
executed 52 times by 1 test: return v4->throwTypeError(); Executed by:
| 52 | ||||||||||||||||||||||||
426 | - | |||||||||||||||||||||||||
427 | return executed 24679 times by 1 test: Encode(v->d()->byteLength/v->d()->type->bytesPerElement);return Encode(v->d()->byteLength/v->d()->type->bytesPerElement); Executed by:
executed 24679 times by 1 test: return Encode(v->d()->byteLength/v->d()->type->bytesPerElement); Executed by:
| 24679 | ||||||||||||||||||||||||
428 | } | - | ||||||||||||||||||||||||
429 | - | |||||||||||||||||||||||||
430 | ReturnedValue IntrinsicTypedArrayPrototype::method_entries(const FunctionObject *b, const Value *thisObject, const Value *, int) | - | ||||||||||||||||||||||||
431 | { | - | ||||||||||||||||||||||||
432 | Scope scope(b); | - | ||||||||||||||||||||||||
433 | Scoped<TypedArray> O(scope, thisObject); | - | ||||||||||||||||||||||||
434 | if (!O
| 52-72 | ||||||||||||||||||||||||
435 | return executed 52 times by 1 test: scope.engine->throwTypeError();return scope.engine->throwTypeError(); Executed by:
executed 52 times by 1 test: return scope.engine->throwTypeError(); Executed by:
| 52 | ||||||||||||||||||||||||
436 | - | |||||||||||||||||||||||||
437 | Scoped<ArrayIteratorObject> ao(scope, scope.engine->newArrayIteratorObject(O)); | - | ||||||||||||||||||||||||
438 | ao->d()->iterationKind = IteratorKind::KeyValueIteratorKind; | - | ||||||||||||||||||||||||
439 | return executed 72 times by 1 test: ao->asReturnedValue();return ao->asReturnedValue(); Executed by:
executed 72 times by 1 test: return ao->asReturnedValue(); Executed by:
| 72 | ||||||||||||||||||||||||
440 | } | - | ||||||||||||||||||||||||
441 | - | |||||||||||||||||||||||||
442 | ReturnedValue IntrinsicTypedArrayPrototype::method_keys(const FunctionObject *b, const Value *thisObject, const Value *, int) | - | ||||||||||||||||||||||||
443 | { | - | ||||||||||||||||||||||||
444 | Scope scope(b); | - | ||||||||||||||||||||||||
445 | Scoped<TypedArray> O(scope, thisObject); | - | ||||||||||||||||||||||||
446 | if (!O
| 52-76 | ||||||||||||||||||||||||
447 | return executed 52 times by 1 test: scope.engine->throwTypeError();return scope.engine->throwTypeError(); Executed by:
executed 52 times by 1 test: return scope.engine->throwTypeError(); Executed by:
| 52 | ||||||||||||||||||||||||
448 | - | |||||||||||||||||||||||||
449 | Scoped<ArrayIteratorObject> ao(scope, scope.engine->newArrayIteratorObject(O)); | - | ||||||||||||||||||||||||
450 | ao->d()->iterationKind = IteratorKind::KeyIteratorKind; | - | ||||||||||||||||||||||||
451 | return executed 76 times by 1 test: ao->asReturnedValue();return ao->asReturnedValue(); Executed by:
executed 76 times by 1 test: return ao->asReturnedValue(); Executed by:
| 76 | ||||||||||||||||||||||||
452 | } | - | ||||||||||||||||||||||||
453 | - | |||||||||||||||||||||||||
454 | ReturnedValue IntrinsicTypedArrayPrototype::method_values(const FunctionObject *b, const Value *thisObject, const Value *, int) | - | ||||||||||||||||||||||||
455 | { | - | ||||||||||||||||||||||||
456 | Scope scope(b); | - | ||||||||||||||||||||||||
457 | Scoped<TypedArray> O(scope, thisObject); | - | ||||||||||||||||||||||||
458 | if (!O
| 52-179 | ||||||||||||||||||||||||
459 | return executed 52 times by 1 test: scope.engine->throwTypeError();return scope.engine->throwTypeError(); Executed by:
executed 52 times by 1 test: return scope.engine->throwTypeError(); Executed by:
| 52 | ||||||||||||||||||||||||
460 | - | |||||||||||||||||||||||||
461 | Scoped<ArrayIteratorObject> ao(scope, scope.engine->newArrayIteratorObject(O)); | - | ||||||||||||||||||||||||
462 | ao->d()->iterationKind = IteratorKind::ValueIteratorKind; | - | ||||||||||||||||||||||||
463 | return executed 180 times by 1 test: ao->asReturnedValue();return ao->asReturnedValue(); Executed by:
executed 180 times by 1 test: return ao->asReturnedValue(); Executed by:
| 180 | ||||||||||||||||||||||||
464 | } | - | ||||||||||||||||||||||||
465 | - | |||||||||||||||||||||||||
466 | ReturnedValue IntrinsicTypedArrayPrototype::method_set(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) | - | ||||||||||||||||||||||||
467 | { | - | ||||||||||||||||||||||||
468 | Scope scope(b); | - | ||||||||||||||||||||||||
469 | Scoped<TypedArray> a(scope, *thisObject); | - | ||||||||||||||||||||||||
470 | if (!a
| 96-5979 | ||||||||||||||||||||||||
471 | return executed 96 times by 1 test: scope.engine->throwTypeError();return scope.engine->throwTypeError(); Executed by:
executed 96 times by 1 test: return scope.engine->throwTypeError(); Executed by:
| 96 | ||||||||||||||||||||||||
472 | Scoped<ArrayBuffer> buffer(scope, a->d()->buffer); | - | ||||||||||||||||||||||||
473 | if (!buffer
| 0-5980 | ||||||||||||||||||||||||
474 | scope.engine->throwTypeError(); never executed: scope.engine->throwTypeError(); | 0 | ||||||||||||||||||||||||
475 | - | |||||||||||||||||||||||||
476 | double doffset = argc >= 2
| 2461-3519 | ||||||||||||||||||||||||
477 | if (scope.engine->hasException
| 228-5753 | ||||||||||||||||||||||||
478 | return executed 228 times by 1 test: QV4::Encode::undefined();return QV4::Encode::undefined(); Executed by:
executed 228 times by 1 test: return QV4::Encode::undefined(); Executed by:
| 228 | ||||||||||||||||||||||||
479 | - | |||||||||||||||||||||||||
480 | if (doffset < 0
| 36-5537 | ||||||||||||||||||||||||
481 | (0x7fffffff * 2U + 1U)
| 36-5499 | ||||||||||||||||||||||||
482 | ) | - | ||||||||||||||||||||||||
483 | return executed 252 times by 1 test: QV4::Encode(scope.engine->throwRangeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "TypedArray.set: out of range")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "TypedArray.set: out of range" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); returnreturn QV4::Encode(scope.engine->throwRangeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "TypedArray.set: out of range")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "TypedArray.set: out of range" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()))); Executed by:
executed 252 times by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 252 times by 1 test: }())));return qstring_literal_temp; Executed by:
executed 252 times by 1 test: return QV4::Encode(scope.engine->throwRangeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "TypedArray.set: out of range")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "TypedArray.set: out of range" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()))); Executed by:
| 252 | ||||||||||||||||||||||||
484 | uint offset = (uint)doffset; | - | ||||||||||||||||||||||||
485 | uint elementSize = a->d()->type->bytesPerElement; | - | ||||||||||||||||||||||||
486 | - | |||||||||||||||||||||||||
487 | Scoped<TypedArray> srcTypedArray(scope, argv[0]); | - | ||||||||||||||||||||||||
488 | if (!srcTypedArray
| 2720-2780 | ||||||||||||||||||||||||
489 | - | |||||||||||||||||||||||||
490 | ScopedObject o(scope, argv[0].toObject(scope.engine)); | - | ||||||||||||||||||||||||
491 | if (scope.engine->hasException
| 0-2708 | ||||||||||||||||||||||||
492 | return executed 72 times by 1 test: scope.engine->throwTypeError();return scope.engine->throwTypeError(); Executed by:
executed 72 times by 1 test: return scope.engine->throwTypeError(); Executed by:
| 72 | ||||||||||||||||||||||||
493 | - | |||||||||||||||||||||||||
494 | double len = ScopedValue(scope, o->get(scope.engine->id_length()))->toNumber(); | - | ||||||||||||||||||||||||
495 | uint l = (uint)len; | - | ||||||||||||||||||||||||
496 | if (scope.engine->hasException
| 0-2563 | ||||||||||||||||||||||||
497 | return executed 144 times by 1 test: scope.engine->throwTypeError();return scope.engine->throwTypeError(); Executed by:
executed 144 times by 1 test: return scope.engine->throwTypeError(); Executed by:
| 144 | ||||||||||||||||||||||||
498 | - | |||||||||||||||||||||||||
499 | if (offset + l > a->length()
| 0-2564 | ||||||||||||||||||||||||
500 | return never executed: QV4::Encode(scope.engine->throwRangeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "TypedArray.set: out of range")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "TypedArray.set: out of range" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); returnreturn QV4::Encode(scope.engine->throwRangeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "TypedArray.set: out of range")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "TypedArray.set: out of range" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()))); never executed: qstring_literal_temp;return qstring_literal_temp; never executed: }())));return qstring_literal_temp; never executed: return QV4::Encode(scope.engine->throwRangeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "TypedArray.set: out of range")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "TypedArray.set: out of range" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()))); | 0 | ||||||||||||||||||||||||
501 | - | |||||||||||||||||||||||||
502 | uint idx = 0; | - | ||||||||||||||||||||||||
503 | char *b = buffer->d()->data->data() + a->d()->byteOffset + offset*elementSize; | - | ||||||||||||||||||||||||
504 | ScopedValue val(scope); | - | ||||||||||||||||||||||||
505 | while (idx < l
| 2448-3467 | ||||||||||||||||||||||||
506 | val = o->get(idx); | - | ||||||||||||||||||||||||
507 | a->d()->type->write(scope.engine, b, 0, val); | - | ||||||||||||||||||||||||
508 | if (scope.engine->hasException
| 116-3351 | ||||||||||||||||||||||||
509 | return executed 116 times by 1 test: QV4::Encode::undefined();return QV4::Encode::undefined(); Executed by:
executed 116 times by 1 test: return QV4::Encode::undefined(); Executed by:
| 116 | ||||||||||||||||||||||||
510 | ++idx; | - | ||||||||||||||||||||||||
511 | b += elementSize; | - | ||||||||||||||||||||||||
512 | } executed 3351 times by 1 test: end of block Executed by:
| 3351 | ||||||||||||||||||||||||
513 | return executed 2448 times by 1 test: QV4::Encode::undefined();return QV4::Encode::undefined(); Executed by:
executed 2448 times by 1 test: return QV4::Encode::undefined(); Executed by:
| 2448 | ||||||||||||||||||||||||
514 | } | - | ||||||||||||||||||||||||
515 | - | |||||||||||||||||||||||||
516 | - | |||||||||||||||||||||||||
517 | Scoped<ArrayBuffer> srcBuffer(scope, srcTypedArray->d()->buffer); | - | ||||||||||||||||||||||||
518 | if (!srcBuffer
| 0-2720 | ||||||||||||||||||||||||
519 | return never executed: scope.engine->throwTypeError();return scope.engine->throwTypeError(); never executed: return scope.engine->throwTypeError(); | 0 | ||||||||||||||||||||||||
520 | - | |||||||||||||||||||||||||
521 | uint l = srcTypedArray->length(); | - | ||||||||||||||||||||||||
522 | if (offset + l > a->length()
| 108-2615 | ||||||||||||||||||||||||
523 | return executed 108 times by 1 test: QV4::Encode(scope.engine->throwRangeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "TypedArray.set: out of range")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "TypedArray.set: out of range" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); returnreturn QV4::Encode(scope.engine->throwRangeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "TypedArray.set: out of range")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "TypedArray.set: out of range" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()))); Executed by:
executed 108 times by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 108 times by 1 test: }())));return qstring_literal_temp; Executed by:
executed 108 times by 1 test: return QV4::Encode(scope.engine->throwRangeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "TypedArray.set: out of range")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "TypedArray.set: out of range" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()))); Executed by:
| 108 | ||||||||||||||||||||||||
524 | - | |||||||||||||||||||||||||
525 | char *dest = buffer->d()->data->data() + a->d()->byteOffset + offset*elementSize; | - | ||||||||||||||||||||||||
526 | const char *src = srcBuffer->d()->data->data() + srcTypedArray->d()->byteOffset; | - | ||||||||||||||||||||||||
527 | if (srcTypedArray->d()->type == a->d()->type
| 1016-1598 | ||||||||||||||||||||||||
528 | - | |||||||||||||||||||||||||
529 | memmove(dest, src, srcTypedArray->d()->byteLength); | - | ||||||||||||||||||||||||
530 | return executed 1016 times by 1 test: QV4::Encode::undefined();return QV4::Encode::undefined(); Executed by:
executed 1016 times by 1 test: return QV4::Encode::undefined(); Executed by:
| 1016 | ||||||||||||||||||||||||
531 | } | - | ||||||||||||||||||||||||
532 | - | |||||||||||||||||||||||||
533 | char *srcCopy = nullptr; | - | ||||||||||||||||||||||||
534 | if (buffer->d() == srcBuffer->d()
| 108-1491 | ||||||||||||||||||||||||
535 | - | |||||||||||||||||||||||||
536 | srcCopy = new char[srcTypedArray->d()->byteLength]; | - | ||||||||||||||||||||||||
537 | memcpy(srcCopy, src, srcTypedArray->d()->byteLength); | - | ||||||||||||||||||||||||
538 | src = srcCopy; | - | ||||||||||||||||||||||||
539 | } executed 108 times by 1 test: end of block Executed by:
| 108 | ||||||||||||||||||||||||
540 | - | |||||||||||||||||||||||||
541 | - | |||||||||||||||||||||||||
542 | uint srcElementSize = srcTypedArray->d()->type->bytesPerElement; | - | ||||||||||||||||||||||||
543 | TypedArrayRead read = srcTypedArray->d()->type->read; | - | ||||||||||||||||||||||||
544 | TypedArrayWrite write = a->d()->type->write; | - | ||||||||||||||||||||||||
545 | for (uint i = 0; i < l
| 1600-1887 | ||||||||||||||||||||||||
546 | Primitive val; | - | ||||||||||||||||||||||||
547 | val.setRawValue(read(src, i*srcElementSize)); | - | ||||||||||||||||||||||||
548 | write(scope.engine, dest, i*elementSize, val); | - | ||||||||||||||||||||||||
549 | } executed 1886 times by 1 test: end of block Executed by:
| 1886 | ||||||||||||||||||||||||
550 | - | |||||||||||||||||||||||||
551 | if (srcCopy
| 108-1492 | ||||||||||||||||||||||||
552 | delete [] srcCopy; executed 108 times by 1 test: delete [] srcCopy; Executed by:
| 108 | ||||||||||||||||||||||||
553 | - | |||||||||||||||||||||||||
554 | return executed 1600 times by 1 test: QV4::Encode::undefined();return QV4::Encode::undefined(); Executed by:
executed 1600 times by 1 test: return QV4::Encode::undefined(); Executed by:
| 1600 | ||||||||||||||||||||||||
555 | } | - | ||||||||||||||||||||||||
556 | - | |||||||||||||||||||||||||
557 | ReturnedValue IntrinsicTypedArrayPrototype::method_subarray(const FunctionObject *builtin, const Value *thisObject, const Value *argv, int argc) | - | ||||||||||||||||||||||||
558 | { | - | ||||||||||||||||||||||||
559 | Scope scope(builtin); | - | ||||||||||||||||||||||||
560 | Scoped<TypedArray> a(scope, *thisObject); | - | ||||||||||||||||||||||||
561 | - | |||||||||||||||||||||||||
562 | if (!a
| 52-4202 | ||||||||||||||||||||||||
563 | return executed 52 times by 1 test: scope.engine->throwTypeError();return scope.engine->throwTypeError(); Executed by:
executed 52 times by 1 test: return scope.engine->throwTypeError(); Executed by:
| 52 | ||||||||||||||||||||||||
564 | - | |||||||||||||||||||||||||
565 | Scoped<ArrayBuffer> buffer(scope, a->d()->buffer); | - | ||||||||||||||||||||||||
566 | if (!buffer
| 0-4203 | ||||||||||||||||||||||||
567 | return never executed: scope.engine->throwTypeError();return scope.engine->throwTypeError(); never executed: return scope.engine->throwTypeError(); | 0 | ||||||||||||||||||||||||
568 | - | |||||||||||||||||||||||||
569 | int len = a->length(); | - | ||||||||||||||||||||||||
570 | double b = argc > 0
| 0-4207 | ||||||||||||||||||||||||
571 | if (b < 0
| 972-3233 | ||||||||||||||||||||||||
572 | b = len + b; executed 972 times by 1 test: b = len + b; Executed by:
| 972 | ||||||||||||||||||||||||
573 | uint begin = (uint)qBound(0., b, (double)len); | - | ||||||||||||||||||||||||
574 | - | |||||||||||||||||||||||||
575 | double e = argc < 2
| 36-2486 | ||||||||||||||||||||||||
576 | if (e < 0
| 828-3379 | ||||||||||||||||||||||||
577 | e = len + e; executed 828 times by 1 test: e = len + e; Executed by:
| 828 | ||||||||||||||||||||||||
578 | uint end = (uint)qBound(0., e, (double)len); | - | ||||||||||||||||||||||||
579 | if (end < begin
| 144-4062 | ||||||||||||||||||||||||
580 | end = begin; executed 144 times by 1 test: end = begin; Executed by:
| 144 | ||||||||||||||||||||||||
581 | - | |||||||||||||||||||||||||
582 | if (scope.engine->hasException
| 216-3991 | ||||||||||||||||||||||||
583 | return executed 216 times by 1 test: QV4::Encode::undefined();return QV4::Encode::undefined(); Executed by:
executed 216 times by 1 test: return QV4::Encode::undefined(); Executed by:
| 216 | ||||||||||||||||||||||||
584 | - | |||||||||||||||||||||||||
585 | int newLen = end - begin; | - | ||||||||||||||||||||||||
586 | - | |||||||||||||||||||||||||
587 | ScopedFunctionObject constructor(scope, a->get(scope.engine->id_constructor())); | - | ||||||||||||||||||||||||
588 | if (!constructor
| 536-3453 | ||||||||||||||||||||||||
589 | return executed 535 times by 1 test: scope.engine->throwTypeError();return scope.engine->throwTypeError(); Executed by:
executed 535 times by 1 test: return scope.engine->throwTypeError(); Executed by:
| 535 | ||||||||||||||||||||||||
590 | - | |||||||||||||||||||||||||
591 | Value *arguments = scope.alloc(3); | - | ||||||||||||||||||||||||
592 | arguments[0] = buffer; | - | ||||||||||||||||||||||||
593 | arguments[1] = Encode(a->d()->byteOffset + begin*a->d()->type->bytesPerElement); | - | ||||||||||||||||||||||||
594 | arguments[2] = Encode(newLen); | - | ||||||||||||||||||||||||
595 | return executed 3455 times by 1 test: constructor->callAsConstructor(arguments, 3);return constructor->callAsConstructor(arguments, 3); Executed by:
executed 3455 times by 1 test: return constructor->callAsConstructor(arguments, 3); Executed by:
| 3455 | ||||||||||||||||||||||||
596 | } | - | ||||||||||||||||||||||||
597 | - | |||||||||||||||||||||||||
598 | ReturnedValue IntrinsicTypedArrayPrototype::method_get_toStringTag(const FunctionObject *, const Value *thisObject, const Value *, int) | - | ||||||||||||||||||||||||
599 | { | - | ||||||||||||||||||||||||
600 | const TypedArray *a = thisObject->as<TypedArray>(); | - | ||||||||||||||||||||||||
601 | if (!a
| 64-1731 | ||||||||||||||||||||||||
602 | return executed 64 times by 1 test: Encode::undefined();return Encode::undefined(); Executed by:
executed 64 times by 1 test: return Encode::undefined(); Executed by:
| 64 | ||||||||||||||||||||||||
603 | - | |||||||||||||||||||||||||
604 | return executed 1731 times by 1 test: a->engine()->newString(QString::fromLatin1(a->d()->type->name))->asReturnedValue();return a->engine()->newString(QString::fromLatin1(a->d()->type->name))->asReturnedValue(); Executed by:
executed 1731 times by 1 test: return a->engine()->newString(QString::fromLatin1(a->d()->type->name))->asReturnedValue(); Executed by:
| 1731 | ||||||||||||||||||||||||
605 | } | - | ||||||||||||||||||||||||
606 | - | |||||||||||||||||||||||||
607 | ReturnedValue IntrinsicTypedArrayCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *, int, const Value *) | - | ||||||||||||||||||||||||
608 | { | - | ||||||||||||||||||||||||
609 | return executed 24 times by 1 test: f->engine()->throwTypeError();return f->engine()->throwTypeError(); Executed by:
executed 24 times by 1 test: return f->engine()->throwTypeError(); Executed by:
| 24 | ||||||||||||||||||||||||
610 | } | - | ||||||||||||||||||||||||
611 | - | |||||||||||||||||||||||||
612 | ReturnedValue IntrinsicTypedArrayCtor::virtualCall(const FunctionObject *f, const Value *, const Value *, int) | - | ||||||||||||||||||||||||
613 | { | - | ||||||||||||||||||||||||
614 | return executed 24 times by 1 test: f->engine()->throwTypeError();return f->engine()->throwTypeError(); Executed by:
executed 24 times by 1 test: return f->engine()->throwTypeError(); Executed by:
| 24 | ||||||||||||||||||||||||
615 | } | - | ||||||||||||||||||||||||
616 | - | |||||||||||||||||||||||||
617 | void IntrinsicTypedArrayPrototype::init(ExecutionEngine *engine, IntrinsicTypedArrayCtor *ctor) | - | ||||||||||||||||||||||||
618 | { | - | ||||||||||||||||||||||||
619 | ctor->defineReadonlyProperty(engine->id_prototype(), *this); | - | ||||||||||||||||||||||||
620 | ctor->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(0)); | - | ||||||||||||||||||||||||
621 | ctor->addSymbolSpecies(); | - | ||||||||||||||||||||||||
622 | - | |||||||||||||||||||||||||
623 | defineAccessorProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "buffer")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "buffer" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98273 times by 153 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 98273 times by 153 tests: }()), method_get_buffer, nullptr);return qstring_literal_temp; Executed by:
| 98273 | ||||||||||||||||||||||||
624 | defineAccessorProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "byteLength")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "byteLength" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98167 times by 153 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 98167 times by 153 tests: }()), method_get_byteLength, nullptr);return qstring_literal_temp; Executed by:
| 98167 | ||||||||||||||||||||||||
625 | defineAccessorProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "byteOffset")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "byteOffset" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98915 times by 153 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 98915 times by 153 tests: }()), method_get_byteOffset, nullptr);return qstring_literal_temp; Executed by:
| 98915 | ||||||||||||||||||||||||
626 | defineAccessorProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "length")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "length" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98694 times by 153 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 98694 times by 153 tests: }()), method_get_length, nullptr);return qstring_literal_temp; Executed by:
| 98694 | ||||||||||||||||||||||||
627 | - | |||||||||||||||||||||||||
628 | defineDefaultProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "entries")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "entries" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98975 times by 153 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 98975 times by 153 tests: }()), method_entries, 0);return qstring_literal_temp; Executed by:
| 98975 | ||||||||||||||||||||||||
629 | defineDefaultProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "keys")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "keys" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98983 times by 153 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 98983 times by 153 tests: }()), method_keys, 0);return qstring_literal_temp; Executed by:
| 98983 | ||||||||||||||||||||||||
630 | defineDefaultProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "set")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "set" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98854 times by 153 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 98854 times by 153 tests: }()), method_set, 1);return qstring_literal_temp; Executed by:
| 98854 | ||||||||||||||||||||||||
631 | defineDefaultProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "subarray")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "subarray" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98900 times by 153 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 98900 times by 153 tests: }()), method_subarray, 0);return qstring_literal_temp; Executed by:
| 98900 | ||||||||||||||||||||||||
632 | - | |||||||||||||||||||||||||
633 | Scope scope(engine); | - | ||||||||||||||||||||||||
634 | ScopedString valuesString(scope, engine->newIdentifier(([]() noexcept -> QString { enum { Size = sizeof(u"" "values")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "values" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98814 times by 153 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 98814 times by 153 tests: }())));return qstring_literal_temp; Executed by:
| 98814 | ||||||||||||||||||||||||
635 | ScopedObject values(scope, FunctionObject::createBuiltinFunction(engine, valuesString, method_values, 0)); | - | ||||||||||||||||||||||||
636 | defineDefaultProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "values")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "values" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98409 times by 153 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 98409 times by 153 tests: }()), values);return qstring_literal_temp; Executed by:
| 98409 | ||||||||||||||||||||||||
637 | defineDefaultProperty(engine->symbol_iterator(), values); | - | ||||||||||||||||||||||||
638 | - | |||||||||||||||||||||||||
639 | defineAccessorProperty(engine->symbol_toStringTag(), method_get_toStringTag, nullptr); | - | ||||||||||||||||||||||||
640 | } executed 98559 times by 153 tests: end of block Executed by:
| 98559 | ||||||||||||||||||||||||
Switch to Source code | Preprocessed file |