Changeset 41168 in webkit for trunk/JavaScriptCore/runtime
- Timestamp:
- Feb 23, 2009, 7:58:09 PM (16 years ago)
- Location:
- trunk/JavaScriptCore/runtime
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/ArrayPrototype.cpp
r40993 r41168 301 301 JSValuePtr arrayProtoFuncPop(ExecState* exec, JSObject*, JSValuePtr thisValue, const ArgList&) 302 302 { 303 if ( exec->interpreter()->isJSArray(thisValue))303 if (isJSArray(&exec->globalData(), thisValue)) 304 304 return asArray(thisValue)->pop(); 305 305 … … 320 320 JSValuePtr arrayProtoFuncPush(ExecState* exec, JSObject*, JSValuePtr thisValue, const ArgList& args) 321 321 { 322 if ( exec->interpreter()->isJSArray(thisValue) && args.size() == 1) {322 if (isJSArray(&exec->globalData(), thisValue) && args.size() == 1) { 323 323 JSArray* array = asArray(thisValue); 324 324 array->push(exec, args.begin()->jsValue(exec)); -
trunk/JavaScriptCore/runtime/FunctionPrototype.cpp
r41083 r41168 113 113 if (asObject(array)->classInfo() == &Arguments::info) 114 114 asArguments(array)->fillArgList(exec, applyArgs); 115 else if ( exec->interpreter()->isJSArray(array))115 else if (isJSArray(&exec->globalData(), array)) 116 116 asArray(array)->fillArgList(exec, applyArgs); 117 117 else if (asObject(array)->inherits(&JSArray::info)) { -
trunk/JavaScriptCore/runtime/JSArray.h
r40993 r41168 123 123 } 124 124 125 inline bool isJSArray(JSGlobalData* globalData, JSValuePtr v) { return v.isCell() && v.asCell()->vptr() == globalData->jsArrayVPtr; } 126 125 127 } // namespace JSC 126 128 -
trunk/JavaScriptCore/runtime/JSByteArray.h
r40536 r41168 34 34 35 35 class JSByteArray : public JSObject { 36 friend class Interpreter;36 friend class VPtrSet; 37 37 public: 38 38 bool canAccessIndex(unsigned i) { return i < m_storage->length(); } … … 108 108 return static_cast<JSByteArray*>(asCell(value)); 109 109 } 110 }111 110 112 #endif 111 inline bool isJSByteArray(JSGlobalData* globalData, JSValuePtr v) { return v.isCell() && v.asCell()->vptr() == globalData->jsByteArrayVPtr; } 112 113 } // namespace JSC 114 115 #endif // JSByteArray_h -
trunk/JavaScriptCore/runtime/JSCell.h
r40046 r41168 33 33 34 34 class JSCell : Noncopyable { 35 friend class JIT;36 35 friend class GetterSetter; 37 36 friend class Heap; 37 friend class JIT; 38 38 friend class JSNumberCell; 39 39 friend class JSObject; … … 41 41 friend class JSString; 42 42 friend class JSValuePtr; 43 friend class Interpreter;43 friend class VPtrSet; 44 44 45 45 private: -
trunk/JavaScriptCore/runtime/JSFunction.h
r41126 r41168 39 39 40 40 class JSFunction : public InternalFunction { 41 friend class Interpreter;42 41 friend class JIT; 43 42 friend class JITStubs; 43 friend class VPtrSet; 44 44 45 45 typedef InternalFunction Base; -
trunk/JavaScriptCore/runtime/JSGlobalData.cpp
r41126 r41168 36 36 #include "Interpreter.h" 37 37 #include "JSActivation.h" 38 #include "JSArray.h" 39 #include "JSByteArray.h" 38 40 #include "JSClassRef.h" 39 41 #include "JSLock.h" … … 65 67 extern const HashTable stringTable; 66 68 67 JSGlobalData::JSGlobalData(bool isShared) 69 struct VPtrSet { 70 VPtrSet(); 71 72 void* jsArrayVPtr; 73 void* jsByteArrayVPtr; 74 void* jsStringVPtr; 75 void* jsFunctionVPtr; 76 }; 77 78 VPtrSet::VPtrSet() 79 { 80 // Bizarrely, calling fastMalloc here is faster than allocating space on the stack. 81 void* storage = fastMalloc(sizeof(CollectorBlock)); 82 83 JSCell* jsArray = new (storage) JSArray(JSArray::createStructure(jsNull())); 84 jsArrayVPtr = jsArray->vptr(); 85 jsArray->~JSCell(); 86 87 JSCell* jsByteArray = new (storage) JSByteArray(JSByteArray::VPtrStealingHack); 88 jsByteArrayVPtr = jsByteArray->vptr(); 89 jsByteArray->~JSCell(); 90 91 JSCell* jsString = new (storage) JSString(JSString::VPtrStealingHack); 92 jsStringVPtr = jsString->vptr(); 93 jsString->~JSCell(); 94 95 JSCell* jsFunction = new (storage) JSFunction(JSFunction::createStructure(jsNull())); 96 jsFunctionVPtr = jsFunction->vptr(); 97 jsFunction->~JSCell(); 98 99 fastFree(storage); 100 } 101 102 JSGlobalData::JSGlobalData(bool isShared, const VPtrSet& vptrSet) 68 103 : isSharedInstance(isShared) 69 104 , clientData(0) 70 , interpreter(new Interpreter)71 , exception(noValue())72 , initializingLazyNumericCompareFunction(false)73 105 , arrayTable(new HashTable(JSC::arrayTable)) 74 106 , dateTable(new HashTable(JSC::dateTable)) … … 87 119 , numberStructure(JSNumberCell::createStructure(jsNull())) 88 120 #endif 121 , jsArrayVPtr(vptrSet.jsArrayVPtr) 122 , jsByteArrayVPtr(vptrSet.jsByteArrayVPtr) 123 , jsStringVPtr(vptrSet.jsStringVPtr) 124 , jsFunctionVPtr(vptrSet.jsFunctionVPtr) 89 125 , identifierTable(createIdentifierTable()) 90 126 , propertyNames(new CommonIdentifiers(this)) … … 92 128 , lexer(new Lexer(this)) 93 129 , parser(new Parser) 130 , interpreter(new Interpreter) 131 #if ENABLE(JIT) 132 , jitStubs(this) 133 #endif 134 , heap(this) 135 , exception(noValue()) 136 , initializingLazyNumericCompareFunction(false) 94 137 , newParserObjects(0) 95 138 , parserObjectExtraRefCounts(0) … … 97 140 , dynamicGlobalObject(0) 98 141 , scopeNodeBeingReparsed(0) 99 , heap(this)100 142 { 101 143 #if PLATFORM(MAC) 102 144 startProfilerServerIfNeeded(); 103 145 #endif 104 interpreter->initialize(this);105 146 } 106 147 … … 146 187 } 147 188 148 PassRefPtr<JSGlobalData> JSGlobalData::create( )149 { 150 return adoptRef(new JSGlobalData );189 PassRefPtr<JSGlobalData> JSGlobalData::create(bool isShared) 190 { 191 return adoptRef(new JSGlobalData(isShared, VPtrSet())); 151 192 } 152 193 … … 172 213 JSGlobalData*& instance = sharedInstanceInternal(); 173 214 if (!instance) { 174 instance = new JSGlobalData(true);215 instance = create(true).releaseRef(); 175 216 #if ENABLE(JSC_MULTIPLE_THREADS) 176 217 instance->makeUsableFromMultipleThreads(); -
trunk/JavaScriptCore/runtime/JSGlobalData.h
r41126 r41168 32 32 #include "Collector.h" 33 33 #include "ExecutableAllocator.h" 34 #include "JITStubs.h" 34 35 #include "JSValue.h" 35 36 #include "SmallStrings.h" … … 59 60 class UString; 60 61 struct HashTable; 62 struct VPtrSet; 61 63 62 64 class JSGlobalData : public RefCounted<JSGlobalData> { … … 69 71 static JSGlobalData& sharedInstance(); 70 72 71 static PassRefPtr<JSGlobalData> create( );73 static PassRefPtr<JSGlobalData> create(bool isShared = false); 72 74 static PassRefPtr<JSGlobalData> createLeaked(); 73 75 ~JSGlobalData(); … … 80 82 bool isSharedInstance; 81 83 ClientData* clientData; 82 83 Interpreter* interpreter;84 TimeoutChecker timeoutChecker;85 86 JSValuePtr exception;87 #if ENABLE(JIT)88 void* exceptionLocation;89 #endif90 91 const Vector<Instruction>& numericCompareFunction(ExecState*);92 Vector<Instruction> lazyNumericCompareFunction;93 bool initializingLazyNumericCompareFunction;94 84 95 85 const HashTable* arrayTable; … … 111 101 #endif 112 102 103 void* jsArrayVPtr; 104 void* jsByteArrayVPtr; 105 void* jsStringVPtr; 106 void* jsFunctionVPtr; 107 113 108 IdentifierTable* identifierTable; 114 109 CommonIdentifiers* propertyNames; 115 110 const ArgList* emptyList; // Lists are supposed to be allocated on the stack to have their elements properly marked, which is not the case here - but this list has nothing to mark. 116 111 SmallStrings smallStrings; 117 118 HashMap<OpaqueJSClass*, OpaqueJSClassContextData*> opaqueJSClassData; 112 113 #if ENABLE(ASSEMBLER) 114 ExecutableAllocator executableAllocator; 115 #endif 119 116 120 117 Lexer* lexer; 121 118 Parser* parser; 119 Interpreter* interpreter; 120 #if ENABLE(JIT) 121 JITStubs jitStubs; 122 #endif 123 TimeoutChecker timeoutChecker; 124 Heap heap; 125 126 JSValuePtr exception; 127 #if ENABLE(JIT) 128 void* exceptionLocation; 129 #endif 130 131 const Vector<Instruction>& numericCompareFunction(ExecState*); 132 Vector<Instruction> lazyNumericCompareFunction; 133 bool initializingLazyNumericCompareFunction; 134 135 HashMap<OpaqueJSClass*, OpaqueJSClassContextData*> opaqueJSClassData; 136 122 137 HashSet<ParserRefCounted*>* newParserObjects; 123 138 HashCountedSet<ParserRefCounted*>* parserObjectExtraRefCounts; … … 130 145 ScopeNode* scopeNodeBeingReparsed; 131 146 132 Heap heap;133 #if ENABLE(ASSEMBLER)134 PassRefPtr<ExecutablePool> poolForSize(size_t n) { return m_executableAllocator.poolForSize(n); }135 #endif136 137 147 private: 138 JSGlobalData(bool isShared = false); 139 #if ENABLE(ASSEMBLER) 140 ExecutableAllocator m_executableAllocator; 141 #endif 142 148 JSGlobalData(bool isShared, const VPtrSet&); 143 149 static JSGlobalData*& sharedInstanceInternal(); 144 150 }; -
trunk/JavaScriptCore/runtime/JSString.h
r39769 r41168 61 61 class JSString : public JSCell { 62 62 friend class JIT; 63 friend class Interpreter;63 friend class VPtrSet; 64 64 65 65 public: … … 203 203 } 204 204 205 inline bool isJSString(JSGlobalData* globalData, JSValuePtr v) { return v.isCell() && v.asCell()->vptr() == globalData->jsStringVPtr; } 206 205 207 // --- JSValue inlines ---------------------------- 206 208 -
trunk/JavaScriptCore/runtime/Operations.h
r41100 r41168 147 147 return n1 < n2; 148 148 149 Interpreter* interpreter = callFrame->interpreter();150 if (i nterpreter->isJSString(v1) && interpreter->isJSString(v2))149 JSGlobalData* globalData = &callFrame->globalData(); 150 if (isJSString(globalData, v1) && isJSString(globalData, v2)) 151 151 return asString(v1)->value() < asString(v2)->value(); 152 152 … … 172 172 return n1 <= n2; 173 173 174 Interpreter* interpreter = callFrame->interpreter();175 if (i nterpreter->isJSString(v1) && interpreter->isJSString(v2))174 JSGlobalData* globalData = &callFrame->globalData(); 175 if (isJSString(globalData, v1) && isJSString(globalData, v2)) 176 176 return !(asString(v2)->value() < asString(v1)->value()); 177 177
Note:
See TracChangeset
for help on using the changeset viewer.