Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 8948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8959 "inc(1);" | 8959 "inc(1);" |
| 8960 "o.x = inc;" | 8960 "o.x = inc;" |
| 8961 "var result = 0;" | 8961 "var result = 0;" |
| 8962 "for (var i = 0; i < 1000; i++) {" | 8962 "for (var i = 0; i < 1000; i++) {" |
| 8963 " result = o.x(42);" | 8963 " result = o.x(42);" |
| 8964 "}"); | 8964 "}"); |
| 8965 CHECK_EQ(41, value->Int32Value()); | 8965 CHECK_EQ(41, value->Int32Value()); |
| 8966 } | 8966 } |
| 8967 | 8967 |
| 8968 | 8968 |
| 8969 // Same test as above, except the code is wrapped in a function | |
| 8970 // 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.
| |
| 8971 THREADED_TEST(InterceptorCallICConstantFunctionNotNeededWrapped) { | |
| 8972 v8::HandleScope scope; | |
| 8973 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | |
| 8974 templ->SetNamedPropertyHandler(InterceptorCallICGetter5); | |
| 8975 LocalContext context; | |
| 8976 context->Global()->Set(v8_str("o"), templ->NewInstance()); | |
| 8977 call_ic_function5 = | |
| 8978 v8_compile("function f(x) { return x - 1; }; f")->Run(); | |
| 8979 v8::Handle<Value> value = CompileRun( | |
| 8980 "(function() {" | |
| 8981 " function inc(x) { return x + 1; };" | |
| 8982 " inc(1);" | |
| 8983 " o.x = inc;" | |
| 8984 " var result = 0;" | |
| 8985 " for (var i = 0; i < 1000; i++) {" | |
| 8986 " result = o.x(42);" | |
| 8987 " }" | |
| 8988 " return result;" | |
| 8989 "})();"); | |
| 8990 CHECK_EQ(41, value->Int32Value()); | |
| 8991 } | |
| 8992 | |
| 8993 | |
| 8969 // Test the case when we stored constant function into | 8994 // Test the case when we stored constant function into |
| 8970 // a stub, but it got invalidated later on | 8995 // a stub, but it got invalidated later on |
| 8971 THREADED_TEST(InterceptorCallICInvalidatedConstantFunction) { | 8996 THREADED_TEST(InterceptorCallICInvalidatedConstantFunction) { |
| 8972 v8::HandleScope scope; | 8997 v8::HandleScope scope; |
| 8973 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 8998 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 8974 templ->SetNamedPropertyHandler(NoBlockGetterX); | 8999 templ->SetNamedPropertyHandler(NoBlockGetterX); |
| 8975 LocalContext context; | 9000 LocalContext context; |
| 8976 context->Global()->Set(v8_str("o"), templ->NewInstance()); | 9001 context->Global()->Set(v8_str("o"), templ->NewInstance()); |
| 8977 v8::Handle<Value> value = CompileRun( | 9002 v8::Handle<Value> value = CompileRun( |
| 8978 "function inc(x) { return x + 1; };" | 9003 "function inc(x) { return x + 1; };" |
| (...skipping 6905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 15884 CompileRun("throw 'exception';"); | 15909 CompileRun("throw 'exception';"); |
| 15885 } | 15910 } |
| 15886 | 15911 |
| 15887 | 15912 |
| 15888 TEST(CallCompletedCallbackTwoExceptions) { | 15913 TEST(CallCompletedCallbackTwoExceptions) { |
| 15889 v8::HandleScope scope; | 15914 v8::HandleScope scope; |
| 15890 LocalContext env; | 15915 LocalContext env; |
| 15891 v8::V8::AddCallCompletedCallback(CallCompletedCallbackException); | 15916 v8::V8::AddCallCompletedCallback(CallCompletedCallbackException); |
| 15892 CompileRun("throw 'first exception';"); | 15917 CompileRun("throw 'first exception';"); |
| 15893 } | 15918 } |
| OLD | NEW |