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