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

Side by Side Diff: test/cctest/test-heap.cc

Issue 816653002: Monomorphic and polymorphic ICs with cleared maps should not go megamorphic. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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/ic/ic.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 4621 matching lines...) Expand 10 before | Expand all | Expand 10 after
4632 " var proto = {'name' : 'weak'};" 4632 " var proto = {'name' : 'weak'};"
4633 " var obj = Object.create(proto);" 4633 " var obj = Object.create(proto);"
4634 " compareNilIC(obj);" 4634 " compareNilIC(obj);"
4635 " compareNilIC(obj);" 4635 " compareNilIC(obj);"
4636 " compareNilIC(obj);" 4636 " compareNilIC(obj);"
4637 " return proto;" 4637 " return proto;"
4638 " })();"); 4638 " })();");
4639 } 4639 }
4640 4640
4641 4641
4642 Handle<JSFunction> GetFunctionByName(Isolate* isolate, const char* name) {
4643 Handle<String> str = isolate->factory()->InternalizeUtf8String(name);
4644 Handle<Object> obj =
4645 Object::GetProperty(isolate->global_object(), str).ToHandleChecked();
4646 return Handle<JSFunction>::cast(obj);
4647 }
4648
4649
4650 void CheckIC(Code* code, Code::Kind kind, InlineCacheState state) {
4651 Code* ic = FindFirstIC(code, kind);
4652 CHECK(ic->is_inline_cache_stub());
4653 CHECK(ic->ic_state() == state);
4654 }
4655
4656
4657 TEST(MonomorphicStaysMonomorphicAfterGC) {
4658 if (FLAG_always_opt) return;
4659 // TODO(mvstanton): vector ics need weak support!
4660 if (FLAG_vector_ics) return;
4661 CcTest::InitializeVM();
4662 Isolate* isolate = CcTest::i_isolate();
4663 Heap* heap = isolate->heap();
4664 v8::HandleScope scope(CcTest::isolate());
4665 CompileRun(
4666 "function loadIC(obj) {"
4667 " return obj.name;"
4668 "}"
4669 "function testIC() {"
4670 " var proto = {'name' : 'weak'};"
4671 " var obj = Object.create(proto);"
4672 " loadIC(obj);"
4673 " loadIC(obj);"
4674 " loadIC(obj);"
4675 " return proto;"
4676 "};");
4677 Handle<JSFunction> loadIC = GetFunctionByName(isolate, "loadIC");
4678 {
4679 v8::HandleScope scope(CcTest::isolate());
4680 CompileRun("(testIC())");
4681 }
4682 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
4683 CheckIC(loadIC->code(), Code::LOAD_IC, MONOMORPHIC);
4684 {
4685 v8::HandleScope scope(CcTest::isolate());
4686 CompileRun("(testIC())");
4687 }
4688 CheckIC(loadIC->code(), Code::LOAD_IC, MONOMORPHIC);
4689 }
4690
4691
4692 TEST(PolymorphicStaysPolymorphicAfterGC) {
4693 if (FLAG_always_opt) return;
4694 // TODO(mvstanton): vector ics need weak support!
4695 if (FLAG_vector_ics) return;
4696 CcTest::InitializeVM();
4697 Isolate* isolate = CcTest::i_isolate();
4698 Heap* heap = isolate->heap();
4699 v8::HandleScope scope(CcTest::isolate());
4700 CompileRun(
4701 "function loadIC(obj) {"
4702 " return obj.name;"
4703 "}"
4704 "function testIC() {"
4705 " var proto = {'name' : 'weak'};"
4706 " var obj = Object.create(proto);"
4707 " loadIC(obj);"
4708 " loadIC(obj);"
4709 " loadIC(obj);"
4710 " var poly = Object.create(proto);"
4711 " poly.x = true;"
4712 " loadIC(poly);"
4713 " return proto;"
4714 "};");
4715 Handle<JSFunction> loadIC = GetFunctionByName(isolate, "loadIC");
4716 {
4717 v8::HandleScope scope(CcTest::isolate());
4718 CompileRun("(testIC())");
4719 }
4720 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
4721 CheckIC(loadIC->code(), Code::LOAD_IC, POLYMORPHIC);
4722 {
4723 v8::HandleScope scope(CcTest::isolate());
4724 CompileRun("(testIC())");
4725 }
4726 CheckIC(loadIC->code(), Code::LOAD_IC, POLYMORPHIC);
4727 }
4728
4729
4642 TEST(WeakCell) { 4730 TEST(WeakCell) {
4643 CcTest::InitializeVM(); 4731 CcTest::InitializeVM();
4644 Isolate* isolate = CcTest::i_isolate(); 4732 Isolate* isolate = CcTest::i_isolate();
4645 v8::internal::Heap* heap = CcTest::heap(); 4733 v8::internal::Heap* heap = CcTest::heap();
4646 v8::internal::Factory* factory = isolate->factory(); 4734 v8::internal::Factory* factory = isolate->factory();
4647 4735
4648 HandleScope outer_scope(isolate); 4736 HandleScope outer_scope(isolate);
4649 Handle<WeakCell> weak_cell1; 4737 Handle<WeakCell> weak_cell1;
4650 { 4738 {
4651 HandleScope inner_scope(isolate); 4739 HandleScope inner_scope(isolate);
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
5009 #ifdef DEBUG 5097 #ifdef DEBUG
5010 TEST(PathTracer) { 5098 TEST(PathTracer) {
5011 CcTest::InitializeVM(); 5099 CcTest::InitializeVM();
5012 v8::HandleScope scope(CcTest::isolate()); 5100 v8::HandleScope scope(CcTest::isolate());
5013 5101
5014 v8::Local<v8::Value> result = CompileRun("'abc'"); 5102 v8::Local<v8::Value> result = CompileRun("'abc'");
5015 Handle<Object> o = v8::Utils::OpenHandle(*result); 5103 Handle<Object> o = v8::Utils::OpenHandle(*result);
5016 CcTest::i_isolate()->heap()->TracePathToObject(*o); 5104 CcTest::i_isolate()->heap()->TracePathToObject(*o);
5017 } 5105 }
5018 #endif // DEBUG 5106 #endif // DEBUG
OLDNEW
« no previous file with comments | « src/ic/ic.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698