Use indices into the runtime functions array instead of function pointers in the...
authorSimon Hausmann <simon.hausmann@digia.com>
Fri, 16 Aug 2013 19:04:15 +0000 (21:04 +0200)
committerLars Knoll <lars.knoll@digia.com>
Fri, 16 Aug 2013 19:36:48 +0000 (21:36 +0200)
Change-Id: Ieaf7b112f80adc3f1041cb1397db4eab55fb0184
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/qml/compiler/qv4instr_moth_p.h
src/qml/compiler/qv4isel_masm.cpp
src/qml/compiler/qv4isel_moth.cpp
src/qml/jsruntime/qv4runtime.cpp
src/qml/jsruntime/qv4runtime_p.h

index 642e6f4..5cdfa3f 100644 (file)
@@ -237,7 +237,7 @@ union Instr
     };
     struct instr_loadClosure {
         MOTH_INSTR_HEADER
-        QV4::Function *value;
+        int value;
         Param result;
     };
     struct instr_loadName {
index e0b79ac..8dbf0b9 100644 (file)
@@ -1070,9 +1070,8 @@ void InstructionSelection::setActivationProperty(V4IR::Temp *source, const QStri
 
 void InstructionSelection::initClosure(V4IR::Closure *closure, V4IR::Temp *target)
 {
-    QV4::Function *vmFunc = _irToVM[closure->value];
-    assert(vmFunc);
-    generateFunctionCall(Assembler::Void, __qmljs_init_closure, Assembler::ContextRegister, Assembler::PointerToValue(target), Assembler::TrustedImmPtr(vmFunc));
+    int id = jsUnitGenerator.irModule->functions.indexOf(closure->value);
+    generateFunctionCall(Assembler::Void, __qmljs_init_closure, Assembler::ContextRegister, Assembler::PointerToValue(target), Assembler::TrustedImm32(id));
 }
 
 void InstructionSelection::getProperty(V4IR::Temp *base, const QString &name, V4IR::Temp *target)
index cbf7b48..523d426 100644 (file)
@@ -430,10 +430,9 @@ void InstructionSelection::setActivationProperty(V4IR::Temp *source, const QStri
 
 void InstructionSelection::initClosure(V4IR::Closure *closure, V4IR::Temp *target)
 {
-    QV4::Function *vmFunc = _irToVM[closure->value];
-    assert(vmFunc);
+    int id = jsUnitGenerator.irModule->functions.indexOf(closure->value);
     Instruction::LoadClosure load;
-    load.value = vmFunc;
+    load.value = id;
     load.result = getResultParam(target);
     addInstruction(load);
 }
index 3e0cf9a..d34e3d5 100644 (file)
@@ -118,8 +118,10 @@ void __qmljs_numberToString(QString *result, double num, int radix)
         result->prepend(QLatin1Char('-'));
 }
 
-void __qmljs_init_closure(ExecutionContext *ctx, Value *result, Function *clos)
+void __qmljs_init_closure(ExecutionContext *ctx, Value *result, int functionId)
 {
+    const QV4::Function *runtimeFunction = ctx->runtimeFunction();
+    QV4::Function *clos = runtimeFunction->compilationUnit->runtimeFunctions[functionId];
     assert(clos);
     *result = Value::fromObject(ctx->engine->newScriptFunction(ctx, clos));
 }
index ba6681e..c018509 100644 (file)
@@ -130,7 +130,7 @@ void __qmljs_value_from_string(QV4::Value *result, QV4::String *string);
 void __qmljs_lookup_runtime_regexp(QV4::ExecutionContext *ctx, QV4::Value *result, int id);
 
 // constructors
-void __qmljs_init_closure(QV4::ExecutionContext *ctx, QV4::Value *result, QV4::Function *clos);
+void __qmljs_init_closure(QV4::ExecutionContext *ctx, QV4::Value *result, int functionId);
 
 // strings
 Q_QML_EXPORT double __qmljs_string_to_number(const QString &s);