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

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

Issue 976623002: Serializer: correctly deal with internal references. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: argh I keep making mistakes. Created 5 years, 9 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 | « src/x87/assembler-x87-inl.h ('k') | test/mjsunit/mjsunit.status » ('j') | 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 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 int b = CompileRun("b.length")->ToNumber(v8_isolate)->Int32Value(); 699 int b = CompileRun("b.length")->ToNumber(v8_isolate)->Int32Value();
700 CHECK_EQ(100002, b); 700 CHECK_EQ(100002, b);
701 } 701 }
702 DeleteArray(snapshot); 702 DeleteArray(snapshot);
703 } 703 }
704 v8_isolate->Dispose(); 704 v8_isolate->Dispose();
705 } 705 }
706 706
707 707
708 TEST(PerIsolateSnapshotBlobs) { 708 TEST(PerIsolateSnapshotBlobs) {
709 const char* flag = "--turbo-filter=\"\"";
710 FlagList::SetFlagsFromString(flag, StrLength(flag));
711
709 const char* source1 = "function f() { return 42; }"; 712 const char* source1 = "function f() { return 42; }";
710 const char* source2 = 713 const char* source2 =
711 "function f() { return g() * 2; }" 714 "function f() { return g() * 2; }"
712 "function g() { return 43; }"; 715 "function g() { return 43; }"
716 "/./.test('a')";
713 717
714 v8::StartupData data1 = v8::V8::CreateSnapshotDataBlob(source1); 718 v8::StartupData data1 = v8::V8::CreateSnapshotDataBlob(source1);
715 v8::StartupData data2 = v8::V8::CreateSnapshotDataBlob(source2); 719 v8::StartupData data2 = v8::V8::CreateSnapshotDataBlob(source2);
716 720
717 v8::Isolate::CreateParams params1; 721 v8::Isolate::CreateParams params1;
718 params1.snapshot_blob = &data1; 722 params1.snapshot_blob = &data1;
719 v8::Isolate* isolate1 = v8::Isolate::New(params1); 723 v8::Isolate* isolate1 = v8::Isolate::New(params1);
720 { 724 {
721 v8::Isolate::Scope i_scope(isolate1); 725 v8::Isolate::Scope i_scope(isolate1);
722 v8::HandleScope h_scope(isolate1); 726 v8::HandleScope h_scope(isolate1);
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
1488 { 1492 {
1489 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); 1493 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2));
1490 script = v8::ScriptCompiler::CompileUnbound( 1494 script = v8::ScriptCompiler::CompileUnbound(
1491 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); 1495 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache);
1492 } 1496 }
1493 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); 1497 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run();
1494 CHECK(result->ToString(isolate2)->Equals(v8_str("XY"))); 1498 CHECK(result->ToString(isolate2)->Equals(v8_str("XY")));
1495 } 1499 }
1496 isolate2->Dispose(); 1500 isolate2->Dispose();
1497 } 1501 }
1502
1503
1504 TEST(SerializeInternalReference) {
1505 // Disable experimental natives that are loaded after deserialization.
1506 FLAG_turbo_deoptimization = false;
1507 FLAG_context_specialization = false;
1508 FLAG_always_opt = true;
1509 const char* flag = "--turbo-filter=foo";
1510 FlagList::SetFlagsFromString(flag, StrLength(flag));
1511
1512 const char* source =
1513 "var foo = (function(stdlib, foreign, heap) {"
1514 " function foo(i) {"
1515 " i = i|0;"
1516 " var j = 0;"
1517 " switch (i) {"
1518 " case 0:"
1519 " case 1: j = 1; break;"
1520 " case 2:"
1521 " case 3: j = 2; break;"
1522 " case 4:"
1523 " case 5: j = 3; break;"
1524 " default: j = 0; break;"
1525 " }"
1526 " return j|0;"
1527 " }"
1528 " return { foo: foo };"
1529 "})(this, {}, undefined).foo;"
1530 "foo(1);";
1531
1532 v8::StartupData data = v8::V8::CreateSnapshotDataBlob(source);
1533 CHECK(data.data);
1534
1535 v8::Isolate::CreateParams params;
1536 params.snapshot_blob = &data;
1537 v8::Isolate* isolate = v8::Isolate::New(params);
1538 {
1539 v8::Isolate::Scope i_scope(isolate);
1540 v8::HandleScope h_scope(isolate);
1541 v8::Local<v8::Context> context = v8::Context::New(isolate);
1542 delete[] data.data; // We can dispose of the snapshot blob now.
1543 v8::Context::Scope c_scope(context);
1544 v8::Handle<v8::Function> foo =
1545 v8::Handle<v8::Function>::Cast(CompileRun("foo"));
1546 CHECK(v8::Utils::OpenHandle(*foo)->code()->is_turbofanned());
1547 CHECK_EQ(3, CompileRun("foo(4)")->ToInt32(isolate)->Int32Value());
1548 }
1549 isolate->Dispose();
1550 }
OLDNEW
« no previous file with comments | « src/x87/assembler-x87-inl.h ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698