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 20 matching lines...) Expand all Loading... |
31 jsgraph_(jsgraph), | 31 jsgraph_(jsgraph), |
32 flags_(flags), | 32 flags_(flags), |
33 native_context_(native_context), | 33 native_context_(native_context), |
34 dependencies_(dependencies), | 34 dependencies_(dependencies), |
35 zone_(zone), | 35 zone_(zone), |
36 type_cache_(TypeCache::Get()) {} | 36 type_cache_(TypeCache::Get()) {} |
37 | 37 |
38 | 38 |
39 Reduction JSNativeContextSpecialization::Reduce(Node* node) { | 39 Reduction JSNativeContextSpecialization::Reduce(Node* node) { |
40 switch (node->opcode()) { | 40 switch (node->opcode()) { |
| 41 case IrOpcode::kJSLoadContext: |
| 42 return ReduceJSLoadContext(node); |
41 case IrOpcode::kJSLoadNamed: | 43 case IrOpcode::kJSLoadNamed: |
42 return ReduceJSLoadNamed(node); | 44 return ReduceJSLoadNamed(node); |
43 case IrOpcode::kJSStoreNamed: | 45 case IrOpcode::kJSStoreNamed: |
44 return ReduceJSStoreNamed(node); | 46 return ReduceJSStoreNamed(node); |
45 case IrOpcode::kJSLoadProperty: | 47 case IrOpcode::kJSLoadProperty: |
46 return ReduceJSLoadProperty(node); | 48 return ReduceJSLoadProperty(node); |
47 case IrOpcode::kJSStoreProperty: | 49 case IrOpcode::kJSStoreProperty: |
48 return ReduceJSStoreProperty(node); | 50 return ReduceJSStoreProperty(node); |
49 default: | 51 default: |
50 break; | 52 break; |
51 } | 53 } |
52 return NoChange(); | 54 return NoChange(); |
53 } | 55 } |
54 | 56 |
| 57 Reduction JSNativeContextSpecialization::ReduceJSLoadContext(Node* node) { |
| 58 DCHECK_EQ(IrOpcode::kJSLoadContext, node->opcode()); |
| 59 ContextAccess const& access = ContextAccessOf(node->op()); |
| 60 Handle<Context> native_context; |
| 61 // Specialize JSLoadContext(NATIVE_CONTEXT_INDEX) to the known native |
| 62 // context (if any), so we can constant-fold those fields, which is |
| 63 // safe, since the NATIVE_CONTEXT_INDEX slot is always immutable. |
| 64 if (access.index() == Context::NATIVE_CONTEXT_INDEX && |
| 65 GetNativeContext(node).ToHandle(&native_context)) { |
| 66 Node* value = jsgraph()->HeapConstant(native_context); |
| 67 ReplaceWithValue(node, value); |
| 68 return Replace(value); |
| 69 } |
| 70 return NoChange(); |
| 71 } |
55 | 72 |
56 Reduction JSNativeContextSpecialization::ReduceNamedAccess( | 73 Reduction JSNativeContextSpecialization::ReduceNamedAccess( |
57 Node* node, Node* value, MapHandleList const& receiver_maps, | 74 Node* node, Node* value, MapHandleList const& receiver_maps, |
58 Handle<Name> name, AccessMode access_mode, LanguageMode language_mode, | 75 Handle<Name> name, AccessMode access_mode, LanguageMode language_mode, |
59 Node* index) { | 76 Node* index) { |
60 DCHECK(node->opcode() == IrOpcode::kJSLoadNamed || | 77 DCHECK(node->opcode() == IrOpcode::kJSLoadNamed || |
61 node->opcode() == IrOpcode::kJSStoreNamed || | 78 node->opcode() == IrOpcode::kJSStoreNamed || |
62 node->opcode() == IrOpcode::kJSLoadProperty || | 79 node->opcode() == IrOpcode::kJSLoadProperty || |
63 node->opcode() == IrOpcode::kJSStoreProperty); | 80 node->opcode() == IrOpcode::kJSStoreProperty); |
64 Node* receiver = NodeProperties::GetValueInput(node, 0); | 81 Node* receiver = NodeProperties::GetValueInput(node, 0); |
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 } | 1043 } |
1027 | 1044 |
1028 | 1045 |
1029 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const { | 1046 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const { |
1030 return jsgraph()->simplified(); | 1047 return jsgraph()->simplified(); |
1031 } | 1048 } |
1032 | 1049 |
1033 } // namespace compiler | 1050 } // namespace compiler |
1034 } // namespace internal | 1051 } // namespace internal |
1035 } // namespace v8 | 1052 } // namespace v8 |
OLD | NEW |