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

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

Issue 10035060: Fix bug in forced-deletion of globals. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 8 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/api.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 12358 matching lines...) Expand 10 before | Expand all | Expand 10 after
12369 CHECK_EQ(4, CompileRun("f()")->Int32Value()); 12369 CHECK_EQ(4, CompileRun("f()")->Int32Value());
12370 // Force the deletion of foo. 12370 // Force the deletion of foo.
12371 CHECK(context->Global()->ForceDelete(v8_str("foo"))); 12371 CHECK(context->Global()->ForceDelete(v8_str("foo")));
12372 // Make sure the value for foo is read from the prototype, and that 12372 // Make sure the value for foo is read from the prototype, and that
12373 // we don't get in trouble with reading the deleted cell value 12373 // we don't get in trouble with reading the deleted cell value
12374 // sentinel. 12374 // sentinel.
12375 CHECK_EQ(5, CompileRun("f()")->Int32Value()); 12375 CHECK_EQ(5, CompileRun("f()")->Int32Value());
12376 } 12376 }
12377 12377
12378 12378
12379 TEST(InlinedFunctionAcrossContexts) {
12380 i::FLAG_allow_natives_syntax = true;
12381 v8::HandleScope outer_scope;
12382 v8::Persistent<v8::Context> ctx1 = v8::Context::New();
12383 v8::Persistent<v8::Context> ctx2 = v8::Context::New();
12384 ctx1->Enter();
12385
12386 {
12387 v8::HandleScope inner_scope;
12388 CompileRun("var G = 42; function foo() { return G; }");
12389 v8::Local<v8::Value> foo = ctx1->Global()->Get(v8_str("foo"));
12390 ctx2->Enter();
12391 ctx2->Global()->Set(v8_str("o"), foo);
12392 v8::Local<v8::Value> res = CompileRun(
12393 "function f() { return o(); }"
12394 "for (var i = 0; i < 10; ++i) f();"
12395 "%OptimizeFunctionOnNextCall(f);"
12396 "f();");
12397 CHECK_EQ(42, res->Int32Value());
12398 ctx2->Exit();
12399 v8::Handle<v8::String> G_property = v8::String::New("G");
12400 CHECK(ctx1->Global()->ForceDelete(G_property));
12401 ctx2->Enter();
12402 ExpectString(
12403 "(function() {"
12404 " try {"
12405 " return f();"
12406 " } catch(e) {"
12407 " return e.toString();"
12408 " }"
12409 " })()",
12410 "ReferenceError: G is not defined");
12411 ctx2->Exit();
12412 ctx1->Exit();
12413 ctx1.Dispose();
12414 }
12415 ctx2.Dispose();
12416 }
12417
12418
12379 v8::Persistent<Context> calling_context0; 12419 v8::Persistent<Context> calling_context0;
12380 v8::Persistent<Context> calling_context1; 12420 v8::Persistent<Context> calling_context1;
12381 v8::Persistent<Context> calling_context2; 12421 v8::Persistent<Context> calling_context2;
12382 12422
12383 12423
12384 // Check that the call to the callback is initiated in 12424 // Check that the call to the callback is initiated in
12385 // calling_context2, the directly calling context is calling_context1 12425 // calling_context2, the directly calling context is calling_context1
12386 // and the callback itself is in calling_context0. 12426 // and the callback itself is in calling_context0.
12387 static v8::Handle<Value> GetCallingContextCallback(const v8::Arguments& args) { 12427 static v8::Handle<Value> GetCallingContextCallback(const v8::Arguments& args) {
12388 ApiTestFuzzer::Fuzz(); 12428 ApiTestFuzzer::Fuzz();
(...skipping 4011 matching lines...) Expand 10 before | Expand all | Expand 10 after
16400 16440
16401 16441
16402 TEST(SecondaryStubCache) { 16442 TEST(SecondaryStubCache) {
16403 StubCacheHelper(true); 16443 StubCacheHelper(true);
16404 } 16444 }
16405 16445
16406 16446
16407 TEST(PrimaryStubCache) { 16447 TEST(PrimaryStubCache) {
16408 StubCacheHelper(false); 16448 StubCacheHelper(false);
16409 } 16449 }
16410
OLDNEW
« no previous file with comments | « src/api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698