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

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

Issue 909473002: Add hash fields to code cache header. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix test case Created 5 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
« no previous file with comments | « test/cctest/test-api.cc ('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 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 } 1310 }
1311 CHECK(!cache->rejected); 1311 CHECK(!cache->rejected);
1312 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); 1312 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run();
1313 CHECK(result->ToString(isolate2)->Equals(v8_str("abcdef"))); 1313 CHECK(result->ToString(isolate2)->Equals(v8_str("abcdef")));
1314 } 1314 }
1315 DCHECK(toplevel_test_code_event_found); 1315 DCHECK(toplevel_test_code_event_found);
1316 isolate2->Dispose(); 1316 isolate2->Dispose();
1317 } 1317 }
1318 1318
1319 1319
1320 TEST(SerializeToplevelFlagChange) {
1321 FLAG_serialize_toplevel = true;
1322
1323 const char* source = "function f() { return 'abc'; }; f() + 'def'";
1324 v8::ScriptCompiler::CachedData* cache;
1325
1326 v8::Isolate* isolate1 = v8::Isolate::New();
1327 {
1328 v8::Isolate::Scope iscope(isolate1);
1329 v8::HandleScope scope(isolate1);
1330 v8::Local<v8::Context> context = v8::Context::New(isolate1);
1331 v8::Context::Scope context_scope(context);
1332
1333 v8::Local<v8::String> source_str = v8_str(source);
1334 v8::ScriptOrigin origin(v8_str("test"));
1335 v8::ScriptCompiler::Source source(source_str, origin);
1336 v8::Local<v8::UnboundScript> script = v8::ScriptCompiler::CompileUnbound(
1337 isolate1, &source, v8::ScriptCompiler::kProduceCodeCache);
1338 const v8::ScriptCompiler::CachedData* data = source.GetCachedData();
1339 CHECK(data);
1340 // Persist cached data.
1341 uint8_t* buffer = NewArray<uint8_t>(data->length);
1342 MemCopy(buffer, data->data, data->length);
1343 cache = new v8::ScriptCompiler::CachedData(
1344 buffer, data->length, v8::ScriptCompiler::CachedData::BufferOwned);
1345
1346 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run();
1347 CHECK(result->ToString(isolate1)->Equals(v8_str("abcdef")));
1348 }
1349 isolate1->Dispose();
1350
1351 v8::Isolate* isolate2 = v8::Isolate::New();
1352 FLAG_allow_natives_syntax = true; // Flag change should trigger cache reject.
1353 {
1354 v8::Isolate::Scope iscope(isolate2);
1355 v8::HandleScope scope(isolate2);
1356 v8::Local<v8::Context> context = v8::Context::New(isolate2);
1357 v8::Context::Scope context_scope(context);
1358
1359 v8::Local<v8::String> source_str = v8_str(source);
1360 v8::ScriptOrigin origin(v8_str("test"));
1361 v8::ScriptCompiler::Source source(source_str, origin, cache);
1362 v8::ScriptCompiler::CompileUnbound(isolate2, &source,
1363 v8::ScriptCompiler::kConsumeCodeCache);
1364 CHECK(cache->rejected);
1365 }
1366 isolate2->Dispose();
1367 }
1368
1369
1320 TEST(SerializeWithHarmonyScoping) { 1370 TEST(SerializeWithHarmonyScoping) {
1321 FLAG_serialize_toplevel = true; 1371 FLAG_serialize_toplevel = true;
1322 FLAG_harmony_scoping = true; 1372 FLAG_harmony_scoping = true;
1323 1373
1324 const char* source1 = "'use strict'; let x = 'X'"; 1374 const char* source1 = "'use strict'; let x = 'X'";
1325 const char* source2 = "'use strict'; let y = 'Y'"; 1375 const char* source2 = "'use strict'; let y = 'Y'";
1326 const char* source3 = "'use strict'; x + y"; 1376 const char* source3 = "'use strict'; x + y";
1327 1377
1328 v8::ScriptCompiler::CachedData* cache; 1378 v8::ScriptCompiler::CachedData* cache;
1329 1379
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 { 1423 {
1374 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); 1424 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2));
1375 script = v8::ScriptCompiler::CompileUnbound( 1425 script = v8::ScriptCompiler::CompileUnbound(
1376 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); 1426 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache);
1377 } 1427 }
1378 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); 1428 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run();
1379 CHECK(result->ToString(isolate2)->Equals(v8_str("XY"))); 1429 CHECK(result->ToString(isolate2)->Equals(v8_str("XY")));
1380 } 1430 }
1381 isolate2->Dispose(); 1431 isolate2->Dispose();
1382 } 1432 }
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698