aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp13
-rw-r--r--src/qml/jsruntime/qv4functionobject_p.h5
-rw-r--r--src/qml/jsruntime/qv4object.cpp4
-rw-r--r--tests/auto/qml/ecmascripttests/TestExpectations2
4 files changed, 13 insertions, 11 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index 9523f59018..8722ff65b6 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -469,7 +469,7 @@ ReturnedValue ScriptFunction::virtualCallAsConstructor(const FunctionObject *fo,
if (nt->d() == f->d()) {
ic = f->classForConstructor();
} else {
- const Object *o = nt->d()->protoProperty();
+ ScopedObject o(scope, nt->protoProperty());
ic = scope.engine->internalClasses(EngineBase::Class_Object);
if (o)
ic = ic->changePrototype(o->d());
@@ -537,14 +537,15 @@ void Heap::ScriptFunction::init(QV4::ExecutionContext *scope, Function *function
Heap::InternalClass *ScriptFunction::classForConstructor() const
{
- const Object *o = d()->protoProperty();
- if (d()->cachedClassForConstructor && d()->cachedClassForConstructor->prototype == o->d())
+ Scope scope(engine());
+ ScopedValue o(scope, protoProperty());
+ if (d()->cachedClassForConstructor && d()->cachedClassForConstructor->prototype == o->heapObject())
return d()->cachedClassForConstructor;
- Scope scope(engine());
Scoped<InternalClass> ic(scope, engine()->internalClasses(EngineBase::Class_Object));
- if (o)
- ic = ic->changePrototype(o->d());
+ ScopedObject p(scope, o);
+ if (p)
+ ic = ic->changePrototype(p->d());
d()->cachedClassForConstructor.set(scope.engine, ic->d());
return ic->d();
diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h
index ba1146af37..a9ffa90b90 100644
--- a/src/qml/jsruntime/qv4functionobject_p.h
+++ b/src/qml/jsruntime/qv4functionobject_p.h
@@ -91,8 +91,6 @@ DECLARE_HEAP_OBJECT(FunctionObject, Object) {
unsigned int formalParameterCount() { return function ? function->nFormals : 0; }
unsigned int varCount() { return function ? function->compiledFunction->nLocals : 0; }
-
- const QV4::Object *protoProperty() const { return propertyData(Index_Prototype)->as<QV4::Object>(); }
};
struct FunctionCtor : FunctionObject {
@@ -190,6 +188,9 @@ struct Q_QML_EXPORT FunctionObject: Object {
bool isBinding() const;
bool isBoundFunction() const;
+ ReturnedValue protoProperty() const { return get(engine()->id_prototype()); }
+
+
QQmlSourceLocation sourceLocation() const;
};
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp
index 718bfbe5ec..701c22331d 100644
--- a/src/qml/jsruntime/qv4object.cpp
+++ b/src/qml/jsruntime/qv4object.cpp
@@ -742,8 +742,10 @@ ReturnedValue Object::virtualInstanceOf(const Object *typeObject, const Value &v
if (!lhs)
return Encode(false);
+ Scope scope(f->internalClass->engine);
// 15.3.5.3, 2
- const Object *o = f->protoProperty();
+ ScopedFunctionObject ff(scope, f);
+ ScopedObject o(scope, ff->protoProperty());
if (!o) // 15.3.5.3, 3
return engine->throwTypeError();
diff --git a/tests/auto/qml/ecmascripttests/TestExpectations b/tests/auto/qml/ecmascripttests/TestExpectations
index d536833ae6..5e14120da0 100644
--- a/tests/auto/qml/ecmascripttests/TestExpectations
+++ b/tests/auto/qml/ecmascripttests/TestExpectations
@@ -2098,8 +2098,6 @@ language/expressions/generators/yield-as-literal-property-name.js fails
language/expressions/generators/yield-as-property-name.js fails
language/expressions/generators/yield-identifier-non-strict.js sloppyFails
language/expressions/generators/yield-star-before-newline.js fails
-language/expressions/instanceof/prototype-getter-with-object-throws.js fails
-language/expressions/instanceof/prototype-getter-with-object.js fails
language/expressions/logical-and/tco-right.js strictFails
language/expressions/logical-or/tco-right.js strictFails
language/expressions/new.target/value-via-reflect-construct.js fails