OLD | NEW |
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 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 2919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2930 "delete obj.y;" | 2930 "delete obj.y;" |
2931 "for (var i = 0; i < 10; i++) get_x(obj);" | 2931 "for (var i = 0; i < 10; i++) get_x(obj);" |
2932 "interceptor_obj.x = 42;" | 2932 "interceptor_obj.x = 42;" |
2933 "interceptor_obj.y = 10;" | 2933 "interceptor_obj.y = 10;" |
2934 "delete interceptor_obj.y;" | 2934 "delete interceptor_obj.y;" |
2935 "get_x(interceptor_obj)"); | 2935 "get_x(interceptor_obj)"); |
2936 CHECK_EQ(result, v8_str("x")); | 2936 CHECK_EQ(result, v8_str("x")); |
2937 } | 2937 } |
2938 | 2938 |
2939 | 2939 |
| 2940 THREADED_TEST(NamedInterceptorDictionaryICMultipleContext) { |
| 2941 v8::HandleScope scope; |
| 2942 |
| 2943 v8::Persistent<Context> context1 = Context::New(); |
| 2944 |
| 2945 context1->Enter(); |
| 2946 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 2947 templ->SetNamedPropertyHandler(XPropertyGetter); |
| 2948 // Create an object with a named interceptor. |
| 2949 v8::Local<v8::Object> object = templ->NewInstance(); |
| 2950 context1->Global()->Set(v8_str("interceptor_obj"), object); |
| 2951 |
| 2952 // Force the object into the slow case. |
| 2953 CompileRun("interceptor_obj.y = 0;" |
| 2954 "delete interceptor_obj.y;"); |
| 2955 context1->Exit(); |
| 2956 |
| 2957 { |
| 2958 // Introduce the object into a different context. |
| 2959 // Repeat named loads to exercise ICs. |
| 2960 LocalContext context2; |
| 2961 context2->Global()->Set(v8_str("interceptor_obj"), object); |
| 2962 Local<Value> result = |
| 2963 CompileRun("function get_x(o) { return o.x; }" |
| 2964 "interceptor_obj.x = 42;" |
| 2965 "for (var i=0; i != 10; i++) {" |
| 2966 " get_x(interceptor_obj);" |
| 2967 "}" |
| 2968 "get_x(interceptor_obj)"); |
| 2969 // Check that the interceptor was actually invoked. |
| 2970 CHECK_EQ(result, v8_str("x")); |
| 2971 } |
| 2972 |
| 2973 // Return to the original context and force some object to the slow case |
| 2974 // to cause the NormalizedMapCache to verify. |
| 2975 context1->Enter(); |
| 2976 CompileRun("var obj = { x : 0 }; delete obj.x;"); |
| 2977 context1->Exit(); |
| 2978 |
| 2979 context1.Dispose(); |
| 2980 } |
| 2981 |
| 2982 |
2940 static v8::Handle<Value> SetXOnPrototypeGetter(Local<String> property, | 2983 static v8::Handle<Value> SetXOnPrototypeGetter(Local<String> property, |
2941 const AccessorInfo& info) { | 2984 const AccessorInfo& info) { |
2942 // Set x on the prototype object and do not handle the get request. | 2985 // Set x on the prototype object and do not handle the get request. |
2943 v8::Handle<v8::Value> proto = info.Holder()->GetPrototype(); | 2986 v8::Handle<v8::Value> proto = info.Holder()->GetPrototype(); |
2944 proto.As<v8::Object>()->Set(v8_str("x"), v8::Integer::New(23)); | 2987 proto.As<v8::Object>()->Set(v8_str("x"), v8::Integer::New(23)); |
2945 return v8::Handle<Value>(); | 2988 return v8::Handle<Value>(); |
2946 } | 2989 } |
2947 | 2990 |
2948 | 2991 |
2949 // This is a regression test for http://crbug.com/20104. Map | 2992 // This is a regression test for http://crbug.com/20104. Map |
(...skipping 8443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11393 | 11436 |
11394 { | 11437 { |
11395 // Change the Boolean.prototype in the second context and check | 11438 // Change the Boolean.prototype in the second context and check |
11396 // that the right function gets called. | 11439 // that the right function gets called. |
11397 v8::HandleScope scope; | 11440 v8::HandleScope scope; |
11398 LocalContext context2; | 11441 LocalContext context2; |
11399 CompileRun("Boolean.prototype.toString = function() { return \"\"; }"); | 11442 CompileRun("Boolean.prototype.toString = function() { return \"\"; }"); |
11400 ExpectString(code, ""); | 11443 ExpectString(code, ""); |
11401 } | 11444 } |
11402 } | 11445 } |
OLD | NEW |