1 // Copyright 2014 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef V8_COMPILER_JS_INLINING_H_ 6 #define V8_COMPILER_JS_INLINING_H_ 7 8 #include "src/compiler/js-graph.h" 9 #include "src/compiler/graph-reducer.h" 10 11 namespace v8 { 12 namespace internal { 13 14 // Forward declarations. 15 class CompilationInfo; 16 17 namespace compiler { 18 19 // The JSInliner provides the core graph inlining machinery. Note that this 20 // class only deals with the mechanics of how to inline one graph into another, 21 // heuristics that decide what and how much to inline are beyond its scope. 22 class JSInliner final : public AdvancedReducer { 23 public: JSInliner(Editor * editor,Zone * local_zone,CompilationInfo * info,JSGraph * jsgraph)24 JSInliner(Editor* editor, Zone* local_zone, CompilationInfo* info, 25 JSGraph* jsgraph) 26 : AdvancedReducer(editor), 27 local_zone_(local_zone), 28 info_(info), 29 jsgraph_(jsgraph) {} 30 31 // Reducer interface, eagerly inlines everything. 32 Reduction Reduce(Node* node) final; 33 34 // Can be used by inlining heuristics or by testing code directly, without 35 // using the above generic reducer interface of the inlining machinery. 36 Reduction ReduceJSCall(Node* node, Handle<JSFunction> function); 37 38 private: 39 Zone* local_zone_; 40 CompilationInfo* info_; 41 JSGraph* jsgraph_; 42 43 Node* CreateArtificialFrameState(Node* node, Node* outer_frame_state, 44 int parameter_count, 45 FrameStateType frame_state_type, 46 Handle<SharedFunctionInfo> shared); 47 48 Reduction InlineCall(Node* call, Node* new_target, Node* context, 49 Node* frame_state, Node* start, Node* end); 50 }; 51 52 } // namespace compiler 53 } // namespace internal 54 } // namespace v8 55 56 #endif // V8_COMPILER_JS_INLINING_H_ 57