| OLD | NEW |
| 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/code-factory.h" | 5 #include "src/code-factory.h" |
| 6 #include "src/compilation-dependencies.h" | 6 #include "src/compilation-dependencies.h" |
| 7 #include "src/compiler/access-builder.h" | 7 #include "src/compiler/access-builder.h" |
| 8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
| 9 #include "src/compiler/js-typed-lowering.h" | 9 #include "src/compiler/js-typed-lowering.h" |
| 10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
| (...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1059 return NoChange(); | 1059 return NoChange(); |
| 1060 } | 1060 } |
| 1061 | 1061 |
| 1062 | 1062 |
| 1063 Reduction JSTypedLowering::ReduceJSInstanceOf(Node* node) { | 1063 Reduction JSTypedLowering::ReduceJSInstanceOf(Node* node) { |
| 1064 DCHECK_EQ(IrOpcode::kJSInstanceOf, node->opcode()); | 1064 DCHECK_EQ(IrOpcode::kJSInstanceOf, node->opcode()); |
| 1065 Node* const context = NodeProperties::GetContextInput(node); | 1065 Node* const context = NodeProperties::GetContextInput(node); |
| 1066 Node* const frame_state = NodeProperties::GetFrameStateInput(node, 0); | 1066 Node* const frame_state = NodeProperties::GetFrameStateInput(node, 0); |
| 1067 | 1067 |
| 1068 // If deoptimization is disabled, we cannot optimize. | 1068 // If deoptimization is disabled, we cannot optimize. |
| 1069 if (!(flags() & kDeoptimizationEnabled) || | 1069 if (!(flags() & kDeoptimizationEnabled)) return NoChange(); |
| 1070 (flags() & kDisableBinaryOpReduction)) { | |
| 1071 return NoChange(); | |
| 1072 } | |
| 1073 | 1070 |
| 1074 // If we are in a try block, don't optimize since the runtime call | 1071 // If we are in a try block, don't optimize since the runtime call |
| 1075 // in the proxy case can throw. | 1072 // in the proxy case can throw. |
| 1076 if (NodeProperties::IsExceptionalCall(node)) return NoChange(); | 1073 if (NodeProperties::IsExceptionalCall(node)) return NoChange(); |
| 1077 | 1074 |
| 1078 JSBinopReduction r(this, node); | 1075 JSBinopReduction r(this, node); |
| 1079 Node* effect = r.effect(); | 1076 Node* effect = r.effect(); |
| 1080 Node* control = r.control(); | 1077 Node* control = r.control(); |
| 1081 | 1078 |
| 1082 if (!r.right_type()->IsConstant() || | 1079 if (!r.right_type()->IsConstant() || |
| 1083 !r.right_type()->AsConstant()->Value()->IsJSFunction()) { | 1080 !r.right_type()->AsConstant()->Value()->IsJSFunction()) { |
| 1084 return NoChange(); | 1081 return NoChange(); |
| 1085 } | 1082 } |
| 1086 | 1083 |
| 1087 Handle<JSFunction> function = | 1084 Handle<JSFunction> function = |
| 1088 Handle<JSFunction>::cast(r.right_type()->AsConstant()->Value()); | 1085 Handle<JSFunction>::cast(r.right_type()->AsConstant()->Value()); |
| 1089 Handle<SharedFunctionInfo> shared(function->shared(), isolate()); | 1086 Handle<SharedFunctionInfo> shared(function->shared(), isolate()); |
| 1090 | 1087 |
| 1091 if (!function->IsConstructor() || | 1088 // Make sure the prototype of {function} is the %FunctionPrototype%, and it |
| 1092 function->map()->has_non_instance_prototype()) { | 1089 // already has a meaningful initial map (i.e. we constructed at least one |
| 1090 // instance using the constructor {function}). |
| 1091 if (function->map()->prototype() != function->native_context()->closure() || |
| 1092 function->map()->has_non_instance_prototype() || |
| 1093 !function->has_initial_map()) { |
| 1093 return NoChange(); | 1094 return NoChange(); |
| 1094 } | 1095 } |
| 1095 | 1096 |
| 1096 JSFunction::EnsureHasInitialMap(function); | 1097 // We can only use the fast case if @@hasInstance was not used so far. |
| 1097 DCHECK(function->has_initial_map()); | 1098 if (!isolate()->IsHasInstanceLookupChainIntact()) return NoChange(); |
| 1099 dependencies()->AssumePropertyCell(factory()->has_instance_protector()); |
| 1100 |
| 1098 Handle<Map> initial_map(function->initial_map(), isolate()); | 1101 Handle<Map> initial_map(function->initial_map(), isolate()); |
| 1099 this->dependencies()->AssumeInitialMapCantChange(initial_map); | 1102 dependencies()->AssumeInitialMapCantChange(initial_map); |
| 1100 Node* prototype = | 1103 Node* prototype = |
| 1101 jsgraph()->Constant(handle(initial_map->prototype(), isolate())); | 1104 jsgraph()->Constant(handle(initial_map->prototype(), isolate())); |
| 1102 | 1105 |
| 1103 Node* if_is_smi = nullptr; | 1106 Node* if_is_smi = nullptr; |
| 1104 Node* e_is_smi = nullptr; | 1107 Node* e_is_smi = nullptr; |
| 1105 // If the left hand side is an object, no smi check is needed. | 1108 // If the left hand side is an object, no smi check is needed. |
| 1106 if (r.left_type()->Maybe(Type::TaggedSigned())) { | 1109 if (r.left_type()->Maybe(Type::TaggedSigned())) { |
| 1107 Node* is_smi = graph()->NewNode(simplified()->ObjectIsSmi(), r.left()); | 1110 Node* is_smi = graph()->NewNode(simplified()->ObjectIsSmi(), r.left()); |
| 1108 Node* branch_is_smi = | 1111 Node* branch_is_smi = |
| 1109 graph()->NewNode(common()->Branch(BranchHint::kFalse), is_smi, control); | 1112 graph()->NewNode(common()->Branch(BranchHint::kFalse), is_smi, control); |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1808 } | 1811 } |
| 1809 | 1812 |
| 1810 | 1813 |
| 1811 CompilationDependencies* JSTypedLowering::dependencies() const { | 1814 CompilationDependencies* JSTypedLowering::dependencies() const { |
| 1812 return dependencies_; | 1815 return dependencies_; |
| 1813 } | 1816 } |
| 1814 | 1817 |
| 1815 } // namespace compiler | 1818 } // namespace compiler |
| 1816 } // namespace internal | 1819 } // namespace internal |
| 1817 } // namespace v8 | 1820 } // namespace v8 |
| OLD | NEW |