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

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

Issue 2122183002: [Interpreter] Collect type feedback for calls in the bytecode handler (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updated cctest.status to mark the tests fail with ignition. Created 4 years, 5 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/test-compiler.cc ('k') | test/mjsunit/regress/regress-353551.js » ('j') | 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); 214 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback());
215 // CallIC doesn't return map feedback. 215 // CallIC doesn't return map feedback.
216 CHECK(!nexus.FindFirstMap()); 216 CHECK(!nexus.FindFirstMap());
217 217
218 CompileRun("f(function() { return 16; })"); 218 CompileRun("f(function() { return 16; })");
219 CHECK_EQ(GENERIC, nexus.StateFromFeedback()); 219 CHECK_EQ(GENERIC, nexus.StateFromFeedback());
220 220
221 // After a collection, state should remain GENERIC. 221 // After a collection, state should remain GENERIC.
222 heap->CollectAllGarbage(); 222 heap->CollectAllGarbage();
223 CHECK_EQ(GENERIC, nexus.StateFromFeedback()); 223 CHECK_EQ(GENERIC, nexus.StateFromFeedback());
224 }
225
226 TEST(VectorCallFeedbackForArray) {
227 if (i::FLAG_always_opt) return;
228 CcTest::InitializeVM();
229 LocalContext context;
230 v8::HandleScope scope(context->GetIsolate());
231 Isolate* isolate = CcTest::i_isolate();
232 Heap* heap = isolate->heap();
233
234 // Make sure function f has a call that uses a type feedback slot.
235 CompileRun(
236 "function foo() { return 17; }"
237 "function f(a) { a(); } f(Array);");
238 Handle<JSFunction> f = GetFunction("f");
239 // There should be one IC.
240 Handle<TypeFeedbackVector> feedback_vector =
241 Handle<TypeFeedbackVector>(f->feedback_vector(), isolate);
242 FeedbackVectorSlot slot(0);
243 CallICNexus nexus(feedback_vector, slot);
224 244
225 // A call to Array is special, it contains an AllocationSite as feedback. 245 // A call to Array is special, it contains an AllocationSite as feedback.
226 // Clear the IC manually in order to test this case.
227 nexus.Clear(f->shared()->code());
228 CompileRun("f(Array)");
229 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); 246 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback());
230 CHECK(nexus.GetFeedback()->IsAllocationSite()); 247 CHECK(nexus.GetFeedback()->IsAllocationSite());
231 248
232 heap->CollectAllGarbage(); 249 heap->CollectAllGarbage();
250 // It should stay monomorphic even after a GC.
233 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); 251 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback());
234 } 252 }
235 253
236 TEST(VectorCallCounts) { 254 TEST(VectorCallCounts) {
237 if (i::FLAG_always_opt) return; 255 if (i::FLAG_always_opt) return;
238 CcTest::InitializeVM(); 256 CcTest::InitializeVM();
239 LocalContext context; 257 LocalContext context;
240 v8::HandleScope scope(context->GetIsolate()); 258 v8::HandleScope scope(context->GetIsolate());
241 Isolate* isolate = CcTest::i_isolate(); 259 Isolate* isolate = CcTest::i_isolate();
242 260
243 // Make sure function f has a call that uses a type feedback slot. 261 // Make sure function f has a call that uses a type feedback slot.
244 CompileRun( 262 CompileRun(
245 "function foo() { return 17; }" 263 "function foo() { return 17; }"
246 "function f(a) { a(); } f(foo);"); 264 "function f(a) { a(); } f(foo);");
247 Handle<JSFunction> f = GetFunction("f"); 265 Handle<JSFunction> f = GetFunction("f");
248 // There should be one IC. 266 // There should be one IC.
249 Handle<TypeFeedbackVector> feedback_vector = 267 Handle<TypeFeedbackVector> feedback_vector =
250 Handle<TypeFeedbackVector>(f->feedback_vector(), isolate); 268 Handle<TypeFeedbackVector>(f->feedback_vector(), isolate);
251 FeedbackVectorSlot slot(0); 269 FeedbackVectorSlot slot(0);
252 CallICNexus nexus(feedback_vector, slot); 270 CallICNexus nexus(feedback_vector, slot);
253 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); 271 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback());
254 272
255 CompileRun("f(foo); f(foo);"); 273 CompileRun("f(foo); f(foo);");
256 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); 274 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback());
257 CHECK_EQ(3, nexus.ExtractCallCount()); 275 CHECK_EQ(3, nexus.ExtractCallCount());
276 }
258 277
278 TEST(VectorConstructCounts) {
279 if (i::FLAG_always_opt) return;
280 CcTest::InitializeVM();
281 LocalContext context;
282 v8::HandleScope scope(context->GetIsolate());
283 Isolate* isolate = CcTest::i_isolate();
284
285 // Make sure function f has a call that uses a type feedback slot.
259 CompileRun( 286 CompileRun(
260 "function Foo() {}" 287 "function Foo() {}"
261 "function f(a) { new a(); } f(Foo);"); 288 "function f(a) { new a(); } f(Foo);");
262 f = GetFunction("f"); 289 Handle<JSFunction> f = GetFunction("f");
263 // There should be one IC. 290 Handle<TypeFeedbackVector> feedback_vector =
264 feedback_vector = Handle<TypeFeedbackVector>(f->feedback_vector(), isolate); 291 Handle<TypeFeedbackVector>(f->feedback_vector(), isolate);
265 FeedbackVectorSlot cslot(1); 292 FeedbackVectorSlot slot(0);
293 CHECK(feedback_vector->Get(slot)->IsWeakCell());
266 294
267 CompileRun("f(Foo); f(Foo);"); 295 CompileRun("f(Foo); f(Foo);");
296 FeedbackVectorSlot cslot(1);
268 CHECK(feedback_vector->Get(cslot)->IsSmi()); 297 CHECK(feedback_vector->Get(cslot)->IsSmi());
269 CHECK_EQ(3, Smi::cast(feedback_vector->Get(cslot))->value()); 298 CHECK_EQ(3, Smi::cast(feedback_vector->Get(cslot))->value());
270 } 299 }
271 300
272 TEST(VectorLoadICStates) { 301 TEST(VectorLoadICStates) {
273 if (i::FLAG_always_opt) return; 302 if (i::FLAG_always_opt) return;
274 CcTest::InitializeVM(); 303 CcTest::InitializeVM();
275 LocalContext context; 304 LocalContext context;
276 v8::HandleScope scope(context->GetIsolate()); 305 v8::HandleScope scope(context->GetIsolate());
277 Isolate* isolate = CcTest::i_isolate(); 306 Isolate* isolate = CcTest::i_isolate();
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 // There should be one IC slot. 574 // There should be one IC slot.
546 Handle<TypeFeedbackVector> feedback_vector(f->feedback_vector()); 575 Handle<TypeFeedbackVector> feedback_vector(f->feedback_vector());
547 FeedbackVectorHelper helper(feedback_vector); 576 FeedbackVectorHelper helper(feedback_vector);
548 CHECK_EQ(1, helper.slot_count()); 577 CHECK_EQ(1, helper.slot_count());
549 FeedbackVectorSlot slot(0); 578 FeedbackVectorSlot slot(0);
550 StoreICNexus nexus(feedback_vector, slot); 579 StoreICNexus nexus(feedback_vector, slot);
551 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); 580 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback());
552 } 581 }
553 582
554 } // namespace 583 } // namespace
OLDNEW
« no previous file with comments | « test/cctest/test-compiler.cc ('k') | test/mjsunit/regress/regress-353551.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698