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

Side by Side Diff: src/compiler/js-context-specialization.cc

Issue 1221103003: [turbofan] Move context specialization into JSContextSpecializer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix predicate. Created 5 years, 5 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
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/compiler/js-context-specialization.h" 5 #include "src/compiler/js-context-specialization.h"
6 6
7 #include "src/compiler/common-operator.h" 7 #include "src/compiler/common-operator.h"
8 #include "src/compiler/js-graph.h" 8 #include "src/compiler/js-graph.h"
9 #include "src/compiler/js-operator.h" 9 #include "src/compiler/js-operator.h"
10 #include "src/compiler/node-matchers.h" 10 #include "src/compiler/node-matchers.h"
11 #include "src/compiler/node-properties.h" 11 #include "src/compiler/node-properties.h"
12 #include "src/contexts.h" 12 #include "src/contexts.h"
13 13
14 namespace v8 { 14 namespace v8 {
15 namespace internal { 15 namespace internal {
16 namespace compiler { 16 namespace compiler {
17 17
18 Reduction JSContextSpecializer::Reduce(Node* node) { 18 Reduction JSContextSpecializer::Reduce(Node* node) {
19 if (node->opcode() == IrOpcode::kJSLoadContext) { 19 switch (node->opcode()) {
20 return ReduceJSLoadContext(node); 20 case IrOpcode::kParameter:
21 } 21 return ReduceParameter(node);
22 if (node->opcode() == IrOpcode::kJSStoreContext) { 22 case IrOpcode::kJSLoadContext:
23 return ReduceJSStoreContext(node); 23 return ReduceJSLoadContext(node);
24 case IrOpcode::kJSStoreContext:
25 return ReduceJSStoreContext(node);
26 default:
27 break;
24 } 28 }
25 return NoChange(); 29 return NoChange();
26 } 30 }
31
32
33 Reduction JSContextSpecializer::ReduceParameter(Node* node) {
34 DCHECK_EQ(IrOpcode::kParameter, node->opcode());
35 Handle<Context> context_constant;
36 if (ParameterIndexOf(node->op()) == context_index() &&
37 context().ToHandle(&context_constant)) {
38 return Replace(jsgraph()->Constant(context_constant));
39 }
40 return NoChange();
41 }
27 42
28 43
29 Reduction JSContextSpecializer::ReduceJSLoadContext(Node* node) { 44 Reduction JSContextSpecializer::ReduceJSLoadContext(Node* node) {
30 DCHECK_EQ(IrOpcode::kJSLoadContext, node->opcode()); 45 DCHECK_EQ(IrOpcode::kJSLoadContext, node->opcode());
31 46
32 HeapObjectMatcher m(NodeProperties::GetValueInput(node, 0)); 47 HeapObjectMatcher m(NodeProperties::GetValueInput(node, 0));
33 // If the context is not constant, no reduction can occur. 48 // If the context is not constant, no reduction can occur.
34 if (!m.HasValue()) { 49 if (!m.HasValue()) {
35 return NoChange(); 50 return NoChange();
36 } 51 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 Isolate* JSContextSpecializer::isolate() const { return jsgraph()->isolate(); } 121 Isolate* JSContextSpecializer::isolate() const { return jsgraph()->isolate(); }
107 122
108 123
109 JSOperatorBuilder* JSContextSpecializer::javascript() const { 124 JSOperatorBuilder* JSContextSpecializer::javascript() const {
110 return jsgraph()->javascript(); 125 return jsgraph()->javascript();
111 } 126 }
112 127
113 } // namespace compiler 128 } // namespace compiler
114 } // namespace internal 129 } // namespace internal
115 } // namespace v8 130 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698