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

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

Issue 146183006: Allow externalizing strings in old pointer space. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Also fix two-byte String::MakeExternal Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « src/objects-inl.h ('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 17844 matching lines...) Expand 10 before | Expand all | Expand 10 after
17855 CHECK(found_resource_[i]); 17855 CHECK(found_resource_[i]);
17856 } 17856 }
17857 } 17857 }
17858 17858
17859 private: 17859 private:
17860 v8::String::ExternalStringResource* resource_[4]; 17860 v8::String::ExternalStringResource* resource_[4];
17861 bool found_resource_[4]; 17861 bool found_resource_[4];
17862 }; 17862 };
17863 17863
17864 17864
17865 TEST(ExternalizeOldSpaceTwoByteCons) {
17866 LocalContext env;
17867 v8::HandleScope scope(env->GetIsolate());
17868 v8::Local<v8::String> cons =
17869 CompileRun("'Romeo Montague ' + 'Juliet Capulet'")->ToString();
17870 CHECK(v8::Utils::OpenHandle(*cons)->IsConsString());
17871 CcTest::heap()->CollectAllAvailableGarbage();
17872 CHECK(CcTest::heap()->old_pointer_space()->Contains(
17873 *v8::Utils::OpenHandle(*cons)));
17874
17875 TestResource* resource = new TestResource(
17876 AsciiToTwoByteString("Romeo Montague Juliet Capulet"));
17877 cons->MakeExternal(resource);
17878
17879 CHECK(cons->IsExternal());
17880 CHECK_EQ(resource, cons->GetExternalStringResource());
17881 String::Encoding encoding;
17882 CHECK_EQ(resource, cons->GetExternalStringResourceBase(&encoding));
17883 CHECK_EQ(String::TWO_BYTE_ENCODING, encoding);
17884 }
17885
17886
17887 TEST(ExternalizeOldSpaceOneByteCons) {
17888 LocalContext env;
17889 v8::HandleScope scope(env->GetIsolate());
17890 v8::Local<v8::String> cons =
17891 CompileRun("'Romeo Montague ' + 'Juliet Capulet'")->ToString();
17892 CHECK(v8::Utils::OpenHandle(*cons)->IsConsString());
17893 CcTest::heap()->CollectAllAvailableGarbage();
17894 CHECK(CcTest::heap()->old_pointer_space()->Contains(
17895 *v8::Utils::OpenHandle(*cons)));
17896
17897 TestAsciiResource* resource =
17898 new TestAsciiResource(i::StrDup("Romeo Montague Juliet Capulet"));
17899 cons->MakeExternal(resource);
17900
17901 CHECK(cons->IsExternalAscii());
17902 CHECK_EQ(resource, cons->GetExternalAsciiStringResource());
17903 String::Encoding encoding;
17904 CHECK_EQ(resource, cons->GetExternalStringResourceBase(&encoding));
17905 CHECK_EQ(String::ONE_BYTE_ENCODING, encoding);
17906 }
17907
17908
17865 TEST(VisitExternalStrings) { 17909 TEST(VisitExternalStrings) {
17866 LocalContext env; 17910 LocalContext env;
17867 v8::HandleScope scope(env->GetIsolate()); 17911 v8::HandleScope scope(env->GetIsolate());
17868 const char* string = "Some string"; 17912 const char* string = "Some string";
17869 uint16_t* two_byte_string = AsciiToTwoByteString(string); 17913 uint16_t* two_byte_string = AsciiToTwoByteString(string);
17870 TestResource* resource[4]; 17914 TestResource* resource[4];
17871 resource[0] = new TestResource(two_byte_string); 17915 resource[0] = new TestResource(two_byte_string);
17872 v8::Local<v8::String> string0 = 17916 v8::Local<v8::String> string0 =
17873 v8::String::NewExternal(env->GetIsolate(), resource[0]); 17917 v8::String::NewExternal(env->GetIsolate(), resource[0]);
17874 resource[1] = new TestResource(two_byte_string, NULL, false); 17918 resource[1] = new TestResource(two_byte_string, NULL, false);
(...skipping 4100 matching lines...) Expand 10 before | Expand all | Expand 10 after
21975 22019
21976 22020
21977 TEST(TestFunctionCallOptimization) { 22021 TEST(TestFunctionCallOptimization) {
21978 i::FLAG_allow_natives_syntax = true; 22022 i::FLAG_allow_natives_syntax = true;
21979 ApiCallOptimizationChecker checker; 22023 ApiCallOptimizationChecker checker;
21980 checker.Run(true, true); 22024 checker.Run(true, true);
21981 checker.Run(false, true); 22025 checker.Run(false, true);
21982 checker.Run(true, false); 22026 checker.Run(true, false);
21983 checker.Run(false, false); 22027 checker.Run(false, false);
21984 } 22028 }
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698