OLD | NEW |
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 Loading... |
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 DisableTurbofan(); |
| 1887 v8::StartupData blob; |
| 1888 { |
| 1889 v8::SnapshotCreator creator; |
| 1890 v8::Isolate* isolate = creator.GetIsolate(); |
| 1891 { |
| 1892 v8::HandleScope handle_scope(isolate); |
| 1893 v8::Local<v8::Context> context = v8::Context::New(isolate); |
| 1894 v8::Context::Scope context_scope(context); |
| 1895 CompileRun("var f = function() { return 1; }"); |
| 1896 CHECK_EQ(0, creator.AddContext(context)); |
| 1897 } |
| 1898 { |
| 1899 v8::HandleScope handle_scope(isolate); |
| 1900 v8::Local<v8::Context> context = v8::Context::New(isolate); |
| 1901 v8::Context::Scope context_scope(context); |
| 1902 CompileRun("var f = function() { return 2; }"); |
| 1903 CHECK_EQ(1, creator.AddContext(context)); |
| 1904 } |
| 1905 { |
| 1906 v8::HandleScope handle_scope(isolate); |
| 1907 v8::Local<v8::Context> context = v8::Context::New(isolate); |
| 1908 CHECK_EQ(2, creator.AddContext(context)); |
| 1909 } |
| 1910 blob = |
| 1911 creator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kClear); |
| 1912 } |
| 1913 |
| 1914 v8::Isolate::CreateParams params; |
| 1915 params.snapshot_blob = &blob; |
| 1916 params.array_buffer_allocator = CcTest::array_buffer_allocator(); |
| 1917 v8::Isolate* isolate = v8::Isolate::New(params); |
| 1918 { |
| 1919 v8::Isolate::Scope isolate_scope(isolate); |
| 1920 v8::ExtensionConfiguration* no_extension = nullptr; |
| 1921 v8::Local<v8::ObjectTemplate> no_template = v8::Local<v8::ObjectTemplate>(); |
| 1922 v8::Local<v8::Value> no_object = v8::Local<v8::Value>(); |
| 1923 { |
| 1924 v8::HandleScope handle_scope(isolate); |
| 1925 v8::Local<v8::Context> context = |
| 1926 v8::Context::New(isolate, no_extension, no_template, no_object, 0); |
| 1927 v8::Context::Scope context_scope(context); |
| 1928 ExpectInt32("f()", 1); |
| 1929 } |
| 1930 { |
| 1931 v8::HandleScope handle_scope(isolate); |
| 1932 v8::Local<v8::Context> context = |
| 1933 v8::Context::New(isolate, no_extension, no_template, no_object, 1); |
| 1934 v8::Context::Scope context_scope(context); |
| 1935 ExpectInt32("f()", 2); |
| 1936 } |
| 1937 { |
| 1938 v8::HandleScope handle_scope(isolate); |
| 1939 v8::Local<v8::Context> context = |
| 1940 v8::Context::New(isolate, no_extension, no_template, no_object, 2); |
| 1941 v8::Context::Scope context_scope(context); |
| 1942 ExpectUndefined("this.f"); |
| 1943 } |
| 1944 } |
| 1945 |
| 1946 isolate->Dispose(); |
| 1947 delete[] blob.data; |
| 1948 } |
| 1949 |
1885 TEST(SerializationMemoryStats) { | 1950 TEST(SerializationMemoryStats) { |
1886 FLAG_profile_deserialization = true; | 1951 FLAG_profile_deserialization = true; |
1887 FLAG_always_opt = false; | 1952 FLAG_always_opt = false; |
1888 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); | 1953 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); |
1889 delete[] blob.data; | 1954 delete[] blob.data; |
1890 } | 1955 } |
OLD | NEW |