Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: test/cctest/test-feedback-vector.cc

Issue 2333243004: CallConstruct also gets call count information if megamorphic. (Closed)
Patch Set: Compile/runtime fixes. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« src/compiler/js-call-reducer.cc ('K') | « src/x64/code-stubs-x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 v8::HandleScope scope(context->GetIsolate()); 283 v8::HandleScope scope(context->GetIsolate());
284 Isolate* isolate = CcTest::i_isolate(); 284 Isolate* isolate = CcTest::i_isolate();
285 285
286 // 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.
287 CompileRun( 287 CompileRun(
288 "function Foo() {}" 288 "function Foo() {}"
289 "function f(a) { new a(); } f(Foo);"); 289 "function f(a) { new a(); } f(Foo);");
290 Handle<JSFunction> f = GetFunction("f"); 290 Handle<JSFunction> f = GetFunction("f");
291 Handle<TypeFeedbackVector> feedback_vector = 291 Handle<TypeFeedbackVector> feedback_vector =
292 Handle<TypeFeedbackVector>(f->feedback_vector(), isolate); 292 Handle<TypeFeedbackVector>(f->feedback_vector(), isolate);
293
293 FeedbackVectorSlot slot(0); 294 FeedbackVectorSlot slot(0);
295 CallICNexus nexus(feedback_vector, slot);
296 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback());
297
294 CHECK(feedback_vector->Get(slot)->IsWeakCell()); 298 CHECK(feedback_vector->Get(slot)->IsWeakCell());
295 299
296 CompileRun("f(Foo); f(Foo);"); 300 CompileRun("f(Foo); f(Foo);");
297 FeedbackVectorSlot cslot(1); 301 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback());
298 CHECK(feedback_vector->Get(cslot)->IsSmi()); 302 CHECK_EQ(3, nexus.ExtractCallCount());
299 CHECK_EQ(3, Smi::cast(feedback_vector->Get(cslot))->value()); 303
304 // Send the IC megamorphic, but we should still have incrementing counts.
305 CompileRun("f(function() {});");
306 CHECK_EQ(GENERIC, nexus.StateFromFeedback());
307 CHECK_EQ(4, nexus.ExtractCallCount());
300 } 308 }
301 309
302 TEST(VectorLoadICStates) { 310 TEST(VectorLoadICStates) {
303 if (i::FLAG_always_opt) return; 311 if (i::FLAG_always_opt) return;
304 CcTest::InitializeVM(); 312 CcTest::InitializeVM();
305 LocalContext context; 313 LocalContext context;
306 v8::HandleScope scope(context->GetIsolate()); 314 v8::HandleScope scope(context->GetIsolate());
307 Isolate* isolate = CcTest::i_isolate(); 315 Isolate* isolate = CcTest::i_isolate();
308 316
309 // Make sure function f has a call that uses a type feedback slot. 317 // Make sure function f has a call that uses a type feedback slot.
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 // There should be one IC slot. 584 // There should be one IC slot.
577 Handle<TypeFeedbackVector> feedback_vector(f->feedback_vector()); 585 Handle<TypeFeedbackVector> feedback_vector(f->feedback_vector());
578 FeedbackVectorHelper helper(feedback_vector); 586 FeedbackVectorHelper helper(feedback_vector);
579 CHECK_EQ(1, helper.slot_count()); 587 CHECK_EQ(1, helper.slot_count());
580 FeedbackVectorSlot slot(0); 588 FeedbackVectorSlot slot(0);
581 StoreICNexus nexus(feedback_vector, slot); 589 StoreICNexus nexus(feedback_vector, slot);
582 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); 590 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback());
583 } 591 }
584 592
585 } // namespace 593 } // namespace
OLDNEW
« src/compiler/js-call-reducer.cc ('K') | « src/x64/code-stubs-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698