source: webkit/trunk/JavaScriptCore/runtime/JSFunction.h@ 54571

Last change on this file since 54571 was 54022, checked in by [email protected], 15 years ago

2010-01-28 Oliver Hunt <[email protected]>

Reviewed by Gavin Barraclough.

Simplify anonymous slot implementation
https://bugs.webkit.org/show_bug.cgi?id=34282

A class must now specify the number of slots it needs at construction time
rather than later on with a transition. This makes many things simpler,
we no longer need to need an additional transition on object creation to
add the anonymous slots, and we remove the need for a number of transition
type checks.

  • API/JSCallbackConstructor.h: (JSC::JSCallbackConstructor::createStructure):
  • API/JSCallbackFunction.h: (JSC::JSCallbackFunction::createStructure):
  • API/JSCallbackObject.h: (JSC::JSCallbackObject::createStructure):
  • JavaScriptCore.exp:
  • debugger/DebuggerActivation.h: (JSC::DebuggerActivation::createStructure):
  • runtime/Arguments.h: (JSC::Arguments::createStructure):
  • runtime/BooleanObject.h: (JSC::BooleanObject::createStructure):
  • runtime/DateInstance.h: (JSC::DateInstance::createStructure):
  • runtime/DatePrototype.h: (JSC::DatePrototype::createStructure):
  • runtime/FunctionPrototype.h: (JSC::FunctionPrototype::createStructure):
  • runtime/GetterSetter.h: (JSC::GetterSetter::createStructure):
  • runtime/GlobalEvalFunction.h: (JSC::GlobalEvalFunction::createStructure):
  • runtime/InternalFunction.h: (JSC::InternalFunction::createStructure):
  • runtime/JSAPIValueWrapper.h: (JSC::JSAPIValueWrapper::createStructure):
  • runtime/JSActivation.h: (JSC::JSActivation::createStructure):
  • runtime/JSArray.h: (JSC::JSArray::createStructure):
  • runtime/JSByteArray.cpp: (JSC::JSByteArray::createStructure):
  • runtime/JSCell.h: (JSC::JSCell::createDummyStructure):
  • runtime/JSFunction.h: (JSC::JSFunction::createStructure):
  • runtime/JSGlobalObject.h: (JSC::JSGlobalObject::createStructure):
  • runtime/JSNotAnObject.h: (JSC::JSNotAnObject::createStructure):
  • runtime/JSONObject.h: (JSC::JSONObject::createStructure):
  • runtime/JSObject.h: (JSC::JSObject::createStructure): (JSC::JSObject::putAnonymousValue): (JSC::JSObject::getAnonymousValue):
  • runtime/JSPropertyNameIterator.h: (JSC::JSPropertyNameIterator::createStructure):
  • runtime/JSStaticScopeObject.h: (JSC::JSStaticScopeObject::createStructure):
  • runtime/JSString.h: (JSC::Fiber::createStructure):
  • runtime/JSVariableObject.h: (JSC::JSVariableObject::createStructure):
  • runtime/JSWrapperObject.h: (JSC::JSWrapperObject::createStructure): (JSC::JSWrapperObject::JSWrapperObject):
  • runtime/MathObject.h: (JSC::MathObject::createStructure):
  • runtime/NumberConstructor.h: (JSC::NumberConstructor::createStructure):
  • runtime/NumberObject.h: (JSC::NumberObject::createStructure):
  • runtime/RegExpConstructor.h: (JSC::RegExpConstructor::createStructure):
  • runtime/RegExpObject.h: (JSC::RegExpObject::createStructure):
  • runtime/StringObject.h: (JSC::StringObject::createStructure):
  • runtime/StringObjectThatMasqueradesAsUndefined.h: (JSC::StringObjectThatMasqueradesAsUndefined::createStructure):
  • runtime/Structure.cpp: (JSC::Structure::~Structure): (JSC::Structure::materializePropertyMap):
  • runtime/Structure.h: (JSC::Structure::create): (JSC::Structure::anonymousSlotCount):
  • runtime/StructureTransitionTable.h:

2010-01-28 Oliver Hunt <[email protected]>

Reviewed by Gavin Barraclough.

Simplify anonymous slot implementation
https://bugs.webkit.org/show_bug.cgi?id=34282

Update JSGlue Structure usage to pass the anonymous slot count.

  • UserObjectImp.h: (UserObjectImp::createStructure):

2010-01-28 Oliver Hunt <[email protected]>

Reviewed by Gavin Barraclough.

Simplify anonymous slot implementation
https://bugs.webkit.org/show_bug.cgi?id=34282

Update the WebCore JS DOM bindings to correctly pass and
propagate the anonymous slot count information.

  • bindings/js/JSDOMBinding.h: (WebCore::DOMObjectWithGlobalPointer::createStructure): (WebCore::DOMConstructorObject::createStructure):
  • bindings/js/JSDOMWindowShell.h: (WebCore::JSDOMWindowShell::createStructure):
  • bindings/scripts/CodeGeneratorJS.pm:
  • bridge/objc/objc_runtime.h: (JSC::Bindings::ObjcFallbackObjectImp::createStructure):
  • bridge/runtime_array.h: (JSC::RuntimeArray::createStructure):
  • bridge/runtime_method.h: (JSC::RuntimeMethod::createStructure):
  • bridge/runtime_object.h: (JSC::RuntimeObjectImp::createStructure):
  • Property svn:eol-style set to native
File size: 4.9 KB
Line 
1/*
2 * Copyright (C) 1999-2000 Harri Porten ([email protected])
3 * Copyright (C) 2003, 2006, 2007, 2008, 2009 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
29namespace JSC {
30
31 class ExecutableBase;
32 class FunctionExecutable;
33 class FunctionPrototype;
34 class JSActivation;
35 class JSGlobalObject;
36
37 class JSFunction : public InternalFunction {
38 friend class JIT;
39 friend class JSGlobalData;
40
41 typedef InternalFunction Base;
42
43 public:
44 JSFunction(ExecState*, NonNullPassRefPtr<Structure>, int length, const Identifier&, NativeFunction);
45 JSFunction(ExecState*, NonNullPassRefPtr<FunctionExecutable>, ScopeChainNode*);
46 virtual ~JSFunction();
47
48 JSObject* construct(ExecState*, const ArgList&);
49 JSValue call(ExecState*, JSValue thisValue, const ArgList&);
50
51 void setScope(const ScopeChain& scopeChain) { setScopeChain(scopeChain); }
52 ScopeChain& scope() { return scopeChain(); }
53
54 ExecutableBase* executable() const { return m_executable.get(); }
55
56 // To call either of these methods include Executable.h
57 inline bool isHostFunction() const;
58 FunctionExecutable* jsExecutable() const;
59
60 static JS_EXPORTDATA const ClassInfo info;
61
62 static PassRefPtr<Structure> createStructure(JSValue prototype)
63 {
64 return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
65 }
66
67 NativeFunction nativeFunction()
68 {
69 return *WTF::bitwise_cast<NativeFunction*>(m_data);
70 }
71
72 virtual ConstructType getConstructData(ConstructData&);
73 virtual CallType getCallData(CallData&);
74
75 protected:
76 const static unsigned StructureFlags = OverridesGetOwnPropertySlot | ImplementsHasInstance | OverridesMarkChildren | OverridesGetPropertyNames | InternalFunction::StructureFlags;
77
78 private:
79 JSFunction(NonNullPassRefPtr<Structure>);
80
81 bool isHostFunctionNonInline() const;
82
83 virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
84 virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
85 virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
86 virtual void put(ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
87 virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
88
89 virtual void markChildren(MarkStack&);
90
91 virtual const ClassInfo* classInfo() const { return &info; }
92
93 static JSValue argumentsGetter(ExecState*, const Identifier&, const PropertySlot&);
94 static JSValue callerGetter(ExecState*, const Identifier&, const PropertySlot&);
95 static JSValue lengthGetter(ExecState*, const Identifier&, const PropertySlot&);
96
97 RefPtr<ExecutableBase> m_executable;
98 ScopeChain& scopeChain()
99 {
100 ASSERT(!isHostFunctionNonInline());
101 return *WTF::bitwise_cast<ScopeChain*>(m_data);
102 }
103 void clearScopeChain()
104 {
105 ASSERT(!isHostFunctionNonInline());
106 new (m_data) ScopeChain(NoScopeChain());
107 }
108 void setScopeChain(ScopeChainNode* sc)
109 {
110 ASSERT(!isHostFunctionNonInline());
111 new (m_data) ScopeChain(sc);
112 }
113 void setScopeChain(const ScopeChain& sc)
114 {
115 ASSERT(!isHostFunctionNonInline());
116 *WTF::bitwise_cast<ScopeChain*>(m_data) = sc;
117 }
118 void setNativeFunction(NativeFunction func)
119 {
120 *WTF::bitwise_cast<NativeFunction*>(m_data) = func;
121 }
122 unsigned char m_data[sizeof(void*)];
123 };
124
125 JSFunction* asFunction(JSValue);
126
127 inline JSFunction* asFunction(JSValue value)
128 {
129 ASSERT(asObject(value)->inherits(&JSFunction::info));
130 return static_cast<JSFunction*>(asObject(value));
131 }
132
133} // namespace JSC
134
135#endif // JSFunction_h
Note: See TracBrowser for help on using the repository browser.