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

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

Issue 6170001: Direct call api functions (arm implementation) (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 11 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/arm/stub-cache-arm.cc ('K') | « 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 7207 matching lines...) Expand 10 before | Expand all | Expand 10 after
7218 // Helper to maximize the odds of object moving. 7218 // Helper to maximize the odds of object moving.
7219 static void GenerateSomeGarbage() { 7219 static void GenerateSomeGarbage() {
7220 CompileRun( 7220 CompileRun(
7221 "var garbage;" 7221 "var garbage;"
7222 "for (var i = 0; i < 1000; i++) {" 7222 "for (var i = 0; i < 1000; i++) {"
7223 " garbage = [1/i, \"garbage\" + i, garbage, {foo: garbage}];" 7223 " garbage = [1/i, \"garbage\" + i, garbage, {foo: garbage}];"
7224 "}" 7224 "}"
7225 "garbage = undefined;"); 7225 "garbage = undefined;");
7226 } 7226 }
7227 7227
7228 v8::Handle<v8::Value> callback(const v8::Arguments& args) {
7229 static int count = 0;
7230 if (count++ % 3 == 0) {
7231 v8::V8::LowMemoryNotification(); // This should move the stub
7232 GenerateSomeGarbage(); // This should ensure the old stub memory is flushed
7233 }
7234 return v8::Handle<v8::Value>();
7235 }
7236
7237
7238 THREADED_TEST(CallICFastApi_DirectCall_GCMoveStub) {
7239 v8::HandleScope scope;
7240 v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();
7241 v8::Persistent<v8::Context> context = v8::Context::New(0, global);
7242 v8::Context::Scope context_scope(context);
antonm 2011/01/26 11:36:38 we have handy LocalContext to get rid of those two
Zaheer 2011/02/02 10:05:59 Done.
7243 v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New();
7244 nativeobject_templ->Set("callback", v8::FunctionTemplate::New(callback));
7245 v8::Local<v8::Object> nativeobject_obj = nativeobject_templ->NewInstance();
7246 context->Global()->Set(String::New("nativeobject"), nativeobject_obj);
antonm 2011/01/26 11:36:38 we have handy v8_str for String::New
Zaheer 2011/02/02 10:05:59 Done.
7247 // call the api function multiple times to ensure direct call stub creation
7248 // and make the function garbage so that the stub becomes garbage and a
7249 // compact GC moves stubs created later.
7250 v8::Handle<Value> value = CompileRun(
antonm 2011/01/26 11:36:38 nit: as you don't need return value, you can just
Zaheer 2011/02/02 10:05:59 Done.
7251 "function outer() { "
7252 " function inner (){ "
antonm 2011/01/26 11:36:38 nit: no space before ( in function declaration and
Zaheer 2011/02/02 10:05:59 Done.
7253 " for (var i = 1; i <= 3; i++){ "
7254 " nativeobject.callback(); "
7255 " } "
7256 " } "
7257 " return inner; "
7258 "} "
7259 "for (var j = 1; j <= 4; j++){ "
7260 " outer()(); "
antonm 2011/01/26 11:36:38 why such involved structure: function which create
Zaheer 2011/02/02 10:05:59 simplified. on device test, the stub doesnt seem t
7261 "} ");
7262 }
7263
7228 THREADED_TEST(InterceptorCallICFastApi_TrivialSignature) { 7264 THREADED_TEST(InterceptorCallICFastApi_TrivialSignature) {
7229 int interceptor_call_count = 0; 7265 int interceptor_call_count = 0;
7230 v8::HandleScope scope; 7266 v8::HandleScope scope;
7231 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 7267 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
7232 v8::Handle<v8::FunctionTemplate> method_templ = 7268 v8::Handle<v8::FunctionTemplate> method_templ =
7233 v8::FunctionTemplate::New(FastApiCallback_TrivialSignature, 7269 v8::FunctionTemplate::New(FastApiCallback_TrivialSignature,
7234 v8_str("method_data"), 7270 v8_str("method_data"),
7235 v8::Handle<v8::Signature>()); 7271 v8::Handle<v8::Signature>());
7236 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 7272 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
7237 proto_templ->Set(v8_str("method"), method_templ); 7273 proto_templ->Set(v8_str("method"), method_templ);
(...skipping 4835 matching lines...) Expand 10 before | Expand all | Expand 10 after
12073 v8::Context::Scope context_scope(context.local()); 12109 v8::Context::Scope context_scope(context.local());
12074 12110
12075 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(); 12111 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New();
12076 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator); 12112 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator);
12077 context->Global()->Set(v8_str("o"), tmpl->NewInstance()); 12113 context->Global()->Set(v8_str("o"), tmpl->NewInstance());
12078 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( 12114 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun(
12079 "var result = []; for (var k in o) result.push(k); result")); 12115 "var result = []; for (var k in o) result.push(k); result"));
12080 CHECK_EQ(1, result->Length()); 12116 CHECK_EQ(1, result->Length());
12081 CHECK_EQ(v8_str("universalAnswer"), result->Get(0)); 12117 CHECK_EQ(v8_str("universalAnswer"), result->Get(0));
12082 } 12118 }
OLDNEW
« src/arm/stub-cache-arm.cc ('K') | « src/top.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698