Changeset 254252 in webkit for trunk/Source/JavaScriptCore/dfg/DFGObjectAllocationSinkingPhase.cpp
- Timestamp:
- Jan 8, 2020, 10:07:29 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/dfg/DFGObjectAllocationSinkingPhase.cpp
r254087 r254252 41 41 #include "DFGSSACalculator.h" 42 42 #include "DFGValidate.h" 43 #include "JSArrayIterator.h" 43 44 #include "JSCInlines.h" 44 45 #include <wtf/StdList.h> … … 141 142 // replace any use of those pointers by the corresponding 142 143 // materialization 143 enum class Kind { Escaped, Object, Activation, Function, GeneratorFunction, AsyncFunction, AsyncGeneratorFunction, RegExpObject };144 enum class Kind { Escaped, Object, Activation, Function, GeneratorFunction, AsyncFunction, AsyncGeneratorFunction, InternalFieldObject, RegExpObject }; 144 145 145 146 using Fields = HashMap<PromotedLocationDescriptor, Node*>; … … 246 247 } 247 248 249 bool isInternalFieldObjectAllocation() const 250 { 251 return m_kind == Kind::InternalFieldObject; 252 } 253 248 254 bool isRegExpObjectAllocation() const 249 255 { … … 290 296 case Kind::AsyncFunction: 291 297 out.print("AsyncFunction"); 298 break; 299 300 case Kind::InternalFieldObject: 301 out.print("InternalFieldObject"); 292 302 break; 293 303 … … 816 826 } 817 827 828 template<typename InternalFieldClass> 829 Allocation* handleInternalFieldClass(Node* node, HashMap<PromotedLocationDescriptor, LazyNode>& writes) 830 { 831 Allocation* result = &m_heap.newAllocation(node, Allocation::Kind::InternalFieldObject); 832 writes.add(StructurePLoc, LazyNode(m_graph.freeze(node->structure().get()))); 833 auto initialValues = InternalFieldClass::initialValues(); 834 static_assert(initialValues.size() == InternalFieldClass::numberOfInternalFields); 835 for (unsigned index = 0; index < initialValues.size(); ++index) 836 writes.add(PromotedLocationDescriptor(InternalFieldObjectPLoc, index), LazyNode(m_graph.freeze(initialValues[index]))); 837 838 return result; 839 } 840 818 841 template<typename WriteFunctor, typename ResolveFunctor> 819 842 void handleNode( … … 857 880 writes.add(FunctionExecutablePLoc, LazyNode(node->cellOperand())); 858 881 writes.add(FunctionActivationPLoc, LazyNode(node->child1().node())); 882 break; 883 } 884 885 case NewArrayIterator: { 886 target = handleInternalFieldClass<JSArrayIterator>(node, writes); 859 887 break; 860 888 } … … 1069 1097 } 1070 1098 break; 1099 1100 case GetInternalField: { 1101 target = m_heap.onlyLocalAllocation(node->child1().node()); 1102 if (target && target->isInternalFieldObjectAllocation()) 1103 exactRead = PromotedLocationDescriptor(InternalFieldObjectPLoc, node->internalFieldIndex()); 1104 else 1105 m_heap.escape(node->child1().node()); 1106 break; 1107 } 1108 1109 case PutInternalField: { 1110 target = m_heap.onlyLocalAllocation(node->child1().node()); 1111 if (target && target->isInternalFieldObjectAllocation()) 1112 writes.add(PromotedLocationDescriptor(InternalFieldObjectPLoc, node->internalFieldIndex()), LazyNode(node->child2().node())); 1113 else { 1114 m_heap.escape(node->child1().node()); 1115 m_heap.escape(node->child2().node()); 1116 } 1117 break; 1118 } 1071 1119 1072 1120 case Check: … … 1562 1610 } 1563 1611 1612 case Allocation::Kind::InternalFieldObject: { 1613 ObjectMaterializationData* data = m_graph.m_objectMaterializationData.add(); 1614 return m_graph.addNode( 1615 allocation.identifier()->prediction(), Node::VarArg, MaterializeNewInternalFieldObject, 1616 where->origin.withSemantic( 1617 allocation.identifier()->origin.semantic), 1618 OpInfo(allocation.identifier()->structure()), OpInfo(data), 0, 0); 1619 } 1620 1564 1621 case Allocation::Kind::Activation: { 1565 1622 ObjectMaterializationData* data = m_graph.m_objectMaterializationData.add(); … … 1947 2004 case NewAsyncFunction: 1948 2005 node->convertToPhantomNewAsyncFunction(); 2006 break; 2007 2008 case NewArrayIterator: 2009 node->convertToPhantomNewArrayIterator(); 1949 2010 break; 1950 2011 … … 2225 2286 } 2226 2287 2288 case MaterializeNewInternalFieldObject: { 2289 ObjectMaterializationData& data = node->objectMaterializationData(); 2290 2291 unsigned firstChild = m_graph.m_varArgChildren.size(); 2292 2293 Vector<PromotedHeapLocation> locations = m_locationsForAllocation.get(escapee); 2294 2295 PromotedHeapLocation structure(StructurePLoc, allocation.identifier()); 2296 ASSERT(locations.contains(structure)); 2297 m_graph.m_varArgChildren.append(Edge(resolve(block, structure), KnownCellUse)); 2298 2299 for (PromotedHeapLocation location : locations) { 2300 switch (location.kind()) { 2301 case StructurePLoc: { 2302 ASSERT(location == structure); 2303 break; 2304 } 2305 2306 case InternalFieldObjectPLoc: { 2307 ASSERT(location.base() == allocation.identifier()); 2308 data.m_properties.append(location.descriptor()); 2309 Node* value = resolve(block, location); 2310 if (m_sinkCandidates.contains(value)) 2311 m_graph.m_varArgChildren.append(m_bottom); 2312 else 2313 m_graph.m_varArgChildren.append(value); 2314 break; 2315 } 2316 2317 default: 2318 DFG_CRASH(m_graph, node, "Bad location kind"); 2319 } 2320 } 2321 2322 node->children = AdjacencyList( 2323 AdjacencyList::Variable, 2324 firstChild, m_graph.m_varArgChildren.size() - firstChild); 2325 break; 2326 } 2327 2227 2328 case NewRegexp: { 2228 2329 Vector<PromotedHeapLocation> locations = m_locationsForAllocation.get(escapee); … … 2356 2457 } 2357 2458 2459 case InternalFieldObjectPLoc: { 2460 return m_graph.addNode( 2461 PutInternalField, 2462 origin.takeValidExit(canExit), 2463 OpInfo(location.info()), 2464 Edge(base, KnownCellUse), 2465 value->defaultEdge()); 2466 } 2467 2358 2468 case RegExpObjectLastIndexPLoc: { 2359 2469 return m_graph.addNode(
Note:
See TracChangeset
for help on using the changeset viewer.