Index: test/cctest/test-api.cc |
=================================================================== |
--- test/cctest/test-api.cc (revision 10417) |
+++ test/cctest/test-api.cc (working copy) |
@@ -8966,6 +8966,31 @@ |
} |
+// Same test as above, except the code is wrapped in a function |
+// to test the optimized compiler. |
Erik Corry
2012/01/17 13:30:51
Can we force optimization?
fschneider
2012/01/17 15:56:40
Done.
|
+THREADED_TEST(InterceptorCallICConstantFunctionNotNeededWrapped) { |
+ v8::HandleScope scope; |
+ v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
+ templ->SetNamedPropertyHandler(InterceptorCallICGetter5); |
+ LocalContext context; |
+ context->Global()->Set(v8_str("o"), templ->NewInstance()); |
+ call_ic_function5 = |
+ v8_compile("function f(x) { return x - 1; }; f")->Run(); |
+ v8::Handle<Value> value = CompileRun( |
+ "(function() {" |
+ " function inc(x) { return x + 1; };" |
+ " inc(1);" |
+ " o.x = inc;" |
+ " var result = 0;" |
+ " for (var i = 0; i < 1000; i++) {" |
+ " result = o.x(42);" |
+ " }" |
+ " return result;" |
+ "})();"); |
+ CHECK_EQ(41, value->Int32Value()); |
+} |
+ |
+ |
// Test the case when we stored constant function into |
// a stub, but it got invalidated later on |
THREADED_TEST(InterceptorCallICInvalidatedConstantFunction) { |