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

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

Issue 15979014: remove V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT and V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 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/global-handles.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 4332 matching lines...) Expand 10 before | Expand all | Expand 10 after
4343 CHECK(v8_num(1)->StrictEquals(v8_num(1))); 4343 CHECK(v8_num(1)->StrictEquals(v8_num(1)));
4344 CHECK(!v8_num(1)->StrictEquals(v8_num(2))); 4344 CHECK(!v8_num(1)->StrictEquals(v8_num(2)));
4345 CHECK(v8_num(0)->StrictEquals(v8_num(-0))); 4345 CHECK(v8_num(0)->StrictEquals(v8_num(-0)));
4346 Local<Value> not_a_number = v8_num(i::OS::nan_value()); 4346 Local<Value> not_a_number = v8_num(i::OS::nan_value());
4347 CHECK(!not_a_number->StrictEquals(not_a_number)); 4347 CHECK(!not_a_number->StrictEquals(not_a_number));
4348 CHECK(v8::False()->StrictEquals(v8::False())); 4348 CHECK(v8::False()->StrictEquals(v8::False()));
4349 CHECK(!v8::False()->StrictEquals(v8::Undefined())); 4349 CHECK(!v8::False()->StrictEquals(v8::Undefined()));
4350 4350
4351 v8::Handle<v8::Object> obj = v8::Object::New(); 4351 v8::Handle<v8::Object> obj = v8::Object::New();
4352 v8::Persistent<v8::Object> alias(isolate, obj); 4352 v8::Persistent<v8::Object> alias(isolate, obj);
4353 CHECK(alias->StrictEquals(obj)); 4353 CHECK(v8::Local<v8::Object>::New(isolate, alias)->StrictEquals(obj));
4354 alias.Dispose(isolate); 4354 alias.Dispose(isolate);
4355 } 4355 }
4356 4356
4357 4357
4358 THREADED_TEST(MultiRun) { 4358 THREADED_TEST(MultiRun) {
4359 LocalContext context; 4359 LocalContext context;
4360 v8::HandleScope scope(context->GetIsolate()); 4360 v8::HandleScope scope(context->GetIsolate());
4361 Local<Script> script = Script::Compile(v8_str("x")); 4361 Local<Script> script = Script::Compile(v8_str("x"));
4362 for (int i = 0; i < 10; i++) 4362 for (int i = 0; i < 10; i++)
4363 script->Run(); 4363 script->Run();
(...skipping 1713 matching lines...) Expand 10 before | Expand all | Expand 10 after
6077 6077
6078 v8::Handle<Value> WhammyPropertyGetter(Local<String> name, 6078 v8::Handle<Value> WhammyPropertyGetter(Local<String> name,
6079 const AccessorInfo& info) { 6079 const AccessorInfo& info) {
6080 Whammy* whammy = 6080 Whammy* whammy =
6081 static_cast<Whammy*>(v8::Handle<v8::External>::Cast(info.Data())->Value()); 6081 static_cast<Whammy*>(v8::Handle<v8::External>::Cast(info.Data())->Value());
6082 6082
6083 v8::Persistent<v8::Object>& prev = whammy->objects_[whammy->cursor_]; 6083 v8::Persistent<v8::Object>& prev = whammy->objects_[whammy->cursor_];
6084 6084
6085 v8::Handle<v8::Object> obj = v8::Object::New(); 6085 v8::Handle<v8::Object> obj = v8::Object::New();
6086 if (!prev.IsEmpty()) { 6086 if (!prev.IsEmpty()) {
6087 prev->Set(v8_str("next"), obj); 6087 v8::Local<v8::Object>::New(info.GetIsolate(), prev)
6088 ->Set(v8_str("next"), obj);
6088 prev.MakeWeak<Value, Snorkel>(info.GetIsolate(), 6089 prev.MakeWeak<Value, Snorkel>(info.GetIsolate(),
6089 new Snorkel(), 6090 new Snorkel(),
6090 &HandleWeakReference); 6091 &HandleWeakReference);
6091 whammy->objects_[whammy->cursor_].Clear(); 6092 whammy->objects_[whammy->cursor_].Clear();
6092 } 6093 }
6093 whammy->objects_[whammy->cursor_].Reset(info.GetIsolate(), obj); 6094 whammy->objects_[whammy->cursor_].Reset(info.GetIsolate(), obj);
6094 whammy->cursor_ = (whammy->cursor_ + 1) % Whammy::kObjectCount; 6095 whammy->cursor_ = (whammy->cursor_ + 1) % Whammy::kObjectCount;
6095 return whammy->getScript()->Run(); 6096 return whammy->getScript()->Run();
6096 } 6097 }
6097 6098
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
6230 6231
6231 THREADED_TEST(IndependentHandleRevival) { 6232 THREADED_TEST(IndependentHandleRevival) {
6232 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 6233 v8::Isolate* isolate = v8::Isolate::GetCurrent();
6233 v8::HandleScope scope(isolate); 6234 v8::HandleScope scope(isolate);
6234 v8::Handle<Context> context = Context::New(isolate); 6235 v8::Handle<Context> context = Context::New(isolate);
6235 Context::Scope context_scope(context); 6236 Context::Scope context_scope(context);
6236 6237
6237 v8::Persistent<v8::Object> object; 6238 v8::Persistent<v8::Object> object;
6238 { 6239 {
6239 v8::HandleScope handle_scope(isolate); 6240 v8::HandleScope handle_scope(isolate);
6240 object.Reset(isolate, v8::Object::New()); 6241 v8::Local<v8::Object> o = v8::Object::New();
6241 object->Set(v8_str("x"), v8::Integer::New(1)); 6242 object.Reset(isolate, o);
6243 o->Set(v8_str("x"), v8::Integer::New(1));
6242 v8::Local<String> y_str = v8_str("y"); 6244 v8::Local<String> y_str = v8_str("y");
6243 object->Set(y_str, y_str); 6245 o->Set(y_str, y_str);
6244 } 6246 }
6245 bool revived = false; 6247 bool revived = false;
6246 object.MakeWeak(isolate, &revived, &RevivingCallback); 6248 object.MakeWeak(isolate, &revived, &RevivingCallback);
6247 object.MarkIndependent(isolate); 6249 object.MarkIndependent(isolate);
6248 HEAP->PerformScavenge(); 6250 HEAP->PerformScavenge();
6249 CHECK(revived); 6251 CHECK(revived);
6250 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); 6252 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
6251 { 6253 {
6252 v8::HandleScope handle_scope(isolate); 6254 v8::HandleScope handle_scope(isolate);
6255 v8::Local<v8::Object> o = v8::Local<v8::Object>::New(isolate, object);
6253 v8::Local<String> y_str = v8_str("y"); 6256 v8::Local<String> y_str = v8_str("y");
6254 CHECK_EQ(v8::Integer::New(1), object->Get(v8_str("x"))); 6257 CHECK_EQ(v8::Integer::New(1), o->Get(v8_str("x")));
6255 CHECK(object->Get(y_str)->Equals(y_str)); 6258 CHECK(o->Get(y_str)->Equals(y_str));
6256 } 6259 }
6257 } 6260 }
6258 6261
6259 6262
6260 v8::Handle<Function> args_fun; 6263 v8::Handle<Function> args_fun;
6261 6264
6262 6265
6263 static v8::Handle<Value> ArgumentsTestCallback(const v8::Arguments& args) { 6266 static v8::Handle<Value> ArgumentsTestCallback(const v8::Arguments& args) {
6264 ApiTestFuzzer::Fuzz(); 6267 ApiTestFuzzer::Fuzz();
6265 CHECK_EQ(args_fun, args.Callee()); 6268 CHECK_EQ(args_fun, args.Callee());
(...skipping 6192 matching lines...) Expand 10 before | Expand all | Expand 10 after
12458 THREADED_TEST(DisposeEnteredContext) { 12461 THREADED_TEST(DisposeEnteredContext) {
12459 LocalContext outer; 12462 LocalContext outer;
12460 v8::Isolate* isolate = outer->GetIsolate(); 12463 v8::Isolate* isolate = outer->GetIsolate();
12461 v8::Persistent<v8::Context> inner; 12464 v8::Persistent<v8::Context> inner;
12462 { 12465 {
12463 v8::HandleScope scope(isolate); 12466 v8::HandleScope scope(isolate);
12464 inner.Reset(isolate, v8::Context::New(isolate)); 12467 inner.Reset(isolate, v8::Context::New(isolate));
12465 } 12468 }
12466 v8::HandleScope scope(isolate); 12469 v8::HandleScope scope(isolate);
12467 { 12470 {
12468 inner->Enter(); 12471 // Don't want a handle here, so do this unsafely
12469 inner.Dispose(inner->GetIsolate()); 12472 v8::Handle<v8::Context> inner_local =
12473 *reinterpret_cast<v8::Handle<v8::Context>*>(&inner);
12474 inner_local->Enter();
12475 inner.Dispose();
12470 inner.Clear(); 12476 inner.Clear();
12471 inner->Exit(); 12477 inner_local->Exit();
12472 } 12478 }
12473 } 12479 }
12474 12480
12475 12481
12476 // Regression test for issue 54, object templates with internal fields 12482 // Regression test for issue 54, object templates with internal fields
12477 // but no accessors or interceptors did not get their internal field 12483 // but no accessors or interceptors did not get their internal field
12478 // count set on instances. 12484 // count set on instances.
12479 THREADED_TEST(Regress54) { 12485 THREADED_TEST(Regress54) {
12480 LocalContext context; 12486 LocalContext context;
12481 v8::Isolate* isolate = context->GetIsolate(); 12487 v8::Isolate* isolate = context->GetIsolate();
12482 v8::HandleScope outer(isolate); 12488 v8::HandleScope outer(isolate);
12483 static v8::Persistent<v8::ObjectTemplate> templ; 12489 static v8::Persistent<v8::ObjectTemplate> templ;
12484 if (templ.IsEmpty()) { 12490 if (templ.IsEmpty()) {
12485 v8::HandleScope inner(isolate); 12491 v8::HandleScope inner(isolate);
12486 v8::Handle<v8::ObjectTemplate> local = v8::ObjectTemplate::New(); 12492 v8::Handle<v8::ObjectTemplate> local = v8::ObjectTemplate::New();
12487 local->SetInternalFieldCount(1); 12493 local->SetInternalFieldCount(1);
12488 templ.Reset(isolate, inner.Close(local)); 12494 templ.Reset(isolate, inner.Close(local));
12489 } 12495 }
12490 v8::Handle<v8::Object> result = templ->NewInstance(); 12496 v8::Handle<v8::Object> result =
12497 v8::Local<v8::ObjectTemplate>::New(isolate, templ)->NewInstance();
12491 CHECK_EQ(1, result->InternalFieldCount()); 12498 CHECK_EQ(1, result->InternalFieldCount());
12492 } 12499 }
12493 12500
12494 12501
12495 // If part of the threaded tests, this test makes ThreadingTest fail 12502 // If part of the threaded tests, this test makes ThreadingTest fail
12496 // on mac. 12503 // on mac.
12497 TEST(CatchStackOverflow) { 12504 TEST(CatchStackOverflow) {
12498 LocalContext context; 12505 LocalContext context;
12499 v8::HandleScope scope(context->GetIsolate()); 12506 v8::HandleScope scope(context->GetIsolate());
12500 v8::TryCatch try_catch; 12507 v8::TryCatch try_catch;
(...skipping 4640 matching lines...) Expand 10 before | Expand all | Expand 10 after
17141 { 17148 {
17142 v8::HandleScope scope(v8::Isolate::GetCurrent()); 17149 v8::HandleScope scope(v8::Isolate::GetCurrent());
17143 v8::Local<v8::Context> context = 17150 v8::Local<v8::Context> context =
17144 v8::Local<v8::Context>::New(v8::Isolate::GetCurrent(), context1); 17151 v8::Local<v8::Context>::New(v8::Isolate::GetCurrent(), context1);
17145 v8::Context::Scope context_scope(context); 17152 v8::Context::Scope context_scope(context);
17146 ExpectString("function f() { return foo; }; f()", "isolate 1"); 17153 ExpectString("function f() { return foo; }; f()", "isolate 1");
17147 } 17154 }
17148 17155
17149 { 17156 {
17150 v8::Isolate::Scope iscope(isolate2); 17157 v8::Isolate::Scope iscope(isolate2);
17151 context2.Dispose(context2->GetIsolate()); 17158 context2.Dispose();
17152 } 17159 }
17153 17160
17154 context1.Dispose(context1->GetIsolate()); 17161 context1.Dispose();
17155 isolate1->Exit(); 17162 isolate1->Exit();
17156 17163
17157 v8::V8::SetFatalErrorHandler(StoringErrorCallback); 17164 v8::V8::SetFatalErrorHandler(StoringErrorCallback);
17158 last_location = last_message = NULL; 17165 last_location = last_message = NULL;
17159 17166
17160 isolate1->Dispose(); 17167 isolate1->Dispose();
17161 CHECK_EQ(last_location, NULL); 17168 CHECK_EQ(last_location, NULL);
17162 CHECK_EQ(last_message, NULL); 17169 CHECK_EQ(last_message, NULL);
17163 17170
17164 isolate2->Dispose(); 17171 isolate2->Dispose();
(...skipping 1918 matching lines...) Expand 10 before | Expand all | Expand 10 after
19083 i::Semaphore* sem_; 19090 i::Semaphore* sem_;
19084 volatile int sem_value_; 19091 volatile int sem_value_;
19085 }; 19092 };
19086 19093
19087 19094
19088 THREADED_TEST(SemaphoreInterruption) { 19095 THREADED_TEST(SemaphoreInterruption) {
19089 ThreadInterruptTest().RunTest(); 19096 ThreadInterruptTest().RunTest();
19090 } 19097 }
19091 19098
19092 #endif // WIN32 19099 #endif // WIN32
OLDNEW
« no previous file with comments | « src/global-handles.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698