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

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

Issue 6286078: Landing for Zaheer Ahmad. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Using __ str(pc, ...) 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
« no previous file with comments | « src/top.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 v8::Handle<v8::Value> DirectApiCallback(const v8::Arguments& args) {
7529 static int count = 0;
7530 if (count++ % 3 == 0) {
7531 v8::V8::LowMemoryNotification(); // This should move the stub
7532 GenerateSomeGarbage(); // This should ensure the old stub memory is flushed
7533 }
7534 return v8::Handle<v8::Value>();
7535 }
7536
7537
7538 THREADED_TEST(CallICFastApi_DirectCall_GCMoveStub) {
7539 v8::HandleScope scope;
7540 LocalContext context;
7541 v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New();
7542 nativeobject_templ->Set("callback",
7543 v8::FunctionTemplate::New(DirectApiCallback));
7544 v8::Local<v8::Object> nativeobject_obj = nativeobject_templ->NewInstance();
7545 context->Global()->Set(v8_str("nativeobject"), nativeobject_obj);
7546 // call the api function multiple times to ensure direct call stub creation.
7547 CompileRun(
7548 "function f() {"
7549 " for (var i = 1; i <= 30; i++) {"
7550 " nativeobject.callback();"
7551 " }"
7552 "}"
7553 "f();");
7554 }
7555
7556
7557 v8::Handle<v8::Value> ThrowingDirectApiCallback(const v8::Arguments& args) {
7558 return v8::ThrowException(v8_str("g"));
7559 }
7560
7561
7562 THREADED_TEST(CallICFastApi_DirectCall_Throw) {
7563 v8::HandleScope scope;
7564 LocalContext context;
7565 v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New();
7566 nativeobject_templ->Set("callback",
7567 v8::FunctionTemplate::New(ThrowingDirectApiCallback));
7568 v8::Local<v8::Object> nativeobject_obj = nativeobject_templ->NewInstance();
7569 context->Global()->Set(v8_str("nativeobject"), nativeobject_obj);
7570 // call the api function multiple times to ensure direct call stub creation.
7571 v8::Handle<Value> result = CompileRun(
7572 "var result = '';"
7573 "function f() {"
7574 " for (var i = 1; i <= 5; i++) {"
7575 " try { nativeobject.callback(); } catch (e) { result += e; }"
7576 " }"
7577 "}"
7578 "f(); result;");
7579 CHECK_EQ(v8_str("ggggg"), result);
7580 }
7581
7582
7528 THREADED_TEST(InterceptorCallICFastApi_TrivialSignature) { 7583 THREADED_TEST(InterceptorCallICFastApi_TrivialSignature) {
7529 int interceptor_call_count = 0; 7584 int interceptor_call_count = 0;
7530 v8::HandleScope scope; 7585 v8::HandleScope scope;
7531 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 7586 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
7532 v8::Handle<v8::FunctionTemplate> method_templ = 7587 v8::Handle<v8::FunctionTemplate> method_templ =
7533 v8::FunctionTemplate::New(FastApiCallback_TrivialSignature, 7588 v8::FunctionTemplate::New(FastApiCallback_TrivialSignature,
7534 v8_str("method_data"), 7589 v8_str("method_data"),
7535 v8::Handle<v8::Signature>()); 7590 v8::Handle<v8::Signature>());
7536 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 7591 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
7537 proto_templ->Set(v8_str("method"), method_templ); 7592 proto_templ->Set(v8_str("method"), method_templ);
(...skipping 4949 matching lines...) Expand 10 before | Expand all | Expand 10 after
12487 v8::Context::Scope context_scope(context.local()); 12542 v8::Context::Scope context_scope(context.local());
12488 12543
12489 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(); 12544 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New();
12490 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator); 12545 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator);
12491 context->Global()->Set(v8_str("o"), tmpl->NewInstance()); 12546 context->Global()->Set(v8_str("o"), tmpl->NewInstance());
12492 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( 12547 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun(
12493 "var result = []; for (var k in o) result.push(k); result")); 12548 "var result = []; for (var k in o) result.push(k); result"));
12494 CHECK_EQ(1, result->Length()); 12549 CHECK_EQ(1, result->Length());
12495 CHECK_EQ(v8_str("universalAnswer"), result->Get(0)); 12550 CHECK_EQ(v8_str("universalAnswer"), result->Get(0));
12496 } 12551 }
OLDNEW
« no previous file with comments | « src/top.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698