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/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
9 #include "src/objects-inl.h" | 9 #include "src/objects-inl.h" |
10 #include "src/type-feedback-vector-inl.h" | 10 #include "src/type-feedback-vector-inl.h" |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 // Try to specialize JSCallFunction {node}s with constant {target}s. | 209 // Try to specialize JSCallFunction {node}s with constant {target}s. |
210 HeapObjectMatcher m(target); | 210 HeapObjectMatcher m(target); |
211 if (m.HasValue()) { | 211 if (m.HasValue()) { |
212 if (m.Value()->IsJSFunction()) { | 212 if (m.Value()->IsJSFunction()) { |
213 Handle<JSFunction> function = Handle<JSFunction>::cast(m.Value()); | 213 Handle<JSFunction> function = Handle<JSFunction>::cast(m.Value()); |
214 Handle<SharedFunctionInfo> shared(function->shared(), isolate()); | 214 Handle<SharedFunctionInfo> shared(function->shared(), isolate()); |
215 | 215 |
216 // Raise a TypeError if the {target} is a "classConstructor". | 216 // Raise a TypeError if the {target} is a "classConstructor". |
217 if (IsClassConstructor(shared->kind())) { | 217 if (IsClassConstructor(shared->kind())) { |
218 NodeProperties::RemoveFrameStateInput(node, 0); | 218 NodeProperties::RemoveFrameStateInput(node, 0); |
219 NodeProperties::RemoveValueInputs(node); | 219 NodeProperties::ReplaceValueInputs(node, target); |
220 NodeProperties::ChangeOp( | 220 NodeProperties::ChangeOp( |
221 node, javascript()->CallRuntime( | 221 node, javascript()->CallRuntime( |
222 Runtime::kThrowConstructorNonCallableError, 0)); | 222 Runtime::kThrowConstructorNonCallableError, 1)); |
223 return Changed(node); | 223 return Changed(node); |
224 } | 224 } |
225 | 225 |
226 // Check for known builtin functions. | 226 // Check for known builtin functions. |
227 if (shared->HasBuiltinFunctionId()) { | 227 if (shared->HasBuiltinFunctionId()) { |
228 switch (shared->builtin_function_id()) { | 228 switch (shared->builtin_function_id()) { |
229 case kFunctionApply: | 229 case kFunctionApply: |
230 return ReduceFunctionPrototypeApply(node); | 230 return ReduceFunctionPrototypeApply(node); |
231 case kFunctionCall: | 231 case kFunctionCall: |
232 return ReduceFunctionPrototypeCall(node); | 232 return ReduceFunctionPrototypeCall(node); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 } | 493 } |
494 | 494 |
495 | 495 |
496 JSOperatorBuilder* JSCallReducer::javascript() const { | 496 JSOperatorBuilder* JSCallReducer::javascript() const { |
497 return jsgraph()->javascript(); | 497 return jsgraph()->javascript(); |
498 } | 498 } |
499 | 499 |
500 } // namespace compiler | 500 } // namespace compiler |
501 } // namespace internal | 501 } // namespace internal |
502 } // namespace v8 | 502 } // namespace v8 |
OLD | NEW |