| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 TEST(NativeAccessorUninitializedIC) { | 711 TEST(NativeAccessorUninitializedIC) { |
| 712 LocalContext env; | 712 LocalContext env; |
| 713 v8::HandleScope scope(env->GetIsolate()); | 713 v8::HandleScope scope(env->GetIsolate()); |
| 714 | 714 |
| 715 | 715 |
| 716 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(); | 716 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(); |
| 717 v8::Local<v8::ObjectTemplate> instance_template = | 717 v8::Local<v8::ObjectTemplate> instance_template = |
| 718 func_template->InstanceTemplate(); | 718 func_template->InstanceTemplate(); |
| 719 | 719 |
| 720 TestApiCallbacks accessors(100); | 720 TestApiCallbacks accessors(100); |
| 721 v8::Local<v8::External> data = v8::External::New(&accessors); | 721 v8::Local<v8::External> data = |
| 722 v8::External::New(env->GetIsolate(), &accessors); |
| 722 instance_template->SetAccessor( | 723 instance_template->SetAccessor( |
| 723 v8::String::New("foo"), &TestApiCallbacks::Getter, | 724 v8::String::New("foo"), &TestApiCallbacks::Getter, |
| 724 &TestApiCallbacks::Setter, data); | 725 &TestApiCallbacks::Setter, data); |
| 725 v8::Local<v8::Function> func = func_template->GetFunction(); | 726 v8::Local<v8::Function> func = func_template->GetFunction(); |
| 726 v8::Local<v8::Object> instance = func->NewInstance(); | 727 v8::Local<v8::Object> instance = func->NewInstance(); |
| 727 env->Global()->Set(v8::String::New("instance"), instance); | 728 env->Global()->Set(v8::String::New("instance"), instance); |
| 728 | 729 |
| 729 v8::Script::Compile(v8::String::New(native_accessor_test_source))->Run(); | 730 v8::Script::Compile(v8::String::New(native_accessor_test_source))->Run(); |
| 730 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 731 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
| 731 env->Global()->Get(v8::String::New("start"))); | 732 env->Global()->Get(v8::String::New("start"))); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 751 TEST(NativeAccessorMonomorphicIC) { | 752 TEST(NativeAccessorMonomorphicIC) { |
| 752 LocalContext env; | 753 LocalContext env; |
| 753 v8::HandleScope scope(env->GetIsolate()); | 754 v8::HandleScope scope(env->GetIsolate()); |
| 754 | 755 |
| 755 | 756 |
| 756 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(); | 757 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(); |
| 757 v8::Local<v8::ObjectTemplate> instance_template = | 758 v8::Local<v8::ObjectTemplate> instance_template = |
| 758 func_template->InstanceTemplate(); | 759 func_template->InstanceTemplate(); |
| 759 | 760 |
| 760 TestApiCallbacks accessors(1); | 761 TestApiCallbacks accessors(1); |
| 761 v8::Local<v8::External> data = v8::External::New(&accessors); | 762 v8::Local<v8::External> data = |
| 763 v8::External::New(env->GetIsolate(), &accessors); |
| 762 instance_template->SetAccessor( | 764 instance_template->SetAccessor( |
| 763 v8::String::New("foo"), &TestApiCallbacks::Getter, | 765 v8::String::New("foo"), &TestApiCallbacks::Getter, |
| 764 &TestApiCallbacks::Setter, data); | 766 &TestApiCallbacks::Setter, data); |
| 765 v8::Local<v8::Function> func = func_template->GetFunction(); | 767 v8::Local<v8::Function> func = func_template->GetFunction(); |
| 766 v8::Local<v8::Object> instance = func->NewInstance(); | 768 v8::Local<v8::Object> instance = func->NewInstance(); |
| 767 env->Global()->Set(v8::String::New("instance"), instance); | 769 env->Global()->Set(v8::String::New("instance"), instance); |
| 768 | 770 |
| 769 v8::Script::Compile(v8::String::New(native_accessor_test_source))->Run(); | 771 v8::Script::Compile(v8::String::New(native_accessor_test_source))->Run(); |
| 770 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 772 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
| 771 env->Global()->Get(v8::String::New("start"))); | 773 env->Global()->Get(v8::String::New("start"))); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 800 " instance.fooMethod();\n" | 802 " instance.fooMethod();\n" |
| 801 " }\n" | 803 " }\n" |
| 802 "}\n"; | 804 "}\n"; |
| 803 | 805 |
| 804 | 806 |
| 805 TEST(NativeMethodUninitializedIC) { | 807 TEST(NativeMethodUninitializedIC) { |
| 806 LocalContext env; | 808 LocalContext env; |
| 807 v8::HandleScope scope(env->GetIsolate()); | 809 v8::HandleScope scope(env->GetIsolate()); |
| 808 | 810 |
| 809 TestApiCallbacks callbacks(100); | 811 TestApiCallbacks callbacks(100); |
| 810 v8::Local<v8::External> data = v8::External::New(&callbacks); | 812 v8::Local<v8::External> data = |
| 813 v8::External::New(env->GetIsolate(), &callbacks); |
| 811 | 814 |
| 812 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(); | 815 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(); |
| 813 func_template->SetClassName(v8::String::New("Test_InstanceCostructor")); | 816 func_template->SetClassName(v8::String::New("Test_InstanceCostructor")); |
| 814 v8::Local<v8::ObjectTemplate> proto_template = | 817 v8::Local<v8::ObjectTemplate> proto_template = |
| 815 func_template->PrototypeTemplate(); | 818 func_template->PrototypeTemplate(); |
| 816 v8::Local<v8::Signature> signature = v8::Signature::New(func_template); | 819 v8::Local<v8::Signature> signature = v8::Signature::New(func_template); |
| 817 proto_template->Set(v8::String::New("fooMethod"), v8::FunctionTemplate::New( | 820 proto_template->Set(v8::String::New("fooMethod"), v8::FunctionTemplate::New( |
| 818 &TestApiCallbacks::Callback, data, signature, 0)); | 821 &TestApiCallbacks::Callback, data, signature, 0)); |
| 819 | 822 |
| 820 v8::Local<v8::Function> func = func_template->GetFunction(); | 823 v8::Local<v8::Function> func = func_template->GetFunction(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 837 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); | 840 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); |
| 838 cpu_profiler->DeleteAllCpuProfiles(); | 841 cpu_profiler->DeleteAllCpuProfiles(); |
| 839 } | 842 } |
| 840 | 843 |
| 841 | 844 |
| 842 TEST(NativeMethodMonomorphicIC) { | 845 TEST(NativeMethodMonomorphicIC) { |
| 843 LocalContext env; | 846 LocalContext env; |
| 844 v8::HandleScope scope(env->GetIsolate()); | 847 v8::HandleScope scope(env->GetIsolate()); |
| 845 | 848 |
| 846 TestApiCallbacks callbacks(1); | 849 TestApiCallbacks callbacks(1); |
| 847 v8::Local<v8::External> data = v8::External::New(&callbacks); | 850 v8::Local<v8::External> data = |
| 851 v8::External::New(env->GetIsolate(), &callbacks); |
| 848 | 852 |
| 849 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(); | 853 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(); |
| 850 func_template->SetClassName(v8::String::New("Test_InstanceCostructor")); | 854 func_template->SetClassName(v8::String::New("Test_InstanceCostructor")); |
| 851 v8::Local<v8::ObjectTemplate> proto_template = | 855 v8::Local<v8::ObjectTemplate> proto_template = |
| 852 func_template->PrototypeTemplate(); | 856 func_template->PrototypeTemplate(); |
| 853 v8::Local<v8::Signature> signature = v8::Signature::New(func_template); | 857 v8::Local<v8::Signature> signature = v8::Signature::New(func_template); |
| 854 proto_template->Set(v8::String::New("fooMethod"), v8::FunctionTemplate::New( | 858 proto_template->Set(v8::String::New("fooMethod"), v8::FunctionTemplate::New( |
| 855 &TestApiCallbacks::Callback, data, signature, 0)); | 859 &TestApiCallbacks::Callback, data, signature, 0)); |
| 856 | 860 |
| 857 v8::Local<v8::Function> func = func_template->GetFunction(); | 861 v8::Local<v8::Function> func = func_template->GetFunction(); |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1433 ProfileGenerator::kAnonymousFunctionName); | 1437 ProfileGenerator::kAnonymousFunctionName); |
| 1434 CheckFunctionDetails(script, ProfileGenerator::kAnonymousFunctionName, | 1438 CheckFunctionDetails(script, ProfileGenerator::kAnonymousFunctionName, |
| 1435 "script_b", script_b->GetId(), 1, 1); | 1439 "script_b", script_b->GetId(), 1, 1); |
| 1436 const v8::CpuProfileNode* baz = GetChild(script, "baz"); | 1440 const v8::CpuProfileNode* baz = GetChild(script, "baz"); |
| 1437 CheckFunctionDetails(baz, "baz", "script_b", script_b->GetId(), 3, 16); | 1441 CheckFunctionDetails(baz, "baz", "script_b", script_b->GetId(), 3, 16); |
| 1438 const v8::CpuProfileNode* foo = GetChild(baz, "foo"); | 1442 const v8::CpuProfileNode* foo = GetChild(baz, "foo"); |
| 1439 CheckFunctionDetails(foo, "foo", "script_a", script_a->GetId(), 2, 1); | 1443 CheckFunctionDetails(foo, "foo", "script_a", script_a->GetId(), 2, 1); |
| 1440 const v8::CpuProfileNode* bar = GetChild(foo, "bar"); | 1444 const v8::CpuProfileNode* bar = GetChild(foo, "bar"); |
| 1441 CheckFunctionDetails(bar, "bar", "script_a", script_a->GetId(), 3, 14); | 1445 CheckFunctionDetails(bar, "bar", "script_a", script_a->GetId(), 3, 14); |
| 1442 } | 1446 } |
| OLD | NEW |