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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 i::Heap::CollectGarbage(0, i::NEW_SPACE); // in survivor space now | 440 i::Heap::CollectGarbage(0, i::NEW_SPACE); // in survivor space now |
441 i::Heap::CollectGarbage(0, i::NEW_SPACE); // in old gen now | 441 i::Heap::CollectGarbage(0, i::NEW_SPACE); // in old gen now |
442 i::Handle<i::String> isymbol = i::Factory::SymbolFromString(istring); | 442 i::Handle<i::String> isymbol = i::Factory::SymbolFromString(istring); |
443 CHECK(isymbol->IsSymbol()); | 443 CHECK(isymbol->IsSymbol()); |
444 } | 444 } |
445 i::Heap::CollectAllGarbage(false); | 445 i::Heap::CollectAllGarbage(false); |
446 i::Heap::CollectAllGarbage(false); | 446 i::Heap::CollectAllGarbage(false); |
447 } | 447 } |
448 | 448 |
449 | 449 |
| 450 THREADED_TEST(ScavengeExternalString) { |
| 451 TestResource::dispose_count = 0; |
| 452 { |
| 453 v8::HandleScope scope; |
| 454 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); |
| 455 Local<String> string = |
| 456 String::NewExternal(new TestResource(two_byte_string)); |
| 457 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); |
| 458 i::Heap::CollectGarbage(0, i::NEW_SPACE); |
| 459 CHECK(i::Heap::InNewSpace(*istring)); |
| 460 CHECK_EQ(0, TestResource::dispose_count); |
| 461 } |
| 462 i::Heap::CollectGarbage(0, i::NEW_SPACE); |
| 463 CHECK_EQ(1, TestResource::dispose_count); |
| 464 } |
| 465 |
| 466 |
| 467 THREADED_TEST(ScavengeExternalAsciiString) { |
| 468 TestAsciiResource::dispose_count = 0; |
| 469 { |
| 470 v8::HandleScope scope; |
| 471 const char* one_byte_string = "test string"; |
| 472 Local<String> string = String::NewExternal( |
| 473 new TestAsciiResource(i::StrDup(one_byte_string))); |
| 474 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); |
| 475 i::Heap::CollectGarbage(0, i::NEW_SPACE); |
| 476 CHECK(i::Heap::InNewSpace(*istring)); |
| 477 CHECK_EQ(0, TestAsciiResource::dispose_count); |
| 478 } |
| 479 i::Heap::CollectGarbage(0, i::NEW_SPACE); |
| 480 CHECK_EQ(1, TestAsciiResource::dispose_count); |
| 481 } |
| 482 |
| 483 |
450 THREADED_TEST(StringConcat) { | 484 THREADED_TEST(StringConcat) { |
451 { | 485 { |
452 v8::HandleScope scope; | 486 v8::HandleScope scope; |
453 LocalContext env; | 487 LocalContext env; |
454 const char* one_byte_string_1 = "function a_times_t"; | 488 const char* one_byte_string_1 = "function a_times_t"; |
455 const char* two_byte_string_1 = "wo_plus_b(a, b) {return "; | 489 const char* two_byte_string_1 = "wo_plus_b(a, b) {return "; |
456 const char* one_byte_extern_1 = "a * 2 + b;} a_times_two_plus_b(4, 8) + "; | 490 const char* one_byte_extern_1 = "a * 2 + b;} a_times_two_plus_b(4, 8) + "; |
457 const char* two_byte_extern_1 = "a_times_two_plus_b(4, 8) + "; | 491 const char* two_byte_extern_1 = "a_times_two_plus_b(4, 8) + "; |
458 const char* one_byte_string_2 = "a_times_two_plus_b(4, 8) + "; | 492 const char* one_byte_string_2 = "a_times_two_plus_b(4, 8) + "; |
459 const char* two_byte_string_2 = "a_times_two_plus_b(4, 8) + "; | 493 const char* two_byte_string_2 = "a_times_two_plus_b(4, 8) + "; |
(...skipping 8145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8605 CompileRun(source_exception); | 8639 CompileRun(source_exception); |
8606 other_context->Exit(); | 8640 other_context->Exit(); |
8607 v8::internal::Heap::CollectAllGarbage(false); | 8641 v8::internal::Heap::CollectAllGarbage(false); |
8608 if (GetGlobalObjectsCount() == 1) break; | 8642 if (GetGlobalObjectsCount() == 1) break; |
8609 } | 8643 } |
8610 CHECK_GE(2, gc_count); | 8644 CHECK_GE(2, gc_count); |
8611 CHECK_EQ(1, GetGlobalObjectsCount()); | 8645 CHECK_EQ(1, GetGlobalObjectsCount()); |
8612 | 8646 |
8613 other_context.Dispose(); | 8647 other_context.Dispose(); |
8614 } | 8648 } |
OLD | NEW |