| 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 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1299 void* ptr = v8::External::Cast(*args.Data())->Value(); | 1299 void* ptr = v8::External::Cast(*args.Data())->Value(); |
| 1300 CHECK_EQ(expected_ptr, ptr); | 1300 CHECK_EQ(expected_ptr, ptr); |
| 1301 args.GetReturnValue().Set(true); | 1301 args.GetReturnValue().Set(true); |
| 1302 } | 1302 } |
| 1303 | 1303 |
| 1304 | 1304 |
| 1305 static void TestExternalPointerWrapping() { | 1305 static void TestExternalPointerWrapping() { |
| 1306 LocalContext env; | 1306 LocalContext env; |
| 1307 v8::HandleScope scope(env->GetIsolate()); | 1307 v8::HandleScope scope(env->GetIsolate()); |
| 1308 | 1308 |
| 1309 v8::Handle<v8::Value> data = v8::External::New(expected_ptr); | 1309 v8::Handle<v8::Value> data = |
| 1310 v8::External::New(env->GetIsolate(), expected_ptr); |
| 1310 | 1311 |
| 1311 v8::Handle<v8::Object> obj = v8::Object::New(); | 1312 v8::Handle<v8::Object> obj = v8::Object::New(); |
| 1312 obj->Set(v8_str("func"), | 1313 obj->Set(v8_str("func"), |
| 1313 v8::FunctionTemplate::New(callback, data)->GetFunction()); | 1314 v8::FunctionTemplate::New(callback, data)->GetFunction()); |
| 1314 env->Global()->Set(v8_str("obj"), obj); | 1315 env->Global()->Set(v8_str("obj"), obj); |
| 1315 | 1316 |
| 1316 CHECK(CompileRun( | 1317 CHECK(CompileRun( |
| 1317 "function foo() {\n" | 1318 "function foo() {\n" |
| 1318 " for (var i = 0; i < 13; i++) obj.func();\n" | 1319 " for (var i = 0; i < 13; i++) obj.func();\n" |
| 1319 "}\n" | 1320 "}\n" |
| (...skipping 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2736 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); | 2737 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); |
| 2737 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); | 2738 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); |
| 2738 | 2739 |
| 2739 CHECK(obj->Has(sym1)); | 2740 CHECK(obj->Has(sym1)); |
| 2740 CHECK(obj->Has(sym2)); | 2741 CHECK(obj->Has(sym2)); |
| 2741 CHECK(obj->Delete(sym2)); | 2742 CHECK(obj->Delete(sym2)); |
| 2742 CHECK(obj->Has(sym1)); | 2743 CHECK(obj->Has(sym1)); |
| 2743 CHECK(!obj->Has(sym2)); | 2744 CHECK(!obj->Has(sym2)); |
| 2744 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); | 2745 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); |
| 2745 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); | 2746 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); |
| 2747 |
| 2748 // Symbol properties are inherited. |
| 2749 v8::Local<v8::Object> child = v8::Object::New(); |
| 2750 child->SetPrototype(obj); |
| 2751 CHECK(child->Has(sym1)); |
| 2752 CHECK_EQ(2002, child->Get(sym1)->Int32Value()); |
| 2753 CHECK_EQ(0, child->GetOwnPropertyNames()->Length()); |
| 2746 } | 2754 } |
| 2747 | 2755 |
| 2748 | 2756 |
| 2757 THREADED_TEST(PrivateProperties) { |
| 2758 LocalContext env; |
| 2759 v8::Isolate* isolate = env->GetIsolate(); |
| 2760 v8::HandleScope scope(isolate); |
| 2761 |
| 2762 v8::Local<v8::Object> obj = v8::Object::New(); |
| 2763 v8::Local<v8::Private> priv1 = v8::Private::New(isolate); |
| 2764 v8::Local<v8::Private> priv2 = v8::Private::New(isolate, "my-private"); |
| 2765 |
| 2766 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 2767 |
| 2768 CHECK(priv2->Name()->Equals(v8::String::New("my-private"))); |
| 2769 |
| 2770 // Make sure delete of a non-existent private symbol property works. |
| 2771 CHECK(obj->DeletePrivate(priv1)); |
| 2772 CHECK(!obj->HasPrivate(priv1)); |
| 2773 |
| 2774 CHECK(obj->SetPrivate(priv1, v8::Integer::New(1503))); |
| 2775 CHECK(obj->HasPrivate(priv1)); |
| 2776 CHECK_EQ(1503, obj->GetPrivate(priv1)->Int32Value()); |
| 2777 CHECK(obj->SetPrivate(priv1, v8::Integer::New(2002))); |
| 2778 CHECK(obj->HasPrivate(priv1)); |
| 2779 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); |
| 2780 |
| 2781 CHECK_EQ(0, obj->GetOwnPropertyNames()->Length()); |
| 2782 int num_props = obj->GetPropertyNames()->Length(); |
| 2783 CHECK(obj->Set(v8::String::New("bla"), v8::Integer::New(20))); |
| 2784 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); |
| 2785 CHECK_EQ(num_props + 1, obj->GetPropertyNames()->Length()); |
| 2786 |
| 2787 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 2788 |
| 2789 // Add another property and delete it afterwards to force the object in |
| 2790 // slow case. |
| 2791 CHECK(obj->SetPrivate(priv2, v8::Integer::New(2008))); |
| 2792 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); |
| 2793 CHECK_EQ(2008, obj->GetPrivate(priv2)->Int32Value()); |
| 2794 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); |
| 2795 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); |
| 2796 |
| 2797 CHECK(obj->HasPrivate(priv1)); |
| 2798 CHECK(obj->HasPrivate(priv2)); |
| 2799 CHECK(obj->DeletePrivate(priv2)); |
| 2800 CHECK(obj->HasPrivate(priv1)); |
| 2801 CHECK(!obj->HasPrivate(priv2)); |
| 2802 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); |
| 2803 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); |
| 2804 |
| 2805 // Private properties are inherited (for the time being). |
| 2806 v8::Local<v8::Object> child = v8::Object::New(); |
| 2807 child->SetPrototype(obj); |
| 2808 CHECK(child->HasPrivate(priv1)); |
| 2809 CHECK_EQ(2002, child->GetPrivate(priv1)->Int32Value()); |
| 2810 CHECK_EQ(0, child->GetOwnPropertyNames()->Length()); |
| 2811 } |
| 2812 |
| 2813 |
| 2749 class ScopedArrayBufferContents { | 2814 class ScopedArrayBufferContents { |
| 2750 public: | 2815 public: |
| 2751 explicit ScopedArrayBufferContents( | 2816 explicit ScopedArrayBufferContents( |
| 2752 const v8::ArrayBuffer::Contents& contents) | 2817 const v8::ArrayBuffer::Contents& contents) |
| 2753 : contents_(contents) {} | 2818 : contents_(contents) {} |
| 2754 ~ScopedArrayBufferContents() { free(contents_.Data()); } | 2819 ~ScopedArrayBufferContents() { free(contents_.Data()); } |
| 2755 void* Data() const { return contents_.Data(); } | 2820 void* Data() const { return contents_.Data(); } |
| 2756 size_t ByteLength() const { return contents_.ByteLength(); } | 2821 size_t ByteLength() const { return contents_.ByteLength(); } |
| 2757 private: | 2822 private: |
| 2758 const v8::ArrayBuffer::Contents contents_; | 2823 const v8::ArrayBuffer::Contents contents_; |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3112 Local<v8::Object> obj = function->NewInstance(); | 3177 Local<v8::Object> obj = function->NewInstance(); |
| 3113 CHECK(obj->SetHiddenValue(key, v8::Integer::New(2302))); | 3178 CHECK(obj->SetHiddenValue(key, v8::Integer::New(2302))); |
| 3114 CHECK_EQ(2302, obj->GetHiddenValue(key)->Int32Value()); | 3179 CHECK_EQ(2302, obj->GetHiddenValue(key)->Int32Value()); |
| 3115 CHECK(!interceptor_for_hidden_properties_called); | 3180 CHECK(!interceptor_for_hidden_properties_called); |
| 3116 } | 3181 } |
| 3117 | 3182 |
| 3118 | 3183 |
| 3119 THREADED_TEST(External) { | 3184 THREADED_TEST(External) { |
| 3120 v8::HandleScope scope(CcTest::isolate()); | 3185 v8::HandleScope scope(CcTest::isolate()); |
| 3121 int x = 3; | 3186 int x = 3; |
| 3122 Local<v8::External> ext = v8::External::New(&x); | 3187 Local<v8::External> ext = v8::External::New(CcTest::isolate(), &x); |
| 3123 LocalContext env; | 3188 LocalContext env; |
| 3124 env->Global()->Set(v8_str("ext"), ext); | 3189 env->Global()->Set(v8_str("ext"), ext); |
| 3125 Local<Value> reext_obj = Script::Compile(v8_str("this.ext"))->Run(); | 3190 Local<Value> reext_obj = Script::Compile(v8_str("this.ext"))->Run(); |
| 3126 v8::Handle<v8::External> reext = reext_obj.As<v8::External>(); | 3191 v8::Handle<v8::External> reext = reext_obj.As<v8::External>(); |
| 3127 int* ptr = static_cast<int*>(reext->Value()); | 3192 int* ptr = static_cast<int*>(reext->Value()); |
| 3128 CHECK_EQ(x, 3); | 3193 CHECK_EQ(x, 3); |
| 3129 *ptr = 10; | 3194 *ptr = 10; |
| 3130 CHECK_EQ(x, 10); | 3195 CHECK_EQ(x, 10); |
| 3131 | 3196 |
| 3132 // Make sure unaligned pointers are wrapped properly. | 3197 // Make sure unaligned pointers are wrapped properly. |
| 3133 char* data = i::StrDup("0123456789"); | 3198 char* data = i::StrDup("0123456789"); |
| 3134 Local<v8::Value> zero = v8::External::New(&data[0]); | 3199 Local<v8::Value> zero = v8::External::New(CcTest::isolate(), &data[0]); |
| 3135 Local<v8::Value> one = v8::External::New(&data[1]); | 3200 Local<v8::Value> one = v8::External::New(CcTest::isolate(), &data[1]); |
| 3136 Local<v8::Value> two = v8::External::New(&data[2]); | 3201 Local<v8::Value> two = v8::External::New(CcTest::isolate(), &data[2]); |
| 3137 Local<v8::Value> three = v8::External::New(&data[3]); | 3202 Local<v8::Value> three = v8::External::New(CcTest::isolate(), &data[3]); |
| 3138 | 3203 |
| 3139 char* char_ptr = reinterpret_cast<char*>(v8::External::Cast(*zero)->Value()); | 3204 char* char_ptr = reinterpret_cast<char*>(v8::External::Cast(*zero)->Value()); |
| 3140 CHECK_EQ('0', *char_ptr); | 3205 CHECK_EQ('0', *char_ptr); |
| 3141 char_ptr = reinterpret_cast<char*>(v8::External::Cast(*one)->Value()); | 3206 char_ptr = reinterpret_cast<char*>(v8::External::Cast(*one)->Value()); |
| 3142 CHECK_EQ('1', *char_ptr); | 3207 CHECK_EQ('1', *char_ptr); |
| 3143 char_ptr = reinterpret_cast<char*>(v8::External::Cast(*two)->Value()); | 3208 char_ptr = reinterpret_cast<char*>(v8::External::Cast(*two)->Value()); |
| 3144 CHECK_EQ('2', *char_ptr); | 3209 CHECK_EQ('2', *char_ptr); |
| 3145 char_ptr = reinterpret_cast<char*>(v8::External::Cast(*three)->Value()); | 3210 char_ptr = reinterpret_cast<char*>(v8::External::Cast(*three)->Value()); |
| 3146 CHECK_EQ('3', *char_ptr); | 3211 CHECK_EQ('3', *char_ptr); |
| 3147 i::DeleteArray(data); | 3212 i::DeleteArray(data); |
| (...skipping 3719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6867 info.GetReturnValue().Set(whammy->getScript()->Run()); | 6932 info.GetReturnValue().Set(whammy->getScript()->Run()); |
| 6868 } | 6933 } |
| 6869 | 6934 |
| 6870 | 6935 |
| 6871 THREADED_TEST(WeakReference) { | 6936 THREADED_TEST(WeakReference) { |
| 6872 v8::HandleScope handle_scope(CcTest::isolate()); | 6937 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6873 v8::Handle<v8::ObjectTemplate> templ= v8::ObjectTemplate::New(); | 6938 v8::Handle<v8::ObjectTemplate> templ= v8::ObjectTemplate::New(); |
| 6874 Whammy* whammy = new Whammy(CcTest::isolate()); | 6939 Whammy* whammy = new Whammy(CcTest::isolate()); |
| 6875 templ->SetNamedPropertyHandler(WhammyPropertyGetter, | 6940 templ->SetNamedPropertyHandler(WhammyPropertyGetter, |
| 6876 0, 0, 0, 0, | 6941 0, 0, 0, 0, |
| 6877 v8::External::New(whammy)); | 6942 v8::External::New(CcTest::isolate(), whammy)); |
| 6878 const char* extension_list[] = { "v8/gc" }; | 6943 const char* extension_list[] = { "v8/gc" }; |
| 6879 v8::ExtensionConfiguration extensions(1, extension_list); | 6944 v8::ExtensionConfiguration extensions(1, extension_list); |
| 6880 v8::Handle<Context> context = | 6945 v8::Handle<Context> context = |
| 6881 Context::New(CcTest::isolate(), &extensions); | 6946 Context::New(CcTest::isolate(), &extensions); |
| 6882 Context::Scope context_scope(context); | 6947 Context::Scope context_scope(context); |
| 6883 | 6948 |
| 6884 v8::Handle<v8::Object> interceptor = templ->NewInstance(); | 6949 v8::Handle<v8::Object> interceptor = templ->NewInstance(); |
| 6885 context->Global()->Set(v8_str("whammy"), interceptor); | 6950 context->Global()->Set(v8_str("whammy"), interceptor); |
| 6886 const char* code = | 6951 const char* code = |
| 6887 "var last;" | 6952 "var last;" |
| (...skipping 4674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11562 int interceptor_call_count = 0; | 11627 int interceptor_call_count = 0; |
| 11563 v8::HandleScope scope(CcTest::isolate()); | 11628 v8::HandleScope scope(CcTest::isolate()); |
| 11564 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11629 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 11565 v8::Handle<v8::FunctionTemplate> method_templ = | 11630 v8::Handle<v8::FunctionTemplate> method_templ = |
| 11566 v8::FunctionTemplate::New(FastApiCallback_TrivialSignature, | 11631 v8::FunctionTemplate::New(FastApiCallback_TrivialSignature, |
| 11567 v8_str("method_data"), | 11632 v8_str("method_data"), |
| 11568 v8::Handle<v8::Signature>()); | 11633 v8::Handle<v8::Signature>()); |
| 11569 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11634 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11570 proto_templ->Set(v8_str("method"), method_templ); | 11635 proto_templ->Set(v8_str("method"), method_templ); |
| 11571 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 11636 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
| 11572 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, | 11637 templ->SetNamedPropertyHandler( |
| 11573 NULL, NULL, NULL, NULL, | 11638 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, |
| 11574 v8::External::New(&interceptor_call_count)); | 11639 v8::External::New(CcTest::isolate(), &interceptor_call_count)); |
| 11575 LocalContext context; | 11640 LocalContext context; |
| 11576 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 11641 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 11577 GenerateSomeGarbage(); | 11642 GenerateSomeGarbage(); |
| 11578 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 11643 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 11579 CompileRun( | 11644 CompileRun( |
| 11580 "var result = 0;" | 11645 "var result = 0;" |
| 11581 "for (var i = 0; i < 100; i++) {" | 11646 "for (var i = 0; i < 100; i++) {" |
| 11582 " result = o.method(41);" | 11647 " result = o.method(41);" |
| 11583 "}"); | 11648 "}"); |
| 11584 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); | 11649 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 11585 CHECK_EQ(100, interceptor_call_count); | 11650 CHECK_EQ(100, interceptor_call_count); |
| 11586 } | 11651 } |
| 11587 | 11652 |
| 11588 | 11653 |
| 11589 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature) { | 11654 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature) { |
| 11590 int interceptor_call_count = 0; | 11655 int interceptor_call_count = 0; |
| 11591 v8::HandleScope scope(CcTest::isolate()); | 11656 v8::HandleScope scope(CcTest::isolate()); |
| 11592 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11657 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 11593 v8::Handle<v8::FunctionTemplate> method_templ = | 11658 v8::Handle<v8::FunctionTemplate> method_templ = |
| 11594 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, | 11659 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, |
| 11595 v8_str("method_data"), | 11660 v8_str("method_data"), |
| 11596 v8::Signature::New(fun_templ)); | 11661 v8::Signature::New(fun_templ)); |
| 11597 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11662 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11598 proto_templ->Set(v8_str("method"), method_templ); | 11663 proto_templ->Set(v8_str("method"), method_templ); |
| 11599 fun_templ->SetHiddenPrototype(true); | 11664 fun_templ->SetHiddenPrototype(true); |
| 11600 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 11665 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
| 11601 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, | 11666 templ->SetNamedPropertyHandler( |
| 11602 NULL, NULL, NULL, NULL, | 11667 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, |
| 11603 v8::External::New(&interceptor_call_count)); | 11668 v8::External::New(CcTest::isolate(), &interceptor_call_count)); |
| 11604 LocalContext context; | 11669 LocalContext context; |
| 11605 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 11670 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 11606 GenerateSomeGarbage(); | 11671 GenerateSomeGarbage(); |
| 11607 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 11672 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 11608 CompileRun( | 11673 CompileRun( |
| 11609 "o.foo = 17;" | 11674 "o.foo = 17;" |
| 11610 "var receiver = {};" | 11675 "var receiver = {};" |
| 11611 "receiver.__proto__ = o;" | 11676 "receiver.__proto__ = o;" |
| 11612 "var result = 0;" | 11677 "var result = 0;" |
| 11613 "for (var i = 0; i < 100; i++) {" | 11678 "for (var i = 0; i < 100; i++) {" |
| 11614 " result = receiver.method(41);" | 11679 " result = receiver.method(41);" |
| 11615 "}"); | 11680 "}"); |
| 11616 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); | 11681 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 11617 CHECK_EQ(100, interceptor_call_count); | 11682 CHECK_EQ(100, interceptor_call_count); |
| 11618 } | 11683 } |
| 11619 | 11684 |
| 11620 | 11685 |
| 11621 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss1) { | 11686 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss1) { |
| 11622 int interceptor_call_count = 0; | 11687 int interceptor_call_count = 0; |
| 11623 v8::HandleScope scope(CcTest::isolate()); | 11688 v8::HandleScope scope(CcTest::isolate()); |
| 11624 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11689 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 11625 v8::Handle<v8::FunctionTemplate> method_templ = | 11690 v8::Handle<v8::FunctionTemplate> method_templ = |
| 11626 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, | 11691 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, |
| 11627 v8_str("method_data"), | 11692 v8_str("method_data"), |
| 11628 v8::Signature::New(fun_templ)); | 11693 v8::Signature::New(fun_templ)); |
| 11629 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11694 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11630 proto_templ->Set(v8_str("method"), method_templ); | 11695 proto_templ->Set(v8_str("method"), method_templ); |
| 11631 fun_templ->SetHiddenPrototype(true); | 11696 fun_templ->SetHiddenPrototype(true); |
| 11632 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 11697 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
| 11633 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, | 11698 templ->SetNamedPropertyHandler( |
| 11634 NULL, NULL, NULL, NULL, | 11699 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, |
| 11635 v8::External::New(&interceptor_call_count)); | 11700 v8::External::New(CcTest::isolate(), &interceptor_call_count)); |
| 11636 LocalContext context; | 11701 LocalContext context; |
| 11637 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 11702 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 11638 GenerateSomeGarbage(); | 11703 GenerateSomeGarbage(); |
| 11639 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 11704 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 11640 CompileRun( | 11705 CompileRun( |
| 11641 "o.foo = 17;" | 11706 "o.foo = 17;" |
| 11642 "var receiver = {};" | 11707 "var receiver = {};" |
| 11643 "receiver.__proto__ = o;" | 11708 "receiver.__proto__ = o;" |
| 11644 "var result = 0;" | 11709 "var result = 0;" |
| 11645 "var saved_result = 0;" | 11710 "var saved_result = 0;" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 11661 v8::HandleScope scope(CcTest::isolate()); | 11726 v8::HandleScope scope(CcTest::isolate()); |
| 11662 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11727 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 11663 v8::Handle<v8::FunctionTemplate> method_templ = | 11728 v8::Handle<v8::FunctionTemplate> method_templ = |
| 11664 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, | 11729 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, |
| 11665 v8_str("method_data"), | 11730 v8_str("method_data"), |
| 11666 v8::Signature::New(fun_templ)); | 11731 v8::Signature::New(fun_templ)); |
| 11667 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11732 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11668 proto_templ->Set(v8_str("method"), method_templ); | 11733 proto_templ->Set(v8_str("method"), method_templ); |
| 11669 fun_templ->SetHiddenPrototype(true); | 11734 fun_templ->SetHiddenPrototype(true); |
| 11670 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 11735 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
| 11671 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, | 11736 templ->SetNamedPropertyHandler( |
| 11672 NULL, NULL, NULL, NULL, | 11737 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, |
| 11673 v8::External::New(&interceptor_call_count)); | 11738 v8::External::New(CcTest::isolate(), &interceptor_call_count)); |
| 11674 LocalContext context; | 11739 LocalContext context; |
| 11675 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 11740 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 11676 GenerateSomeGarbage(); | 11741 GenerateSomeGarbage(); |
| 11677 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 11742 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 11678 CompileRun( | 11743 CompileRun( |
| 11679 "o.foo = 17;" | 11744 "o.foo = 17;" |
| 11680 "var receiver = {};" | 11745 "var receiver = {};" |
| 11681 "receiver.__proto__ = o;" | 11746 "receiver.__proto__ = o;" |
| 11682 "var result = 0;" | 11747 "var result = 0;" |
| 11683 "var saved_result = 0;" | 11748 "var saved_result = 0;" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 11699 v8::HandleScope scope(CcTest::isolate()); | 11764 v8::HandleScope scope(CcTest::isolate()); |
| 11700 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11765 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 11701 v8::Handle<v8::FunctionTemplate> method_templ = | 11766 v8::Handle<v8::FunctionTemplate> method_templ = |
| 11702 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, | 11767 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, |
| 11703 v8_str("method_data"), | 11768 v8_str("method_data"), |
| 11704 v8::Signature::New(fun_templ)); | 11769 v8::Signature::New(fun_templ)); |
| 11705 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11770 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11706 proto_templ->Set(v8_str("method"), method_templ); | 11771 proto_templ->Set(v8_str("method"), method_templ); |
| 11707 fun_templ->SetHiddenPrototype(true); | 11772 fun_templ->SetHiddenPrototype(true); |
| 11708 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 11773 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
| 11709 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, | 11774 templ->SetNamedPropertyHandler( |
| 11710 NULL, NULL, NULL, NULL, | 11775 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, |
| 11711 v8::External::New(&interceptor_call_count)); | 11776 v8::External::New(CcTest::isolate(), &interceptor_call_count)); |
| 11712 LocalContext context; | 11777 LocalContext context; |
| 11713 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 11778 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 11714 GenerateSomeGarbage(); | 11779 GenerateSomeGarbage(); |
| 11715 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 11780 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 11716 v8::TryCatch try_catch; | 11781 v8::TryCatch try_catch; |
| 11717 CompileRun( | 11782 CompileRun( |
| 11718 "o.foo = 17;" | 11783 "o.foo = 17;" |
| 11719 "var receiver = {};" | 11784 "var receiver = {};" |
| 11720 "receiver.__proto__ = o;" | 11785 "receiver.__proto__ = o;" |
| 11721 "var result = 0;" | 11786 "var result = 0;" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 11740 v8::HandleScope scope(CcTest::isolate()); | 11805 v8::HandleScope scope(CcTest::isolate()); |
| 11741 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11806 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 11742 v8::Handle<v8::FunctionTemplate> method_templ = | 11807 v8::Handle<v8::FunctionTemplate> method_templ = |
| 11743 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, | 11808 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, |
| 11744 v8_str("method_data"), | 11809 v8_str("method_data"), |
| 11745 v8::Signature::New(fun_templ)); | 11810 v8::Signature::New(fun_templ)); |
| 11746 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11811 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11747 proto_templ->Set(v8_str("method"), method_templ); | 11812 proto_templ->Set(v8_str("method"), method_templ); |
| 11748 fun_templ->SetHiddenPrototype(true); | 11813 fun_templ->SetHiddenPrototype(true); |
| 11749 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 11814 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
| 11750 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, | 11815 templ->SetNamedPropertyHandler( |
| 11751 NULL, NULL, NULL, NULL, | 11816 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, |
| 11752 v8::External::New(&interceptor_call_count)); | 11817 v8::External::New(CcTest::isolate(), &interceptor_call_count)); |
| 11753 LocalContext context; | 11818 LocalContext context; |
| 11754 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 11819 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 11755 GenerateSomeGarbage(); | 11820 GenerateSomeGarbage(); |
| 11756 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 11821 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 11757 v8::TryCatch try_catch; | 11822 v8::TryCatch try_catch; |
| 11758 CompileRun( | 11823 CompileRun( |
| 11759 "o.foo = 17;" | 11824 "o.foo = 17;" |
| 11760 "var receiver = {};" | 11825 "var receiver = {};" |
| 11761 "receiver.__proto__ = o;" | 11826 "receiver.__proto__ = o;" |
| 11762 "var result = 0;" | 11827 "var result = 0;" |
| (...skipping 8045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19808 TEST(SecondaryStubCache) { | 19873 TEST(SecondaryStubCache) { |
| 19809 StubCacheHelper(true); | 19874 StubCacheHelper(true); |
| 19810 } | 19875 } |
| 19811 | 19876 |
| 19812 | 19877 |
| 19813 TEST(PrimaryStubCache) { | 19878 TEST(PrimaryStubCache) { |
| 19814 StubCacheHelper(false); | 19879 StubCacheHelper(false); |
| 19815 } | 19880 } |
| 19816 | 19881 |
| 19817 | 19882 |
| 19883 static int cow_arrays_created_runtime = 0; |
| 19884 |
| 19885 |
| 19886 static int* LookupCounterCOWArrays(const char* name) { |
| 19887 if (strcmp(name, "c:V8.COWArraysCreatedRuntime") == 0) { |
| 19888 return &cow_arrays_created_runtime; |
| 19889 } |
| 19890 return NULL; |
| 19891 } |
| 19892 |
| 19893 |
| 19894 TEST(CheckCOWArraysCreatedRuntimeCounter) { |
| 19895 V8::SetCounterFunction(LookupCounterCOWArrays); |
| 19896 #ifdef DEBUG |
| 19897 i::FLAG_native_code_counters = true; |
| 19898 LocalContext env; |
| 19899 v8::HandleScope scope(env->GetIsolate()); |
| 19900 int initial_cow_arrays = cow_arrays_created_runtime; |
| 19901 CompileRun("var o = [1, 2, 3];"); |
| 19902 CHECK_EQ(1, cow_arrays_created_runtime - initial_cow_arrays); |
| 19903 CompileRun("var o = {foo: [4, 5, 6], bar: [3, 0]};"); |
| 19904 CHECK_EQ(3, cow_arrays_created_runtime - initial_cow_arrays); |
| 19905 CompileRun("var o = {foo: [1, 2, 3, [4, 5, 6]], bar: 'hi'};"); |
| 19906 CHECK_EQ(4, cow_arrays_created_runtime - initial_cow_arrays); |
| 19907 #endif |
| 19908 } |
| 19909 |
| 19910 |
| 19818 TEST(StaticGetters) { | 19911 TEST(StaticGetters) { |
| 19819 LocalContext context; | 19912 LocalContext context; |
| 19820 i::Factory* factory = CcTest::i_isolate()->factory(); | 19913 i::Factory* factory = CcTest::i_isolate()->factory(); |
| 19821 v8::Isolate* isolate = CcTest::isolate(); | 19914 v8::Isolate* isolate = CcTest::isolate(); |
| 19822 v8::HandleScope scope(isolate); | 19915 v8::HandleScope scope(isolate); |
| 19823 i::Handle<i::Object> undefined_value = factory->undefined_value(); | 19916 i::Handle<i::Object> undefined_value = factory->undefined_value(); |
| 19824 CHECK(*v8::Utils::OpenHandle(*v8::Undefined(isolate)) == *undefined_value); | 19917 CHECK(*v8::Utils::OpenHandle(*v8::Undefined(isolate)) == *undefined_value); |
| 19825 i::Handle<i::Object> null_value = factory->null_value(); | 19918 i::Handle<i::Object> null_value = factory->null_value(); |
| 19826 CHECK(*v8::Utils::OpenHandle(*v8::Null(isolate)) == *null_value); | 19919 CHECK(*v8::Utils::OpenHandle(*v8::Null(isolate)) == *null_value); |
| 19827 i::Handle<i::Object> true_value = factory->true_value(); | 19920 i::Handle<i::Object> true_value = factory->true_value(); |
| (...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20711 } | 20804 } |
| 20712 for (int i = 0; i < runs; i++) { | 20805 for (int i = 0; i < runs; i++) { |
| 20713 Local<String> expected; | 20806 Local<String> expected; |
| 20714 if (i != 0) { | 20807 if (i != 0) { |
| 20715 CHECK_EQ(v8_str("escape value"), values[i]); | 20808 CHECK_EQ(v8_str("escape value"), values[i]); |
| 20716 } else { | 20809 } else { |
| 20717 CHECK(values[i].IsEmpty()); | 20810 CHECK(values[i].IsEmpty()); |
| 20718 } | 20811 } |
| 20719 } | 20812 } |
| 20720 } | 20813 } |
| OLD | NEW |