Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Side by Side Diff: test/cctest/test-api.cc

Issue 1327002: Simplify passing of AccessorInfo to interceptors: (Closed)
Patch Set: . Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« src/ia32/stub-cache-ia32.cc ('K') | « src/x64/stub-cache-x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 5876 matching lines...) Expand 10 before | Expand all | Expand 10 after
5887 "proto1.y = 42;" 5887 "proto1.y = 42;"
5888 "var result = 0;" 5888 "var result = 0;"
5889 "for (var i = 0; i < 1000; i++) {" 5889 "for (var i = 0; i < 1000; i++) {"
5890 " result += o.y;" 5890 " result += o.y;"
5891 "}" 5891 "}"
5892 "result;", 5892 "result;",
5893 42 * 1000); 5893 42 * 1000);
5894 } 5894 }
5895 5895
5896 5896
5897 static int interceptor_load_not_handled_calls = 0;
5898 static v8::Handle<Value> InterceptorLoadNotHandled(Local<String> name,
5899 const AccessorInfo& info) {
5900 ++interceptor_load_not_handled_calls;
5901 return v8::Handle<v8::Value>();
5902 }
5903
5904
5905 // Test how post-interceptor lookups are done in the non-cacheable
5906 // case: the interceptor should not be invoked during this lookup.
5907 THREADED_TEST(InterceptorLoadICPostInterceptor) {
5908 interceptor_load_not_handled_calls = 0;
5909 CheckInterceptorLoadIC(InterceptorLoadNotHandled,
5910 "receiver = new Object();"
5911 "receiver.__proto__ = o;"
5912 "proto = new Object();"
5913 "/* Make proto a slow-case object. */"
5914 "for (var i = 0; i < 1000; i++) {"
5915 " proto[\"xxxxxxxx\" + i] = [];"
5916 "}"
5917 "proto.x = 17;"
5918 "o.__proto__ = proto;"
5919 "var result = 0;"
5920 "for (var i = 0; i < 1000; i++) {"
5921 " result += receiver.x;"
5922 "}"
5923 "result;",
5924 17 * 1000);
5925 CHECK_EQ(1000, interceptor_load_not_handled_calls);
5926 }
5927
5928
5897 // Test the case when we stored field into 5929 // Test the case when we stored field into
5898 // a stub, but it got invalidated later on due to override on 5930 // a stub, but it got invalidated later on due to override on
5899 // global object which is between interceptor and fields' holders. 5931 // global object which is between interceptor and fields' holders.
5900 THREADED_TEST(InterceptorLoadICInvalidatedFieldViaGlobal) { 5932 THREADED_TEST(InterceptorLoadICInvalidatedFieldViaGlobal) {
5901 CheckInterceptorLoadIC(InterceptorLoadXICGetter, 5933 CheckInterceptorLoadIC(InterceptorLoadXICGetter,
5902 "o.__proto__ = this;" // set a global to be a proto of o. 5934 "o.__proto__ = this;" // set a global to be a proto of o.
5903 "this.__proto__.y = 239;" 5935 "this.__proto__.y = 239;"
5904 "for (var i = 0; i < 10; i++) {" 5936 "for (var i = 0; i < 10; i++) {"
5905 " if (o.y != 239) throw 'oops: ' + o.y;" 5937 " if (o.y != 239) throw 'oops: ' + o.y;"
5906 // Now it should be ICed and keep a reference to y defined on field_holder. 5938 // Now it should be ICed and keep a reference to y defined on field_holder.
(...skipping 4041 matching lines...) Expand 10 before | Expand all | Expand 10 after
9948 // This compile will get the code from the compilation cache. 9980 // This compile will get the code from the compilation cache.
9949 CompileRun(source); 9981 CompileRun(source);
9950 9982
9951 script = v8::Script::Compile(v8_str("new C1();")); 9983 script = v8::Script::Compile(v8_str("new C1();"));
9952 for (int i = 0; i < 10; i++) { 9984 for (int i = 0; i < 10; i++) {
9953 v8::Handle<v8::Object> c1 = v8::Handle<v8::Object>::Cast(script->Run()); 9985 v8::Handle<v8::Object> c1 = v8::Handle<v8::Object>::Cast(script->Run());
9954 CHECK_EQ(42, c1->Get(v8_str("x"))->Int32Value()); 9986 CHECK_EQ(42, c1->Get(v8_str("x"))->Int32Value());
9955 CHECK_EQ(23, c1->Get(v8_str("y"))->Int32Value()); 9987 CHECK_EQ(23, c1->Get(v8_str("y"))->Int32Value());
9956 } 9988 }
9957 } 9989 }
OLDNEW
« src/ia32/stub-cache-ia32.cc ('K') | « src/x64/stub-cache-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698