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 1932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1943 templ->PrototypeTemplate()->SetAccessor(name, getter, setter); | 1943 templ->PrototypeTemplate()->SetAccessor(name, getter, setter); |
1944 } | 1944 } |
1945 | 1945 |
1946 void AddInterceptor(Handle<FunctionTemplate> templ, | 1946 void AddInterceptor(Handle<FunctionTemplate> templ, |
1947 v8::NamedPropertyGetterCallback getter, | 1947 v8::NamedPropertyGetterCallback getter, |
1948 v8::NamedPropertySetterCallback setter) { | 1948 v8::NamedPropertySetterCallback setter) { |
1949 templ->InstanceTemplate()->SetNamedPropertyHandler(getter, setter); | 1949 templ->InstanceTemplate()->SetNamedPropertyHandler(getter, setter); |
1950 } | 1950 } |
1951 | 1951 |
1952 | 1952 |
| 1953 THREADED_TEST(EmptyInterceptorBreakTransitions) { |
| 1954 v8::HandleScope scope(CcTest::isolate()); |
| 1955 Handle<FunctionTemplate> templ = FunctionTemplate::New(); |
| 1956 AddInterceptor(templ, EmptyInterceptorGetter, EmptyInterceptorSetter); |
| 1957 LocalContext env; |
| 1958 env->Global()->Set(v8_str("Constructor"), templ->GetFunction()); |
| 1959 CompileRun("var o1 = new Constructor;" |
| 1960 "o1.a = 1;" // Ensure a and x share the descriptor array. |
| 1961 "Object.defineProperty(o1, 'x', {value: 10});"); |
| 1962 CompileRun("var o2 = new Constructor;" |
| 1963 "o2.a = 1;" |
| 1964 "Object.defineProperty(o2, 'x', {value: 10});"); |
| 1965 } |
| 1966 |
| 1967 |
1953 THREADED_TEST(EmptyInterceptorDoesNotShadowAccessors) { | 1968 THREADED_TEST(EmptyInterceptorDoesNotShadowAccessors) { |
1954 v8::HandleScope scope(CcTest::isolate()); | 1969 v8::HandleScope scope(CcTest::isolate()); |
1955 Handle<FunctionTemplate> parent = FunctionTemplate::New(); | 1970 Handle<FunctionTemplate> parent = FunctionTemplate::New(); |
1956 Handle<FunctionTemplate> child = FunctionTemplate::New(); | 1971 Handle<FunctionTemplate> child = FunctionTemplate::New(); |
1957 child->Inherit(parent); | 1972 child->Inherit(parent); |
1958 AddAccessor(parent, v8_str("age"), | 1973 AddAccessor(parent, v8_str("age"), |
1959 SimpleAccessorGetter, SimpleAccessorSetter); | 1974 SimpleAccessorGetter, SimpleAccessorSetter); |
1960 AddInterceptor(child, EmptyInterceptorGetter, EmptyInterceptorSetter); | 1975 AddInterceptor(child, EmptyInterceptorGetter, EmptyInterceptorSetter); |
1961 LocalContext env; | 1976 LocalContext env; |
1962 env->Global()->Set(v8_str("Child"), child->GetFunction()); | 1977 env->Global()->Set(v8_str("Child"), child->GetFunction()); |
(...skipping 18918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20881 } | 20896 } |
20882 for (int i = 0; i < runs; i++) { | 20897 for (int i = 0; i < runs; i++) { |
20883 Local<String> expected; | 20898 Local<String> expected; |
20884 if (i != 0) { | 20899 if (i != 0) { |
20885 CHECK_EQ(v8_str("escape value"), values[i]); | 20900 CHECK_EQ(v8_str("escape value"), values[i]); |
20886 } else { | 20901 } else { |
20887 CHECK(values[i].IsEmpty()); | 20902 CHECK(values[i].IsEmpty()); |
20888 } | 20903 } |
20889 } | 20904 } |
20890 } | 20905 } |
OLD | NEW |