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

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

Issue 17059005: Make sure ExternalCallbackScope is always created when VM state changes to EXTERNAL (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/stub-cache.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 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 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 LocalContext env; 1067 LocalContext env;
1068 v8::HandleScope scope(env->GetIsolate()); 1068 v8::HandleScope scope(env->GetIsolate());
1069 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New(); 1069 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New();
1070 v8::FunctionCallback callback = &FastReturnValueCallback<T>; 1070 v8::FunctionCallback callback = &FastReturnValueCallback<T>;
1071 object_template->Set("callback", v8::FunctionTemplate::New(callback)); 1071 object_template->Set("callback", v8::FunctionTemplate::New(callback));
1072 v8::Local<v8::Object> object = object_template->NewInstance(); 1072 v8::Local<v8::Object> object = object_template->NewInstance();
1073 (*env)->Global()->Set(v8_str("callback_object"), object); 1073 (*env)->Global()->Set(v8_str("callback_object"), object);
1074 return scope.Close(CompileRun("callback_object.callback()")); 1074 return scope.Close(CompileRun("callback_object.callback()"));
1075 } 1075 }
1076 1076
1077 THREADED_TEST(FastReturnValues) { 1077 THREADED_PROFILED_TEST(FastReturnValues) {
1078 LocalContext env; 1078 LocalContext env;
1079 v8::HandleScope scope(v8::Isolate::GetCurrent()); 1079 v8::HandleScope scope(v8::Isolate::GetCurrent());
1080 v8::Handle<v8::Value> value; 1080 v8::Handle<v8::Value> value;
1081 // check int32_t and uint32_t 1081 // check int32_t and uint32_t
1082 int32_t int_values[] = { 1082 int32_t int_values[] = {
1083 0, 234, -723, 1083 0, 234, -723,
1084 i::Smi::kMinValue, i::Smi::kMaxValue 1084 i::Smi::kMinValue, i::Smi::kMaxValue
1085 }; 1085 };
1086 for (size_t i = 0; i < ARRAY_SIZE(int_values); i++) { 1086 for (size_t i = 0; i < ARRAY_SIZE(int_values); i++) {
1087 for (int modifier = -1; modifier <= 1; modifier++) { 1087 for (int modifier = -1; modifier <= 1; modifier++) {
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
2095 2095
2096 2096
2097 void CheckThisNamedPropertyEnumerator( 2097 void CheckThisNamedPropertyEnumerator(
2098 const v8::PropertyCallbackInfo<v8::Array>& info) { 2098 const v8::PropertyCallbackInfo<v8::Array>& info) {
2099 CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertyEnumerator)); 2099 CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertyEnumerator));
2100 ApiTestFuzzer::Fuzz(); 2100 ApiTestFuzzer::Fuzz();
2101 CHECK(info.This()->Equals(bottom)); 2101 CHECK(info.This()->Equals(bottom));
2102 } 2102 }
2103 2103
2104 2104
2105 THREADED_TEST(PropertyHandlerInPrototype) { 2105 THREADED_PROFILED_TEST(PropertyHandlerInPrototype) {
2106 LocalContext env; 2106 LocalContext env;
2107 v8::HandleScope scope(env->GetIsolate()); 2107 v8::HandleScope scope(env->GetIsolate());
2108 2108
2109 // Set up a prototype chain with three interceptors. 2109 // Set up a prototype chain with three interceptors.
2110 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); 2110 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
2111 templ->InstanceTemplate()->SetIndexedPropertyHandler( 2111 templ->InstanceTemplate()->SetIndexedPropertyHandler(
2112 CheckThisIndexedPropertyHandler, 2112 CheckThisIndexedPropertyHandler,
2113 CheckThisIndexedPropertySetter, 2113 CheckThisIndexedPropertySetter,
2114 CheckThisIndexedPropertyQuery, 2114 CheckThisIndexedPropertyQuery,
2115 CheckThisIndexedPropertyDeleter, 2115 CheckThisIndexedPropertyDeleter,
(...skipping 8634 matching lines...) Expand 10 before | Expand all | Expand 10 after
10750 v8::Handle<v8::Value> result = CompileRun( 10750 v8::Handle<v8::Value> result = CompileRun(
10751 "function f() {" 10751 "function f() {"
10752 " for (var i = 0; i < 30; i++) o1.p1;" 10752 " for (var i = 0; i < 30; i++) o1.p1;"
10753 " return o1.p1" 10753 " return o1.p1"
10754 "}" 10754 "}"
10755 "f();"); 10755 "f();");
10756 CHECK_EQ(v8_str("Direct Getter Result"), result); 10756 CHECK_EQ(v8_str("Direct Getter Result"), result);
10757 CHECK_EQ(31, p_getter_count); 10757 CHECK_EQ(31, p_getter_count);
10758 } 10758 }
10759 10759
10760 THREADED_TEST(LoadICFastApi_DirectCall_GCMoveStub) { 10760 THREADED_PROFILED_TEST(LoadICFastApi_DirectCall_GCMoveStub) {
10761 LoadICFastApi_DirectCall_GCMoveStub(DirectGetterCallback); 10761 LoadICFastApi_DirectCall_GCMoveStub(DirectGetterCallback);
10762 } 10762 }
10763 10763
10764 10764
10765 void ThrowingDirectGetterCallback( 10765 void ThrowingDirectGetterCallback(
10766 Local<String> name, 10766 Local<String> name,
10767 const v8::PropertyCallbackInfo<v8::Value>& info) { 10767 const v8::PropertyCallbackInfo<v8::Value>& info) {
10768 v8::ThrowException(v8_str("g")); 10768 v8::ThrowException(v8_str("g"));
10769 } 10769 }
10770 10770
10771 10771
10772 THREADED_TEST(LoadICFastApi_DirectCall_Throw) { 10772 THREADED_TEST(LoadICFastApi_DirectCall_Throw) {
10773 LocalContext context; 10773 LocalContext context;
10774 v8::HandleScope scope(context->GetIsolate()); 10774 v8::HandleScope scope(context->GetIsolate());
10775 v8::Handle<v8::ObjectTemplate> obj = v8::ObjectTemplate::New(); 10775 v8::Handle<v8::ObjectTemplate> obj = v8::ObjectTemplate::New();
10776 obj->SetAccessor(v8_str("p1"), ThrowingDirectGetterCallback); 10776 obj->SetAccessor(v8_str("p1"), ThrowingDirectGetterCallback);
10777 context->Global()->Set(v8_str("o1"), obj->NewInstance()); 10777 context->Global()->Set(v8_str("o1"), obj->NewInstance());
10778 v8::Handle<Value> result = CompileRun( 10778 v8::Handle<Value> result = CompileRun(
10779 "var result = '';" 10779 "var result = '';"
10780 "for (var i = 0; i < 5; i++) {" 10780 "for (var i = 0; i < 5; i++) {"
10781 " try { o1.p1; } catch (e) { result += e; }" 10781 " try { o1.p1; } catch (e) { result += e; }"
10782 "}" 10782 "}"
10783 "result;"); 10783 "result;");
10784 CHECK_EQ(v8_str("ggggg"), result); 10784 CHECK_EQ(v8_str("ggggg"), result);
10785 } 10785 }
10786 10786
10787 10787
10788 THREADED_TEST(InterceptorCallICFastApi_TrivialSignature) { 10788 THREADED_PROFILED_TEST(InterceptorCallICFastApi_TrivialSignature) {
10789 int interceptor_call_count = 0; 10789 int interceptor_call_count = 0;
10790 v8::HandleScope scope(v8::Isolate::GetCurrent()); 10790 v8::HandleScope scope(v8::Isolate::GetCurrent());
10791 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 10791 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
10792 v8::Handle<v8::FunctionTemplate> method_templ = 10792 v8::Handle<v8::FunctionTemplate> method_templ =
10793 v8::FunctionTemplate::New(FastApiCallback_TrivialSignature, 10793 v8::FunctionTemplate::New(FastApiCallback_TrivialSignature,
10794 v8_str("method_data"), 10794 v8_str("method_data"),
10795 v8::Handle<v8::Signature>()); 10795 v8::Handle<v8::Signature>());
10796 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 10796 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
10797 proto_templ->Set(v8_str("method"), method_templ); 10797 proto_templ->Set(v8_str("method"), method_templ);
10798 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); 10798 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
10799 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, 10799 templ->SetNamedPropertyHandler(InterceptorCallICFastApi,
10800 NULL, NULL, NULL, NULL, 10800 NULL, NULL, NULL, NULL,
10801 v8::External::New(&interceptor_call_count)); 10801 v8::External::New(&interceptor_call_count));
10802 LocalContext context; 10802 LocalContext context;
10803 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 10803 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
10804 GenerateSomeGarbage(); 10804 GenerateSomeGarbage();
10805 context->Global()->Set(v8_str("o"), fun->NewInstance()); 10805 context->Global()->Set(v8_str("o"), fun->NewInstance());
10806 CompileRun( 10806 CompileRun(
10807 "var result = 0;" 10807 "var result = 0;"
10808 "for (var i = 0; i < 100; i++) {" 10808 "for (var i = 0; i < 100; i++) {"
10809 " result = o.method(41);" 10809 " result = o.method(41);"
10810 "}"); 10810 "}");
10811 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); 10811 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value());
10812 CHECK_EQ(100, interceptor_call_count); 10812 CHECK_EQ(100, interceptor_call_count);
10813 } 10813 }
10814 10814
10815 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature) { 10815 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature) {
10816 int interceptor_call_count = 0; 10816 int interceptor_call_count = 0;
10817 v8::HandleScope scope(v8::Isolate::GetCurrent()); 10817 v8::HandleScope scope(v8::Isolate::GetCurrent());
10818 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 10818 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
10819 v8::Handle<v8::FunctionTemplate> method_templ = 10819 v8::Handle<v8::FunctionTemplate> method_templ =
10820 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 10820 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
10821 v8_str("method_data"), 10821 v8_str("method_data"),
10822 v8::Signature::New(fun_templ)); 10822 v8::Signature::New(fun_templ));
10823 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 10823 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
10824 proto_templ->Set(v8_str("method"), method_templ); 10824 proto_templ->Set(v8_str("method"), method_templ);
10825 fun_templ->SetHiddenPrototype(true); 10825 fun_templ->SetHiddenPrototype(true);
(...skipping 10 matching lines...) Expand all
10836 "var receiver = {};" 10836 "var receiver = {};"
10837 "receiver.__proto__ = o;" 10837 "receiver.__proto__ = o;"
10838 "var result = 0;" 10838 "var result = 0;"
10839 "for (var i = 0; i < 100; i++) {" 10839 "for (var i = 0; i < 100; i++) {"
10840 " result = receiver.method(41);" 10840 " result = receiver.method(41);"
10841 "}"); 10841 "}");
10842 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); 10842 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value());
10843 CHECK_EQ(100, interceptor_call_count); 10843 CHECK_EQ(100, interceptor_call_count);
10844 } 10844 }
10845 10845
10846 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss1) { 10846 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss1) {
10847 int interceptor_call_count = 0; 10847 int interceptor_call_count = 0;
10848 v8::HandleScope scope(v8::Isolate::GetCurrent()); 10848 v8::HandleScope scope(v8::Isolate::GetCurrent());
10849 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 10849 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
10850 v8::Handle<v8::FunctionTemplate> method_templ = 10850 v8::Handle<v8::FunctionTemplate> method_templ =
10851 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 10851 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
10852 v8_str("method_data"), 10852 v8_str("method_data"),
10853 v8::Signature::New(fun_templ)); 10853 v8::Signature::New(fun_templ));
10854 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 10854 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
10855 proto_templ->Set(v8_str("method"), method_templ); 10855 proto_templ->Set(v8_str("method"), method_templ);
10856 fun_templ->SetHiddenPrototype(true); 10856 fun_templ->SetHiddenPrototype(true);
(...skipping 16 matching lines...) Expand all
10873 " if (i == 50) {" 10873 " if (i == 50) {"
10874 " saved_result = result;" 10874 " saved_result = result;"
10875 " receiver = {method: function(x) { return x - 1 }};" 10875 " receiver = {method: function(x) { return x - 1 }};"
10876 " }" 10876 " }"
10877 "}"); 10877 "}");
10878 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value()); 10878 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value());
10879 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); 10879 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
10880 CHECK_GE(interceptor_call_count, 50); 10880 CHECK_GE(interceptor_call_count, 50);
10881 } 10881 }
10882 10882
10883 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss2) { 10883 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss2) {
10884 int interceptor_call_count = 0; 10884 int interceptor_call_count = 0;
10885 v8::HandleScope scope(v8::Isolate::GetCurrent()); 10885 v8::HandleScope scope(v8::Isolate::GetCurrent());
10886 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 10886 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
10887 v8::Handle<v8::FunctionTemplate> method_templ = 10887 v8::Handle<v8::FunctionTemplate> method_templ =
10888 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 10888 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
10889 v8_str("method_data"), 10889 v8_str("method_data"),
10890 v8::Signature::New(fun_templ)); 10890 v8::Signature::New(fun_templ));
10891 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 10891 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
10892 proto_templ->Set(v8_str("method"), method_templ); 10892 proto_templ->Set(v8_str("method"), method_templ);
10893 fun_templ->SetHiddenPrototype(true); 10893 fun_templ->SetHiddenPrototype(true);
(...skipping 16 matching lines...) Expand all
10910 " if (i == 50) {" 10910 " if (i == 50) {"
10911 " saved_result = result;" 10911 " saved_result = result;"
10912 " o.method = function(x) { return x - 1 };" 10912 " o.method = function(x) { return x - 1 };"
10913 " }" 10913 " }"
10914 "}"); 10914 "}");
10915 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value()); 10915 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value());
10916 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); 10916 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
10917 CHECK_GE(interceptor_call_count, 50); 10917 CHECK_GE(interceptor_call_count, 50);
10918 } 10918 }
10919 10919
10920 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss3) { 10920 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss3) {
10921 int interceptor_call_count = 0; 10921 int interceptor_call_count = 0;
10922 v8::HandleScope scope(v8::Isolate::GetCurrent()); 10922 v8::HandleScope scope(v8::Isolate::GetCurrent());
10923 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 10923 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
10924 v8::Handle<v8::FunctionTemplate> method_templ = 10924 v8::Handle<v8::FunctionTemplate> method_templ =
10925 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 10925 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
10926 v8_str("method_data"), 10926 v8_str("method_data"),
10927 v8::Signature::New(fun_templ)); 10927 v8::Signature::New(fun_templ));
10928 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 10928 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
10929 proto_templ->Set(v8_str("method"), method_templ); 10929 proto_templ->Set(v8_str("method"), method_templ);
10930 fun_templ->SetHiddenPrototype(true); 10930 fun_templ->SetHiddenPrototype(true);
(...skipping 19 matching lines...) Expand all
10950 " receiver = 333;" 10950 " receiver = 333;"
10951 " }" 10951 " }"
10952 "}"); 10952 "}");
10953 CHECK(try_catch.HasCaught()); 10953 CHECK(try_catch.HasCaught());
10954 CHECK_EQ(v8_str("TypeError: Object 333 has no method 'method'"), 10954 CHECK_EQ(v8_str("TypeError: Object 333 has no method 'method'"),
10955 try_catch.Exception()->ToString()); 10955 try_catch.Exception()->ToString());
10956 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); 10956 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
10957 CHECK_GE(interceptor_call_count, 50); 10957 CHECK_GE(interceptor_call_count, 50);
10958 } 10958 }
10959 10959
10960 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) { 10960 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) {
10961 int interceptor_call_count = 0; 10961 int interceptor_call_count = 0;
10962 v8::HandleScope scope(v8::Isolate::GetCurrent()); 10962 v8::HandleScope scope(v8::Isolate::GetCurrent());
10963 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 10963 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
10964 v8::Handle<v8::FunctionTemplate> method_templ = 10964 v8::Handle<v8::FunctionTemplate> method_templ =
10965 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 10965 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
10966 v8_str("method_data"), 10966 v8_str("method_data"),
10967 v8::Signature::New(fun_templ)); 10967 v8::Signature::New(fun_templ));
10968 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 10968 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
10969 proto_templ->Set(v8_str("method"), method_templ); 10969 proto_templ->Set(v8_str("method"), method_templ);
10970 fun_templ->SetHiddenPrototype(true); 10970 fun_templ->SetHiddenPrototype(true);
(...skipping 19 matching lines...) Expand all
10990 " receiver = {method: receiver.method};" 10990 " receiver = {method: receiver.method};"
10991 " }" 10991 " }"
10992 "}"); 10992 "}");
10993 CHECK(try_catch.HasCaught()); 10993 CHECK(try_catch.HasCaught());
10994 CHECK_EQ(v8_str("TypeError: Illegal invocation"), 10994 CHECK_EQ(v8_str("TypeError: Illegal invocation"),
10995 try_catch.Exception()->ToString()); 10995 try_catch.Exception()->ToString());
10996 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); 10996 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
10997 CHECK_GE(interceptor_call_count, 50); 10997 CHECK_GE(interceptor_call_count, 50);
10998 } 10998 }
10999 10999
11000 THREADED_TEST(CallICFastApi_TrivialSignature) { 11000 THREADED_PROFILED_TEST(CallICFastApi_TrivialSignature) {
11001 v8::HandleScope scope(v8::Isolate::GetCurrent()); 11001 v8::HandleScope scope(v8::Isolate::GetCurrent());
11002 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 11002 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
11003 v8::Handle<v8::FunctionTemplate> method_templ = 11003 v8::Handle<v8::FunctionTemplate> method_templ =
11004 v8::FunctionTemplate::New(FastApiCallback_TrivialSignature, 11004 v8::FunctionTemplate::New(FastApiCallback_TrivialSignature,
11005 v8_str("method_data"), 11005 v8_str("method_data"),
11006 v8::Handle<v8::Signature>()); 11006 v8::Handle<v8::Signature>());
11007 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 11007 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
11008 proto_templ->Set(v8_str("method"), method_templ); 11008 proto_templ->Set(v8_str("method"), method_templ);
11009 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); 11009 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
11010 USE(templ); 11010 USE(templ);
11011 LocalContext context; 11011 LocalContext context;
11012 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 11012 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
11013 GenerateSomeGarbage(); 11013 GenerateSomeGarbage();
11014 context->Global()->Set(v8_str("o"), fun->NewInstance()); 11014 context->Global()->Set(v8_str("o"), fun->NewInstance());
11015 CompileRun( 11015 CompileRun(
11016 "var result = 0;" 11016 "var result = 0;"
11017 "for (var i = 0; i < 100; i++) {" 11017 "for (var i = 0; i < 100; i++) {"
11018 " result = o.method(41);" 11018 " result = o.method(41);"
11019 "}"); 11019 "}");
11020 11020
11021 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); 11021 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value());
11022 } 11022 }
11023 11023
11024 THREADED_TEST(CallICFastApi_SimpleSignature) { 11024 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature) {
11025 v8::HandleScope scope(v8::Isolate::GetCurrent()); 11025 v8::HandleScope scope(v8::Isolate::GetCurrent());
11026 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 11026 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
11027 v8::Handle<v8::FunctionTemplate> method_templ = 11027 v8::Handle<v8::FunctionTemplate> method_templ =
11028 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 11028 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
11029 v8_str("method_data"), 11029 v8_str("method_data"),
11030 v8::Signature::New(fun_templ)); 11030 v8::Signature::New(fun_templ));
11031 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 11031 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
11032 proto_templ->Set(v8_str("method"), method_templ); 11032 proto_templ->Set(v8_str("method"), method_templ);
11033 fun_templ->SetHiddenPrototype(true); 11033 fun_templ->SetHiddenPrototype(true);
11034 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); 11034 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
11035 CHECK(!templ.IsEmpty()); 11035 CHECK(!templ.IsEmpty());
11036 LocalContext context; 11036 LocalContext context;
11037 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 11037 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
11038 GenerateSomeGarbage(); 11038 GenerateSomeGarbage();
11039 context->Global()->Set(v8_str("o"), fun->NewInstance()); 11039 context->Global()->Set(v8_str("o"), fun->NewInstance());
11040 CompileRun( 11040 CompileRun(
11041 "o.foo = 17;" 11041 "o.foo = 17;"
11042 "var receiver = {};" 11042 "var receiver = {};"
11043 "receiver.__proto__ = o;" 11043 "receiver.__proto__ = o;"
11044 "var result = 0;" 11044 "var result = 0;"
11045 "for (var i = 0; i < 100; i++) {" 11045 "for (var i = 0; i < 100; i++) {"
11046 " result = receiver.method(41);" 11046 " result = receiver.method(41);"
11047 "}"); 11047 "}");
11048 11048
11049 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); 11049 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value());
11050 } 11050 }
11051 11051
11052 THREADED_TEST(CallICFastApi_SimpleSignature_Miss1) { 11052 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_Miss1) {
11053 v8::HandleScope scope(v8::Isolate::GetCurrent()); 11053 v8::HandleScope scope(v8::Isolate::GetCurrent());
11054 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 11054 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
11055 v8::Handle<v8::FunctionTemplate> method_templ = 11055 v8::Handle<v8::FunctionTemplate> method_templ =
11056 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 11056 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
11057 v8_str("method_data"), 11057 v8_str("method_data"),
11058 v8::Signature::New(fun_templ)); 11058 v8::Signature::New(fun_templ));
11059 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 11059 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
11060 proto_templ->Set(v8_str("method"), method_templ); 11060 proto_templ->Set(v8_str("method"), method_templ);
11061 fun_templ->SetHiddenPrototype(true); 11061 fun_templ->SetHiddenPrototype(true);
11062 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); 11062 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
(...skipping 12 matching lines...) Expand all
11075 " result = receiver.method(41);" 11075 " result = receiver.method(41);"
11076 " if (i == 50) {" 11076 " if (i == 50) {"
11077 " saved_result = result;" 11077 " saved_result = result;"
11078 " receiver = {method: function(x) { return x - 1 }};" 11078 " receiver = {method: function(x) { return x - 1 }};"
11079 " }" 11079 " }"
11080 "}"); 11080 "}");
11081 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value()); 11081 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value());
11082 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); 11082 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
11083 } 11083 }
11084 11084
11085 THREADED_TEST(CallICFastApi_SimpleSignature_Miss2) { 11085 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_Miss2) {
11086 v8::HandleScope scope(v8::Isolate::GetCurrent()); 11086 v8::HandleScope scope(v8::Isolate::GetCurrent());
11087 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 11087 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
11088 v8::Handle<v8::FunctionTemplate> method_templ = 11088 v8::Handle<v8::FunctionTemplate> method_templ =
11089 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 11089 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
11090 v8_str("method_data"), 11090 v8_str("method_data"),
11091 v8::Signature::New(fun_templ)); 11091 v8::Signature::New(fun_templ));
11092 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 11092 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
11093 proto_templ->Set(v8_str("method"), method_templ); 11093 proto_templ->Set(v8_str("method"), method_templ);
11094 fun_templ->SetHiddenPrototype(true); 11094 fun_templ->SetHiddenPrototype(true);
11095 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); 11095 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
(...skipping 15 matching lines...) Expand all
11111 " saved_result = result;" 11111 " saved_result = result;"
11112 " receiver = 333;" 11112 " receiver = 333;"
11113 " }" 11113 " }"
11114 "}"); 11114 "}");
11115 CHECK(try_catch.HasCaught()); 11115 CHECK(try_catch.HasCaught());
11116 CHECK_EQ(v8_str("TypeError: Object 333 has no method 'method'"), 11116 CHECK_EQ(v8_str("TypeError: Object 333 has no method 'method'"),
11117 try_catch.Exception()->ToString()); 11117 try_catch.Exception()->ToString());
11118 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); 11118 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
11119 } 11119 }
11120 11120
11121 THREADED_TEST(CallICFastApi_SimpleSignature_TypeError) { 11121 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_TypeError) {
11122 v8::HandleScope scope(v8::Isolate::GetCurrent()); 11122 v8::HandleScope scope(v8::Isolate::GetCurrent());
11123 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 11123 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
11124 v8::Handle<v8::FunctionTemplate> method_templ = 11124 v8::Handle<v8::FunctionTemplate> method_templ =
11125 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 11125 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
11126 v8_str("method_data"), 11126 v8_str("method_data"),
11127 v8::Signature::New(fun_templ)); 11127 v8::Signature::New(fun_templ));
11128 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 11128 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
11129 proto_templ->Set(v8_str("method"), method_templ); 11129 proto_templ->Set(v8_str("method"), method_templ);
11130 fun_templ->SetHiddenPrototype(true); 11130 fun_templ->SetHiddenPrototype(true);
11131 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); 11131 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
(...skipping 8205 matching lines...) Expand 10 before | Expand all | Expand 10 after
19337 i::Semaphore* sem_; 19337 i::Semaphore* sem_;
19338 volatile int sem_value_; 19338 volatile int sem_value_;
19339 }; 19339 };
19340 19340
19341 19341
19342 THREADED_TEST(SemaphoreInterruption) { 19342 THREADED_TEST(SemaphoreInterruption) {
19343 ThreadInterruptTest().RunTest(); 19343 ThreadInterruptTest().RunTest();
19344 } 19344 }
19345 19345
19346 #endif // WIN32 19346 #endif // WIN32
OLDNEW
« no previous file with comments | « src/stub-cache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698