| OLD | NEW |
| 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/access-builder.h" | 10 #include "src/compiler/access-builder.h" |
| (...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 942 | 942 |
| 943 // Don't mess with other {node}s that have a constant {target}. | 943 // Don't mess with other {node}s that have a constant {target}. |
| 944 // TODO(bmeurer): Also support proxies here. | 944 // TODO(bmeurer): Also support proxies here. |
| 945 return NoChange(); | 945 return NoChange(); |
| 946 } | 946 } |
| 947 | 947 |
| 948 // Extract feedback from the {node} using the CallICNexus. | 948 // Extract feedback from the {node} using the CallICNexus. |
| 949 if (!p.feedback().IsValid()) return NoChange(); | 949 if (!p.feedback().IsValid()) return NoChange(); |
| 950 CallICNexus nexus(p.feedback().vector(), p.feedback().slot()); | 950 CallICNexus nexus(p.feedback().vector(), p.feedback().slot()); |
| 951 if (nexus.IsUninitialized()) { | 951 if (nexus.IsUninitialized()) { |
| 952 // TODO(turbofan): Tail-calling to a CallIC stub is not supported. | 952 if (flags() & kBailoutOnUninitialized) { |
| 953 if (p.tail_call_mode() == TailCallMode::kAllow) return NoChange(); | 953 // Introduce a SOFT deopt if the call {node} wasn't executed so far. |
| 954 | 954 Node* frame_state = NodeProperties::FindFrameStateBefore(node); |
| 955 // Insert a CallIC here to collect feedback for uninitialized calls. | 955 Node* deoptimize = graph()->NewNode( |
| 956 int const arg_count = static_cast<int>(p.arity() - 2); | 956 common()->Deoptimize( |
| 957 Callable callable = CodeFactory::CallIC(isolate(), p.convert_mode()); | 957 DeoptimizeKind::kSoft, |
| 958 CallDescriptor::Flags flags = CallDescriptor::kNeedsFrameState; | 958 DeoptimizeReason::kInsufficientTypeFeedbackForCall), |
| 959 CallDescriptor const* const desc = Linkage::GetStubCallDescriptor( | 959 frame_state, effect, control); |
| 960 isolate(), graph()->zone(), callable.descriptor(), arg_count + 1, | 960 // TODO(bmeurer): This should be on the AdvancedReducer somehow. |
| 961 flags); | 961 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); |
| 962 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 962 Revisit(graph()->end()); |
| 963 Node* stub_arity = jsgraph()->Constant(arg_count); | 963 node->TrimInputCount(0); |
| 964 Node* slot_index = | 964 NodeProperties::ChangeOp(node, common()->Dead()); |
| 965 jsgraph()->Constant(FeedbackVector::GetIndex(p.feedback().slot())); | 965 return Changed(node); |
| 966 Node* feedback_vector = jsgraph()->HeapConstant(p.feedback().vector()); | 966 } |
| 967 node->InsertInput(graph()->zone(), 0, stub_code); | 967 return NoChange(); |
| 968 node->InsertInput(graph()->zone(), 2, stub_arity); | |
| 969 node->InsertInput(graph()->zone(), 3, slot_index); | |
| 970 node->InsertInput(graph()->zone(), 4, feedback_vector); | |
| 971 NodeProperties::ChangeOp(node, common()->Call(desc)); | |
| 972 return Changed(node); | |
| 973 } | 968 } |
| 974 | 969 |
| 975 Handle<Object> feedback(nexus.GetFeedback(), isolate()); | 970 Handle<Object> feedback(nexus.GetFeedback(), isolate()); |
| 976 if (feedback->IsAllocationSite()) { | 971 if (feedback->IsAllocationSite()) { |
| 977 // Retrieve the Array function from the {node}. | 972 // Retrieve the Array function from the {node}. |
| 978 Node* array_function = jsgraph()->HeapConstant( | 973 Node* array_function = jsgraph()->HeapConstant( |
| 979 handle(native_context()->array_function(), isolate())); | 974 handle(native_context()->array_function(), isolate())); |
| 980 | 975 |
| 981 // Check that the {target} is still the {array_function}. | 976 // Check that the {target} is still the {array_function}. |
| 982 Node* check = graph()->NewNode(simplified()->ReferenceEqual(), target, | 977 Node* check = graph()->NewNode(simplified()->ReferenceEqual(), target, |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1191 return jsgraph()->javascript(); | 1186 return jsgraph()->javascript(); |
| 1192 } | 1187 } |
| 1193 | 1188 |
| 1194 SimplifiedOperatorBuilder* JSCallReducer::simplified() const { | 1189 SimplifiedOperatorBuilder* JSCallReducer::simplified() const { |
| 1195 return jsgraph()->simplified(); | 1190 return jsgraph()->simplified(); |
| 1196 } | 1191 } |
| 1197 | 1192 |
| 1198 } // namespace compiler | 1193 } // namespace compiler |
| 1199 } // namespace internal | 1194 } // namespace internal |
| 1200 } // namespace v8 | 1195 } // namespace v8 |
| OLD | NEW |