Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(450)

Side by Side Diff: test/cctest/test-api.cc

Issue 10837141: Add checks for interceptors to negative lookup code in Crankshaft. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/hydrogen-instructions.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 14719 matching lines...) Expand 10 before | Expand all | Expand 10 after
14730 } 14730 }
14731 14731
14732 14732
14733 static void SetterWhichSetsYOnThisTo23(Local<String> name, 14733 static void SetterWhichSetsYOnThisTo23(Local<String> name,
14734 Local<Value> value, 14734 Local<Value> value,
14735 const AccessorInfo& info) { 14735 const AccessorInfo& info) {
14736 info.This()->Set(v8_str("y"), v8_num(23)); 14736 info.This()->Set(v8_str("y"), v8_num(23));
14737 } 14737 }
14738 14738
14739 14739
14740 Handle<Value> FooGetInterceptor(Local<String> name,
14741 const AccessorInfo& info) {
14742 if (!name->Equals(v8_str("foo"))) return Handle<Value>();
14743 return v8_num(42);
14744 }
14745
14746
14747 Handle<Value> FooSetInterceptor(Local<String> name,
14748 Local<Value> value,
14749 const AccessorInfo& info) {
14750 if (!name->Equals(v8_str("foo"))) return Handle<Value>();
14751 info.This()->Set(v8_str("y"), v8_num(23));
14752 return v8_num(23);
14753 }
14754
14755
14740 TEST(SetterOnConstructorPrototype) { 14756 TEST(SetterOnConstructorPrototype) {
14741 v8::HandleScope scope; 14757 v8::HandleScope scope;
14742 Local<ObjectTemplate> templ = ObjectTemplate::New(); 14758 Local<ObjectTemplate> templ = ObjectTemplate::New();
14743 templ->SetAccessor(v8_str("x"), 14759 templ->SetAccessor(v8_str("x"),
14744 GetterWhichReturns42, 14760 GetterWhichReturns42,
14745 SetterWhichSetsYOnThisTo23); 14761 SetterWhichSetsYOnThisTo23);
14746 LocalContext context; 14762 LocalContext context;
14747 context->Global()->Set(v8_str("P"), templ->NewInstance()); 14763 context->Global()->Set(v8_str("P"), templ->NewInstance());
14748 CompileRun("function C1() {" 14764 CompileRun("function C1() {"
14749 " this.x = 23;" 14765 " this.x = 23;"
(...skipping 2218 matching lines...) Expand 10 before | Expand all | Expand 10 after
16968 CHECK(try_catch.HasCaught()); 16984 CHECK(try_catch.HasCaught());
16969 Local<Message> message = try_catch.Message(); 16985 Local<Message> message = try_catch.Message();
16970 CHECK(!message.IsEmpty()); 16986 CHECK(!message.IsEmpty());
16971 CHECK_EQ(6, message->GetLineNumber()); 16987 CHECK_EQ(6, message->GetLineNumber());
16972 } 16988 }
16973 } 16989 }
16974 16990
16975 16991
16976 static void Helper137002(bool do_store, 16992 static void Helper137002(bool do_store,
16977 bool polymorphic, 16993 bool polymorphic,
16978 bool remove_accessor) { 16994 bool remove_accessor,
16995 bool interceptor) {
16979 LocalContext context; 16996 LocalContext context;
16980 Local<ObjectTemplate> templ = ObjectTemplate::New(); 16997 Local<ObjectTemplate> templ = ObjectTemplate::New();
16981 templ->SetAccessor(v8_str("foo"), 16998 if (interceptor) {
16982 GetterWhichReturns42, 16999 templ->SetNamedPropertyHandler(FooGetInterceptor, FooSetInterceptor);
16983 SetterWhichSetsYOnThisTo23); 17000 } else {
17001 templ->SetAccessor(v8_str("foo"),
17002 GetterWhichReturns42,
17003 SetterWhichSetsYOnThisTo23);
17004 }
16984 context->Global()->Set(v8_str("obj"), templ->NewInstance()); 17005 context->Global()->Set(v8_str("obj"), templ->NewInstance());
16985 17006
16986 // Turn monomorphic on slow object with native accessor, then turn 17007 // Turn monomorphic on slow object with native accessor, then turn
16987 // polymorphic, finally optimize to create negative lookup and fail. 17008 // polymorphic, finally optimize to create negative lookup and fail.
16988 CompileRun(do_store ? 17009 CompileRun(do_store ?
16989 "function f(x) { x.foo = void 0; }" : 17010 "function f(x) { x.foo = void 0; }" :
16990 "function f(x) { return x.foo; }"); 17011 "function f(x) { return x.foo; }");
16991 CompileRun("obj.y = void 0;" 17012 CompileRun("obj.y = void 0;");
16992 "%OptimizeObjectForAddingMultipleProperties(obj, 1);" 17013 if (!interceptor) {
16993 "obj.__proto__ = null;" 17014 CompileRun("%OptimizeObjectForAddingMultipleProperties(obj, 1);");
16994 "f(obj); f(obj);"); 17015 }
17016 CompileRun("obj.__proto__ = null;"
17017 "f(obj); f(obj); f(obj);");
16995 if (polymorphic) { 17018 if (polymorphic) {
16996 CompileRun("f({});"); 17019 CompileRun("f({});");
16997 } 17020 }
16998 CompileRun("obj.y = void 0;" 17021 CompileRun("obj.y = void 0;"
16999 "%OptimizeFunctionOnNextCall(f);"); 17022 "%OptimizeFunctionOnNextCall(f);");
17000 if (remove_accessor) { 17023 if (remove_accessor) {
17001 CompileRun("delete obj.foo;"); 17024 CompileRun("delete obj.foo;");
17002 } 17025 }
17003 CompileRun("var result = f(obj);"); 17026 CompileRun("var result = f(obj);");
17004 if (do_store) { 17027 if (do_store) {
17005 CompileRun("result = obj.y;"); 17028 CompileRun("result = obj.y;");
17006 } 17029 }
17007 if (remove_accessor) { 17030 if (remove_accessor && !interceptor) {
17008 CHECK(context->Global()->Get(v8_str("result"))->IsUndefined()); 17031 CHECK(context->Global()->Get(v8_str("result"))->IsUndefined());
17009 } else { 17032 } else {
17010 CHECK_EQ(do_store ? 23 : 42, 17033 CHECK_EQ(do_store ? 23 : 42,
17011 context->Global()->Get(v8_str("result"))->Int32Value()); 17034 context->Global()->Get(v8_str("result"))->Int32Value());
17012 } 17035 }
17013 } 17036 }
17014 17037
17015 17038
17016 THREADED_TEST(Regress137002a) { 17039 THREADED_TEST(Regress137002a) {
17017 i::FLAG_allow_natives_syntax = true; 17040 i::FLAG_allow_natives_syntax = true;
17018 i::FLAG_compilation_cache = false; 17041 i::FLAG_compilation_cache = false;
17019 v8::HandleScope scope; 17042 v8::HandleScope scope;
17020 Helper137002(false, false, false); 17043 Helper137002(false, false, false, false);
17021 Helper137002(false, false, true); 17044 Helper137002(false, false, false, true);
17022 Helper137002(false, true, false); 17045 Helper137002(false, false, true, false);
17023 Helper137002(false, true, true); 17046 Helper137002(false, false, true, true);
17024 Helper137002(true, false, false); 17047 Helper137002(false, true, false, false);
17025 Helper137002(true, false, true); 17048 Helper137002(false, true, false, true);
17026 Helper137002(true, true, false); 17049 Helper137002(false, true, true, false);
17027 Helper137002(true, true, true); 17050 Helper137002(false, true, true, true);
17051 Helper137002(true, false, false, false);
17052 Helper137002(true, false, false, true);
17053 Helper137002(true, false, true, false);
17054 Helper137002(true, false, true, true);
17055 Helper137002(true, true, false, false);
17056 Helper137002(true, true, false, true);
17057 Helper137002(true, true, true, false);
17058 Helper137002(true, true, true, true);
17028 } 17059 }
17029 17060
17030 17061
17031 THREADED_TEST(Regress137002b) { 17062 THREADED_TEST(Regress137002b) {
17032 i::FLAG_allow_natives_syntax = true; 17063 i::FLAG_allow_natives_syntax = true;
17033 v8::HandleScope scope; 17064 v8::HandleScope scope;
17034 LocalContext context; 17065 LocalContext context;
17035 Local<ObjectTemplate> templ = ObjectTemplate::New(); 17066 Local<ObjectTemplate> templ = ObjectTemplate::New();
17036 templ->SetAccessor(v8_str("foo"), 17067 templ->SetAccessor(v8_str("foo"),
17037 GetterWhichReturns42, 17068 GetterWhichReturns42,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
17090 v8::HandleScope scope; 17121 v8::HandleScope scope;
17091 LocalContext context; 17122 LocalContext context;
17092 17123
17093 // Compile a try-finally clause where the finally block causes a GC 17124 // Compile a try-finally clause where the finally block causes a GC
17094 // while there still is a message pending for external reporting. 17125 // while there still is a message pending for external reporting.
17095 TryCatch try_catch; 17126 TryCatch try_catch;
17096 try_catch.SetVerbose(true); 17127 try_catch.SetVerbose(true);
17097 CompileRun("try { throw new Error(); } finally { gc(); }"); 17128 CompileRun("try { throw new Error(); } finally { gc(); }");
17098 CHECK(try_catch.HasCaught()); 17129 CHECK(try_catch.HasCaught());
17099 } 17130 }
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698