OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 Local<Value> value = script->Run(); | 406 Local<Value> value = script->Run(); |
407 CHECK(value->IsNumber()); | 407 CHECK(value->IsNumber()); |
408 CHECK_EQ(7, value->Int32Value()); | 408 CHECK_EQ(7, value->Int32Value()); |
409 CHECK(source->IsExternal()); | 409 CHECK(source->IsExternal()); |
410 CHECK_EQ(resource, | 410 CHECK_EQ(resource, |
411 static_cast<TestResource*>(source->GetExternalStringResource())); | 411 static_cast<TestResource*>(source->GetExternalStringResource())); |
412 String::Encoding encoding = String::UNKNOWN_ENCODING; | 412 String::Encoding encoding = String::UNKNOWN_ENCODING; |
413 CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource), | 413 CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource), |
414 source->GetExternalStringResourceBase(&encoding)); | 414 source->GetExternalStringResourceBase(&encoding)); |
415 CHECK_EQ(String::TWO_BYTE_ENCODING, encoding); | 415 CHECK_EQ(String::TWO_BYTE_ENCODING, encoding); |
416 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 416 CcTest::heap()->CollectAllGarbage(); |
417 CHECK_EQ(0, dispose_count); | 417 CHECK_EQ(0, dispose_count); |
418 } | 418 } |
419 CcTest::i_isolate()->compilation_cache()->Clear(); | 419 CcTest::i_isolate()->compilation_cache()->Clear(); |
420 CcTest::heap()->CollectAllAvailableGarbage(); | 420 CcTest::heap()->CollectAllAvailableGarbage(); |
421 CHECK_EQ(1, dispose_count); | 421 CHECK_EQ(1, dispose_count); |
422 } | 422 } |
423 | 423 |
424 | 424 |
425 THREADED_TEST(ScriptUsingOneByteStringResource) { | 425 THREADED_TEST(ScriptUsingOneByteStringResource) { |
426 int dispose_count = 0; | 426 int dispose_count = 0; |
427 const char* c_source = "1 + 2 * 3"; | 427 const char* c_source = "1 + 2 * 3"; |
428 { | 428 { |
429 LocalContext env; | 429 LocalContext env; |
430 v8::HandleScope scope(env->GetIsolate()); | 430 v8::HandleScope scope(env->GetIsolate()); |
431 TestOneByteResource* resource = | 431 TestOneByteResource* resource = |
432 new TestOneByteResource(i::StrDup(c_source), &dispose_count); | 432 new TestOneByteResource(i::StrDup(c_source), &dispose_count); |
433 Local<String> source = String::NewExternal(env->GetIsolate(), resource); | 433 Local<String> source = String::NewExternal(env->GetIsolate(), resource); |
434 CHECK(source->IsExternalOneByte()); | 434 CHECK(source->IsExternalOneByte()); |
435 CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource), | 435 CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource), |
436 source->GetExternalOneByteStringResource()); | 436 source->GetExternalOneByteStringResource()); |
437 String::Encoding encoding = String::UNKNOWN_ENCODING; | 437 String::Encoding encoding = String::UNKNOWN_ENCODING; |
438 CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource), | 438 CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource), |
439 source->GetExternalStringResourceBase(&encoding)); | 439 source->GetExternalStringResourceBase(&encoding)); |
440 CHECK_EQ(String::ONE_BYTE_ENCODING, encoding); | 440 CHECK_EQ(String::ONE_BYTE_ENCODING, encoding); |
441 Local<Script> script = v8_compile(source); | 441 Local<Script> script = v8_compile(source); |
442 Local<Value> value = script->Run(); | 442 Local<Value> value = script->Run(); |
443 CHECK(value->IsNumber()); | 443 CHECK(value->IsNumber()); |
444 CHECK_EQ(7, value->Int32Value()); | 444 CHECK_EQ(7, value->Int32Value()); |
445 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 445 CcTest::heap()->CollectAllGarbage(); |
446 CHECK_EQ(0, dispose_count); | 446 CHECK_EQ(0, dispose_count); |
447 } | 447 } |
448 CcTest::i_isolate()->compilation_cache()->Clear(); | 448 CcTest::i_isolate()->compilation_cache()->Clear(); |
449 CcTest::heap()->CollectAllAvailableGarbage(); | 449 CcTest::heap()->CollectAllAvailableGarbage(); |
450 CHECK_EQ(1, dispose_count); | 450 CHECK_EQ(1, dispose_count); |
451 } | 451 } |
452 | 452 |
453 | 453 |
454 THREADED_TEST(ScriptMakingExternalString) { | 454 THREADED_TEST(ScriptMakingExternalString) { |
455 int dispose_count = 0; | 455 int dispose_count = 0; |
(...skipping 11 matching lines...) Expand all Loading... |
467 String::Encoding encoding = String::UNKNOWN_ENCODING; | 467 String::Encoding encoding = String::UNKNOWN_ENCODING; |
468 CHECK(!source->GetExternalStringResourceBase(&encoding)); | 468 CHECK(!source->GetExternalStringResourceBase(&encoding)); |
469 CHECK_EQ(String::ONE_BYTE_ENCODING, encoding); | 469 CHECK_EQ(String::ONE_BYTE_ENCODING, encoding); |
470 bool success = source->MakeExternal(new TestResource(two_byte_source, | 470 bool success = source->MakeExternal(new TestResource(two_byte_source, |
471 &dispose_count)); | 471 &dispose_count)); |
472 CHECK(success); | 472 CHECK(success); |
473 Local<Script> script = v8_compile(source); | 473 Local<Script> script = v8_compile(source); |
474 Local<Value> value = script->Run(); | 474 Local<Value> value = script->Run(); |
475 CHECK(value->IsNumber()); | 475 CHECK(value->IsNumber()); |
476 CHECK_EQ(7, value->Int32Value()); | 476 CHECK_EQ(7, value->Int32Value()); |
477 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 477 CcTest::heap()->CollectAllGarbage(); |
478 CHECK_EQ(0, dispose_count); | 478 CHECK_EQ(0, dispose_count); |
479 } | 479 } |
480 CcTest::i_isolate()->compilation_cache()->Clear(); | 480 CcTest::i_isolate()->compilation_cache()->Clear(); |
481 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 481 CcTest::heap()->CollectAllGarbage(); |
482 CHECK_EQ(1, dispose_count); | 482 CHECK_EQ(1, dispose_count); |
483 } | 483 } |
484 | 484 |
485 | 485 |
486 THREADED_TEST(ScriptMakingExternalOneByteString) { | 486 THREADED_TEST(ScriptMakingExternalOneByteString) { |
487 int dispose_count = 0; | 487 int dispose_count = 0; |
488 const char* c_source = "1 + 2 * 3"; | 488 const char* c_source = "1 + 2 * 3"; |
489 { | 489 { |
490 LocalContext env; | 490 LocalContext env; |
491 v8::HandleScope scope(env->GetIsolate()); | 491 v8::HandleScope scope(env->GetIsolate()); |
492 Local<String> source = v8_str(c_source); | 492 Local<String> source = v8_str(c_source); |
493 // Trigger GCs so that the newly allocated string moves to old gen. | 493 // Trigger GCs so that the newly allocated string moves to old gen. |
494 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now | 494 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now |
495 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now | 495 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now |
496 bool success = source->MakeExternal( | 496 bool success = source->MakeExternal( |
497 new TestOneByteResource(i::StrDup(c_source), &dispose_count)); | 497 new TestOneByteResource(i::StrDup(c_source), &dispose_count)); |
498 CHECK(success); | 498 CHECK(success); |
499 Local<Script> script = v8_compile(source); | 499 Local<Script> script = v8_compile(source); |
500 Local<Value> value = script->Run(); | 500 Local<Value> value = script->Run(); |
501 CHECK(value->IsNumber()); | 501 CHECK(value->IsNumber()); |
502 CHECK_EQ(7, value->Int32Value()); | 502 CHECK_EQ(7, value->Int32Value()); |
503 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 503 CcTest::heap()->CollectAllGarbage(); |
504 CHECK_EQ(0, dispose_count); | 504 CHECK_EQ(0, dispose_count); |
505 } | 505 } |
506 CcTest::i_isolate()->compilation_cache()->Clear(); | 506 CcTest::i_isolate()->compilation_cache()->Clear(); |
507 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 507 CcTest::heap()->CollectAllGarbage(); |
508 CHECK_EQ(1, dispose_count); | 508 CHECK_EQ(1, dispose_count); |
509 } | 509 } |
510 | 510 |
511 | 511 |
512 TEST(MakingExternalStringConditions) { | 512 TEST(MakingExternalStringConditions) { |
513 LocalContext env; | 513 LocalContext env; |
514 v8::HandleScope scope(env->GetIsolate()); | 514 v8::HandleScope scope(env->GetIsolate()); |
515 | 515 |
516 // Free some space in the new space so that we can check freshness. | 516 // Free some space in the new space so that we can check freshness. |
517 CcTest::heap()->CollectGarbage(i::NEW_SPACE); | 517 CcTest::heap()->CollectGarbage(i::NEW_SPACE); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 const char* c_cons = "_abcdefghijklmnopqrstuvwxyz"; | 616 const char* c_cons = "_abcdefghijklmnopqrstuvwxyz"; |
617 bool success = | 617 bool success = |
618 cons->MakeExternal(new TestOneByteResource(i::StrDup(c_cons), NULL, 1)); | 618 cons->MakeExternal(new TestOneByteResource(i::StrDup(c_cons), NULL, 1)); |
619 CHECK(success); | 619 CHECK(success); |
620 const char* c_slice = "_bcdefghijklmnopqrstuvwxyz"; | 620 const char* c_slice = "_bcdefghijklmnopqrstuvwxyz"; |
621 success = | 621 success = |
622 slice->MakeExternal(new TestOneByteResource(i::StrDup(c_slice), NULL, 1)); | 622 slice->MakeExternal(new TestOneByteResource(i::StrDup(c_slice), NULL, 1)); |
623 CHECK(success); | 623 CHECK(success); |
624 | 624 |
625 // Trigger GCs and force evacuation. | 625 // Trigger GCs and force evacuation. |
626 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 626 CcTest::heap()->CollectAllGarbage(); |
627 CcTest::heap()->CollectAllGarbage(i::Heap::kReduceMemoryFootprintMask); | 627 CcTest::heap()->CollectAllGarbage(i::Heap::kReduceMemoryFootprintMask); |
628 } | 628 } |
629 | 629 |
630 | 630 |
631 THREADED_TEST(UsingExternalString) { | 631 THREADED_TEST(UsingExternalString) { |
632 i::Factory* factory = CcTest::i_isolate()->factory(); | 632 i::Factory* factory = CcTest::i_isolate()->factory(); |
633 { | 633 { |
634 v8::HandleScope scope(CcTest::isolate()); | 634 v8::HandleScope scope(CcTest::isolate()); |
635 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); | 635 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); |
636 Local<String> string = String::NewExternal( | 636 Local<String> string = String::NewExternal( |
637 CcTest::isolate(), new TestResource(two_byte_string)); | 637 CcTest::isolate(), new TestResource(two_byte_string)); |
638 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); | 638 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); |
639 // Trigger GCs so that the newly allocated string moves to old gen. | 639 // Trigger GCs so that the newly allocated string moves to old gen. |
640 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now | 640 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now |
641 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now | 641 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now |
642 i::Handle<i::String> isymbol = | 642 i::Handle<i::String> isymbol = |
643 factory->InternalizeString(istring); | 643 factory->InternalizeString(istring); |
644 CHECK(isymbol->IsInternalizedString()); | 644 CHECK(isymbol->IsInternalizedString()); |
645 } | 645 } |
646 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 646 CcTest::heap()->CollectAllGarbage(); |
647 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 647 CcTest::heap()->CollectAllGarbage(); |
648 } | 648 } |
649 | 649 |
650 | 650 |
651 THREADED_TEST(UsingExternalOneByteString) { | 651 THREADED_TEST(UsingExternalOneByteString) { |
652 i::Factory* factory = CcTest::i_isolate()->factory(); | 652 i::Factory* factory = CcTest::i_isolate()->factory(); |
653 { | 653 { |
654 v8::HandleScope scope(CcTest::isolate()); | 654 v8::HandleScope scope(CcTest::isolate()); |
655 const char* one_byte_string = "test string"; | 655 const char* one_byte_string = "test string"; |
656 Local<String> string = String::NewExternal( | 656 Local<String> string = String::NewExternal( |
657 CcTest::isolate(), new TestOneByteResource(i::StrDup(one_byte_string))); | 657 CcTest::isolate(), new TestOneByteResource(i::StrDup(one_byte_string))); |
658 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); | 658 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); |
659 // Trigger GCs so that the newly allocated string moves to old gen. | 659 // Trigger GCs so that the newly allocated string moves to old gen. |
660 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now | 660 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now |
661 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now | 661 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now |
662 i::Handle<i::String> isymbol = | 662 i::Handle<i::String> isymbol = |
663 factory->InternalizeString(istring); | 663 factory->InternalizeString(istring); |
664 CHECK(isymbol->IsInternalizedString()); | 664 CHECK(isymbol->IsInternalizedString()); |
665 } | 665 } |
666 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 666 CcTest::heap()->CollectAllGarbage(); |
667 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 667 CcTest::heap()->CollectAllGarbage(); |
668 } | 668 } |
669 | 669 |
670 | 670 |
671 class RandomLengthResource : public v8::String::ExternalStringResource { | 671 class RandomLengthResource : public v8::String::ExternalStringResource { |
672 public: | 672 public: |
673 explicit RandomLengthResource(int length) : length_(length) {} | 673 explicit RandomLengthResource(int length) : length_(length) {} |
674 virtual const uint16_t* data() const { return string_; } | 674 virtual const uint16_t* data() const { return string_; } |
675 virtual size_t length() const { return length_; } | 675 virtual size_t length() const { return length_; } |
676 | 676 |
677 private: | 677 private: |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 right = String::NewExternal( | 864 right = String::NewExternal( |
865 env->GetIsolate(), | 865 env->GetIsolate(), |
866 new TestResource(AsciiToTwoByteString(two_byte_extern_2))); | 866 new TestResource(AsciiToTwoByteString(two_byte_extern_2))); |
867 source = String::Concat(source, right); | 867 source = String::Concat(source, right); |
868 Local<Script> script = v8_compile(source); | 868 Local<Script> script = v8_compile(source); |
869 Local<Value> value = script->Run(); | 869 Local<Value> value = script->Run(); |
870 CHECK(value->IsNumber()); | 870 CHECK(value->IsNumber()); |
871 CHECK_EQ(68, value->Int32Value()); | 871 CHECK_EQ(68, value->Int32Value()); |
872 } | 872 } |
873 CcTest::i_isolate()->compilation_cache()->Clear(); | 873 CcTest::i_isolate()->compilation_cache()->Clear(); |
874 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 874 CcTest::heap()->CollectAllGarbage(); |
875 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 875 CcTest::heap()->CollectAllGarbage(); |
876 } | 876 } |
877 | 877 |
878 | 878 |
879 THREADED_TEST(GlobalProperties) { | 879 THREADED_TEST(GlobalProperties) { |
880 LocalContext env; | 880 LocalContext env; |
881 v8::HandleScope scope(env->GetIsolate()); | 881 v8::HandleScope scope(env->GetIsolate()); |
882 v8::Handle<v8::Object> global = env->Global(); | 882 v8::Handle<v8::Object> global = env->Global(); |
883 global->Set(v8_str("pi"), v8_num(3.1415926)); | 883 global->Set(v8_str("pi"), v8_num(3.1415926)); |
884 Local<Value> pi = global->Get(v8_str("pi")); | 884 Local<Value> pi = global->Get(v8_str("pi")); |
885 CHECK_EQ(3.1415926, pi->NumberValue()); | 885 CHECK_EQ(3.1415926, pi->NumberValue()); |
(...skipping 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2085 v8::Local<v8::Object> global = env->Global(); | 2085 v8::Local<v8::Object> global = env->Global(); |
2086 global->Set(0, v8::String::NewFromUtf8(CcTest::isolate(), "value")); | 2086 global->Set(0, v8::String::NewFromUtf8(CcTest::isolate(), "value")); |
2087 CHECK(global->HasRealIndexedProperty(0)); | 2087 CHECK(global->HasRealIndexedProperty(0)); |
2088 } | 2088 } |
2089 | 2089 |
2090 | 2090 |
2091 static void CheckAlignedPointerInInternalField(Handle<v8::Object> obj, | 2091 static void CheckAlignedPointerInInternalField(Handle<v8::Object> obj, |
2092 void* value) { | 2092 void* value) { |
2093 CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(value) & 0x1)); | 2093 CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(value) & 0x1)); |
2094 obj->SetAlignedPointerInInternalField(0, value); | 2094 obj->SetAlignedPointerInInternalField(0, value); |
2095 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2095 CcTest::heap()->CollectAllGarbage(); |
2096 CHECK_EQ(value, obj->GetAlignedPointerFromInternalField(0)); | 2096 CHECK_EQ(value, obj->GetAlignedPointerFromInternalField(0)); |
2097 } | 2097 } |
2098 | 2098 |
2099 | 2099 |
2100 THREADED_TEST(InternalFieldsAlignedPointers) { | 2100 THREADED_TEST(InternalFieldsAlignedPointers) { |
2101 LocalContext env; | 2101 LocalContext env; |
2102 v8::Isolate* isolate = env->GetIsolate(); | 2102 v8::Isolate* isolate = env->GetIsolate(); |
2103 v8::HandleScope scope(isolate); | 2103 v8::HandleScope scope(isolate); |
2104 | 2104 |
2105 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); | 2105 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); |
(...skipping 17 matching lines...) Expand all Loading... |
2123 v8::Global<v8::Object> persistent(isolate, obj); | 2123 v8::Global<v8::Object> persistent(isolate, obj); |
2124 CHECK_EQ(1, Object::InternalFieldCount(persistent)); | 2124 CHECK_EQ(1, Object::InternalFieldCount(persistent)); |
2125 CHECK_EQ(huge, Object::GetAlignedPointerFromInternalField(persistent, 0)); | 2125 CHECK_EQ(huge, Object::GetAlignedPointerFromInternalField(persistent, 0)); |
2126 } | 2126 } |
2127 | 2127 |
2128 | 2128 |
2129 static void CheckAlignedPointerInEmbedderData(LocalContext* env, int index, | 2129 static void CheckAlignedPointerInEmbedderData(LocalContext* env, int index, |
2130 void* value) { | 2130 void* value) { |
2131 CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(value) & 0x1)); | 2131 CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(value) & 0x1)); |
2132 (*env)->SetAlignedPointerInEmbedderData(index, value); | 2132 (*env)->SetAlignedPointerInEmbedderData(index, value); |
2133 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2133 CcTest::heap()->CollectAllGarbage(); |
2134 CHECK_EQ(value, (*env)->GetAlignedPointerFromEmbedderData(index)); | 2134 CHECK_EQ(value, (*env)->GetAlignedPointerFromEmbedderData(index)); |
2135 } | 2135 } |
2136 | 2136 |
2137 | 2137 |
2138 static void* AlignedTestPointer(int i) { | 2138 static void* AlignedTestPointer(int i) { |
2139 return reinterpret_cast<void*>(i * 1234); | 2139 return reinterpret_cast<void*>(i * 1234); |
2140 } | 2140 } |
2141 | 2141 |
2142 | 2142 |
2143 THREADED_TEST(EmbedderDataAlignedPointers) { | 2143 THREADED_TEST(EmbedderDataAlignedPointers) { |
2144 LocalContext env; | 2144 LocalContext env; |
2145 v8::HandleScope scope(env->GetIsolate()); | 2145 v8::HandleScope scope(env->GetIsolate()); |
2146 | 2146 |
2147 CheckAlignedPointerInEmbedderData(&env, 0, NULL); | 2147 CheckAlignedPointerInEmbedderData(&env, 0, NULL); |
2148 | 2148 |
2149 int* heap_allocated = new int[100]; | 2149 int* heap_allocated = new int[100]; |
2150 CheckAlignedPointerInEmbedderData(&env, 1, heap_allocated); | 2150 CheckAlignedPointerInEmbedderData(&env, 1, heap_allocated); |
2151 delete[] heap_allocated; | 2151 delete[] heap_allocated; |
2152 | 2152 |
2153 int stack_allocated[100]; | 2153 int stack_allocated[100]; |
2154 CheckAlignedPointerInEmbedderData(&env, 2, stack_allocated); | 2154 CheckAlignedPointerInEmbedderData(&env, 2, stack_allocated); |
2155 | 2155 |
2156 void* huge = reinterpret_cast<void*>(~static_cast<uintptr_t>(1)); | 2156 void* huge = reinterpret_cast<void*>(~static_cast<uintptr_t>(1)); |
2157 CheckAlignedPointerInEmbedderData(&env, 3, huge); | 2157 CheckAlignedPointerInEmbedderData(&env, 3, huge); |
2158 | 2158 |
2159 // Test growing of the embedder data's backing store. | 2159 // Test growing of the embedder data's backing store. |
2160 for (int i = 0; i < 100; i++) { | 2160 for (int i = 0; i < 100; i++) { |
2161 env->SetAlignedPointerInEmbedderData(i, AlignedTestPointer(i)); | 2161 env->SetAlignedPointerInEmbedderData(i, AlignedTestPointer(i)); |
2162 } | 2162 } |
2163 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2163 CcTest::heap()->CollectAllGarbage(); |
2164 for (int i = 0; i < 100; i++) { | 2164 for (int i = 0; i < 100; i++) { |
2165 CHECK_EQ(AlignedTestPointer(i), env->GetAlignedPointerFromEmbedderData(i)); | 2165 CHECK_EQ(AlignedTestPointer(i), env->GetAlignedPointerFromEmbedderData(i)); |
2166 } | 2166 } |
2167 } | 2167 } |
2168 | 2168 |
2169 | 2169 |
2170 static void CheckEmbedderData(LocalContext* env, int index, | 2170 static void CheckEmbedderData(LocalContext* env, int index, |
2171 v8::Handle<Value> data) { | 2171 v8::Handle<Value> data) { |
2172 (*env)->SetEmbedderData(index, data); | 2172 (*env)->SetEmbedderData(index, data); |
2173 CHECK((*env)->GetEmbedderData(index)->StrictEquals(data)); | 2173 CHECK((*env)->GetEmbedderData(index)->StrictEquals(data)); |
(...skipping 24 matching lines...) Expand all Loading... |
2198 } | 2198 } |
2199 | 2199 |
2200 | 2200 |
2201 THREADED_TEST(IdentityHash) { | 2201 THREADED_TEST(IdentityHash) { |
2202 LocalContext env; | 2202 LocalContext env; |
2203 v8::Isolate* isolate = env->GetIsolate(); | 2203 v8::Isolate* isolate = env->GetIsolate(); |
2204 v8::HandleScope scope(isolate); | 2204 v8::HandleScope scope(isolate); |
2205 | 2205 |
2206 // Ensure that the test starts with an fresh heap to test whether the hash | 2206 // Ensure that the test starts with an fresh heap to test whether the hash |
2207 // code is based on the address. | 2207 // code is based on the address. |
2208 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2208 CcTest::heap()->CollectAllGarbage(); |
2209 Local<v8::Object> obj = v8::Object::New(isolate); | 2209 Local<v8::Object> obj = v8::Object::New(isolate); |
2210 int hash = obj->GetIdentityHash(); | 2210 int hash = obj->GetIdentityHash(); |
2211 int hash1 = obj->GetIdentityHash(); | 2211 int hash1 = obj->GetIdentityHash(); |
2212 CHECK_EQ(hash, hash1); | 2212 CHECK_EQ(hash, hash1); |
2213 int hash2 = v8::Object::New(isolate)->GetIdentityHash(); | 2213 int hash2 = v8::Object::New(isolate)->GetIdentityHash(); |
2214 // Since the identity hash is essentially a random number two consecutive | 2214 // Since the identity hash is essentially a random number two consecutive |
2215 // objects should not be assigned the same hash code. If the test below fails | 2215 // objects should not be assigned the same hash code. If the test below fails |
2216 // the random number generator should be evaluated. | 2216 // the random number generator should be evaluated. |
2217 CHECK_NE(hash, hash2); | 2217 CHECK_NE(hash, hash2); |
2218 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2218 CcTest::heap()->CollectAllGarbage(); |
2219 int hash3 = v8::Object::New(isolate)->GetIdentityHash(); | 2219 int hash3 = v8::Object::New(isolate)->GetIdentityHash(); |
2220 // Make sure that the identity hash is not based on the initial address of | 2220 // Make sure that the identity hash is not based on the initial address of |
2221 // the object alone. If the test below fails the random number generator | 2221 // the object alone. If the test below fails the random number generator |
2222 // should be evaluated. | 2222 // should be evaluated. |
2223 CHECK_NE(hash, hash3); | 2223 CHECK_NE(hash, hash3); |
2224 int hash4 = obj->GetIdentityHash(); | 2224 int hash4 = obj->GetIdentityHash(); |
2225 CHECK_EQ(hash, hash4); | 2225 CHECK_EQ(hash, hash4); |
2226 | 2226 |
2227 // Check identity hashes behaviour in the presence of JS accessors. | 2227 // Check identity hashes behaviour in the presence of JS accessors. |
2228 // Put a getter for 'v8::IdentityHash' on the Object's prototype: | 2228 // Put a getter for 'v8::IdentityHash' on the Object's prototype: |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2265 TEST(SymbolIdentityHash) { | 2265 TEST(SymbolIdentityHash) { |
2266 LocalContext env; | 2266 LocalContext env; |
2267 v8::Isolate* isolate = env->GetIsolate(); | 2267 v8::Isolate* isolate = env->GetIsolate(); |
2268 v8::HandleScope scope(isolate); | 2268 v8::HandleScope scope(isolate); |
2269 | 2269 |
2270 { | 2270 { |
2271 Local<v8::Symbol> symbol = v8::Symbol::New(isolate); | 2271 Local<v8::Symbol> symbol = v8::Symbol::New(isolate); |
2272 int hash = symbol->GetIdentityHash(); | 2272 int hash = symbol->GetIdentityHash(); |
2273 int hash1 = symbol->GetIdentityHash(); | 2273 int hash1 = symbol->GetIdentityHash(); |
2274 CHECK_EQ(hash, hash1); | 2274 CHECK_EQ(hash, hash1); |
2275 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2275 CcTest::heap()->CollectAllGarbage(); |
2276 int hash3 = symbol->GetIdentityHash(); | 2276 int hash3 = symbol->GetIdentityHash(); |
2277 CHECK_EQ(hash, hash3); | 2277 CHECK_EQ(hash, hash3); |
2278 } | 2278 } |
2279 | 2279 |
2280 { | 2280 { |
2281 v8::Handle<v8::Symbol> js_symbol = | 2281 v8::Handle<v8::Symbol> js_symbol = |
2282 CompileRun("Symbol('foo')").As<v8::Symbol>(); | 2282 CompileRun("Symbol('foo')").As<v8::Symbol>(); |
2283 int hash = js_symbol->GetIdentityHash(); | 2283 int hash = js_symbol->GetIdentityHash(); |
2284 int hash1 = js_symbol->GetIdentityHash(); | 2284 int hash1 = js_symbol->GetIdentityHash(); |
2285 CHECK_EQ(hash, hash1); | 2285 CHECK_EQ(hash, hash1); |
2286 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2286 CcTest::heap()->CollectAllGarbage(); |
2287 int hash3 = js_symbol->GetIdentityHash(); | 2287 int hash3 = js_symbol->GetIdentityHash(); |
2288 CHECK_EQ(hash, hash3); | 2288 CHECK_EQ(hash, hash3); |
2289 } | 2289 } |
2290 } | 2290 } |
2291 | 2291 |
2292 | 2292 |
2293 TEST(StringIdentityHash) { | 2293 TEST(StringIdentityHash) { |
2294 LocalContext env; | 2294 LocalContext env; |
2295 v8::Isolate* isolate = env->GetIsolate(); | 2295 v8::Isolate* isolate = env->GetIsolate(); |
2296 v8::HandleScope scope(isolate); | 2296 v8::HandleScope scope(isolate); |
2297 | 2297 |
2298 Local<v8::String> str = v8::String::NewFromUtf8(isolate, "str1"); | 2298 Local<v8::String> str = v8::String::NewFromUtf8(isolate, "str1"); |
2299 int hash = str->GetIdentityHash(); | 2299 int hash = str->GetIdentityHash(); |
2300 int hash1 = str->GetIdentityHash(); | 2300 int hash1 = str->GetIdentityHash(); |
2301 CHECK_EQ(hash, hash1); | 2301 CHECK_EQ(hash, hash1); |
2302 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2302 CcTest::heap()->CollectAllGarbage(); |
2303 int hash3 = str->GetIdentityHash(); | 2303 int hash3 = str->GetIdentityHash(); |
2304 CHECK_EQ(hash, hash3); | 2304 CHECK_EQ(hash, hash3); |
2305 | 2305 |
2306 Local<v8::String> str2 = v8::String::NewFromUtf8(isolate, "str1"); | 2306 Local<v8::String> str2 = v8::String::NewFromUtf8(isolate, "str1"); |
2307 int hash4 = str2->GetIdentityHash(); | 2307 int hash4 = str2->GetIdentityHash(); |
2308 CHECK_EQ(hash, hash4); | 2308 CHECK_EQ(hash, hash4); |
2309 } | 2309 } |
2310 | 2310 |
2311 | 2311 |
2312 THREADED_TEST(SymbolProperties) { | 2312 THREADED_TEST(SymbolProperties) { |
2313 LocalContext env; | 2313 LocalContext env; |
2314 v8::Isolate* isolate = env->GetIsolate(); | 2314 v8::Isolate* isolate = env->GetIsolate(); |
2315 v8::HandleScope scope(isolate); | 2315 v8::HandleScope scope(isolate); |
2316 | 2316 |
2317 v8::Local<v8::Object> obj = v8::Object::New(isolate); | 2317 v8::Local<v8::Object> obj = v8::Object::New(isolate); |
2318 v8::Local<v8::Symbol> sym1 = v8::Symbol::New(isolate); | 2318 v8::Local<v8::Symbol> sym1 = v8::Symbol::New(isolate); |
2319 v8::Local<v8::Symbol> sym2 = v8::Symbol::New(isolate, v8_str("my-symbol")); | 2319 v8::Local<v8::Symbol> sym2 = v8::Symbol::New(isolate, v8_str("my-symbol")); |
2320 v8::Local<v8::Symbol> sym3 = v8::Symbol::New(isolate, v8_str("sym3")); | 2320 v8::Local<v8::Symbol> sym3 = v8::Symbol::New(isolate, v8_str("sym3")); |
2321 | 2321 |
2322 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2322 CcTest::heap()->CollectAllGarbage(); |
2323 | 2323 |
2324 // Check basic symbol functionality. | 2324 // Check basic symbol functionality. |
2325 CHECK(sym1->IsSymbol()); | 2325 CHECK(sym1->IsSymbol()); |
2326 CHECK(sym2->IsSymbol()); | 2326 CHECK(sym2->IsSymbol()); |
2327 CHECK(!obj->IsSymbol()); | 2327 CHECK(!obj->IsSymbol()); |
2328 | 2328 |
2329 CHECK(sym1->Equals(sym1)); | 2329 CHECK(sym1->Equals(sym1)); |
2330 CHECK(sym2->Equals(sym2)); | 2330 CHECK(sym2->Equals(sym2)); |
2331 CHECK(!sym1->Equals(sym2)); | 2331 CHECK(!sym1->Equals(sym2)); |
2332 CHECK(!sym2->Equals(sym1)); | 2332 CHECK(!sym2->Equals(sym1)); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2364 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); | 2364 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); |
2365 CHECK_EQ(v8::None, obj->GetPropertyAttributes(sym1)); | 2365 CHECK_EQ(v8::None, obj->GetPropertyAttributes(sym1)); |
2366 | 2366 |
2367 CHECK_EQ(0u, obj->GetOwnPropertyNames()->Length()); | 2367 CHECK_EQ(0u, obj->GetOwnPropertyNames()->Length()); |
2368 unsigned num_props = obj->GetPropertyNames()->Length(); | 2368 unsigned num_props = obj->GetPropertyNames()->Length(); |
2369 CHECK(obj->Set(v8::String::NewFromUtf8(isolate, "bla"), | 2369 CHECK(obj->Set(v8::String::NewFromUtf8(isolate, "bla"), |
2370 v8::Integer::New(isolate, 20))); | 2370 v8::Integer::New(isolate, 20))); |
2371 CHECK_EQ(1u, obj->GetOwnPropertyNames()->Length()); | 2371 CHECK_EQ(1u, obj->GetOwnPropertyNames()->Length()); |
2372 CHECK_EQ(num_props + 1, obj->GetPropertyNames()->Length()); | 2372 CHECK_EQ(num_props + 1, obj->GetPropertyNames()->Length()); |
2373 | 2373 |
2374 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2374 CcTest::heap()->CollectAllGarbage(); |
2375 | 2375 |
2376 CHECK(obj->SetAccessor(sym3, SymbolAccessorGetter, SymbolAccessorSetter)); | 2376 CHECK(obj->SetAccessor(sym3, SymbolAccessorGetter, SymbolAccessorSetter)); |
2377 CHECK(obj->Get(sym3)->IsUndefined()); | 2377 CHECK(obj->Get(sym3)->IsUndefined()); |
2378 CHECK(obj->Set(sym3, v8::Integer::New(isolate, 42))); | 2378 CHECK(obj->Set(sym3, v8::Integer::New(isolate, 42))); |
2379 CHECK(obj->Get(sym3)->Equals(v8::Integer::New(isolate, 42))); | 2379 CHECK(obj->Get(sym3)->Equals(v8::Integer::New(isolate, 42))); |
2380 CHECK(obj->Get(v8::String::NewFromUtf8(isolate, "accessor_sym3")) | 2380 CHECK(obj->Get(v8::String::NewFromUtf8(isolate, "accessor_sym3")) |
2381 ->Equals(v8::Integer::New(isolate, 42))); | 2381 ->Equals(v8::Integer::New(isolate, 42))); |
2382 | 2382 |
2383 // Add another property and delete it afterwards to force the object in | 2383 // Add another property and delete it afterwards to force the object in |
2384 // slow case. | 2384 // slow case. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2432 THREADED_TEST(PrivateProperties) { | 2432 THREADED_TEST(PrivateProperties) { |
2433 LocalContext env; | 2433 LocalContext env; |
2434 v8::Isolate* isolate = env->GetIsolate(); | 2434 v8::Isolate* isolate = env->GetIsolate(); |
2435 v8::HandleScope scope(isolate); | 2435 v8::HandleScope scope(isolate); |
2436 | 2436 |
2437 v8::Local<v8::Object> obj = v8::Object::New(isolate); | 2437 v8::Local<v8::Object> obj = v8::Object::New(isolate); |
2438 v8::Local<v8::Private> priv1 = v8::Private::New(isolate); | 2438 v8::Local<v8::Private> priv1 = v8::Private::New(isolate); |
2439 v8::Local<v8::Private> priv2 = | 2439 v8::Local<v8::Private> priv2 = |
2440 v8::Private::New(isolate, v8_str("my-private")); | 2440 v8::Private::New(isolate, v8_str("my-private")); |
2441 | 2441 |
2442 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2442 CcTest::heap()->CollectAllGarbage(); |
2443 | 2443 |
2444 CHECK(priv2->Name()->Equals(v8::String::NewFromUtf8(isolate, "my-private"))); | 2444 CHECK(priv2->Name()->Equals(v8::String::NewFromUtf8(isolate, "my-private"))); |
2445 | 2445 |
2446 // Make sure delete of a non-existent private symbol property works. | 2446 // Make sure delete of a non-existent private symbol property works. |
2447 CHECK(obj->DeletePrivate(priv1)); | 2447 CHECK(obj->DeletePrivate(priv1)); |
2448 CHECK(!obj->HasPrivate(priv1)); | 2448 CHECK(!obj->HasPrivate(priv1)); |
2449 | 2449 |
2450 CHECK(obj->SetPrivate(priv1, v8::Integer::New(isolate, 1503))); | 2450 CHECK(obj->SetPrivate(priv1, v8::Integer::New(isolate, 1503))); |
2451 CHECK(obj->HasPrivate(priv1)); | 2451 CHECK(obj->HasPrivate(priv1)); |
2452 CHECK_EQ(1503, obj->GetPrivate(priv1)->Int32Value()); | 2452 CHECK_EQ(1503, obj->GetPrivate(priv1)->Int32Value()); |
2453 CHECK(obj->SetPrivate(priv1, v8::Integer::New(isolate, 2002))); | 2453 CHECK(obj->SetPrivate(priv1, v8::Integer::New(isolate, 2002))); |
2454 CHECK(obj->HasPrivate(priv1)); | 2454 CHECK(obj->HasPrivate(priv1)); |
2455 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); | 2455 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); |
2456 | 2456 |
2457 CHECK_EQ(0u, obj->GetOwnPropertyNames()->Length()); | 2457 CHECK_EQ(0u, obj->GetOwnPropertyNames()->Length()); |
2458 unsigned num_props = obj->GetPropertyNames()->Length(); | 2458 unsigned num_props = obj->GetPropertyNames()->Length(); |
2459 CHECK(obj->Set(v8::String::NewFromUtf8(isolate, "bla"), | 2459 CHECK(obj->Set(v8::String::NewFromUtf8(isolate, "bla"), |
2460 v8::Integer::New(isolate, 20))); | 2460 v8::Integer::New(isolate, 20))); |
2461 CHECK_EQ(1u, obj->GetOwnPropertyNames()->Length()); | 2461 CHECK_EQ(1u, obj->GetOwnPropertyNames()->Length()); |
2462 CHECK_EQ(num_props + 1, obj->GetPropertyNames()->Length()); | 2462 CHECK_EQ(num_props + 1, obj->GetPropertyNames()->Length()); |
2463 | 2463 |
2464 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2464 CcTest::heap()->CollectAllGarbage(); |
2465 | 2465 |
2466 // Add another property and delete it afterwards to force the object in | 2466 // Add another property and delete it afterwards to force the object in |
2467 // slow case. | 2467 // slow case. |
2468 CHECK(obj->SetPrivate(priv2, v8::Integer::New(isolate, 2008))); | 2468 CHECK(obj->SetPrivate(priv2, v8::Integer::New(isolate, 2008))); |
2469 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); | 2469 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); |
2470 CHECK_EQ(2008, obj->GetPrivate(priv2)->Int32Value()); | 2470 CHECK_EQ(2008, obj->GetPrivate(priv2)->Int32Value()); |
2471 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); | 2471 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); |
2472 CHECK_EQ(1u, obj->GetOwnPropertyNames()->Length()); | 2472 CHECK_EQ(1u, obj->GetOwnPropertyNames()->Length()); |
2473 | 2473 |
2474 CHECK(obj->HasPrivate(priv1)); | 2474 CHECK(obj->HasPrivate(priv1)); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2581 | 2581 |
2582 THREADED_TEST(ArrayBuffer_ApiInternalToExternal) { | 2582 THREADED_TEST(ArrayBuffer_ApiInternalToExternal) { |
2583 LocalContext env; | 2583 LocalContext env; |
2584 v8::Isolate* isolate = env->GetIsolate(); | 2584 v8::Isolate* isolate = env->GetIsolate(); |
2585 v8::HandleScope handle_scope(isolate); | 2585 v8::HandleScope handle_scope(isolate); |
2586 | 2586 |
2587 Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(isolate, 1024); | 2587 Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(isolate, 1024); |
2588 CheckInternalFieldsAreZero(ab); | 2588 CheckInternalFieldsAreZero(ab); |
2589 CHECK_EQ(1024, static_cast<int>(ab->ByteLength())); | 2589 CHECK_EQ(1024, static_cast<int>(ab->ByteLength())); |
2590 CHECK(!ab->IsExternal()); | 2590 CHECK(!ab->IsExternal()); |
2591 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2591 CcTest::heap()->CollectAllGarbage(); |
2592 | 2592 |
2593 ScopedArrayBufferContents ab_contents(ab->Externalize()); | 2593 ScopedArrayBufferContents ab_contents(ab->Externalize()); |
2594 CHECK(ab->IsExternal()); | 2594 CHECK(ab->IsExternal()); |
2595 | 2595 |
2596 CHECK_EQ(1024, static_cast<int>(ab_contents.ByteLength())); | 2596 CHECK_EQ(1024, static_cast<int>(ab_contents.ByteLength())); |
2597 uint8_t* data = static_cast<uint8_t*>(ab_contents.Data()); | 2597 uint8_t* data = static_cast<uint8_t*>(ab_contents.Data()); |
2598 DCHECK(data != NULL); | 2598 DCHECK(data != NULL); |
2599 env->Global()->Set(v8_str("ab"), ab); | 2599 env->Global()->Set(v8_str("ab"), ab); |
2600 | 2600 |
2601 v8::Handle<v8::Value> result = CompileRun("ab.byteLength"); | 2601 v8::Handle<v8::Value> result = CompileRun("ab.byteLength"); |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2844 THREADED_TEST(HiddenProperties) { | 2844 THREADED_TEST(HiddenProperties) { |
2845 LocalContext env; | 2845 LocalContext env; |
2846 v8::Isolate* isolate = env->GetIsolate(); | 2846 v8::Isolate* isolate = env->GetIsolate(); |
2847 v8::HandleScope scope(isolate); | 2847 v8::HandleScope scope(isolate); |
2848 | 2848 |
2849 v8::Local<v8::Object> obj = v8::Object::New(env->GetIsolate()); | 2849 v8::Local<v8::Object> obj = v8::Object::New(env->GetIsolate()); |
2850 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); | 2850 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); |
2851 v8::Local<v8::String> empty = v8_str(""); | 2851 v8::Local<v8::String> empty = v8_str(""); |
2852 v8::Local<v8::String> prop_name = v8_str("prop_name"); | 2852 v8::Local<v8::String> prop_name = v8_str("prop_name"); |
2853 | 2853 |
2854 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2854 CcTest::heap()->CollectAllGarbage(); |
2855 | 2855 |
2856 // Make sure delete of a non-existent hidden value works | 2856 // Make sure delete of a non-existent hidden value works |
2857 CHECK(obj->DeleteHiddenValue(key)); | 2857 CHECK(obj->DeleteHiddenValue(key)); |
2858 | 2858 |
2859 CHECK(obj->SetHiddenValue(key, v8::Integer::New(isolate, 1503))); | 2859 CHECK(obj->SetHiddenValue(key, v8::Integer::New(isolate, 1503))); |
2860 CHECK_EQ(1503, obj->GetHiddenValue(key)->Int32Value()); | 2860 CHECK_EQ(1503, obj->GetHiddenValue(key)->Int32Value()); |
2861 CHECK(obj->SetHiddenValue(key, v8::Integer::New(isolate, 2002))); | 2861 CHECK(obj->SetHiddenValue(key, v8::Integer::New(isolate, 2002))); |
2862 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 2862 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
2863 | 2863 |
2864 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2864 CcTest::heap()->CollectAllGarbage(); |
2865 | 2865 |
2866 // Make sure we do not find the hidden property. | 2866 // Make sure we do not find the hidden property. |
2867 CHECK(!obj->Has(empty)); | 2867 CHECK(!obj->Has(empty)); |
2868 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 2868 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
2869 CHECK(obj->Get(empty)->IsUndefined()); | 2869 CHECK(obj->Get(empty)->IsUndefined()); |
2870 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 2870 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
2871 CHECK(obj->Set(empty, v8::Integer::New(isolate, 2003))); | 2871 CHECK(obj->Set(empty, v8::Integer::New(isolate, 2003))); |
2872 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 2872 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
2873 CHECK_EQ(2003, obj->Get(empty)->Int32Value()); | 2873 CHECK_EQ(2003, obj->Get(empty)->Int32Value()); |
2874 | 2874 |
2875 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2875 CcTest::heap()->CollectAllGarbage(); |
2876 | 2876 |
2877 // Add another property and delete it afterwards to force the object in | 2877 // Add another property and delete it afterwards to force the object in |
2878 // slow case. | 2878 // slow case. |
2879 CHECK(obj->Set(prop_name, v8::Integer::New(isolate, 2008))); | 2879 CHECK(obj->Set(prop_name, v8::Integer::New(isolate, 2008))); |
2880 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 2880 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
2881 CHECK_EQ(2008, obj->Get(prop_name)->Int32Value()); | 2881 CHECK_EQ(2008, obj->Get(prop_name)->Int32Value()); |
2882 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 2882 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
2883 CHECK(obj->Delete(prop_name)); | 2883 CHECK(obj->Delete(prop_name)); |
2884 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 2884 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
2885 | 2885 |
2886 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2886 CcTest::heap()->CollectAllGarbage(); |
2887 | 2887 |
2888 CHECK(obj->SetHiddenValue(key, Handle<Value>())); | 2888 CHECK(obj->SetHiddenValue(key, Handle<Value>())); |
2889 CHECK(obj->GetHiddenValue(key).IsEmpty()); | 2889 CHECK(obj->GetHiddenValue(key).IsEmpty()); |
2890 | 2890 |
2891 CHECK(obj->SetHiddenValue(key, v8::Integer::New(isolate, 2002))); | 2891 CHECK(obj->SetHiddenValue(key, v8::Integer::New(isolate, 2002))); |
2892 CHECK(obj->DeleteHiddenValue(key)); | 2892 CHECK(obj->DeleteHiddenValue(key)); |
2893 CHECK(obj->GetHiddenValue(key).IsEmpty()); | 2893 CHECK(obj->GetHiddenValue(key).IsEmpty()); |
2894 } | 2894 } |
2895 | 2895 |
2896 | 2896 |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3163 | 3163 |
3164 | 3164 |
3165 void SecondPassCallback(const v8::WeakCallbackInfo<TwoPassCallbackData>& data) { | 3165 void SecondPassCallback(const v8::WeakCallbackInfo<TwoPassCallbackData>& data) { |
3166 ApiTestFuzzer::Fuzz(); | 3166 ApiTestFuzzer::Fuzz(); |
3167 bool trigger_gc = data.GetParameter()->trigger_gc(); | 3167 bool trigger_gc = data.GetParameter()->trigger_gc(); |
3168 int* instance_counter = data.GetParameter()->instance_counter(); | 3168 int* instance_counter = data.GetParameter()->instance_counter(); |
3169 data.GetParameter()->SecondPass(); | 3169 data.GetParameter()->SecondPass(); |
3170 if (!trigger_gc) return; | 3170 if (!trigger_gc) return; |
3171 auto data_2 = new TwoPassCallbackData(data.GetIsolate(), instance_counter); | 3171 auto data_2 = new TwoPassCallbackData(data.GetIsolate(), instance_counter); |
3172 data_2->SetWeak(); | 3172 data_2->SetWeak(); |
3173 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 3173 CcTest::heap()->CollectAllGarbage(); |
3174 } | 3174 } |
3175 | 3175 |
3176 | 3176 |
3177 void FirstPassCallback(const v8::WeakCallbackInfo<TwoPassCallbackData>& data) { | 3177 void FirstPassCallback(const v8::WeakCallbackInfo<TwoPassCallbackData>& data) { |
3178 data.GetParameter()->FirstPass(); | 3178 data.GetParameter()->FirstPass(); |
3179 data.SetSecondPassCallback(SecondPassCallback); | 3179 data.SetSecondPassCallback(SecondPassCallback); |
3180 } | 3180 } |
3181 | 3181 |
3182 } // namespace | 3182 } // namespace |
3183 | 3183 |
3184 | 3184 |
3185 TEST(TwoPassPhantomCallbacks) { | 3185 TEST(TwoPassPhantomCallbacks) { |
3186 auto isolate = CcTest::isolate(); | 3186 auto isolate = CcTest::isolate(); |
3187 const size_t kLength = 20; | 3187 const size_t kLength = 20; |
3188 int instance_counter = 0; | 3188 int instance_counter = 0; |
3189 for (size_t i = 0; i < kLength; ++i) { | 3189 for (size_t i = 0; i < kLength; ++i) { |
3190 auto data = new TwoPassCallbackData(isolate, &instance_counter); | 3190 auto data = new TwoPassCallbackData(isolate, &instance_counter); |
3191 data->SetWeak(); | 3191 data->SetWeak(); |
3192 } | 3192 } |
3193 CHECK_EQ(static_cast<int>(kLength), instance_counter); | 3193 CHECK_EQ(static_cast<int>(kLength), instance_counter); |
3194 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 3194 CcTest::heap()->CollectAllGarbage(); |
3195 CHECK_EQ(0, instance_counter); | 3195 CHECK_EQ(0, instance_counter); |
3196 } | 3196 } |
3197 | 3197 |
3198 | 3198 |
3199 TEST(TwoPassPhantomCallbacksNestedGc) { | 3199 TEST(TwoPassPhantomCallbacksNestedGc) { |
3200 auto isolate = CcTest::isolate(); | 3200 auto isolate = CcTest::isolate(); |
3201 const size_t kLength = 20; | 3201 const size_t kLength = 20; |
3202 TwoPassCallbackData* array[kLength]; | 3202 TwoPassCallbackData* array[kLength]; |
3203 int instance_counter = 0; | 3203 int instance_counter = 0; |
3204 for (size_t i = 0; i < kLength; ++i) { | 3204 for (size_t i = 0; i < kLength; ++i) { |
3205 array[i] = new TwoPassCallbackData(isolate, &instance_counter); | 3205 array[i] = new TwoPassCallbackData(isolate, &instance_counter); |
3206 array[i]->SetWeak(); | 3206 array[i]->SetWeak(); |
3207 } | 3207 } |
3208 array[5]->MarkTriggerGc(); | 3208 array[5]->MarkTriggerGc(); |
3209 array[10]->MarkTriggerGc(); | 3209 array[10]->MarkTriggerGc(); |
3210 array[15]->MarkTriggerGc(); | 3210 array[15]->MarkTriggerGc(); |
3211 CHECK_EQ(static_cast<int>(kLength), instance_counter); | 3211 CHECK_EQ(static_cast<int>(kLength), instance_counter); |
3212 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 3212 CcTest::heap()->CollectAllGarbage(); |
3213 CHECK_EQ(0, instance_counter); | 3213 CHECK_EQ(0, instance_counter); |
3214 } | 3214 } |
3215 | 3215 |
3216 | 3216 |
3217 template <typename K, typename V> | 3217 template <typename K, typename V> |
3218 class WeakStdMapTraits : public v8::StdMapTraits<K, V> { | 3218 class WeakStdMapTraits : public v8::StdMapTraits<K, V> { |
3219 public: | 3219 public: |
3220 typedef typename v8::PersistentValueMap<K, V, WeakStdMapTraits<K, V>> MapType; | 3220 typedef typename v8::PersistentValueMap<K, V, WeakStdMapTraits<K, V>> MapType; |
3221 static const v8::PersistentContainerCallbackType kCallbackType = v8::kWeak; | 3221 static const v8::PersistentContainerCallbackType kCallbackType = v8::kWeak; |
3222 struct WeakCallbackDataType { | 3222 struct WeakCallbackDataType { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3280 removed = map.Set(8, v8::Global<v8::Object>(isolate, expected2), &ref); | 3280 removed = map.Set(8, v8::Global<v8::Object>(isolate, expected2), &ref); |
3281 CHECK_EQ(1, static_cast<int>(map.Size())); | 3281 CHECK_EQ(1, static_cast<int>(map.Size())); |
3282 CHECK(expected == removed); | 3282 CHECK(expected == removed); |
3283 CHECK(expected2->Equals(ref.NewLocal(isolate))); | 3283 CHECK(expected2->Equals(ref.NewLocal(isolate))); |
3284 } | 3284 } |
3285 } | 3285 } |
3286 CHECK_EQ(initial_handle_count + 1, global_handles->global_handles_count()); | 3286 CHECK_EQ(initial_handle_count + 1, global_handles->global_handles_count()); |
3287 if (map.IsWeak()) { | 3287 if (map.IsWeak()) { |
3288 reinterpret_cast<v8::internal::Isolate*>(isolate) | 3288 reinterpret_cast<v8::internal::Isolate*>(isolate) |
3289 ->heap() | 3289 ->heap() |
3290 ->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 3290 ->CollectAllGarbage(); |
3291 } else { | 3291 } else { |
3292 map.Clear(); | 3292 map.Clear(); |
3293 } | 3293 } |
3294 CHECK_EQ(0, static_cast<int>(map.Size())); | 3294 CHECK_EQ(0, static_cast<int>(map.Size())); |
3295 CHECK_EQ(initial_handle_count, global_handles->global_handles_count()); | 3295 CHECK_EQ(initial_handle_count, global_handles->global_handles_count()); |
3296 } | 3296 } |
3297 | 3297 |
3298 | 3298 |
3299 TEST(PersistentValueMap) { | 3299 TEST(PersistentValueMap) { |
3300 // Default case, w/o weak callbacks: | 3300 // Default case, w/o weak callbacks: |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3616 iso->SetObjectGroupId(g1s1.handle, id1); | 3616 iso->SetObjectGroupId(g1s1.handle, id1); |
3617 iso->SetObjectGroupId(g1s2.handle, id1); | 3617 iso->SetObjectGroupId(g1s2.handle, id1); |
3618 iso->SetReferenceFromGroup(id1, g1c1.handle); | 3618 iso->SetReferenceFromGroup(id1, g1c1.handle); |
3619 iso->SetObjectGroupId(g2s1.handle, id2); | 3619 iso->SetObjectGroupId(g2s1.handle, id2); |
3620 iso->SetObjectGroupId(g2s2.handle, id2); | 3620 iso->SetObjectGroupId(g2s2.handle, id2); |
3621 iso->SetReferenceFromGroup(id2, g2c1.handle); | 3621 iso->SetReferenceFromGroup(id2, g2c1.handle); |
3622 } | 3622 } |
3623 // Do a single full GC, ensure incremental marking is stopped. | 3623 // Do a single full GC, ensure incremental marking is stopped. |
3624 v8::internal::Heap* heap = | 3624 v8::internal::Heap* heap = |
3625 reinterpret_cast<v8::internal::Isolate*>(iso)->heap(); | 3625 reinterpret_cast<v8::internal::Isolate*>(iso)->heap(); |
3626 heap->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 3626 heap->CollectAllGarbage(); |
3627 | 3627 |
3628 // All object should be alive. | 3628 // All object should be alive. |
3629 CHECK_EQ(0, counter.NumberOfWeakCalls()); | 3629 CHECK_EQ(0, counter.NumberOfWeakCalls()); |
3630 | 3630 |
3631 // Weaken the root. | 3631 // Weaken the root. |
3632 root.handle.SetWeak(&root, &WeakPointerCallback); | 3632 root.handle.SetWeak(&root, &WeakPointerCallback); |
3633 // But make children strong roots---all the objects (except for children) | 3633 // But make children strong roots---all the objects (except for children) |
3634 // should be collectable now. | 3634 // should be collectable now. |
3635 g1c1.handle.ClearWeak(); | 3635 g1c1.handle.ClearWeak(); |
3636 g2c1.handle.ClearWeak(); | 3636 g2c1.handle.ClearWeak(); |
3637 | 3637 |
3638 // Groups are deleted, rebuild groups. | 3638 // Groups are deleted, rebuild groups. |
3639 { | 3639 { |
3640 UniqueId id1 = MakeUniqueId(g1s1.handle); | 3640 UniqueId id1 = MakeUniqueId(g1s1.handle); |
3641 UniqueId id2 = MakeUniqueId(g2s2.handle); | 3641 UniqueId id2 = MakeUniqueId(g2s2.handle); |
3642 iso->SetObjectGroupId(g1s1.handle, id1); | 3642 iso->SetObjectGroupId(g1s1.handle, id1); |
3643 iso->SetObjectGroupId(g1s2.handle, id1); | 3643 iso->SetObjectGroupId(g1s2.handle, id1); |
3644 iso->SetReferenceFromGroup(id1, g1c1.handle); | 3644 iso->SetReferenceFromGroup(id1, g1c1.handle); |
3645 iso->SetObjectGroupId(g2s1.handle, id2); | 3645 iso->SetObjectGroupId(g2s1.handle, id2); |
3646 iso->SetObjectGroupId(g2s2.handle, id2); | 3646 iso->SetObjectGroupId(g2s2.handle, id2); |
3647 iso->SetReferenceFromGroup(id2, g2c1.handle); | 3647 iso->SetReferenceFromGroup(id2, g2c1.handle); |
3648 } | 3648 } |
3649 | 3649 |
3650 heap->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 3650 heap->CollectAllGarbage(); |
3651 | 3651 |
3652 // All objects should be gone. 5 global handles in total. | 3652 // All objects should be gone. 5 global handles in total. |
3653 CHECK_EQ(5, counter.NumberOfWeakCalls()); | 3653 CHECK_EQ(5, counter.NumberOfWeakCalls()); |
3654 | 3654 |
3655 // And now make children weak again and collect them. | 3655 // And now make children weak again and collect them. |
3656 g1c1.handle.SetWeak(&g1c1, &WeakPointerCallback); | 3656 g1c1.handle.SetWeak(&g1c1, &WeakPointerCallback); |
3657 g2c1.handle.SetWeak(&g2c1, &WeakPointerCallback); | 3657 g2c1.handle.SetWeak(&g2c1, &WeakPointerCallback); |
3658 | 3658 |
3659 heap->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 3659 heap->CollectAllGarbage(); |
3660 CHECK_EQ(7, counter.NumberOfWeakCalls()); | 3660 CHECK_EQ(7, counter.NumberOfWeakCalls()); |
3661 } | 3661 } |
3662 | 3662 |
3663 | 3663 |
3664 THREADED_TEST(ApiObjectGroupsForSubtypes) { | 3664 THREADED_TEST(ApiObjectGroupsForSubtypes) { |
3665 LocalContext env; | 3665 LocalContext env; |
3666 v8::Isolate* iso = env->GetIsolate(); | 3666 v8::Isolate* iso = env->GetIsolate(); |
3667 HandleScope scope(iso); | 3667 HandleScope scope(iso); |
3668 | 3668 |
3669 WeakCallCounter counter(1234); | 3669 WeakCallCounter counter(1234); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3710 iso->SetObjectGroupId(g1s1.handle, id1); | 3710 iso->SetObjectGroupId(g1s1.handle, id1); |
3711 iso->SetObjectGroupId(g1s2.handle, id1); | 3711 iso->SetObjectGroupId(g1s2.handle, id1); |
3712 iso->SetReference(g1s1.handle, g1c1.handle); | 3712 iso->SetReference(g1s1.handle, g1c1.handle); |
3713 iso->SetObjectGroupId(g2s1.handle, id2); | 3713 iso->SetObjectGroupId(g2s1.handle, id2); |
3714 iso->SetObjectGroupId(g2s2.handle, id2); | 3714 iso->SetObjectGroupId(g2s2.handle, id2); |
3715 iso->SetReferenceFromGroup(id2, g2c1.handle); | 3715 iso->SetReferenceFromGroup(id2, g2c1.handle); |
3716 } | 3716 } |
3717 // Do a single full GC, ensure incremental marking is stopped. | 3717 // Do a single full GC, ensure incremental marking is stopped. |
3718 v8::internal::Heap* heap = | 3718 v8::internal::Heap* heap = |
3719 reinterpret_cast<v8::internal::Isolate*>(iso)->heap(); | 3719 reinterpret_cast<v8::internal::Isolate*>(iso)->heap(); |
3720 heap->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 3720 heap->CollectAllGarbage(); |
3721 | 3721 |
3722 // All object should be alive. | 3722 // All object should be alive. |
3723 CHECK_EQ(0, counter.NumberOfWeakCalls()); | 3723 CHECK_EQ(0, counter.NumberOfWeakCalls()); |
3724 | 3724 |
3725 // Weaken the root. | 3725 // Weaken the root. |
3726 root.handle.SetWeak(&root, &WeakPointerCallback); | 3726 root.handle.SetWeak(&root, &WeakPointerCallback); |
3727 // But make children strong roots---all the objects (except for children) | 3727 // But make children strong roots---all the objects (except for children) |
3728 // should be collectable now. | 3728 // should be collectable now. |
3729 g1c1.handle.ClearWeak(); | 3729 g1c1.handle.ClearWeak(); |
3730 g2c1.handle.ClearWeak(); | 3730 g2c1.handle.ClearWeak(); |
3731 | 3731 |
3732 // Groups are deleted, rebuild groups. | 3732 // Groups are deleted, rebuild groups. |
3733 { | 3733 { |
3734 UniqueId id1 = MakeUniqueId(g1s1.handle); | 3734 UniqueId id1 = MakeUniqueId(g1s1.handle); |
3735 UniqueId id2 = MakeUniqueId(g2s2.handle); | 3735 UniqueId id2 = MakeUniqueId(g2s2.handle); |
3736 iso->SetObjectGroupId(g1s1.handle, id1); | 3736 iso->SetObjectGroupId(g1s1.handle, id1); |
3737 iso->SetObjectGroupId(g1s2.handle, id1); | 3737 iso->SetObjectGroupId(g1s2.handle, id1); |
3738 iso->SetReference(g1s1.handle, g1c1.handle); | 3738 iso->SetReference(g1s1.handle, g1c1.handle); |
3739 iso->SetObjectGroupId(g2s1.handle, id2); | 3739 iso->SetObjectGroupId(g2s1.handle, id2); |
3740 iso->SetObjectGroupId(g2s2.handle, id2); | 3740 iso->SetObjectGroupId(g2s2.handle, id2); |
3741 iso->SetReferenceFromGroup(id2, g2c1.handle); | 3741 iso->SetReferenceFromGroup(id2, g2c1.handle); |
3742 } | 3742 } |
3743 | 3743 |
3744 heap->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 3744 heap->CollectAllGarbage(); |
3745 | 3745 |
3746 // All objects should be gone. 5 global handles in total. | 3746 // All objects should be gone. 5 global handles in total. |
3747 CHECK_EQ(5, counter.NumberOfWeakCalls()); | 3747 CHECK_EQ(5, counter.NumberOfWeakCalls()); |
3748 | 3748 |
3749 // And now make children weak again and collect them. | 3749 // And now make children weak again and collect them. |
3750 g1c1.handle.SetWeak(&g1c1, &WeakPointerCallback); | 3750 g1c1.handle.SetWeak(&g1c1, &WeakPointerCallback); |
3751 g2c1.handle.SetWeak(&g2c1, &WeakPointerCallback); | 3751 g2c1.handle.SetWeak(&g2c1, &WeakPointerCallback); |
3752 | 3752 |
3753 heap->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 3753 heap->CollectAllGarbage(); |
3754 CHECK_EQ(7, counter.NumberOfWeakCalls()); | 3754 CHECK_EQ(7, counter.NumberOfWeakCalls()); |
3755 } | 3755 } |
3756 | 3756 |
3757 | 3757 |
3758 THREADED_TEST(ApiObjectGroupsCycle) { | 3758 THREADED_TEST(ApiObjectGroupsCycle) { |
3759 LocalContext env; | 3759 LocalContext env; |
3760 v8::Isolate* iso = env->GetIsolate(); | 3760 v8::Isolate* iso = env->GetIsolate(); |
3761 HandleScope scope(iso); | 3761 HandleScope scope(iso); |
3762 | 3762 |
3763 WeakCallCounter counter(1234); | 3763 WeakCallCounter counter(1234); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3822 iso->SetObjectGroupId(g3s1.handle, id3); | 3822 iso->SetObjectGroupId(g3s1.handle, id3); |
3823 iso->SetObjectGroupId(g3s2.handle, id3); | 3823 iso->SetObjectGroupId(g3s2.handle, id3); |
3824 iso->SetReferenceFromGroup(id3, g4s1.handle); | 3824 iso->SetReferenceFromGroup(id3, g4s1.handle); |
3825 iso->SetObjectGroupId(g4s1.handle, id4); | 3825 iso->SetObjectGroupId(g4s1.handle, id4); |
3826 iso->SetObjectGroupId(g4s2.handle, id4); | 3826 iso->SetObjectGroupId(g4s2.handle, id4); |
3827 iso->SetReferenceFromGroup(id4, g1s1.handle); | 3827 iso->SetReferenceFromGroup(id4, g1s1.handle); |
3828 } | 3828 } |
3829 // Do a single full GC | 3829 // Do a single full GC |
3830 v8::internal::Heap* heap = | 3830 v8::internal::Heap* heap = |
3831 reinterpret_cast<v8::internal::Isolate*>(iso)->heap(); | 3831 reinterpret_cast<v8::internal::Isolate*>(iso)->heap(); |
3832 heap->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 3832 heap->CollectAllGarbage(); |
3833 | 3833 |
3834 // All object should be alive. | 3834 // All object should be alive. |
3835 CHECK_EQ(0, counter.NumberOfWeakCalls()); | 3835 CHECK_EQ(0, counter.NumberOfWeakCalls()); |
3836 | 3836 |
3837 // Weaken the root. | 3837 // Weaken the root. |
3838 root.handle.SetWeak(&root, &WeakPointerCallback); | 3838 root.handle.SetWeak(&root, &WeakPointerCallback); |
3839 | 3839 |
3840 // Groups are deleted, rebuild groups. | 3840 // Groups are deleted, rebuild groups. |
3841 { | 3841 { |
3842 UniqueId id1 = MakeUniqueId(g1s1.handle); | 3842 UniqueId id1 = MakeUniqueId(g1s1.handle); |
3843 UniqueId id2 = MakeUniqueId(g2s1.handle); | 3843 UniqueId id2 = MakeUniqueId(g2s1.handle); |
3844 UniqueId id3 = MakeUniqueId(g3s1.handle); | 3844 UniqueId id3 = MakeUniqueId(g3s1.handle); |
3845 UniqueId id4 = MakeUniqueId(g4s1.handle); | 3845 UniqueId id4 = MakeUniqueId(g4s1.handle); |
3846 iso->SetObjectGroupId(g1s1.handle, id1); | 3846 iso->SetObjectGroupId(g1s1.handle, id1); |
3847 iso->SetObjectGroupId(g1s2.handle, id1); | 3847 iso->SetObjectGroupId(g1s2.handle, id1); |
3848 iso->SetReferenceFromGroup(id1, g2s1.handle); | 3848 iso->SetReferenceFromGroup(id1, g2s1.handle); |
3849 iso->SetObjectGroupId(g2s1.handle, id2); | 3849 iso->SetObjectGroupId(g2s1.handle, id2); |
3850 iso->SetObjectGroupId(g2s2.handle, id2); | 3850 iso->SetObjectGroupId(g2s2.handle, id2); |
3851 iso->SetReferenceFromGroup(id2, g3s1.handle); | 3851 iso->SetReferenceFromGroup(id2, g3s1.handle); |
3852 iso->SetObjectGroupId(g3s1.handle, id3); | 3852 iso->SetObjectGroupId(g3s1.handle, id3); |
3853 iso->SetObjectGroupId(g3s2.handle, id3); | 3853 iso->SetObjectGroupId(g3s2.handle, id3); |
3854 iso->SetReferenceFromGroup(id3, g4s1.handle); | 3854 iso->SetReferenceFromGroup(id3, g4s1.handle); |
3855 iso->SetObjectGroupId(g4s1.handle, id4); | 3855 iso->SetObjectGroupId(g4s1.handle, id4); |
3856 iso->SetObjectGroupId(g4s2.handle, id4); | 3856 iso->SetObjectGroupId(g4s2.handle, id4); |
3857 iso->SetReferenceFromGroup(id4, g1s1.handle); | 3857 iso->SetReferenceFromGroup(id4, g1s1.handle); |
3858 } | 3858 } |
3859 | 3859 |
3860 heap->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 3860 heap->CollectAllGarbage(); |
3861 | 3861 |
3862 // All objects should be gone. 9 global handles in total. | 3862 // All objects should be gone. 9 global handles in total. |
3863 CHECK_EQ(9, counter.NumberOfWeakCalls()); | 3863 CHECK_EQ(9, counter.NumberOfWeakCalls()); |
3864 } | 3864 } |
3865 | 3865 |
3866 | 3866 |
3867 THREADED_TEST(WeakRootsSurviveTwoRoundsOfGC) { | 3867 THREADED_TEST(WeakRootsSurviveTwoRoundsOfGC) { |
3868 LocalContext env; | 3868 LocalContext env; |
3869 v8::Isolate* iso = env->GetIsolate(); | 3869 v8::Isolate* iso = env->GetIsolate(); |
3870 HandleScope scope(iso); | 3870 HandleScope scope(iso); |
3871 | 3871 |
3872 WeakCallCounter counter(1234); | 3872 WeakCallCounter counter(1234); |
3873 | 3873 |
3874 WeakCallCounterAndPersistent<Value> weak_obj(&counter); | 3874 WeakCallCounterAndPersistent<Value> weak_obj(&counter); |
3875 | 3875 |
3876 // Create a weak object that references a internalized string. | 3876 // Create a weak object that references a internalized string. |
3877 { | 3877 { |
3878 HandleScope scope(iso); | 3878 HandleScope scope(iso); |
3879 weak_obj.handle.Reset(iso, Object::New(iso)); | 3879 weak_obj.handle.Reset(iso, Object::New(iso)); |
3880 weak_obj.handle.SetWeak(&weak_obj, &WeakPointerCallback); | 3880 weak_obj.handle.SetWeak(&weak_obj, &WeakPointerCallback); |
3881 CHECK(weak_obj.handle.IsWeak()); | 3881 CHECK(weak_obj.handle.IsWeak()); |
3882 Local<Object>::New(iso, weak_obj.handle.As<Object>()) | 3882 Local<Object>::New(iso, weak_obj.handle.As<Object>()) |
3883 ->Set(v8_str("x"), String::NewFromUtf8(iso, "magic cookie", | 3883 ->Set(v8_str("x"), String::NewFromUtf8(iso, "magic cookie", |
3884 String::kInternalizedString)); | 3884 String::kInternalizedString)); |
3885 } | 3885 } |
3886 // Do a single full GC | 3886 // Do a single full GC |
3887 i::Isolate* i_iso = reinterpret_cast<v8::internal::Isolate*>(iso); | 3887 i::Isolate* i_iso = reinterpret_cast<v8::internal::Isolate*>(iso); |
3888 i::Heap* heap = i_iso->heap(); | 3888 i::Heap* heap = i_iso->heap(); |
3889 heap->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 3889 heap->CollectAllGarbage(); |
3890 | 3890 |
3891 // We should have received the weak callback. | 3891 // We should have received the weak callback. |
3892 CHECK_EQ(1, counter.NumberOfWeakCalls()); | 3892 CHECK_EQ(1, counter.NumberOfWeakCalls()); |
3893 | 3893 |
3894 // Check that the string is still alive. | 3894 // Check that the string is still alive. |
3895 { | 3895 { |
3896 HandleScope scope(iso); | 3896 HandleScope scope(iso); |
3897 i::MaybeHandle<i::String> magic_string = | 3897 i::MaybeHandle<i::String> magic_string = |
3898 i::StringTable::LookupStringIfExists( | 3898 i::StringTable::LookupStringIfExists( |
3899 i_iso, | 3899 i_iso, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3964 Local<Object>::New(iso, g2s1.handle.As<Object>()) | 3964 Local<Object>::New(iso, g2s1.handle.As<Object>()) |
3965 ->Set(v8_str("x"), Local<Value>::New(iso, g3s1.handle)); | 3965 ->Set(v8_str("x"), Local<Value>::New(iso, g3s1.handle)); |
3966 iso->SetObjectGroupId(g3s1.handle, UniqueId(3)); | 3966 iso->SetObjectGroupId(g3s1.handle, UniqueId(3)); |
3967 iso->SetObjectGroupId(g3s2.handle, UniqueId(3)); | 3967 iso->SetObjectGroupId(g3s2.handle, UniqueId(3)); |
3968 Local<Object>::New(iso, g3s1.handle.As<Object>()) | 3968 Local<Object>::New(iso, g3s1.handle.As<Object>()) |
3969 ->Set(v8_str("x"), Local<Value>::New(iso, g1s1.handle)); | 3969 ->Set(v8_str("x"), Local<Value>::New(iso, g1s1.handle)); |
3970 } | 3970 } |
3971 | 3971 |
3972 v8::internal::Heap* heap = | 3972 v8::internal::Heap* heap = |
3973 reinterpret_cast<v8::internal::Isolate*>(iso)->heap(); | 3973 reinterpret_cast<v8::internal::Isolate*>(iso)->heap(); |
3974 heap->CollectAllGarbage(i::Heap::kNoGCFlags); | 3974 heap->CollectAllGarbage(); |
3975 | 3975 |
3976 // All objects should be alive. | 3976 // All objects should be alive. |
3977 CHECK_EQ(0, counter.NumberOfWeakCalls()); | 3977 CHECK_EQ(0, counter.NumberOfWeakCalls()); |
3978 | 3978 |
3979 // Weaken the root. | 3979 // Weaken the root. |
3980 root.handle.SetWeak(&root, &WeakPointerCallback); | 3980 root.handle.SetWeak(&root, &WeakPointerCallback); |
3981 root.handle.MarkPartiallyDependent(); | 3981 root.handle.MarkPartiallyDependent(); |
3982 | 3982 |
3983 // Groups are deleted, rebuild groups. | 3983 // Groups are deleted, rebuild groups. |
3984 { | 3984 { |
(...skipping 11 matching lines...) Expand all Loading... |
3996 iso->SetObjectGroupId(g2s1.handle, UniqueId(2)); | 3996 iso->SetObjectGroupId(g2s1.handle, UniqueId(2)); |
3997 iso->SetObjectGroupId(g2s2.handle, UniqueId(2)); | 3997 iso->SetObjectGroupId(g2s2.handle, UniqueId(2)); |
3998 Local<Object>::New(iso, g2s1.handle.As<Object>()) | 3998 Local<Object>::New(iso, g2s1.handle.As<Object>()) |
3999 ->Set(v8_str("x"), Local<Value>::New(iso, g3s1.handle)); | 3999 ->Set(v8_str("x"), Local<Value>::New(iso, g3s1.handle)); |
4000 iso->SetObjectGroupId(g3s1.handle, UniqueId(3)); | 4000 iso->SetObjectGroupId(g3s1.handle, UniqueId(3)); |
4001 iso->SetObjectGroupId(g3s2.handle, UniqueId(3)); | 4001 iso->SetObjectGroupId(g3s2.handle, UniqueId(3)); |
4002 Local<Object>::New(iso, g3s1.handle.As<Object>()) | 4002 Local<Object>::New(iso, g3s1.handle.As<Object>()) |
4003 ->Set(v8_str("x"), Local<Value>::New(iso, g1s1.handle)); | 4003 ->Set(v8_str("x"), Local<Value>::New(iso, g1s1.handle)); |
4004 } | 4004 } |
4005 | 4005 |
4006 heap->CollectAllGarbage(i::Heap::kNoGCFlags); | 4006 heap->CollectAllGarbage(); |
4007 | 4007 |
4008 // All objects should be gone. 7 global handles in total. | 4008 // All objects should be gone. 7 global handles in total. |
4009 CHECK_EQ(7, counter.NumberOfWeakCalls()); | 4009 CHECK_EQ(7, counter.NumberOfWeakCalls()); |
4010 } | 4010 } |
4011 | 4011 |
4012 | 4012 |
4013 THREADED_TEST(ScriptException) { | 4013 THREADED_TEST(ScriptException) { |
4014 LocalContext env; | 4014 LocalContext env; |
4015 v8::HandleScope scope(env->GetIsolate()); | 4015 v8::HandleScope scope(env->GetIsolate()); |
4016 Local<Script> script = v8_compile("throw 'panama!';"); | 4016 Local<Script> script = v8_compile("throw 'panama!';"); |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4256 CHECK(weak_map->Has(local1)); | 4256 CHECK(weak_map->Has(local1)); |
4257 CHECK(weak_map->Has(obj1)); | 4257 CHECK(weak_map->Has(obj1)); |
4258 CHECK(weak_map->Has(obj2)); | 4258 CHECK(weak_map->Has(obj2)); |
4259 CHECK(weak_map->Has(sym1)); | 4259 CHECK(weak_map->Has(sym1)); |
4260 | 4260 |
4261 CHECK(value->Equals(weak_map->Get(local1))); | 4261 CHECK(value->Equals(weak_map->Get(local1))); |
4262 CHECK(value->Equals(weak_map->Get(obj1))); | 4262 CHECK(value->Equals(weak_map->Get(obj1))); |
4263 CHECK(value->Equals(weak_map->Get(obj2))); | 4263 CHECK(value->Equals(weak_map->Get(obj2))); |
4264 CHECK(value->Equals(weak_map->Get(sym1))); | 4264 CHECK(value->Equals(weak_map->Get(sym1))); |
4265 } | 4265 } |
4266 CcTest::heap()->CollectAllGarbage(TestHeap::Heap::kNoGCFlags); | 4266 CcTest::heap()->CollectAllGarbage(); |
4267 { | 4267 { |
4268 HandleScope scope(isolate); | 4268 HandleScope scope(isolate); |
4269 CHECK(value->Equals(weak_map->Get(local1))); | 4269 CHECK(value->Equals(weak_map->Get(local1))); |
4270 CHECK(value->Equals(weak_map->Get(Local<Value>::New(isolate, o1.handle)))); | 4270 CHECK(value->Equals(weak_map->Get(Local<Value>::New(isolate, o1.handle)))); |
4271 CHECK(value->Equals(weak_map->Get(Local<Value>::New(isolate, o2.handle)))); | 4271 CHECK(value->Equals(weak_map->Get(Local<Value>::New(isolate, o2.handle)))); |
4272 CHECK(value->Equals(weak_map->Get(Local<Value>::New(isolate, s1.handle)))); | 4272 CHECK(value->Equals(weak_map->Get(Local<Value>::New(isolate, s1.handle)))); |
4273 } | 4273 } |
4274 | 4274 |
4275 o1.handle.SetWeak(&o1, &WeakPointerCallback); | 4275 o1.handle.SetWeak(&o1, &WeakPointerCallback); |
4276 o2.handle.SetWeak(&o2, &WeakPointerCallback); | 4276 o2.handle.SetWeak(&o2, &WeakPointerCallback); |
4277 s1.handle.SetWeak(&s1, &WeakPointerCallback); | 4277 s1.handle.SetWeak(&s1, &WeakPointerCallback); |
4278 | 4278 |
4279 CcTest::heap()->CollectAllGarbage(TestHeap::Heap::kNoGCFlags); | 4279 CcTest::heap()->CollectAllGarbage(); |
4280 CHECK_EQ(3, counter.NumberOfWeakCalls()); | 4280 CHECK_EQ(3, counter.NumberOfWeakCalls()); |
4281 | 4281 |
4282 CHECK(o1.handle.IsEmpty()); | 4282 CHECK(o1.handle.IsEmpty()); |
4283 CHECK(o2.handle.IsEmpty()); | 4283 CHECK(o2.handle.IsEmpty()); |
4284 CHECK(s1.handle.IsEmpty()); | 4284 CHECK(s1.handle.IsEmpty()); |
4285 | 4285 |
4286 CHECK(value->Equals(weak_map->Get(local1))); | 4286 CHECK(value->Equals(weak_map->Get(local1))); |
4287 CHECK(weak_map->Delete(local1)); | 4287 CHECK(weak_map->Delete(local1)); |
4288 CHECK(!weak_map->Has(local1)); | 4288 CHECK(!weak_map->Has(local1)); |
4289 CHECK(weak_map->Get(local1)->IsUndefined()); | 4289 CHECK(weak_map->Get(local1)->IsUndefined()); |
(...skipping 2232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6522 v8::HandleScope handle_scope(iso); | 6522 v8::HandleScope handle_scope(iso); |
6523 Local<Object> a(v8::Object::New(iso)); | 6523 Local<Object> a(v8::Object::New(iso)); |
6524 Local<Object> b(v8::Object::New(iso)); | 6524 Local<Object> b(v8::Object::New(iso)); |
6525 object_a.handle.Reset(iso, a); | 6525 object_a.handle.Reset(iso, a); |
6526 object_b.handle.Reset(iso, b); | 6526 object_b.handle.Reset(iso, b); |
6527 if (interlinked) { | 6527 if (interlinked) { |
6528 a->Set(v8_str("x"), b); | 6528 a->Set(v8_str("x"), b); |
6529 b->Set(v8_str("x"), a); | 6529 b->Set(v8_str("x"), a); |
6530 } | 6530 } |
6531 if (global_gc) { | 6531 if (global_gc) { |
6532 CcTest::heap()->CollectAllGarbage(TestHeap::Heap::kNoGCFlags); | 6532 CcTest::heap()->CollectAllGarbage(); |
6533 } else { | 6533 } else { |
6534 CcTest::heap()->CollectGarbage(i::NEW_SPACE); | 6534 CcTest::heap()->CollectGarbage(i::NEW_SPACE); |
6535 } | 6535 } |
6536 // We are relying on this creating a big flag array and reserving the space | 6536 // We are relying on this creating a big flag array and reserving the space |
6537 // up front. | 6537 // up front. |
6538 v8::Handle<Value> big_array = CompileRun("new Array(50000)"); | 6538 v8::Handle<Value> big_array = CompileRun("new Array(50000)"); |
6539 a->Set(v8_str("y"), big_array); | 6539 a->Set(v8_str("y"), big_array); |
6540 big_heap_size = CcTest::heap()->SizeOfObjects(); | 6540 big_heap_size = CcTest::heap()->SizeOfObjects(); |
6541 } | 6541 } |
6542 | 6542 |
6543 object_a.flag = false; | 6543 object_a.flag = false; |
6544 object_b.flag = false; | 6544 object_b.flag = false; |
6545 object_a.handle.SetWeak(&object_a, &SetFlag, | 6545 object_a.handle.SetWeak(&object_a, &SetFlag, |
6546 v8::WeakCallbackType::kParameter); | 6546 v8::WeakCallbackType::kParameter); |
6547 object_b.handle.SetWeak(&object_b, &SetFlag, | 6547 object_b.handle.SetWeak(&object_b, &SetFlag, |
6548 v8::WeakCallbackType::kParameter); | 6548 v8::WeakCallbackType::kParameter); |
6549 CHECK(!object_b.handle.IsIndependent()); | 6549 CHECK(!object_b.handle.IsIndependent()); |
6550 object_a.handle.MarkIndependent(); | 6550 object_a.handle.MarkIndependent(); |
6551 object_b.handle.MarkIndependent(); | 6551 object_b.handle.MarkIndependent(); |
6552 CHECK(object_b.handle.IsIndependent()); | 6552 CHECK(object_b.handle.IsIndependent()); |
6553 if (global_gc) { | 6553 if (global_gc) { |
6554 CcTest::heap()->CollectAllGarbage(TestHeap::Heap::kNoGCFlags); | 6554 CcTest::heap()->CollectAllGarbage(); |
6555 } else { | 6555 } else { |
6556 CcTest::heap()->CollectGarbage(i::NEW_SPACE); | 6556 CcTest::heap()->CollectGarbage(i::NEW_SPACE); |
6557 } | 6557 } |
6558 // A single GC should be enough to reclaim the memory, since we are using | 6558 // A single GC should be enough to reclaim the memory, since we are using |
6559 // phantom handles. | 6559 // phantom handles. |
6560 CHECK_LT(CcTest::heap()->SizeOfObjects(), big_heap_size - 200000); | 6560 CHECK_LT(CcTest::heap()->SizeOfObjects(), big_heap_size - 200000); |
6561 CHECK(object_a.flag); | 6561 CHECK(object_a.flag); |
6562 CHECK(object_b.flag); | 6562 CHECK(object_b.flag); |
6563 } | 6563 } |
6564 | 6564 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6640 reinterpret_cast<Trivial2*>(obj->GetAlignedPointerFromInternalField(1)); | 6640 reinterpret_cast<Trivial2*>(obj->GetAlignedPointerFromInternalField(1)); |
6641 CHECK_EQ(103, t2->x()); | 6641 CHECK_EQ(103, t2->x()); |
6642 | 6642 |
6643 handle.SetWeak<v8::Persistent<v8::Object>>( | 6643 handle.SetWeak<v8::Persistent<v8::Object>>( |
6644 &handle, CheckInternalFields, v8::WeakCallbackType::kInternalFields); | 6644 &handle, CheckInternalFields, v8::WeakCallbackType::kInternalFields); |
6645 if (!global_gc) { | 6645 if (!global_gc) { |
6646 handle.MarkIndependent(); | 6646 handle.MarkIndependent(); |
6647 } | 6647 } |
6648 } | 6648 } |
6649 if (global_gc) { | 6649 if (global_gc) { |
6650 CcTest::heap()->CollectAllGarbage(TestHeap::Heap::kNoGCFlags); | 6650 CcTest::heap()->CollectAllGarbage(); |
6651 } else { | 6651 } else { |
6652 CcTest::heap()->CollectGarbage(i::NEW_SPACE); | 6652 CcTest::heap()->CollectGarbage(i::NEW_SPACE); |
6653 } | 6653 } |
6654 | 6654 |
6655 CHECK_EQ(1729, t1->x()); | 6655 CHECK_EQ(1729, t1->x()); |
6656 CHECK_EQ(33550336, t2->x()); | 6656 CHECK_EQ(33550336, t2->x()); |
6657 | 6657 |
6658 delete t1; | 6658 delete t1; |
6659 delete t2; | 6659 delete t2; |
6660 } | 6660 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6720 | 6720 |
6721 THREADED_TEST(ResetWeakHandle) { | 6721 THREADED_TEST(ResetWeakHandle) { |
6722 ResetWeakHandle(false); | 6722 ResetWeakHandle(false); |
6723 ResetWeakHandle(true); | 6723 ResetWeakHandle(true); |
6724 } | 6724 } |
6725 | 6725 |
6726 | 6726 |
6727 static void InvokeScavenge() { CcTest::heap()->CollectGarbage(i::NEW_SPACE); } | 6727 static void InvokeScavenge() { CcTest::heap()->CollectGarbage(i::NEW_SPACE); } |
6728 | 6728 |
6729 | 6729 |
6730 static void InvokeMarkSweep() { | 6730 static void InvokeMarkSweep() { CcTest::heap()->CollectAllGarbage(); } |
6731 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | |
6732 } | |
6733 | 6731 |
6734 | 6732 |
6735 static void ForceScavenge( | 6733 static void ForceScavenge( |
6736 const v8::WeakCallbackData<v8::Object, FlagAndPersistent>& data) { | 6734 const v8::WeakCallbackData<v8::Object, FlagAndPersistent>& data) { |
6737 data.GetParameter()->handle.Reset(); | 6735 data.GetParameter()->handle.Reset(); |
6738 data.GetParameter()->flag = true; | 6736 data.GetParameter()->flag = true; |
6739 InvokeScavenge(); | 6737 InvokeScavenge(); |
6740 } | 6738 } |
6741 | 6739 |
6742 | 6740 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6800 object.handle.Reset(isolate, o); | 6798 object.handle.Reset(isolate, o); |
6801 o->Set(v8_str("x"), v8::Integer::New(isolate, 1)); | 6799 o->Set(v8_str("x"), v8::Integer::New(isolate, 1)); |
6802 v8::Local<String> y_str = v8_str("y"); | 6800 v8::Local<String> y_str = v8_str("y"); |
6803 o->Set(y_str, y_str); | 6801 o->Set(y_str, y_str); |
6804 } | 6802 } |
6805 object.flag = false; | 6803 object.flag = false; |
6806 object.handle.SetWeak(&object, &RevivingCallback); | 6804 object.handle.SetWeak(&object, &RevivingCallback); |
6807 object.handle.MarkIndependent(); | 6805 object.handle.MarkIndependent(); |
6808 CcTest::heap()->CollectGarbage(i::NEW_SPACE); | 6806 CcTest::heap()->CollectGarbage(i::NEW_SPACE); |
6809 CHECK(object.flag); | 6807 CHECK(object.flag); |
6810 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 6808 CcTest::heap()->CollectAllGarbage(); |
6811 { | 6809 { |
6812 v8::HandleScope handle_scope(isolate); | 6810 v8::HandleScope handle_scope(isolate); |
6813 v8::Local<v8::Object> o = | 6811 v8::Local<v8::Object> o = |
6814 v8::Local<v8::Object>::New(isolate, object.handle); | 6812 v8::Local<v8::Object>::New(isolate, object.handle); |
6815 v8::Local<String> y_str = v8_str("y"); | 6813 v8::Local<String> y_str = v8_str("y"); |
6816 CHECK(v8::Integer::New(isolate, 1)->Equals(o->Get(v8_str("x")))); | 6814 CHECK(v8::Integer::New(isolate, 1)->Equals(o->Get(v8_str("x")))); |
6817 CHECK(o->Get(y_str)->Equals(y_str)); | 6815 CHECK(o->Get(y_str)->Equals(y_str)); |
6818 } | 6816 } |
6819 } | 6817 } |
6820 | 6818 |
6821 | 6819 |
6822 v8::Handle<Function> args_fun; | 6820 v8::Handle<Function> args_fun; |
6823 | 6821 |
6824 | 6822 |
6825 static void ArgumentsTestCallback( | 6823 static void ArgumentsTestCallback( |
6826 const v8::FunctionCallbackInfo<v8::Value>& args) { | 6824 const v8::FunctionCallbackInfo<v8::Value>& args) { |
6827 ApiTestFuzzer::Fuzz(); | 6825 ApiTestFuzzer::Fuzz(); |
6828 v8::Isolate* isolate = args.GetIsolate(); | 6826 v8::Isolate* isolate = args.GetIsolate(); |
6829 CHECK(args_fun->Equals(args.Callee())); | 6827 CHECK(args_fun->Equals(args.Callee())); |
6830 CHECK_EQ(3, args.Length()); | 6828 CHECK_EQ(3, args.Length()); |
6831 CHECK(v8::Integer::New(isolate, 1)->Equals(args[0])); | 6829 CHECK(v8::Integer::New(isolate, 1)->Equals(args[0])); |
6832 CHECK(v8::Integer::New(isolate, 2)->Equals(args[1])); | 6830 CHECK(v8::Integer::New(isolate, 2)->Equals(args[1])); |
6833 CHECK(v8::Integer::New(isolate, 3)->Equals(args[2])); | 6831 CHECK(v8::Integer::New(isolate, 3)->Equals(args[2])); |
6834 CHECK(v8::Undefined(isolate)->Equals(args[3])); | 6832 CHECK(v8::Undefined(isolate)->Equals(args[3])); |
6835 v8::HandleScope scope(args.GetIsolate()); | 6833 v8::HandleScope scope(args.GetIsolate()); |
6836 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 6834 CcTest::heap()->CollectAllGarbage(); |
6837 } | 6835 } |
6838 | 6836 |
6839 | 6837 |
6840 THREADED_TEST(Arguments) { | 6838 THREADED_TEST(Arguments) { |
6841 v8::Isolate* isolate = CcTest::isolate(); | 6839 v8::Isolate* isolate = CcTest::isolate(); |
6842 v8::HandleScope scope(isolate); | 6840 v8::HandleScope scope(isolate); |
6843 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(isolate); | 6841 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(isolate); |
6844 global->Set(v8_str("f"), | 6842 global->Set(v8_str("f"), |
6845 v8::FunctionTemplate::New(isolate, ArgumentsTestCallback)); | 6843 v8::FunctionTemplate::New(isolate, ArgumentsTestCallback)); |
6846 LocalContext context(NULL, global); | 6844 LocalContext context(NULL, global); |
(...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8078 CHECK(access_f3->Run().IsEmpty()); | 8076 CHECK(access_f3->Run().IsEmpty()); |
8079 } | 8077 } |
8080 } | 8078 } |
8081 | 8079 |
8082 | 8080 |
8083 static bool security_check_with_gc_called; | 8081 static bool security_check_with_gc_called; |
8084 | 8082 |
8085 static bool SecurityTestCallbackWithGC(Local<v8::Object> global, | 8083 static bool SecurityTestCallbackWithGC(Local<v8::Object> global, |
8086 Local<v8::Value> name, | 8084 Local<v8::Value> name, |
8087 v8::AccessType type, Local<Value> data) { | 8085 v8::AccessType type, Local<Value> data) { |
8088 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 8086 CcTest::heap()->CollectAllGarbage(); |
8089 security_check_with_gc_called = true; | 8087 security_check_with_gc_called = true; |
8090 return true; | 8088 return true; |
8091 } | 8089 } |
8092 | 8090 |
8093 | 8091 |
8094 TEST(SecurityTestGCAllowed) { | 8092 TEST(SecurityTestGCAllowed) { |
8095 v8::Isolate* isolate = CcTest::isolate(); | 8093 v8::Isolate* isolate = CcTest::isolate(); |
8096 v8::HandleScope handle_scope(isolate); | 8094 v8::HandleScope handle_scope(isolate); |
8097 v8::Handle<v8::ObjectTemplate> object_template = | 8095 v8::Handle<v8::ObjectTemplate> object_template = |
8098 v8::ObjectTemplate::New(isolate); | 8096 v8::ObjectTemplate::New(isolate); |
(...skipping 2262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10361 | 10359 |
10362 | 10360 |
10363 static void InterceptorCallICFastApi( | 10361 static void InterceptorCallICFastApi( |
10364 Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { | 10362 Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { |
10365 ApiTestFuzzer::Fuzz(); | 10363 ApiTestFuzzer::Fuzz(); |
10366 CheckReturnValue(info, FUNCTION_ADDR(InterceptorCallICFastApi)); | 10364 CheckReturnValue(info, FUNCTION_ADDR(InterceptorCallICFastApi)); |
10367 int* call_count = | 10365 int* call_count = |
10368 reinterpret_cast<int*>(v8::External::Cast(*info.Data())->Value()); | 10366 reinterpret_cast<int*>(v8::External::Cast(*info.Data())->Value()); |
10369 ++(*call_count); | 10367 ++(*call_count); |
10370 if ((*call_count) % 20 == 0) { | 10368 if ((*call_count) % 20 == 0) { |
10371 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 10369 CcTest::heap()->CollectAllGarbage(); |
10372 } | 10370 } |
10373 } | 10371 } |
10374 | 10372 |
10375 static void FastApiCallback_TrivialSignature( | 10373 static void FastApiCallback_TrivialSignature( |
10376 const v8::FunctionCallbackInfo<v8::Value>& args) { | 10374 const v8::FunctionCallbackInfo<v8::Value>& args) { |
10377 ApiTestFuzzer::Fuzz(); | 10375 ApiTestFuzzer::Fuzz(); |
10378 CheckReturnValue(args, FUNCTION_ADDR(FastApiCallback_TrivialSignature)); | 10376 CheckReturnValue(args, FUNCTION_ADDR(FastApiCallback_TrivialSignature)); |
10379 v8::Isolate* isolate = CcTest::isolate(); | 10377 v8::Isolate* isolate = CcTest::isolate(); |
10380 CHECK_EQ(isolate, args.GetIsolate()); | 10378 CHECK_EQ(isolate, args.GetIsolate()); |
10381 CHECK(args.This()->Equals(args.Holder())); | 10379 CHECK(args.This()->Equals(args.Holder())); |
(...skipping 23 matching lines...) Expand all Loading... |
10405 "for (var i = 0; i < 1000; i++) {" | 10403 "for (var i = 0; i < 1000; i++) {" |
10406 " garbage = [1/i, \"garbage\" + i, garbage, {foo: garbage}];" | 10404 " garbage = [1/i, \"garbage\" + i, garbage, {foo: garbage}];" |
10407 "}" | 10405 "}" |
10408 "garbage = undefined;"); | 10406 "garbage = undefined;"); |
10409 } | 10407 } |
10410 | 10408 |
10411 | 10409 |
10412 void DirectApiCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { | 10410 void DirectApiCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { |
10413 static int count = 0; | 10411 static int count = 0; |
10414 if (count++ % 3 == 0) { | 10412 if (count++ % 3 == 0) { |
10415 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 10413 CcTest::heap()->CollectAllGarbage(); |
10416 // This should move the stub | 10414 // This should move the stub |
10417 GenerateSomeGarbage(); // This should ensure the old stub memory is flushed | 10415 GenerateSomeGarbage(); // This should ensure the old stub memory is flushed |
10418 } | 10416 } |
10419 } | 10417 } |
10420 | 10418 |
10421 | 10419 |
10422 THREADED_TEST(CallICFastApi_DirectCall_GCMoveStub) { | 10420 THREADED_TEST(CallICFastApi_DirectCall_GCMoveStub) { |
10423 LocalContext context; | 10421 LocalContext context; |
10424 v8::Isolate* isolate = context->GetIsolate(); | 10422 v8::Isolate* isolate = context->GetIsolate(); |
10425 v8::HandleScope scope(isolate); | 10423 v8::HandleScope scope(isolate); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10469 "f(); result;"); | 10467 "f(); result;"); |
10470 CHECK(v8_str("ggggg")->Equals(result)); | 10468 CHECK(v8_str("ggggg")->Equals(result)); |
10471 } | 10469 } |
10472 | 10470 |
10473 | 10471 |
10474 static int p_getter_count_3; | 10472 static int p_getter_count_3; |
10475 | 10473 |
10476 | 10474 |
10477 static Handle<Value> DoDirectGetter() { | 10475 static Handle<Value> DoDirectGetter() { |
10478 if (++p_getter_count_3 % 3 == 0) { | 10476 if (++p_getter_count_3 % 3 == 0) { |
10479 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 10477 CcTest::heap()->CollectAllGarbage(); |
10480 GenerateSomeGarbage(); | 10478 GenerateSomeGarbage(); |
10481 } | 10479 } |
10482 return v8_str("Direct Getter Result"); | 10480 return v8_str("Direct Getter Result"); |
10483 } | 10481 } |
10484 | 10482 |
10485 | 10483 |
10486 static void DirectGetterCallback( | 10484 static void DirectGetterCallback( |
10487 Local<String> name, | 10485 Local<String> name, |
10488 const v8::PropertyCallbackInfo<v8::Value>& info) { | 10486 const v8::PropertyCallbackInfo<v8::Value>& info) { |
10489 CheckReturnValue(info, FUNCTION_ADDR(DirectGetterCallback)); | 10487 CheckReturnValue(info, FUNCTION_ADDR(DirectGetterCallback)); |
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11702 return count; | 11700 return count; |
11703 } | 11701 } |
11704 | 11702 |
11705 | 11703 |
11706 static void CheckSurvivingGlobalObjectsCount(int expected) { | 11704 static void CheckSurvivingGlobalObjectsCount(int expected) { |
11707 // We need to collect all garbage twice to be sure that everything | 11705 // We need to collect all garbage twice to be sure that everything |
11708 // has been collected. This is because inline caches are cleared in | 11706 // has been collected. This is because inline caches are cleared in |
11709 // the first garbage collection but some of the maps have already | 11707 // the first garbage collection but some of the maps have already |
11710 // been marked at that point. Therefore some of the maps are not | 11708 // been marked at that point. Therefore some of the maps are not |
11711 // collected until the second garbage collection. | 11709 // collected until the second garbage collection. |
11712 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 11710 CcTest::heap()->CollectAllGarbage(); |
11713 CcTest::heap()->CollectAllGarbage(i::Heap::kMakeHeapIterableMask); | 11711 CcTest::heap()->CollectAllGarbage(i::Heap::kMakeHeapIterableMask); |
11714 int count = GetGlobalObjectsCount(); | 11712 int count = GetGlobalObjectsCount(); |
11715 #ifdef DEBUG | 11713 #ifdef DEBUG |
11716 if (count != expected) CcTest::heap()->TracePathToGlobal(); | 11714 if (count != expected) CcTest::heap()->TracePathToGlobal(); |
11717 #endif | 11715 #endif |
11718 CHECK_EQ(expected, count); | 11716 CHECK_EQ(expected, count); |
11719 } | 11717 } |
11720 | 11718 |
11721 | 11719 |
11722 TEST(DontLeakGlobalObjects) { | 11720 TEST(DontLeakGlobalObjects) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11803 int initial_handles = globals->global_handles_count(); | 11801 int initial_handles = globals->global_handles_count(); |
11804 { | 11802 { |
11805 v8::HandleScope scope(isolate); | 11803 v8::HandleScope scope(isolate); |
11806 v8::Local<v8::Object> obj = v8::Object::New(isolate); | 11804 v8::Local<v8::Object> obj = v8::Object::New(isolate); |
11807 obj->Set(v8_str("key"), v8::Integer::New(isolate, 231)); | 11805 obj->Set(v8_str("key"), v8::Integer::New(isolate, 231)); |
11808 v8::Persistent<v8::Object>* handle = | 11806 v8::Persistent<v8::Object>* handle = |
11809 new v8::Persistent<v8::Object>(isolate, obj); | 11807 new v8::Persistent<v8::Object>(isolate, obj); |
11810 handle->SetWeak<v8::Object, v8::Persistent<v8::Object> >(handle, | 11808 handle->SetWeak<v8::Object, v8::Persistent<v8::Object> >(handle, |
11811 WeakApiCallback); | 11809 WeakApiCallback); |
11812 } | 11810 } |
11813 reinterpret_cast<i::Isolate*>(isolate)->heap()-> | 11811 reinterpret_cast<i::Isolate*>(isolate)->heap()->CollectAllGarbage( |
11814 CollectAllGarbage(i::Heap::kNoGCFlags); | 11812 i::Heap::kAbortIncrementalMarkingMask); |
11815 // Verify disposed. | 11813 // Verify disposed. |
11816 CHECK_EQ(initial_handles, globals->global_handles_count()); | 11814 CHECK_EQ(initial_handles, globals->global_handles_count()); |
11817 } | 11815 } |
11818 | 11816 |
11819 | 11817 |
11820 v8::Persistent<v8::Object> some_object; | 11818 v8::Persistent<v8::Object> some_object; |
11821 v8::Persistent<v8::Object> bad_handle; | 11819 v8::Persistent<v8::Object> bad_handle; |
11822 | 11820 |
11823 void NewPersistentHandleCallback( | 11821 void NewPersistentHandleCallback( |
11824 const v8::WeakCallbackData<v8::Object, v8::Persistent<v8::Object> >& data) { | 11822 const v8::WeakCallbackData<v8::Object, v8::Persistent<v8::Object> >& data) { |
(...skipping 13 matching lines...) Expand all Loading... |
11838 some_object.Reset(isolate, v8::Object::New(isolate)); | 11836 some_object.Reset(isolate, v8::Object::New(isolate)); |
11839 handle1.Reset(isolate, v8::Object::New(isolate)); | 11837 handle1.Reset(isolate, v8::Object::New(isolate)); |
11840 handle2.Reset(isolate, v8::Object::New(isolate)); | 11838 handle2.Reset(isolate, v8::Object::New(isolate)); |
11841 } | 11839 } |
11842 // Note: order is implementation dependent alas: currently | 11840 // Note: order is implementation dependent alas: currently |
11843 // global handle nodes are processed by PostGarbageCollectionProcessing | 11841 // global handle nodes are processed by PostGarbageCollectionProcessing |
11844 // in reverse allocation order, so if second allocated handle is deleted, | 11842 // in reverse allocation order, so if second allocated handle is deleted, |
11845 // weak callback of the first handle would be able to 'reallocate' it. | 11843 // weak callback of the first handle would be able to 'reallocate' it. |
11846 handle1.SetWeak(&handle1, NewPersistentHandleCallback); | 11844 handle1.SetWeak(&handle1, NewPersistentHandleCallback); |
11847 handle2.Reset(); | 11845 handle2.Reset(); |
11848 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 11846 CcTest::heap()->CollectAllGarbage(); |
11849 } | 11847 } |
11850 | 11848 |
11851 | 11849 |
11852 v8::Persistent<v8::Object> to_be_disposed; | 11850 v8::Persistent<v8::Object> to_be_disposed; |
11853 | 11851 |
11854 void DisposeAndForceGcCallback( | 11852 void DisposeAndForceGcCallback( |
11855 const v8::WeakCallbackData<v8::Object, v8::Persistent<v8::Object> >& data) { | 11853 const v8::WeakCallbackData<v8::Object, v8::Persistent<v8::Object> >& data) { |
11856 to_be_disposed.Reset(); | 11854 to_be_disposed.Reset(); |
11857 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 11855 CcTest::heap()->CollectAllGarbage(); |
11858 data.GetParameter()->Reset(); | 11856 data.GetParameter()->Reset(); |
11859 } | 11857 } |
11860 | 11858 |
11861 | 11859 |
11862 THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc) { | 11860 THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc) { |
11863 LocalContext context; | 11861 LocalContext context; |
11864 v8::Isolate* isolate = context->GetIsolate(); | 11862 v8::Isolate* isolate = context->GetIsolate(); |
11865 | 11863 |
11866 v8::Persistent<v8::Object> handle1, handle2; | 11864 v8::Persistent<v8::Object> handle1, handle2; |
11867 { | 11865 { |
11868 v8::HandleScope scope(isolate); | 11866 v8::HandleScope scope(isolate); |
11869 handle1.Reset(isolate, v8::Object::New(isolate)); | 11867 handle1.Reset(isolate, v8::Object::New(isolate)); |
11870 handle2.Reset(isolate, v8::Object::New(isolate)); | 11868 handle2.Reset(isolate, v8::Object::New(isolate)); |
11871 } | 11869 } |
11872 handle1.SetWeak(&handle1, DisposeAndForceGcCallback); | 11870 handle1.SetWeak(&handle1, DisposeAndForceGcCallback); |
11873 to_be_disposed.Reset(isolate, handle2); | 11871 to_be_disposed.Reset(isolate, handle2); |
11874 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 11872 CcTest::heap()->CollectAllGarbage(); |
11875 } | 11873 } |
11876 | 11874 |
11877 void DisposingCallback( | 11875 void DisposingCallback( |
11878 const v8::WeakCallbackData<v8::Object, v8::Persistent<v8::Object> >& data) { | 11876 const v8::WeakCallbackData<v8::Object, v8::Persistent<v8::Object> >& data) { |
11879 data.GetParameter()->Reset(); | 11877 data.GetParameter()->Reset(); |
11880 } | 11878 } |
11881 | 11879 |
11882 void HandleCreatingCallback( | 11880 void HandleCreatingCallback( |
11883 const v8::WeakCallbackData<v8::Object, v8::Persistent<v8::Object> >& data) { | 11881 const v8::WeakCallbackData<v8::Object, v8::Persistent<v8::Object> >& data) { |
11884 v8::HandleScope scope(data.GetIsolate()); | 11882 v8::HandleScope scope(data.GetIsolate()); |
11885 v8::Persistent<v8::Object>(data.GetIsolate(), | 11883 v8::Persistent<v8::Object>(data.GetIsolate(), |
11886 v8::Object::New(data.GetIsolate())); | 11884 v8::Object::New(data.GetIsolate())); |
11887 data.GetParameter()->Reset(); | 11885 data.GetParameter()->Reset(); |
11888 } | 11886 } |
11889 | 11887 |
11890 | 11888 |
11891 THREADED_TEST(NoGlobalHandlesOrphaningDueToWeakCallback) { | 11889 THREADED_TEST(NoGlobalHandlesOrphaningDueToWeakCallback) { |
11892 LocalContext context; | 11890 LocalContext context; |
11893 v8::Isolate* isolate = context->GetIsolate(); | 11891 v8::Isolate* isolate = context->GetIsolate(); |
11894 | 11892 |
11895 v8::Persistent<v8::Object> handle1, handle2, handle3; | 11893 v8::Persistent<v8::Object> handle1, handle2, handle3; |
11896 { | 11894 { |
11897 v8::HandleScope scope(isolate); | 11895 v8::HandleScope scope(isolate); |
11898 handle3.Reset(isolate, v8::Object::New(isolate)); | 11896 handle3.Reset(isolate, v8::Object::New(isolate)); |
11899 handle2.Reset(isolate, v8::Object::New(isolate)); | 11897 handle2.Reset(isolate, v8::Object::New(isolate)); |
11900 handle1.Reset(isolate, v8::Object::New(isolate)); | 11898 handle1.Reset(isolate, v8::Object::New(isolate)); |
11901 } | 11899 } |
11902 handle2.SetWeak(&handle2, DisposingCallback); | 11900 handle2.SetWeak(&handle2, DisposingCallback); |
11903 handle3.SetWeak(&handle3, HandleCreatingCallback); | 11901 handle3.SetWeak(&handle3, HandleCreatingCallback); |
11904 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 11902 CcTest::heap()->CollectAllGarbage(); |
11905 } | 11903 } |
11906 | 11904 |
11907 | 11905 |
11908 THREADED_TEST(CheckForCrossContextObjectLiterals) { | 11906 THREADED_TEST(CheckForCrossContextObjectLiterals) { |
11909 v8::V8::Initialize(); | 11907 v8::V8::Initialize(); |
11910 | 11908 |
11911 const int nof = 2; | 11909 const int nof = 2; |
11912 const char* sources[nof] = { | 11910 const char* sources[nof] = { |
11913 "try { [ 2, 3, 4 ].forEach(5); } catch(e) { e.toString(); }", | 11911 "try { [ 2, 3, 4 ].forEach(5); } catch(e) { e.toString(); }", |
11914 "Object()" | 11912 "Object()" |
(...skipping 1700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13615 "var sum = 0;" | 13613 "var sum = 0;" |
13616 "for (var i = 0; i < 8; i++) {" | 13614 "for (var i = 0; i < 8; i++) {" |
13617 " tmp_array[i] = i;" | 13615 " tmp_array[i] = i;" |
13618 " sum += tmp_array[i];" | 13616 " sum += tmp_array[i];" |
13619 " if (i == 4) {" | 13617 " if (i == 4) {" |
13620 " tmp_array = {};" | 13618 " tmp_array = {};" |
13621 " }" | 13619 " }" |
13622 "}" | 13620 "}" |
13623 "sum;"); | 13621 "sum;"); |
13624 // Force GC to trigger verification. | 13622 // Force GC to trigger verification. |
13625 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 13623 CcTest::heap()->CollectAllGarbage(); |
13626 CHECK_EQ(28, result->Int32Value()); | 13624 CHECK_EQ(28, result->Int32Value()); |
13627 | 13625 |
13628 // Make sure out-of-range loads do not throw. | 13626 // Make sure out-of-range loads do not throw. |
13629 i::SNPrintF(test_buf, | 13627 i::SNPrintF(test_buf, |
13630 "var caught_exception = false;" | 13628 "var caught_exception = false;" |
13631 "try {" | 13629 "try {" |
13632 " ext_array[%d];" | 13630 " ext_array[%d];" |
13633 "} catch (e) {" | 13631 "} catch (e) {" |
13634 " caught_exception = true;" | 13632 " caught_exception = true;" |
13635 "}" | 13633 "}" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13818 i::Isolate* isolate = CcTest::i_isolate(); | 13816 i::Isolate* isolate = CcTest::i_isolate(); |
13819 i::Factory* factory = isolate->factory(); | 13817 i::Factory* factory = isolate->factory(); |
13820 v8::HandleScope scope(context->GetIsolate()); | 13818 v8::HandleScope scope(context->GetIsolate()); |
13821 const int kElementCount = 260; | 13819 const int kElementCount = 260; |
13822 i::Handle<FixedTypedArrayClass> fixed_array = | 13820 i::Handle<FixedTypedArrayClass> fixed_array = |
13823 i::Handle<FixedTypedArrayClass>::cast( | 13821 i::Handle<FixedTypedArrayClass>::cast( |
13824 factory->NewFixedTypedArray(kElementCount, array_type)); | 13822 factory->NewFixedTypedArray(kElementCount, array_type)); |
13825 CHECK_EQ(FixedTypedArrayClass::kInstanceType, | 13823 CHECK_EQ(FixedTypedArrayClass::kInstanceType, |
13826 fixed_array->map()->instance_type()); | 13824 fixed_array->map()->instance_type()); |
13827 CHECK_EQ(kElementCount, fixed_array->length()); | 13825 CHECK_EQ(kElementCount, fixed_array->length()); |
13828 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 13826 CcTest::heap()->CollectAllGarbage(); |
13829 for (int i = 0; i < kElementCount; i++) { | 13827 for (int i = 0; i < kElementCount; i++) { |
13830 fixed_array->set(i, static_cast<ElementType>(i)); | 13828 fixed_array->set(i, static_cast<ElementType>(i)); |
13831 } | 13829 } |
13832 // Force GC to trigger verification. | 13830 // Force GC to trigger verification. |
13833 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 13831 CcTest::heap()->CollectAllGarbage(); |
13834 for (int i = 0; i < kElementCount; i++) { | 13832 for (int i = 0; i < kElementCount; i++) { |
13835 CHECK_EQ(static_cast<int64_t>(static_cast<ElementType>(i)), | 13833 CHECK_EQ(static_cast<int64_t>(static_cast<ElementType>(i)), |
13836 static_cast<int64_t>(fixed_array->get_scalar(i))); | 13834 static_cast<int64_t>(fixed_array->get_scalar(i))); |
13837 } | 13835 } |
13838 v8::Handle<v8::Object> obj = v8::Object::New(CcTest::isolate()); | 13836 v8::Handle<v8::Object> obj = v8::Object::New(CcTest::isolate()); |
13839 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); | 13837 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); |
13840 i::Handle<i::Map> fixed_array_map = | 13838 i::Handle<i::Map> fixed_array_map = |
13841 i::JSObject::GetElementsTransitionMap(jsobj, elements_kind); | 13839 i::JSObject::GetElementsTransitionMap(jsobj, elements_kind); |
13842 jsobj->set_map(*fixed_array_map); | 13840 jsobj->set_map(*fixed_array_map); |
13843 jsobj->set_elements(*fixed_array); | 13841 jsobj->set_elements(*fixed_array); |
(...skipping 1756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15600 Local<v8::String> obj = v8::String::NewFromUtf8(isolate, ""); | 15598 Local<v8::String> obj = v8::String::NewFromUtf8(isolate, ""); |
15601 context->SetEmbedderData(0, obj); | 15599 context->SetEmbedderData(0, obj); |
15602 CompileRun(source_simple); | 15600 CompileRun(source_simple); |
15603 context->Exit(); | 15601 context->Exit(); |
15604 } | 15602 } |
15605 isolate->ContextDisposedNotification(); | 15603 isolate->ContextDisposedNotification(); |
15606 for (gc_count = 1; gc_count < 10; gc_count++) { | 15604 for (gc_count = 1; gc_count < 10; gc_count++) { |
15607 other_context->Enter(); | 15605 other_context->Enter(); |
15608 CompileRun(source_simple); | 15606 CompileRun(source_simple); |
15609 other_context->Exit(); | 15607 other_context->Exit(); |
15610 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 15608 CcTest::heap()->CollectAllGarbage(); |
15611 if (GetGlobalObjectsCount() == 1) break; | 15609 if (GetGlobalObjectsCount() == 1) break; |
15612 } | 15610 } |
15613 CHECK_GE(2, gc_count); | 15611 CHECK_GE(2, gc_count); |
15614 CHECK_EQ(1, GetGlobalObjectsCount()); | 15612 CHECK_EQ(1, GetGlobalObjectsCount()); |
15615 | 15613 |
15616 // Eval in a function creates reference from the compilation cache to the | 15614 // Eval in a function creates reference from the compilation cache to the |
15617 // global object. | 15615 // global object. |
15618 const char* source_eval = "function f(){eval('1')}; f()"; | 15616 const char* source_eval = "function f(){eval('1')}; f()"; |
15619 { | 15617 { |
15620 v8::HandleScope scope(isolate); | 15618 v8::HandleScope scope(isolate); |
15621 v8::Local<Context> context = Context::New(isolate); | 15619 v8::Local<Context> context = Context::New(isolate); |
15622 | 15620 |
15623 context->Enter(); | 15621 context->Enter(); |
15624 CompileRun(source_eval); | 15622 CompileRun(source_eval); |
15625 context->Exit(); | 15623 context->Exit(); |
15626 } | 15624 } |
15627 isolate->ContextDisposedNotification(); | 15625 isolate->ContextDisposedNotification(); |
15628 for (gc_count = 1; gc_count < 10; gc_count++) { | 15626 for (gc_count = 1; gc_count < 10; gc_count++) { |
15629 other_context->Enter(); | 15627 other_context->Enter(); |
15630 CompileRun(source_eval); | 15628 CompileRun(source_eval); |
15631 other_context->Exit(); | 15629 other_context->Exit(); |
15632 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 15630 CcTest::heap()->CollectAllGarbage(); |
15633 if (GetGlobalObjectsCount() == 1) break; | 15631 if (GetGlobalObjectsCount() == 1) break; |
15634 } | 15632 } |
15635 CHECK_GE(2, gc_count); | 15633 CHECK_GE(2, gc_count); |
15636 CHECK_EQ(1, GetGlobalObjectsCount()); | 15634 CHECK_EQ(1, GetGlobalObjectsCount()); |
15637 | 15635 |
15638 // Looking up the line number for an exception creates reference from the | 15636 // Looking up the line number for an exception creates reference from the |
15639 // compilation cache to the global object. | 15637 // compilation cache to the global object. |
15640 const char* source_exception = "function f(){throw 1;} f()"; | 15638 const char* source_exception = "function f(){throw 1;} f()"; |
15641 { | 15639 { |
15642 v8::HandleScope scope(isolate); | 15640 v8::HandleScope scope(isolate); |
15643 v8::Local<Context> context = Context::New(isolate); | 15641 v8::Local<Context> context = Context::New(isolate); |
15644 | 15642 |
15645 context->Enter(); | 15643 context->Enter(); |
15646 v8::TryCatch try_catch; | 15644 v8::TryCatch try_catch; |
15647 CompileRun(source_exception); | 15645 CompileRun(source_exception); |
15648 CHECK(try_catch.HasCaught()); | 15646 CHECK(try_catch.HasCaught()); |
15649 v8::Handle<v8::Message> message = try_catch.Message(); | 15647 v8::Handle<v8::Message> message = try_catch.Message(); |
15650 CHECK(!message.IsEmpty()); | 15648 CHECK(!message.IsEmpty()); |
15651 CHECK_EQ(1, message->GetLineNumber()); | 15649 CHECK_EQ(1, message->GetLineNumber()); |
15652 context->Exit(); | 15650 context->Exit(); |
15653 } | 15651 } |
15654 isolate->ContextDisposedNotification(); | 15652 isolate->ContextDisposedNotification(); |
15655 for (gc_count = 1; gc_count < 10; gc_count++) { | 15653 for (gc_count = 1; gc_count < 10; gc_count++) { |
15656 other_context->Enter(); | 15654 other_context->Enter(); |
15657 CompileRun(source_exception); | 15655 CompileRun(source_exception); |
15658 other_context->Exit(); | 15656 other_context->Exit(); |
15659 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 15657 CcTest::heap()->CollectAllGarbage(); |
15660 if (GetGlobalObjectsCount() == 1) break; | 15658 if (GetGlobalObjectsCount() == 1) break; |
15661 } | 15659 } |
15662 CHECK_GE(2, gc_count); | 15660 CHECK_GE(2, gc_count); |
15663 CHECK_EQ(1, GetGlobalObjectsCount()); | 15661 CHECK_EQ(1, GetGlobalObjectsCount()); |
15664 | 15662 |
15665 isolate->ContextDisposedNotification(); | 15663 isolate->ContextDisposedNotification(); |
15666 } | 15664 } |
15667 | 15665 |
15668 | 15666 |
15669 THREADED_TEST(ScriptOrigin) { | 15667 THREADED_TEST(ScriptOrigin) { |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16169 } | 16167 } |
16170 | 16168 |
16171 | 16169 |
16172 TEST(GCCallbacksOld) { | 16170 TEST(GCCallbacksOld) { |
16173 LocalContext context; | 16171 LocalContext context; |
16174 | 16172 |
16175 v8::V8::AddGCPrologueCallback(PrologueCallback); | 16173 v8::V8::AddGCPrologueCallback(PrologueCallback); |
16176 v8::V8::AddGCEpilogueCallback(EpilogueCallback); | 16174 v8::V8::AddGCEpilogueCallback(EpilogueCallback); |
16177 CHECK_EQ(0, prologue_call_count); | 16175 CHECK_EQ(0, prologue_call_count); |
16178 CHECK_EQ(0, epilogue_call_count); | 16176 CHECK_EQ(0, epilogue_call_count); |
16179 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 16177 CcTest::heap()->CollectAllGarbage(); |
16180 CHECK_EQ(1, prologue_call_count); | 16178 CHECK_EQ(1, prologue_call_count); |
16181 CHECK_EQ(1, epilogue_call_count); | 16179 CHECK_EQ(1, epilogue_call_count); |
16182 v8::V8::AddGCPrologueCallback(PrologueCallbackSecond); | 16180 v8::V8::AddGCPrologueCallback(PrologueCallbackSecond); |
16183 v8::V8::AddGCEpilogueCallback(EpilogueCallbackSecond); | 16181 v8::V8::AddGCEpilogueCallback(EpilogueCallbackSecond); |
16184 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 16182 CcTest::heap()->CollectAllGarbage(); |
16185 CHECK_EQ(2, prologue_call_count); | 16183 CHECK_EQ(2, prologue_call_count); |
16186 CHECK_EQ(2, epilogue_call_count); | 16184 CHECK_EQ(2, epilogue_call_count); |
16187 CHECK_EQ(1, prologue_call_count_second); | 16185 CHECK_EQ(1, prologue_call_count_second); |
16188 CHECK_EQ(1, epilogue_call_count_second); | 16186 CHECK_EQ(1, epilogue_call_count_second); |
16189 v8::V8::RemoveGCPrologueCallback(PrologueCallback); | 16187 v8::V8::RemoveGCPrologueCallback(PrologueCallback); |
16190 v8::V8::RemoveGCEpilogueCallback(EpilogueCallback); | 16188 v8::V8::RemoveGCEpilogueCallback(EpilogueCallback); |
16191 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 16189 CcTest::heap()->CollectAllGarbage(); |
16192 CHECK_EQ(2, prologue_call_count); | 16190 CHECK_EQ(2, prologue_call_count); |
16193 CHECK_EQ(2, epilogue_call_count); | 16191 CHECK_EQ(2, epilogue_call_count); |
16194 CHECK_EQ(2, prologue_call_count_second); | 16192 CHECK_EQ(2, prologue_call_count_second); |
16195 CHECK_EQ(2, epilogue_call_count_second); | 16193 CHECK_EQ(2, epilogue_call_count_second); |
16196 v8::V8::RemoveGCPrologueCallback(PrologueCallbackSecond); | 16194 v8::V8::RemoveGCPrologueCallback(PrologueCallbackSecond); |
16197 v8::V8::RemoveGCEpilogueCallback(EpilogueCallbackSecond); | 16195 v8::V8::RemoveGCEpilogueCallback(EpilogueCallbackSecond); |
16198 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 16196 CcTest::heap()->CollectAllGarbage(); |
16199 CHECK_EQ(2, prologue_call_count); | 16197 CHECK_EQ(2, prologue_call_count); |
16200 CHECK_EQ(2, epilogue_call_count); | 16198 CHECK_EQ(2, epilogue_call_count); |
16201 CHECK_EQ(2, prologue_call_count_second); | 16199 CHECK_EQ(2, prologue_call_count_second); |
16202 CHECK_EQ(2, epilogue_call_count_second); | 16200 CHECK_EQ(2, epilogue_call_count_second); |
16203 } | 16201 } |
16204 | 16202 |
16205 | 16203 |
16206 TEST(GCCallbacks) { | 16204 TEST(GCCallbacks) { |
16207 LocalContext context; | 16205 LocalContext context; |
16208 v8::Isolate* isolate = context->GetIsolate(); | 16206 v8::Isolate* isolate = context->GetIsolate(); |
16209 gc_callbacks_isolate = isolate; | 16207 gc_callbacks_isolate = isolate; |
16210 isolate->AddGCPrologueCallback(PrologueCallback); | 16208 isolate->AddGCPrologueCallback(PrologueCallback); |
16211 isolate->AddGCEpilogueCallback(EpilogueCallback); | 16209 isolate->AddGCEpilogueCallback(EpilogueCallback); |
16212 CHECK_EQ(0, prologue_call_count); | 16210 CHECK_EQ(0, prologue_call_count); |
16213 CHECK_EQ(0, epilogue_call_count); | 16211 CHECK_EQ(0, epilogue_call_count); |
16214 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 16212 CcTest::heap()->CollectAllGarbage(); |
16215 CHECK_EQ(1, prologue_call_count); | 16213 CHECK_EQ(1, prologue_call_count); |
16216 CHECK_EQ(1, epilogue_call_count); | 16214 CHECK_EQ(1, epilogue_call_count); |
16217 isolate->AddGCPrologueCallback(PrologueCallbackSecond); | 16215 isolate->AddGCPrologueCallback(PrologueCallbackSecond); |
16218 isolate->AddGCEpilogueCallback(EpilogueCallbackSecond); | 16216 isolate->AddGCEpilogueCallback(EpilogueCallbackSecond); |
16219 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 16217 CcTest::heap()->CollectAllGarbage(); |
16220 CHECK_EQ(2, prologue_call_count); | 16218 CHECK_EQ(2, prologue_call_count); |
16221 CHECK_EQ(2, epilogue_call_count); | 16219 CHECK_EQ(2, epilogue_call_count); |
16222 CHECK_EQ(1, prologue_call_count_second); | 16220 CHECK_EQ(1, prologue_call_count_second); |
16223 CHECK_EQ(1, epilogue_call_count_second); | 16221 CHECK_EQ(1, epilogue_call_count_second); |
16224 isolate->RemoveGCPrologueCallback(PrologueCallback); | 16222 isolate->RemoveGCPrologueCallback(PrologueCallback); |
16225 isolate->RemoveGCEpilogueCallback(EpilogueCallback); | 16223 isolate->RemoveGCEpilogueCallback(EpilogueCallback); |
16226 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 16224 CcTest::heap()->CollectAllGarbage(); |
16227 CHECK_EQ(2, prologue_call_count); | 16225 CHECK_EQ(2, prologue_call_count); |
16228 CHECK_EQ(2, epilogue_call_count); | 16226 CHECK_EQ(2, epilogue_call_count); |
16229 CHECK_EQ(2, prologue_call_count_second); | 16227 CHECK_EQ(2, prologue_call_count_second); |
16230 CHECK_EQ(2, epilogue_call_count_second); | 16228 CHECK_EQ(2, epilogue_call_count_second); |
16231 isolate->RemoveGCPrologueCallback(PrologueCallbackSecond); | 16229 isolate->RemoveGCPrologueCallback(PrologueCallbackSecond); |
16232 isolate->RemoveGCEpilogueCallback(EpilogueCallbackSecond); | 16230 isolate->RemoveGCEpilogueCallback(EpilogueCallbackSecond); |
16233 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 16231 CcTest::heap()->CollectAllGarbage(); |
16234 CHECK_EQ(2, prologue_call_count); | 16232 CHECK_EQ(2, prologue_call_count); |
16235 CHECK_EQ(2, epilogue_call_count); | 16233 CHECK_EQ(2, epilogue_call_count); |
16236 CHECK_EQ(2, prologue_call_count_second); | 16234 CHECK_EQ(2, prologue_call_count_second); |
16237 CHECK_EQ(2, epilogue_call_count_second); | 16235 CHECK_EQ(2, epilogue_call_count_second); |
16238 | 16236 |
16239 CHECK_EQ(0, prologue_call_count_alloc); | 16237 CHECK_EQ(0, prologue_call_count_alloc); |
16240 CHECK_EQ(0, epilogue_call_count_alloc); | 16238 CHECK_EQ(0, epilogue_call_count_alloc); |
16241 isolate->AddGCPrologueCallback(PrologueCallbackAlloc); | 16239 isolate->AddGCPrologueCallback(PrologueCallbackAlloc); |
16242 isolate->AddGCEpilogueCallback(EpilogueCallbackAlloc); | 16240 isolate->AddGCEpilogueCallback(EpilogueCallbackAlloc); |
16243 CcTest::heap()->CollectAllGarbage( | 16241 CcTest::heap()->CollectAllGarbage( |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16519 string_contents[zero_offset] = 0x41; | 16517 string_contents[zero_offset] = 0x41; |
16520 } | 16518 } |
16521 } | 16519 } |
16522 } | 16520 } |
16523 | 16521 |
16524 | 16522 |
16525 // Failed access check callback that performs a GC on each invocation. | 16523 // Failed access check callback that performs a GC on each invocation. |
16526 void FailedAccessCheckCallbackGC(Local<v8::Object> target, | 16524 void FailedAccessCheckCallbackGC(Local<v8::Object> target, |
16527 v8::AccessType type, | 16525 v8::AccessType type, |
16528 Local<v8::Value> data) { | 16526 Local<v8::Value> data) { |
16529 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 16527 CcTest::heap()->CollectAllGarbage(); |
16530 } | 16528 } |
16531 | 16529 |
16532 | 16530 |
16533 TEST(GCInFailedAccessCheckCallback) { | 16531 TEST(GCInFailedAccessCheckCallback) { |
16534 // Install a failed access check callback that performs a GC on each | 16532 // Install a failed access check callback that performs a GC on each |
16535 // invocation. Then force the callback to be called from va | 16533 // invocation. Then force the callback to be called from va |
16536 | 16534 |
16537 v8::V8::Initialize(); | 16535 v8::V8::Initialize(); |
16538 v8::V8::SetFailedAccessCheckCallbackFunction(&FailedAccessCheckCallbackGC); | 16536 v8::V8::SetFailedAccessCheckCallbackFunction(&FailedAccessCheckCallbackGC); |
16539 | 16537 |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17038 ExpectBoolean("delete cell", true); | 17036 ExpectBoolean("delete cell", true); |
17039 ExpectString("(function() {" | 17037 ExpectString("(function() {" |
17040 " try {" | 17038 " try {" |
17041 " return readCell();" | 17039 " return readCell();" |
17042 " } catch(e) {" | 17040 " } catch(e) {" |
17043 " return e.toString();" | 17041 " return e.toString();" |
17044 " }" | 17042 " }" |
17045 "})()", | 17043 "})()", |
17046 "ReferenceError: cell is not defined"); | 17044 "ReferenceError: cell is not defined"); |
17047 CompileRun("cell = \"new_second\";"); | 17045 CompileRun("cell = \"new_second\";"); |
17048 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 17046 CcTest::heap()->CollectAllGarbage(); |
17049 ExpectString("readCell()", "new_second"); | 17047 ExpectString("readCell()", "new_second"); |
17050 ExpectString("readCell()", "new_second"); | 17048 ExpectString("readCell()", "new_second"); |
17051 } | 17049 } |
17052 } | 17050 } |
17053 | 17051 |
17054 | 17052 |
17055 class Visitor42 : public v8::PersistentHandleVisitor { | 17053 class Visitor42 : public v8::PersistentHandleVisitor { |
17056 public: | 17054 public: |
17057 explicit Visitor42(v8::Persistent<v8::Object>* object) | 17055 explicit Visitor42(v8::Persistent<v8::Object>* object) |
17058 : counter_(0), object_(object) { } | 17056 : counter_(0), object_(object) { } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17107 | 17105 |
17108 TEST(PersistentHandleInNewSpaceVisitor) { | 17106 TEST(PersistentHandleInNewSpaceVisitor) { |
17109 LocalContext context; | 17107 LocalContext context; |
17110 v8::Isolate* isolate = context->GetIsolate(); | 17108 v8::Isolate* isolate = context->GetIsolate(); |
17111 v8::HandleScope scope(isolate); | 17109 v8::HandleScope scope(isolate); |
17112 v8::Persistent<v8::Object> object1(isolate, v8::Object::New(isolate)); | 17110 v8::Persistent<v8::Object> object1(isolate, v8::Object::New(isolate)); |
17113 CHECK_EQ(0, object1.WrapperClassId()); | 17111 CHECK_EQ(0, object1.WrapperClassId()); |
17114 object1.SetWrapperClassId(42); | 17112 object1.SetWrapperClassId(42); |
17115 CHECK_EQ(42, object1.WrapperClassId()); | 17113 CHECK_EQ(42, object1.WrapperClassId()); |
17116 | 17114 |
17117 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 17115 CcTest::heap()->CollectAllGarbage(); |
17118 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 17116 CcTest::heap()->CollectAllGarbage(); |
17119 | 17117 |
17120 v8::Persistent<v8::Object> object2(isolate, v8::Object::New(isolate)); | 17118 v8::Persistent<v8::Object> object2(isolate, v8::Object::New(isolate)); |
17121 CHECK_EQ(0, object2.WrapperClassId()); | 17119 CHECK_EQ(0, object2.WrapperClassId()); |
17122 object2.SetWrapperClassId(42); | 17120 object2.SetWrapperClassId(42); |
17123 CHECK_EQ(42, object2.WrapperClassId()); | 17121 CHECK_EQ(42, object2.WrapperClassId()); |
17124 | 17122 |
17125 Visitor42 visitor(&object2); | 17123 Visitor42 visitor(&object2); |
17126 v8::V8::VisitHandlesForPartialDependence(isolate, &visitor); | 17124 v8::V8::VisitHandlesForPartialDependence(isolate, &visitor); |
17127 CHECK_EQ(1, visitor.counter_); | 17125 CHECK_EQ(1, visitor.counter_); |
17128 | 17126 |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17674 "'a00': 0, 'a01': 0, 'a02': 0, 'a03': 0, 'a04': 0, " | 17672 "'a00': 0, 'a01': 0, 'a02': 0, 'a03': 0, 'a04': 0, " |
17675 "'a05': 0, 'a06': 0, 'a07': 0, 'a08': 0, 'a09': 0, " | 17673 "'a05': 0, 'a06': 0, 'a07': 0, 'a08': 0, 'a09': 0, " |
17676 "'a10': 0, 'a11': 0, 'a12': 0, 'a13': 0, 'a14': 0, " | 17674 "'a10': 0, 'a11': 0, 'a12': 0, 'a13': 0, 'a14': 0, " |
17677 "'a15': 0, 'a16': 0, 'a17': 0, 'a18': 0, 'a19': 0, " | 17675 "'a15': 0, 'a16': 0, 'a17': 0, 'a18': 0, 'a19': 0, " |
17678 "})"); | 17676 "})"); |
17679 } | 17677 } |
17680 | 17678 |
17681 int elements = CountLiveMapsInMapCache(CcTest::i_isolate()->context()); | 17679 int elements = CountLiveMapsInMapCache(CcTest::i_isolate()->context()); |
17682 CHECK_LE(1, elements); | 17680 CHECK_LE(1, elements); |
17683 | 17681 |
17684 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 17682 CcTest::heap()->CollectAllGarbage(); |
17685 | 17683 |
17686 CHECK_GT(elements, CountLiveMapsInMapCache(CcTest::i_isolate()->context())); | 17684 CHECK_GT(elements, CountLiveMapsInMapCache(CcTest::i_isolate()->context())); |
17687 } | 17685 } |
17688 | 17686 |
17689 | 17687 |
17690 THREADED_TEST(Regress93759) { | 17688 THREADED_TEST(Regress93759) { |
17691 v8::Isolate* isolate = CcTest::isolate(); | 17689 v8::Isolate* isolate = CcTest::isolate(); |
17692 HandleScope scope(isolate); | 17690 HandleScope scope(isolate); |
17693 | 17691 |
17694 // Template for object with security check. | 17692 // Template for object with security check. |
(...skipping 3324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21019 | 21017 |
21020 { | 21018 { |
21021 v8::HandleScope handle_scope(isolate); | 21019 v8::HandleScope handle_scope(isolate); |
21022 | 21020 |
21023 // Should work | 21021 // Should work |
21024 v8::Local<v8::Object> obj = v8::Object::New(isolate); | 21022 v8::Local<v8::Object> obj = v8::Object::New(isolate); |
21025 | 21023 |
21026 USE(obj); | 21024 USE(obj); |
21027 } | 21025 } |
21028 } | 21026 } |
OLD | NEW |