You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							36 lines
						
					
					
						
							793 B
						
					
					
				
			
		
		
	
	
							36 lines
						
					
					
						
							793 B
						
					
					
				/*
 | 
						|
 * Copyright (c) 2018-present, Facebook, Inc.
 | 
						|
 *
 | 
						|
 * This source code is licensed under the MIT license found in the
 | 
						|
 * LICENSE file in the root directory of this source tree.
 | 
						|
 */
 | 
						|
 | 
						|
class HoistExpensive {
 | 
						|
 | 
						|
  int incr(int x) {
 | 
						|
    return x + 1;
 | 
						|
  }
 | 
						|
 | 
						|
  // incr will not be hoisted since it is cheap
 | 
						|
  void cheap_dont_hoist(int size) {
 | 
						|
    int x = 10;
 | 
						|
    for (int i = 0; i < size; i++) {
 | 
						|
      incr(x);
 | 
						|
    }
 | 
						|
  }
 | 
						|
 | 
						|
  // call to cheap_dont_hoist will be hoisted since it is expensive.
 | 
						|
  void symbolic_expensive_hoist(int size) {
 | 
						|
    for (int i = 0; i < size; i++) {
 | 
						|
      cheap_dont_hoist(size);
 | 
						|
    }
 | 
						|
  }
 | 
						|
 | 
						|
  // call to cheap_dont_hoist will NOT be hoisted since it is cheap.
 | 
						|
  void instantiated_cheap_hoist(int size) {
 | 
						|
    for (int i = 0; i < size; i++) {
 | 
						|
      cheap_dont_hoist(1);
 | 
						|
    }
 | 
						|
  }
 | 
						|
}
 |