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

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

Issue 2282001: Various refactorings in interceptor calling and loading. (Closed)
Patch Set: Addressing Soeren's comments Created 10 years, 7 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
« no previous file with comments | « 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 6227 matching lines...) Expand 10 before | Expand all | Expand 10 after
6238 } 6238 }
6239 6239
6240 6240
6241 THREADED_TEST(InterceptorLoadICWithCallbackOnHolder) { 6241 THREADED_TEST(InterceptorLoadICWithCallbackOnHolder) {
6242 v8::HandleScope scope; 6242 v8::HandleScope scope;
6243 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); 6243 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
6244 templ->SetNamedPropertyHandler(InterceptorLoadXICGetter); 6244 templ->SetNamedPropertyHandler(InterceptorLoadXICGetter);
6245 templ->SetAccessor(v8_str("y"), Return239); 6245 templ->SetAccessor(v8_str("y"), Return239);
6246 LocalContext context; 6246 LocalContext context;
6247 context->Global()->Set(v8_str("o"), templ->NewInstance()); 6247 context->Global()->Set(v8_str("o"), templ->NewInstance());
6248
6249 // Check the case when receiver and interceptor's holder
6250 // are the same objects.
6248 v8::Handle<Value> value = CompileRun( 6251 v8::Handle<Value> value = CompileRun(
6249 "var result = 0;" 6252 "var result = 0;"
6250 "for (var i = 0; i < 7; i++) {" 6253 "for (var i = 0; i < 7; i++) {"
6251 " result = o.y;" 6254 " result = o.y;"
6252 "}"); 6255 "}");
6253 CHECK_EQ(239, value->Int32Value()); 6256 CHECK_EQ(239, value->Int32Value());
6257
6258 // Check the case when interceptor's holder is in proto chain
6259 // of receiver.
6260 value = CompileRun(
6261 "r = { __proto__: o };"
6262 "var result = 0;"
6263 "for (var i = 0; i < 7; i++) {"
6264 " result = r.y;"
6265 "}");
6266 CHECK_EQ(239, value->Int32Value());
6254 } 6267 }
6255 6268
6256 6269
6257 THREADED_TEST(InterceptorLoadICWithCallbackOnProto) { 6270 THREADED_TEST(InterceptorLoadICWithCallbackOnProto) {
6258 v8::HandleScope scope; 6271 v8::HandleScope scope;
6259 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); 6272 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New();
6260 templ_o->SetNamedPropertyHandler(InterceptorLoadXICGetter); 6273 templ_o->SetNamedPropertyHandler(InterceptorLoadXICGetter);
6261 v8::Handle<v8::ObjectTemplate> templ_p = ObjectTemplate::New(); 6274 v8::Handle<v8::ObjectTemplate> templ_p = ObjectTemplate::New();
6262 templ_p->SetAccessor(v8_str("y"), Return239); 6275 templ_p->SetAccessor(v8_str("y"), Return239);
6263 6276
6264 LocalContext context; 6277 LocalContext context;
6265 context->Global()->Set(v8_str("o"), templ_o->NewInstance()); 6278 context->Global()->Set(v8_str("o"), templ_o->NewInstance());
6266 context->Global()->Set(v8_str("p"), templ_p->NewInstance()); 6279 context->Global()->Set(v8_str("p"), templ_p->NewInstance());
6267 6280
6281 // Check the case when receiver and interceptor's holder
6282 // are the same objects.
6268 v8::Handle<Value> value = CompileRun( 6283 v8::Handle<Value> value = CompileRun(
6269 "o.__proto__ = p;" 6284 "o.__proto__ = p;"
6270 "var result = 0;" 6285 "var result = 0;"
6271 "for (var i = 0; i < 7; i++) {" 6286 "for (var i = 0; i < 7; i++) {"
6272 " result = o.x + o.y;" 6287 " result = o.x + o.y;"
6273 "}"); 6288 "}");
6274 CHECK_EQ(239 + 42, value->Int32Value()); 6289 CHECK_EQ(239 + 42, value->Int32Value());
6290
6291 // Check the case when interceptor's holder is in proto chain
6292 // of receiver.
6293 value = CompileRun(
6294 "r = { __proto__: o };"
6295 "var result = 0;"
6296 "for (var i = 0; i < 7; i++) {"
6297 " result = r.x + r.y;"
6298 "}");
6299 CHECK_EQ(239 + 42, value->Int32Value());
6275 } 6300 }
6276 6301
6277 6302
6278 THREADED_TEST(InterceptorLoadICForCallbackWithOverride) { 6303 THREADED_TEST(InterceptorLoadICForCallbackWithOverride) {
6279 v8::HandleScope scope; 6304 v8::HandleScope scope;
6280 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); 6305 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
6281 templ->SetNamedPropertyHandler(InterceptorLoadXICGetter); 6306 templ->SetNamedPropertyHandler(InterceptorLoadXICGetter);
6282 templ->SetAccessor(v8_str("y"), Return239); 6307 templ->SetAccessor(v8_str("y"), Return239);
6283 6308
6284 LocalContext context; 6309 LocalContext context;
(...skipping 4297 matching lines...) Expand 10 before | Expand all | Expand 10 after
10582 const char* code = 10607 const char* code =
10583 "(function() {" 10608 "(function() {"
10584 " for (var i = 0; i < 2*16; i++) {" 10609 " for (var i = 0; i < 2*16; i++) {"
10585 " %_GetFromCache(0, 'a' + i);" 10610 " %_GetFromCache(0, 'a' + i);"
10586 " };" 10611 " };"
10587 " return 'PASSED';" 10612 " return 'PASSED';"
10588 "})()"; 10613 "})()";
10589 v8::internal::Heap::ClearJSFunctionResultCaches(); 10614 v8::internal::Heap::ClearJSFunctionResultCaches();
10590 ExpectString(code, "PASSED"); 10615 ExpectString(code, "PASSED");
10591 } 10616 }
OLDNEW
« no previous file with comments | « src/x64/stub-cache-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698