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

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

Issue 1027463002: Revert "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_space()); 611 SimulateFullSpace(CcTest::heap()->old_pointer_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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 int dispose_count = 0; 721 int dispose_count = 0;
722 bool in_new_space = false; 722 bool in_new_space = false;
723 { 723 {
724 v8::HandleScope scope(CcTest::isolate()); 724 v8::HandleScope scope(CcTest::isolate());
725 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); 725 uint16_t* two_byte_string = AsciiToTwoByteString("test string");
726 Local<String> string = String::NewExternal( 726 Local<String> string = String::NewExternal(
727 CcTest::isolate(), new TestResource(two_byte_string, &dispose_count)); 727 CcTest::isolate(), new TestResource(two_byte_string, &dispose_count));
728 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); 728 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
729 CcTest::heap()->CollectGarbage(i::NEW_SPACE); 729 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
730 in_new_space = CcTest::heap()->InNewSpace(*istring); 730 in_new_space = CcTest::heap()->InNewSpace(*istring);
731 CHECK(in_new_space || CcTest::heap()->old_space()->Contains(*istring)); 731 CHECK(in_new_space || CcTest::heap()->old_data_space()->Contains(*istring));
732 CHECK_EQ(0, dispose_count); 732 CHECK_EQ(0, dispose_count);
733 } 733 }
734 CcTest::heap()->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_SPACE); 734 CcTest::heap()->CollectGarbage(in_new_space ? i::NEW_SPACE
735 : i::OLD_DATA_SPACE);
735 CHECK_EQ(1, dispose_count); 736 CHECK_EQ(1, dispose_count);
736 } 737 }
737 738
738 739
739 THREADED_TEST(ScavengeExternalOneByteString) { 740 THREADED_TEST(ScavengeExternalOneByteString) {
740 i::FLAG_stress_compaction = false; 741 i::FLAG_stress_compaction = false;
741 i::FLAG_gc_global = false; 742 i::FLAG_gc_global = false;
742 int dispose_count = 0; 743 int dispose_count = 0;
743 bool in_new_space = false; 744 bool in_new_space = false;
744 { 745 {
745 v8::HandleScope scope(CcTest::isolate()); 746 v8::HandleScope scope(CcTest::isolate());
746 const char* one_byte_string = "test string"; 747 const char* one_byte_string = "test string";
747 Local<String> string = String::NewExternal( 748 Local<String> string = String::NewExternal(
748 CcTest::isolate(), 749 CcTest::isolate(),
749 new TestOneByteResource(i::StrDup(one_byte_string), &dispose_count)); 750 new TestOneByteResource(i::StrDup(one_byte_string), &dispose_count));
750 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); 751 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
751 CcTest::heap()->CollectGarbage(i::NEW_SPACE); 752 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
752 in_new_space = CcTest::heap()->InNewSpace(*istring); 753 in_new_space = CcTest::heap()->InNewSpace(*istring);
753 CHECK(in_new_space || CcTest::heap()->old_space()->Contains(*istring)); 754 CHECK(in_new_space || CcTest::heap()->old_data_space()->Contains(*istring));
754 CHECK_EQ(0, dispose_count); 755 CHECK_EQ(0, dispose_count);
755 } 756 }
756 CcTest::heap()->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_SPACE); 757 CcTest::heap()->CollectGarbage(in_new_space ? i::NEW_SPACE
758 : i::OLD_DATA_SPACE);
757 CHECK_EQ(1, dispose_count); 759 CHECK_EQ(1, dispose_count);
758 } 760 }
759 761
760 762
761 class TestOneByteResourceWithDisposeControl : public TestOneByteResource { 763 class TestOneByteResourceWithDisposeControl : public TestOneByteResource {
762 public: 764 public:
763 // Only used by non-threaded tests, so it can use static fields. 765 // Only used by non-threaded tests, so it can use static fields.
764 static int dispose_calls; 766 static int dispose_calls;
765 static int dispose_count; 767 static int dispose_count;
766 768
(...skipping 15142 matching lines...) Expand 10 before | Expand all | Expand 10 after
15909 15911
15910 15912
15911 TEST(ExternalizeOldSpaceTwoByteCons) { 15913 TEST(ExternalizeOldSpaceTwoByteCons) {
15912 v8::Isolate* isolate = CcTest::isolate(); 15914 v8::Isolate* isolate = CcTest::isolate();
15913 LocalContext env; 15915 LocalContext env;
15914 v8::HandleScope scope(isolate); 15916 v8::HandleScope scope(isolate);
15915 v8::Local<v8::String> cons = 15917 v8::Local<v8::String> cons =
15916 CompileRun("'Romeo Montague ' + 'Juliet Capulet'")->ToString(isolate); 15918 CompileRun("'Romeo Montague ' + 'Juliet Capulet'")->ToString(isolate);
15917 CHECK(v8::Utils::OpenHandle(*cons)->IsConsString()); 15919 CHECK(v8::Utils::OpenHandle(*cons)->IsConsString());
15918 CcTest::heap()->CollectAllAvailableGarbage(); 15920 CcTest::heap()->CollectAllAvailableGarbage();
15919 CHECK(CcTest::heap()->old_space()->Contains(*v8::Utils::OpenHandle(*cons))); 15921 CHECK(CcTest::heap()->old_pointer_space()->Contains(
15922 *v8::Utils::OpenHandle(*cons)));
15920 15923
15921 TestResource* resource = new TestResource( 15924 TestResource* resource = new TestResource(
15922 AsciiToTwoByteString("Romeo Montague Juliet Capulet")); 15925 AsciiToTwoByteString("Romeo Montague Juliet Capulet"));
15923 cons->MakeExternal(resource); 15926 cons->MakeExternal(resource);
15924 15927
15925 CHECK(cons->IsExternal()); 15928 CHECK(cons->IsExternal());
15926 CHECK_EQ(resource, cons->GetExternalStringResource()); 15929 CHECK_EQ(resource, cons->GetExternalStringResource());
15927 String::Encoding encoding; 15930 String::Encoding encoding;
15928 CHECK_EQ(resource, cons->GetExternalStringResourceBase(&encoding)); 15931 CHECK_EQ(resource, cons->GetExternalStringResourceBase(&encoding));
15929 CHECK_EQ(String::TWO_BYTE_ENCODING, encoding); 15932 CHECK_EQ(String::TWO_BYTE_ENCODING, encoding);
15930 } 15933 }
15931 15934
15932 15935
15933 TEST(ExternalizeOldSpaceOneByteCons) { 15936 TEST(ExternalizeOldSpaceOneByteCons) {
15934 v8::Isolate* isolate = CcTest::isolate(); 15937 v8::Isolate* isolate = CcTest::isolate();
15935 LocalContext env; 15938 LocalContext env;
15936 v8::HandleScope scope(isolate); 15939 v8::HandleScope scope(isolate);
15937 v8::Local<v8::String> cons = 15940 v8::Local<v8::String> cons =
15938 CompileRun("'Romeo Montague ' + 'Juliet Capulet'")->ToString(isolate); 15941 CompileRun("'Romeo Montague ' + 'Juliet Capulet'")->ToString(isolate);
15939 CHECK(v8::Utils::OpenHandle(*cons)->IsConsString()); 15942 CHECK(v8::Utils::OpenHandle(*cons)->IsConsString());
15940 CcTest::heap()->CollectAllAvailableGarbage(); 15943 CcTest::heap()->CollectAllAvailableGarbage();
15941 CHECK(CcTest::heap()->old_space()->Contains(*v8::Utils::OpenHandle(*cons))); 15944 CHECK(CcTest::heap()->old_pointer_space()->Contains(
15945 *v8::Utils::OpenHandle(*cons)));
15942 15946
15943 TestOneByteResource* resource = 15947 TestOneByteResource* resource =
15944 new TestOneByteResource(i::StrDup("Romeo Montague Juliet Capulet")); 15948 new TestOneByteResource(i::StrDup("Romeo Montague Juliet Capulet"));
15945 cons->MakeExternal(resource); 15949 cons->MakeExternal(resource);
15946 15950
15947 CHECK(cons->IsExternalOneByte()); 15951 CHECK(cons->IsExternalOneByte());
15948 CHECK_EQ(resource, cons->GetExternalOneByteStringResource()); 15952 CHECK_EQ(resource, cons->GetExternalOneByteStringResource());
15949 String::Encoding encoding; 15953 String::Encoding encoding;
15950 CHECK_EQ(resource, cons->GetExternalStringResourceBase(&encoding)); 15954 CHECK_EQ(resource, cons->GetExternalStringResourceBase(&encoding));
15951 CHECK_EQ(String::ONE_BYTE_ENCODING, encoding); 15955 CHECK_EQ(String::ONE_BYTE_ENCODING, encoding);
(...skipping 5678 matching lines...) Expand 10 before | Expand all | Expand 10 after
21630 } 21634 }
21631 { 21635 {
21632 v8::TryCatch try_catch; 21636 v8::TryCatch try_catch;
21633 uint16_t* data = reinterpret_cast<uint16_t*>(buffer); 21637 uint16_t* data = reinterpret_cast<uint16_t*>(buffer);
21634 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString, 21638 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString,
21635 length).IsEmpty()); 21639 length).IsEmpty());
21636 CHECK(!try_catch.HasCaught()); 21640 CHECK(!try_catch.HasCaught());
21637 } 21641 }
21638 free(buffer); 21642 free(buffer);
21639 } 21643 }
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