We should support CreateThis in the FTL
[WebKit-https.git] / Source / JavaScriptCore / runtime / JSPropertyNameEnumerator.cpp
index 7e7d1ac..c366470 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include "JSPropertyNameEnumerator.h"
 
 #include "JSCInlines.h"
+#include "LockDuringMarking.h"
 #include "StrongInlines.h"
 
 namespace JSC {
 
-const ClassInfo JSPropertyNameEnumerator::s_info = { "JSPropertyNameEnumerator", 0, 0, CREATE_METHOD_TABLE(JSPropertyNameEnumerator) };
+const ClassInfo JSPropertyNameEnumerator::s_info = { "JSPropertyNameEnumerator", nullptr, nullptr, nullptr, CREATE_METHOD_TABLE(JSPropertyNameEnumerator) };
 
 JSPropertyNameEnumerator* JSPropertyNameEnumerator::create(VM& vm)
 {
     if (!vm.emptyPropertyNameEnumerator.get()) {
-        PropertyNameArray propertyNames(&vm);
-        vm.emptyPropertyNameEnumerator = Strong<JSCell>(vm, create(vm, 0, 0, 0, propertyNames));
+        PropertyNameArray propertyNames(&vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude);
+        vm.emptyPropertyNameEnumerator = Strong<JSCell>(vm, create(vm, 0, 0, 0, WTFMove(propertyNames)));
     }
     return jsCast<JSPropertyNameEnumerator*>(vm.emptyPropertyNameEnumerator.get());
 }
 
-JSPropertyNameEnumerator* JSPropertyNameEnumerator::create(VM& vm, Structure* structure, uint32_t indexedLength, uint32_t numberStructureProperties, PropertyNameArray& propertyNames)
+JSPropertyNameEnumerator* JSPropertyNameEnumerator::create(VM& vm, Structure* structure, uint32_t indexedLength, uint32_t numberStructureProperties, PropertyNameArray&& propertyNames)
 {
     StructureID structureID = structure ? structure->id() : 0;
     uint32_t inlineCapacity = structure ? structure->inlineCapacity() : 0;
     JSPropertyNameEnumerator* enumerator = new (NotNull, 
         allocateCell<JSPropertyNameEnumerator>(vm.heap)) JSPropertyNameEnumerator(vm, structureID, inlineCapacity);
-    enumerator->finishCreation(vm, indexedLength, numberStructureProperties, propertyNames.data());
+    enumerator->finishCreation(vm, indexedLength, numberStructureProperties, propertyNames.releaseData());
     return enumerator;
 }
 
@@ -59,18 +60,20 @@ JSPropertyNameEnumerator::JSPropertyNameEnumerator(VM& vm, StructureID structure
 {
 }
 
-void JSPropertyNameEnumerator::finishCreation(VM& vm, uint32_t indexedLength, uint32_t endStructurePropertyIndex, PassRefPtr<PropertyNameArrayData> idents)
+void JSPropertyNameEnumerator::finishCreation(VM& vm, uint32_t indexedLength, uint32_t endStructurePropertyIndex, RefPtr<PropertyNameArrayData>&& identifiers)
 {
     Base::finishCreation(vm);
 
-    RefPtr<PropertyNameArrayData> identifiers = idents;
     PropertyNameArrayData::PropertyNameVector& vector = identifiers->propertyNameVector();
 
     m_indexedLength = indexedLength;
     m_endStructurePropertyIndex = endStructurePropertyIndex;
     m_endGenericPropertyIndex = vector.size();
 
-    m_propertyNames.resizeToFit(vector.size());
+    {
+        auto locker = lockDuringMarking(vm.heap, cellLock());
+        m_propertyNames.resizeToFit(vector.size());
+    }
     for (unsigned i = 0; i < vector.size(); ++i) {
         const Identifier& identifier = vector[i];
         m_propertyNames[i].set(vm, this, jsString(&vm, identifier.string()));
@@ -79,16 +82,17 @@ void JSPropertyNameEnumerator::finishCreation(VM& vm, uint32_t indexedLength, ui
 
 void JSPropertyNameEnumerator::destroy(JSCell* cell)
 {
-    jsCast<JSPropertyNameEnumerator*>(cell)->JSPropertyNameEnumerator::~JSPropertyNameEnumerator();
+    static_cast<JSPropertyNameEnumerator*>(cell)->JSPropertyNameEnumerator::~JSPropertyNameEnumerator();
 }
 
 void JSPropertyNameEnumerator::visitChildren(JSCell* cell, SlotVisitor& visitor)
 {
     Base::visitChildren(cell, visitor);
     JSPropertyNameEnumerator* thisObject = jsCast<JSPropertyNameEnumerator*>(cell);
-    for (unsigned i = 0; i < thisObject->m_propertyNames.size(); ++i)
-        visitor.append(&thisObject->m_propertyNames[i]);
-    visitor.append(&thisObject->m_prototypeChain);
+    auto locker = holdLock(thisObject->cellLock());
+    for (auto& propertyName : thisObject->m_propertyNames)
+        visitor.append(propertyName);
+    visitor.append(thisObject->m_prototypeChain);
 }
 
 } // namespace JSC