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/compiler/js-context-specialization.h" | 5 #include "src/compiler/js-context-specialization.h" |
6 #include "src/compiler/js-operator.h" | 6 #include "src/compiler/js-operator.h" |
7 #include "src/compiler/node-matchers.h" | 7 #include "src/compiler/node-matchers.h" |
8 #include "src/compiler/node-properties-inl.h" | 8 #include "src/compiler/node-properties-inl.h" |
9 #include "src/compiler/simplified-node-factory.h" | 9 #include "src/compiler/simplified-node-factory.h" |
10 #include "src/compiler/source-position.h" | 10 #include "src/compiler/source-position.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // Mutable slot, constant context, depth > 0 => fold-in parent context. | 88 // Mutable slot, constant context, depth > 0 => fold-in parent context. |
89 Node* load = t.NewNode( | 89 Node* load = t.NewNode( |
90 t.javascript()->LoadContext(2, Context::GLOBAL_EVAL_FUN_INDEX, false), | 90 t.javascript()->LoadContext(2, Context::GLOBAL_EVAL_FUN_INDEX, false), |
91 deep_const_context, deep_const_context, start); | 91 deep_const_context, deep_const_context, start); |
92 Reduction r = spec.ReduceJSLoadContext(load); | 92 Reduction r = spec.ReduceJSLoadContext(load); |
93 CHECK(r.Changed()); | 93 CHECK(r.Changed()); |
94 Node* new_context_input = NodeProperties::GetValueInput(r.replacement(), 0); | 94 Node* new_context_input = NodeProperties::GetValueInput(r.replacement(), 0); |
95 CHECK_EQ(IrOpcode::kHeapConstant, new_context_input->opcode()); | 95 CHECK_EQ(IrOpcode::kHeapConstant, new_context_input->opcode()); |
96 ValueMatcher<Handle<Context> > match(new_context_input); | 96 ValueMatcher<Handle<Context> > match(new_context_input); |
97 CHECK_EQ(*native, *match.Value()); | 97 CHECK_EQ(*native, *match.Value()); |
98 ContextAccess access = static_cast<Operator1<ContextAccess>*>( | 98 ContextAccess access = OpParameter<ContextAccess>(r.replacement()); |
99 r.replacement()->op())->parameter(); | |
100 CHECK_EQ(Context::GLOBAL_EVAL_FUN_INDEX, access.index()); | 99 CHECK_EQ(Context::GLOBAL_EVAL_FUN_INDEX, access.index()); |
101 CHECK_EQ(0, access.depth()); | 100 CHECK_EQ(0, access.depth()); |
102 CHECK_EQ(false, access.immutable()); | 101 CHECK_EQ(false, access.immutable()); |
103 } | 102 } |
104 | 103 |
105 { | 104 { |
106 // Immutable slot, constant context, depth = 0 => specialize. | 105 // Immutable slot, constant context, depth = 0 => specialize. |
107 Node* load = t.NewNode(t.javascript()->LoadContext(0, slot, true), | 106 Node* load = t.NewNode(t.javascript()->LoadContext(0, slot, true), |
108 const_context, const_context, start); | 107 const_context, const_context, start); |
109 Reduction r = spec.ReduceJSLoadContext(load); | 108 Reduction r = spec.ReduceJSLoadContext(load); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 // Mutable slot, constant context, depth > 0 => fold-in parent context. | 168 // Mutable slot, constant context, depth > 0 => fold-in parent context. |
170 Node* load = t.NewNode( | 169 Node* load = t.NewNode( |
171 t.javascript()->StoreContext(2, Context::GLOBAL_EVAL_FUN_INDEX), | 170 t.javascript()->StoreContext(2, Context::GLOBAL_EVAL_FUN_INDEX), |
172 deep_const_context, deep_const_context, start); | 171 deep_const_context, deep_const_context, start); |
173 Reduction r = spec.ReduceJSStoreContext(load); | 172 Reduction r = spec.ReduceJSStoreContext(load); |
174 CHECK(r.Changed()); | 173 CHECK(r.Changed()); |
175 Node* new_context_input = NodeProperties::GetValueInput(r.replacement(), 0); | 174 Node* new_context_input = NodeProperties::GetValueInput(r.replacement(), 0); |
176 CHECK_EQ(IrOpcode::kHeapConstant, new_context_input->opcode()); | 175 CHECK_EQ(IrOpcode::kHeapConstant, new_context_input->opcode()); |
177 ValueMatcher<Handle<Context> > match(new_context_input); | 176 ValueMatcher<Handle<Context> > match(new_context_input); |
178 CHECK_EQ(*native, *match.Value()); | 177 CHECK_EQ(*native, *match.Value()); |
179 ContextAccess access = static_cast<Operator1<ContextAccess>*>( | 178 ContextAccess access = OpParameter<ContextAccess>(r.replacement()); |
180 r.replacement()->op())->parameter(); | |
181 CHECK_EQ(Context::GLOBAL_EVAL_FUN_INDEX, access.index()); | 179 CHECK_EQ(Context::GLOBAL_EVAL_FUN_INDEX, access.index()); |
182 CHECK_EQ(0, access.depth()); | 180 CHECK_EQ(0, access.depth()); |
183 CHECK_EQ(false, access.immutable()); | 181 CHECK_EQ(false, access.immutable()); |
184 } | 182 } |
185 } | 183 } |
186 | 184 |
187 | 185 |
188 // TODO(titzer): factor out common code with effects checking in typed lowering. | 186 // TODO(titzer): factor out common code with effects checking in typed lowering. |
189 static void CheckEffectInput(Node* effect, Node* use) { | 187 static void CheckEffectInput(Node* effect, Node* use) { |
190 CHECK_EQ(effect, NodeProperties::GetEffectInput(use)); | 188 CHECK_EQ(effect, NodeProperties::GetEffectInput(use)); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 { | 298 { |
301 FunctionTester T( | 299 FunctionTester T( |
302 "(function() { if (false) { var x = 1; } function inc(a)" | 300 "(function() { if (false) { var x = 1; } function inc(a)" |
303 " { return a + x; } return inc; })()"); // x is undefined! | 301 " { return a + x; } return inc; })()"); // x is undefined! |
304 | 302 |
305 CHECK(T.Call(T.Val(0.0), T.Val(0.0)).ToHandleChecked()->IsNaN()); | 303 CHECK(T.Call(T.Val(0.0), T.Val(0.0)).ToHandleChecked()->IsNaN()); |
306 CHECK(T.Call(T.Val(2.0), T.Val(0.0)).ToHandleChecked()->IsNaN()); | 304 CHECK(T.Call(T.Val(2.0), T.Val(0.0)).ToHandleChecked()->IsNaN()); |
307 CHECK(T.Call(T.Val(-2.1), T.Val(0.0)).ToHandleChecked()->IsNaN()); | 305 CHECK(T.Call(T.Val(-2.1), T.Val(0.0)).ToHandleChecked()->IsNaN()); |
308 } | 306 } |
309 } | 307 } |
OLD | NEW |