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

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

Issue 1116633002: Pass ArrayBuffer::Allocator via Isolate::CreateParams (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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-random-number-generator.cc ('k') | test/cctest/test-spaces.cc » ('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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 // TestIsolate is used for testing isolate serialization. 61 // TestIsolate is used for testing isolate serialization.
62 class TestIsolate : public Isolate { 62 class TestIsolate : public Isolate {
63 public: 63 public:
64 static v8::Isolate* NewInitialized(bool enable_serializer) { 64 static v8::Isolate* NewInitialized(bool enable_serializer) {
65 i::Isolate* isolate = new TestIsolate(enable_serializer); 65 i::Isolate* isolate = new TestIsolate(enable_serializer);
66 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); 66 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
67 v8::Isolate::Scope isolate_scope(v8_isolate); 67 v8::Isolate::Scope isolate_scope(v8_isolate);
68 isolate->Init(NULL); 68 isolate->Init(NULL);
69 return v8_isolate; 69 return v8_isolate;
70 } 70 }
71 explicit TestIsolate(bool enable_serializer) : Isolate(enable_serializer) {} 71 explicit TestIsolate(bool enable_serializer) : Isolate(enable_serializer) {
72 set_array_buffer_allocator(CcTest::array_buffer_allocator());
73 }
72 }; 74 };
73 75
74 76
75 void WritePayload(const Vector<const byte>& payload, const char* file_name) { 77 void WritePayload(const Vector<const byte>& payload, const char* file_name) {
76 FILE* file = v8::base::OS::FOpen(file_name, "wb"); 78 FILE* file = v8::base::OS::FOpen(file_name, "wb");
77 if (file == NULL) { 79 if (file == NULL) {
78 PrintF("Unable to write to snapshot file \"%s\"\n", file_name); 80 PrintF("Unable to write to snapshot file \"%s\"\n", file_name);
79 exit(1); 81 exit(1);
80 } 82 }
81 size_t written = fwrite(payload.begin(), 1, payload.length(), file); 83 size_t written = fwrite(payload.begin(), 1, payload.length(), file);
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 const char* source2 = 664 const char* source2 =
663 "function f() { return g() * 2; }" 665 "function f() { return g() * 2; }"
664 "function g() { return 43; }" 666 "function g() { return 43; }"
665 "/./.test('a')"; 667 "/./.test('a')";
666 668
667 v8::StartupData data1 = v8::V8::CreateSnapshotDataBlob(source1); 669 v8::StartupData data1 = v8::V8::CreateSnapshotDataBlob(source1);
668 v8::StartupData data2 = v8::V8::CreateSnapshotDataBlob(source2); 670 v8::StartupData data2 = v8::V8::CreateSnapshotDataBlob(source2);
669 671
670 v8::Isolate::CreateParams params1; 672 v8::Isolate::CreateParams params1;
671 params1.snapshot_blob = &data1; 673 params1.snapshot_blob = &data1;
674 params1.array_buffer_allocator = CcTest::array_buffer_allocator();
675
672 v8::Isolate* isolate1 = v8::Isolate::New(params1); 676 v8::Isolate* isolate1 = v8::Isolate::New(params1);
673 { 677 {
674 v8::Isolate::Scope i_scope(isolate1); 678 v8::Isolate::Scope i_scope(isolate1);
675 v8::HandleScope h_scope(isolate1); 679 v8::HandleScope h_scope(isolate1);
676 v8::Local<v8::Context> context = v8::Context::New(isolate1); 680 v8::Local<v8::Context> context = v8::Context::New(isolate1);
677 delete[] data1.data; // We can dispose of the snapshot blob now. 681 delete[] data1.data; // We can dispose of the snapshot blob now.
678 v8::Context::Scope c_scope(context); 682 v8::Context::Scope c_scope(context);
679 CHECK_EQ(42, CompileRun("f()")->ToInt32(isolate1)->Int32Value()); 683 CHECK_EQ(42, CompileRun("f()")->ToInt32(isolate1)->Int32Value());
680 CHECK(CompileRun("this.g")->IsUndefined()); 684 CHECK(CompileRun("this.g")->IsUndefined());
681 } 685 }
682 isolate1->Dispose(); 686 isolate1->Dispose();
683 687
684 v8::Isolate::CreateParams params2; 688 v8::Isolate::CreateParams params2;
685 params2.snapshot_blob = &data2; 689 params2.snapshot_blob = &data2;
690 params2.array_buffer_allocator = CcTest::array_buffer_allocator();
686 v8::Isolate* isolate2 = v8::Isolate::New(params2); 691 v8::Isolate* isolate2 = v8::Isolate::New(params2);
687 { 692 {
688 v8::Isolate::Scope i_scope(isolate2); 693 v8::Isolate::Scope i_scope(isolate2);
689 v8::HandleScope h_scope(isolate2); 694 v8::HandleScope h_scope(isolate2);
690 v8::Local<v8::Context> context = v8::Context::New(isolate2); 695 v8::Local<v8::Context> context = v8::Context::New(isolate2);
691 delete[] data2.data; // We can dispose of the snapshot blob now. 696 delete[] data2.data; // We can dispose of the snapshot blob now.
692 v8::Context::Scope c_scope(context); 697 v8::Context::Scope c_scope(context);
693 CHECK_EQ(86, CompileRun("f()")->ToInt32(isolate2)->Int32Value()); 698 CHECK_EQ(86, CompileRun("f()")->ToInt32(isolate2)->Int32Value());
694 CHECK_EQ(43, CompileRun("g()")->ToInt32(isolate2)->Int32Value()); 699 CHECK_EQ(43, CompileRun("g()")->ToInt32(isolate2)->Int32Value());
695 } 700 }
696 isolate2->Dispose(); 701 isolate2->Dispose();
697 } 702 }
698 703
699 704
700 TEST(PerIsolateSnapshotBlobsWithLocker) { 705 TEST(PerIsolateSnapshotBlobsWithLocker) {
701 DisableTurbofan(); 706 DisableTurbofan();
702 v8::Isolate* isolate0 = v8::Isolate::New(); 707 v8::Isolate::CreateParams create_params;
708 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
709 v8::Isolate* isolate0 = v8::Isolate::New(create_params);
703 { 710 {
704 v8::Locker locker(isolate0); 711 v8::Locker locker(isolate0);
705 v8::Isolate::Scope i_scope(isolate0); 712 v8::Isolate::Scope i_scope(isolate0);
706 v8::HandleScope h_scope(isolate0); 713 v8::HandleScope h_scope(isolate0);
707 v8::Local<v8::Context> context = v8::Context::New(isolate0); 714 v8::Local<v8::Context> context = v8::Context::New(isolate0);
708 v8::Context::Scope c_scope(context); 715 v8::Context::Scope c_scope(context);
709 CHECK_EQ(1, CompileRun("Math.cos(0)")->ToInt32(isolate0)->Int32Value()); 716 CHECK_EQ(1, CompileRun("Math.cos(0)")->ToInt32(isolate0)->Int32Value());
710 } 717 }
711 isolate0->Dispose(); 718 isolate0->Dispose();
712 719
713 const char* source1 = "function f() { return 42; }"; 720 const char* source1 = "function f() { return 42; }";
714 721
715 v8::StartupData data1 = v8::V8::CreateSnapshotDataBlob(source1); 722 v8::StartupData data1 = v8::V8::CreateSnapshotDataBlob(source1);
716 723
717 v8::Isolate::CreateParams params1; 724 v8::Isolate::CreateParams params1;
718 params1.snapshot_blob = &data1; 725 params1.snapshot_blob = &data1;
726 params1.array_buffer_allocator = CcTest::array_buffer_allocator();
719 v8::Isolate* isolate1 = v8::Isolate::New(params1); 727 v8::Isolate* isolate1 = v8::Isolate::New(params1);
720 { 728 {
721 v8::Locker locker(isolate1); 729 v8::Locker locker(isolate1);
722 v8::Isolate::Scope i_scope(isolate1); 730 v8::Isolate::Scope i_scope(isolate1);
723 v8::HandleScope h_scope(isolate1); 731 v8::HandleScope h_scope(isolate1);
724 v8::Local<v8::Context> context = v8::Context::New(isolate1); 732 v8::Local<v8::Context> context = v8::Context::New(isolate1);
725 delete[] data1.data; // We can dispose of the snapshot blob now. 733 delete[] data1.data; // We can dispose of the snapshot blob now.
726 v8::Context::Scope c_scope(context); 734 v8::Context::Scope c_scope(context);
727 CHECK_EQ(42, CompileRun("f()")->ToInt32(isolate1)->Int32Value()); 735 CHECK_EQ(42, CompileRun("f()")->ToInt32(isolate1)->Int32Value());
728 } 736 }
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 static void SerializerCodeEventListener(const v8::JitCodeEvent* event) { 1304 static void SerializerCodeEventListener(const v8::JitCodeEvent* event) {
1297 if (event->type == v8::JitCodeEvent::CODE_ADDED && 1305 if (event->type == v8::JitCodeEvent::CODE_ADDED &&
1298 memcmp(event->name.str, "Script:~test", 12) == 0) { 1306 memcmp(event->name.str, "Script:~test", 12) == 0) {
1299 toplevel_test_code_event_found = true; 1307 toplevel_test_code_event_found = true;
1300 } 1308 }
1301 } 1309 }
1302 1310
1303 1311
1304 v8::ScriptCompiler::CachedData* ProduceCache(const char* source) { 1312 v8::ScriptCompiler::CachedData* ProduceCache(const char* source) {
1305 v8::ScriptCompiler::CachedData* cache; 1313 v8::ScriptCompiler::CachedData* cache;
1306 v8::Isolate* isolate1 = v8::Isolate::New(); 1314 v8::Isolate::CreateParams create_params;
1315 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
1316 v8::Isolate* isolate1 = v8::Isolate::New(create_params);
1307 { 1317 {
1308 v8::Isolate::Scope iscope(isolate1); 1318 v8::Isolate::Scope iscope(isolate1);
1309 v8::HandleScope scope(isolate1); 1319 v8::HandleScope scope(isolate1);
1310 v8::Local<v8::Context> context = v8::Context::New(isolate1); 1320 v8::Local<v8::Context> context = v8::Context::New(isolate1);
1311 v8::Context::Scope context_scope(context); 1321 v8::Context::Scope context_scope(context);
1312 1322
1313 v8::Local<v8::String> source_str = v8_str(source); 1323 v8::Local<v8::String> source_str = v8_str(source);
1314 v8::ScriptOrigin origin(v8_str("test")); 1324 v8::ScriptOrigin origin(v8_str("test"));
1315 v8::ScriptCompiler::Source source(source_str, origin); 1325 v8::ScriptCompiler::Source source(source_str, origin);
1316 v8::Local<v8::UnboundScript> script = v8::ScriptCompiler::CompileUnbound( 1326 v8::Local<v8::UnboundScript> script = v8::ScriptCompiler::CompileUnbound(
(...skipping 13 matching lines...) Expand all
1330 return cache; 1340 return cache;
1331 } 1341 }
1332 1342
1333 1343
1334 TEST(SerializeToplevelIsolates) { 1344 TEST(SerializeToplevelIsolates) {
1335 FLAG_serialize_toplevel = true; 1345 FLAG_serialize_toplevel = true;
1336 1346
1337 const char* source = "function f() { return 'abc'; }; f() + 'def'"; 1347 const char* source = "function f() { return 'abc'; }; f() + 'def'";
1338 v8::ScriptCompiler::CachedData* cache = ProduceCache(source); 1348 v8::ScriptCompiler::CachedData* cache = ProduceCache(source);
1339 1349
1340 v8::Isolate* isolate2 = v8::Isolate::New(); 1350 v8::Isolate::CreateParams create_params;
1351 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
1352 v8::Isolate* isolate2 = v8::Isolate::New(create_params);
1341 isolate2->SetJitCodeEventHandler(v8::kJitCodeEventDefault, 1353 isolate2->SetJitCodeEventHandler(v8::kJitCodeEventDefault,
1342 SerializerCodeEventListener); 1354 SerializerCodeEventListener);
1343 toplevel_test_code_event_found = false; 1355 toplevel_test_code_event_found = false;
1344 { 1356 {
1345 v8::Isolate::Scope iscope(isolate2); 1357 v8::Isolate::Scope iscope(isolate2);
1346 v8::HandleScope scope(isolate2); 1358 v8::HandleScope scope(isolate2);
1347 v8::Local<v8::Context> context = v8::Context::New(isolate2); 1359 v8::Local<v8::Context> context = v8::Context::New(isolate2);
1348 v8::Context::Scope context_scope(context); 1360 v8::Context::Scope context_scope(context);
1349 1361
1350 v8::Local<v8::String> source_str = v8_str(source); 1362 v8::Local<v8::String> source_str = v8_str(source);
(...skipping 13 matching lines...) Expand all
1364 isolate2->Dispose(); 1376 isolate2->Dispose();
1365 } 1377 }
1366 1378
1367 1379
1368 TEST(SerializeToplevelFlagChange) { 1380 TEST(SerializeToplevelFlagChange) {
1369 FLAG_serialize_toplevel = true; 1381 FLAG_serialize_toplevel = true;
1370 1382
1371 const char* source = "function f() { return 'abc'; }; f() + 'def'"; 1383 const char* source = "function f() { return 'abc'; }; f() + 'def'";
1372 v8::ScriptCompiler::CachedData* cache = ProduceCache(source); 1384 v8::ScriptCompiler::CachedData* cache = ProduceCache(source);
1373 1385
1374 v8::Isolate* isolate2 = v8::Isolate::New(); 1386 v8::Isolate::CreateParams create_params;
1387 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
1388 v8::Isolate* isolate2 = v8::Isolate::New(create_params);
1375 1389
1376 FLAG_allow_natives_syntax = true; // Flag change should trigger cache reject. 1390 FLAG_allow_natives_syntax = true; // Flag change should trigger cache reject.
1377 FlagList::EnforceFlagImplications(); 1391 FlagList::EnforceFlagImplications();
1378 { 1392 {
1379 v8::Isolate::Scope iscope(isolate2); 1393 v8::Isolate::Scope iscope(isolate2);
1380 v8::HandleScope scope(isolate2); 1394 v8::HandleScope scope(isolate2);
1381 v8::Local<v8::Context> context = v8::Context::New(isolate2); 1395 v8::Local<v8::Context> context = v8::Context::New(isolate2);
1382 v8::Context::Scope context_scope(context); 1396 v8::Context::Scope context_scope(context);
1383 1397
1384 v8::Local<v8::String> source_str = v8_str(source); 1398 v8::Local<v8::String> source_str = v8_str(source);
1385 v8::ScriptOrigin origin(v8_str("test")); 1399 v8::ScriptOrigin origin(v8_str("test"));
1386 v8::ScriptCompiler::Source source(source_str, origin, cache); 1400 v8::ScriptCompiler::Source source(source_str, origin, cache);
1387 v8::ScriptCompiler::CompileUnbound(isolate2, &source, 1401 v8::ScriptCompiler::CompileUnbound(isolate2, &source,
1388 v8::ScriptCompiler::kConsumeCodeCache); 1402 v8::ScriptCompiler::kConsumeCodeCache);
1389 CHECK(cache->rejected); 1403 CHECK(cache->rejected);
1390 } 1404 }
1391 isolate2->Dispose(); 1405 isolate2->Dispose();
1392 } 1406 }
1393 1407
1394 1408
1395 TEST(SerializeToplevelBitFlip) { 1409 TEST(SerializeToplevelBitFlip) {
1396 FLAG_serialize_toplevel = true; 1410 FLAG_serialize_toplevel = true;
1397 1411
1398 const char* source = "function f() { return 'abc'; }; f() + 'def'"; 1412 const char* source = "function f() { return 'abc'; }; f() + 'def'";
1399 v8::ScriptCompiler::CachedData* cache = ProduceCache(source); 1413 v8::ScriptCompiler::CachedData* cache = ProduceCache(source);
1400 1414
1401 // Random bit flip. 1415 // Random bit flip.
1402 const_cast<uint8_t*>(cache->data)[337] ^= 0x40; 1416 const_cast<uint8_t*>(cache->data)[337] ^= 0x40;
1403 1417
1404 v8::Isolate* isolate2 = v8::Isolate::New(); 1418 v8::Isolate::CreateParams create_params;
1419 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
1420 v8::Isolate* isolate2 = v8::Isolate::New(create_params);
1405 { 1421 {
1406 v8::Isolate::Scope iscope(isolate2); 1422 v8::Isolate::Scope iscope(isolate2);
1407 v8::HandleScope scope(isolate2); 1423 v8::HandleScope scope(isolate2);
1408 v8::Local<v8::Context> context = v8::Context::New(isolate2); 1424 v8::Local<v8::Context> context = v8::Context::New(isolate2);
1409 v8::Context::Scope context_scope(context); 1425 v8::Context::Scope context_scope(context);
1410 1426
1411 v8::Local<v8::String> source_str = v8_str(source); 1427 v8::Local<v8::String> source_str = v8_str(source);
1412 v8::ScriptOrigin origin(v8_str("test")); 1428 v8::ScriptOrigin origin(v8_str("test"));
1413 v8::ScriptCompiler::Source source(source_str, origin, cache); 1429 v8::ScriptCompiler::Source source(source_str, origin, cache);
1414 v8::ScriptCompiler::CompileUnbound(isolate2, &source, 1430 v8::ScriptCompiler::CompileUnbound(isolate2, &source,
1415 v8::ScriptCompiler::kConsumeCodeCache); 1431 v8::ScriptCompiler::kConsumeCodeCache);
1416 CHECK(cache->rejected); 1432 CHECK(cache->rejected);
1417 } 1433 }
1418 isolate2->Dispose(); 1434 isolate2->Dispose();
1419 } 1435 }
1420 1436
1421 1437
1422 TEST(SerializeWithHarmonyScoping) { 1438 TEST(SerializeWithHarmonyScoping) {
1423 FLAG_serialize_toplevel = true; 1439 FLAG_serialize_toplevel = true;
1424 1440
1425 const char* source1 = "'use strict'; let x = 'X'"; 1441 const char* source1 = "'use strict'; let x = 'X'";
1426 const char* source2 = "'use strict'; let y = 'Y'"; 1442 const char* source2 = "'use strict'; let y = 'Y'";
1427 const char* source3 = "'use strict'; x + y"; 1443 const char* source3 = "'use strict'; x + y";
1428 1444
1429 v8::ScriptCompiler::CachedData* cache; 1445 v8::ScriptCompiler::CachedData* cache;
1430 1446
1431 v8::Isolate* isolate1 = v8::Isolate::New(); 1447 v8::Isolate::CreateParams create_params;
1448 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
1449 v8::Isolate* isolate1 = v8::Isolate::New(create_params);
1432 { 1450 {
1433 v8::Isolate::Scope iscope(isolate1); 1451 v8::Isolate::Scope iscope(isolate1);
1434 v8::HandleScope scope(isolate1); 1452 v8::HandleScope scope(isolate1);
1435 v8::Local<v8::Context> context = v8::Context::New(isolate1); 1453 v8::Local<v8::Context> context = v8::Context::New(isolate1);
1436 v8::Context::Scope context_scope(context); 1454 v8::Context::Scope context_scope(context);
1437 1455
1438 CompileRun(source1); 1456 CompileRun(source1);
1439 CompileRun(source2); 1457 CompileRun(source2);
1440 1458
1441 v8::Local<v8::String> source_str = v8_str(source3); 1459 v8::Local<v8::String> source_str = v8_str(source3);
1442 v8::ScriptOrigin origin(v8_str("test")); 1460 v8::ScriptOrigin origin(v8_str("test"));
1443 v8::ScriptCompiler::Source source(source_str, origin); 1461 v8::ScriptCompiler::Source source(source_str, origin);
1444 v8::Local<v8::UnboundScript> script = v8::ScriptCompiler::CompileUnbound( 1462 v8::Local<v8::UnboundScript> script = v8::ScriptCompiler::CompileUnbound(
1445 isolate1, &source, v8::ScriptCompiler::kProduceCodeCache); 1463 isolate1, &source, v8::ScriptCompiler::kProduceCodeCache);
1446 const v8::ScriptCompiler::CachedData* data = source.GetCachedData(); 1464 const v8::ScriptCompiler::CachedData* data = source.GetCachedData();
1447 CHECK(data); 1465 CHECK(data);
1448 // Persist cached data. 1466 // Persist cached data.
1449 uint8_t* buffer = NewArray<uint8_t>(data->length); 1467 uint8_t* buffer = NewArray<uint8_t>(data->length);
1450 MemCopy(buffer, data->data, data->length); 1468 MemCopy(buffer, data->data, data->length);
1451 cache = new v8::ScriptCompiler::CachedData( 1469 cache = new v8::ScriptCompiler::CachedData(
1452 buffer, data->length, v8::ScriptCompiler::CachedData::BufferOwned); 1470 buffer, data->length, v8::ScriptCompiler::CachedData::BufferOwned);
1453 1471
1454 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); 1472 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run();
1455 CHECK(result->ToString(isolate1)->Equals(v8_str("XY"))); 1473 CHECK(result->ToString(isolate1)->Equals(v8_str("XY")));
1456 } 1474 }
1457 isolate1->Dispose(); 1475 isolate1->Dispose();
1458 1476
1459 v8::Isolate* isolate2 = v8::Isolate::New(); 1477 v8::Isolate* isolate2 = v8::Isolate::New(create_params);
1460 { 1478 {
1461 v8::Isolate::Scope iscope(isolate2); 1479 v8::Isolate::Scope iscope(isolate2);
1462 v8::HandleScope scope(isolate2); 1480 v8::HandleScope scope(isolate2);
1463 v8::Local<v8::Context> context = v8::Context::New(isolate2); 1481 v8::Local<v8::Context> context = v8::Context::New(isolate2);
1464 v8::Context::Scope context_scope(context); 1482 v8::Context::Scope context_scope(context);
1465 1483
1466 // Reverse order of prior running scripts. 1484 // Reverse order of prior running scripts.
1467 CompileRun(source2); 1485 CompileRun(source2);
1468 CompileRun(source1); 1486 CompileRun(source1);
1469 1487
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1512 " }" 1530 " }"
1513 " return { foo: foo };" 1531 " return { foo: foo };"
1514 "})(this, {}, undefined).foo;" 1532 "})(this, {}, undefined).foo;"
1515 "foo(1);"; 1533 "foo(1);";
1516 1534
1517 v8::StartupData data = v8::V8::CreateSnapshotDataBlob(source); 1535 v8::StartupData data = v8::V8::CreateSnapshotDataBlob(source);
1518 CHECK(data.data); 1536 CHECK(data.data);
1519 1537
1520 v8::Isolate::CreateParams params; 1538 v8::Isolate::CreateParams params;
1521 params.snapshot_blob = &data; 1539 params.snapshot_blob = &data;
1540 params.array_buffer_allocator = CcTest::array_buffer_allocator();
1522 v8::Isolate* isolate = v8::Isolate::New(params); 1541 v8::Isolate* isolate = v8::Isolate::New(params);
1523 { 1542 {
1524 v8::Isolate::Scope i_scope(isolate); 1543 v8::Isolate::Scope i_scope(isolate);
1525 v8::HandleScope h_scope(isolate); 1544 v8::HandleScope h_scope(isolate);
1526 v8::Local<v8::Context> context = v8::Context::New(isolate); 1545 v8::Local<v8::Context> context = v8::Context::New(isolate);
1527 delete[] data.data; // We can dispose of the snapshot blob now. 1546 delete[] data.data; // We can dispose of the snapshot blob now.
1528 v8::Context::Scope c_scope(context); 1547 v8::Context::Scope c_scope(context);
1529 v8::Handle<v8::Function> foo = 1548 v8::Handle<v8::Function> foo =
1530 v8::Handle<v8::Function>::Cast(CompileRun("foo")); 1549 v8::Handle<v8::Function>::Cast(CompileRun("foo"));
1531 1550
(...skipping 18 matching lines...) Expand all
1550 isolate->Dispose(); 1569 isolate->Dispose();
1551 } 1570 }
1552 1571
1553 1572
1554 TEST(SerializationMemoryStats) { 1573 TEST(SerializationMemoryStats) {
1555 FLAG_profile_deserialization = true; 1574 FLAG_profile_deserialization = true;
1556 FLAG_always_opt = false; 1575 FLAG_always_opt = false;
1557 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); 1576 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob();
1558 delete[] blob.data; 1577 delete[] blob.data;
1559 } 1578 }
OLDNEW
« no previous file with comments | « test/cctest/test-random-number-generator.cc ('k') | test/cctest/test-spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698