source: webkit/trunk/JavaScriptCore/kjs/ExecState.cpp@ 28479

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

JavaScriptCore:

Reviewed by Darin Adler.

Third step in refactoring JSGlobalObject: Moved data members and
functions accessing data members from Interpreter to JSGlobalObject.
Changed Interpreter member functions to static functions.


This resolves a bug in global object bootstrapping, where the global
ExecState could be used when uninitialized.


This is a big change, but it's mostly code motion and renaming.


Layout and JS tests, and testjsglue and testapi, pass. SunSpider reports
a .7% regression, but Shark sees no difference related to this patch,
and SunSpider reported a .7% speedup from an earlier step in this
refactoring, so I think it's fair to call that a wash.

JavaScriptGlue:

Reviewed by Darin Adler.

Third step in refactoring JSGlobalObject: Moved data members and data
member access from Interpreter to JSGlobalObject. Replaced JSInterpreter
subclass with JSGlobalObject subclass.


  • JSRun.cpp: (JSRun::JSRun): (JSRun::Evaluate): (JSRun::CheckSyntax):
  • JSRun.h: (JSGlueGlobalObject::JSGlueGlobalObject):
  • JSUtils.cpp: (KJSValueToCFTypeInternal):
  • JSValueWrapper.cpp: (getThreadGlobalExecState):

WebCore:

Reviewed by Darin Adler.

Third step in refactoring JSGlobalObject: Moved data members and data
member access from Interpreter to JSGlobalObject. Changed Interpreter
member functions to static functions. Same for the subclass,
ScriptInterpreter.


This is a big change, but it's mostly code motion and renaming.

WebKit/mac:

Reviewed by Darin Adler.

Third step in refactoring JSGlobalObject: Moved data members and data
member access from Interpreter to JSGlobalObject.


  • WebView/WebFrame.mm: (-[WebFrame _attachScriptDebugger]):

WebKit/win:

Reviewed by Darin Adler.

Third step in refactoring JSGlobalObject: Moved data members and data
member access from Interpreter to JSGlobalObject.


  • WebFrame.cpp: (WebFrame::globalContext): (WebFrame::attachScriptDebugger): (WebFrame::windowObjectCleared):
  • WebScriptDebugger.cpp: (WebScriptDebugger::WebScriptDebugger):
  • Property svn:eol-style set to native
File size: 3.3 KB
Line 
1// -*- mode: c++; c-basic-offset: 4 -*-
2/*
3 * This file is part of the KDE libraries
4 * Copyright (C) 1999-2001 Harri Porten ([email protected])
5 * Copyright (C) 2001 Peter Kelly ([email protected])
6 * Copyright (C) 2003, 2007 Apple Inc. All rights reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 *
23 */
24
25#include "config.h"
26#include "ExecState.h"
27
28#include "JSGlobalObject.h"
29#include "function.h"
30#include "internal.h"
31
32namespace KJS {
33
34// ECMA 10.2
35ExecState::ExecState(JSGlobalObject* globalObject, JSObject* thisV,
36 FunctionBodyNode* currentBody, CodeType type, ExecState* callingExec, ExecState* currentExec,
37 FunctionImp* func, const List* args)
38 : m_globalObject(globalObject)
39 , m_exception(0)
40 , m_propertyNames(CommonIdentifiers::shared())
41 , m_callingExec(callingExec)
42 , m_savedExec(currentExec)
43 , m_currentBody(currentBody)
44 , m_function(func)
45 , m_arguments(args)
46 , m_iterationDepth(0)
47 , m_switchDepth(0)
48 , m_codeType(type)
49{
50 // create and initialize activation object (ECMA 10.1.6)
51 if (type == FunctionCode) {
52 m_activation = new ActivationImp(this);
53 m_variable = m_activation;
54 } else {
55 m_activation = 0;
56 m_variable = globalObject;
57 }
58
59 // ECMA 10.2
60 switch(type) {
61 case EvalCode:
62 if (m_callingExec) {
63 m_scopeChain = m_callingExec->scopeChain();
64 m_variable = m_callingExec->variableObject();
65 m_thisVal = m_callingExec->thisValue();
66 break;
67 } // else same as GlobalCode
68 case GlobalCode:
69 m_scopeChain.push(globalObject);
70 m_thisVal = globalObject;
71 break;
72 case FunctionCode:
73 m_scopeChain = func->scope();
74 m_scopeChain.push(m_activation);
75 m_variable = m_activation; // TODO: DontDelete ? (ECMA 10.2.3)
76 m_thisVal = thisV;
77 break;
78 }
79
80 if (currentBody)
81 m_globalObject->setCurrentExec(this);
82}
83
84ExecState::~ExecState()
85{
86 m_globalObject->setCurrentExec(m_savedExec);
87}
88
89void ExecState::mark()
90{
91 for (ExecState* exec = this; exec; exec = exec->m_callingExec)
92 exec->m_scopeChain.mark();
93}
94
95JSGlobalObject* ExecState::lexicalGlobalObject() const
96{
97 if (scopeChain().isEmpty())
98 return dynamicGlobalObject();
99
100 JSObject* object = scopeChain().bottom();
101 if (object && object->isGlobalObject())
102 return static_cast<JSGlobalObject*>(object);
103
104 return dynamicGlobalObject();
105}
106
107void ExecState::updateLocalStorage()
108{
109 m_localStorageBuffer = static_cast<ActivationImp*>(m_activation)->localStorage().data();
110}
111
112} // namespace KJS
Note: See TracBrowser for help on using the repository browser.