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

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

Issue 1032843002: VectorICs: Address test-heap TODOS (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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 | « no previous file | 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 4578 matching lines...) Expand 10 before | Expand all | Expand 10 after
4589 4589
4590 4590
4591 Handle<JSFunction> GetFunctionByName(Isolate* isolate, const char* name) { 4591 Handle<JSFunction> GetFunctionByName(Isolate* isolate, const char* name) {
4592 Handle<String> str = isolate->factory()->InternalizeUtf8String(name); 4592 Handle<String> str = isolate->factory()->InternalizeUtf8String(name);
4593 Handle<Object> obj = 4593 Handle<Object> obj =
4594 Object::GetProperty(isolate->global_object(), str).ToHandleChecked(); 4594 Object::GetProperty(isolate->global_object(), str).ToHandleChecked();
4595 return Handle<JSFunction>::cast(obj); 4595 return Handle<JSFunction>::cast(obj);
4596 } 4596 }
4597 4597
4598 4598
4599 void CheckIC(Code* code, Code::Kind kind, InlineCacheState state) { 4599 void CheckIC(Code* code, Code::Kind kind, SharedFunctionInfo* shared,
4600 Code* ic = FindFirstIC(code, kind); 4600 int ic_slot, InlineCacheState state) {
4601 CHECK(ic->is_inline_cache_stub()); 4601 if (FLAG_vector_ics &&
4602 CHECK(ic->ic_state() == state); 4602 (kind == Code::LOAD_IC || kind == Code::KEYED_LOAD_IC ||
4603 kind == Code::CALL_IC)) {
4604 TypeFeedbackVector* vector = shared->feedback_vector();
4605 FeedbackVectorICSlot slot(ic_slot);
4606 if (kind == Code::LOAD_IC) {
4607 LoadICNexus nexus(vector, slot);
4608 CHECK_EQ(nexus.StateFromFeedback(), state);
4609 } else if (kind == Code::KEYED_LOAD_IC) {
4610 KeyedLoadICNexus nexus(vector, slot);
4611 CHECK_EQ(nexus.StateFromFeedback(), state);
4612 } else if (kind == Code::CALL_IC) {
4613 CallICNexus nexus(vector, slot);
4614 CHECK_EQ(nexus.StateFromFeedback(), state);
4615 }
4616 } else {
4617 Code* ic = FindFirstIC(code, kind);
4618 CHECK(ic->is_inline_cache_stub());
4619 CHECK(ic->ic_state() == state);
4620 }
4603 } 4621 }
4604 4622
4605 4623
4606 TEST(MonomorphicStaysMonomorphicAfterGC) { 4624 TEST(MonomorphicStaysMonomorphicAfterGC) {
4607 if (FLAG_always_opt) return; 4625 if (FLAG_always_opt) return;
4608 // TODO(mvstanton): vector ics need weak support!
4609 if (FLAG_vector_ics) return;
4610 CcTest::InitializeVM(); 4626 CcTest::InitializeVM();
4611 Isolate* isolate = CcTest::i_isolate(); 4627 Isolate* isolate = CcTest::i_isolate();
4612 Heap* heap = isolate->heap(); 4628 Heap* heap = isolate->heap();
4613 v8::HandleScope scope(CcTest::isolate()); 4629 v8::HandleScope scope(CcTest::isolate());
4614 CompileRun( 4630 CompileRun(
4615 "function loadIC(obj) {" 4631 "function loadIC(obj) {"
4616 " return obj.name;" 4632 " return obj.name;"
4617 "}" 4633 "}"
4618 "function testIC() {" 4634 "function testIC() {"
4619 " var proto = {'name' : 'weak'};" 4635 " var proto = {'name' : 'weak'};"
4620 " var obj = Object.create(proto);" 4636 " var obj = Object.create(proto);"
4621 " loadIC(obj);" 4637 " loadIC(obj);"
4622 " loadIC(obj);" 4638 " loadIC(obj);"
4623 " loadIC(obj);" 4639 " loadIC(obj);"
4624 " return proto;" 4640 " return proto;"
4625 "};"); 4641 "};");
4626 Handle<JSFunction> loadIC = GetFunctionByName(isolate, "loadIC"); 4642 Handle<JSFunction> loadIC = GetFunctionByName(isolate, "loadIC");
4627 { 4643 {
4628 v8::HandleScope scope(CcTest::isolate()); 4644 v8::HandleScope scope(CcTest::isolate());
4629 CompileRun("(testIC())"); 4645 CompileRun("(testIC())");
4630 } 4646 }
4631 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 4647 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
4632 CheckIC(loadIC->code(), Code::LOAD_IC, MONOMORPHIC); 4648 CheckIC(loadIC->code(), Code::LOAD_IC, loadIC->shared(), 0, MONOMORPHIC);
4633 { 4649 {
4634 v8::HandleScope scope(CcTest::isolate()); 4650 v8::HandleScope scope(CcTest::isolate());
4635 CompileRun("(testIC())"); 4651 CompileRun("(testIC())");
4636 } 4652 }
4637 CheckIC(loadIC->code(), Code::LOAD_IC, MONOMORPHIC); 4653 CheckIC(loadIC->code(), Code::LOAD_IC, loadIC->shared(), 0, MONOMORPHIC);
4638 } 4654 }
4639 4655
4640 4656
4641 TEST(PolymorphicStaysPolymorphicAfterGC) { 4657 TEST(PolymorphicStaysPolymorphicAfterGC) {
4642 if (FLAG_always_opt) return; 4658 if (FLAG_always_opt) return;
4643 // TODO(mvstanton): vector ics need weak support!
4644 if (FLAG_vector_ics) return;
4645 CcTest::InitializeVM(); 4659 CcTest::InitializeVM();
4646 Isolate* isolate = CcTest::i_isolate(); 4660 Isolate* isolate = CcTest::i_isolate();
4647 Heap* heap = isolate->heap(); 4661 Heap* heap = isolate->heap();
4648 v8::HandleScope scope(CcTest::isolate()); 4662 v8::HandleScope scope(CcTest::isolate());
4649 CompileRun( 4663 CompileRun(
4650 "function loadIC(obj) {" 4664 "function loadIC(obj) {"
4651 " return obj.name;" 4665 " return obj.name;"
4652 "}" 4666 "}"
4653 "function testIC() {" 4667 "function testIC() {"
4654 " var proto = {'name' : 'weak'};" 4668 " var proto = {'name' : 'weak'};"
4655 " var obj = Object.create(proto);" 4669 " var obj = Object.create(proto);"
4656 " loadIC(obj);" 4670 " loadIC(obj);"
4657 " loadIC(obj);" 4671 " loadIC(obj);"
4658 " loadIC(obj);" 4672 " loadIC(obj);"
4659 " var poly = Object.create(proto);" 4673 " var poly = Object.create(proto);"
4660 " poly.x = true;" 4674 " poly.x = true;"
4661 " loadIC(poly);" 4675 " loadIC(poly);"
4662 " return proto;" 4676 " return proto;"
4663 "};"); 4677 "};");
4664 Handle<JSFunction> loadIC = GetFunctionByName(isolate, "loadIC"); 4678 Handle<JSFunction> loadIC = GetFunctionByName(isolate, "loadIC");
4665 { 4679 {
4666 v8::HandleScope scope(CcTest::isolate()); 4680 v8::HandleScope scope(CcTest::isolate());
4667 CompileRun("(testIC())"); 4681 CompileRun("(testIC())");
4668 } 4682 }
4669 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 4683 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
4670 CheckIC(loadIC->code(), Code::LOAD_IC, POLYMORPHIC); 4684 CheckIC(loadIC->code(), Code::LOAD_IC, loadIC->shared(), 0, POLYMORPHIC);
4671 { 4685 {
4672 v8::HandleScope scope(CcTest::isolate()); 4686 v8::HandleScope scope(CcTest::isolate());
4673 CompileRun("(testIC())"); 4687 CompileRun("(testIC())");
4674 } 4688 }
4675 CheckIC(loadIC->code(), Code::LOAD_IC, POLYMORPHIC); 4689 CheckIC(loadIC->code(), Code::LOAD_IC, loadIC->shared(), 0, POLYMORPHIC);
4676 } 4690 }
4677 4691
4678 4692
4679 TEST(WeakCell) { 4693 TEST(WeakCell) {
4680 CcTest::InitializeVM(); 4694 CcTest::InitializeVM();
4681 Isolate* isolate = CcTest::i_isolate(); 4695 Isolate* isolate = CcTest::i_isolate();
4682 v8::internal::Heap* heap = CcTest::heap(); 4696 v8::internal::Heap* heap = CcTest::heap();
4683 v8::internal::Factory* factory = isolate->factory(); 4697 v8::internal::Factory* factory = isolate->factory();
4684 4698
4685 HandleScope outer_scope(isolate); 4699 HandleScope outer_scope(isolate);
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
5178 5192
5179 TEST(WritableVsImmortalRoots) { 5193 TEST(WritableVsImmortalRoots) {
5180 for (int i = 0; i < Heap::kStrongRootListLength; ++i) { 5194 for (int i = 0; i < Heap::kStrongRootListLength; ++i) {
5181 Heap::RootListIndex root_index = static_cast<Heap::RootListIndex>(i); 5195 Heap::RootListIndex root_index = static_cast<Heap::RootListIndex>(i);
5182 bool writable = Heap::RootCanBeWrittenAfterInitialization(root_index); 5196 bool writable = Heap::RootCanBeWrittenAfterInitialization(root_index);
5183 bool immortal = Heap::RootIsImmortalImmovable(root_index); 5197 bool immortal = Heap::RootIsImmortalImmovable(root_index);
5184 // A root value can be writable, immortal, or neither, but not both. 5198 // A root value can be writable, immortal, or neither, but not both.
5185 CHECK(!immortal || !writable); 5199 CHECK(!immortal || !writable);
5186 } 5200 }
5187 } 5201 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698