| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 static void Test##Name(); \ | 81 static void Test##Name(); \ |
| 82 TEST(Name##WithProfiler) { \ | 82 TEST(Name##WithProfiler) { \ |
| 83 RunWithProfiler(&Test##Name); \ | 83 RunWithProfiler(&Test##Name); \ |
| 84 } \ | 84 } \ |
| 85 THREADED_TEST(Name) | 85 THREADED_TEST(Name) |
| 86 | 86 |
| 87 | 87 |
| 88 void RunWithProfiler(void (*test)()) { | 88 void RunWithProfiler(void (*test)()) { |
| 89 LocalContext env; | 89 LocalContext env; |
| 90 v8::HandleScope scope(env->GetIsolate()); | 90 v8::HandleScope scope(env->GetIsolate()); |
| 91 v8::Local<v8::String> profile_name = v8::String::New("my_profile1"); | 91 v8::Local<v8::String> profile_name = |
| 92 v8::String::NewFromUtf8(env->GetIsolate(), "my_profile1"); |
| 92 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); | 93 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); |
| 93 | 94 |
| 94 cpu_profiler->StartCpuProfiling(profile_name); | 95 cpu_profiler->StartCpuProfiling(profile_name); |
| 95 (*test)(); | 96 (*test)(); |
| 96 cpu_profiler->DeleteAllCpuProfiles(); | 97 cpu_profiler->DeleteAllCpuProfiles(); |
| 97 } | 98 } |
| 98 | 99 |
| 99 | 100 |
| 100 static void ExpectString(const char* code, const char* expected) { | 101 static void ExpectString(const char* code, const char* expected) { |
| 101 Local<Value> result = CompileRun(code); | 102 Local<Value> result = CompileRun(code); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 | 196 |
| 196 // Local context should still be live. | 197 // Local context should still be live. |
| 197 CHECK(!local_env.IsEmpty()); | 198 CHECK(!local_env.IsEmpty()); |
| 198 local_env->Enter(); | 199 local_env->Enter(); |
| 199 | 200 |
| 200 v8::Handle<v8::Primitive> undef = v8::Undefined(CcTest::isolate()); | 201 v8::Handle<v8::Primitive> undef = v8::Undefined(CcTest::isolate()); |
| 201 CHECK(!undef.IsEmpty()); | 202 CHECK(!undef.IsEmpty()); |
| 202 CHECK(undef->IsUndefined()); | 203 CHECK(undef->IsUndefined()); |
| 203 | 204 |
| 204 const char* c_source = "1 + 2 + 3"; | 205 const char* c_source = "1 + 2 + 3"; |
| 205 Local<String> source = String::New(c_source); | 206 Local<String> source = String::NewFromUtf8(CcTest::isolate(), c_source); |
| 206 Local<Script> script = Script::Compile(source); | 207 Local<Script> script = Script::Compile(source); |
| 207 CHECK_EQ(6, script->Run()->Int32Value()); | 208 CHECK_EQ(6, script->Run()->Int32Value()); |
| 208 | 209 |
| 209 local_env->Exit(); | 210 local_env->Exit(); |
| 210 } | 211 } |
| 211 | 212 |
| 212 | 213 |
| 213 THREADED_TEST(IsolateOfContext) { | 214 THREADED_TEST(IsolateOfContext) { |
| 214 v8::HandleScope scope(CcTest::isolate()); | 215 v8::HandleScope scope(CcTest::isolate()); |
| 215 v8::Handle<Context> env = Context::New(CcTest::isolate()); | 216 v8::Handle<Context> env = Context::New(CcTest::isolate()); |
| 216 | 217 |
| 217 CHECK(!env->InContext()); | 218 CHECK(!env->GetIsolate()->InContext()); |
| 218 CHECK(env->GetIsolate() == CcTest::isolate()); | 219 CHECK(env->GetIsolate() == CcTest::isolate()); |
| 219 env->Enter(); | 220 env->Enter(); |
| 220 CHECK(env->InContext()); | 221 CHECK(env->GetIsolate()->InContext()); |
| 221 CHECK(env->GetIsolate() == CcTest::isolate()); | 222 CHECK(env->GetIsolate() == CcTest::isolate()); |
| 222 env->Exit(); | 223 env->Exit(); |
| 223 CHECK(!env->InContext()); | 224 CHECK(!env->GetIsolate()->InContext()); |
| 224 CHECK(env->GetIsolate() == CcTest::isolate()); | 225 CHECK(env->GetIsolate() == CcTest::isolate()); |
| 225 } | 226 } |
| 226 | 227 |
| 227 | 228 |
| 228 static void TestSignature(const char* loop_js, Local<Value> receiver) { | 229 static void TestSignature(const char* loop_js, Local<Value> receiver) { |
| 229 i::ScopedVector<char> source(200); | 230 i::ScopedVector<char> source(200); |
| 230 i::OS::SNPrintF(source, | 231 i::OS::SNPrintF(source, |
| 231 "for (var i = 0; i < 10; i++) {" | 232 "for (var i = 0; i < 10; i++) {" |
| 232 " %s" | 233 " %s" |
| 233 "}", | 234 "}", |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 Local<v8::Array> value = CompileRun("[\"a\", \"b\"]").As<v8::Array>(); | 428 Local<v8::Array> value = CompileRun("[\"a\", \"b\"]").As<v8::Array>(); |
| 428 CHECK_EQ(v8_str("a"), value->Get(0)); | 429 CHECK_EQ(v8_str("a"), value->Get(0)); |
| 429 CHECK_EQ(v8_str("b"), value->Get(1)); | 430 CHECK_EQ(v8_str("b"), value->Get(1)); |
| 430 } | 431 } |
| 431 | 432 |
| 432 | 433 |
| 433 THREADED_TEST(Script) { | 434 THREADED_TEST(Script) { |
| 434 LocalContext env; | 435 LocalContext env; |
| 435 v8::HandleScope scope(env->GetIsolate()); | 436 v8::HandleScope scope(env->GetIsolate()); |
| 436 const char* c_source = "1 + 2 + 3"; | 437 const char* c_source = "1 + 2 + 3"; |
| 437 Local<String> source = String::New(c_source); | 438 Local<String> source = String::NewFromUtf8(env->GetIsolate(), c_source); |
| 438 Local<Script> script = Script::Compile(source); | 439 Local<Script> script = Script::Compile(source); |
| 439 CHECK_EQ(6, script->Run()->Int32Value()); | 440 CHECK_EQ(6, script->Run()->Int32Value()); |
| 440 } | 441 } |
| 441 | 442 |
| 442 | 443 |
| 443 static uint16_t* AsciiToTwoByteString(const char* source) { | 444 static uint16_t* AsciiToTwoByteString(const char* source) { |
| 444 int array_length = i::StrLength(source) + 1; | 445 int array_length = i::StrLength(source) + 1; |
| 445 uint16_t* converted = i::NewArray<uint16_t>(array_length); | 446 uint16_t* converted = i::NewArray<uint16_t>(array_length); |
| 446 for (int i = 0; i < array_length; i++) converted[i] = source[i]; | 447 for (int i = 0; i < array_length; i++) converted[i] = source[i]; |
| 447 return converted; | 448 return converted; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 CHECK_EQ(1, dispose_count); | 556 CHECK_EQ(1, dispose_count); |
| 556 } | 557 } |
| 557 | 558 |
| 558 | 559 |
| 559 THREADED_TEST(ScriptMakingExternalString) { | 560 THREADED_TEST(ScriptMakingExternalString) { |
| 560 int dispose_count = 0; | 561 int dispose_count = 0; |
| 561 uint16_t* two_byte_source = AsciiToTwoByteString("1 + 2 * 3"); | 562 uint16_t* two_byte_source = AsciiToTwoByteString("1 + 2 * 3"); |
| 562 { | 563 { |
| 563 LocalContext env; | 564 LocalContext env; |
| 564 v8::HandleScope scope(env->GetIsolate()); | 565 v8::HandleScope scope(env->GetIsolate()); |
| 565 Local<String> source = String::New(two_byte_source); | 566 Local<String> source = |
| 567 String::NewFromTwoByte(env->GetIsolate(), two_byte_source); |
| 566 // Trigger GCs so that the newly allocated string moves to old gen. | 568 // Trigger GCs so that the newly allocated string moves to old gen. |
| 567 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now | 569 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now |
| 568 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now | 570 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now |
| 569 CHECK_EQ(source->IsExternal(), false); | 571 CHECK_EQ(source->IsExternal(), false); |
| 570 CHECK_EQ(source->IsExternalAscii(), false); | 572 CHECK_EQ(source->IsExternalAscii(), false); |
| 571 String::Encoding encoding = String::UNKNOWN_ENCODING; | 573 String::Encoding encoding = String::UNKNOWN_ENCODING; |
| 572 CHECK_EQ(NULL, source->GetExternalStringResourceBase(&encoding)); | 574 CHECK_EQ(NULL, source->GetExternalStringResourceBase(&encoding)); |
| 573 CHECK_EQ(String::ASCII_ENCODING, encoding); | 575 CHECK_EQ(String::ASCII_ENCODING, encoding); |
| 574 bool success = source->MakeExternal(new TestResource(two_byte_source, | 576 bool success = source->MakeExternal(new TestResource(two_byte_source, |
| 575 &dispose_count)); | 577 &dispose_count)); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 | 617 |
| 616 TEST(MakingExternalStringConditions) { | 618 TEST(MakingExternalStringConditions) { |
| 617 LocalContext env; | 619 LocalContext env; |
| 618 v8::HandleScope scope(env->GetIsolate()); | 620 v8::HandleScope scope(env->GetIsolate()); |
| 619 | 621 |
| 620 // Free some space in the new space so that we can check freshness. | 622 // Free some space in the new space so that we can check freshness. |
| 621 CcTest::heap()->CollectGarbage(i::NEW_SPACE); | 623 CcTest::heap()->CollectGarbage(i::NEW_SPACE); |
| 622 CcTest::heap()->CollectGarbage(i::NEW_SPACE); | 624 CcTest::heap()->CollectGarbage(i::NEW_SPACE); |
| 623 | 625 |
| 624 uint16_t* two_byte_string = AsciiToTwoByteString("s1"); | 626 uint16_t* two_byte_string = AsciiToTwoByteString("s1"); |
| 625 Local<String> small_string = String::New(two_byte_string); | 627 Local<String> small_string = |
| 628 String::NewFromTwoByte(env->GetIsolate(), two_byte_string); |
| 626 i::DeleteArray(two_byte_string); | 629 i::DeleteArray(two_byte_string); |
| 627 | 630 |
| 628 // We should refuse to externalize newly created small string. | 631 // We should refuse to externalize newly created small string. |
| 629 CHECK(!small_string->CanMakeExternal()); | 632 CHECK(!small_string->CanMakeExternal()); |
| 630 // Trigger GCs so that the newly allocated string moves to old gen. | 633 // Trigger GCs so that the newly allocated string moves to old gen. |
| 631 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now | 634 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now |
| 632 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now | 635 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now |
| 633 // Old space strings should be accepted. | 636 // Old space strings should be accepted. |
| 634 CHECK(small_string->CanMakeExternal()); | 637 CHECK(small_string->CanMakeExternal()); |
| 635 | 638 |
| 636 two_byte_string = AsciiToTwoByteString("small string 2"); | 639 two_byte_string = AsciiToTwoByteString("small string 2"); |
| 637 small_string = String::New(two_byte_string); | 640 small_string = String::NewFromTwoByte(env->GetIsolate(), two_byte_string); |
| 638 i::DeleteArray(two_byte_string); | 641 i::DeleteArray(two_byte_string); |
| 639 | 642 |
| 640 // We should refuse externalizing newly created small string. | 643 // We should refuse externalizing newly created small string. |
| 641 CHECK(!small_string->CanMakeExternal()); | 644 CHECK(!small_string->CanMakeExternal()); |
| 642 for (int i = 0; i < 100; i++) { | 645 for (int i = 0; i < 100; i++) { |
| 643 String::Value value(small_string); | 646 String::Value value(small_string); |
| 644 } | 647 } |
| 645 // Frequently used strings should be accepted. | 648 // Frequently used strings should be accepted. |
| 646 CHECK(small_string->CanMakeExternal()); | 649 CHECK(small_string->CanMakeExternal()); |
| 647 | 650 |
| 648 const int buf_size = 10 * 1024; | 651 const int buf_size = 10 * 1024; |
| 649 char* buf = i::NewArray<char>(buf_size); | 652 char* buf = i::NewArray<char>(buf_size); |
| 650 memset(buf, 'a', buf_size); | 653 memset(buf, 'a', buf_size); |
| 651 buf[buf_size - 1] = '\0'; | 654 buf[buf_size - 1] = '\0'; |
| 652 | 655 |
| 653 two_byte_string = AsciiToTwoByteString(buf); | 656 two_byte_string = AsciiToTwoByteString(buf); |
| 654 Local<String> large_string = String::New(two_byte_string); | 657 Local<String> large_string = |
| 658 String::NewFromTwoByte(env->GetIsolate(), two_byte_string); |
| 655 i::DeleteArray(buf); | 659 i::DeleteArray(buf); |
| 656 i::DeleteArray(two_byte_string); | 660 i::DeleteArray(two_byte_string); |
| 657 // Large strings should be immediately accepted. | 661 // Large strings should be immediately accepted. |
| 658 CHECK(large_string->CanMakeExternal()); | 662 CHECK(large_string->CanMakeExternal()); |
| 659 } | 663 } |
| 660 | 664 |
| 661 | 665 |
| 662 TEST(MakingExternalAsciiStringConditions) { | 666 TEST(MakingExternalAsciiStringConditions) { |
| 663 LocalContext env; | 667 LocalContext env; |
| 664 v8::HandleScope scope(env->GetIsolate()); | 668 v8::HandleScope scope(env->GetIsolate()); |
| 665 | 669 |
| 666 // Free some space in the new space so that we can check freshness. | 670 // Free some space in the new space so that we can check freshness. |
| 667 CcTest::heap()->CollectGarbage(i::NEW_SPACE); | 671 CcTest::heap()->CollectGarbage(i::NEW_SPACE); |
| 668 CcTest::heap()->CollectGarbage(i::NEW_SPACE); | 672 CcTest::heap()->CollectGarbage(i::NEW_SPACE); |
| 669 | 673 |
| 670 Local<String> small_string = String::New("s1"); | 674 Local<String> small_string = String::NewFromUtf8(env->GetIsolate(), "s1"); |
| 671 // We should refuse to externalize newly created small string. | 675 // We should refuse to externalize newly created small string. |
| 672 CHECK(!small_string->CanMakeExternal()); | 676 CHECK(!small_string->CanMakeExternal()); |
| 673 // Trigger GCs so that the newly allocated string moves to old gen. | 677 // Trigger GCs so that the newly allocated string moves to old gen. |
| 674 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now | 678 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now |
| 675 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now | 679 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now |
| 676 // Old space strings should be accepted. | 680 // Old space strings should be accepted. |
| 677 CHECK(small_string->CanMakeExternal()); | 681 CHECK(small_string->CanMakeExternal()); |
| 678 | 682 |
| 679 small_string = String::New("small string 2"); | 683 small_string = String::NewFromUtf8(env->GetIsolate(), "small string 2"); |
| 680 // We should refuse externalizing newly created small string. | 684 // We should refuse externalizing newly created small string. |
| 681 CHECK(!small_string->CanMakeExternal()); | 685 CHECK(!small_string->CanMakeExternal()); |
| 682 for (int i = 0; i < 100; i++) { | 686 for (int i = 0; i < 100; i++) { |
| 683 String::Value value(small_string); | 687 String::Value value(small_string); |
| 684 } | 688 } |
| 685 // Frequently used strings should be accepted. | 689 // Frequently used strings should be accepted. |
| 686 CHECK(small_string->CanMakeExternal()); | 690 CHECK(small_string->CanMakeExternal()); |
| 687 | 691 |
| 688 const int buf_size = 10 * 1024; | 692 const int buf_size = 10 * 1024; |
| 689 char* buf = i::NewArray<char>(buf_size); | 693 char* buf = i::NewArray<char>(buf_size); |
| 690 memset(buf, 'a', buf_size); | 694 memset(buf, 'a', buf_size); |
| 691 buf[buf_size - 1] = '\0'; | 695 buf[buf_size - 1] = '\0'; |
| 692 Local<String> large_string = String::New(buf); | 696 Local<String> large_string = String::NewFromUtf8(env->GetIsolate(), buf); |
| 693 i::DeleteArray(buf); | 697 i::DeleteArray(buf); |
| 694 // Large strings should be immediately accepted. | 698 // Large strings should be immediately accepted. |
| 695 CHECK(large_string->CanMakeExternal()); | 699 CHECK(large_string->CanMakeExternal()); |
| 696 } | 700 } |
| 697 | 701 |
| 698 | 702 |
| 699 TEST(MakingExternalUnalignedAsciiString) { | 703 TEST(MakingExternalUnalignedAsciiString) { |
| 700 LocalContext env; | 704 LocalContext env; |
| 701 v8::HandleScope scope(env->GetIsolate()); | 705 v8::HandleScope scope(env->GetIsolate()); |
| 702 | 706 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 const char* one_byte_string_1 = "function a_times_t"; | 896 const char* one_byte_string_1 = "function a_times_t"; |
| 893 const char* two_byte_string_1 = "wo_plus_b(a, b) {return "; | 897 const char* two_byte_string_1 = "wo_plus_b(a, b) {return "; |
| 894 const char* one_byte_extern_1 = "a * 2 + b;} a_times_two_plus_b(4, 8) + "; | 898 const char* one_byte_extern_1 = "a * 2 + b;} a_times_two_plus_b(4, 8) + "; |
| 895 const char* two_byte_extern_1 = "a_times_two_plus_b(4, 8) + "; | 899 const char* two_byte_extern_1 = "a_times_two_plus_b(4, 8) + "; |
| 896 const char* one_byte_string_2 = "a_times_two_plus_b(4, 8) + "; | 900 const char* one_byte_string_2 = "a_times_two_plus_b(4, 8) + "; |
| 897 const char* two_byte_string_2 = "a_times_two_plus_b(4, 8) + "; | 901 const char* two_byte_string_2 = "a_times_two_plus_b(4, 8) + "; |
| 898 const char* two_byte_extern_2 = "a_times_two_plus_b(1, 2);"; | 902 const char* two_byte_extern_2 = "a_times_two_plus_b(1, 2);"; |
| 899 Local<String> left = v8_str(one_byte_string_1); | 903 Local<String> left = v8_str(one_byte_string_1); |
| 900 | 904 |
| 901 uint16_t* two_byte_source = AsciiToTwoByteString(two_byte_string_1); | 905 uint16_t* two_byte_source = AsciiToTwoByteString(two_byte_string_1); |
| 902 Local<String> right = String::New(two_byte_source); | 906 Local<String> right = |
| 907 String::NewFromTwoByte(env->GetIsolate(), two_byte_source); |
| 903 i::DeleteArray(two_byte_source); | 908 i::DeleteArray(two_byte_source); |
| 904 | 909 |
| 905 Local<String> source = String::Concat(left, right); | 910 Local<String> source = String::Concat(left, right); |
| 906 right = String::NewExternal( | 911 right = String::NewExternal( |
| 907 new TestAsciiResource(i::StrDup(one_byte_extern_1))); | 912 new TestAsciiResource(i::StrDup(one_byte_extern_1))); |
| 908 source = String::Concat(source, right); | 913 source = String::Concat(source, right); |
| 909 right = String::NewExternal( | 914 right = String::NewExternal( |
| 910 new TestResource(AsciiToTwoByteString(two_byte_extern_1))); | 915 new TestResource(AsciiToTwoByteString(two_byte_extern_1))); |
| 911 source = String::Concat(source, right); | 916 source = String::Concat(source, right); |
| 912 right = v8_str(one_byte_string_2); | 917 right = v8_str(one_byte_string_2); |
| 913 source = String::Concat(source, right); | 918 source = String::Concat(source, right); |
| 914 | 919 |
| 915 two_byte_source = AsciiToTwoByteString(two_byte_string_2); | 920 two_byte_source = AsciiToTwoByteString(two_byte_string_2); |
| 916 right = String::New(two_byte_source); | 921 right = String::NewFromTwoByte(env->GetIsolate(), two_byte_source); |
| 917 i::DeleteArray(two_byte_source); | 922 i::DeleteArray(two_byte_source); |
| 918 | 923 |
| 919 source = String::Concat(source, right); | 924 source = String::Concat(source, right); |
| 920 right = String::NewExternal( | 925 right = String::NewExternal( |
| 921 new TestResource(AsciiToTwoByteString(two_byte_extern_2))); | 926 new TestResource(AsciiToTwoByteString(two_byte_extern_2))); |
| 922 source = String::Concat(source, right); | 927 source = String::Concat(source, right); |
| 923 Local<Script> script = Script::Compile(source); | 928 Local<Script> script = Script::Compile(source); |
| 924 Local<Value> value = script->Run(); | 929 Local<Value> value = script->Run(); |
| 925 CHECK(value->IsNumber()); | 930 CHECK(value->IsNumber()); |
| 926 CHECK_EQ(68, value->Int32Value()); | 931 CHECK_EQ(68, value->Int32Value()); |
| (...skipping 1588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2515 global->SetInternalField(0, v8_num(17)); | 2520 global->SetInternalField(0, v8_num(17)); |
| 2516 CHECK_EQ(17, global->GetInternalField(0)->Int32Value()); | 2521 CHECK_EQ(17, global->GetInternalField(0)->Int32Value()); |
| 2517 } | 2522 } |
| 2518 | 2523 |
| 2519 | 2524 |
| 2520 THREADED_TEST(GlobalObjectHasRealIndexedProperty) { | 2525 THREADED_TEST(GlobalObjectHasRealIndexedProperty) { |
| 2521 LocalContext env; | 2526 LocalContext env; |
| 2522 v8::HandleScope scope(CcTest::isolate()); | 2527 v8::HandleScope scope(CcTest::isolate()); |
| 2523 | 2528 |
| 2524 v8::Local<v8::Object> global = env->Global(); | 2529 v8::Local<v8::Object> global = env->Global(); |
| 2525 global->Set(0, v8::String::New("value")); | 2530 global->Set(0, v8::String::NewFromUtf8(CcTest::isolate(), "value")); |
| 2526 CHECK(global->HasRealIndexedProperty(0)); | 2531 CHECK(global->HasRealIndexedProperty(0)); |
| 2527 } | 2532 } |
| 2528 | 2533 |
| 2529 | 2534 |
| 2530 static void CheckAlignedPointerInInternalField(Handle<v8::Object> obj, | 2535 static void CheckAlignedPointerInInternalField(Handle<v8::Object> obj, |
| 2531 void* value) { | 2536 void* value) { |
| 2532 CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(value) & 0x1)); | 2537 CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(value) & 0x1)); |
| 2533 obj->SetAlignedPointerInInternalField(0, value); | 2538 obj->SetAlignedPointerInInternalField(0, value); |
| 2534 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2539 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 2535 CHECK_EQ(value, obj->GetAlignedPointerFromInternalField(0)); | 2540 CHECK_EQ(value, obj->GetAlignedPointerFromInternalField(0)); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2607 v8::Handle<Value> data) { | 2612 v8::Handle<Value> data) { |
| 2608 (*env)->SetEmbedderData(index, data); | 2613 (*env)->SetEmbedderData(index, data); |
| 2609 CHECK((*env)->GetEmbedderData(index)->StrictEquals(data)); | 2614 CHECK((*env)->GetEmbedderData(index)->StrictEquals(data)); |
| 2610 } | 2615 } |
| 2611 | 2616 |
| 2612 | 2617 |
| 2613 THREADED_TEST(EmbedderData) { | 2618 THREADED_TEST(EmbedderData) { |
| 2614 LocalContext env; | 2619 LocalContext env; |
| 2615 v8::HandleScope scope(env->GetIsolate()); | 2620 v8::HandleScope scope(env->GetIsolate()); |
| 2616 | 2621 |
| 2617 CheckEmbedderData(&env, 3, v8::String::New("The quick brown fox jumps")); | 2622 CheckEmbedderData( |
| 2618 CheckEmbedderData(&env, 2, v8::String::New("over the lazy dog.")); | 2623 &env, 3, |
| 2624 v8::String::NewFromUtf8(env->GetIsolate(), "The quick brown fox jumps")); |
| 2625 CheckEmbedderData(&env, 2, v8::String::NewFromUtf8(env->GetIsolate(), |
| 2626 "over the lazy dog.")); |
| 2619 CheckEmbedderData(&env, 1, v8::Number::New(1.2345)); | 2627 CheckEmbedderData(&env, 1, v8::Number::New(1.2345)); |
| 2620 CheckEmbedderData(&env, 0, v8::Boolean::New(true)); | 2628 CheckEmbedderData(&env, 0, v8::Boolean::New(true)); |
| 2621 } | 2629 } |
| 2622 | 2630 |
| 2623 | 2631 |
| 2624 THREADED_TEST(IdentityHash) { | 2632 THREADED_TEST(IdentityHash) { |
| 2625 LocalContext env; | 2633 LocalContext env; |
| 2626 v8::HandleScope scope(env->GetIsolate()); | 2634 v8::HandleScope scope(env->GetIsolate()); |
| 2627 | 2635 |
| 2628 // Ensure that the test starts with an fresh heap to test whether the hash | 2636 // Ensure that the test starts with an fresh heap to test whether the hash |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2685 | 2693 |
| 2686 CHECK(sym1->Equals(sym1)); | 2694 CHECK(sym1->Equals(sym1)); |
| 2687 CHECK(sym2->Equals(sym2)); | 2695 CHECK(sym2->Equals(sym2)); |
| 2688 CHECK(!sym1->Equals(sym2)); | 2696 CHECK(!sym1->Equals(sym2)); |
| 2689 CHECK(!sym2->Equals(sym1)); | 2697 CHECK(!sym2->Equals(sym1)); |
| 2690 CHECK(sym1->StrictEquals(sym1)); | 2698 CHECK(sym1->StrictEquals(sym1)); |
| 2691 CHECK(sym2->StrictEquals(sym2)); | 2699 CHECK(sym2->StrictEquals(sym2)); |
| 2692 CHECK(!sym1->StrictEquals(sym2)); | 2700 CHECK(!sym1->StrictEquals(sym2)); |
| 2693 CHECK(!sym2->StrictEquals(sym1)); | 2701 CHECK(!sym2->StrictEquals(sym1)); |
| 2694 | 2702 |
| 2695 CHECK(sym2->Name()->Equals(v8::String::New("my-symbol"))); | 2703 CHECK(sym2->Name()->Equals(v8::String::NewFromUtf8(isolate, "my-symbol"))); |
| 2696 | 2704 |
| 2697 v8::Local<v8::Value> sym_val = sym2; | 2705 v8::Local<v8::Value> sym_val = sym2; |
| 2698 CHECK(sym_val->IsSymbol()); | 2706 CHECK(sym_val->IsSymbol()); |
| 2699 CHECK(sym_val->Equals(sym2)); | 2707 CHECK(sym_val->Equals(sym2)); |
| 2700 CHECK(sym_val->StrictEquals(sym2)); | 2708 CHECK(sym_val->StrictEquals(sym2)); |
| 2701 CHECK(v8::Symbol::Cast(*sym_val)->Equals(sym2)); | 2709 CHECK(v8::Symbol::Cast(*sym_val)->Equals(sym2)); |
| 2702 | 2710 |
| 2703 v8::Local<v8::Value> sym_obj = v8::SymbolObject::New(isolate, sym2); | 2711 v8::Local<v8::Value> sym_obj = v8::SymbolObject::New(isolate, sym2); |
| 2704 CHECK(sym_obj->IsSymbolObject()); | 2712 CHECK(sym_obj->IsSymbolObject()); |
| 2705 CHECK(!sym2->IsSymbolObject()); | 2713 CHECK(!sym2->IsSymbolObject()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2716 CHECK(obj->Set(sym1, v8::Integer::New(1503))); | 2724 CHECK(obj->Set(sym1, v8::Integer::New(1503))); |
| 2717 CHECK(obj->Has(sym1)); | 2725 CHECK(obj->Has(sym1)); |
| 2718 CHECK_EQ(1503, obj->Get(sym1)->Int32Value()); | 2726 CHECK_EQ(1503, obj->Get(sym1)->Int32Value()); |
| 2719 CHECK(obj->Set(sym1, v8::Integer::New(2002))); | 2727 CHECK(obj->Set(sym1, v8::Integer::New(2002))); |
| 2720 CHECK(obj->Has(sym1)); | 2728 CHECK(obj->Has(sym1)); |
| 2721 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); | 2729 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); |
| 2722 CHECK_EQ(v8::None, obj->GetPropertyAttributes(sym1)); | 2730 CHECK_EQ(v8::None, obj->GetPropertyAttributes(sym1)); |
| 2723 | 2731 |
| 2724 CHECK_EQ(0, obj->GetOwnPropertyNames()->Length()); | 2732 CHECK_EQ(0, obj->GetOwnPropertyNames()->Length()); |
| 2725 int num_props = obj->GetPropertyNames()->Length(); | 2733 int num_props = obj->GetPropertyNames()->Length(); |
| 2726 CHECK(obj->Set(v8::String::New("bla"), v8::Integer::New(20))); | 2734 CHECK( |
| 2735 obj->Set(v8::String::NewFromUtf8(isolate, "bla"), v8::Integer::New(20))); |
| 2727 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); | 2736 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); |
| 2728 CHECK_EQ(num_props + 1, obj->GetPropertyNames()->Length()); | 2737 CHECK_EQ(num_props + 1, obj->GetPropertyNames()->Length()); |
| 2729 | 2738 |
| 2730 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2739 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 2731 | 2740 |
| 2732 // Add another property and delete it afterwards to force the object in | 2741 // Add another property and delete it afterwards to force the object in |
| 2733 // slow case. | 2742 // slow case. |
| 2734 CHECK(obj->Set(sym2, v8::Integer::New(2008))); | 2743 CHECK(obj->Set(sym2, v8::Integer::New(2008))); |
| 2735 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); | 2744 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); |
| 2736 CHECK_EQ(2008, obj->Get(sym2)->Int32Value()); | 2745 CHECK_EQ(2008, obj->Get(sym2)->Int32Value()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2758 LocalContext env; | 2767 LocalContext env; |
| 2759 v8::Isolate* isolate = env->GetIsolate(); | 2768 v8::Isolate* isolate = env->GetIsolate(); |
| 2760 v8::HandleScope scope(isolate); | 2769 v8::HandleScope scope(isolate); |
| 2761 | 2770 |
| 2762 v8::Local<v8::Object> obj = v8::Object::New(); | 2771 v8::Local<v8::Object> obj = v8::Object::New(); |
| 2763 v8::Local<v8::Private> priv1 = v8::Private::New(isolate); | 2772 v8::Local<v8::Private> priv1 = v8::Private::New(isolate); |
| 2764 v8::Local<v8::Private> priv2 = v8::Private::New(isolate, "my-private"); | 2773 v8::Local<v8::Private> priv2 = v8::Private::New(isolate, "my-private"); |
| 2765 | 2774 |
| 2766 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2775 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 2767 | 2776 |
| 2768 CHECK(priv2->Name()->Equals(v8::String::New("my-private"))); | 2777 CHECK(priv2->Name()->Equals(v8::String::NewFromUtf8(isolate, "my-private"))); |
| 2769 | 2778 |
| 2770 // Make sure delete of a non-existent private symbol property works. | 2779 // Make sure delete of a non-existent private symbol property works. |
| 2771 CHECK(obj->DeletePrivate(priv1)); | 2780 CHECK(obj->DeletePrivate(priv1)); |
| 2772 CHECK(!obj->HasPrivate(priv1)); | 2781 CHECK(!obj->HasPrivate(priv1)); |
| 2773 | 2782 |
| 2774 CHECK(obj->SetPrivate(priv1, v8::Integer::New(1503))); | 2783 CHECK(obj->SetPrivate(priv1, v8::Integer::New(1503))); |
| 2775 CHECK(obj->HasPrivate(priv1)); | 2784 CHECK(obj->HasPrivate(priv1)); |
| 2776 CHECK_EQ(1503, obj->GetPrivate(priv1)->Int32Value()); | 2785 CHECK_EQ(1503, obj->GetPrivate(priv1)->Int32Value()); |
| 2777 CHECK(obj->SetPrivate(priv1, v8::Integer::New(2002))); | 2786 CHECK(obj->SetPrivate(priv1, v8::Integer::New(2002))); |
| 2778 CHECK(obj->HasPrivate(priv1)); | 2787 CHECK(obj->HasPrivate(priv1)); |
| 2779 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); | 2788 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); |
| 2780 | 2789 |
| 2781 CHECK_EQ(0, obj->GetOwnPropertyNames()->Length()); | 2790 CHECK_EQ(0, obj->GetOwnPropertyNames()->Length()); |
| 2782 int num_props = obj->GetPropertyNames()->Length(); | 2791 int num_props = obj->GetPropertyNames()->Length(); |
| 2783 CHECK(obj->Set(v8::String::New("bla"), v8::Integer::New(20))); | 2792 CHECK( |
| 2793 obj->Set(v8::String::NewFromUtf8(isolate, "bla"), v8::Integer::New(20))); |
| 2784 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); | 2794 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); |
| 2785 CHECK_EQ(num_props + 1, obj->GetPropertyNames()->Length()); | 2795 CHECK_EQ(num_props + 1, obj->GetPropertyNames()->Length()); |
| 2786 | 2796 |
| 2787 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2797 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 2788 | 2798 |
| 2789 // Add another property and delete it afterwards to force the object in | 2799 // Add another property and delete it afterwards to force the object in |
| 2790 // slow case. | 2800 // slow case. |
| 2791 CHECK(obj->SetPrivate(priv2, v8::Integer::New(2008))); | 2801 CHECK(obj->SetPrivate(priv2, v8::Integer::New(2008))); |
| 2792 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); | 2802 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); |
| 2793 CHECK_EQ(2008, obj->GetPrivate(priv2)->Int32Value()); | 2803 CHECK_EQ(2008, obj->GetPrivate(priv2)->Int32Value()); |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3217 v8::Isolate* isolate = CcTest::isolate(); | 3227 v8::Isolate* isolate = CcTest::isolate(); |
| 3218 v8::Persistent<String> global; | 3228 v8::Persistent<String> global; |
| 3219 { | 3229 { |
| 3220 v8::HandleScope scope(isolate); | 3230 v8::HandleScope scope(isolate); |
| 3221 global.Reset(isolate, v8_str("str")); | 3231 global.Reset(isolate, v8_str("str")); |
| 3222 } | 3232 } |
| 3223 { | 3233 { |
| 3224 v8::HandleScope scope(isolate); | 3234 v8::HandleScope scope(isolate); |
| 3225 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 3); | 3235 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 3); |
| 3226 } | 3236 } |
| 3227 global.Dispose(); | 3237 global.Reset(); |
| 3228 global.Clear(); | |
| 3229 { | 3238 { |
| 3230 v8::HandleScope scope(isolate); | 3239 v8::HandleScope scope(isolate); |
| 3231 global.Reset(isolate, v8_str("str")); | 3240 global.Reset(isolate, v8_str("str")); |
| 3232 } | 3241 } |
| 3233 { | 3242 { |
| 3234 v8::HandleScope scope(isolate); | 3243 v8::HandleScope scope(isolate); |
| 3235 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 3); | 3244 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 3); |
| 3236 } | 3245 } |
| 3237 global.Dispose(); | 3246 global.Reset(); |
| 3238 } | 3247 } |
| 3239 | 3248 |
| 3240 | 3249 |
| 3241 THREADED_TEST(ResettingGlobalHandle) { | 3250 THREADED_TEST(ResettingGlobalHandle) { |
| 3242 v8::Isolate* isolate = CcTest::isolate(); | 3251 v8::Isolate* isolate = CcTest::isolate(); |
| 3243 v8::Persistent<String> global; | 3252 v8::Persistent<String> global; |
| 3244 { | 3253 { |
| 3245 v8::HandleScope scope(isolate); | 3254 v8::HandleScope scope(isolate); |
| 3246 global.Reset(isolate, v8_str("str")); | 3255 global.Reset(isolate, v8_str("str")); |
| 3247 } | 3256 } |
| 3248 v8::internal::GlobalHandles* global_handles = | 3257 v8::internal::GlobalHandles* global_handles = |
| 3249 reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles(); | 3258 reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles(); |
| 3250 int initial_handle_count = global_handles->global_handles_count(); | 3259 int initial_handle_count = global_handles->global_handles_count(); |
| 3251 { | 3260 { |
| 3252 v8::HandleScope scope(isolate); | 3261 v8::HandleScope scope(isolate); |
| 3253 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 3); | 3262 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 3); |
| 3254 } | 3263 } |
| 3255 { | 3264 { |
| 3256 v8::HandleScope scope(isolate); | 3265 v8::HandleScope scope(isolate); |
| 3257 global.Reset(isolate, v8_str("longer")); | 3266 global.Reset(isolate, v8_str("longer")); |
| 3258 } | 3267 } |
| 3259 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count); | 3268 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count); |
| 3260 { | 3269 { |
| 3261 v8::HandleScope scope(isolate); | 3270 v8::HandleScope scope(isolate); |
| 3262 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 6); | 3271 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 6); |
| 3263 } | 3272 } |
| 3264 global.Dispose(); | 3273 global.Reset(); |
| 3265 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count - 1); | 3274 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count - 1); |
| 3266 } | 3275 } |
| 3267 | 3276 |
| 3268 | 3277 |
| 3269 THREADED_TEST(ResettingGlobalHandleToEmpty) { | 3278 THREADED_TEST(ResettingGlobalHandleToEmpty) { |
| 3270 v8::Isolate* isolate = CcTest::isolate(); | 3279 v8::Isolate* isolate = CcTest::isolate(); |
| 3271 v8::Persistent<String> global; | 3280 v8::Persistent<String> global; |
| 3272 { | 3281 { |
| 3273 v8::HandleScope scope(isolate); | 3282 v8::HandleScope scope(isolate); |
| 3274 global.Reset(isolate, v8_str("str")); | 3283 global.Reset(isolate, v8_str("str")); |
| 3275 } | 3284 } |
| 3276 v8::internal::GlobalHandles* global_handles = | 3285 v8::internal::GlobalHandles* global_handles = |
| 3277 reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles(); | 3286 reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles(); |
| 3278 int initial_handle_count = global_handles->global_handles_count(); | 3287 int initial_handle_count = global_handles->global_handles_count(); |
| 3279 { | 3288 { |
| 3280 v8::HandleScope scope(isolate); | 3289 v8::HandleScope scope(isolate); |
| 3281 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 3); | 3290 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 3); |
| 3282 } | 3291 } |
| 3283 { | 3292 { |
| 3284 v8::HandleScope scope(isolate); | 3293 v8::HandleScope scope(isolate); |
| 3285 Local<String> empty; | 3294 Local<String> empty; |
| 3286 global.Reset(isolate, empty); | 3295 global.Reset(isolate, empty); |
| 3287 } | 3296 } |
| 3288 CHECK(global.IsEmpty()); | 3297 CHECK(global.IsEmpty()); |
| 3289 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count - 1); | 3298 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count - 1); |
| 3290 } | 3299 } |
| 3291 | 3300 |
| 3292 | 3301 |
| 3293 THREADED_TEST(ClearAndLeakGlobal) { | |
| 3294 v8::Isolate* isolate = CcTest::isolate(); | |
| 3295 v8::internal::GlobalHandles* global_handles = NULL; | |
| 3296 int initial_handle_count = 0; | |
| 3297 v8::Persistent<String> global; | |
| 3298 { | |
| 3299 v8::HandleScope scope(isolate); | |
| 3300 Local<String> str = v8_str("str"); | |
| 3301 global_handles = | |
| 3302 reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles(); | |
| 3303 initial_handle_count = global_handles->global_handles_count(); | |
| 3304 global.Reset(isolate, str); | |
| 3305 } | |
| 3306 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count + 1); | |
| 3307 String* str = global.ClearAndLeak(); | |
| 3308 CHECK(global.IsEmpty()); | |
| 3309 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count + 1); | |
| 3310 global_handles->Destroy(reinterpret_cast<i::Object**>(str)); | |
| 3311 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count); | |
| 3312 } | |
| 3313 | |
| 3314 | |
| 3315 THREADED_TEST(GlobalHandleUpcast) { | 3302 THREADED_TEST(GlobalHandleUpcast) { |
| 3316 v8::Isolate* isolate = CcTest::isolate(); | 3303 v8::Isolate* isolate = CcTest::isolate(); |
| 3317 v8::HandleScope scope(isolate); | 3304 v8::HandleScope scope(isolate); |
| 3318 v8::Local<String> local = v8::Local<String>::New(isolate, v8_str("str")); | 3305 v8::Local<String> local = v8::Local<String>::New(isolate, v8_str("str")); |
| 3319 v8::Persistent<String> global_string(isolate, local); | 3306 v8::Persistent<String> global_string(isolate, local); |
| 3320 v8::Persistent<Value>& global_value = | 3307 v8::Persistent<Value>& global_value = |
| 3321 v8::Persistent<Value>::Cast(global_string); | 3308 v8::Persistent<Value>::Cast(global_string); |
| 3322 CHECK(v8::Local<v8::Value>::New(isolate, global_value)->IsString()); | 3309 CHECK(v8::Local<v8::Value>::New(isolate, global_value)->IsString()); |
| 3323 CHECK(global_string == v8::Persistent<String>::Cast(global_value)); | 3310 CHECK(global_string == v8::Persistent<String>::Cast(global_value)); |
| 3324 global_string.Dispose(); | 3311 global_string.Reset(); |
| 3325 } | 3312 } |
| 3326 | 3313 |
| 3327 | 3314 |
| 3328 THREADED_TEST(HandleEquality) { | 3315 THREADED_TEST(HandleEquality) { |
| 3329 v8::Isolate* isolate = CcTest::isolate(); | 3316 v8::Isolate* isolate = CcTest::isolate(); |
| 3330 v8::Persistent<String> global1; | 3317 v8::Persistent<String> global1; |
| 3331 v8::Persistent<String> global2; | 3318 v8::Persistent<String> global2; |
| 3332 { | 3319 { |
| 3333 v8::HandleScope scope(isolate); | 3320 v8::HandleScope scope(isolate); |
| 3334 global1.Reset(isolate, v8_str("str")); | 3321 global1.Reset(isolate, v8_str("str")); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 3351 CHECK_EQ(local2 == global1, false); | 3338 CHECK_EQ(local2 == global1, false); |
| 3352 CHECK_EQ(local2 != global1, true); | 3339 CHECK_EQ(local2 != global1, true); |
| 3353 | 3340 |
| 3354 CHECK_EQ(local1 == local2, false); | 3341 CHECK_EQ(local1 == local2, false); |
| 3355 CHECK_EQ(local1 != local2, true); | 3342 CHECK_EQ(local1 != local2, true); |
| 3356 | 3343 |
| 3357 Local<String> anotherLocal1 = Local<String>::New(isolate, global1); | 3344 Local<String> anotherLocal1 = Local<String>::New(isolate, global1); |
| 3358 CHECK_EQ(local1 == anotherLocal1, true); | 3345 CHECK_EQ(local1 == anotherLocal1, true); |
| 3359 CHECK_EQ(local1 != anotherLocal1, false); | 3346 CHECK_EQ(local1 != anotherLocal1, false); |
| 3360 } | 3347 } |
| 3361 global1.Dispose(); | 3348 global1.Reset(); |
| 3362 global2.Dispose(); | 3349 global2.Reset(); |
| 3363 } | 3350 } |
| 3364 | 3351 |
| 3365 | 3352 |
| 3366 THREADED_TEST(LocalHandle) { | 3353 THREADED_TEST(LocalHandle) { |
| 3367 v8::HandleScope scope(CcTest::isolate()); | 3354 v8::HandleScope scope(CcTest::isolate()); |
| 3368 v8::Local<String> local = | 3355 v8::Local<String> local = |
| 3369 v8::Local<String>::New(CcTest::isolate(), v8_str("str")); | 3356 v8::Local<String>::New(CcTest::isolate(), v8_str("str")); |
| 3370 CHECK_EQ(local->Length(), 3); | 3357 CHECK_EQ(local->Length(), 3); |
| 3371 } | 3358 } |
| 3372 | 3359 |
| 3373 | 3360 |
| 3374 class WeakCallCounter { | 3361 class WeakCallCounter { |
| 3375 public: | 3362 public: |
| 3376 explicit WeakCallCounter(int id) : id_(id), number_of_weak_calls_(0) { } | 3363 explicit WeakCallCounter(int id) : id_(id), number_of_weak_calls_(0) { } |
| 3377 int id() { return id_; } | 3364 int id() { return id_; } |
| 3378 void increment() { number_of_weak_calls_++; } | 3365 void increment() { number_of_weak_calls_++; } |
| 3379 int NumberOfWeakCalls() { return number_of_weak_calls_; } | 3366 int NumberOfWeakCalls() { return number_of_weak_calls_; } |
| 3380 private: | 3367 private: |
| 3381 int id_; | 3368 int id_; |
| 3382 int number_of_weak_calls_; | 3369 int number_of_weak_calls_; |
| 3383 }; | 3370 }; |
| 3384 | 3371 |
| 3385 | 3372 |
| 3386 template<typename T> | 3373 template<typename T> |
| 3387 static void WeakPointerCallback(v8::Isolate* isolate, | 3374 static void WeakPointerCallback(v8::Isolate* isolate, |
| 3388 Persistent<T>* handle, | 3375 Persistent<T>* handle, |
| 3389 WeakCallCounter* counter) { | 3376 WeakCallCounter* counter) { |
| 3390 CHECK_EQ(1234, counter->id()); | 3377 CHECK_EQ(1234, counter->id()); |
| 3391 counter->increment(); | 3378 counter->increment(); |
| 3392 handle->Dispose(); | 3379 handle->Reset(); |
| 3393 } | 3380 } |
| 3394 | 3381 |
| 3395 | 3382 |
| 3396 template<typename T> | 3383 template<typename T> |
| 3397 static UniqueId MakeUniqueId(const Persistent<T>& p) { | 3384 static UniqueId MakeUniqueId(const Persistent<T>& p) { |
| 3398 return UniqueId(reinterpret_cast<uintptr_t>(*v8::Utils::OpenPersistent(p))); | 3385 return UniqueId(reinterpret_cast<uintptr_t>(*v8::Utils::OpenPersistent(p))); |
| 3399 } | 3386 } |
| 3400 | 3387 |
| 3401 | 3388 |
| 3402 THREADED_TEST(ApiObjectGroups) { | 3389 THREADED_TEST(ApiObjectGroups) { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3502 Persistent<String> g1c1; | 3489 Persistent<String> g1c1; |
| 3503 Persistent<Object> g2s1; | 3490 Persistent<Object> g2s1; |
| 3504 Persistent<String> g2s2; | 3491 Persistent<String> g2s2; |
| 3505 Persistent<String> g2c1; | 3492 Persistent<String> g2c1; |
| 3506 | 3493 |
| 3507 WeakCallCounter counter(1234); | 3494 WeakCallCounter counter(1234); |
| 3508 | 3495 |
| 3509 { | 3496 { |
| 3510 HandleScope scope(iso); | 3497 HandleScope scope(iso); |
| 3511 g1s1.Reset(iso, Object::New()); | 3498 g1s1.Reset(iso, Object::New()); |
| 3512 g1s2.Reset(iso, String::New("foo1")); | 3499 g1s2.Reset(iso, String::NewFromUtf8(iso, "foo1")); |
| 3513 g1c1.Reset(iso, String::New("foo2")); | 3500 g1c1.Reset(iso, String::NewFromUtf8(iso, "foo2")); |
| 3514 g1s1.MakeWeak(&counter, &WeakPointerCallback); | 3501 g1s1.MakeWeak(&counter, &WeakPointerCallback); |
| 3515 g1s2.MakeWeak(&counter, &WeakPointerCallback); | 3502 g1s2.MakeWeak(&counter, &WeakPointerCallback); |
| 3516 g1c1.MakeWeak(&counter, &WeakPointerCallback); | 3503 g1c1.MakeWeak(&counter, &WeakPointerCallback); |
| 3517 | 3504 |
| 3518 g2s1.Reset(iso, Object::New()); | 3505 g2s1.Reset(iso, Object::New()); |
| 3519 g2s2.Reset(iso, String::New("foo3")); | 3506 g2s2.Reset(iso, String::NewFromUtf8(iso, "foo3")); |
| 3520 g2c1.Reset(iso, String::New("foo4")); | 3507 g2c1.Reset(iso, String::NewFromUtf8(iso, "foo4")); |
| 3521 g2s1.MakeWeak(&counter, &WeakPointerCallback); | 3508 g2s1.MakeWeak(&counter, &WeakPointerCallback); |
| 3522 g2s2.MakeWeak(&counter, &WeakPointerCallback); | 3509 g2s2.MakeWeak(&counter, &WeakPointerCallback); |
| 3523 g2c1.MakeWeak(&counter, &WeakPointerCallback); | 3510 g2c1.MakeWeak(&counter, &WeakPointerCallback); |
| 3524 } | 3511 } |
| 3525 | 3512 |
| 3526 Persistent<Value> root(iso, g1s1); // make a root. | 3513 Persistent<Value> root(iso, g1s1); // make a root. |
| 3527 | 3514 |
| 3528 // Connect group 1 and 2, make a cycle. | 3515 // Connect group 1 and 2, make a cycle. |
| 3529 { | 3516 { |
| 3530 HandleScope scope(iso); | 3517 HandleScope scope(iso); |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4262 static const int K = 1024; | 4249 static const int K = 1024; |
| 4263 v8::ResourceConstraints constraints; | 4250 v8::ResourceConstraints constraints; |
| 4264 constraints.set_max_young_space_size(256 * K); | 4251 constraints.set_max_young_space_size(256 * K); |
| 4265 constraints.set_max_old_space_size(5 * K * K); | 4252 constraints.set_max_old_space_size(5 * K * K); |
| 4266 v8::SetResourceConstraints(CcTest::isolate(), &constraints); | 4253 v8::SetResourceConstraints(CcTest::isolate(), &constraints); |
| 4267 | 4254 |
| 4268 // Execute a script that causes out of memory. | 4255 // Execute a script that causes out of memory. |
| 4269 LocalContext context; | 4256 LocalContext context; |
| 4270 v8::HandleScope scope(context->GetIsolate()); | 4257 v8::HandleScope scope(context->GetIsolate()); |
| 4271 v8::V8::IgnoreOutOfMemoryException(); | 4258 v8::V8::IgnoreOutOfMemoryException(); |
| 4272 Local<Script> script = | 4259 Local<Script> script = Script::Compile(String::NewFromUtf8( |
| 4273 Script::Compile(String::New(js_code_causing_out_of_memory)); | 4260 context->GetIsolate(), js_code_causing_out_of_memory)); |
| 4274 Local<Value> result = script->Run(); | 4261 Local<Value> result = script->Run(); |
| 4275 | 4262 |
| 4276 // Check for out of memory state. | 4263 // Check for out of memory state. |
| 4277 CHECK(result.IsEmpty()); | 4264 CHECK(result.IsEmpty()); |
| 4278 CHECK(context->HasOutOfMemoryException()); | 4265 CHECK(context->HasOutOfMemoryException()); |
| 4279 } | 4266 } |
| 4280 | 4267 |
| 4281 | 4268 |
| 4282 void ProvokeOutOfMemory(const v8::FunctionCallbackInfo<v8::Value>& args) { | 4269 void ProvokeOutOfMemory(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 4283 ApiTestFuzzer::Fuzz(); | 4270 ApiTestFuzzer::Fuzz(); |
| 4284 | 4271 |
| 4285 LocalContext context; | 4272 LocalContext context; |
| 4286 v8::HandleScope scope(context->GetIsolate()); | 4273 v8::HandleScope scope(context->GetIsolate()); |
| 4287 Local<Script> script = | 4274 Local<Script> script = Script::Compile(String::NewFromUtf8( |
| 4288 Script::Compile(String::New(js_code_causing_out_of_memory)); | 4275 context->GetIsolate(), js_code_causing_out_of_memory)); |
| 4289 Local<Value> result = script->Run(); | 4276 Local<Value> result = script->Run(); |
| 4290 | 4277 |
| 4291 // Check for out of memory state. | 4278 // Check for out of memory state. |
| 4292 CHECK(result.IsEmpty()); | 4279 CHECK(result.IsEmpty()); |
| 4293 CHECK(context->HasOutOfMemoryException()); | 4280 CHECK(context->HasOutOfMemoryException()); |
| 4294 | 4281 |
| 4295 args.GetReturnValue().Set(result); | 4282 args.GetReturnValue().Set(result); |
| 4296 } | 4283 } |
| 4297 | 4284 |
| 4298 | 4285 |
| (...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5168 CHECK(!v8_num(1)->StrictEquals(v8_num(2))); | 5155 CHECK(!v8_num(1)->StrictEquals(v8_num(2))); |
| 5169 CHECK(v8_num(0.0)->StrictEquals(v8_num(-0.0))); | 5156 CHECK(v8_num(0.0)->StrictEquals(v8_num(-0.0))); |
| 5170 Local<Value> not_a_number = v8_num(i::OS::nan_value()); | 5157 Local<Value> not_a_number = v8_num(i::OS::nan_value()); |
| 5171 CHECK(!not_a_number->StrictEquals(not_a_number)); | 5158 CHECK(!not_a_number->StrictEquals(not_a_number)); |
| 5172 CHECK(v8::False(isolate)->StrictEquals(v8::False(isolate))); | 5159 CHECK(v8::False(isolate)->StrictEquals(v8::False(isolate))); |
| 5173 CHECK(!v8::False(isolate)->StrictEquals(v8::Undefined(isolate))); | 5160 CHECK(!v8::False(isolate)->StrictEquals(v8::Undefined(isolate))); |
| 5174 | 5161 |
| 5175 v8::Handle<v8::Object> obj = v8::Object::New(); | 5162 v8::Handle<v8::Object> obj = v8::Object::New(); |
| 5176 v8::Persistent<v8::Object> alias(isolate, obj); | 5163 v8::Persistent<v8::Object> alias(isolate, obj); |
| 5177 CHECK(v8::Local<v8::Object>::New(isolate, alias)->StrictEquals(obj)); | 5164 CHECK(v8::Local<v8::Object>::New(isolate, alias)->StrictEquals(obj)); |
| 5178 alias.Dispose(); | 5165 alias.Reset(); |
| 5179 | 5166 |
| 5180 CHECK(v8_str("a")->SameValue(v8_str("a"))); | 5167 CHECK(v8_str("a")->SameValue(v8_str("a"))); |
| 5181 CHECK(!v8_str("a")->SameValue(v8_str("b"))); | 5168 CHECK(!v8_str("a")->SameValue(v8_str("b"))); |
| 5182 CHECK(!v8_str("5")->SameValue(v8_num(5))); | 5169 CHECK(!v8_str("5")->SameValue(v8_num(5))); |
| 5183 CHECK(v8_num(1)->SameValue(v8_num(1))); | 5170 CHECK(v8_num(1)->SameValue(v8_num(1))); |
| 5184 CHECK(!v8_num(1)->SameValue(v8_num(2))); | 5171 CHECK(!v8_num(1)->SameValue(v8_num(2))); |
| 5185 CHECK(!v8_num(0.0)->SameValue(v8_num(-0.0))); | 5172 CHECK(!v8_num(0.0)->SameValue(v8_num(-0.0))); |
| 5186 CHECK(not_a_number->SameValue(not_a_number)); | 5173 CHECK(not_a_number->SameValue(not_a_number)); |
| 5187 CHECK(v8::False(isolate)->SameValue(v8::False(isolate))); | 5174 CHECK(v8::False(isolate)->SameValue(v8::False(isolate))); |
| 5188 CHECK(!v8::False(isolate)->SameValue(v8::Undefined(isolate))); | 5175 CHECK(!v8::False(isolate)->SameValue(v8::Undefined(isolate))); |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5493 v8::HandleScope scope(CcTest::isolate()); | 5480 v8::HandleScope scope(CcTest::isolate()); |
| 5494 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5481 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5495 templ->SetAccessor(v8_str("x"), GetXValue, SetXValue, v8_str("donut")); | 5482 templ->SetAccessor(v8_str("x"), GetXValue, SetXValue, v8_str("donut")); |
| 5496 LocalContext context; | 5483 LocalContext context; |
| 5497 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 5484 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
| 5498 Local<Script> script = Script::Compile(v8_str("obj.x = 4")); | 5485 Local<Script> script = Script::Compile(v8_str("obj.x = 4")); |
| 5499 for (int i = 0; i < 10; i++) { | 5486 for (int i = 0; i < 10; i++) { |
| 5500 CHECK(xValue.IsEmpty()); | 5487 CHECK(xValue.IsEmpty()); |
| 5501 script->Run(); | 5488 script->Run(); |
| 5502 CHECK_EQ(v8_num(4), Local<Value>::New(CcTest::isolate(), xValue)); | 5489 CHECK_EQ(v8_num(4), Local<Value>::New(CcTest::isolate(), xValue)); |
| 5503 xValue.Dispose(); | 5490 xValue.Reset(); |
| 5504 xValue.Clear(); | |
| 5505 } | 5491 } |
| 5506 } | 5492 } |
| 5507 | 5493 |
| 5508 | 5494 |
| 5509 THREADED_TEST(SetterOnly) { | 5495 THREADED_TEST(SetterOnly) { |
| 5510 v8::HandleScope scope(CcTest::isolate()); | 5496 v8::HandleScope scope(CcTest::isolate()); |
| 5511 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5497 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5512 templ->SetAccessor(v8_str("x"), NULL, SetXValue, v8_str("donut")); | 5498 templ->SetAccessor(v8_str("x"), NULL, SetXValue, v8_str("donut")); |
| 5513 LocalContext context; | 5499 LocalContext context; |
| 5514 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 5500 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
| 5515 Local<Script> script = Script::Compile(v8_str("obj.x = 4; obj.x")); | 5501 Local<Script> script = Script::Compile(v8_str("obj.x = 4; obj.x")); |
| 5516 for (int i = 0; i < 10; i++) { | 5502 for (int i = 0; i < 10; i++) { |
| 5517 CHECK(xValue.IsEmpty()); | 5503 CHECK(xValue.IsEmpty()); |
| 5518 script->Run(); | 5504 script->Run(); |
| 5519 CHECK_EQ(v8_num(4), Local<Value>::New(CcTest::isolate(), xValue)); | 5505 CHECK_EQ(v8_num(4), Local<Value>::New(CcTest::isolate(), xValue)); |
| 5520 xValue.Dispose(); | 5506 xValue.Reset(); |
| 5521 xValue.Clear(); | |
| 5522 } | 5507 } |
| 5523 } | 5508 } |
| 5524 | 5509 |
| 5525 | 5510 |
| 5526 THREADED_TEST(NoAccessors) { | 5511 THREADED_TEST(NoAccessors) { |
| 5527 v8::HandleScope scope(CcTest::isolate()); | 5512 v8::HandleScope scope(CcTest::isolate()); |
| 5528 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5513 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5529 templ->SetAccessor(v8_str("x"), | 5514 templ->SetAccessor(v8_str("x"), |
| 5530 static_cast<v8::AccessorGetterCallback>(NULL), | 5515 static_cast<v8::AccessorGetterCallback>(NULL), |
| 5531 NULL, | 5516 NULL, |
| (...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6301 script->Run(); | 6286 script->Run(); |
| 6302 ExpectBoolean("undetectable.y == undefined", true); | 6287 ExpectBoolean("undetectable.y == undefined", true); |
| 6303 } | 6288 } |
| 6304 | 6289 |
| 6305 | 6290 |
| 6306 | 6291 |
| 6307 THREADED_TEST(UndetectableString) { | 6292 THREADED_TEST(UndetectableString) { |
| 6308 LocalContext env; | 6293 LocalContext env; |
| 6309 v8::HandleScope scope(env->GetIsolate()); | 6294 v8::HandleScope scope(env->GetIsolate()); |
| 6310 | 6295 |
| 6311 Local<String> obj = String::NewUndetectable("foo"); | 6296 Local<String> obj = String::NewFromUtf8(env->GetIsolate(), "foo", |
| 6297 String::kUndetectableString); |
| 6312 env->Global()->Set(v8_str("undetectable"), obj); | 6298 env->Global()->Set(v8_str("undetectable"), obj); |
| 6313 | 6299 |
| 6314 ExpectString("undetectable", "foo"); | 6300 ExpectString("undetectable", "foo"); |
| 6315 ExpectString("typeof undetectable", "undefined"); | 6301 ExpectString("typeof undetectable", "undefined"); |
| 6316 ExpectString("typeof(undetectable)", "undefined"); | 6302 ExpectString("typeof(undetectable)", "undefined"); |
| 6317 ExpectBoolean("typeof undetectable == 'undefined'", true); | 6303 ExpectBoolean("typeof undetectable == 'undefined'", true); |
| 6318 ExpectBoolean("typeof undetectable == 'string'", false); | 6304 ExpectBoolean("typeof undetectable == 'string'", false); |
| 6319 ExpectBoolean("if (undetectable) { true; } else { false; }", false); | 6305 ExpectBoolean("if (undetectable) { true; } else { false; }", false); |
| 6320 ExpectBoolean("!undetectable", true); | 6306 ExpectBoolean("!undetectable", true); |
| 6321 | 6307 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 6342 ExpectBoolean("undefined===undetectable", false); | 6328 ExpectBoolean("undefined===undetectable", false); |
| 6343 ExpectBoolean("undetectable===undetectable", true); | 6329 ExpectBoolean("undetectable===undetectable", true); |
| 6344 } | 6330 } |
| 6345 | 6331 |
| 6346 | 6332 |
| 6347 TEST(UndetectableOptimized) { | 6333 TEST(UndetectableOptimized) { |
| 6348 i::FLAG_allow_natives_syntax = true; | 6334 i::FLAG_allow_natives_syntax = true; |
| 6349 LocalContext env; | 6335 LocalContext env; |
| 6350 v8::HandleScope scope(env->GetIsolate()); | 6336 v8::HandleScope scope(env->GetIsolate()); |
| 6351 | 6337 |
| 6352 Local<String> obj = String::NewUndetectable("foo"); | 6338 Local<String> obj = String::NewFromUtf8(env->GetIsolate(), "foo", |
| 6339 String::kUndetectableString); |
| 6353 env->Global()->Set(v8_str("undetectable"), obj); | 6340 env->Global()->Set(v8_str("undetectable"), obj); |
| 6354 env->Global()->Set(v8_str("detectable"), v8_str("bar")); | 6341 env->Global()->Set(v8_str("detectable"), v8_str("bar")); |
| 6355 | 6342 |
| 6356 ExpectString( | 6343 ExpectString( |
| 6357 "function testBranch() {" | 6344 "function testBranch() {" |
| 6358 " if (!%_IsUndetectableObject(undetectable)) throw 1;" | 6345 " if (!%_IsUndetectableObject(undetectable)) throw 1;" |
| 6359 " if (%_IsUndetectableObject(detectable)) throw 2;" | 6346 " if (%_IsUndetectableObject(detectable)) throw 2;" |
| 6360 "}\n" | 6347 "}\n" |
| 6361 "function testBool() {" | 6348 "function testBool() {" |
| 6362 " var b1 = !%_IsUndetectableObject(undetectable);" | 6349 " var b1 = !%_IsUndetectableObject(undetectable);" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 6377 | 6364 |
| 6378 | 6365 |
| 6379 template <typename T> static void USE(T) { } | 6366 template <typename T> static void USE(T) { } |
| 6380 | 6367 |
| 6381 | 6368 |
| 6382 // This test is not intended to be run, just type checked. | 6369 // This test is not intended to be run, just type checked. |
| 6383 static inline void PersistentHandles(v8::Isolate* isolate) { | 6370 static inline void PersistentHandles(v8::Isolate* isolate) { |
| 6384 USE(PersistentHandles); | 6371 USE(PersistentHandles); |
| 6385 Local<String> str = v8_str("foo"); | 6372 Local<String> str = v8_str("foo"); |
| 6386 v8::Persistent<String> p_str(isolate, str); | 6373 v8::Persistent<String> p_str(isolate, str); |
| 6387 p_str.Dispose(); | 6374 p_str.Reset(); |
| 6388 Local<Script> scr = Script::Compile(v8_str("")); | 6375 Local<Script> scr = Script::Compile(v8_str("")); |
| 6389 v8::Persistent<Script> p_scr(isolate, scr); | 6376 v8::Persistent<Script> p_scr(isolate, scr); |
| 6390 p_scr.Dispose(); | 6377 p_scr.Reset(); |
| 6391 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 6378 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 6392 v8::Persistent<ObjectTemplate> p_templ(isolate, templ); | 6379 v8::Persistent<ObjectTemplate> p_templ(isolate, templ); |
| 6393 p_templ.Dispose(); | 6380 p_templ.Reset(); |
| 6394 } | 6381 } |
| 6395 | 6382 |
| 6396 | 6383 |
| 6397 static void HandleLogDelegator( | 6384 static void HandleLogDelegator( |
| 6398 const v8::FunctionCallbackInfo<v8::Value>& args) { | 6385 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 6399 ApiTestFuzzer::Fuzz(); | 6386 ApiTestFuzzer::Fuzz(); |
| 6400 } | 6387 } |
| 6401 | 6388 |
| 6402 | 6389 |
| 6403 THREADED_TEST(GlobalObjectTemplate) { | 6390 THREADED_TEST(GlobalObjectTemplate) { |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6690 v8::Handle<Context> context = | 6677 v8::Handle<Context> context = |
| 6691 Context::New(CcTest::isolate(), &extensions); | 6678 Context::New(CcTest::isolate(), &extensions); |
| 6692 CHECK(context.IsEmpty()); | 6679 CHECK(context.IsEmpty()); |
| 6693 } | 6680 } |
| 6694 | 6681 |
| 6695 | 6682 |
| 6696 static void CheckDependencies(const char* name, const char* expected) { | 6683 static void CheckDependencies(const char* name, const char* expected) { |
| 6697 v8::HandleScope handle_scope(CcTest::isolate()); | 6684 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6698 v8::ExtensionConfiguration config(1, &name); | 6685 v8::ExtensionConfiguration config(1, &name); |
| 6699 LocalContext context(&config); | 6686 LocalContext context(&config); |
| 6700 CHECK_EQ(String::New(expected), context->Global()->Get(v8_str("loaded"))); | 6687 CHECK_EQ(String::NewFromUtf8(CcTest::isolate(), expected), |
| 6688 context->Global()->Get(v8_str("loaded"))); |
| 6701 } | 6689 } |
| 6702 | 6690 |
| 6703 | 6691 |
| 6704 /* | 6692 /* |
| 6705 * Configuration: | 6693 * Configuration: |
| 6706 * | 6694 * |
| 6707 * /-- B <--\ | 6695 * /-- B <--\ |
| 6708 * A <- -- D <-- E | 6696 * A <- -- D <-- E |
| 6709 * \-- C <--/ | 6697 * \-- C <--/ |
| 6710 */ | 6698 */ |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6847 void OOMCallback(const char* location, const char* message) { | 6835 void OOMCallback(const char* location, const char* message) { |
| 6848 exit(0); | 6836 exit(0); |
| 6849 } | 6837 } |
| 6850 | 6838 |
| 6851 | 6839 |
| 6852 TEST(RegexpOutOfMemory) { | 6840 TEST(RegexpOutOfMemory) { |
| 6853 // Execute a script that causes out of memory when flattening a string. | 6841 // Execute a script that causes out of memory when flattening a string. |
| 6854 v8::HandleScope scope(CcTest::isolate()); | 6842 v8::HandleScope scope(CcTest::isolate()); |
| 6855 v8::V8::SetFatalErrorHandler(OOMCallback); | 6843 v8::V8::SetFatalErrorHandler(OOMCallback); |
| 6856 LocalContext context; | 6844 LocalContext context; |
| 6857 Local<Script> script = | 6845 Local<Script> script = Script::Compile(String::NewFromUtf8( |
| 6858 Script::Compile(String::New(js_code_causing_huge_string_flattening)); | 6846 CcTest::isolate(), js_code_causing_huge_string_flattening)); |
| 6859 last_location = NULL; | 6847 last_location = NULL; |
| 6860 script->Run(); | 6848 script->Run(); |
| 6861 | 6849 |
| 6862 CHECK(false); // Should not return. | 6850 CHECK(false); // Should not return. |
| 6863 } | 6851 } |
| 6864 | 6852 |
| 6865 | 6853 |
| 6866 static void MissingScriptInfoMessageListener(v8::Handle<v8::Message> message, | 6854 static void MissingScriptInfoMessageListener(v8::Handle<v8::Message> message, |
| 6867 v8::Handle<Value> data) { | 6855 v8::Handle<Value> data) { |
| 6868 CHECK(message->GetScriptResourceName()->IsUndefined()); | 6856 CHECK(message->GetScriptResourceName()->IsUndefined()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 6885 | 6873 |
| 6886 class Snorkel { | 6874 class Snorkel { |
| 6887 public: | 6875 public: |
| 6888 Snorkel() { index_ = global_index++; } | 6876 Snorkel() { index_ = global_index++; } |
| 6889 int index_; | 6877 int index_; |
| 6890 }; | 6878 }; |
| 6891 | 6879 |
| 6892 class Whammy { | 6880 class Whammy { |
| 6893 public: | 6881 public: |
| 6894 explicit Whammy(v8::Isolate* isolate) : cursor_(0), isolate_(isolate) { } | 6882 explicit Whammy(v8::Isolate* isolate) : cursor_(0), isolate_(isolate) { } |
| 6895 ~Whammy() { script_.Dispose(); } | 6883 ~Whammy() { script_.Reset(); } |
| 6896 v8::Handle<Script> getScript() { | 6884 v8::Handle<Script> getScript() { |
| 6897 if (script_.IsEmpty()) script_.Reset(isolate_, v8_compile("({}).blammo")); | 6885 if (script_.IsEmpty()) script_.Reset(isolate_, v8_compile("({}).blammo")); |
| 6898 return Local<Script>::New(isolate_, script_); | 6886 return Local<Script>::New(isolate_, script_); |
| 6899 } | 6887 } |
| 6900 | 6888 |
| 6901 public: | 6889 public: |
| 6902 static const int kObjectCount = 256; | 6890 static const int kObjectCount = 256; |
| 6903 int cursor_; | 6891 int cursor_; |
| 6904 v8::Isolate* isolate_; | 6892 v8::Isolate* isolate_; |
| 6905 v8::Persistent<v8::Object> objects_[kObjectCount]; | 6893 v8::Persistent<v8::Object> objects_[kObjectCount]; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 6918 Whammy* whammy = | 6906 Whammy* whammy = |
| 6919 static_cast<Whammy*>(v8::Handle<v8::External>::Cast(info.Data())->Value()); | 6907 static_cast<Whammy*>(v8::Handle<v8::External>::Cast(info.Data())->Value()); |
| 6920 | 6908 |
| 6921 v8::Persistent<v8::Object>& prev = whammy->objects_[whammy->cursor_]; | 6909 v8::Persistent<v8::Object>& prev = whammy->objects_[whammy->cursor_]; |
| 6922 | 6910 |
| 6923 v8::Handle<v8::Object> obj = v8::Object::New(); | 6911 v8::Handle<v8::Object> obj = v8::Object::New(); |
| 6924 if (!prev.IsEmpty()) { | 6912 if (!prev.IsEmpty()) { |
| 6925 v8::Local<v8::Object>::New(info.GetIsolate(), prev) | 6913 v8::Local<v8::Object>::New(info.GetIsolate(), prev) |
| 6926 ->Set(v8_str("next"), obj); | 6914 ->Set(v8_str("next"), obj); |
| 6927 prev.MakeWeak<Value, Snorkel>(new Snorkel(), &HandleWeakReference); | 6915 prev.MakeWeak<Value, Snorkel>(new Snorkel(), &HandleWeakReference); |
| 6928 whammy->objects_[whammy->cursor_].Clear(); | |
| 6929 } | 6916 } |
| 6930 whammy->objects_[whammy->cursor_].Reset(info.GetIsolate(), obj); | 6917 whammy->objects_[whammy->cursor_].Reset(info.GetIsolate(), obj); |
| 6931 whammy->cursor_ = (whammy->cursor_ + 1) % Whammy::kObjectCount; | 6918 whammy->cursor_ = (whammy->cursor_ + 1) % Whammy::kObjectCount; |
| 6932 info.GetReturnValue().Set(whammy->getScript()->Run()); | 6919 info.GetReturnValue().Set(whammy->getScript()->Run()); |
| 6933 } | 6920 } |
| 6934 | 6921 |
| 6935 | 6922 |
| 6936 THREADED_TEST(WeakReference) { | 6923 THREADED_TEST(WeakReference) { |
| 6937 v8::HandleScope handle_scope(CcTest::isolate()); | 6924 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6938 v8::Handle<v8::ObjectTemplate> templ= v8::ObjectTemplate::New(); | 6925 v8::Handle<v8::ObjectTemplate> templ= v8::ObjectTemplate::New(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 6959 "4"; | 6946 "4"; |
| 6960 v8::Handle<Value> result = CompileRun(code); | 6947 v8::Handle<Value> result = CompileRun(code); |
| 6961 CHECK_EQ(4.0, result->NumberValue()); | 6948 CHECK_EQ(4.0, result->NumberValue()); |
| 6962 delete whammy; | 6949 delete whammy; |
| 6963 } | 6950 } |
| 6964 | 6951 |
| 6965 | 6952 |
| 6966 static void DisposeAndSetFlag(v8::Isolate* isolate, | 6953 static void DisposeAndSetFlag(v8::Isolate* isolate, |
| 6967 v8::Persistent<v8::Object>* obj, | 6954 v8::Persistent<v8::Object>* obj, |
| 6968 bool* data) { | 6955 bool* data) { |
| 6969 obj->Dispose(); | 6956 obj->Reset(); |
| 6970 *(data) = true; | 6957 *(data) = true; |
| 6971 } | 6958 } |
| 6972 | 6959 |
| 6973 | 6960 |
| 6974 THREADED_TEST(IndependentWeakHandle) { | 6961 THREADED_TEST(IndependentWeakHandle) { |
| 6975 v8::Isolate* iso = CcTest::isolate(); | 6962 v8::Isolate* iso = CcTest::isolate(); |
| 6976 v8::HandleScope scope(iso); | 6963 v8::HandleScope scope(iso); |
| 6977 v8::Handle<Context> context = Context::New(iso); | 6964 v8::Handle<Context> context = Context::New(iso); |
| 6978 Context::Scope context_scope(context); | 6965 Context::Scope context_scope(context); |
| 6979 | 6966 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 7005 | 6992 |
| 7006 | 6993 |
| 7007 static void InvokeMarkSweep() { | 6994 static void InvokeMarkSweep() { |
| 7008 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 6995 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 7009 } | 6996 } |
| 7010 | 6997 |
| 7011 | 6998 |
| 7012 static void ForceScavenge(v8::Isolate* isolate, | 6999 static void ForceScavenge(v8::Isolate* isolate, |
| 7013 v8::Persistent<v8::Object>* obj, | 7000 v8::Persistent<v8::Object>* obj, |
| 7014 bool* data) { | 7001 bool* data) { |
| 7015 obj->Dispose(); | 7002 obj->Reset(); |
| 7016 *(data) = true; | 7003 *(data) = true; |
| 7017 InvokeScavenge(); | 7004 InvokeScavenge(); |
| 7018 } | 7005 } |
| 7019 | 7006 |
| 7020 | 7007 |
| 7021 static void ForceMarkSweep(v8::Isolate* isolate, | 7008 static void ForceMarkSweep(v8::Isolate* isolate, |
| 7022 v8::Persistent<v8::Object>* obj, | 7009 v8::Persistent<v8::Object>* obj, |
| 7023 bool* data) { | 7010 bool* data) { |
| 7024 obj->Dispose(); | 7011 obj->Reset(); |
| 7025 *(data) = true; | 7012 *(data) = true; |
| 7026 InvokeMarkSweep(); | 7013 InvokeMarkSweep(); |
| 7027 } | 7014 } |
| 7028 | 7015 |
| 7029 | 7016 |
| 7030 THREADED_TEST(GCFromWeakCallbacks) { | 7017 THREADED_TEST(GCFromWeakCallbacks) { |
| 7031 v8::Isolate* isolate = CcTest::isolate(); | 7018 v8::Isolate* isolate = CcTest::isolate(); |
| 7032 v8::HandleScope scope(isolate); | 7019 v8::HandleScope scope(isolate); |
| 7033 v8::Handle<Context> context = Context::New(isolate); | 7020 v8::Handle<Context> context = Context::New(isolate); |
| 7034 Context::Scope context_scope(context); | 7021 Context::Scope context_scope(context); |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7407 return len; | 7394 return len; |
| 7408 } | 7395 } |
| 7409 | 7396 |
| 7410 | 7397 |
| 7411 THREADED_TEST(StringWrite) { | 7398 THREADED_TEST(StringWrite) { |
| 7412 LocalContext context; | 7399 LocalContext context; |
| 7413 v8::HandleScope scope(context->GetIsolate()); | 7400 v8::HandleScope scope(context->GetIsolate()); |
| 7414 v8::Handle<String> str = v8_str("abcde"); | 7401 v8::Handle<String> str = v8_str("abcde"); |
| 7415 // abc<Icelandic eth><Unicode snowman>. | 7402 // abc<Icelandic eth><Unicode snowman>. |
| 7416 v8::Handle<String> str2 = v8_str("abc\303\260\342\230\203"); | 7403 v8::Handle<String> str2 = v8_str("abc\303\260\342\230\203"); |
| 7417 v8::Handle<String> str3 = v8::String::New("abc\0def", 7); | 7404 v8::Handle<String> str3 = v8::String::NewFromUtf8( |
| 7405 context->GetIsolate(), "abc\0def", v8::String::kNormalString, 7); |
| 7418 const int kStride = 4; // Must match stride in for loops in JS below. | 7406 const int kStride = 4; // Must match stride in for loops in JS below. |
| 7419 CompileRun( | 7407 CompileRun( |
| 7420 "var left = '';" | 7408 "var left = '';" |
| 7421 "for (var i = 0; i < 0xd800; i += 4) {" | 7409 "for (var i = 0; i < 0xd800; i += 4) {" |
| 7422 " left = left + String.fromCharCode(i);" | 7410 " left = left + String.fromCharCode(i);" |
| 7423 "}"); | 7411 "}"); |
| 7424 CompileRun( | 7412 CompileRun( |
| 7425 "var right = '';" | 7413 "var right = '';" |
| 7426 "for (var i = 0; i < 0xd800; i += 4) {" | 7414 "for (var i = 0; i < 0xd800; i += 4) {" |
| 7427 " right = String.fromCharCode(i) + right;" | 7415 " right = String.fromCharCode(i) + right;" |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7801 WriteUtf8Helper(context, "c2", "a2lens", 81); | 7789 WriteUtf8Helper(context, "c2", "a2lens", 81); |
| 7802 } | 7790 } |
| 7803 | 7791 |
| 7804 | 7792 |
| 7805 static bool SameSymbol(Handle<String> s1, Handle<String> s2) { | 7793 static bool SameSymbol(Handle<String> s1, Handle<String> s2) { |
| 7806 i::Handle<i::String> is1(v8::Utils::OpenHandle(*s1)); | 7794 i::Handle<i::String> is1(v8::Utils::OpenHandle(*s1)); |
| 7807 i::Handle<i::String> is2(v8::Utils::OpenHandle(*s2)); | 7795 i::Handle<i::String> is2(v8::Utils::OpenHandle(*s2)); |
| 7808 return *is1 == *is2; | 7796 return *is1 == *is2; |
| 7809 } | 7797 } |
| 7810 | 7798 |
| 7811 | 7799 static void SameSymbolHelper(v8::Isolate* isolate, const char* a, |
| 7812 static void SameSymbolHelper(const char* a, const char* b) { | 7800 const char* b) { |
| 7813 Handle<String> symbol1 = v8::String::NewSymbol(a); | 7801 Handle<String> symbol1 = |
| 7814 Handle<String> symbol2 = v8::String::NewSymbol(b); | 7802 v8::String::NewFromUtf8(isolate, a, v8::String::kInternalizedString); |
| 7803 Handle<String> symbol2 = |
| 7804 v8::String::NewFromUtf8(isolate, b, v8::String::kInternalizedString); |
| 7815 CHECK(SameSymbol(symbol1, symbol2)); | 7805 CHECK(SameSymbol(symbol1, symbol2)); |
| 7816 } | 7806 } |
| 7817 | 7807 |
| 7818 | 7808 |
| 7819 THREADED_TEST(Utf16Symbol) { | 7809 THREADED_TEST(Utf16Symbol) { |
| 7820 LocalContext context; | 7810 LocalContext context; |
| 7821 v8::HandleScope scope(context->GetIsolate()); | 7811 v8::HandleScope scope(context->GetIsolate()); |
| 7822 | 7812 |
| 7823 Handle<String> symbol1 = v8::String::NewSymbol("abc"); | 7813 Handle<String> symbol1 = v8::String::NewFromUtf8( |
| 7824 Handle<String> symbol2 = v8::String::NewSymbol("abc"); | 7814 context->GetIsolate(), "abc", v8::String::kInternalizedString); |
| 7815 Handle<String> symbol2 = v8::String::NewFromUtf8( |
| 7816 context->GetIsolate(), "abc", v8::String::kInternalizedString); |
| 7825 CHECK(SameSymbol(symbol1, symbol2)); | 7817 CHECK(SameSymbol(symbol1, symbol2)); |
| 7826 | 7818 |
| 7827 SameSymbolHelper("\360\220\220\205", // 4 byte encoding. | 7819 SameSymbolHelper(context->GetIsolate(), |
| 7820 "\360\220\220\205", // 4 byte encoding. |
| 7828 "\355\240\201\355\260\205"); // 2 3-byte surrogates. | 7821 "\355\240\201\355\260\205"); // 2 3-byte surrogates. |
| 7829 SameSymbolHelper("\355\240\201\355\260\206", // 2 3-byte surrogates. | 7822 SameSymbolHelper(context->GetIsolate(), |
| 7823 "\355\240\201\355\260\206", // 2 3-byte surrogates. |
| 7830 "\360\220\220\206"); // 4 byte encoding. | 7824 "\360\220\220\206"); // 4 byte encoding. |
| 7831 SameSymbolHelper("x\360\220\220\205", // 4 byte encoding. | 7825 SameSymbolHelper(context->GetIsolate(), |
| 7826 "x\360\220\220\205", // 4 byte encoding. |
| 7832 "x\355\240\201\355\260\205"); // 2 3-byte surrogates. | 7827 "x\355\240\201\355\260\205"); // 2 3-byte surrogates. |
| 7833 SameSymbolHelper("x\355\240\201\355\260\206", // 2 3-byte surrogates. | 7828 SameSymbolHelper(context->GetIsolate(), |
| 7829 "x\355\240\201\355\260\206", // 2 3-byte surrogates. |
| 7834 "x\360\220\220\206"); // 4 byte encoding. | 7830 "x\360\220\220\206"); // 4 byte encoding. |
| 7835 CompileRun( | 7831 CompileRun( |
| 7836 "var sym0 = 'benedictus';" | 7832 "var sym0 = 'benedictus';" |
| 7837 "var sym0b = 'S\303\270ren';" | 7833 "var sym0b = 'S\303\270ren';" |
| 7838 "var sym1 = '\355\240\201\355\260\207';" | 7834 "var sym1 = '\355\240\201\355\260\207';" |
| 7839 "var sym2 = '\360\220\220\210';" | 7835 "var sym2 = '\360\220\220\210';" |
| 7840 "var sym3 = 'x\355\240\201\355\260\207';" | 7836 "var sym3 = 'x\355\240\201\355\260\207';" |
| 7841 "var sym4 = 'x\360\220\220\210';" | 7837 "var sym4 = 'x\360\220\220\210';" |
| 7842 "if (sym1.length != 2) throw sym1;" | 7838 "if (sym1.length != 2) throw sym1;" |
| 7843 "if (sym1.charCodeAt(1) != 0xdc07) throw sym1.charCodeAt(1);" | 7839 "if (sym1.charCodeAt(1) != 0xdc07) throw sym1.charCodeAt(1);" |
| 7844 "if (sym2.length != 2) throw sym2;" | 7840 "if (sym2.length != 2) throw sym2;" |
| 7845 "if (sym2.charCodeAt(1) != 0xdc08) throw sym2.charCodeAt(2);" | 7841 "if (sym2.charCodeAt(1) != 0xdc08) throw sym2.charCodeAt(2);" |
| 7846 "if (sym3.length != 3) throw sym3;" | 7842 "if (sym3.length != 3) throw sym3;" |
| 7847 "if (sym3.charCodeAt(2) != 0xdc07) throw sym1.charCodeAt(2);" | 7843 "if (sym3.charCodeAt(2) != 0xdc07) throw sym1.charCodeAt(2);" |
| 7848 "if (sym4.length != 3) throw sym4;" | 7844 "if (sym4.length != 3) throw sym4;" |
| 7849 "if (sym4.charCodeAt(2) != 0xdc08) throw sym2.charCodeAt(2);"); | 7845 "if (sym4.charCodeAt(2) != 0xdc08) throw sym2.charCodeAt(2);"); |
| 7850 Handle<String> sym0 = v8::String::NewSymbol("benedictus"); | 7846 Handle<String> sym0 = v8::String::NewFromUtf8( |
| 7851 Handle<String> sym0b = v8::String::NewSymbol("S\303\270ren"); | 7847 context->GetIsolate(), "benedictus", v8::String::kInternalizedString); |
| 7852 Handle<String> sym1 = v8::String::NewSymbol("\355\240\201\355\260\207"); | 7848 Handle<String> sym0b = v8::String::NewFromUtf8( |
| 7853 Handle<String> sym2 = v8::String::NewSymbol("\360\220\220\210"); | 7849 context->GetIsolate(), "S\303\270ren", v8::String::kInternalizedString); |
| 7854 Handle<String> sym3 = v8::String::NewSymbol("x\355\240\201\355\260\207"); | 7850 Handle<String> sym1 = |
| 7855 Handle<String> sym4 = v8::String::NewSymbol("x\360\220\220\210"); | 7851 v8::String::NewFromUtf8(context->GetIsolate(), "\355\240\201\355\260\207", |
| 7852 v8::String::kInternalizedString); |
| 7853 Handle<String> sym2 = |
| 7854 v8::String::NewFromUtf8(context->GetIsolate(), "\360\220\220\210", |
| 7855 v8::String::kInternalizedString); |
| 7856 Handle<String> sym3 = v8::String::NewFromUtf8( |
| 7857 context->GetIsolate(), "x\355\240\201\355\260\207", |
| 7858 v8::String::kInternalizedString); |
| 7859 Handle<String> sym4 = |
| 7860 v8::String::NewFromUtf8(context->GetIsolate(), "x\360\220\220\210", |
| 7861 v8::String::kInternalizedString); |
| 7856 v8::Local<v8::Object> global = context->Global(); | 7862 v8::Local<v8::Object> global = context->Global(); |
| 7857 Local<Value> s0 = global->Get(v8_str("sym0")); | 7863 Local<Value> s0 = global->Get(v8_str("sym0")); |
| 7858 Local<Value> s0b = global->Get(v8_str("sym0b")); | 7864 Local<Value> s0b = global->Get(v8_str("sym0b")); |
| 7859 Local<Value> s1 = global->Get(v8_str("sym1")); | 7865 Local<Value> s1 = global->Get(v8_str("sym1")); |
| 7860 Local<Value> s2 = global->Get(v8_str("sym2")); | 7866 Local<Value> s2 = global->Get(v8_str("sym2")); |
| 7861 Local<Value> s3 = global->Get(v8_str("sym3")); | 7867 Local<Value> s3 = global->Get(v8_str("sym3")); |
| 7862 Local<Value> s4 = global->Get(v8_str("sym4")); | 7868 Local<Value> s4 = global->Get(v8_str("sym4")); |
| 7863 CHECK(SameSymbol(sym0, Handle<String>::Cast(s0))); | 7869 CHECK(SameSymbol(sym0, Handle<String>::Cast(s0))); |
| 7864 CHECK(SameSymbol(sym0b, Handle<String>::Cast(s0b))); | 7870 CHECK(SameSymbol(sym0b, Handle<String>::Cast(s0b))); |
| 7865 CHECK(SameSymbol(sym1, Handle<String>::Cast(s1))); | 7871 CHECK(SameSymbol(sym1, Handle<String>::Cast(s1))); |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8076 | 8082 |
| 8077 TEST(ExceptionInNativeScript) { | 8083 TEST(ExceptionInNativeScript) { |
| 8078 LocalContext env; | 8084 LocalContext env; |
| 8079 v8::HandleScope scope(env->GetIsolate()); | 8085 v8::HandleScope scope(env->GetIsolate()); |
| 8080 v8::V8::AddMessageListener(ExceptionInNativeScriptTestListener); | 8086 v8::V8::AddMessageListener(ExceptionInNativeScriptTestListener); |
| 8081 | 8087 |
| 8082 Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(TroubleCallback); | 8088 Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(TroubleCallback); |
| 8083 v8::Local<v8::Object> global = env->Global(); | 8089 v8::Local<v8::Object> global = env->Global(); |
| 8084 global->Set(v8_str("trouble"), fun->GetFunction()); | 8090 global->Set(v8_str("trouble"), fun->GetFunction()); |
| 8085 | 8091 |
| 8086 Script::Compile(v8_str("function trouble() {\n" | 8092 Script::Compile( |
| 8087 " var o = {};\n" | 8093 v8_str( |
| 8088 " new o.foo();\n" | 8094 "function trouble() {\n" |
| 8089 "};"), v8::String::New(script_resource_name))->Run(); | 8095 " var o = {};\n" |
| 8096 " new o.foo();\n" |
| 8097 "};"), |
| 8098 v8::String::NewFromUtf8(env->GetIsolate(), script_resource_name))->Run(); |
| 8090 Local<Value> trouble = global->Get(v8_str("trouble")); | 8099 Local<Value> trouble = global->Get(v8_str("trouble")); |
| 8091 CHECK(trouble->IsFunction()); | 8100 CHECK(trouble->IsFunction()); |
| 8092 Function::Cast(*trouble)->Call(global, 0, NULL); | 8101 Function::Cast(*trouble)->Call(global, 0, NULL); |
| 8093 v8::V8::RemoveMessageListeners(ExceptionInNativeScriptTestListener); | 8102 v8::V8::RemoveMessageListeners(ExceptionInNativeScriptTestListener); |
| 8094 } | 8103 } |
| 8095 | 8104 |
| 8096 | 8105 |
| 8097 TEST(CompilationErrorUsingTryCatchHandler) { | 8106 TEST(CompilationErrorUsingTryCatchHandler) { |
| 8098 LocalContext env; | 8107 LocalContext env; |
| 8099 v8::HandleScope scope(env->GetIsolate()); | 8108 v8::HandleScope scope(env->GetIsolate()); |
| (...skipping 4928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13028 | 13037 |
| 13029 | 13038 |
| 13030 v8::Persistent<v8::Object> some_object; | 13039 v8::Persistent<v8::Object> some_object; |
| 13031 v8::Persistent<v8::Object> bad_handle; | 13040 v8::Persistent<v8::Object> bad_handle; |
| 13032 | 13041 |
| 13033 void NewPersistentHandleCallback(v8::Isolate* isolate, | 13042 void NewPersistentHandleCallback(v8::Isolate* isolate, |
| 13034 v8::Persistent<v8::Value>* handle, | 13043 v8::Persistent<v8::Value>* handle, |
| 13035 void*) { | 13044 void*) { |
| 13036 v8::HandleScope scope(isolate); | 13045 v8::HandleScope scope(isolate); |
| 13037 bad_handle.Reset(isolate, some_object); | 13046 bad_handle.Reset(isolate, some_object); |
| 13038 handle->Dispose(); | 13047 handle->Reset(); |
| 13039 } | 13048 } |
| 13040 | 13049 |
| 13041 | 13050 |
| 13042 THREADED_TEST(NewPersistentHandleFromWeakCallback) { | 13051 THREADED_TEST(NewPersistentHandleFromWeakCallback) { |
| 13043 LocalContext context; | 13052 LocalContext context; |
| 13044 v8::Isolate* isolate = context->GetIsolate(); | 13053 v8::Isolate* isolate = context->GetIsolate(); |
| 13045 | 13054 |
| 13046 v8::Persistent<v8::Object> handle1, handle2; | 13055 v8::Persistent<v8::Object> handle1, handle2; |
| 13047 { | 13056 { |
| 13048 v8::HandleScope scope(isolate); | 13057 v8::HandleScope scope(isolate); |
| 13049 some_object.Reset(isolate, v8::Object::New()); | 13058 some_object.Reset(isolate, v8::Object::New()); |
| 13050 handle1.Reset(isolate, v8::Object::New()); | 13059 handle1.Reset(isolate, v8::Object::New()); |
| 13051 handle2.Reset(isolate, v8::Object::New()); | 13060 handle2.Reset(isolate, v8::Object::New()); |
| 13052 } | 13061 } |
| 13053 // Note: order is implementation dependent alas: currently | 13062 // Note: order is implementation dependent alas: currently |
| 13054 // global handle nodes are processed by PostGarbageCollectionProcessing | 13063 // global handle nodes are processed by PostGarbageCollectionProcessing |
| 13055 // in reverse allocation order, so if second allocated handle is deleted, | 13064 // in reverse allocation order, so if second allocated handle is deleted, |
| 13056 // weak callback of the first handle would be able to 'reallocate' it. | 13065 // weak callback of the first handle would be able to 'reallocate' it. |
| 13057 handle1.MakeWeak<v8::Value, void>(NULL, NewPersistentHandleCallback); | 13066 handle1.MakeWeak<v8::Value, void>(NULL, NewPersistentHandleCallback); |
| 13058 handle2.Dispose(); | 13067 handle2.Reset(); |
| 13059 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 13068 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 13060 } | 13069 } |
| 13061 | 13070 |
| 13062 | 13071 |
| 13063 v8::Persistent<v8::Object> to_be_disposed; | 13072 v8::Persistent<v8::Object> to_be_disposed; |
| 13064 | 13073 |
| 13065 void DisposeAndForceGcCallback(v8::Isolate* isolate, | 13074 void DisposeAndForceGcCallback(v8::Isolate* isolate, |
| 13066 v8::Persistent<v8::Value>* handle, | 13075 v8::Persistent<v8::Value>* handle, |
| 13067 void*) { | 13076 void*) { |
| 13068 to_be_disposed.Dispose(); | 13077 to_be_disposed.Reset(); |
| 13069 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 13078 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 13070 handle->Dispose(); | 13079 handle->Reset(); |
| 13071 } | 13080 } |
| 13072 | 13081 |
| 13073 | 13082 |
| 13074 THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc) { | 13083 THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc) { |
| 13075 LocalContext context; | 13084 LocalContext context; |
| 13076 v8::Isolate* isolate = context->GetIsolate(); | 13085 v8::Isolate* isolate = context->GetIsolate(); |
| 13077 | 13086 |
| 13078 v8::Persistent<v8::Object> handle1, handle2; | 13087 v8::Persistent<v8::Object> handle1, handle2; |
| 13079 { | 13088 { |
| 13080 v8::HandleScope scope(isolate); | 13089 v8::HandleScope scope(isolate); |
| 13081 handle1.Reset(isolate, v8::Object::New()); | 13090 handle1.Reset(isolate, v8::Object::New()); |
| 13082 handle2.Reset(isolate, v8::Object::New()); | 13091 handle2.Reset(isolate, v8::Object::New()); |
| 13083 } | 13092 } |
| 13084 handle1.MakeWeak<v8::Value, void>(NULL, DisposeAndForceGcCallback); | 13093 handle1.MakeWeak<v8::Value, void>(NULL, DisposeAndForceGcCallback); |
| 13085 to_be_disposed.Reset(isolate, handle2); | 13094 to_be_disposed.Reset(isolate, handle2); |
| 13086 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 13095 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 13087 } | 13096 } |
| 13088 | 13097 |
| 13089 void DisposingCallback(v8::Isolate* isolate, | 13098 void DisposingCallback(v8::Isolate* isolate, |
| 13090 v8::Persistent<v8::Value>* handle, | 13099 v8::Persistent<v8::Value>* handle, |
| 13091 void*) { | 13100 void*) { |
| 13092 handle->Dispose(); | 13101 handle->Reset(); |
| 13093 } | 13102 } |
| 13094 | 13103 |
| 13095 void HandleCreatingCallback(v8::Isolate* isolate, | 13104 void HandleCreatingCallback(v8::Isolate* isolate, |
| 13096 v8::Persistent<v8::Value>* handle, | 13105 v8::Persistent<v8::Value>* handle, |
| 13097 void*) { | 13106 void*) { |
| 13098 v8::HandleScope scope(isolate); | 13107 v8::HandleScope scope(isolate); |
| 13099 v8::Persistent<v8::Object>(isolate, v8::Object::New()); | 13108 v8::Persistent<v8::Object>(isolate, v8::Object::New()); |
| 13100 handle->Dispose(); | 13109 handle->Reset(); |
| 13101 } | 13110 } |
| 13102 | 13111 |
| 13103 | 13112 |
| 13104 THREADED_TEST(NoGlobalHandlesOrphaningDueToWeakCallback) { | 13113 THREADED_TEST(NoGlobalHandlesOrphaningDueToWeakCallback) { |
| 13105 LocalContext context; | 13114 LocalContext context; |
| 13106 v8::Isolate* isolate = context->GetIsolate(); | 13115 v8::Isolate* isolate = context->GetIsolate(); |
| 13107 | 13116 |
| 13108 v8::Persistent<v8::Object> handle1, handle2, handle3; | 13117 v8::Persistent<v8::Object> handle1, handle2, handle3; |
| 13109 { | 13118 { |
| 13110 v8::HandleScope scope(isolate); | 13119 v8::HandleScope scope(isolate); |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13781 CHECK_EQ(1, result->InternalFieldCount()); | 13790 CHECK_EQ(1, result->InternalFieldCount()); |
| 13782 } | 13791 } |
| 13783 | 13792 |
| 13784 | 13793 |
| 13785 // If part of the threaded tests, this test makes ThreadingTest fail | 13794 // If part of the threaded tests, this test makes ThreadingTest fail |
| 13786 // on mac. | 13795 // on mac. |
| 13787 TEST(CatchStackOverflow) { | 13796 TEST(CatchStackOverflow) { |
| 13788 LocalContext context; | 13797 LocalContext context; |
| 13789 v8::HandleScope scope(context->GetIsolate()); | 13798 v8::HandleScope scope(context->GetIsolate()); |
| 13790 v8::TryCatch try_catch; | 13799 v8::TryCatch try_catch; |
| 13791 v8::Handle<v8::Script> script = v8::Script::Compile(v8::String::New( | 13800 v8::Handle<v8::Script> script = v8::Script::Compile(v8::String::NewFromUtf8( |
| 13801 context->GetIsolate(), |
| 13792 "function f() {" | 13802 "function f() {" |
| 13793 " return f();" | 13803 " return f();" |
| 13794 "}" | 13804 "}" |
| 13795 "" | 13805 "" |
| 13796 "f();")); | 13806 "f();")); |
| 13797 v8::Handle<v8::Value> result = script->Run(); | 13807 v8::Handle<v8::Value> result = script->Run(); |
| 13798 CHECK(result.IsEmpty()); | 13808 CHECK(result.IsEmpty()); |
| 13799 } | 13809 } |
| 13800 | 13810 |
| 13801 | 13811 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 13817 v8::String::Utf8Value line(message->GetSourceLine()); | 13827 v8::String::Utf8Value line(message->GetSourceLine()); |
| 13818 CHECK_EQ(" throw 'nirk';", *line); | 13828 CHECK_EQ(" throw 'nirk';", *line); |
| 13819 v8::String::Utf8Value name(message->GetScriptResourceName()); | 13829 v8::String::Utf8Value name(message->GetScriptResourceName()); |
| 13820 CHECK_EQ(resource_name, *name); | 13830 CHECK_EQ(resource_name, *name); |
| 13821 } | 13831 } |
| 13822 | 13832 |
| 13823 | 13833 |
| 13824 THREADED_TEST(TryCatchSourceInfo) { | 13834 THREADED_TEST(TryCatchSourceInfo) { |
| 13825 LocalContext context; | 13835 LocalContext context; |
| 13826 v8::HandleScope scope(context->GetIsolate()); | 13836 v8::HandleScope scope(context->GetIsolate()); |
| 13827 v8::Handle<v8::String> source = v8::String::New( | 13837 v8::Handle<v8::String> source = v8::String::NewFromUtf8( |
| 13838 context->GetIsolate(), |
| 13828 "function Foo() {\n" | 13839 "function Foo() {\n" |
| 13829 " return Bar();\n" | 13840 " return Bar();\n" |
| 13830 "}\n" | 13841 "}\n" |
| 13831 "\n" | 13842 "\n" |
| 13832 "function Bar() {\n" | 13843 "function Bar() {\n" |
| 13833 " return Baz();\n" | 13844 " return Baz();\n" |
| 13834 "}\n" | 13845 "}\n" |
| 13835 "\n" | 13846 "\n" |
| 13836 "function Baz() {\n" | 13847 "function Baz() {\n" |
| 13837 " throw 'nirk';\n" | 13848 " throw 'nirk';\n" |
| 13838 "}\n" | 13849 "}\n" |
| 13839 "\n" | 13850 "\n" |
| 13840 "Foo();\n"); | 13851 "Foo();\n"); |
| 13841 | 13852 |
| 13842 const char* resource_name; | 13853 const char* resource_name; |
| 13843 v8::Handle<v8::Script> script; | 13854 v8::Handle<v8::Script> script; |
| 13844 resource_name = "test.js"; | 13855 resource_name = "test.js"; |
| 13845 script = v8::Script::Compile(source, v8::String::New(resource_name)); | 13856 script = v8::Script::Compile( |
| 13857 source, v8::String::NewFromUtf8(context->GetIsolate(), resource_name)); |
| 13846 CheckTryCatchSourceInfo(script, resource_name, 0); | 13858 CheckTryCatchSourceInfo(script, resource_name, 0); |
| 13847 | 13859 |
| 13848 resource_name = "test1.js"; | 13860 resource_name = "test1.js"; |
| 13849 v8::ScriptOrigin origin1(v8::String::New(resource_name)); | 13861 v8::ScriptOrigin origin1( |
| 13862 v8::String::NewFromUtf8(context->GetIsolate(), resource_name)); |
| 13850 script = v8::Script::Compile(source, &origin1); | 13863 script = v8::Script::Compile(source, &origin1); |
| 13851 CheckTryCatchSourceInfo(script, resource_name, 0); | 13864 CheckTryCatchSourceInfo(script, resource_name, 0); |
| 13852 | 13865 |
| 13853 resource_name = "test2.js"; | 13866 resource_name = "test2.js"; |
| 13854 v8::ScriptOrigin origin2(v8::String::New(resource_name), v8::Integer::New(7)); | 13867 v8::ScriptOrigin origin2( |
| 13868 v8::String::NewFromUtf8(context->GetIsolate(), resource_name), |
| 13869 v8::Integer::New(7)); |
| 13855 script = v8::Script::Compile(source, &origin2); | 13870 script = v8::Script::Compile(source, &origin2); |
| 13856 CheckTryCatchSourceInfo(script, resource_name, 7); | 13871 CheckTryCatchSourceInfo(script, resource_name, 7); |
| 13857 } | 13872 } |
| 13858 | 13873 |
| 13859 | 13874 |
| 13860 THREADED_TEST(CompilationCache) { | 13875 THREADED_TEST(CompilationCache) { |
| 13861 LocalContext context; | 13876 LocalContext context; |
| 13862 v8::HandleScope scope(context->GetIsolate()); | 13877 v8::HandleScope scope(context->GetIsolate()); |
| 13863 v8::Handle<v8::String> source0 = v8::String::New("1234"); | 13878 v8::Handle<v8::String> source0 = |
| 13864 v8::Handle<v8::String> source1 = v8::String::New("1234"); | 13879 v8::String::NewFromUtf8(context->GetIsolate(), "1234"); |
| 13865 v8::Handle<v8::Script> script0 = | 13880 v8::Handle<v8::String> source1 = |
| 13866 v8::Script::Compile(source0, v8::String::New("test.js")); | 13881 v8::String::NewFromUtf8(context->GetIsolate(), "1234"); |
| 13867 v8::Handle<v8::Script> script1 = | 13882 v8::Handle<v8::Script> script0 = v8::Script::Compile( |
| 13868 v8::Script::Compile(source1, v8::String::New("test.js")); | 13883 source0, v8::String::NewFromUtf8(context->GetIsolate(), "test.js")); |
| 13884 v8::Handle<v8::Script> script1 = v8::Script::Compile( |
| 13885 source1, v8::String::NewFromUtf8(context->GetIsolate(), "test.js")); |
| 13869 v8::Handle<v8::Script> script2 = | 13886 v8::Handle<v8::Script> script2 = |
| 13870 v8::Script::Compile(source0); // different origin | 13887 v8::Script::Compile(source0); // different origin |
| 13871 CHECK_EQ(1234, script0->Run()->Int32Value()); | 13888 CHECK_EQ(1234, script0->Run()->Int32Value()); |
| 13872 CHECK_EQ(1234, script1->Run()->Int32Value()); | 13889 CHECK_EQ(1234, script1->Run()->Int32Value()); |
| 13873 CHECK_EQ(1234, script2->Run()->Int32Value()); | 13890 CHECK_EQ(1234, script2->Run()->Int32Value()); |
| 13874 } | 13891 } |
| 13875 | 13892 |
| 13876 | 13893 |
| 13877 static void FunctionNameCallback( | 13894 static void FunctionNameCallback( |
| 13878 const v8::FunctionCallbackInfo<v8::Value>& args) { | 13895 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13923 for (int i = 0; i < elmc; i++) { | 13940 for (int i = 0; i < elmc; i++) { |
| 13924 v8::String::Utf8Value elm(props->Get(v8::Integer::New(i))); | 13941 v8::String::Utf8Value elm(props->Get(v8::Integer::New(i))); |
| 13925 CHECK_EQ(elmv[i], *elm); | 13942 CHECK_EQ(elmv[i], *elm); |
| 13926 } | 13943 } |
| 13927 } | 13944 } |
| 13928 | 13945 |
| 13929 | 13946 |
| 13930 THREADED_TEST(PropertyEnumeration) { | 13947 THREADED_TEST(PropertyEnumeration) { |
| 13931 LocalContext context; | 13948 LocalContext context; |
| 13932 v8::HandleScope scope(context->GetIsolate()); | 13949 v8::HandleScope scope(context->GetIsolate()); |
| 13933 v8::Handle<v8::Value> obj = v8::Script::Compile(v8::String::New( | 13950 v8::Handle<v8::Value> obj = v8::Script::Compile(v8::String::NewFromUtf8( |
| 13951 context->GetIsolate(), |
| 13934 "var result = [];" | 13952 "var result = [];" |
| 13935 "result[0] = {};" | 13953 "result[0] = {};" |
| 13936 "result[1] = {a: 1, b: 2};" | 13954 "result[1] = {a: 1, b: 2};" |
| 13937 "result[2] = [1, 2, 3];" | 13955 "result[2] = [1, 2, 3];" |
| 13938 "var proto = {x: 1, y: 2, z: 3};" | 13956 "var proto = {x: 1, y: 2, z: 3};" |
| 13939 "var x = { __proto__: proto, w: 0, z: 1 };" | 13957 "var x = { __proto__: proto, w: 0, z: 1 };" |
| 13940 "result[3] = x;" | 13958 "result[3] = x;" |
| 13941 "result;"))->Run(); | 13959 "result;"))->Run(); |
| 13942 v8::Handle<v8::Array> elms = obj.As<v8::Array>(); | 13960 v8::Handle<v8::Array> elms = obj.As<v8::Array>(); |
| 13943 CHECK_EQ(4, elms->Length()); | 13961 CHECK_EQ(4, elms->Length()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 13958 CheckProperties(elms->Get(v8::Integer::New(3)), elmc3, elmv3); | 13976 CheckProperties(elms->Get(v8::Integer::New(3)), elmc3, elmv3); |
| 13959 int elmc4 = 2; | 13977 int elmc4 = 2; |
| 13960 const char* elmv4[] = {"w", "z"}; | 13978 const char* elmv4[] = {"w", "z"}; |
| 13961 CheckOwnProperties(elms->Get(v8::Integer::New(3)), elmc4, elmv4); | 13979 CheckOwnProperties(elms->Get(v8::Integer::New(3)), elmc4, elmv4); |
| 13962 } | 13980 } |
| 13963 | 13981 |
| 13964 | 13982 |
| 13965 THREADED_TEST(PropertyEnumeration2) { | 13983 THREADED_TEST(PropertyEnumeration2) { |
| 13966 LocalContext context; | 13984 LocalContext context; |
| 13967 v8::HandleScope scope(context->GetIsolate()); | 13985 v8::HandleScope scope(context->GetIsolate()); |
| 13968 v8::Handle<v8::Value> obj = v8::Script::Compile(v8::String::New( | 13986 v8::Handle<v8::Value> obj = v8::Script::Compile(v8::String::NewFromUtf8( |
| 13987 context->GetIsolate(), |
| 13969 "var result = [];" | 13988 "var result = [];" |
| 13970 "result[0] = {};" | 13989 "result[0] = {};" |
| 13971 "result[1] = {a: 1, b: 2};" | 13990 "result[1] = {a: 1, b: 2};" |
| 13972 "result[2] = [1, 2, 3];" | 13991 "result[2] = [1, 2, 3];" |
| 13973 "var proto = {x: 1, y: 2, z: 3};" | 13992 "var proto = {x: 1, y: 2, z: 3};" |
| 13974 "var x = { __proto__: proto, w: 0, z: 1 };" | 13993 "var x = { __proto__: proto, w: 0, z: 1 };" |
| 13975 "result[3] = x;" | 13994 "result[3] = x;" |
| 13976 "result;"))->Run(); | 13995 "result;"))->Run(); |
| 13977 v8::Handle<v8::Array> elms = obj.As<v8::Array>(); | 13996 v8::Handle<v8::Array> elms = obj.As<v8::Array>(); |
| 13978 CHECK_EQ(4, elms->Length()); | 13997 CHECK_EQ(4, elms->Length()); |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14358 const int kFunctionEntrySize = i::FunctionEntry::kSize; | 14377 const int kFunctionEntrySize = i::FunctionEntry::kSize; |
| 14359 const int kFunctionEntryStartOffset = 0; | 14378 const int kFunctionEntryStartOffset = 0; |
| 14360 const int kFunctionEntryEndOffset = 1; | 14379 const int kFunctionEntryEndOffset = 1; |
| 14361 unsigned* sd_data = | 14380 unsigned* sd_data = |
| 14362 reinterpret_cast<unsigned*>(const_cast<char*>(sd->Data())); | 14381 reinterpret_cast<unsigned*>(const_cast<char*>(sd->Data())); |
| 14363 | 14382 |
| 14364 // Overwrite function bar's end position with 0. | 14383 // Overwrite function bar's end position with 0. |
| 14365 sd_data[kHeaderSize + 1 * kFunctionEntrySize + kFunctionEntryEndOffset] = 0; | 14384 sd_data[kHeaderSize + 1 * kFunctionEntrySize + kFunctionEntryEndOffset] = 0; |
| 14366 v8::TryCatch try_catch; | 14385 v8::TryCatch try_catch; |
| 14367 | 14386 |
| 14368 Local<String> source = String::New(script); | 14387 Local<String> source = String::NewFromUtf8(isolate, script); |
| 14369 Local<Script> compiled_script = Script::New(source, NULL, sd); | 14388 Local<Script> compiled_script = Script::New(source, NULL, sd); |
| 14370 CHECK(try_catch.HasCaught()); | 14389 CHECK(try_catch.HasCaught()); |
| 14371 String::Utf8Value exception_value(try_catch.Message()->Get()); | 14390 String::Utf8Value exception_value(try_catch.Message()->Get()); |
| 14372 CHECK_EQ("Uncaught SyntaxError: Invalid preparser data for function bar", | 14391 CHECK_EQ("Uncaught SyntaxError: Invalid preparser data for function bar", |
| 14373 *exception_value); | 14392 *exception_value); |
| 14374 | 14393 |
| 14375 try_catch.Reset(); | 14394 try_catch.Reset(); |
| 14376 | 14395 |
| 14377 // Overwrite function bar's start position with 200. The function entry | 14396 // Overwrite function bar's start position with 200. The function entry |
| 14378 // will not be found when searching for it by position and we should fall | 14397 // will not be found when searching for it by position and we should fall |
| (...skipping 19 matching lines...) Expand all Loading... |
| 14398 const char* cstring = "function foo(a) { return a+1; }"; | 14417 const char* cstring = "function foo(a) { return a+1; }"; |
| 14399 | 14418 |
| 14400 v8::ScriptData* sd_from_cstring = | 14419 v8::ScriptData* sd_from_cstring = |
| 14401 v8::ScriptData::PreCompile(isolate, cstring, i::StrLength(cstring)); | 14420 v8::ScriptData::PreCompile(isolate, cstring, i::StrLength(cstring)); |
| 14402 | 14421 |
| 14403 TestAsciiResource* resource = new TestAsciiResource(cstring); | 14422 TestAsciiResource* resource = new TestAsciiResource(cstring); |
| 14404 v8::ScriptData* sd_from_external_string = v8::ScriptData::PreCompile( | 14423 v8::ScriptData* sd_from_external_string = v8::ScriptData::PreCompile( |
| 14405 v8::String::NewExternal(resource)); | 14424 v8::String::NewExternal(resource)); |
| 14406 | 14425 |
| 14407 v8::ScriptData* sd_from_string = v8::ScriptData::PreCompile( | 14426 v8::ScriptData* sd_from_string = v8::ScriptData::PreCompile( |
| 14408 v8::String::New(cstring)); | 14427 v8::String::NewFromUtf8(isolate, cstring)); |
| 14409 | 14428 |
| 14410 CHECK_EQ(sd_from_cstring->Length(), sd_from_external_string->Length()); | 14429 CHECK_EQ(sd_from_cstring->Length(), sd_from_external_string->Length()); |
| 14411 CHECK_EQ(0, memcmp(sd_from_cstring->Data(), | 14430 CHECK_EQ(0, memcmp(sd_from_cstring->Data(), |
| 14412 sd_from_external_string->Data(), | 14431 sd_from_external_string->Data(), |
| 14413 sd_from_cstring->Length())); | 14432 sd_from_cstring->Length())); |
| 14414 | 14433 |
| 14415 CHECK_EQ(sd_from_cstring->Length(), sd_from_string->Length()); | 14434 CHECK_EQ(sd_from_cstring->Length(), sd_from_string->Length()); |
| 14416 CHECK_EQ(0, memcmp(sd_from_cstring->Data(), | 14435 CHECK_EQ(0, memcmp(sd_from_cstring->Data(), |
| 14417 sd_from_string->Data(), | 14436 sd_from_string->Data(), |
| 14418 sd_from_cstring->Length())); | 14437 sd_from_cstring->Length())); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14613 "/[^a-z]/.test(slice);" | 14632 "/[^a-z]/.test(slice);" |
| 14614 "/[^a-z]/.test(slice_on_cons);"); | 14633 "/[^a-z]/.test(slice_on_cons);"); |
| 14615 const char* expected_cons = | 14634 const char* expected_cons = |
| 14616 "Now is the time for all good men to come to the aid of the party" | 14635 "Now is the time for all good men to come to the aid of the party" |
| 14617 "Now is the time for all good men to come to the aid of the party"; | 14636 "Now is the time for all good men to come to the aid of the party"; |
| 14618 const char* expected_slice = | 14637 const char* expected_slice = |
| 14619 "ow is the time for all good men to come to the aid of the part"; | 14638 "ow is the time for all good men to come to the aid of the part"; |
| 14620 const char* expected_slice_on_cons = | 14639 const char* expected_slice_on_cons = |
| 14621 "ow is the time for all good men to come to the aid of the party" | 14640 "ow is the time for all good men to come to the aid of the party" |
| 14622 "Now is the time for all good men to come to the aid of the part"; | 14641 "Now is the time for all good men to come to the aid of the part"; |
| 14623 CHECK_EQ(String::New(expected_cons), | 14642 CHECK_EQ(String::NewFromUtf8(env->GetIsolate(), expected_cons), |
| 14624 env->Global()->Get(v8_str("cons"))); | 14643 env->Global()->Get(v8_str("cons"))); |
| 14625 CHECK_EQ(String::New(expected_slice), | 14644 CHECK_EQ(String::NewFromUtf8(env->GetIsolate(), expected_slice), |
| 14626 env->Global()->Get(v8_str("slice"))); | 14645 env->Global()->Get(v8_str("slice"))); |
| 14627 CHECK_EQ(String::New(expected_slice_on_cons), | 14646 CHECK_EQ(String::NewFromUtf8(env->GetIsolate(), expected_slice_on_cons), |
| 14628 env->Global()->Get(v8_str("slice_on_cons"))); | 14647 env->Global()->Get(v8_str("slice_on_cons"))); |
| 14629 } | 14648 } |
| 14630 i::DeleteArray(two_byte_string); | 14649 i::DeleteArray(two_byte_string); |
| 14631 } | 14650 } |
| 14632 | 14651 |
| 14633 | 14652 |
| 14634 TEST(CompileExternalTwoByteSource) { | 14653 TEST(CompileExternalTwoByteSource) { |
| 14635 LocalContext context; | 14654 LocalContext context; |
| 14636 v8::HandleScope scope(context->GetIsolate()); | 14655 v8::HandleScope scope(context->GetIsolate()); |
| 14637 | 14656 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14718 | 14737 |
| 14719 v8::TryCatch try_catch; | 14738 v8::TryCatch try_catch; |
| 14720 timeout_thread.Start(); | 14739 timeout_thread.Start(); |
| 14721 | 14740 |
| 14722 CompileRun("/((a*)*)*b/.exec(a)"); | 14741 CompileRun("/((a*)*)*b/.exec(a)"); |
| 14723 CHECK(try_catch.HasTerminated()); | 14742 CHECK(try_catch.HasTerminated()); |
| 14724 | 14743 |
| 14725 timeout_thread.Join(); | 14744 timeout_thread.Join(); |
| 14726 | 14745 |
| 14727 delete regexp_interruption_data.string_resource; | 14746 delete regexp_interruption_data.string_resource; |
| 14728 regexp_interruption_data.string.Dispose(); | 14747 regexp_interruption_data.string.Reset(); |
| 14729 } | 14748 } |
| 14730 | 14749 |
| 14731 #endif // V8_INTERPRETED_REGEXP | 14750 #endif // V8_INTERPRETED_REGEXP |
| 14732 | 14751 |
| 14733 | 14752 |
| 14734 // Test that we cannot set a property on the global object if there | 14753 // Test that we cannot set a property on the global object if there |
| 14735 // is a read-only property in the prototype chain. | 14754 // is a read-only property in the prototype chain. |
| 14736 TEST(ReadOnlyPropertyInGlobalProto) { | 14755 TEST(ReadOnlyPropertyInGlobalProto) { |
| 14737 i::FLAG_es5_readonly = true; | 14756 i::FLAG_es5_readonly = true; |
| 14738 v8::HandleScope scope(CcTest::isolate()); | 14757 v8::HandleScope scope(CcTest::isolate()); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14783 } | 14802 } |
| 14784 | 14803 |
| 14785 | 14804 |
| 14786 TEST(ForceSet) { | 14805 TEST(ForceSet) { |
| 14787 force_set_get_count = 0; | 14806 force_set_get_count = 0; |
| 14788 force_set_set_count = 0; | 14807 force_set_set_count = 0; |
| 14789 pass_on_get = false; | 14808 pass_on_get = false; |
| 14790 | 14809 |
| 14791 v8::HandleScope scope(CcTest::isolate()); | 14810 v8::HandleScope scope(CcTest::isolate()); |
| 14792 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); | 14811 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); |
| 14793 v8::Handle<v8::String> access_property = v8::String::New("a"); | 14812 v8::Handle<v8::String> access_property = |
| 14813 v8::String::NewFromUtf8(CcTest::isolate(), "a"); |
| 14794 templ->SetAccessor(access_property, ForceSetGetter, ForceSetSetter); | 14814 templ->SetAccessor(access_property, ForceSetGetter, ForceSetSetter); |
| 14795 LocalContext context(NULL, templ); | 14815 LocalContext context(NULL, templ); |
| 14796 v8::Handle<v8::Object> global = context->Global(); | 14816 v8::Handle<v8::Object> global = context->Global(); |
| 14797 | 14817 |
| 14798 // Ordinary properties | 14818 // Ordinary properties |
| 14799 v8::Handle<v8::String> simple_property = v8::String::New("p"); | 14819 v8::Handle<v8::String> simple_property = |
| 14820 v8::String::NewFromUtf8(CcTest::isolate(), "p"); |
| 14800 global->Set(simple_property, v8::Int32::New(4), v8::ReadOnly); | 14821 global->Set(simple_property, v8::Int32::New(4), v8::ReadOnly); |
| 14801 CHECK_EQ(4, global->Get(simple_property)->Int32Value()); | 14822 CHECK_EQ(4, global->Get(simple_property)->Int32Value()); |
| 14802 // This should fail because the property is read-only | 14823 // This should fail because the property is read-only |
| 14803 global->Set(simple_property, v8::Int32::New(5)); | 14824 global->Set(simple_property, v8::Int32::New(5)); |
| 14804 CHECK_EQ(4, global->Get(simple_property)->Int32Value()); | 14825 CHECK_EQ(4, global->Get(simple_property)->Int32Value()); |
| 14805 // This should succeed even though the property is read-only | 14826 // This should succeed even though the property is read-only |
| 14806 global->ForceSet(simple_property, v8::Int32::New(6)); | 14827 global->ForceSet(simple_property, v8::Int32::New(6)); |
| 14807 CHECK_EQ(6, global->Get(simple_property)->Int32Value()); | 14828 CHECK_EQ(6, global->Get(simple_property)->Int32Value()); |
| 14808 | 14829 |
| 14809 // Accessors | 14830 // Accessors |
| (...skipping 19 matching lines...) Expand all Loading... |
| 14829 force_set_get_count = 0; | 14850 force_set_get_count = 0; |
| 14830 force_set_set_count = 0; | 14851 force_set_set_count = 0; |
| 14831 pass_on_get = false; | 14852 pass_on_get = false; |
| 14832 | 14853 |
| 14833 v8::HandleScope scope(CcTest::isolate()); | 14854 v8::HandleScope scope(CcTest::isolate()); |
| 14834 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); | 14855 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); |
| 14835 templ->SetNamedPropertyHandler(ForceSetGetter, ForceSetInterceptSetter); | 14856 templ->SetNamedPropertyHandler(ForceSetGetter, ForceSetInterceptSetter); |
| 14836 LocalContext context(NULL, templ); | 14857 LocalContext context(NULL, templ); |
| 14837 v8::Handle<v8::Object> global = context->Global(); | 14858 v8::Handle<v8::Object> global = context->Global(); |
| 14838 | 14859 |
| 14839 v8::Handle<v8::String> some_property = v8::String::New("a"); | 14860 v8::Handle<v8::String> some_property = |
| 14861 v8::String::NewFromUtf8(CcTest::isolate(), "a"); |
| 14840 CHECK_EQ(0, force_set_set_count); | 14862 CHECK_EQ(0, force_set_set_count); |
| 14841 CHECK_EQ(0, force_set_get_count); | 14863 CHECK_EQ(0, force_set_get_count); |
| 14842 CHECK_EQ(3, global->Get(some_property)->Int32Value()); | 14864 CHECK_EQ(3, global->Get(some_property)->Int32Value()); |
| 14843 // Setting the property shouldn't override it, just call the setter | 14865 // Setting the property shouldn't override it, just call the setter |
| 14844 // which in this case does nothing. | 14866 // which in this case does nothing. |
| 14845 global->Set(some_property, v8::Int32::New(7)); | 14867 global->Set(some_property, v8::Int32::New(7)); |
| 14846 CHECK_EQ(3, global->Get(some_property)->Int32Value()); | 14868 CHECK_EQ(3, global->Get(some_property)->Int32Value()); |
| 14847 CHECK_EQ(1, force_set_set_count); | 14869 CHECK_EQ(1, force_set_set_count); |
| 14848 CHECK_EQ(2, force_set_get_count); | 14870 CHECK_EQ(2, force_set_get_count); |
| 14849 // Getting the property when the interceptor returns an empty handle | 14871 // Getting the property when the interceptor returns an empty handle |
| 14850 // should yield undefined, since the property isn't present on the | 14872 // should yield undefined, since the property isn't present on the |
| 14851 // object itself yet. | 14873 // object itself yet. |
| 14852 pass_on_get = true; | 14874 pass_on_get = true; |
| 14853 CHECK(global->Get(some_property)->IsUndefined()); | 14875 CHECK(global->Get(some_property)->IsUndefined()); |
| 14854 CHECK_EQ(1, force_set_set_count); | 14876 CHECK_EQ(1, force_set_set_count); |
| 14855 CHECK_EQ(3, force_set_get_count); | 14877 CHECK_EQ(3, force_set_get_count); |
| 14856 // Forcing the property to be set should cause the value to be | 14878 // Forcing the property to be set should cause the value to be |
| 14857 // set locally without calling the interceptor. | 14879 // set locally without calling the interceptor. |
| 14858 global->ForceSet(some_property, v8::Int32::New(8)); | 14880 global->ForceSet(some_property, v8::Int32::New(8)); |
| 14859 CHECK_EQ(8, global->Get(some_property)->Int32Value()); | 14881 CHECK_EQ(8, global->Get(some_property)->Int32Value()); |
| 14860 CHECK_EQ(1, force_set_set_count); | 14882 CHECK_EQ(1, force_set_set_count); |
| 14861 CHECK_EQ(4, force_set_get_count); | 14883 CHECK_EQ(4, force_set_get_count); |
| 14862 // Reenabling the interceptor should cause it to take precedence over | 14884 // Reenabling the interceptor should cause it to take precedence over |
| 14863 // the property | 14885 // the property |
| 14864 pass_on_get = false; | 14886 pass_on_get = false; |
| 14865 CHECK_EQ(3, global->Get(some_property)->Int32Value()); | 14887 CHECK_EQ(3, global->Get(some_property)->Int32Value()); |
| 14866 CHECK_EQ(1, force_set_set_count); | 14888 CHECK_EQ(1, force_set_set_count); |
| 14867 CHECK_EQ(5, force_set_get_count); | 14889 CHECK_EQ(5, force_set_get_count); |
| 14868 // The interceptor should also work for other properties | 14890 // The interceptor should also work for other properties |
| 14869 CHECK_EQ(3, global->Get(v8::String::New("b"))->Int32Value()); | 14891 CHECK_EQ(3, global->Get(v8::String::NewFromUtf8(CcTest::isolate(), "b")) |
| 14892 ->Int32Value()); |
| 14870 CHECK_EQ(1, force_set_set_count); | 14893 CHECK_EQ(1, force_set_set_count); |
| 14871 CHECK_EQ(6, force_set_get_count); | 14894 CHECK_EQ(6, force_set_get_count); |
| 14872 } | 14895 } |
| 14873 | 14896 |
| 14874 | 14897 |
| 14875 THREADED_TEST(ForceDelete) { | 14898 THREADED_TEST(ForceDelete) { |
| 14876 v8::HandleScope scope(CcTest::isolate()); | 14899 v8::HandleScope scope(CcTest::isolate()); |
| 14877 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); | 14900 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); |
| 14878 LocalContext context(NULL, templ); | 14901 LocalContext context(NULL, templ); |
| 14879 v8::Handle<v8::Object> global = context->Global(); | 14902 v8::Handle<v8::Object> global = context->Global(); |
| 14880 | 14903 |
| 14881 // Ordinary properties | 14904 // Ordinary properties |
| 14882 v8::Handle<v8::String> simple_property = v8::String::New("p"); | 14905 v8::Handle<v8::String> simple_property = |
| 14906 v8::String::NewFromUtf8(CcTest::isolate(), "p"); |
| 14883 global->Set(simple_property, v8::Int32::New(4), v8::DontDelete); | 14907 global->Set(simple_property, v8::Int32::New(4), v8::DontDelete); |
| 14884 CHECK_EQ(4, global->Get(simple_property)->Int32Value()); | 14908 CHECK_EQ(4, global->Get(simple_property)->Int32Value()); |
| 14885 // This should fail because the property is dont-delete. | 14909 // This should fail because the property is dont-delete. |
| 14886 CHECK(!global->Delete(simple_property)); | 14910 CHECK(!global->Delete(simple_property)); |
| 14887 CHECK_EQ(4, global->Get(simple_property)->Int32Value()); | 14911 CHECK_EQ(4, global->Get(simple_property)->Int32Value()); |
| 14888 // This should succeed even though the property is dont-delete. | 14912 // This should succeed even though the property is dont-delete. |
| 14889 CHECK(global->ForceDelete(simple_property)); | 14913 CHECK(global->ForceDelete(simple_property)); |
| 14890 CHECK(global->Get(simple_property)->IsUndefined()); | 14914 CHECK(global->Get(simple_property)->IsUndefined()); |
| 14891 } | 14915 } |
| 14892 | 14916 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 14907 THREADED_TEST(ForceDeleteWithInterceptor) { | 14931 THREADED_TEST(ForceDeleteWithInterceptor) { |
| 14908 force_delete_interceptor_count = 0; | 14932 force_delete_interceptor_count = 0; |
| 14909 pass_on_delete = false; | 14933 pass_on_delete = false; |
| 14910 | 14934 |
| 14911 v8::HandleScope scope(CcTest::isolate()); | 14935 v8::HandleScope scope(CcTest::isolate()); |
| 14912 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); | 14936 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); |
| 14913 templ->SetNamedPropertyHandler(0, 0, 0, ForceDeleteDeleter); | 14937 templ->SetNamedPropertyHandler(0, 0, 0, ForceDeleteDeleter); |
| 14914 LocalContext context(NULL, templ); | 14938 LocalContext context(NULL, templ); |
| 14915 v8::Handle<v8::Object> global = context->Global(); | 14939 v8::Handle<v8::Object> global = context->Global(); |
| 14916 | 14940 |
| 14917 v8::Handle<v8::String> some_property = v8::String::New("a"); | 14941 v8::Handle<v8::String> some_property = |
| 14942 v8::String::NewFromUtf8(CcTest::isolate(), "a"); |
| 14918 global->Set(some_property, v8::Integer::New(42), v8::DontDelete); | 14943 global->Set(some_property, v8::Integer::New(42), v8::DontDelete); |
| 14919 | 14944 |
| 14920 // Deleting a property should get intercepted and nothing should | 14945 // Deleting a property should get intercepted and nothing should |
| 14921 // happen. | 14946 // happen. |
| 14922 CHECK_EQ(0, force_delete_interceptor_count); | 14947 CHECK_EQ(0, force_delete_interceptor_count); |
| 14923 CHECK(global->Delete(some_property)); | 14948 CHECK(global->Delete(some_property)); |
| 14924 CHECK_EQ(1, force_delete_interceptor_count); | 14949 CHECK_EQ(1, force_delete_interceptor_count); |
| 14925 CHECK_EQ(42, global->Get(some_property)->Int32Value()); | 14950 CHECK_EQ(42, global->Get(some_property)->Int32Value()); |
| 14926 // Deleting the property when the interceptor returns an empty | 14951 // Deleting the property when the interceptor returns an empty |
| 14927 // handle should not delete the property since it is DontDelete. | 14952 // handle should not delete the property since it is DontDelete. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14973 v8::Local<v8::Value> foo = ctx1->Global()->Get(v8_str("foo")); | 14998 v8::Local<v8::Value> foo = ctx1->Global()->Get(v8_str("foo")); |
| 14974 ctx2->Enter(); | 14999 ctx2->Enter(); |
| 14975 ctx2->Global()->Set(v8_str("o"), foo); | 15000 ctx2->Global()->Set(v8_str("o"), foo); |
| 14976 v8::Local<v8::Value> res = CompileRun( | 15001 v8::Local<v8::Value> res = CompileRun( |
| 14977 "function f() { return o(); }" | 15002 "function f() { return o(); }" |
| 14978 "for (var i = 0; i < 10; ++i) f();" | 15003 "for (var i = 0; i < 10; ++i) f();" |
| 14979 "%OptimizeFunctionOnNextCall(f);" | 15004 "%OptimizeFunctionOnNextCall(f);" |
| 14980 "f();"); | 15005 "f();"); |
| 14981 CHECK_EQ(42, res->Int32Value()); | 15006 CHECK_EQ(42, res->Int32Value()); |
| 14982 ctx2->Exit(); | 15007 ctx2->Exit(); |
| 14983 v8::Handle<v8::String> G_property = v8::String::New("G"); | 15008 v8::Handle<v8::String> G_property = |
| 15009 v8::String::NewFromUtf8(CcTest::isolate(), "G"); |
| 14984 CHECK(ctx1->Global()->ForceDelete(G_property)); | 15010 CHECK(ctx1->Global()->ForceDelete(G_property)); |
| 14985 ctx2->Enter(); | 15011 ctx2->Enter(); |
| 14986 ExpectString( | 15012 ExpectString( |
| 14987 "(function() {" | 15013 "(function() {" |
| 14988 " try {" | 15014 " try {" |
| 14989 " return f();" | 15015 " return f();" |
| 14990 " } catch(e) {" | 15016 " } catch(e) {" |
| 14991 " return e.toString();" | 15017 " return e.toString();" |
| 14992 " }" | 15018 " }" |
| 14993 " })()", | 15019 " })()", |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15091 // Regression test for issue 398. | 15117 // Regression test for issue 398. |
| 15092 // If a function is added to an object, creating a constant function | 15118 // If a function is added to an object, creating a constant function |
| 15093 // field, and the result is cloned, replacing the constant function on the | 15119 // field, and the result is cloned, replacing the constant function on the |
| 15094 // original should not affect the clone. | 15120 // original should not affect the clone. |
| 15095 // See http://code.google.com/p/v8/issues/detail?id=398 | 15121 // See http://code.google.com/p/v8/issues/detail?id=398 |
| 15096 THREADED_TEST(ReplaceConstantFunction) { | 15122 THREADED_TEST(ReplaceConstantFunction) { |
| 15097 LocalContext context; | 15123 LocalContext context; |
| 15098 v8::HandleScope scope(context->GetIsolate()); | 15124 v8::HandleScope scope(context->GetIsolate()); |
| 15099 v8::Handle<v8::Object> obj = v8::Object::New(); | 15125 v8::Handle<v8::Object> obj = v8::Object::New(); |
| 15100 v8::Handle<v8::FunctionTemplate> func_templ = v8::FunctionTemplate::New(); | 15126 v8::Handle<v8::FunctionTemplate> func_templ = v8::FunctionTemplate::New(); |
| 15101 v8::Handle<v8::String> foo_string = v8::String::New("foo"); | 15127 v8::Handle<v8::String> foo_string = |
| 15128 v8::String::NewFromUtf8(context->GetIsolate(), "foo"); |
| 15102 obj->Set(foo_string, func_templ->GetFunction()); | 15129 obj->Set(foo_string, func_templ->GetFunction()); |
| 15103 v8::Handle<v8::Object> obj_clone = obj->Clone(); | 15130 v8::Handle<v8::Object> obj_clone = obj->Clone(); |
| 15104 obj_clone->Set(foo_string, v8::String::New("Hello")); | 15131 obj_clone->Set(foo_string, |
| 15132 v8::String::NewFromUtf8(context->GetIsolate(), "Hello")); |
| 15105 CHECK(!obj->Get(foo_string)->IsUndefined()); | 15133 CHECK(!obj->Get(foo_string)->IsUndefined()); |
| 15106 } | 15134 } |
| 15107 | 15135 |
| 15108 | 15136 |
| 15109 // Regression test for http://crbug.com/16276. | 15137 // Regression test for http://crbug.com/16276. |
| 15110 THREADED_TEST(Regress16276) { | 15138 THREADED_TEST(Regress16276) { |
| 15111 LocalContext context; | 15139 LocalContext context; |
| 15112 v8::HandleScope scope(context->GetIsolate()); | 15140 v8::HandleScope scope(context->GetIsolate()); |
| 15113 // Force the IC in f to be a dictionary load IC. | 15141 // Force the IC in f to be a dictionary load IC. |
| 15114 CompileRun("function f(obj) { return obj.x; }\n" | 15142 CompileRun("function f(obj) { return obj.x; }\n" |
| (...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16403 IS_ARRAY_BUFFER_VIEW_TEST(DataView) | 16431 IS_ARRAY_BUFFER_VIEW_TEST(DataView) |
| 16404 | 16432 |
| 16405 #undef IS_ARRAY_BUFFER_VIEW_TEST | 16433 #undef IS_ARRAY_BUFFER_VIEW_TEST |
| 16406 | 16434 |
| 16407 | 16435 |
| 16408 | 16436 |
| 16409 THREADED_TEST(ScriptContextDependence) { | 16437 THREADED_TEST(ScriptContextDependence) { |
| 16410 LocalContext c1; | 16438 LocalContext c1; |
| 16411 v8::HandleScope scope(c1->GetIsolate()); | 16439 v8::HandleScope scope(c1->GetIsolate()); |
| 16412 const char *source = "foo"; | 16440 const char *source = "foo"; |
| 16413 v8::Handle<v8::Script> dep = v8::Script::Compile(v8::String::New(source)); | 16441 v8::Handle<v8::Script> dep = |
| 16414 v8::Handle<v8::Script> indep = v8::Script::New(v8::String::New(source)); | 16442 v8::Script::Compile(v8::String::NewFromUtf8(c1->GetIsolate(), source)); |
| 16415 c1->Global()->Set(v8::String::New("foo"), v8::Integer::New(100)); | 16443 v8::Handle<v8::Script> indep = |
| 16444 v8::Script::New(v8::String::NewFromUtf8(c1->GetIsolate(), source)); |
| 16445 c1->Global()->Set(v8::String::NewFromUtf8(c1->GetIsolate(), "foo"), |
| 16446 v8::Integer::New(100)); |
| 16416 CHECK_EQ(dep->Run()->Int32Value(), 100); | 16447 CHECK_EQ(dep->Run()->Int32Value(), 100); |
| 16417 CHECK_EQ(indep->Run()->Int32Value(), 100); | 16448 CHECK_EQ(indep->Run()->Int32Value(), 100); |
| 16418 LocalContext c2; | 16449 LocalContext c2; |
| 16419 c2->Global()->Set(v8::String::New("foo"), v8::Integer::New(101)); | 16450 c2->Global()->Set(v8::String::NewFromUtf8(c2->GetIsolate(), "foo"), |
| 16451 v8::Integer::New(101)); |
| 16420 CHECK_EQ(dep->Run()->Int32Value(), 100); | 16452 CHECK_EQ(dep->Run()->Int32Value(), 100); |
| 16421 CHECK_EQ(indep->Run()->Int32Value(), 101); | 16453 CHECK_EQ(indep->Run()->Int32Value(), 101); |
| 16422 } | 16454 } |
| 16423 | 16455 |
| 16424 | 16456 |
| 16425 THREADED_TEST(StackTrace) { | 16457 THREADED_TEST(StackTrace) { |
| 16426 LocalContext context; | 16458 LocalContext context; |
| 16427 v8::HandleScope scope(context->GetIsolate()); | 16459 v8::HandleScope scope(context->GetIsolate()); |
| 16428 v8::TryCatch try_catch; | 16460 v8::TryCatch try_catch; |
| 16429 const char *source = "function foo() { FAIL.FAIL; }; foo();"; | 16461 const char *source = "function foo() { FAIL.FAIL; }; foo();"; |
| 16430 v8::Handle<v8::String> src = v8::String::New(source); | 16462 v8::Handle<v8::String> src = |
| 16431 v8::Handle<v8::String> origin = v8::String::New("stack-trace-test"); | 16463 v8::String::NewFromUtf8(context->GetIsolate(), source); |
| 16464 v8::Handle<v8::String> origin = |
| 16465 v8::String::NewFromUtf8(context->GetIsolate(), "stack-trace-test"); |
| 16432 v8::Script::New(src, origin)->Run(); | 16466 v8::Script::New(src, origin)->Run(); |
| 16433 CHECK(try_catch.HasCaught()); | 16467 CHECK(try_catch.HasCaught()); |
| 16434 v8::String::Utf8Value stack(try_catch.StackTrace()); | 16468 v8::String::Utf8Value stack(try_catch.StackTrace()); |
| 16435 CHECK(strstr(*stack, "at foo (stack-trace-test") != NULL); | 16469 CHECK(strstr(*stack, "at foo (stack-trace-test") != NULL); |
| 16436 } | 16470 } |
| 16437 | 16471 |
| 16438 | 16472 |
| 16439 // Checks that a StackFrame has certain expected values. | 16473 // Checks that a StackFrame has certain expected values. |
| 16440 void checkStackFrame(const char* expected_script_name, | 16474 void checkStackFrame(const char* expected_script_name, |
| 16441 const char* expected_func_name, int expected_line_number, | 16475 const char* expected_func_name, int expected_line_number, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16507 CHECK(stackTrace->AsArray()->IsArray()); | 16541 CHECK(stackTrace->AsArray()->IsArray()); |
| 16508 } | 16542 } |
| 16509 } | 16543 } |
| 16510 | 16544 |
| 16511 | 16545 |
| 16512 // Tests the C++ StackTrace API. | 16546 // Tests the C++ StackTrace API. |
| 16513 // TODO(3074796): Reenable this as a THREADED_TEST once it passes. | 16547 // TODO(3074796): Reenable this as a THREADED_TEST once it passes. |
| 16514 // THREADED_TEST(CaptureStackTrace) { | 16548 // THREADED_TEST(CaptureStackTrace) { |
| 16515 TEST(CaptureStackTrace) { | 16549 TEST(CaptureStackTrace) { |
| 16516 v8::HandleScope scope(CcTest::isolate()); | 16550 v8::HandleScope scope(CcTest::isolate()); |
| 16517 v8::Handle<v8::String> origin = v8::String::New("capture-stack-trace-test"); | 16551 v8::Handle<v8::String> origin = |
| 16552 v8::String::NewFromUtf8(CcTest::isolate(), "capture-stack-trace-test"); |
| 16518 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 16553 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 16519 templ->Set(v8_str("AnalyzeStackInNativeCode"), | 16554 templ->Set(v8_str("AnalyzeStackInNativeCode"), |
| 16520 v8::FunctionTemplate::New(AnalyzeStackInNativeCode)); | 16555 v8::FunctionTemplate::New(AnalyzeStackInNativeCode)); |
| 16521 LocalContext context(0, templ); | 16556 LocalContext context(0, templ); |
| 16522 | 16557 |
| 16523 // Test getting OVERVIEW information. Should ignore information that is not | 16558 // Test getting OVERVIEW information. Should ignore information that is not |
| 16524 // script name, function name, line number, and column offset. | 16559 // script name, function name, line number, and column offset. |
| 16525 const char *overview_source = | 16560 const char *overview_source = |
| 16526 "function bar() {\n" | 16561 "function bar() {\n" |
| 16527 " var y; AnalyzeStackInNativeCode(1);\n" | 16562 " var y; AnalyzeStackInNativeCode(1);\n" |
| 16528 "}\n" | 16563 "}\n" |
| 16529 "function foo() {\n" | 16564 "function foo() {\n" |
| 16530 "\n" | 16565 "\n" |
| 16531 " bar();\n" | 16566 " bar();\n" |
| 16532 "}\n" | 16567 "}\n" |
| 16533 "var x;eval('new foo();');"; | 16568 "var x;eval('new foo();');"; |
| 16534 v8::Handle<v8::String> overview_src = v8::String::New(overview_source); | 16569 v8::Handle<v8::String> overview_src = |
| 16570 v8::String::NewFromUtf8(CcTest::isolate(), overview_source); |
| 16535 v8::Handle<Value> overview_result( | 16571 v8::Handle<Value> overview_result( |
| 16536 v8::Script::New(overview_src, origin)->Run()); | 16572 v8::Script::New(overview_src, origin)->Run()); |
| 16537 CHECK(!overview_result.IsEmpty()); | 16573 CHECK(!overview_result.IsEmpty()); |
| 16538 CHECK(overview_result->IsObject()); | 16574 CHECK(overview_result->IsObject()); |
| 16539 | 16575 |
| 16540 // Test getting DETAILED information. | 16576 // Test getting DETAILED information. |
| 16541 const char *detailed_source = | 16577 const char *detailed_source = |
| 16542 "function bat() {AnalyzeStackInNativeCode(2);\n" | 16578 "function bat() {AnalyzeStackInNativeCode(2);\n" |
| 16543 "}\n" | 16579 "}\n" |
| 16544 "\n" | 16580 "\n" |
| 16545 "function baz() {\n" | 16581 "function baz() {\n" |
| 16546 " bat();\n" | 16582 " bat();\n" |
| 16547 "}\n" | 16583 "}\n" |
| 16548 "eval('new baz();');"; | 16584 "eval('new baz();');"; |
| 16549 v8::Handle<v8::String> detailed_src = v8::String::New(detailed_source); | 16585 v8::Handle<v8::String> detailed_src = |
| 16586 v8::String::NewFromUtf8(CcTest::isolate(), detailed_source); |
| 16550 // Make the script using a non-zero line and column offset. | 16587 // Make the script using a non-zero line and column offset. |
| 16551 v8::Handle<v8::Integer> line_offset = v8::Integer::New(3); | 16588 v8::Handle<v8::Integer> line_offset = v8::Integer::New(3); |
| 16552 v8::Handle<v8::Integer> column_offset = v8::Integer::New(5); | 16589 v8::Handle<v8::Integer> column_offset = v8::Integer::New(5); |
| 16553 v8::ScriptOrigin detailed_origin(origin, line_offset, column_offset); | 16590 v8::ScriptOrigin detailed_origin(origin, line_offset, column_offset); |
| 16554 v8::Handle<v8::Script> detailed_script( | 16591 v8::Handle<v8::Script> detailed_script( |
| 16555 v8::Script::New(detailed_src, &detailed_origin)); | 16592 v8::Script::New(detailed_src, &detailed_origin)); |
| 16556 v8::Handle<Value> detailed_result(detailed_script->Run()); | 16593 v8::Handle<Value> detailed_result(detailed_script->Run()); |
| 16557 CHECK(!detailed_result.IsEmpty()); | 16594 CHECK(!detailed_result.IsEmpty()); |
| 16558 CHECK(detailed_result->IsObject()); | 16595 CHECK(detailed_result->IsObject()); |
| 16559 } | 16596 } |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16803 } | 16840 } |
| 16804 | 16841 |
| 16805 | 16842 |
| 16806 TEST(ScriptIdInStackTrace) { | 16843 TEST(ScriptIdInStackTrace) { |
| 16807 v8::HandleScope scope(CcTest::isolate()); | 16844 v8::HandleScope scope(CcTest::isolate()); |
| 16808 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 16845 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 16809 templ->Set(v8_str("AnalyzeScriptIdInStack"), | 16846 templ->Set(v8_str("AnalyzeScriptIdInStack"), |
| 16810 v8::FunctionTemplate::New(AnalyzeScriptIdInStack)); | 16847 v8::FunctionTemplate::New(AnalyzeScriptIdInStack)); |
| 16811 LocalContext context(0, templ); | 16848 LocalContext context(0, templ); |
| 16812 | 16849 |
| 16813 v8::Handle<v8::String> scriptSource = v8::String::New( | 16850 v8::Handle<v8::String> scriptSource = v8::String::NewFromUtf8( |
| 16851 CcTest::isolate(), |
| 16814 "function foo() {\n" | 16852 "function foo() {\n" |
| 16815 " AnalyzeScriptIdInStack();" | 16853 " AnalyzeScriptIdInStack();" |
| 16816 "}\n" | 16854 "}\n" |
| 16817 "foo();\n"); | 16855 "foo();\n"); |
| 16818 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); | 16856 v8::ScriptOrigin origin = |
| 16857 v8::ScriptOrigin(v8::String::NewFromUtf8(CcTest::isolate(), "test")); |
| 16819 v8::Local<v8::Script> script(v8::Script::Compile(scriptSource, &origin)); | 16858 v8::Local<v8::Script> script(v8::Script::Compile(scriptSource, &origin)); |
| 16820 script->Run(); | 16859 script->Run(); |
| 16821 for (int i = 0; i < 2; i++) { | 16860 for (int i = 0; i < 2; i++) { |
| 16822 CHECK(scriptIdInStack[i] != v8::Message::kNoScriptIdInfo); | 16861 CHECK(scriptIdInStack[i] != v8::Message::kNoScriptIdInfo); |
| 16823 CHECK_EQ(scriptIdInStack[i], script->GetId()); | 16862 CHECK_EQ(scriptIdInStack[i], script->GetId()); |
| 16824 } | 16863 } |
| 16825 } | 16864 } |
| 16826 | 16865 |
| 16827 | 16866 |
| 16828 void AnalyzeStackOfInlineScriptWithSourceURL( | 16867 void AnalyzeStackOfInlineScriptWithSourceURL( |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17157 const char* string = "Some string"; | 17196 const char* string = "Some string"; |
| 17158 uint16_t* two_byte_string = AsciiToTwoByteString(string); | 17197 uint16_t* two_byte_string = AsciiToTwoByteString(string); |
| 17159 TestResource* resource[4]; | 17198 TestResource* resource[4]; |
| 17160 resource[0] = new TestResource(two_byte_string); | 17199 resource[0] = new TestResource(two_byte_string); |
| 17161 v8::Local<v8::String> string0 = v8::String::NewExternal(resource[0]); | 17200 v8::Local<v8::String> string0 = v8::String::NewExternal(resource[0]); |
| 17162 resource[1] = new TestResource(two_byte_string); | 17201 resource[1] = new TestResource(two_byte_string); |
| 17163 v8::Local<v8::String> string1 = v8::String::NewExternal(resource[1]); | 17202 v8::Local<v8::String> string1 = v8::String::NewExternal(resource[1]); |
| 17164 | 17203 |
| 17165 // Externalized symbol. | 17204 // Externalized symbol. |
| 17166 resource[2] = new TestResource(two_byte_string); | 17205 resource[2] = new TestResource(two_byte_string); |
| 17167 v8::Local<v8::String> string2 = v8::String::NewSymbol(string); | 17206 v8::Local<v8::String> string2 = v8::String::NewFromUtf8( |
| 17207 env->GetIsolate(), string, v8::String::kInternalizedString); |
| 17168 CHECK(string2->MakeExternal(resource[2])); | 17208 CHECK(string2->MakeExternal(resource[2])); |
| 17169 | 17209 |
| 17170 // Symbolized External. | 17210 // Symbolized External. |
| 17171 resource[3] = new TestResource(AsciiToTwoByteString("Some other string")); | 17211 resource[3] = new TestResource(AsciiToTwoByteString("Some other string")); |
| 17172 v8::Local<v8::String> string3 = v8::String::NewExternal(resource[3]); | 17212 v8::Local<v8::String> string3 = v8::String::NewExternal(resource[3]); |
| 17173 CcTest::heap()->CollectAllAvailableGarbage(); // Tenure string. | 17213 CcTest::heap()->CollectAllAvailableGarbage(); // Tenure string. |
| 17174 // Turn into a symbol. | 17214 // Turn into a symbol. |
| 17175 i::Handle<i::String> string3_i = v8::Utils::OpenHandle(*string3); | 17215 i::Handle<i::String> string3_i = v8::Utils::OpenHandle(*string3); |
| 17176 CHECK(!CcTest::heap()->InternalizeString(*string3_i)->IsFailure()); | 17216 CHECK(!CcTest::heap()->InternalizeString(*string3_i)->IsFailure()); |
| 17177 CHECK(string3_i->IsInternalizedString()); | 17217 CHECK(string3_i->IsInternalizedString()); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17332 tc.ReThrow(); | 17372 tc.ReThrow(); |
| 17333 } | 17373 } |
| 17334 | 17374 |
| 17335 | 17375 |
| 17336 // Test that an exception can be propagated down through a spaghetti | 17376 // Test that an exception can be propagated down through a spaghetti |
| 17337 // stack using ReThrow. | 17377 // stack using ReThrow. |
| 17338 THREADED_TEST(SpaghettiStackReThrow) { | 17378 THREADED_TEST(SpaghettiStackReThrow) { |
| 17339 v8::HandleScope scope(CcTest::isolate()); | 17379 v8::HandleScope scope(CcTest::isolate()); |
| 17340 LocalContext context; | 17380 LocalContext context; |
| 17341 context->Global()->Set( | 17381 context->Global()->Set( |
| 17342 v8::String::New("s"), | 17382 v8::String::NewFromUtf8(CcTest::isolate(), "s"), |
| 17343 v8::FunctionTemplate::New(SpaghettiIncident)->GetFunction()); | 17383 v8::FunctionTemplate::New(SpaghettiIncident)->GetFunction()); |
| 17344 v8::TryCatch try_catch; | 17384 v8::TryCatch try_catch; |
| 17345 CompileRun( | 17385 CompileRun( |
| 17346 "var i = 0;" | 17386 "var i = 0;" |
| 17347 "var o = {" | 17387 "var o = {" |
| 17348 " toString: function () {" | 17388 " toString: function () {" |
| 17349 " if (i == 10) {" | 17389 " if (i == 10) {" |
| 17350 " throw 'Hey!';" | 17390 " throw 'Hey!';" |
| 17351 " } else {" | 17391 " } else {" |
| 17352 " i++;" | 17392 " i++;" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 17373 other_context = Context::New(isolate); | 17413 other_context = Context::New(isolate); |
| 17374 | 17414 |
| 17375 // Context-dependent context data creates reference from the compilation | 17415 // Context-dependent context data creates reference from the compilation |
| 17376 // cache to the global object. | 17416 // cache to the global object. |
| 17377 const char* source_simple = "1"; | 17417 const char* source_simple = "1"; |
| 17378 { | 17418 { |
| 17379 v8::HandleScope scope(isolate); | 17419 v8::HandleScope scope(isolate); |
| 17380 v8::Local<Context> context = Context::New(isolate); | 17420 v8::Local<Context> context = Context::New(isolate); |
| 17381 | 17421 |
| 17382 context->Enter(); | 17422 context->Enter(); |
| 17383 Local<v8::String> obj = v8::String::New(""); | 17423 Local<v8::String> obj = v8::String::NewFromUtf8(isolate, ""); |
| 17384 context->SetEmbedderData(0, obj); | 17424 context->SetEmbedderData(0, obj); |
| 17385 CompileRun(source_simple); | 17425 CompileRun(source_simple); |
| 17386 context->Exit(); | 17426 context->Exit(); |
| 17387 } | 17427 } |
| 17388 v8::V8::ContextDisposedNotification(); | 17428 v8::V8::ContextDisposedNotification(); |
| 17389 for (gc_count = 1; gc_count < 10; gc_count++) { | 17429 for (gc_count = 1; gc_count < 10; gc_count++) { |
| 17390 other_context->Enter(); | 17430 other_context->Enter(); |
| 17391 CompileRun(source_simple); | 17431 CompileRun(source_simple); |
| 17392 other_context->Exit(); | 17432 other_context->Exit(); |
| 17393 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 17433 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17445 CHECK_GE(2, gc_count); | 17485 CHECK_GE(2, gc_count); |
| 17446 CHECK_EQ(1, GetGlobalObjectsCount()); | 17486 CHECK_EQ(1, GetGlobalObjectsCount()); |
| 17447 | 17487 |
| 17448 v8::V8::ContextDisposedNotification(); | 17488 v8::V8::ContextDisposedNotification(); |
| 17449 } | 17489 } |
| 17450 | 17490 |
| 17451 | 17491 |
| 17452 THREADED_TEST(ScriptOrigin) { | 17492 THREADED_TEST(ScriptOrigin) { |
| 17453 LocalContext env; | 17493 LocalContext env; |
| 17454 v8::HandleScope scope(env->GetIsolate()); | 17494 v8::HandleScope scope(env->GetIsolate()); |
| 17455 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); | 17495 v8::ScriptOrigin origin = |
| 17456 v8::Handle<v8::String> script = v8::String::New( | 17496 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test")); |
| 17457 "function f() {}\n\nfunction g() {}"); | 17497 v8::Handle<v8::String> script = v8::String::NewFromUtf8( |
| 17498 env->GetIsolate(), "function f() {}\n\nfunction g() {}"); |
| 17458 v8::Script::Compile(script, &origin)->Run(); | 17499 v8::Script::Compile(script, &origin)->Run(); |
| 17459 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( | 17500 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( |
| 17460 env->Global()->Get(v8::String::New("f"))); | 17501 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
| 17461 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( | 17502 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( |
| 17462 env->Global()->Get(v8::String::New("g"))); | 17503 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); |
| 17463 | 17504 |
| 17464 v8::ScriptOrigin script_origin_f = f->GetScriptOrigin(); | 17505 v8::ScriptOrigin script_origin_f = f->GetScriptOrigin(); |
| 17465 CHECK_EQ("test", *v8::String::Utf8Value(script_origin_f.ResourceName())); | 17506 CHECK_EQ("test", *v8::String::Utf8Value(script_origin_f.ResourceName())); |
| 17466 CHECK_EQ(0, script_origin_f.ResourceLineOffset()->Int32Value()); | 17507 CHECK_EQ(0, script_origin_f.ResourceLineOffset()->Int32Value()); |
| 17467 | 17508 |
| 17468 v8::ScriptOrigin script_origin_g = g->GetScriptOrigin(); | 17509 v8::ScriptOrigin script_origin_g = g->GetScriptOrigin(); |
| 17469 CHECK_EQ("test", *v8::String::Utf8Value(script_origin_g.ResourceName())); | 17510 CHECK_EQ("test", *v8::String::Utf8Value(script_origin_g.ResourceName())); |
| 17470 CHECK_EQ(0, script_origin_g.ResourceLineOffset()->Int32Value()); | 17511 CHECK_EQ(0, script_origin_g.ResourceLineOffset()->Int32Value()); |
| 17471 } | 17512 } |
| 17472 | 17513 |
| 17473 | 17514 |
| 17474 THREADED_TEST(FunctionGetInferredName) { | 17515 THREADED_TEST(FunctionGetInferredName) { |
| 17475 LocalContext env; | 17516 LocalContext env; |
| 17476 v8::HandleScope scope(env->GetIsolate()); | 17517 v8::HandleScope scope(env->GetIsolate()); |
| 17477 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); | 17518 v8::ScriptOrigin origin = |
| 17478 v8::Handle<v8::String> script = v8::String::New( | 17519 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test")); |
| 17520 v8::Handle<v8::String> script = v8::String::NewFromUtf8( |
| 17521 env->GetIsolate(), |
| 17479 "var foo = { bar : { baz : function() {}}}; var f = foo.bar.baz;"); | 17522 "var foo = { bar : { baz : function() {}}}; var f = foo.bar.baz;"); |
| 17480 v8::Script::Compile(script, &origin)->Run(); | 17523 v8::Script::Compile(script, &origin)->Run(); |
| 17481 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( | 17524 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( |
| 17482 env->Global()->Get(v8::String::New("f"))); | 17525 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
| 17483 CHECK_EQ("foo.bar.baz", *v8::String::Utf8Value(f->GetInferredName())); | 17526 CHECK_EQ("foo.bar.baz", *v8::String::Utf8Value(f->GetInferredName())); |
| 17484 } | 17527 } |
| 17485 | 17528 |
| 17486 | 17529 |
| 17487 THREADED_TEST(FunctionGetDisplayName) { | 17530 THREADED_TEST(FunctionGetDisplayName) { |
| 17488 LocalContext env; | 17531 LocalContext env; |
| 17489 v8::HandleScope scope(env->GetIsolate()); | 17532 v8::HandleScope scope(env->GetIsolate()); |
| 17490 const char* code = "var error = false;" | 17533 const char* code = "var error = false;" |
| 17491 "function a() { this.x = 1; };" | 17534 "function a() { this.x = 1; };" |
| 17492 "a.displayName = 'display_a';" | 17535 "a.displayName = 'display_a';" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 17513 "});" | 17556 "});" |
| 17514 "function f() {};" | 17557 "function f() {};" |
| 17515 "f.displayName = { 'foo': 6, toString: function() {" | 17558 "f.displayName = { 'foo': 6, toString: function() {" |
| 17516 " error = true;" | 17559 " error = true;" |
| 17517 " return 'wrong_display_name';" | 17560 " return 'wrong_display_name';" |
| 17518 "}};" | 17561 "}};" |
| 17519 "var g = function() {" | 17562 "var g = function() {" |
| 17520 " arguments.callee.displayName = 'set_in_runtime';" | 17563 " arguments.callee.displayName = 'set_in_runtime';" |
| 17521 "}; g();" | 17564 "}; g();" |
| 17522 ; | 17565 ; |
| 17523 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); | 17566 v8::ScriptOrigin origin = |
| 17524 v8::Script::Compile(v8::String::New(code), &origin)->Run(); | 17567 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test")); |
| 17525 v8::Local<v8::Value> error = env->Global()->Get(v8::String::New("error")); | 17568 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), code), &origin) |
| 17569 ->Run(); |
| 17570 v8::Local<v8::Value> error = |
| 17571 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "error")); |
| 17526 v8::Local<v8::Function> a = v8::Local<v8::Function>::Cast( | 17572 v8::Local<v8::Function> a = v8::Local<v8::Function>::Cast( |
| 17527 env->Global()->Get(v8::String::New("a"))); | 17573 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "a"))); |
| 17528 v8::Local<v8::Function> b = v8::Local<v8::Function>::Cast( | 17574 v8::Local<v8::Function> b = v8::Local<v8::Function>::Cast( |
| 17529 env->Global()->Get(v8::String::New("b"))); | 17575 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "b"))); |
| 17530 v8::Local<v8::Function> c = v8::Local<v8::Function>::Cast( | 17576 v8::Local<v8::Function> c = v8::Local<v8::Function>::Cast( |
| 17531 env->Global()->Get(v8::String::New("c"))); | 17577 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "c"))); |
| 17532 v8::Local<v8::Function> d = v8::Local<v8::Function>::Cast( | 17578 v8::Local<v8::Function> d = v8::Local<v8::Function>::Cast( |
| 17533 env->Global()->Get(v8::String::New("d"))); | 17579 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "d"))); |
| 17534 v8::Local<v8::Function> e = v8::Local<v8::Function>::Cast( | 17580 v8::Local<v8::Function> e = v8::Local<v8::Function>::Cast( |
| 17535 env->Global()->Get(v8::String::New("e"))); | 17581 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "e"))); |
| 17536 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( | 17582 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( |
| 17537 env->Global()->Get(v8::String::New("f"))); | 17583 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
| 17538 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( | 17584 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( |
| 17539 env->Global()->Get(v8::String::New("g"))); | 17585 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); |
| 17540 CHECK_EQ(false, error->BooleanValue()); | 17586 CHECK_EQ(false, error->BooleanValue()); |
| 17541 CHECK_EQ("display_a", *v8::String::Utf8Value(a->GetDisplayName())); | 17587 CHECK_EQ("display_a", *v8::String::Utf8Value(a->GetDisplayName())); |
| 17542 CHECK_EQ("display_b", *v8::String::Utf8Value(b->GetDisplayName())); | 17588 CHECK_EQ("display_b", *v8::String::Utf8Value(b->GetDisplayName())); |
| 17543 CHECK(c->GetDisplayName()->IsUndefined()); | 17589 CHECK(c->GetDisplayName()->IsUndefined()); |
| 17544 CHECK(d->GetDisplayName()->IsUndefined()); | 17590 CHECK(d->GetDisplayName()->IsUndefined()); |
| 17545 CHECK(e->GetDisplayName()->IsUndefined()); | 17591 CHECK(e->GetDisplayName()->IsUndefined()); |
| 17546 CHECK(f->GetDisplayName()->IsUndefined()); | 17592 CHECK(f->GetDisplayName()->IsUndefined()); |
| 17547 CHECK_EQ("set_in_runtime", *v8::String::Utf8Value(g->GetDisplayName())); | 17593 CHECK_EQ("set_in_runtime", *v8::String::Utf8Value(g->GetDisplayName())); |
| 17548 } | 17594 } |
| 17549 | 17595 |
| 17550 | 17596 |
| 17551 THREADED_TEST(ScriptLineNumber) { | 17597 THREADED_TEST(ScriptLineNumber) { |
| 17552 LocalContext env; | 17598 LocalContext env; |
| 17553 v8::HandleScope scope(env->GetIsolate()); | 17599 v8::HandleScope scope(env->GetIsolate()); |
| 17554 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); | 17600 v8::ScriptOrigin origin = |
| 17555 v8::Handle<v8::String> script = v8::String::New( | 17601 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test")); |
| 17556 "function f() {}\n\nfunction g() {}"); | 17602 v8::Handle<v8::String> script = v8::String::NewFromUtf8( |
| 17603 env->GetIsolate(), "function f() {}\n\nfunction g() {}"); |
| 17557 v8::Script::Compile(script, &origin)->Run(); | 17604 v8::Script::Compile(script, &origin)->Run(); |
| 17558 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( | 17605 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( |
| 17559 env->Global()->Get(v8::String::New("f"))); | 17606 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
| 17560 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( | 17607 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( |
| 17561 env->Global()->Get(v8::String::New("g"))); | 17608 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); |
| 17562 CHECK_EQ(0, f->GetScriptLineNumber()); | 17609 CHECK_EQ(0, f->GetScriptLineNumber()); |
| 17563 CHECK_EQ(2, g->GetScriptLineNumber()); | 17610 CHECK_EQ(2, g->GetScriptLineNumber()); |
| 17564 } | 17611 } |
| 17565 | 17612 |
| 17566 | 17613 |
| 17567 THREADED_TEST(ScriptColumnNumber) { | 17614 THREADED_TEST(ScriptColumnNumber) { |
| 17568 LocalContext env; | 17615 LocalContext env; |
| 17569 v8::HandleScope scope(env->GetIsolate()); | 17616 v8::HandleScope scope(env->GetIsolate()); |
| 17570 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test"), | 17617 v8::ScriptOrigin origin = |
| 17571 v8::Integer::New(3), v8::Integer::New(2)); | 17618 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test"), |
| 17572 v8::Handle<v8::String> script = v8::String::New( | 17619 v8::Integer::New(3), v8::Integer::New(2)); |
| 17573 "function foo() {}\n\n function bar() {}"); | 17620 v8::Handle<v8::String> script = v8::String::NewFromUtf8( |
| 17621 env->GetIsolate(), "function foo() {}\n\n function bar() {}"); |
| 17574 v8::Script::Compile(script, &origin)->Run(); | 17622 v8::Script::Compile(script, &origin)->Run(); |
| 17575 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( | 17623 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( |
| 17576 env->Global()->Get(v8::String::New("foo"))); | 17624 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))); |
| 17577 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast( | 17625 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast( |
| 17578 env->Global()->Get(v8::String::New("bar"))); | 17626 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "bar"))); |
| 17579 CHECK_EQ(14, foo->GetScriptColumnNumber()); | 17627 CHECK_EQ(14, foo->GetScriptColumnNumber()); |
| 17580 CHECK_EQ(17, bar->GetScriptColumnNumber()); | 17628 CHECK_EQ(17, bar->GetScriptColumnNumber()); |
| 17581 } | 17629 } |
| 17582 | 17630 |
| 17583 | 17631 |
| 17584 THREADED_TEST(FunctionIsBuiltin) { | 17632 THREADED_TEST(FunctionIsBuiltin) { |
| 17585 LocalContext env; | 17633 LocalContext env; |
| 17586 v8::HandleScope scope(env->GetIsolate()); | 17634 v8::HandleScope scope(env->GetIsolate()); |
| 17587 v8::Local<v8::Function> f; | 17635 v8::Local<v8::Function> f; |
| 17588 f = v8::Local<v8::Function>::Cast(CompileRun("Math.floor")); | 17636 f = v8::Local<v8::Function>::Cast(CompileRun("Math.floor")); |
| 17589 CHECK(f->IsBuiltin()); | 17637 CHECK(f->IsBuiltin()); |
| 17590 f = v8::Local<v8::Function>::Cast(CompileRun("Object")); | 17638 f = v8::Local<v8::Function>::Cast(CompileRun("Object")); |
| 17591 CHECK(f->IsBuiltin()); | 17639 CHECK(f->IsBuiltin()); |
| 17592 f = v8::Local<v8::Function>::Cast(CompileRun("Object.__defineSetter__")); | 17640 f = v8::Local<v8::Function>::Cast(CompileRun("Object.__defineSetter__")); |
| 17593 CHECK(f->IsBuiltin()); | 17641 CHECK(f->IsBuiltin()); |
| 17594 f = v8::Local<v8::Function>::Cast(CompileRun("Array.prototype.toString")); | 17642 f = v8::Local<v8::Function>::Cast(CompileRun("Array.prototype.toString")); |
| 17595 CHECK(f->IsBuiltin()); | 17643 CHECK(f->IsBuiltin()); |
| 17596 f = v8::Local<v8::Function>::Cast(CompileRun("function a() {}; a;")); | 17644 f = v8::Local<v8::Function>::Cast(CompileRun("function a() {}; a;")); |
| 17597 CHECK(!f->IsBuiltin()); | 17645 CHECK(!f->IsBuiltin()); |
| 17598 } | 17646 } |
| 17599 | 17647 |
| 17600 | 17648 |
| 17601 THREADED_TEST(FunctionGetScriptId) { | 17649 THREADED_TEST(FunctionGetScriptId) { |
| 17602 LocalContext env; | 17650 LocalContext env; |
| 17603 v8::HandleScope scope(env->GetIsolate()); | 17651 v8::HandleScope scope(env->GetIsolate()); |
| 17604 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test"), | 17652 v8::ScriptOrigin origin = |
| 17605 v8::Integer::New(3), v8::Integer::New(2)); | 17653 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test"), |
| 17606 v8::Handle<v8::String> scriptSource = v8::String::New( | 17654 v8::Integer::New(3), v8::Integer::New(2)); |
| 17607 "function foo() {}\n\n function bar() {}"); | 17655 v8::Handle<v8::String> scriptSource = v8::String::NewFromUtf8( |
| 17656 env->GetIsolate(), "function foo() {}\n\n function bar() {}"); |
| 17608 v8::Local<v8::Script> script(v8::Script::Compile(scriptSource, &origin)); | 17657 v8::Local<v8::Script> script(v8::Script::Compile(scriptSource, &origin)); |
| 17609 script->Run(); | 17658 script->Run(); |
| 17610 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( | 17659 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( |
| 17611 env->Global()->Get(v8::String::New("foo"))); | 17660 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))); |
| 17612 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast( | 17661 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast( |
| 17613 env->Global()->Get(v8::String::New("bar"))); | 17662 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "bar"))); |
| 17614 CHECK_EQ(script->Id(), foo->GetScriptId()); | 17663 CHECK_EQ(script->GetId(), foo->ScriptId()); |
| 17615 CHECK_EQ(script->Id(), bar->GetScriptId()); | 17664 CHECK_EQ(script->GetId(), bar->ScriptId()); |
| 17616 } | 17665 } |
| 17617 | 17666 |
| 17618 | 17667 |
| 17619 static void GetterWhichReturns42( | 17668 static void GetterWhichReturns42( |
| 17620 Local<String> name, | 17669 Local<String> name, |
| 17621 const v8::PropertyCallbackInfo<v8::Value>& info) { | 17670 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 17622 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); | 17671 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); |
| 17623 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); | 17672 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); |
| 17624 info.GetReturnValue().Set(v8_num(42)); | 17673 info.GetReturnValue().Set(v8_num(42)); |
| 17625 } | 17674 } |
| (...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18401 { | 18450 { |
| 18402 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 18451 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 18403 v8::Local<v8::Context> context = | 18452 v8::Local<v8::Context> context = |
| 18404 v8::Local<v8::Context>::New(v8::Isolate::GetCurrent(), context1); | 18453 v8::Local<v8::Context>::New(v8::Isolate::GetCurrent(), context1); |
| 18405 v8::Context::Scope context_scope(context); | 18454 v8::Context::Scope context_scope(context); |
| 18406 ExpectString("function f() { return foo; }; f()", "isolate 1"); | 18455 ExpectString("function f() { return foo; }; f()", "isolate 1"); |
| 18407 } | 18456 } |
| 18408 | 18457 |
| 18409 { | 18458 { |
| 18410 v8::Isolate::Scope iscope(isolate2); | 18459 v8::Isolate::Scope iscope(isolate2); |
| 18411 context2.Dispose(); | 18460 context2.Reset(); |
| 18412 } | 18461 } |
| 18413 | 18462 |
| 18414 context1.Dispose(); | 18463 context1.Reset(); |
| 18415 isolate1->Exit(); | 18464 isolate1->Exit(); |
| 18416 | 18465 |
| 18417 v8::V8::SetFatalErrorHandler(StoringErrorCallback); | 18466 v8::V8::SetFatalErrorHandler(StoringErrorCallback); |
| 18418 last_location = last_message = NULL; | 18467 last_location = last_message = NULL; |
| 18419 | 18468 |
| 18420 isolate1->Dispose(); | 18469 isolate1->Dispose(); |
| 18421 CHECK_EQ(last_location, NULL); | 18470 CHECK_EQ(last_location, NULL); |
| 18422 CHECK_EQ(last_message, NULL); | 18471 CHECK_EQ(last_message, NULL); |
| 18423 | 18472 |
| 18424 isolate2->Dispose(); | 18473 isolate2->Dispose(); |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18819 v8::HandleScope scope(isolate); | 18868 v8::HandleScope scope(isolate); |
| 18820 v8::Persistent<v8::Object> object(isolate, v8::Object::New()); | 18869 v8::Persistent<v8::Object> object(isolate, v8::Object::New()); |
| 18821 CHECK_EQ(0, object.WrapperClassId()); | 18870 CHECK_EQ(0, object.WrapperClassId()); |
| 18822 object.SetWrapperClassId(42); | 18871 object.SetWrapperClassId(42); |
| 18823 CHECK_EQ(42, object.WrapperClassId()); | 18872 CHECK_EQ(42, object.WrapperClassId()); |
| 18824 | 18873 |
| 18825 Visitor42 visitor(&object); | 18874 Visitor42 visitor(&object); |
| 18826 v8::V8::VisitHandlesWithClassIds(&visitor); | 18875 v8::V8::VisitHandlesWithClassIds(&visitor); |
| 18827 CHECK_EQ(1, visitor.counter_); | 18876 CHECK_EQ(1, visitor.counter_); |
| 18828 | 18877 |
| 18829 object.Dispose(); | 18878 object.Reset(); |
| 18830 } | 18879 } |
| 18831 | 18880 |
| 18832 | 18881 |
| 18833 TEST(WrapperClassId) { | 18882 TEST(WrapperClassId) { |
| 18834 LocalContext context; | 18883 LocalContext context; |
| 18835 v8::Isolate* isolate = context->GetIsolate(); | 18884 v8::Isolate* isolate = context->GetIsolate(); |
| 18836 v8::HandleScope scope(isolate); | 18885 v8::HandleScope scope(isolate); |
| 18837 v8::Persistent<v8::Object> object(isolate, v8::Object::New()); | 18886 v8::Persistent<v8::Object> object(isolate, v8::Object::New()); |
| 18838 CHECK_EQ(0, object.WrapperClassId()); | 18887 CHECK_EQ(0, object.WrapperClassId()); |
| 18839 object.SetWrapperClassId(65535); | 18888 object.SetWrapperClassId(65535); |
| 18840 CHECK_EQ(65535, object.WrapperClassId()); | 18889 CHECK_EQ(65535, object.WrapperClassId()); |
| 18841 object.Dispose(); | 18890 object.Reset(); |
| 18842 } | 18891 } |
| 18843 | 18892 |
| 18844 | 18893 |
| 18845 TEST(PersistentHandleInNewSpaceVisitor) { | 18894 TEST(PersistentHandleInNewSpaceVisitor) { |
| 18846 LocalContext context; | 18895 LocalContext context; |
| 18847 v8::Isolate* isolate = context->GetIsolate(); | 18896 v8::Isolate* isolate = context->GetIsolate(); |
| 18848 v8::HandleScope scope(isolate); | 18897 v8::HandleScope scope(isolate); |
| 18849 v8::Persistent<v8::Object> object1(isolate, v8::Object::New()); | 18898 v8::Persistent<v8::Object> object1(isolate, v8::Object::New()); |
| 18850 CHECK_EQ(0, object1.WrapperClassId()); | 18899 CHECK_EQ(0, object1.WrapperClassId()); |
| 18851 object1.SetWrapperClassId(42); | 18900 object1.SetWrapperClassId(42); |
| 18852 CHECK_EQ(42, object1.WrapperClassId()); | 18901 CHECK_EQ(42, object1.WrapperClassId()); |
| 18853 | 18902 |
| 18854 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 18903 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 18855 | 18904 |
| 18856 v8::Persistent<v8::Object> object2(isolate, v8::Object::New()); | 18905 v8::Persistent<v8::Object> object2(isolate, v8::Object::New()); |
| 18857 CHECK_EQ(0, object2.WrapperClassId()); | 18906 CHECK_EQ(0, object2.WrapperClassId()); |
| 18858 object2.SetWrapperClassId(42); | 18907 object2.SetWrapperClassId(42); |
| 18859 CHECK_EQ(42, object2.WrapperClassId()); | 18908 CHECK_EQ(42, object2.WrapperClassId()); |
| 18860 | 18909 |
| 18861 Visitor42 visitor(&object2); | 18910 Visitor42 visitor(&object2); |
| 18862 v8::V8::VisitHandlesForPartialDependence(isolate, &visitor); | 18911 v8::V8::VisitHandlesForPartialDependence(isolate, &visitor); |
| 18863 CHECK_EQ(1, visitor.counter_); | 18912 CHECK_EQ(1, visitor.counter_); |
| 18864 | 18913 |
| 18865 object1.Dispose(); | 18914 object1.Reset(); |
| 18866 object2.Dispose(); | 18915 object2.Reset(); |
| 18867 } | 18916 } |
| 18868 | 18917 |
| 18869 | 18918 |
| 18870 TEST(RegExp) { | 18919 TEST(RegExp) { |
| 18871 LocalContext context; | 18920 LocalContext context; |
| 18872 v8::HandleScope scope(context->GetIsolate()); | 18921 v8::HandleScope scope(context->GetIsolate()); |
| 18873 | 18922 |
| 18874 v8::Handle<v8::RegExp> re = v8::RegExp::New(v8_str("foo"), v8::RegExp::kNone); | 18923 v8::Handle<v8::RegExp> re = v8::RegExp::New(v8_str("foo"), v8::RegExp::kNone); |
| 18875 CHECK(re->IsRegExp()); | 18924 CHECK(re->IsRegExp()); |
| 18876 CHECK(re->GetSource()->Equals(v8_str("foo"))); | 18925 CHECK(re->GetSource()->Equals(v8_str("foo"))); |
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19671 v8::HandleScope scope(env->GetIsolate()); | 19720 v8::HandleScope scope(env->GetIsolate()); |
| 19672 v8::Handle<v8::FunctionTemplate> recursive_runtime = | 19721 v8::Handle<v8::FunctionTemplate> recursive_runtime = |
| 19673 v8::FunctionTemplate::New(RecursiveCall); | 19722 v8::FunctionTemplate::New(RecursiveCall); |
| 19674 env->Global()->Set(v8_str("recursion"), | 19723 env->Global()->Set(v8_str("recursion"), |
| 19675 recursive_runtime->GetFunction()); | 19724 recursive_runtime->GetFunction()); |
| 19676 // Adding the same callback a second time has no effect. | 19725 // Adding the same callback a second time has no effect. |
| 19677 v8::V8::AddCallCompletedCallback(CallCompletedCallback1); | 19726 v8::V8::AddCallCompletedCallback(CallCompletedCallback1); |
| 19678 v8::V8::AddCallCompletedCallback(CallCompletedCallback1); | 19727 v8::V8::AddCallCompletedCallback(CallCompletedCallback1); |
| 19679 v8::V8::AddCallCompletedCallback(CallCompletedCallback2); | 19728 v8::V8::AddCallCompletedCallback(CallCompletedCallback2); |
| 19680 i::OS::Print("--- Script (1) ---\n"); | 19729 i::OS::Print("--- Script (1) ---\n"); |
| 19681 Local<Script> script = | 19730 Local<Script> script = v8::Script::Compile( |
| 19682 v8::Script::Compile(v8::String::New("recursion(0)")); | 19731 v8::String::NewFromUtf8(env->GetIsolate(), "recursion(0)")); |
| 19683 script->Run(); | 19732 script->Run(); |
| 19684 CHECK_EQ(3, callback_fired); | 19733 CHECK_EQ(3, callback_fired); |
| 19685 | 19734 |
| 19686 i::OS::Print("\n--- Script (2) ---\n"); | 19735 i::OS::Print("\n--- Script (2) ---\n"); |
| 19687 callback_fired = 0; | 19736 callback_fired = 0; |
| 19688 v8::V8::RemoveCallCompletedCallback(CallCompletedCallback1); | 19737 v8::V8::RemoveCallCompletedCallback(CallCompletedCallback1); |
| 19689 script->Run(); | 19738 script->Run(); |
| 19690 CHECK_EQ(2, callback_fired); | 19739 CHECK_EQ(2, callback_fired); |
| 19691 | 19740 |
| 19692 i::OS::Print("\n--- Function ---\n"); | 19741 i::OS::Print("\n--- Function ---\n"); |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20285 Local<Object> map_object(Local<Object>::Cast(map_value)); | 20334 Local<Object> map_object(Local<Object>::Cast(map_value)); |
| 20286 CHECK_EQ(0, map_object->InternalFieldCount()); | 20335 CHECK_EQ(0, map_object->InternalFieldCount()); |
| 20287 } | 20336 } |
| 20288 | 20337 |
| 20289 | 20338 |
| 20290 THREADED_TEST(Regress2746) { | 20339 THREADED_TEST(Regress2746) { |
| 20291 LocalContext context; | 20340 LocalContext context; |
| 20292 v8::Isolate* isolate = context->GetIsolate(); | 20341 v8::Isolate* isolate = context->GetIsolate(); |
| 20293 v8::HandleScope scope(isolate); | 20342 v8::HandleScope scope(isolate); |
| 20294 Local<Object> obj = Object::New(); | 20343 Local<Object> obj = Object::New(); |
| 20295 Local<String> key = String::New("key"); | 20344 Local<String> key = String::NewFromUtf8(context->GetIsolate(), "key"); |
| 20296 obj->SetHiddenValue(key, v8::Undefined(isolate)); | 20345 obj->SetHiddenValue(key, v8::Undefined(isolate)); |
| 20297 Local<Value> value = obj->GetHiddenValue(key); | 20346 Local<Value> value = obj->GetHiddenValue(key); |
| 20298 CHECK(!value.IsEmpty()); | 20347 CHECK(!value.IsEmpty()); |
| 20299 CHECK(value->IsUndefined()); | 20348 CHECK(value->IsUndefined()); |
| 20300 } | 20349 } |
| 20301 | 20350 |
| 20302 | 20351 |
| 20303 THREADED_TEST(Regress260106) { | 20352 THREADED_TEST(Regress260106) { |
| 20304 LocalContext context; | 20353 LocalContext context; |
| 20305 v8::HandleScope scope(context->GetIsolate()); | 20354 v8::HandleScope scope(context->GetIsolate()); |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20731 } | 20780 } |
| 20732 for (int i = 0; i < runs; i++) { | 20781 for (int i = 0; i < runs; i++) { |
| 20733 Local<String> expected; | 20782 Local<String> expected; |
| 20734 if (i != 0) { | 20783 if (i != 0) { |
| 20735 CHECK_EQ(v8_str("escape value"), values[i]); | 20784 CHECK_EQ(v8_str("escape value"), values[i]); |
| 20736 } else { | 20785 } else { |
| 20737 CHECK(values[i].IsEmpty()); | 20786 CHECK(values[i].IsEmpty()); |
| 20738 } | 20787 } |
| 20739 } | 20788 } |
| 20740 } | 20789 } |
| OLD | NEW |