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

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

Issue 1425883004: [turbofan] Fix missing bailout point before calls. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Update unittests. Created 5 years, 1 month 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-generic-lowering.cc ('k') | src/compiler/js-typed-lowering.cc » ('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/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.h" 9 #include "src/compiler.h"
10 #include "src/compiler/all-nodes.h" 10 #include "src/compiler/all-nodes.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 return call_->InputAt(static_cast<int>(2 + index)); 49 return call_->InputAt(static_cast<int>(2 + index));
50 } 50 }
51 51
52 size_t formal_arguments() { 52 size_t formal_arguments() {
53 // {value_inputs} includes jsfunction and receiver. 53 // {value_inputs} includes jsfunction and receiver.
54 size_t value_inputs = call_->op()->ValueInputCount(); 54 size_t value_inputs = call_->op()->ValueInputCount();
55 DCHECK_GE(call_->InputCount(), 2); 55 DCHECK_GE(call_->InputCount(), 2);
56 return value_inputs - 2; 56 return value_inputs - 2;
57 } 57 }
58 58
59 Node* frame_state() { return NodeProperties::GetFrameStateInput(call_, 0); } 59 Node* frame_state_before() {
60 return NodeProperties::GetFrameStateInput(call_, 1);
61 }
62 Node* frame_state_after() {
63 return NodeProperties::GetFrameStateInput(call_, 0);
64 }
60 65
61 private: 66 private:
62 Node* call_; 67 Node* call_;
63 }; 68 };
64 69
65 70
66 class CopyVisitor { 71 class CopyVisitor {
67 public: 72 public:
68 CopyVisitor(Graph* source_graph, Graph* target_graph, Zone* temp_zone) 73 CopyVisitor(Graph* source_graph, Graph* target_graph, Zone* temp_zone)
69 : sentinel_op_(IrOpcode::kDead, Operator::kNoProperties, "Sentinel", 0, 0, 74 : sentinel_op_(IrOpcode::kDead, Operator::kNoProperties, "Sentinel", 0, 0,
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 Node* node0 = jsgraph_->graph()->NewNode(op0); 235 Node* node0 = jsgraph_->graph()->NewNode(op0);
231 NodeVector params(local_zone_); 236 NodeVector params(local_zone_);
232 params.push_back(call->receiver()); 237 params.push_back(call->receiver());
233 for (size_t argument = 0; argument != call->formal_arguments(); ++argument) { 238 for (size_t argument = 0; argument != call->formal_arguments(); ++argument) {
234 params.push_back(call->formal_argument(argument)); 239 params.push_back(call->formal_argument(argument));
235 } 240 }
236 const Operator* op_param = 241 const Operator* op_param =
237 jsgraph_->common()->StateValues(static_cast<int>(params.size())); 242 jsgraph_->common()->StateValues(static_cast<int>(params.size()));
238 Node* params_node = jsgraph_->graph()->NewNode( 243 Node* params_node = jsgraph_->graph()->NewNode(
239 op_param, static_cast<int>(params.size()), &params.front()); 244 op_param, static_cast<int>(params.size()), &params.front());
240 return jsgraph_->graph()->NewNode(op, params_node, node0, node0, 245 return jsgraph_->graph()->NewNode(
241 jsgraph_->UndefinedConstant(), 246 op, params_node, node0, node0, jsgraph_->UndefinedConstant(),
242 call->jsfunction(), call->frame_state()); 247 call->jsfunction(), call->frame_state_after());
243 } 248 }
244 249
245 250
246 Reduction JSInliner::Reduce(Node* node) { 251 Reduction JSInliner::Reduce(Node* node) {
247 if (node->opcode() != IrOpcode::kJSCallFunction) return NoChange(); 252 if (node->opcode() != IrOpcode::kJSCallFunction) return NoChange();
248 253
249 JSCallFunctionAccessor call(node); 254 JSCallFunctionAccessor call(node);
250 HeapObjectMatcher match(call.jsfunction()); 255 HeapObjectMatcher match(call.jsfunction());
251 if (!match.HasValue() || !match.Value()->IsJSFunction()) return NoChange(); 256 if (!match.HasValue() || !match.Value()->IsJSFunction()) return NoChange();
252 Handle<JSFunction> function = Handle<JSFunction>::cast(match.Value()); 257 Handle<JSFunction> function = Handle<JSFunction>::cast(match.Value());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 info_->context()->native_context()) { 293 info_->context()->native_context()) {
289 TRACE("Not inlining %s into %s because of different native contexts\n", 294 TRACE("Not inlining %s into %s because of different native contexts\n",
290 function->shared()->DebugName()->ToCString().get(), 295 function->shared()->DebugName()->ToCString().get(),
291 info_->shared_info()->DebugName()->ToCString().get()); 296 info_->shared_info()->DebugName()->ToCString().get());
292 return NoChange(); 297 return NoChange();
293 } 298 }
294 299
295 // TODO(turbofan): TranslatedState::GetAdaptedArguments() currently relies on 300 // TODO(turbofan): TranslatedState::GetAdaptedArguments() currently relies on
296 // not inlining recursive functions. We might want to relax that at some 301 // not inlining recursive functions. We might want to relax that at some
297 // point. 302 // point.
298 for (Node* frame_state = call.frame_state(); 303 for (Node* frame_state = call.frame_state_after();
299 frame_state->opcode() == IrOpcode::kFrameState; 304 frame_state->opcode() == IrOpcode::kFrameState;
300 frame_state = frame_state->InputAt(kFrameStateOuterStateInput)) { 305 frame_state = frame_state->InputAt(kFrameStateOuterStateInput)) {
301 FrameStateInfo const& info = OpParameter<FrameStateInfo>(frame_state); 306 FrameStateInfo const& info = OpParameter<FrameStateInfo>(frame_state);
302 Handle<SharedFunctionInfo> shared_info; 307 Handle<SharedFunctionInfo> shared_info;
303 if (info.shared_info().ToHandle(&shared_info) && 308 if (info.shared_info().ToHandle(&shared_info) &&
304 *shared_info == function->shared()) { 309 *shared_info == function->shared()) {
305 TRACE("Not inlining %s into %s because call is recursive\n", 310 TRACE("Not inlining %s into %s because call is recursive\n",
306 function->shared()->DebugName()->ToCString().get(), 311 function->shared()->DebugName()->ToCString().get(),
307 info_->shared_info()->DebugName()->ToCString().get()); 312 info_->shared_info()->DebugName()->ToCString().get());
308 return NoChange(); 313 return NoChange();
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 // TODO(turbofan): We might want to load the context from the JSFunction at 407 // TODO(turbofan): We might want to load the context from the JSFunction at
403 // runtime in case we only know the SharedFunctionInfo once we have dynamic 408 // runtime in case we only know the SharedFunctionInfo once we have dynamic
404 // type feedback in the compiler. 409 // type feedback in the compiler.
405 Node* context = jsgraph_->Constant(handle(function->context())); 410 Node* context = jsgraph_->Constant(handle(function->context()));
406 411
407 CopyVisitor visitor(&graph, jsgraph_->graph(), &zone); 412 CopyVisitor visitor(&graph, jsgraph_->graph(), &zone);
408 visitor.CopyGraph(); 413 visitor.CopyGraph();
409 414
410 Node* start = visitor.GetCopy(graph.start()); 415 Node* start = visitor.GetCopy(graph.start());
411 Node* end = visitor.GetCopy(graph.end()); 416 Node* end = visitor.GetCopy(graph.end());
412 Node* frame_state = call.frame_state(); 417 Node* frame_state = call.frame_state_after();
418
419 // Insert a JSConvertReceiver node for sloppy callees. Note that the context
420 // passed into this node has to be the callees context (loaded above). Note
421 // that the frame state passed to the JSConvertReceiver must be the frame
422 // state _before_ the call; it is not necessary to fiddle with the receiver
423 // in that frame state tho, as the conversion of the receiver can be repeated
424 // any number of times, it's not observable.
425 if (is_sloppy(info.language_mode()) && !function->shared()->native()) {
426 const CallFunctionParameters& p = CallFunctionParametersOf(node->op());
427 Node* effect = NodeProperties::GetEffectInput(node);
428 Node* convert = jsgraph_->graph()->NewNode(
429 jsgraph_->javascript()->ConvertReceiver(p.convert_mode()),
430 call.receiver(), context, call.frame_state_before(), effect, start);
431 NodeProperties::ReplaceValueInput(node, convert, 1);
432 NodeProperties::ReplaceEffectInput(node, convert);
433 }
413 434
414 // Insert argument adaptor frame if required. The callees formal parameter 435 // Insert argument adaptor frame if required. The callees formal parameter
415 // count (i.e. value outputs of start node minus target, receiver & context) 436 // count (i.e. value outputs of start node minus target, receiver & context)
416 // have to match the number of arguments passed to the call. 437 // have to match the number of arguments passed to the call.
417 DCHECK_EQ(static_cast<int>(parameter_count), 438 DCHECK_EQ(static_cast<int>(parameter_count),
418 start->op()->ValueOutputCount() - 3); 439 start->op()->ValueOutputCount() - 3);
419 if (call.formal_arguments() != parameter_count) { 440 if (call.formal_arguments() != parameter_count) {
420 frame_state = CreateArgumentsAdaptorFrameState(&call, info.shared_info()); 441 frame_state = CreateArgumentsAdaptorFrameState(&call, info.shared_info());
421 } 442 }
422 443
423 // Insert a JSConvertReceiver node for sloppy callees. Note that the context
424 // passed into this node has to be the callees context (loaded above).
425 if (is_sloppy(info.language_mode()) && !function->shared()->native()) {
426 const CallFunctionParameters& p = CallFunctionParametersOf(node->op());
427 Node* effect = NodeProperties::GetEffectInput(node);
428 Node* convert = jsgraph_->graph()->NewNode(
429 jsgraph_->javascript()->ConvertReceiver(p.convert_mode()),
430 call.receiver(), context, frame_state, effect, start);
431 NodeProperties::ReplaceValueInput(node, convert, 1);
432 NodeProperties::ReplaceEffectInput(node, convert);
433 }
434
435 return InlineCall(node, context, frame_state, start, end); 444 return InlineCall(node, context, frame_state, start, end);
436 } 445 }
437 446
438 } // namespace compiler 447 } // namespace compiler
439 } // namespace internal 448 } // namespace internal
440 } // namespace v8 449 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-generic-lowering.cc ('k') | src/compiler/js-typed-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698