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

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

Issue 1225683004: [turbofan] Add new JSFrameSpecialization reducer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Also specialize Parameters as discussed with Jaro. 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
« no previous file with comments | « src/compiler/js-frame-specialization.h ('k') | src/compiler/pipeline.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 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 #include "src/compiler/js-frame-specialization.h"
6
7 #include "src/compiler/js-graph.h"
8 #include "src/compiler/linkage.h"
9 #include "src/frames-inl.h"
10
11 namespace v8 {
12 namespace internal {
13 namespace compiler {
14
15 Reduction JSFrameSpecialization::Reduce(Node* node) {
16 switch (node->opcode()) {
17 case IrOpcode::kOsrValue:
18 return ReduceOsrValue(node);
19 case IrOpcode::kParameter:
20 return ReduceParameter(node);
21 default:
22 break;
23 }
24 return NoChange();
25 }
26
27
28 Reduction JSFrameSpecialization::ReduceOsrValue(Node* node) {
29 DCHECK_EQ(IrOpcode::kOsrValue, node->opcode());
30 DisallowHeapAllocation no_gc;
31 Object* object;
32 int const index = OpParameter<int>(node);
33 int const parameters_count = frame()->ComputeParametersCount() + 1;
34 if (index == Linkage::kOsrContextSpillSlotIndex) {
35 object = frame()->context();
36 } else if (index >= parameters_count) {
37 object = frame()->GetExpression(index - parameters_count);
38 } else {
39 // The OsrValue index 0 is the receiver.
40 object = index ? frame()->GetParameter(index - 1) : frame()->receiver();
41 }
42 return Replace(jsgraph()->Constant(handle(object, isolate())));
43 }
44
45
46 Reduction JSFrameSpecialization::ReduceParameter(Node* node) {
47 DCHECK_EQ(IrOpcode::kParameter, node->opcode());
48 DisallowHeapAllocation no_gc;
49 Object* object;
50 int const index = ParameterIndexOf(node->op());
51 int const parameters_count = frame()->ComputeParametersCount() + 1;
52 if (index == Linkage::kJSFunctionCallClosureParamIndex) {
53 object = frame()->function();
54 } else if (index == parameters_count) {
55 // The Parameter index (arity + 1) is the context.
56 object = frame()->context();
57 } else {
58 // The Parameter index 0 is the receiver.
59 object = index ? frame()->GetParameter(index - 1) : frame()->receiver();
60 }
61 return Replace(jsgraph()->Constant(handle(object, isolate())));
62 }
63
64
65 Isolate* JSFrameSpecialization::isolate() const { return jsgraph()->isolate(); }
66
67 } // namespace compiler
68 } // namespace internal
69 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-frame-specialization.h ('k') | src/compiler/pipeline.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698