| 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/debug.h" | 9 #include "src/debug/debug.h" |
| 10 #include "src/execution.h" | 10 #include "src/execution.h" |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 // There should be one IC. | 262 // There should be one IC. |
| 263 Handle<TypeFeedbackVector> feedback_vector = | 263 Handle<TypeFeedbackVector> feedback_vector = |
| 264 Handle<TypeFeedbackVector>(f->feedback_vector(), isolate); | 264 Handle<TypeFeedbackVector>(f->feedback_vector(), isolate); |
| 265 FeedbackVectorSlot slot(0); | 265 FeedbackVectorSlot slot(0); |
| 266 CallICNexus nexus(feedback_vector, slot); | 266 CallICNexus nexus(feedback_vector, slot); |
| 267 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); | 267 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); |
| 268 | 268 |
| 269 CompileRun("f(foo); f(foo);"); | 269 CompileRun("f(foo); f(foo);"); |
| 270 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); | 270 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); |
| 271 CHECK_EQ(3, nexus.ExtractCallCount()); | 271 CHECK_EQ(3, nexus.ExtractCallCount()); |
| 272 |
| 273 // Send the IC megamorphic, but we should still have incrementing counts. |
| 274 CompileRun("f(function() { return 12; });"); |
| 275 CHECK_EQ(GENERIC, nexus.StateFromFeedback()); |
| 276 CHECK_EQ(4, nexus.ExtractCallCount()); |
| 272 } | 277 } |
| 273 | 278 |
| 274 TEST(VectorConstructCounts) { | 279 TEST(VectorConstructCounts) { |
| 275 if (i::FLAG_always_opt) return; | 280 if (i::FLAG_always_opt) return; |
| 276 CcTest::InitializeVM(); | 281 CcTest::InitializeVM(); |
| 277 LocalContext context; | 282 LocalContext context; |
| 278 v8::HandleScope scope(context->GetIsolate()); | 283 v8::HandleScope scope(context->GetIsolate()); |
| 279 Isolate* isolate = CcTest::i_isolate(); | 284 Isolate* isolate = CcTest::i_isolate(); |
| 280 | 285 |
| 281 // Make sure function f has a call that uses a type feedback slot. | 286 // Make sure function f has a call that uses a type feedback slot. |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 // There should be one IC slot. | 576 // There should be one IC slot. |
| 572 Handle<TypeFeedbackVector> feedback_vector(f->feedback_vector()); | 577 Handle<TypeFeedbackVector> feedback_vector(f->feedback_vector()); |
| 573 FeedbackVectorHelper helper(feedback_vector); | 578 FeedbackVectorHelper helper(feedback_vector); |
| 574 CHECK_EQ(1, helper.slot_count()); | 579 CHECK_EQ(1, helper.slot_count()); |
| 575 FeedbackVectorSlot slot(0); | 580 FeedbackVectorSlot slot(0); |
| 576 StoreICNexus nexus(feedback_vector, slot); | 581 StoreICNexus nexus(feedback_vector, slot); |
| 577 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); | 582 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); |
| 578 } | 583 } |
| 579 | 584 |
| 580 } // namespace | 585 } // namespace |
| OLD | NEW |