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

Side by Side Diff: src/compiler/js-call-reducer.cc

Issue 2664423003: [turbofan] fix wrong materialization of arguments object (Closed)
Patch Set: merged test files Created 3 years, 10 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 | « no previous file | test/mjsunit/arguments-deopt.js » ('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 2015 the V8 project authors. All rights reserved. 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 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-call-reducer.h" 5 #include "src/compiler/js-call-reducer.h"
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/compilation-dependencies.h" 9 #include "src/compilation-dependencies.h"
10 #include "src/compiler/js-graph.h" 10 #include "src/compiler/js-graph.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 if (!NodeProperties::IsValueEdge(edge)) continue; 110 if (!NodeProperties::IsValueEdge(edge)) continue;
111 if (edge.from() == node) continue; 111 if (edge.from() == node) continue;
112 return NoChange(); 112 return NoChange();
113 } 113 }
114 // Check if the arguments can be handled in the fast case (i.e. we don't 114 // Check if the arguments can be handled in the fast case (i.e. we don't
115 // have aliased sloppy arguments), and compute the {start_index} for 115 // have aliased sloppy arguments), and compute the {start_index} for
116 // rest parameters. 116 // rest parameters.
117 CreateArgumentsType const type = CreateArgumentsTypeOf(arg_array->op()); 117 CreateArgumentsType const type = CreateArgumentsTypeOf(arg_array->op());
118 Node* frame_state = NodeProperties::GetFrameStateInput(arg_array); 118 Node* frame_state = NodeProperties::GetFrameStateInput(arg_array);
119 FrameStateInfo state_info = OpParameter<FrameStateInfo>(frame_state); 119 FrameStateInfo state_info = OpParameter<FrameStateInfo>(frame_state);
120 int formal_parameter_count;
120 int start_index = 0; 121 int start_index = 0;
122 {
123 Handle<SharedFunctionInfo> shared;
124 if (!state_info.shared_info().ToHandle(&shared)) return NoChange();
125 formal_parameter_count = shared->internal_formal_parameter_count();
126 }
121 if (type == CreateArgumentsType::kMappedArguments) { 127 if (type == CreateArgumentsType::kMappedArguments) {
122 // Mapped arguments (sloppy mode) cannot be handled if they are aliased. 128 // Mapped arguments (sloppy mode) cannot be handled if they are aliased.
123 Handle<SharedFunctionInfo> shared; 129 if (formal_parameter_count != 0) return NoChange();
124 if (!state_info.shared_info().ToHandle(&shared)) return NoChange();
125 if (shared->internal_formal_parameter_count() != 0) return NoChange();
126 } else if (type == CreateArgumentsType::kRestParameter) { 130 } else if (type == CreateArgumentsType::kRestParameter) {
127 Handle<SharedFunctionInfo> shared; 131 start_index = formal_parameter_count;
128 if (!state_info.shared_info().ToHandle(&shared)) return NoChange();
129 start_index = shared->internal_formal_parameter_count();
130 } 132 }
131 // Check if are applying to inlined arguments or to the arguments of 133 // Check if are applying to inlined arguments or to the arguments of
132 // the outermost function. 134 // the outermost function.
133 Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput); 135 Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
134 if (outer_state->opcode() != IrOpcode::kFrameState) { 136 if (outer_state->opcode() != IrOpcode::kFrameState) {
135 // TODO(jarin,bmeurer): Support the NewUnmappedArgumentsElement and 137 // TODO(jarin,bmeurer): Support the NewUnmappedArgumentsElement and
136 // NewRestParameterElements in the EscapeAnalysis and Deoptimizer 138 // NewRestParameterElements in the EscapeAnalysis and Deoptimizer
137 // instead, then we don't need this hack. 139 // instead, then we don't need this hack.
138 if (type != CreateArgumentsType::kRestParameter) { 140 // Only works with zero formal parameters because of lacking deoptimizer
141 // support.
142 if (type != CreateArgumentsType::kRestParameter &&
143 formal_parameter_count == 0) {
139 // There are no other uses of the {arg_array} except in StateValues, 144 // There are no other uses of the {arg_array} except in StateValues,
140 // so we just replace {arg_array} with a marker for the Deoptimizer 145 // so we just replace {arg_array} with a marker for the Deoptimizer
141 // that this refers to the arguments object. 146 // that this refers to the arguments object.
142 Node* arguments = graph()->NewNode(common()->ArgumentsObjectState()); 147 Node* arguments = graph()->NewNode(common()->ArgumentsObjectState());
143 ReplaceWithValue(arg_array, arguments); 148 ReplaceWithValue(arg_array, arguments);
144 } 149 }
145 150
146 // Reduce {node} to a JSCallForwardVarargs operation, which just 151 // Reduce {node} to a JSCallForwardVarargs operation, which just
147 // re-pushes the incoming arguments and calls the {target}. 152 // re-pushes the incoming arguments and calls the {target}.
148 node->RemoveInput(0); // Function.prototype.apply 153 node->RemoveInput(0); // Function.prototype.apply
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 return jsgraph()->javascript(); 788 return jsgraph()->javascript();
784 } 789 }
785 790
786 SimplifiedOperatorBuilder* JSCallReducer::simplified() const { 791 SimplifiedOperatorBuilder* JSCallReducer::simplified() const {
787 return jsgraph()->simplified(); 792 return jsgraph()->simplified();
788 } 793 }
789 794
790 } // namespace compiler 795 } // namespace compiler
791 } // namespace internal 796 } // namespace internal
792 } // namespace v8 797 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/arguments-deopt.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698