source: webkit/trunk/JavaScriptCore/runtime/JSArray.h@ 38473

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

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

Reviewed by a few people on squirrelfish-dev.


Renamed CTI => JIT.

  • VM/CTI.cpp: (JSC::JIT::killLastResultRegister): (JSC::JIT::emitGetVirtualRegister): (JSC::JIT::emitGetVirtualRegisters): (JSC::JIT::emitPutCTIArgFromVirtualRegister): (JSC::JIT::emitPutCTIArg): (JSC::JIT::emitGetCTIArg): (JSC::JIT::emitPutCTIArgConstant): (JSC::JIT::getConstantImmediateNumericArg): (JSC::JIT::emitPutCTIParam): (JSC::JIT::emitGetCTIParam): (JSC::JIT::emitPutToCallFrameHeader): (JSC::JIT::emitGetFromCallFrameHeader): (JSC::JIT::emitPutVirtualRegister): (JSC::JIT::emitInitRegister): (JSC::JIT::printBytecodeOperandTypes): (JSC::JIT::emitAllocateNumber): (JSC::JIT::emitNakedCall): (JSC::JIT::emitNakedFastCall): (JSC::JIT::emitCTICall): (JSC::JIT::emitJumpSlowCaseIfNotJSCell): (JSC::JIT::linkSlowCaseIfNotJSCell): (JSC::JIT::emitJumpSlowCaseIfNotImmNum): (JSC::JIT::emitJumpSlowCaseIfNotImmNums): (JSC::JIT::getDeTaggedConstantImmediate): (JSC::JIT::emitFastArithDeTagImmediate): (JSC::JIT::emitFastArithDeTagImmediateJumpIfZero): (JSC::JIT::emitFastArithReTagImmediate): (JSC::JIT::emitFastArithPotentiallyReTagImmediate): (JSC::JIT::emitFastArithImmToInt): (JSC::JIT::emitFastArithIntToImmOrSlowCase): (JSC::JIT::emitFastArithIntToImmNoCheck): (JSC::JIT::emitArithIntToImmWithJump): (JSC::JIT::emitTagAsBoolImmediate): (JSC::JIT::JIT): (JSC::JIT::compileOpCallInitializeCallFrame): (JSC::JIT::compileOpCallSetupArgs): (JSC::JIT::compileOpCallEvalSetupArgs): (JSC::JIT::compileOpConstructSetupArgs): (JSC::JIT::compileOpCall): (JSC::JIT::compileOpStrictEq): (JSC::JIT::emitSlowScriptCheck): (JSC::JIT::putDoubleResultToJSNumberCellOrJSImmediate): (JSC::JIT::compileBinaryArithOp): (JSC::JIT::compileBinaryArithOpSlowCase): (JSC::JIT::privateCompileMainPass): (JSC::JIT::privateCompileLinkPass): (JSC::JIT::privateCompileSlowCases): (JSC::JIT::privateCompile): (JSC::JIT::privateCompileGetByIdSelf): (JSC::JIT::privateCompileGetByIdProto): (JSC::JIT::privateCompileGetByIdChain): (JSC::JIT::privateCompilePutByIdReplace): (JSC::JIT::privateCompilePutByIdTransition): (JSC::JIT::unlinkCall): (JSC::JIT::linkCall): (JSC::JIT::privateCompileCTIMachineTrampolines): (JSC::JIT::freeCTIMachineTrampolines): (JSC::JIT::patchGetByIdSelf): (JSC::JIT::patchPutByIdReplace): (JSC::JIT::privateCompilePatchGetArrayLength): (JSC::JIT::emitGetVariableObjectRegister): (JSC::JIT::emitPutVariableObjectRegister):
  • VM/CTI.h: (JSC::JIT::compile): (JSC::JIT::compileGetByIdSelf): (JSC::JIT::compileGetByIdProto): (JSC::JIT::compileGetByIdChain): (JSC::JIT::compilePutByIdReplace): (JSC::JIT::compilePutByIdTransition): (JSC::JIT::compileCTIMachineTrampolines): (JSC::JIT::compilePatchGetArrayLength):
  • VM/CodeBlock.cpp: (JSC::CodeBlock::unlinkCallers):
  • VM/Machine.cpp: (JSC::Interpreter::initialize): (JSC::Interpreter::~Interpreter): (JSC::Interpreter::execute): (JSC::Interpreter::tryCTICachePutByID): (JSC::Interpreter::tryCTICacheGetByID): (JSC::Interpreter::cti_op_call_JSFunction): (JSC::Interpreter::cti_vm_dontLazyLinkCall): (JSC::Interpreter::cti_vm_lazyLinkCall):
  • VM/Machine.h:
  • VM/RegisterFile.h:
  • parser/Nodes.h:
  • runtime/JSArray.h:
  • runtime/JSCell.h:
  • runtime/JSFunction.h:
  • runtime/JSImmediate.h:
  • runtime/JSNumberCell.h:
  • runtime/JSObject.h:
  • runtime/JSString.h:
  • runtime/JSVariableObject.h:
  • runtime/ScopeChain.h:
  • runtime/Structure.h:
  • runtime/TypeInfo.h:
  • runtime/UString.h:
  • Property svn:eol-style set to native
File size: 4.4 KB
Line 
1/*
2 * Copyright (C) 1999-2000 Harri Porten ([email protected])
3 * Copyright (C) 2003, 2007, 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 Lesser 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 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 */
20
21#ifndef JSArray_h
22#define JSArray_h
23
24#include "JSObject.h"
25
26namespace JSC {
27
28 typedef HashMap<unsigned, JSValue*> SparseArrayValueMap;
29
30 struct ArrayStorage {
31 unsigned m_length;
32 unsigned m_vectorLength;
33 unsigned m_numValuesInVector;
34 SparseArrayValueMap* m_sparseValueMap;
35 void* lazyCreationData; // A JSArray subclass can use this to fill the vector lazily.
36 JSValue* m_vector[1];
37 };
38
39 class JSArray : public JSObject {
40 friend class JIT;
41
42 public:
43 explicit JSArray(PassRefPtr<Structure>);
44 JSArray(PassRefPtr<Structure>, unsigned initialLength);
45 JSArray(ExecState*, PassRefPtr<Structure>, const ArgList& initialValues);
46 virtual ~JSArray();
47
48 virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
49 virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
50 virtual void put(ExecState*, unsigned propertyName, JSValue*); // FIXME: Make protected and add setItem.
51
52 static const ClassInfo info;
53
54 unsigned length() const { return m_storage->m_length; }
55 void setLength(unsigned); // OK to use on new arrays, but not if it might be a RegExpMatchArray.
56
57 void sort(ExecState*);
58 void sort(ExecState*, JSValue* compareFunction, CallType, const CallData&);
59
60 void push(ExecState*, JSValue*);
61 JSValue* pop();
62
63 bool canGetIndex(unsigned i) { return i < m_fastAccessCutoff; }
64 JSValue* getIndex(unsigned i)
65 {
66 ASSERT(canGetIndex(i));
67 return m_storage->m_vector[i];
68 }
69
70 bool canSetIndex(unsigned i) { return i < m_fastAccessCutoff; }
71 JSValue* setIndex(unsigned i, JSValue* v)
72 {
73 ASSERT(canSetIndex(i));
74 return m_storage->m_vector[i] = v;
75 }
76
77 void fillArgList(ExecState*, ArgList&);
78
79 static PassRefPtr<Structure> createStructure(JSValue* prototype)
80 {
81 return Structure::create(prototype, TypeInfo(ObjectType));
82 }
83
84 protected:
85 virtual void put(ExecState*, const Identifier& propertyName, JSValue*, PutPropertySlot&);
86 virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
87 virtual bool deleteProperty(ExecState*, unsigned propertyName);
88 virtual void getPropertyNames(ExecState*, PropertyNameArray&);
89 virtual void mark();
90
91 void* lazyCreationData();
92 void setLazyCreationData(void*);
93
94 private:
95 virtual const ClassInfo* classInfo() const { return &info; }
96
97 bool getOwnPropertySlotSlowCase(ExecState*, unsigned propertyName, PropertySlot&);
98 void putSlowCase(ExecState*, unsigned propertyName, JSValue*);
99
100 bool increaseVectorLength(unsigned newLength);
101
102 unsigned compactForSorting();
103
104 enum ConsistencyCheckType { NormalConsistencyCheck, DestructorConsistencyCheck, SortConsistencyCheck };
105 void checkConsistency(ConsistencyCheckType = NormalConsistencyCheck);
106
107 unsigned m_fastAccessCutoff;
108 ArrayStorage* m_storage;
109 };
110
111 JSArray* asArray(JSValue*);
112
113 JSArray* constructEmptyArray(ExecState*);
114 JSArray* constructEmptyArray(ExecState*, unsigned initialLength);
115 JSArray* constructArray(ExecState*, JSValue* singleItemValue);
116 JSArray* constructArray(ExecState*, const ArgList& values);
117
118 inline JSArray* asArray(JSValue* value)
119 {
120 ASSERT(asObject(value)->inherits(&JSArray::info));
121 return static_cast<JSArray*>(asObject(value));
122 }
123
124} // namespace JSC
125
126#endif // JSArray_h
Note: See TracBrowser for help on using the repository browser.