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

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

Issue 680883003: Add serializer test case to bug fix in r24871. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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 | « 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 2007-2010 the V8 project authors. All rights reserved. 1 // Copyright 2007-2010 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 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 819
820 int result_int; 820 int result_int;
821 CHECK(copy_result->ToInt32(&result_int)); 821 CHECK(copy_result->ToInt32(&result_int));
822 CHECK_EQ(7, result_int); 822 CHECK_EQ(7, result_int);
823 823
824 delete cache; 824 delete cache;
825 source.Dispose(); 825 source.Dispose();
826 } 826 }
827 827
828 828
829 TEST(SerializeToplevelLargeString) { 829 TEST(SerializeToplevelLargeStrings) {
830 FLAG_serialize_toplevel = true; 830 FLAG_serialize_toplevel = true;
831 LocalContext context; 831 LocalContext context;
832 Isolate* isolate = CcTest::i_isolate(); 832 Isolate* isolate = CcTest::i_isolate();
833 Factory* f = isolate->factory();
833 isolate->compilation_cache()->Disable(); // Disable same-isolate code cache. 834 isolate->compilation_cache()->Disable(); // Disable same-isolate code cache.
834 835
835 v8::HandleScope scope(CcTest::isolate()); 836 v8::HandleScope scope(CcTest::isolate());
836 837
837 Vector<const uint8_t> source = ConstructSource( 838 Vector<const uint8_t> source_s = ConstructSource(
838 STATIC_CHAR_VECTOR("var s = \""), STATIC_CHAR_VECTOR("abcdef"), 839 STATIC_CHAR_VECTOR("var s = \""), STATIC_CHAR_VECTOR("abcdef"),
839 STATIC_CHAR_VECTOR("\"; s"), 1000000); 840 STATIC_CHAR_VECTOR("\";"), 1000000);
841 Vector<const uint8_t> source_t = ConstructSource(
842 STATIC_CHAR_VECTOR("var t = \""), STATIC_CHAR_VECTOR("uvwxyz"),
843 STATIC_CHAR_VECTOR("\"; s + t"), 999999);
840 Handle<String> source_str = 844 Handle<String> source_str =
841 isolate->factory()->NewStringFromOneByte(source).ToHandleChecked(); 845 f->NewConsString(f->NewStringFromOneByte(source_s).ToHandleChecked(),
846 f->NewStringFromOneByte(source_t).ToHandleChecked())
847 .ToHandleChecked();
842 848
843 Handle<JSObject> global(isolate->context()->global_object()); 849 Handle<JSObject> global(isolate->context()->global_object());
844 ScriptData* cache = NULL; 850 ScriptData* cache = NULL;
845 851
846 Handle<SharedFunctionInfo> orig = Compiler::CompileScript( 852 Handle<SharedFunctionInfo> orig = Compiler::CompileScript(
847 source_str, Handle<String>(), 0, 0, false, 853 source_str, Handle<String>(), 0, 0, false,
848 Handle<Context>(isolate->native_context()), NULL, &cache, 854 Handle<Context>(isolate->native_context()), NULL, &cache,
849 v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE); 855 v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE);
850 856
851 Handle<SharedFunctionInfo> copy; 857 Handle<SharedFunctionInfo> copy;
852 { 858 {
853 DisallowCompilation no_compile_expected(isolate); 859 DisallowCompilation no_compile_expected(isolate);
854 copy = Compiler::CompileScript( 860 copy = Compiler::CompileScript(
855 source_str, Handle<String>(), 0, 0, false, 861 source_str, Handle<String>(), 0, 0, false,
856 Handle<Context>(isolate->native_context()), NULL, &cache, 862 Handle<Context>(isolate->native_context()), NULL, &cache,
857 v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE); 863 v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE);
858 } 864 }
859 CHECK_NE(*orig, *copy); 865 CHECK_NE(*orig, *copy);
860 866
861 Handle<JSFunction> copy_fun = 867 Handle<JSFunction> copy_fun =
862 isolate->factory()->NewFunctionFromSharedFunctionInfo( 868 isolate->factory()->NewFunctionFromSharedFunctionInfo(
863 copy, isolate->native_context()); 869 copy, isolate->native_context());
864 870
865 Handle<Object> copy_result = 871 Handle<Object> copy_result =
866 Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked(); 872 Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked();
867 873
868 CHECK_EQ(6 * 1000000, Handle<String>::cast(copy_result)->length()); 874 CHECK_EQ(6 * 1999999, Handle<String>::cast(copy_result)->length());
869 CHECK(isolate->heap()->InSpace(HeapObject::cast(*copy_result), LO_SPACE)); 875 Handle<Object> property = JSObject::GetDataProperty(
876 isolate->global_object(), f->NewStringFromAsciiChecked("s"));
877 CHECK(isolate->heap()->InSpace(HeapObject::cast(*property), LO_SPACE));
878 property = JSObject::GetDataProperty(isolate->global_object(),
879 f->NewStringFromAsciiChecked("t"));
880 CHECK(isolate->heap()->InSpace(HeapObject::cast(*property), LO_SPACE));
870 // Make sure we do not serialize too much, e.g. include the source string. 881 // Make sure we do not serialize too much, e.g. include the source string.
871 CHECK_LT(cache->length(), 7000000); 882 CHECK_LT(cache->length(), 13000000);
872 883
873 delete cache; 884 delete cache;
874 source.Dispose(); 885 source_s.Dispose();
886 source_t.Dispose();
875 } 887 }
876 888
877 889
878 TEST(SerializeToplevelThreeBigStrings) { 890 TEST(SerializeToplevelThreeBigStrings) {
879 FLAG_serialize_toplevel = true; 891 FLAG_serialize_toplevel = true;
880 LocalContext context; 892 LocalContext context;
881 Isolate* isolate = CcTest::i_isolate(); 893 Isolate* isolate = CcTest::i_isolate();
882 Factory* f = isolate->factory(); 894 Factory* f = isolate->factory();
883 isolate->compilation_cache()->Disable(); // Disable same-isolate code cache. 895 isolate->compilation_cache()->Disable(); // Disable same-isolate code cache.
884 896
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 { 1295 {
1284 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); 1296 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2));
1285 script = v8::ScriptCompiler::CompileUnbound( 1297 script = v8::ScriptCompiler::CompileUnbound(
1286 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); 1298 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache);
1287 } 1299 }
1288 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); 1300 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run();
1289 CHECK(result->ToString()->Equals(v8_str("XY"))); 1301 CHECK(result->ToString()->Equals(v8_str("XY")));
1290 } 1302 }
1291 isolate2->Dispose(); 1303 isolate2->Dispose();
1292 } 1304 }
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