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

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

Issue 115106: Fix intermittent crashes caused by unexpected GCs in... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 7 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/runtime.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 2007-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-2008 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 4721 matching lines...) Expand 10 before | Expand all | Expand 10 after
4732 "o.ostehaps = 42;" 4732 "o.ostehaps = 42;"
4733 "o.hasOwnProperty('ostehaps');"); 4733 "o.hasOwnProperty('ostehaps');");
4734 CHECK_EQ(true, value->BooleanValue()); 4734 CHECK_EQ(true, value->BooleanValue());
4735 value = CompileRun( 4735 value = CompileRun(
4736 "var p = new constructor();" 4736 "var p = new constructor();"
4737 "p.hasOwnProperty('ostehaps');"); 4737 "p.hasOwnProperty('ostehaps');");
4738 CHECK_EQ(false, value->BooleanValue()); 4738 CHECK_EQ(false, value->BooleanValue());
4739 } 4739 }
4740 4740
4741 4741
4742 static v8::Handle<Value> InterceptorHasOwnPropertyGetterGC(
4743 Local<String> name,
4744 const AccessorInfo& info) {
4745 ApiTestFuzzer::Fuzz();
4746 i::Heap::CollectAllGarbage();
4747 return v8::Handle<Value>();
4748 }
4749
4750
4751 THREADED_TEST(InterceptorHasOwnPropertyCausingGC) {
4752 v8::HandleScope scope;
4753 LocalContext context;
4754 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
4755 Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate();
4756 instance_templ->SetNamedPropertyHandler(InterceptorHasOwnPropertyGetterGC);
4757 Local<Function> function = fun_templ->GetFunction();
4758 context->Global()->Set(v8_str("constructor"), function);
4759 // Let's first make some stuff so we can be sure to get a good GC.
4760 CompileRun(
4761 "function makestr(size) {"
4762 " switch (size) {"
4763 " case 1: return 'f';"
4764 " case 2: return 'fo';"
4765 " case 3: return 'foo';"
4766 " }"
4767 " return makestr(size >> 1) + makestr((size + 1) >> 1);"
4768 "}"
4769 "var x = makestr(12345);"
4770 "x = makestr(31415);"
4771 "x = makestr(23456);");
4772 v8::Handle<Value> value = CompileRun(
4773 "var o = new constructor();"
4774 "o.__proto__ = new String(x);"
4775 "o.hasOwnProperty('ostehaps');");
4776 CHECK_EQ(false, value->BooleanValue());
4777 }
4778
4779
4742 static v8::Handle<Value> InterceptorLoadICGetter(Local<String> name, 4780 static v8::Handle<Value> InterceptorLoadICGetter(Local<String> name,
4743 const AccessorInfo& info) { 4781 const AccessorInfo& info) {
4744 ApiTestFuzzer::Fuzz(); 4782 ApiTestFuzzer::Fuzz();
4745 CHECK(v8_str("x")->Equals(name)); 4783 CHECK(v8_str("x")->Equals(name));
4746 return v8::Integer::New(42); 4784 return v8::Integer::New(42);
4747 } 4785 }
4748 4786
4749 4787
4750 // This test should hit the load IC for the interceptor case. 4788 // This test should hit the load IC for the interceptor case.
4751 THREADED_TEST(InterceptorLoadIC) { 4789 THREADED_TEST(InterceptorLoadIC) {
(...skipping 1774 matching lines...) Expand 10 before | Expand all | Expand 10 after
6526 // the property 6564 // the property
6527 pass_on_get = false; 6565 pass_on_get = false;
6528 CHECK_EQ(3, global->Get(some_property)->Int32Value()); 6566 CHECK_EQ(3, global->Get(some_property)->Int32Value());
6529 CHECK_EQ(1, force_set_set_count); 6567 CHECK_EQ(1, force_set_set_count);
6530 CHECK_EQ(5, force_set_get_count); 6568 CHECK_EQ(5, force_set_get_count);
6531 // The interceptor should also work for other properties 6569 // The interceptor should also work for other properties
6532 CHECK_EQ(3, global->Get(v8::String::New("b"))->Int32Value()); 6570 CHECK_EQ(3, global->Get(v8::String::New("b"))->Int32Value());
6533 CHECK_EQ(1, force_set_set_count); 6571 CHECK_EQ(1, force_set_set_count);
6534 CHECK_EQ(6, force_set_get_count); 6572 CHECK_EQ(6, force_set_get_count);
6535 } 6573 }
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698