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

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

Issue 2055203002: [snapshot] support multiple contexts in the same snapshot. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@sinkmember
Patch Set: Created 4 years, 6 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
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 1864 matching lines...) Expand 10 before | Expand all | Expand 10 after
1875 RelocIterator rit2(copy->code(), 1 << RelocInfo::CELL); 1875 RelocIterator rit2(copy->code(), 1 << RelocInfo::CELL);
1876 CHECK(rit2.rinfo()->target_cell()->IsCell()); 1876 CHECK(rit2.rinfo()->target_cell()->IsCell());
1877 Handle<Cell> cell(rit2.rinfo()->target_cell()); 1877 Handle<Cell> cell(rit2.rinfo()->target_cell());
1878 CHECK(cell->value()->IsHeapNumber()); 1878 CHECK(cell->value()->IsHeapNumber());
1879 CHECK_EQ(0.3, HeapNumber::cast(cell->value())->value()); 1879 CHECK_EQ(0.3, HeapNumber::cast(cell->value())->value());
1880 1880
1881 delete script_data; 1881 delete script_data;
1882 } 1882 }
1883 #endif // V8_TARGET_ARCH_X64 1883 #endif // V8_TARGET_ARCH_X64
1884 1884
1885 TEST(SnapshotCreatorMultipleContexts) {
1886 v8::StartupData blob;
1887 {
1888 v8::SnapshotCreator creator;
1889 v8::Isolate* isolate = creator.GetIsolate();
1890 {
1891 v8::HandleScope handle_scope(isolate);
1892 v8::Local<v8::Context> context = v8::Context::New(isolate);
1893 v8::Context::Scope context_scope(context);
1894 CompileRun("var f = function() { return 1; }");
1895 CHECK_EQ(0, creator.AddContext(context));
1896 }
1897 {
1898 v8::HandleScope handle_scope(isolate);
1899 v8::Local<v8::Context> context = v8::Context::New(isolate);
1900 v8::Context::Scope context_scope(context);
1901 CompileRun("var f = function() { return 2; }");
1902 CHECK_EQ(1, creator.AddContext(context));
1903 }
1904 {
1905 v8::HandleScope handle_scope(isolate);
1906 v8::Local<v8::Context> context = v8::Context::New(isolate);
1907 CHECK_EQ(2, creator.AddContext(context));
1908 }
1909 blob =
1910 creator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kClear);
1911 }
1912
1913 v8::Isolate::CreateParams params;
1914 params.snapshot_blob = &blob;
1915 params.array_buffer_allocator = CcTest::array_buffer_allocator();
1916 v8::Isolate* isolate = v8::Isolate::New(params);
1917 {
1918 v8::Isolate::Scope isolate_scope(isolate);
1919 v8::ExtensionConfiguration* no_extension = nullptr;
1920 v8::Local<v8::ObjectTemplate> no_template = v8::Local<v8::ObjectTemplate>();
1921 v8::Local<v8::Value> no_object = v8::Local<v8::Value>();
1922 {
1923 v8::HandleScope handle_scope(isolate);
1924 v8::Local<v8::Context> context =
1925 v8::Context::New(isolate, no_extension, no_template, no_object, 0);
1926 v8::Context::Scope context_scope(context);
1927 ExpectInt32("f()", 1);
1928 }
1929 {
1930 v8::HandleScope handle_scope(isolate);
1931 v8::Local<v8::Context> context =
1932 v8::Context::New(isolate, no_extension, no_template, no_object, 1);
1933 v8::Context::Scope context_scope(context);
1934 ExpectInt32("f()", 2);
1935 }
1936 {
1937 v8::HandleScope handle_scope(isolate);
1938 v8::Local<v8::Context> context =
1939 v8::Context::New(isolate, no_extension, no_template, no_object, 2);
vogelheim 2016/06/13 16:20:20 Hrmm.... so requesting context snapshot N+1 is the
Yang 2016/06/14 11:45:30 No... We added three contexts, so loading context
1940 v8::Context::Scope context_scope(context);
1941 ExpectUndefined("this.f");
1942 }
1943 }
1944
1945 isolate->Dispose();
1946 delete blob.data;
1947 }
1948
1885 TEST(SerializationMemoryStats) { 1949 TEST(SerializationMemoryStats) {
1886 FLAG_profile_deserialization = true; 1950 FLAG_profile_deserialization = true;
1887 FLAG_always_opt = false; 1951 FLAG_always_opt = false;
1888 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); 1952 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob();
1889 delete[] blob.data; 1953 delete[] blob.data;
1890 } 1954 }
OLDNEW
« include/v8.h ('K') | « src/snapshot/startup-serializer.cc ('k') | test/memory/Memory.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698