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 16951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16962 "} \n"; | 16962 "} \n"; |
16963 CompileRun(throw_again); | 16963 CompileRun(throw_again); |
16964 CHECK(try_catch.HasCaught()); | 16964 CHECK(try_catch.HasCaught()); |
16965 Local<Message> message = try_catch.Message(); | 16965 Local<Message> message = try_catch.Message(); |
16966 CHECK(!message.IsEmpty()); | 16966 CHECK(!message.IsEmpty()); |
16967 CHECK_EQ(6, message->GetLineNumber()); | 16967 CHECK_EQ(6, message->GetLineNumber()); |
16968 } | 16968 } |
16969 } | 16969 } |
16970 | 16970 |
16971 | 16971 |
16972 THREADED_TEST(Regress137002a) { | 16972 static void Helper137002(bool do_store, |
16973 i::FLAG_allow_natives_syntax = true; | 16973 bool polymorphic, |
16974 v8::HandleScope scope; | 16974 bool remove_accessor) { |
16975 LocalContext context; | 16975 LocalContext context; |
16976 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 16976 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
16977 templ->SetAccessor(v8_str("foo"), | 16977 templ->SetAccessor(v8_str("foo"), |
16978 GetterWhichReturns42, | 16978 GetterWhichReturns42, |
16979 SetterWhichSetsYOnThisTo23); | 16979 SetterWhichSetsYOnThisTo23); |
16980 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 16980 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
16981 | 16981 |
16982 // Turn monomorphic on slow object with native accessor, then turn | 16982 // Turn monomorphic on slow object with native accessor, then turn |
16983 // polymorphic, finally optimize to create negative lookup and fail. | 16983 // polymorphic, finally optimize to create negative lookup and fail. |
16984 CompileRun("function f(x) { return x.foo; }" | 16984 CompileRun(do_store ? |
| 16985 "function f(x) { x.foo = void 0; }" : |
| 16986 "function f(x) { return x.foo; }"); |
| 16987 CompileRun("obj.y = void 0;" |
16985 "%OptimizeObjectForAddingMultipleProperties(obj, 1);" | 16988 "%OptimizeObjectForAddingMultipleProperties(obj, 1);" |
16986 "obj.__proto__ = null;" | 16989 "obj.__proto__ = null;" |
16987 "f(obj); f(obj); f({});" | 16990 "f(obj); f(obj);"); |
16988 "%OptimizeFunctionOnNextCall(f);" | 16991 if (polymorphic) { |
16989 "var result = f(obj);"); | 16992 CompileRun("f({});"); |
16990 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); | 16993 } |
| 16994 CompileRun("obj.y = void 0;" |
| 16995 "%OptimizeFunctionOnNextCall(f);"); |
| 16996 if (remove_accessor) { |
| 16997 CompileRun("delete obj.foo;"); |
| 16998 } |
| 16999 CompileRun("var result = f(obj);"); |
| 17000 if (do_store) { |
| 17001 CompileRun("result = obj.y;"); |
| 17002 } |
| 17003 if (remove_accessor) { |
| 17004 CHECK(context->Global()->Get(v8_str("result"))->IsUndefined()); |
| 17005 } else { |
| 17006 CHECK_EQ(do_store ? 23 : 42, |
| 17007 context->Global()->Get(v8_str("result"))->Int32Value()); |
| 17008 } |
| 17009 } |
| 17010 |
| 17011 |
| 17012 THREADED_TEST(Regress137002a) { |
| 17013 i::FLAG_allow_natives_syntax = true; |
| 17014 i::FLAG_compilation_cache = false; |
| 17015 v8::HandleScope scope; |
| 17016 Helper137002(false, false, false); |
| 17017 Helper137002(false, false, true); |
| 17018 Helper137002(false, true, false); |
| 17019 Helper137002(false, true, true); |
| 17020 Helper137002(true, false, false); |
| 17021 Helper137002(true, false, true); |
| 17022 Helper137002(true, true, false); |
| 17023 Helper137002(true, true, true); |
16991 } | 17024 } |
16992 | 17025 |
16993 | 17026 |
16994 THREADED_TEST(Regress137002b) { | 17027 THREADED_TEST(Regress137002b) { |
16995 i::FLAG_allow_natives_syntax = true; | 17028 i::FLAG_allow_natives_syntax = true; |
16996 v8::HandleScope scope; | 17029 v8::HandleScope scope; |
16997 LocalContext context; | 17030 LocalContext context; |
16998 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 17031 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
16999 templ->SetAccessor(v8_str("foo"), | 17032 templ->SetAccessor(v8_str("foo"), |
17000 GetterWhichReturns42, | 17033 GetterWhichReturns42, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17053 v8::HandleScope scope; | 17086 v8::HandleScope scope; |
17054 LocalContext context; | 17087 LocalContext context; |
17055 | 17088 |
17056 // Compile a try-finally clause where the finally block causes a GC | 17089 // Compile a try-finally clause where the finally block causes a GC |
17057 // while there still is a message pending for external reporting. | 17090 // while there still is a message pending for external reporting. |
17058 TryCatch try_catch; | 17091 TryCatch try_catch; |
17059 try_catch.SetVerbose(true); | 17092 try_catch.SetVerbose(true); |
17060 CompileRun("try { throw new Error(); } finally { gc(); }"); | 17093 CompileRun("try { throw new Error(); } finally { gc(); }"); |
17061 CHECK(try_catch.HasCaught()); | 17094 CHECK(try_catch.HasCaught()); |
17062 } | 17095 } |
OLD | NEW |