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/v8.h" | 5 #include "src/v8.h" |
6 #include "test/cctest/cctest.h" | 6 #include "test/cctest/cctest.h" |
7 | 7 |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/debug.h" | 9 #include "src/debug.h" |
10 #include "src/execution.h" | 10 #include "src/execution.h" |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 CompileRun("f({ blarg: 3, gran: 3, torino: 10, foo: 2 })"); | 300 CompileRun("f({ blarg: 3, gran: 3, torino: 10, foo: 2 })"); |
301 CHECK_EQ(MEGAMORPHIC, nexus.StateFromFeedback()); | 301 CHECK_EQ(MEGAMORPHIC, nexus.StateFromFeedback()); |
302 CHECK(!nexus.FindFirstMap()); | 302 CHECK(!nexus.FindFirstMap()); |
303 | 303 |
304 // After a collection, state should not be reset to PREMONOMORPHIC. | 304 // After a collection, state should not be reset to PREMONOMORPHIC. |
305 heap->CollectAllGarbage(i::Heap::kNoGCFlags); | 305 heap->CollectAllGarbage(i::Heap::kNoGCFlags); |
306 CHECK_EQ(MEGAMORPHIC, nexus.StateFromFeedback()); | 306 CHECK_EQ(MEGAMORPHIC, nexus.StateFromFeedback()); |
307 } | 307 } |
308 | 308 |
309 | 309 |
| 310 TEST(VectorLoadICSlotSharing) { |
| 311 if (i::FLAG_always_opt || !i::FLAG_vector_ics) return; |
| 312 CcTest::InitializeVM(); |
| 313 LocalContext context; |
| 314 v8::HandleScope scope(context->GetIsolate()); |
| 315 Isolate* isolate = CcTest::i_isolate(); |
| 316 |
| 317 // Function f has 3 LoadICs, one for each o, but the ICs share the same |
| 318 // feedback vector IC slot. |
| 319 CompileRun( |
| 320 "var o = 10;" |
| 321 "function f() {" |
| 322 " var x = o + 10;" |
| 323 " return o + x + o;" |
| 324 "}" |
| 325 "f();"); |
| 326 Handle<JSFunction> f = v8::Utils::OpenHandle( |
| 327 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))); |
| 328 // There should be one IC slot. |
| 329 Handle<TypeFeedbackVector> feedback_vector = |
| 330 Handle<TypeFeedbackVector>(f->shared()->feedback_vector(), isolate); |
| 331 CHECK_EQ(1, feedback_vector->ICSlots()); |
| 332 FeedbackVectorICSlot slot(0); |
| 333 LoadICNexus nexus(feedback_vector, slot); |
| 334 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); |
| 335 } |
| 336 |
| 337 |
310 TEST(VectorLoadICOnSmi) { | 338 TEST(VectorLoadICOnSmi) { |
311 if (i::FLAG_always_opt || !i::FLAG_vector_ics) return; | 339 if (i::FLAG_always_opt || !i::FLAG_vector_ics) return; |
312 CcTest::InitializeVM(); | 340 CcTest::InitializeVM(); |
313 LocalContext context; | 341 LocalContext context; |
314 v8::HandleScope scope(context->GetIsolate()); | 342 v8::HandleScope scope(context->GetIsolate()); |
315 Isolate* isolate = CcTest::i_isolate(); | 343 Isolate* isolate = CcTest::i_isolate(); |
316 Heap* heap = isolate->heap(); | 344 Heap* heap = isolate->heap(); |
317 | 345 |
318 // Make sure function f has a call that uses a type feedback slot. | 346 // Make sure function f has a call that uses a type feedback slot. |
319 CompileRun( | 347 CompileRun( |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 CHECK(number_map_found && o_map_found); | 385 CHECK(number_map_found && o_map_found); |
358 | 386 |
359 // The degree of polymorphism doesn't change. | 387 // The degree of polymorphism doesn't change. |
360 CompileRun("f(100)"); | 388 CompileRun("f(100)"); |
361 CHECK_EQ(POLYMORPHIC, nexus.StateFromFeedback()); | 389 CHECK_EQ(POLYMORPHIC, nexus.StateFromFeedback()); |
362 MapHandleList maps2; | 390 MapHandleList maps2; |
363 nexus.FindAllMaps(&maps2); | 391 nexus.FindAllMaps(&maps2); |
364 CHECK_EQ(2, maps2.length()); | 392 CHECK_EQ(2, maps2.length()); |
365 } | 393 } |
366 } | 394 } |
OLD | NEW |