Commit 5cf37c86 authored by mjs's avatar mjs

Separated Completion from Value and made it a pure stack

	object. This removed another 160,000 of the remaining 580,000
	garbage collected object allocations.

	6% speed increas on cvs-js-performance test.

        * kjs/completion.cpp: Added. New implementation that doesn't
	require a ValueImp *.
        (Completion::Completion):
        (Completion::complType):
        (Completion::value):
        (Completion::target):
        (Completion::isValueCompletion):
        * kjs/completion.h: Added.
        * kjs/function.cpp:
	(GlobalFuncImp::call): Removed some (apparently mistaken) uses of
	Completion as a Value.
        * kjs/internal.cpp:
        * kjs/internal.h:
        * kjs/types.cpp: Removed Completion stuff.
        * kjs/types.h: Removed Completion stuff.
        * JavaScriptCore.pbproj/project.pbxproj: Added new header.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1859 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 961ccb3b
2002-08-18 Maciej Stachowiak <mjs@apple.com>
Separated Completion from Value and made it a pure stack
object. This removed another 160,000 of the remaining 580,000
garbage collected object allocations.
6% speed increas on cvs-js-performance test.
* kjs/completion.cpp: Added. New implementation that doesn't
require a ValueImp *.
(Completion::Completion):
(Completion::complType):
(Completion::value):
(Completion::target):
(Completion::isValueCompletion):
* kjs/completion.h: Added.
* kjs/function.cpp:
(GlobalFuncImp::call): Removed some (apparently mistaken) uses of
Completion as a Value.
* kjs/internal.cpp:
* kjs/internal.h:
* kjs/types.cpp: Removed Completion stuff.
* kjs/types.h: Removed Completion stuff.
* JavaScriptCore.pbproj/project.pbxproj: Added new header.
2002-08-16 Darin Adler <darin@apple.com>
Fix the Development build.
......
2002-08-18 Maciej Stachowiak <mjs@apple.com>
Separated Completion from Value and made it a pure stack
object. This removed another 160,000 of the remaining 580,000
garbage collected object allocations.
6% speed increas on cvs-js-performance test.
* kjs/completion.cpp: Added. New implementation that doesn't
require a ValueImp *.
(Completion::Completion):
(Completion::complType):
(Completion::value):
(Completion::target):
(Completion::isValueCompletion):
* kjs/completion.h: Added.
* kjs/function.cpp:
(GlobalFuncImp::call): Removed some (apparently mistaken) uses of
Completion as a Value.
* kjs/internal.cpp:
* kjs/internal.h:
* kjs/types.cpp: Removed Completion stuff.
* kjs/types.h: Removed Completion stuff.
* JavaScriptCore.pbproj/project.pbxproj: Added new header.
2002-08-16 Darin Adler <darin@apple.com>
Fix the Development build.
......
2002-08-18 Maciej Stachowiak <mjs@apple.com>
Separated Completion from Value and made it a pure stack
object. This removed another 160,000 of the remaining 580,000
garbage collected object allocations.
6% speed increas on cvs-js-performance test.
* kjs/completion.cpp: Added. New implementation that doesn't
require a ValueImp *.
(Completion::Completion):
(Completion::complType):
(Completion::value):
(Completion::target):
(Completion::isValueCompletion):
* kjs/completion.h: Added.
* kjs/function.cpp:
(GlobalFuncImp::call): Removed some (apparently mistaken) uses of
Completion as a Value.
* kjs/internal.cpp:
* kjs/internal.h:
* kjs/types.cpp: Removed Completion stuff.
* kjs/types.h: Removed Completion stuff.
* JavaScriptCore.pbproj/project.pbxproj: Added new header.
2002-08-16 Darin Adler <darin@apple.com>
Fix the Development build.
......
......@@ -220,6 +220,7 @@
F50888B7030BB74C012A967E,
F54F0801030CD22001B5C2EB,
F5341393030CEEB1018BE7F3,
F5BB2BC7030F772101FCFE1D,
);
isa = PBXHeadersBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
......@@ -264,6 +265,7 @@
F5FFE657026B47A6018635CA,
F5341392030CEEB1018BE7F3,
F5341395030CF5F8018BE7F3,
F5BB2BC6030F772101FCFE1D,
);
isa = PBXSourcesBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
......@@ -320,6 +322,8 @@
F692A8510255597D01FF60F7,
F692A8520255597D01FF60F7,
F692A8530255597D01FF60F7,
F5BB2BC4030F772101FCFE1D,
F5BB2BC5030F772101FCFE1D,
F692A8550255597D01FF60F7,
F692A8560255597D01FF60F7,
F692A8570255597D01FF60F7,
......@@ -532,6 +536,33 @@
isa = PBXBuildStyle;
name = Mixed;
};
F5BB2BC4030F772101FCFE1D = {
isa = PBXFileReference;
name = completion.cpp;
path = kjs/completion.cpp;
refType = 4;
};
F5BB2BC5030F772101FCFE1D = {
isa = PBXFileReference;
name = completion.h;
path = kjs/completion.h;
refType = 4;
};
F5BB2BC6030F772101FCFE1D = {
fileRef = F5BB2BC4030F772101FCFE1D;
isa = PBXBuildFile;
settings = {
};
};
F5BB2BC7030F772101FCFE1D = {
fileRef = F5BB2BC5030F772101FCFE1D;
isa = PBXBuildFile;
settings = {
ATTRIBUTES = (
Private,
);
};
};
F5C290E50284F960018635CA = {
children = (
F692A8540255597D01FF60F7,
......
// -*- c-basic-offset: 2 -*-
/*
* This file is part of the KDE libraries
* Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
* Copyright (C) 2001 Peter Kelly (pmk@post.com)
* Copyright (C) 2002 Apple Computer, Inc
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#include "completion.h"
using namespace KJS;
// ------------------------------ Completion -----------------------------------
Completion::Completion(ComplType c, const Value& v, const UString &t)
: comp(c), val(v), tar(t)
{
}
ComplType Completion::complType() const
{
return comp;
}
Value Completion::value() const
{
return val;
}
UString Completion::target() const
{
return tar;
}
bool Completion::isValueCompletion() const
{
return val.isNull();
}
// -*- c-basic-offset: 2 -*-
/*
* This file is part of the KDE libraries
* Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
* Copyright (C) 2001 Peter Kelly (pmk@post.com)
* Copyright (C) 2002 Apple Computer, Inc
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#ifndef _KJS_COMPLETION_H_
#define _KJS_COMPLETION_H_
#include "value.h"
namespace KJS {
/**
* Completion types.
*/
enum ComplType { Normal, Break, Continue, ReturnValue, Throw };
/**
* Completion objects are used to convey the return status and value
* from functions.
*
* See @ref FunctionImp::execute()
*
* @see FunctionImp
*
* @short Handle for a Completion type.
*/
class Completion : private Value {
public:
Completion(ComplType c = Normal, const Value& v = Value(),
const UString &t = UString::null);
Completion(CompletionImp *v);
ComplType complType() const;
Value value() const;
UString target() const;
bool isValueCompletion() const;
private:
ComplType comp;
Value val;
UString tar;
};
}
#endif
......@@ -416,7 +416,7 @@ Value GlobalFuncImp::call(ExecState *exec, Object &/*thisObj*/, const List &args
if ( progNode->deref() )
delete progNode;
if (c.complType() == ReturnValue)
return c;
return c.value();
// ### setException() on throw?
else if (c.complType() == Normal) {
if (c.isValueCompletion())
......@@ -424,7 +424,7 @@ Value GlobalFuncImp::call(ExecState *exec, Object &/*thisObj*/, const List &args
else
return Undefined();
} else {
return c;
return Undefined();
}
}
break;
......
......@@ -331,60 +331,6 @@ void LabelStack::clear()
}
}
// ------------------------------ CompletionImp --------------------------------
CompletionImp::CompletionImp(ComplType c, const Value& v, const UString& t)
: comp(c), val(v.imp()), tar(t)
{
}
CompletionImp::~CompletionImp()
{
}
void CompletionImp::mark()
{
ValueImp::mark();
if (val && !val->marked())
val->mark();
}
Value CompletionImp::toPrimitive(ExecState */*exec*/, Type /*preferredType*/) const
{
// invalid for Completion
assert(false);
return Value();
}
bool CompletionImp::toBoolean(ExecState */*exec*/) const
{
// invalid for Completion
assert(false);
return false;
}
double CompletionImp::toNumber(ExecState */*exec*/) const
{
// invalid for Completion
assert(false);
return 0;
}
UString CompletionImp::toString(ExecState */*exec*/) const
{
// invalid for Completion
assert(false);
return UString::null;
}
Object CompletionImp::toObject(ExecState */*exec*/) const
{
// invalid for Completion
assert(false);
return Object();
}
// ------------------------------ ListImp --------------------------------------
#ifdef KJS_DEBUG_MEM
......
......@@ -142,32 +142,6 @@ namespace KJS {
// Internal type impls
// ---------------------------------------------------------------------------
class CompletionImp : public ValueImp {
public:
Type type() const { return CompletionType; }
CompletionImp(ComplType c, const Value& v, const UString& t);
virtual ~CompletionImp();
virtual void mark();
Value toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
bool toBoolean(ExecState *exec) const;
double toNumber(ExecState *exec) const;
UString toString(ExecState *exec) const;
Object toObject(ExecState *exec) const;
ComplType complType() const { return comp; }
Value value() const { return Value(val); }
UString target() const { return tar; }
private:
ComplType comp;
ValueImp * val;
UString tar;
};
inline Completion::Completion(CompletionImp *imp) : Value(imp) { }
/**
* @internal
*/
......
......@@ -203,38 +203,3 @@ void List::globalClear()
}
#endif
// ------------------------------ Completion -----------------------------------
Completion::Completion(ComplType c, const Value& v, const UString &t)
: Value(new CompletionImp(c,v,t))
{
}
Completion Completion::dynamicCast(const Value &v)
{
if (v.isNull() || v.type() != CompletionType)
return 0;
return static_cast<CompletionImp*>(v.imp());
}
ComplType Completion::complType() const
{
return static_cast<CompletionImp*>(rep)->complType();
}
Value Completion::value() const
{
return static_cast<CompletionImp*>(rep)->value();
}
UString Completion::target() const
{
return static_cast<CompletionImp*>(rep)->target();
}
bool Completion::isValueCompletion() const
{
return !value().isNull();
}
......@@ -27,6 +27,8 @@
// internal data types
#include "value.h"
#include "reference.h"
#include "completion.h"
namespace KJS {
......@@ -199,44 +201,6 @@ namespace KJS {
#endif
};
/**
* Completion types.
*/
enum ComplType { Normal, Break, Continue, ReturnValue, Throw };
/**
* Completion objects are used to convey the return status and value
* from functions.
*
* See @ref FunctionImp::execute()
*
* @see FunctionImp
*
* @short Handle for a Completion type.
*/
class Completion : public Value {
public:
Completion(ComplType c = Normal, const Value& v = Value(),
const UString &t = UString::null);
Completion(CompletionImp *v);
/**
* Converts a Value into an Completion. If the value's type is not
* CompletionType, a null object will be returned (i.e. one with it's
* internal pointer set to 0). If you do not know for sure whether the
* value is of type CompletionType, you should check the @ref isNull()
* methods afterwards before calling any methods on the returned value.
*
* @return The value converted to an Completion
*/
static Completion dynamicCast(const Value &v);
ComplType complType() const;
Value value() const;
UString target() const;
bool isValueCompletion() const;
};
}; // namespace
#endif // _KJS_TYPES_H_
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment