OLD | NEW |
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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) { | 340 DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) { |
341 if (!Snapshot::HaveASnapshotToStartFrom()) { | 341 if (!Snapshot::HaveASnapshotToStartFrom()) { |
342 v8::Isolate* isolate = CcTest::isolate(); | 342 v8::Isolate* isolate = CcTest::isolate(); |
343 v8::HandleScope scope(isolate); | 343 v8::HandleScope scope(isolate); |
344 Deserialize(); | 344 Deserialize(); |
345 | 345 |
346 v8::Local<v8::Context> env = v8::Context::New(isolate); | 346 v8::Local<v8::Context> env = v8::Context::New(isolate); |
347 env->Enter(); | 347 env->Enter(); |
348 | 348 |
349 const char* c_source = "\"1234\".length"; | 349 const char* c_source = "\"1234\".length"; |
350 v8::Local<v8::String> source = v8::String::New(c_source); | 350 v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, c_source); |
351 v8::Local<v8::Script> script = v8::Script::Compile(source); | 351 v8::Local<v8::Script> script = v8::Script::Compile(source); |
352 CHECK_EQ(4, script->Run()->Int32Value()); | 352 CHECK_EQ(4, script->Run()->Int32Value()); |
353 } | 353 } |
354 } | 354 } |
355 | 355 |
356 | 356 |
357 DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2, | 357 DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2, |
358 SerializeTwice) { | 358 SerializeTwice) { |
359 if (!Snapshot::HaveASnapshotToStartFrom()) { | 359 if (!Snapshot::HaveASnapshotToStartFrom()) { |
360 v8::Isolate* isolate = CcTest::isolate(); | 360 v8::Isolate* isolate = CcTest::isolate(); |
361 v8::HandleScope scope(isolate); | 361 v8::HandleScope scope(isolate); |
362 Deserialize(); | 362 Deserialize(); |
363 | 363 |
364 v8::Local<v8::Context> env = v8::Context::New(isolate); | 364 v8::Local<v8::Context> env = v8::Context::New(isolate); |
365 env->Enter(); | 365 env->Enter(); |
366 | 366 |
367 const char* c_source = "\"1234\".length"; | 367 const char* c_source = "\"1234\".length"; |
368 v8::Local<v8::String> source = v8::String::New(c_source); | 368 v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, c_source); |
369 v8::Local<v8::Script> script = v8::Script::Compile(source); | 369 v8::Local<v8::Script> script = v8::Script::Compile(source); |
370 CHECK_EQ(4, script->Run()->Int32Value()); | 370 CHECK_EQ(4, script->Run()->Int32Value()); |
371 } | 371 } |
372 } | 372 } |
373 | 373 |
374 | 374 |
375 TEST(PartialSerialization) { | 375 TEST(PartialSerialization) { |
376 if (!Snapshot::HaveASnapshotToStartFrom()) { | 376 if (!Snapshot::HaveASnapshotToStartFrom()) { |
377 Isolate* isolate = CcTest::i_isolate(); | 377 Isolate* isolate = CcTest::i_isolate(); |
378 Serializer::Enable(isolate); | 378 Serializer::Enable(isolate); |
(...skipping 16 matching lines...) Expand all Loading... |
395 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { | 395 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { |
396 isolate->bootstrapper()->NativesSourceLookup(i); | 396 isolate->bootstrapper()->NativesSourceLookup(i); |
397 } | 397 } |
398 } | 398 } |
399 heap->CollectAllGarbage(Heap::kNoGCFlags); | 399 heap->CollectAllGarbage(Heap::kNoGCFlags); |
400 heap->CollectAllGarbage(Heap::kNoGCFlags); | 400 heap->CollectAllGarbage(Heap::kNoGCFlags); |
401 | 401 |
402 Object* raw_foo; | 402 Object* raw_foo; |
403 { | 403 { |
404 v8::HandleScope handle_scope(v8_isolate); | 404 v8::HandleScope handle_scope(v8_isolate); |
405 v8::Local<v8::String> foo = v8::String::New("foo"); | 405 v8::Local<v8::String> foo = v8::String::NewFromUtf8(v8_isolate, "foo"); |
406 ASSERT(!foo.IsEmpty()); | 406 ASSERT(!foo.IsEmpty()); |
407 raw_foo = *(v8::Utils::OpenHandle(*foo)); | 407 raw_foo = *(v8::Utils::OpenHandle(*foo)); |
408 } | 408 } |
409 | 409 |
410 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; | 410 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; |
411 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); | 411 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); |
412 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); | 412 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); |
413 | 413 |
414 { | 414 { |
415 v8::HandleScope handle_scope(v8_isolate); | 415 v8::HandleScope handle_scope(v8_isolate); |
416 v8::Local<v8::Context>::New(v8_isolate, env)->Exit(); | 416 v8::Local<v8::Context>::New(v8_isolate, env)->Exit(); |
417 } | 417 } |
418 env.Dispose(); | 418 env.Reset(); |
419 | 419 |
420 FileByteSink startup_sink(startup_name.start()); | 420 FileByteSink startup_sink(startup_name.start()); |
421 StartupSerializer startup_serializer(isolate, &startup_sink); | 421 StartupSerializer startup_serializer(isolate, &startup_sink); |
422 startup_serializer.SerializeStrongReferences(); | 422 startup_serializer.SerializeStrongReferences(); |
423 | 423 |
424 FileByteSink partial_sink(FLAG_testing_serialization_file); | 424 FileByteSink partial_sink(FLAG_testing_serialization_file); |
425 PartialSerializer p_ser(isolate, &startup_serializer, &partial_sink); | 425 PartialSerializer p_ser(isolate, &startup_serializer, &partial_sink); |
426 p_ser.Serialize(&raw_foo); | 426 p_ser.Serialize(&raw_foo); |
427 startup_serializer.SerializeWeakReferences(); | 427 startup_serializer.SerializeWeakReferences(); |
428 | 428 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); | 555 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); |
556 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); | 556 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); |
557 | 557 |
558 { | 558 { |
559 v8::HandleScope handle_scope(v8_isolate); | 559 v8::HandleScope handle_scope(v8_isolate); |
560 v8::Local<v8::Context>::New(v8_isolate, env)->Exit(); | 560 v8::Local<v8::Context>::New(v8_isolate, env)->Exit(); |
561 } | 561 } |
562 | 562 |
563 i::Object* raw_context = *v8::Utils::OpenPersistent(env); | 563 i::Object* raw_context = *v8::Utils::OpenPersistent(env); |
564 | 564 |
565 env.Dispose(); | 565 env.Reset(); |
566 | 566 |
567 FileByteSink startup_sink(startup_name.start()); | 567 FileByteSink startup_sink(startup_name.start()); |
568 StartupSerializer startup_serializer(isolate, &startup_sink); | 568 StartupSerializer startup_serializer(isolate, &startup_sink); |
569 startup_serializer.SerializeStrongReferences(); | 569 startup_serializer.SerializeStrongReferences(); |
570 | 570 |
571 FileByteSink partial_sink(FLAG_testing_serialization_file); | 571 FileByteSink partial_sink(FLAG_testing_serialization_file); |
572 PartialSerializer p_ser(isolate, &startup_serializer, &partial_sink); | 572 PartialSerializer p_ser(isolate, &startup_serializer, &partial_sink); |
573 p_ser.Serialize(&raw_context); | 573 p_ser.Serialize(&raw_context); |
574 startup_serializer.SerializeWeakReferences(); | 574 startup_serializer.SerializeWeakReferences(); |
575 | 575 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 TEST(TestThatAlwaysFails) { | 642 TEST(TestThatAlwaysFails) { |
643 bool ArtificialFailure = false; | 643 bool ArtificialFailure = false; |
644 CHECK(ArtificialFailure); | 644 CHECK(ArtificialFailure); |
645 } | 645 } |
646 | 646 |
647 | 647 |
648 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { | 648 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { |
649 bool ArtificialFailure2 = false; | 649 bool ArtificialFailure2 = false; |
650 CHECK(ArtificialFailure2); | 650 CHECK(ArtificialFailure2); |
651 } | 651 } |
OLD | NEW |