Commit b26080de authored by darin's avatar darin

Reviewed by Maciej.

        - http://bugs.webkit.org/show_bug.cgi?id=15579
          stop churning identifier reference counts copying Completion objects

        * kjs/completion.h: Replace the Identifier with an Identifier*.
        * kjs/nodes.cpp:
        (ForInNode::execute): Update for change to Completion constructor.
        (ContinueNode::execute): Ditto.
        (BreakNode::execute): Ditto.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@26832 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9177ecfd
2007-10-20 Darin Adler <darin@apple.com>
Reviewed by Maciej.
- http://bugs.webkit.org/show_bug.cgi?id=15579
stop churning identifier reference counts copying Completion objects
* kjs/completion.h: Replace the Identifier with an Identifier*.
* kjs/nodes.cpp:
(ForInNode::execute): Update for change to Completion constructor.
(ContinueNode::execute): Ditto.
(BreakNode::execute): Ditto.
2007-10-20 Mark Rowe <mrowe@apple.com> 2007-10-20 Mark Rowe <mrowe@apple.com>
Reviewed by Alp. Reviewed by Alp.
......
// -*- c-basic-offset: 2 -*- // -*- c-basic-offset: 2 -*-
/* /*
* This file is part of the KDE libraries
* Copyright (C) 1999-2001 Harri Porten (porten@kde.org) * Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
* Copyright (C) 2001 Peter Kelly (pmk@post.com) * Copyright (C) 2001 Peter Kelly (pmk@post.com)
* Copyright (C) 2003 Apple Computer, Inc * Copyright (C) 2003, 2007 Apple Inc. All rights reserved.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Library General Public
...@@ -22,17 +21,14 @@ ...@@ -22,17 +21,14 @@
* *
*/ */
#ifndef _KJS_COMPLETION_H_ #ifndef KJS_COMPLETION_H
#define _KJS_COMPLETION_H_ #define KJS_COMPLETION_H
#include "CommonIdentifiers.h"
#include "value.h"
namespace KJS { namespace KJS {
/** class Identifier;
* Completion types. class JSValue;
*/
enum ComplType { Normal, Break, Continue, ReturnValue, Throw, Interrupted }; enum ComplType { Normal, Break, Continue, ReturnValue, Throw, Interrupted };
/** /**
...@@ -47,18 +43,21 @@ namespace KJS { ...@@ -47,18 +43,21 @@ namespace KJS {
*/ */
class Completion { class Completion {
public: public:
Completion(ComplType c = Normal, JSValue *v = NULL, const Identifier &t = CommonIdentifiers::shared()->nullIdentifier) Completion(ComplType type = Normal, JSValue* value = 0)
: comp(c), val(v), tar(t) { } : m_type(type), m_value(value), m_target(0) { }
Completion(ComplType type, const Identifier* target)
: m_type(type), m_value(0), m_target(target) { }
ComplType complType() const { return m_type; }
JSValue* value() const { return m_value; }
void setValue(JSValue* v) { m_value = v; }
const Identifier& target() const { return *m_target; }
bool isValueCompletion() const { return !!m_value; }
ComplType complType() const { return comp; }
JSValue *value() const { return val; }
void setValue(JSValue* v) { val = v; }
Identifier target() const { return tar; }
bool isValueCompletion() const { return !!val; }
private: private:
ComplType comp; ComplType m_type;
JSValue *val; JSValue* m_value;
Identifier tar; const Identifier* m_target;
}; };
} }
......
...@@ -1998,9 +1998,8 @@ Completion ForInNode::execute(ExecState *exec) ...@@ -1998,9 +1998,8 @@ Completion ForInNode::execute(ExecState *exec)
// the loop at all, because their object wrappers will have a // the loop at all, because their object wrappers will have a
// property list but will throw an exception if you attempt to // property list but will throw an exception if you attempt to
// access any property. // access any property.
if (e->isUndefinedOrNull()) { if (e->isUndefinedOrNull())
return Completion(Normal, 0); return Completion(Normal);
}
KJS_CHECKEXCEPTION KJS_CHECKEXCEPTION
v = e->toObject(exec); v = e->toObject(exec);
...@@ -2090,10 +2089,9 @@ Completion ContinueNode::execute(ExecState *exec) ...@@ -2090,10 +2089,9 @@ Completion ContinueNode::execute(ExecState *exec)
if (ident.isEmpty() && !exec->context()->inIteration()) if (ident.isEmpty() && !exec->context()->inIteration())
return createErrorCompletion(exec, SyntaxError, "Invalid continue statement."); return createErrorCompletion(exec, SyntaxError, "Invalid continue statement.");
else if (!ident.isEmpty() && !exec->context()->seenLabels()->contains(ident)) if (!ident.isEmpty() && !exec->context()->seenLabels()->contains(ident))
return createErrorCompletion(exec, SyntaxError, "Label %s not found.", ident); return createErrorCompletion(exec, SyntaxError, "Label %s not found.", ident);
else return Completion(Continue, &ident);
return Completion(Continue, 0, ident);
} }
// ------------------------------ BreakNode ------------------------------------ // ------------------------------ BreakNode ------------------------------------
...@@ -2106,10 +2104,9 @@ Completion BreakNode::execute(ExecState *exec) ...@@ -2106,10 +2104,9 @@ Completion BreakNode::execute(ExecState *exec)
if (ident.isEmpty() && !exec->context()->inIteration() && if (ident.isEmpty() && !exec->context()->inIteration() &&
!exec->context()->inSwitch()) !exec->context()->inSwitch())
return createErrorCompletion(exec, SyntaxError, "Invalid break statement."); return createErrorCompletion(exec, SyntaxError, "Invalid break statement.");
else if (!ident.isEmpty() && !exec->context()->seenLabels()->contains(ident)) if (!ident.isEmpty() && !exec->context()->seenLabels()->contains(ident))
return createErrorCompletion(exec, SyntaxError, "Label %s not found."); return createErrorCompletion(exec, SyntaxError, "Label %s not found.");
else return Completion(Break, &ident);
return Completion(Break, 0, ident);
} }
// ------------------------------ ReturnNode ----------------------------------- // ------------------------------ ReturnNode -----------------------------------
......
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