source: webkit/trunk/JavaScriptCore/runtime/ExecState.h@ 38247

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

2008-11-03 Cameron Zwarich <[email protected]>

Rubber-stamped by Maciej Stachowiak.

Move more files into the runtime subdirectory of JavaScriptCore.

JavaScriptCore:

  • API/JSBase.cpp:
  • API/JSCallbackConstructor.cpp:
  • API/JSCallbackFunction.cpp:
  • API/JSClassRef.cpp:
  • API/OpaqueJSString.cpp:
  • GNUmakefile.am:
  • JavaScriptCore.pri:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • JavaScriptCoreSources.bkl:
  • kjs/AllInOneFile.cpp:
  • kjs/ArgList.cpp: Removed.
  • kjs/ArgList.h: Removed.
  • kjs/Arguments.cpp: Removed.
  • kjs/Arguments.h: Removed.
  • kjs/BatchedTransitionOptimizer.h: Removed.
  • kjs/CollectorHeapIterator.h: Removed.
  • kjs/CommonIdentifiers.cpp: Removed.
  • kjs/CommonIdentifiers.h: Removed.
  • kjs/ExecState.cpp: Removed.
  • kjs/ExecState.h: Removed.
  • kjs/GetterSetter.cpp: Removed.
  • kjs/GetterSetter.h: Removed.
  • kjs/InitializeThreading.cpp: Removed.
  • kjs/InitializeThreading.h: Removed.
  • kjs/JSActivation.cpp: Removed.
  • kjs/JSActivation.h: Removed.
  • kjs/JSGlobalData.cpp: Removed.
  • kjs/JSGlobalData.h: Removed.
  • kjs/JSLock.cpp: Removed.
  • kjs/JSLock.h: Removed.
  • kjs/JSStaticScopeObject.cpp: Removed.
  • kjs/JSStaticScopeObject.h: Removed.
  • kjs/JSType.h: Removed.
  • kjs/PropertyNameArray.cpp: Removed.
  • kjs/PropertyNameArray.h: Removed.
  • kjs/ScopeChain.cpp: Removed.
  • kjs/ScopeChain.h: Removed.
  • kjs/ScopeChainMark.h: Removed.
  • kjs/SymbolTable.h: Removed.
  • kjs/Tracing.d: Removed.
  • kjs/Tracing.h: Removed.
  • runtime/ArgList.cpp: Copied from kjs/ArgList.cpp.
  • runtime/ArgList.h: Copied from kjs/ArgList.h.
  • runtime/Arguments.cpp: Copied from kjs/Arguments.cpp.
  • runtime/Arguments.h: Copied from kjs/Arguments.h.
  • runtime/BatchedTransitionOptimizer.h: Copied from kjs/BatchedTransitionOptimizer.h.
  • runtime/CollectorHeapIterator.h: Copied from kjs/CollectorHeapIterator.h.
  • runtime/CommonIdentifiers.cpp: Copied from kjs/CommonIdentifiers.cpp.
  • runtime/CommonIdentifiers.h: Copied from kjs/CommonIdentifiers.h.
  • runtime/ExecState.cpp: Copied from kjs/ExecState.cpp.
  • runtime/ExecState.h: Copied from kjs/ExecState.h.
  • runtime/GetterSetter.cpp: Copied from kjs/GetterSetter.cpp.
  • runtime/GetterSetter.h: Copied from kjs/GetterSetter.h.
  • runtime/InitializeThreading.cpp: Copied from kjs/InitializeThreading.cpp.
  • runtime/InitializeThreading.h: Copied from kjs/InitializeThreading.h.
  • runtime/JSActivation.cpp: Copied from kjs/JSActivation.cpp.
  • runtime/JSActivation.h: Copied from kjs/JSActivation.h.
  • runtime/JSGlobalData.cpp: Copied from kjs/JSGlobalData.cpp.
  • runtime/JSGlobalData.h: Copied from kjs/JSGlobalData.h.
  • runtime/JSLock.cpp: Copied from kjs/JSLock.cpp.
  • runtime/JSLock.h: Copied from kjs/JSLock.h.
  • runtime/JSStaticScopeObject.cpp: Copied from kjs/JSStaticScopeObject.cpp.
  • runtime/JSStaticScopeObject.h: Copied from kjs/JSStaticScopeObject.h.
  • runtime/JSType.h: Copied from kjs/JSType.h.
  • runtime/PropertyNameArray.cpp: Copied from kjs/PropertyNameArray.cpp.
  • runtime/PropertyNameArray.h: Copied from kjs/PropertyNameArray.h.
  • runtime/ScopeChain.cpp: Copied from kjs/ScopeChain.cpp.
  • runtime/ScopeChain.h: Copied from kjs/ScopeChain.h.
  • runtime/ScopeChainMark.h: Copied from kjs/ScopeChainMark.h.
  • runtime/SymbolTable.h: Copied from kjs/SymbolTable.h.
  • runtime/Tracing.d: Copied from kjs/Tracing.d.
  • runtime/Tracing.h: Copied from kjs/Tracing.h.

WebCore:

  • ForwardingHeaders/kjs/ArgList.h: Removed.
  • ForwardingHeaders/kjs/CollectorHeapIterator.h: Removed.
  • ForwardingHeaders/kjs/ExecState.h: Removed.
  • ForwardingHeaders/kjs/InitializeThreading.h: Removed.
  • ForwardingHeaders/kjs/JSGlobalData.h: Removed.
  • ForwardingHeaders/kjs/JSLock.h: Removed.
  • ForwardingHeaders/kjs/SymbolTable.h: Removed.
  • ForwardingHeaders/runtime/ArgList.h: Copied from ForwardingHeaders/kjs/ArgList.h.
  • ForwardingHeaders/runtime/CollectorHeapIterator.h: Copied from ForwardingHeaders/kjs/CollectorHeapIterator.h.
  • ForwardingHeaders/runtime/ExecState.h: Copied from ForwardingHeaders/kjs/ExecState.h.
  • ForwardingHeaders/runtime/InitializeThreading.h: Copied from ForwardingHeaders/kjs/InitializeThreading.h.
  • ForwardingHeaders/runtime/JSGlobalData.h: Copied from ForwardingHeaders/kjs/JSGlobalData.h.
  • ForwardingHeaders/runtime/JSLock.h: Copied from ForwardingHeaders/kjs/JSLock.h.
  • ForwardingHeaders/runtime/SymbolTable.h: Copied from ForwardingHeaders/kjs/SymbolTable.h.
  • bindings/js/GCController.cpp:
  • bindings/js/JSCustomPositionCallback.cpp:
  • bindings/js/JSCustomPositionErrorCallback.cpp:
  • bindings/js/JSCustomSQLStatementCallback.cpp:
  • bindings/js/JSCustomSQLStatementErrorCallback.cpp:
  • bindings/js/JSCustomSQLTransactionCallback.cpp:
  • bindings/js/JSCustomSQLTransactionErrorCallback.cpp:
  • bindings/js/JSCustomVoidCallback.cpp:
  • bindings/js/JSCustomXPathNSResolver.cpp:
  • bindings/js/JSDOMWindowBase.cpp:
  • bindings/js/JSEventCustom.cpp:
  • bindings/js/JSEventListener.cpp:
  • bindings/js/JSNodeFilterCondition.cpp:
  • bindings/js/ScheduledAction.cpp:
  • bindings/js/ScriptController.cpp:
  • bindings/js/ScriptControllerMac.mm:
  • bindings/objc/WebScriptObject.mm:
  • bridge/NP_jsobject.cpp:
  • bridge/c/c_class.cpp:
  • bridge/c/c_instance.cpp:
  • bridge/c/c_runtime.cpp:
  • bridge/c/c_utility.cpp:
  • bridge/jni/jni_class.cpp:
  • bridge/jni/jni_instance.cpp:
  • bridge/jni/jni_jsobject.mm:
  • bridge/jni/jni_objc.mm:
  • bridge/jni/jni_runtime.cpp:
  • bridge/jni/jni_runtime.h:
  • bridge/jni/jni_utility.cpp:
  • bridge/npruntime.cpp:
  • bridge/objc/objc_instance.mm:
  • bridge/objc/objc_runtime.mm:
  • bridge/objc/objc_utility.mm:
  • bridge/runtime.cpp:
  • dom/Document.cpp:
  • dom/Node.cpp:
  • dom/NodeFilter.cpp:
  • dom/NodeIterator.cpp:
  • dom/TreeWalker.cpp:
  • history/CachedPage.cpp:
  • inspector/InspectorController.cpp:
  • inspector/JavaScriptCallFrame.cpp:
  • inspector/JavaScriptCallFrame.h:
  • inspector/JavaScriptDebugServer.cpp:
  • inspector/JavaScriptProfileNode.cpp:
  • loader/FrameLoader.cpp:
  • loader/icon/IconDatabase.cpp:
  • page/Console.cpp:
  • page/Page.cpp:
  • page/mac/FrameMac.mm:
  • plugins/PluginView.cpp:
  • plugins/gtk/PluginViewGtk.cpp:
  • plugins/qt/PluginViewQt.cpp:
  • plugins/win/PluginViewWin.cpp:
  • storage/Database.cpp:
  • xml/XMLHttpRequest.cpp:

WebKit/gtk:

  • webkit/webkitprivate.cpp:

WebKit/mac:

  • ForwardingHeaders/kjs/JSLock.h: Removed.
  • ForwardingHeaders/kjs/SymbolTable.h: Removed.
  • ForwardingHeaders/runtime/JSLock.h: Copied from ForwardingHeaders/kjs/JSLock.h.
  • ForwardingHeaders/runtime/SymbolTable.h: Copied from ForwardingHeaders/kjs/SymbolTable.h.
  • Misc/WebCoreStatistics.mm:
  • Plugins/WebBaseNetscapePluginStream.mm:
  • Plugins/WebBaseNetscapePluginView.mm:
  • Plugins/WebPluginController.mm:
  • WebView/WebFrame.mm:
  • WebView/WebScriptDebugDelegate.mm:
  • WebView/WebView.mm:

WebKit/qt:

  • Api/qwebpage.cpp:

WebKit/win:

  • WebJavaScriptCollector.cpp:
  • Property svn:eol-style set to native
File size: 7.1 KB
Line 
1/*
2 * Copyright (C) 1999-2001 Harri Porten ([email protected])
3 * Copyright (C) 2001 Peter Kelly ([email protected])
4 * Copyright (C) 2003, 2007, 2008 Apple Inc. All rights reserved.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22
23#ifndef ExecState_h
24#define ExecState_h
25
26// FIXME: Rename this file to CallFrame.h.
27
28#include "JSGlobalData.h"
29#include "Machine.h"
30#include "ScopeChain.h"
31
32namespace JSC {
33
34 class Arguments;
35 class JSActivation;
36
37 // Represents the current state of script execution.
38 // Passed as the first argument to most functions.
39 class ExecState : private Register {
40 public:
41 JSFunction* callee() const { return this[RegisterFile::Callee].function(); }
42 CodeBlock* codeBlock() const { return this[RegisterFile::CodeBlock].Register::codeBlock(); }
43 ScopeChainNode* scopeChain() const { return this[RegisterFile::ScopeChain].Register::scopeChain(); }
44
45 JSValue* thisValue();
46
47 // Global object in which execution began.
48 JSGlobalObject* dynamicGlobalObject();
49
50 // Global object in which the currently executing code was defined.
51 // Differs from dynamicGlobalObject() during function calls across web browser frames.
52 JSGlobalObject* lexicalGlobalObject() const
53 {
54 return scopeChain()->globalObject();
55 }
56
57 // Differs from lexicalGlobalObject because this will have DOM window shell rather than
58 // the actual DOM window, which can't be "this" for security reasons.
59 JSObject* globalThisValue() const
60 {
61 return scopeChain()->globalThisObject();
62 }
63
64 // FIXME: Elsewhere, we use JSGlobalData* rather than JSGlobalData&.
65 // We should make this more uniform and either use a reference everywhere
66 // or a pointer everywhere.
67 JSGlobalData& globalData() const
68 {
69 return *scopeChain()->globalData;
70 }
71
72 // Convenience functions for access to global data.
73 // It takes a few memory references to get from a call frame to the global data
74 // pointer, so these are inefficient, and should be used sparingly in new code.
75 // But they're used in many places in legacy code, so they're not going away any time soon.
76
77 void setException(JSValue* exception) { globalData().exception = exception; }
78 void clearException() { globalData().exception = noValue(); }
79 JSValue* exception() const { return globalData().exception; }
80 JSValue** exceptionSlot() { return &globalData().exception; }
81 bool hadException() const { return !!globalData().exception; }
82
83 const CommonIdentifiers& propertyNames() const { return *globalData().propertyNames; }
84 const ArgList& emptyList() const { return *globalData().emptyList; }
85 Machine* machine() { return globalData().machine; }
86 Heap* heap() { return &globalData().heap; }
87
88 static const HashTable* arrayTable(CallFrame* callFrame) { return callFrame->globalData().arrayTable; }
89 static const HashTable* dateTable(CallFrame* callFrame) { return callFrame->globalData().dateTable; }
90 static const HashTable* mathTable(CallFrame* callFrame) { return callFrame->globalData().mathTable; }
91 static const HashTable* numberTable(CallFrame* callFrame) { return callFrame->globalData().numberTable; }
92 static const HashTable* regExpTable(CallFrame* callFrame) { return callFrame->globalData().regExpTable; }
93 static const HashTable* regExpConstructorTable(CallFrame* callFrame) { return callFrame->globalData().regExpConstructorTable; }
94 static const HashTable* stringTable(CallFrame* callFrame) { return callFrame->globalData().stringTable; }
95
96 private:
97 friend class Arguments;
98 friend class JSActivation;
99 friend class JSGlobalObject;
100 friend class Machine;
101
102 static CallFrame* create(Register* callFrameBase) { return static_cast<CallFrame*>(callFrameBase); }
103 Register* registers() { return this; }
104
105 CallFrame& operator=(const Register& r) { *static_cast<Register*>(this) = r; return *this; }
106
107 int argumentCount() const { return this[RegisterFile::ArgumentCount].i(); }
108 CallFrame* callerFrame() const { return this[RegisterFile::CallerFrame].callFrame(); }
109 Arguments* optionalCalleeArguments() const { return this[RegisterFile::OptionalCalleeArguments].arguments(); }
110 Instruction* returnPC() const { return this[RegisterFile::ReturnPC].vPC(); }
111 int returnValueRegister() const { return this[RegisterFile::ReturnValueRegister].i(); }
112
113 void setArgumentCount(int count) { this[RegisterFile::ArgumentCount] = count; }
114 void setCallee(JSFunction* callee) { this[RegisterFile::Callee] = callee; }
115 void setCalleeArguments(Arguments* arguments) { this[RegisterFile::OptionalCalleeArguments] = arguments; }
116 void setCallerFrame(CallFrame* callerFrame) { this[RegisterFile::CallerFrame] = callerFrame; }
117 void setCodeBlock(CodeBlock* codeBlock) { this[RegisterFile::CodeBlock] = codeBlock; }
118 void setScopeChain(ScopeChainNode* scopeChain) { this[RegisterFile::ScopeChain] = scopeChain; }
119
120 ALWAYS_INLINE void init(CodeBlock* codeBlock, Instruction* vPC, ScopeChainNode* scopeChain,
121 CallFrame* callerFrame, int returnValueRegister, int argc, JSFunction* function)
122 {
123 ASSERT(callerFrame); // Use noCaller() rather than 0 for the outer host call frame caller.
124
125 setCodeBlock(codeBlock);
126 setScopeChain(scopeChain);
127 setCallerFrame(callerFrame);
128 this[RegisterFile::ReturnPC] = vPC;
129 this[RegisterFile::ReturnValueRegister] = returnValueRegister;
130 setArgumentCount(argc); // original argument count (for the sake of the "arguments" object)
131 setCallee(function);
132 setCalleeArguments(0);
133 }
134
135 static const intptr_t HostCallFrameFlag = 1;
136
137 static CallFrame* noCaller() { return reinterpret_cast<CallFrame*>(HostCallFrameFlag); }
138 bool hasHostCallFrameFlag() const { return reinterpret_cast<intptr_t>(this) & HostCallFrameFlag; }
139 CallFrame* addHostCallFrameFlag() const { return reinterpret_cast<CallFrame*>(reinterpret_cast<intptr_t>(this) | HostCallFrameFlag); }
140 CallFrame* removeHostCallFrameFlag() { return reinterpret_cast<CallFrame*>(reinterpret_cast<intptr_t>(this) & ~HostCallFrameFlag); }
141
142 ExecState();
143 ~ExecState();
144 };
145
146} // namespace JSC
147
148#endif // ExecState_h
Note: See TracBrowser for help on using the repository browser.