source: webkit/trunk/JavaScriptCore/kjs/ExecState.h@ 34979

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

2008-06-30 Geoffrey Garen <[email protected]>

Reviewed by Oliver Hunt.


Removed the "registerBase" abstraction. Since the register file never
reallocates, we can keep direct pointers into it, instead of
<registerBase, offset> tuples.


SunSpider says 0.8% faster.

  • Property svn:eol-style set to native
File size: 4.5 KB
Line 
1// -*- mode: c++; c-basic-offset: 4 -*-
2/*
3 * Copyright (C) 1999-2001 Harri Porten ([email protected])
4 * Copyright (C) 2001 Peter Kelly ([email protected])
5 * Copyright (C) 2003, 2007, 2008 Apple Inc. All rights reserved.
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 ExecState_h
25#define ExecState_h
26
27#include "JSGlobalData.h"
28#include "ScopeChain.h"
29
30namespace KJS {
31
32 class EvalNode;
33 class FunctionBodyNode;
34 class JSFunction;
35 class GlobalFuncImp;
36 class Interpreter;
37 class JSGlobalObject;
38 class JSVariableObject;
39 class Machine;
40 class ProgramNode;
41 class Register;
42 class RegisterFile;
43 class ScopeNode;
44
45 struct Instruction;
46
47 // Represents the current state of script execution.
48 // Passed as the first argument to most functions.
49 class ExecState : Noncopyable {
50 friend class Machine;
51 friend class DebuggerCallFrame;
52
53 public:
54 ExecState(JSGlobalObject*, JSObject* globalThisValue, ScopeChainNode* globalScopeChain);
55
56 // Global object in which execution began.
57 JSGlobalObject* dynamicGlobalObject() const { return m_globalObject; }
58
59 // Global object in which the current script was defined. (Can differ
60 // from dynamicGlobalObject() during function calls across frames.)
61 JSGlobalObject* lexicalGlobalObject() const
62 {
63 return m_scopeChain->globalObject();
64 }
65
66 JSObject* globalThisValue() const { return m_scopeChain->globalThisObject(); }
67
68 // Exception propogation.
69 void setException(JSValue* exception) { m_exception = exception; }
70 void clearException() { m_exception = 0; }
71 JSValue* exception() const { return m_exception; }
72 JSValue** exceptionSlot() { return &m_exception; }
73 bool hadException() const { return !!m_exception; }
74
75 JSGlobalData& globalData() { return *m_globalData; }
76
77 IdentifierTable* identifierTable() { return m_globalData->identifierTable; }
78 const CommonIdentifiers& propertyNames() const { return *m_globalData->propertyNames; }
79 const ArgList& emptyList() const { return m_globalData->emptyList; }
80 Lexer* lexer() { return m_globalData->lexer; }
81 Parser* parser() { return m_globalData->parser; }
82 Machine* machine() const { return m_globalData->machine; }
83 static const HashTable* arrayTable(ExecState* exec) { return exec->m_globalData->arrayTable; }
84 static const HashTable* dateTable(ExecState* exec) { return exec->m_globalData->dateTable; }
85 static const HashTable* mathTable(ExecState* exec) { return exec->m_globalData->mathTable; }
86 static const HashTable* numberTable(ExecState* exec) { return exec->m_globalData->numberTable; }
87 static const HashTable* regExpTable(ExecState* exec) { return exec->m_globalData->regExpTable; }
88 static const HashTable* regExpConstructorTable(ExecState* exec) { return exec->m_globalData->regExpConstructorTable; }
89 static const HashTable* stringTable(ExecState* exec) { return exec->m_globalData->stringTable; }
90
91 Heap* heap() const { return m_globalData->heap; }
92
93 private:
94 // Default constructor required for gcc 3.
95 ExecState() { }
96
97 ExecState(ExecState*, RegisterFile*, ScopeChainNode*, Register* callFrame);
98
99 bool isGlobalObject(JSObject*) const;
100
101 JSGlobalObject* m_globalObject;
102 JSObject* m_globalThisValue;
103
104 JSValue* m_exception;
105
106 JSGlobalData* m_globalData;
107
108 // These values are controlled by the machine.
109 ExecState* m_prev;
110 RegisterFile* m_registerFile;
111 ScopeChainNode* m_scopeChain;
112 Register* m_callFrame; // The most recent call frame.
113 };
114
115 enum CodeType { GlobalCode, EvalCode, FunctionCode };
116
117} // namespace KJS
118
119#endif // ExecState_h
Note: See TracBrowser for help on using the repository browser.