source: webkit/trunk/JavaScriptCore/kjs/PropertySlot.cpp@ 34945

Last change on this file since 34945 was 34945, checked in by [email protected], 17 years ago

2008-07-01 Geoffrey Garen <[email protected]>

Reviewed by Oliver Hunt.


Removed and/or reordered exception checks in array-style a[n] access.


SunSpider says 1.4% faster.

  • VM/Machine.cpp: (KJS::Machine::privateExecute): No need to check for exceptions before calling toString, toNumber and/or get. If the call ends up being observable through toString, valueOf, or a getter, we short-circuit it there, instead. In the op_del_by_val case, I removed the incorrect comment without actually removing the code, since I didn't want to tempt the GCC fates!
  • kjs/JSObject.cpp: (KJS::callDefaultValueFunction): Added exception check to prevent toString and valueOf functions from observing execution after an exception has been thrown. This removes some of the burden of exception checking from the machine.

(KJS::JSObject::defaultValue): Removed redundant exception check here.

  • kjs/PropertySlot.cpp: (KJS::PropertySlot::functionGetter): Added exception check to prevent getter functions from observing execution after an exception has been thrown. This removes some of the burden of exception checking from the machine.
  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1// -*- c-basic-offset: 4 -*-
2/*
3 * Copyright (C) 2005, 2008 Apple Inc. All rights reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 *
20 */
21
22
23#include "config.h"
24#include "PropertySlot.h"
25
26#include "JSFunction.h"
27#include "JSGlobalObject.h"
28#include "JSObject.h"
29
30namespace KJS {
31
32JSValue* PropertySlot::undefinedGetter(ExecState*, const Identifier&, const PropertySlot&)
33{
34 return jsUndefined();
35}
36
37JSValue* PropertySlot::functionGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
38{
39 // Prevent getter functions from observing execution if an exception is pending.
40 if (exec->hadException())
41 return exec->exception();
42
43 CallData callData;
44 CallType callType = slot.m_data.getterFunc->getCallData(callData);
45 if (callType == CallTypeNative)
46 return callData.native.function(exec, slot.m_data.getterFunc, slot.slotBase(), exec->emptyList());
47 ASSERT(callType == CallTypeJS);
48 // FIXME: Can this be done more efficiently using the callData?
49 return static_cast<JSFunction*>(slot.m_data.getterFunc)->call(exec, slot.slotBase(), exec->emptyList());
50}
51
52} // namespace KJS
Note: See TracBrowser for help on using the repository browser.