OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdlib.h> | 5 #include <stdlib.h> |
6 | 6 |
7 #include "test/cctest/test-api.h" | 7 #include "test/cctest/test-api.h" |
8 | 8 |
9 #include "include/v8-util.h" | 9 #include "include/v8-util.h" |
10 #include "src/api.h" | 10 #include "src/api.h" |
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 i::Handle<i::JSReceiver> global_proxy = | 866 i::Handle<i::JSReceiver> global_proxy = |
867 v8::Utils::OpenHandle<Object, i::JSReceiver>(context->Global()); | 867 v8::Utils::OpenHandle<Object, i::JSReceiver>(context->Global()); |
868 CHECK(global_proxy->IsJSGlobalProxy()); | 868 CHECK(global_proxy->IsJSGlobalProxy()); |
869 i::Handle<i::JSGlobalObject> global( | 869 i::Handle<i::JSGlobalObject> global( |
870 i::JSGlobalObject::cast(global_proxy->map()->prototype())); | 870 i::JSGlobalObject::cast(global_proxy->map()->prototype())); |
871 CHECK(global->map()->has_named_interceptor()); | 871 CHECK(global->map()->has_named_interceptor()); |
872 | 872 |
873 v8::Local<Value> value = CompileRun( | 873 v8::Local<Value> value = CompileRun( |
874 "var f = function() { " | 874 "var f = function() { " |
875 " try {" | 875 " try {" |
876 " x;" | 876 " x1;" |
| 877 " } catch(e) {" |
| 878 " }" |
| 879 " return typeof x1 === 'undefined';" |
| 880 "};" |
| 881 "for (var i = 0; i < 10; i++) {" |
| 882 " f();" |
| 883 "};" |
| 884 "f();"); |
| 885 CHECK_EQ(true, value->BooleanValue(context.local()).FromJust()); |
| 886 |
| 887 value = CompileRun( |
| 888 "var f = function() { " |
| 889 " try {" |
| 890 " x2;" |
877 " return false;" | 891 " return false;" |
878 " } catch(e) {" | 892 " } catch(e) {" |
879 " return true;" | 893 " return true;" |
880 " }" | 894 " }" |
881 "};" | 895 "};" |
882 "for (var i = 0; i < 10; i++) {" | 896 "for (var i = 0; i < 10; i++) {" |
883 " f();" | 897 " f();" |
884 "};" | 898 "};" |
885 "f();"); | 899 "f();"); |
886 CHECK_EQ(true, value->BooleanValue(context.local()).FromJust()); | 900 CHECK_EQ(true, value->BooleanValue(context.local()).FromJust()); |
887 | 901 |
888 value = CompileRun( | 902 value = CompileRun( |
889 "var f = function() { " | 903 "var f = function() { " |
890 " try {" | 904 " try {" |
891 " typeof(x);" | 905 " typeof(x3);" |
892 " return true;" | 906 " return true;" |
893 " } catch(e) {" | 907 " } catch(e) {" |
894 " return false;" | 908 " return false;" |
895 " }" | 909 " }" |
896 "};" | 910 "};" |
897 "for (var i = 0; i < 10; i++) {" | 911 "for (var i = 0; i < 10; i++) {" |
898 " f();" | 912 " f();" |
899 "};" | 913 "};" |
900 "f();"); | 914 "f();"); |
901 CHECK_EQ(true, value->BooleanValue(context.local()).FromJust()); | 915 CHECK_EQ(true, value->BooleanValue(context.local()).FromJust()); |
(...skipping 3070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3972 ->Set(env.local(), v8_str("Fun"), | 3986 ->Set(env.local(), v8_str("Fun"), |
3973 fun_templ->GetFunction(env.local()).ToLocalChecked()) | 3987 fun_templ->GetFunction(env.local()).ToLocalChecked()) |
3974 .FromJust()); | 3988 .FromJust()); |
3975 | 3989 |
3976 CompileRun( | 3990 CompileRun( |
3977 "var f = new Fun();" | 3991 "var f = new Fun();" |
3978 "Number.prototype.__proto__ = f;" | 3992 "Number.prototype.__proto__ = f;" |
3979 "var a = 42;" | 3993 "var a = 42;" |
3980 "for (var i = 0; i<3; i++) { a.foo; }"); | 3994 "for (var i = 0; i<3; i++) { a.foo; }"); |
3981 } | 3995 } |
OLD | NEW |