| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/js-inlining.h" | 5 #include "src/compiler/js-inlining.h" |
| 6 | 6 |
| 7 #include "src/ast.h" | 7 #include "src/ast.h" |
| 8 #include "src/ast-numbering.h" | 8 #include "src/ast-numbering.h" |
| 9 #include "src/compiler/all-nodes.h" | 9 #include "src/compiler/all-nodes.h" |
| 10 #include "src/compiler/ast-graph-builder.h" | 10 #include "src/compiler/ast-graph-builder.h" |
| 11 #include "src/compiler/common-operator.h" | 11 #include "src/compiler/common-operator.h" |
| 12 #include "src/compiler/js-context-specialization.h" | 12 #include "src/compiler/js-context-specialization.h" |
| 13 #include "src/compiler/js-operator.h" | 13 #include "src/compiler/js-operator.h" |
| 14 #include "src/compiler/node-matchers.h" | 14 #include "src/compiler/node-matchers.h" |
| 15 #include "src/compiler/node-properties.h" | 15 #include "src/compiler/node-properties.h" |
| 16 #include "src/compiler/operator-properties.h" | 16 #include "src/compiler/operator-properties.h" |
| 17 #include "src/full-codegen.h" | 17 #include "src/full-codegen.h" |
| 18 #include "src/parser.h" | 18 #include "src/parser.h" |
| 19 #include "src/rewriter.h" | 19 #include "src/rewriter.h" |
| 20 #include "src/scopes.h" | 20 #include "src/scopes.h" |
| 21 | 21 |
| 22 namespace v8 { | 22 namespace v8 { |
| 23 namespace internal { | 23 namespace internal { |
| 24 namespace compiler { | 24 namespace compiler { |
| 25 | 25 |
| 26 #define TRACE(...) \ |
| 27 do { \ |
| 28 if (FLAG_trace_turbo_inlining) PrintF(__VA_ARGS__); \ |
| 29 } while (false) |
| 30 |
| 26 | 31 |
| 27 // Provides convenience accessors for calls to JS functions. | 32 // Provides convenience accessors for calls to JS functions. |
| 28 class JSCallFunctionAccessor { | 33 class JSCallFunctionAccessor { |
| 29 public: | 34 public: |
| 30 explicit JSCallFunctionAccessor(Node* call) : call_(call) { | 35 explicit JSCallFunctionAccessor(Node* call) : call_(call) { |
| 31 DCHECK_EQ(IrOpcode::kJSCallFunction, call->opcode()); | 36 DCHECK_EQ(IrOpcode::kJSCallFunction, call->opcode()); |
| 32 } | 37 } |
| 33 | 38 |
| 34 Node* jsfunction() { return call_->InputAt(0); } | 39 Node* jsfunction() { return call_->InputAt(0); } |
| 35 | 40 |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 return NoChange(); | 320 return NoChange(); |
| 316 } | 321 } |
| 317 | 322 |
| 318 CompilationInfoWithZone info(function); | 323 CompilationInfoWithZone info(function); |
| 319 | 324 |
| 320 if (!Compiler::ParseAndAnalyze(info.parse_info())) return NoChange(); | 325 if (!Compiler::ParseAndAnalyze(info.parse_info())) return NoChange(); |
| 321 if (!Compiler::EnsureDeoptimizationSupport(&info)) return NoChange(); | 326 if (!Compiler::EnsureDeoptimizationSupport(&info)) return NoChange(); |
| 322 | 327 |
| 323 if (info.scope()->arguments() != NULL && is_sloppy(info.language_mode())) { | 328 if (info.scope()->arguments() != NULL && is_sloppy(info.language_mode())) { |
| 324 // For now do not inline functions that use their arguments array. | 329 // For now do not inline functions that use their arguments array. |
| 325 SmartArrayPointer<char> name = function->shared()->DebugName()->ToCString(); | 330 TRACE("Not Inlining %s into %s because inlinee uses arguments array\n", |
| 326 if (FLAG_trace_turbo_inlining) { | 331 function->shared()->DebugName()->ToCString().get(), |
| 327 PrintF( | 332 info_->shared_info()->DebugName()->ToCString().get()); |
| 328 "Not Inlining %s into %s because inlinee uses arguments " | |
| 329 "array\n", | |
| 330 name.get(), info_->shared_info()->DebugName()->ToCString().get()); | |
| 331 } | |
| 332 return NoChange(); | 333 return NoChange(); |
| 333 } | 334 } |
| 334 | 335 |
| 335 if (FLAG_trace_turbo_inlining) { | 336 TRACE("Inlining %s into %s\n", |
| 336 SmartArrayPointer<char> name = function->shared()->DebugName()->ToCString(); | 337 function->shared()->DebugName()->ToCString().get(), |
| 337 PrintF("Inlining %s into %s\n", name.get(), | 338 info_->shared_info()->DebugName()->ToCString().get()); |
| 338 info_->shared_info()->DebugName()->ToCString().get()); | |
| 339 } | |
| 340 | 339 |
| 341 Graph graph(info.zone()); | 340 Graph graph(info.zone()); |
| 342 JSGraph jsgraph(info.isolate(), &graph, jsgraph_->common(), | 341 JSGraph jsgraph(info.isolate(), &graph, jsgraph_->common(), |
| 343 jsgraph_->javascript(), jsgraph_->machine()); | 342 jsgraph_->javascript(), jsgraph_->machine()); |
| 344 | 343 |
| 345 // The inlinee specializes to the context from the JSFunction object. | 344 // The inlinee specializes to the context from the JSFunction object. |
| 346 // TODO(turbofan): We might want to load the context from the JSFunction at | 345 // TODO(turbofan): We might want to load the context from the JSFunction at |
| 347 // runtime in case we only know the SharedFunctionInfo once we have dynamic | 346 // runtime in case we only know the SharedFunctionInfo once we have dynamic |
| 348 // type feedback in the compiler. | 347 // type feedback in the compiler. |
| 349 AstGraphBuilder graph_builder(local_zone_, &info, &jsgraph); | 348 AstGraphBuilder graph_builder(local_zone_, &info, &jsgraph); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 375 } | 374 } |
| 376 } | 375 } |
| 377 } | 376 } |
| 378 | 377 |
| 379 return inlinee.InlineAtCall(jsgraph_, node); | 378 return inlinee.InlineAtCall(jsgraph_, node); |
| 380 } | 379 } |
| 381 | 380 |
| 382 } // namespace compiler | 381 } // namespace compiler |
| 383 } // namespace internal | 382 } // namespace internal |
| 384 } // namespace v8 | 383 } // namespace v8 |
| OLD | NEW |