source: webkit/trunk/JavaScriptCore/runtime/JSGlobalData.cpp@ 38528

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

JavaScriptCore:

2008-11-17 Geoffrey Garen <[email protected]>

Reviewed by Sam Weinig.


Moved VM/Machine.h => interpreter/Interpreter.h

  • GNUmakefile.am:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • VM/CTI.cpp:
  • VM/CTI.h:
  • VM/ExceptionHelpers.cpp:
  • VM/Machine.cpp:
  • VM/Machine.h: Removed.
  • VM/SamplingTool.cpp:
  • bytecode/CodeBlock.cpp:
  • bytecompiler/BytecodeGenerator.cpp:
  • bytecompiler/BytecodeGenerator.h:
  • debugger/DebuggerCallFrame.cpp:
  • interpreter: Added.
  • interpreter/Interpreter.h: Copied from VM/Machine.h.
  • profiler/ProfileGenerator.cpp:
  • runtime/Arguments.h:
  • runtime/ArrayPrototype.cpp:
  • runtime/Collector.cpp:
  • runtime/Completion.cpp:
  • runtime/ExecState.h:
  • runtime/FunctionPrototype.cpp:
  • runtime/JSActivation.cpp:
  • runtime/JSFunction.cpp:
  • runtime/JSGlobalData.cpp:
  • runtime/JSGlobalObject.cpp:
  • runtime/JSGlobalObjectFunctions.cpp:
  • wrec/WREC.cpp:

WebCore:

2008-11-17 Geoffrey Garen <[email protected]>

Reviewed by Sam Weinig.


Updated for JavaScriptCore renames.

  • ForwardingHeaders/VM: Removed.
  • ForwardingHeaders/VM/Machine.h: Removed.
  • ForwardingHeaders/interpreter: Added.
  • ForwardingHeaders/interpreter/Interpreter.h: Copied from ForwardingHeaders/VM/Machine.h.
  • WebCore.pro:
  • bindings/js/JSXMLHttpRequestCustom.cpp:
  • page/Console.cpp:
  • webcore-base.bkl:

WebKit/wx:

2008-11-17 Geoffrey Garen <[email protected]>

Reviewed by Sam Weinig.


Updated for JavaScriptCore renames.

  • presets/wxwebkit.bkl:
  • Property svn:eol-style set to native
File size: 5.4 KB
Line 
1/*
2 * Copyright (C) 2008 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#include "config.h"
30#include "JSGlobalData.h"
31
32#include "ArgList.h"
33#include "CommonIdentifiers.h"
34#include "JSActivation.h"
35#include "JSClassRef.h"
36#include "JSLock.h"
37#include "JSNotAnObject.h"
38#include "JSStaticScopeObject.h"
39#include "Interpreter.h"
40#include "Parser.h"
41#include "Collector.h"
42#include "Lexer.h"
43#include "Lookup.h"
44#include "Nodes.h"
45
46#if ENABLE(JSC_MULTIPLE_THREADS)
47#include <wtf/Threading.h>
48#endif
49
50#if PLATFORM(MAC)
51#include "ProfilerServer.h"
52#endif
53
54using namespace WTF;
55
56namespace JSC {
57
58extern const HashTable arrayTable;
59extern const HashTable dateTable;
60extern const HashTable mathTable;
61extern const HashTable numberTable;
62extern const HashTable regExpTable;
63extern const HashTable regExpConstructorTable;
64extern const HashTable stringTable;
65
66JSGlobalData::JSGlobalData(bool isShared)
67 : interpreter(new Interpreter)
68 , exception(noValue())
69 , arrayTable(new HashTable(JSC::arrayTable))
70 , dateTable(new HashTable(JSC::dateTable))
71 , mathTable(new HashTable(JSC::mathTable))
72 , numberTable(new HashTable(JSC::numberTable))
73 , regExpTable(new HashTable(JSC::regExpTable))
74 , regExpConstructorTable(new HashTable(JSC::regExpConstructorTable))
75 , stringTable(new HashTable(JSC::stringTable))
76 , activationStructure(JSActivation::createStructure(jsNull()))
77 , interruptedExecutionErrorStructure(JSObject::createStructure(jsNull()))
78 , staticScopeStructure(JSStaticScopeObject::createStructure(jsNull()))
79 , stringStructure(JSString::createStructure(jsNull()))
80 , notAnObjectErrorStubStructure(JSNotAnObjectErrorStub::createStructure(jsNull()))
81 , notAnObjectStructure(JSNotAnObject::createStructure(jsNull()))
82 , numberStructure(JSNumberCell::createStructure(jsNull()))
83 , identifierTable(createIdentifierTable())
84 , propertyNames(new CommonIdentifiers(this))
85 , emptyList(new ArgList)
86 , newParserObjects(0)
87 , parserObjectExtraRefCounts(0)
88 , lexer(new Lexer(this))
89 , parser(new Parser)
90 , head(0)
91 , dynamicGlobalObject(0)
92 , isSharedInstance(isShared)
93 , clientData(0)
94 , heap(this)
95{
96#if PLATFORM(MAC)
97 startProfilerServerIfNeeded();
98#endif
99 interpreter->initialize(this);
100}
101
102JSGlobalData::~JSGlobalData()
103{
104 // By the time this is destroyed, heap.destroy() must already have been called.
105
106 delete interpreter;
107#ifndef NDEBUG
108 // Zeroing out to make the behavior more predictable when someone attempts to use a deleted instance.
109 interpreter = 0;
110#endif
111
112 arrayTable->deleteTable();
113 dateTable->deleteTable();
114 mathTable->deleteTable();
115 numberTable->deleteTable();
116 regExpTable->deleteTable();
117 regExpConstructorTable->deleteTable();
118 stringTable->deleteTable();
119 delete arrayTable;
120 delete dateTable;
121 delete mathTable;
122 delete numberTable;
123 delete regExpTable;
124 delete regExpConstructorTable;
125 delete stringTable;
126
127 delete parser;
128 delete lexer;
129
130 deleteAllValues(opaqueJSClassData);
131
132 delete emptyList;
133
134 delete propertyNames;
135 deleteIdentifierTable(identifierTable);
136
137 delete newParserObjects;
138 delete parserObjectExtraRefCounts;
139
140 delete clientData;
141}
142
143PassRefPtr<JSGlobalData> JSGlobalData::create()
144{
145 return adoptRef(new JSGlobalData);
146}
147
148PassRefPtr<JSGlobalData> JSGlobalData::createLeaked()
149{
150#ifndef NDEBUG
151 Structure::startIgnoringLeaks();
152 RefPtr<JSGlobalData> data = create();
153 Structure::stopIgnoringLeaks();
154 return data.release();
155#else
156 return create();
157#endif
158}
159
160bool JSGlobalData::sharedInstanceExists()
161{
162 return sharedInstanceInternal();
163}
164
165JSGlobalData& JSGlobalData::sharedInstance()
166{
167 JSGlobalData*& instance = sharedInstanceInternal();
168 if (!instance)
169 instance = new JSGlobalData(true);
170 return *instance;
171}
172
173JSGlobalData*& JSGlobalData::sharedInstanceInternal()
174{
175 ASSERT(JSLock::currentThreadIsHoldingLock());
176 static JSGlobalData* sharedInstance;
177 return sharedInstance;
178}
179
180JSGlobalData::ClientData::~ClientData()
181{
182}
183
184}
Note: See TracBrowser for help on using the repository browser.