struct instr_callBuiltinDefineObjectLiteral {
MOTH_INSTR_HEADER
int internalClassId;
- int arrayValueCount;
- int arrayGetterSetterCount;
+ uint arrayValueCount;
+ uint arrayGetterSetterCountAndFlags; // 30 bits for count, 1 bit for needsSparseArray boolean
quint32 args;
Param result;
};
addInstruction(call);
}
-void InstructionSelection::callBuiltinDefineObjectLiteral(IR::Temp *result, int keyValuePairCount, IR::ExprList *keyValuePairs, IR::ExprList *arrayEntries)
+void InstructionSelection::callBuiltinDefineObjectLiteral(IR::Temp *result, int keyValuePairCount, IR::ExprList *keyValuePairs, IR::ExprList *arrayEntries, bool needSparseArray)
{
int argLocation = outgoingArgumentTempStart();
}
// Process array values
- int arrayValueCount = 0;
+ uint arrayValueCount = 0;
it = arrayEntries;
while (it) {
IR::Const *index = it->expr->asConst();
}
// Process array getter/setter pairs
- int arrayGetterSetterCount = 0;
+ uint arrayGetterSetterCount = 0;
it = arrayEntries;
while (it) {
IR::Const *index = it->expr->asConst();
Instruction::CallBuiltinDefineObjectLiteral call;
call.internalClassId = classId;
call.arrayValueCount = arrayValueCount;
- call.arrayGetterSetterCount = arrayGetterSetterCount;
+ call.arrayGetterSetterCountAndFlags = arrayGetterSetterCount | (needSparseArray << 30);
call.args = outgoingArgumentTempStart();
call.result = getResultParam(result);
addInstruction(call);
virtual void callBuiltinPopScope();
virtual void callBuiltinDeclareVar(bool deletable, const QString &name);
virtual void callBuiltinDefineArray(IR::Temp *result, IR::ExprList *args);
- virtual void callBuiltinDefineObjectLiteral(IR::Temp *result, int keyValuePairCount, IR::ExprList *keyValuePairs, IR::ExprList *arrayEntries);
+ virtual void callBuiltinDefineObjectLiteral(IR::Temp *result, int keyValuePairCount, IR::ExprList *keyValuePairs, IR::ExprList *arrayEntries, bool needSparseArray);
virtual void callBuiltinSetupArgumentObject(IR::Temp *result);
virtual void callBuiltinConvertThisToObject();
virtual void callValue(IR::Temp *value, IR::ExprList *args, IR::Temp *result);
}
IR::ExprList *arrayEntries = args;
+ bool needSparseArray = false;
+ for (IR::ExprList *it = arrayEntries; it; it = it->next) {
+ uint index = it->expr->asConst()->value;
+ if (index > 16) {
+ needSparseArray = true;
+ break;
+ }
+ it = it->next;
+ bool isData = it->expr->asConst()->value;
+ it = it->next;
+ if (!isData)
+ it = it->next;
+ }
- callBuiltinDefineObjectLiteral(result, keyValuePairsCount, keyValuePairs, arrayEntries);
+ callBuiltinDefineObjectLiteral(result, keyValuePairsCount, keyValuePairs, arrayEntries, needSparseArray);
} return;
case IR::Name::builtin_setup_argument_object:
virtual void callBuiltinPopScope() = 0;
virtual void callBuiltinDeclareVar(bool deletable, const QString &name) = 0;
virtual void callBuiltinDefineArray(IR::Temp *result, IR::ExprList *args) = 0;
- virtual void callBuiltinDefineObjectLiteral(IR::Temp *result, int keyValuePairCount, IR::ExprList *keyValuePairs, IR::ExprList *arrayEntries) = 0;
+ virtual void callBuiltinDefineObjectLiteral(IR::Temp *result, int keyValuePairCount, IR::ExprList *keyValuePairs, IR::ExprList *arrayEntries, bool needSparseArray) = 0;
virtual void callBuiltinSetupArgumentObject(IR::Temp *result) = 0;
virtual void callBuiltinConvertThisToObject() = 0;
virtual void callValue(IR::Temp *value, IR::ExprList *args, IR::Temp *result) = 0;
baseAddressForCallArguments(), Assembler::TrustedImm32(length));
}
-void InstructionSelection::callBuiltinDefineObjectLiteral(IR::Temp *result, int keyValuePairCount, IR::ExprList *keyValuePairs, IR::ExprList *arrayEntries)
+void InstructionSelection::callBuiltinDefineObjectLiteral(IR::Temp *result, int keyValuePairCount, IR::ExprList *keyValuePairs, IR::ExprList *arrayEntries, bool needSparseArray)
{
Q_ASSERT(result);
}
it = arrayEntries;
- int arrayValueCount = 0;
+ uint arrayValueCount = 0;
while (it) {
uint index = it->expr->asConst()->value;
it = it->next;
}
it = arrayEntries;
- int arrayGetterSetterCount = 0;
+ uint arrayGetterSetterCount = 0;
while (it) {
uint index = it->expr->asConst()->value;
it = it->next;
generateFunctionCall(result, __qmljs_builtin_define_object_literal, Assembler::ContextRegister,
baseAddressForCallArguments(), Assembler::TrustedImm32(classId),
- Assembler::TrustedImm32(arrayValueCount), Assembler::TrustedImm32(arrayGetterSetterCount));
+ Assembler::TrustedImm32(arrayValueCount), Assembler::TrustedImm32(arrayGetterSetterCount | (needSparseArray << 30)));
}
void InstructionSelection::callBuiltinSetupArgumentObject(IR::Temp *result)
virtual void callBuiltinPopScope();
virtual void callBuiltinDeclareVar(bool deletable, const QString &name);
virtual void callBuiltinDefineArray(IR::Temp *result, IR::ExprList *args);
- virtual void callBuiltinDefineObjectLiteral(IR::Temp *result, int keyValuePairCount, IR::ExprList *keyValuePairs, IR::ExprList *arrayEntries);
+ virtual void callBuiltinDefineObjectLiteral(IR::Temp *result, int keyValuePairCount, IR::ExprList *keyValuePairs, IR::ExprList *arrayEntries, bool needSparseArray);
virtual void callBuiltinSetupArgumentObject(IR::Temp *result);
virtual void callBuiltinConvertThisToObject();
virtual void callValue(IR::Temp *value, IR::ExprList *args, IR::Temp *result);
virtual void callBuiltinPopScope() {}
virtual void callBuiltinDeclareVar(bool , const QString &) {}
virtual void callBuiltinDefineArray(IR::Temp *, IR::ExprList *) {}
- virtual void callBuiltinDefineObjectLiteral(IR::Temp *, int, IR::ExprList *, IR::ExprList *) {}
+ virtual void callBuiltinDefineObjectLiteral(IR::Temp *, int, IR::ExprList *, IR::ExprList *, bool) {}
virtual void callBuiltinSetupArgumentObject(IR::Temp *) {}
virtual void callBuiltinConvertThisToObject() {}
return a.asReturnedValue();
}
-ReturnedValue __qmljs_builtin_define_object_literal(QV4::ExecutionContext *ctx, const QV4::Value *args, int classId, int arrayValueCount, int arrayGetterSetterCount)
+ReturnedValue __qmljs_builtin_define_object_literal(QV4::ExecutionContext *ctx, const QV4::Value *args, int classId, int arrayValueCount, int arrayGetterSetterCountAndFlags)
{
Scope scope(ctx);
QV4::InternalClass *klass = ctx->compilationUnit->runtimeClasses[classId];
Scoped<Object> o(scope, ctx->engine->newObject(klass));
+ {
+ bool needSparseArray = arrayGetterSetterCountAndFlags >> 30;
+ if (needSparseArray)
+ o->initSparseArray();
+ }
+
for (uint i = 0; i < klass->size; ++i) {
if (klass->propertyData[i].isData())
o->memberData[i].value = *args++;
ScopedValue entry(scope);
for (int i = 0; i < arrayValueCount; ++i) {
uint idx = args->toUInt32();
- if (idx > 16 && (!o->arrayData || idx > o->arrayData->length() * 2))
- o->initSparseArray();
++args;
entry = *args++;
o->arraySet(idx, entry);
}
ScopedProperty pd(scope);
- for (int i = 0; i < arrayGetterSetterCount; ++i) {
+ uint arrayGetterSetterCount = arrayGetterSetterCountAndFlags & ((1 << 30) - 1);
+ for (uint i = 0; i < arrayGetterSetterCount; ++i) {
uint idx = args->toUInt32();
- if (idx > 16 && (!o->arrayData || idx > o->arrayData->length() * 2))
- o->initSparseArray();
++args;
pd->value = *args;
++args;
ReturnedValue __qmljs_builtin_unwind_exception(ExecutionContext *ctx);
void __qmljs_builtin_declare_var(QV4::ExecutionContext *ctx, bool deletable, const QV4::StringRef name);
QV4::ReturnedValue __qmljs_builtin_define_array(QV4::ExecutionContext *ctx, Value *values, uint length);
-QV4::ReturnedValue __qmljs_builtin_define_object_literal(QV4::ExecutionContext *ctx, const QV4::Value *args, int classId, int arrayValueCount, int arrayGetterSetterCount);
+QV4::ReturnedValue __qmljs_builtin_define_object_literal(QV4::ExecutionContext *ctx, const QV4::Value *args, int classId, int arrayValueCount, int arrayGetterSetterCountAndFlags);
QV4::ReturnedValue __qmljs_builtin_setup_arguments_object(ExecutionContext *ctx);
void __qmljs_builtin_convert_this_to_object(ExecutionContext *ctx);
MOTH_BEGIN_INSTR(CallBuiltinDefineObjectLiteral)
QV4::Value *args = stack + instr.args;
- STOREVALUE(instr.result, __qmljs_builtin_define_object_literal(context, args, instr.internalClassId, instr.arrayValueCount, instr.arrayGetterSetterCount));
+ STOREVALUE(instr.result, __qmljs_builtin_define_object_literal(context, args, instr.internalClassId, instr.arrayValueCount, instr.arrayGetterSetterCountAndFlags));
MOTH_END_INSTR(CallBuiltinDefineObjectLiteral)
MOTH_BEGIN_INSTR(CallBuiltinSetupArgumentsObject)