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

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

Issue 2428463002: [serializer] add test case for unknown external references. (Closed)
Patch Set: fix 2 Created 4 years, 2 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/cctest.status ('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 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 1992 matching lines...) Expand 10 before | Expand all | Expand 10 after
2003 v8::Context::FromSnapshot(isolate, 2).ToLocalChecked(); 2003 v8::Context::FromSnapshot(isolate, 2).ToLocalChecked();
2004 v8::Context::Scope context_scope(context); 2004 v8::Context::Scope context_scope(context);
2005 ExpectUndefined("this.f"); 2005 ExpectUndefined("this.f");
2006 } 2006 }
2007 } 2007 }
2008 2008
2009 isolate->Dispose(); 2009 isolate->Dispose();
2010 delete[] blob.data; 2010 delete[] blob.data;
2011 } 2011 }
2012 2012
2013 static void SerializedCallback( 2013 void SerializedCallback(const v8::FunctionCallbackInfo<v8::Value>& args) {
2014 const v8::FunctionCallbackInfo<v8::Value>& args) {
2015 args.GetReturnValue().Set(v8_num(42)); 2014 args.GetReturnValue().Set(v8_num(42));
2016 } 2015 }
2017 2016
2018 static void SerializedCallbackReplacement( 2017 void SerializedCallbackReplacement(
2019 const v8::FunctionCallbackInfo<v8::Value>& args) { 2018 const v8::FunctionCallbackInfo<v8::Value>& args) {
2020 args.GetReturnValue().Set(v8_num(1337)); 2019 args.GetReturnValue().Set(v8_num(1337));
2021 } 2020 }
2022 2021
2023 intptr_t original_external_references[] = { 2022 intptr_t original_external_references[] = {
2024 reinterpret_cast<intptr_t>(SerializedCallback), 0}; 2023 reinterpret_cast<intptr_t>(SerializedCallback), 0};
2025 2024
2026 intptr_t replaced_external_references[] = { 2025 intptr_t replaced_external_references[] = {
2027 reinterpret_cast<intptr_t>(SerializedCallbackReplacement), 0}; 2026 reinterpret_cast<intptr_t>(SerializedCallbackReplacement), 0};
2028 2027
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2079 v8::Local<v8::Context> context = 2078 v8::Local<v8::Context> context =
2080 v8::Context::FromSnapshot(isolate, 0).ToLocalChecked(); 2079 v8::Context::FromSnapshot(isolate, 0).ToLocalChecked();
2081 v8::Context::Scope context_scope(context); 2080 v8::Context::Scope context_scope(context);
2082 ExpectInt32("f()", 1337); 2081 ExpectInt32("f()", 1337);
2083 } 2082 }
2084 isolate->Dispose(); 2083 isolate->Dispose();
2085 } 2084 }
2086 delete[] blob.data; 2085 delete[] blob.data;
2087 } 2086 }
2088 2087
2088 TEST(SnapshotCreatorUnknownExternalReferences) {
2089 DisableTurbofan();
2090 v8::SnapshotCreator creator;
2091 v8::Isolate* isolate = creator.GetIsolate();
2092 {
2093 v8::HandleScope handle_scope(isolate);
2094 v8::Local<v8::Context> context = v8::Context::New(isolate);
2095 v8::Context::Scope context_scope(context);
2096
2097 v8::Local<v8::FunctionTemplate> callback =
2098 v8::FunctionTemplate::New(isolate, SerializedCallback);
2099 v8::Local<v8::Value> function =
2100 callback->GetFunction(context).ToLocalChecked();
2101 CHECK(context->Global()->Set(context, v8_str("f"), function).FromJust());
2102 ExpectInt32("f()", 42);
2103
2104 CHECK_EQ(0, creator.AddContext(context));
2105 }
2106 v8::StartupData blob =
2107 creator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kClear);
2108
2109 delete[] blob.data;
2110 }
2111
2089 TEST(SnapshotCreatorTemplates) { 2112 TEST(SnapshotCreatorTemplates) {
2090 DisableTurbofan(); 2113 DisableTurbofan();
2091 v8::StartupData blob; 2114 v8::StartupData blob;
2092 { 2115 {
2093 v8::SnapshotCreator creator(original_external_references); 2116 v8::SnapshotCreator creator(original_external_references);
2094 v8::Isolate* isolate = creator.GetIsolate(); 2117 v8::Isolate* isolate = creator.GetIsolate();
2095 { 2118 {
2096 v8::HandleScope handle_scope(isolate); 2119 v8::HandleScope handle_scope(isolate);
2097 v8::ExtensionConfiguration* no_extension = nullptr; 2120 v8::ExtensionConfiguration* no_extension = nullptr;
2098 v8::Local<v8::ObjectTemplate> global_template = 2121 v8::Local<v8::ObjectTemplate> global_template =
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2178 } 2201 }
2179 delete[] blob.data; 2202 delete[] blob.data;
2180 } 2203 }
2181 2204
2182 TEST(SerializationMemoryStats) { 2205 TEST(SerializationMemoryStats) {
2183 FLAG_profile_deserialization = true; 2206 FLAG_profile_deserialization = true;
2184 FLAG_always_opt = false; 2207 FLAG_always_opt = false;
2185 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); 2208 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob();
2186 delete[] blob.data; 2209 delete[] blob.data;
2187 } 2210 }
OLDNEW
« no previous file with comments | « test/cctest/cctest.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698