source: webkit/trunk/JavaScriptCore/runtime/JSCell.cpp@ 50320

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

At long last, I pronounce the death of AllInOneFile.cpp.

Patch by Geoffrey Garen <[email protected]> on 2009-10-08
Reviewed by Maciej Stachowiak.

SunSpider reports a 1.01x speedup.

to compilation stages.

  • parser/Grammar.y:
  • parser/Lexer.cpp:
  • parser/Lexer.h:

(JSC::jscyylex):

  • runtime/ArrayConstructor.cpp:

(JSC::constructArrayWithSizeQuirk):

  • runtime/Collector.h:
  • runtime/JSCell.cpp:

(JSC::JSCell::operator new):

  • runtime/JSCell.h:

(JSC::JSCell::operator new):

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::operator new):

  • runtime/JSNumberCell.h:

(JSC::JSNumberCell::operator new):

  • runtime/JSString.cpp:
  • runtime/JSString.h:

(JSC::jsString):
(JSC::jsSubstring):
(JSC::jsOwnedString):

  • runtime/RegExpConstructor.cpp:
  • runtime/RegExpConstructor.h:

(JSC::RegExpConstructorPrivate::RegExpConstructorPrivate):
(JSC::RegExpConstructorPrivate::lastOvector):
(JSC::RegExpConstructorPrivate::tempOvector):
(JSC::RegExpConstructorPrivate::changeLastOvector):
(JSC::RegExpConstructor::performMatch):

  • runtime/StringPrototype.cpp:

(JSC::stringProtoFuncMatch):

  • yarr/RegexJIT.cpp:
  • yarr/RegexJIT.h:

(JSC::Yarr::executeRegex): Inlined a few things that Shark said
were hot, on the presumption that AllInOneFile.cpp used to inline them
automatically.

  • Property svn:eol-style set to native
File size: 5.9 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#include "config.h"
24#include "JSCell.h"
25
26#include "JSFunction.h"
27#include "JSString.h"
28#include "JSObject.h"
29#include <wtf/MathExtras.h>
30
31namespace JSC {
32
33#if defined NAN && defined INFINITY
34
35extern const double NaN = NAN;
36extern const double Inf = INFINITY;
37
38#else // !(defined NAN && defined INFINITY)
39
40// The trick is to define the NaN and Inf globals with a different type than the declaration.
41// This trick works because the mangled name of the globals does not include the type, although
42// I'm not sure that's guaranteed. There could be alignment issues with this, since arrays of
43// characters don't necessarily need the same alignment doubles do, but for now it seems to work.
44// It would be good to figure out a 100% clean way that still avoids code that runs at init time.
45
46// Note, we have to use union to ensure alignment. Otherwise, NaN_Bytes can start anywhere,
47// while NaN_double has to be 4-byte aligned for 32-bits.
48// With -fstrict-aliasing enabled, unions are the only safe way to do type masquerading.
49
50static const union {
51 struct {
52 unsigned char NaN_Bytes[8];
53 unsigned char Inf_Bytes[8];
54 } bytes;
55
56 struct {
57 double NaN_Double;
58 double Inf_Double;
59 } doubles;
60
61} NaNInf = { {
62#if PLATFORM(BIG_ENDIAN)
63 { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 },
64 { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 }
65#elif PLATFORM(MIDDLE_ENDIAN)
66 { 0, 0, 0xf8, 0x7f, 0, 0, 0, 0 },
67 { 0, 0, 0xf0, 0x7f, 0, 0, 0, 0 }
68#else
69 { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f },
70 { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }
71#endif
72} } ;
73
74extern const double NaN = NaNInf.doubles.NaN_Double;
75extern const double Inf = NaNInf.doubles.Inf_Double;
76
77#endif // !(defined NAN && defined INFINITY)
78
79void* JSCell::operator new(size_t size, ExecState* exec)
80{
81 return exec->heap()->allocate(size);
82}
83
84bool JSCell::getUInt32(uint32_t&) const
85{
86 return false;
87}
88
89bool JSCell::getString(UString&stringValue) const
90{
91 if (!isString())
92 return false;
93 stringValue = static_cast<const JSString*>(this)->value();
94 return true;
95}
96
97UString JSCell::getString() const
98{
99 return isString() ? static_cast<const JSString*>(this)->value() : UString();
100}
101
102JSObject* JSCell::getObject()
103{
104 return isObject() ? asObject(this) : 0;
105}
106
107const JSObject* JSCell::getObject() const
108{
109 return isObject() ? static_cast<const JSObject*>(this) : 0;
110}
111
112CallType JSCell::getCallData(CallData&)
113{
114 return CallTypeNone;
115}
116
117ConstructType JSCell::getConstructData(ConstructData&)
118{
119 return ConstructTypeNone;
120}
121
122bool JSCell::getOwnPropertySlot(ExecState* exec, const Identifier& identifier, PropertySlot& slot)
123{
124 // This is not a general purpose implementation of getOwnPropertySlot.
125 // It should only be called by JSValue::get.
126 // It calls getPropertySlot, not getOwnPropertySlot.
127 JSObject* object = toObject(exec);
128 slot.setBase(object);
129 if (!object->getPropertySlot(exec, identifier, slot))
130 slot.setUndefined();
131 return true;
132}
133
134bool JSCell::getOwnPropertySlot(ExecState* exec, unsigned identifier, PropertySlot& slot)
135{
136 // This is not a general purpose implementation of getOwnPropertySlot.
137 // It should only be called by JSValue::get.
138 // It calls getPropertySlot, not getOwnPropertySlot.
139 JSObject* object = toObject(exec);
140 slot.setBase(object);
141 if (!object->getPropertySlot(exec, identifier, slot))
142 slot.setUndefined();
143 return true;
144}
145
146void JSCell::put(ExecState* exec, const Identifier& identifier, JSValue value, PutPropertySlot& slot)
147{
148 toObject(exec)->put(exec, identifier, value, slot);
149}
150
151void JSCell::put(ExecState* exec, unsigned identifier, JSValue value)
152{
153 toObject(exec)->put(exec, identifier, value);
154}
155
156bool JSCell::deleteProperty(ExecState* exec, const Identifier& identifier)
157{
158 return toObject(exec)->deleteProperty(exec, identifier);
159}
160
161bool JSCell::deleteProperty(ExecState* exec, unsigned identifier)
162{
163 return toObject(exec)->deleteProperty(exec, identifier);
164}
165
166JSObject* JSCell::toThisObject(ExecState* exec) const
167{
168 return toObject(exec);
169}
170
171UString JSCell::toThisString(ExecState* exec) const
172{
173 return toThisObject(exec)->toString(exec);
174}
175
176JSString* JSCell::toThisJSString(ExecState* exec)
177{
178 return jsString(exec, toThisString(exec));
179}
180
181const ClassInfo* JSCell::classInfo() const
182{
183 return 0;
184}
185
186JSValue JSCell::getJSNumber()
187{
188 return JSValue();
189}
190
191bool JSCell::isGetterSetter() const
192{
193 return false;
194}
195
196JSValue JSCell::toPrimitive(ExecState*, PreferredPrimitiveType) const
197{
198 ASSERT_NOT_REACHED();
199 return JSValue();
200}
201
202bool JSCell::getPrimitiveNumber(ExecState*, double&, JSValue&)
203{
204 ASSERT_NOT_REACHED();
205 return false;
206}
207
208bool JSCell::toBoolean(ExecState*) const
209{
210 ASSERT_NOT_REACHED();
211 return false;
212}
213
214double JSCell::toNumber(ExecState*) const
215{
216 ASSERT_NOT_REACHED();
217 return 0;
218}
219
220UString JSCell::toString(ExecState*) const
221{
222 ASSERT_NOT_REACHED();
223 return UString();
224}
225
226JSObject* JSCell::toObject(ExecState*) const
227{
228 ASSERT_NOT_REACHED();
229 return 0;
230}
231
232} // namespace JSC
Note: See TracBrowser for help on using the repository browser.