Index: test/cctest/test-api.cc |
=================================================================== |
--- test/cctest/test-api.cc (revision 6213) |
+++ test/cctest/test-api.cc (working copy) |
@@ -7225,6 +7225,42 @@ |
"garbage = undefined;"); |
} |
+v8::Handle<v8::Value> callback(const v8::Arguments& args) { |
+ static int count = 0; |
+ if (count++ % 3 == 0) { |
+ v8::V8::LowMemoryNotification(); // This should move the stub |
+ GenerateSomeGarbage(); // This should ensure the old stub memory is flushed |
+ } |
+ return v8::Handle<v8::Value>(); |
+} |
+ |
+ |
+THREADED_TEST(CallICFastApi_DirectCall_GCMoveStub) { |
+ v8::HandleScope scope; |
+ v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(); |
+ v8::Persistent<v8::Context> context = v8::Context::New(0, global); |
+ 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.
|
+ v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New(); |
+ nativeobject_templ->Set("callback", v8::FunctionTemplate::New(callback)); |
+ v8::Local<v8::Object> nativeobject_obj = nativeobject_templ->NewInstance(); |
+ 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.
|
+ // call the api function multiple times to ensure direct call stub creation |
+ // and make the function garbage so that the stub becomes garbage and a |
+ // compact GC moves stubs created later. |
+ 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.
|
+ "function outer() { " |
+ " 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.
|
+ " for (var i = 1; i <= 3; i++){ " |
+ " nativeobject.callback(); " |
+ " } " |
+ " } " |
+ " return inner; " |
+ "} " |
+ "for (var j = 1; j <= 4; j++){ " |
+ " 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
|
+ "} "); |
+} |
+ |
THREADED_TEST(InterceptorCallICFastApi_TrivialSignature) { |
int interceptor_call_count = 0; |
v8::HandleScope scope; |