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

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

Issue 2867013: [Isolates] CompilationCache was moved to Isolate. (Closed) Base URL: git@github.com:v8isolate/v8isolates.git
Patch Set: Created 10 years, 6 months 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
« no previous file with comments | « src/jsregexp.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 Local<Script> script = Script::Compile(source); 377 Local<Script> script = Script::Compile(source);
378 Local<Value> value = script->Run(); 378 Local<Value> value = script->Run();
379 CHECK(value->IsNumber()); 379 CHECK(value->IsNumber());
380 CHECK_EQ(7, value->Int32Value()); 380 CHECK_EQ(7, value->Int32Value());
381 CHECK(source->IsExternal()); 381 CHECK(source->IsExternal());
382 CHECK_EQ(resource, 382 CHECK_EQ(resource,
383 static_cast<TestResource*>(source->GetExternalStringResource())); 383 static_cast<TestResource*>(source->GetExternalStringResource()));
384 HEAP->CollectAllGarbage(false); 384 HEAP->CollectAllGarbage(false);
385 CHECK_EQ(0, TestResource::dispose_count); 385 CHECK_EQ(0, TestResource::dispose_count);
386 } 386 }
387 v8::internal::CompilationCache::Clear(); 387 v8::internal::Isolate::Current()->compilation_cache()->Clear();
388 HEAP->CollectAllGarbage(false); 388 HEAP->CollectAllGarbage(false);
389 CHECK_EQ(1, TestResource::dispose_count); 389 CHECK_EQ(1, TestResource::dispose_count);
390 } 390 }
391 391
392 392
393 THREADED_TEST(ScriptUsingAsciiStringResource) { 393 THREADED_TEST(ScriptUsingAsciiStringResource) {
394 TestAsciiResource::dispose_count = 0; 394 TestAsciiResource::dispose_count = 0;
395 const char* c_source = "1 + 2 * 3"; 395 const char* c_source = "1 + 2 * 3";
396 { 396 {
397 v8::HandleScope scope; 397 v8::HandleScope scope;
398 LocalContext env; 398 LocalContext env;
399 Local<String> source = 399 Local<String> source =
400 String::NewExternal(new TestAsciiResource(i::StrDup(c_source))); 400 String::NewExternal(new TestAsciiResource(i::StrDup(c_source)));
401 Local<Script> script = Script::Compile(source); 401 Local<Script> script = Script::Compile(source);
402 Local<Value> value = script->Run(); 402 Local<Value> value = script->Run();
403 CHECK(value->IsNumber()); 403 CHECK(value->IsNumber());
404 CHECK_EQ(7, value->Int32Value()); 404 CHECK_EQ(7, value->Int32Value());
405 HEAP->CollectAllGarbage(false); 405 HEAP->CollectAllGarbage(false);
406 CHECK_EQ(0, TestAsciiResource::dispose_count); 406 CHECK_EQ(0, TestAsciiResource::dispose_count);
407 } 407 }
408 v8::internal::CompilationCache::Clear(); 408 v8::internal::Isolate::Current()->compilation_cache()->Clear();
409 HEAP->CollectAllGarbage(false); 409 HEAP->CollectAllGarbage(false);
410 CHECK_EQ(1, TestAsciiResource::dispose_count); 410 CHECK_EQ(1, TestAsciiResource::dispose_count);
411 } 411 }
412 412
413 413
414 THREADED_TEST(ScriptMakingExternalString) { 414 THREADED_TEST(ScriptMakingExternalString) {
415 TestResource::dispose_count = 0; 415 TestResource::dispose_count = 0;
416 uint16_t* two_byte_source = AsciiToTwoByteString("1 + 2 * 3"); 416 uint16_t* two_byte_source = AsciiToTwoByteString("1 + 2 * 3");
417 { 417 {
418 v8::HandleScope scope; 418 v8::HandleScope scope;
419 LocalContext env; 419 LocalContext env;
420 Local<String> source = String::New(two_byte_source); 420 Local<String> source = String::New(two_byte_source);
421 // Trigger GCs so that the newly allocated string moves to old gen. 421 // Trigger GCs so that the newly allocated string moves to old gen.
422 HEAP->CollectGarbage(0, i::NEW_SPACE); // in survivor space now 422 HEAP->CollectGarbage(0, i::NEW_SPACE); // in survivor space now
423 HEAP->CollectGarbage(0, i::NEW_SPACE); // in old gen now 423 HEAP->CollectGarbage(0, i::NEW_SPACE); // in old gen now
424 bool success = source->MakeExternal(new TestResource(two_byte_source)); 424 bool success = source->MakeExternal(new TestResource(two_byte_source));
425 CHECK(success); 425 CHECK(success);
426 Local<Script> script = Script::Compile(source); 426 Local<Script> script = Script::Compile(source);
427 Local<Value> value = script->Run(); 427 Local<Value> value = script->Run();
428 CHECK(value->IsNumber()); 428 CHECK(value->IsNumber());
429 CHECK_EQ(7, value->Int32Value()); 429 CHECK_EQ(7, value->Int32Value());
430 HEAP->CollectAllGarbage(false); 430 HEAP->CollectAllGarbage(false);
431 CHECK_EQ(0, TestResource::dispose_count); 431 CHECK_EQ(0, TestResource::dispose_count);
432 } 432 }
433 v8::internal::CompilationCache::Clear(); 433 v8::internal::Isolate::Current()->compilation_cache()->Clear();
434 HEAP->CollectAllGarbage(false); 434 HEAP->CollectAllGarbage(false);
435 CHECK_EQ(1, TestResource::dispose_count); 435 CHECK_EQ(1, TestResource::dispose_count);
436 } 436 }
437 437
438 438
439 THREADED_TEST(ScriptMakingExternalAsciiString) { 439 THREADED_TEST(ScriptMakingExternalAsciiString) {
440 TestAsciiResource::dispose_count = 0; 440 TestAsciiResource::dispose_count = 0;
441 const char* c_source = "1 + 2 * 3"; 441 const char* c_source = "1 + 2 * 3";
442 { 442 {
443 v8::HandleScope scope; 443 v8::HandleScope scope;
444 LocalContext env; 444 LocalContext env;
445 Local<String> source = v8_str(c_source); 445 Local<String> source = v8_str(c_source);
446 // Trigger GCs so that the newly allocated string moves to old gen. 446 // Trigger GCs so that the newly allocated string moves to old gen.
447 HEAP->CollectGarbage(0, i::NEW_SPACE); // in survivor space now 447 HEAP->CollectGarbage(0, i::NEW_SPACE); // in survivor space now
448 HEAP->CollectGarbage(0, i::NEW_SPACE); // in old gen now 448 HEAP->CollectGarbage(0, i::NEW_SPACE); // in old gen now
449 bool success = source->MakeExternal( 449 bool success = source->MakeExternal(
450 new TestAsciiResource(i::StrDup(c_source))); 450 new TestAsciiResource(i::StrDup(c_source)));
451 CHECK(success); 451 CHECK(success);
452 Local<Script> script = Script::Compile(source); 452 Local<Script> script = Script::Compile(source);
453 Local<Value> value = script->Run(); 453 Local<Value> value = script->Run();
454 CHECK(value->IsNumber()); 454 CHECK(value->IsNumber());
455 CHECK_EQ(7, value->Int32Value()); 455 CHECK_EQ(7, value->Int32Value());
456 HEAP->CollectAllGarbage(false); 456 HEAP->CollectAllGarbage(false);
457 CHECK_EQ(0, TestAsciiResource::dispose_count); 457 CHECK_EQ(0, TestAsciiResource::dispose_count);
458 } 458 }
459 v8::internal::CompilationCache::Clear(); 459 v8::internal::Isolate::Current()->compilation_cache()->Clear();
460 HEAP->CollectAllGarbage(false); 460 HEAP->CollectAllGarbage(false);
461 CHECK_EQ(1, TestAsciiResource::dispose_count); 461 CHECK_EQ(1, TestAsciiResource::dispose_count);
462 } 462 }
463 463
464 464
465 TEST(MakingExternalStringConditions) { 465 TEST(MakingExternalStringConditions) {
466 v8::HandleScope scope; 466 v8::HandleScope scope;
467 LocalContext env; 467 LocalContext env;
468 468
469 // Free some space in the new space so that we can check freshness. 469 // Free some space in the new space so that we can check freshness.
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 v8::HandleScope scope; 641 v8::HandleScope scope;
642 LocalContext env; 642 LocalContext env;
643 Local<String> source = String::NewExternal(&res_stack); 643 Local<String> source = String::NewExternal(&res_stack);
644 Local<Script> script = Script::Compile(source); 644 Local<Script> script = Script::Compile(source);
645 Local<Value> value = script->Run(); 645 Local<Value> value = script->Run();
646 CHECK(value->IsNumber()); 646 CHECK(value->IsNumber());
647 CHECK_EQ(7, value->Int32Value()); 647 CHECK_EQ(7, value->Int32Value());
648 HEAP->CollectAllGarbage(false); 648 HEAP->CollectAllGarbage(false);
649 CHECK_EQ(0, TestAsciiResource::dispose_count); 649 CHECK_EQ(0, TestAsciiResource::dispose_count);
650 } 650 }
651 v8::internal::CompilationCache::Clear(); 651 v8::internal::Isolate::Current()->compilation_cache()->Clear();
652 HEAP->CollectAllGarbage(false); 652 HEAP->CollectAllGarbage(false);
653 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); 653 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls);
654 CHECK_EQ(0, TestAsciiResource::dispose_count); 654 CHECK_EQ(0, TestAsciiResource::dispose_count);
655 655
656 // Use a heap allocated external string resource allocated object. 656 // Use a heap allocated external string resource allocated object.
657 TestAsciiResource::dispose_count = 0; 657 TestAsciiResource::dispose_count = 0;
658 TestAsciiResourceWithDisposeControl::dispose_calls = 0; 658 TestAsciiResourceWithDisposeControl::dispose_calls = 0;
659 TestAsciiResource* res_heap = 659 TestAsciiResource* res_heap =
660 new TestAsciiResourceWithDisposeControl(i::StrDup(c_source), true); 660 new TestAsciiResourceWithDisposeControl(i::StrDup(c_source), true);
661 { 661 {
662 v8::HandleScope scope; 662 v8::HandleScope scope;
663 LocalContext env; 663 LocalContext env;
664 Local<String> source = String::NewExternal(res_heap); 664 Local<String> source = String::NewExternal(res_heap);
665 Local<Script> script = Script::Compile(source); 665 Local<Script> script = Script::Compile(source);
666 Local<Value> value = script->Run(); 666 Local<Value> value = script->Run();
667 CHECK(value->IsNumber()); 667 CHECK(value->IsNumber());
668 CHECK_EQ(7, value->Int32Value()); 668 CHECK_EQ(7, value->Int32Value());
669 HEAP->CollectAllGarbage(false); 669 HEAP->CollectAllGarbage(false);
670 CHECK_EQ(0, TestAsciiResource::dispose_count); 670 CHECK_EQ(0, TestAsciiResource::dispose_count);
671 } 671 }
672 v8::internal::CompilationCache::Clear(); 672 v8::internal::Isolate::Current()->compilation_cache()->Clear();
673 HEAP->CollectAllGarbage(false); 673 HEAP->CollectAllGarbage(false);
674 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); 674 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls);
675 CHECK_EQ(1, TestAsciiResource::dispose_count); 675 CHECK_EQ(1, TestAsciiResource::dispose_count);
676 } 676 }
677 677
678 678
679 THREADED_TEST(StringConcat) { 679 THREADED_TEST(StringConcat) {
680 { 680 {
681 v8::HandleScope scope; 681 v8::HandleScope scope;
682 LocalContext env; 682 LocalContext env;
(...skipping 18 matching lines...) Expand all
701 right = String::New(AsciiToTwoByteString(two_byte_string_2)); 701 right = String::New(AsciiToTwoByteString(two_byte_string_2));
702 source = String::Concat(source, right); 702 source = String::Concat(source, right);
703 right = String::NewExternal( 703 right = String::NewExternal(
704 new TestResource(AsciiToTwoByteString(two_byte_extern_2))); 704 new TestResource(AsciiToTwoByteString(two_byte_extern_2)));
705 source = String::Concat(source, right); 705 source = String::Concat(source, right);
706 Local<Script> script = Script::Compile(source); 706 Local<Script> script = Script::Compile(source);
707 Local<Value> value = script->Run(); 707 Local<Value> value = script->Run();
708 CHECK(value->IsNumber()); 708 CHECK(value->IsNumber());
709 CHECK_EQ(68, value->Int32Value()); 709 CHECK_EQ(68, value->Int32Value());
710 } 710 }
711 v8::internal::CompilationCache::Clear(); 711 v8::internal::Isolate::Current()->compilation_cache()->Clear();
712 HEAP->CollectAllGarbage(false); 712 HEAP->CollectAllGarbage(false);
713 HEAP->CollectAllGarbage(false); 713 HEAP->CollectAllGarbage(false);
714 } 714 }
715 715
716 716
717 THREADED_TEST(GlobalProperties) { 717 THREADED_TEST(GlobalProperties) {
718 v8::HandleScope scope; 718 v8::HandleScope scope;
719 LocalContext env; 719 LocalContext env;
720 v8::Handle<v8::Object> global = env->Global(); 720 v8::Handle<v8::Object> global = env->Global();
721 global->Set(v8_str("pi"), v8_num(3.1415926)); 721 global->Set(v8_str("pi"), v8_num(3.1415926));
(...skipping 10195 matching lines...) Expand 10 before | Expand all | Expand 10 after
10917 const char* code = 10917 const char* code =
10918 "(function() {" 10918 "(function() {"
10919 " for (var i = 0; i < 2*16; i++) {" 10919 " for (var i = 0; i < 2*16; i++) {"
10920 " %_GetFromCache(0, 'a' + i);" 10920 " %_GetFromCache(0, 'a' + i);"
10921 " };" 10921 " };"
10922 " return 'PASSED';" 10922 " return 'PASSED';"
10923 "})()"; 10923 "})()";
10924 HEAP->ClearJSFunctionResultCaches(); 10924 HEAP->ClearJSFunctionResultCaches();
10925 ExpectString(code, "PASSED"); 10925 ExpectString(code, "PASSED");
10926 } 10926 }
OLDNEW
« no previous file with comments | « src/jsregexp.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698