source: webkit/trunk/JavaScriptCore/kjs/JSNotAnObject.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.
File size: 3.8 KB
Line 
1/*
2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef JSNotAnObject_h
30#define JSNotAnObject_h
31
32#include "JSObject.h"
33
34namespace JSC {
35
36 class JSNotAnObjectErrorStub : public JSObject {
37 public:
38 JSNotAnObjectErrorStub(ExecState* exec, bool isNull)
39 : JSObject(exec->globalData().notAnObjectErrorStubStructure)
40 , m_isNull(isNull)
41 {
42 }
43
44 bool isNull() const { return m_isNull; }
45
46 private:
47 virtual bool isNotAnObjectErrorStub() const { return true; }
48
49 bool m_isNull;
50 };
51
52 // This unholy class is used to allow us to avoid multiple exception checks
53 // in certain SquirrelFish opcodes -- effectively it just silently consumes
54 // any operations performed on the result of a failed toObject call.
55 class JSNotAnObject : public JSObject {
56 public:
57 JSNotAnObject(ExecState* exec, JSNotAnObjectErrorStub* exception)
58 : JSObject(exec->globalData().notAnObjectStructure)
59 , m_exception(exception)
60 {
61 }
62
63 static PassRefPtr<StructureID> createStructureID(JSValuePtr prototype)
64 {
65 return StructureID::create(prototype, TypeInfo(ObjectType));
66 }
67
68 private:
69 // JSValue methods
70 virtual JSValuePtr toPrimitive(ExecState*, PreferredPrimitiveType) const;
71 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValuePtr&);
72 virtual bool toBoolean(ExecState*) const;
73 virtual double toNumber(ExecState*) const;
74 virtual UString toString(ExecState*) const;
75 virtual JSObject* toObject(ExecState*) const;
76
77 // Marking
78 virtual void mark();
79
80 // JSObject methods
81 virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
82 virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
83
84 virtual void put(ExecState*, const Identifier& propertyName, JSValuePtr, PutPropertySlot&);
85 virtual void put(ExecState*, unsigned propertyName, JSValuePtr);
86
87 virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
88 virtual bool deleteProperty(ExecState*, unsigned propertyName);
89
90 virtual void getPropertyNames(ExecState*, PropertyNameArray&);
91
92 JSNotAnObjectErrorStub* m_exception;
93 };
94
95} // namespace JSC
96
97#endif // JSNotAnObject_h
Note: See TracBrowser for help on using the repository browser.