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

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

Issue 2809923002: Unify implementations of Map handles vectors and lists (Closed)
Patch Set: Review feedback Created 3 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 | « src/type-info.cc ('k') | test/cctest/test-field-type-tracking.cc » ('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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 CompileRun("f({ blarg: 3, foo: 2 })"); 342 CompileRun("f({ blarg: 3, foo: 2 })");
343 CHECK_EQ(POLYMORPHIC, nexus.StateFromFeedback()); 343 CHECK_EQ(POLYMORPHIC, nexus.StateFromFeedback());
344 344
345 CompileRun( 345 CompileRun(
346 "delete o.foo;" 346 "delete o.foo;"
347 "f(o)"); 347 "f(o)");
348 CHECK_EQ(POLYMORPHIC, nexus.StateFromFeedback()); 348 CHECK_EQ(POLYMORPHIC, nexus.StateFromFeedback());
349 349
350 CompileRun("f({ blarg: 3, torino: 10, foo: 2 })"); 350 CompileRun("f({ blarg: 3, torino: 10, foo: 2 })");
351 CHECK_EQ(POLYMORPHIC, nexus.StateFromFeedback()); 351 CHECK_EQ(POLYMORPHIC, nexus.StateFromFeedback());
352 MapHandleList maps; 352 MapHandles maps;
353 nexus.ExtractMaps(&maps); 353 nexus.ExtractMaps(&maps);
354 CHECK_EQ(4, maps.length()); 354 CHECK_EQ(4, maps.size());
355 355
356 // Finally driven megamorphic. 356 // Finally driven megamorphic.
357 CompileRun("f({ blarg: 3, gran: 3, torino: 10, foo: 2 })"); 357 CompileRun("f({ blarg: 3, gran: 3, torino: 10, foo: 2 })");
358 CHECK_EQ(MEGAMORPHIC, nexus.StateFromFeedback()); 358 CHECK_EQ(MEGAMORPHIC, nexus.StateFromFeedback());
359 CHECK(!nexus.FindFirstMap()); 359 CHECK(!nexus.FindFirstMap());
360 360
361 // After a collection, state should not be reset to PREMONOMORPHIC. 361 // After a collection, state should not be reset to PREMONOMORPHIC.
362 CcTest::CollectAllGarbage(); 362 CcTest::CollectAllGarbage();
363 CHECK_EQ(MEGAMORPHIC, nexus.StateFromFeedback()); 363 CHECK_EQ(MEGAMORPHIC, nexus.StateFromFeedback());
364 } 364 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 CompileRun("f(34)"); 421 CompileRun("f(34)");
422 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); 422 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback());
423 // Verify that the monomorphic map is the one we expect. 423 // Verify that the monomorphic map is the one we expect.
424 Map* number_map = heap->heap_number_map(); 424 Map* number_map = heap->heap_number_map();
425 CHECK_EQ(number_map, nexus.FindFirstMap()); 425 CHECK_EQ(number_map, nexus.FindFirstMap());
426 426
427 // Now go polymorphic on o. 427 // Now go polymorphic on o.
428 CompileRun("f(o)"); 428 CompileRun("f(o)");
429 CHECK_EQ(POLYMORPHIC, nexus.StateFromFeedback()); 429 CHECK_EQ(POLYMORPHIC, nexus.StateFromFeedback());
430 430
431 MapHandleList maps; 431 MapHandles maps;
432 nexus.ExtractMaps(&maps); 432 nexus.ExtractMaps(&maps);
433 CHECK_EQ(2, maps.length()); 433 CHECK_EQ(2, maps.size());
434 434
435 // One of the maps should be the o map. 435 // One of the maps should be the o map.
436 v8::MaybeLocal<v8::Value> v8_o = 436 v8::MaybeLocal<v8::Value> v8_o =
437 CcTest::global()->Get(context.local(), v8_str("o")); 437 CcTest::global()->Get(context.local(), v8_str("o"));
438 Handle<JSObject> o = 438 Handle<JSObject> o =
439 Handle<JSObject>::cast(v8::Utils::OpenHandle(*v8_o.ToLocalChecked())); 439 Handle<JSObject>::cast(v8::Utils::OpenHandle(*v8_o.ToLocalChecked()));
440 bool number_map_found = false; 440 bool number_map_found = false;
441 bool o_map_found = false; 441 bool o_map_found = false;
442 for (int i = 0; i < maps.length(); i++) { 442 for (Handle<Map> current : maps) {
443 Handle<Map> current = maps[i];
444 if (*current == number_map) 443 if (*current == number_map)
445 number_map_found = true; 444 number_map_found = true;
446 else if (*current == o->map()) 445 else if (*current == o->map())
447 o_map_found = true; 446 o_map_found = true;
448 } 447 }
449 CHECK(number_map_found && o_map_found); 448 CHECK(number_map_found && o_map_found);
450 449
451 // The degree of polymorphism doesn't change. 450 // The degree of polymorphism doesn't change.
452 CompileRun("f(100)"); 451 CompileRun("f(100)");
453 CHECK_EQ(POLYMORPHIC, nexus.StateFromFeedback()); 452 CHECK_EQ(POLYMORPHIC, nexus.StateFromFeedback());
454 MapHandleList maps2; 453 MapHandles maps2;
455 nexus.ExtractMaps(&maps2); 454 nexus.ExtractMaps(&maps2);
456 CHECK_EQ(2, maps2.length()); 455 CHECK_EQ(2, maps2.size());
457 } 456 }
458 457
459 458
460 TEST(ReferenceContextAllocatesNoSlots) { 459 TEST(ReferenceContextAllocatesNoSlots) {
461 if (i::FLAG_always_opt) return; 460 if (i::FLAG_always_opt) return;
462 CcTest::InitializeVM(); 461 CcTest::InitializeVM();
463 LocalContext context; 462 LocalContext context;
464 v8::HandleScope scope(context->GetIsolate()); 463 v8::HandleScope scope(context->GetIsolate());
465 Isolate* isolate = CcTest::i_isolate(); 464 Isolate* isolate = CcTest::i_isolate();
466 465
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 Handle<FeedbackVector> feedback_vector(f->feedback_vector()); 639 Handle<FeedbackVector> feedback_vector(f->feedback_vector());
641 FeedbackVectorHelper helper(feedback_vector); 640 FeedbackVectorHelper helper(feedback_vector);
642 CHECK_EQ(2, helper.slot_count()); 641 CHECK_EQ(2, helper.slot_count());
643 CHECK_SLOT_KIND(helper, 0, FeedbackSlotKind::kLiteral); 642 CHECK_SLOT_KIND(helper, 0, FeedbackSlotKind::kLiteral);
644 CHECK_SLOT_KIND(helper, 1, FeedbackSlotKind::kStoreOwnNamed); 643 CHECK_SLOT_KIND(helper, 1, FeedbackSlotKind::kStoreOwnNamed);
645 StoreOwnICNexus nexus(feedback_vector, helper.slot(1)); 644 StoreOwnICNexus nexus(feedback_vector, helper.slot(1));
646 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); 645 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback());
647 } 646 }
648 647
649 } // namespace 648 } // namespace
OLDNEW
« no previous file with comments | « src/type-info.cc ('k') | test/cctest/test-field-type-tracking.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698