source: webkit/trunk/JavaScriptCore/runtime/JSGlobalData.h@ 51875

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

Bug 31859 - Make world selection for JSC IsolatedWorlds automagical.

Reviewed by Geoff Garen.

JavaScriptCore:

WebCore presently has to explicitly specify the world before entering into JSC,
which is a little fragile (particularly since property access via a
getter/setter might invoke execution). Instead derive the current world from
the lexical global object.

Remove the temporary duct tape of willExecute/didExecute virtual hooks on the JSGlobalData::ClientData - these are no longer necessary.

  • API/JSBase.cpp:

(JSEvaluateScript):

  • API/JSObjectRef.cpp:

(JSObjectCallAsFunction):

  • JavaScriptCore.exp:
  • runtime/JSGlobalData.cpp:
  • runtime/JSGlobalData.h:

WebCore:

WebCore presently has to explicitly specify the world before entering into JSC,
which is a little fragile (particularly since property access via a
getter/setter might invoke execution). Instead derive the current world from
the lexical global object.

Remove the last uses of mainThreadCurrentWorld(), so the world is always obtained via
currentWorld(). Switch this to obtain the world from the ExecsState's lexical global
object instead. Remove the call/construct/evaluate 'InWorld' methods, since these
are no longer necessary.

  • WebCore.base.exp:
  • bindings/js/JSCallbackData.cpp:

(WebCore::JSCallbackData::invokeCallback):

  • bindings/js/JSCallbackData.h:

(WebCore::JSCallbackData::JSCallbackData):

  • bindings/js/JSCustomXPathNSResolver.cpp:

(WebCore::JSCustomXPathNSResolver::lookupNamespaceURI):

  • bindings/js/JSDOMBinding.cpp:

(WebCore::currentWorld):
(WebCore::mainThreadNormalWorld):

  • bindings/js/JSDOMBinding.h:

(WebCore::WebCoreJSClientData::WebCoreJSClientData):

  • bindings/js/JSDOMWindowBase.cpp:

(WebCore::JSDOMWindowBase::updateDocument):

  • bindings/js/JSDOMWindowBase.h:
  • bindings/js/JSEventListener.cpp:

(WebCore::JSEventListener::handleEvent):
(WebCore::JSEventListener::reportError):

  • bindings/js/JSHTMLDocumentCustom.cpp:

(WebCore::JSHTMLDocument::open):

  • bindings/js/JSNodeFilterCondition.cpp:

(WebCore::JSNodeFilterCondition::acceptNode):

  • bindings/js/JSQuarantinedObjectWrapper.cpp:

(WebCore::JSQuarantinedObjectWrapper::construct):
(WebCore::JSQuarantinedObjectWrapper::call):

  • bindings/js/ScheduledAction.cpp:

(WebCore::ScheduledAction::executeFunctionInContext):

  • bindings/js/ScriptController.cpp:

(WebCore::ScriptController::evaluateInWorld):
(WebCore::ScriptController::initScript):
(WebCore::ScriptController::updateDocument):

  • bindings/js/ScriptFunctionCall.cpp:

(WebCore::ScriptFunctionCall::call):
(WebCore::ScriptFunctionCall::construct):

  • bindings/js/ScriptObjectQuarantine.cpp:

(WebCore::getQuarantinedScriptObject):

  • bindings/js/ScriptState.cpp:

(WebCore::scriptStateFromNode):
(WebCore::scriptStateFromPage):

  • bindings/js/ScriptState.h:
  • bindings/js/WorkerScriptController.cpp:

(WebCore::WorkerScriptController::evaluate):

  • bindings/objc/WebScriptObject.mm:

(-[WebScriptObject callWebScriptMethod:withArguments:]):
(-[WebScriptObject evaluateWebScript:]):

  • bridge/NP_jsobject.cpp:

(_NPN_InvokeDefault):
(_NPN_Invoke):
(_NPN_Evaluate):
(_NPN_Construct):

  • bridge/jni/jni_jsobject.mm:

(JavaJSObject::call):
(JavaJSObject::eval):

  • dom/NodeFilter.h:

(WebCore::NodeFilter::acceptNode):

  • dom/NodeIterator.h:

(WebCore::NodeIterator::nextNode):
(WebCore::NodeIterator::previousNode):

  • dom/TreeWalker.h:

(WebCore::TreeWalker::parentNode):
(WebCore::TreeWalker::firstChild):
(WebCore::TreeWalker::lastChild):
(WebCore::TreeWalker::previousSibling):
(WebCore::TreeWalker::nextSibling):
(WebCore::TreeWalker::previousNode):
(WebCore::TreeWalker::nextNode):

  • inspector/InspectorController.cpp:

(WebCore::InspectorController::windowScriptObjectAvailable):
(WebCore::InspectorController::didEvaluateForTestInFrontend):

  • inspector/JavaScriptCallFrame.cpp:

(WebCore::JavaScriptCallFrame::evaluate):

WebKit/mac:

WebCore presently has to explicitly specify the world before entering into JSC,
which is a little fragile (particularly since property access via a
getter/setter might invoke execution). Instead derive the current world from
the lexical global object.

Since WebCore no longer needs to explicitly specify the world on entry to JSC DebuggerCallFrame::evaluate can be called directly.

  • WebView/WebScriptDebugDelegate.mm:

(-[WebScriptCallFrame evaluateWebScript:]):

  • Property svn:eol-style set to native
File size: 6.1 KB
Line 
1/*
2 * Copyright (C) 2008, 2009 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 JSGlobalData_h
30#define JSGlobalData_h
31
32#include "Collector.h"
33#include "DateInstanceCache.h"
34#include "ExecutableAllocator.h"
35#include "JITStubs.h"
36#include "JSValue.h"
37#include "MarkStack.h"
38#include "NumericStrings.h"
39#include "SmallStrings.h"
40#include "TimeoutChecker.h"
41#include "WeakRandom.h"
42#include <wtf/Forward.h>
43#include <wtf/HashMap.h>
44#include <wtf/RefCounted.h>
45
46struct OpaqueJSClass;
47struct OpaqueJSClassContextData;
48
49namespace JSC {
50
51 class CodeBlock;
52 class CommonIdentifiers;
53 class IdentifierTable;
54 class Interpreter;
55 class JSGlobalObject;
56 class JSObject;
57 class Lexer;
58 class Parser;
59 class Stringifier;
60 class Structure;
61 class UString;
62
63 struct HashTable;
64 struct Instruction;
65 struct VPtrSet;
66
67 struct DSTOffsetCache {
68 DSTOffsetCache()
69 {
70 reset();
71 }
72
73 void reset()
74 {
75 offset = 0.0;
76 start = 0.0;
77 end = -1.0;
78 increment = 0.0;
79 }
80
81 double offset;
82 double start;
83 double end;
84 double increment;
85 };
86
87 class JSGlobalData : public RefCounted<JSGlobalData> {
88 public:
89 struct ClientData {
90 virtual ~ClientData() = 0;
91 };
92
93 static bool sharedInstanceExists();
94 static JSGlobalData& sharedInstance();
95
96 static PassRefPtr<JSGlobalData> create(bool isShared = false);
97 static PassRefPtr<JSGlobalData> createLeaked();
98 ~JSGlobalData();
99
100#if ENABLE(JSC_MULTIPLE_THREADS)
101 // Will start tracking threads that use the heap, which is resource-heavy.
102 void makeUsableFromMultipleThreads() { heap.makeUsableFromMultipleThreads(); }
103#endif
104
105 bool isSharedInstance;
106 ClientData* clientData;
107
108 const HashTable* arrayTable;
109 const HashTable* dateTable;
110 const HashTable* jsonTable;
111 const HashTable* mathTable;
112 const HashTable* numberTable;
113 const HashTable* regExpTable;
114 const HashTable* regExpConstructorTable;
115 const HashTable* stringTable;
116
117 RefPtr<Structure> activationStructure;
118 RefPtr<Structure> interruptedExecutionErrorStructure;
119 RefPtr<Structure> staticScopeStructure;
120 RefPtr<Structure> stringStructure;
121 RefPtr<Structure> notAnObjectErrorStubStructure;
122 RefPtr<Structure> notAnObjectStructure;
123 RefPtr<Structure> propertyNameIteratorStructure;
124 RefPtr<Structure> getterSetterStructure;
125 RefPtr<Structure> apiWrapperStructure;
126
127#if USE(JSVALUE32)
128 RefPtr<Structure> numberStructure;
129#endif
130
131 void* jsArrayVPtr;
132 void* jsByteArrayVPtr;
133 void* jsStringVPtr;
134 void* jsFunctionVPtr;
135
136 IdentifierTable* identifierTable;
137 CommonIdentifiers* propertyNames;
138 const MarkedArgumentBuffer* emptyList; // Lists are supposed to be allocated on the stack to have their elements properly marked, which is not the case here - but this list has nothing to mark.
139 SmallStrings smallStrings;
140 NumericStrings numericStrings;
141 DateInstanceCache dateInstanceCache;
142
143#if ENABLE(ASSEMBLER)
144 ExecutableAllocator executableAllocator;
145#endif
146
147 Lexer* lexer;
148 Parser* parser;
149 Interpreter* interpreter;
150#if ENABLE(JIT)
151 JITThunks jitStubs;
152#endif
153 TimeoutChecker timeoutChecker;
154 Heap heap;
155
156 JSValue exception;
157#if ENABLE(JIT)
158 ReturnAddressPtr exceptionLocation;
159#endif
160
161 const Vector<Instruction>& numericCompareFunction(ExecState*);
162 Vector<Instruction> lazyNumericCompareFunction;
163 bool initializingLazyNumericCompareFunction;
164
165 HashMap<OpaqueJSClass*, OpaqueJSClassContextData*> opaqueJSClassData;
166
167 JSGlobalObject* head;
168 JSGlobalObject* dynamicGlobalObject;
169
170 HashSet<JSObject*> arrayVisitedElements;
171
172 CodeBlock* functionCodeBlockBeingReparsed;
173 Stringifier* firstStringifierToMark;
174
175 MarkStack markStack;
176
177 double cachedUTCOffset;
178 DSTOffsetCache dstOffsetCache;
179
180 UString cachedDateString;
181 double cachedDateStringValue;
182
183 WeakRandom weakRandom;
184
185#ifndef NDEBUG
186 bool mainThreadOnly;
187#endif
188
189 void resetDateCache();
190
191 void startSampling();
192 void stopSampling();
193 void dumpSampleData(ExecState* exec);
194 private:
195 JSGlobalData(bool isShared, const VPtrSet&);
196 static JSGlobalData*& sharedInstanceInternal();
197 void createNativeThunk();
198 };
199
200} // namespace JSC
201
202#endif // JSGlobalData_h
Note: See TracBrowser for help on using the repository browser.