source: webkit/trunk/JavaScriptCore/kjs/JSFunction.h@ 37799

Last change on this file since 37799 was 37799, checked in by Darin Adler, 17 years ago

JavaScriptCore:

2008-10-22 Darin Adler <Darin Adler>

Reviewed by Sam Weinig.

A bit over 3% faster on V8 tests.

  • JavascriptCore.exp: Export leak-related functions..
  • API/JSCallbackConstructor.h: (JSC::JSCallbackConstructor::createStructureID): Set HasStandardGetOwnPropertySlot since this class doesn't override getPropertySlot.
  • API/JSCallbackFunction.h: (JSC::JSCallbackFunction::createStructureID): Ditto.
  • VM/ExceptionHelpers.cpp: (JSC::InterruptedExecutionError::InterruptedExecutionError): Use a structure that's created just for this class instead of trying to share a single "null prototype" structure.
  • VM/Machine.cpp: (JSC::Machine::cti_op_create_arguments_no_params): Rename Arguments::ArgumentsNoParameters to Arguments::NoParameters.


  • kjs/Arguments.h: Rename the enum from Arguments::ArgumentsParameters to Arguments::NoParametersType and the value from Arguments::ArgumentsNoParameters to Arguments::NoParameters. (JSC::Arguments::createStructureID): Added. Returns a structure without HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot. (JSC::Arguments::Arguments): Added an assertion that there are no parameters.
  • kjs/DatePrototype.h: (JSC::DatePrototype::createStructureID): Added. Returns a structure without HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
  • kjs/FunctionPrototype.h: (JSC::FunctionPrototype::createStructureID): Set HasStandardGetOwnPropertySlot since this class doesn't override getPropertySlot.
  • kjs/InternalFunction.h: (JSC::InternalFunction::createStructureID): Ditto.
  • kjs/JSArray.h: (JSC::JSArray::createStructureID): Added. Returns a structure without HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
  • kjs/JSCell.h: Added declaration of fastGetOwnPropertySlot; a non-virtual version that uses the structure bit to decide whether to call the virtual version.
  • kjs/JSFunction.h: (JSC::JSFunction::createStructureID): Added. Returns a structure without HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
  • kjs/JSGlobalData.cpp: (JSC::JSGlobalData::JSGlobalData): Initialize new structures; removed nullProtoStructureID.
  • kjs/JSGlobalData.h: Added new structures. Removed nullProtoStructureID.
  • kjs/JSGlobalObject.h: (JSC::JSGlobalObject::createStructureID): Added. Returns a structure without HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
  • kjs/JSNotAnObject.h: (JSC::JSNotAnObjectErrorStub::JSNotAnObjectErrorStub): Use a structure that's created just for this class instead of trying to share a single "null prototype" structure. (JSC::JSNotAnObjectErrorStub::isNotAnObjectErrorStub): Marked this function virtual for clarity and made it private since no one should call it if they already have a pointer to this specific type. (JSC::JSNotAnObject::JSNotAnObject): Use a structure that's created just for this class instead of trying to share a single "null prototype" structure. (JSC::JSNotAnObject::createStructureID): Added. Returns a structure without HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
  • kjs/JSObject.h: (JSC::JSObject::createStructureID): Added HasStandardGetOwnPropertySlot. (JSC::JSObject::inlineGetOwnPropertySlot): Added. Used so we can share code between getOwnPropertySlot and fastGetOwnPropertySlot. (JSC::JSObject::getOwnPropertySlot): Moved so that functions are above the functions that call them. Moved the guts of this function into inlineGetOwnPropertySlot. (JSC::JSCell::fastGetOwnPropertySlot): Added. Checks the HasStandardGetOwnPropertySlot bit and if it's set, calls inlineGetOwnPropertySlot, otherwise calls getOwnPropertySlot. (JSC::JSObject::getPropertySlot): Changed to call fastGetOwnPropertySlot. (JSC::JSValue::get): Changed to call fastGetOwnPropertySlot.
  • kjs/JSWrapperObject.h: Made constructor protected to emphasize that this class is only a base class and never instantiated.
  • kjs/MathObject.h: (JSC::MathObject::createStructureID): Added. Returns a structure without HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
  • kjs/NumberConstructor.h: (JSC::NumberConstructor::createStructureID): Ditto.
  • kjs/RegExpConstructor.h: (JSC::RegExpConstructor::createStructureID): Ditto.
  • kjs/RegExpObject.h: (JSC::RegExpObject::createStructureID): Ditto.
  • kjs/StringObject.h: (JSC::StringObject::createStructureID): Ditto.
  • kjs/TypeInfo.h: Added HasStandardGetOwnPropertySlot flag and hasStandardGetOwnPropertySlot accessor function.

JavaScriptGlue:

2008-10-22 Darin Adler <Darin Adler>

Reviewed by Sam Weinig.

  • JSRun.cpp: (JSGlueGlobalObject::JSGlueGlobalObject): Moved constructor here. Set up flags in its new location in global object data, and set up a structure for UserObjectImp too. (JSRun::JSRun): Added code to give the JSGlueGlobalObject its own unique structure, rather than using the default one from JSGlobalObject.
  • JSRun.h: Made JSGlueGlobalObject take a structure ID. Also moved the data into a separate data object. And added userObjectStructure, a Structure to be used by UserObjectImp.
  • JSUtils.cpp: Removed unused sharedGlobalData global. (JSObjectKJSValue): Pass Structure in when creating UserObjectImp. (unprotectGlobalObject): Use JSGlueGLobalObject type specifically. (initializeGlobalObjectKey): Removed code to set up unused sharedGlobalData. (getThreadGlobalObject): Added. Shared by JSObjectKJSValue and getThreadGlobalExecState. Also now passes in a structure ID when creating the global object. (getThreadGlobalExecState): Changed to call getThreadGlobalObject.
  • UserObjectImp.cpp: (UserObjectImp::UserObjectImp): Changed to take a structure.
  • UserObjectImp.h: (UserObjectImp::createStructureID): Added. Returns a structure without HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.

WebCore:

2008-10-22 Darin Adler <Darin Adler>

Reviewed by Sam Weinig.

  • bindings/js/JSDOMWindowShell.h: (WebCore::JSDOMWindowShell::createStructureID): Added. Returns a structure without HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
  • bindings/js/JSInspectorCallbackWrapper.cpp: (WebCore::JSInspectorCallbackWrapper::wrap): Change to use a unique structure for this class rather than sharing nullProtoStructureID, which no longer exists.
  • bindings/js/JSNamedNodesCollection.h: (WebCore::JSNamedNodesCollection::createStructureID): Added. Returns a structure without HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
  • bindings/js/JSRGBColor.h: (WebCore::JSRGBColor::createStructureID): Ditto.
  • bindings/scripts/CodeGeneratorJS.pm: Added createStructureID functions for the wrappers, constructors, and prototypes in any case where they override getOwnPropertySlot, without HasStandardGetOwnPropertySlot.
  • bridge/objc/objc_runtime.h: (JSC::Bindings::ObjcFallbackObjectImp::createStructureID): Added. Returns a structure without HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
  • bridge/qt/qt_runtime.h: (JSC::Bindings::QtRuntimeMethod::createStructureID): Ditto.
  • bridge/runtime_array.h: (JSC::RuntimeArray::createStructureID): Ditto.
  • bridge/runtime_method.h: (JSC::RuntimeMethod::createStructureID): Ditto.
  • bridge/runtime_object.h: (JSC::RuntimeObjectImp::createStructureID): Ditto.
  • Property svn:eol-style set to native
File size: 3.5 KB
Line 
1/*
2 * Copyright (C) 1999-2000 Harri Porten ([email protected])
3 * Copyright (C) 2003, 2006, 2007, 2008 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Cameron Zwarich ([email protected])
5 * Copyright (C) 2007 Maks Orlovich
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 *
22 */
23
24#ifndef JSFunction_h
25#define JSFunction_h
26
27#include "InternalFunction.h"
28#include "JSVariableObject.h"
29#include "SymbolTable.h"
30#include "nodes.h"
31#include "JSObject.h"
32
33namespace JSC {
34
35 class FunctionBodyNode;
36 class FunctionPrototype;
37 class JSActivation;
38 class JSGlobalObject;
39
40 class JSFunction : public InternalFunction {
41 friend class CTI;
42 friend class Machine;
43
44 typedef InternalFunction Base;
45 JSFunction(PassRefPtr<JSC::StructureID> st) : InternalFunction(st), m_scopeChain(NoScopeChain()) {}
46 public:
47 JSFunction(ExecState*, const Identifier&, FunctionBodyNode*, ScopeChainNode*);
48 ~JSFunction();
49
50 virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
51 virtual void put(ExecState*, const Identifier& propertyName, JSValuePtr, PutPropertySlot&);
52 virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
53
54 JSObject* construct(ExecState*, const ArgList&);
55 JSValuePtr call(ExecState*, JSValuePtr thisValue, const ArgList&);
56
57 // Note: Returns a null identifier for any parameters that will never get set
58 // due to a later parameter with the same name.
59 const Identifier& getParameterName(int index);
60
61 void setScope(const ScopeChain& scopeChain) { m_scopeChain = scopeChain; }
62 ScopeChain& scope() { return m_scopeChain; }
63
64 virtual void mark();
65
66 static const ClassInfo info;
67
68 // FIXME: This should be private
69 RefPtr<FunctionBodyNode> m_body;
70
71 static PassRefPtr<StructureID> createStructureID(JSValuePtr prototype)
72 {
73 return StructureID::create(prototype, TypeInfo(ObjectType, ImplementsHasInstance));
74 }
75
76 private:
77 virtual const ClassInfo* classInfo() const { return &info; }
78
79 virtual ConstructType getConstructData(ConstructData&);
80 virtual CallType getCallData(CallData&);
81
82 static JSValuePtr argumentsGetter(ExecState*, const Identifier&, const PropertySlot&);
83 static JSValuePtr callerGetter(ExecState*, const Identifier&, const PropertySlot&);
84 static JSValuePtr lengthGetter(ExecState*, const Identifier&, const PropertySlot&);
85
86 ScopeChain m_scopeChain;
87 };
88
89 JSFunction* asFunction(JSValuePtr);
90
91 inline JSFunction* asFunction(JSValuePtr value)
92 {
93 ASSERT(asObject(value)->inherits(&JSFunction::info));
94 return static_cast<JSFunction*>(asObject(value));
95 }
96
97} // namespace kJS
98
99#endif // JSFunction_h
Note: See TracBrowser for help on using the repository browser.