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

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

Issue 1012023002: Merge old data and pointer space. (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 | « test/cctest/test-alloc.cc ('k') | test/cctest/test-constantpool.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 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 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 CompileRun("function cons(a, b) { return a + b; }" 601 CompileRun("function cons(a, b) { return a + b; }"
602 "function slice(a) { return a.substring(1); }"); 602 "function slice(a) { return a.substring(1); }");
603 // Create a cons string that will land in old pointer space. 603 // Create a cons string that will land in old pointer space.
604 Local<String> cons = Local<String>::Cast(CompileRun( 604 Local<String> cons = Local<String>::Cast(CompileRun(
605 "cons('abcdefghijklm', 'nopqrstuvwxyz');")); 605 "cons('abcdefghijklm', 'nopqrstuvwxyz');"));
606 // Create a sliced string that will land in old pointer space. 606 // Create a sliced string that will land in old pointer space.
607 Local<String> slice = Local<String>::Cast(CompileRun( 607 Local<String> slice = Local<String>::Cast(CompileRun(
608 "slice('abcdefghijklmnopqrstuvwxyz');")); 608 "slice('abcdefghijklmnopqrstuvwxyz');"));
609 609
610 // Trigger GCs so that the newly allocated string moves to old gen. 610 // Trigger GCs so that the newly allocated string moves to old gen.
611 SimulateFullSpace(CcTest::heap()->old_pointer_space()); 611 SimulateFullSpace(CcTest::heap()->old_space());
612 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now 612 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
613 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now 613 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now
614 614
615 // Turn into external string with unaligned resource data. 615 // Turn into external string with unaligned resource data.
616 const char* c_cons = "_abcdefghijklmnopqrstuvwxyz"; 616 const char* c_cons = "_abcdefghijklmnopqrstuvwxyz";
617 bool success = 617 bool success =
618 cons->MakeExternal(new TestOneByteResource(i::StrDup(c_cons), NULL, 1)); 618 cons->MakeExternal(new TestOneByteResource(i::StrDup(c_cons), NULL, 1));
619 CHECK(success); 619 CHECK(success);
620 const char* c_slice = "_bcdefghijklmnopqrstuvwxyz"; 620 const char* c_slice = "_bcdefghijklmnopqrstuvwxyz";
621 success = 621 success =
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 int dispose_count = 0; 726 int dispose_count = 0;
727 bool in_new_space = false; 727 bool in_new_space = false;
728 { 728 {
729 v8::HandleScope scope(CcTest::isolate()); 729 v8::HandleScope scope(CcTest::isolate());
730 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); 730 uint16_t* two_byte_string = AsciiToTwoByteString("test string");
731 Local<String> string = String::NewExternal( 731 Local<String> string = String::NewExternal(
732 CcTest::isolate(), new TestResource(two_byte_string, &dispose_count)); 732 CcTest::isolate(), new TestResource(two_byte_string, &dispose_count));
733 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); 733 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
734 CcTest::heap()->CollectGarbage(i::NEW_SPACE); 734 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
735 in_new_space = CcTest::heap()->InNewSpace(*istring); 735 in_new_space = CcTest::heap()->InNewSpace(*istring);
736 CHECK(in_new_space || CcTest::heap()->old_data_space()->Contains(*istring)); 736 CHECK(in_new_space || CcTest::heap()->old_space()->Contains(*istring));
737 CHECK_EQ(0, dispose_count); 737 CHECK_EQ(0, dispose_count);
738 } 738 }
739 CcTest::heap()->CollectGarbage( 739 CcTest::heap()->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_SPACE);
740 in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE);
741 CHECK_EQ(1, dispose_count); 740 CHECK_EQ(1, dispose_count);
742 } 741 }
743 742
744 743
745 THREADED_TEST(ScavengeExternalOneByteString) { 744 THREADED_TEST(ScavengeExternalOneByteString) {
746 i::FLAG_stress_compaction = false; 745 i::FLAG_stress_compaction = false;
747 i::FLAG_gc_global = false; 746 i::FLAG_gc_global = false;
748 int dispose_count = 0; 747 int dispose_count = 0;
749 bool in_new_space = false; 748 bool in_new_space = false;
750 { 749 {
751 v8::HandleScope scope(CcTest::isolate()); 750 v8::HandleScope scope(CcTest::isolate());
752 const char* one_byte_string = "test string"; 751 const char* one_byte_string = "test string";
753 Local<String> string = String::NewExternal( 752 Local<String> string = String::NewExternal(
754 CcTest::isolate(), 753 CcTest::isolate(),
755 new TestOneByteResource(i::StrDup(one_byte_string), &dispose_count)); 754 new TestOneByteResource(i::StrDup(one_byte_string), &dispose_count));
756 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); 755 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
757 CcTest::heap()->CollectGarbage(i::NEW_SPACE); 756 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
758 in_new_space = CcTest::heap()->InNewSpace(*istring); 757 in_new_space = CcTest::heap()->InNewSpace(*istring);
759 CHECK(in_new_space || CcTest::heap()->old_data_space()->Contains(*istring)); 758 CHECK(in_new_space || CcTest::heap()->old_space()->Contains(*istring));
760 CHECK_EQ(0, dispose_count); 759 CHECK_EQ(0, dispose_count);
761 } 760 }
762 CcTest::heap()->CollectGarbage( 761 CcTest::heap()->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_SPACE);
763 in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE);
764 CHECK_EQ(1, dispose_count); 762 CHECK_EQ(1, dispose_count);
765 } 763 }
766 764
767 765
768 class TestOneByteResourceWithDisposeControl : public TestOneByteResource { 766 class TestOneByteResourceWithDisposeControl : public TestOneByteResource {
769 public: 767 public:
770 // Only used by non-threaded tests, so it can use static fields. 768 // Only used by non-threaded tests, so it can use static fields.
771 static int dispose_calls; 769 static int dispose_calls;
772 static int dispose_count; 770 static int dispose_count;
773 771
(...skipping 15142 matching lines...) Expand 10 before | Expand all | Expand 10 after
15916 15914
15917 15915
15918 TEST(ExternalizeOldSpaceTwoByteCons) { 15916 TEST(ExternalizeOldSpaceTwoByteCons) {
15919 v8::Isolate* isolate = CcTest::isolate(); 15917 v8::Isolate* isolate = CcTest::isolate();
15920 LocalContext env; 15918 LocalContext env;
15921 v8::HandleScope scope(isolate); 15919 v8::HandleScope scope(isolate);
15922 v8::Local<v8::String> cons = 15920 v8::Local<v8::String> cons =
15923 CompileRun("'Romeo Montague ' + 'Juliet Capulet'")->ToString(isolate); 15921 CompileRun("'Romeo Montague ' + 'Juliet Capulet'")->ToString(isolate);
15924 CHECK(v8::Utils::OpenHandle(*cons)->IsConsString()); 15922 CHECK(v8::Utils::OpenHandle(*cons)->IsConsString());
15925 CcTest::heap()->CollectAllAvailableGarbage(); 15923 CcTest::heap()->CollectAllAvailableGarbage();
15926 CHECK(CcTest::heap()->old_pointer_space()->Contains( 15924 CHECK(CcTest::heap()->old_space()->Contains(*v8::Utils::OpenHandle(*cons)));
15927 *v8::Utils::OpenHandle(*cons)));
15928 15925
15929 TestResource* resource = new TestResource( 15926 TestResource* resource = new TestResource(
15930 AsciiToTwoByteString("Romeo Montague Juliet Capulet")); 15927 AsciiToTwoByteString("Romeo Montague Juliet Capulet"));
15931 cons->MakeExternal(resource); 15928 cons->MakeExternal(resource);
15932 15929
15933 CHECK(cons->IsExternal()); 15930 CHECK(cons->IsExternal());
15934 CHECK_EQ(resource, cons->GetExternalStringResource()); 15931 CHECK_EQ(resource, cons->GetExternalStringResource());
15935 String::Encoding encoding; 15932 String::Encoding encoding;
15936 CHECK_EQ(resource, cons->GetExternalStringResourceBase(&encoding)); 15933 CHECK_EQ(resource, cons->GetExternalStringResourceBase(&encoding));
15937 CHECK_EQ(String::TWO_BYTE_ENCODING, encoding); 15934 CHECK_EQ(String::TWO_BYTE_ENCODING, encoding);
15938 } 15935 }
15939 15936
15940 15937
15941 TEST(ExternalizeOldSpaceOneByteCons) { 15938 TEST(ExternalizeOldSpaceOneByteCons) {
15942 v8::Isolate* isolate = CcTest::isolate(); 15939 v8::Isolate* isolate = CcTest::isolate();
15943 LocalContext env; 15940 LocalContext env;
15944 v8::HandleScope scope(isolate); 15941 v8::HandleScope scope(isolate);
15945 v8::Local<v8::String> cons = 15942 v8::Local<v8::String> cons =
15946 CompileRun("'Romeo Montague ' + 'Juliet Capulet'")->ToString(isolate); 15943 CompileRun("'Romeo Montague ' + 'Juliet Capulet'")->ToString(isolate);
15947 CHECK(v8::Utils::OpenHandle(*cons)->IsConsString()); 15944 CHECK(v8::Utils::OpenHandle(*cons)->IsConsString());
15948 CcTest::heap()->CollectAllAvailableGarbage(); 15945 CcTest::heap()->CollectAllAvailableGarbage();
15949 CHECK(CcTest::heap()->old_pointer_space()->Contains( 15946 CHECK(CcTest::heap()->old_space()->Contains(*v8::Utils::OpenHandle(*cons)));
15950 *v8::Utils::OpenHandle(*cons)));
15951 15947
15952 TestOneByteResource* resource = 15948 TestOneByteResource* resource =
15953 new TestOneByteResource(i::StrDup("Romeo Montague Juliet Capulet")); 15949 new TestOneByteResource(i::StrDup("Romeo Montague Juliet Capulet"));
15954 cons->MakeExternal(resource); 15950 cons->MakeExternal(resource);
15955 15951
15956 CHECK(cons->IsExternalOneByte()); 15952 CHECK(cons->IsExternalOneByte());
15957 CHECK_EQ(resource, cons->GetExternalOneByteStringResource()); 15953 CHECK_EQ(resource, cons->GetExternalOneByteStringResource());
15958 String::Encoding encoding; 15954 String::Encoding encoding;
15959 CHECK_EQ(resource, cons->GetExternalStringResourceBase(&encoding)); 15955 CHECK_EQ(resource, cons->GetExternalStringResourceBase(&encoding));
15960 CHECK_EQ(String::ONE_BYTE_ENCODING, encoding); 15956 CHECK_EQ(String::ONE_BYTE_ENCODING, encoding);
(...skipping 5679 matching lines...) Expand 10 before | Expand all | Expand 10 after
21640 } 21636 }
21641 { 21637 {
21642 v8::TryCatch try_catch; 21638 v8::TryCatch try_catch;
21643 uint16_t* data = reinterpret_cast<uint16_t*>(buffer); 21639 uint16_t* data = reinterpret_cast<uint16_t*>(buffer);
21644 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString, 21640 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString,
21645 length).IsEmpty()); 21641 length).IsEmpty());
21646 CHECK(try_catch.HasCaught()); 21642 CHECK(try_catch.HasCaught());
21647 } 21643 }
21648 free(buffer); 21644 free(buffer);
21649 } 21645 }
OLDNEW
« no previous file with comments | « test/cctest/test-alloc.cc ('k') | test/cctest/test-constantpool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698