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

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

JavaScriptCore:

2008-08-25 Kevin McCullough <[email protected]>

Reviewed by Geoff, Tim and Mark.

<rdar://problem/6150623> JSProfiler: It would be nice if the profiles
in the console said what file and line number they came from

  • Lay the foundation for getting line numbers and other data from the JavaScript engine. With the cleanup in kjs/ExecState this is actually a slight performance improvement.
  • JavaScriptCore.exp: Export retrieveLastCaller() for WebCore.
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • VM/Machine.cpp: Now Host and JS functions set a call frame on the exec state, so this and the profiler code were pulled out of the branches. (KJS::Machine::privateExecute): (KJS::Machine::retrieveLastCaller): This get's the lineNumber, sourceID and sourceURL for the previously called function.
  • VM/Machine.h:
  • kjs/ExecState.cpp: Remove references to JSFunction since it's not used anywhere.
  • kjs/ExecState.h:

WebCore:

2008-08-22 Kevin McCullough <[email protected]>

Reviewed by Geoff, Mark and Tim.

<rdar://problem/6150623> JSProfiler: It would be nice if the profiles
in the console said what file and line number they came from

  • Lay the foundation for getting line numbers and other data from the JavaScript engine.
  • ForwardingHeaders/VM: Added.
  • ForwardingHeaders/VM/Machine.h: Added.
  • page/Console.cpp: Gather the line number and file information when profileEnd has been called, but don't use it until didFinishProfiling is called. We won't need to wait once we remove the profiler "zombie" mode which this patch helps pave the foundation for. (WebCore::Console::Console): (WebCore::Console::profileEnd): (WebCore::Console::finishedProfiling):
  • page/Console.h:
  • page/InspectorController.cpp: Modify calls to addProfileMessageToConsole to satisfy the new arguments it takes. (WebCore::InspectorController::finishedProfiling): (WebCore::InspectorController::addProfile): (WebCore::InspectorController::addProfileMessageToConsole): (WebCore::InspectorController::finishedProfiling):
  • page/InspectorController.h:
  • Property svn:eol-style set to native
File size: 4.5 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#include "JSGlobalData.h"
27#include "ScopeChain.h"
28
29namespace KJS {
30
31 class EvalNode;
32 class FunctionBodyNode;
33 class JSValue;
34 class GlobalFuncImp;
35 class Interpreter;
36 class JSGlobalObject;
37 class JSVariableObject;
38 class Machine;
39 class ProgramNode;
40 class Register;
41 class RegisterFile;
42 class ScopeNode;
43
44 struct Instruction;
45
46 // Represents the current state of script execution.
47 // Passed as the first argument to most functions.
48 class ExecState : Noncopyable {
49 friend class Machine;
50 friend class DebuggerCallFrame;
51
52 public:
53 ExecState(JSGlobalObject*, JSObject* globalThisValue, ScopeChainNode* globalScopeChain);
54
55 // Global object in which execution began.
56 JSGlobalObject* dynamicGlobalObject() const { return m_globalObject; }
57
58 // Global object in which the current script was defined. (Can differ
59 // from dynamicGlobalObject() during function calls across frames.)
60 JSGlobalObject* lexicalGlobalObject() const
61 {
62 return m_scopeChain->globalObject();
63 }
64
65 JSObject* globalThisValue() const { return m_scopeChain->globalThisObject(); }
66
67 // Exception propogation.
68 void setException(JSValue* exception) { m_exception = exception; }
69 void clearException() { m_exception = 0; }
70 JSValue* exception() const { return m_exception; }
71 JSValue** exceptionSlot() { return &m_exception; }
72 bool hadException() const { return !!m_exception; }
73
74 JSGlobalData& globalData() { return *m_globalData; }
75
76 IdentifierTable* identifierTable() { return m_globalData->identifierTable; }
77 const CommonIdentifiers& propertyNames() const { return *m_globalData->propertyNames; }
78 const ArgList& emptyList() const { return *m_globalData->emptyList; }
79 Lexer* lexer() { return m_globalData->lexer; }
80 Parser* parser() { return m_globalData->parser; }
81 Machine* machine() const { return m_globalData->machine; }
82 static const HashTable* arrayTable(ExecState* exec) { return exec->m_globalData->arrayTable; }
83 static const HashTable* dateTable(ExecState* exec) { return exec->m_globalData->dateTable; }
84 static const HashTable* mathTable(ExecState* exec) { return exec->m_globalData->mathTable; }
85 static const HashTable* numberTable(ExecState* exec) { return exec->m_globalData->numberTable; }
86 static const HashTable* regExpTable(ExecState* exec) { return exec->m_globalData->regExpTable; }
87 static const HashTable* regExpConstructorTable(ExecState* exec) { return exec->m_globalData->regExpConstructorTable; }
88 static const HashTable* stringTable(ExecState* exec) { return exec->m_globalData->stringTable; }
89
90 Heap* heap() const { return m_globalData->heap; }
91
92 private:
93 // Default constructor required for gcc 3.
94 ExecState() { }
95
96 ExecState(ExecState*, RegisterFile*, ScopeChainNode*, Register* callFrame);
97
98 bool isGlobalObject(JSObject*) const;
99
100 JSGlobalObject* m_globalObject;
101 JSObject* m_globalThisValue;
102
103 JSValue* m_exception;
104
105 JSGlobalData* m_globalData;
106
107 // These values are controlled by the machine.
108 ExecState* m_prev;
109 RegisterFile* m_registerFile;
110 ScopeChainNode* m_scopeChain;
111 Register* m_callFrame; // The most recent call frame.
112 };
113
114 enum CodeType { GlobalCode, EvalCode, FunctionCode };
115
116} // namespace KJS
117
118#endif // ExecState_h
Note: See TracBrowser for help on using the repository browser.