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

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

Issue 2537763002: [turbofan] Also optimize instanceof with bound functions. (Closed)
Patch Set: Created 4 years 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-builtin-reducer.h ('k') | src/compiler/js-call-reducer.h » ('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-builtin-reducer.h" 5 #include "src/compiler/js-builtin-reducer.h"
6 6
7 #include "src/compilation-dependencies.h" 7 #include "src/compilation-dependencies.h"
8 #include "src/compiler/access-builder.h" 8 #include "src/compiler/access-builder.h"
9 #include "src/compiler/js-graph.h" 9 #include "src/compiler/js-graph.h"
10 #include "src/compiler/node-matchers.h" 10 #include "src/compiler/node-matchers.h"
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 if (HasInstanceTypeWitness(receiver, effect, JS_DATE_TYPE)) { 957 if (HasInstanceTypeWitness(receiver, effect, JS_DATE_TYPE)) {
958 Node* value = effect = graph()->NewNode( 958 Node* value = effect = graph()->NewNode(
959 simplified()->LoadField(AccessBuilder::ForJSDateValue()), receiver, 959 simplified()->LoadField(AccessBuilder::ForJSDateValue()), receiver,
960 effect, control); 960 effect, control);
961 ReplaceWithValue(node, value, effect, control); 961 ReplaceWithValue(node, value, effect, control);
962 return Replace(value); 962 return Replace(value);
963 } 963 }
964 return NoChange(); 964 return NoChange();
965 } 965 }
966 966
967 // ES6 section 19.2.3.6 Function.prototype [ @@hasInstance ] ( V )
968 Reduction JSBuiltinReducer::ReduceFunctionHasInstance(Node* node) {
969 Node* receiver = NodeProperties::GetValueInput(node, 1);
970 Node* object = (node->op()->ValueInputCount() >= 3)
971 ? NodeProperties::GetValueInput(node, 2)
972 : jsgraph()->UndefinedConstant();
973 Node* context = NodeProperties::GetContextInput(node);
974 Node* frame_state = NodeProperties::GetFrameStateInput(node);
975 Node* effect = NodeProperties::GetEffectInput(node);
976 Node* control = NodeProperties::GetControlInput(node);
977
978 // TODO(turbofan): If JSOrdinaryToInstance raises an exception, the
979 // stack trace doesn't contain the @@hasInstance call; we have the
980 // corresponding bug in the baseline case. Some massaging of the frame
981 // state would be necessary here.
982
983 // Morph this {node} into a JSOrdinaryHasInstance node.
984 node->ReplaceInput(0, receiver);
985 node->ReplaceInput(1, object);
986 node->ReplaceInput(2, context);
987 node->ReplaceInput(3, frame_state);
988 node->ReplaceInput(4, effect);
989 node->ReplaceInput(5, control);
990 node->TrimInputCount(6);
991 NodeProperties::ChangeOp(node, javascript()->OrdinaryHasInstance());
992 return Changed(node);
993 }
994
995 // ES6 section 18.2.2 isFinite ( number ) 967 // ES6 section 18.2.2 isFinite ( number )
996 Reduction JSBuiltinReducer::ReduceGlobalIsFinite(Node* node) { 968 Reduction JSBuiltinReducer::ReduceGlobalIsFinite(Node* node) {
997 JSCallReduction r(node); 969 JSCallReduction r(node);
998 if (r.InputsMatchOne(Type::PlainPrimitive())) { 970 if (r.InputsMatchOne(Type::PlainPrimitive())) {
999 // isFinite(a:plain-primitive) -> NumberEqual(a', a') 971 // isFinite(a:plain-primitive) -> NumberEqual(a', a')
1000 // where a' = NumberSubtract(ToNumber(a), ToNumber(a)) 972 // where a' = NumberSubtract(ToNumber(a), ToNumber(a))
1001 Node* input = ToNumber(r.GetJSCallInput(0)); 973 Node* input = ToNumber(r.GetJSCallInput(0));
1002 Node* diff = graph()->NewNode(simplified()->NumberSubtract(), input, input); 974 Node* diff = graph()->NewNode(simplified()->NumberSubtract(), input, input);
1003 Node* value = graph()->NewNode(simplified()->NumberEqual(), diff, diff); 975 Node* value = graph()->NewNode(simplified()->NumberEqual(), diff, diff);
1004 return Replace(value); 976 return Replace(value);
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 case kArrayValues: 1840 case kArrayValues:
1869 return ReduceArrayIterator(node, IterationKind::kValues); 1841 return ReduceArrayIterator(node, IterationKind::kValues);
1870 case kArrayIteratorNext: 1842 case kArrayIteratorNext:
1871 return ReduceArrayIteratorNext(node); 1843 return ReduceArrayIteratorNext(node);
1872 case kArrayPop: 1844 case kArrayPop:
1873 return ReduceArrayPop(node); 1845 return ReduceArrayPop(node);
1874 case kArrayPush: 1846 case kArrayPush:
1875 return ReduceArrayPush(node); 1847 return ReduceArrayPush(node);
1876 case kDateGetTime: 1848 case kDateGetTime:
1877 return ReduceDateGetTime(node); 1849 return ReduceDateGetTime(node);
1878 case kFunctionHasInstance:
1879 return ReduceFunctionHasInstance(node);
1880 break;
1881 case kGlobalIsFinite: 1850 case kGlobalIsFinite:
1882 reduction = ReduceGlobalIsFinite(node); 1851 reduction = ReduceGlobalIsFinite(node);
1883 break; 1852 break;
1884 case kGlobalIsNaN: 1853 case kGlobalIsNaN:
1885 reduction = ReduceGlobalIsNaN(node); 1854 reduction = ReduceGlobalIsNaN(node);
1886 break; 1855 break;
1887 case kMathAbs: 1856 case kMathAbs:
1888 reduction = ReduceMathAbs(node); 1857 reduction = ReduceMathAbs(node);
1889 break; 1858 break;
1890 case kMathAcos: 1859 case kMathAcos:
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
2074 return jsgraph()->simplified(); 2043 return jsgraph()->simplified();
2075 } 2044 }
2076 2045
2077 JSOperatorBuilder* JSBuiltinReducer::javascript() const { 2046 JSOperatorBuilder* JSBuiltinReducer::javascript() const {
2078 return jsgraph()->javascript(); 2047 return jsgraph()->javascript();
2079 } 2048 }
2080 2049
2081 } // namespace compiler 2050 } // namespace compiler
2082 } // namespace internal 2051 } // namespace internal
2083 } // namespace v8 2052 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-builtin-reducer.h ('k') | src/compiler/js-call-reducer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698