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

Last change on this file since 40176 was 39958, checked in by [email protected], 16 years ago

2009-01-15 Gavin Barraclough <[email protected]>

Reviewed by Geoff Garen.

On x86-64 allow JSImmediate to encode 64-bit double precision values.
This patch only affects builds that set USE(ALTERNATE_JSIMMEDIATE).

Updates the implementation of JSValuePtr
and JSImmediate:: methods that operate on neumeric values to be be aware of the new representation. When this representation is in use, the class JSNumberCell is redundant and is compiled out.

The format of the new immediate representation is documented in JSImmediate.h.

  • JavaScriptCore.exp:
  • assembler/MacroAssembler.h: (JSC::MacroAssembler::subPtr):
  • assembler/X86Assembler.h: (JSC::X86Assembler::): (JSC::X86Assembler::subq_rr): (JSC::X86Assembler::movq_rr): (JSC::X86Assembler::ucomisd_rr): (JSC::X86Assembler::X86InstructionFormatter::twoByteOp64):
  • interpreter/Interpreter.cpp: (JSC::Interpreter::cti_op_stricteq): (JSC::Interpreter::cti_op_nstricteq):
  • jit/JIT.cpp: (JSC::JIT::compileOpStrictEq): (JSC::JIT::privateCompileMainPass): (JSC::JIT::privateCompileSlowCases):
  • jit/JIT.h:
  • jit/JITArithmetic.cpp: (JSC::JIT::compileFastArith_op_lshift): (JSC::JIT::compileFastArith_op_rshift): (JSC::JIT::compileFastArith_op_bitand): (JSC::JIT::compileFastArith_op_mod): (JSC::JIT::compileFastArith_op_add): (JSC::JIT::compileFastArith_op_mul): (JSC::JIT::compileFastArith_op_post_inc): (JSC::JIT::compileFastArith_op_post_dec): (JSC::JIT::compileFastArith_op_pre_inc): (JSC::JIT::compileFastArith_op_pre_dec): (JSC::JIT::putDoubleResultToJSNumberCellOrJSImmediate): (JSC::JIT::compileBinaryArithOp):
  • jit/JITInlineMethods.h: (JSC::JIT::emitJumpIfBothJSCells): (JSC::JIT::emitJumpIfEitherNumber): (JSC::JIT::emitJumpIfNotEitherNumber): (JSC::JIT::emitJumpIfImmediateIntegerNumber): (JSC::JIT::emitJumpIfNotImmediateIntegerNumber): (JSC::JIT::emitJumpIfNotImmediateIntegerNumbers): (JSC::JIT::emitJumpSlowCaseIfNotImmediateIntegerNumber): (JSC::JIT::emitJumpSlowCaseIfNotImmediateIntegerNumbers): (JSC::JIT::emitFastArithDeTagImmediate): (JSC::JIT::emitFastArithDeTagImmediateJumpIfZero): (JSC::JIT::emitFastArithReTagImmediate): (JSC::JIT::emitFastArithIntToImmNoCheck):
  • runtime/JSCell.h:
  • runtime/JSGlobalData.cpp: (JSC::JSGlobalData::JSGlobalData):
  • runtime/JSImmediate.cpp: (JSC::JSImmediate::toThisObject): (JSC::JSImmediate::toObject): (JSC::JSImmediate::toString):
  • runtime/JSImmediate.h: (JSC::wtf_reinterpret_cast): (JSC::JSImmediate::isNumber): (JSC::JSImmediate::isIntegerNumber): (JSC::JSImmediate::isDoubleNumber): (JSC::JSImmediate::isPositiveIntegerNumber): (JSC::JSImmediate::areBothImmediateIntegerNumbers): (JSC::JSImmediate::makeInt): (JSC::JSImmediate::makeDouble): (JSC::JSImmediate::doubleValue): (JSC::doubleToBoolean): (JSC::JSImmediate::toBoolean): (JSC::JSImmediate::getTruncatedUInt32): (JSC::JSImmediate::makeOutOfIntegerRange): (JSC::JSImmediate::from): (JSC::JSImmediate::getTruncatedInt32): (JSC::JSImmediate::toDouble): (JSC::JSImmediate::getUInt32): (JSC::JSValuePtr::isInt32Fast): (JSC::JSValuePtr::isUInt32Fast): (JSC::JSValuePtr::areBothInt32Fast): (JSC::JSFastMath::canDoFastBitwiseOperations): (JSC::JSFastMath::xorImmediateNumbers): (JSC::JSFastMath::canDoFastRshift): (JSC::JSFastMath::canDoFastUrshift): (JSC::JSFastMath::rightShiftImmediateNumbers): (JSC::JSFastMath::canDoFastAdditiveOperations): (JSC::JSFastMath::addImmediateNumbers): (JSC::JSFastMath::subImmediateNumbers):
  • runtime/JSNumberCell.cpp: (JSC::jsNumberCell):
  • runtime/JSNumberCell.h: (JSC::createNumberStructure): (JSC::isNumberCell): (JSC::asNumberCell): (JSC::jsNumber): (JSC::JSValuePtr::isDoubleNumber): (JSC::JSValuePtr::getDoubleNumber): (JSC::JSValuePtr::isNumber): (JSC::JSValuePtr::uncheckedGetNumber): (JSC::jsNaN): (JSC::JSValuePtr::getNumber): (JSC::JSValuePtr::numberToInt32): (JSC::JSValuePtr::numberToUInt32):
  • runtime/JSValue.h:
  • runtime/NumberConstructor.cpp: (JSC::numberConstructorNegInfinity): (JSC::numberConstructorPosInfinity): (JSC::numberConstructorMaxValue): (JSC::numberConstructorMinValue):
  • runtime/NumberObject.cpp: (JSC::constructNumber):
  • runtime/NumberObject.h:
  • runtime/Operations.h: (JSC::JSValuePtr::equal): (JSC::JSValuePtr::equalSlowCaseInline): (JSC::JSValuePtr::strictEqual): (JSC::JSValuePtr::strictEqualSlowCaseInline):
  • wtf/Platform.h:
  • Property svn:eol-style set to native
File size: 5.6 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 "Collector.h"
34#include "CommonIdentifiers.h"
35#include "Interpreter.h"
36#include "JSActivation.h"
37#include "JSClassRef.h"
38#include "JSLock.h"
39#include "JSNotAnObject.h"
40#include "JSStaticScopeObject.h"
41#include "Parser.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#if !USE(ALTERNATE_JSIMMEDIATE)
83 , numberStructure(JSNumberCell::createStructure(jsNull()))
84#endif
85 , identifierTable(createIdentifierTable())
86 , propertyNames(new CommonIdentifiers(this))
87 , emptyList(new ArgList)
88 , newParserObjects(0)
89 , parserObjectExtraRefCounts(0)
90 , lexer(new Lexer(this))
91 , parser(new Parser)
92 , head(0)
93 , dynamicGlobalObject(0)
94 , isSharedInstance(isShared)
95 , clientData(0)
96 , scopeNodeBeingReparsed(0)
97 , heap(this)
98{
99#if PLATFORM(MAC)
100 startProfilerServerIfNeeded();
101#endif
102 interpreter->initialize(this);
103}
104
105JSGlobalData::~JSGlobalData()
106{
107 // By the time this is destroyed, heap.destroy() must already have been called.
108
109 delete interpreter;
110#ifndef NDEBUG
111 // Zeroing out to make the behavior more predictable when someone attempts to use a deleted instance.
112 interpreter = 0;
113#endif
114
115 arrayTable->deleteTable();
116 dateTable->deleteTable();
117 mathTable->deleteTable();
118 numberTable->deleteTable();
119 regExpTable->deleteTable();
120 regExpConstructorTable->deleteTable();
121 stringTable->deleteTable();
122 delete arrayTable;
123 delete dateTable;
124 delete mathTable;
125 delete numberTable;
126 delete regExpTable;
127 delete regExpConstructorTable;
128 delete stringTable;
129
130 delete parser;
131 delete lexer;
132
133 deleteAllValues(opaqueJSClassData);
134
135 delete emptyList;
136
137 delete propertyNames;
138 deleteIdentifierTable(identifierTable);
139
140 delete newParserObjects;
141 delete parserObjectExtraRefCounts;
142
143 delete clientData;
144}
145
146PassRefPtr<JSGlobalData> JSGlobalData::create()
147{
148 return adoptRef(new JSGlobalData);
149}
150
151PassRefPtr<JSGlobalData> JSGlobalData::createLeaked()
152{
153#ifndef NDEBUG
154 Structure::startIgnoringLeaks();
155 RefPtr<JSGlobalData> data = create();
156 Structure::stopIgnoringLeaks();
157 return data.release();
158#else
159 return create();
160#endif
161}
162
163bool JSGlobalData::sharedInstanceExists()
164{
165 return sharedInstanceInternal();
166}
167
168JSGlobalData& JSGlobalData::sharedInstance()
169{
170 JSGlobalData*& instance = sharedInstanceInternal();
171 if (!instance) {
172 instance = new JSGlobalData(true);
173#if ENABLE(JSC_MULTIPLE_THREADS)
174 instance->makeUsableFromMultipleThreads();
175#endif
176 }
177 return *instance;
178}
179
180JSGlobalData*& JSGlobalData::sharedInstanceInternal()
181{
182 ASSERT(JSLock::currentThreadIsHoldingLock());
183 static JSGlobalData* sharedInstance;
184 return sharedInstance;
185}
186
187JSGlobalData::ClientData::~ClientData()
188{
189}
190
191}
Note: See TracBrowser for help on using the repository browser.