| 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.h" | 8 #include "src/compiler/node-properties.h" |
| 9 #include "src/compiler/source-position.h" | 9 #include "src/compiler/source-position.h" |
| 10 #include "test/cctest/cctest.h" | 10 #include "test/cctest/cctest.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 | 178 |
| 179 | 179 |
| 180 // TODO(titzer): factor out common code with effects checking in typed lowering. | 180 // TODO(titzer): factor out common code with effects checking in typed lowering. |
| 181 static void CheckEffectInput(Node* effect, Node* use) { | 181 static void CheckEffectInput(Node* effect, Node* use) { |
| 182 CHECK_EQ(effect, NodeProperties::GetEffectInput(use)); | 182 CHECK_EQ(effect, NodeProperties::GetEffectInput(use)); |
| 183 } | 183 } |
| 184 | 184 |
| 185 | 185 |
| 186 TEST(SpecializeToContext) { | 186 TEST_WITH_STRONG(SpecializeToContext) { |
| 187 ContextSpecializationTester t; | 187 ContextSpecializationTester t; |
| 188 | 188 |
| 189 Node* start = t.NewNode(t.common()->Start(0)); | 189 Node* start = t.NewNode(t.common()->Start(0)); |
| 190 t.graph()->SetStart(start); | 190 t.graph()->SetStart(start); |
| 191 | 191 |
| 192 // Make a context and initialize it a bit for this test. | 192 // Make a context and initialize it a bit for this test. |
| 193 Handle<Context> native = t.factory()->NewNativeContext(); | 193 Handle<Context> native = t.factory()->NewNativeContext(); |
| 194 Handle<Object> expected = t.factory()->InternalizeUtf8String("gboy!"); | 194 Handle<Object> expected = t.factory()->InternalizeUtf8String("gboy!"); |
| 195 const int slot = Context::GLOBAL_OBJECT_INDEX; | 195 const int slot = Context::GLOBAL_OBJECT_INDEX; |
| 196 native->set(slot, *expected); | 196 native->set(slot, *expected); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 207 const_context, const_context, effect_in); | 207 const_context, const_context, effect_in); |
| 208 | 208 |
| 209 | 209 |
| 210 Node* value_use = t.NewNode(t.simplified()->ChangeTaggedToInt32(), load); | 210 Node* value_use = t.NewNode(t.simplified()->ChangeTaggedToInt32(), load); |
| 211 Node* other_load = t.NewNode(t.javascript()->LoadContext(0, slot, true), | 211 Node* other_load = t.NewNode(t.javascript()->LoadContext(0, slot, true), |
| 212 param_context, param_context, load); | 212 param_context, param_context, load); |
| 213 Node* effect_use = other_load; | 213 Node* effect_use = other_load; |
| 214 Node* other_use = | 214 Node* other_use = |
| 215 t.NewNode(t.simplified()->ChangeTaggedToInt32(), other_load); | 215 t.NewNode(t.simplified()->ChangeTaggedToInt32(), other_load); |
| 216 | 216 |
| 217 Node* add = t.NewNode(t.javascript()->Add(), value_use, other_use, | 217 Node* add = t.NewNode(t.javascript()->Add(language_mode), value_use, |
| 218 param_context, other_load, start); | 218 other_use, param_context, other_load, start); |
| 219 | 219 |
| 220 Node* ret = t.NewNode(t.common()->Return(), add, effect_use, start); | 220 Node* ret = t.NewNode(t.common()->Return(), add, effect_use, start); |
| 221 Node* end = t.NewNode(t.common()->End(), ret); | 221 Node* end = t.NewNode(t.common()->End(), ret); |
| 222 USE(end); | 222 USE(end); |
| 223 t.graph()->SetEnd(end); | 223 t.graph()->SetEnd(end); |
| 224 | 224 |
| 225 // Double check the above graph is what we expect, or the test is broken. | 225 // Double check the above graph is what we expect, or the test is broken. |
| 226 CheckEffectInput(effect_in, load); | 226 CheckEffectInput(effect_in, load); |
| 227 CheckEffectInput(load, effect_use); | 227 CheckEffectInput(load, effect_use); |
| 228 | 228 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 { | 294 { |
| 295 FunctionTester T( | 295 FunctionTester T( |
| 296 "(function() { if (false) { var x = 1; } function inc(a)" | 296 "(function() { if (false) { var x = 1; } function inc(a)" |
| 297 " { return a + x; } return inc; })()"); // x is undefined! | 297 " { return a + x; } return inc; })()"); // x is undefined! |
| 298 | 298 |
| 299 CHECK(T.Call(T.Val(0.0), T.Val(0.0)).ToHandleChecked()->IsNaN()); | 299 CHECK(T.Call(T.Val(0.0), T.Val(0.0)).ToHandleChecked()->IsNaN()); |
| 300 CHECK(T.Call(T.Val(2.0), T.Val(0.0)).ToHandleChecked()->IsNaN()); | 300 CHECK(T.Call(T.Val(2.0), T.Val(0.0)).ToHandleChecked()->IsNaN()); |
| 301 CHECK(T.Call(T.Val(-2.1), T.Val(0.0)).ToHandleChecked()->IsNaN()); | 301 CHECK(T.Call(T.Val(-2.1), T.Val(0.0)).ToHandleChecked()->IsNaN()); |
| 302 } | 302 } |
| 303 } | 303 } |
| OLD | NEW |