#include "qv4syntaxchecker_p.h"
#include "qv4ecmaobjects_p.h"
#include "qv4isel_p.h"
-#include "qv4mm_moth.h"
+#include "qv4mm.h"
#include <QtCore>
#include <private/qqmljsengine_p.h>
#endif // QMLJS_NO_LLVM
case use_masm:
case use_moth: {
- QScopedPointer<QQmlJS::VM::MemoryManager> mm;
+ QScopedPointer<QQmlJS::VM::MemoryManager> mm(new QQmlJS::VM::MemoryManagerWithNativeStack);
QScopedPointer<QQmlJS::EvalISelFactory> iSelFactory;
if (mode == use_moth) {
- mm.reset(new QQmlJS::Moth::MemoryManager);
iSelFactory.reset(new QQmlJS::Moth::ISelFactory);
} else {
- mm.reset(new QQmlJS::VM::MemoryManagerWithNativeStack);
iSelFactory.reset(new QQmlJS::MASM::ISelFactory);
}
HEADERS += \
$$PWD/qv4isel_moth_p.h \
$$PWD/qv4instr_moth_p.h \
- $$PWD/qv4vme_moth_p.h \
- $$PWD/qv4mm_moth.h
+ $$PWD/qv4vme_moth_p.h
SOURCES += \
$$PWD/qv4isel_moth.cpp \
$$PWD/qv4instr_moth.cpp \
- $$PWD/qv4vme_moth.cpp \
- $$PWD/qv4mm_moth.cpp
+ $$PWD/qv4vme_moth.cpp
#DEFINES += DO_TRACE_INSTR
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#include "qmljs_engine.h"
-#include "qv4mm_moth.h"
-
-#include <QList>
-
-using namespace QQmlJS;
-using namespace QQmlJS::Moth;
-
-MemoryManager::MemoryManager()
-{
- stackFrames.reserve(64);
-}
-
-MemoryManager::~MemoryManager()
-{
-}
-
-VM::Value *MemoryManager::allocStackFrame(std::size_t frameSize)
-{
- std::size_t size = frameSize * sizeof(VM::Value);
- MMObject *m = alloc(align(size));
- stackFrames.append(m);
- return reinterpret_cast<VM::Value *>(&m->data);
-}
-
-void MemoryManager::deallocStackFrame(VM::Value *stackFrame)
-{
- MMObject *o = toObject(stackFrame);
- for (int i = stackFrames.size() - 1; i >= 0; --i) {
- if (stackFrames[i] == o) {
- stackFrames.remove(i);
- dealloc(o);
- return;
- }
- }
-
- Q_UNREACHABLE();
-}
-
-void MemoryManager::collectRootsOnStack(QVector<VM::Object *> &roots) const
-{
- for (int i = 0, ei = stackFrames.size(); i < ei; ++i) {
- MMObject *m = stackFrames[i];
- VM::Value *frame = reinterpret_cast<VM::Value *>(&m->data);
- std::size_t frameSize = (m->info.size - align(sizeof(MMInfo))) / sizeof(VM::Value);
- for (std::size_t j = 0; j < frameSize; ++j) {
- if (VM::Object *o = frame[j].asObject()) {
- roots.append(o);
- }
- }
- }
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#ifndef QV4GC_MOTH_H
-#define QV4GC_MOTH_H
-
-#include "qv4mm.h"
-
-#include <QVector>
-
-namespace QQmlJS {
-namespace Moth {
-
-class MemoryManager: public QQmlJS::VM::MemoryManager
-{
-public:
- MemoryManager();
- ~MemoryManager();
-
- VM::Value *allocStackFrame(std::size_t frameSize);
- void deallocStackFrame(VM::Value *stackFrame);
-
-protected:
- virtual void collectRootsOnStack(QVector<VM::Object *> &roots) const;
-
-private:
- QVector<MMObject *> stackFrames;
-};
-
-} // namespace Moth
-} // namespace QQmlJS
-
-#endif // QV4GC_MOTH_H
#include "qv4instr_moth_p.h"
#include "qmljs_value.h"
#include "debugging.h"
-#include "qv4mm_moth.h"
#include <iostream>
+#include <alloca.h>
+
#ifdef DO_TRACE_INSTR
# define TRACE_INSTR(I) fprintf(stderr, "executing a %s\n", #I);
# define TRACE(n, str, ...) { char buf[4096]; snprintf(buf, 4096, str, __VA_ARGS__); fprintf(stderr, " %s : %s\n", #n, buf); }
, code(code)
{}
- ~FunctionState()
- { if (stack) static_cast<MemoryManager *>(context()->engine->memoryManager)->deallocStackFrame(stack); }
-
virtual VM::Value *temp(unsigned idx) { return stack + idx; }
void setStack(VM::Value *stack, unsigned stackSize)
MOTH_BEGIN_INSTR(Push)
TRACE(inline, "stack size: %u", instr.value);
stackSize = instr.value;
- stack = static_cast<MemoryManager *>(context->engine->memoryManager)->allocStackFrame(stackSize);
+ stack = static_cast<VM::Value *>(alloca(stackSize * sizeof(VM::Value)));
state.setStack(stack, stackSize);
MOTH_END_INSTR(Push)