| 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-native-context-specialization.h" | 5 #include "src/compiler/js-native-context-specialization.h" | 
| 6 | 6 | 
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" | 
| 8 #include "src/code-factory.h" | 8 #include "src/code-factory.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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 168 | 168 | 
| 169   return NoChange(); | 169   return NoChange(); | 
| 170 } | 170 } | 
| 171 | 171 | 
| 172 Reduction JSNativeContextSpecialization::ReduceJSInstanceOf(Node* node) { | 172 Reduction JSNativeContextSpecialization::ReduceJSInstanceOf(Node* node) { | 
| 173   DCHECK_EQ(IrOpcode::kJSInstanceOf, node->opcode()); | 173   DCHECK_EQ(IrOpcode::kJSInstanceOf, node->opcode()); | 
| 174   Node* object = NodeProperties::GetValueInput(node, 0); | 174   Node* object = NodeProperties::GetValueInput(node, 0); | 
| 175   Node* constructor = NodeProperties::GetValueInput(node, 1); | 175   Node* constructor = NodeProperties::GetValueInput(node, 1); | 
| 176   Node* context = NodeProperties::GetContextInput(node); | 176   Node* context = NodeProperties::GetContextInput(node); | 
| 177   Node* effect = NodeProperties::GetEffectInput(node); | 177   Node* effect = NodeProperties::GetEffectInput(node); | 
|  | 178   Node* frame_state = NodeProperties::GetFrameStateInput(node); | 
| 178   Node* control = NodeProperties::GetControlInput(node); | 179   Node* control = NodeProperties::GetControlInput(node); | 
| 179 | 180 | 
| 180   // Check if the right hand side is a known {receiver}. | 181   // Check if the right hand side is a known {receiver}. | 
| 181   HeapObjectMatcher m(constructor); | 182   HeapObjectMatcher m(constructor); | 
| 182   if (!m.HasValue() || !m.Value()->IsJSObject()) return NoChange(); | 183   if (!m.HasValue() || !m.Value()->IsJSObject()) return NoChange(); | 
| 183   Handle<JSObject> receiver = Handle<JSObject>::cast(m.Value()); | 184   Handle<JSObject> receiver = Handle<JSObject>::cast(m.Value()); | 
| 184   Handle<Map> receiver_map(receiver->map(), isolate()); | 185   Handle<Map> receiver_map(receiver->map(), isolate()); | 
| 185 | 186 | 
| 186   // Compute property access info for @@hasInstance on {receiver}. | 187   // Compute property access info for @@hasInstance on {receiver}. | 
| 187   PropertyAccessInfo access_info; | 188   PropertyAccessInfo access_info; | 
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 237       FieldIndex field_index = access_info.field_index(); | 238       FieldIndex field_index = access_info.field_index(); | 
| 238       constant = JSObject::FastPropertyAt(holder, Representation::Tagged(), | 239       constant = JSObject::FastPropertyAt(holder, Representation::Tagged(), | 
| 239                                           field_index); | 240                                           field_index); | 
| 240     } | 241     } | 
| 241     DCHECK(constant->IsCallable()); | 242     DCHECK(constant->IsCallable()); | 
| 242 | 243 | 
| 243     // Monomorphic property access. | 244     // Monomorphic property access. | 
| 244     effect = BuildCheckMaps(constructor, effect, control, | 245     effect = BuildCheckMaps(constructor, effect, control, | 
| 245                             access_info.receiver_maps()); | 246                             access_info.receiver_maps()); | 
| 246 | 247 | 
|  | 248     // Create a nested frame state inside the current method's most-recent frame | 
|  | 249     // state that will ensure that deopts that happen after this point will not | 
|  | 250     // fallback to the last Checkpoint--which would completely re-execute the | 
|  | 251     // instanceof logic--but rather create an activation of a version of the | 
|  | 252     // ToBoolean stub that finishes the remaining work of instanceof and returns | 
|  | 253     // to the caller without duplicating side-effects upon a lazy deopt. | 
|  | 254     Node* continuation_frame_state = CreateStubBuiltinContinuationFrameState( | 
|  | 255         jsgraph(), Builtins::kToBooleanLazyDeoptContinuation, context, nullptr, | 
|  | 256         0, frame_state, ContinuationFrameStateMode::LAZY); | 
|  | 257 | 
| 247     // Call the @@hasInstance handler. | 258     // Call the @@hasInstance handler. | 
| 248     Node* target = jsgraph()->Constant(constant); | 259     Node* target = jsgraph()->Constant(constant); | 
| 249     node->InsertInput(graph()->zone(), 0, target); | 260     node->InsertInput(graph()->zone(), 0, target); | 
| 250     node->ReplaceInput(1, constructor); | 261     node->ReplaceInput(1, constructor); | 
| 251     node->ReplaceInput(2, object); | 262     node->ReplaceInput(2, object); | 
|  | 263     node->ReplaceInput(4, continuation_frame_state); | 
| 252     node->ReplaceInput(5, effect); | 264     node->ReplaceInput(5, effect); | 
| 253     NodeProperties::ChangeOp( | 265     NodeProperties::ChangeOp( | 
| 254         node, javascript()->Call(3, CallFrequency(), VectorSlotPair(), | 266         node, javascript()->Call(3, CallFrequency(), VectorSlotPair(), | 
| 255                                  ConvertReceiverMode::kNotNullOrUndefined)); | 267                                  ConvertReceiverMode::kNotNullOrUndefined)); | 
| 256 | 268 | 
| 257     // Rewire the value uses of {node} to ToBoolean conversion of the result. | 269     // Rewire the value uses of {node} to ToBoolean conversion of the result. | 
| 258     Node* value = graph()->NewNode(javascript()->ToBoolean(ToBooleanHint::kAny), | 270     Node* value = graph()->NewNode(javascript()->ToBoolean(ToBooleanHint::kAny), | 
| 259                                    node, context); | 271                                    node, context); | 
| 260     for (Edge edge : node->use_edges()) { | 272     for (Edge edge : node->use_edges()) { | 
| 261       if (NodeProperties::IsValueEdge(edge) && edge.from() != value) { | 273       if (NodeProperties::IsValueEdge(edge) && edge.from() != value) { | 
| (...skipping 2352 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2614   return jsgraph()->javascript(); | 2626   return jsgraph()->javascript(); | 
| 2615 } | 2627 } | 
| 2616 | 2628 | 
| 2617 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const { | 2629 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const { | 
| 2618   return jsgraph()->simplified(); | 2630   return jsgraph()->simplified(); | 
| 2619 } | 2631 } | 
| 2620 | 2632 | 
| 2621 }  // namespace compiler | 2633 }  // namespace compiler | 
| 2622 }  // namespace internal | 2634 }  // namespace internal | 
| 2623 }  // namespace v8 | 2635 }  // namespace v8 | 
| OLD | NEW | 
|---|