Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 static uint16_t* AsciiToTwoByteString(const char* source) { | 324 static uint16_t* AsciiToTwoByteString(const char* source) { |
| 325 int array_length = i::StrLength(source) + 1; | 325 int array_length = i::StrLength(source) + 1; |
| 326 uint16_t* converted = i::NewArray<uint16_t>(array_length); | 326 uint16_t* converted = i::NewArray<uint16_t>(array_length); |
| 327 for (int i = 0; i < array_length; i++) converted[i] = source[i]; | 327 for (int i = 0; i < array_length; i++) converted[i] = source[i]; |
| 328 return converted; | 328 return converted; |
| 329 } | 329 } |
| 330 | 330 |
| 331 | 331 |
| 332 class TestResource: public String::ExternalStringResource { | 332 class TestResource: public String::ExternalStringResource { |
| 333 public: | 333 public: |
| 334 static int dispose_count; | 334 explicit TestResource(uint16_t* data, int* counter = NULL) |
| 335 | 335 : data_(data), length_(0), counter_(counter) { |
| 336 explicit TestResource(uint16_t* data) | |
| 337 : data_(data), length_(0) { | |
| 338 while (data[length_]) ++length_; | 336 while (data[length_]) ++length_; |
| 339 } | 337 } |
| 340 | 338 |
| 341 ~TestResource() { | 339 ~TestResource() { |
| 342 i::DeleteArray(data_); | 340 i::DeleteArray(data_); |
| 343 ++dispose_count; | 341 if (counter_ != NULL) ++*counter_; |
| 344 } | 342 } |
| 345 | 343 |
| 346 const uint16_t* data() const { | 344 const uint16_t* data() const { |
| 347 return data_; | 345 return data_; |
| 348 } | 346 } |
| 349 | 347 |
| 350 size_t length() const { | 348 size_t length() const { |
| 351 return length_; | 349 return length_; |
| 352 } | 350 } |
| 353 private: | 351 private: |
| 354 uint16_t* data_; | 352 uint16_t* data_; |
| 355 size_t length_; | 353 size_t length_; |
| 354 int* counter_; | |
| 356 }; | 355 }; |
| 357 | 356 |
| 358 | 357 |
| 359 int TestResource::dispose_count = 0; | |
| 360 | |
| 361 | |
| 362 class TestAsciiResource: public String::ExternalAsciiStringResource { | 358 class TestAsciiResource: public String::ExternalAsciiStringResource { |
| 363 public: | 359 public: |
| 364 static int dispose_count; | 360 explicit TestAsciiResource(const char* data, int* counter = NULL) |
| 365 | 361 : data_(data), length_(strlen(data)), counter_(counter) { } |
| 366 explicit TestAsciiResource(const char* data) | |
| 367 : data_(data), | |
| 368 length_(strlen(data)) { } | |
| 369 | 362 |
| 370 ~TestAsciiResource() { | 363 ~TestAsciiResource() { |
| 371 i::DeleteArray(data_); | 364 i::DeleteArray(data_); |
| 372 ++dispose_count; | 365 if (counter_ != NULL) ++*counter_; |
| 373 } | 366 } |
| 374 | 367 |
| 375 const char* data() const { | 368 const char* data() const { |
| 376 return data_; | 369 return data_; |
| 377 } | 370 } |
| 378 | 371 |
| 379 size_t length() const { | 372 size_t length() const { |
| 380 return length_; | 373 return length_; |
| 381 } | 374 } |
| 382 private: | 375 private: |
| 383 const char* data_; | 376 const char* data_; |
| 384 size_t length_; | 377 size_t length_; |
| 378 int* counter_; | |
| 385 }; | 379 }; |
| 386 | 380 |
| 387 | 381 |
| 388 int TestAsciiResource::dispose_count = 0; | |
| 389 | |
| 390 | |
| 391 THREADED_TEST(ScriptUsingStringResource) { | 382 THREADED_TEST(ScriptUsingStringResource) { |
| 392 TestResource::dispose_count = 0; | 383 int dispose_count = 0; |
| 393 const char* c_source = "1 + 2 * 3"; | 384 const char* c_source = "1 + 2 * 3"; |
| 394 uint16_t* two_byte_source = AsciiToTwoByteString(c_source); | 385 uint16_t* two_byte_source = AsciiToTwoByteString(c_source); |
| 395 { | 386 { |
| 396 v8::HandleScope scope; | 387 v8::HandleScope scope; |
| 397 LocalContext env; | 388 LocalContext env; |
| 398 TestResource* resource = new TestResource(two_byte_source); | 389 TestResource* resource = new TestResource(two_byte_source, &dispose_count); |
| 399 Local<String> source = String::NewExternal(resource); | 390 Local<String> source = String::NewExternal(resource); |
| 400 Local<Script> script = Script::Compile(source); | 391 Local<Script> script = Script::Compile(source); |
| 401 Local<Value> value = script->Run(); | 392 Local<Value> value = script->Run(); |
| 402 CHECK(value->IsNumber()); | 393 CHECK(value->IsNumber()); |
| 403 CHECK_EQ(7, value->Int32Value()); | 394 CHECK_EQ(7, value->Int32Value()); |
| 404 CHECK(source->IsExternal()); | 395 CHECK(source->IsExternal()); |
| 405 CHECK_EQ(resource, | 396 CHECK_EQ(resource, |
| 406 static_cast<TestResource*>(source->GetExternalStringResource())); | 397 static_cast<TestResource*>(source->GetExternalStringResource())); |
| 407 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 398 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 408 CHECK_EQ(0, TestResource::dispose_count); | 399 CHECK_EQ(0, dispose_count); |
| 409 } | 400 } |
| 410 i::Isolate::Current()->compilation_cache()->Clear(); | 401 i::Isolate::Current()->compilation_cache()->Clear(); |
| 402 if (HEAP->incremental_marking()->IsMarking()) { | |
|
Vyacheslav Egorov (Chromium)
2011/08/11 11:37:24
Maybe we should always abort incremental marking w
Lasse Reichstein
2011/08/11 12:20:13
Actaully CollectAllAvailableGarbage does use the k
| |
| 403 // Incremental marking might already have marked the string. | |
| 404 // We need to start a GC from scratch to ensure that it will be collected. | |
| 405 HEAP->incremental_marking()->Abort(); | |
| 406 } | |
| 411 HEAP->CollectAllAvailableGarbage(); | 407 HEAP->CollectAllAvailableGarbage(); |
| 412 CHECK_EQ(1, TestResource::dispose_count); | 408 CHECK_EQ(1, dispose_count); |
| 413 } | 409 } |
| 414 | 410 |
| 415 | 411 |
| 416 THREADED_TEST(ScriptUsingAsciiStringResource) { | 412 THREADED_TEST(ScriptUsingAsciiStringResource) { |
| 417 TestAsciiResource::dispose_count = 0; | 413 int dispose_count = 0; |
| 418 const char* c_source = "1 + 2 * 3"; | 414 const char* c_source = "1 + 2 * 3"; |
| 419 { | 415 { |
| 420 v8::HandleScope scope; | 416 v8::HandleScope scope; |
| 421 LocalContext env; | 417 LocalContext env; |
| 422 Local<String> source = | 418 Local<String> source = |
| 423 String::NewExternal(new TestAsciiResource(i::StrDup(c_source))); | 419 String::NewExternal(new TestAsciiResource(i::StrDup(c_source), |
| 420 &dispose_count)); | |
| 424 Local<Script> script = Script::Compile(source); | 421 Local<Script> script = Script::Compile(source); |
| 425 Local<Value> value = script->Run(); | 422 Local<Value> value = script->Run(); |
| 426 CHECK(value->IsNumber()); | 423 CHECK(value->IsNumber()); |
| 427 CHECK_EQ(7, value->Int32Value()); | 424 CHECK_EQ(7, value->Int32Value()); |
| 428 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 425 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 429 CHECK_EQ(0, TestAsciiResource::dispose_count); | 426 CHECK_EQ(0, dispose_count); |
| 430 } | 427 } |
| 431 i::Isolate::Current()->compilation_cache()->Clear(); | 428 i::Isolate::Current()->compilation_cache()->Clear(); |
| 429 if (HEAP->incremental_marking()->IsMarking()) { | |
| 430 HEAP->incremental_marking()->Abort(); | |
| 431 } | |
| 432 HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask); | 432 HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask); |
| 433 CHECK_EQ(1, TestAsciiResource::dispose_count); | 433 CHECK_EQ(1, dispose_count); |
| 434 } | 434 } |
| 435 | 435 |
| 436 | 436 |
| 437 THREADED_TEST(ScriptMakingExternalString) { | 437 THREADED_TEST(ScriptMakingExternalString) { |
| 438 TestResource::dispose_count = 0; | 438 int dispose_count = 0; |
| 439 uint16_t* two_byte_source = AsciiToTwoByteString("1 + 2 * 3"); | 439 uint16_t* two_byte_source = AsciiToTwoByteString("1 + 2 * 3"); |
| 440 { | 440 { |
| 441 v8::HandleScope scope; | 441 v8::HandleScope scope; |
| 442 LocalContext env; | 442 LocalContext env; |
| 443 Local<String> source = String::New(two_byte_source); | 443 Local<String> source = String::New(two_byte_source); |
| 444 // Trigger GCs so that the newly allocated string moves to old gen. | 444 // Trigger GCs so that the newly allocated string moves to old gen. |
| 445 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now | 445 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now |
| 446 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now | 446 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now |
| 447 bool success = source->MakeExternal(new TestResource(two_byte_source)); | 447 bool success = source->MakeExternal(new TestResource(two_byte_source, |
| 448 &dispose_count)); | |
| 448 CHECK(success); | 449 CHECK(success); |
| 449 Local<Script> script = Script::Compile(source); | 450 Local<Script> script = Script::Compile(source); |
| 450 Local<Value> value = script->Run(); | 451 Local<Value> value = script->Run(); |
| 451 CHECK(value->IsNumber()); | 452 CHECK(value->IsNumber()); |
| 452 CHECK_EQ(7, value->Int32Value()); | 453 CHECK_EQ(7, value->Int32Value()); |
| 453 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 454 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 454 CHECK_EQ(0, TestResource::dispose_count); | 455 CHECK_EQ(0, dispose_count); |
| 455 } | 456 } |
| 456 i::Isolate::Current()->compilation_cache()->Clear(); | 457 i::Isolate::Current()->compilation_cache()->Clear(); |
| 458 if (HEAP->incremental_marking()->IsMarking()) { | |
| 459 HEAP->incremental_marking()->Abort(); | |
| 460 } | |
| 457 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 461 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 458 CHECK_EQ(1, TestResource::dispose_count); | 462 CHECK_EQ(1, dispose_count); |
| 459 } | 463 } |
| 460 | 464 |
| 461 | 465 |
| 462 THREADED_TEST(ScriptMakingExternalAsciiString) { | 466 THREADED_TEST(ScriptMakingExternalAsciiString) { |
| 463 TestAsciiResource::dispose_count = 0; | 467 int dispose_count = 0; |
| 464 const char* c_source = "1 + 2 * 3"; | 468 const char* c_source = "1 + 2 * 3"; |
| 465 { | 469 { |
| 466 v8::HandleScope scope; | 470 v8::HandleScope scope; |
| 467 LocalContext env; | 471 LocalContext env; |
| 468 Local<String> source = v8_str(c_source); | 472 Local<String> source = v8_str(c_source); |
| 469 // Trigger GCs so that the newly allocated string moves to old gen. | 473 // Trigger GCs so that the newly allocated string moves to old gen. |
| 470 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now | 474 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now |
| 471 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now | 475 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now |
| 472 bool success = source->MakeExternal( | 476 bool success = source->MakeExternal( |
| 473 new TestAsciiResource(i::StrDup(c_source))); | 477 new TestAsciiResource(i::StrDup(c_source), &dispose_count)); |
| 474 CHECK(success); | 478 CHECK(success); |
| 475 Local<Script> script = Script::Compile(source); | 479 Local<Script> script = Script::Compile(source); |
| 476 Local<Value> value = script->Run(); | 480 Local<Value> value = script->Run(); |
| 477 CHECK(value->IsNumber()); | 481 CHECK(value->IsNumber()); |
| 478 CHECK_EQ(7, value->Int32Value()); | 482 CHECK_EQ(7, value->Int32Value()); |
| 479 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 483 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 480 CHECK_EQ(0, TestAsciiResource::dispose_count); | 484 CHECK_EQ(0, dispose_count); |
| 481 } | 485 } |
| 482 i::Isolate::Current()->compilation_cache()->Clear(); | 486 i::Isolate::Current()->compilation_cache()->Clear(); |
| 487 if (HEAP->incremental_marking()->IsMarking()) { | |
| 488 HEAP->incremental_marking()->Abort(); | |
| 489 } | |
| 483 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 490 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 484 CHECK_EQ(1, TestAsciiResource::dispose_count); | 491 CHECK_EQ(1, dispose_count); |
| 485 } | 492 } |
| 486 | 493 |
| 487 | 494 |
| 488 TEST(MakingExternalStringConditions) { | 495 TEST(MakingExternalStringConditions) { |
| 489 v8::HandleScope scope; | 496 v8::HandleScope scope; |
| 490 LocalContext env; | 497 LocalContext env; |
| 491 | 498 |
| 492 // Free some space in the new space so that we can check freshness. | 499 // Free some space in the new space so that we can check freshness. |
| 493 HEAP->CollectGarbage(i::NEW_SPACE); | 500 HEAP->CollectGarbage(i::NEW_SPACE); |
| 494 HEAP->CollectGarbage(i::NEW_SPACE); | 501 HEAP->CollectGarbage(i::NEW_SPACE); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 598 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now | 605 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now |
| 599 i::Handle<i::String> isymbol = FACTORY->SymbolFromString(istring); | 606 i::Handle<i::String> isymbol = FACTORY->SymbolFromString(istring); |
| 600 CHECK(isymbol->IsSymbol()); | 607 CHECK(isymbol->IsSymbol()); |
| 601 } | 608 } |
| 602 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 609 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 603 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 610 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 604 } | 611 } |
| 605 | 612 |
| 606 | 613 |
| 607 THREADED_TEST(ScavengeExternalString) { | 614 THREADED_TEST(ScavengeExternalString) { |
| 608 TestResource::dispose_count = 0; | 615 int dispose_count = 0; |
| 609 bool in_new_space = false; | 616 bool in_new_space = false; |
| 610 { | 617 { |
| 611 v8::HandleScope scope; | 618 v8::HandleScope scope; |
| 612 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); | 619 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); |
| 613 Local<String> string = | 620 Local<String> string = |
| 614 String::NewExternal(new TestResource(two_byte_string)); | 621 String::NewExternal(new TestResource(two_byte_string, |
| 622 &dispose_count)); | |
| 615 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); | 623 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); |
| 616 HEAP->CollectGarbage(i::NEW_SPACE); | 624 HEAP->CollectGarbage(i::NEW_SPACE); |
| 617 in_new_space = HEAP->InNewSpace(*istring); | 625 in_new_space = HEAP->InNewSpace(*istring); |
| 618 CHECK(in_new_space || HEAP->old_data_space()->Contains(*istring)); | 626 CHECK(in_new_space || HEAP->old_data_space()->Contains(*istring)); |
| 619 CHECK_EQ(0, TestResource::dispose_count); | 627 CHECK_EQ(0, dispose_count); |
| 620 } | 628 } |
| 621 HEAP->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE); | 629 HEAP->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE); |
| 622 CHECK_EQ(1, TestResource::dispose_count); | 630 CHECK_EQ(1, dispose_count); |
| 623 } | 631 } |
| 624 | 632 |
| 625 | 633 |
| 626 THREADED_TEST(ScavengeExternalAsciiString) { | 634 THREADED_TEST(ScavengeExternalAsciiString) { |
| 627 TestAsciiResource::dispose_count = 0; | 635 int dispose_count = 0; |
| 628 bool in_new_space = false; | 636 bool in_new_space = false; |
| 629 { | 637 { |
| 630 v8::HandleScope scope; | 638 v8::HandleScope scope; |
| 631 const char* one_byte_string = "test string"; | 639 const char* one_byte_string = "test string"; |
| 632 Local<String> string = String::NewExternal( | 640 Local<String> string = String::NewExternal( |
| 633 new TestAsciiResource(i::StrDup(one_byte_string))); | 641 new TestAsciiResource(i::StrDup(one_byte_string), &dispose_count)); |
| 634 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); | 642 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); |
| 635 HEAP->CollectGarbage(i::NEW_SPACE); | 643 HEAP->CollectGarbage(i::NEW_SPACE); |
| 636 in_new_space = HEAP->InNewSpace(*istring); | 644 in_new_space = HEAP->InNewSpace(*istring); |
| 637 CHECK(in_new_space || HEAP->old_data_space()->Contains(*istring)); | 645 CHECK(in_new_space || HEAP->old_data_space()->Contains(*istring)); |
| 638 CHECK_EQ(0, TestAsciiResource::dispose_count); | 646 CHECK_EQ(0, dispose_count); |
| 639 } | 647 } |
| 640 HEAP->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE); | 648 HEAP->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE); |
| 641 CHECK_EQ(1, TestAsciiResource::dispose_count); | 649 CHECK_EQ(1, dispose_count); |
| 642 } | 650 } |
| 643 | 651 |
| 644 | 652 |
| 645 class TestAsciiResourceWithDisposeControl: public TestAsciiResource { | 653 class TestAsciiResourceWithDisposeControl: public TestAsciiResource { |
| 646 public: | 654 public: |
| 655 // Only used by non-threaded tests, so it can use static fields. | |
| 647 static int dispose_calls; | 656 static int dispose_calls; |
| 657 static int dispose_count; | |
| 648 | 658 |
| 649 TestAsciiResourceWithDisposeControl(const char* data, bool dispose) | 659 TestAsciiResourceWithDisposeControl(const char* data, bool dispose) |
| 650 : TestAsciiResource(data), | 660 : TestAsciiResource(data, &dispose_count), |
| 651 dispose_(dispose) { } | 661 dispose_(dispose) { } |
| 652 | 662 |
| 653 void Dispose() { | 663 void Dispose() { |
| 654 ++dispose_calls; | 664 ++dispose_calls; |
| 655 if (dispose_) delete this; | 665 if (dispose_) delete this; |
| 656 } | 666 } |
| 657 private: | 667 private: |
| 658 bool dispose_; | 668 bool dispose_; |
| 659 }; | 669 }; |
| 660 | 670 |
| 661 | 671 |
| 672 int TestAsciiResourceWithDisposeControl::dispose_count = 0; | |
| 662 int TestAsciiResourceWithDisposeControl::dispose_calls = 0; | 673 int TestAsciiResourceWithDisposeControl::dispose_calls = 0; |
| 663 | 674 |
| 664 | 675 |
| 665 TEST(ExternalStringWithDisposeHandling) { | 676 TEST(ExternalStringWithDisposeHandling) { |
| 666 const char* c_source = "1 + 2 * 3"; | 677 const char* c_source = "1 + 2 * 3"; |
| 667 | 678 |
| 668 // Use a stack allocated external string resource allocated object. | 679 // Use a stack allocated external string resource allocated object. |
| 669 TestAsciiResource::dispose_count = 0; | 680 TestAsciiResourceWithDisposeControl::dispose_count = 0; |
| 670 TestAsciiResourceWithDisposeControl::dispose_calls = 0; | 681 TestAsciiResourceWithDisposeControl::dispose_calls = 0; |
| 671 TestAsciiResourceWithDisposeControl res_stack(i::StrDup(c_source), false); | 682 TestAsciiResourceWithDisposeControl res_stack(i::StrDup(c_source), false); |
| 672 { | 683 { |
| 673 v8::HandleScope scope; | 684 v8::HandleScope scope; |
| 674 LocalContext env; | 685 LocalContext env; |
| 675 Local<String> source = String::NewExternal(&res_stack); | 686 Local<String> source = String::NewExternal(&res_stack); |
| 676 Local<Script> script = Script::Compile(source); | 687 Local<Script> script = Script::Compile(source); |
| 677 Local<Value> value = script->Run(); | 688 Local<Value> value = script->Run(); |
| 678 CHECK(value->IsNumber()); | 689 CHECK(value->IsNumber()); |
| 679 CHECK_EQ(7, value->Int32Value()); | 690 CHECK_EQ(7, value->Int32Value()); |
| 680 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 691 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 681 CHECK_EQ(0, TestAsciiResource::dispose_count); | 692 CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); |
| 682 } | 693 } |
| 683 i::Isolate::Current()->compilation_cache()->Clear(); | 694 i::Isolate::Current()->compilation_cache()->Clear(); |
| 695 if (HEAP->incremental_marking()->IsMarking()) { | |
| 696 HEAP->incremental_marking()->Abort(); | |
| 697 } | |
| 684 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 698 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 685 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); | 699 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); |
| 686 CHECK_EQ(0, TestAsciiResource::dispose_count); | 700 CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); |
| 687 | 701 |
| 688 // Use a heap allocated external string resource allocated object. | 702 // Use a heap allocated external string resource allocated object. |
| 689 TestAsciiResource::dispose_count = 0; | 703 TestAsciiResourceWithDisposeControl::dispose_count = 0; |
| 690 TestAsciiResourceWithDisposeControl::dispose_calls = 0; | 704 TestAsciiResourceWithDisposeControl::dispose_calls = 0; |
| 691 TestAsciiResource* res_heap = | 705 TestAsciiResource* res_heap = |
| 692 new TestAsciiResourceWithDisposeControl(i::StrDup(c_source), true); | 706 new TestAsciiResourceWithDisposeControl(i::StrDup(c_source), true); |
| 693 { | 707 { |
| 694 v8::HandleScope scope; | 708 v8::HandleScope scope; |
| 695 LocalContext env; | 709 LocalContext env; |
| 696 Local<String> source = String::NewExternal(res_heap); | 710 Local<String> source = String::NewExternal(res_heap); |
| 697 Local<Script> script = Script::Compile(source); | 711 Local<Script> script = Script::Compile(source); |
| 698 Local<Value> value = script->Run(); | 712 Local<Value> value = script->Run(); |
| 699 CHECK(value->IsNumber()); | 713 CHECK(value->IsNumber()); |
| 700 CHECK_EQ(7, value->Int32Value()); | 714 CHECK_EQ(7, value->Int32Value()); |
| 701 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 715 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 702 CHECK_EQ(0, TestAsciiResource::dispose_count); | 716 CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); |
| 703 } | 717 } |
| 704 i::Isolate::Current()->compilation_cache()->Clear(); | 718 i::Isolate::Current()->compilation_cache()->Clear(); |
| 719 if (HEAP->incremental_marking()->IsMarking()) { | |
| 720 HEAP->incremental_marking()->Abort(); | |
| 721 } | |
| 705 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 722 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 706 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); | 723 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); |
| 707 CHECK_EQ(1, TestAsciiResource::dispose_count); | 724 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_count); |
| 708 } | 725 } |
| 709 | 726 |
| 710 | 727 |
| 711 THREADED_TEST(StringConcat) { | 728 THREADED_TEST(StringConcat) { |
| 712 { | 729 { |
| 713 v8::HandleScope scope; | 730 v8::HandleScope scope; |
| 714 LocalContext env; | 731 LocalContext env; |
| 715 const char* one_byte_string_1 = "function a_times_t"; | 732 const char* one_byte_string_1 = "function a_times_t"; |
| 716 const char* two_byte_string_1 = "wo_plus_b(a, b) {return "; | 733 const char* two_byte_string_1 = "wo_plus_b(a, b) {return "; |
| 717 const char* one_byte_extern_1 = "a * 2 + b;} a_times_two_plus_b(4, 8) + "; | 734 const char* one_byte_extern_1 = "a * 2 + b;} a_times_two_plus_b(4, 8) + "; |
| (...skipping 14117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 14835 } | 14852 } |
| 14836 | 14853 |
| 14837 i::Isolate::Current()->heap()->CollectAllGarbage(true); | 14854 i::Isolate::Current()->heap()->CollectAllGarbage(true); |
| 14838 { i::Object* raw_map_cache = i::Isolate::Current()->context()->map_cache(); | 14855 { i::Object* raw_map_cache = i::Isolate::Current()->context()->map_cache(); |
| 14839 if (raw_map_cache != i::Isolate::Current()->heap()->undefined_value()) { | 14856 if (raw_map_cache != i::Isolate::Current()->heap()->undefined_value()) { |
| 14840 i::MapCache* map_cache = i::MapCache::cast(raw_map_cache); | 14857 i::MapCache* map_cache = i::MapCache::cast(raw_map_cache); |
| 14841 CHECK_GT(elements, map_cache->NumberOfElements()); | 14858 CHECK_GT(elements, map_cache->NumberOfElements()); |
| 14842 } | 14859 } |
| 14843 } | 14860 } |
| 14844 } | 14861 } |
| OLD | NEW |