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

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

Issue 1005183006: Serializer: serialize internal references via object visitor. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix compilation 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/x64/assembler-x64-inl.h ('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 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); 1477 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache);
1478 } 1478 }
1479 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); 1479 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run();
1480 CHECK(result->ToString(isolate2)->Equals(v8_str("XY"))); 1480 CHECK(result->ToString(isolate2)->Equals(v8_str("XY")));
1481 } 1481 }
1482 isolate2->Dispose(); 1482 isolate2->Dispose();
1483 } 1483 }
1484 1484
1485 1485
1486 TEST(SerializeInternalReference) { 1486 TEST(SerializeInternalReference) {
1487 #ifdef V8_TARGET_ARCH_ARM64
1488 return;
1489 #endif // V8_TARGET_ARCH_ARM64
1487 // Disable experimental natives that are loaded after deserialization. 1490 // Disable experimental natives that are loaded after deserialization.
1488 FLAG_turbo_deoptimization = false; 1491 FLAG_turbo_deoptimization = false;
1489 FLAG_context_specialization = false; 1492 FLAG_context_specialization = false;
1490 FLAG_always_opt = true; 1493 FLAG_always_opt = true;
1491 const char* flag = "--turbo-filter=foo"; 1494 const char* flag = "--turbo-filter=foo";
1492 FlagList::SetFlagsFromString(flag, StrLength(flag)); 1495 FlagList::SetFlagsFromString(flag, StrLength(flag));
1493 1496
1494 const char* source = 1497 const char* source =
1495 "var foo = (function(stdlib, foreign, heap) {" 1498 "var foo = (function(stdlib, foreign, heap) {"
1496 " function foo(i) {" 1499 " function foo(i) {"
1497 " i = i|0;" 1500 " i = i|0;"
1498 " var j = 0;" 1501 " var j = 0;"
1499 " switch (i) {" 1502 " switch (i) {"
1500 " case 0:" 1503 " case 0:"
1501 " case 1: j = 1; break;" 1504 " case 1: j = 1; break;"
1502 " case 2:" 1505 " case 2:"
1503 " case 3: j = 2; break;" 1506 " case 3: j = 2; break;"
1504 " case 4:" 1507 " case 4:"
1505 " case 5: j = 3; break;" 1508 " case 5: j = foo(3) + 1; break;"
1506 " default: j = 0; break;" 1509 " default: j = 0; break;"
1507 " }" 1510 " }"
1508 " return j|0;" 1511 " return j + 10;"
1509 " }" 1512 " }"
1510 " return { foo: foo };" 1513 " return { foo: foo };"
1511 "})(this, {}, undefined).foo;" 1514 "})(this, {}, undefined).foo;"
1512 "foo(1);"; 1515 "foo(1);";
1513 1516
1514 v8::StartupData data = v8::V8::CreateSnapshotDataBlob(source); 1517 v8::StartupData data = v8::V8::CreateSnapshotDataBlob(source);
1515 CHECK(data.data); 1518 CHECK(data.data);
1516 1519
1517 v8::Isolate::CreateParams params; 1520 v8::Isolate::CreateParams params;
1518 params.snapshot_blob = &data; 1521 params.snapshot_blob = &data;
1519 v8::Isolate* isolate = v8::Isolate::New(params); 1522 v8::Isolate* isolate = v8::Isolate::New(params);
1520 { 1523 {
1521 v8::Isolate::Scope i_scope(isolate); 1524 v8::Isolate::Scope i_scope(isolate);
1522 v8::HandleScope h_scope(isolate); 1525 v8::HandleScope h_scope(isolate);
1523 v8::Local<v8::Context> context = v8::Context::New(isolate); 1526 v8::Local<v8::Context> context = v8::Context::New(isolate);
1524 delete[] data.data; // We can dispose of the snapshot blob now. 1527 delete[] data.data; // We can dispose of the snapshot blob now.
1525 v8::Context::Scope c_scope(context); 1528 v8::Context::Scope c_scope(context);
1526 v8::Handle<v8::Function> foo = 1529 v8::Handle<v8::Function> foo =
1527 v8::Handle<v8::Function>::Cast(CompileRun("foo")); 1530 v8::Handle<v8::Function>::Cast(CompileRun("foo"));
1531
1532 // There are at least 6 internal references.
1533 int mask = RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE) |
1534 RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE_ENCODED);
1535 RelocIterator it(v8::Utils::OpenHandle(*foo)->code(), mask);
1536 for (int i = 0; i < 6; ++i) {
1537 CHECK(!it.done());
1538 it.next();
1539 }
1540
1528 CHECK(v8::Utils::OpenHandle(*foo)->code()->is_turbofanned()); 1541 CHECK(v8::Utils::OpenHandle(*foo)->code()->is_turbofanned());
1529 CHECK_EQ(3, CompileRun("foo(4)")->ToInt32(isolate)->Int32Value()); 1542 CHECK_EQ(11, CompileRun("foo(0)")->ToInt32(isolate)->Int32Value());
1543 CHECK_EQ(11, CompileRun("foo(1)")->ToInt32(isolate)->Int32Value());
1544 CHECK_EQ(12, CompileRun("foo(2)")->ToInt32(isolate)->Int32Value());
1545 CHECK_EQ(12, CompileRun("foo(3)")->ToInt32(isolate)->Int32Value());
1546 CHECK_EQ(23, CompileRun("foo(4)")->ToInt32(isolate)->Int32Value());
1547 CHECK_EQ(23, CompileRun("foo(5)")->ToInt32(isolate)->Int32Value());
1548 CHECK_EQ(10, CompileRun("foo(6)")->ToInt32(isolate)->Int32Value());
1530 } 1549 }
1531 isolate->Dispose(); 1550 isolate->Dispose();
1532 } 1551 }
OLDNEW
« no previous file with comments | « src/x64/assembler-x64-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698