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

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

Issue 6462029: Direct call accessor getter callbacks (arm implementation). (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 10 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 | Annotate | Revision Log
« src/assembler.h ('K') | « src/assembler.h ('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 7507 matching lines...) Expand 10 before | Expand all | Expand 10 after
7518 // Helper to maximize the odds of object moving. 7518 // Helper to maximize the odds of object moving.
7519 static void GenerateSomeGarbage() { 7519 static void GenerateSomeGarbage() {
7520 CompileRun( 7520 CompileRun(
7521 "var garbage;" 7521 "var garbage;"
7522 "for (var i = 0; i < 1000; i++) {" 7522 "for (var i = 0; i < 1000; i++) {"
7523 " garbage = [1/i, \"garbage\" + i, garbage, {foo: garbage}];" 7523 " garbage = [1/i, \"garbage\" + i, garbage, {foo: garbage}];"
7524 "}" 7524 "}"
7525 "garbage = undefined;"); 7525 "garbage = undefined;");
7526 } 7526 }
7527 7527
7528
7528 v8::Handle<v8::Value> DirectApiCallback(const v8::Arguments& args) { 7529 v8::Handle<v8::Value> DirectApiCallback(const v8::Arguments& args) {
7529 static int count = 0; 7530 static int count = 0;
7530 if (count++ % 3 == 0) { 7531 if (count++ % 3 == 0) {
7531 v8::V8::LowMemoryNotification(); // This should move the stub 7532 v8::V8::LowMemoryNotification(); // This should move the stub
7532 GenerateSomeGarbage(); // This should ensure the old stub memory is flushed 7533 GenerateSomeGarbage(); // This should ensure the old stub memory is flushed
7533 } 7534 }
7534 return v8::Handle<v8::Value>(); 7535 return v8::Handle<v8::Value>();
7535 } 7536 }
7536 7537
7537 7538
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
7573 "function f() {" 7574 "function f() {"
7574 " for (var i = 1; i <= 5; i++) {" 7575 " for (var i = 1; i <= 5; i++) {"
7575 " try { nativeobject.callback(); } catch (e) { result += e; }" 7576 " try { nativeobject.callback(); } catch (e) { result += e; }"
7576 " }" 7577 " }"
7577 "}" 7578 "}"
7578 "f(); result;"); 7579 "f(); result;");
7579 CHECK_EQ(v8_str("ggggg"), result); 7580 CHECK_EQ(v8_str("ggggg"), result);
7580 } 7581 }
7581 7582
7582 7583
7584 v8::Handle<v8::Value> DirectLoadCallback(Local<String> name,
7585 const v8::AccessorInfo& info) {
7586 if (++p_getter_count % 3 == 0) {
7587 v8::V8::LowMemoryNotification();
antonm 2011/02/17 16:13:44 you can probably directly force GC as v8::internal
Zaheer 2011/02/21 10:25:35 Done.
7588 GenerateSomeGarbage();
7589 }
7590 return v8::Handle<v8::Value>();
7591 }
7592
7593
7594 THREADED_TEST(LoadICFastApi_DirectCall_GCMoveStub) {
7595 v8::HandleScope scope;
7596 LocalContext context;
7597 v8::Handle<v8::ObjectTemplate> obj = v8::ObjectTemplate::New();
7598 obj->SetAccessor(v8_str("p1"), DirectLoadCallback);
7599 context->Global()->Set(v8_str("o1"), obj->NewInstance());
7600 p_getter_count = 0;
7601 CompileRun(
7602 "function f() {"
7603 " for (var i = 0; i < 30; i++) o1.p1;"
7604 "}"
7605 "f();");
7606 CHECK_EQ(30, p_getter_count);
7607 }
7608
7609
7610 v8::Handle<v8::Value> ThrowingDirectLoadCallback(Local<String> name,
7611 const v8::AccessorInfo& info) {
7612 return v8::ThrowException(v8_str("g"));
7613 }
7614
7615
7616 THREADED_TEST(LoadICFastApi_DirectCall_Throw) {
7617 v8::HandleScope scope;
7618 LocalContext context;
7619 v8::Handle<v8::ObjectTemplate> obj = v8::ObjectTemplate::New();
7620 obj->SetAccessor(v8_str("p1"), ThrowingDirectLoadCallback);
7621 context->Global()->Set(v8_str("o1"), obj->NewInstance());
7622 v8::Handle<Value> result = CompileRun(
7623 "var result = '';"
7624 "for (var i = 0; i < 5; i++) {"
7625 " try { o1.p1; } catch (e) { result += e; }"
7626 "}"
7627 "result;");
7628 CHECK_EQ(v8_str("ggggg"), result);
antonm 2011/02/17 16:13:44 Thank you very much for the tests!
7629 }
7630
7631
7583 THREADED_TEST(InterceptorCallICFastApi_TrivialSignature) { 7632 THREADED_TEST(InterceptorCallICFastApi_TrivialSignature) {
7584 int interceptor_call_count = 0; 7633 int interceptor_call_count = 0;
7585 v8::HandleScope scope; 7634 v8::HandleScope scope;
7586 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 7635 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
7587 v8::Handle<v8::FunctionTemplate> method_templ = 7636 v8::Handle<v8::FunctionTemplate> method_templ =
7588 v8::FunctionTemplate::New(FastApiCallback_TrivialSignature, 7637 v8::FunctionTemplate::New(FastApiCallback_TrivialSignature,
7589 v8_str("method_data"), 7638 v8_str("method_data"),
7590 v8::Handle<v8::Signature>()); 7639 v8::Handle<v8::Signature>());
7591 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 7640 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
7592 proto_templ->Set(v8_str("method"), method_templ); 7641 proto_templ->Set(v8_str("method"), method_templ);
(...skipping 4949 matching lines...) Expand 10 before | Expand all | Expand 10 after
12542 v8::Context::Scope context_scope(context.local()); 12591 v8::Context::Scope context_scope(context.local());
12543 12592
12544 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(); 12593 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New();
12545 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator); 12594 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator);
12546 context->Global()->Set(v8_str("o"), tmpl->NewInstance()); 12595 context->Global()->Set(v8_str("o"), tmpl->NewInstance());
12547 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( 12596 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun(
12548 "var result = []; for (var k in o) result.push(k); result")); 12597 "var result = []; for (var k in o) result.push(k); result"));
12549 CHECK_EQ(1, result->Length()); 12598 CHECK_EQ(1, result->Length());
12550 CHECK_EQ(v8_str("universalAnswer"), result->Get(0)); 12599 CHECK_EQ(v8_str("universalAnswer"), result->Get(0));
12551 } 12600 }
OLDNEW
« src/assembler.h ('K') | « src/assembler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698