Changeset 201182 in webkit for trunk/Source/JavaScriptCore/dfg/DFGLICMPhase.cpp
- Timestamp:
- May 19, 2016, 2:25:29 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/dfg/DFGLICMPhase.cpp
r198364 r201182 1 1 /* 2 * Copyright (C) 2013-201 5Apple Inc. All rights reserved.2 * Copyright (C) 2013-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 34 34 #include "DFGClobberSet.h" 35 35 #include "DFGClobberize.h" 36 #include "DFGControlEquivalenceAnalysis.h" 36 37 #include "DFGEdgeDominates.h" 37 38 #include "DFGGraph.h" 38 39 #include "DFGInsertionSet.h" 40 #include "DFGMayExit.h" 39 41 #include "DFGNaturalLoops.h" 40 42 #include "DFGPhase.h" … … 75 77 m_graph.ensureDominators(); 76 78 m_graph.ensureNaturalLoops(); 79 m_graph.ensureControlEquivalenceAnalysis(); 77 80 78 81 if (verbose) { … … 261 264 // https://bugs.webkit.org/show_bug.cgi?id=144525 262 265 263 // FIXME: If a node has a type check - even something like a CheckStructure - then we should264 // only hoist the node if we know that it will execute on every loop iteration or if we know265 // that the type check will always succeed at the loop pre-header through some other means266 // (like looking at prediction propagation results). Otherwise, we might make a mistake like267 // this:268 //269 // var o = ...; // sometimes null and sometimes an object with structure S1.270 // for (...) {271 // if (o)272 // ... = o.f; // CheckStructure and GetByOffset, which we will currently hoist.273 // }274 //275 // When we encounter such code, we'll hoist the CheckStructure and GetByOffset and then we276 // will have a recompile. We'll then end up thinking that the get_by_id needs to be277 // polymorphic, which is false.278 //279 // We can counter this by either having a control flow equivalence check, or by consulting280 // prediction propagation to see if the check would always succeed. Prediction propagation281 // would not be enough for things like:282 //283 // var p = ...; // some boolean predicate284 // var o = {};285 // if (p)286 // o.f = 42;287 // for (...) {288 // if (p)289 // ... = o.f;290 // }291 //292 // Prediction propagation can't tell us anything about the structure, and the CheckStructure293 // will appear to be hoistable because the loop doesn't clobber structures. The cell check294 // in the CheckStructure will be hoistable though, since prediction propagation can tell us295 // that o is always SpecFinalObject. In cases like this, control flow equivalence is the296 // only effective guard.297 //298 // https://bugs.webkit.org/show_bug.cgi?id=144527299 300 266 if (readsOverlap(m_graph, node, data.writes)) { 301 267 if (verbose) { … … 312 278 dataLog( 313 279 " Not hoisting ", node, " because it isn't safe to execute.\n"); 280 } 281 return false; 282 } 283 284 NodeOrigin originalOrigin = node->origin; 285 286 // NOTE: We could just use BackwardsDominators here directly, since we already know that the 287 // preHeader dominates fromBlock. But we wouldn't get anything from being so clever, since 288 // dominance checks are O(1) and only a few integer compares. 289 bool addsBlindSpeculation = mayExit(m_graph, node, m_state) 290 && !m_graph.m_controlEquivalenceAnalysis->dominatesEquivalently(data.preHeader, fromBlock); 291 292 if (addsBlindSpeculation 293 && m_graph.baselineCodeBlockFor(originalOrigin.semantic)->hasExitSite(FrequentExitSite(HoistingFailed))) { 294 if (verbose) { 295 dataLog( 296 " Not hoisting ", node, " because it may exit and the pre-header (", 297 *data.preHeader, ") is not control equivalent to the node's original block (", 298 *fromBlock, ") and hoisting had previously failed.\n"); 314 299 } 315 300 return false; … … 327 312 data.preHeader->insertBeforeTerminal(node); 328 313 node->owner = data.preHeader; 329 NodeOrigin originalOrigin = node->origin; 330 node->origin = data.preHeader->terminal()->origin.withSemantic(node->origin.semantic); 314 NodeOrigin terminalOrigin = data.preHeader->terminal()->origin; 315 node->origin = terminalOrigin.withSemantic(node->origin.semantic); 316 node->origin.wasHoisted |= addsBlindSpeculation; 331 317 332 318 // Modify the states at the end of the preHeader of the loop we hoisted to,
Note:
See TracChangeset
for help on using the changeset viewer.