| 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 8779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8790 context1->Exit(); | 8790 context1->Exit(); |
| 8791 context0->Exit(); | 8791 context0->Exit(); |
| 8792 } | 8792 } |
| 8793 | 8793 |
| 8794 | 8794 |
| 8795 THREADED_TEST(Version) { | 8795 THREADED_TEST(Version) { |
| 8796 v8::V8::GetVersion(); | 8796 v8::V8::GetVersion(); |
| 8797 } | 8797 } |
| 8798 | 8798 |
| 8799 | 8799 |
| 8800 static v8::Handle<Value> InstanceFunctionCallback(const v8::Arguments& args) { | 8800 static void InstanceFunctionCallback( |
| 8801 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 8801 ApiTestFuzzer::Fuzz(); | 8802 ApiTestFuzzer::Fuzz(); |
| 8802 return v8_num(12); | 8803 args.GetReturnValue().Set(v8_num(12)); |
| 8803 } | 8804 } |
| 8804 | 8805 |
| 8805 | 8806 |
| 8806 THREADED_TEST(InstanceProperties) { | 8807 THREADED_TEST(InstanceProperties) { |
| 8807 LocalContext context; | 8808 LocalContext context; |
| 8808 v8::HandleScope handle_scope(context->GetIsolate()); | 8809 v8::HandleScope handle_scope(context->GetIsolate()); |
| 8809 | 8810 |
| 8810 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); | 8811 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); |
| 8811 Local<ObjectTemplate> instance = t->InstanceTemplate(); | 8812 Local<ObjectTemplate> instance = t->InstanceTemplate(); |
| 8812 | 8813 |
| 8813 instance->Set(v8_str("x"), v8_num(42)); | 8814 instance->Set(v8_str("x"), v8_num(42)); |
| 8814 instance->Set(v8_str("f"), | 8815 instance->Set(v8_str("f"), |
| 8815 v8::FunctionTemplate::New(InstanceFunctionCallback)); | 8816 v8::FunctionTemplate::New(InstanceFunctionCallback)); |
| 8816 | 8817 |
| 8817 Local<Value> o = t->GetFunction()->NewInstance(); | 8818 Local<Value> o = t->GetFunction()->NewInstance(); |
| 8818 | 8819 |
| 8819 context->Global()->Set(v8_str("i"), o); | 8820 context->Global()->Set(v8_str("i"), o); |
| 8820 Local<Value> value = Script::Compile(v8_str("i.x"))->Run(); | 8821 Local<Value> value = Script::Compile(v8_str("i.x"))->Run(); |
| 8821 CHECK_EQ(42, value->Int32Value()); | 8822 CHECK_EQ(42, value->Int32Value()); |
| 8822 | 8823 |
| 8823 value = Script::Compile(v8_str("i.f()"))->Run(); | 8824 value = Script::Compile(v8_str("i.f()"))->Run(); |
| 8824 CHECK_EQ(12, value->Int32Value()); | 8825 CHECK_EQ(12, value->Int32Value()); |
| 8825 } | 8826 } |
| 8826 | 8827 |
| 8827 | 8828 |
| 8828 static v8::Handle<Value> | 8829 static void GlobalObjectInstancePropertiesGet( |
| 8829 GlobalObjectInstancePropertiesGet(Local<String> key, const AccessorInfo&) { | 8830 Local<String> key, |
| 8831 const v8::PropertyCallbackInfo<v8::Value>&) { |
| 8830 ApiTestFuzzer::Fuzz(); | 8832 ApiTestFuzzer::Fuzz(); |
| 8831 return v8::Handle<Value>(); | |
| 8832 } | 8833 } |
| 8833 | 8834 |
| 8834 | 8835 |
| 8835 THREADED_TEST(GlobalObjectInstanceProperties) { | 8836 THREADED_TEST(GlobalObjectInstanceProperties) { |
| 8836 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 8837 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); |
| 8837 | 8838 |
| 8838 Local<Value> global_object; | 8839 Local<Value> global_object; |
| 8839 | 8840 |
| 8840 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); | 8841 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); |
| 8841 t->InstanceTemplate()->SetNamedPropertyHandler( | 8842 t->InstanceTemplate()->SetNamedPropertyHandler( |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8921 | 8922 |
| 8922 { | 8923 { |
| 8923 // Create new environment reusing the global object. | 8924 // Create new environment reusing the global object. |
| 8924 LocalContext env(NULL, instance_template, global_object); | 8925 LocalContext env(NULL, instance_template, global_object); |
| 8925 env->Global()->Set(v8_str("foo"), foo); | 8926 env->Global()->Set(v8_str("foo"), foo); |
| 8926 Script::Compile(v8_str("foo()"))->Run(); | 8927 Script::Compile(v8_str("foo()"))->Run(); |
| 8927 } | 8928 } |
| 8928 } | 8929 } |
| 8929 | 8930 |
| 8930 | 8931 |
| 8931 static v8::Handle<Value> ShadowFunctionCallback(const v8::Arguments& args) { | 8932 static void ShadowFunctionCallback( |
| 8933 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 8932 ApiTestFuzzer::Fuzz(); | 8934 ApiTestFuzzer::Fuzz(); |
| 8933 return v8_num(42); | 8935 args.GetReturnValue().Set(v8_num(42)); |
| 8934 } | 8936 } |
| 8935 | 8937 |
| 8936 | 8938 |
| 8937 static int shadow_y; | 8939 static int shadow_y; |
| 8938 static int shadow_y_setter_call_count; | 8940 static int shadow_y_setter_call_count; |
| 8939 static int shadow_y_getter_call_count; | 8941 static int shadow_y_getter_call_count; |
| 8940 | 8942 |
| 8941 | 8943 |
| 8942 static void ShadowYSetter(Local<String>, Local<Value>, const AccessorInfo&) { | 8944 static void ShadowYSetter(Local<String>, |
| 8945 Local<Value>, |
| 8946 const v8::PropertyCallbackInfo<void>&) { |
| 8943 shadow_y_setter_call_count++; | 8947 shadow_y_setter_call_count++; |
| 8944 shadow_y = 42; | 8948 shadow_y = 42; |
| 8945 } | 8949 } |
| 8946 | 8950 |
| 8947 | 8951 |
| 8948 static v8::Handle<Value> ShadowYGetter(Local<String> name, | 8952 static void ShadowYGetter(Local<String> name, |
| 8949 const AccessorInfo& info) { | 8953 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 8950 ApiTestFuzzer::Fuzz(); | 8954 ApiTestFuzzer::Fuzz(); |
| 8951 shadow_y_getter_call_count++; | 8955 shadow_y_getter_call_count++; |
| 8952 return v8_num(shadow_y); | 8956 info.GetReturnValue().Set(v8_num(shadow_y)); |
| 8953 } | 8957 } |
| 8954 | 8958 |
| 8955 | 8959 |
| 8956 static v8::Handle<Value> ShadowIndexedGet(uint32_t index, | 8960 static void ShadowIndexedGet(uint32_t index, |
| 8957 const AccessorInfo& info) { | 8961 const v8::PropertyCallbackInfo<v8::Value>&) { |
| 8958 return v8::Handle<Value>(); | |
| 8959 } | 8962 } |
| 8960 | 8963 |
| 8961 | 8964 |
| 8962 static v8::Handle<Value> ShadowNamedGet(Local<String> key, | 8965 static void ShadowNamedGet(Local<String> key, |
| 8963 const AccessorInfo&) { | 8966 const v8::PropertyCallbackInfo<v8::Value>&) { |
| 8964 return v8::Handle<Value>(); | |
| 8965 } | 8967 } |
| 8966 | 8968 |
| 8967 | 8969 |
| 8968 THREADED_TEST(ShadowObject) { | 8970 THREADED_TEST(ShadowObject) { |
| 8969 shadow_y = shadow_y_setter_call_count = shadow_y_getter_call_count = 0; | 8971 shadow_y = shadow_y_setter_call_count = shadow_y_getter_call_count = 0; |
| 8970 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 8972 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); |
| 8971 | 8973 |
| 8972 Local<ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 8974 Local<ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
| 8973 LocalContext context(NULL, global_template); | 8975 LocalContext context(NULL, global_template); |
| 8974 | 8976 |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9304 Local<Function> cons = templ->GetFunction(); | 9306 Local<Function> cons = templ->GetFunction(); |
| 9305 context->Global()->Set(v8_str("Fun"), cons); | 9307 context->Global()->Set(v8_str("Fun"), cons); |
| 9306 Local<v8::Object> inst = cons->NewInstance(); | 9308 Local<v8::Object> inst = cons->NewInstance(); |
| 9307 i::Handle<i::JSObject> obj(v8::Utils::OpenHandle(*inst)); | 9309 i::Handle<i::JSObject> obj(v8::Utils::OpenHandle(*inst)); |
| 9308 CHECK(obj->IsJSObject()); | 9310 CHECK(obj->IsJSObject()); |
| 9309 Local<Value> value = CompileRun("(new Fun()).constructor === Fun"); | 9311 Local<Value> value = CompileRun("(new Fun()).constructor === Fun"); |
| 9310 CHECK(value->BooleanValue()); | 9312 CHECK(value->BooleanValue()); |
| 9311 } | 9313 } |
| 9312 | 9314 |
| 9313 | 9315 |
| 9314 static Handle<Value> ConstructorCallback(const Arguments& args) { | 9316 static void ConstructorCallback( |
| 9317 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 9315 ApiTestFuzzer::Fuzz(); | 9318 ApiTestFuzzer::Fuzz(); |
| 9316 Local<Object> This; | 9319 Local<Object> This; |
| 9317 | 9320 |
| 9318 if (args.IsConstructCall()) { | 9321 if (args.IsConstructCall()) { |
| 9319 Local<Object> Holder = args.Holder(); | 9322 Local<Object> Holder = args.Holder(); |
| 9320 This = Object::New(); | 9323 This = Object::New(); |
| 9321 Local<Value> proto = Holder->GetPrototype(); | 9324 Local<Value> proto = Holder->GetPrototype(); |
| 9322 if (proto->IsObject()) { | 9325 if (proto->IsObject()) { |
| 9323 This->SetPrototype(proto); | 9326 This->SetPrototype(proto); |
| 9324 } | 9327 } |
| 9325 } else { | 9328 } else { |
| 9326 This = args.This(); | 9329 This = args.This(); |
| 9327 } | 9330 } |
| 9328 | 9331 |
| 9329 This->Set(v8_str("a"), args[0]); | 9332 This->Set(v8_str("a"), args[0]); |
| 9330 return This; | 9333 args.GetReturnValue().Set(This); |
| 9331 } | 9334 } |
| 9332 | 9335 |
| 9333 | 9336 |
| 9334 static Handle<Value> FakeConstructorCallback(const Arguments& args) { | 9337 static void FakeConstructorCallback( |
| 9338 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 9335 ApiTestFuzzer::Fuzz(); | 9339 ApiTestFuzzer::Fuzz(); |
| 9336 return args[0]; | 9340 args.GetReturnValue().Set(args[0]); |
| 9337 } | 9341 } |
| 9338 | 9342 |
| 9339 | 9343 |
| 9340 THREADED_TEST(ConstructorForObject) { | 9344 THREADED_TEST(ConstructorForObject) { |
| 9341 LocalContext context; | 9345 LocalContext context; |
| 9342 v8::HandleScope handle_scope(context->GetIsolate()); | 9346 v8::HandleScope handle_scope(context->GetIsolate()); |
| 9343 | 9347 |
| 9344 { Local<ObjectTemplate> instance_template = ObjectTemplate::New(); | 9348 { Local<ObjectTemplate> instance_template = ObjectTemplate::New(); |
| 9345 instance_template->SetCallAsFunctionHandler(ConstructorCallback); | 9349 instance_template->SetCallAsFunctionHandler(ConstructorCallback); |
| 9346 Local<Object> instance = instance_template->NewInstance(); | 9350 Local<Object> instance = instance_template->NewInstance(); |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9694 current->Global()->Set(v8_str("other"), other->Global()); | 9698 current->Global()->Set(v8_str("other"), other->Global()); |
| 9695 | 9699 |
| 9696 // Trigger lazy loading in other context. | 9700 // Trigger lazy loading in other context. |
| 9697 Local<Script> script = | 9701 Local<Script> script = |
| 9698 Script::Compile(v8_str("other.eval('new Date(42)')")); | 9702 Script::Compile(v8_str("other.eval('new Date(42)')")); |
| 9699 Local<Value> value = script->Run(); | 9703 Local<Value> value = script->Run(); |
| 9700 CHECK_EQ(42.0, value->NumberValue()); | 9704 CHECK_EQ(42.0, value->NumberValue()); |
| 9701 } | 9705 } |
| 9702 | 9706 |
| 9703 | 9707 |
| 9704 static v8::Handle<Value> call_as_function(const v8::Arguments& args) { | 9708 static void call_as_function(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 9705 ApiTestFuzzer::Fuzz(); | 9709 ApiTestFuzzer::Fuzz(); |
| 9706 if (args.IsConstructCall()) { | 9710 if (args.IsConstructCall()) { |
| 9707 if (args[0]->IsInt32()) { | 9711 if (args[0]->IsInt32()) { |
| 9708 return v8_num(-args[0]->Int32Value()); | 9712 args.GetReturnValue().Set(v8_num(-args[0]->Int32Value())); |
| 9713 return; |
| 9709 } | 9714 } |
| 9710 } | 9715 } |
| 9711 | 9716 |
| 9712 return args[0]; | 9717 args.GetReturnValue().Set(args[0]); |
| 9713 } | 9718 } |
| 9714 | 9719 |
| 9715 | 9720 |
| 9716 // Test that a call handler can be set for objects which will allow | 9721 // Test that a call handler can be set for objects which will allow |
| 9717 // non-function objects created through the API to be called as | 9722 // non-function objects created through the API to be called as |
| 9718 // functions. | 9723 // functions. |
| 9719 THREADED_TEST(CallAsFunction) { | 9724 THREADED_TEST(CallAsFunction) { |
| 9720 LocalContext context; | 9725 LocalContext context; |
| 9721 v8::HandleScope scope(context->GetIsolate()); | 9726 v8::HandleScope scope(context->GetIsolate()); |
| 9722 | 9727 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9906 CHECK_EQ(j + 1 + kIterations, CountHandles()); | 9911 CHECK_EQ(j + 1 + kIterations, CountHandles()); |
| 9907 } | 9912 } |
| 9908 } | 9913 } |
| 9909 CHECK_EQ(kIterations, CountHandles()); | 9914 CHECK_EQ(kIterations, CountHandles()); |
| 9910 } | 9915 } |
| 9911 CHECK_EQ(0, CountHandles()); | 9916 CHECK_EQ(0, CountHandles()); |
| 9912 CHECK_EQ(kNesting * kIterations, Recurse(kNesting, kIterations)); | 9917 CHECK_EQ(kNesting * kIterations, Recurse(kNesting, kIterations)); |
| 9913 } | 9918 } |
| 9914 | 9919 |
| 9915 | 9920 |
| 9916 static v8::Handle<Value> InterceptorHasOwnPropertyGetter( | 9921 static void InterceptorHasOwnPropertyGetter( |
| 9917 Local<String> name, | 9922 Local<String> name, |
| 9918 const AccessorInfo& info) { | 9923 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 9919 ApiTestFuzzer::Fuzz(); | 9924 ApiTestFuzzer::Fuzz(); |
| 9920 return v8::Handle<Value>(); | |
| 9921 } | 9925 } |
| 9922 | 9926 |
| 9923 | 9927 |
| 9924 THREADED_TEST(InterceptorHasOwnProperty) { | 9928 THREADED_TEST(InterceptorHasOwnProperty) { |
| 9925 LocalContext context; | 9929 LocalContext context; |
| 9926 v8::HandleScope scope(context->GetIsolate()); | 9930 v8::HandleScope scope(context->GetIsolate()); |
| 9927 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 9931 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 9928 Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate(); | 9932 Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate(); |
| 9929 instance_templ->SetNamedPropertyHandler(InterceptorHasOwnPropertyGetter); | 9933 instance_templ->SetNamedPropertyHandler(InterceptorHasOwnPropertyGetter); |
| 9930 Local<Function> function = fun_templ->GetFunction(); | 9934 Local<Function> function = fun_templ->GetFunction(); |
| 9931 context->Global()->Set(v8_str("constructor"), function); | 9935 context->Global()->Set(v8_str("constructor"), function); |
| 9932 v8::Handle<Value> value = CompileRun( | 9936 v8::Handle<Value> value = CompileRun( |
| 9933 "var o = new constructor();" | 9937 "var o = new constructor();" |
| 9934 "o.hasOwnProperty('ostehaps');"); | 9938 "o.hasOwnProperty('ostehaps');"); |
| 9935 CHECK_EQ(false, value->BooleanValue()); | 9939 CHECK_EQ(false, value->BooleanValue()); |
| 9936 value = CompileRun( | 9940 value = CompileRun( |
| 9937 "o.ostehaps = 42;" | 9941 "o.ostehaps = 42;" |
| 9938 "o.hasOwnProperty('ostehaps');"); | 9942 "o.hasOwnProperty('ostehaps');"); |
| 9939 CHECK_EQ(true, value->BooleanValue()); | 9943 CHECK_EQ(true, value->BooleanValue()); |
| 9940 value = CompileRun( | 9944 value = CompileRun( |
| 9941 "var p = new constructor();" | 9945 "var p = new constructor();" |
| 9942 "p.hasOwnProperty('ostehaps');"); | 9946 "p.hasOwnProperty('ostehaps');"); |
| 9943 CHECK_EQ(false, value->BooleanValue()); | 9947 CHECK_EQ(false, value->BooleanValue()); |
| 9944 } | 9948 } |
| 9945 | 9949 |
| 9946 | 9950 |
| 9947 static v8::Handle<Value> InterceptorHasOwnPropertyGetterGC( | 9951 static void InterceptorHasOwnPropertyGetterGC( |
| 9948 Local<String> name, | 9952 Local<String> name, |
| 9949 const AccessorInfo& info) { | 9953 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 9950 ApiTestFuzzer::Fuzz(); | 9954 ApiTestFuzzer::Fuzz(); |
| 9951 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 9955 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 9952 return v8::Handle<Value>(); | |
| 9953 } | 9956 } |
| 9954 | 9957 |
| 9955 | 9958 |
| 9956 THREADED_TEST(InterceptorHasOwnPropertyCausingGC) { | 9959 THREADED_TEST(InterceptorHasOwnPropertyCausingGC) { |
| 9957 LocalContext context; | 9960 LocalContext context; |
| 9958 v8::HandleScope scope(context->GetIsolate()); | 9961 v8::HandleScope scope(context->GetIsolate()); |
| 9959 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 9962 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 9960 Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate(); | 9963 Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate(); |
| 9961 instance_templ->SetNamedPropertyHandler(InterceptorHasOwnPropertyGetterGC); | 9964 instance_templ->SetNamedPropertyHandler(InterceptorHasOwnPropertyGetterGC); |
| 9962 Local<Function> function = fun_templ->GetFunction(); | 9965 Local<Function> function = fun_templ->GetFunction(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 9975 "x = makestr(31415);" | 9978 "x = makestr(31415);" |
| 9976 "x = makestr(23456);"); | 9979 "x = makestr(23456);"); |
| 9977 v8::Handle<Value> value = CompileRun( | 9980 v8::Handle<Value> value = CompileRun( |
| 9978 "var o = new constructor();" | 9981 "var o = new constructor();" |
| 9979 "o.__proto__ = new String(x);" | 9982 "o.__proto__ = new String(x);" |
| 9980 "o.hasOwnProperty('ostehaps');"); | 9983 "o.hasOwnProperty('ostehaps');"); |
| 9981 CHECK_EQ(false, value->BooleanValue()); | 9984 CHECK_EQ(false, value->BooleanValue()); |
| 9982 } | 9985 } |
| 9983 | 9986 |
| 9984 | 9987 |
| 9985 typedef v8::Handle<Value> (*NamedPropertyGetter)(Local<String> property, | 9988 typedef void (*NamedPropertyGetter)( |
| 9986 const AccessorInfo& info); | 9989 Local<String> property, |
| 9990 const v8::PropertyCallbackInfo<v8::Value>& info); |
| 9987 | 9991 |
| 9988 | 9992 |
| 9989 static void CheckInterceptorLoadIC(NamedPropertyGetter getter, | 9993 static void CheckInterceptorLoadIC(NamedPropertyGetter getter, |
| 9990 const char* source, | 9994 const char* source, |
| 9991 int expected) { | 9995 int expected) { |
| 9992 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 9996 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 9993 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 9997 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 9994 templ->SetNamedPropertyHandler(getter, 0, 0, 0, 0, v8_str("data")); | 9998 templ->SetNamedPropertyHandler(getter, 0, 0, 0, 0, v8_str("data")); |
| 9995 LocalContext context; | 9999 LocalContext context; |
| 9996 context->Global()->Set(v8_str("o"), templ->NewInstance()); | 10000 context->Global()->Set(v8_str("o"), templ->NewInstance()); |
| 9997 v8::Handle<Value> value = CompileRun(source); | 10001 v8::Handle<Value> value = CompileRun(source); |
| 9998 CHECK_EQ(expected, value->Int32Value()); | 10002 CHECK_EQ(expected, value->Int32Value()); |
| 9999 } | 10003 } |
| 10000 | 10004 |
| 10001 | 10005 |
| 10002 static v8::Handle<Value> InterceptorLoadICGetter(Local<String> name, | 10006 static void InterceptorLoadICGetter( |
| 10003 const AccessorInfo& info) { | 10007 Local<String> name, |
| 10008 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 10004 ApiTestFuzzer::Fuzz(); | 10009 ApiTestFuzzer::Fuzz(); |
| 10005 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 10010 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 10006 CHECK_EQ(isolate, info.GetIsolate()); | 10011 CHECK_EQ(isolate, info.GetIsolate()); |
| 10007 CHECK_EQ(v8_str("data"), info.Data()); | 10012 CHECK_EQ(v8_str("data"), info.Data()); |
| 10008 CHECK_EQ(v8_str("x"), name); | 10013 CHECK_EQ(v8_str("x"), name); |
| 10009 return v8::Integer::New(42); | 10014 info.GetReturnValue().Set(v8::Integer::New(42)); |
| 10010 } | 10015 } |
| 10011 | 10016 |
| 10012 | 10017 |
| 10013 // This test should hit the load IC for the interceptor case. | 10018 // This test should hit the load IC for the interceptor case. |
| 10014 THREADED_TEST(InterceptorLoadIC) { | 10019 THREADED_TEST(InterceptorLoadIC) { |
| 10015 CheckInterceptorLoadIC(InterceptorLoadICGetter, | 10020 CheckInterceptorLoadIC(InterceptorLoadICGetter, |
| 10016 "var result = 0;" | 10021 "var result = 0;" |
| 10017 "for (var i = 0; i < 1000; i++) {" | 10022 "for (var i = 0; i < 1000; i++) {" |
| 10018 " result = o.x;" | 10023 " result = o.x;" |
| 10019 "}", | 10024 "}", |
| 10020 42); | 10025 42); |
| 10021 } | 10026 } |
| 10022 | 10027 |
| 10023 | 10028 |
| 10024 // Below go several tests which verify that JITing for various | 10029 // Below go several tests which verify that JITing for various |
| 10025 // configurations of interceptor and explicit fields works fine | 10030 // configurations of interceptor and explicit fields works fine |
| 10026 // (those cases are special cased to get better performance). | 10031 // (those cases are special cased to get better performance). |
| 10027 | 10032 |
| 10028 static v8::Handle<Value> InterceptorLoadXICGetter(Local<String> name, | 10033 static void InterceptorLoadXICGetter( |
| 10029 const AccessorInfo& info) { | 10034 Local<String> name, |
| 10035 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 10030 ApiTestFuzzer::Fuzz(); | 10036 ApiTestFuzzer::Fuzz(); |
| 10031 return v8_str("x")->Equals(name) | 10037 info.GetReturnValue().Set( |
| 10032 ? v8::Handle<v8::Value>(v8::Integer::New(42)) : v8::Handle<v8::Value>(); | 10038 v8_str("x")->Equals(name) ? |
| 10039 v8::Handle<v8::Value>(v8::Integer::New(42)) : |
| 10040 v8::Handle<v8::Value>()); |
| 10033 } | 10041 } |
| 10034 | 10042 |
| 10035 | 10043 |
| 10036 THREADED_TEST(InterceptorLoadICWithFieldOnHolder) { | 10044 THREADED_TEST(InterceptorLoadICWithFieldOnHolder) { |
| 10037 CheckInterceptorLoadIC(InterceptorLoadXICGetter, | 10045 CheckInterceptorLoadIC(InterceptorLoadXICGetter, |
| 10038 "var result = 0;" | 10046 "var result = 0;" |
| 10039 "o.y = 239;" | 10047 "o.y = 239;" |
| 10040 "for (var i = 0; i < 1000; i++) {" | 10048 "for (var i = 0; i < 1000; i++) {" |
| 10041 " result = o.y;" | 10049 " result = o.y;" |
| 10042 "}", | 10050 "}", |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10131 "var result = 0;" | 10139 "var result = 0;" |
| 10132 "for (var i = 0; i < 1000; i++) {" | 10140 "for (var i = 0; i < 1000; i++) {" |
| 10133 " result += o.y;" | 10141 " result += o.y;" |
| 10134 "}" | 10142 "}" |
| 10135 "result;", | 10143 "result;", |
| 10136 42 * 1000); | 10144 42 * 1000); |
| 10137 } | 10145 } |
| 10138 | 10146 |
| 10139 | 10147 |
| 10140 static int interceptor_load_not_handled_calls = 0; | 10148 static int interceptor_load_not_handled_calls = 0; |
| 10141 static v8::Handle<Value> InterceptorLoadNotHandled(Local<String> name, | 10149 static void InterceptorLoadNotHandled( |
| 10142 const AccessorInfo& info) { | 10150 Local<String> name, |
| 10151 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 10143 ++interceptor_load_not_handled_calls; | 10152 ++interceptor_load_not_handled_calls; |
| 10144 return v8::Handle<v8::Value>(); | |
| 10145 } | 10153 } |
| 10146 | 10154 |
| 10147 | 10155 |
| 10148 // Test how post-interceptor lookups are done in the non-cacheable | 10156 // Test how post-interceptor lookups are done in the non-cacheable |
| 10149 // case: the interceptor should not be invoked during this lookup. | 10157 // case: the interceptor should not be invoked during this lookup. |
| 10150 THREADED_TEST(InterceptorLoadICPostInterceptor) { | 10158 THREADED_TEST(InterceptorLoadICPostInterceptor) { |
| 10151 interceptor_load_not_handled_calls = 0; | 10159 interceptor_load_not_handled_calls = 0; |
| 10152 CheckInterceptorLoadIC(InterceptorLoadNotHandled, | 10160 CheckInterceptorLoadIC(InterceptorLoadNotHandled, |
| 10153 "receiver = new Object();" | 10161 "receiver = new Object();" |
| 10154 "receiver.__proto__ = o;" | 10162 "receiver.__proto__ = o;" |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10368 "this.y = 42;" | 10376 "this.y = 42;" |
| 10369 "var result = 0;" | 10377 "var result = 0;" |
| 10370 "for (var i = 0; i < 10; i++) {" | 10378 "for (var i = 0; i < 10; i++) {" |
| 10371 " result += o.y;" | 10379 " result += o.y;" |
| 10372 "}" | 10380 "}" |
| 10373 "result"); | 10381 "result"); |
| 10374 CHECK_EQ(42 * 10, value->Int32Value()); | 10382 CHECK_EQ(42 * 10, value->Int32Value()); |
| 10375 } | 10383 } |
| 10376 | 10384 |
| 10377 | 10385 |
| 10378 static v8::Handle<Value> InterceptorLoadICGetter0(Local<String> name, | 10386 static void InterceptorLoadICGetter0( |
| 10379 const AccessorInfo& info) { | 10387 Local<String> name, |
| 10388 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 10380 ApiTestFuzzer::Fuzz(); | 10389 ApiTestFuzzer::Fuzz(); |
| 10381 CHECK(v8_str("x")->Equals(name)); | 10390 CHECK(v8_str("x")->Equals(name)); |
| 10382 return v8::Integer::New(0); | 10391 info.GetReturnValue().Set(v8::Integer::New(0)); |
| 10383 } | 10392 } |
| 10384 | 10393 |
| 10385 | 10394 |
| 10386 THREADED_TEST(InterceptorReturningZero) { | 10395 THREADED_TEST(InterceptorReturningZero) { |
| 10387 CheckInterceptorLoadIC(InterceptorLoadICGetter0, | 10396 CheckInterceptorLoadIC(InterceptorLoadICGetter0, |
| 10388 "o.x == undefined ? 1 : 0", | 10397 "o.x == undefined ? 1 : 0", |
| 10389 0); | 10398 0); |
| 10390 } | 10399 } |
| 10391 | 10400 |
| 10392 | 10401 |
| 10393 static v8::Handle<Value> InterceptorStoreICSetter( | 10402 static void InterceptorStoreICSetter( |
| 10394 Local<String> key, Local<Value> value, const AccessorInfo&) { | 10403 Local<String> key, |
| 10404 Local<Value> value, |
| 10405 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 10395 CHECK(v8_str("x")->Equals(key)); | 10406 CHECK(v8_str("x")->Equals(key)); |
| 10396 CHECK_EQ(42, value->Int32Value()); | 10407 CHECK_EQ(42, value->Int32Value()); |
| 10397 return value; | 10408 info.GetReturnValue().Set(value); |
| 10398 } | 10409 } |
| 10399 | 10410 |
| 10400 | 10411 |
| 10401 // This test should hit the store IC for the interceptor case. | 10412 // This test should hit the store IC for the interceptor case. |
| 10402 THREADED_TEST(InterceptorStoreIC) { | 10413 THREADED_TEST(InterceptorStoreIC) { |
| 10403 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10414 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 10404 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 10415 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 10405 templ->SetNamedPropertyHandler(InterceptorLoadICGetter, | 10416 templ->SetNamedPropertyHandler(InterceptorLoadICGetter, |
| 10406 InterceptorStoreICSetter, | 10417 InterceptorStoreICSetter, |
| 10407 0, 0, 0, v8_str("data")); | 10418 0, 0, 0, v8_str("data")); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 10428 CHECK_EQ(239 + 42, value->Int32Value()); | 10439 CHECK_EQ(239 + 42, value->Int32Value()); |
| 10429 } | 10440 } |
| 10430 | 10441 |
| 10431 | 10442 |
| 10432 | 10443 |
| 10433 | 10444 |
| 10434 v8::Handle<Value> call_ic_function; | 10445 v8::Handle<Value> call_ic_function; |
| 10435 v8::Handle<Value> call_ic_function2; | 10446 v8::Handle<Value> call_ic_function2; |
| 10436 v8::Handle<Value> call_ic_function3; | 10447 v8::Handle<Value> call_ic_function3; |
| 10437 | 10448 |
| 10438 static v8::Handle<Value> InterceptorCallICGetter(Local<String> name, | 10449 static void InterceptorCallICGetter( |
| 10439 const AccessorInfo& info) { | 10450 Local<String> name, |
| 10451 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 10440 ApiTestFuzzer::Fuzz(); | 10452 ApiTestFuzzer::Fuzz(); |
| 10441 CHECK(v8_str("x")->Equals(name)); | 10453 CHECK(v8_str("x")->Equals(name)); |
| 10442 return call_ic_function; | 10454 info.GetReturnValue().Set(call_ic_function); |
| 10443 } | 10455 } |
| 10444 | 10456 |
| 10445 | 10457 |
| 10446 // This test should hit the call IC for the interceptor case. | 10458 // This test should hit the call IC for the interceptor case. |
| 10447 THREADED_TEST(InterceptorCallIC) { | 10459 THREADED_TEST(InterceptorCallIC) { |
| 10448 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10460 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 10449 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 10461 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 10450 templ->SetNamedPropertyHandler(InterceptorCallICGetter); | 10462 templ->SetNamedPropertyHandler(InterceptorCallICGetter); |
| 10451 LocalContext context; | 10463 LocalContext context; |
| 10452 context->Global()->Set(v8_str("o"), templ->NewInstance()); | 10464 context->Global()->Set(v8_str("o"), templ->NewInstance()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 10473 "o.x = function f(x) { return x + 1; };" | 10485 "o.x = function f(x) { return x + 1; };" |
| 10474 "var result = 0;" | 10486 "var result = 0;" |
| 10475 "for (var i = 0; i < 7; i++) {" | 10487 "for (var i = 0; i < 7; i++) {" |
| 10476 " result = o.x(41);" | 10488 " result = o.x(41);" |
| 10477 "}"); | 10489 "}"); |
| 10478 CHECK_EQ(42, value->Int32Value()); | 10490 CHECK_EQ(42, value->Int32Value()); |
| 10479 } | 10491 } |
| 10480 | 10492 |
| 10481 | 10493 |
| 10482 static v8::Handle<Value> call_ic_function4; | 10494 static v8::Handle<Value> call_ic_function4; |
| 10483 static v8::Handle<Value> InterceptorCallICGetter4(Local<String> name, | 10495 static void InterceptorCallICGetter4( |
| 10484 const AccessorInfo& info) { | 10496 Local<String> name, |
| 10497 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 10485 ApiTestFuzzer::Fuzz(); | 10498 ApiTestFuzzer::Fuzz(); |
| 10486 CHECK(v8_str("x")->Equals(name)); | 10499 CHECK(v8_str("x")->Equals(name)); |
| 10487 return call_ic_function4; | 10500 info.GetReturnValue().Set(call_ic_function4); |
| 10488 } | 10501 } |
| 10489 | 10502 |
| 10490 | 10503 |
| 10491 // This test checks that if interceptor provides a function, | 10504 // This test checks that if interceptor provides a function, |
| 10492 // even if we cached shadowed variant, interceptor's function | 10505 // even if we cached shadowed variant, interceptor's function |
| 10493 // is invoked | 10506 // is invoked |
| 10494 THREADED_TEST(InterceptorCallICCacheableNotNeeded) { | 10507 THREADED_TEST(InterceptorCallICCacheableNotNeeded) { |
| 10495 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10508 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 10496 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 10509 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 10497 templ->SetNamedPropertyHandler(InterceptorCallICGetter4); | 10510 templ->SetNamedPropertyHandler(InterceptorCallICGetter4); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10550 "o.x = inc;" | 10563 "o.x = inc;" |
| 10551 "var result = 0;" | 10564 "var result = 0;" |
| 10552 "for (var i = 0; i < 1000; i++) {" | 10565 "for (var i = 0; i < 1000; i++) {" |
| 10553 " result = o.x(42);" | 10566 " result = o.x(42);" |
| 10554 "}"); | 10567 "}"); |
| 10555 CHECK_EQ(43, value->Int32Value()); | 10568 CHECK_EQ(43, value->Int32Value()); |
| 10556 } | 10569 } |
| 10557 | 10570 |
| 10558 | 10571 |
| 10559 static v8::Handle<Value> call_ic_function5; | 10572 static v8::Handle<Value> call_ic_function5; |
| 10560 static v8::Handle<Value> InterceptorCallICGetter5(Local<String> name, | 10573 static void InterceptorCallICGetter5( |
| 10561 const AccessorInfo& info) { | 10574 Local<String> name, |
| 10575 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 10562 ApiTestFuzzer::Fuzz(); | 10576 ApiTestFuzzer::Fuzz(); |
| 10563 if (v8_str("x")->Equals(name)) | 10577 if (v8_str("x")->Equals(name)) |
| 10564 return call_ic_function5; | 10578 info.GetReturnValue().Set(call_ic_function5); |
| 10565 else | |
| 10566 return Local<Value>(); | |
| 10567 } | 10579 } |
| 10568 | 10580 |
| 10569 | 10581 |
| 10570 // This test checks that if interceptor provides a function, | 10582 // This test checks that if interceptor provides a function, |
| 10571 // even if we cached constant function, interceptor's function | 10583 // even if we cached constant function, interceptor's function |
| 10572 // is invoked | 10584 // is invoked |
| 10573 THREADED_TEST(InterceptorCallICConstantFunctionNotNeeded) { | 10585 THREADED_TEST(InterceptorCallICConstantFunctionNotNeeded) { |
| 10574 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10586 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 10575 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 10587 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 10576 templ->SetNamedPropertyHandler(InterceptorCallICGetter5); | 10588 templ->SetNamedPropertyHandler(InterceptorCallICGetter5); |
| 10577 LocalContext context; | 10589 LocalContext context; |
| 10578 context->Global()->Set(v8_str("o"), templ->NewInstance()); | 10590 context->Global()->Set(v8_str("o"), templ->NewInstance()); |
| 10579 call_ic_function5 = | 10591 call_ic_function5 = |
| 10580 v8_compile("function f(x) { return x - 1; }; f")->Run(); | 10592 v8_compile("function f(x) { return x - 1; }; f")->Run(); |
| 10581 v8::Handle<Value> value = CompileRun( | 10593 v8::Handle<Value> value = CompileRun( |
| 10582 "function inc(x) { return x + 1; };" | 10594 "function inc(x) { return x + 1; };" |
| 10583 "inc(1);" | 10595 "inc(1);" |
| 10584 "o.x = inc;" | 10596 "o.x = inc;" |
| 10585 "var result = 0;" | 10597 "var result = 0;" |
| 10586 "for (var i = 0; i < 1000; i++) {" | 10598 "for (var i = 0; i < 1000; i++) {" |
| 10587 " result = o.x(42);" | 10599 " result = o.x(42);" |
| 10588 "}"); | 10600 "}"); |
| 10589 CHECK_EQ(41, value->Int32Value()); | 10601 CHECK_EQ(41, value->Int32Value()); |
| 10590 } | 10602 } |
| 10591 | 10603 |
| 10592 | 10604 |
| 10593 static v8::Handle<Value> call_ic_function6; | 10605 static v8::Handle<Value> call_ic_function6; |
| 10594 static v8::Handle<Value> InterceptorCallICGetter6(Local<String> name, | 10606 static void InterceptorCallICGetter6( |
| 10595 const AccessorInfo& info) { | 10607 Local<String> name, |
| 10608 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 10596 ApiTestFuzzer::Fuzz(); | 10609 ApiTestFuzzer::Fuzz(); |
| 10597 if (v8_str("x")->Equals(name)) | 10610 if (v8_str("x")->Equals(name)) |
| 10598 return call_ic_function6; | 10611 info.GetReturnValue().Set(call_ic_function6); |
| 10599 else | |
| 10600 return Local<Value>(); | |
| 10601 } | 10612 } |
| 10602 | 10613 |
| 10603 | 10614 |
| 10604 // Same test as above, except the code is wrapped in a function | 10615 // Same test as above, except the code is wrapped in a function |
| 10605 // to test the optimized compiler. | 10616 // to test the optimized compiler. |
| 10606 THREADED_TEST(InterceptorCallICConstantFunctionNotNeededWrapped) { | 10617 THREADED_TEST(InterceptorCallICConstantFunctionNotNeededWrapped) { |
| 10607 i::FLAG_allow_natives_syntax = true; | 10618 i::FLAG_allow_natives_syntax = true; |
| 10608 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10619 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 10609 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 10620 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 10610 templ->SetNamedPropertyHandler(InterceptorCallICGetter6); | 10621 templ->SetNamedPropertyHandler(InterceptorCallICGetter6); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10709 " for (var i = 0; i < 10; i++) {" | 10720 " for (var i = 0; i < 10; i++) {" |
| 10710 " result += o.parseFloat('239');" | 10721 " result += o.parseFloat('239');" |
| 10711 " }" | 10722 " }" |
| 10712 " result" | 10723 " result" |
| 10713 "} catch(e) {" | 10724 "} catch(e) {" |
| 10714 " e" | 10725 " e" |
| 10715 "};"); | 10726 "};"); |
| 10716 CHECK_EQ(239 * 10, value->Int32Value()); | 10727 CHECK_EQ(239 * 10, value->Int32Value()); |
| 10717 } | 10728 } |
| 10718 | 10729 |
| 10719 static v8::Handle<Value> InterceptorCallICFastApi(Local<String> name, | 10730 static void InterceptorCallICFastApi( |
| 10720 const AccessorInfo& info) { | 10731 Local<String> name, |
| 10732 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 10721 ApiTestFuzzer::Fuzz(); | 10733 ApiTestFuzzer::Fuzz(); |
| 10722 CheckReturnValue(info, FUNCTION_ADDR(InterceptorCallICFastApi)); | 10734 CheckReturnValue(info, FUNCTION_ADDR(InterceptorCallICFastApi)); |
| 10723 int* call_count = | 10735 int* call_count = |
| 10724 reinterpret_cast<int*>(v8::External::Cast(*info.Data())->Value()); | 10736 reinterpret_cast<int*>(v8::External::Cast(*info.Data())->Value()); |
| 10725 ++(*call_count); | 10737 ++(*call_count); |
| 10726 if ((*call_count) % 20 == 0) { | 10738 if ((*call_count) % 20 == 0) { |
| 10727 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 10739 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 10728 } | 10740 } |
| 10729 return v8::Handle<Value>(); | |
| 10730 } | 10741 } |
| 10731 | 10742 |
| 10732 static v8::Handle<Value> FastApiCallback_TrivialSignature( | 10743 static void FastApiCallback_TrivialSignature( |
| 10733 const v8::Arguments& args) { | 10744 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 10734 ApiTestFuzzer::Fuzz(); | 10745 ApiTestFuzzer::Fuzz(); |
| 10735 CheckReturnValue(args, FUNCTION_ADDR(FastApiCallback_TrivialSignature)); | 10746 CheckReturnValue(args, FUNCTION_ADDR(FastApiCallback_TrivialSignature)); |
| 10736 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 10747 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 10737 CHECK_EQ(isolate, args.GetIsolate()); | 10748 CHECK_EQ(isolate, args.GetIsolate()); |
| 10738 CHECK_EQ(args.This(), args.Holder()); | 10749 CHECK_EQ(args.This(), args.Holder()); |
| 10739 CHECK(args.Data()->Equals(v8_str("method_data"))); | 10750 CHECK(args.Data()->Equals(v8_str("method_data"))); |
| 10740 return v8::Integer::New(args[0]->Int32Value() + 1); | 10751 args.GetReturnValue().Set(args[0]->Int32Value() + 1); |
| 10741 } | 10752 } |
| 10742 | 10753 |
| 10743 static v8::Handle<Value> FastApiCallback_SimpleSignature( | 10754 static void FastApiCallback_SimpleSignature( |
| 10744 const v8::Arguments& args) { | 10755 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 10745 ApiTestFuzzer::Fuzz(); | 10756 ApiTestFuzzer::Fuzz(); |
| 10746 CheckReturnValue(args, FUNCTION_ADDR(FastApiCallback_SimpleSignature)); | 10757 CheckReturnValue(args, FUNCTION_ADDR(FastApiCallback_SimpleSignature)); |
| 10747 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 10758 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 10748 CHECK_EQ(isolate, args.GetIsolate()); | 10759 CHECK_EQ(isolate, args.GetIsolate()); |
| 10749 CHECK_EQ(args.This()->GetPrototype(), args.Holder()); | 10760 CHECK_EQ(args.This()->GetPrototype(), args.Holder()); |
| 10750 CHECK(args.Data()->Equals(v8_str("method_data"))); | 10761 CHECK(args.Data()->Equals(v8_str("method_data"))); |
| 10751 // Note, we're using HasRealNamedProperty instead of Has to avoid | 10762 // Note, we're using HasRealNamedProperty instead of Has to avoid |
| 10752 // invoking the interceptor again. | 10763 // invoking the interceptor again. |
| 10753 CHECK(args.Holder()->HasRealNamedProperty(v8_str("foo"))); | 10764 CHECK(args.Holder()->HasRealNamedProperty(v8_str("foo"))); |
| 10754 return v8::Integer::New(args[0]->Int32Value() + 1); | 10765 args.GetReturnValue().Set(args[0]->Int32Value() + 1); |
| 10755 } | 10766 } |
| 10756 | 10767 |
| 10757 // Helper to maximize the odds of object moving. | 10768 // Helper to maximize the odds of object moving. |
| 10758 static void GenerateSomeGarbage() { | 10769 static void GenerateSomeGarbage() { |
| 10759 CompileRun( | 10770 CompileRun( |
| 10760 "var garbage;" | 10771 "var garbage;" |
| 10761 "for (var i = 0; i < 1000; i++) {" | 10772 "for (var i = 0; i < 1000; i++) {" |
| 10762 " garbage = [1/i, \"garbage\" + i, garbage, {foo: garbage}];" | 10773 " garbage = [1/i, \"garbage\" + i, garbage, {foo: garbage}];" |
| 10763 "}" | 10774 "}" |
| 10764 "garbage = undefined;"); | 10775 "garbage = undefined;"); |
| 10765 } | 10776 } |
| 10766 | 10777 |
| 10767 | 10778 |
| 10768 v8::Handle<v8::Value> DirectApiCallback(const v8::Arguments& args) { | 10779 void DirectApiCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 10769 static int count = 0; | 10780 static int count = 0; |
| 10770 if (count++ % 3 == 0) { | 10781 if (count++ % 3 == 0) { |
| 10771 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 10782 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
| 10772 // This should move the stub | 10783 // This should move the stub |
| 10773 GenerateSomeGarbage(); // This should ensure the old stub memory is flushed | 10784 GenerateSomeGarbage(); // This should ensure the old stub memory is flushed |
| 10774 } | 10785 } |
| 10775 return v8::Handle<v8::Value>(); | |
| 10776 } | 10786 } |
| 10777 | 10787 |
| 10778 | 10788 |
| 10779 THREADED_TEST(CallICFastApi_DirectCall_GCMoveStub) { | 10789 THREADED_TEST(CallICFastApi_DirectCall_GCMoveStub) { |
| 10780 LocalContext context; | 10790 LocalContext context; |
| 10781 v8::HandleScope scope(context->GetIsolate()); | 10791 v8::HandleScope scope(context->GetIsolate()); |
| 10782 v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New(); | 10792 v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New(); |
| 10783 nativeobject_templ->Set("callback", | 10793 nativeobject_templ->Set("callback", |
| 10784 v8::FunctionTemplate::New(DirectApiCallback)); | 10794 v8::FunctionTemplate::New(DirectApiCallback)); |
| 10785 v8::Local<v8::Object> nativeobject_obj = nativeobject_templ->NewInstance(); | 10795 v8::Local<v8::Object> nativeobject_obj = nativeobject_templ->NewInstance(); |
| 10786 context->Global()->Set(v8_str("nativeobject"), nativeobject_obj); | 10796 context->Global()->Set(v8_str("nativeobject"), nativeobject_obj); |
| 10787 // call the api function multiple times to ensure direct call stub creation. | 10797 // call the api function multiple times to ensure direct call stub creation. |
| 10788 CompileRun( | 10798 CompileRun( |
| 10789 "function f() {" | 10799 "function f() {" |
| 10790 " for (var i = 1; i <= 30; i++) {" | 10800 " for (var i = 1; i <= 30; i++) {" |
| 10791 " nativeobject.callback();" | 10801 " nativeobject.callback();" |
| 10792 " }" | 10802 " }" |
| 10793 "}" | 10803 "}" |
| 10794 "f();"); | 10804 "f();"); |
| 10795 } | 10805 } |
| 10796 | 10806 |
| 10797 | 10807 |
| 10798 v8::Handle<v8::Value> ThrowingDirectApiCallback(const v8::Arguments& args) { | 10808 void ThrowingDirectApiCallback( |
| 10799 return v8::ThrowException(v8_str("g")); | 10809 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 10810 v8::ThrowException(v8_str("g")); |
| 10800 } | 10811 } |
| 10801 | 10812 |
| 10802 | 10813 |
| 10803 THREADED_TEST(CallICFastApi_DirectCall_Throw) { | 10814 THREADED_TEST(CallICFastApi_DirectCall_Throw) { |
| 10804 LocalContext context; | 10815 LocalContext context; |
| 10805 v8::HandleScope scope(context->GetIsolate()); | 10816 v8::HandleScope scope(context->GetIsolate()); |
| 10806 v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New(); | 10817 v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New(); |
| 10807 nativeobject_templ->Set("callback", | 10818 nativeobject_templ->Set("callback", |
| 10808 v8::FunctionTemplate::New(ThrowingDirectApiCallback)); | 10819 v8::FunctionTemplate::New(ThrowingDirectApiCallback)); |
| 10809 v8::Local<v8::Object> nativeobject_obj = nativeobject_templ->NewInstance(); | 10820 v8::Local<v8::Object> nativeobject_obj = nativeobject_templ->NewInstance(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 10822 | 10833 |
| 10823 | 10834 |
| 10824 static Handle<Value> DoDirectGetter() { | 10835 static Handle<Value> DoDirectGetter() { |
| 10825 if (++p_getter_count % 3 == 0) { | 10836 if (++p_getter_count % 3 == 0) { |
| 10826 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 10837 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
| 10827 GenerateSomeGarbage(); | 10838 GenerateSomeGarbage(); |
| 10828 } | 10839 } |
| 10829 return v8_str("Direct Getter Result"); | 10840 return v8_str("Direct Getter Result"); |
| 10830 } | 10841 } |
| 10831 | 10842 |
| 10832 static v8::Handle<v8::Value> DirectGetter(Local<String> name, | |
| 10833 const v8::AccessorInfo& info) { | |
| 10834 CheckReturnValue(info, FUNCTION_ADDR(DirectGetter)); | |
| 10835 info.GetReturnValue().Set(v8_str("Garbage")); | |
| 10836 return DoDirectGetter(); | |
| 10837 } | |
| 10838 | |
| 10839 static v8::Handle<v8::Value> DirectGetterIndirect( | |
| 10840 Local<String> name, | |
| 10841 const v8::AccessorInfo& info) { | |
| 10842 CheckReturnValue(info, FUNCTION_ADDR(DirectGetterIndirect)); | |
| 10843 info.GetReturnValue().Set(DoDirectGetter()); | |
| 10844 return v8::Handle<v8::Value>(); | |
| 10845 } | |
| 10846 | |
| 10847 static void DirectGetterCallback( | 10843 static void DirectGetterCallback( |
| 10848 Local<String> name, | 10844 Local<String> name, |
| 10849 const v8::PropertyCallbackInfo<v8::Value>& info) { | 10845 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 10850 CheckReturnValue(info, FUNCTION_ADDR(DirectGetterCallback)); | 10846 CheckReturnValue(info, FUNCTION_ADDR(DirectGetterCallback)); |
| 10851 info.GetReturnValue().Set(DoDirectGetter()); | 10847 info.GetReturnValue().Set(DoDirectGetter()); |
| 10852 } | 10848 } |
| 10853 | 10849 |
| 10854 | 10850 |
| 10855 template<typename Accessor> | 10851 template<typename Accessor> |
| 10856 static void LoadICFastApi_DirectCall_GCMoveStub(Accessor accessor) { | 10852 static void LoadICFastApi_DirectCall_GCMoveStub(Accessor accessor) { |
| 10857 LocalContext context; | 10853 LocalContext context; |
| 10858 v8::HandleScope scope(context->GetIsolate()); | 10854 v8::HandleScope scope(context->GetIsolate()); |
| 10859 v8::Handle<v8::ObjectTemplate> obj = v8::ObjectTemplate::New(); | 10855 v8::Handle<v8::ObjectTemplate> obj = v8::ObjectTemplate::New(); |
| 10860 obj->SetAccessor(v8_str("p1"), accessor); | 10856 obj->SetAccessor(v8_str("p1"), accessor); |
| 10861 context->Global()->Set(v8_str("o1"), obj->NewInstance()); | 10857 context->Global()->Set(v8_str("o1"), obj->NewInstance()); |
| 10862 p_getter_count = 0; | 10858 p_getter_count = 0; |
| 10863 v8::Handle<v8::Value> result = CompileRun( | 10859 v8::Handle<v8::Value> result = CompileRun( |
| 10864 "function f() {" | 10860 "function f() {" |
| 10865 " for (var i = 0; i < 30; i++) o1.p1;" | 10861 " for (var i = 0; i < 30; i++) o1.p1;" |
| 10866 " return o1.p1" | 10862 " return o1.p1" |
| 10867 "}" | 10863 "}" |
| 10868 "f();"); | 10864 "f();"); |
| 10869 CHECK_EQ(v8_str("Direct Getter Result"), result); | 10865 CHECK_EQ(v8_str("Direct Getter Result"), result); |
| 10870 CHECK_EQ(31, p_getter_count); | 10866 CHECK_EQ(31, p_getter_count); |
| 10871 } | 10867 } |
| 10872 | 10868 |
| 10873 THREADED_TEST(LoadICFastApi_DirectCall_GCMoveStub) { | 10869 THREADED_TEST(LoadICFastApi_DirectCall_GCMoveStub) { |
| 10874 LoadICFastApi_DirectCall_GCMoveStub(DirectGetterIndirect); | |
| 10875 LoadICFastApi_DirectCall_GCMoveStub(DirectGetterCallback); | 10870 LoadICFastApi_DirectCall_GCMoveStub(DirectGetterCallback); |
| 10876 LoadICFastApi_DirectCall_GCMoveStub(DirectGetter); | |
| 10877 } | 10871 } |
| 10878 | 10872 |
| 10879 | 10873 |
| 10880 v8::Handle<v8::Value> ThrowingDirectGetterCallback( | 10874 void ThrowingDirectGetterCallback( |
| 10881 Local<String> name, const v8::AccessorInfo& info) { | 10875 Local<String> name, |
| 10882 return v8::ThrowException(v8_str("g")); | 10876 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 10877 v8::ThrowException(v8_str("g")); |
| 10883 } | 10878 } |
| 10884 | 10879 |
| 10885 | 10880 |
| 10886 THREADED_TEST(LoadICFastApi_DirectCall_Throw) { | 10881 THREADED_TEST(LoadICFastApi_DirectCall_Throw) { |
| 10887 LocalContext context; | 10882 LocalContext context; |
| 10888 v8::HandleScope scope(context->GetIsolate()); | 10883 v8::HandleScope scope(context->GetIsolate()); |
| 10889 v8::Handle<v8::ObjectTemplate> obj = v8::ObjectTemplate::New(); | 10884 v8::Handle<v8::ObjectTemplate> obj = v8::ObjectTemplate::New(); |
| 10890 obj->SetAccessor(v8_str("p1"), ThrowingDirectGetterCallback); | 10885 obj->SetAccessor(v8_str("p1"), ThrowingDirectGetterCallback); |
| 10891 context->Global()->Set(v8_str("o1"), obj->NewInstance()); | 10886 context->Global()->Set(v8_str("o1"), obj->NewInstance()); |
| 10892 v8::Handle<Value> result = CompileRun( | 10887 v8::Handle<Value> result = CompileRun( |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11264 "}"); | 11259 "}"); |
| 11265 CHECK(try_catch.HasCaught()); | 11260 CHECK(try_catch.HasCaught()); |
| 11266 CHECK_EQ(v8_str("TypeError: Illegal invocation"), | 11261 CHECK_EQ(v8_str("TypeError: Illegal invocation"), |
| 11267 try_catch.Exception()->ToString()); | 11262 try_catch.Exception()->ToString()); |
| 11268 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 11263 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
| 11269 } | 11264 } |
| 11270 | 11265 |
| 11271 | 11266 |
| 11272 v8::Handle<Value> keyed_call_ic_function; | 11267 v8::Handle<Value> keyed_call_ic_function; |
| 11273 | 11268 |
| 11274 static v8::Handle<Value> InterceptorKeyedCallICGetter( | 11269 static void InterceptorKeyedCallICGetter( |
| 11275 Local<String> name, const AccessorInfo& info) { | 11270 Local<String> name, |
| 11271 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 11276 ApiTestFuzzer::Fuzz(); | 11272 ApiTestFuzzer::Fuzz(); |
| 11277 if (v8_str("x")->Equals(name)) { | 11273 if (v8_str("x")->Equals(name)) { |
| 11278 return keyed_call_ic_function; | 11274 info.GetReturnValue().Set(keyed_call_ic_function); |
| 11279 } | 11275 } |
| 11280 return v8::Handle<Value>(); | |
| 11281 } | 11276 } |
| 11282 | 11277 |
| 11283 | 11278 |
| 11284 // Test the case when we stored cacheable lookup into | 11279 // Test the case when we stored cacheable lookup into |
| 11285 // a stub, but the function name changed (to another cacheable function). | 11280 // a stub, but the function name changed (to another cacheable function). |
| 11286 THREADED_TEST(InterceptorKeyedCallICKeyChange1) { | 11281 THREADED_TEST(InterceptorKeyedCallICKeyChange1) { |
| 11287 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11282 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 11288 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 11283 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 11289 templ->SetNamedPropertyHandler(NoBlockGetterX); | 11284 templ->SetNamedPropertyHandler(NoBlockGetterX); |
| 11290 LocalContext context; | 11285 LocalContext context; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11421 "for (var i = 0; i < 10; i++) {" | 11416 "for (var i = 0; i < 10; i++) {" |
| 11422 " if (i == 5) { proto.method = function(x) { return x - 1; }; };" | 11417 " if (i == 5) { proto.method = function(x) { return x - 1; }; };" |
| 11423 " result += o[m](41);" | 11418 " result += o[m](41);" |
| 11424 "}"); | 11419 "}"); |
| 11425 CHECK_EQ(42*5 + 40*5, context->Global()->Get(v8_str("result"))->Int32Value()); | 11420 CHECK_EQ(42*5 + 40*5, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 11426 } | 11421 } |
| 11427 | 11422 |
| 11428 | 11423 |
| 11429 static int interceptor_call_count = 0; | 11424 static int interceptor_call_count = 0; |
| 11430 | 11425 |
| 11431 static v8::Handle<Value> InterceptorICRefErrorGetter(Local<String> name, | 11426 static void InterceptorICRefErrorGetter( |
| 11432 const AccessorInfo& info) { | 11427 Local<String> name, |
| 11428 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 11433 ApiTestFuzzer::Fuzz(); | 11429 ApiTestFuzzer::Fuzz(); |
| 11434 if (v8_str("x")->Equals(name) && interceptor_call_count++ < 20) { | 11430 if (v8_str("x")->Equals(name) && interceptor_call_count++ < 20) { |
| 11435 return call_ic_function2; | 11431 info.GetReturnValue().Set(call_ic_function2); |
| 11436 } | 11432 } |
| 11437 return v8::Handle<Value>(); | |
| 11438 } | 11433 } |
| 11439 | 11434 |
| 11440 | 11435 |
| 11441 // This test should hit load and call ICs for the interceptor case. | 11436 // This test should hit load and call ICs for the interceptor case. |
| 11442 // Once in a while, the interceptor will reply that a property was not | 11437 // Once in a while, the interceptor will reply that a property was not |
| 11443 // found in which case we should get a reference error. | 11438 // found in which case we should get a reference error. |
| 11444 THREADED_TEST(InterceptorICReferenceErrors) { | 11439 THREADED_TEST(InterceptorICReferenceErrors) { |
| 11445 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11440 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 11446 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 11441 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 11447 templ->SetNamedPropertyHandler(InterceptorICRefErrorGetter); | 11442 templ->SetNamedPropertyHandler(InterceptorICRefErrorGetter); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 11464 " }" | 11459 " }" |
| 11465 " return false;" | 11460 " return false;" |
| 11466 "};" | 11461 "};" |
| 11467 "g();"); | 11462 "g();"); |
| 11468 CHECK_EQ(true, value->BooleanValue()); | 11463 CHECK_EQ(true, value->BooleanValue()); |
| 11469 } | 11464 } |
| 11470 | 11465 |
| 11471 | 11466 |
| 11472 static int interceptor_ic_exception_get_count = 0; | 11467 static int interceptor_ic_exception_get_count = 0; |
| 11473 | 11468 |
| 11474 static v8::Handle<Value> InterceptorICExceptionGetter( | 11469 static void InterceptorICExceptionGetter( |
| 11475 Local<String> name, | 11470 Local<String> name, |
| 11476 const AccessorInfo& info) { | 11471 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 11477 ApiTestFuzzer::Fuzz(); | 11472 ApiTestFuzzer::Fuzz(); |
| 11478 if (v8_str("x")->Equals(name) && ++interceptor_ic_exception_get_count < 20) { | 11473 if (v8_str("x")->Equals(name) && ++interceptor_ic_exception_get_count < 20) { |
| 11479 return call_ic_function3; | 11474 info.GetReturnValue().Set(call_ic_function3); |
| 11480 } | 11475 } |
| 11481 if (interceptor_ic_exception_get_count == 20) { | 11476 if (interceptor_ic_exception_get_count == 20) { |
| 11482 return v8::ThrowException(v8_num(42)); | 11477 v8::ThrowException(v8_num(42)); |
| 11478 return; |
| 11483 } | 11479 } |
| 11484 // Do not handle get for properties other than x. | |
| 11485 return v8::Handle<Value>(); | |
| 11486 } | 11480 } |
| 11487 | 11481 |
| 11488 // Test interceptor load/call IC where the interceptor throws an | 11482 // Test interceptor load/call IC where the interceptor throws an |
| 11489 // exception once in a while. | 11483 // exception once in a while. |
| 11490 THREADED_TEST(InterceptorICGetterExceptions) { | 11484 THREADED_TEST(InterceptorICGetterExceptions) { |
| 11491 interceptor_ic_exception_get_count = 0; | 11485 interceptor_ic_exception_get_count = 0; |
| 11492 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11486 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 11493 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 11487 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 11494 templ->SetNamedPropertyHandler(InterceptorICExceptionGetter); | 11488 templ->SetNamedPropertyHandler(InterceptorICExceptionGetter); |
| 11495 LocalContext context(0, templ, v8::Handle<Value>()); | 11489 LocalContext context(0, templ, v8::Handle<Value>()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 11511 " }" | 11505 " }" |
| 11512 " return false;" | 11506 " return false;" |
| 11513 "};" | 11507 "};" |
| 11514 "f();"); | 11508 "f();"); |
| 11515 CHECK_EQ(true, value->BooleanValue()); | 11509 CHECK_EQ(true, value->BooleanValue()); |
| 11516 } | 11510 } |
| 11517 | 11511 |
| 11518 | 11512 |
| 11519 static int interceptor_ic_exception_set_count = 0; | 11513 static int interceptor_ic_exception_set_count = 0; |
| 11520 | 11514 |
| 11521 static v8::Handle<Value> InterceptorICExceptionSetter( | 11515 static void InterceptorICExceptionSetter( |
| 11522 Local<String> key, Local<Value> value, const AccessorInfo&) { | 11516 Local<String> key, |
| 11517 Local<Value> value, |
| 11518 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 11523 ApiTestFuzzer::Fuzz(); | 11519 ApiTestFuzzer::Fuzz(); |
| 11524 if (++interceptor_ic_exception_set_count > 20) { | 11520 if (++interceptor_ic_exception_set_count > 20) { |
| 11525 return v8::ThrowException(v8_num(42)); | 11521 v8::ThrowException(v8_num(42)); |
| 11526 } | 11522 } |
| 11527 // Do not actually handle setting. | |
| 11528 return v8::Handle<Value>(); | |
| 11529 } | 11523 } |
| 11530 | 11524 |
| 11531 // Test interceptor store IC where the interceptor throws an exception | 11525 // Test interceptor store IC where the interceptor throws an exception |
| 11532 // once in a while. | 11526 // once in a while. |
| 11533 THREADED_TEST(InterceptorICSetterExceptions) { | 11527 THREADED_TEST(InterceptorICSetterExceptions) { |
| 11534 interceptor_ic_exception_set_count = 0; | 11528 interceptor_ic_exception_set_count = 0; |
| 11535 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11529 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 11536 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 11530 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 11537 templ->SetNamedPropertyHandler(0, InterceptorICExceptionSetter); | 11531 templ->SetNamedPropertyHandler(0, InterceptorICExceptionSetter); |
| 11538 LocalContext context(0, templ, v8::Handle<Value>()); | 11532 LocalContext context(0, templ, v8::Handle<Value>()); |
| 11539 v8::Handle<Value> value = CompileRun( | 11533 v8::Handle<Value> value = CompileRun( |
| 11540 "function f() {" | 11534 "function f() {" |
| 11541 " for (var i = 0; i < 100; i++) {" | 11535 " for (var i = 0; i < 100; i++) {" |
| 11542 " try { x = 42; } catch(e) { return true; }" | 11536 " try { x = 42; } catch(e) { return true; }" |
| 11543 " }" | 11537 " }" |
| 11544 " return false;" | 11538 " return false;" |
| 11545 "};" | 11539 "};" |
| 11546 "f();"); | 11540 "f();"); |
| 11547 CHECK_EQ(true, value->BooleanValue()); | 11541 CHECK_EQ(true, value->BooleanValue()); |
| 11548 } | 11542 } |
| 11549 | 11543 |
| 11550 | 11544 |
| 11551 // Test that we ignore null interceptors. | 11545 // Test that we ignore null interceptors. |
| 11552 THREADED_TEST(NullNamedInterceptor) { | 11546 THREADED_TEST(NullNamedInterceptor) { |
| 11553 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11547 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 11554 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 11548 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 11555 templ->SetNamedPropertyHandler(static_cast<v8::NamedPropertyGetter>(0)); | 11549 templ->SetNamedPropertyHandler( |
| 11550 static_cast<v8::NamedPropertyGetterCallback>(0)); |
| 11556 LocalContext context; | 11551 LocalContext context; |
| 11557 templ->Set("x", v8_num(42)); | 11552 templ->Set("x", v8_num(42)); |
| 11558 v8::Handle<v8::Object> obj = templ->NewInstance(); | 11553 v8::Handle<v8::Object> obj = templ->NewInstance(); |
| 11559 context->Global()->Set(v8_str("obj"), obj); | 11554 context->Global()->Set(v8_str("obj"), obj); |
| 11560 v8::Handle<Value> value = CompileRun("obj.x"); | 11555 v8::Handle<Value> value = CompileRun("obj.x"); |
| 11561 CHECK(value->IsInt32()); | 11556 CHECK(value->IsInt32()); |
| 11562 CHECK_EQ(42, value->Int32Value()); | 11557 CHECK_EQ(42, value->Int32Value()); |
| 11563 } | 11558 } |
| 11564 | 11559 |
| 11565 | 11560 |
| 11566 // Test that we ignore null interceptors. | 11561 // Test that we ignore null interceptors. |
| 11567 THREADED_TEST(NullIndexedInterceptor) { | 11562 THREADED_TEST(NullIndexedInterceptor) { |
| 11568 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11563 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 11569 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 11564 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 11570 templ->SetIndexedPropertyHandler(static_cast<v8::IndexedPropertyGetter>(0)); | 11565 templ->SetIndexedPropertyHandler( |
| 11566 static_cast<v8::IndexedPropertyGetterCallback>(0)); |
| 11571 LocalContext context; | 11567 LocalContext context; |
| 11572 templ->Set("42", v8_num(42)); | 11568 templ->Set("42", v8_num(42)); |
| 11573 v8::Handle<v8::Object> obj = templ->NewInstance(); | 11569 v8::Handle<v8::Object> obj = templ->NewInstance(); |
| 11574 context->Global()->Set(v8_str("obj"), obj); | 11570 context->Global()->Set(v8_str("obj"), obj); |
| 11575 v8::Handle<Value> value = CompileRun("obj[42]"); | 11571 v8::Handle<Value> value = CompileRun("obj[42]"); |
| 11576 CHECK(value->IsInt32()); | 11572 CHECK(value->IsInt32()); |
| 11577 CHECK_EQ(42, value->Int32Value()); | 11573 CHECK_EQ(42, value->Int32Value()); |
| 11578 } | 11574 } |
| 11579 | 11575 |
| 11580 | 11576 |
| 11581 THREADED_TEST(NamedPropertyHandlerGetterAttributes) { | 11577 THREADED_TEST(NamedPropertyHandlerGetterAttributes) { |
| 11582 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11578 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 11583 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); | 11579 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); |
| 11584 templ->InstanceTemplate()->SetNamedPropertyHandler(InterceptorLoadXICGetter); | 11580 templ->InstanceTemplate()->SetNamedPropertyHandler(InterceptorLoadXICGetter); |
| 11585 LocalContext env; | 11581 LocalContext env; |
| 11586 env->Global()->Set(v8_str("obj"), | 11582 env->Global()->Set(v8_str("obj"), |
| 11587 templ->GetFunction()->NewInstance()); | 11583 templ->GetFunction()->NewInstance()); |
| 11588 ExpectTrue("obj.x === 42"); | 11584 ExpectTrue("obj.x === 42"); |
| 11589 ExpectTrue("!obj.propertyIsEnumerable('x')"); | 11585 ExpectTrue("!obj.propertyIsEnumerable('x')"); |
| 11590 } | 11586 } |
| 11591 | 11587 |
| 11592 | 11588 |
| 11593 static Handle<Value> ThrowingGetter(Local<String> name, | 11589 static void ThrowingGetter(Local<String> name, |
| 11594 const AccessorInfo& info) { | 11590 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 11595 ApiTestFuzzer::Fuzz(); | 11591 ApiTestFuzzer::Fuzz(); |
| 11596 ThrowException(Handle<Value>()); | 11592 ThrowException(Handle<Value>()); |
| 11597 return Undefined(); | 11593 info.GetReturnValue().SetUndefined(); |
| 11598 } | 11594 } |
| 11599 | 11595 |
| 11600 | 11596 |
| 11601 THREADED_TEST(VariousGetPropertiesAndThrowingCallbacks) { | 11597 THREADED_TEST(VariousGetPropertiesAndThrowingCallbacks) { |
| 11602 LocalContext context; | 11598 LocalContext context; |
| 11603 HandleScope scope(context->GetIsolate()); | 11599 HandleScope scope(context->GetIsolate()); |
| 11604 | 11600 |
| 11605 Local<FunctionTemplate> templ = FunctionTemplate::New(); | 11601 Local<FunctionTemplate> templ = FunctionTemplate::New(); |
| 11606 Local<ObjectTemplate> instance_templ = templ->InstanceTemplate(); | 11602 Local<ObjectTemplate> instance_templ = templ->InstanceTemplate(); |
| 11607 instance_templ->SetAccessor(v8_str("f"), ThrowingGetter); | 11603 instance_templ->SetAccessor(v8_str("f"), ThrowingGetter); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11644 try_catch.Reset(); | 11640 try_catch.Reset(); |
| 11645 CHECK(result.IsEmpty()); | 11641 CHECK(result.IsEmpty()); |
| 11646 | 11642 |
| 11647 result = with_js_getter->Get(v8_str("f")); | 11643 result = with_js_getter->Get(v8_str("f")); |
| 11648 CHECK(try_catch.HasCaught()); | 11644 CHECK(try_catch.HasCaught()); |
| 11649 try_catch.Reset(); | 11645 try_catch.Reset(); |
| 11650 CHECK(result.IsEmpty()); | 11646 CHECK(result.IsEmpty()); |
| 11651 } | 11647 } |
| 11652 | 11648 |
| 11653 | 11649 |
| 11654 static Handle<Value> ThrowingCallbackWithTryCatch(const Arguments& args) { | 11650 static void ThrowingCallbackWithTryCatch( |
| 11651 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 11655 TryCatch try_catch; | 11652 TryCatch try_catch; |
| 11656 // Verboseness is important: it triggers message delivery which can call into | 11653 // Verboseness is important: it triggers message delivery which can call into |
| 11657 // external code. | 11654 // external code. |
| 11658 try_catch.SetVerbose(true); | 11655 try_catch.SetVerbose(true); |
| 11659 CompileRun("throw 'from JS';"); | 11656 CompileRun("throw 'from JS';"); |
| 11660 CHECK(try_catch.HasCaught()); | 11657 CHECK(try_catch.HasCaught()); |
| 11661 CHECK(!i::Isolate::Current()->has_pending_exception()); | 11658 CHECK(!i::Isolate::Current()->has_pending_exception()); |
| 11662 CHECK(!i::Isolate::Current()->has_scheduled_exception()); | 11659 CHECK(!i::Isolate::Current()->has_scheduled_exception()); |
| 11663 return Undefined(); | |
| 11664 } | 11660 } |
| 11665 | 11661 |
| 11666 | 11662 |
| 11667 static int call_depth; | 11663 static int call_depth; |
| 11668 | 11664 |
| 11669 | 11665 |
| 11670 static void WithTryCatch(Handle<Message> message, Handle<Value> data) { | 11666 static void WithTryCatch(Handle<Message> message, Handle<Value> data) { |
| 11671 TryCatch try_catch; | 11667 TryCatch try_catch; |
| 11672 } | 11668 } |
| 11673 | 11669 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11711 "var thrown = false;\n" | 11707 "var thrown = false;\n" |
| 11712 "try { func(); } catch(e) { thrown = true; }\n" | 11708 "try { func(); } catch(e) { thrown = true; }\n" |
| 11713 "thrown\n"); | 11709 "thrown\n"); |
| 11714 if (callback != NULL) { | 11710 if (callback != NULL) { |
| 11715 V8::RemoveMessageListeners(callback); | 11711 V8::RemoveMessageListeners(callback); |
| 11716 } | 11712 } |
| 11717 } | 11713 } |
| 11718 } | 11714 } |
| 11719 | 11715 |
| 11720 | 11716 |
| 11721 static v8::Handle<Value> ParentGetter(Local<String> name, | 11717 static void ParentGetter(Local<String> name, |
| 11722 const AccessorInfo& info) { | 11718 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 11723 ApiTestFuzzer::Fuzz(); | 11719 ApiTestFuzzer::Fuzz(); |
| 11724 return v8_num(1); | 11720 info.GetReturnValue().Set(v8_num(1)); |
| 11725 } | 11721 } |
| 11726 | 11722 |
| 11727 | 11723 |
| 11728 static v8::Handle<Value> ChildGetter(Local<String> name, | 11724 static void ChildGetter(Local<String> name, |
| 11729 const AccessorInfo& info) { | 11725 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 11730 ApiTestFuzzer::Fuzz(); | 11726 ApiTestFuzzer::Fuzz(); |
| 11731 return v8_num(42); | 11727 info.GetReturnValue().Set(v8_num(42)); |
| 11732 } | 11728 } |
| 11733 | 11729 |
| 11734 | 11730 |
| 11735 THREADED_TEST(Overriding) { | 11731 THREADED_TEST(Overriding) { |
| 11736 i::FLAG_es5_readonly = true; | 11732 i::FLAG_es5_readonly = true; |
| 11737 LocalContext context; | 11733 LocalContext context; |
| 11738 v8::HandleScope scope(context->GetIsolate()); | 11734 v8::HandleScope scope(context->GetIsolate()); |
| 11739 | 11735 |
| 11740 // Parent template. | 11736 // Parent template. |
| 11741 Local<v8::FunctionTemplate> parent_templ = v8::FunctionTemplate::New(); | 11737 Local<v8::FunctionTemplate> parent_templ = v8::FunctionTemplate::New(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11783 // Check that 'h' cannot be shadowed. | 11779 // Check that 'h' cannot be shadowed. |
| 11784 value = v8_compile("o.h = 3; o.h")->Run(); | 11780 value = v8_compile("o.h = 3; o.h")->Run(); |
| 11785 CHECK_EQ(1, value->Int32Value()); | 11781 CHECK_EQ(1, value->Int32Value()); |
| 11786 | 11782 |
| 11787 // Check that 'i' cannot be shadowed or changed. | 11783 // Check that 'i' cannot be shadowed or changed. |
| 11788 value = v8_compile("o.i = 3; o.i")->Run(); | 11784 value = v8_compile("o.i = 3; o.i")->Run(); |
| 11789 CHECK_EQ(42, value->Int32Value()); | 11785 CHECK_EQ(42, value->Int32Value()); |
| 11790 } | 11786 } |
| 11791 | 11787 |
| 11792 | 11788 |
| 11793 static v8::Handle<Value> IsConstructHandler(const v8::Arguments& args) { | 11789 static void IsConstructHandler( |
| 11790 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 11794 ApiTestFuzzer::Fuzz(); | 11791 ApiTestFuzzer::Fuzz(); |
| 11795 return v8::Boolean::New(args.IsConstructCall()); | 11792 args.GetReturnValue().Set(args.IsConstructCall()); |
| 11796 } | 11793 } |
| 11797 | 11794 |
| 11798 | 11795 |
| 11799 THREADED_TEST(IsConstructCall) { | 11796 THREADED_TEST(IsConstructCall) { |
| 11800 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11797 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 11801 | 11798 |
| 11802 // Function template with call handler. | 11799 // Function template with call handler. |
| 11803 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); | 11800 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); |
| 11804 templ->SetCallHandler(IsConstructHandler); | 11801 templ->SetCallHandler(IsConstructHandler); |
| 11805 | 11802 |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12026 | 12023 |
| 12027 void ApiTestFuzzer::CallTest() { | 12024 void ApiTestFuzzer::CallTest() { |
| 12028 if (kLogThreading) | 12025 if (kLogThreading) |
| 12029 printf("Start test %d\n", test_number_); | 12026 printf("Start test %d\n", test_number_); |
| 12030 CallTestNumber(test_number_); | 12027 CallTestNumber(test_number_); |
| 12031 if (kLogThreading) | 12028 if (kLogThreading) |
| 12032 printf("End test %d\n", test_number_); | 12029 printf("End test %d\n", test_number_); |
| 12033 } | 12030 } |
| 12034 | 12031 |
| 12035 | 12032 |
| 12036 static v8::Handle<Value> ThrowInJS(const v8::Arguments& args) { | 12033 static void ThrowInJS(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 12037 CHECK(v8::Locker::IsLocked(CcTest::default_isolate())); | 12034 CHECK(v8::Locker::IsLocked(CcTest::default_isolate())); |
| 12038 ApiTestFuzzer::Fuzz(); | 12035 ApiTestFuzzer::Fuzz(); |
| 12039 v8::Unlocker unlocker(CcTest::default_isolate()); | 12036 v8::Unlocker unlocker(CcTest::default_isolate()); |
| 12040 const char* code = "throw 7;"; | 12037 const char* code = "throw 7;"; |
| 12041 { | 12038 { |
| 12042 v8::Locker nested_locker(CcTest::default_isolate()); | 12039 v8::Locker nested_locker(CcTest::default_isolate()); |
| 12043 v8::HandleScope scope(args.GetIsolate()); | 12040 v8::HandleScope scope(args.GetIsolate()); |
| 12044 v8::Handle<Value> exception; | 12041 v8::Handle<Value> exception; |
| 12045 { v8::TryCatch try_catch; | 12042 { v8::TryCatch try_catch; |
| 12046 v8::Handle<Value> value = CompileRun(code); | 12043 v8::Handle<Value> value = CompileRun(code); |
| 12047 CHECK(value.IsEmpty()); | 12044 CHECK(value.IsEmpty()); |
| 12048 CHECK(try_catch.HasCaught()); | 12045 CHECK(try_catch.HasCaught()); |
| 12049 // Make sure to wrap the exception in a new handle because | 12046 // Make sure to wrap the exception in a new handle because |
| 12050 // the handle returned from the TryCatch is destroyed | 12047 // the handle returned from the TryCatch is destroyed |
| 12051 // when the TryCatch is destroyed. | 12048 // when the TryCatch is destroyed. |
| 12052 exception = Local<Value>::New(try_catch.Exception()); | 12049 exception = Local<Value>::New(try_catch.Exception()); |
| 12053 } | 12050 } |
| 12054 return v8::ThrowException(exception); | 12051 v8::ThrowException(exception); |
| 12055 } | 12052 } |
| 12056 } | 12053 } |
| 12057 | 12054 |
| 12058 | 12055 |
| 12059 static v8::Handle<Value> ThrowInJSNoCatch(const v8::Arguments& args) { | 12056 static void ThrowInJSNoCatch(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 12060 CHECK(v8::Locker::IsLocked(CcTest::default_isolate())); | 12057 CHECK(v8::Locker::IsLocked(CcTest::default_isolate())); |
| 12061 ApiTestFuzzer::Fuzz(); | 12058 ApiTestFuzzer::Fuzz(); |
| 12062 v8::Unlocker unlocker(CcTest::default_isolate()); | 12059 v8::Unlocker unlocker(CcTest::default_isolate()); |
| 12063 const char* code = "throw 7;"; | 12060 const char* code = "throw 7;"; |
| 12064 { | 12061 { |
| 12065 v8::Locker nested_locker(CcTest::default_isolate()); | 12062 v8::Locker nested_locker(CcTest::default_isolate()); |
| 12066 v8::HandleScope scope(args.GetIsolate()); | 12063 v8::HandleScope scope(args.GetIsolate()); |
| 12067 v8::Handle<Value> value = CompileRun(code); | 12064 v8::Handle<Value> value = CompileRun(code); |
| 12068 CHECK(value.IsEmpty()); | 12065 CHECK(value.IsEmpty()); |
| 12069 return scope.Close(v8_str("foo")); | 12066 args.GetReturnValue().Set(v8_str("foo")); |
| 12070 } | 12067 } |
| 12071 } | 12068 } |
| 12072 | 12069 |
| 12073 | 12070 |
| 12074 // These are locking tests that don't need to be run again | 12071 // These are locking tests that don't need to be run again |
| 12075 // as part of the locking aggregation tests. | 12072 // as part of the locking aggregation tests. |
| 12076 TEST(NestedLockers) { | 12073 TEST(NestedLockers) { |
| 12077 v8::Locker locker(CcTest::default_isolate()); | 12074 v8::Locker locker(CcTest::default_isolate()); |
| 12078 CHECK(v8::Locker::IsLocked(CcTest::default_isolate())); | 12075 CHECK(v8::Locker::IsLocked(CcTest::default_isolate())); |
| 12079 LocalContext env; | 12076 LocalContext env; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12117 | 12114 |
| 12118 THREADED_TEST(RecursiveLocking) { | 12115 THREADED_TEST(RecursiveLocking) { |
| 12119 v8::Locker locker(CcTest::default_isolate()); | 12116 v8::Locker locker(CcTest::default_isolate()); |
| 12120 { | 12117 { |
| 12121 v8::Locker locker2(CcTest::default_isolate()); | 12118 v8::Locker locker2(CcTest::default_isolate()); |
| 12122 CHECK(v8::Locker::IsLocked(CcTest::default_isolate())); | 12119 CHECK(v8::Locker::IsLocked(CcTest::default_isolate())); |
| 12123 } | 12120 } |
| 12124 } | 12121 } |
| 12125 | 12122 |
| 12126 | 12123 |
| 12127 static v8::Handle<Value> UnlockForAMoment(const v8::Arguments& args) { | 12124 static void UnlockForAMoment(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 12128 ApiTestFuzzer::Fuzz(); | 12125 ApiTestFuzzer::Fuzz(); |
| 12129 v8::Unlocker unlocker(CcTest::default_isolate()); | 12126 v8::Unlocker unlocker(CcTest::default_isolate()); |
| 12130 return v8::Undefined(); | |
| 12131 } | 12127 } |
| 12132 | 12128 |
| 12133 | 12129 |
| 12134 THREADED_TEST(LockUnlockLock) { | 12130 THREADED_TEST(LockUnlockLock) { |
| 12135 { | 12131 { |
| 12136 v8::Locker locker(CcTest::default_isolate()); | 12132 v8::Locker locker(CcTest::default_isolate()); |
| 12137 v8::HandleScope scope(CcTest::default_isolate()); | 12133 v8::HandleScope scope(CcTest::default_isolate()); |
| 12138 LocalContext env; | 12134 LocalContext env; |
| 12139 Local<v8::FunctionTemplate> fun_templ = | 12135 Local<v8::FunctionTemplate> fun_templ = |
| 12140 v8::FunctionTemplate::New(UnlockForAMoment); | 12136 v8::FunctionTemplate::New(UnlockForAMoment); |
| (...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12878 v8::Handle<v8::Script> script1 = | 12874 v8::Handle<v8::Script> script1 = |
| 12879 v8::Script::Compile(source1, v8::String::New("test.js")); | 12875 v8::Script::Compile(source1, v8::String::New("test.js")); |
| 12880 v8::Handle<v8::Script> script2 = | 12876 v8::Handle<v8::Script> script2 = |
| 12881 v8::Script::Compile(source0); // different origin | 12877 v8::Script::Compile(source0); // different origin |
| 12882 CHECK_EQ(1234, script0->Run()->Int32Value()); | 12878 CHECK_EQ(1234, script0->Run()->Int32Value()); |
| 12883 CHECK_EQ(1234, script1->Run()->Int32Value()); | 12879 CHECK_EQ(1234, script1->Run()->Int32Value()); |
| 12884 CHECK_EQ(1234, script2->Run()->Int32Value()); | 12880 CHECK_EQ(1234, script2->Run()->Int32Value()); |
| 12885 } | 12881 } |
| 12886 | 12882 |
| 12887 | 12883 |
| 12888 static v8::Handle<Value> FunctionNameCallback(const v8::Arguments& args) { | 12884 static void FunctionNameCallback( |
| 12885 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 12889 ApiTestFuzzer::Fuzz(); | 12886 ApiTestFuzzer::Fuzz(); |
| 12890 return v8_num(42); | 12887 args.GetReturnValue().Set(v8_num(42)); |
| 12891 } | 12888 } |
| 12892 | 12889 |
| 12893 | 12890 |
| 12894 THREADED_TEST(CallbackFunctionName) { | 12891 THREADED_TEST(CallbackFunctionName) { |
| 12895 LocalContext context; | 12892 LocalContext context; |
| 12896 v8::HandleScope scope(context->GetIsolate()); | 12893 v8::HandleScope scope(context->GetIsolate()); |
| 12897 Local<ObjectTemplate> t = ObjectTemplate::New(); | 12894 Local<ObjectTemplate> t = ObjectTemplate::New(); |
| 12898 t->Set(v8_str("asdf"), v8::FunctionTemplate::New(FunctionNameCallback)); | 12895 t->Set(v8_str("asdf"), v8::FunctionTemplate::New(FunctionNameCallback)); |
| 12899 context->Global()->Set(v8_str("obj"), t->NewInstance()); | 12896 context->Global()->Set(v8_str("obj"), t->NewInstance()); |
| 12900 v8::Handle<v8::Value> value = CompileRun("obj.asdf.name"); | 12897 v8::Handle<v8::Value> value = CompileRun("obj.asdf.name"); |
| (...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14049 CHECK_EQ(v8::Integer::New(0), res); | 14046 CHECK_EQ(v8::Integer::New(0), res); |
| 14050 // Check with 'with'. | 14047 // Check with 'with'. |
| 14051 res = CompileRun("function f() { with (this) { y = 44 }; return y; }; f()"); | 14048 res = CompileRun("function f() { with (this) { y = 44 }; return y; }; f()"); |
| 14052 CHECK_EQ(v8::Integer::New(0), res); | 14049 CHECK_EQ(v8::Integer::New(0), res); |
| 14053 } | 14050 } |
| 14054 | 14051 |
| 14055 static int force_set_set_count = 0; | 14052 static int force_set_set_count = 0; |
| 14056 static int force_set_get_count = 0; | 14053 static int force_set_get_count = 0; |
| 14057 bool pass_on_get = false; | 14054 bool pass_on_get = false; |
| 14058 | 14055 |
| 14059 static v8::Handle<v8::Value> ForceSetGetter(v8::Local<v8::String> name, | 14056 static void ForceSetGetter(v8::Local<v8::String> name, |
| 14060 const v8::AccessorInfo& info) { | 14057 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 14061 force_set_get_count++; | 14058 force_set_get_count++; |
| 14062 if (pass_on_get) { | 14059 if (pass_on_get) { |
| 14063 return v8::Handle<v8::Value>(); | 14060 return; |
| 14064 } else { | |
| 14065 return v8::Int32::New(3); | |
| 14066 } | 14061 } |
| 14062 info.GetReturnValue().Set(3); |
| 14067 } | 14063 } |
| 14068 | 14064 |
| 14069 static void ForceSetSetter(v8::Local<v8::String> name, | 14065 static void ForceSetSetter(v8::Local<v8::String> name, |
| 14070 v8::Local<v8::Value> value, | 14066 v8::Local<v8::Value> value, |
| 14071 const v8::AccessorInfo& info) { | 14067 const v8::PropertyCallbackInfo<void>& info) { |
| 14072 force_set_set_count++; | 14068 force_set_set_count++; |
| 14073 } | 14069 } |
| 14074 | 14070 |
| 14075 static v8::Handle<v8::Value> ForceSetInterceptSetter( | 14071 static void ForceSetInterceptSetter( |
| 14076 v8::Local<v8::String> name, | 14072 v8::Local<v8::String> name, |
| 14077 v8::Local<v8::Value> value, | 14073 v8::Local<v8::Value> value, |
| 14078 const v8::AccessorInfo& info) { | 14074 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 14079 force_set_set_count++; | 14075 force_set_set_count++; |
| 14080 return v8::Undefined(); | 14076 info.GetReturnValue().SetUndefined(); |
| 14081 } | 14077 } |
| 14082 | 14078 |
| 14083 TEST(ForceSet) { | 14079 TEST(ForceSet) { |
| 14084 force_set_get_count = 0; | 14080 force_set_get_count = 0; |
| 14085 force_set_set_count = 0; | 14081 force_set_set_count = 0; |
| 14086 pass_on_get = false; | 14082 pass_on_get = false; |
| 14087 | 14083 |
| 14088 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 14084 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 14089 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); | 14085 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); |
| 14090 v8::Handle<v8::String> access_property = v8::String::New("a"); | 14086 v8::Handle<v8::String> access_property = v8::String::New("a"); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14184 // This should succeed even though the property is dont-delete. | 14180 // This should succeed even though the property is dont-delete. |
| 14185 CHECK(global->ForceDelete(simple_property)); | 14181 CHECK(global->ForceDelete(simple_property)); |
| 14186 CHECK(global->Get(simple_property)->IsUndefined()); | 14182 CHECK(global->Get(simple_property)->IsUndefined()); |
| 14187 } | 14183 } |
| 14188 | 14184 |
| 14189 | 14185 |
| 14190 static int force_delete_interceptor_count = 0; | 14186 static int force_delete_interceptor_count = 0; |
| 14191 static bool pass_on_delete = false; | 14187 static bool pass_on_delete = false; |
| 14192 | 14188 |
| 14193 | 14189 |
| 14194 static v8::Handle<v8::Boolean> ForceDeleteDeleter( | 14190 static void ForceDeleteDeleter( |
| 14195 v8::Local<v8::String> name, | 14191 v8::Local<v8::String> name, |
| 14196 const v8::AccessorInfo& info) { | 14192 const v8::PropertyCallbackInfo<v8::Boolean>& info) { |
| 14197 force_delete_interceptor_count++; | 14193 force_delete_interceptor_count++; |
| 14198 if (pass_on_delete) { | 14194 if (pass_on_delete) return; |
| 14199 return v8::Handle<v8::Boolean>(); | 14195 info.GetReturnValue().Set(true); |
| 14200 } else { | |
| 14201 return v8::True(); | |
| 14202 } | |
| 14203 } | 14196 } |
| 14204 | 14197 |
| 14205 | 14198 |
| 14206 THREADED_TEST(ForceDeleteWithInterceptor) { | 14199 THREADED_TEST(ForceDeleteWithInterceptor) { |
| 14207 force_delete_interceptor_count = 0; | 14200 force_delete_interceptor_count = 0; |
| 14208 pass_on_delete = false; | 14201 pass_on_delete = false; |
| 14209 | 14202 |
| 14210 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 14203 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 14211 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); | 14204 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); |
| 14212 templ->SetNamedPropertyHandler(0, 0, 0, ForceDeleteDeleter); | 14205 templ->SetNamedPropertyHandler(0, 0, 0, ForceDeleteDeleter); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14298 | 14291 |
| 14299 | 14292 |
| 14300 static v8::Local<Context> calling_context0; | 14293 static v8::Local<Context> calling_context0; |
| 14301 static v8::Local<Context> calling_context1; | 14294 static v8::Local<Context> calling_context1; |
| 14302 static v8::Local<Context> calling_context2; | 14295 static v8::Local<Context> calling_context2; |
| 14303 | 14296 |
| 14304 | 14297 |
| 14305 // Check that the call to the callback is initiated in | 14298 // Check that the call to the callback is initiated in |
| 14306 // calling_context2, the directly calling context is calling_context1 | 14299 // calling_context2, the directly calling context is calling_context1 |
| 14307 // and the callback itself is in calling_context0. | 14300 // and the callback itself is in calling_context0. |
| 14308 static v8::Handle<Value> GetCallingContextCallback(const v8::Arguments& args) { | 14301 static void GetCallingContextCallback( |
| 14302 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 14309 ApiTestFuzzer::Fuzz(); | 14303 ApiTestFuzzer::Fuzz(); |
| 14310 CHECK(Context::GetCurrent() == calling_context0); | 14304 CHECK(Context::GetCurrent() == calling_context0); |
| 14311 CHECK(args.GetIsolate()->GetCurrentContext() == calling_context0); | 14305 CHECK(args.GetIsolate()->GetCurrentContext() == calling_context0); |
| 14312 CHECK(Context::GetCalling() == calling_context1); | 14306 CHECK(Context::GetCalling() == calling_context1); |
| 14313 CHECK(Context::GetEntered() == calling_context2); | 14307 CHECK(Context::GetEntered() == calling_context2); |
| 14314 return v8::Integer::New(42); | 14308 args.GetReturnValue().Set(42); |
| 14315 } | 14309 } |
| 14316 | 14310 |
| 14317 | 14311 |
| 14318 THREADED_TEST(GetCallingContext) { | 14312 THREADED_TEST(GetCallingContext) { |
| 14319 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 14313 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 14320 v8::HandleScope scope(isolate); | 14314 v8::HandleScope scope(isolate); |
| 14321 | 14315 |
| 14322 Local<Context> calling_context0(Context::New(isolate)); | 14316 Local<Context> calling_context0(Context::New(isolate)); |
| 14323 Local<Context> calling_context1(Context::New(isolate)); | 14317 Local<Context> calling_context1(Context::New(isolate)); |
| 14324 Local<Context> calling_context2(Context::New(isolate)); | 14318 Local<Context> calling_context2(Context::New(isolate)); |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14810 v8::Handle<v8::Object> obj = v8::Object::New(); | 14804 v8::Handle<v8::Object> obj = v8::Object::New(); |
| 14811 obj->SetIndexedPropertiesToPixelData(pixel_data, size); | 14805 obj->SetIndexedPropertiesToPixelData(pixel_data, size); |
| 14812 CHECK(obj->HasIndexedPropertiesInPixelData()); | 14806 CHECK(obj->HasIndexedPropertiesInPixelData()); |
| 14813 CHECK_EQ(pixel_data, obj->GetIndexedPropertiesPixelData()); | 14807 CHECK_EQ(pixel_data, obj->GetIndexedPropertiesPixelData()); |
| 14814 CHECK_EQ(size, obj->GetIndexedPropertiesPixelDataLength()); | 14808 CHECK_EQ(size, obj->GetIndexedPropertiesPixelDataLength()); |
| 14815 free(pixel_data); | 14809 free(pixel_data); |
| 14816 } | 14810 } |
| 14817 } | 14811 } |
| 14818 | 14812 |
| 14819 | 14813 |
| 14820 static v8::Handle<Value> NotHandledIndexedPropertyGetter( | 14814 static void NotHandledIndexedPropertyGetter( |
| 14821 uint32_t index, | 14815 uint32_t index, |
| 14822 const AccessorInfo& info) { | 14816 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 14823 ApiTestFuzzer::Fuzz(); | 14817 ApiTestFuzzer::Fuzz(); |
| 14824 return v8::Handle<Value>(); | |
| 14825 } | 14818 } |
| 14826 | 14819 |
| 14827 | 14820 |
| 14828 static v8::Handle<Value> NotHandledIndexedPropertySetter( | 14821 static void NotHandledIndexedPropertySetter( |
| 14829 uint32_t index, | 14822 uint32_t index, |
| 14830 Local<Value> value, | 14823 Local<Value> value, |
| 14831 const AccessorInfo& info) { | 14824 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 14832 ApiTestFuzzer::Fuzz(); | 14825 ApiTestFuzzer::Fuzz(); |
| 14833 return v8::Handle<Value>(); | |
| 14834 } | 14826 } |
| 14835 | 14827 |
| 14836 | 14828 |
| 14837 THREADED_TEST(PixelArrayWithInterceptor) { | 14829 THREADED_TEST(PixelArrayWithInterceptor) { |
| 14838 LocalContext context; | 14830 LocalContext context; |
| 14839 i::Factory* factory = i::Isolate::Current()->factory(); | 14831 i::Factory* factory = i::Isolate::Current()->factory(); |
| 14840 v8::HandleScope scope(context->GetIsolate()); | 14832 v8::HandleScope scope(context->GetIsolate()); |
| 14841 const int kElementCount = 260; | 14833 const int kElementCount = 260; |
| 14842 uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(kElementCount)); | 14834 uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(kElementCount)); |
| 14843 i::Handle<i::ExternalPixelArray> pixels = | 14835 i::Handle<i::ExternalPixelArray> pixels = |
| (...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15719 CHECK(strstr(*script_name, expected_script_name) != NULL); | 15711 CHECK(strstr(*script_name, expected_script_name) != NULL); |
| 15720 } | 15712 } |
| 15721 CHECK(strstr(*func_name, expected_func_name) != NULL); | 15713 CHECK(strstr(*func_name, expected_func_name) != NULL); |
| 15722 CHECK_EQ(expected_line_number, frame->GetLineNumber()); | 15714 CHECK_EQ(expected_line_number, frame->GetLineNumber()); |
| 15723 CHECK_EQ(expected_column, frame->GetColumn()); | 15715 CHECK_EQ(expected_column, frame->GetColumn()); |
| 15724 CHECK_EQ(is_eval, frame->IsEval()); | 15716 CHECK_EQ(is_eval, frame->IsEval()); |
| 15725 CHECK_EQ(is_constructor, frame->IsConstructor()); | 15717 CHECK_EQ(is_constructor, frame->IsConstructor()); |
| 15726 } | 15718 } |
| 15727 | 15719 |
| 15728 | 15720 |
| 15729 v8::Handle<Value> AnalyzeStackInNativeCode(const v8::Arguments& args) { | 15721 void AnalyzeStackInNativeCode(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 15730 v8::HandleScope scope(args.GetIsolate()); | 15722 v8::HandleScope scope(args.GetIsolate()); |
| 15731 const char* origin = "capture-stack-trace-test"; | 15723 const char* origin = "capture-stack-trace-test"; |
| 15732 const int kOverviewTest = 1; | 15724 const int kOverviewTest = 1; |
| 15733 const int kDetailedTest = 2; | 15725 const int kDetailedTest = 2; |
| 15734 | 15726 |
| 15735 ASSERT(args.Length() == 1); | 15727 ASSERT(args.Length() == 1); |
| 15736 | 15728 |
| 15737 int testGroup = args[0]->Int32Value(); | 15729 int testGroup = args[0]->Int32Value(); |
| 15738 if (testGroup == kOverviewTest) { | 15730 if (testGroup == kOverviewTest) { |
| 15739 v8::Handle<v8::StackTrace> stackTrace = | 15731 v8::Handle<v8::StackTrace> stackTrace = |
| (...skipping 27 matching lines...) Expand all Loading... |
| 15767 | 15759 |
| 15768 // This is the source string inside the eval which has the call to baz. | 15760 // This is the source string inside the eval which has the call to baz. |
| 15769 checkStackFrame(NULL, "", 1, 5, is_eval, false, | 15761 checkStackFrame(NULL, "", 1, 5, is_eval, false, |
| 15770 stackTrace->GetFrame(2)); | 15762 stackTrace->GetFrame(2)); |
| 15771 // The last frame is an anonymous function which has the initial eval call. | 15763 // The last frame is an anonymous function which has the initial eval call. |
| 15772 checkStackFrame(origin, "", 10, 1, false, false, | 15764 checkStackFrame(origin, "", 10, 1, false, false, |
| 15773 stackTrace->GetFrame(3)); | 15765 stackTrace->GetFrame(3)); |
| 15774 | 15766 |
| 15775 CHECK(stackTrace->AsArray()->IsArray()); | 15767 CHECK(stackTrace->AsArray()->IsArray()); |
| 15776 } | 15768 } |
| 15777 return v8::Undefined(); | |
| 15778 } | 15769 } |
| 15779 | 15770 |
| 15780 | 15771 |
| 15781 // Tests the C++ StackTrace API. | 15772 // Tests the C++ StackTrace API. |
| 15782 // TODO(3074796): Reenable this as a THREADED_TEST once it passes. | 15773 // TODO(3074796): Reenable this as a THREADED_TEST once it passes. |
| 15783 // THREADED_TEST(CaptureStackTrace) { | 15774 // THREADED_TEST(CaptureStackTrace) { |
| 15784 TEST(CaptureStackTrace) { | 15775 TEST(CaptureStackTrace) { |
| 15785 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 15776 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 15786 v8::Handle<v8::String> origin = v8::String::New("capture-stack-trace-test"); | 15777 v8::Handle<v8::String> origin = v8::String::New("capture-stack-trace-test"); |
| 15787 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 15778 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16006 "var e = {__proto__: new Error()} \n" | 15997 "var e = {__proto__: new Error()} \n" |
| 16007 "throw e; \n"; | 15998 "throw e; \n"; |
| 16008 v8::V8::AddMessageListener(RethrowBogusErrorStackTraceHandler); | 15999 v8::V8::AddMessageListener(RethrowBogusErrorStackTraceHandler); |
| 16009 v8::V8::SetCaptureStackTraceForUncaughtExceptions(true); | 16000 v8::V8::SetCaptureStackTraceForUncaughtExceptions(true); |
| 16010 CompileRun(source); | 16001 CompileRun(source); |
| 16011 v8::V8::SetCaptureStackTraceForUncaughtExceptions(false); | 16002 v8::V8::SetCaptureStackTraceForUncaughtExceptions(false); |
| 16012 v8::V8::RemoveMessageListeners(RethrowBogusErrorStackTraceHandler); | 16003 v8::V8::RemoveMessageListeners(RethrowBogusErrorStackTraceHandler); |
| 16013 } | 16004 } |
| 16014 | 16005 |
| 16015 | 16006 |
| 16016 v8::Handle<Value> AnalyzeStackOfEvalWithSourceURL(const v8::Arguments& args) { | 16007 void AnalyzeStackOfEvalWithSourceURL( |
| 16008 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 16017 v8::HandleScope scope(args.GetIsolate()); | 16009 v8::HandleScope scope(args.GetIsolate()); |
| 16018 v8::Handle<v8::StackTrace> stackTrace = | 16010 v8::Handle<v8::StackTrace> stackTrace = |
| 16019 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed); | 16011 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed); |
| 16020 CHECK_EQ(5, stackTrace->GetFrameCount()); | 16012 CHECK_EQ(5, stackTrace->GetFrameCount()); |
| 16021 v8::Handle<v8::String> url = v8_str("eval_url"); | 16013 v8::Handle<v8::String> url = v8_str("eval_url"); |
| 16022 for (int i = 0; i < 3; i++) { | 16014 for (int i = 0; i < 3; i++) { |
| 16023 v8::Handle<v8::String> name = | 16015 v8::Handle<v8::String> name = |
| 16024 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); | 16016 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); |
| 16025 CHECK(!name.IsEmpty()); | 16017 CHECK(!name.IsEmpty()); |
| 16026 CHECK_EQ(url, name); | 16018 CHECK_EQ(url, name); |
| 16027 } | 16019 } |
| 16028 return v8::Undefined(); | |
| 16029 } | 16020 } |
| 16030 | 16021 |
| 16031 | 16022 |
| 16032 TEST(SourceURLInStackTrace) { | 16023 TEST(SourceURLInStackTrace) { |
| 16033 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 16024 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 16034 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 16025 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 16035 templ->Set(v8_str("AnalyzeStackOfEvalWithSourceURL"), | 16026 templ->Set(v8_str("AnalyzeStackOfEvalWithSourceURL"), |
| 16036 v8::FunctionTemplate::New(AnalyzeStackOfEvalWithSourceURL)); | 16027 v8::FunctionTemplate::New(AnalyzeStackOfEvalWithSourceURL)); |
| 16037 LocalContext context(0, templ); | 16028 LocalContext context(0, templ); |
| 16038 | 16029 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 16050 "eval('(' + outer +')()%s');"; | 16041 "eval('(' + outer +')()%s');"; |
| 16051 | 16042 |
| 16052 i::ScopedVector<char> code(1024); | 16043 i::ScopedVector<char> code(1024); |
| 16053 i::OS::SNPrintF(code, source, "//# sourceURL=eval_url"); | 16044 i::OS::SNPrintF(code, source, "//# sourceURL=eval_url"); |
| 16054 CHECK(CompileRun(code.start())->IsUndefined()); | 16045 CHECK(CompileRun(code.start())->IsUndefined()); |
| 16055 i::OS::SNPrintF(code, source, "//@ sourceURL=eval_url"); | 16046 i::OS::SNPrintF(code, source, "//@ sourceURL=eval_url"); |
| 16056 CHECK(CompileRun(code.start())->IsUndefined()); | 16047 CHECK(CompileRun(code.start())->IsUndefined()); |
| 16057 } | 16048 } |
| 16058 | 16049 |
| 16059 | 16050 |
| 16060 v8::Handle<Value> AnalyzeStackOfInlineScriptWithSourceURL( | 16051 void AnalyzeStackOfInlineScriptWithSourceURL( |
| 16061 const v8::Arguments& args) { | 16052 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 16062 v8::HandleScope scope(args.GetIsolate()); | 16053 v8::HandleScope scope(args.GetIsolate()); |
| 16063 v8::Handle<v8::StackTrace> stackTrace = | 16054 v8::Handle<v8::StackTrace> stackTrace = |
| 16064 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed); | 16055 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed); |
| 16065 CHECK_EQ(4, stackTrace->GetFrameCount()); | 16056 CHECK_EQ(4, stackTrace->GetFrameCount()); |
| 16066 v8::Handle<v8::String> url = v8_str("url"); | 16057 v8::Handle<v8::String> url = v8_str("url"); |
| 16067 for (int i = 0; i < 3; i++) { | 16058 for (int i = 0; i < 3; i++) { |
| 16068 v8::Handle<v8::String> name = | 16059 v8::Handle<v8::String> name = |
| 16069 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); | 16060 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); |
| 16070 CHECK(!name.IsEmpty()); | 16061 CHECK(!name.IsEmpty()); |
| 16071 CHECK_EQ(url, name); | 16062 CHECK_EQ(url, name); |
| 16072 } | 16063 } |
| 16073 return v8::Undefined(); | |
| 16074 } | 16064 } |
| 16075 | 16065 |
| 16076 | 16066 |
| 16077 TEST(InlineScriptWithSourceURLInStackTrace) { | 16067 TEST(InlineScriptWithSourceURLInStackTrace) { |
| 16078 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 16068 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 16079 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 16069 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 16080 templ->Set(v8_str("AnalyzeStackOfInlineScriptWithSourceURL"), | 16070 templ->Set(v8_str("AnalyzeStackOfInlineScriptWithSourceURL"), |
| 16081 v8::FunctionTemplate::New( | 16071 v8::FunctionTemplate::New( |
| 16082 AnalyzeStackOfInlineScriptWithSourceURL)); | 16072 AnalyzeStackOfInlineScriptWithSourceURL)); |
| 16083 LocalContext context(0, templ); | 16073 LocalContext context(0, templ); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 16096 "outer()\n%s"; | 16086 "outer()\n%s"; |
| 16097 | 16087 |
| 16098 i::ScopedVector<char> code(1024); | 16088 i::ScopedVector<char> code(1024); |
| 16099 i::OS::SNPrintF(code, source, "//# sourceURL=source_url"); | 16089 i::OS::SNPrintF(code, source, "//# sourceURL=source_url"); |
| 16100 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 1)->IsUndefined()); | 16090 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 1)->IsUndefined()); |
| 16101 i::OS::SNPrintF(code, source, "//@ sourceURL=source_url"); | 16091 i::OS::SNPrintF(code, source, "//@ sourceURL=source_url"); |
| 16102 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 1)->IsUndefined()); | 16092 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 1)->IsUndefined()); |
| 16103 } | 16093 } |
| 16104 | 16094 |
| 16105 | 16095 |
| 16106 v8::Handle<Value> AnalyzeStackOfDynamicScriptWithSourceURL( | 16096 void AnalyzeStackOfDynamicScriptWithSourceURL( |
| 16107 const v8::Arguments& args) { | 16097 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 16108 v8::HandleScope scope(args.GetIsolate()); | 16098 v8::HandleScope scope(args.GetIsolate()); |
| 16109 v8::Handle<v8::StackTrace> stackTrace = | 16099 v8::Handle<v8::StackTrace> stackTrace = |
| 16110 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed); | 16100 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed); |
| 16111 CHECK_EQ(4, stackTrace->GetFrameCount()); | 16101 CHECK_EQ(4, stackTrace->GetFrameCount()); |
| 16112 v8::Handle<v8::String> url = v8_str("source_url"); | 16102 v8::Handle<v8::String> url = v8_str("source_url"); |
| 16113 for (int i = 0; i < 3; i++) { | 16103 for (int i = 0; i < 3; i++) { |
| 16114 v8::Handle<v8::String> name = | 16104 v8::Handle<v8::String> name = |
| 16115 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); | 16105 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); |
| 16116 CHECK(!name.IsEmpty()); | 16106 CHECK(!name.IsEmpty()); |
| 16117 CHECK_EQ(url, name); | 16107 CHECK_EQ(url, name); |
| 16118 } | 16108 } |
| 16119 return v8::Undefined(); | |
| 16120 } | 16109 } |
| 16121 | 16110 |
| 16122 | 16111 |
| 16123 TEST(DynamicWithSourceURLInStackTrace) { | 16112 TEST(DynamicWithSourceURLInStackTrace) { |
| 16124 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 16113 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 16125 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 16114 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 16126 templ->Set(v8_str("AnalyzeStackOfDynamicScriptWithSourceURL"), | 16115 templ->Set(v8_str("AnalyzeStackOfDynamicScriptWithSourceURL"), |
| 16127 v8::FunctionTemplate::New( | 16116 v8::FunctionTemplate::New( |
| 16128 AnalyzeStackOfDynamicScriptWithSourceURL)); | 16117 AnalyzeStackOfDynamicScriptWithSourceURL)); |
| 16129 LocalContext context(0, templ); | 16118 LocalContext context(0, templ); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16245 bool finished = false; | 16234 bool finished = false; |
| 16246 for (int i = 0; i < 200 && !finished; i++) { | 16235 for (int i = 0; i < 200 && !finished; i++) { |
| 16247 finished = v8::V8::IdleNotification(kShortIdlePauseInMs); | 16236 finished = v8::V8::IdleNotification(kShortIdlePauseInMs); |
| 16248 } | 16237 } |
| 16249 intptr_t final_size = HEAP->SizeOfObjects(); | 16238 intptr_t final_size = HEAP->SizeOfObjects(); |
| 16250 CHECK_LT(final_size, initial_size + 1); | 16239 CHECK_LT(final_size, initial_size + 1); |
| 16251 } | 16240 } |
| 16252 | 16241 |
| 16253 static uint32_t* stack_limit; | 16242 static uint32_t* stack_limit; |
| 16254 | 16243 |
| 16255 static v8::Handle<Value> GetStackLimitCallback(const v8::Arguments& args) { | 16244 static void GetStackLimitCallback( |
| 16245 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 16256 stack_limit = reinterpret_cast<uint32_t*>( | 16246 stack_limit = reinterpret_cast<uint32_t*>( |
| 16257 i::Isolate::Current()->stack_guard()->real_climit()); | 16247 i::Isolate::Current()->stack_guard()->real_climit()); |
| 16258 return v8::Undefined(); | |
| 16259 } | 16248 } |
| 16260 | 16249 |
| 16261 | 16250 |
| 16262 // Uses the address of a local variable to determine the stack top now. | 16251 // Uses the address of a local variable to determine the stack top now. |
| 16263 // Given a size, returns an address that is that far from the current | 16252 // Given a size, returns an address that is that far from the current |
| 16264 // top of stack. | 16253 // top of stack. |
| 16265 static uint32_t* ComputeStackLimit(uint32_t size) { | 16254 static uint32_t* ComputeStackLimit(uint32_t size) { |
| 16266 uint32_t* answer = &size - (size / sizeof(size)); | 16255 uint32_t* answer = &size - (size / sizeof(size)); |
| 16267 // If the size is very large and the stack is very near the bottom of | 16256 // If the size is very large and the stack is very near the bottom of |
| 16268 // memory then the calculation above may wrap around and give an address | 16257 // memory then the calculation above may wrap around and give an address |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16517 // on MIPS architecture. Allowed by IEEE-754. | 16506 // on MIPS architecture. Allowed by IEEE-754. |
| 16518 CHECK_EQ(0xffe, static_cast<int>((stored_bits >> 51) & 0xfff)); | 16507 CHECK_EQ(0xffe, static_cast<int>((stored_bits >> 51) & 0xfff)); |
| 16519 #else | 16508 #else |
| 16520 CHECK_EQ(0xfff, static_cast<int>((stored_bits >> 51) & 0xfff)); | 16509 CHECK_EQ(0xfff, static_cast<int>((stored_bits >> 51) & 0xfff)); |
| 16521 #endif | 16510 #endif |
| 16522 } | 16511 } |
| 16523 } | 16512 } |
| 16524 } | 16513 } |
| 16525 | 16514 |
| 16526 | 16515 |
| 16527 static v8::Handle<Value> SpaghettiIncident(const v8::Arguments& args) { | 16516 static void SpaghettiIncident( |
| 16517 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 16528 v8::HandleScope scope(args.GetIsolate()); | 16518 v8::HandleScope scope(args.GetIsolate()); |
| 16529 v8::TryCatch tc; | 16519 v8::TryCatch tc; |
| 16530 v8::Handle<v8::String> str(args[0]->ToString()); | 16520 v8::Handle<v8::String> str(args[0]->ToString()); |
| 16531 USE(str); | 16521 USE(str); |
| 16532 if (tc.HasCaught()) | 16522 if (tc.HasCaught()) |
| 16533 return tc.ReThrow(); | 16523 tc.ReThrow(); |
| 16534 return v8::Undefined(); | |
| 16535 } | 16524 } |
| 16536 | 16525 |
| 16537 | 16526 |
| 16538 // Test that an exception can be propagated down through a spaghetti | 16527 // Test that an exception can be propagated down through a spaghetti |
| 16539 // stack using ReThrow. | 16528 // stack using ReThrow. |
| 16540 THREADED_TEST(SpaghettiStackReThrow) { | 16529 THREADED_TEST(SpaghettiStackReThrow) { |
| 16541 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 16530 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 16542 LocalContext context; | 16531 LocalContext context; |
| 16543 context->Global()->Set( | 16532 context->Global()->Set( |
| 16544 v8::String::New("s"), | 16533 v8::String::New("s"), |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16728 script->Run(); | 16717 script->Run(); |
| 16729 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( | 16718 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( |
| 16730 env->Global()->Get(v8::String::New("foo"))); | 16719 env->Global()->Get(v8::String::New("foo"))); |
| 16731 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast( | 16720 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast( |
| 16732 env->Global()->Get(v8::String::New("bar"))); | 16721 env->Global()->Get(v8::String::New("bar"))); |
| 16733 CHECK_EQ(script->Id(), foo->GetScriptId()); | 16722 CHECK_EQ(script->Id(), foo->GetScriptId()); |
| 16734 CHECK_EQ(script->Id(), bar->GetScriptId()); | 16723 CHECK_EQ(script->Id(), bar->GetScriptId()); |
| 16735 } | 16724 } |
| 16736 | 16725 |
| 16737 | 16726 |
| 16738 static v8::Handle<Value> GetterWhichReturns42(Local<String> name, | 16727 static void GetterWhichReturns42( |
| 16739 const AccessorInfo& info) { | 16728 Local<String> name, |
| 16729 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 16740 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); | 16730 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); |
| 16741 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); | 16731 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); |
| 16742 return v8_num(42); | 16732 info.GetReturnValue().Set(v8_num(42)); |
| 16743 } | 16733 } |
| 16744 | 16734 |
| 16745 | 16735 |
| 16746 static void SetterWhichSetsYOnThisTo23(Local<String> name, | 16736 static void SetterWhichSetsYOnThisTo23( |
| 16747 Local<Value> value, | 16737 Local<String> name, |
| 16748 const AccessorInfo& info) { | 16738 Local<Value> value, |
| 16739 const v8::PropertyCallbackInfo<void>& info) { |
| 16749 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); | 16740 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); |
| 16750 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); | 16741 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); |
| 16751 info.This()->Set(v8_str("y"), v8_num(23)); | 16742 info.This()->Set(v8_str("y"), v8_num(23)); |
| 16752 } | 16743 } |
| 16753 | 16744 |
| 16754 | 16745 |
| 16755 Handle<Value> FooGetInterceptor(Local<String> name, | 16746 void FooGetInterceptor(Local<String> name, |
| 16756 const AccessorInfo& info) { | 16747 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 16757 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); | 16748 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); |
| 16758 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); | 16749 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); |
| 16759 if (!name->Equals(v8_str("foo"))) return Handle<Value>(); | 16750 if (!name->Equals(v8_str("foo"))) return; |
| 16760 return v8_num(42); | 16751 info.GetReturnValue().Set(v8_num(42)); |
| 16761 } | 16752 } |
| 16762 | 16753 |
| 16763 | 16754 |
| 16764 Handle<Value> FooSetInterceptor(Local<String> name, | 16755 void FooSetInterceptor(Local<String> name, |
| 16765 Local<Value> value, | 16756 Local<Value> value, |
| 16766 const AccessorInfo& info) { | 16757 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 16767 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); | 16758 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); |
| 16768 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); | 16759 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); |
| 16769 if (!name->Equals(v8_str("foo"))) return Handle<Value>(); | 16760 if (!name->Equals(v8_str("foo"))) return; |
| 16770 info.This()->Set(v8_str("y"), v8_num(23)); | 16761 info.This()->Set(v8_str("y"), v8_num(23)); |
| 16771 return v8_num(23); | 16762 info.GetReturnValue().Set(v8_num(23)); |
| 16772 } | 16763 } |
| 16773 | 16764 |
| 16774 | 16765 |
| 16775 TEST(SetterOnConstructorPrototype) { | 16766 TEST(SetterOnConstructorPrototype) { |
| 16776 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 16767 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 16777 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 16768 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 16778 templ->SetAccessor(v8_str("x"), | 16769 templ->SetAccessor(v8_str("x"), |
| 16779 GetterWhichReturns42, | 16770 GetterWhichReturns42, |
| 16780 SetterWhichSetsYOnThisTo23); | 16771 SetterWhichSetsYOnThisTo23); |
| 16781 LocalContext context; | 16772 LocalContext context; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 16800 | 16791 |
| 16801 script = v8::Script::Compile(v8_str("new C2();")); | 16792 script = v8::Script::Compile(v8_str("new C2();")); |
| 16802 for (int i = 0; i < 10; i++) { | 16793 for (int i = 0; i < 10; i++) { |
| 16803 v8::Handle<v8::Object> c2 = v8::Handle<v8::Object>::Cast(script->Run()); | 16794 v8::Handle<v8::Object> c2 = v8::Handle<v8::Object>::Cast(script->Run()); |
| 16804 CHECK_EQ(42, c2->Get(v8_str("x"))->Int32Value()); | 16795 CHECK_EQ(42, c2->Get(v8_str("x"))->Int32Value()); |
| 16805 CHECK_EQ(23, c2->Get(v8_str("y"))->Int32Value()); | 16796 CHECK_EQ(23, c2->Get(v8_str("y"))->Int32Value()); |
| 16806 } | 16797 } |
| 16807 } | 16798 } |
| 16808 | 16799 |
| 16809 | 16800 |
| 16810 static v8::Handle<Value> NamedPropertyGetterWhichReturns42( | 16801 static void NamedPropertyGetterWhichReturns42( |
| 16811 Local<String> name, const AccessorInfo& info) { | 16802 Local<String> name, |
| 16812 return v8_num(42); | 16803 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 16804 info.GetReturnValue().Set(v8_num(42)); |
| 16813 } | 16805 } |
| 16814 | 16806 |
| 16815 | 16807 |
| 16816 static v8::Handle<Value> NamedPropertySetterWhichSetsYOnThisTo23( | 16808 static void NamedPropertySetterWhichSetsYOnThisTo23( |
| 16817 Local<String> name, Local<Value> value, const AccessorInfo& info) { | 16809 Local<String> name, |
| 16810 Local<Value> value, |
| 16811 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 16818 if (name->Equals(v8_str("x"))) { | 16812 if (name->Equals(v8_str("x"))) { |
| 16819 info.This()->Set(v8_str("y"), v8_num(23)); | 16813 info.This()->Set(v8_str("y"), v8_num(23)); |
| 16820 } | 16814 } |
| 16821 return v8::Handle<Value>(); | |
| 16822 } | 16815 } |
| 16823 | 16816 |
| 16824 | 16817 |
| 16825 THREADED_TEST(InterceptorOnConstructorPrototype) { | 16818 THREADED_TEST(InterceptorOnConstructorPrototype) { |
| 16826 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 16819 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 16827 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 16820 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 16828 templ->SetNamedPropertyHandler(NamedPropertyGetterWhichReturns42, | 16821 templ->SetNamedPropertyHandler(NamedPropertyGetterWhichReturns42, |
| 16829 NamedPropertySetterWhichSetsYOnThisTo23); | 16822 NamedPropertySetterWhichSetsYOnThisTo23); |
| 16830 LocalContext context; | 16823 LocalContext context; |
| 16831 context->Global()->Set(v8_str("P"), templ->NewInstance()); | 16824 context->Global()->Set(v8_str("P"), templ->NewInstance()); |
| (...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18051 CHECK(!globalProxy->StrictEquals(global)); | 18044 CHECK(!globalProxy->StrictEquals(global)); |
| 18052 CHECK(globalProxy->StrictEquals(globalProxy)); | 18045 CHECK(globalProxy->StrictEquals(globalProxy)); |
| 18053 | 18046 |
| 18054 CHECK(global->Equals(global)); | 18047 CHECK(global->Equals(global)); |
| 18055 CHECK(!global->Equals(globalProxy)); | 18048 CHECK(!global->Equals(globalProxy)); |
| 18056 CHECK(!globalProxy->Equals(global)); | 18049 CHECK(!globalProxy->Equals(global)); |
| 18057 CHECK(globalProxy->Equals(globalProxy)); | 18050 CHECK(globalProxy->Equals(globalProxy)); |
| 18058 } | 18051 } |
| 18059 | 18052 |
| 18060 | 18053 |
| 18061 static v8::Handle<v8::Value> Getter(v8::Local<v8::String> property, | 18054 static void Getter(v8::Local<v8::String> property, |
| 18062 const v8::AccessorInfo& info ) { | 18055 const v8::PropertyCallbackInfo<v8::Value>& info ) { |
| 18063 return v8_str("42!"); | 18056 info.GetReturnValue().Set(v8_str("42!")); |
| 18064 } | 18057 } |
| 18065 | 18058 |
| 18066 | 18059 |
| 18067 static v8::Handle<v8::Array> Enumerator(const v8::AccessorInfo& info) { | 18060 static void Enumerator(const v8::PropertyCallbackInfo<v8::Array>& info) { |
| 18068 v8::Handle<v8::Array> result = v8::Array::New(); | 18061 v8::Handle<v8::Array> result = v8::Array::New(); |
| 18069 result->Set(0, v8_str("universalAnswer")); | 18062 result->Set(0, v8_str("universalAnswer")); |
| 18070 return result; | 18063 info.GetReturnValue().Set(result); |
| 18071 } | 18064 } |
| 18072 | 18065 |
| 18073 | 18066 |
| 18074 TEST(NamedEnumeratorAndForIn) { | 18067 TEST(NamedEnumeratorAndForIn) { |
| 18075 LocalContext context; | 18068 LocalContext context; |
| 18076 v8::HandleScope handle_scope(context->GetIsolate()); | 18069 v8::HandleScope handle_scope(context->GetIsolate()); |
| 18077 v8::Context::Scope context_scope(context.local()); | 18070 v8::Context::Scope context_scope(context.local()); |
| 18078 | 18071 |
| 18079 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(); | 18072 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(); |
| 18080 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator); | 18073 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18206 { | 18199 { |
| 18207 Context::Scope scope(context); | 18200 Context::Scope scope(context); |
| 18208 function = CompileRun("function foo() {}; foo").As<Object>(); | 18201 function = CompileRun("function foo() {}; foo").As<Object>(); |
| 18209 } | 18202 } |
| 18210 | 18203 |
| 18211 CHECK(function->CreationContext() == context); | 18204 CHECK(function->CreationContext() == context); |
| 18212 CheckContextId(function, 1); | 18205 CheckContextId(function, 1); |
| 18213 } | 18206 } |
| 18214 | 18207 |
| 18215 | 18208 |
| 18216 Handle<Value> HasOwnPropertyIndexedPropertyGetter(uint32_t index, | 18209 void HasOwnPropertyIndexedPropertyGetter( |
| 18217 const AccessorInfo& info) { | 18210 uint32_t index, |
| 18218 if (index == 42) return v8_str("yes"); | 18211 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 18219 return Handle<v8::Integer>(); | 18212 if (index == 42) info.GetReturnValue().Set(v8_str("yes")); |
| 18220 } | 18213 } |
| 18221 | 18214 |
| 18222 | 18215 |
| 18223 Handle<Value> HasOwnPropertyNamedPropertyGetter(Local<String> property, | 18216 void HasOwnPropertyNamedPropertyGetter( |
| 18224 const AccessorInfo& info) { | 18217 Local<String> property, |
| 18225 if (property->Equals(v8_str("foo"))) return v8_str("yes"); | 18218 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 18226 return Handle<Value>(); | 18219 if (property->Equals(v8_str("foo"))) info.GetReturnValue().Set(v8_str("yes")); |
| 18227 } | 18220 } |
| 18228 | 18221 |
| 18229 | 18222 |
| 18230 Handle<v8::Integer> HasOwnPropertyIndexedPropertyQuery( | 18223 void HasOwnPropertyIndexedPropertyQuery( |
| 18231 uint32_t index, const AccessorInfo& info) { | 18224 uint32_t index, const v8::PropertyCallbackInfo<v8::Integer>& info) { |
| 18232 if (index == 42) return v8_num(1).As<v8::Integer>(); | 18225 if (index == 42) info.GetReturnValue().Set(1); |
| 18233 return Handle<v8::Integer>(); | |
| 18234 } | 18226 } |
| 18235 | 18227 |
| 18236 | 18228 |
| 18237 Handle<v8::Integer> HasOwnPropertyNamedPropertyQuery( | 18229 void HasOwnPropertyNamedPropertyQuery( |
| 18238 Local<String> property, const AccessorInfo& info) { | 18230 Local<String> property, |
| 18239 if (property->Equals(v8_str("foo"))) return v8_num(1).As<v8::Integer>(); | 18231 const v8::PropertyCallbackInfo<v8::Integer>& info) { |
| 18240 return Handle<v8::Integer>(); | 18232 if (property->Equals(v8_str("foo"))) info.GetReturnValue().Set(1); |
| 18241 } | 18233 } |
| 18242 | 18234 |
| 18243 | 18235 |
| 18244 Handle<v8::Integer> HasOwnPropertyNamedPropertyQuery2( | 18236 void HasOwnPropertyNamedPropertyQuery2( |
| 18245 Local<String> property, const AccessorInfo& info) { | 18237 Local<String> property, |
| 18246 if (property->Equals(v8_str("bar"))) return v8_num(1).As<v8::Integer>(); | 18238 const v8::PropertyCallbackInfo<v8::Integer>& info) { |
| 18247 return Handle<v8::Integer>(); | 18239 if (property->Equals(v8_str("bar"))) info.GetReturnValue().Set(1); |
| 18248 } | 18240 } |
| 18249 | 18241 |
| 18250 | 18242 |
| 18251 Handle<Value> HasOwnPropertyAccessorGetter(Local<String> property, | 18243 void HasOwnPropertyAccessorGetter( |
| 18252 const AccessorInfo& info) { | 18244 Local<String> property, |
| 18253 return v8_str("yes"); | 18245 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 18246 info.GetReturnValue().Set(v8_str("yes")); |
| 18254 } | 18247 } |
| 18255 | 18248 |
| 18256 | 18249 |
| 18257 TEST(HasOwnProperty) { | 18250 TEST(HasOwnProperty) { |
| 18258 LocalContext env; | 18251 LocalContext env; |
| 18259 v8::HandleScope scope(env->GetIsolate()); | 18252 v8::HandleScope scope(env->GetIsolate()); |
| 18260 { // Check normal properties and defined getters. | 18253 { // Check normal properties and defined getters. |
| 18261 Handle<Value> value = CompileRun( | 18254 Handle<Value> value = CompileRun( |
| 18262 "function Foo() {" | 18255 "function Foo() {" |
| 18263 " this.foo = 11;" | 18256 " this.foo = 11;" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18430 context->AllowCodeGenerationFromStrings(false); | 18423 context->AllowCodeGenerationFromStrings(false); |
| 18431 context->SetErrorMessageForCodeGenerationFromStrings(message); | 18424 context->SetErrorMessageForCodeGenerationFromStrings(message); |
| 18432 Handle<Value> result = CompileRun("eval('42')"); | 18425 Handle<Value> result = CompileRun("eval('42')"); |
| 18433 CHECK(result.IsEmpty()); | 18426 CHECK(result.IsEmpty()); |
| 18434 CHECK(try_catch.HasCaught()); | 18427 CHECK(try_catch.HasCaught()); |
| 18435 Handle<String> actual_message = try_catch.Message()->Get(); | 18428 Handle<String> actual_message = try_catch.Message()->Get(); |
| 18436 CHECK(expected_message->Equals(actual_message)); | 18429 CHECK(expected_message->Equals(actual_message)); |
| 18437 } | 18430 } |
| 18438 | 18431 |
| 18439 | 18432 |
| 18440 static v8::Handle<Value> NonObjectThis(const v8::Arguments& args) { | 18433 static void NonObjectThis(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 18441 return v8::Undefined(); | |
| 18442 } | 18434 } |
| 18443 | 18435 |
| 18444 | 18436 |
| 18445 THREADED_TEST(CallAPIFunctionOnNonObject) { | 18437 THREADED_TEST(CallAPIFunctionOnNonObject) { |
| 18446 LocalContext context; | 18438 LocalContext context; |
| 18447 v8::HandleScope scope(context->GetIsolate()); | 18439 v8::HandleScope scope(context->GetIsolate()); |
| 18448 Handle<FunctionTemplate> templ = v8::FunctionTemplate::New(NonObjectThis); | 18440 Handle<FunctionTemplate> templ = v8::FunctionTemplate::New(NonObjectThis); |
| 18449 Handle<Function> function = templ->GetFunction(); | 18441 Handle<Function> function = templ->GetFunction(); |
| 18450 context->Global()->Set(v8_str("f"), function); | 18442 context->Global()->Set(v8_str("f"), function); |
| 18451 TryCatch try_catch; | 18443 TryCatch try_catch; |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18744 callback_fired ^= 1; // Toggle first bit. | 18736 callback_fired ^= 1; // Toggle first bit. |
| 18745 } | 18737 } |
| 18746 | 18738 |
| 18747 | 18739 |
| 18748 void CallCompletedCallback2() { | 18740 void CallCompletedCallback2() { |
| 18749 i::OS::Print("Firing callback 2.\n"); | 18741 i::OS::Print("Firing callback 2.\n"); |
| 18750 callback_fired ^= 2; // Toggle second bit. | 18742 callback_fired ^= 2; // Toggle second bit. |
| 18751 } | 18743 } |
| 18752 | 18744 |
| 18753 | 18745 |
| 18754 Handle<Value> RecursiveCall(const Arguments& args) { | 18746 void RecursiveCall(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 18755 int32_t level = args[0]->Int32Value(); | 18747 int32_t level = args[0]->Int32Value(); |
| 18756 if (level < 3) { | 18748 if (level < 3) { |
| 18757 level++; | 18749 level++; |
| 18758 i::OS::Print("Entering recursion level %d.\n", level); | 18750 i::OS::Print("Entering recursion level %d.\n", level); |
| 18759 char script[64]; | 18751 char script[64]; |
| 18760 i::Vector<char> script_vector(script, sizeof(script)); | 18752 i::Vector<char> script_vector(script, sizeof(script)); |
| 18761 i::OS::SNPrintF(script_vector, "recursion(%d)", level); | 18753 i::OS::SNPrintF(script_vector, "recursion(%d)", level); |
| 18762 CompileRun(script_vector.start()); | 18754 CompileRun(script_vector.start()); |
| 18763 i::OS::Print("Leaving recursion level %d.\n", level); | 18755 i::OS::Print("Leaving recursion level %d.\n", level); |
| 18764 CHECK_EQ(0, callback_fired); | 18756 CHECK_EQ(0, callback_fired); |
| 18765 } else { | 18757 } else { |
| 18766 i::OS::Print("Recursion ends.\n"); | 18758 i::OS::Print("Recursion ends.\n"); |
| 18767 CHECK_EQ(0, callback_fired); | 18759 CHECK_EQ(0, callback_fired); |
| 18768 } | 18760 } |
| 18769 return Undefined(); | |
| 18770 } | 18761 } |
| 18771 | 18762 |
| 18772 | 18763 |
| 18773 TEST(CallCompletedCallback) { | 18764 TEST(CallCompletedCallback) { |
| 18774 LocalContext env; | 18765 LocalContext env; |
| 18775 v8::HandleScope scope(env->GetIsolate()); | 18766 v8::HandleScope scope(env->GetIsolate()); |
| 18776 v8::Handle<v8::FunctionTemplate> recursive_runtime = | 18767 v8::Handle<v8::FunctionTemplate> recursive_runtime = |
| 18777 v8::FunctionTemplate::New(RecursiveCall); | 18768 v8::FunctionTemplate::New(RecursiveCall); |
| 18778 env->Global()->Set(v8_str("recursion"), | 18769 env->Global()->Set(v8_str("recursion"), |
| 18779 recursive_runtime->GetFunction()); | 18770 recursive_runtime->GetFunction()); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18987 CHECK(!i::Internals::IsInitialized(isolate)); | 18978 CHECK(!i::Internals::IsInitialized(isolate)); |
| 18988 CHECK_EQ(1, fatal_error_callback_counter); | 18979 CHECK_EQ(1, fatal_error_callback_counter); |
| 18989 CHECK(v8::String::Empty().IsEmpty()); | 18980 CHECK(v8::String::Empty().IsEmpty()); |
| 18990 CHECK_EQ(2, fatal_error_callback_counter); | 18981 CHECK_EQ(2, fatal_error_callback_counter); |
| 18991 CHECK(v8::String::Empty(isolate).IsEmpty()); | 18982 CHECK(v8::String::Empty(isolate).IsEmpty()); |
| 18992 CHECK_EQ(3, fatal_error_callback_counter); | 18983 CHECK_EQ(3, fatal_error_callback_counter); |
| 18993 } | 18984 } |
| 18994 | 18985 |
| 18995 | 18986 |
| 18996 static int instance_checked_getter_count = 0; | 18987 static int instance_checked_getter_count = 0; |
| 18997 static Handle<Value> InstanceCheckedGetter(Local<String> name, | 18988 static void InstanceCheckedGetter( |
| 18998 const AccessorInfo& info) { | 18989 Local<String> name, |
| 18990 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 18999 CHECK_EQ(name, v8_str("foo")); | 18991 CHECK_EQ(name, v8_str("foo")); |
| 19000 instance_checked_getter_count++; | 18992 instance_checked_getter_count++; |
| 19001 return v8_num(11); | 18993 info.GetReturnValue().Set(v8_num(11)); |
| 19002 } | 18994 } |
| 19003 | 18995 |
| 19004 | 18996 |
| 19005 static int instance_checked_setter_count = 0; | 18997 static int instance_checked_setter_count = 0; |
| 19006 static void InstanceCheckedSetter(Local<String> name, | 18998 static void InstanceCheckedSetter(Local<String> name, |
| 19007 Local<Value> value, | 18999 Local<Value> value, |
| 19008 const AccessorInfo& info) { | 19000 const v8::PropertyCallbackInfo<void>& info) { |
| 19009 CHECK_EQ(name, v8_str("foo")); | 19001 CHECK_EQ(name, v8_str("foo")); |
| 19010 CHECK_EQ(value, v8_num(23)); | 19002 CHECK_EQ(value, v8_num(23)); |
| 19011 instance_checked_setter_count++; | 19003 instance_checked_setter_count++; |
| 19012 } | 19004 } |
| 19013 | 19005 |
| 19014 | 19006 |
| 19015 static void CheckInstanceCheckedResult(int getters, | 19007 static void CheckInstanceCheckedResult(int getters, |
| 19016 int setters, | 19008 int setters, |
| 19017 bool expects_callbacks, | 19009 bool expects_callbacks, |
| 19018 TryCatch* try_catch) { | 19010 TryCatch* try_catch) { |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19453 i::Semaphore* sem_; | 19445 i::Semaphore* sem_; |
| 19454 volatile int sem_value_; | 19446 volatile int sem_value_; |
| 19455 }; | 19447 }; |
| 19456 | 19448 |
| 19457 | 19449 |
| 19458 THREADED_TEST(SemaphoreInterruption) { | 19450 THREADED_TEST(SemaphoreInterruption) { |
| 19459 ThreadInterruptTest().RunTest(); | 19451 ThreadInterruptTest().RunTest(); |
| 19460 } | 19452 } |
| 19461 | 19453 |
| 19462 #endif // WIN32 | 19454 #endif // WIN32 |
| OLD | NEW |