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

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

Issue 1969783002: Collect call counts for constructor calls, too. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixed cctest.status, and addressed mips64 comment. Created 4 years, 7 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
« no previous file with comments | « test/cctest/interpreter/bytecode_expectations/CallNew.golden ('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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 // Clear the IC manually in order to test this case. 226 // Clear the IC manually in order to test this case.
227 nexus.Clear(f->shared()->code()); 227 nexus.Clear(f->shared()->code());
228 CompileRun("f(Array)"); 228 CompileRun("f(Array)");
229 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); 229 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback());
230 CHECK(nexus.GetFeedback()->IsAllocationSite()); 230 CHECK(nexus.GetFeedback()->IsAllocationSite());
231 231
232 heap->CollectAllGarbage(); 232 heap->CollectAllGarbage();
233 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); 233 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback());
234 } 234 }
235 235
236 TEST(VectorCallCounts) {
237 if (i::FLAG_always_opt) return;
238 CcTest::InitializeVM();
239 LocalContext context;
240 v8::HandleScope scope(context->GetIsolate());
241 Isolate* isolate = CcTest::i_isolate();
242
243 // Make sure function f has a call that uses a type feedback slot.
244 CompileRun(
245 "function foo() { return 17; }"
246 "function f(a) { a(); } f(foo);");
247 Handle<JSFunction> f = GetFunction("f");
248 // There should be one IC.
249 Handle<TypeFeedbackVector> feedback_vector =
250 Handle<TypeFeedbackVector>(f->shared()->feedback_vector(), isolate);
251 FeedbackVectorSlot slot(0);
252 CallICNexus nexus(feedback_vector, slot);
253 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback());
254
255 CompileRun("f(foo); f(foo);");
256 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback());
257 CHECK_EQ(3, nexus.ExtractCallCount());
258
259 CompileRun(
260 "function Foo() {}"
261 "function f(a) { new a(); } f(Foo);");
262 f = GetFunction("f");
263 // There should be one IC.
264 feedback_vector =
265 Handle<TypeFeedbackVector>(f->shared()->feedback_vector(), isolate);
266 FeedbackVectorSlot cslot(1);
267
268 CompileRun("f(Foo); f(Foo);");
269 CHECK(feedback_vector->Get(cslot)->IsSmi());
270 CHECK_EQ(3, Smi::cast(feedback_vector->Get(cslot))->value());
271 }
236 272
237 TEST(VectorLoadICStates) { 273 TEST(VectorLoadICStates) {
238 if (i::FLAG_always_opt) return; 274 if (i::FLAG_always_opt) return;
239 CcTest::InitializeVM(); 275 CcTest::InitializeVM();
240 LocalContext context; 276 LocalContext context;
241 v8::HandleScope scope(context->GetIsolate()); 277 v8::HandleScope scope(context->GetIsolate());
242 Isolate* isolate = CcTest::i_isolate(); 278 Isolate* isolate = CcTest::i_isolate();
243 Heap* heap = isolate->heap(); 279 Heap* heap = isolate->heap();
244 280
245 // Make sure function f has a call that uses a type feedback slot. 281 // Make sure function f has a call that uses a type feedback slot.
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 // There should be one IC slot. 542 // There should be one IC slot.
507 Handle<TypeFeedbackVector> feedback_vector(f->shared()->feedback_vector()); 543 Handle<TypeFeedbackVector> feedback_vector(f->shared()->feedback_vector());
508 FeedbackVectorHelper helper(feedback_vector); 544 FeedbackVectorHelper helper(feedback_vector);
509 CHECK_EQ(1, helper.slot_count()); 545 CHECK_EQ(1, helper.slot_count());
510 FeedbackVectorSlot slot(0); 546 FeedbackVectorSlot slot(0);
511 StoreICNexus nexus(feedback_vector, slot); 547 StoreICNexus nexus(feedback_vector, slot);
512 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); 548 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback());
513 } 549 }
514 550
515 } // namespace 551 } // namespace
OLDNEW
« no previous file with comments | « test/cctest/interpreter/bytecode_expectations/CallNew.golden ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698