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 1920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1931 templ->PrototypeTemplate()->SetAccessor(name, getter, setter); | 1931 templ->PrototypeTemplate()->SetAccessor(name, getter, setter); |
1932 } | 1932 } |
1933 | 1933 |
1934 void AddInterceptor(Handle<FunctionTemplate> templ, | 1934 void AddInterceptor(Handle<FunctionTemplate> templ, |
1935 v8::NamedPropertyGetterCallback getter, | 1935 v8::NamedPropertyGetterCallback getter, |
1936 v8::NamedPropertySetterCallback setter) { | 1936 v8::NamedPropertySetterCallback setter) { |
1937 templ->InstanceTemplate()->SetNamedPropertyHandler(getter, setter); | 1937 templ->InstanceTemplate()->SetNamedPropertyHandler(getter, setter); |
1938 } | 1938 } |
1939 | 1939 |
1940 | 1940 |
| 1941 THREADED_TEST(EmptyInterceptorBreakTransitions) { |
| 1942 v8::HandleScope scope(CcTest::isolate()); |
| 1943 Handle<FunctionTemplate> templ = FunctionTemplate::New(); |
| 1944 AddInterceptor(templ, EmptyInterceptorGetter, EmptyInterceptorSetter); |
| 1945 LocalContext env; |
| 1946 env->Global()->Set(v8_str("Constructor"), templ->GetFunction()); |
| 1947 CompileRun("var o1 = new Constructor;" |
| 1948 "o1.a = 1;" // Ensure a and x share the descriptor array. |
| 1949 "Object.defineProperty(o1, 'x', {value: 10});"); |
| 1950 CompileRun("var o2 = new Constructor;" |
| 1951 "o2.a = 1;" |
| 1952 "Object.defineProperty(o2, 'x', {value: 10});"); |
| 1953 } |
| 1954 |
| 1955 |
1941 THREADED_TEST(EmptyInterceptorDoesNotShadowAccessors) { | 1956 THREADED_TEST(EmptyInterceptorDoesNotShadowAccessors) { |
1942 v8::HandleScope scope(CcTest::isolate()); | 1957 v8::HandleScope scope(CcTest::isolate()); |
1943 Handle<FunctionTemplate> parent = FunctionTemplate::New(); | 1958 Handle<FunctionTemplate> parent = FunctionTemplate::New(); |
1944 Handle<FunctionTemplate> child = FunctionTemplate::New(); | 1959 Handle<FunctionTemplate> child = FunctionTemplate::New(); |
1945 child->Inherit(parent); | 1960 child->Inherit(parent); |
1946 AddAccessor(parent, v8_str("age"), | 1961 AddAccessor(parent, v8_str("age"), |
1947 SimpleAccessorGetter, SimpleAccessorSetter); | 1962 SimpleAccessorGetter, SimpleAccessorSetter); |
1948 AddInterceptor(child, EmptyInterceptorGetter, EmptyInterceptorSetter); | 1963 AddInterceptor(child, EmptyInterceptorGetter, EmptyInterceptorSetter); |
1949 LocalContext env; | 1964 LocalContext env; |
1950 env->Global()->Set(v8_str("Child"), child->GetFunction()); | 1965 env->Global()->Set(v8_str("Child"), child->GetFunction()); |
(...skipping 18760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20711 } | 20726 } |
20712 for (int i = 0; i < runs; i++) { | 20727 for (int i = 0; i < runs; i++) { |
20713 Local<String> expected; | 20728 Local<String> expected; |
20714 if (i != 0) { | 20729 if (i != 0) { |
20715 CHECK_EQ(v8_str("escape value"), values[i]); | 20730 CHECK_EQ(v8_str("escape value"), values[i]); |
20716 } else { | 20731 } else { |
20717 CHECK(values[i].IsEmpty()); | 20732 CHECK(values[i].IsEmpty()); |
20718 } | 20733 } |
20719 } | 20734 } |
20720 } | 20735 } |
OLD | NEW |