Index: test/cctest/test-api.cc |
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc |
index a00097b54f0fc286f7dff226b9f9d5fcdda4a869..e05d73780d8f8920a74e011bea33c3c6e6cfddac 100644 |
--- a/test/cctest/test-api.cc |
+++ b/test/cctest/test-api.cc |
@@ -5675,6 +5675,35 @@ THREADED_TEST(InterceptorCallICInvalidatedConstantFunctionViaGlobal) { |
} |
+// Test the case when actual function to call sits on global object. |
+THREADED_TEST(InterceptorCallICCachedFromGlobal) { |
+ v8::HandleScope scope; |
+ v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); |
+ templ_o->SetNamedPropertyHandler(NoBlockGetterX); |
+ |
+ LocalContext context; |
+ context->Global()->Set(v8_str("o"), templ_o->NewInstance()); |
+ |
+ v8::Handle<Value> value = CompileRun( |
+ "try {" |
+ " o.__proto__ = this;" |
+ " for (var i = 0; i < 10; i++) {" |
+ " var v = o.parseFloat('239');" |
+ " if (v != 239) throw v;" |
+ // Now it should be ICed and keep a reference to parseFloat. |
+ " }" |
+ " var result = 0;" |
+ " for (var i = 0; i < 10; i++) {" |
+ " result += o.parseFloat('239');" |
+ " }" |
+ " result" |
+ "} catch(e) {" |
+ " e" |
+ "};"); |
+ CHECK_EQ(239 * 10, value->Int32Value()); |
+} |
+ |
+ |
static int interceptor_call_count = 0; |
static v8::Handle<Value> InterceptorICRefErrorGetter(Local<String> name, |