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

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

Issue 8551006: Version 3.7.9. (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/x64/lithium-x64.cc ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 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 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 484
485 485
486 TEST(MakingExternalStringConditions) { 486 TEST(MakingExternalStringConditions) {
487 v8::HandleScope scope; 487 v8::HandleScope scope;
488 LocalContext env; 488 LocalContext env;
489 489
490 // Free some space in the new space so that we can check freshness. 490 // Free some space in the new space so that we can check freshness.
491 HEAP->CollectGarbage(i::NEW_SPACE); 491 HEAP->CollectGarbage(i::NEW_SPACE);
492 HEAP->CollectGarbage(i::NEW_SPACE); 492 HEAP->CollectGarbage(i::NEW_SPACE);
493 493
494 uint16_t* two_byte_string = AsciiToTwoByteString("small"); 494 uint16_t* two_byte_string = AsciiToTwoByteString("abcdefghi");
495 Local<String> small_string = String::New(two_byte_string); 495 Local<String> small_string = String::New(two_byte_string);
496 i::DeleteArray(two_byte_string); 496 i::DeleteArray(two_byte_string);
497 497
498 // We should refuse to externalize newly created small string. 498 // We should refuse to externalize newly created small string.
499 CHECK(!small_string->CanMakeExternal()); 499 CHECK(!small_string->CanMakeExternal());
500 // Trigger GCs so that the newly allocated string moves to old gen. 500 // Trigger GCs so that the newly allocated string moves to old gen.
501 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now 501 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now
502 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now 502 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now
503 // Old space strings should be accepted. 503 // Old space strings should be accepted.
504 CHECK(small_string->CanMakeExternal()); 504 CHECK(small_string->CanMakeExternal());
505 505
506 two_byte_string = AsciiToTwoByteString("small 2"); 506 two_byte_string = AsciiToTwoByteString("abcdefghi");
507 small_string = String::New(two_byte_string); 507 small_string = String::New(two_byte_string);
508 i::DeleteArray(two_byte_string); 508 i::DeleteArray(two_byte_string);
509 509
510 // We should refuse externalizing newly created small string. 510 // We should refuse externalizing newly created small string.
511 CHECK(!small_string->CanMakeExternal()); 511 CHECK(!small_string->CanMakeExternal());
512 for (int i = 0; i < 100; i++) { 512 for (int i = 0; i < 100; i++) {
513 String::Value value(small_string); 513 String::Value value(small_string);
514 } 514 }
515 // Frequently used strings should be accepted. 515 // Frequently used strings should be accepted.
516 CHECK(small_string->CanMakeExternal()); 516 CHECK(small_string->CanMakeExternal());
(...skipping 13 matching lines...) Expand all
530 530
531 531
532 TEST(MakingExternalAsciiStringConditions) { 532 TEST(MakingExternalAsciiStringConditions) {
533 v8::HandleScope scope; 533 v8::HandleScope scope;
534 LocalContext env; 534 LocalContext env;
535 535
536 // Free some space in the new space so that we can check freshness. 536 // Free some space in the new space so that we can check freshness.
537 HEAP->CollectGarbage(i::NEW_SPACE); 537 HEAP->CollectGarbage(i::NEW_SPACE);
538 HEAP->CollectGarbage(i::NEW_SPACE); 538 HEAP->CollectGarbage(i::NEW_SPACE);
539 539
540 Local<String> small_string = String::New("small"); 540 Local<String> small_string = String::New("abcdefghi");
541 // We should refuse to externalize newly created small string. 541 // We should refuse to externalize newly created small string.
542 CHECK(!small_string->CanMakeExternal()); 542 CHECK(!small_string->CanMakeExternal());
543 // Trigger GCs so that the newly allocated string moves to old gen. 543 // Trigger GCs so that the newly allocated string moves to old gen.
544 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now 544 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now
545 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now 545 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now
546 // Old space strings should be accepted. 546 // Old space strings should be accepted.
547 CHECK(small_string->CanMakeExternal()); 547 CHECK(small_string->CanMakeExternal());
548 548
549 small_string = String::New("small 2"); 549 small_string = String::New("abcdefghi");
550 // We should refuse externalizing newly created small string. 550 // We should refuse externalizing newly created small string.
551 CHECK(!small_string->CanMakeExternal()); 551 CHECK(!small_string->CanMakeExternal());
552 for (int i = 0; i < 100; i++) { 552 for (int i = 0; i < 100; i++) {
553 String::Value value(small_string); 553 String::Value value(small_string);
554 } 554 }
555 // Frequently used strings should be accepted. 555 // Frequently used strings should be accepted.
556 CHECK(small_string->CanMakeExternal()); 556 CHECK(small_string->CanMakeExternal());
557 557
558 const int buf_size = 10 * 1024; 558 const int buf_size = 10 * 1024;
559 char* buf = i::NewArray<char>(buf_size); 559 char* buf = i::NewArray<char>(buf_size);
(...skipping 15030 matching lines...) Expand 10 before | Expand all | Expand 10 after
15590 CHECK(i->Equals(CompileRun("'abcbd'.replace(/b/g,func)[3]"))); 15590 CHECK(i->Equals(CompileRun("'abcbd'.replace(/b/g,func)[3]")));
15591 15591
15592 // TODO(1547): Make the following also return "i". 15592 // TODO(1547): Make the following also return "i".
15593 // Calling with environment record as base. 15593 // Calling with environment record as base.
15594 TestReceiver(o, context->Global(), "func()"); 15594 TestReceiver(o, context->Global(), "func()");
15595 // Calling with no base. 15595 // Calling with no base.
15596 TestReceiver(o, context->Global(), "(1,func)()"); 15596 TestReceiver(o, context->Global(), "(1,func)()");
15597 15597
15598 foreign_context.Dispose(); 15598 foreign_context.Dispose();
15599 } 15599 }
OLDNEW
« no previous file with comments | « src/x64/lithium-x64.cc ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698