Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1416)

Side by Side Diff: src/compiler/js-inlining.cc

Issue 872363002: [turbofan] Add new JSIntrinsicsLowering reducer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/js-inlining.h ('k') | src/compiler/js-intrinsic-builder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ast.h" 5 #include "src/ast.h"
6 #include "src/ast-numbering.h" 6 #include "src/ast-numbering.h"
7 #include "src/compiler/access-builder.h" 7 #include "src/compiler/access-builder.h"
8 #include "src/compiler/ast-graph-builder.h" 8 #include "src/compiler/ast-graph-builder.h"
9 #include "src/compiler/common-operator.h" 9 #include "src/compiler/common-operator.h"
10 #include "src/compiler/graph-inl.h" 10 #include "src/compiler/graph-inl.h"
11 #include "src/compiler/graph-visualizer.h" 11 #include "src/compiler/graph-visualizer.h"
12 #include "src/compiler/js-inlining.h" 12 #include "src/compiler/js-inlining.h"
13 #include "src/compiler/js-intrinsic-builder.h"
14 #include "src/compiler/js-operator.h" 13 #include "src/compiler/js-operator.h"
15 #include "src/compiler/node-aux-data-inl.h" 14 #include "src/compiler/node-aux-data-inl.h"
16 #include "src/compiler/node-matchers.h" 15 #include "src/compiler/node-matchers.h"
17 #include "src/compiler/node-properties-inl.h" 16 #include "src/compiler/node-properties-inl.h"
18 #include "src/compiler/simplified-operator.h" 17 #include "src/compiler/simplified-operator.h"
19 #include "src/compiler/typer.h" 18 #include "src/compiler/typer.h"
20 #include "src/full-codegen.h" 19 #include "src/full-codegen.h"
21 #include "src/parser.h" 20 #include "src/parser.h"
22 #include "src/rewriter.h" 21 #include "src/rewriter.h"
23 #include "src/scopes.h" 22 #include "src/scopes.h"
24 23
25 24
26 namespace v8 { 25 namespace v8 {
27 namespace internal { 26 namespace internal {
28 namespace compiler { 27 namespace compiler {
29 28
30 class InlinerVisitor : public NullNodeVisitor { 29 class InlinerVisitor : public NullNodeVisitor {
31 public: 30 public:
32 explicit InlinerVisitor(JSInliner* inliner) : inliner_(inliner) {} 31 explicit InlinerVisitor(JSInliner* inliner) : inliner_(inliner) {}
33 32
34 void Post(Node* node) { 33 void Post(Node* node) {
35 switch (node->opcode()) { 34 switch (node->opcode()) {
36 case IrOpcode::kJSCallFunction: 35 case IrOpcode::kJSCallFunction:
37 inliner_->TryInlineJSCall(node); 36 inliner_->TryInlineJSCall(node);
38 break; 37 break;
39 case IrOpcode::kJSCallRuntime:
40 if (FLAG_turbo_inlining_intrinsics) {
41 inliner_->TryInlineRuntimeCall(node);
42 }
43 break;
44 default: 38 default:
45 break; 39 break;
46 } 40 }
47 } 41 }
48 42
49 private: 43 private:
50 JSInliner* inliner_; 44 JSInliner* inliner_;
51 }; 45 };
52 46
53 47
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 if (node && node->opcode() == IrOpcode::kFrameState) { 405 if (node && node->opcode() == IrOpcode::kFrameState) {
412 AddClosureToFrameState(node, function); 406 AddClosureToFrameState(node, function);
413 NodeProperties::ReplaceFrameStateInput(node, outer_frame_state); 407 NodeProperties::ReplaceFrameStateInput(node, outer_frame_state);
414 } 408 }
415 } 409 }
416 } 410 }
417 411
418 inlinee.InlineAtCall(jsgraph_, call_node); 412 inlinee.InlineAtCall(jsgraph_, call_node);
419 } 413 }
420 414
421 415 } // namespace compiler
422 class JSCallRuntimeAccessor { 416 } // namespace internal
423 public: 417 } // namespace v8
424 explicit JSCallRuntimeAccessor(Node* call) : call_(call) {
425 DCHECK_EQ(IrOpcode::kJSCallRuntime, call->opcode());
426 }
427
428 Node* formal_argument(size_t index) {
429 DCHECK(index < formal_arguments());
430 return call_->InputAt(static_cast<int>(index));
431 }
432
433 size_t formal_arguments() {
434 size_t value_inputs = call_->op()->ValueInputCount();
435 return value_inputs;
436 }
437
438 Node* frame_state() const {
439 return NodeProperties::GetFrameStateInput(call_);
440 }
441 Node* context() const { return NodeProperties::GetContextInput(call_); }
442 Node* control() const { return NodeProperties::GetControlInput(call_); }
443 Node* effect() const { return NodeProperties::GetEffectInput(call_); }
444
445 const Runtime::Function* function() const {
446 return Runtime::FunctionForId(CallRuntimeParametersOf(call_->op()).id());
447 }
448
449 NodeVector inputs(Zone* zone) const {
450 NodeVector inputs(zone);
451 for (Node* const node : call_->inputs()) {
452 inputs.push_back(node);
453 }
454 return inputs;
455 }
456
457 private:
458 Node* call_;
459 };
460
461
462 void JSInliner::TryInlineRuntimeCall(Node* call_node) {
463 JSCallRuntimeAccessor call(call_node);
464 const Runtime::Function* f = call.function();
465
466 if (f->intrinsic_type != Runtime::IntrinsicType::INLINE) {
467 return;
468 }
469
470 JSIntrinsicBuilder intrinsic_builder(jsgraph_);
471
472 ResultAndEffect r = intrinsic_builder.BuildGraphFor(
473 f->function_id, call.inputs(jsgraph_->zone()));
474
475 if (r.first != NULL) {
476 if (FLAG_trace_turbo_inlining) {
477 PrintF("Inlining %s into %s\n", f->name,
478 info_->shared_info()->DebugName()->ToCString().get());
479 }
480 NodeProperties::ReplaceWithValue(call_node, r.first, r.second);
481 call_node->RemoveAllInputs();
482 DCHECK_EQ(0, call_node->UseCount());
483 }
484 }
485 }
486 }
487 } // namespace v8::internal::compiler
OLDNEW
« no previous file with comments | « src/compiler/js-inlining.h ('k') | src/compiler/js-intrinsic-builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698