source: webkit/trunk/JavaScriptCore/runtime/Operations.cpp@ 41126

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

2009-02-19 Geoffrey Garen <[email protected]>

Reviewed by Gavin Barraclough.


First step in splitting JIT functionality out of the Interpreter class:
Created JITStubs.h/.cpp, and moved Interpreter::cti_* into JITStubs.cpp.


Functions that the Interpreter and JITStubs share moved to Operations.h/.cpp.

  • GNUmakefile.am:
  • JavaScriptCore.pri:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • interpreter/Interpreter.cpp: (JSC::Interpreter::resolveBase): (JSC::Interpreter::checkTimeout): (JSC::Interpreter::privateExecute):
  • interpreter/Interpreter.h:
  • jit/JITStubs.cpp: Copied from interpreter/Interpreter.cpp. (JSC::Interpreter::cti_op_resolve_base):
  • jit/JITStubs.h: Copied from interpreter/Interpreter.h.
  • runtime/Operations.cpp: (JSC::jsAddSlowCase): (JSC::jsTypeStringForValue): (JSC::jsIsObjectType): (JSC::jsIsFunctionType):
  • runtime/Operations.h: (JSC::jsLess): (JSC::jsLessEq): (JSC::jsAdd): (JSC::cachePrototypeChain): (JSC::countPrototypeChainEntriesAndCheckForProxies): (JSC::resolveBase):
  • Property svn:eol-style set to native
File size: 3.7 KB
Line 
1/*
2 * Copyright (C) 1999-2000 Harri Porten ([email protected])
3 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 *
20 */
21
22#include "config.h"
23#include "Operations.h"
24
25#include "Error.h"
26#include "JSObject.h"
27#include "JSString.h"
28#include <math.h>
29#include <stdio.h>
30#include <wtf/MathExtras.h>
31
32#if HAVE(FLOAT_H)
33#include <float.h>
34#endif
35
36namespace JSC {
37
38bool JSValuePtr::equalSlowCase(ExecState* exec, JSValuePtr v1, JSValuePtr v2)
39{
40 return equalSlowCaseInline(exec, v1, v2);
41}
42
43bool JSValuePtr::strictEqualSlowCase(JSValuePtr v1, JSValuePtr v2)
44{
45 return strictEqualSlowCaseInline(v1, v2);
46}
47
48NEVER_INLINE JSValuePtr throwOutOfMemoryError(ExecState* exec)
49{
50 JSObject* error = Error::create(exec, GeneralError, "Out of memory");
51 exec->setException(error);
52 return error;
53}
54
55NEVER_INLINE JSValuePtr jsAddSlowCase(CallFrame* callFrame, JSValuePtr v1, JSValuePtr v2)
56{
57 // exception for the Date exception in defaultValue()
58 JSValuePtr p1 = v1.toPrimitive(callFrame);
59 JSValuePtr p2 = v2.toPrimitive(callFrame);
60
61 if (p1.isString() || p2.isString()) {
62 RefPtr<UString::Rep> value = concatenate(p1.toString(callFrame).rep(), p2.toString(callFrame).rep());
63 if (!value)
64 return throwOutOfMemoryError(callFrame);
65 return jsString(callFrame, value.release());
66 }
67
68 return jsNumber(callFrame, p1.toNumber(callFrame) + p2.toNumber(callFrame));
69}
70
71JSValuePtr jsTypeStringForValue(CallFrame* callFrame, JSValuePtr v)
72{
73 if (v.isUndefined())
74 return jsNontrivialString(callFrame, "undefined");
75 if (v.isBoolean())
76 return jsNontrivialString(callFrame, "boolean");
77 if (v.isNumber())
78 return jsNontrivialString(callFrame, "number");
79 if (v.isString())
80 return jsNontrivialString(callFrame, "string");
81 if (v.isObject()) {
82 // Return "undefined" for objects that should be treated
83 // as null when doing comparisons.
84 if (asObject(v)->structure()->typeInfo().masqueradesAsUndefined())
85 return jsNontrivialString(callFrame, "undefined");
86 CallData callData;
87 if (asObject(v)->getCallData(callData) != CallTypeNone)
88 return jsNontrivialString(callFrame, "function");
89 }
90 return jsNontrivialString(callFrame, "object");
91}
92
93bool jsIsObjectType(JSValuePtr v)
94{
95 if (!v.isCell())
96 return v.isNull();
97
98 JSType type = asCell(v)->structure()->typeInfo().type();
99 if (type == NumberType || type == StringType)
100 return false;
101 if (type == ObjectType) {
102 if (asObject(v)->structure()->typeInfo().masqueradesAsUndefined())
103 return false;
104 CallData callData;
105 if (asObject(v)->getCallData(callData) != CallTypeNone)
106 return false;
107 }
108 return true;
109}
110
111bool jsIsFunctionType(JSValuePtr v)
112{
113 if (v.isObject()) {
114 CallData callData;
115 if (asObject(v)->getCallData(callData) != CallTypeNone)
116 return true;
117 }
118 return false;
119}
120
121} // namespace JSC
Note: See TracBrowser for help on using the repository browser.