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

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

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

Reviewed by Sam Weinig.


Renamed BytecodeInterpreter => Interpreter.

  • JavaScriptCore.exp:
  • VM/CTI.cpp: (JSC::): (JSC::CTI::compileOpCall): (JSC::CTI::emitSlowScriptCheck): (JSC::CTI::compileBinaryArithOpSlowCase): (JSC::CTI::privateCompileMainPass): (JSC::CTI::privateCompileSlowCases): (JSC::CTI::privateCompile): (JSC::CTI::privateCompileGetByIdSelf): (JSC::CTI::privateCompileGetByIdProto): (JSC::CTI::privateCompileGetByIdChain): (JSC::CTI::privateCompilePutByIdReplace): (JSC::CTI::privateCompilePutByIdTransition): (JSC::CTI::privateCompileCTIMachineTrampolines): (JSC::CTI::freeCTIMachineTrampolines): (JSC::CTI::patchGetByIdSelf): (JSC::CTI::patchPutByIdReplace): (JSC::CTI::privateCompilePatchGetArrayLength):
  • VM/CTI.h:
  • VM/CodeBlock.cpp: (JSC::CodeBlock::printStructures): (JSC::CodeBlock::derefStructures): (JSC::CodeBlock::refStructures):
  • VM/Machine.cpp: (JSC::jsLess): (JSC::jsLessEq): (JSC::Interpreter::resolve): (JSC::Interpreter::resolveSkip): (JSC::Interpreter::resolveGlobal): (JSC::Interpreter::resolveBase): (JSC::Interpreter::resolveBaseAndProperty): (JSC::Interpreter::resolveBaseAndFunc): (JSC::Interpreter::slideRegisterWindowForCall): (JSC::Interpreter::callEval): (JSC::Interpreter::Interpreter): (JSC::Interpreter::initialize): (JSC::Interpreter::~Interpreter): (JSC::Interpreter::dumpCallFrame): (JSC::Interpreter::dumpRegisters): (JSC::Interpreter::isOpcode): (JSC::Interpreter::unwindCallFrame): (JSC::Interpreter::throwException): (JSC::Interpreter::execute): (JSC::Interpreter::debug): (JSC::Interpreter::resetTimeoutCheck): (JSC::Interpreter::checkTimeout): (JSC::Interpreter::createExceptionScope): (JSC::Interpreter::tryCachePutByID): (JSC::Interpreter::uncachePutByID): (JSC::Interpreter::tryCacheGetByID): (JSC::Interpreter::uncacheGetByID): (JSC::Interpreter::privateExecute): (JSC::Interpreter::retrieveArguments): (JSC::Interpreter::retrieveCaller): (JSC::Interpreter::retrieveLastCaller): (JSC::Interpreter::findFunctionCallFrame): (JSC::Interpreter::tryCTICachePutByID): (JSC::Interpreter::tryCTICacheGetByID): (JSC::Interpreter::cti_op_convert_this): (JSC::Interpreter::cti_op_end): (JSC::Interpreter::cti_op_add): (JSC::Interpreter::cti_op_pre_inc): (JSC::Interpreter::cti_timeout_check): (JSC::Interpreter::cti_register_file_check): (JSC::Interpreter::cti_op_loop_if_less): (JSC::Interpreter::cti_op_loop_if_lesseq): (JSC::Interpreter::cti_op_new_object): (JSC::Interpreter::cti_op_put_by_id): (JSC::Interpreter::cti_op_put_by_id_second): (JSC::Interpreter::cti_op_put_by_id_generic): (JSC::Interpreter::cti_op_put_by_id_fail): (JSC::Interpreter::cti_op_get_by_id): (JSC::Interpreter::cti_op_get_by_id_second): (JSC::Interpreter::cti_op_get_by_id_generic): (JSC::Interpreter::cti_op_get_by_id_fail): (JSC::Interpreter::cti_op_instanceof): (JSC::Interpreter::cti_op_del_by_id): (JSC::Interpreter::cti_op_mul): (JSC::Interpreter::cti_op_new_func): (JSC::Interpreter::cti_op_call_JSFunction): (JSC::Interpreter::cti_op_call_arityCheck): (JSC::Interpreter::cti_vm_dontLazyLinkCall): (JSC::Interpreter::cti_vm_lazyLinkCall): (JSC::Interpreter::cti_op_push_activation): (JSC::Interpreter::cti_op_call_NotJSFunction): (JSC::Interpreter::cti_op_create_arguments): (JSC::Interpreter::cti_op_create_arguments_no_params): (JSC::Interpreter::cti_op_tear_off_activation): (JSC::Interpreter::cti_op_tear_off_arguments): (JSC::Interpreter::cti_op_profile_will_call): (JSC::Interpreter::cti_op_profile_did_call): (JSC::Interpreter::cti_op_ret_scopeChain): (JSC::Interpreter::cti_op_new_array): (JSC::Interpreter::cti_op_resolve): (JSC::Interpreter::cti_op_construct_JSConstruct): (JSC::Interpreter::cti_op_construct_NotJSConstruct): (JSC::Interpreter::cti_op_get_by_val): (JSC::Interpreter::cti_op_resolve_func): (JSC::Interpreter::cti_op_sub): (JSC::Interpreter::cti_op_put_by_val): (JSC::Interpreter::cti_op_put_by_val_array): (JSC::Interpreter::cti_op_lesseq): (JSC::Interpreter::cti_op_loop_if_true): (JSC::Interpreter::cti_op_negate): (JSC::Interpreter::cti_op_resolve_base): (JSC::Interpreter::cti_op_resolve_skip): (JSC::Interpreter::cti_op_resolve_global): (JSC::Interpreter::cti_op_div): (JSC::Interpreter::cti_op_pre_dec): (JSC::Interpreter::cti_op_jless): (JSC::Interpreter::cti_op_not): (JSC::Interpreter::cti_op_jtrue): (JSC::Interpreter::cti_op_post_inc): (JSC::Interpreter::cti_op_eq): (JSC::Interpreter::cti_op_lshift): (JSC::Interpreter::cti_op_bitand): (JSC::Interpreter::cti_op_rshift): (JSC::Interpreter::cti_op_bitnot): (JSC::Interpreter::cti_op_resolve_with_base): (JSC::Interpreter::cti_op_new_func_exp): (JSC::Interpreter::cti_op_mod): (JSC::Interpreter::cti_op_less): (JSC::Interpreter::cti_op_neq): (JSC::Interpreter::cti_op_post_dec): (JSC::Interpreter::cti_op_urshift): (JSC::Interpreter::cti_op_bitxor): (JSC::Interpreter::cti_op_new_regexp): (JSC::Interpreter::cti_op_bitor): (JSC::Interpreter::cti_op_call_eval): (JSC::Interpreter::cti_op_throw): (JSC::Interpreter::cti_op_get_pnames): (JSC::Interpreter::cti_op_next_pname): (JSC::Interpreter::cti_op_push_scope): (JSC::Interpreter::cti_op_pop_scope): (JSC::Interpreter::cti_op_typeof): (JSC::Interpreter::cti_op_is_undefined): (JSC::Interpreter::cti_op_is_boolean): (JSC::Interpreter::cti_op_is_number): (JSC::Interpreter::cti_op_is_string): (JSC::Interpreter::cti_op_is_object): (JSC::Interpreter::cti_op_is_function): (JSC::Interpreter::cti_op_stricteq): (JSC::Interpreter::cti_op_nstricteq): (JSC::Interpreter::cti_op_to_jsnumber): (JSC::Interpreter::cti_op_in): (JSC::Interpreter::cti_op_push_new_scope): (JSC::Interpreter::cti_op_jmp_scopes): (JSC::Interpreter::cti_op_put_by_index): (JSC::Interpreter::cti_op_switch_imm): (JSC::Interpreter::cti_op_switch_char): (JSC::Interpreter::cti_op_switch_string): (JSC::Interpreter::cti_op_del_by_val): (JSC::Interpreter::cti_op_put_getter): (JSC::Interpreter::cti_op_put_setter): (JSC::Interpreter::cti_op_new_error): (JSC::Interpreter::cti_op_debug): (JSC::Interpreter::cti_vm_throw):
  • VM/Machine.h:
  • VM/Register.h:
  • VM/SamplingTool.h: (JSC::SamplingTool::SamplingTool):
  • bytecompiler/CodeGenerator.cpp: (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::BytecodeGenerator):
  • jsc.cpp: (runWithScripts):
  • runtime/ExecState.h: (JSC::ExecState::interpreter):
  • runtime/JSCell.h:
  • runtime/JSFunction.h:
  • runtime/JSGlobalData.cpp: (JSC::JSGlobalData::JSGlobalData):
  • runtime/JSGlobalData.h:
  • runtime/JSString.h:
  • wrec/WREC.cpp: (WREC::compileRegExp):
  • wrec/WREC.h:
  • 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 "Machine.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.