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

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

Issue 23707009: Deprecate Persistent functions which were marked to be deprecated. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Code review (svenpanne) Created 7 years, 3 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/mksnapshot.cc ('k') | test/cctest/test-debug.cc » ('j') | 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 3090 matching lines...) Expand 10 before | Expand all | Expand 10 after
3101 } 3101 }
3102 { 3102 {
3103 v8::HandleScope scope(isolate); 3103 v8::HandleScope scope(isolate);
3104 global.Reset(isolate, v8_str("longer")); 3104 global.Reset(isolate, v8_str("longer"));
3105 } 3105 }
3106 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count); 3106 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count);
3107 { 3107 {
3108 v8::HandleScope scope(isolate); 3108 v8::HandleScope scope(isolate);
3109 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 6); 3109 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 6);
3110 } 3110 }
3111 global.Dispose(isolate); 3111 global.Dispose();
3112 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count - 1); 3112 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count - 1);
3113 } 3113 }
3114 3114
3115 3115
3116 THREADED_TEST(ResettingGlobalHandleToEmpty) { 3116 THREADED_TEST(ResettingGlobalHandleToEmpty) {
3117 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 3117 v8::Isolate* isolate = v8::Isolate::GetCurrent();
3118 v8::Persistent<String> global; 3118 v8::Persistent<String> global;
3119 { 3119 {
3120 v8::HandleScope scope(isolate); 3120 v8::HandleScope scope(isolate);
3121 global.Reset(isolate, v8_str("str")); 3121 global.Reset(isolate, v8_str("str"));
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
3235 int id_; 3235 int id_;
3236 int number_of_weak_calls_; 3236 int number_of_weak_calls_;
3237 }; 3237 };
3238 3238
3239 3239
3240 static void WeakPointerCallback(v8::Isolate* isolate, 3240 static void WeakPointerCallback(v8::Isolate* isolate,
3241 Persistent<Value>* handle, 3241 Persistent<Value>* handle,
3242 WeakCallCounter* counter) { 3242 WeakCallCounter* counter) {
3243 CHECK_EQ(1234, counter->id()); 3243 CHECK_EQ(1234, counter->id());
3244 counter->increment(); 3244 counter->increment();
3245 handle->Dispose(isolate); 3245 handle->Dispose();
3246 } 3246 }
3247 3247
3248 3248
3249 static UniqueId MakeUniqueId(const Persistent<Value>& p) { 3249 static UniqueId MakeUniqueId(const Persistent<Value>& p) {
3250 return UniqueId(reinterpret_cast<uintptr_t>(*v8::Utils::OpenPersistent(p))); 3250 return UniqueId(reinterpret_cast<uintptr_t>(*v8::Utils::OpenPersistent(p)));
3251 } 3251 }
3252 3252
3253 3253
3254 THREADED_TEST(ApiObjectGroups) { 3254 THREADED_TEST(ApiObjectGroups) {
3255 LocalContext env; 3255 LocalContext env;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
3308 iso)->heap(); 3308 iso)->heap();
3309 heap->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); 3309 heap->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
3310 3310
3311 // All object should be alive. 3311 // All object should be alive.
3312 CHECK_EQ(0, counter.NumberOfWeakCalls()); 3312 CHECK_EQ(0, counter.NumberOfWeakCalls());
3313 3313
3314 // Weaken the root. 3314 // Weaken the root.
3315 root.MakeWeak(&counter, &WeakPointerCallback); 3315 root.MakeWeak(&counter, &WeakPointerCallback);
3316 // But make children strong roots---all the objects (except for children) 3316 // But make children strong roots---all the objects (except for children)
3317 // should be collectable now. 3317 // should be collectable now.
3318 g1c1.ClearWeak(iso); 3318 g1c1.ClearWeak();
3319 g2c1.ClearWeak(iso); 3319 g2c1.ClearWeak();
3320 3320
3321 // Groups are deleted, rebuild groups. 3321 // Groups are deleted, rebuild groups.
3322 { 3322 {
3323 UniqueId id1 = MakeUniqueId(g1s1); 3323 UniqueId id1 = MakeUniqueId(g1s1);
3324 UniqueId id2 = MakeUniqueId(g2s2); 3324 UniqueId id2 = MakeUniqueId(g2s2);
3325 iso->SetObjectGroupId(g1s1, id1); 3325 iso->SetObjectGroupId(g1s1, id1);
3326 iso->SetObjectGroupId(g1s2, id1); 3326 iso->SetObjectGroupId(g1s2, id1);
3327 iso->SetReferenceFromGroup(id1, g1c1); 3327 iso->SetReferenceFromGroup(id1, g1c1);
3328 iso->SetObjectGroupId(g2s1, id2); 3328 iso->SetObjectGroupId(g2s1, id2);
3329 iso->SetObjectGroupId(g2s2, id2); 3329 iso->SetObjectGroupId(g2s2, id2);
(...skipping 29 matching lines...) Expand all
3359 Persistent<Value> g3s2; 3359 Persistent<Value> g3s2;
3360 Persistent<Value> g4s1; 3360 Persistent<Value> g4s1;
3361 Persistent<Value> g4s2; 3361 Persistent<Value> g4s2;
3362 3362
3363 { 3363 {
3364 HandleScope scope(iso); 3364 HandleScope scope(iso);
3365 g1s1.Reset(iso, Object::New()); 3365 g1s1.Reset(iso, Object::New());
3366 g1s2.Reset(iso, Object::New()); 3366 g1s2.Reset(iso, Object::New());
3367 g1s1.MakeWeak(&counter, &WeakPointerCallback); 3367 g1s1.MakeWeak(&counter, &WeakPointerCallback);
3368 g1s2.MakeWeak(&counter, &WeakPointerCallback); 3368 g1s2.MakeWeak(&counter, &WeakPointerCallback);
3369 CHECK(g1s1.IsWeak(iso)); 3369 CHECK(g1s1.IsWeak());
3370 CHECK(g1s2.IsWeak(iso)); 3370 CHECK(g1s2.IsWeak());
3371 3371
3372 g2s1.Reset(iso, Object::New()); 3372 g2s1.Reset(iso, Object::New());
3373 g2s2.Reset(iso, Object::New()); 3373 g2s2.Reset(iso, Object::New());
3374 g2s1.MakeWeak(&counter, &WeakPointerCallback); 3374 g2s1.MakeWeak(&counter, &WeakPointerCallback);
3375 g2s2.MakeWeak(&counter, &WeakPointerCallback); 3375 g2s2.MakeWeak(&counter, &WeakPointerCallback);
3376 CHECK(g2s1.IsWeak(iso)); 3376 CHECK(g2s1.IsWeak());
3377 CHECK(g2s2.IsWeak(iso)); 3377 CHECK(g2s2.IsWeak());
3378 3378
3379 g3s1.Reset(iso, Object::New()); 3379 g3s1.Reset(iso, Object::New());
3380 g3s2.Reset(iso, Object::New()); 3380 g3s2.Reset(iso, Object::New());
3381 g3s1.MakeWeak(&counter, &WeakPointerCallback); 3381 g3s1.MakeWeak(&counter, &WeakPointerCallback);
3382 g3s2.MakeWeak(&counter, &WeakPointerCallback); 3382 g3s2.MakeWeak(&counter, &WeakPointerCallback);
3383 CHECK(g3s1.IsWeak(iso)); 3383 CHECK(g3s1.IsWeak());
3384 CHECK(g3s2.IsWeak(iso)); 3384 CHECK(g3s2.IsWeak());
3385 3385
3386 g4s1.Reset(iso, Object::New()); 3386 g4s1.Reset(iso, Object::New());
3387 g4s2.Reset(iso, Object::New()); 3387 g4s2.Reset(iso, Object::New());
3388 g4s1.MakeWeak(&counter, &WeakPointerCallback); 3388 g4s1.MakeWeak(&counter, &WeakPointerCallback);
3389 g4s2.MakeWeak(&counter, &WeakPointerCallback); 3389 g4s2.MakeWeak(&counter, &WeakPointerCallback);
3390 CHECK(g4s1.IsWeak(iso)); 3390 CHECK(g4s1.IsWeak());
3391 CHECK(g4s2.IsWeak(iso)); 3391 CHECK(g4s2.IsWeak());
3392 } 3392 }
3393 3393
3394 Persistent<Value> root(iso, g1s1); // make a root. 3394 Persistent<Value> root(iso, g1s1); // make a root.
3395 3395
3396 // Connect groups. We're building the following cycle: 3396 // Connect groups. We're building the following cycle:
3397 // G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other 3397 // G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other
3398 // groups. 3398 // groups.
3399 { 3399 {
3400 UniqueId id1 = MakeUniqueId(g1s1); 3400 UniqueId id1 = MakeUniqueId(g1s1);
3401 UniqueId id2 = MakeUniqueId(g2s1); 3401 UniqueId id2 = MakeUniqueId(g2s1);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
3483 g2s2.MakeWeak(&counter, &WeakPointerCallback); 3483 g2s2.MakeWeak(&counter, &WeakPointerCallback);
3484 3484
3485 g3s1.Reset(iso, Object::New()); 3485 g3s1.Reset(iso, Object::New());
3486 g3s2.Reset(iso, Object::New()); 3486 g3s2.Reset(iso, Object::New());
3487 g3s1.MakeWeak(&counter, &WeakPointerCallback); 3487 g3s1.MakeWeak(&counter, &WeakPointerCallback);
3488 g3s2.MakeWeak(&counter, &WeakPointerCallback); 3488 g3s2.MakeWeak(&counter, &WeakPointerCallback);
3489 } 3489 }
3490 3490
3491 // Make a root. 3491 // Make a root.
3492 Persistent<Value> root(iso, g1s1); 3492 Persistent<Value> root(iso, g1s1);
3493 root.MarkPartiallyDependent(iso); 3493 root.MarkPartiallyDependent();
3494 3494
3495 // Connect groups. We're building the following cycle: 3495 // Connect groups. We're building the following cycle:
3496 // G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other 3496 // G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other
3497 // groups. 3497 // groups.
3498 { 3498 {
3499 HandleScope handle_scope(iso); 3499 HandleScope handle_scope(iso);
3500 g1s1.MarkPartiallyDependent(iso); 3500 g1s1.MarkPartiallyDependent();
3501 g1s2.MarkPartiallyDependent(iso); 3501 g1s2.MarkPartiallyDependent();
3502 g2s1.MarkPartiallyDependent(iso); 3502 g2s1.MarkPartiallyDependent();
3503 g2s2.MarkPartiallyDependent(iso); 3503 g2s2.MarkPartiallyDependent();
3504 g3s1.MarkPartiallyDependent(iso); 3504 g3s1.MarkPartiallyDependent();
3505 g3s2.MarkPartiallyDependent(iso); 3505 g3s2.MarkPartiallyDependent();
3506 iso->SetObjectGroupId(g1s1, UniqueId(1)); 3506 iso->SetObjectGroupId(g1s1, UniqueId(1));
3507 iso->SetObjectGroupId(g1s2, UniqueId(1)); 3507 iso->SetObjectGroupId(g1s2, UniqueId(1));
3508 Local<Object>::New(iso, g1s1.As<Object>())->Set( 3508 Local<Object>::New(iso, g1s1.As<Object>())->Set(
3509 v8_str("x"), Local<Value>::New(iso, g2s1)); 3509 v8_str("x"), Local<Value>::New(iso, g2s1));
3510 iso->SetObjectGroupId(g2s1, UniqueId(2)); 3510 iso->SetObjectGroupId(g2s1, UniqueId(2));
3511 iso->SetObjectGroupId(g2s2, UniqueId(2)); 3511 iso->SetObjectGroupId(g2s2, UniqueId(2));
3512 Local<Object>::New(iso, g2s1.As<Object>())->Set( 3512 Local<Object>::New(iso, g2s1.As<Object>())->Set(
3513 v8_str("x"), Local<Value>::New(iso, g3s1)); 3513 v8_str("x"), Local<Value>::New(iso, g3s1));
3514 iso->SetObjectGroupId(g3s1, UniqueId(3)); 3514 iso->SetObjectGroupId(g3s1, UniqueId(3));
3515 iso->SetObjectGroupId(g3s2, UniqueId(3)); 3515 iso->SetObjectGroupId(g3s2, UniqueId(3));
3516 Local<Object>::New(iso, g3s1.As<Object>())->Set( 3516 Local<Object>::New(iso, g3s1.As<Object>())->Set(
3517 v8_str("x"), Local<Value>::New(iso, g1s1)); 3517 v8_str("x"), Local<Value>::New(iso, g1s1));
3518 } 3518 }
3519 3519
3520 v8::internal::Heap* heap = reinterpret_cast<v8::internal::Isolate*>( 3520 v8::internal::Heap* heap = reinterpret_cast<v8::internal::Isolate*>(
3521 iso)->heap(); 3521 iso)->heap();
3522 heap->CollectGarbage(i::NEW_SPACE); 3522 heap->CollectGarbage(i::NEW_SPACE);
3523 3523
3524 // All objects should be alive. 3524 // All objects should be alive.
3525 CHECK_EQ(0, counter.NumberOfWeakCalls()); 3525 CHECK_EQ(0, counter.NumberOfWeakCalls());
3526 3526
3527 // Weaken the root. 3527 // Weaken the root.
3528 root.MakeWeak(&counter, &WeakPointerCallback); 3528 root.MakeWeak(&counter, &WeakPointerCallback);
3529 root.MarkPartiallyDependent(iso); 3529 root.MarkPartiallyDependent();
3530 3530
3531 v8::Isolate* isolate = v8::Isolate::GetCurrent();
3532 // Groups are deleted, rebuild groups. 3531 // Groups are deleted, rebuild groups.
3533 { 3532 {
3534 HandleScope handle_scope(iso); 3533 HandleScope handle_scope(iso);
3535 g1s1.MarkPartiallyDependent(isolate); 3534 g1s1.MarkPartiallyDependent();
3536 g1s2.MarkPartiallyDependent(isolate); 3535 g1s2.MarkPartiallyDependent();
3537 g2s1.MarkPartiallyDependent(isolate); 3536 g2s1.MarkPartiallyDependent();
3538 g2s2.MarkPartiallyDependent(isolate); 3537 g2s2.MarkPartiallyDependent();
3539 g3s1.MarkPartiallyDependent(isolate); 3538 g3s1.MarkPartiallyDependent();
3540 g3s2.MarkPartiallyDependent(isolate); 3539 g3s2.MarkPartiallyDependent();
3541 iso->SetObjectGroupId(g1s1, UniqueId(1)); 3540 iso->SetObjectGroupId(g1s1, UniqueId(1));
3542 iso->SetObjectGroupId(g1s2, UniqueId(1)); 3541 iso->SetObjectGroupId(g1s2, UniqueId(1));
3543 Local<Object>::New(iso, g1s1.As<Object>())->Set( 3542 Local<Object>::New(iso, g1s1.As<Object>())->Set(
3544 v8_str("x"), Local<Value>::New(iso, g2s1)); 3543 v8_str("x"), Local<Value>::New(iso, g2s1));
3545 iso->SetObjectGroupId(g2s1, UniqueId(2)); 3544 iso->SetObjectGroupId(g2s1, UniqueId(2));
3546 iso->SetObjectGroupId(g2s2, UniqueId(2)); 3545 iso->SetObjectGroupId(g2s2, UniqueId(2));
3547 Local<Object>::New(iso, g2s1.As<Object>())->Set( 3546 Local<Object>::New(iso, g2s1.As<Object>())->Set(
3548 v8_str("x"), Local<Value>::New(iso, g3s1)); 3547 v8_str("x"), Local<Value>::New(iso, g3s1));
3549 iso->SetObjectGroupId(g3s1, UniqueId(3)); 3548 iso->SetObjectGroupId(g3s1, UniqueId(3));
3550 iso->SetObjectGroupId(g3s2, UniqueId(3)); 3549 iso->SetObjectGroupId(g3s2, UniqueId(3));
(...skipping 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after
4888 CHECK(!v8_num(1)->StrictEquals(v8_num(2))); 4887 CHECK(!v8_num(1)->StrictEquals(v8_num(2)));
4889 CHECK(v8_num(0)->StrictEquals(v8_num(-0))); 4888 CHECK(v8_num(0)->StrictEquals(v8_num(-0)));
4890 Local<Value> not_a_number = v8_num(i::OS::nan_value()); 4889 Local<Value> not_a_number = v8_num(i::OS::nan_value());
4891 CHECK(!not_a_number->StrictEquals(not_a_number)); 4890 CHECK(!not_a_number->StrictEquals(not_a_number));
4892 CHECK(v8::False()->StrictEquals(v8::False())); 4891 CHECK(v8::False()->StrictEquals(v8::False()));
4893 CHECK(!v8::False()->StrictEquals(v8::Undefined())); 4892 CHECK(!v8::False()->StrictEquals(v8::Undefined()));
4894 4893
4895 v8::Handle<v8::Object> obj = v8::Object::New(); 4894 v8::Handle<v8::Object> obj = v8::Object::New();
4896 v8::Persistent<v8::Object> alias(isolate, obj); 4895 v8::Persistent<v8::Object> alias(isolate, obj);
4897 CHECK(v8::Local<v8::Object>::New(isolate, alias)->StrictEquals(obj)); 4896 CHECK(v8::Local<v8::Object>::New(isolate, alias)->StrictEquals(obj));
4898 alias.Dispose(isolate); 4897 alias.Dispose();
4899 } 4898 }
4900 4899
4901 4900
4902 THREADED_TEST(MultiRun) { 4901 THREADED_TEST(MultiRun) {
4903 LocalContext context; 4902 LocalContext context;
4904 v8::HandleScope scope(context->GetIsolate()); 4903 v8::HandleScope scope(context->GetIsolate());
4905 Local<Script> script = Script::Compile(v8_str("x")); 4904 Local<Script> script = Script::Compile(v8_str("x"));
4906 for (int i = 0; i < 10; i++) 4905 for (int i = 0; i < 10; i++)
4907 script->Run(); 4906 script->Run();
4908 } 4907 }
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
5203 v8::HandleScope scope(v8::Isolate::GetCurrent()); 5202 v8::HandleScope scope(v8::Isolate::GetCurrent());
5204 Local<ObjectTemplate> templ = ObjectTemplate::New(); 5203 Local<ObjectTemplate> templ = ObjectTemplate::New();
5205 templ->SetAccessor(v8_str("x"), GetXValue, SetXValue, v8_str("donut")); 5204 templ->SetAccessor(v8_str("x"), GetXValue, SetXValue, v8_str("donut"));
5206 LocalContext context; 5205 LocalContext context;
5207 context->Global()->Set(v8_str("obj"), templ->NewInstance()); 5206 context->Global()->Set(v8_str("obj"), templ->NewInstance());
5208 Local<Script> script = Script::Compile(v8_str("obj.x = 4")); 5207 Local<Script> script = Script::Compile(v8_str("obj.x = 4"));
5209 for (int i = 0; i < 10; i++) { 5208 for (int i = 0; i < 10; i++) {
5210 CHECK(xValue.IsEmpty()); 5209 CHECK(xValue.IsEmpty());
5211 script->Run(); 5210 script->Run();
5212 CHECK_EQ(v8_num(4), Local<Value>::New(v8::Isolate::GetCurrent(), xValue)); 5211 CHECK_EQ(v8_num(4), Local<Value>::New(v8::Isolate::GetCurrent(), xValue));
5213 xValue.Dispose(context->GetIsolate()); 5212 xValue.Dispose();
5214 xValue.Clear(); 5213 xValue.Clear();
5215 } 5214 }
5216 } 5215 }
5217 5216
5218 5217
5219 THREADED_TEST(SetterOnly) { 5218 THREADED_TEST(SetterOnly) {
5220 v8::HandleScope scope(v8::Isolate::GetCurrent()); 5219 v8::HandleScope scope(v8::Isolate::GetCurrent());
5221 Local<ObjectTemplate> templ = ObjectTemplate::New(); 5220 Local<ObjectTemplate> templ = ObjectTemplate::New();
5222 templ->SetAccessor(v8_str("x"), NULL, SetXValue, v8_str("donut")); 5221 templ->SetAccessor(v8_str("x"), NULL, SetXValue, v8_str("donut"));
5223 LocalContext context; 5222 LocalContext context;
5224 context->Global()->Set(v8_str("obj"), templ->NewInstance()); 5223 context->Global()->Set(v8_str("obj"), templ->NewInstance());
5225 Local<Script> script = Script::Compile(v8_str("obj.x = 4; obj.x")); 5224 Local<Script> script = Script::Compile(v8_str("obj.x = 4; obj.x"));
5226 for (int i = 0; i < 10; i++) { 5225 for (int i = 0; i < 10; i++) {
5227 CHECK(xValue.IsEmpty()); 5226 CHECK(xValue.IsEmpty());
5228 script->Run(); 5227 script->Run();
5229 CHECK_EQ(v8_num(4), Local<Value>::New(v8::Isolate::GetCurrent(), xValue)); 5228 CHECK_EQ(v8_num(4), Local<Value>::New(v8::Isolate::GetCurrent(), xValue));
5230 xValue.Dispose(context->GetIsolate()); 5229 xValue.Dispose();
5231 xValue.Clear(); 5230 xValue.Clear();
5232 } 5231 }
5233 } 5232 }
5234 5233
5235 5234
5236 THREADED_TEST(NoAccessors) { 5235 THREADED_TEST(NoAccessors) {
5237 v8::HandleScope scope(v8::Isolate::GetCurrent()); 5236 v8::HandleScope scope(v8::Isolate::GetCurrent());
5238 Local<ObjectTemplate> templ = ObjectTemplate::New(); 5237 Local<ObjectTemplate> templ = ObjectTemplate::New();
5239 templ->SetAccessor(v8_str("x"), 5238 templ->SetAccessor(v8_str("x"),
5240 static_cast<v8::AccessorGetterCallback>(NULL), 5239 static_cast<v8::AccessorGetterCallback>(NULL),
(...skipping 1354 matching lines...) Expand 10 before | Expand all | Expand 10 after
6595 6594
6596 class Snorkel { 6595 class Snorkel {
6597 public: 6596 public:
6598 Snorkel() { index_ = global_index++; } 6597 Snorkel() { index_ = global_index++; }
6599 int index_; 6598 int index_;
6600 }; 6599 };
6601 6600
6602 class Whammy { 6601 class Whammy {
6603 public: 6602 public:
6604 explicit Whammy(v8::Isolate* isolate) : cursor_(0), isolate_(isolate) { } 6603 explicit Whammy(v8::Isolate* isolate) : cursor_(0), isolate_(isolate) { }
6605 ~Whammy() { script_.Dispose(isolate_); } 6604 ~Whammy() { script_.Dispose(); }
6606 v8::Handle<Script> getScript() { 6605 v8::Handle<Script> getScript() {
6607 if (script_.IsEmpty()) script_.Reset(isolate_, v8_compile("({}).blammo")); 6606 if (script_.IsEmpty()) script_.Reset(isolate_, v8_compile("({}).blammo"));
6608 return Local<Script>::New(isolate_, script_); 6607 return Local<Script>::New(isolate_, script_);
6609 } 6608 }
6610 6609
6611 public: 6610 public:
6612 static const int kObjectCount = 256; 6611 static const int kObjectCount = 256;
6613 int cursor_; 6612 int cursor_;
6614 v8::Isolate* isolate_; 6613 v8::Isolate* isolate_;
6615 v8::Persistent<v8::Object> objects_[kObjectCount]; 6614 v8::Persistent<v8::Object> objects_[kObjectCount];
6616 v8::Persistent<Script> script_; 6615 v8::Persistent<Script> script_;
6617 }; 6616 };
6618 6617
6619 static void HandleWeakReference(v8::Isolate* isolate, 6618 static void HandleWeakReference(v8::Isolate* isolate,
6620 v8::Persistent<v8::Value>* obj, 6619 v8::Persistent<v8::Value>* obj,
6621 Snorkel* snorkel) { 6620 Snorkel* snorkel) {
6622 delete snorkel; 6621 delete snorkel;
6623 obj->ClearWeak(isolate); 6622 obj->ClearWeak();
6624 } 6623 }
6625 6624
6626 void WhammyPropertyGetter(Local<String> name, 6625 void WhammyPropertyGetter(Local<String> name,
6627 const v8::PropertyCallbackInfo<v8::Value>& info) { 6626 const v8::PropertyCallbackInfo<v8::Value>& info) {
6628 Whammy* whammy = 6627 Whammy* whammy =
6629 static_cast<Whammy*>(v8::Handle<v8::External>::Cast(info.Data())->Value()); 6628 static_cast<Whammy*>(v8::Handle<v8::External>::Cast(info.Data())->Value());
6630 6629
6631 v8::Persistent<v8::Object>& prev = whammy->objects_[whammy->cursor_]; 6630 v8::Persistent<v8::Object>& prev = whammy->objects_[whammy->cursor_];
6632 6631
6633 v8::Handle<v8::Object> obj = v8::Object::New(); 6632 v8::Handle<v8::Object> obj = v8::Object::New();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
6669 "4"; 6668 "4";
6670 v8::Handle<Value> result = CompileRun(code); 6669 v8::Handle<Value> result = CompileRun(code);
6671 CHECK_EQ(4.0, result->NumberValue()); 6670 CHECK_EQ(4.0, result->NumberValue());
6672 delete whammy; 6671 delete whammy;
6673 } 6672 }
6674 6673
6675 6674
6676 static void DisposeAndSetFlag(v8::Isolate* isolate, 6675 static void DisposeAndSetFlag(v8::Isolate* isolate,
6677 v8::Persistent<v8::Object>* obj, 6676 v8::Persistent<v8::Object>* obj,
6678 bool* data) { 6677 bool* data) {
6679 obj->Dispose(isolate); 6678 obj->Dispose();
6680 *(data) = true; 6679 *(data) = true;
6681 } 6680 }
6682 6681
6683 6682
6684 THREADED_TEST(IndependentWeakHandle) { 6683 THREADED_TEST(IndependentWeakHandle) {
6685 v8::Isolate* iso = v8::Isolate::GetCurrent(); 6684 v8::Isolate* iso = v8::Isolate::GetCurrent();
6686 v8::HandleScope scope(iso); 6685 v8::HandleScope scope(iso);
6687 v8::Handle<Context> context = Context::New(iso); 6686 v8::Handle<Context> context = Context::New(iso);
6688 Context::Scope context_scope(context); 6687 Context::Scope context_scope(context);
6689 6688
6690 v8::Persistent<v8::Object> object_a, object_b; 6689 v8::Persistent<v8::Object> object_a, object_b;
6691 6690
6692 { 6691 {
6693 v8::HandleScope handle_scope(iso); 6692 v8::HandleScope handle_scope(iso);
6694 object_a.Reset(iso, v8::Object::New()); 6693 object_a.Reset(iso, v8::Object::New());
6695 object_b.Reset(iso, v8::Object::New()); 6694 object_b.Reset(iso, v8::Object::New());
6696 } 6695 }
6697 6696
6698 bool object_a_disposed = false; 6697 bool object_a_disposed = false;
6699 bool object_b_disposed = false; 6698 bool object_b_disposed = false;
6700 object_a.MakeWeak(&object_a_disposed, &DisposeAndSetFlag); 6699 object_a.MakeWeak(&object_a_disposed, &DisposeAndSetFlag);
6701 object_b.MakeWeak(&object_b_disposed, &DisposeAndSetFlag); 6700 object_b.MakeWeak(&object_b_disposed, &DisposeAndSetFlag);
6702 CHECK(!object_b.IsIndependent(iso)); 6701 CHECK(!object_b.IsIndependent());
6703 object_a.MarkIndependent(iso); 6702 object_a.MarkIndependent();
6704 object_b.MarkIndependent(iso); 6703 object_b.MarkIndependent();
6705 CHECK(object_b.IsIndependent(iso)); 6704 CHECK(object_b.IsIndependent());
6706 HEAP->PerformScavenge(); 6705 HEAP->PerformScavenge();
6707 CHECK(object_a_disposed); 6706 CHECK(object_a_disposed);
6708 CHECK(object_b_disposed); 6707 CHECK(object_b_disposed);
6709 } 6708 }
6710 6709
6711 6710
6712 static void InvokeScavenge() { 6711 static void InvokeScavenge() {
6713 HEAP->PerformScavenge(); 6712 HEAP->PerformScavenge();
6714 } 6713 }
6715 6714
6716 6715
6717 static void InvokeMarkSweep() { 6716 static void InvokeMarkSweep() {
6718 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); 6717 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
6719 } 6718 }
6720 6719
6721 6720
6722 static void ForceScavenge(v8::Isolate* isolate, 6721 static void ForceScavenge(v8::Isolate* isolate,
6723 v8::Persistent<v8::Object>* obj, 6722 v8::Persistent<v8::Object>* obj,
6724 bool* data) { 6723 bool* data) {
6725 obj->Dispose(isolate); 6724 obj->Dispose();
6726 *(data) = true; 6725 *(data) = true;
6727 InvokeScavenge(); 6726 InvokeScavenge();
6728 } 6727 }
6729 6728
6730 6729
6731 static void ForceMarkSweep(v8::Isolate* isolate, 6730 static void ForceMarkSweep(v8::Isolate* isolate,
6732 v8::Persistent<v8::Object>* obj, 6731 v8::Persistent<v8::Object>* obj,
6733 bool* data) { 6732 bool* data) {
6734 obj->Dispose(isolate); 6733 obj->Dispose();
6735 *(data) = true; 6734 *(data) = true;
6736 InvokeMarkSweep(); 6735 InvokeMarkSweep();
6737 } 6736 }
6738 6737
6739 6738
6740 THREADED_TEST(GCFromWeakCallbacks) { 6739 THREADED_TEST(GCFromWeakCallbacks) {
6741 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 6740 v8::Isolate* isolate = v8::Isolate::GetCurrent();
6742 v8::HandleScope scope(isolate); 6741 v8::HandleScope scope(isolate);
6743 v8::Handle<Context> context = Context::New(isolate); 6742 v8::Handle<Context> context = Context::New(isolate);
6744 Context::Scope context_scope(context); 6743 Context::Scope context_scope(context);
6745 6744
6746 static const int kNumberOfGCTypes = 2; 6745 static const int kNumberOfGCTypes = 2;
6747 typedef v8::WeakReferenceCallbacks<v8::Object, bool>::Revivable Callback; 6746 typedef v8::WeakReferenceCallbacks<v8::Object, bool>::Revivable Callback;
6748 Callback gc_forcing_callback[kNumberOfGCTypes] = 6747 Callback gc_forcing_callback[kNumberOfGCTypes] =
6749 {&ForceScavenge, &ForceMarkSweep}; 6748 {&ForceScavenge, &ForceMarkSweep};
6750 6749
6751 typedef void (*GCInvoker)(); 6750 typedef void (*GCInvoker)();
6752 GCInvoker invoke_gc[kNumberOfGCTypes] = {&InvokeScavenge, &InvokeMarkSweep}; 6751 GCInvoker invoke_gc[kNumberOfGCTypes] = {&InvokeScavenge, &InvokeMarkSweep};
6753 6752
6754 for (int outer_gc = 0; outer_gc < kNumberOfGCTypes; outer_gc++) { 6753 for (int outer_gc = 0; outer_gc < kNumberOfGCTypes; outer_gc++) {
6755 for (int inner_gc = 0; inner_gc < kNumberOfGCTypes; inner_gc++) { 6754 for (int inner_gc = 0; inner_gc < kNumberOfGCTypes; inner_gc++) {
6756 v8::Persistent<v8::Object> object; 6755 v8::Persistent<v8::Object> object;
6757 { 6756 {
6758 v8::HandleScope handle_scope(isolate); 6757 v8::HandleScope handle_scope(isolate);
6759 object.Reset(isolate, v8::Object::New()); 6758 object.Reset(isolate, v8::Object::New());
6760 } 6759 }
6761 bool disposed = false; 6760 bool disposed = false;
6762 object.MakeWeak(&disposed, gc_forcing_callback[inner_gc]); 6761 object.MakeWeak(&disposed, gc_forcing_callback[inner_gc]);
6763 object.MarkIndependent(isolate); 6762 object.MarkIndependent();
6764 invoke_gc[outer_gc](); 6763 invoke_gc[outer_gc]();
6765 CHECK(disposed); 6764 CHECK(disposed);
6766 } 6765 }
6767 } 6766 }
6768 } 6767 }
6769 6768
6770 6769
6771 static void RevivingCallback(v8::Isolate* isolate, 6770 static void RevivingCallback(v8::Isolate* isolate,
6772 v8::Persistent<v8::Object>* obj, 6771 v8::Persistent<v8::Object>* obj,
6773 bool* data) { 6772 bool* data) {
6774 obj->ClearWeak(isolate); 6773 obj->ClearWeak();
6775 *(data) = true; 6774 *(data) = true;
6776 } 6775 }
6777 6776
6778 6777
6779 THREADED_TEST(IndependentHandleRevival) { 6778 THREADED_TEST(IndependentHandleRevival) {
6780 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 6779 v8::Isolate* isolate = v8::Isolate::GetCurrent();
6781 v8::HandleScope scope(isolate); 6780 v8::HandleScope scope(isolate);
6782 v8::Handle<Context> context = Context::New(isolate); 6781 v8::Handle<Context> context = Context::New(isolate);
6783 Context::Scope context_scope(context); 6782 Context::Scope context_scope(context);
6784 6783
6785 v8::Persistent<v8::Object> object; 6784 v8::Persistent<v8::Object> object;
6786 { 6785 {
6787 v8::HandleScope handle_scope(isolate); 6786 v8::HandleScope handle_scope(isolate);
6788 v8::Local<v8::Object> o = v8::Object::New(); 6787 v8::Local<v8::Object> o = v8::Object::New();
6789 object.Reset(isolate, o); 6788 object.Reset(isolate, o);
6790 o->Set(v8_str("x"), v8::Integer::New(1)); 6789 o->Set(v8_str("x"), v8::Integer::New(1));
6791 v8::Local<String> y_str = v8_str("y"); 6790 v8::Local<String> y_str = v8_str("y");
6792 o->Set(y_str, y_str); 6791 o->Set(y_str, y_str);
6793 } 6792 }
6794 bool revived = false; 6793 bool revived = false;
6795 object.MakeWeak(&revived, &RevivingCallback); 6794 object.MakeWeak(&revived, &RevivingCallback);
6796 object.MarkIndependent(isolate); 6795 object.MarkIndependent();
6797 HEAP->PerformScavenge(); 6796 HEAP->PerformScavenge();
6798 CHECK(revived); 6797 CHECK(revived);
6799 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); 6798 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
6800 { 6799 {
6801 v8::HandleScope handle_scope(isolate); 6800 v8::HandleScope handle_scope(isolate);
6802 v8::Local<v8::Object> o = v8::Local<v8::Object>::New(isolate, object); 6801 v8::Local<v8::Object> o = v8::Local<v8::Object>::New(isolate, object);
6803 v8::Local<String> y_str = v8_str("y"); 6802 v8::Local<String> y_str = v8_str("y");
6804 CHECK_EQ(v8::Integer::New(1), o->Get(v8_str("x"))); 6803 CHECK_EQ(v8::Integer::New(1), o->Get(v8_str("x")));
6805 CHECK(o->Get(y_str)->Equals(y_str)); 6804 CHECK(o->Get(y_str)->Equals(y_str));
6806 } 6805 }
(...skipping 5785 matching lines...) Expand 10 before | Expand all | Expand 10 after
12592 12591
12593 12592
12594 v8::Persistent<v8::Object> some_object; 12593 v8::Persistent<v8::Object> some_object;
12595 v8::Persistent<v8::Object> bad_handle; 12594 v8::Persistent<v8::Object> bad_handle;
12596 12595
12597 void NewPersistentHandleCallback(v8::Isolate* isolate, 12596 void NewPersistentHandleCallback(v8::Isolate* isolate,
12598 v8::Persistent<v8::Value>* handle, 12597 v8::Persistent<v8::Value>* handle,
12599 void*) { 12598 void*) {
12600 v8::HandleScope scope(isolate); 12599 v8::HandleScope scope(isolate);
12601 bad_handle.Reset(isolate, some_object); 12600 bad_handle.Reset(isolate, some_object);
12602 handle->Dispose(isolate); 12601 handle->Dispose();
12603 } 12602 }
12604 12603
12605 12604
12606 THREADED_TEST(NewPersistentHandleFromWeakCallback) { 12605 THREADED_TEST(NewPersistentHandleFromWeakCallback) {
12607 LocalContext context; 12606 LocalContext context;
12608 v8::Isolate* isolate = context->GetIsolate(); 12607 v8::Isolate* isolate = context->GetIsolate();
12609 12608
12610 v8::Persistent<v8::Object> handle1, handle2; 12609 v8::Persistent<v8::Object> handle1, handle2;
12611 { 12610 {
12612 v8::HandleScope scope(isolate); 12611 v8::HandleScope scope(isolate);
12613 some_object.Reset(isolate, v8::Object::New()); 12612 some_object.Reset(isolate, v8::Object::New());
12614 handle1.Reset(isolate, v8::Object::New()); 12613 handle1.Reset(isolate, v8::Object::New());
12615 handle2.Reset(isolate, v8::Object::New()); 12614 handle2.Reset(isolate, v8::Object::New());
12616 } 12615 }
12617 // Note: order is implementation dependent alas: currently 12616 // Note: order is implementation dependent alas: currently
12618 // global handle nodes are processed by PostGarbageCollectionProcessing 12617 // global handle nodes are processed by PostGarbageCollectionProcessing
12619 // in reverse allocation order, so if second allocated handle is deleted, 12618 // in reverse allocation order, so if second allocated handle is deleted,
12620 // weak callback of the first handle would be able to 'reallocate' it. 12619 // weak callback of the first handle would be able to 'reallocate' it.
12621 handle1.MakeWeak<v8::Value, void>(NULL, NewPersistentHandleCallback); 12620 handle1.MakeWeak<v8::Value, void>(NULL, NewPersistentHandleCallback);
12622 handle2.Dispose(isolate); 12621 handle2.Dispose();
12623 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); 12622 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
12624 } 12623 }
12625 12624
12626 12625
12627 v8::Persistent<v8::Object> to_be_disposed; 12626 v8::Persistent<v8::Object> to_be_disposed;
12628 12627
12629 void DisposeAndForceGcCallback(v8::Isolate* isolate, 12628 void DisposeAndForceGcCallback(v8::Isolate* isolate,
12630 v8::Persistent<v8::Value>* handle, 12629 v8::Persistent<v8::Value>* handle,
12631 void*) { 12630 void*) {
12632 to_be_disposed.Dispose(isolate); 12631 to_be_disposed.Dispose();
12633 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); 12632 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
12634 handle->Dispose(isolate); 12633 handle->Dispose();
12635 } 12634 }
12636 12635
12637 12636
12638 THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc) { 12637 THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc) {
12639 LocalContext context; 12638 LocalContext context;
12640 v8::Isolate* isolate = context->GetIsolate(); 12639 v8::Isolate* isolate = context->GetIsolate();
12641 12640
12642 v8::Persistent<v8::Object> handle1, handle2; 12641 v8::Persistent<v8::Object> handle1, handle2;
12643 { 12642 {
12644 v8::HandleScope scope(isolate); 12643 v8::HandleScope scope(isolate);
12645 handle1.Reset(isolate, v8::Object::New()); 12644 handle1.Reset(isolate, v8::Object::New());
12646 handle2.Reset(isolate, v8::Object::New()); 12645 handle2.Reset(isolate, v8::Object::New());
12647 } 12646 }
12648 handle1.MakeWeak<v8::Value, void>(NULL, DisposeAndForceGcCallback); 12647 handle1.MakeWeak<v8::Value, void>(NULL, DisposeAndForceGcCallback);
12649 to_be_disposed.Reset(isolate, handle2); 12648 to_be_disposed.Reset(isolate, handle2);
12650 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); 12649 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
12651 } 12650 }
12652 12651
12653 void DisposingCallback(v8::Isolate* isolate, 12652 void DisposingCallback(v8::Isolate* isolate,
12654 v8::Persistent<v8::Value>* handle, 12653 v8::Persistent<v8::Value>* handle,
12655 void*) { 12654 void*) {
12656 handle->Dispose(isolate); 12655 handle->Dispose();
12657 } 12656 }
12658 12657
12659 void HandleCreatingCallback(v8::Isolate* isolate, 12658 void HandleCreatingCallback(v8::Isolate* isolate,
12660 v8::Persistent<v8::Value>* handle, 12659 v8::Persistent<v8::Value>* handle,
12661 void*) { 12660 void*) {
12662 v8::HandleScope scope(isolate); 12661 v8::HandleScope scope(isolate);
12663 v8::Persistent<v8::Object>(isolate, v8::Object::New()); 12662 v8::Persistent<v8::Object>(isolate, v8::Object::New());
12664 handle->Dispose(isolate); 12663 handle->Dispose();
12665 } 12664 }
12666 12665
12667 12666
12668 THREADED_TEST(NoGlobalHandlesOrphaningDueToWeakCallback) { 12667 THREADED_TEST(NoGlobalHandlesOrphaningDueToWeakCallback) {
12669 LocalContext context; 12668 LocalContext context;
12670 v8::Isolate* isolate = context->GetIsolate(); 12669 v8::Isolate* isolate = context->GetIsolate();
12671 12670
12672 v8::Persistent<v8::Object> handle1, handle2, handle3; 12671 v8::Persistent<v8::Object> handle1, handle2, handle3;
12673 { 12672 {
12674 v8::HandleScope scope(isolate); 12673 v8::HandleScope scope(isolate);
(...skipping 5875 matching lines...) Expand 10 before | Expand all | Expand 10 after
18550 int counter_; 18549 int counter_;
18551 v8::Persistent<v8::Object>* object_; 18550 v8::Persistent<v8::Object>* object_;
18552 }; 18551 };
18553 18552
18554 18553
18555 TEST(PersistentHandleVisitor) { 18554 TEST(PersistentHandleVisitor) {
18556 LocalContext context; 18555 LocalContext context;
18557 v8::Isolate* isolate = context->GetIsolate(); 18556 v8::Isolate* isolate = context->GetIsolate();
18558 v8::HandleScope scope(isolate); 18557 v8::HandleScope scope(isolate);
18559 v8::Persistent<v8::Object> object(isolate, v8::Object::New()); 18558 v8::Persistent<v8::Object> object(isolate, v8::Object::New());
18560 CHECK_EQ(0, object.WrapperClassId(isolate)); 18559 CHECK_EQ(0, object.WrapperClassId());
18561 object.SetWrapperClassId(isolate, 42); 18560 object.SetWrapperClassId(42);
18562 CHECK_EQ(42, object.WrapperClassId(isolate)); 18561 CHECK_EQ(42, object.WrapperClassId());
18563 18562
18564 Visitor42 visitor(&object); 18563 Visitor42 visitor(&object);
18565 v8::V8::VisitHandlesWithClassIds(&visitor); 18564 v8::V8::VisitHandlesWithClassIds(&visitor);
18566 CHECK_EQ(1, visitor.counter_); 18565 CHECK_EQ(1, visitor.counter_);
18567 18566
18568 object.Dispose(isolate); 18567 object.Dispose();
18569 } 18568 }
18570 18569
18571 18570
18572 TEST(WrapperClassId) { 18571 TEST(WrapperClassId) {
18573 LocalContext context; 18572 LocalContext context;
18574 v8::Isolate* isolate = context->GetIsolate(); 18573 v8::Isolate* isolate = context->GetIsolate();
18575 v8::HandleScope scope(isolate); 18574 v8::HandleScope scope(isolate);
18576 v8::Persistent<v8::Object> object(isolate, v8::Object::New()); 18575 v8::Persistent<v8::Object> object(isolate, v8::Object::New());
18577 CHECK_EQ(0, object.WrapperClassId(isolate)); 18576 CHECK_EQ(0, object.WrapperClassId());
18578 object.SetWrapperClassId(isolate, 65535); 18577 object.SetWrapperClassId(65535);
18579 CHECK_EQ(65535, object.WrapperClassId(isolate)); 18578 CHECK_EQ(65535, object.WrapperClassId());
18580 object.Dispose(isolate); 18579 object.Dispose();
18581 } 18580 }
18582 18581
18583 18582
18584 TEST(PersistentHandleInNewSpaceVisitor) { 18583 TEST(PersistentHandleInNewSpaceVisitor) {
18585 LocalContext context; 18584 LocalContext context;
18586 v8::Isolate* isolate = context->GetIsolate(); 18585 v8::Isolate* isolate = context->GetIsolate();
18587 v8::HandleScope scope(isolate); 18586 v8::HandleScope scope(isolate);
18588 v8::Persistent<v8::Object> object1(isolate, v8::Object::New()); 18587 v8::Persistent<v8::Object> object1(isolate, v8::Object::New());
18589 CHECK_EQ(0, object1.WrapperClassId(isolate)); 18588 CHECK_EQ(0, object1.WrapperClassId());
18590 object1.SetWrapperClassId(isolate, 42); 18589 object1.SetWrapperClassId(42);
18591 CHECK_EQ(42, object1.WrapperClassId(isolate)); 18590 CHECK_EQ(42, object1.WrapperClassId());
18592 18591
18593 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); 18592 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
18594 18593
18595 v8::Persistent<v8::Object> object2(isolate, v8::Object::New()); 18594 v8::Persistent<v8::Object> object2(isolate, v8::Object::New());
18596 CHECK_EQ(0, object2.WrapperClassId(isolate)); 18595 CHECK_EQ(0, object2.WrapperClassId());
18597 object2.SetWrapperClassId(isolate, 42); 18596 object2.SetWrapperClassId(42);
18598 CHECK_EQ(42, object2.WrapperClassId(isolate)); 18597 CHECK_EQ(42, object2.WrapperClassId());
18599 18598
18600 Visitor42 visitor(&object2); 18599 Visitor42 visitor(&object2);
18601 v8::V8::VisitHandlesForPartialDependence(isolate, &visitor); 18600 v8::V8::VisitHandlesForPartialDependence(isolate, &visitor);
18602 CHECK_EQ(1, visitor.counter_); 18601 CHECK_EQ(1, visitor.counter_);
18603 18602
18604 object1.Dispose(isolate); 18603 object1.Dispose();
18605 object2.Dispose(isolate); 18604 object2.Dispose();
18606 } 18605 }
18607 18606
18608 18607
18609 TEST(RegExp) { 18608 TEST(RegExp) {
18610 LocalContext context; 18609 LocalContext context;
18611 v8::HandleScope scope(context->GetIsolate()); 18610 v8::HandleScope scope(context->GetIsolate());
18612 18611
18613 v8::Handle<v8::RegExp> re = v8::RegExp::New(v8_str("foo"), v8::RegExp::kNone); 18612 v8::Handle<v8::RegExp> re = v8::RegExp::New(v8_str("foo"), v8::RegExp::kNone);
18614 CHECK(re->IsRegExp()); 18613 CHECK(re->IsRegExp());
18615 CHECK(re->GetSource()->Equals(v8_str("foo"))); 18614 CHECK(re->GetSource()->Equals(v8_str("foo")));
(...skipping 1651 matching lines...) Expand 10 before | Expand all | Expand 10 after
20267 CheckCorrectThrow("%GetLocalPropertyNames(other, true)"); 20266 CheckCorrectThrow("%GetLocalPropertyNames(other, true)");
20268 CheckCorrectThrow("%DefineOrRedefineAccessorProperty(" 20267 CheckCorrectThrow("%DefineOrRedefineAccessorProperty("
20269 "other, 'x', null, null, 1)"); 20268 "other, 'x', null, null, 1)");
20270 20269
20271 // Reset the failed access check callback so it does not influence 20270 // Reset the failed access check callback so it does not influence
20272 // the other tests. 20271 // the other tests.
20273 v8::V8::SetFailedAccessCheckCallbackFunction(NULL); 20272 v8::V8::SetFailedAccessCheckCallbackFunction(NULL);
20274 } 20273 }
20275 20274
20276 #endif // V8_OS_POSIX 20275 #endif // V8_OS_POSIX
OLDNEW
« no previous file with comments | « src/mksnapshot.cc ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698