Changeset 229518 in webkit for trunk/Source/JavaScriptCore/runtime/DirectArguments.cpp
- Timestamp:
- Mar 11, 2018, 2:09:20 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/DirectArguments.cpp
r227617 r229518 37 37 const ClassInfo DirectArguments::s_info = { "Arguments", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(DirectArguments) }; 38 38 39 DirectArguments::DirectArguments(VM& vm, Structure* structure, unsigned length, unsigned capacity)39 DirectArguments::DirectArguments(VM& vm, Structure* structure, WriteBarrier<Unknown>* storage) 40 40 : GenericArguments(vm, structure) 41 , m_length(length) 42 , m_minCapacity(capacity) 41 , m_storage(vm, this, storage) 43 42 { 44 43 // When we construct the object from C++ code, we expect the capacity to be at least as large as 45 44 // length. JIT-allocated DirectArguments objects play evil tricks, though. 46 ASSERT( capacity >=length);45 ASSERT(storageHeader(storage).minCapacity >= storageHeader(storage).length); 47 46 } 48 47 … … 50 49 VM& vm, Structure* structure, unsigned length, unsigned capacity) 51 50 { 51 void* rawStoragePtr = vm.jsValueGigacageAuxiliarySpace.allocateNonVirtual( 52 vm, storageSize(capacity), nullptr, AllocationFailureMode::Assert); 53 WriteBarrier<Unknown>* storage = static_cast<WriteBarrier<Unknown>*>(rawStoragePtr) + 1; 54 storageHeader(storage).length = length; 55 storageHeader(storage).minCapacity = capacity; 56 52 57 DirectArguments* result = 53 new (NotNull, allocateCell<DirectArguments>(vm.heap , allocationSize(capacity)))54 DirectArguments(vm, structure, length, capacity);58 new (NotNull, allocateCell<DirectArguments>(vm.heap)) 59 DirectArguments(vm, structure, storage); 55 60 result->finishCreation(vm); 56 61 return result; … … 60 65 { 61 66 DirectArguments* result = createUninitialized(vm, structure, length, capacity); 62 67 68 WriteBarrier<Unknown>* storage = result->storage(); 63 69 for (unsigned i = capacity; i--;) 64 result->storage()[i].clear();70 storage[i].clear(); 65 71 66 72 return result; … … 76 82 vm, exec->lexicalGlobalObject()->directArgumentsStructure(), length, capacity); 77 83 84 WriteBarrier<Unknown>* storage = result->storage(); 78 85 for (unsigned i = capacity; i--;) 79 result->storage()[i].set(vm, result, exec->getArgumentUnsafe(i));86 storage[i].set(vm, result, exec->getArgumentUnsafe(i)); 80 87 81 88 result->callee().set(vm, result, jsCast<JSFunction*>(exec->jsCallee())); … … 88 95 DirectArguments* thisObject = jsCast<DirectArguments*>(cell); 89 96 size_t mappedArgumentsSize = thisObject->m_mappedArguments ? thisObject->mappedArgumentsSize() * sizeof(bool) : 0; 90 size_t modifiedArgumentsSize = thisObject->m_modifiedArgumentsDescriptor ? thisObject-> m_length * sizeof(bool) : 0;97 size_t modifiedArgumentsSize = thisObject->m_modifiedArgumentsDescriptor ? thisObject->storageHeader().length * sizeof(bool) : 0; 91 98 return Base::estimatedSize(cell) + mappedArgumentsSize + modifiedArgumentsSize; 92 99 } … … 98 105 Base::visitChildren(thisObject, visitor); 99 106 100 visitor.appendValues(thisObject->storage(), std::max(thisObject->m_length, thisObject->m_minCapacity)); 107 visitor.markAuxiliary(&thisObject->storageHeader()); 108 visitor.appendValues(thisObject->storage(), std::max(thisObject->storageHeader().length, thisObject->storageHeader().minCapacity)); 109 101 110 visitor.append(thisObject->m_callee); 102 111 103 112 if (thisObject->m_mappedArguments) 104 113 visitor.markAuxiliary(thisObject->m_mappedArguments.get()); 114 105 115 GenericArguments<DirectArguments>::visitChildren(thisCell, visitor); 106 116 } … … 115 125 RELEASE_ASSERT(!m_mappedArguments); 116 126 117 putDirect(vm, vm.propertyNames->length, jsNumber( m_length), static_cast<unsigned>(PropertyAttribute::DontEnum));127 putDirect(vm, vm.propertyNames->length, jsNumber(storageHeader().length), static_cast<unsigned>(PropertyAttribute::DontEnum)); 118 128 putDirect(vm, vm.propertyNames->callee, m_callee.get(), static_cast<unsigned>(PropertyAttribute::DontEnum)); 119 129 putDirect(vm, vm.propertyNames->iteratorSymbol, globalObject()->arrayProtoValuesFunction(), static_cast<unsigned>(PropertyAttribute::DontEnum)); … … 122 132 bool* overrides = static_cast<bool*>(backingStore); 123 133 m_mappedArguments.set(vm, this, overrides); 124 for (unsigned i = m_length; i--;)134 for (unsigned i = storageHeader().length; i--;) 125 135 overrides[i] = false; 126 136 } … … 141 151 { 142 152 if (!m_mappedArguments) { 143 unsigned limit = std::min(length + offset, m_length);153 unsigned limit = std::min(length + offset, storageHeader().length); 144 154 unsigned i; 145 155 VirtualRegister start = firstElementDest - offset; 156 WriteBarrier<Unknown>* storage = this->storage(); 146 157 for (i = offset; i < limit; ++i) 147 exec->r(start + i) = storage ()[i].get();158 exec->r(start + i) = storage[i].get(); 148 159 for (; i < length; ++i) 149 160 exec->r(start + i) = get(exec, i); … … 159 170 // still allocate so that m_mappedArguments is non-null. We use that to indicate that the other properties 160 171 // (length, etc) are overridden. 161 return WTF::roundUpToMultipleOf<8>( m_length ? m_length : 1);172 return WTF::roundUpToMultipleOf<8>(storageHeader().length ? storageHeader().length : 1); 162 173 } 163 174
Note:
See TracChangeset
for help on using the changeset viewer.