| OLD | NEW |
| 1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 LocalContext env; | 387 LocalContext env; |
| 388 TestResource* resource = new TestResource(two_byte_source); | 388 TestResource* resource = new TestResource(two_byte_source); |
| 389 Local<String> source = String::NewExternal(resource); | 389 Local<String> source = String::NewExternal(resource); |
| 390 Local<Script> script = Script::Compile(source); | 390 Local<Script> script = Script::Compile(source); |
| 391 Local<Value> value = script->Run(); | 391 Local<Value> value = script->Run(); |
| 392 CHECK(value->IsNumber()); | 392 CHECK(value->IsNumber()); |
| 393 CHECK_EQ(7, value->Int32Value()); | 393 CHECK_EQ(7, value->Int32Value()); |
| 394 CHECK(source->IsExternal()); | 394 CHECK(source->IsExternal()); |
| 395 CHECK_EQ(resource, | 395 CHECK_EQ(resource, |
| 396 static_cast<TestResource*>(source->GetExternalStringResource())); | 396 static_cast<TestResource*>(source->GetExternalStringResource())); |
| 397 i::Heap::CollectAllGarbage(false); | 397 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 398 CHECK_EQ(0, TestResource::dispose_count); | 398 CHECK_EQ(0, TestResource::dispose_count); |
| 399 } | 399 } |
| 400 i::CompilationCache::Clear(); | 400 i::CompilationCache::Clear(); |
| 401 i::Heap::CollectAllGarbage(false); | 401 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 402 CHECK_EQ(1, TestResource::dispose_count); | 402 CHECK_EQ(1, TestResource::dispose_count); |
| 403 } | 403 } |
| 404 | 404 |
| 405 | 405 |
| 406 THREADED_TEST(ScriptUsingAsciiStringResource) { | 406 THREADED_TEST(ScriptUsingAsciiStringResource) { |
| 407 TestAsciiResource::dispose_count = 0; | 407 TestAsciiResource::dispose_count = 0; |
| 408 const char* c_source = "1 + 2 * 3"; | 408 const char* c_source = "1 + 2 * 3"; |
| 409 { | 409 { |
| 410 v8::HandleScope scope; | 410 v8::HandleScope scope; |
| 411 LocalContext env; | 411 LocalContext env; |
| 412 Local<String> source = | 412 Local<String> source = |
| 413 String::NewExternal(new TestAsciiResource(i::StrDup(c_source))); | 413 String::NewExternal(new TestAsciiResource(i::StrDup(c_source))); |
| 414 Local<Script> script = Script::Compile(source); | 414 Local<Script> script = Script::Compile(source); |
| 415 Local<Value> value = script->Run(); | 415 Local<Value> value = script->Run(); |
| 416 CHECK(value->IsNumber()); | 416 CHECK(value->IsNumber()); |
| 417 CHECK_EQ(7, value->Int32Value()); | 417 CHECK_EQ(7, value->Int32Value()); |
| 418 i::Heap::CollectAllGarbage(false); | 418 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 419 CHECK_EQ(0, TestAsciiResource::dispose_count); | 419 CHECK_EQ(0, TestAsciiResource::dispose_count); |
| 420 } | 420 } |
| 421 i::CompilationCache::Clear(); | 421 i::CompilationCache::Clear(); |
| 422 i::Heap::CollectAllGarbage(false); | 422 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 423 CHECK_EQ(1, TestAsciiResource::dispose_count); | 423 CHECK_EQ(1, TestAsciiResource::dispose_count); |
| 424 } | 424 } |
| 425 | 425 |
| 426 | 426 |
| 427 THREADED_TEST(ScriptMakingExternalString) { | 427 THREADED_TEST(ScriptMakingExternalString) { |
| 428 TestResource::dispose_count = 0; | 428 TestResource::dispose_count = 0; |
| 429 uint16_t* two_byte_source = AsciiToTwoByteString("1 + 2 * 3"); | 429 uint16_t* two_byte_source = AsciiToTwoByteString("1 + 2 * 3"); |
| 430 { | 430 { |
| 431 v8::HandleScope scope; | 431 v8::HandleScope scope; |
| 432 LocalContext env; | 432 LocalContext env; |
| 433 Local<String> source = String::New(two_byte_source); | 433 Local<String> source = String::New(two_byte_source); |
| 434 // Trigger GCs so that the newly allocated string moves to old gen. | 434 // Trigger GCs so that the newly allocated string moves to old gen. |
| 435 i::Heap::CollectGarbage(i::NEW_SPACE); // in survivor space now | 435 i::Heap::CollectGarbage(i::NEW_SPACE); // in survivor space now |
| 436 i::Heap::CollectGarbage(i::NEW_SPACE); // in old gen now | 436 i::Heap::CollectGarbage(i::NEW_SPACE); // in old gen now |
| 437 bool success = source->MakeExternal(new TestResource(two_byte_source)); | 437 bool success = source->MakeExternal(new TestResource(two_byte_source)); |
| 438 CHECK(success); | 438 CHECK(success); |
| 439 Local<Script> script = Script::Compile(source); | 439 Local<Script> script = Script::Compile(source); |
| 440 Local<Value> value = script->Run(); | 440 Local<Value> value = script->Run(); |
| 441 CHECK(value->IsNumber()); | 441 CHECK(value->IsNumber()); |
| 442 CHECK_EQ(7, value->Int32Value()); | 442 CHECK_EQ(7, value->Int32Value()); |
| 443 i::Heap::CollectAllGarbage(false); | 443 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 444 CHECK_EQ(0, TestResource::dispose_count); | 444 CHECK_EQ(0, TestResource::dispose_count); |
| 445 } | 445 } |
| 446 i::CompilationCache::Clear(); | 446 i::CompilationCache::Clear(); |
| 447 i::Heap::CollectAllGarbage(false); | 447 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 448 CHECK_EQ(1, TestResource::dispose_count); | 448 CHECK_EQ(1, TestResource::dispose_count); |
| 449 } | 449 } |
| 450 | 450 |
| 451 | 451 |
| 452 THREADED_TEST(ScriptMakingExternalAsciiString) { | 452 THREADED_TEST(ScriptMakingExternalAsciiString) { |
| 453 TestAsciiResource::dispose_count = 0; | 453 TestAsciiResource::dispose_count = 0; |
| 454 const char* c_source = "1 + 2 * 3"; | 454 const char* c_source = "1 + 2 * 3"; |
| 455 { | 455 { |
| 456 v8::HandleScope scope; | 456 v8::HandleScope scope; |
| 457 LocalContext env; | 457 LocalContext env; |
| 458 Local<String> source = v8_str(c_source); | 458 Local<String> source = v8_str(c_source); |
| 459 // Trigger GCs so that the newly allocated string moves to old gen. | 459 // Trigger GCs so that the newly allocated string moves to old gen. |
| 460 i::Heap::CollectGarbage(i::NEW_SPACE); // in survivor space now | 460 i::Heap::CollectGarbage(i::NEW_SPACE); // in survivor space now |
| 461 i::Heap::CollectGarbage(i::NEW_SPACE); // in old gen now | 461 i::Heap::CollectGarbage(i::NEW_SPACE); // in old gen now |
| 462 bool success = source->MakeExternal( | 462 bool success = source->MakeExternal( |
| 463 new TestAsciiResource(i::StrDup(c_source))); | 463 new TestAsciiResource(i::StrDup(c_source))); |
| 464 CHECK(success); | 464 CHECK(success); |
| 465 Local<Script> script = Script::Compile(source); | 465 Local<Script> script = Script::Compile(source); |
| 466 Local<Value> value = script->Run(); | 466 Local<Value> value = script->Run(); |
| 467 CHECK(value->IsNumber()); | 467 CHECK(value->IsNumber()); |
| 468 CHECK_EQ(7, value->Int32Value()); | 468 CHECK_EQ(7, value->Int32Value()); |
| 469 i::Heap::CollectAllGarbage(false); | 469 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 470 CHECK_EQ(0, TestAsciiResource::dispose_count); | 470 CHECK_EQ(0, TestAsciiResource::dispose_count); |
| 471 } | 471 } |
| 472 i::CompilationCache::Clear(); | 472 i::CompilationCache::Clear(); |
| 473 i::Heap::CollectAllGarbage(false); | 473 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 474 CHECK_EQ(1, TestAsciiResource::dispose_count); | 474 CHECK_EQ(1, TestAsciiResource::dispose_count); |
| 475 } | 475 } |
| 476 | 476 |
| 477 | 477 |
| 478 TEST(MakingExternalStringConditions) { | 478 TEST(MakingExternalStringConditions) { |
| 479 v8::HandleScope scope; | 479 v8::HandleScope scope; |
| 480 LocalContext env; | 480 LocalContext env; |
| 481 | 481 |
| 482 // Free some space in the new space so that we can check freshness. | 482 // Free some space in the new space so that we can check freshness. |
| 483 i::Heap::CollectGarbage(i::NEW_SPACE); | 483 i::Heap::CollectGarbage(i::NEW_SPACE); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); | 564 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); |
| 565 Local<String> string = | 565 Local<String> string = |
| 566 String::NewExternal(new TestResource(two_byte_string)); | 566 String::NewExternal(new TestResource(two_byte_string)); |
| 567 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); | 567 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); |
| 568 // Trigger GCs so that the newly allocated string moves to old gen. | 568 // Trigger GCs so that the newly allocated string moves to old gen. |
| 569 i::Heap::CollectGarbage(i::NEW_SPACE); // in survivor space now | 569 i::Heap::CollectGarbage(i::NEW_SPACE); // in survivor space now |
| 570 i::Heap::CollectGarbage(i::NEW_SPACE); // in old gen now | 570 i::Heap::CollectGarbage(i::NEW_SPACE); // in old gen now |
| 571 i::Handle<i::String> isymbol = i::Factory::SymbolFromString(istring); | 571 i::Handle<i::String> isymbol = i::Factory::SymbolFromString(istring); |
| 572 CHECK(isymbol->IsSymbol()); | 572 CHECK(isymbol->IsSymbol()); |
| 573 } | 573 } |
| 574 i::Heap::CollectAllGarbage(false); | 574 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 575 i::Heap::CollectAllGarbage(false); | 575 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 576 } | 576 } |
| 577 | 577 |
| 578 | 578 |
| 579 THREADED_TEST(UsingExternalAsciiString) { | 579 THREADED_TEST(UsingExternalAsciiString) { |
| 580 { | 580 { |
| 581 v8::HandleScope scope; | 581 v8::HandleScope scope; |
| 582 const char* one_byte_string = "test string"; | 582 const char* one_byte_string = "test string"; |
| 583 Local<String> string = String::NewExternal( | 583 Local<String> string = String::NewExternal( |
| 584 new TestAsciiResource(i::StrDup(one_byte_string))); | 584 new TestAsciiResource(i::StrDup(one_byte_string))); |
| 585 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); | 585 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); |
| 586 // Trigger GCs so that the newly allocated string moves to old gen. | 586 // Trigger GCs so that the newly allocated string moves to old gen. |
| 587 i::Heap::CollectGarbage(i::NEW_SPACE); // in survivor space now | 587 i::Heap::CollectGarbage(i::NEW_SPACE); // in survivor space now |
| 588 i::Heap::CollectGarbage(i::NEW_SPACE); // in old gen now | 588 i::Heap::CollectGarbage(i::NEW_SPACE); // in old gen now |
| 589 i::Handle<i::String> isymbol = i::Factory::SymbolFromString(istring); | 589 i::Handle<i::String> isymbol = i::Factory::SymbolFromString(istring); |
| 590 CHECK(isymbol->IsSymbol()); | 590 CHECK(isymbol->IsSymbol()); |
| 591 } | 591 } |
| 592 i::Heap::CollectAllGarbage(false); | 592 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 593 i::Heap::CollectAllGarbage(false); | 593 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 594 } | 594 } |
| 595 | 595 |
| 596 | 596 |
| 597 THREADED_TEST(ScavengeExternalString) { | 597 THREADED_TEST(ScavengeExternalString) { |
| 598 TestResource::dispose_count = 0; | 598 TestResource::dispose_count = 0; |
| 599 bool in_new_space = false; | 599 bool in_new_space = false; |
| 600 { | 600 { |
| 601 v8::HandleScope scope; | 601 v8::HandleScope scope; |
| 602 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); | 602 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); |
| 603 Local<String> string = | 603 Local<String> string = |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 TestAsciiResourceWithDisposeControl::dispose_calls = 0; | 660 TestAsciiResourceWithDisposeControl::dispose_calls = 0; |
| 661 TestAsciiResourceWithDisposeControl res_stack(i::StrDup(c_source), false); | 661 TestAsciiResourceWithDisposeControl res_stack(i::StrDup(c_source), false); |
| 662 { | 662 { |
| 663 v8::HandleScope scope; | 663 v8::HandleScope scope; |
| 664 LocalContext env; | 664 LocalContext env; |
| 665 Local<String> source = String::NewExternal(&res_stack); | 665 Local<String> source = String::NewExternal(&res_stack); |
| 666 Local<Script> script = Script::Compile(source); | 666 Local<Script> script = Script::Compile(source); |
| 667 Local<Value> value = script->Run(); | 667 Local<Value> value = script->Run(); |
| 668 CHECK(value->IsNumber()); | 668 CHECK(value->IsNumber()); |
| 669 CHECK_EQ(7, value->Int32Value()); | 669 CHECK_EQ(7, value->Int32Value()); |
| 670 i::Heap::CollectAllGarbage(false); | 670 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 671 CHECK_EQ(0, TestAsciiResource::dispose_count); | 671 CHECK_EQ(0, TestAsciiResource::dispose_count); |
| 672 } | 672 } |
| 673 i::CompilationCache::Clear(); | 673 i::CompilationCache::Clear(); |
| 674 i::Heap::CollectAllGarbage(false); | 674 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 675 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); | 675 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); |
| 676 CHECK_EQ(0, TestAsciiResource::dispose_count); | 676 CHECK_EQ(0, TestAsciiResource::dispose_count); |
| 677 | 677 |
| 678 // Use a heap allocated external string resource allocated object. | 678 // Use a heap allocated external string resource allocated object. |
| 679 TestAsciiResource::dispose_count = 0; | 679 TestAsciiResource::dispose_count = 0; |
| 680 TestAsciiResourceWithDisposeControl::dispose_calls = 0; | 680 TestAsciiResourceWithDisposeControl::dispose_calls = 0; |
| 681 TestAsciiResource* res_heap = | 681 TestAsciiResource* res_heap = |
| 682 new TestAsciiResourceWithDisposeControl(i::StrDup(c_source), true); | 682 new TestAsciiResourceWithDisposeControl(i::StrDup(c_source), true); |
| 683 { | 683 { |
| 684 v8::HandleScope scope; | 684 v8::HandleScope scope; |
| 685 LocalContext env; | 685 LocalContext env; |
| 686 Local<String> source = String::NewExternal(res_heap); | 686 Local<String> source = String::NewExternal(res_heap); |
| 687 Local<Script> script = Script::Compile(source); | 687 Local<Script> script = Script::Compile(source); |
| 688 Local<Value> value = script->Run(); | 688 Local<Value> value = script->Run(); |
| 689 CHECK(value->IsNumber()); | 689 CHECK(value->IsNumber()); |
| 690 CHECK_EQ(7, value->Int32Value()); | 690 CHECK_EQ(7, value->Int32Value()); |
| 691 i::Heap::CollectAllGarbage(false); | 691 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 692 CHECK_EQ(0, TestAsciiResource::dispose_count); | 692 CHECK_EQ(0, TestAsciiResource::dispose_count); |
| 693 } | 693 } |
| 694 i::CompilationCache::Clear(); | 694 i::CompilationCache::Clear(); |
| 695 i::Heap::CollectAllGarbage(false); | 695 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 696 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); | 696 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); |
| 697 CHECK_EQ(1, TestAsciiResource::dispose_count); | 697 CHECK_EQ(1, TestAsciiResource::dispose_count); |
| 698 } | 698 } |
| 699 | 699 |
| 700 | 700 |
| 701 THREADED_TEST(StringConcat) { | 701 THREADED_TEST(StringConcat) { |
| 702 { | 702 { |
| 703 v8::HandleScope scope; | 703 v8::HandleScope scope; |
| 704 LocalContext env; | 704 LocalContext env; |
| 705 const char* one_byte_string_1 = "function a_times_t"; | 705 const char* one_byte_string_1 = "function a_times_t"; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 732 source = String::Concat(source, right); | 732 source = String::Concat(source, right); |
| 733 right = String::NewExternal( | 733 right = String::NewExternal( |
| 734 new TestResource(AsciiToTwoByteString(two_byte_extern_2))); | 734 new TestResource(AsciiToTwoByteString(two_byte_extern_2))); |
| 735 source = String::Concat(source, right); | 735 source = String::Concat(source, right); |
| 736 Local<Script> script = Script::Compile(source); | 736 Local<Script> script = Script::Compile(source); |
| 737 Local<Value> value = script->Run(); | 737 Local<Value> value = script->Run(); |
| 738 CHECK(value->IsNumber()); | 738 CHECK(value->IsNumber()); |
| 739 CHECK_EQ(68, value->Int32Value()); | 739 CHECK_EQ(68, value->Int32Value()); |
| 740 } | 740 } |
| 741 i::CompilationCache::Clear(); | 741 i::CompilationCache::Clear(); |
| 742 i::Heap::CollectAllGarbage(false); | 742 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 743 i::Heap::CollectAllGarbage(false); | 743 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 744 } | 744 } |
| 745 | 745 |
| 746 | 746 |
| 747 THREADED_TEST(GlobalProperties) { | 747 THREADED_TEST(GlobalProperties) { |
| 748 v8::HandleScope scope; | 748 v8::HandleScope scope; |
| 749 LocalContext env; | 749 LocalContext env; |
| 750 v8::Handle<v8::Object> global = env->Global(); | 750 v8::Handle<v8::Object> global = env->Global(); |
| 751 global->Set(v8_str("pi"), v8_num(3.1415926)); | 751 global->Set(v8_str("pi"), v8_num(3.1415926)); |
| 752 Local<Value> pi = global->Get(v8_str("pi")); | 752 Local<Value> pi = global->Get(v8_str("pi")); |
| 753 CHECK_EQ(3.1415926, pi->NumberValue()); | 753 CHECK_EQ(3.1415926, pi->NumberValue()); |
| (...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1568 | 1568 |
| 1569 char* data = new char[100]; | 1569 char* data = new char[100]; |
| 1570 | 1570 |
| 1571 void* aligned = data; | 1571 void* aligned = data; |
| 1572 CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(aligned) & 0x1)); | 1572 CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(aligned) & 0x1)); |
| 1573 void* unaligned = data + 1; | 1573 void* unaligned = data + 1; |
| 1574 CHECK_EQ(1, static_cast<int>(reinterpret_cast<uintptr_t>(unaligned) & 0x1)); | 1574 CHECK_EQ(1, static_cast<int>(reinterpret_cast<uintptr_t>(unaligned) & 0x1)); |
| 1575 | 1575 |
| 1576 // Check reading and writing aligned pointers. | 1576 // Check reading and writing aligned pointers. |
| 1577 obj->SetPointerInInternalField(0, aligned); | 1577 obj->SetPointerInInternalField(0, aligned); |
| 1578 i::Heap::CollectAllGarbage(false); | 1578 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 1579 CHECK_EQ(aligned, obj->GetPointerFromInternalField(0)); | 1579 CHECK_EQ(aligned, obj->GetPointerFromInternalField(0)); |
| 1580 | 1580 |
| 1581 // Check reading and writing unaligned pointers. | 1581 // Check reading and writing unaligned pointers. |
| 1582 obj->SetPointerInInternalField(0, unaligned); | 1582 obj->SetPointerInInternalField(0, unaligned); |
| 1583 i::Heap::CollectAllGarbage(false); | 1583 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 1584 CHECK_EQ(unaligned, obj->GetPointerFromInternalField(0)); | 1584 CHECK_EQ(unaligned, obj->GetPointerFromInternalField(0)); |
| 1585 | 1585 |
| 1586 delete[] data; | 1586 delete[] data; |
| 1587 } | 1587 } |
| 1588 | 1588 |
| 1589 | 1589 |
| 1590 THREADED_TEST(InternalFieldsNativePointersAndExternal) { | 1590 THREADED_TEST(InternalFieldsNativePointersAndExternal) { |
| 1591 v8::HandleScope scope; | 1591 v8::HandleScope scope; |
| 1592 LocalContext env; | 1592 LocalContext env; |
| 1593 | 1593 |
| 1594 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); | 1594 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); |
| 1595 Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate(); | 1595 Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate(); |
| 1596 instance_templ->SetInternalFieldCount(1); | 1596 instance_templ->SetInternalFieldCount(1); |
| 1597 Local<v8::Object> obj = templ->GetFunction()->NewInstance(); | 1597 Local<v8::Object> obj = templ->GetFunction()->NewInstance(); |
| 1598 CHECK_EQ(1, obj->InternalFieldCount()); | 1598 CHECK_EQ(1, obj->InternalFieldCount()); |
| 1599 CHECK(obj->GetPointerFromInternalField(0) == NULL); | 1599 CHECK(obj->GetPointerFromInternalField(0) == NULL); |
| 1600 | 1600 |
| 1601 char* data = new char[100]; | 1601 char* data = new char[100]; |
| 1602 | 1602 |
| 1603 void* aligned = data; | 1603 void* aligned = data; |
| 1604 CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(aligned) & 0x1)); | 1604 CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(aligned) & 0x1)); |
| 1605 void* unaligned = data + 1; | 1605 void* unaligned = data + 1; |
| 1606 CHECK_EQ(1, static_cast<int>(reinterpret_cast<uintptr_t>(unaligned) & 0x1)); | 1606 CHECK_EQ(1, static_cast<int>(reinterpret_cast<uintptr_t>(unaligned) & 0x1)); |
| 1607 | 1607 |
| 1608 obj->SetPointerInInternalField(0, aligned); | 1608 obj->SetPointerInInternalField(0, aligned); |
| 1609 i::Heap::CollectAllGarbage(false); | 1609 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 1610 CHECK_EQ(aligned, v8::External::Unwrap(obj->GetInternalField(0))); | 1610 CHECK_EQ(aligned, v8::External::Unwrap(obj->GetInternalField(0))); |
| 1611 | 1611 |
| 1612 obj->SetPointerInInternalField(0, unaligned); | 1612 obj->SetPointerInInternalField(0, unaligned); |
| 1613 i::Heap::CollectAllGarbage(false); | 1613 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 1614 CHECK_EQ(unaligned, v8::External::Unwrap(obj->GetInternalField(0))); | 1614 CHECK_EQ(unaligned, v8::External::Unwrap(obj->GetInternalField(0))); |
| 1615 | 1615 |
| 1616 obj->SetInternalField(0, v8::External::Wrap(aligned)); | 1616 obj->SetInternalField(0, v8::External::Wrap(aligned)); |
| 1617 i::Heap::CollectAllGarbage(false); | 1617 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 1618 CHECK_EQ(aligned, obj->GetPointerFromInternalField(0)); | 1618 CHECK_EQ(aligned, obj->GetPointerFromInternalField(0)); |
| 1619 | 1619 |
| 1620 obj->SetInternalField(0, v8::External::Wrap(unaligned)); | 1620 obj->SetInternalField(0, v8::External::Wrap(unaligned)); |
| 1621 i::Heap::CollectAllGarbage(false); | 1621 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 1622 CHECK_EQ(unaligned, obj->GetPointerFromInternalField(0)); | 1622 CHECK_EQ(unaligned, obj->GetPointerFromInternalField(0)); |
| 1623 | 1623 |
| 1624 delete[] data; | 1624 delete[] data; |
| 1625 } | 1625 } |
| 1626 | 1626 |
| 1627 | 1627 |
| 1628 THREADED_TEST(IdentityHash) { | 1628 THREADED_TEST(IdentityHash) { |
| 1629 v8::HandleScope scope; | 1629 v8::HandleScope scope; |
| 1630 LocalContext env; | 1630 LocalContext env; |
| 1631 | 1631 |
| 1632 // Ensure that the test starts with an fresh heap to test whether the hash | 1632 // Ensure that the test starts with an fresh heap to test whether the hash |
| 1633 // code is based on the address. | 1633 // code is based on the address. |
| 1634 i::Heap::CollectAllGarbage(false); | 1634 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 1635 Local<v8::Object> obj = v8::Object::New(); | 1635 Local<v8::Object> obj = v8::Object::New(); |
| 1636 int hash = obj->GetIdentityHash(); | 1636 int hash = obj->GetIdentityHash(); |
| 1637 int hash1 = obj->GetIdentityHash(); | 1637 int hash1 = obj->GetIdentityHash(); |
| 1638 CHECK_EQ(hash, hash1); | 1638 CHECK_EQ(hash, hash1); |
| 1639 int hash2 = v8::Object::New()->GetIdentityHash(); | 1639 int hash2 = v8::Object::New()->GetIdentityHash(); |
| 1640 // Since the identity hash is essentially a random number two consecutive | 1640 // Since the identity hash is essentially a random number two consecutive |
| 1641 // objects should not be assigned the same hash code. If the test below fails | 1641 // objects should not be assigned the same hash code. If the test below fails |
| 1642 // the random number generator should be evaluated. | 1642 // the random number generator should be evaluated. |
| 1643 CHECK_NE(hash, hash2); | 1643 CHECK_NE(hash, hash2); |
| 1644 i::Heap::CollectAllGarbage(false); | 1644 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 1645 int hash3 = v8::Object::New()->GetIdentityHash(); | 1645 int hash3 = v8::Object::New()->GetIdentityHash(); |
| 1646 // Make sure that the identity hash is not based on the initial address of | 1646 // Make sure that the identity hash is not based on the initial address of |
| 1647 // the object alone. If the test below fails the random number generator | 1647 // the object alone. If the test below fails the random number generator |
| 1648 // should be evaluated. | 1648 // should be evaluated. |
| 1649 CHECK_NE(hash, hash3); | 1649 CHECK_NE(hash, hash3); |
| 1650 int hash4 = obj->GetIdentityHash(); | 1650 int hash4 = obj->GetIdentityHash(); |
| 1651 CHECK_EQ(hash, hash4); | 1651 CHECK_EQ(hash, hash4); |
| 1652 | 1652 |
| 1653 // Check identity hashes behaviour in the presence of JS accessors. | 1653 // Check identity hashes behaviour in the presence of JS accessors. |
| 1654 // Put a getter for 'v8::IdentityHash' on the Object's prototype: | 1654 // Put a getter for 'v8::IdentityHash' on the Object's prototype: |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1671 | 1671 |
| 1672 THREADED_TEST(HiddenProperties) { | 1672 THREADED_TEST(HiddenProperties) { |
| 1673 v8::HandleScope scope; | 1673 v8::HandleScope scope; |
| 1674 LocalContext env; | 1674 LocalContext env; |
| 1675 | 1675 |
| 1676 v8::Local<v8::Object> obj = v8::Object::New(); | 1676 v8::Local<v8::Object> obj = v8::Object::New(); |
| 1677 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); | 1677 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); |
| 1678 v8::Local<v8::String> empty = v8_str(""); | 1678 v8::Local<v8::String> empty = v8_str(""); |
| 1679 v8::Local<v8::String> prop_name = v8_str("prop_name"); | 1679 v8::Local<v8::String> prop_name = v8_str("prop_name"); |
| 1680 | 1680 |
| 1681 i::Heap::CollectAllGarbage(false); | 1681 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 1682 | 1682 |
| 1683 // Make sure delete of a non-existent hidden value works | 1683 // Make sure delete of a non-existent hidden value works |
| 1684 CHECK(obj->DeleteHiddenValue(key)); | 1684 CHECK(obj->DeleteHiddenValue(key)); |
| 1685 | 1685 |
| 1686 CHECK(obj->SetHiddenValue(key, v8::Integer::New(1503))); | 1686 CHECK(obj->SetHiddenValue(key, v8::Integer::New(1503))); |
| 1687 CHECK_EQ(1503, obj->GetHiddenValue(key)->Int32Value()); | 1687 CHECK_EQ(1503, obj->GetHiddenValue(key)->Int32Value()); |
| 1688 CHECK(obj->SetHiddenValue(key, v8::Integer::New(2002))); | 1688 CHECK(obj->SetHiddenValue(key, v8::Integer::New(2002))); |
| 1689 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 1689 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
| 1690 | 1690 |
| 1691 i::Heap::CollectAllGarbage(false); | 1691 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 1692 | 1692 |
| 1693 // Make sure we do not find the hidden property. | 1693 // Make sure we do not find the hidden property. |
| 1694 CHECK(!obj->Has(empty)); | 1694 CHECK(!obj->Has(empty)); |
| 1695 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 1695 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
| 1696 CHECK(obj->Get(empty)->IsUndefined()); | 1696 CHECK(obj->Get(empty)->IsUndefined()); |
| 1697 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 1697 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
| 1698 CHECK(obj->Set(empty, v8::Integer::New(2003))); | 1698 CHECK(obj->Set(empty, v8::Integer::New(2003))); |
| 1699 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 1699 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
| 1700 CHECK_EQ(2003, obj->Get(empty)->Int32Value()); | 1700 CHECK_EQ(2003, obj->Get(empty)->Int32Value()); |
| 1701 | 1701 |
| 1702 i::Heap::CollectAllGarbage(false); | 1702 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 1703 | 1703 |
| 1704 // Add another property and delete it afterwards to force the object in | 1704 // Add another property and delete it afterwards to force the object in |
| 1705 // slow case. | 1705 // slow case. |
| 1706 CHECK(obj->Set(prop_name, v8::Integer::New(2008))); | 1706 CHECK(obj->Set(prop_name, v8::Integer::New(2008))); |
| 1707 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 1707 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
| 1708 CHECK_EQ(2008, obj->Get(prop_name)->Int32Value()); | 1708 CHECK_EQ(2008, obj->Get(prop_name)->Int32Value()); |
| 1709 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 1709 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
| 1710 CHECK(obj->Delete(prop_name)); | 1710 CHECK(obj->Delete(prop_name)); |
| 1711 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 1711 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
| 1712 | 1712 |
| 1713 i::Heap::CollectAllGarbage(false); | 1713 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 1714 | 1714 |
| 1715 CHECK(obj->DeleteHiddenValue(key)); | 1715 CHECK(obj->DeleteHiddenValue(key)); |
| 1716 CHECK(obj->GetHiddenValue(key).IsEmpty()); | 1716 CHECK(obj->GetHiddenValue(key).IsEmpty()); |
| 1717 } | 1717 } |
| 1718 | 1718 |
| 1719 | 1719 |
| 1720 static bool interceptor_for_hidden_properties_called; | 1720 static bool interceptor_for_hidden_properties_called; |
| 1721 static v8::Handle<Value> InterceptorForHiddenProperties( | 1721 static v8::Handle<Value> InterceptorForHiddenProperties( |
| 1722 Local<String> name, const AccessorInfo& info) { | 1722 Local<String> name, const AccessorInfo& info) { |
| 1723 interceptor_for_hidden_properties_called = true; | 1723 interceptor_for_hidden_properties_called = true; |
| (...skipping 2476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4200 object_b = v8::Persistent<v8::Object>::New(v8::Object::New()); | 4200 object_b = v8::Persistent<v8::Object>::New(v8::Object::New()); |
| 4201 object_a = v8::Persistent<v8::Object>::New(v8::Object::New()); | 4201 object_a = v8::Persistent<v8::Object>::New(v8::Object::New()); |
| 4202 } | 4202 } |
| 4203 | 4203 |
| 4204 bool object_a_disposed = false; | 4204 bool object_a_disposed = false; |
| 4205 object_a.MakeWeak(&object_a_disposed, &ForceScavenge); | 4205 object_a.MakeWeak(&object_a_disposed, &ForceScavenge); |
| 4206 bool released_in_scavenge = false; | 4206 bool released_in_scavenge = false; |
| 4207 object_b.MakeWeak(&released_in_scavenge, &CheckIsNotInvokedInScavenge); | 4207 object_b.MakeWeak(&released_in_scavenge, &CheckIsNotInvokedInScavenge); |
| 4208 | 4208 |
| 4209 while (!object_a_disposed) { | 4209 while (!object_a_disposed) { |
| 4210 i::Heap::CollectAllGarbage(false); | 4210 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 4211 } | 4211 } |
| 4212 CHECK(!released_in_scavenge); | 4212 CHECK(!released_in_scavenge); |
| 4213 } | 4213 } |
| 4214 | 4214 |
| 4215 | 4215 |
| 4216 v8::Handle<Function> args_fun; | 4216 v8::Handle<Function> args_fun; |
| 4217 | 4217 |
| 4218 | 4218 |
| 4219 static v8::Handle<Value> ArgumentsTestCallback(const v8::Arguments& args) { | 4219 static v8::Handle<Value> ArgumentsTestCallback(const v8::Arguments& args) { |
| 4220 ApiTestFuzzer::Fuzz(); | 4220 ApiTestFuzzer::Fuzz(); |
| 4221 CHECK_EQ(args_fun, args.Callee()); | 4221 CHECK_EQ(args_fun, args.Callee()); |
| 4222 CHECK_EQ(3, args.Length()); | 4222 CHECK_EQ(3, args.Length()); |
| 4223 CHECK_EQ(v8::Integer::New(1), args[0]); | 4223 CHECK_EQ(v8::Integer::New(1), args[0]); |
| 4224 CHECK_EQ(v8::Integer::New(2), args[1]); | 4224 CHECK_EQ(v8::Integer::New(2), args[1]); |
| 4225 CHECK_EQ(v8::Integer::New(3), args[2]); | 4225 CHECK_EQ(v8::Integer::New(3), args[2]); |
| 4226 CHECK_EQ(v8::Undefined(), args[3]); | 4226 CHECK_EQ(v8::Undefined(), args[3]); |
| 4227 v8::HandleScope scope; | 4227 v8::HandleScope scope; |
| 4228 i::Heap::CollectAllGarbage(false); | 4228 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 4229 return v8::Undefined(); | 4229 return v8::Undefined(); |
| 4230 } | 4230 } |
| 4231 | 4231 |
| 4232 | 4232 |
| 4233 THREADED_TEST(Arguments) { | 4233 THREADED_TEST(Arguments) { |
| 4234 v8::HandleScope scope; | 4234 v8::HandleScope scope; |
| 4235 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(); | 4235 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(); |
| 4236 global->Set(v8_str("f"), v8::FunctionTemplate::New(ArgumentsTestCallback)); | 4236 global->Set(v8_str("f"), v8::FunctionTemplate::New(ArgumentsTestCallback)); |
| 4237 LocalContext context(NULL, global); | 4237 LocalContext context(NULL, global); |
| 4238 args_fun = context->Global()->Get(v8_str("f")).As<Function>(); | 4238 args_fun = context->Global()->Get(v8_str("f")).As<Function>(); |
| (...skipping 2561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6800 "var p = new constructor();" | 6800 "var p = new constructor();" |
| 6801 "p.hasOwnProperty('ostehaps');"); | 6801 "p.hasOwnProperty('ostehaps');"); |
| 6802 CHECK_EQ(false, value->BooleanValue()); | 6802 CHECK_EQ(false, value->BooleanValue()); |
| 6803 } | 6803 } |
| 6804 | 6804 |
| 6805 | 6805 |
| 6806 static v8::Handle<Value> InterceptorHasOwnPropertyGetterGC( | 6806 static v8::Handle<Value> InterceptorHasOwnPropertyGetterGC( |
| 6807 Local<String> name, | 6807 Local<String> name, |
| 6808 const AccessorInfo& info) { | 6808 const AccessorInfo& info) { |
| 6809 ApiTestFuzzer::Fuzz(); | 6809 ApiTestFuzzer::Fuzz(); |
| 6810 i::Heap::CollectAllGarbage(false); | 6810 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 6811 return v8::Handle<Value>(); | 6811 return v8::Handle<Value>(); |
| 6812 } | 6812 } |
| 6813 | 6813 |
| 6814 | 6814 |
| 6815 THREADED_TEST(InterceptorHasOwnPropertyCausingGC) { | 6815 THREADED_TEST(InterceptorHasOwnPropertyCausingGC) { |
| 6816 v8::HandleScope scope; | 6816 v8::HandleScope scope; |
| 6817 LocalContext context; | 6817 LocalContext context; |
| 6818 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 6818 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 6819 Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate(); | 6819 Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate(); |
| 6820 instance_templ->SetNamedPropertyHandler(InterceptorHasOwnPropertyGetterGC); | 6820 instance_templ->SetNamedPropertyHandler(InterceptorHasOwnPropertyGetterGC); |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7530 "};"); | 7530 "};"); |
| 7531 CHECK_EQ(239 * 10, value->Int32Value()); | 7531 CHECK_EQ(239 * 10, value->Int32Value()); |
| 7532 } | 7532 } |
| 7533 | 7533 |
| 7534 static v8::Handle<Value> InterceptorCallICFastApi(Local<String> name, | 7534 static v8::Handle<Value> InterceptorCallICFastApi(Local<String> name, |
| 7535 const AccessorInfo& info) { | 7535 const AccessorInfo& info) { |
| 7536 ApiTestFuzzer::Fuzz(); | 7536 ApiTestFuzzer::Fuzz(); |
| 7537 int* call_count = reinterpret_cast<int*>(v8::External::Unwrap(info.Data())); | 7537 int* call_count = reinterpret_cast<int*>(v8::External::Unwrap(info.Data())); |
| 7538 ++(*call_count); | 7538 ++(*call_count); |
| 7539 if ((*call_count) % 20 == 0) { | 7539 if ((*call_count) % 20 == 0) { |
| 7540 i::Heap::CollectAllGarbage(true); | 7540 i::Heap::CollectAllGarbage(i::Heap::kForceCompactionMask); |
| 7541 } | 7541 } |
| 7542 return v8::Handle<Value>(); | 7542 return v8::Handle<Value>(); |
| 7543 } | 7543 } |
| 7544 | 7544 |
| 7545 static v8::Handle<Value> FastApiCallback_TrivialSignature( | 7545 static v8::Handle<Value> FastApiCallback_TrivialSignature( |
| 7546 const v8::Arguments& args) { | 7546 const v8::Arguments& args) { |
| 7547 ApiTestFuzzer::Fuzz(); | 7547 ApiTestFuzzer::Fuzz(); |
| 7548 CHECK_EQ(args.This(), args.Holder()); | 7548 CHECK_EQ(args.This(), args.Holder()); |
| 7549 CHECK(args.Data()->Equals(v8_str("method_data"))); | 7549 CHECK(args.Data()->Equals(v8_str("method_data"))); |
| 7550 return v8::Integer::New(args[0]->Int32Value() + 1); | 7550 return v8::Integer::New(args[0]->Int32Value() + 1); |
| (...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8697 Local<Script> script = v8_compile("(function () {" | 8697 Local<Script> script = v8_compile("(function () {" |
| 8698 " unlock_for_a_moment();" | 8698 " unlock_for_a_moment();" |
| 8699 " return 42;" | 8699 " return 42;" |
| 8700 "})();"); | 8700 "})();"); |
| 8701 CHECK_EQ(42, script->Run()->Int32Value()); | 8701 CHECK_EQ(42, script->Run()->Int32Value()); |
| 8702 } | 8702 } |
| 8703 } | 8703 } |
| 8704 | 8704 |
| 8705 | 8705 |
| 8706 static int GetGlobalObjectsCount() { | 8706 static int GetGlobalObjectsCount() { |
| 8707 i::Heap::EnsureHeapIsIterable(); |
| 8707 int count = 0; | 8708 int count = 0; |
| 8708 i::HeapIterator it; | 8709 i::HeapIterator it; |
| 8709 for (i::HeapObject* object = it.next(); object != NULL; object = it.next()) | 8710 for (i::HeapObject* object = it.Next(); object != NULL; object = it.Next()) |
| 8710 if (object->IsJSGlobalObject()) count++; | 8711 if (object->IsJSGlobalObject()) count++; |
| 8711 return count; | 8712 return count; |
| 8712 } | 8713 } |
| 8713 | 8714 |
| 8714 | 8715 |
| 8715 static void CheckSurvivingGlobalObjectsCount(int expected) { | 8716 static void CheckSurvivingGlobalObjectsCount(int expected) { |
| 8716 // We need to collect all garbage twice to be sure that everything | 8717 // We need to collect all garbage twice to be sure that everything |
| 8717 // has been collected. This is because inline caches are cleared in | 8718 // has been collected. This is because inline caches are cleared in |
| 8718 // the first garbage collection but some of the maps have already | 8719 // the first garbage collection but some of the maps have already |
| 8719 // been marked at that point. Therefore some of the maps are not | 8720 // been marked at that point. Therefore some of the maps are not |
| 8720 // collected until the second garbage collection. | 8721 // collected until the second garbage collection. |
| 8721 i::Heap::CollectAllGarbage(false); | 8722 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 8722 i::Heap::CollectAllGarbage(false); | 8723 i::Heap::CollectAllGarbage(i::Heap::kSweepPreciselyMask); |
| 8723 int count = GetGlobalObjectsCount(); | 8724 int count = GetGlobalObjectsCount(); |
| 8724 #ifdef DEBUG | 8725 #ifdef DEBUG |
| 8725 if (count != expected) i::Heap::TracePathToGlobal(); | 8726 if (count != expected) i::Heap::TracePathToGlobal(); |
| 8726 #endif | 8727 #endif |
| 8727 CHECK_EQ(expected, count); | 8728 CHECK_EQ(expected, count); |
| 8728 } | 8729 } |
| 8729 | 8730 |
| 8730 | 8731 |
| 8731 TEST(DontLeakGlobalObjects) { | 8732 TEST(DontLeakGlobalObjects) { |
| 8732 // Regression test for issues 1139850 and 1174891. | 8733 // Regression test for issues 1139850 and 1174891. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8781 some_object = v8::Persistent<v8::Object>::New(v8::Object::New()); | 8782 some_object = v8::Persistent<v8::Object>::New(v8::Object::New()); |
| 8782 handle1 = v8::Persistent<v8::Object>::New(v8::Object::New()); | 8783 handle1 = v8::Persistent<v8::Object>::New(v8::Object::New()); |
| 8783 handle2 = v8::Persistent<v8::Object>::New(v8::Object::New()); | 8784 handle2 = v8::Persistent<v8::Object>::New(v8::Object::New()); |
| 8784 } | 8785 } |
| 8785 // Note: order is implementation dependent alas: currently | 8786 // Note: order is implementation dependent alas: currently |
| 8786 // global handle nodes are processed by PostGarbageCollectionProcessing | 8787 // global handle nodes are processed by PostGarbageCollectionProcessing |
| 8787 // in reverse allocation order, so if second allocated handle is deleted, | 8788 // in reverse allocation order, so if second allocated handle is deleted, |
| 8788 // weak callback of the first handle would be able to 'reallocate' it. | 8789 // weak callback of the first handle would be able to 'reallocate' it. |
| 8789 handle1.MakeWeak(NULL, NewPersistentHandleCallback); | 8790 handle1.MakeWeak(NULL, NewPersistentHandleCallback); |
| 8790 handle2.Dispose(); | 8791 handle2.Dispose(); |
| 8791 i::Heap::CollectAllGarbage(false); | 8792 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 8792 } | 8793 } |
| 8793 | 8794 |
| 8794 | 8795 |
| 8795 v8::Persistent<v8::Object> to_be_disposed; | 8796 v8::Persistent<v8::Object> to_be_disposed; |
| 8796 | 8797 |
| 8797 void DisposeAndForceGcCallback(v8::Persistent<v8::Value> handle, void*) { | 8798 void DisposeAndForceGcCallback(v8::Persistent<v8::Value> handle, void*) { |
| 8798 to_be_disposed.Dispose(); | 8799 to_be_disposed.Dispose(); |
| 8799 i::Heap::CollectAllGarbage(false); | 8800 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 8800 handle.Dispose(); | 8801 handle.Dispose(); |
| 8801 } | 8802 } |
| 8802 | 8803 |
| 8803 | 8804 |
| 8804 THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc) { | 8805 THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc) { |
| 8805 LocalContext context; | 8806 LocalContext context; |
| 8806 | 8807 |
| 8807 v8::Persistent<v8::Object> handle1, handle2; | 8808 v8::Persistent<v8::Object> handle1, handle2; |
| 8808 { | 8809 { |
| 8809 v8::HandleScope scope; | 8810 v8::HandleScope scope; |
| 8810 handle1 = v8::Persistent<v8::Object>::New(v8::Object::New()); | 8811 handle1 = v8::Persistent<v8::Object>::New(v8::Object::New()); |
| 8811 handle2 = v8::Persistent<v8::Object>::New(v8::Object::New()); | 8812 handle2 = v8::Persistent<v8::Object>::New(v8::Object::New()); |
| 8812 } | 8813 } |
| 8813 handle1.MakeWeak(NULL, DisposeAndForceGcCallback); | 8814 handle1.MakeWeak(NULL, DisposeAndForceGcCallback); |
| 8814 to_be_disposed = handle2; | 8815 to_be_disposed = handle2; |
| 8815 i::Heap::CollectAllGarbage(false); | 8816 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 8816 } | 8817 } |
| 8817 | 8818 |
| 8818 void DisposingCallback(v8::Persistent<v8::Value> handle, void*) { | 8819 void DisposingCallback(v8::Persistent<v8::Value> handle, void*) { |
| 8819 handle.Dispose(); | 8820 handle.Dispose(); |
| 8820 } | 8821 } |
| 8821 | 8822 |
| 8822 void HandleCreatingCallback(v8::Persistent<v8::Value> handle, void*) { | 8823 void HandleCreatingCallback(v8::Persistent<v8::Value> handle, void*) { |
| 8823 v8::HandleScope scope; | 8824 v8::HandleScope scope; |
| 8824 v8::Persistent<v8::Object>::New(v8::Object::New()); | 8825 v8::Persistent<v8::Object>::New(v8::Object::New()); |
| 8825 handle.Dispose(); | 8826 handle.Dispose(); |
| 8826 } | 8827 } |
| 8827 | 8828 |
| 8828 | 8829 |
| 8829 THREADED_TEST(NoGlobalHandlesOrphaningDueToWeakCallback) { | 8830 THREADED_TEST(NoGlobalHandlesOrphaningDueToWeakCallback) { |
| 8830 LocalContext context; | 8831 LocalContext context; |
| 8831 | 8832 |
| 8832 v8::Persistent<v8::Object> handle1, handle2, handle3; | 8833 v8::Persistent<v8::Object> handle1, handle2, handle3; |
| 8833 { | 8834 { |
| 8834 v8::HandleScope scope; | 8835 v8::HandleScope scope; |
| 8835 handle3 = v8::Persistent<v8::Object>::New(v8::Object::New()); | 8836 handle3 = v8::Persistent<v8::Object>::New(v8::Object::New()); |
| 8836 handle2 = v8::Persistent<v8::Object>::New(v8::Object::New()); | 8837 handle2 = v8::Persistent<v8::Object>::New(v8::Object::New()); |
| 8837 handle1 = v8::Persistent<v8::Object>::New(v8::Object::New()); | 8838 handle1 = v8::Persistent<v8::Object>::New(v8::Object::New()); |
| 8838 } | 8839 } |
| 8839 handle2.MakeWeak(NULL, DisposingCallback); | 8840 handle2.MakeWeak(NULL, DisposingCallback); |
| 8840 handle3.MakeWeak(NULL, HandleCreatingCallback); | 8841 handle3.MakeWeak(NULL, HandleCreatingCallback); |
| 8841 i::Heap::CollectAllGarbage(false); | 8842 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 8842 } | 8843 } |
| 8843 | 8844 |
| 8844 | 8845 |
| 8845 THREADED_TEST(CheckForCrossContextObjectLiterals) { | 8846 THREADED_TEST(CheckForCrossContextObjectLiterals) { |
| 8846 v8::V8::Initialize(); | 8847 v8::V8::Initialize(); |
| 8847 | 8848 |
| 8848 const int nof = 2; | 8849 const int nof = 2; |
| 8849 const char* sources[nof] = { | 8850 const char* sources[nof] = { |
| 8850 "try { [ 2, 3, 4 ].forEach(5); } catch(e) { e.toString(); }", | 8851 "try { [ 2, 3, 4 ].forEach(5); } catch(e) { e.toString(); }", |
| 8851 "Object()" | 8852 "Object()" |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9603 private: | 9604 private: |
| 9604 RegExpInterruptTest* test_; | 9605 RegExpInterruptTest* test_; |
| 9605 }; | 9606 }; |
| 9606 | 9607 |
| 9607 void CollectGarbage() { | 9608 void CollectGarbage() { |
| 9608 block_->Wait(); | 9609 block_->Wait(); |
| 9609 while (gc_during_regexp_ < kRequiredGCs) { | 9610 while (gc_during_regexp_ < kRequiredGCs) { |
| 9610 { | 9611 { |
| 9611 v8::Locker lock; | 9612 v8::Locker lock; |
| 9612 // TODO(lrn): Perhaps create some garbage before collecting. | 9613 // TODO(lrn): Perhaps create some garbage before collecting. |
| 9613 i::Heap::CollectAllGarbage(false); | 9614 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 9614 gc_count_++; | 9615 gc_count_++; |
| 9615 } | 9616 } |
| 9616 i::OS::Sleep(1); | 9617 i::OS::Sleep(1); |
| 9617 } | 9618 } |
| 9618 gc_success_ = true; | 9619 gc_success_ = true; |
| 9619 } | 9620 } |
| 9620 | 9621 |
| 9621 void LongRunningRegExp() { | 9622 void LongRunningRegExp() { |
| 9622 block_->Signal(); // Enable garbage collection thread on next preemption. | 9623 block_->Signal(); // Enable garbage collection thread on next preemption. |
| 9623 int rounds = 0; | 9624 int rounds = 0; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9724 } | 9725 } |
| 9725 private: | 9726 private: |
| 9726 ApplyInterruptTest* test_; | 9727 ApplyInterruptTest* test_; |
| 9727 }; | 9728 }; |
| 9728 | 9729 |
| 9729 void CollectGarbage() { | 9730 void CollectGarbage() { |
| 9730 block_->Wait(); | 9731 block_->Wait(); |
| 9731 while (gc_during_apply_ < kRequiredGCs) { | 9732 while (gc_during_apply_ < kRequiredGCs) { |
| 9732 { | 9733 { |
| 9733 v8::Locker lock; | 9734 v8::Locker lock; |
| 9734 i::Heap::CollectAllGarbage(false); | 9735 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 9735 gc_count_++; | 9736 gc_count_++; |
| 9736 } | 9737 } |
| 9737 i::OS::Sleep(1); | 9738 i::OS::Sleep(1); |
| 9738 } | 9739 } |
| 9739 gc_success_ = true; | 9740 gc_success_ = true; |
| 9740 } | 9741 } |
| 9741 | 9742 |
| 9742 void LongRunningApply() { | 9743 void LongRunningApply() { |
| 9743 block_->Signal(); | 9744 block_->Signal(); |
| 9744 int rounds = 0; | 9745 int rounds = 0; |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10438 } | 10439 } |
| 10439 | 10440 |
| 10440 | 10441 |
| 10441 THREADED_TEST(PixelArray) { | 10442 THREADED_TEST(PixelArray) { |
| 10442 v8::HandleScope scope; | 10443 v8::HandleScope scope; |
| 10443 LocalContext context; | 10444 LocalContext context; |
| 10444 const int kElementCount = 260; | 10445 const int kElementCount = 260; |
| 10445 uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(kElementCount)); | 10446 uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(kElementCount)); |
| 10446 i::Handle<i::PixelArray> pixels = i::Factory::NewPixelArray(kElementCount, | 10447 i::Handle<i::PixelArray> pixels = i::Factory::NewPixelArray(kElementCount, |
| 10447 pixel_data); | 10448 pixel_data); |
| 10448 i::Heap::CollectAllGarbage(false); // Force GC to trigger verification. | 10449 // Force GC to trigger verification. |
| 10450 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 10449 for (int i = 0; i < kElementCount; i++) { | 10451 for (int i = 0; i < kElementCount; i++) { |
| 10450 pixels->set(i, i % 256); | 10452 pixels->set(i, i % 256); |
| 10451 } | 10453 } |
| 10452 i::Heap::CollectAllGarbage(false); // Force GC to trigger verification. | 10454 // Force GC to trigger verification. |
| 10455 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 10453 for (int i = 0; i < kElementCount; i++) { | 10456 for (int i = 0; i < kElementCount; i++) { |
| 10454 CHECK_EQ(i % 256, pixels->get(i)); | 10457 CHECK_EQ(i % 256, pixels->get(i)); |
| 10455 CHECK_EQ(i % 256, pixel_data[i]); | 10458 CHECK_EQ(i % 256, pixel_data[i]); |
| 10456 } | 10459 } |
| 10457 | 10460 |
| 10458 v8::Handle<v8::Object> obj = v8::Object::New(); | 10461 v8::Handle<v8::Object> obj = v8::Object::New(); |
| 10459 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); | 10462 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); |
| 10460 // Set the elements to be the pixels. | 10463 // Set the elements to be the pixels. |
| 10461 // jsobj->set_elements(*pixels); | 10464 // jsobj->set_elements(*pixels); |
| 10462 obj->SetIndexedPropertiesToPixelData(pixel_data, kElementCount); | 10465 obj->SetIndexedPropertiesToPixelData(pixel_data, kElementCount); |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10839 int64_t high) { | 10842 int64_t high) { |
| 10840 v8::HandleScope scope; | 10843 v8::HandleScope scope; |
| 10841 LocalContext context; | 10844 LocalContext context; |
| 10842 const int kElementCount = 40; | 10845 const int kElementCount = 40; |
| 10843 int element_size = ExternalArrayElementSize(array_type); | 10846 int element_size = ExternalArrayElementSize(array_type); |
| 10844 ElementType* array_data = | 10847 ElementType* array_data = |
| 10845 static_cast<ElementType*>(malloc(kElementCount * element_size)); | 10848 static_cast<ElementType*>(malloc(kElementCount * element_size)); |
| 10846 i::Handle<ExternalArrayClass> array = | 10849 i::Handle<ExternalArrayClass> array = |
| 10847 i::Handle<ExternalArrayClass>::cast( | 10850 i::Handle<ExternalArrayClass>::cast( |
| 10848 i::Factory::NewExternalArray(kElementCount, array_type, array_data)); | 10851 i::Factory::NewExternalArray(kElementCount, array_type, array_data)); |
| 10849 i::Heap::CollectAllGarbage(false); // Force GC to trigger verification. | 10852 // Force GC to trigger verification. |
| 10853 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 10850 for (int i = 0; i < kElementCount; i++) { | 10854 for (int i = 0; i < kElementCount; i++) { |
| 10851 array->set(i, static_cast<ElementType>(i)); | 10855 array->set(i, static_cast<ElementType>(i)); |
| 10852 } | 10856 } |
| 10853 i::Heap::CollectAllGarbage(false); // Force GC to trigger verification. | 10857 // Force GC to trigger verification. |
| 10858 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 10854 for (int i = 0; i < kElementCount; i++) { | 10859 for (int i = 0; i < kElementCount; i++) { |
| 10855 CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(array->get(i))); | 10860 CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(array->get(i))); |
| 10856 CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(array_data[i])); | 10861 CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(array_data[i])); |
| 10857 } | 10862 } |
| 10858 | 10863 |
| 10859 v8::Handle<v8::Object> obj = v8::Object::New(); | 10864 v8::Handle<v8::Object> obj = v8::Object::New(); |
| 10860 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); | 10865 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); |
| 10861 // Set the elements to be the external array. | 10866 // Set the elements to be the external array. |
| 10862 obj->SetIndexedPropertiesToExternalArrayData(array_data, | 10867 obj->SetIndexedPropertiesToExternalArrayData(array_data, |
| 10863 array_type, | 10868 array_type, |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10960 result = CompileRun("var tmp_array = ext_array;" | 10965 result = CompileRun("var tmp_array = ext_array;" |
| 10961 "var sum = 0;" | 10966 "var sum = 0;" |
| 10962 "for (var i = 0; i < 8; i++) {" | 10967 "for (var i = 0; i < 8; i++) {" |
| 10963 " tmp_array[i] = i;" | 10968 " tmp_array[i] = i;" |
| 10964 " sum += tmp_array[i];" | 10969 " sum += tmp_array[i];" |
| 10965 " if (i == 4) {" | 10970 " if (i == 4) {" |
| 10966 " tmp_array = {};" | 10971 " tmp_array = {};" |
| 10967 " }" | 10972 " }" |
| 10968 "}" | 10973 "}" |
| 10969 "sum;"); | 10974 "sum;"); |
| 10970 i::Heap::CollectAllGarbage(false); // Force GC to trigger verification. | 10975 // Force GC to trigger verification. |
| 10976 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 10971 CHECK_EQ(28, result->Int32Value()); | 10977 CHECK_EQ(28, result->Int32Value()); |
| 10972 | 10978 |
| 10973 // Make sure out-of-range loads do not throw. | 10979 // Make sure out-of-range loads do not throw. |
| 10974 i::OS::SNPrintF(test_buf, | 10980 i::OS::SNPrintF(test_buf, |
| 10975 "var caught_exception = false;" | 10981 "var caught_exception = false;" |
| 10976 "try {" | 10982 "try {" |
| 10977 " ext_array[%d];" | 10983 " ext_array[%d];" |
| 10978 "} catch (e) {" | 10984 "} catch (e) {" |
| 10979 " caught_exception = true;" | 10985 " caught_exception = true;" |
| 10980 "}" | 10986 "}" |
| (...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11802 Local<v8::String> obj = v8::String::New(""); | 11808 Local<v8::String> obj = v8::String::New(""); |
| 11803 context->SetData(obj); | 11809 context->SetData(obj); |
| 11804 CompileRun(source_simple); | 11810 CompileRun(source_simple); |
| 11805 context->Exit(); | 11811 context->Exit(); |
| 11806 } | 11812 } |
| 11807 context.Dispose(); | 11813 context.Dispose(); |
| 11808 for (gc_count = 1; gc_count < 10; gc_count++) { | 11814 for (gc_count = 1; gc_count < 10; gc_count++) { |
| 11809 other_context->Enter(); | 11815 other_context->Enter(); |
| 11810 CompileRun(source_simple); | 11816 CompileRun(source_simple); |
| 11811 other_context->Exit(); | 11817 other_context->Exit(); |
| 11812 i::Heap::CollectAllGarbage(false); | 11818 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 11813 if (GetGlobalObjectsCount() == 1) break; | 11819 if (GetGlobalObjectsCount() == 1) break; |
| 11814 } | 11820 } |
| 11815 CHECK_GE(2, gc_count); | 11821 CHECK_GE(2, gc_count); |
| 11816 CHECK_EQ(1, GetGlobalObjectsCount()); | 11822 CHECK_EQ(1, GetGlobalObjectsCount()); |
| 11817 | 11823 |
| 11818 // Eval in a function creates reference from the compilation cache to the | 11824 // Eval in a function creates reference from the compilation cache to the |
| 11819 // global object. | 11825 // global object. |
| 11820 const char* source_eval = "function f(){eval('1')}; f()"; | 11826 const char* source_eval = "function f(){eval('1')}; f()"; |
| 11821 context = Context::New(); | 11827 context = Context::New(); |
| 11822 { | 11828 { |
| 11823 v8::HandleScope scope; | 11829 v8::HandleScope scope; |
| 11824 | 11830 |
| 11825 context->Enter(); | 11831 context->Enter(); |
| 11826 CompileRun(source_eval); | 11832 CompileRun(source_eval); |
| 11827 context->Exit(); | 11833 context->Exit(); |
| 11828 } | 11834 } |
| 11829 context.Dispose(); | 11835 context.Dispose(); |
| 11830 for (gc_count = 1; gc_count < 10; gc_count++) { | 11836 for (gc_count = 1; gc_count < 10; gc_count++) { |
| 11831 other_context->Enter(); | 11837 other_context->Enter(); |
| 11832 CompileRun(source_eval); | 11838 CompileRun(source_eval); |
| 11833 other_context->Exit(); | 11839 other_context->Exit(); |
| 11834 i::Heap::CollectAllGarbage(false); | 11840 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 11835 if (GetGlobalObjectsCount() == 1) break; | 11841 if (GetGlobalObjectsCount() == 1) break; |
| 11836 } | 11842 } |
| 11837 CHECK_GE(2, gc_count); | 11843 CHECK_GE(2, gc_count); |
| 11838 CHECK_EQ(1, GetGlobalObjectsCount()); | 11844 CHECK_EQ(1, GetGlobalObjectsCount()); |
| 11839 | 11845 |
| 11840 // Looking up the line number for an exception creates reference from the | 11846 // Looking up the line number for an exception creates reference from the |
| 11841 // compilation cache to the global object. | 11847 // compilation cache to the global object. |
| 11842 const char* source_exception = "function f(){throw 1;} f()"; | 11848 const char* source_exception = "function f(){throw 1;} f()"; |
| 11843 context = Context::New(); | 11849 context = Context::New(); |
| 11844 { | 11850 { |
| 11845 v8::HandleScope scope; | 11851 v8::HandleScope scope; |
| 11846 | 11852 |
| 11847 context->Enter(); | 11853 context->Enter(); |
| 11848 v8::TryCatch try_catch; | 11854 v8::TryCatch try_catch; |
| 11849 CompileRun(source_exception); | 11855 CompileRun(source_exception); |
| 11850 CHECK(try_catch.HasCaught()); | 11856 CHECK(try_catch.HasCaught()); |
| 11851 v8::Handle<v8::Message> message = try_catch.Message(); | 11857 v8::Handle<v8::Message> message = try_catch.Message(); |
| 11852 CHECK(!message.IsEmpty()); | 11858 CHECK(!message.IsEmpty()); |
| 11853 CHECK_EQ(1, message->GetLineNumber()); | 11859 CHECK_EQ(1, message->GetLineNumber()); |
| 11854 context->Exit(); | 11860 context->Exit(); |
| 11855 } | 11861 } |
| 11856 context.Dispose(); | 11862 context.Dispose(); |
| 11857 for (gc_count = 1; gc_count < 10; gc_count++) { | 11863 for (gc_count = 1; gc_count < 10; gc_count++) { |
| 11858 other_context->Enter(); | 11864 other_context->Enter(); |
| 11859 CompileRun(source_exception); | 11865 CompileRun(source_exception); |
| 11860 other_context->Exit(); | 11866 other_context->Exit(); |
| 11861 i::Heap::CollectAllGarbage(false); | 11867 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 11862 if (GetGlobalObjectsCount() == 1) break; | 11868 if (GetGlobalObjectsCount() == 1) break; |
| 11863 } | 11869 } |
| 11864 CHECK_GE(2, gc_count); | 11870 CHECK_GE(2, gc_count); |
| 11865 CHECK_EQ(1, GetGlobalObjectsCount()); | 11871 CHECK_EQ(1, GetGlobalObjectsCount()); |
| 11866 | 11872 |
| 11867 other_context.Dispose(); | 11873 other_context.Dispose(); |
| 11868 } | 11874 } |
| 11869 | 11875 |
| 11870 | 11876 |
| 11871 THREADED_TEST(ScriptOrigin) { | 11877 THREADED_TEST(ScriptOrigin) { |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12069 ++epilogue_call_count_second; | 12075 ++epilogue_call_count_second; |
| 12070 } | 12076 } |
| 12071 | 12077 |
| 12072 TEST(GCCallbacks) { | 12078 TEST(GCCallbacks) { |
| 12073 LocalContext context; | 12079 LocalContext context; |
| 12074 | 12080 |
| 12075 v8::V8::AddGCPrologueCallback(PrologueCallback); | 12081 v8::V8::AddGCPrologueCallback(PrologueCallback); |
| 12076 v8::V8::AddGCEpilogueCallback(EpilogueCallback); | 12082 v8::V8::AddGCEpilogueCallback(EpilogueCallback); |
| 12077 CHECK_EQ(0, prologue_call_count); | 12083 CHECK_EQ(0, prologue_call_count); |
| 12078 CHECK_EQ(0, epilogue_call_count); | 12084 CHECK_EQ(0, epilogue_call_count); |
| 12079 i::Heap::CollectAllGarbage(false); | 12085 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 12080 CHECK_EQ(1, prologue_call_count); | 12086 CHECK_EQ(1, prologue_call_count); |
| 12081 CHECK_EQ(1, epilogue_call_count); | 12087 CHECK_EQ(1, epilogue_call_count); |
| 12082 v8::V8::AddGCPrologueCallback(PrologueCallbackSecond); | 12088 v8::V8::AddGCPrologueCallback(PrologueCallbackSecond); |
| 12083 v8::V8::AddGCEpilogueCallback(EpilogueCallbackSecond); | 12089 v8::V8::AddGCEpilogueCallback(EpilogueCallbackSecond); |
| 12084 i::Heap::CollectAllGarbage(false); | 12090 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 12085 CHECK_EQ(2, prologue_call_count); | 12091 CHECK_EQ(2, prologue_call_count); |
| 12086 CHECK_EQ(2, epilogue_call_count); | 12092 CHECK_EQ(2, epilogue_call_count); |
| 12087 CHECK_EQ(1, prologue_call_count_second); | 12093 CHECK_EQ(1, prologue_call_count_second); |
| 12088 CHECK_EQ(1, epilogue_call_count_second); | 12094 CHECK_EQ(1, epilogue_call_count_second); |
| 12089 v8::V8::RemoveGCPrologueCallback(PrologueCallback); | 12095 v8::V8::RemoveGCPrologueCallback(PrologueCallback); |
| 12090 v8::V8::RemoveGCEpilogueCallback(EpilogueCallback); | 12096 v8::V8::RemoveGCEpilogueCallback(EpilogueCallback); |
| 12091 i::Heap::CollectAllGarbage(false); | 12097 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 12092 CHECK_EQ(2, prologue_call_count); | 12098 CHECK_EQ(2, prologue_call_count); |
| 12093 CHECK_EQ(2, epilogue_call_count); | 12099 CHECK_EQ(2, epilogue_call_count); |
| 12094 CHECK_EQ(2, prologue_call_count_second); | 12100 CHECK_EQ(2, prologue_call_count_second); |
| 12095 CHECK_EQ(2, epilogue_call_count_second); | 12101 CHECK_EQ(2, epilogue_call_count_second); |
| 12096 v8::V8::RemoveGCPrologueCallback(PrologueCallbackSecond); | 12102 v8::V8::RemoveGCPrologueCallback(PrologueCallbackSecond); |
| 12097 v8::V8::RemoveGCEpilogueCallback(EpilogueCallbackSecond); | 12103 v8::V8::RemoveGCEpilogueCallback(EpilogueCallbackSecond); |
| 12098 i::Heap::CollectAllGarbage(false); | 12104 i::Heap::CollectAllGarbage(i::Heap::kNoGCFlags); |
| 12099 CHECK_EQ(2, prologue_call_count); | 12105 CHECK_EQ(2, prologue_call_count); |
| 12100 CHECK_EQ(2, epilogue_call_count); | 12106 CHECK_EQ(2, epilogue_call_count); |
| 12101 CHECK_EQ(2, prologue_call_count_second); | 12107 CHECK_EQ(2, prologue_call_count_second); |
| 12102 CHECK_EQ(2, epilogue_call_count_second); | 12108 CHECK_EQ(2, epilogue_call_count_second); |
| 12103 } | 12109 } |
| 12104 | 12110 |
| 12105 | 12111 |
| 12106 THREADED_TEST(AddToJSFunctionResultCache) { | 12112 THREADED_TEST(AddToJSFunctionResultCache) { |
| 12107 i::FLAG_allow_natives_syntax = true; | 12113 i::FLAG_allow_natives_syntax = true; |
| 12108 v8::HandleScope scope; | 12114 v8::HandleScope scope; |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12298 | 12304 |
| 12299 reresult = CompileRun("str2.charCodeAt(2);"); | 12305 reresult = CompileRun("str2.charCodeAt(2);"); |
| 12300 CHECK_EQ(static_cast<int32_t>('e'), reresult->Int32Value()); | 12306 CHECK_EQ(static_cast<int32_t>('e'), reresult->Int32Value()); |
| 12301 } | 12307 } |
| 12302 | 12308 |
| 12303 | 12309 |
| 12304 // Failed access check callback that performs a GC on each invocation. | 12310 // Failed access check callback that performs a GC on each invocation. |
| 12305 void FailedAccessCheckCallbackGC(Local<v8::Object> target, | 12311 void FailedAccessCheckCallbackGC(Local<v8::Object> target, |
| 12306 v8::AccessType type, | 12312 v8::AccessType type, |
| 12307 Local<v8::Value> data) { | 12313 Local<v8::Value> data) { |
| 12308 i::Heap::CollectAllGarbage(true); | 12314 i::Heap::CollectAllGarbage(i::Heap::kForceCompactionMask); |
| 12309 } | 12315 } |
| 12310 | 12316 |
| 12311 | 12317 |
| 12312 TEST(GCInFailedAccessCheckCallback) { | 12318 TEST(GCInFailedAccessCheckCallback) { |
| 12313 // Install a failed access check callback that performs a GC on each | 12319 // Install a failed access check callback that performs a GC on each |
| 12314 // invocation. Then force the callback to be called from va | 12320 // invocation. Then force the callback to be called from va |
| 12315 | 12321 |
| 12316 v8::V8::Initialize(); | 12322 v8::V8::Initialize(); |
| 12317 v8::V8::SetFailedAccessCheckCallbackFunction(&FailedAccessCheckCallbackGC); | 12323 v8::V8::SetFailedAccessCheckCallbackFunction(&FailedAccessCheckCallbackGC); |
| 12318 | 12324 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12482 ExpectBoolean("delete cell", true); | 12488 ExpectBoolean("delete cell", true); |
| 12483 ExpectString("(function() {" | 12489 ExpectString("(function() {" |
| 12484 " try {" | 12490 " try {" |
| 12485 " return readCell();" | 12491 " return readCell();" |
| 12486 " } catch(e) {" | 12492 " } catch(e) {" |
| 12487 " return e.toString();" | 12493 " return e.toString();" |
| 12488 " }" | 12494 " }" |
| 12489 "})()", | 12495 "})()", |
| 12490 "ReferenceError: cell is not defined"); | 12496 "ReferenceError: cell is not defined"); |
| 12491 CompileRun("cell = \"new_second\";"); | 12497 CompileRun("cell = \"new_second\";"); |
| 12492 i::Heap::CollectAllGarbage(true); | 12498 i::Heap::CollectAllGarbage(i::Heap::kForceCompactionMask); |
| 12493 ExpectString("readCell()", "new_second"); | 12499 ExpectString("readCell()", "new_second"); |
| 12494 ExpectString("readCell()", "new_second"); | 12500 ExpectString("readCell()", "new_second"); |
| 12495 } | 12501 } |
| 12496 } | 12502 } |
| 12497 | 12503 |
| 12498 | 12504 |
| 12499 TEST(DontDeleteCellLoadICForceDelete) { | 12505 TEST(DontDeleteCellLoadICForceDelete) { |
| 12500 const char* function_code = | 12506 const char* function_code = |
| 12501 "function readCell() { while (true) { return cell; } }"; | 12507 "function readCell() { while (true) { return cell; } }"; |
| 12502 | 12508 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12713 v8::Handle<v8::Function> define_property = | 12719 v8::Handle<v8::Function> define_property = |
| 12714 CompileRun("(function() {" | 12720 CompileRun("(function() {" |
| 12715 " Object.defineProperty(" | 12721 " Object.defineProperty(" |
| 12716 " this," | 12722 " this," |
| 12717 " 1," | 12723 " 1," |
| 12718 " { configurable: true, enumerable: true, value: 3 });" | 12724 " { configurable: true, enumerable: true, value: 3 });" |
| 12719 "})").As<Function>(); | 12725 "})").As<Function>(); |
| 12720 context->DetachGlobal(); | 12726 context->DetachGlobal(); |
| 12721 define_property->Call(proxy, 0, NULL); | 12727 define_property->Call(proxy, 0, NULL); |
| 12722 } | 12728 } |
| OLD | NEW |