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 21909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21920 } | 21920 } |
21921 { | 21921 { |
21922 v8::TryCatch try_catch; | 21922 v8::TryCatch try_catch; |
21923 uint16_t* data = reinterpret_cast<uint16_t*>(buffer); | 21923 uint16_t* data = reinterpret_cast<uint16_t*>(buffer); |
21924 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString, | 21924 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString, |
21925 length).IsEmpty()); | 21925 length).IsEmpty()); |
21926 CHECK(!try_catch.HasCaught()); | 21926 CHECK(!try_catch.HasCaught()); |
21927 } | 21927 } |
21928 free(buffer); | 21928 free(buffer); |
21929 } | 21929 } |
| 21930 |
| 21931 |
| 21932 TEST(CompatibleReceiverCheckOnCachedICHandler) { |
| 21933 v8::Isolate* isolate = CcTest::isolate(); |
| 21934 v8::HandleScope scope(isolate); |
| 21935 v8::Local<v8::FunctionTemplate> parent = FunctionTemplate::New(isolate); |
| 21936 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, parent); |
| 21937 auto returns_42 = |
| 21938 v8::FunctionTemplate::New(isolate, Returns42, Local<Value>(), signature); |
| 21939 parent->PrototypeTemplate()->SetAccessorProperty(v8_str("age"), returns_42); |
| 21940 v8::Local<v8::FunctionTemplate> child = v8::FunctionTemplate::New(isolate); |
| 21941 child->Inherit(parent); |
| 21942 LocalContext env; |
| 21943 env->Global()->Set(v8_str("Child"), child->GetFunction()); |
| 21944 |
| 21945 // Make sure there's a compiled stub for "Child.prototype.age" in the cache. |
| 21946 CompileRun( |
| 21947 "var real = new Child();\n" |
| 21948 "for (var i = 0; i < 3; ++i) {\n" |
| 21949 " real.age;\n" |
| 21950 "}\n"); |
| 21951 |
| 21952 // Check that the cached stub is never used. |
| 21953 ExpectInt32( |
| 21954 "var fake = Object.create(Child.prototype);\n" |
| 21955 "var result = 0;\n" |
| 21956 "function test(d) {\n" |
| 21957 " if (d == 3) return;\n" |
| 21958 " try {\n" |
| 21959 " fake.age;\n" |
| 21960 " result = 1;\n" |
| 21961 " } catch (e) {\n" |
| 21962 " }\n" |
| 21963 " test(d+1);\n" |
| 21964 "}\n" |
| 21965 "test(0);\n" |
| 21966 "result;\n", |
| 21967 0); |
| 21968 } |
OLD | NEW |